@initia/interwovenkit-react 2.3.0 → 2.4.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,4 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wa=require("@privy-io/cross-app-connect/rainbow-kit"),ve=require("wagmi"),T=require("@tanstack/react-query"),j=require("@initia/utils"),B=require("bignumber.js"),A=require("ramda"),ye=require("@lukemorales/query-key-factory"),z=require("ky"),_=require("react"),ie=require("@cosmjs/encoding"),Gi=require("@mysten/bcs"),W=require("jotai"),Ha=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),ao=require("@cosmjs/amino/build/signdoc"),ro=require("@cosmjs/crypto"),ra=require("@cosmjs/math"),ms=require("@cosmjs/proto-signing"),Ke=require("@cosmjs/stargate"),ia=require("@cosmjs/tendermint-rpc"),Yi=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),It=require("cosmjs-types/cosmos/tx/v1beta1/tx"),pt=require("ethers"),sn=require("@initia/amino-converter"),jn=require("@cosmjs/amino"),Zi=require("cosmjs-types/cosmos/auth/v1beta1/auth"),io=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Ji=require("cosmjs-types/google/protobuf/any"),Ge=require("date-fns"),bo=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),ca=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),la=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),Qa=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),J=require("radix-ui"),Le=require("usehooks-ts"),Ga=require("react-error-boundary"),L=require("clsx"),_e=require("react-hook-form"),ke=require("@base-ui/react/dialog"),Xi=require("xss"),S=require("@initia/icons-react"),rt=require("@react-spring/web"),hs=require("change-case"),ut=require("@base-ui/react/select"),Ps=require("@base-ui/react/collapsible"),da=require("nanoid"),ec=require("react-dom"),tc=require("jotai/utils"),Ya=require("react-merge-refs"),nc=require("react-number-format"),sc=require("react-intersection-observer"),oc=require("@noble/hashes/sha3"),Dt=require("@noble/hashes/utils"),ac=require("qr-code-styling"),ht=require("@base-ui/react"),wt=require("@base-ui/react/tabs"),Qt=require("@base-ui/react/popover"),ua=require("cosmjs-types/cosmos/bank/v1beta1/tx");function rc(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const wo=rc(Ha),on=1.4,Za=1.05,Ja={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",lockStakeModuleAddress:"0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initia.xyz",vipUrl:"https://vip-api.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark"},ic={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",lockStakeModuleAddress:"0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initiation-2.initia.xyz",vipUrl:"https://vip-api.testnet.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark",disableAnalytics:!0},vo="cmbq1ozyc006al70lx4uciz0q",bn={id:vo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},cc=Wa.toPrivyWalletConnector(bn),lc=Wa.toPrivyWallet(bn),Xa=_.createContext(null);function Y(){const e=_.useContext(Xa);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function dc(e){if(e instanceof z.HTTPError){const{response:n}=e,s=n.headers.get("content-type")??"";if(A.includes("application/json",s))try{const o=await n.json();if(o.message)return o.message}catch{return e.message}try{return await n.text()}catch{return e.message}}if(e instanceof Error){if(A.path(["code"],e)===4001||A.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const n=A.path(["error","message"],e),s=A.path(["cause","message"],e),o=A.path(["shortMessage"],e);return n||s||o||e.message}return String(e)}async function ft(e){return new Error(await dc(e))}const ps=ye.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Qn(e){const n=A.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function uc(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,l=o||s,c=a?.png??"",{rpc:d,rest:u,["json-rpc"]:h,indexer:m}=r,f=Qn(d),p=Qn(u),g=Qn(m),x=i?.minitia?.type==="minievm"?Qn(h):void 0;return{...e,chainId:n,name:l,logoUrl:c,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:x}}function de(){const{defaultChainId:e,registryUrl:n,customChain:s}=Y(),{data:o}=T.useSuspenseQuery({queryKey:ps.list(n).queryKey,queryFn:()=>z.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(uc).toSorted(A.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return o}function er(){const{registryUrl:e}=Y(),{data:n}=T.useSuspenseQuery({queryKey:ps.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:K.MINUTE});return n}function Ye(){const e=ae(),n=de(),s=er();return o=>{const a=n.find(i=>i.chain_id===o);if(a)return a;const r=s.find(i=>i.chain_id===o);if(!r)throw new Error(`Chain not found: ${o}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:r.pretty_name,logoUrl:r.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function Ze(e){return Ye()(e)}function Vt(){const{defaultChainId:e}=Y();return Ze(e)}function ae(){const n=de().find(s=>s.metadata?.is_l1);if(!n)throw new Error("Layer 1 not found");return n}function tr(){return({chainId:e})=>T.queryOptions({queryKey:ps.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function _t(e){const n=tr();return T.useQuery(n(e))}function Co(){const e=de(),n=tr();return T.useQueries({queries:e.map(s=>n(s))})}const mc=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const or=require("@privy-io/cross-app-connect/rainbow-kit"),Ee=require("wagmi"),$=require("@tanstack/react-query"),v=require("@initia/utils"),B=require("bignumber.js"),T=require("ramda"),ye=require("@lukemorales/query-key-factory"),z=require("ky"),x=require("react"),se=require("@cosmjs/encoding"),Cc=require("@mysten/bcs"),U=require("jotai"),ar=require("@amplitude/analytics-browser"),t=require("react/jsx-runtime"),Cn=require("@cosmjs/amino/build/signdoc"),Qe=require("@cosmjs/crypto"),ct=require("ethers"),Mo=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),Nn=require("@cosmjs/amino"),Cs=require("@cosmjs/proto-signing"),yo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),Nc=require("cosmjs-types/google/protobuf/any"),Et=require("viem"),xa=require("@cosmjs/math"),je=require("@cosmjs/stargate"),ya=require("@cosmjs/tendermint-rpc"),rr=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),De=require("cosmjs-types/cosmos/tx/v1beta1/tx"),Wt=require("@initia/amino-converter"),kc=require("cosmjs-types/cosmos/auth/v1beta1/auth"),Rt=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),ja=require("cosmjs-types/cosmos/tx/v1beta1/service"),Re=require("date-fns"),wa=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),ir=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),Z=require("radix-ui"),Le=require("usehooks-ts"),cr=require("react-error-boundary"),q=require("clsx"),_e=require("react-hook-form"),ke=require("@base-ui/react/dialog"),Ic=require("xss"),S=require("@initia/icons-react"),lt=require("@react-spring/web"),Ns=require("change-case"),ft=require("@base-ui/react/select"),Ys=require("@base-ui/react/collapsible"),ba=require("nanoid"),Ac=require("react-dom"),Sc=require("psl"),Tc=require("jotai/utils"),lr=require("react-merge-refs"),$c=require("react-number-format"),Ec=require("react-intersection-observer"),Mc=require("@noble/hashes/sha3"),Ft=require("@noble/hashes/utils"),Lc=require("qr-code-styling"),gt=require("@base-ui/react"),Ct=require("@base-ui/react/tabs"),Xt=require("@base-ui/react/popover"),va=require("cosmjs-types/cosmos/bank/v1beta1/tx");function qc(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return n.default=e,Object.freeze(n)}const Lo=qc(ar),zt=1.4,dr=1.05,ur={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",lockStakeModuleAddress:"0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initia.xyz",vipUrl:"https://vip-api.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark"},Pc={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",lockStakeModuleAddress:"0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initiation-2.initia.xyz",vipUrl:"https://vip-api.testnet.initia.xyz",civitiaUrl:"https://api.civitia.org",theme:"dark",disableAnalytics:!0},qo="cmbq1ozyc006al70lx4uciz0q",kn={id:qo,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Dc=or.toPrivyWalletConnector(kn),Bc=or.toPrivyWallet(kn),mr=x.createContext(null);function ee(){const e=x.useContext(mr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const K={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Rc(e){if(e instanceof z.HTTPError){const{response:n}=e,s=n.headers.get("content-type")??"";if(T.includes("application/json",s))try{const o=await n.json();if(o.message)return o.message}catch{return e.message}try{return await n.text()}catch{return e.message}}if(e instanceof Error){if(T.path(["code"],e)===4001||T.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const n=T.path(["error","message"],e),s=T.path(["cause","message"],e),o=T.path(["shortMessage"],e);return n||s||o||e.message}return String(e)}async function _t(e){return new Error(await Rc(e))}const ks=ye.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function Xn(e){const n=T.path([0,"address"],e);if(!n)throw new Error("URL not found");return n}function Fc(e){const{chain_id:n,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:d,rest:m,["json-rpc"]:u,indexer:h}=r,f=Xn(d),p=Xn(m),g=Xn(h),_=i?.minitia?.type==="minievm"?Xn(u):void 0;return{...e,chainId:n,name:c,logoUrl:l,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:_}}function de(){const{defaultChainId:e,registryUrl:n,customChain:s}=ee(),{data:o}=$.useSuspenseQuery({queryKey:ks.list(n).queryKey,queryFn:()=>z.create({prefixUrl:n}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(Fc).toSorted(T.descend(i=>i.chainId===e)),staleTime:K.MINUTE});return o}function hr(){const{registryUrl:e}=ee(),{data:n}=$.useSuspenseQuery({queryKey:ks.profiles(e).queryKey,queryFn:()=>z.create({prefixUrl:e}).get("profiles.json").json(),staleTime:K.MINUTE});return n}function Fe(){const e=re(),n=de(),s=hr();return o=>{const a=n.find(i=>i.chain_id===o);if(a)return a;const r=s.find(i=>i.chain_id===o);if(!r)throw new Error(`Chain not found: ${o}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:r.pretty_name,logoUrl:r.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function Xe(e){return Fe()(e)}function Gt(){const{defaultChainId:e}=ee();return Xe(e)}function re(){const n=de().find(s=>s.metadata?.is_l1);if(!n)throw new Error("Layer 1 not found");return n}function fr(){return({chainId:e})=>$.queryOptions({queryKey:ks.prices(e).queryKey,queryFn:()=>z.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:K.SECOND})}function yt(e){const n=fr();return $.useQuery(n(e))}function Po(){const e=de(),n=fr();return $.useQueries({queries:e.map(s=>n(s))})}const Uc=`<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>`,hc=encodeURIComponent(mc),No=`data:image/svg+xml;utf8,${hc}`,wn=ye.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,n)=>[e,n],resource:(e,n)=>[e.chainId,n.denom],denom:(e,n)=>[e,n],metadata:(e,n)=>[e,n]});function pc(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:l,traces:c}=e,d=o.find(h=>h.denom===a)?.exponent??o.find(h=>h.denom===n)?.exponent??A.head(o)?.exponent??0,u=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:u,name:i,address:l,traces:c}}function nr(){const e=T.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return T.queryOptions({queryKey:wn.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(pc);for(const r of a)e.setQueryData(wn.item(n.chainId,r.denom).queryKey,r);return a},staleTime:K.MINUTE})}}function gt(e){const n=nr(),{data:s}=T.useSuspenseQuery(n(e));return s}function Sn(){const e=de(),n=nr();return T.useQueries({queries:e.map(s=>n(s))})}function lt(e){const n=gt(e),s=ae(),o=gt(s),a=or(e);return r=>{const i=n.find(c=>c.denom===r);if(i)return i;const l=o.find(c=>c.denom===a(r));return l?{...l,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:No}}}function sr(e,n){const s=lt(n),a=T.useQueryClient().getQueryData(wn.item(n.chainId,e).queryKey);return a||s(e)}function or(e){const n=ae(),s=gt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(l=>l.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===n.chain_name)return i.counterparty.base_denom}}const a=n.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?j.getIbcDenom(a,o):""}}function Io(e){const n=ae(),s=z.create({prefixUrl:n.restUrl}),o=T.useSuspenseQueries({queries:e.map(a=>({queryFn:()=>s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json(),queryKey:wn.denom(n.restUrl,a).queryKey,select:r=>[a,r.denom],staleTime:K.INFINITY}))});return new Map(o.map(({data:a})=>a))}function fc(e){return e.pagination?.next_key??null}async function ar(e,n,s){const o=z.create(n),a=async(r,i)=>{const l=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),c=l[s]??[],d=fc(l),u=[...r,...c];return d?a(u,d):u};return a([],null)}const ma="usernames";function gc({restUrl:e,moduleAddress:n}){const{viewFunction:s}=j.createMoveClient(e);async function o(i){if(!j.InitiaAddress.validate(i))return null;const l=await s({moduleAddress:n,moduleName:ma,functionName:"get_name_from_address",typeArgs:[],args:[ie.toBase64(j.InitiaAddress(i,32).bytes)]});return l?l+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const l=await s({moduleAddress:n,moduleName:ma,functionName:"get_address_from_name",typeArgs:[],args:[Gi.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return l?j.InitiaAddress(l).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const fs=ye.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function rr(){const{restUrl:e}=ae(),{usernamesModuleAddress:n}=Y();return gc({restUrl:e,moduleAddress:n})}function ir(){const e=te();return n=>T.queryOptions({queryKey:fs.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?ar(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:K.SECOND})}function An(e){const n=ir(),{data:s}=T.useSuspenseQuery(n(e));return s}function _c(){const e=de(),n=ir();return T.useQueries({queries:e.map(s=>n(s))})}function xc(e){const n=An(e),s=gt(e),o=lt(e),a=or(e),{data:r}=_t(e),i=c=>e.fees.fee_tokens.some(d=>d.denom===c),l=c=>s.some(d=>d.denom===c);return A.sortWith([A.descend(({denom:c})=>a(c)==="uinit"),A.descend(({denom:c})=>i(c)),A.descend(({value:c})=>c),A.descend(({denom:c})=>l(c)),({balance:c},{balance:d})=>B(d).comparedTo(c)??0,A.descend(({symbol:c})=>c.toLowerCase())],n.filter(({amount:c})=>!B(c).isZero()).map(({amount:c,denom:d})=>{const u=o(d),h=r?.find(({id:f})=>f===u?.denom)?.price??0,m=B(c).times(h).div(B(10).pow(u.decimals)).toNumber();return{...u,balance:c,price:h,value:m}}))}const cr=_.createContext(null);function gs(){return _.useContext(cr)}function lr(){const{location:e}=gs();return e}function _s(){const{path:e}=lr();return e}function Je(){const{state:e={}}=lr();return e}function dr(){const{history:e}=gs();return e}function Ce(){const{navigate:e}=gs();return e}function ko(){const{reset:e}=gs();return e}const nn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ce(),l=ko(),c=d=>{d.preventDefault(),a?.(d),s?l(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:c,children:o})},ur=({children:e,initialEntry:n})=>{const[s,o]=_.useState([n??{path:"/"}]),a=s[s.length-1],r=_.useCallback((l,c)=>{o(d=>{if(typeof l=="string")return[...d,{path:l,state:c}];const u=d.length+l;if(u<1)return d;const h=A.take(u,d);return c!==void 0?A.adjust(u-1,m=>({...m,state:c}),h):h})},[]),i=_.useCallback((l,c)=>{o([{path:l,state:c}])},[]);return t.jsx(cr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},yc="c33b940c24c17e95f7d9d525d508ac61";function jc(){const{disableAnalytics:e}=Y();_.useEffect(()=>{e||wo.init(yc,{autocapture:!1})},[e])}function bc(){const{connector:e}=ve.useAccount(),{defaultChainId:n,disableAnalytics:s}=Y();_.useEffect(()=>{const o=new Ha.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),wo.identify(o)},[n,e?.name,s])}function Tn(){const e=_s();return _.useCallback((s,o)=>{wo.track(s,{path:e,...o})},[e])}const st="interwovenkit",Se="uinit",We="INIT",Pe=6,wc="uoinit",vc="omniINIT",mr="https://app.initia.xyz",So=`${mr}/liquidity/my`,Cc=`${mr}/vip/my`,Nc=1e3,hr=60*Nc,pr=60*hr,ha=24*pr,oe={PUBLIC_KEY:`${st}:public-key`,BRIDGE_SRC_CHAIN_ID:`${st}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${st}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${st}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${st}:bridge:dst-denom`,BRIDGE_QUANTITY:`${st}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${st}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${st}:bridge:route-type`,BRIDGE_HISTORY:`${st}:bridge:history`,OP_REMINDER:`${st}:op:reminder`},fr=W.atom(!1),gr=W.atom(!1);function xt(){const e=ko(),[n,s]=W.useAtom(fr),o=W.useSetAtom(gr),a=Tn();return{isDrawerOpen:n,openDrawer:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function cn(){const e=ko(),[n,s]=W.useAtom(gr),o=W.useSetAtom(fr),a=Tn();return{isModalOpen:n,openModal:(l,c)=>{l&&e(l,c),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ao(){const e=Ce(),{closeDrawer:n}=xt(),{closeModal:s}=cn(),{disconnect:o}=ve.useDisconnect();return()=>{e("/blank"),n(),s(),o(),localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM),localStorage.removeItem(oe.BRIDGE_QUANTITY),localStorage.removeItem(oe.BRIDGE_SLIPPAGE_PERCENT)}}function Ic(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function kc(){const e=kt(),n=Vt(),{openModal:s}=cn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:l}=o;if(a.length===0)throw new Error("denoms cannot be empty");const c=r??n.chainId,d=a.map(u=>({denom:u,chainId:c}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:l})}}function To(){const{privyContext:e}=Y(),{address:n}=ve.useAccount();return e?n?!!e.privy.user?.linkedAccounts.map(o=>"address"in o&&o.address).filter(o=>!!o)?.some(o=>j.InitiaAddress.equals(o,n)):!1:!0}function Sc(){const{privyContext:e}=Y(),n=To(),{address:s}=ve.useAccount(),{signMessageAsync:o}=ve.useSignMessage(),a=Ao(),r=!!e?.privy.ready,i=_.useRef(e);_.useEffect(()=>{i.current=e},[e]);const l=async c=>{try{if(!i.current)throw new Error("Privy context not found");i.current.privy.authenticated&&await i.current.privy.logout();const d=await i.current.siwe.generateSiweMessage({chainId:"eip155:1",address:c});if(!d)throw new Error("Failed to generate SIWE message");const u=await o({message:d});await i.current.siwe.loginWithSiwe({signature:u,message:d})}catch{a()}};_.useEffect(()=>{n||r&&s&&l(s)},[n,r,s])}function Ac(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=io.PubKey.decode(e.value);return jn.encodeSecp256k1Pubkey(n)}return ms.decodeOptionalPubkey(e)}function Tc({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Zi.BaseAccount.decode(n),i=Ac(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ke.accountFromAny({typeUrl:e,value:n})}function $c(e){return e.type==="initia/PubKeyEthSecp256k1"}const Ec={...jn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function qc(e){if($c(e)){const n=io.PubKey.fromPartial({key:ie.fromBase64(e.value)});return Ji.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(io.PubKey.encode(n).finish())})}return ms.encodePubkey(e)}function _r(e){if(e.length!==33||e[0]!==2&&e[0]!==3)throw new Error("Public key must be compressed secp256k1, i.e. 33 bytes starting with 0x02 or 0x03");return{type:Ec.ethsecp256k1,value:ie.toBase64(e)}}function Lc(e,n){if(n.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:_r(e),signature:ie.toBase64(n)}}const $n=()=>{const e=Y();return new ms.Registry([...sn.protoRegistry,...e.protoTypes??[]])},En=()=>{const e=Y();return new Ke.AminoTypes({...sn.aminoConverters,...e.aminoConverters})};class xr{constructor(n,s,o){this.address=n,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${oe.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=ie.fromHex(s),ie.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,ie.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,ie.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?ie.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=pt.ethers.hashMessage(n),a=pt.ethers.SigningKey.recoverPublicKey(o,s);return ro.Secp256k1.compressPubkey(ie.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const o=ao.escapeCharacters(ao.sortedJsonStringify(s)),a=await this.signMessage(o),r=ie.fromHex(a.replace("0x","")).subarray(0,-1),l=ro.Secp256k1Signature.fromFixedLength(r).toFixedLength(),c=Lc(await this.getCachedPublicKey(),l);return{signed:s,signature:c}}}function xs(){const e=$n(),n=En(),s=qn(),o=$o();return async function(a,r,i,l,c,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const h=await o(a),{accountNumber:m,...f}=await h.getSequence(r),p=f.sequence+(d?.incrementSequence??0),[g]=await u.getAccounts(),x=qc(_r(g.pubkey)),y=Yi.SignMode.SIGN_MODE_EIP_191,b=i.map(w=>n.toAmino(w)),C=ao.makeSignDoc(b,l,a,c,m,p),{signature:v,signed:N}=await u.signAmino(r,C),$={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:N.msgs.map(w=>n.fromAmino(w)),memo:c}},q=e.encode($),V=ra.Int53.fromString(N.fee.gas).toNumber(),M=ra.Int53.fromString(N.sequence).toNumber(),I=ms.makeAuthInfoBytes([{pubkey:x,sequence:M}],N.fee.amount,V,N.fee.granter,N.fee.payer,y);return It.TxRaw.fromPartial({bodyBytes:q,authInfoBytes:I,signatures:[ie.fromBase64(v.signature)]})}}function qn(){const e=te(),{signMessageAsync:n}=ve.useSignMessage(),s=ae();return _.useMemo(()=>new xr(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Ds=new Map,Bs=new Map;function yr(){const e=Ye();return async n=>{if(Ds.has(n))return Ds.get(n);const{rpcUrl:s}=e(n),o=await ia.Comet38Client.create(new ia.HttpClient(s));return Ds.set(n,o),o}}function $o(){const e=$n(),n=En(),s=qn(),o=te(),a=yr();return async r=>{const i=`${o}:${r}`;if(Bs.has(i))return Bs.get(i);if(!s)throw new Error("Signer not initialized");const l=await a(r),c=await Ke.SigningStargateClient.createWithSigner(l,s,{registry:e,aminoTypes:n,accountParser:Tc,broadcastPollIntervalMs:500});return Bs.set(i,c),c}}function jr(){const{connector:e}=ve.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new pt.BrowserProvider(await e.getProvider())}}function br(){const e=te(),n=Ye();return{fetchFeegrant:async(a,r)=>{if(!e)return null;const i=n(a),l=z.create({prefixUrl:i.restUrl});try{const{allowance:c}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${r}`).json();return c}catch{return null}},fetchGrants:async(a,r)=>{if(!e)return[];const i=n(a),l=z.create({prefixUrl:i.restUrl}),{grants:c}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:r}}).json();return c}}}function wr(){const{privyContext:e}=Y(),n=To();if(!(!e||!n))return e.wallets.find(s=>s.connectorType==="embedded")}function ys(){const e=wr();return e?.address?j.InitiaAddress(e.address).bech32:void 0}function vr(){const e=wr(),n=ys(),s=$n(),o=Ye(),a=xs();return async(r,i,l,c,d)=>{if(!e||!n)throw new Error("Embedded wallet not initialized");const u=[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:bo.MsgExec.fromPartial({grantee:n,msgs:l.map(f=>({typeUrl:f.typeUrl,value:s.encode(f)}))})}],h={...c,granter:i},m=new xr(n,e.sign,o(r).restUrl);return await a(r,n,u,h,d,{customSigner:m})}}const vn=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n)=>[e,n],grants:(e,n)=>[e,n]});function js(){const e=Y(),n=Vt(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(n.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function Cr(){const{data:e}=Eo(),n=js();return async(s,o)=>{const a=o.every(i=>{const l=n[s];return l?l.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Eo(){const e=te(),n=ys(),s=js(),{fetchFeegrant:o,fetchGrants:a}=br();return T.useQuery({queryKey:vn.expirations(e,n).queryKey,queryFn:async()=>{if(!e||!n)return{expiredAtByChain:{},isEnabledByChain:{}};const r={};for(const[l,c]of Object.entries(s))try{const d=await a(l,n);if(!c.every(x=>d.some(y=>y.authorization?.msg===x))){r[l]=null;continue}const h=await o(l,n);if(!h){r[l]=null;continue}const m=d.filter(x=>c.includes(x.authorization.msg)).map(x=>x.expiration),f=h.allowance.expiration,p=[...m,f],g=qo(p);r[l]=g?new Date(g):void 0}catch{r[l]=null}const i={};for(const[l,c]of Object.entries(r))switch(c){case null:i[l]=!1;break;case void 0:i[l]=!0;break;default:i[l]=Ge.isFuture(c);break}return{expiredAtByChain:r,isEnabledByChain:i}},staleTime:K.INFINITY,retry:!1})}function Mc(){const{data:e,refetch:n}=Eo();_.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(l=>l instanceof Date&&Ge.isFuture(l));if(o.length===0)return;const r=qo(o).getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function qo(e){return e.filter(n=>n!==void 0).toSorted((n,s)=>new Date(n).getTime()-new Date(s).getTime())[0]}const Nr=_.createContext(null),bs=()=>_.useContext(Nr);class Ir extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,l){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=l}}const Pc=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Rs=new Map;function Dc(e){const n=e.match(Pc);if(!n)return null;const[,s,o,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Bc(e,n,s){const o=`${e}:${n}`;if(Rs.has(o))return Rs.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return Rs.set(o,i),i}catch{return null}}function Rc(e,n,s,o,a,r,i){return new Ir(e,n,s,o,a,r,i)}async function Zt(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await ft(e);const o=Dc(e.message);if(!o)return await ft(e);const a=await Bc(n.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,l=a?.[o.moduleName]?.[o.errorCode],c=l||i,d=!!l;return Rc(c,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const kr="approve",ws=W.atom(),Sr=W.atom(null);function Ar(){const e=W.useAtomValue(ws);if(!e)throw new Error("Tx request not found");return e}function vs(){const e=Ce(),n=te(),{defaultChainId:s,registryUrl:o}=Y(),a=Ye(),{openDrawer:r,closeDrawer:i}=xt(),{openModal:l,closeModal:c}=bs(),d=W.useSetAtom(ws),u=W.useSetAtom(Sr),h=yr(),m=$o(),f=qn(),p=$n(),g=Cr(),x=vr(),y=xs(),b=async({messages:M,memo:I,chainId:w=s})=>{try{return await(await m(w)).simulate(n,M,I)}catch(E){throw await Zt(E,a(w),o)}},C=async({messages:M,memo:I,chainId:w=s})=>{const E=await h(w),U=Ke.QueryClient.withExtensions(E,Ke.setupTxExtension),F=M.map(P=>p.encodeAsAny(P)),[O]=await f.getAccounts(),Z=jn.encodeSecp256k1Pubkey(O.pubkey),H=await m(w),{sequence:R}=await H.getSequence(n);return U.tx.simulate(F,I,Z,R)},v=async({txRequest:M,broadcaster:I})=>{const E={...{memo:"",chainId:s,gas:M.gas||await b(M),gasAdjustment:on,gasPrices:null,spendCoins:[],internal:!1},...M};return new Promise((U,F)=>{d({txRequest:E,resolve:async Z=>{try{const H=await m(E.chainId),R=await I(H,It.TxRaw.encode(Z).finish());U(R),typeof E.internal=="string"&&e(E.internal)}catch(H){F(await Zt(H,a(E.chainId),o))}finally{O()}},reject:Z=>{F(Z),O()}}),E.internal?l({path:"/tx"}):r("/tx");const O=()=>{if(!E.internal){e("/blank"),i();return}c()}})},N=async M=>{const I=M.chainId??s;try{const w=await v({txRequest:M,broadcaster:async(E,U)=>await E.broadcastTxSync(U)});return M.internal&&typeof M.internal!="number"&&(u({txHash:w,chainId:I,status:"loading"}),V({txHash:w,chainId:M.chainId}).then(E=>{u({status:E.code===0?"success":"error",chainId:I,txHash:w})}).catch(()=>{u({status:"error",chainId:I,txHash:w})})),w}catch(w){throw M.internal&&typeof M.internal!="number"&&u({status:"error",chainId:I,error:w}),w}},k=(M,I=30*1e3,w=.5*1e3)=>v({txRequest:M,broadcaster:async(E,U)=>{const F=await E.broadcastTx(U,I,w);if(F.code!==0)throw new Error(F.rawLog);return F}}),$=async M=>{const I=M.chainId??s;try{const{messages:w,memo:E="",fee:U}=M,F=await m(I),Z=await g(I,w)?await x(I,n,w,U,E):await y(I,n,w,U,E);return await F.broadcastTxSync(It.TxRaw.encode(Z).finish())}catch(w){throw await Zt(w,a(I),o)}},q=async(M,I=30*1e3,w=.5*1e3)=>{const E=M.chainId??s;try{const{messages:U,memo:F="",fee:O}=M,Z=await m(E),R=await g(E,U)?await x(E,n,U,O,F):await y(E,n,U,O,F),P=await Z.broadcastTx(It.TxRaw.encode(R).finish(),I,w);if(P.code!==0)throw new Error(P.rawLog);return P}catch(U){throw await Zt(U,a(E),o)}},V=async({chainId:M=s,...I})=>{try{const w=await m(M);return await Tr({...I,client:w})}catch(w){throw await Zt(w,a(M),o)}};return{estimateGas:b,simulateTx:C,requestTxSync:N,requestTxBlock:k,submitTxSync:$,submitTxBlock:q,waitForTxConfirmation:V}}async function Tr({txHash:e,client:n,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await n.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const Ln=W.atom(null);function $r(){const e=te(),n=js(),{fetchFeegrant:s,fetchGrants:o}=br();return async a=>{const{chainId:r,grantee:i}=a;if(!e)throw new Error("Granter wallet not initialized");const l=await s(r,i),c=await o(r,i),d=l?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Qa.MsgRevokeAllowance.fromPartial({granter:e,grantee:i})}]:[],u=n[r].filter(h=>c.some(m=>m?.authorization?.msg===h)).map(h=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:bo.MsgRevoke.fromPartial({granter:e,grantee:i,msgTypeUrl:h})}));return[...d,...u]}}function Fc(){const{privyContext:e}=Y(),n=te(),s=ys(),o=js(),{requestTxBlock:a}=vs(),r=T.useQueryClient(),[i,l]=W.useAtom(Ln),{closeDrawer:c}=xt(),d=$r(),u=async()=>{if(s)return s;if(!e)throw new Error("Privy context not available");const h=await e.createWallet({createAdditional:!1});return j.InitiaAddress(h.address).bech32};return T.useMutation({mutationFn:async h=>{if(!i)throw new Error("No pending request");const{chainId:m}=i,f=await u();if(!n||!f)throw new Error("Wallets not initialized");const p=await d({chainId:m,grantee:f}),g=h===0?void 0:Ge.addMilliseconds(new Date,h),x={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Qa.MsgGrantAllowance.fromPartial({granter:n,grantee:f,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:la.BasicAllowance.encode(la.BasicAllowance.fromPartial({expiration:g})).finish()}})},y=o[m].map(C=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:bo.MsgGrant.fromPartial({granter:n,grantee:f,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:ca.GenericAuthorization.encode(ca.GenericAuthorization.fromPartial({msg:C})).finish()},expiration:g}})})),b=[...p,x,...y];await a({messages:b,chainId:m,internal:!0})},onSuccess:async()=>{await r.invalidateQueries({queryKey:vn.expirations._def}),i?.resolve()},onError:h=>{i?.reject(h)},onSettled:()=>{l(null),c()}})}function Er(e){const n=Y(),s=ys(),o=e?.grantee||s,{requestTxBlock:a}=vs(),r=T.useQueryClient(),i=$r();return T.useMutation({mutationFn:async(l=n.defaultChainId)=>{if(!o)throw new Error("Wallets not initialized");const c=await i({chainId:l,grantee:o});await a({messages:c,chainId:l,internal:e?.internal})},onSuccess:async()=>{const l=[vn.expirations._def,vn.grants._def];for(const c of l)await r.invalidateQueries({queryKey:c})}})}function Uc(){const{defaultChainId:e}=Y(),{openDrawer:n}=xt(),s=W.useSetAtom(Ln),o=Er(),{data:a={expiredAtByChain:{},isEnabledByChain:{}},isLoading:r}=Eo();return{...a,isLoading:r,enable:async(c=e)=>new Promise((d,u)=>{s({chainId:c,resolve:d,reject:u}),n("/autosign/enable")}),disable:async(c=e)=>{await o.mutateAsync(c)}}}function qr(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function Oc(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),B(0)).toString()}function Vc(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??No}}function pa(e){return A.pick(["chainId","name","logoUrl"],e)}function Kc(e){return A.sortWith([A.descend(({symbol:n})=>n===We),A.descend(qr),A.descend(({assets:n})=>n.length),A.ascend(({symbol:n})=>n)])(e)}function zc(e){return A.sortWith([A.descend(({value:n})=>n??0),A.descend(({quantity:n})=>Number(n)),A.ascend(({chain:n})=>n.name)])(e)}function Wc(e,n){return A.sortWith([A.descend(({chain:s})=>s.chainId===n),A.ascend(({chain:s})=>s.name),A.ascend(({denom:s})=>s)])(e)}function Hc(e,n){return A.sortWith([A.descend(({chainId:s})=>s===n),A.descend(A.prop("value"))])(e)}function Qc(e,n,s,o,a){const r=e.find(h=>h.metadata?.is_l1)?.chainId,i={};for(const h of e){const m=h.chainId,f=n[m]??[],p=s[m],g=o[m],x=[];for(const{amount:y,denom:b}of f){if(!B(y).gt(0))continue;const C=p?.find(q=>q.denom===b),v=g?.find(q=>q.id===b)?.price,N=C?.decimals??0,k=j.fromBaseUnit(y,{decimals:N}),$=v?B(k).times(v).toNumber():void 0;x.push({...Vc(b,C),amount:y,denom:b,decimals:N,quantity:k,price:v,value:$,address:C?.address,unlisted:!C,chain:pa(h)})}i[m]=x}const l=new Map;for(const[h,m]of Object.entries(i)){if(m.length===0)continue;const f=e.find(g=>g.chainId===h);if(!f)continue;const p=m.reduce((g,{value:x})=>g+(x??0),0);l.set(h,{...pa(f),value:p})}const c=new Map;for(const h of Object.values(i))for(const m of h)if(!m.unlisted){const{symbol:f}=m,p=c.get(f)??[];c.set(f,[...p,m])}const d=[];for(const[h,m]of c){const f=A.head(m);if(!f)continue;const p=zc(m),g=p.reduce((y,{value:b})=>y+(b??0),0),x=p.reduce((y,{quantity:b})=>y.plus(b),B(0)).toNumber();d.push({symbol:h,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:x})}const u=[];for(const h of Object.values(i))for(const m of h)m.unlisted&&u.push(m);return{chainsByValue:Hc(Array.from(l.values()),a),assetGroups:Kc(d),unlistedAssets:Wc(u,r),totalValue:d.reduce((h,m)=>h+m.totalValue,0)}}function Lo(){const{defaultChainId:e}=Y(),n=de(),s=_c(),o=Sn(),a=Co(),r=n.map(m=>m.chainId),i=A.zipObj(r,s.map(A.prop("data"))),l=A.zipObj(r,o.map(A.prop("data"))),c=A.zipObj(r,a.map(A.prop("data"))),d=Qc(n,i,l,c,e),u=[s,o,a].flat().some(({isLoading:m})=>m);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:m})=>m()),o.forEach(({refetch:m})=>m()),a.forEach(({refetch:m})=>m())}}}function te(){const e=ln();return e?j.InitiaAddress(e).bech32:""}function ln(){const{address:e}=ve.useAccount(),n=To();return!e||!n?"":j.InitiaAddress(e).hex}function kt(){const e=Vt(),n=te(),s=ln();return e.metadata?.minitia?.type==="minievm"?s:n}function Lr(){const e=kt(),n=rr();return T.useQuery({queryKey:fs.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function De(){const e=kt(),n=te(),s=ln(),{data:o}=Lr(),a=qn(),r=Ao(),i=Uc(),{isDrawerOpen:l,openDrawer:c}=xt(),{isModalOpen:d}=cn(),u=()=>{c("/")},h=()=>{c("/connect")},m=b=>{c("/bridge",b)},f=Ic(),p=kc(),g=vs();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:l||d,openConnect:h,openWallet:u,openBridge:m,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const Gc="_status_tn9m1_1",Yc="_error_tn9m1_9",fa={status:Gc,error:Yc},he=({error:e,children:n})=>t.jsx("p",{className:L(fa.status,{[fa.error]:e}),children:n}),me=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(he,{error:!0,children:o.message})},suspenseFallback:n=t.jsx(he,{children:"Loading..."}),children:s})=>t.jsx(Ga.ErrorBoundary,{...e,children:t.jsx(_.Suspense,{fallback:n,children:s})}),Zc="lock_staking";function Mr(e,n){const s=`${n}::lock_staking::StakingAccount`,o=j.createObjectAddress(e,s);return j.InitiaAddress(o).bech32}const Mn=ye.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,n)=>[e,n],undelegations:(e,n,s)=>[e,n,s],lockStaking:(e,n,s)=>[e,n,s],stakingRewards:(e,n)=>[e,n],lockStakingRewards:(e,n,s)=>[e,n,s]});function Mo(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.delegations(e,n||"").queryKey,queryFn:async()=>n?(await z.get(`${e}/initia/mstaking/v1/delegations/${n}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const l=j.denomToMetadata(i.denom),c={denom:i.denom,metadata:l,amount:i.amount,validator:r},d=o.get(l)??[];d.push(c),o.set(l,d)}}return o},staleTime:K.MINUTE})}function Po(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const l=i.validator_address;for(const c of i.entries)for(const d of c.balance){const u=j.denomToMetadata(d.denom),h={denom:d.denom,metadata:u,amount:d.amount,validator:l,completionTime:c.completion_time},m=r.get(u)??[];m.push(h),r.set(u,m)}}return r},staleTime:K.MINUTE})}function Do(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te();return T.useSuspenseQuery({queryKey:Mn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=j.createMoveClient(e);return await o({moduleAddress:n,moduleName:Zc,functionName:"get_locked_delegations",typeArgs:[],args:[ie.toBase64(j.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},l=a.get(r.metadata)??[];l.push(i),a.set(r.metadata,l)}return a},staleTime:K.MINUTE})}function Pr(e){const n=new Map;if(!e.total||!Array.isArray(e.total))return n;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=j.denomToMetadata(s.denom);let a=new B(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=n.get(o);if(r){const i=new B(r.amount);a=a.plus(i)}n.set(o,{denom:s.denom,amount:a.toString()})}return n}function Dr(){const{restUrl:e}=ae(),n=te();return T.useSuspenseQuery({queryKey:Mn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await z.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Br(){const{restUrl:e}=ae(),{lockStakeModuleAddress:n}=Y(),s=te(),o=s?Mr(s,n):"";return T.useSuspenseQuery({queryKey:Mn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Pr,staleTime:K.MINUTE})}function Bo(){const e=ae(),n=gt(e),{data:s,isLoading:o}=_t(e),{data:a}=Mo(),{data:r}=Po(),{data:i}=Do(),l=_.useMemo(()=>{const f=new Set;for(const p of a.keys())f.add(p);for(const p of i.keys())f.add(p);for(const p of r.keys())f.add(p);return Array.from(f)},[a,i,r]),c=Io(l),d=_.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),u=_.useMemo(()=>{const f=new Map;for(const p of n)f.set(p.denom,p);return f},[n]),h=_.useMemo(()=>{const f=[],p=g=>{const x=u.get(g);return x?{symbol:x.symbol,decimals:x.decimals}:null};for(const[g,x]of a){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C};f.push({type:"staking",validator:v.validator,balance:q})}}for(const[g,x]of i){const y=c.get(g);if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=Number(v.releaseTime);f.push({type:"lockstaking",validator:v.validator,releaseTime:Number.isNaN(V)?0:V,balance:q})}}for(const[g,x]of r){const y=c.get(g)??x[0]?.denom;if(!y)continue;const b=p(y);if(!b)continue;const C=d.get(y)??0;for(const v of x){const{symbol:N,decimals:k}=b,$=Number(j.fromBaseUnit(v.amount,{decimals:k})),q={type:"asset",denom:y,symbol:N,amount:v.amount,formattedAmount:$,decimals:k,value:$*C},V=new Date(v.completionTime).getTime(),M=Number.isNaN(V)?0:Math.floor(V/1e3);f.push({type:"unstaking",validator:v.validator,completionTime:M,balance:q})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Se)},[a,i,r,c,u,d]),m=_.useMemo(()=>h.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[h]);return{positions:h,totalValue:m,isLoading:o}}const Ro=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function Jc(e){const n=new Map;for(const s of e){const o=j.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function Xc(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.checkLpTokens(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${n}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:K.MINUTE})}function Rr(){const e=ae(),n=An(e),s=_.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=Xc(s);return _.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return Jc(a)},[n,o])}function Fr(e){const{dexUrl:n}=Y();return T.useSuspenseQuery({queryKey:Ro.lpPrices(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${n}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:K.MINUTE})}function el(e){const{dexUrl:n}=Y(),s=ae(),o=gt(s),a=_.useMemo(()=>{const l=new Map;for(const c of o)l.set(c.denom,c);return l},[o]),i=T.useSuspenseQueries({queries:e.map(l=>({queryKey:Ro.pool(n,l).queryKey,queryFn:async()=>{try{const c=j.denomToMetadata(l);return(await z.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(c)}`).json()).pool}catch{return null}},staleTime:K.MINUTE}))}).map(l=>l.data);return _.useMemo(()=>{const l=new Map;return e.forEach((c,d)=>{const u=i[d];if(!u){l.set(c,null);return}if(c===wc){l.set(c,{...u,symbol:vc});return}const h=u.coins.map(m=>a.get(m.denom)?.symbol||m.denom).join("-");l.set(c,{...u,symbol:h})}),l},[e,i,a])}function tl(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}for(const r of s.keys())a.add(r);for(const[r,i]of o){const l=i[0]?.denom;l&&l!==Se&&a.add(r)}return Array.from(a)}function nl(e){const n=[];for(const[,s]of e)s&&s!==Se&&n.push(s);return n}function sl(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function ol(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=sl(o,s),i=r.length>0&&r.some(c=>c),l=i?void 0:s.get(e)?.logoUrl;return{denom:e,symbol:a,totalAmount:0,totalValue:0,decimals:s.get(e)?.decimals??6,poolType:o?.pool_type,logoUrl:l,coinLogos:i?r:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0}}}function Fs(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r)??i[0]?.denom;if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function al(e,n,s,o,a){for(const[r,i]of e){const l=n.get(r);if(!l||l===Se)continue;const c=o.get(l);if(c)for(const d of i){const u=String(d.amount),h=c.decimals,m=Number(j.fromBaseUnit(u,{decimals:h})),f=s.get(l)??0,p=m*f;c.breakdown[a]+=m,c.totalAmount+=m,c.totalValue+=p}}}function rl(e,n,s,o){for(const[a,r]of e){const i=j.denomToMetadata(a),l=n?.get(i),c=l?j.fromBaseUnit(l.amount,{decimals:Pe}):"0",d=s?.get(i),u=d?j.fromBaseUnit(d.amount,{decimals:Pe}):"0",h=Number(c)+Number(u);h>0&&(r.claimableInit={staking:c,lockStaking:u,total:String(h),totalValue:h*o})}}function Fo(){const e=ae(),n=gt(e),s=Rr(),{data:o}=Mo(),{data:a}=Do(),{data:r}=Po(),{data:i}=Dr(),{data:l}=Br(),{data:c}=_t(e),d=_.useMemo(()=>{const y=new Map;for(const b of n)y.set(b.denom,b);return y},[n]),u=_.useMemo(()=>tl(s,o,a,r),[s,o,a,r]),h=Io(u),m=_.useMemo(()=>nl(h),[h]),{data:f}=Fr(m),p=el(m),{rows:g,totalValue:x}=_.useMemo(()=>{const y=c?.find(N=>N.id===Se)?.price??0,b=new Map;for(const N of m)b.set(N,ol(N,p,d));Fs(s,h,f,b,"deposit"),Fs(o,h,f,b,"staking"),al(a,h,f,b,"lockStaking"),Fs(r,h,f,b,"unstaking"),rl(b,i,l,y);const C=Array.from(b.values()).filter(N=>N.totalAmount>0).sort((N,k)=>k.totalValue-N.totalValue),v=C.reduce((N,k)=>N+k.totalValue,0);return{rows:C,totalValue:v}},[m,p,d,s,o,a,r,h,f,i,l,c]);return{totalValue:x,rows:g}}const il=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function cl(e){return e.filter(n=>n.data.length>0).map(n=>{const s=n.data[0].bridge_id,o=n.data[0].version,a=n.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:n.total_claimable_reward,claimedReward:a,initialReward:n.total_vesting_reward,lockedReward:n.total_locked_reward,requiredScore:n.required_score,rollup:{bridgeId:s,version:o}}}).filter(n=>n.initialReward>0).toSorted((n,s)=>s.initialReward-n.initialReward)}function Ur(){const{vipUrl:e}=Y(),n=te();return T.useQuery({queryKey:il.allVestingPositions(e,n).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${n}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:K.MINUTE,enabled:!!n})}function ll(){const e=de();return _.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Cs(){const{data:e}=Ur(),n=ae(),{data:s}=_t(n),o=ll(),a=_.useMemo(()=>s?.find(c=>c.id===Se)?.price??0,[s]),r=_.useMemo(()=>e?cl(e).map(c=>{const d=o(c.rollup.bridgeId),u=Number(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})),h=Number(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})),m=B(j.fromBaseUnit(String(c.lockedReward),{decimals:Pe})).times(a).toNumber(),f=B(j.fromBaseUnit(String(c.claimableReward),{decimals:Pe})).times(a).toNumber();return{bridgeId:c.rollup.bridgeId,version:c.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:m,claimableReward:h,claimableRewardValue:f}}):[],[e,a,o]),i=_.useMemo(()=>r.reduce((l,c)=>l+c.lockedRewardValue+c.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function Or(){const e=Rr(),{data:n}=Mo(),{data:s}=Do(),{data:o}=Po(),{data:a}=Ur(),r=ae(),{data:i}=_t(r),l=_.useMemo(()=>i?.find(g=>g.id===Se)?.price??0,[i]),c=_.useMemo(()=>{const p=new Set;for(const[g]of e)p.add(g);for(const[g]of n)p.add(g);for(const[g]of s)p.add(g);for(const[g]of o)p.add(g);return Array.from(p)},[e,n,s,o]),d=Io(c),u=_.useMemo(()=>Array.from(d.values()).filter(p=>p!==Se),[d]),{data:h}=Fr(u),m=gt(r),f=_.useMemo(()=>{const p=new Map;for(const g of m)p.set(g.denom,{decimals:g.decimals});return p},[m]);return _.useMemo(()=>{let p=0,g=0;const x=l??0,y=(C,v)=>{const N=d.get(C)??C;if(N===Se)return 0;const k=f.get(N)?.decimals??Pe;return Number(j.fromBaseUnit(v,{decimals:k}))*(h.get(N)??0)};for(const[,C]of n)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of s){const k=(d.get(C)??C)===Se;for(const{amount:$}of v)k?p+=Number(j.fromBaseUnit($,{decimals:Pe}))*x:g+=y(C,$)}for(const[,C]of o)for(const{denom:v,metadata:N,amount:k}of C)v===Se?p+=Number(j.fromBaseUnit(k,{decimals:Pe}))*x:g+=y(N,k);for(const[C,v]of e)for(const{amount:N}of v)g+=y(C,String(N));let b=0;if(a)for(const C of a){const v=C.total_locked_reward??0,N=C.total_claimable_reward??0;b+=Number(j.fromBaseUnit(String(v+N),{decimals:Pe}))*x}return p+g+b},[n,s,o,e,a,l,d,h,f])}function dl(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],n={"initia-wallet-widget:ethereum-public-keys":{prefix:oe.PUBLIC_KEY,getSuffix:s=>j.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(n)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[l,c]of Object.entries(i)){const d=`${o}:${a(l)}`;localStorage.setItem(d,c)}localStorage.removeItem(s)}catch{}}}const co=ye.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,n)=>[e,n],balances:(e,n,s)=>[e,n,s],initiaPositions:(e,n)=>[e,"initia",n],echelonPositions:(e,n)=>[e,"echelon",n],inertiaPositions:(e,n)=>[e,"inertia",n],ravePositions:(e,n,s)=>[e,"rave",n,s],civitiaPositions:(e,n)=>[e,"civitia",n],yominetPositions:(e,n)=>[e,"yominet",n],chainPositions:(e,n,s)=>[e,n,s]});function Uo(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],l=r.data;if(!(!i||!l)){for(const c of l)if(c.logoUrl&&!c.logoUrl.includes("undefined")){const d=`${i.chainId}:${c.denom}`;s.has(d)||s.set(d,c.logoUrl);const u=c.symbol.toUpperCase();o.has(u)||o.set(u,c.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function an(e){if(e.type==="fungible-position")return e.value??0;if(e.balance.type==="unknown")return 0;const n=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-n:n}function ul(e){return e.type==="fungible-position"?null:e.type==="staking"||e.type==="unstaking"||e.type==="lockstaking"?"staking":e.type==="lending"?e.direction==="supply"?"lending":"borrowing":null}function ml(e,n=!1){switch(e){case"staking":return n?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function hl(e){const n=new Map;for(const d of e){const u=ul(d);if(!u)continue;const h=n.get(u)??[];h.push(d),n.set(u,h)}const s=new Map,o=new Map;for(const[d,u]of n){const h=u.reduce((f,p)=>f+an(p),0),m=u.reduce((f,p)=>f+Math.abs(an(p)),0);s.set(d,h),o.set(d,m)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,l=[...n.keys()].sort((d,u)=>{const h=d==="lending"||d==="borrowing"?i:o.get(d)??0,m=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:m-h}),c=new Map;for(const d of l)c.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return c}function pl(e){return e.type==="fungible-position"?e.title:e.balance.denom}function fl(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function gl(e){return e.type==="fungible-position"?null:e.balance}function _l(e){switch(e){case"staking":return"Staking";case"unstaking":return"Unstaking";case"lockstaking":return"Lock staking";case"lending":return"Lending";case"fungible-position":return"Position";default:return""}}function xl(e){const n=new Map;for(const s of e){const o=n.get(s.type)??[];o.push(s),n.set(s.type,o)}return n}function yl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function jl(e){const n=new Map;for(const o of e){const a=pl(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=gl(a[0]);let i=0;for(const l of a)l.type!=="fungible-position"&&l.balance.type!=="unknown"&&(i+=l.balance.formattedAmount);return{denom:o,symbol:fl(a[0]),positions:a,totalValue:a.reduce((l,c)=>l+an(c),0),totalAmount:i,balance:r}}).toSorted(yl)}function Vr(e,n){const s=new Map;return e.forEach((o,a)=>{const r=n[a]?.data;if(r&&r.length>0){const i=new Map(r.map(l=>[l.id,l.price]));s.set(o.chainId,i)}}),s}function bl(e,n){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=n.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function wl(e,n){return e.symbol===We&&n.symbol===We?0:e.symbol===We?-1:n.symbol===We?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function vl(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const l=i.symbol.toUpperCase(),c=`${i.chain.chainId}:${i.denom}`,d=n.get(c)??s.get(l)??"";return d!==i.logoUrl?{...i,logoUrl:d}:i});let r="";for(const i of a)if(i.logoUrl){r=i.logoUrl;break}return r||(r=s.get(o.symbol.toUpperCase())??""),r!==o.logoUrl||a!==o.assets?{...o,logoUrl:r,assets:a}:o})}function Cl(e,n,s){const o=n?e.filter(i=>{const{symbol:l,assets:c}=i,d=n.toLowerCase();return l.toLowerCase().includes(d)||c.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const l=i.assets.filter(({chain:c})=>c.chainId===s);return{...i,assets:l,totalValue:l.reduce((c,d)=>c+(d.value??0),0),totalAmount:l.reduce((c,d)=>c+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,l)=>i+l.assets.reduce((c,d)=>c+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Nl(e,n,s){const o=n?e.filter(({denom:a,address:r})=>{const i=n.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Il(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Cl(e,s,o),i=Nl(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function kl(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const l of e){const{chainName:c,chainId:d,balances:u}=l;if(!Array.isArray(u))continue;const h=n.get(c.toLowerCase()),m=h?.chainId??d??c,f=h?.prettyName??c,p=h?.logoUrl??"",g=s.get(m);for(const x of u){if(x.type==="unknown"){if(!x.amount||x.amount==="0")continue;r.push({symbol:x.denom,logoUrl:"",denom:x.denom,amount:x.amount,decimals:0,quantity:x.amount,value:void 0,unlisted:!0,chain:{chainId:m,name:f,logoUrl:p}});continue}if(x.type==="lp"||(x.value??0)<=0&&(x.formattedAmount??0)<=0)continue;let y=x.value;if((y==null||y<=0)&&g){const v=g.get(x.denom)??0;v>0&&(y=x.formattedAmount*v)}const b={symbol:x.symbol,logoUrl:"",denom:x.denom,amount:x.amount,decimals:x.decimals,quantity:String(x.formattedAmount),value:y,chain:{chainId:m,name:f,logoUrl:p}},C=a.get(x.symbol);C?C.push(b):a.set(x.symbol,[b])}}r.sort((l,c)=>{const d=l.chain.chainId===o,u=c.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const h=l.chain.name.localeCompare(c.chain.name);if(h!==0)return h;try{const m=BigInt(l.amount),f=BigInt(c.amount);if(m>f)return-1;if(m<f)return 1}catch{const m=l.amount.localeCompare(c.amount);if(m!==0)return-m}return l.denom.localeCompare(c.denom)});const i=[];for(const[l,c]of a){c.sort((h,m)=>(m.value??0)-(h.value??0));let d=0,u=0;for(const h of c)d+=h.value??0,u+=Number(h.quantity);i.push({symbol:l,logoUrl:"",assets:c,totalValue:d,totalAmount:u})}return i.sort(wl),{listedGroups:i,unlistedAssets:r}}function Oo(){return ae().network_type==="testnet"}function St(){return _e.useFormContext()}function Sl(){const e=Je(),n=Oo(),s={quantity:"",slippagePercent:"0.5",sender:"",cosmosWalletName:"",recipient:""},o={...s,srcChainId:"initiation-2",srcDenom:"uusdc",dstChainId:"initiation-2",dstDenom:"uinit"},a={...s,srcChainId:"interwoven-1",srcDenom:"ibc/6490A7EAB61059BFC1CDDEB05917DD70BDF3A611654162A1A47DB930D40D8AF4",dstChainId:"interwoven-1",dstDenom:"uinit"},r=A.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(oe.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(oe.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(oe.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(oe.BRIDGE_DST_DENOM),quantity:localStorage.getItem(oe.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(oe.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Al={balances:[],positions:[],isLoading:!0,isComplete:!1},Kr=W.atom(0),Tl=1e3;let ga=0;function $l(){const e=W.useSetAtom(Kr);_.useEffect(()=>{const n=Date.now();n-ga>=Tl&&(ga=n,e(s=>s+1))},[e])}function El(){const e=T.useQueryClient(),n=te(),{minityUrl:s}=Y(),o=Oo(),a=W.useAtomValue(Kr),r=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.balances)?c.balances:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,balances:u})}),i=_.useEffectEvent((c,d)=>{const u=Array.isArray(c.positions)?c.positions:[];d.set(c.chain,{chainName:c.chain,chainId:c.chainId,positions:u})}),l=_.useEffectEvent((c,d)=>{const u=co.ssePortfolio(n??"",s).queryKey,h=e.getQueryData(u)??Al,m=c.size>0||d.size>0;e.setQueryData(u,{...h,balances:Array.from(c.values()),positions:Array.from(d.values()),isLoading:m?!1:h.isLoading,isComplete:!1})});_.useEffect(()=>{if(!n||o)return;const c=co.ssePortfolio(n,s).queryKey,d=e.getQueryData(c),u=new Map,h=new Map;for(const x of d?.balances??[])u.set(x.chainName,x);for(const x of d?.positions??[])h.set(x.chainName,x);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,g=!1;return e.setQueryData(c,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),p=new EventSource(f),p.onmessage=x=>{if(!g)try{const y=JSON.parse(x.data);y.type==="balances"?r(y,u):y.type==="positions"&&i(y,h),l(u,h)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[n,o,a])}const _a={balances:[],positions:[],isLoading:!0,isComplete:!1};function Pn(){const e=te(),{minityUrl:n}=Y(),s=co.ssePortfolio(e??"",n).queryKey,{data:o}=T.useQuery({queryKey:s,queryFn:()=>_a,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??_a}function ql(){const e=de();return _.useMemo(()=>{const n=new Map;for(const s of e){const o=s.chain_name.toLowerCase();n.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return n},[e])}function Ll(){const{balances:e,positions:n}=Pn(),s=de(),o=_.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return _.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((p,g)=>{if(g.type==="fungible-position")return p+(g.value??0);if(g.balance.type==="unknown")return p;const x=g.balance.value??0;return g.type==="lending"&&g.direction==="borrow"?p-x:p+x},0),l=new Map,c=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:p}of c){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+r(y),0);l.set(f,(l.get(f)||0)+g)}for(const{chainName:f,positions:p}of d){if(!Array.isArray(p))continue;const g=p.reduce((x,y)=>x+i(y),0);l.set(f,(l.get(f)||0)+g)}const u=Array.from(l.values()).reduce((f,p)=>f+p,0),h=Array.from(l.entries()).filter(([,f])=>f>0).map(([f,p])=>{const g=o.get(f.toLowerCase());return{chainId:g?.chainId||"",chainName:g?.name||f,logoUrl:g?.logoUrl||"",totalBalance:p,percentage:u>0?p/u:0}}).filter(f=>f.chainId!==""),m=f=>f.chainName.toLowerCase()==="initia";return A.sortWith([A.descend(m),A.descend(A.prop("totalBalance"))],h)},[e,n,o])}function Ml(){const{balances:e}=Pn(),n=de(),s=Co(),o=_.useMemo(()=>Vr(n,s),[n,s]);return _.useMemo(()=>{const a=c=>c.type==="unknown"?0:c.value??0;let r=0;const i=Array.isArray(e)?e:[],l=bl(i,o);for(const{balances:c}of l)if(Array.isArray(c))for(const d of c)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function Pl(){const{positions:e}=Pn();return _.useMemo(()=>{const n=r=>r.positions.reduce((i,l)=>{if(l.type==="fungible-position")return i+(l.value??0);if(l.balance.type==="unknown")return i;const c=l.balance.value??0;return l.type==="lending"&&l.direction==="borrow"?i-c:i+c},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const l=r.toLowerCase();s.includes(l)||Array.isArray(i)&&(o+=i.reduce((c,d)=>c+n(d),0))}return o},[e])}const qe=ye.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,n)=>[e,n],allBalances:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[{...e,quantity:B(e.quantity||0).toString()},n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function Xe(){const{routerApiUrl:e}=Y();return _.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.3.0"}}),[e])}function zr(){const e=de();return n=>e.some(s=>s.chain_id===n)}function Dn(){const e=zr();return n=>e(n.chain_id)?"initia":n.chain_type}function Cn(e){return Dn()(e)}function Bn(){const e=Xe(),{data:n}=T.useSuspenseQuery({queryKey:qe.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>A.sortWith([A.descend(({chain_name:o})=>o==="initia"),A.ascend(({pretty_name:o})=>o)],s),staleTime:K.MINUTE});return n}function yt(){const e=Bn(),n=er();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=n.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function ze(e){return yt()(e)}function Kt(){const e=Xe(),n=Bn(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),select:({chain_to_assets_map:a})=>{const r=[];for(const i in a){if(!n.find(c=>c.chain_id===i))continue;const{assets:l}=a[i]??{assets:[]};s.setQueryData(qe.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...l);for(const c of l)s.setQueryData(qe.asset(i,c.denom).queryKey,c)}return r},staleTime:K.MINUTE});return o}function is(e){const n=Xe(),s=T.useQueryClient(),{data:o}=T.useSuspenseQuery({queryKey:qe.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(qe.asset(e,i.denom).queryKey,i);return r.toSorted(A.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function Wr(e){const n=is(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function it(e,n){return Wr(n)(e)}const Dl=()=>(jc(),bc(),null),Bl="_loader_1vxch_1",Rl={loader:Bl},ct=({size:e=24,color:n="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:Rl.loader,style:o})},Fl="_button_1q027_1",Ul="_outline_1q027_28",Ol="_sm_1q027_46",Vl="_full_1q027_53",Kl="_small_1q027_57",zl="_unpadded_1q027_88",Bt={button:Fl,outline:Ul,sm:Ol,full:Vl,small:Kl,unpadded:zl},Hr=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...l}=e;return t.jsx("button",{...l,className:L(Bt.button,{[Bt.sm]:n,[Bt.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(ct,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Bt.loading,children:o})]}):r})},Wl=({className:e,...n})=>t.jsx(Hr,{...n,className:L(Bt.outline,e)}),Hl=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:L(Bt.small,{[Bt.unpadded]:n},e)}),le={White:Hr,Outline:Wl,Small:Hl},Ql="_footer_1vp4h_1",Gl="_actions_1vp4h_10",xa={footer:Ql,actions:Gl},xe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:L(xa.footer,n),children:[e,t.jsx("div",{className:xa.actions,children:s})]}),Yl="_scrollable_13su7_1",Zl={scrollable:Yl},et=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:L(Zl.scrollable,e),children:n});function Ns(){return Le.useMediaQuery("(max-width: 576px)")}const lo="interwoven-kit";function Qr(){const e=document.querySelector(lo)||document.body.appendChild(document.createElement(lo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Gr(){const{theme:e,container:n}=Y();return _.useEffect(()=>{document.querySelector(lo)?.setAttribute("data-theme",e)},[e]),n??Qr()}function Jl(e){const n=Qr(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const Is=_.createContext(null);function Ot(){const{container:e}=_.useContext(Is);return e}function Yr(e){const n=Ot();return n?getComputedStyle(n).getPropertyValue(e):""}function Xl(){return Le.useScrollLock(),null}function ed(e){return/^[A-F0-9]{64}$/i.test(e)}function td(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return ed(s)?A.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!j.InitiaAddress.validate(o))return;const i=A.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function nd(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const sd="_link_j1lkz_1",ya={link:sd},ks=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:l,onClick:c,...d}=a,u=Ze(e),h=td(u,{txHash:n,accountAddress:s,pathSuffix:o}),m=n?j.truncate(n):s?j.truncate(s):"",f=l??m;return h?t.jsxs("a",{...d,href:Xi(nd(h)),className:L(ya.link,i),onClick:c,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:L(ya.link,i),children:f})},Zr=_.createContext(null),Ss=()=>_.useContext(Zr),od=()=>{const[e,n]=W.useAtom(Sr),{showNotification:s,updateNotification:o,hideNotification:a}=Ss();return _.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:l,error:c}=e,d=c?c.message:l?t.jsx(ks,{txHash:l,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,o,a]),null},cs=({value:e,children:n})=>{const[s,o]=_.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},ad="_placeholder_10r3x_1",rd="_logo_10r3x_5",ja={placeholder:ad,logo:rd},X=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[l,c]=_.useState(void 0),{width:d,height:u}=i,h=s??t.jsx("div",{className:L(ja.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||l===e?h:t.jsx("img",{...i,className:L(i.className,{[ja.logo]:r}),style:{width:d,height:u,...a},src:e,alt:n,loading:"lazy",onError:()=>c(e)})};function Jr(){const{connector:e}=ve.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const id="_header_1q8ju_1",cd="_account_1q8ju_17",ld="_name_1q8ju_28",dd="_address_1q8ju_32",ud="_icon_1q8ju_36",md="_copied_1q8ju_43",hd="_button_1q8ju_58",pd="_settings_1q8ju_69",fd="_disconnect_1q8ju_73",gd="_label_1q8ju_83",_d="_expanded_1q8ju_91",Fe={header:id,account:cd,name:ld,address:dd,icon:ud,copied:md,button:hd,settings:pd,disconnect:fd,label:gd,expanded:_d},xd=()=>{const e=Ao(),{address:n,username:s}=De(),o=Jr(),a=s??n,[r,i]=_.useState(!1),l=_.useRef(null),c=rt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(l.current=setTimeout(()=>{i(!1)},500))},h=()=>{l.current&&(clearTimeout(l.current),l.current=null)};return _.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]),n?t.jsxs("header",{className:Fe.header,children:[t.jsx(cs,{value:n,children:({copy:m,copied:f})=>t.jsxs("button",{className:L(Fe.account,{[Fe.copied]:f}),onClick:m,children:[t.jsx(X,{src:o,width:18,height:18}),t.jsx("div",{className:Fe.address,children:j.truncate(n)}),t.jsx("div",{className:Fe.name,children:j.truncate(a)}),t.jsx(S.IconCopy,{className:Fe.icon,size:12}),f?"Copied!":""]})}),t.jsx(nn,{to:"/settings",className:L(Fe.button,Fe.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(rt.animated.button,{className:L(Fe.button,Fe.disconnect,{[Fe.expanded]:r}),style:c,onClick:d,onMouseLeave:u,onMouseEnter:h,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Fe.label,children:"Disconnect"})]})]}):null},yd="_overlay_jij9g_1",jd="_content_jij9g_28",bd="_inner_jij9g_60",Us={overlay:yd,content:jd,inner:bd},wd=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=xt(),{setContainer:o}=_.useContext(Is),a=Ns(),r=Gr(),i=W.useAtomValue(ws),l=W.useAtomValue(Ln),c=T.useIsMutating({mutationKey:[kr]}),d=()=>{const p=c?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(p)),l?.reject(new Error("User rejected"))},u=_s(),h=Ce(),m=T.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const x=()=>{u==="/bridge"&&(localStorage.removeItem(oe.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_SRC_DENOM),localStorage.removeItem(oe.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(oe.BRIDGE_DST_DENOM)),h("/"),m.clear(),g()};return t.jsxs(et,{children:[t.jsx(he,{error:!0,children:p.message}),t.jsx(xe,{children:t.jsx(le.White,{onClick:x,children:"Retry"})})]})}};return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:p=>!p&&d(),modal:!1,children:t.jsxs(ke.Dialog.Portal,{container:r,children:[a&&t.jsx(ke.Dialog.Backdrop,{className:Us.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(ke.Dialog.Popup,{className:Us.content,children:t.jsxs("div",{className:L(Us.inner,"body"),ref:o,children:[a&&t.jsx(Xl,{}),t.jsx(od,{}),t.jsx(xd,{}),t.jsx(me,{errorBoundaryProps:f,children:e})]})})]})})},vd="_backdrop_1bqx9_1",Cd="_modal_1bqx9_12",Nd="_closeButton_1bqx9_44",Os={backdrop:vd,modal:Cd,closeButton:Nd},Id=({children:e})=>{const{isModalOpen:n,closeModal:s}=cn(),{setContainer:o}=_.useContext(Is),a=Gr();return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:r=>!r&&s(),children:t.jsxs(ke.Dialog.Portal,{container:a,children:[t.jsx(ke.Dialog.Backdrop,{className:Os.backdrop,onClick:s}),t.jsxs(ke.Dialog.Popup,{className:L(Os.modal),ref:o,children:[t.jsx("button",{className:Os.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},Xr=_.createContext(!1),kd="_overlay_1iyfl_1",Sd="_fullscreen_1iyfl_15",Ad="_content_1iyfl_19",Td="_header_1iyfl_56",$d="_title_1iyfl_65",Ed="_close_1iyfl_70",$t={overlay:kd,fullscreen:Sd,content:Ad,header:Td,title:$d,close:Ed},ei=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ot(),l=_.useContext(Xr);return i?t.jsxs(ke.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&t.jsx(ke.Dialog.Trigger,{className:o,children:s}),t.jsxs(ke.Dialog.Portal,{container:i,children:[t.jsx(ke.Dialog.Backdrop,{className:L($t.overlay,{[$t.fullscreen]:l}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(ke.Dialog.Popup,{className:L($t.content,{[$t.fullscreen]:l}),children:[e&&t.jsxs("header",{className:$t.header,children:[t.jsx(ke.Dialog.Title,{className:$t.title,children:e}),t.jsx(ke.Dialog.Close,{className:$t.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},Nn=({children:e})=>{const n=_.useRef(null),[s,o]=_.useState(0),[a,r]=_.useState(!1),i=rt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return _.useEffect(()=>{const l=n.current;if(!l)return;const c=()=>{const{height:u}=l.getBoundingClientRect();o(u),r(!0)};c();const d=new ResizeObserver(c);return d.observe(l),()=>d.disconnect()},[e]),e?t.jsx(rt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},qd="_help_qcmtq_1",Ld="_icon_qcmtq_10",Md="_info_qcmtq_19",Pd="_warning_qcmtq_23",Dd="_error_qcmtq_27",Bd="_success_qcmtq_33",Vs={help:qd,icon:Ld,info:Md,warning:Pd,error:Dd,success:Bd},Jt=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(ct,{size:12});case"info":return t.jsx(S.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(S.IconWarningFilled,{size:12});default:return t.jsx(S.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:L(Vs.help,e&&Vs[e],n),style:{marginTop:s},children:[t.jsx("div",{className:Vs.icon,children:a()}),o]})},Rd="_stack_a6m7u_1",Fd="_help_a6m7u_6",Ud="_info_a6m7u_14",Od="_warning_a6m7u_19",Vd="_error_a6m7u_24",Kd="_success_a6m7u_29",uo={stack:Rd,help:Fd,info:Ud,warning:Od,error:Vd,success:Kd},zd=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx(Nn,{children:t.jsx("div",{className:uo.stack,children:e})}),fe=({mt:e=0,...n})=>t.jsx(Jt,{...n,className:L(uo.help,uo[n.level]),mt:e});fe.Stack=zd;const Wd="_root_16p5j_1",Hd="_item_16p5j_10",Qd="_chevron_16p5j_14",Gd="_trigger_16p5j_19",Yd="_content_16p5j_39",mn={root:Wd,item:Hd,chevron:Qd,trigger:Gd,content:Yd};function Zd(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(J.Accordion.Root,{className:mn.root,type:"multiple",...i,children:[n.map((l,c)=>t.jsxs(J.Accordion.Item,{className:mn.item,value:s?.(l)??String(c),children:[t.jsx(J.Accordion.Header,{children:t.jsxs(J.Accordion.Trigger,{className:mn.trigger,children:[o(l),t.jsx(S.IconChevronDown,{className:mn.chevron,size:16})]})}),t.jsx(J.Accordion.Content,{className:mn.content,children:a(l)})]},s?.(l)??c)),r]})}const Jd=10;function ti(){const e=te();return(n,s)=>T.queryOptions({queryKey:fs.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Jd},{txs:a}=await z.create({prefixUrl:n.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:K.SECOND})}function Xd(e,n){const s=ti();return T.useSuspenseQuery(s(e,n))}function eu(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return A.sortWith([A.descend(o=>new Date(o.timestamp).getTime())])(s)}const tu=()=>{const e=de(),n=ti(),s=T.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(A.prop("data")),a=eu(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};function Vo(e){const{data:n}=T.useSuspenseQuery({queryKey:ps.gasPrices(e).queryKey,queryFn:async()=>{if(e.metadata?.is_l1){const{restUrl:s}=e,{gas_prices:o}=await z.create({prefixUrl:s}).get("initia/tx/v1/gas_prices").json();return o.toSorted(A.descend(({denom:a})=>a==="uinit")).map(({denom:a,amount:r})=>{const i=a==="uinit"?1:Za;return{amount:B(r).times(i).toFixed(18),denom:a}})}return e.fees.fee_tokens.map(({denom:s,fixed_min_gas_price:o})=>{if(A.isNil(o))throw new Error(`${s} has no price`);return{amount:String(o),denom:s}})},staleTime:K.SECOND});return n}function Ko(e){const n=te(),{data:s}=Xd(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>j.InitiaAddress.equals(n,pt.computeAddress(`0x${ie.toHex(ro.Secp256k1.uncompressPubkey(ie.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const nu="_trigger_u613p_1",su="_icon_u613p_18",ou="_content_u613p_27",au="_item_u613p_36",ru="_itemText_u613p_52",iu="_itemIndicator_u613p_57",cu="_active_u613p_60",vt={trigger:nu,icon:su,content:ou,item:au,itemText:ru,itemIndicator:iu,active:cu};function zo({options:e,value:n,onChange:s,classNames:o}){const a=Ot(),r=e.find(l=>l.value===n);if(!r)throw new Error("Selected option not found");const i=l=>{const c=e.find(d=>String(d.value)===l);if(!c)throw new Error(`Option not found: ${l}`);s(c.value)};return t.jsxs(ut.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ut.Select.Trigger,{className:L(vt.trigger,o?.trigger),children:[t.jsx(ut.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ut.Select.Icon,{className:vt.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(ut.Select.Portal,{container:a,children:t.jsx(ut.Select.Positioner,{className:vt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ut.Select.Popup,{className:vt.popup,children:e.map(l=>t.jsxs(ut.Select.Item,{className:L(vt.item,o?.item),value:String(l.value),children:[t.jsx(ut.Select.ItemText,{className:L(vt.itemText,o?.itemText),children:l.label}),t.jsx(S.IconCheck,{size:12,className:L(vt.itemIndicator,{[vt.active]:l.value===n})})]},String(l.value)))})})})]})}const lu="_root_1t37n_1",du="_trigger_1t37n_7",uu="_item_1t37n_11",mu="_itemText_1t37n_17",ba={root:lu,trigger:du,item:uu,itemText:mu},hu=({options:e,value:n,onChange:s})=>{const{txRequest:o}=Ar(),a=Ze(o.chainId),r=lt(a),i=(p,g)=>{if(j.formatAmount(p,{decimals:g})==="0.000000")return 8},l=({amount:[{amount:p,denom:g}]})=>{if(B(p).isZero())return"0";const{symbol:x,decimals:y}=r(g),b=i(p,y);return`${j.formatAmount(p,{decimals:y,dp:b})} ${x}`},c=e.map(p=>{const[{denom:g}]=p.amount,{symbol:x}=r(g);return{value:g,label:l(p),triggerLabel:x}});if(e.length===1)return t.jsx("span",{className:"monospace",children:l(e[0])});const d=e.find(p=>p.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:h}]=d.amount,{decimals:m}=r(h),f=i(u,m);return t.jsxs("div",{className:ba.root,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(u,{decimals:m,dp:f})}),t.jsx(zo,{options:c,value:n,onChange:s,classNames:ba})]})},pu="_root_16nr2_1",fu="_trigger_16nr2_5",gu="_chevron_16nr2_13",_u="_panel_16nr2_27",xu="_details_16nr2_39",yu="_row_16nr2_48",Gt={root:pu,trigger:fu,chevron:gu,panel:_u,details:xu,row:yu},ju=({spend:e,fee:n,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:n},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),l=r===6?void 0:8;return t.jsxs(Ps.Collapsible.Root,{className:Gt.root,children:[t.jsxs(Ps.Collapsible.Trigger,{className:Gt.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:Gt.chevron,size:16})]}),t.jsx(Ps.Collapsible.Panel,{className:Gt.panel,children:t.jsx("div",{className:Gt.details,children:i.map(({label:c,value:d})=>t.jsxs("div",{className:Gt.row,children:[t.jsx("span",{children:c}),t.jsxs("span",{children:[j.formatAmount(d,{decimals:r,dp:l})," ",a]})]},c))})})]})};function ls(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?ie.toBase64(e):Array.isArray(e)?`[${e.map(ls).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const bu="_container_1xzyq_1",wu="_toggle_1xzyq_5",vu="_list_1xzyq_11",Cu="_arg_1xzyq_16",Nu="_type_1xzyq_21",hn={container:bu,toggle:wu,list:vu,arg:Cu,type:Nu},Iu=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),ku=({type:e,arg:n})=>ls(j.resolveBcsType(e).parse(n)),Su=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Le.useToggle(!1),{restUrl:r}=Ze(n),{moduleAddress:i,moduleName:l,functionName:c,args:d}=e,{data:u}=T.useQuery({queryKey:Iu.abi(r,i,l,c).queryKey,queryFn:async()=>{const m=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${l}`).json(),p=JSON.parse(m.module.abi).exposed_functions.find(({name:g})=>g===c);if(!p)throw new Error(`Function ${c} not found in module ${l}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:K.INFINITY});if(!u)return s;const h=(m,f)=>{const p=u[f];return t.jsxs("div",{className:hn.arg,children:[t.jsx("div",{className:hn.type,children:p}),t.jsx(Ga.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(ku,{type:p,arg:m})})]},f)};return t.jsxs("div",{className:hn.container,children:[t.jsx(le.Small,{className:hn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:hn.list,children:d.map(h)}):s]})},Au="_list_oip9m_1",Tu="_key_oip9m_9",$u="_value_oip9m_14",Ks={list:Au,key:Tu,value:$u},Eu=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:Ks.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:Ks.key,children:a}),t.jsx("div",{className:Ks.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Su,{msg:o,chainId:n,fallback:ls(r)}):ls(r)})]},a))})},qu="_item_1n572_1",Lu="_title_1n572_10",Mu="_content_1n572_14",zs={item:qu,title:Lu,content:Mu},Ws=({title:e,content:n})=>t.jsxs("div",{className:zs.item,children:[t.jsx("div",{className:zs.title,children:e}),t.jsx("div",{className:zs.content,children:n})]});function ee(e){const n=e?B(e).abs():void 0;if(n&&n.gt(0)&&n.lt(.01))return"< $0.01";const s=e&&B(e).lt(0),o=j.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function ni(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(l=>l.key==="spender")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d-BigInt(l)}}}if(o.type==="coin_received"){const r=o.attributes.find(l=>l.key==="receiver")?.value,i=o.attributes.find(l=>l.key==="amount")?.value;if(r===n&&i){const[l,c]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(l&&c){const d=s[c]||BigInt(0);s[c]=d+BigInt(l)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function si(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(c=>c.key==="type_tag")?.value,i=o.attributes.find(c=>c.key==="data")?.value;if(!r||!i)continue;let l;try{l=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const c=l.store_addr,d=l.amount,u=l.metadata_addr;if(c&&d&&u&&j.createUserDerivedObjectAddress(n,u)===c){const m=s[u]||BigInt(0);s[u]=m+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const oi=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=T.useSuspenseQuery({queryKey:wn.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:K.INFINITY});return s(a)},Pu="_root_1p8a4_1",Du="_title_1p8a4_8",Bu="_changes_1p8a4_14",Ru="_change_1p8a4_14",Fu="_amount_1p8a4_35",Uu="_text_1p8a4_42",Ou="_value_1p8a4_49",Rt={root:Pu,title:Du,changes:Bu,change:Ru,amount:Fu,text:Uu,value:Ou},ai=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,l=j.formatAmount(e,{decimals:r}),c=s&&B(j.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Rt.change,children:[t.jsxs("div",{className:Rt.amount,children:[t.jsx(X,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Rt.text,children:[l," ",a||o]})]}),c&&t.jsx("div",{className:Rt.value,children:ee(c)})]})},Vu=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,denom:r},i)=>{const l=s(r),c=o?.find(({id:d})=>d===r)?.price;return t.jsx(ai,{amount:a,asset:l,price:c},i)})},Ku=({changes:e,chain:n})=>{const s=lt(n),{data:o}=_t(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(oi,{metadata:r,chain:n,children:l=>{const c=o?.find(({id:d})=>d===l)?.price;return t.jsx(ai,{amount:a,asset:s(l),price:c})}},i))};function zu(e,n){return typeof n=="bigint"?n.toString():n}const Wu=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,zu)]}),Hu=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=De(),r=Ze(s),{simulateTx:i}=vs(),{data:l}=T.useSuspenseQuery({queryKey:Wu.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:K.SECOND}),c=m=>t.jsxs("div",{className:Rt.root,children:[t.jsx("h2",{className:Rt.title,children:"Estimated changes"}),t.jsx("div",{className:Rt.changes,children:m})]});if(!l)return null;const d=l.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const m=si(d,a),[f]=wa(m);return f.length===0?null:c(t.jsx(Ku,{changes:f,chain:r}))}const u=ni(d,o),[h]=wa(u);return h.length===0?null:c(t.jsx(Vu,{changes:h,chain:r}))};function wa(e){return A.partition(n=>new B(n.amount).isNegative(),e)}const Qu="_title_1d032_1",Gu="_meta_1d032_7",Yu="_footer_1d032_14",Zu="_rejectButton_1d032_19",Gn={title:Qu,meta:Gu,footer:Yu,rejectButton:Zu},ri=()=>{const{txRequest:e,resolve:n,reject:s}=Ar(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:l,spendCoins:c}=e,d=te(),u=xs(),h=Ze(r),m=An(h),f=Vo(h),p=Ko(h),g=lt(h),x=Cr(),y=vr(),b=(e.gasPrices??f).map(({amount:w,denom:E})=>Ke.calculateFee(Math.ceil(i*l),Ke.GasPrice.fromString(w+E))),C=b.map(w=>w.amount[0]),v=w=>{const E=m.find(P=>P.denom===w)?.amount??"0",U=C.find(P=>P.denom===w)?.amount??"0",F=c.filter(P=>P.denom===w).reduce((P,Ne)=>B(P).plus(Ne.amount),B("0")),O=B(U).plus(F),Z=B(E).gte(O),{symbol:H,decimals:R}=g(w);return{symbol:H,decimals:R,spend:F.gt(0)?F.toFixed():null,fee:U,total:O.toFixed(),balance:E,isSufficient:Z}},N=()=>{if(p&&v(p).isSufficient)return p;for(const{denom:w}of C)if(v(w).isSufficient)return w;return C[0]?.denom},[k,$]=_.useState(N),{mutate:q,isPending:V}=T.useMutation({mutationKey:[kr],mutationFn:async()=>{const w=b.find(F=>F.amount[0].denom===k);if(!w)throw new Error("Fee not found");const U=!e.internal&&await x(r,o)?await y(r,d,o,w,a||""):await u(r,d,o,w,a);await n(U)},onError:async w=>{s(w)}}),M=v(k),I=!M.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{children:[t.jsx("h1",{className:Gn.title,children:"Confirm tx"}),t.jsxs("div",{className:Gn.meta,children:[t.jsx(Ws,{title:"Chain",content:r}),t.jsx(Ws,{title:"Tx fee",content:t.jsx(hu,{options:b,value:k,onChange:$})}),a&&t.jsx(Ws,{title:"Memo",content:a}),I&&t.jsx(fe,{level:"error",children:t.jsx(ju,{...M})})]}),t.jsx(Hu,{messages:o,memo:a,chainId:r}),t.jsx(Zd,{list:o,renderHeader:({typeUrl:w})=>hs.sentenceCase(w.split(".").pop().replace(/^Msg/,"")),renderContent:w=>t.jsx(Eu,{message:w,chainId:r})})]}),t.jsxs(xe,{className:Gn.footer,children:[t.jsx(le.Outline,{onClick:()=>s(new Error("User rejected")),disabled:V,className:Gn.rejectButton,children:t.jsx(S.IconClose,{size:16})}),t.jsx(le.White,{onClick:()=>q(),disabled:I,loading:V,children:"Approve"})]})]})},Ju=({children:e})=>{const[{title:n,content:s,path:o},a]=_.useState({}),[r,i]=_.useState(!1),l=W.useAtomValue(ws),c=_.useCallback(h=>{a(h),i(!0)},[]),d=_.useCallback(()=>{a({}),i(!1)},[]),u=_.useCallback(h=>{h||(l?.reject(new Error("User rejected")),a({})),i(h)},[l]);return t.jsxs(Nr.Provider,{value:{openModal:c,closeModal:d},children:[e,t.jsx(ei,{title:n,open:r,onOpenChange:u,children:t.jsx(me,{children:o==="/tx"?t.jsx(ri,{}):s})})]})},Xu="_container_1w1hx_1",em="_toast_1w1hx_11",tm="_info_1w1hx_24",nm="_success_1w1hx_28",sm="_error_1w1hx_32",om="_icon_1w1hx_37",am="_content_1w1hx_45",rm="_title_1w1hx_48",im="_description_1w1hx_53",cm="_close_1w1hx_75",Ct={container:Xu,toast:em,info:tm,success:nm,error:sm,icon:om,content:am,title:rm,description:im,close:cm},lm=({notification:e,onClose:n,...s})=>{const o=rt.useTransition(e,{keys:r=>r?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),a=r=>{switch(r){case"loading":return t.jsx(ct,{size:16});case"info":case"success":return t.jsx(S.IconCheckCircleFilled,{size:16});case"error":return t.jsx(S.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:l,title:c,description:d}=i,u=a(l);return t.jsx(rt.animated.div,{style:r,className:Ct.container,children:t.jsxs("div",{className:L(Ct.toast,l&&Ct[l]),...s,children:[u&&t.jsx("div",{className:Ct.icon,children:u}),t.jsxs("div",{className:Ct.content,children:[t.jsx("p",{className:Ct.title,children:c}),d&&t.jsx("div",{className:Ct.description,children:d})]}),t.jsx("button",{className:Ct.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},Hs=5e3,dm=({children:e})=>{const n=Ot(),[s,o]=_.useState(null),a=_.useRef(null),r=_.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},l=_.useCallback(()=>{i(),o(null)},[]),c=_.useCallback(m=>{i(),o({...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),d=_.useCallback(m=>{i(),o(f=>f?{...f,...m}:{...m,id:da.nanoid()}),m.autoHide&&!r.current&&(a.current=setTimeout(()=>l(),Hs))},[l]),u=()=>{i(),r.current=!0},h=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>l(),Hs))};return _.useEffect(()=>()=>i(),[]),t.jsxs(Zr.Provider,{value:{showNotification:c,updateNotification:d,hideNotification:l},children:[e,n&&ec.createPortal(t.jsx(lm,{notification:s,onClose:l,onMouseEnter:u,onMouseLeave:h}),n)]})},um=({children:e})=>{const[n,s]=_.useState(null);return t.jsx(Is.Provider,{value:{container:n,setContainer:s},children:e})},ii=[{value:10*hr,label:"for 10 minutes"},{value:pr,label:"for 1 hour"},{value:ha,label:"for 1 day"},{value:7*ha,label:"for 7 days"},{value:0,label:"until revoked"}],mm=ii[0].value,hm="_container_1422v_1",pm="_title_1422v_7",fm="_description_1422v_14",gm="_sectionTitle_1422v_20",_m="_websiteInfo_1422v_27",xm="_favicon_1422v_37",ym="_websiteTitle_1422v_42",jm="_websiteHost_1422v_48",bm="_warningContent_1422v_54",wm="_ignoreButton_1422v_61",vm="_infoList_1422v_65",Cm="_infoItem_1422v_75",Nm="_label_1422v_84",Im="_infoValue_1422v_94",km="_durationTrigger_1422v_100",Sm="_durationItem_1422v_101",Am="_featureList_1422v_105",Tm="_featureItem_1422v_113",$m="_checkIcon_1422v_123",Em="_learnMoreLink_1422v_127",qm="_feedbackContainer_1422v_140",Lm="_footer_1422v_146",re={container:hm,title:pm,description:fm,sectionTitle:gm,websiteInfo:_m,favicon:xm,websiteTitle:ym,websiteHost:jm,warningContent:bm,ignoreButton:wm,infoList:vm,infoItem:Cm,label:Nm,infoValue:Im,durationTrigger:km,durationItem:Sm,featureList:Am,featureItem:Tm,checkIcon:$m,learnMoreLink:Em,feedbackContainer:qm,footer:Lm},Mm=ye.createQueryKeys("interwovenkit:account",{info:(e,n)=>({queryKey:[e,n],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${n}`;return s.get(o).json()}})}),Pm=()=>{const[e,n]=_.useState(mm),[s,o]=W.useAtom(Ln),[a,r]=_.useState(!1),i=Ye(),l=de(),{address:c,username:d}=De(),{mutate:u,isPending:h}=Fc(),{closeDrawer:m}=xt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:x,isLoading:y}=T.useQuery(Mm.info(g,c)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},C=l.some($=>{if(!$.website)return!1;const q=va(new URL($.website).hostname),V=va(window.location.hostname);return q===V}),v=()=>{u(e)},N=()=>{s?.reject(new Error("User cancelled")),o(null),m()},k=!C&&!a;return t.jsxs(t.Fragment,{children:[t.jsxs(et,{className:re.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:re.title,children:"Enable auto-signing"}),t.jsx("p",{className:re.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:re.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:re.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:re.websiteTitle,children:b.title}),t.jsx("div",{className:re.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:re.infoList,children:[t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Address"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:j.truncate(d??c)})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Chain"}),t.jsxs("div",{className:re.infoValue,children:[t.jsx(X,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:p})]})]}),t.jsxs("div",{className:re.infoItem,children:[t.jsx("div",{className:re.label,children:"Duration"}),t.jsx(zo,{options:ii,value:e,onChange:n,classNames:{trigger:re.durationTrigger,item:re.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:re.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:re.featureList,children:["Send transactions without confirmation pop-ups","Protected by Privy embedded wallet","Revoke permissions any time in settings"].map($=>t.jsxs("li",{className:re.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:re.checkIcon}),t.jsx("span",{children:$})]},$))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",className:re.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(xe,{className:re.footer,extra:t.jsxs("div",{className:re.feedbackContainer,children:[!y&&!x&&t.jsx(fe,{level:"error",children:"Insufficient balance for fee"}),!C&&!a&&t.jsx(fe,{level:"warning",children:t.jsxs("div",{className:re.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:re.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(le.Outline,{onClick:N,children:"Cancel"}),t.jsx(le.White,{onClick:v,disabled:k||!x||y,loading:h,children:"Enable"})]})]})},Dm=()=>W.useAtomValue(Ln)?t.jsx(Pm,{}):null;function va(e){const n=e.split(".");return n.length<2?e:n.slice(-2).join(".")}const Bm="_container_mqvhs_1",Rm="_badge_mqvhs_5",Ca={container:Bm,badge:Rm},ci=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:L(Ca.container,a),children:[o,!s&&t.jsx("div",{className:Ca.badge,style:{right:n,top:n}})]})},Fm="_header_s7mee_1",Um="_back_s7mee_12",Om="_title_s7mee_24",Qs={header:Fm,back:Um,title:Om},dt=({title:e,backButton:n,extra:s,children:o})=>{const a=dr();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:Qs.header,children:[t.jsx(nn,{to:n??(a.length>1?-1:"/"),className:Qs.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:Qs.title,children:e}),s]}),t.jsx(et,{children:o})]})};function li(){const{initiaAddress:e,hexAddress:n}=De(),s=yt(),o=Dn();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function di(){const e=yt(),n=Dn();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return j.InitiaAddress.validate(s);case"evm":return pt.isAddress(s);case"cosmos":try{return ie.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function Vm(){const e=yt(),n=Dn();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),l=n(i),c=e(a),d=n(c);if(l==="evm"&&d==="initia")return j.InitiaAddress(s).bech32;if(l==="initia"&&d==="evm")return j.InitiaAddress(s).hex;if(l===d)return s;if(r){if(d==="initia")return j.InitiaAddress(r).bech32;if(d==="evm")return j.InitiaAddress(r).hex}return""}}const Km="_root_ekn9t_1",zm="_header_ekn9t_6",Wm="_title_ekn9t_12",Hm="_warning_ekn9t_18",Qm="_content_ekn9t_22",Gm="_footer_ekn9t_26",Ym="_secondary_ekn9t_36",Et={root:Km,header:zm,title:Wm,warning:Hm,content:Qm,footer:Gm,secondary:Ym},ui=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(et,{className:Et.root,children:[t.jsxs("header",{className:L(Et.header,n&&Et[n]),children:[s,t.jsx("h1",{className:Et.title,children:o})]}),t.jsx("div",{className:Et.content,children:a}),t.jsxs("footer",{className:Et.footer,children:[t.jsx(le.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Et.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},Zm="_list_k4n3k_1",Jm="_row_k4n3k_9",Xm="_dt_k4n3k_20",eh="_asset_k4n3k_26",Yn={list:Zm,row:Jm,dt:Xm,asset:eh},th=({list:e,onNavigate:n,onDismiss:s})=>{const o=ae(),a=Ye(),r=lt(o);return t.jsx(ui,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:Yn.list,children:e.toSorted((i,l)=>i.chainId.localeCompare(l.chainId)).map(({txHash:i,chainId:l,amount:c,denom:d})=>{const u=a(l),{decimals:h,symbol:m}=r(d),f=j.formatAmount(c,{decimals:h});return t.jsxs("div",{className:Yn.row,children:[t.jsxs("div",{className:Yn.dt,children:[t.jsx(X,{src:u.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:u.name})]}),t.jsxs("span",{className:Yn.asset,children:[f," ",m]})]},i)})})})};function Gs(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const Zn=({chainId:e,txHash:n})=>`${oe.OP_REMINDER}:${e}:${n}`,nh=tc.atomWithStorage(oe.OP_REMINDER,[]);function dn(){const e=te(),[n=[],s]=W.useAtom(nh),o=_.useMemo(()=>n.map(c=>{const d=localStorage.getItem(Zn(c));return d?JSON.parse(d):null}).filter(c=>{if(!c)return!1;const{recipient:d,claimableAt:u}=c;return d!==e?!1:Ge.isPast(u)}),[e,n]),a=_.useCallback((c,d)=>{n.some(u=>Gs(u,c))||(s((u=[])=>[...u,c]),localStorage.setItem(Zn(c),JSON.stringify(d)))},[n,s]),r=_.useCallback(c=>{s((d=[])=>d.filter(u=>!Gs(u,c))),localStorage.removeItem(Zn(c))},[s]),i=_.useCallback(c=>{const d=c.filter(u=>!n.some(h=>Gs(h,u)));d.length!==0&&s((u=[])=>[...u,...d])},[n,s]),l=_.useCallback((c,d)=>{localStorage.setItem(Zn(c),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:l}}function mi(){const e=Ce(),{openModal:n,closeModal:s}=bs(),{reminders:o,setReminder:a}=dn();_.useEffect(()=>{const r=o.filter(c=>!c.dismissed);if(r.length===0)return;const i=()=>{const c=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:c}),l()},l=()=>{s();for(const c of r)a(c,{...c,dismissed:!0})};n({content:_.createElement(th,{list:r,onNavigate:i,onDismiss:l})})},[o,s,e,n,a])}const sh="_wrapper_5ssm8_1",oh="_balance_5ssm8_11",ah="_button_5ssm8_15",Ys={wrapper:sh,balance:oh,button:ah},hi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:Ys.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:Ys.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:Ys.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),rh="_fieldset_up6fh_1",ih="_upper_up6fh_9",ch="_select_up6fh_14",lh="_account_up6fh_20",dh="_lower_up6fh_25",uh="_wrapper_up6fh_26",mh="_balance_up6fh_33",hh="_value_up6fh_37",ph="_error_up6fh_50",mt={fieldset:rh,upper:ih,select:ch,account:lh,lower:dh,wrapper:uh,balance:mh,value:hh,error:ph},mo=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:l}=e;return t.jsxs("div",{className:mt.fieldset,children:[t.jsxs("div",{className:mt.upper,children:[t.jsx("div",{className:mt.select,children:n}),t.jsx("div",{className:mt.account,children:s})]}),!l&&t.jsxs("div",{className:mt.lower,children:[o,t.jsxs("div",{className:mt.wrapper,children:[t.jsx("div",{className:mt.balance,children:a}),r&&t.jsx("div",{className:mt.value,children:r})]}),i&&t.jsxs("footer",{className:mt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Rn(){const e=_.useRef(null),n=Ns();return _.useEffect(()=>{n||e.current?.focus()},[n]),e}const fh="_input_h8073_1",gh={input:fh};function pi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,l=Rn();return t.jsx(_e.Controller,{name:n,control:s,rules:r,render:({field:c})=>t.jsx(nc.NumericFormat,{value:c.value,getInputRef:Ya.mergeRefs([c.ref,l]),className:L(gh.input,a),onValueChange:d=>{c.onChange(d.value)},onBlur:c.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const _h="_input_19r9r_1",xh="_placeholder_19r9r_18",ho={input:_h,placeholder:xh},yh=({children:e})=>t.jsx("p",{className:L(ho.input,{[ho.placeholder]:B(e).isZero()}),children:e}),In=({balance:e,decimals:n,className:s})=>{const{control:o}=_e.useFormContext(),a={required:"Enter amount",validate:r=>B(r).isZero()?"Enter amount":B(j.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(pi,{name:"quantity",control:o,className:L(ho.input,s),rules:a})};In.ReadOnly=yh;const rn=({title:e,content:n,children:s,className:o})=>{const[a,r]=_.useState(!1),i=()=>r(!1);return t.jsx(ei,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},jh="_tooltip_19kvs_1",bh="_arrow_19kvs_44",Na={tooltip:jh,arrow:bh},Fn=({label:e,children:n,small:s,...o})=>t.jsxs(J.Tooltip.Root,{...o,children:[t.jsx(J.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(J.Tooltip.Portal,{container:Ot(),children:t.jsxs(J.Tooltip.Content,{className:L(Na.tooltip,{small:s}),collisionBoundary:Ot(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(J.Tooltip.Arrow,{className:Na.arrow})]})})]});function Wo(e,n){const s=Xe();return T.useQuery({queryKey:qe.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[n].denoms??{}:{}:{},enabled:!!e,staleTime:K.SECOND})}function wh(e,n,s){const{data:o={}}=Wo(e,n);return A.path([s],o)}const vh=[["d",1440*60],["h",3600],["m",60],["s",1]];function kn(e){if(!e)return;const{formattedParts:n}=vh.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function Ho(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${j.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function po(e,n){const{watch:s}=St(),o=s(),a=Xe(),r=Tn(),i={...o,quantity:e},l=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,c=B(i.quantity||0),d=c.isFinite()&&c.gt(0),u=T.useQueryClient();return T.useQuery({queryKey:qe.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:h,srcDenom:m,quantity:f,dstChainId:p,dstDenom:g}=i,{decimals:x}=u.getQueryData(qe.asset(h,m).queryKey)??{decimals:0},y={amount_in:j.toBaseUnit(f,{decimals:x}),source_asset_chain_id:h,source_asset_denom:m,dest_asset_chain_id:p,dest_asset_denom:g,is_op_withdraw:n?.isOpWithdraw},b=await a.post("v2/fungible/route",{json:y}).json(),C={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return r("Bridge Simulation Success",C),b},enabled:d&&!n?.disabled&&!l,staleTime:K.MINUTE})}function Ch(e){return T.useQuery({queryKey:qe.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null},enabled:!!e})}function Nh(){const{watch:e}=St(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=ze(n),i=Cn(r),l=it(s,n),c=it(a,o),d=ae(),u=de();return i==="initia"&&o===d.chainId&&l.symbol===c.symbol&&u.find(h=>h.chainId===n)?.metadata?.op_denoms?.includes(c.denom)}const Ih="_label_t93ix_1",kh="_wrapper_t93ix_7",Sh="_input_t93ix_10",Ah="_clear_t93ix_18",Jn={label:Ih,wrapper:kh,input:Sh,clear:Ah},Qo=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=j.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,l=Rn(),{control:c,getValues:d,setValue:u,formState:h}=_e.useFormContext(),m=d("recipient"),[f,p]=_.useState(m),g=rr(),{data:x,isLoading:y,error:b}=T.useQuery({queryKey:fs.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:K.MINUTE,enabled:g.validateUsername(f)}),C=x??(o(f)?f:""),v=n&&j.InitiaAddress.equals(C,n),N=async()=>{try{const q=await navigator.clipboard.readText();p(q.trim())}catch{}};_.useEffect(()=>{e==="onChange"&&(!f&&!h.dirtyFields.recipient||u("recipient",x??f,{shouldValidate:!0,shouldDirty:!0}))},[h.dirtyFields.recipient,f,e,u,x]);const k=()=>{y||b||(u("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},$=()=>{if(y)return t.jsx(Jt,{level:"loading",children:"Resolving username..."});if(b)return t.jsx(Jt,{level:"error",children:b.message});if(x)return t.jsx(Jt,{level:"success",className:"monospace",children:x});if(e==="onSubmit"&&f&&!C)return t.jsx(Jt,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:Jn.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(le.Small,{type:"button",tabIndex:-1,onClick:N,children:"Paste"})]}),t.jsxs("div",{className:Jn.wrapper,children:[t.jsx(_e.Controller,{name:"recipient",control:c,rules:{required:"Recipient address is required",validate:q=>o(q)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:L(Jn.input,"monospace"),value:f,onChange:q=>p(q.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?Ya.mergeRefs([i,l]):i})}),!!f&&t.jsx("button",{type:"button",className:Jn.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),$(),v&&t.jsx(Jt,{children:"This is my address"}),e==="onSubmit"&&t.jsx(xe,{extra:(!n||!!C&&!v)&&t.jsx(fe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(le.White,{type:"button",onClick:k,disabled:y||!!b||!C,children:"Apply"})})]})},Th="_scrollable_vgj3r_1",$h="_list_vgj3r_5",Eh="_item_vgj3r_9",qh="_name_vgj3r_22",Xn={scrollable:Th,list:$h,item:Eh,name:qh};function fi({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:l}=s;return t.jsx(et,{className:Xn.scrollable,children:t.jsx("div",{className:Xn.list,children:n.map(c=>t.jsxs("button",{className:Xn.item,onClick:()=>e(c),disabled:i?.(c)||l?.(c),children:[t.jsx(X,{src:o(c),width:28,height:28}),t.jsx("span",{className:Xn.name,children:a(c)}),i?.(c)&&t.jsx(ct,{size:16})]},r(c)))})})}function As(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(o=>o.name===s)}}const Lh="_account_h04x1_8",Mh="_clear_h04x1_28",Ph="_white_h04x1_39",pn={account:Lh,clear:Mh,white:Ph},Ia=({type:e})=>{const{watch:n,setValue:s}=St(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),l=n(e==="src"?"sender":"recipient"),c=Cn(ze(a)),{list:d,find:u}=As(),h=u(r),m=li(),f=di(),p=m(a),g=j.InitiaAddress.equals(l,p),x=()=>t.jsx(rn,{title:"Connect wallet",content:C=>t.jsx(fi,{onSelect:async v=>{const N=v.getProvider();if(!N)return window.open(v.fallbackUrl,"_blank");const k=N.getOfflineSigner(o),[{address:$}]=await k.getAccounts();s("sender",$),s("cosmosWalletName",v.name),C()},list:d,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:L(pn.account,{[pn.white]:!l}),children:l?t.jsxs(t.Fragment,{children:[h&&t.jsx(X,{src:h.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:j.truncate(l)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=C=>t.jsx(rn,{title:"Recipient",content:v=>t.jsx(et,{children:t.jsx(Qo,{mode:"onSubmit",myAddress:p,chainType:c,validate:N=>f(N,a),onApply:v})}),className:pn.account,children:C}),b=()=>{switch(c){case"initia":case"evm":return g?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:pn.account,children:[t.jsx("span",{className:"monospace",children:j.truncate(l)}),t.jsx("button",{type:"button",className:pn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(S.IconCloseCircleFilled,{size:14})})]});case"cosmos":return y(t.jsxs(t.Fragment,{children:[l?t.jsx("span",{className:"monospace",children:j.truncate(l)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return x();case"dst":return b()}},Dh="_images_cj4xz_1",Zs={images:Dh},Ts=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:L(Zs.images,r),style:{position:"relative"},children:[t.jsx(X,{src:e,width:n,height:n,className:Zs.asset,logo:!0}),t.jsx(X,{src:s,width:o,height:o,className:Zs.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Bh="_root_6187w_1",Rh="_content_6187w_10",Fh="_details_6187w_20",Uh="_symbol_6187w_26",Oh="_chain_6187w_34",Vh="_chevron_6187w_43",qt={root:Bh,content:Rh,details:Fh,symbol:Uh,chain:Oh,chevron:Vh},gi=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:qt.content,children:[t.jsx(Ts,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:qt.details,children:[t.jsx("div",{className:qt.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:qt.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:qt.root,children:o}):t.jsxs("div",{className:qt.root,children:[o,t.jsx(S.IconChevronDown,{size:16,className:qt.chevron})]})};function Kh(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return A.any(A.includes(n.toLowerCase()),a)})}const zh="_root_1sh27_1",Wh="_label_1sh27_8",Hh="_input_1sh27_21",Qh="_hasValue_1sh27_31",Gh="_clear_1sh27_35",fn={root:zh,label:Wh,input:Hh,hasValue:Qh,clear:Gh},Un=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:L(fn.root,n,{[fn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:fn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:fn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:fn.clear,"aria-label":"Clear search",onMouseDown:l=>l.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},Yh="_container_5tajg_1",Zh="_search_5tajg_7",Jh="_list_5tajg_11",Xh="_item_5tajg_15",ep="_logo_5tajg_37",tp="_info_5tajg_41",np="_symbol_5tajg_47",sp="_name_5tajg_56",op="_balance_5tajg_62",ap="_value_5tajg_69",Ve={container:Yh,search:Zh,list:Jh,item:Xh,logo:ep,info:tp,symbol:np,name:sp,balance:op,value:ap},On=e=>{const{assets:n,onSelect:s,renderAsset:o=(l,c)=>c(l)}=e,[a,r]=_.useState(""),i=Kh(["symbol"],a,n);return t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{value:a,onChange:l=>r(l.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:Ve.search,padding:20,ref:Rn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:Ve.list,children:i.map(l=>t.jsx("button",{type:"button",className:Ve.item,onClick:()=>s(l.denom),children:o(l,c=>{const{denom:d,logoUrl:u,symbol:h,name:m,balance:f,decimals:p,value:g=0}=c;return t.jsxs(t.Fragment,{children:[t.jsx(X,{src:u,width:32,height:32,className:Ve.logo,logo:!0}),t.jsxs("div",{className:Ve.info,children:[t.jsx("div",{className:Ve.symbol,children:h||d}),t.jsx("div",{className:Ve.name,children:m})]}),t.jsxs("div",{className:Ve.balance,children:[f&&t.jsx("div",{children:j.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:Ve.value,children:ee(g)})]})]})})},l.denom))})]})},rp=()=>t.jsxs("div",{className:Ve.container,children:[t.jsx(Un,{rootClassName:Ve.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});On.Placeholder=rp;const ip="_stack_16oqn_1",cp="_title_16oqn_9",lp="_grid_16oqn_16",dp="_item_16oqn_22",up="_button_16oqn_26",mp="_active_16oqn_44",Xt={stack:ip,title:cp,grid:lp,item:dp,button:up,active:mp},Ft=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:Xt.title,children:e}),t.jsx("div",{className:Xt.grid,children:n.map(({chainId:r,name:i,logoUrl:l})=>t.jsx(ci,{offset:-2,disabled:!a?.(r),className:Xt.item,children:t.jsx(Fn,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:L(Xt.button,{[Xt.active]:r===s}),onClick:()=>o(r),children:t.jsx(X,{src:l,width:28,height:28,logo:!0})})})},r))})]}),hp=({children:e})=>t.jsx("div",{className:Xt.stack,children:e});Ft.Stack=hp;const pp=({address:e,chain:n,onSelect:s})=>{const o=is(n.chain_id),{data:a={}}=Wo(e,n.chain_id);return t.jsx(On,{assets:A.sortWith([A.descend(r=>r.symbol==="INIT"),A.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>B(i).comparedTo(r)??0,A.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:l=j.truncate(i),logo_uri:c}=r,d=a[i]??{};return{...r,symbol:l,decimals:r.decimals??0,logoUrl:c??"",name:r.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},fp=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=kt(),i=Bn(),{watch:l,setValue:c}=St(),d=l(a),u=l(s),h=l(o),[m,f]=_.useState(u),p=ze(m),g=Vm(),x=zr(),[y,b]=A.partition(v=>x(v.chain_id),i.filter(v=>!v.hidden)),C=v=>{if(u===m&&h===v){n();return}c(s,m),c(o,v),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Ft.Stack,{children:[t.jsx(Ft,{label:"Interwoven Economy",chains:y.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f}),t.jsx(Ft,{label:"Chains",chains:b.map(({chain_id:v,chain_name:N,pretty_name:k,logo_uri:$})=>({chainId:v,name:k||N,logoUrl:$??""})),value:m,onSelect:f})]}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(pp,{address:g({initialAddress:d,initialChainId:u,chainId:m,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:C})},m)]})},ka=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=St(),r=a(n),i=a(s),l=ze(r),c=it(i,r);return t.jsx(rn,{title:o,content:d=>t.jsx(fp,{type:e,afterSelect:d}),children:t.jsx(gi,{asset:{denom:c.denom,decimals:c.decimals??0,symbol:c.symbol,logoUrl:c.logo_uri??""},chain:{chainId:l.chain_id,name:l.pretty_name||l.chain_name,logoUrl:l.logo_uri??""}})})},gp="_skeleton_1l4jn_1",_p={skeleton:gp},Ut=({width:e="100%",height:n})=>t.jsx("div",{className:_p.skeleton,style:{width:e,height:n}}),xp="_stack_oq1ir_1",yp="_button_oq1ir_6",jp="_isLoading_oq1ir_19",bp="_disabled_oq1ir_19",wp="_checked_oq1ir_23",vp="_header_oq1ir_37",Cp="_title_oq1ir_43",Np="_duration_oq1ir_52",Ip="_warning_oq1ir_62",kp="_amount_oq1ir_66",Sp="_value_oq1ir_67",Oe={stack:xp,button:yp,isLoading:jp,disabled:bp,checked:wp,header:vp,title:Cp,duration:Np,warning:Ip,amount:kp,value:Sp},Ap=({children:e})=>t.jsx("div",{className:Oe.stack,children:e}),os=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:l}=St(),{dstChainId:c,dstDenom:d}=l(),u=it(d,c),h=!i&&a.checked,m=!i&&!r;return t.jsxs("button",{type:"button",className:L(Oe.button,{[Oe.isLoading]:i,[Oe.disabled]:m,[Oe.checked]:h}),onClick:()=>{i||m||o(s)},children:[t.jsxs("div",{className:Oe.header,children:[t.jsxs("div",{className:Oe.title,children:[t.jsx("span",{children:e}),h&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(Ut,{width:80,height:16}):r?t.jsxs("div",{className:L(Oe.duration,{[Oe.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:kn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:Oe.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Oe.amount,children:i?t.jsx(Ut,{width:260,height:40}):r?j.formatAmount(r.amount_out,{decimals:u.decimals}):null}),t.jsx("div",{className:Oe.value,children:i?t.jsx(Ut,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};os.Stack=Ap;const Tp="_description_nuyvt_1",$p="_presets_nuyvt_8",Ep="_preset_nuyvt_8",qp="_active_nuyvt_29",Lp="_custom_nuyvt_40",Mp="_wrapper_nuyvt_47",Pp="_percent_nuyvt_58",ot={description:Tp,presets:$p,preset:Ep,active:qp,custom:Lp,wrapper:Mp,percent:Pp},Sa=["0.1","0.5","1.0"],Dp=({afterConfirm:e})=>{const n=St(),s=n.getValues("slippagePercent"),[o,a]=_.useState(null),{control:r,watch:i,getValues:l,setValue:c}=_e.useForm({defaultValues:{value:s}}),d=i("value");_.useEffect(()=>{const g=Sa.findIndex(x=>x===s);a(g>=0?g:null)},[s]);const u=(g,x)=>{c("value",g),a(x)},h=()=>{a(null)},m=_.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=m?.type==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(et,{children:[t.jsx("p",{className:ot.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:ot.presets,children:[Sa.map((g,x)=>t.jsxs("button",{type:"button",className:L(ot.preset,{[ot.active]:o===x}),onClick:()=>u(g,x),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:L(ot.preset,ot.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:ot.wrapper,children:[t.jsx(pi,{name:"value",control:r,dp:2,onFocus:h,placeholder:"",className:L(ot.preset,ot.active)}),t.jsx("span",{className:ot.percent,children:"%"})]})]}),m&&t.jsx(fe,{level:m.type,children:m.text}),t.jsx(xe,{children:t.jsx(le.White,{type:"button",onClick:()=>p(l()),disabled:f,children:"Confirm"})})]})},Bp="_form_1owk5_1",Rp="_arrow_1owk5_5",Fp="_divider_1owk5_14",Up="_flip_1owk5_23",Op="_meta_1owk5_41",Vp="_row_1owk5_54",Kp="_title_1owk5_60",zp="_description_1owk5_64",Wp="_icon_1owk5_71",Hp="_edit_1owk5_76",Qp="_warning_1owk5_99",Me={form:Bp,arrow:Rp,divider:Fp,flip:Up,meta:Op,row:Vp,title:Kp,description:zp,icon:Wp,edit:Hp,warning:Qp},Gp=()=>{const e=Ce(),n=Ns(),[s,o]=Le.useLocalStorage(oe.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:l}=St(),c=a(),{srcChainId:d,srcDenom:u,dstChainId:h,dstDenom:m,quantity:f,sender:p,slippagePercent:g}=c,x=Ye(),y=ze(d),b=Cn(y),C=ze(h),v=Cn(C),N=it(u,d),k=it(m,h),{data:$}=Wo(p,d),q=wh(p,d,u),V=!q?.amount||B(q.amount).isZero(),[M]=Le.useDebounceValue(f,300),I=b!=="initia"&&v!=="initia",w=Nh(),E=po(M,{disabled:I}),U=po(M,{isOpWithdraw:!0,disabled:!w}),F=w&&s==="op",O=F?U:E,Z=F?E:U,H=F?!I:w,R=O.error&&H?Z:O,{data:P,isLoading:Ne,isFetching:je,error:tt}=R,{data:Be}=Ch(tt),Wt=M&&(Ne||je),un=()=>{r("srcChainId",h),r("srcDenom",m),r("dstChainId",d),r("dstDenom",u),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:Kn,closeModal:zn}=bs(),nt=i(ne=>{if(P?.warning){const{type:Tt="",message:Ms}=P.warning??{};Kn({content:t.jsx(ui,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:hs.sentenceCase(Tt),primaryButton:{label:"Cancel",onClick:zn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:P,values:ne}),zn()}},children:t.jsx("p",{className:Me.warning,children:Ms})})});return}e("/bridge/preview",{route:P,values:ne})}),Re=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[P]),bt=_.useMemo(()=>P?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[P]),Ht=_.useMemo(()=>{for(const ne of bt){const Tt=$?.[ne.origin_asset.denom]?.amount??"0",Ms=P?.source_asset_denom===ne.origin_asset.denom?P.amount_in:"0";if(B(Tt).lt(B(Ms).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[$,P,bt]),Wn=_.useMemo(()=>{if(!c.sender)return"Connect wallet";if(!c.quantity||!M)return"Enter amount";if(!c.recipient)return"Enter recipient address";if(l.errors.quantity)return l.errors.quantity.message;if(!P)return"Route not found";if(Ht)return Ht},[M,Ht,l,P,c]),Wi=P?j.formatAmount(P.amount_out,{decimals:k.decimals}):"0",Hi=B(f).gt(0)&&B(f).isEqualTo(j.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),Qi=(()=>{switch(b){case"initia":return x(d).fees.fee_tokens.some(({denom:ne})=>ne===u);case"cosmos":return y.fee_assets.some(({denom:ne})=>ne===u);case"evm":return!pt.isAddress(u);default:return!1}})(),Ls=_.useCallback((ne,Tt)=>ne.length?t.jsxs("div",{className:Me.description,children:[Ho(ne),!n&&t.jsx(Fn,{label:Tt,children:t.jsx("span",{className:Me.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Hn=B(f).gt(0)&&w&&E.data&&U.data&&U.data.estimated_route_duration_seconds>E.data.estimated_route_duration_seconds,aa=_.useMemo(()=>P?[{condition:!!P.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Ls(Re,"Fee deducted from the amount you receive"),Ls(bt,"Fee charged in addition to the amount you enter")]})},{condition:!Hn&&!!kn(P.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Me.description,children:kn(P.estimated_route_duration_seconds)})},{condition:P.does_swap,title:"Slippage",content:t.jsxs("span",{className:Me.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(rn,{title:"Slippage tolerance",content:ne=>t.jsx(Dp,{afterConfirm:ne}),className:Me.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(ne=>ne.condition):[],[bt,Re,Ls,P,Hn,g]);return t.jsxs("form",{className:Me.form,onSubmit:nt,children:[t.jsx(mo,{selectButton:t.jsx(ka,{type:"src"}),accountButton:b==="cosmos"&&t.jsx(Ia,{type:"src"}),quantityInput:t.jsx(In,{balance:q?.amount,decimals:N?.decimals}),balanceButton:t.jsx(hi,{onClick:()=>r("quantity",j.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:V,children:j.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:P?ee(P.usd_amount_in):"$-"}),t.jsxs("div",{className:Me.arrow,children:[t.jsx("div",{className:Me.divider}),t.jsx("button",{type:"button",className:Me.flip,onClick:()=>un(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(mo,{selectButton:t.jsx(ka,{type:"dst"}),accountButton:t.jsx(Ia,{type:"dst"}),quantityInput:t.jsx(In.ReadOnly,{children:Wi}),value:P?ee(P.usd_amount_out):"$-",hideNumbers:Hn}),t.jsx(Nn,{children:Hn?t.jsxs(os.Stack,{children:[t.jsx(os,{label:"Fast",query:E,value:"default",onSelect:o,checked:s==="default"}),t.jsx(os,{label:"Lossless",query:U,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(xe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(fe.Stack,{children:[P?.extra_infos?.map(ne=>t.jsx(fe,{level:"info",children:ne},ne)),Be&&t.jsx(fe,{level:"info",children:Be}),Hi&&Qi&&t.jsx(fe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),P?.warning&&t.jsx(fe,{level:"warning",children:P.warning.message}),P?.extra_warnings?.map(ne=>t.jsx(fe,{level:"warning",children:ne},ne))]}),t.jsx(Nn,{children:aa.length>0&&t.jsx("div",{className:Me.meta,children:aa.map((ne,Tt)=>t.jsxs("div",{className:Me.row,children:[t.jsx("span",{className:Me.title,children:ne.title}),ne.content]},Tt))})})]}),children:t.jsx(le.White,{loading:Wt&&"Simulating...",disabled:!!Wn,children:Wn??"Preview route"})})]})},Yp=()=>{mi();const e=dr(),n=Ce(),s=kt(),o=Sl(),a=_e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:l,dstChainId:c,srcDenom:d,dstDenom:u,quantity:h,slippagePercent:m,recipient:f}=r();r((w,{name:E})=>{(E==="srcChainId"||E==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=li(),g=p(l),x=p(c),b=di()(f,c);_.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[l,g,i]),_.useEffect(()=>{b||i("recipient",x)},[x,b,i]);const{showNotification:C}=Ss(),v=ze(l),N=ze(c),k=is(l),$=is(c),q=k.some(w=>w.denom===d),V=$.some(w=>w.denom===u);_.useEffect(()=>{k.length>0&&!q&&(i("srcDenom",k[0].denom),C({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[k,q,i,C,v.pretty_name]),_.useEffect(()=>{$.length>0&&!V&&(i("dstDenom",$[0].denom),C({type:"info",title:`Switched to ${$[0].symbol}`,description:`The selected asset is not available on ${N.pretty_name}.`,autoHide:!0}))},[$,V,i,C,N.pretty_name]),_.useEffect(()=>{!q||!V||(localStorage.setItem(oe.BRIDGE_SRC_CHAIN_ID,l),localStorage.setItem(oe.BRIDGE_SRC_DENOM,d),localStorage.setItem(oe.BRIDGE_DST_CHAIN_ID,c),localStorage.setItem(oe.BRIDGE_DST_DENOM,u),localStorage.setItem(oe.BRIDGE_QUANTITY,h),localStorage.setItem(oe.BRIDGE_SLIPPAGE_PERCENT,m))},[l,d,c,u,h,m,q,V]);const M=e[0].path==="/bridge",{reminders:I}=dn();return t.jsx(dt,{title:"Bridge/Swap",backButton:M?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(le.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(ci,{offset:0,disabled:I.length===0,children:t.jsx(le.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:q&&V&&t.jsx(_e.FormProvider,{...a,children:t.jsx(me,{children:t.jsx(Gp,{})})})})},Zp="_button_1crvp_1",Jp="_checkbox_1crvp_11",Xp="_checked_1crvp_25",es={button:Zp,checkbox:Jp,checked:Xp},ef=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:L(es.button,o),onClick:n,children:[t.jsx("div",{className:L(es.checkbox,{[es.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:es.label,children:s})]}),tf="_button_aoxv2_1",nf={button:tf},_i=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=sc.useInView();return _.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:nf.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function xi(e,n){return e.reduce((s,o)=>{const a=n(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const as=({chainId:e,txHash:n})=>`${oe.BRIDGE_HISTORY}:${e}:${n}`,ds=100,Aa=10;function yi(){const[e,n]=Le.useLocalStorage(oe.BRIDGE_HISTORY,[]),s=_.useCallback((a,r)=>{localStorage.setItem(as(a),JSON.stringify(r));for(const i of e.slice(ds-1))localStorage.removeItem(as(i));n((i=[])=>[a,...i.slice(0,ds-1)])},[e,n]),o=_.useCallback(a=>{const r=localStorage.getItem(as(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function ji(e){return Le.useLocalStorage(as(e),null)}const zt=ye.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function $s(){const{restUrl:e}=ae();return _.useMemo(()=>z.create({prefixUrl:e}),[e])}function sf(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Ta=20;function of(e){const n=te();return T.useSuspenseInfiniteQuery({queryKey:zt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Ta,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=A.last(s)?.sequence;return s.length<Ta||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function af(e){const n=$s(),{data:s}=T.useSuspenseQuery({queryKey:zt.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:K.SECOND});return s}function rf({bridge_id:e,output_index:n}){const s=$s(),{data:o}=T.useSuspenseQuery({queryKey:zt.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:K.SECOND});return o}function cf({bridge_id:e,sequence:n}){const o=de().find(({metadata:c})=>c?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Ye()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:l}=T.useSuspenseQuery({queryKey:zt.outputResponse(i,n).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:K.SECOND});return l}function bi(e,n){const{bridge_id:s}=e,o=$s(),{data:a}=T.useSuspenseQuery({queryKey:zt.withdrawalClaimed(s,n).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:K.SECOND});return a}function gn(e){return oc.sha3_256.create().update(e).digest()}function Js(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function wi(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=Js(n.toString(),8),l=Js(s.toString(),8),c=Js(o.amount,8),d=Dt.concatBytes(i,l,gn(Dt.utf8ToBytes(a)),gn(Dt.utf8ToBytes(r)),gn(Dt.utf8ToBytes(o.denom)),c);return gn(gn(d))}async function lf(e,n,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${n}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function df(e,n){const s=z.create({prefixUrl:n}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function fo(e,n){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(l){if(A.path(["error","code"],l)!==4902)throw l;if(!r)throw new Error(`Fee asset is not defined for chain: ${a}`);await e.send("wallet_addEthereumChain",[{chainId:`0x${Number(o).toString(16)}`,chainName:a,nativeCurrency:r,rpcUrls:[i]}]),await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}}function jt(){return Je()}function uf(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ce(),{showNotification:r,updateNotification:i,hideNotification:l}=Ss(),{addHistoryItem:c}=yi(),d=Tn(),{route:u,values:h}=jt(),{srcChainId:m,sender:f,recipient:p,cosmosWalletName:g}=h,x=jr(),{requestTxSync:y,submitTxSync:b,waitForTxConfirmation:C}=De(),{find:v}=As(),N=$n(),k=En(),$=ze(m),q=Cn($),V=Wr(m),M=T.useQueryClient(),{registryUrl:I}=Y(),w=Ye(),E=ae(),{addReminder:U}=dn(),F=Xe();return T.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const O=e.cosmos_tx.msgs.map(({msg_type_url:nt,msg:Re})=>{if(!(nt&&Re))throw new Error("Invalid transaction data");return k.fromAmino({type:sn.aminoConverters[nt].aminoType,value:JSON.parse(Re)})});if(q==="initia"){const{srcDenom:nt,quantity:Re}=h,{decimals:bt}=V(nt),Ht=s?await b({messages:O,chainId:m,fee:s}):await y({messages:O,chainId:m,internal:1,spendCoins:[{denom:nt,amount:j.toBaseUnit(Re,{decimals:bt})}]}),Wn=C({txHash:Ht,chainId:m});return{txHash:Ht,wait:Wn}}const Z=v(g)?.getProvider();if(!Z)throw new Error("Wallet not connected");const H=Z.getOfflineSignerOnlyAmino(m),R=await Ke.SigningStargateClient.connectWithSigner($.rpc,H,{registry:N,aminoTypes:k}),P=await R.getAllBalances(f),Ne=$.fee_assets.find(nt=>P.some(Re=>Re.denom===nt.denom&&B(Re.amount).gt(0)));if(!Ne){const Re=["Insufficient balance for fees.",`Available fee assets: ${$.fee_assets.map(bt=>V(bt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Re)}const{denom:je,gas_price:tt}=Ne;if(!tt)throw new Error(`Gas price not found for ${je}`);const Be=await R.simulate(f,O,""),Wt=Ke.GasPrice.fromString(tt.average+je),un=Ke.calculateFee(Math.ceil(Be*on),Wt),Kn=await R.signAndBroadcastSync(f,O,un),zn=Tr({txHash:Kn,client:R});return{txHash:Kn,wait:zn}}if("evm_tx"in e){const{chain_id:O,to:Z,value:H,data:R}=e.evm_tx,P=await x(),Ne=await P.getSigner();await fo(P,$);const je=await Ne.sendTransaction({chainId:O,to:Z,value:H,data:`0x${R}`});return{txHash:je.hash,wait:je.wait()}}throw new Error("Unlisted chain type")}catch(O){throw await ft(O)}},onSuccess:async({txHash:O,wait:Z})=>{localStorage.removeItem(oe.BRIDGE_QUANTITY),o?o({txhash:O,chainId:m,timestamp:Date.now(),success:!0,route:u,values:h}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Z;const H=Go(u)==="OP Bridge withdrawal",R=H?{success:!0,error:null}:await gf(F,O,m);if(!o&&!R.success&&R.error){const Be=R.error instanceof Error?R.error.message:String(R.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Be}. The transaction may still be processing.`,autoHide:!0})}const P=R.success,je=pf({txHash:O,srcChainId:m,route:u,values:h,recipient:p},P);c(je.tx,je.details),o||i(hf(l));const tt=Xs(h,O);if(d("Bridge Transaction Success",tt),H){const Be=w(m).metadata?.op_bridge_id;if(Be&&!await lf(E.restUrl,Number(Be),u.dest_asset_denom)){const un=ff(je.tx,u,p);U(je.tx,un)}}}catch(H){const R=H instanceof Error?H.message:String(H);o?o({success:!1,error:R,route:u,values:h}):i({type:"error",title:"Transaction not confirmed",description:R});const P={...Xs(h,O),error:R};d("Bridge Confirmation Failed",P)}finally{M.invalidateQueries({queryKey:qe.balances(m,f).queryKey})}},onError:async O=>{const Z=q==="initia"?await Zt(O,w(m),I):O;o?o({success:!1,error:Z.message,route:u,values:h}):r({type:"error",title:"Transaction failed",description:Z.message});const H=Xs(h);d("Bridge Transaction Failed",{...H,error:Z.message})}})}function mf(){const e=Xe(),n=te(),s=xs(),{route:o,values:a}=jt(),r=yt();return T.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:l}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:j.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await df(n,r(o.dest_asset_chain_id).rest);const c=l.map(({msg_type_url:h,msg:m})=>sn.aminoTypes.fromAmino({type:sn.aminoConverters[h].aminoType,value:JSON.parse(m)})),d=await s(i,n,c,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=It.Tx.fromPartial({body:It.TxBody.decode(d.bodyBytes),authInfo:It.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:ie.toBase64(It.Tx.encode(u).finish())}}catch(i){throw await ft(i)}}})}function hf(e){return{type:"info",title:"Transaction submitted",description:_.createElement(_.Fragment,null,"Check ",_.createElement(nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Xs(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function pf(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},l=Go(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:l?"success":void 0,tracked:n},isOpWithdraw:l}}function ff(e,n,s){return{...e,recipient:j.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function gf(e,n,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await ft(i)};await new Promise(l=>setTimeout(l,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function vi(e){const{chainId:n,txHash:s,tracked:o}=e,a=Xe();return T.useQuery({queryKey:qe.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(r){throw await ft(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Ci(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=Xe();return T.useQuery({queryKey:qe.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:l}})=>{if(!l)return!1;const{status:c}=l;if(c==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),h=Math.floor((d-u)/1e3);return h<=0?1e3:h<=300?5e3:60*1e3},staleTime:K.INFINITY})}var rs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(rs||{});function Go(e){const{operations:n,dest_asset_denom:s}=e;return A.has("op_init_transfer",A.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const _f="_success_t4dfk_1",xf="_error_t4dfk_5",$a={success:_f,error:xf},yf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Ci(n),a=n.state??jf(o);switch(_.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:$a.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:$a.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(ct,{size:14})}};function jf(e){if(!e)return"loading";switch(e.state){case"STATE_ABANDONED":case"STATE_COMPLETED_ERROR":case"STATE_PENDING_ERROR":return"error";case"STATE_COMPLETED_SUCCESS":return"success";default:return"loading"}}const bf="_link_104m3_1",wf="_header_104m3_23",vf="_title_104m3_31",Cf="_date_104m3_37",Nf="_explorer_104m3_41",If="_fees_104m3_57",kf="_label_104m3_65",Sf="_content_104m3_69",Af="_route_104m3_75",Tf="_row_104m3_80",$f="_asset_104m3_86",Ef="_amount_104m3_94",qf="_chain_104m3_99",Lf="_account_104m3_108",Mf="_arrow_104m3_115",be={link:bf,header:wf,title:vf,date:Cf,explorer:Nf,fees:If,label:kf,content:Sf,route:Af,row:Tf,asset:$f,amount:Ef,chain:qf,account:Lf,arrow:Mf},Pf=({tx:e})=>{const[n,s]=ji(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:l,tracked:c}=n,{data:d}=vi(n),{address:u="",connector:h}=ve.useAccount(),{find:m}=As();_.useEffect(()=>{d&&s(F=>{if(!F)throw new Error("Bridge history details not found");return{...F,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:x,dest_asset_chain_id:y,dest_asset_denom:b,estimated_fees:C=[]}=r,v=ze(g),N=ze(y),k=it(x,g),$=it(b,y),q=(F,O)=>O?t.jsx(X,{src:O,width:12,height:12}):j.InitiaAddress.equals(F,u)?t.jsx(X,{src:h?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),V=(F,{symbol:O,decimals:Z,logo_uri:H},{chain_name:R,pretty_name:P,...Ne},je,tt)=>t.jsxs("div",{className:be.row,children:[t.jsx(Ts,{assetLogoUrl:H,chainLogoUrl:Ne.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:j.formatAmount(F,{decimals:Z})}),t.jsx("span",{children:O})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",P||R]}),t.jsxs("div",{className:be.account,children:[tt,t.jsx("span",{className:"monospace",children:j.truncate(je)})]})]})]})]}),M=Go(r),I=_.useMemo(()=>{switch(M){case rs.SKIP:return"Skip Explorer";case rs.OP_WITHDRAW:return"Initia Scan"}},[M]),w=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[c?t.jsx(yf,{tx:e}):t.jsx(ct,{size:14}),t.jsx("div",{className:be.date,children:Ge.format(new Date(l),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:I}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[V(f,k,v,i.sender,q(i.sender,m(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),V(p,$,N,i.recipient,q(i.recipient))]}),C.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:Ho(C)})]})]});if(M===rs.OP_WITHDRAW)return t.jsx(ks,{chainId:o,txHash:a,className:be.link,children:w});const E=new URLSearchParams({tx_hash:a,chain_id:o}),U=new URL(`?${E.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:U.toString(),className:be.link,target:"_blank",children:w})},Df="_history_13u9z_1",Bf="_header_13u9z_5",Rf="_checkbox_13u9z_9",Ff="_groups_13u9z_13",Uf="_dateGroup_13u9z_21",Of="_dateHeader_13u9z_26",Vf="_list_13u9z_32",Lt={history:Df,header:Bf,checkbox:Rf,groups:Ff,dateGroup:Uf,dateHeader:Of,list:Vf},Kf=()=>{const{initiaAddress:e,hexAddress:n}=De(),{history:s,getHistoryDetails:o}=yi(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:x,recipient:y}=g;return[x,y].some(b=>[e,n].includes(b))}),[i,l]=_.useState(1),[c,d]=Le.useToggle(!r.length),u=c?a:r,h=u.slice(0,i*Aa),m=_.useMemo(()=>xi(h,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[h,o]);return t.jsx(dt,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Lt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Lt.header,children:t.jsx(ef,{checked:c,onClick:d,label:"Show all transactions stored in this browser",className:Lt.checkbox})}),u.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:Lt.groups,children:Object.entries(m).map(([f,p])=>t.jsxs("div",{className:Lt.dateGroup,children:[t.jsx("div",{className:Lt.dateHeader,children:f}),t.jsx("div",{className:Lt.list,children:p.map(g=>t.jsx(me,{children:t.jsx(Pf,{tx:g})},g.txHash))})]},f))}),u.length>i*Aa?t.jsx(_i,{onClick:()=>l(f=>f+1)}):s.length>=ds&&t.jsxs(he,{children:["Only the latest ",ds," items are stored. Older entries will be removed automatically."]})]})})},Yo=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=uf(e,{customFee:n,onCompleted:s});return t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>r(),loading:i&&"Signing transaction...",disabled:!!a,children:a||o||"Confirm"})})},zf="_content_1hzj2_1",Wf="_info_1hzj2_6",Hf="_arrow_1hzj2_11",Qf="_divider_1hzj2_19",Gf="_type_1hzj2_27",Yf="_asset_1hzj2_47",Zf="_amount_1hzj2_55",Jf="_lower_1hzj2_60",Xf="_chain_1hzj2_66",eg="_address_1hzj2_72",Ue={content:zf,info:Wf,arrow:Hf,divider:Qf,type:Gf,asset:Yf,amount:Zf,lower:Jf,chain:Xf,address:eg},Ni=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:l}=e,{symbol:c=j.truncate(a),decimals:d=0,logo_uri:u=No}=e,{chain_name:h,pretty_name:m,...f}=ze(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:Ue.arrow,children:[t.jsx("div",{className:Ue.divider}),s?t.jsx(Fn,{label:s,children:t.jsx("button",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:Ue.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:Ue.divider})]}),t.jsxs("div",{className:Ue.content,children:[t.jsx(Ts,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:Ue.info,children:[t.jsxs("div",{className:Ue.asset,children:[t.jsx("span",{className:Ue.amount,children:j.formatAmount(o,{decimals:d})}),t.jsx("span",{children:c})]}),t.jsxs("div",{className:Ue.lower,children:[t.jsxs("div",{className:Ue.chain,children:["on ",m||h]}),i&&t.jsx(cs,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:Ue.address,onClick:p,children:[l,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:j.truncate(i)})]})})]})]})]})]})},en=e=>{const n=it(e.denom,e.chainId);return t.jsx(Ni,{...e,...n})};en.Placeholder=Ni;const tg="_root_1hbar_1",ng="_flexEnd_1hbar_6",sg="_toggle_1hbar_11",og="_route_1hbar_36",ag="_content_1hbar_43",_n={root:tg,flexEnd:ng,toggle:sg,route:og,content:ag};function rg(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":hs.capitalCase(A.head(s?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const s=e.swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const s=e.evm_swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const ig=({addressList:e})=>{const{values:n,route:s}=jt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,l=A.zipObj(s.required_chain_addresses,e),{find:c}=As(),{connector:d,address:u=""}=ve.useAccount(),[h,m]=Le.useToggle(!1),f=i.length>1,p=t.jsx(X,{src:n.cosmosWalletName?c(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:p},x=N=>j.InitiaAddress.equals(N,u)?p:t.jsx(S.IconWallet,{size:11}),y=N=>{const{label:k,amount_out:$,denom:q,denom_out:V=q,chain_id:M,from_chain_id:I,to_chain_id:w=M??I}=N,E=l[w];return{label:f&&!h?void 0:k,amount:$,denom:V,chainId:w,address:E,walletIcon:x(E)}},b=i.map(rg).map(y),C=b.slice(0,-1),v=b[b.length-1];return t.jsxs(J.Collapsible.Root,{className:_n.root,open:h,onOpenChange:m,children:[f&&t.jsx("div",{className:_n.flexEnd,children:t.jsx(J.Collapsible.Trigger,{className:_n.toggle,children:h?t.jsxs(t.Fragment,{children:[t.jsx(S.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(S.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:_n.route,children:[t.jsx(en,{...g,source:!0}),t.jsx(J.Collapsible.Content,{className:_n.content,children:C.map((N,k)=>t.jsx(me,{suspenseFallback:t.jsx(en.Placeholder,{...N}),errorBoundaryProps:{fallback:t.jsx(en.Placeholder,{...N})},children:t.jsx(en,{...N})},k))}),t.jsx(en,{...v})]})]})},Ii=({error:e})=>{const n=Ce();return t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:e.message}),children:t.jsx(le.White,{onClick:()=>n("/bridge"),children:"Home"})})},ki=({children:e})=>{const n=jt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:l,recipient:c}=o,{initiaAddress:d,hexAddress:u}=De(),h=qn(),m=yt(),f=Dn(),p=m(r),g=f(p),x=a.slice(0,-1).some($=>{const q=m($);return f(q)==="cosmos"})&&g!=="cosmos",[y,b]=_.useState(void 0),[C,v]=_.useState(!1),[N,k]=_.useState(null);if(_.useEffect(()=>{(async()=>{try{if(!x)return;if(!h)throw new Error("Wallet not connected");v(!0),k(null);const[{pubkey:q}]=await h.getAccounts();b(q)}catch(q){k(await ft(q))}finally{v(!1)}})()},[x,h]),N)return t.jsx(Ii,{error:N});if(C)return t.jsx(xe,{children:t.jsx(le.White,{loading:C&&"Generating intermediary addresses..."})});if(!x||y){const $=a.map((q,V)=>{if(V===a.length-1){const U=m(i);return f(U)==="initia"?j.InitiaAddress(c).bech32:c}const M=m(q),I=f(M),w=m(r),E=f(w);switch(I){case"initia":return d;case"evm":return u;case"cosmos":{if(E==="cosmos")return ie.toBech32(M.bech32_prefix,ie.fromBech32(l).data);if(!y)throw new Error("Pubkey not found");return jn.pubkeyToAddress(jn.encodeSecp256k1Pubkey(y),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e($)}return null},Zo=({tx:e,children:n})=>{const s=jr(),o=yt(),{data:a,isLoading:r}=T.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:h}=e.evm_tx,m=await s();await fo(m,o(u));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:x,spender:y}=g,C=await new pt.ethers.Contract(x,f,m).allowance(h,y);return{approval:g,currentAllowance:BigInt(C.toString())}}))).filter(({approval:g,currentAllowance:x})=>x<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:l,isPending:c,error:d}=T.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,h=await s(),m=await h.getSigner();await fo(h,o(u));for(const f of a){const{token_contract:p,spender:g,amount:x}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new pt.ethers.Contract(p,y,m).approve(g,x)).wait()}return!0}catch(u){throw await ft(u)}}});return r?t.jsx(xe,{children:t.jsx(le.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!l?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:d?.message}),children:t.jsx(le.White,{onClick:()=>i(),loading:c&&"Approving tokens...",children:"Approve tokens"})}):n},Si=({addressList:e,signedOpHook:n,children:s})=>{const o=Xe(),{route:a,values:r}=jt(),[i,l]=_.useState(void 0),[c,d]=_.useState(!1),[u,h]=_.useState(null);return _.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),h(null);const f={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:r.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:p}=await o.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;l(g)}catch(f){h(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),u?t.jsx(Ii,{error:u}):c||!i?t.jsx(xe,{children:t.jsx(le.White,{loading:"Fetching messages..."})}):s(i)},Ai=({children:e})=>{const{route:n}=jt(),s=mf();return n.required_op_hook&&!s.data?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:s.error?.message}),children:t.jsx(le.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},cg=()=>t.jsx(dt,{title:"Route preview",children:t.jsx(ki,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(ig,{addressList:e}),t.jsx(Ai,{children:n=>t.jsx(Si,{addressList:e,signedOpHook:n,children:s=>t.jsx(Zo,{tx:s,children:t.jsx(Yo,{tx:s})})})})]})})}),Ti=_.createContext(null);function Es(){return _.useContext(Ti)}const lg="_button_17r1o_1",dg="_claimed_17r1o_24",Ea={button:lg,claimed:dg},ug=()=>{const{withdrawalTx:e}=Es(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:l,to:c,version:d}=e,u=ae(),h=te(),{requestTxSync:m,waitForTxConfirmation:f}=De(),p=cf(e),g=ie.toBase64(wi(e)),x=bi(e,g),y=T.useQueryClient(),{mutate:b,isPending:C}=T.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:v}=p;return m({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:h,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(ie.fromBase64),from:l,to:c,sequence:BigInt(s),amount:o,version:ie.fromBase64(d),storageRoot:ie.fromBase64(i),lastBlockHash:ie.fromBase64(v)}}],internal:!0})},onSuccess:async v=>{await f({chainId:u.chain_id,txHash:v}),y.invalidateQueries({queryKey:zt.withdrawalClaimed(n,g).queryKey})}});return x?t.jsxs("div",{className:Ea.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ea.button,onClick:()=>b(),disabled:C,children:"Claim"})},mg=({children:e})=>{const{withdrawalTx:n}=Es(),s=sf(n.bridge_id),o=rf(n),a=_.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ge.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},$i=1e3,hg=60,pg=60,fg=24,go=$i*hg,_o=go*pg,qa=_o*fg,gg=({date:e})=>{const n=_.useCallback(()=>{const d=new Date().getTime(),h=e.getTime()-d;if(h<=0)return{days:0,hours:0,minutes:0,seconds:0};const m=Math.floor(h/qa),f=Math.floor(h%qa/_o),p=Math.floor(h%_o/go),g=Math.floor(h%go/$i);return{days:m,hours:f,minutes:p,seconds:g}},[e]),[s,o]=_.useState(n());_.useEffect(()=>{const d=window.setInterval(()=>{o(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:l,seconds:c}=s;return t.jsx(Fn,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(l),"m ",a(c),"s"]})})},_g="_container_1lz3w_1",xg="_title_1lz3w_5",La={container:_g,title:xg},yg=({date:e})=>t.jsxs("div",{className:La.container,children:[t.jsx("div",{className:La.title,children:"Claimable in"}),t.jsx(gg,{date:e})]}),jg="_container_1oldz_1",bg="_icon_1oldz_7",Ma={container:jg,icon:bg},wg="Withdrawal will begin within an hour",Pa=()=>{const e=Ns();return t.jsxs("div",{className:Ma.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Fn,{label:wg,children:t.jsx("span",{className:Ma.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},vg=({children:e})=>{const{withdrawalTx:n}=Es(),s=af(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},Cg=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=Es(),a=ie.toBase64(wi(o)),r=bi(o,a),{setReminder:i,removeReminder:l}=dn();return _.useEffect(()=>{const c={chainId:s,txHash:o.tx_hash};r?l(c):i(c,{...c,recipient:o.to,claimableAt:e.getTime(),amount:o.amount.amount,denom:o.amount.denom,dismissed:Ge.isPast(e.getTime())?!0:void 0})},[s,r,e,l,i,o]),n},Ng=()=>t.jsx(vg,{children:e=>e?t.jsx(Pa,{}):t.jsx(mg,{children:n=>n?t.jsx(Cg,{date:n,children:Ge.isFuture(n)?t.jsx(yg,{date:n}):t.jsx(ug,{})}):t.jsx(Pa,{})})}),Ig="_asset_6h8u2_1",kg="_info_6h8u2_7",Sg="_symbol_6h8u2_11",eo={asset:Ig,info:kg,symbol:Sg},Ag=({amount:e,denom:n})=>{const s=ae(),o=sr(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:eo.asset,children:[t.jsx(X,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:eo.info,children:[t.jsx("span",{className:"monospace",children:j.formatAmount(e,{decimals:i})}),t.jsx("span",{className:eo.symbol,children:a})]})]})},Tg="_item_km5w2_1",$g={item:Tg},Eg=({chain:e})=>{const n=e.metadata?.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=of(n),i=_.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:l}=dn();return _.useEffect(()=>{const c=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));l(c)},[e.chainId,i,l]),i.length?t.jsxs(t.Fragment,{children:[i.map(c=>{const{amount:d}=c;return t.jsxs("div",{className:$g.item,children:[t.jsx(Ag,{...d}),t.jsx(me,{suspenseFallback:null,children:t.jsx(Ti.Provider,{value:{chainId:e.chainId,withdrawalTx:c},children:t.jsx(Ng,{})})})]},c.sequence)}),a&&t.jsx(_i,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},qg="_content_dj1qm_1",Lg="_title_dj1qm_5",Da={content:qg,title:Lg},Mg=()=>{const{chainId:e}=Je(),n=de(),s=Vt(),[o,a]=_.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ye(),{reminders:i}=dn(),l=o?r(o):void 0;return t.jsxs(dt,{title:"OP Bridge withdrawals",children:[t.jsx(Ft,{chains:n.filter(({metadata:c})=>!c?.is_l1&&c?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:c=>i.some(d=>d.chainId===c)}),t.jsx("div",{className:Da.content,children:l?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Da.title,children:l.name}),t.jsx(me,{children:t.jsx(Eg,{chain:l})},o)]}):t.jsx(fe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},us=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Pg="5722e7dffb709492cf5312446ceeff73",Dg=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Pg}`,Ei=["walletconnect-wallets"],Bg=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",qi=async e=>{const n=await z.get(Dg,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(Bg)},Rg=()=>T.useQuery({queryKey:Ei,queryFn:({signal:e})=>qi(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),Fg="_page_13y8q_1",Ug="_pageTop_13y8q_19",Og="_backButtonFixed_13y8q_63",Vg="_listItem_13y8q_64",Kg="_socialButton_13y8q_65",zg="_arrowIcon_13y8q_66",Wg="_searchInputUnderline_13y8q_67",Hg="_header_13y8q_72",Qg="_title_13y8q_81",Gg="_headerSpacer_13y8q_116",Yg="_icon_13y8q_120",Zg="_installedText_13y8q_124",Jg="_divider_13y8q_131",Xg="_dividerText_13y8q_152",e_="_loading_13y8q_193",t_="_socialIcons_13y8q_198",n_="_socialText_13y8q_204",s_="_searchWrapper_13y8q_214",o_="_scrollable_13y8q_248",a_="_list_13y8q_64",r_="_listIconWrapper_13y8q_332",i_="_moreIconSmall_13y8q_342",c_="_externalLinkIcon_13y8q_364",l_="_listName_13y8q_368",d_="_listNameMuted_13y8q_381",u_="_recentBadge_13y8q_394",m_="_learnMoreLink_13y8q_408",D={page:Fg,pageTop:Ug,backButtonFixed:Og,listItem:Vg,socialButton:Kg,arrowIcon:zg,searchInputUnderline:Wg,header:Hg,title:Qg,headerSpacer:Gg,icon:Yg,installedText:Zg,divider:Jg,dividerText:Xg,loading:e_,socialIcons:t_,socialText:n_,searchWrapper:s_,scrollable:o_,list:a_,listIconWrapper:r_,moreIconSmall:i_,externalLinkIcon:c_,listName:l_,listNameMuted:d_,recentBadge:u_,learnMoreLink:m_},h_=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},p_=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,l]=_.useState(""),{data:c=[],isError:d,isLoading:u,isFetching:h}=Rg(),m=u||h&&c.length===0,f=_.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(x=>x.name.toLowerCase().includes(g))},[e,i]),p=_.useMemo(()=>{const g=new Set(e.map(y=>us(y.name))),x=i.toLowerCase();return c.filter(y=>!g.has(us(y.name))).filter(y=>!i||y.name.toLowerCase().includes(x)).sort((y,b)=>y.name.localeCompare(b.name))},[c,e,i]);return t.jsxs("div",{className:D.pageTop,children:[t.jsx("button",{type:"button",className:D.backButtonFixed,onClick:r,"aria-label":"Back",children:t.jsx(S.IconBack,{size:16,"aria-hidden":"true"})}),t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"All Wallets"}),t.jsx("div",{className:D.headerSpacer})]}),t.jsx("div",{className:D.searchWrapper,children:t.jsx(Un,{rootClassName:D.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>l(g.target.value),onClear:()=>l("")})}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[f.map(g=>{const{name:x,icon:y,id:b}=g,C=o===b,v=s===b,N="ready"in g?!!g.ready:!0;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:v}),onClick:()=>a(g),disabled:n||!N,"aria-busy":v,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:x}),v?t.jsx(ct,{size:16}):C?t.jsx("span",{className:D.recentBadge,children:"Recent"}):N?t.jsx("span",{className:D.installedText,children:"Installed"}):null]},`connector:${b}`)}),m&&t.jsxs("div",{className:L(D.listItem,D.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(ct,{size:16})}),t.jsx("span",{className:D.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const x=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,y=x&&h_(x)?x:void 0;return t.jsxs("button",{type:"button",className:D.listItem,disabled:!0,"aria-label":`${g.name} (not installed)`,children:[t.jsx("div",{className:D.listIconWrapper,children:y&&t.jsx(X,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:g.name})]},`wc:${g.id}`)}),d&&t.jsx(fe,{level:"error",children:"Couldn't load additional wallets."})]})})]})},f_=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),g_=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),__=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),x_=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),y_=[{id:"io.rabby",name:"Rabby",icon:"https://assets.initia.xyz/images/wallets/Rabby.webp",url:"https://rabby.io"},{id:"app.phantom",name:"Phantom",icon:"https://assets.initia.xyz/images/wallets/Phantom.webp",url:"https://phantom.com"},{id:"app.keplr",name:"Keplr",icon:"https://assets.initia.xyz/images/wallets/Keplr.webp",url:"https://keplr.app"},{id:"io.leapwallet",name:"Leap",icon:"https://assets.initia.xyz/images/wallets/Leap.webp",url:"https://leapwallet.io"},{id:"io.metamask",name:"MetaMask",icon:"https://assets.initia.xyz/images/wallets/MetaMask.webp",url:"https://metamask.io"}],j_=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:l})=>{const c=e.filter(p=>!("ready"in p)||!!p.ready),d=c.slice(0,5),u=new Set(c.map(p=>p.id)),h=new Set(c.map(p=>us(p.name))),m=Math.max(0,5-d.length),f=y_.filter(p=>!u.has(p.id)&&!h.has(us(p.name))).slice(0,m);return t.jsxs("div",{className:D.page,children:[t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"Sign In"}),t.jsx("div",{className:D.headerSpacer})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:L(D.socialButton,{[D.loading]:o===n.id}),onClick:()=>r(n),disabled:s,"aria-busy":o===n.id,children:[t.jsx("span",{className:D.socialText,children:"Email / Socials"}),o===n.id?t.jsx(ct,{size:16}):t.jsxs("div",{className:D.socialIcons,children:[t.jsx(g_,{}),t.jsx(x_,{}),t.jsx(__,{})]})]}),t.jsx("div",{className:D.divider,children:t.jsx("span",{className:D.dividerText,children:"or"})})]}),t.jsx(et,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[d.map(p=>{const{name:g,icon:x,id:y}=p,b=o===y,C=a===y;return t.jsxs("button",{type:"button",className:L(D.listItem,{[D.loading]:b}),onClick:()=>r(p),disabled:s,"aria-busy":b,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:x,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:g}),b?t.jsx(ct,{size:16}):C?t.jsx("span",{className:D.recentBadge,children:"Recent"}):t.jsx("span",{className:D.installedText,children:"Installed"})]},y)}),f.map(p=>t.jsxs("a",{className:D.listItem,href:p.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${p.name} (opens in new tab)`,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(X,{src:p.icon,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:p.name}),t.jsx(S.IconExternalLink,{size:10,className:D.externalLinkIcon,"aria-hidden":"true"})]},p.id)),t.jsxs("button",{type:"button",className:D.listItem,onClick:i,onMouseEnter:l,onFocus:l,disabled:s,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx("div",{className:D.moreIconSmall,children:t.jsx(f_,{})})}),t.jsx("span",{className:D.listNameMuted,children:"More wallets"}),t.jsx("span",{className:D.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),t.jsxs("a",{className:D.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",t.jsx(S.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Ba=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=ve.useConnect(),o=Le.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=_.useState(null),[i,l]=_.useState("signin"),c=T.useQueryClient(),d=()=>c.prefetchQuery({queryKey:Ei,queryFn:({signal:g})=>qi(g),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:u,isPending:h}=T.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(x){throw await ft(x)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),m=_.useMemo(()=>[...n].sort((g,x)=>g.id===o?-1:x.id===o?1:g.name.localeCompare(x.name)),[n,o]),f=_.useMemo(()=>m.find(g=>g.id===bn.id),[m]),p=_.useMemo(()=>m.filter(g=>g.id!==bn.id),[m]);return i==="all"?t.jsx(p_,{walletConnectors:p,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onBack:()=>l("signin")}):t.jsx(j_,{walletConnectors:p,privyConnector:f,isPending:h,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onShowAll:()=>l("all"),onPrefetchWallets:d})},b_={deposit:{mode:"deposit",label:"Deposit",local:{denomKey:"dstDenom",chainIdKey:"dstChainId"},external:{denomKey:"srcDenom",chainIdKey:"srcChainId"}},withdraw:{mode:"withdraw",label:"Withdraw",local:{denomKey:"srcDenom",chainIdKey:"srcChainId"},external:{denomKey:"dstDenom",chainIdKey:"dstChainId"}}};function Vn(e){return b_[e]}function Jo(){const e=Xe(),n=ln(),s=te(),o=Bn(),a=Object.fromEntries(o.filter(({chain_type:r,bech32_prefix:i})=>r==="evm"||r==="cosmos"&&i==="init").map(r=>[r.chain_id,{address:r.chain_type==="evm"?n:s,denoms:[]}]));return T.useQuery({queryKey:qe.allBalances(Object.keys(a),[n,s]).queryKey,queryFn:()=>e.post("v2/info/balances",{json:{chains:a}}).json(),select:({chains:r})=>r?Object.fromEntries(Object.entries(r).map(([i,{denoms:l}])=>[i,l||{}])):{},enabled:!!s,staleTime:K.SECOND})}function Xo(){const{localOptions:e=[]}=Je();return Kt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function ea(e){const{local:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function w_(e){const{external:n}=Vn(e),s=Kt(),{watch:o}=At(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:l,chain_id:c})=>i===l&&c===r)||null}function v_(e){const n=Kt(),s=yt(),{data:o,isLoading:a}=Jo(),{remoteOptions:r=[]}=Je(),i=ea(e);return i?{data:n.filter(({symbol:c,denom:d,chain_id:u})=>r.length?r.some(h=>h.denom===d&&h.chainId===u):c===i.symbol).map(c=>{if(c.hidden||c.chain_id===i.chain_id)return null;const d=s(c.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const u=o?.[d.chain_id]?.[c.denom];return e==="deposit"&&(!u||!Number(u.amount))?null:{asset:c,chain:d,balance:u}}).filter(c=>c!==null),isLoading:a}:{data:[],isLoading:a}}function At(){return _e.useFormContext()}const C_="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23242629'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%23585F67'/%3e%3cpath%20d='M47.7916%2037.0445C47.7916%2035.2783%2049.2313%2033.8464%2051.0071%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.0071C49.2313%2082.8837%2047.7916%2081.4519%2047.7916%2079.6854V37.0445Z'%20fill='%23585F67'/%3e%3cpath%20d='M91.7372%2056.2323C91.7372%2052.6999%2094.6166%2049.8362%2098.1681%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1681C94.6166%2066.8927%2091.7372%2064.0289%2091.7372%2060.4965V56.2323Z'%20fill='%23242629'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.24%2061.5626C97.4642%2061.5626%2096.0245%2060.1308%2096.0245%2058.3646C96.0245%2056.5984%2097.4642%2055.1665%2099.24%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%23585F67'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%232F3337'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23757C82'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23757C82'/%3e%3c/svg%3e",N_="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e",I_="_container_uxgnj_1",k_="_title_uxgnj_5",S_="_close_uxgnj_12",A_="_emptyIcon_uxgnj_24",T_="_empty_uxgnj_24",$_="_list_uxgnj_51",E_="_asset_uxgnj_66",q_="_placeholder_uxgnj_82",L_="_activeAsset_uxgnj_95",M_="_iconContainer_uxgnj_99",P_="_assetIcon_uxgnj_109",D_="_chainIcon_uxgnj_119",B_="_assetPlaceholder_uxgnj_133",R_="_assetName_uxgnj_154",F_="_assetChain_uxgnj_169",U_="_balance_uxgnj_177",O_="_value_uxgnj_186",ue={container:I_,title:k_,close:S_,emptyIcon:A_,empty:T_,list:$_,asset:E_,placeholder:q_,activeAsset:L_,iconContainer:M_,assetIcon:P_,chainIcon:D_,assetPlaceholder:B_,assetName:R_,assetChain:F_,balance:U_,value:O_},V_=({mode:e})=>{const{external:n}=Vn(e),{data:s,isLoading:o}=v_(e),{setValue:a,watch:r}=At(),i=ea(e),l=Xo(),{theme:c}=Y(),d=r(),u=d[n.denomKey],h=d[n.chainIdKey];function m(){const f=u&&h;return!f&&l.length<=1&&e==="deposit"?null:t.jsx("button",{className:ue.close,onClick:()=>{e==="withdraw"||f?a("page","fields"):a("page","select-local")},children:t.jsx(S.IconBack,{size:20})})}return i?!o&&!s.length?t.jsxs("div",{className:ue.container,children:[m(),t.jsx("h4",{className:ue.title,children:"No available assets"}),t.jsx("img",{src:c==="dark"?C_:N_,alt:"No assets",className:ue.emptyIcon}),t.jsx("p",{className:ue.empty,children:e==="withdraw"?`No supported destinations to withdraw ${i.symbol}.`:`No supported assets to deposit ${i.symbol}.`})]}):t.jsxs("div",{className:ue.container,children:[m(),t.jsxs("h4",{className:ue.title,children:[e==="withdraw"?"Select destination":`Deposit ${i.symbol}`," "]}),t.jsxs("div",{className:ue.list,children:[o&&Array.from({length:5}).map((f,p)=>t.jsxs("div",{className:L(ue.asset,ue.placeholder),children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("div",{className:ue.assetIcon}),t.jsx("div",{className:ue.chainIcon})]}),t.jsx("div",{className:ue.assetPlaceholder})]},p)),!o&&s.sort(({balance:f},{balance:p})=>Number(p?.value_usd??0)-Number(f?.value_usd??0)).map(({asset:f,chain:p,balance:g})=>{const x=u===f.denom&&h===p.chain_id;return t.jsxs("button",{className:L(ue.asset,x&&ue.activeAsset),onClick:()=>{a(n.denomKey,f.denom),a(n.chainIdKey,p.chain_id),e==="deposit"&&a("quantity",""),a("page","fields")},children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("img",{src:f.logo_uri,alt:f.symbol,className:ue.assetIcon}),t.jsx("img",{src:p.logo_uri||"",alt:p.chain_name,className:ue.chainIcon})]}),t.jsxs("p",{className:ue.assetName,children:[f.symbol," ",x&&t.jsx("span",{children:t.jsx(S.IconCheck,{size:16})})]}),t.jsxs("p",{className:ue.assetChain,children:["on ",p.pretty_name]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:ue.balance,children:j.formatAmount(g.amount,{decimals:g.decimals||6})}),t.jsx("p",{className:ue.value,children:ee(g.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},K_="_title_9ovji_1",z_="_list_9ovji_7",W_="_asset_9ovji_15",to={title:K_,list:z_,asset:W_},H_=({mode:e})=>{const{local:n,external:s}=Vn(e),{setValue:o}=At(),a=Xo(),r=(l,c)=>{o(n.denomKey,l),o(n.chainIdKey,c),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=_.useEffectEvent(()=>{const{denom:l,chain_id:c}=a[0];r(l,c)});return _.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:to.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:to.list,children:a.map(({denom:l,chain_id:c,symbol:d,logo_uri:u})=>t.jsxs("button",{className:to.asset,onClick:()=>r(l,c),children:[t.jsx("img",{src:u,alt:d}),d]},`${l}-${c}`))})]}):t.jsx("div",{children:"No assets found"})},Q_="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M29%202.71875C43.5%202.71875%2055.2812%2014.5%2055.2812%2029C55.2812%2043.5%2043.5%2055.2812%2029%2055.2812C14.5%2055.2812%202.71875%2043.5%202.71875%2029C2.71875%2014.5%2014.5%202.71875%2029%202.71875ZM29%206.34375C16.4937%206.34375%206.34375%2016.4937%206.34375%2029C6.34375%2041.5062%2016.4937%2051.6562%2029%2051.6562C41.5062%2051.6562%2051.6562%2041.5062%2051.6562%2029C51.6562%2016.4937%2041.5062%206.34375%2029%206.34375Z'%20fill='%23F85454'/%3e%3cpath%20d='M36.1616%2018.7623C37.0109%2017.9129%2038.3885%2017.9129%2039.2378%2018.7623C40.087%2019.6117%2040.0871%2020.9893%2039.2378%2021.8386L32.0763%2029.0001L39.2378%2036.1616L39.3865%2036.3279C40.083%2037.1822%2040.034%2038.4417%2039.2378%2039.2378C38.4417%2040.034%2037.1822%2040.083%2036.3279%2039.3865L36.1616%2039.2378L29.0001%2032.0763L21.8386%2039.2378C20.9893%2040.0871%2019.6117%2040.087%2018.7623%2039.2378C17.9129%2038.3885%2017.9129%2037.0109%2018.7623%2036.1616L25.9238%2029.0001L18.7623%2021.8386C17.9129%2020.9892%2017.9129%2019.6116%2018.7623%2018.7623C19.6116%2017.9129%2020.9892%2017.9129%2021.8386%2018.7623L29.0001%2025.9238L36.1616%2018.7623Z'%20fill='%23F85454'/%3e%3c/svg%3e",G_="data:image/svg+xml,%3csvg%20width='72'%20height='72'%20viewBox='0%200%2072%2072'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M36%209.71875C50.5%209.71875%2062.2812%2021.5%2062.2812%2036C62.2812%2050.5%2050.5%2062.2812%2036%2062.2812C21.5%2062.2812%209.71875%2050.5%209.71875%2036C9.71875%2021.5%2021.5%209.71875%2036%209.71875ZM36%2013.3438C23.4937%2013.3438%2013.3438%2023.4937%2013.3438%2036C13.3438%2048.5062%2023.4937%2058.6562%2036%2058.6562C48.5062%2058.6562%2058.6562%2048.5062%2058.6562%2036C58.6562%2023.4937%2048.5062%2013.3438%2036%2013.3438Z'%20fill='%23D1242F'/%3e%3cpath%20d='M43.1616%2025.7623C44.0109%2024.9129%2045.3885%2024.9129%2046.2378%2025.7623C47.087%2026.6117%2047.0871%2027.9893%2046.2378%2028.8386L39.0763%2036.0001L46.2378%2043.1616L46.3865%2043.3279C47.083%2044.1822%2047.034%2045.4417%2046.2378%2046.2378C45.4417%2047.034%2044.1822%2047.083%2043.3279%2046.3865L43.1616%2046.2378L36.0001%2039.0763L28.8386%2046.2378C27.9893%2047.0871%2026.6117%2047.087%2025.7623%2046.2378C24.9129%2045.3885%2024.9129%2044.0109%2025.7623%2043.1616L32.9238%2036.0001L25.7623%2028.8386C24.9129%2027.9892%2024.9129%2026.6116%2025.7623%2025.7623C26.6116%2024.9129%2027.9892%2024.9129%2028.8386%2025.7623L36.0001%2032.9238L43.1616%2025.7623Z'%20fill='%23D1242F'/%3e%3c/svg%3e",Y_="_container_9k4hs_1",Z_="_title_9k4hs_8",J_="_subtitle_9k4hs_14",X_="_linkContainer_9k4hs_30",ex="_link_9k4hs_30",tx="_separator_9k4hs_51",nx="_errorIcon_9k4hs_62",sx="_error_9k4hs_62",we={container:Y_,title:Z_,subtitle:J_,linkContainer:X_,link:ex,separator:tx,errorIcon:nx,error:sx};function ox(e){if(!e)return"pending";const n=e.state;return n==="STATE_COMPLETED_SUCCESS"?"success":n==="STATE_ABANDONED"||n==="STATE_COMPLETED_ERROR"||n==="STATE_PENDING_ERROR"?"failed":"pending"}function xo({type:e}){const{closeModal:n}=cn(),{theme:s}=Y(),{watch:o}=At(),{result:a}=o(),{openDrawer:r}=xt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,l=i?"":a.txhash,c=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:h}=a,{srcDenom:m,srcChainId:f,quantity:p}=h,g=it(m,f),x=e==="deposit"?"Deposit":"Withdraw",{data:y}=vi({chainId:c,txHash:l,tracked:!1}),{data:b}=Ci({chainId:c,txHash:l,tracked:!!y,timestamp:d,route:u}),C=ox(b),v=s==="dark"?Q_:G_,N=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:we.container,children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:a?.error}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]});const $=kn(u.estimated_route_duration_seconds),q=new URLSearchParams({tx_hash:l,chain_id:c}),V=new URL(`?${q.toString()}`,"https://explorer.skip.build"),M=()=>t.jsxs("div",{className:we.linkContainer,children:[t.jsx("a",{href:V.toString(),target:"_blank",rel:"noopener noreferrer",className:we.link,children:"View transaction"}),t.jsx("div",{className:we.separator}),t.jsx("button",{className:we.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:we.container,children:[C==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),t.jsx("video",{src:N,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:we.subtitle,children:["Estimated time: ",t.jsx("span",{children:$})]}),M(),t.jsx("p",{className:we.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," complete"]}),t.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:I=>{const w=I.currentTarget;w.duration-w.currentTime<.1&&w.pause()}}),M(),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]}),C==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:we.title,children:[x," failed"]}),t.jsx("img",{src:v,alt:"Failed",className:we.errorIcon}),t.jsx("p",{className:we.error,children:"Your transaction could not be completed"}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const ax=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),rx=({tx:e,children:n})=>{const{values:s}=jt(),{srcChainId:o}=s,a=te(),r=En(),i=$o(),{data:l,isLoading:c}=T.useQuery({queryKey:ax.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const u=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:p})=>{if(!(f&&p))throw new Error("Invalid transaction data");return r.fromAmino({type:sn.aminoConverters[f].aminoType,value:JSON.parse(p)})});return{estimatedGas:await(await i(o)).simulate(a,u,""),messages:u}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(c)return t.jsx(xe,{children:t.jsx(le.White,{loading:"Estimating gas..."})});const d=l?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},ix="_container_eg177_1",cx="_back_eg177_6",lx="_title_eg177_18",dx="_divider_eg177_26",ux="_label_eg177_30",mx="_asset_eg177_37",hx="_assetIcon_eg177_55",px="_chainIcon_eg177_67",fx="_assetName_eg177_80",gx="_chevron_eg177_92",_x="_input_eg177_96",xx="_balanceContainer_eg177_108",yx="_value_eg177_116",jx="_maxButton_eg177_126",bx="_detail_eg177_142",wx="_detailsContainer_eg177_153",vx="_detailsButton_eg177_163",Cx="_detailValue_eg177_180",Nx="_detailToken_eg177_190",Ix="_minimumReceived_eg177_198",Q={container:ix,back:cx,title:lx,divider:dx,label:ux,asset:mx,assetIcon:hx,chainIcon:px,assetName:fx,chevron:gx,input:_x,balanceContainer:xx,value:yx,maxButton:jx,detail:bx,detailsContainer:wx,detailsButton:vx,detailValue:Cx,detailToken:Nx,minimumReceived:Ix},Li=({renderFee:e})=>{const{route:n}=Je(),{values:s}=jt(),{dstDenom:o,dstChainId:a}=s,i=Kt().find(({denom:f,chain_id:p})=>f===o&&p===a),l=te(),c=Jr(),[d,u]=Le.useToggle(!1),h=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const m=n.does_swap?BigInt(n.amount_out||n.estimated_amount_out)*BigInt(1e4-Number(s.slippagePercent)*100)/BigInt(1e4):BigInt(n.amount_out||n.estimated_amount_out);return t.jsx(Nn,{children:t.jsxs("div",{className:Q.detailsContainer,children:[t.jsxs("button",{className:Q.detailsButton,onClick:u,children:["Transaction details"," ",t.jsx(S.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&t.jsxs(t.Fragment,{children:[n.does_swap&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Slippage"}),t.jsxs("p",{className:Q.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:Q.detailValue,children:Ho(n.estimated_fees)})]}),e&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Tx fee"}),t.jsx("div",{className:Q.detailValue,children:e()})]}),l&&t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:c,alt:"Wallet",height:12,width:12})," ",j.truncate(l)]})]})]}),t.jsxs("div",{className:Q.detail,children:[t.jsx("p",{className:Q.detailLabel,children:"Estimated time"}),t.jsx("p",{className:L(Q.detailValue),style:h?{color:"var(--warning)"}:void 0,children:kn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:L(Q.detail,Q.minimumReceived),children:[t.jsx("p",{className:Q.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:Q.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Q.detailToken})," ",j.formatAmount(m,{decimals:i.decimals})," ",i.symbol]})]})]})})},kx="_trigger_1c7d7_1",Sx="_item_1c7d7_5",Ax="_itemText_1c7d7_13",Tx={trigger:kx,item:Sx,itemText:Ax},$x=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=jt(),{srcChainId:r,srcDenom:i,quantity:l}=a,d=Kt().find(({denom:I,chain_id:w})=>I===i&&w===r),u=Ze(r),h=An(u),m=Vo(u),f=Ko(u),p=lt(u),g=m.map(({amount:I,denom:w})=>Ke.calculateFee(Math.ceil(n*on),Ke.GasPrice.fromString(I+w))),x=g.map(I=>I.amount[0]),y=I=>{const w=h.find(R=>R.denom===I)?.amount??"0",E=x.find(R=>R.denom===I)?.amount??"0",U=d&&i===I?B(l||"0").times(B(10).pow(d.decimals)).toFixed(0):"0",F=B(E).plus(U),O=B(w).gte(F),{symbol:Z,decimals:H}=p(I);return{symbol:Z,decimals:H,spend:B(U).gt(0)?U:null,fee:E,total:F.toFixed(),balance:w,isSufficient:O}},b=()=>{if(!x.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:I}of x)if(y(I).isSufficient)return I;return x[0]?.denom},[C,v]=_.useState(b),N=g.find(I=>I.amount[0].denom===C)??void 0,k=C?y(C):null,$=k&&!k.isSufficient?"Insufficient balance":void 0,q=(I,w)=>{if(j.formatAmount(I,{decimals:w})==="0.000000")return 8},V=I=>{const[{amount:w,denom:E}]=I.amount;if(B(w).isZero())return"0";const{symbol:U,decimals:F}=p(E),O=q(w,F);return`${j.formatAmount(w,{decimals:F,dp:O})} ${U}`},M=()=>{if(g.length===0)return null;if(g.length===1)return t.jsx("span",{className:"monospace",children:V(g[0])});if(!N||!C)return null;const I=g.map(O=>{const[{denom:Z}]=O.amount,{symbol:H}=p(Z);return{value:Z,label:V(O),triggerLabel:H}}),[{amount:w,denom:E}]=N.amount,{decimals:U}=p(E),F=q(w,U);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:j.formatAmount(w,{decimals:U,dp:F})}),t.jsx(zo,{options:I,value:C,onChange:v,classNames:Tx})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Li,{renderFee:g.length>0?M:void 0}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:N,onCompleted:o,confirmMessage:s,error:$})})]})},Ex=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(Li,{}),t.jsx(Zo,{tx:e,children:t.jsx(Yo,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),qx=({tx:e,gas:n,mode:s})=>{const{setValue:o}=At(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(Ex,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx($x,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},Lx=({mode:e})=>{const n=Vn(e),s=Ce(),o=Je(),a=Xo(),r=yt(),{data:i}=Jo(),l=ln(),{watch:c,setValue:d,getValues:u}=At(),h=c(),{srcChainId:m,srcDenom:f,quantity:p=""}=h,g=ea(e),x=w_(e),y=h[n.external.chainIdKey],b=y?r(y):null,C=i?.[m]?.[f]?.amount,v=i?.[m]?.[f]?.price||0,N=B(v||0).times(p||0),[k]=Le.useDebounceValue(p,300),$=e==="withdraw"?g:x,q=_.useMemo(()=>{if(e==="deposit"&&!x)return"Select asset";const H=B(p||0);if(!H.isFinite()||H.lte(0))return"Enter amount";const R=j.fromBaseUnit(C??"0",{decimals:$?.decimals||6});if(H.gt(R))return"Insufficient balance";if(e==="withdraw"&&!x)return"Select destination"},[e,p,C,$,x]),{data:V,error:M}=po(k,{disabled:!!q}),I=!M&&!q?V:void 0,w=_.useEffectEvent(()=>{s(0,{...o,route:I,values:{sender:l,recipient:o.recipientAddress?j.InitiaAddress(o.recipientAddress).hex:l,slippagePercent:"1",...u()}})});if(_.useEffect(()=>{w()},[I,l]),!g||e==="deposit"&&!x)return null;const E=$?.decimals||6,U=e==="withdraw"?"Select chain":"Select asset",F=()=>{d("quantity",""),d(n.external.denomKey,""),d(n.external.chainIdKey,""),e==="withdraw"&&(d(n.local.denomKey,""),d(n.local.chainIdKey,"")),d("page",e==="withdraw"?"select-local":"select-external")},O=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:Q.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:Q.assetIcon,children:x?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:x.logo_uri,alt:x.symbol}),t.jsx("img",{src:b?.logo_uri||"",alt:b?.pretty_name,className:Q.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:Q.chainIcon})}),t.jsx("p",{className:Q.assetName,children:x?t.jsxs(t.Fragment,{children:[x.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",b?.pretty_name]})]}):U}),t.jsx(S.IconChevronDown,{className:Q.chevron,size:16})]})]}),Z=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:Q.label,children:"Amount"}),t.jsx(In,{balance:C,decimals:E,className:Q.input}),Number(C)>0&&t.jsxs("div",{className:Q.balanceContainer,children:[t.jsx("p",{className:Q.value,children:N.gt(0)?ee(N.toString()):"$-"}),t.jsxs("button",{className:Q.maxButton,onClick:()=>{const H=j.fromBaseUnit(C??"0",{decimals:E});B(p||0).eq(H)||d("quantity",H)},children:[t.jsx(S.IconWallet,{size:16})," ",j.formatAmount(C,{decimals:E})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:Q.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:Q.back,onClick:F,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:Q.title,children:[n.label," ",g.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[Z,t.jsx("div",{className:Q.divider}),O]}):t.jsxs(t.Fragment,{children:[O,t.jsx("div",{className:Q.divider}),Z]}),!o.route||q?t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:!M&&!q&&"Fetching route...",disabled:!0,fullWidth:!0,children:M?"No route found":q})}):t.jsx(ki,{children:H=>t.jsx(Ai,{children:R=>t.jsx(Si,{addressList:H,signedOpHook:R,children:P=>t.jsx(rx,{tx:P,children:Ne=>t.jsx(qx,{tx:P,gas:Ne,mode:e})})})})})]})},Mx="_container_7nl9j_1",Px="_page_7nl9j_5",Ra={container:Mx,page:Px},Mi=({mode:e})=>{const n=_e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Jo(),t.jsx(_e.FormProvider,{...n,children:t.jsx(Dx,{mode:e})})},Dx=({mode:e})=>{const{watch:n}=At(),s=n("page"),o=rt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return t.jsx(H_,{mode:e});case"select-external":return t.jsx(V_,{mode:e});case"fields":return t.jsx(Lx,{mode:e});case"completed":return t.jsx(xo,{type:e})}};return t.jsx(Nn,{children:t.jsx("div",{className:Ra.container,children:o((r,i)=>t.jsx(rt.animated.div,{style:r,className:Ra.page,children:a(i)}))})})},Bx=()=>t.jsx(Mi,{mode:"deposit"}),Rx=()=>t.jsx(Mi,{mode:"withdraw"}),Fx="_root_1lo0i_1",Ux="_address_1lo0i_9",Ox="_copy_1lo0i_19",Vx="_labelWrapper_1lo0i_33",Kx="_labelCopy_1lo0i_43",zx="_labelCopied_1lo0i_47",Wx="_copied_1lo0i_55",Hx="_derived_1lo0i_65",Qx="_derivedLabel_1lo0i_79",Gx="_derivedAddress_1lo0i_83",Yx="_hexAddress_1lo0i_89",Zx="_derivedCopy_1lo0i_94",Ae={root:Fx,address:Ux,copy:Ox,labelWrapper:Vx,labelCopy:Kx,labelCopied:zx,copied:Wx,derived:Hx,derivedLabel:Qx,derivedAddress:Gx,hexAddress:Yx,derivedCopy:Zx},Jx=()=>{const e=_.useRef(null),n=_.useRef(null),{initiaAddress:s,hexAddress:o}=De(),a=Yr("--gray-0");return _.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new ac({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),n.current.append(e.current)))},[s,a]),t.jsx(dt,{title:"Receive",children:t.jsxs("div",{className:Ae.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:Ae.address,children:s}),t.jsx(cs,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(Ae.copy,{[Ae.copied]:i}),onClick:r,children:[t.jsx(S.IconCopy,{size:12}),t.jsxs("div",{className:Ae.labelWrapper,children:[t.jsx("span",{className:Ae.labelCopy,children:"Copy address"}),t.jsx("span",{className:Ae.labelCopied,children:"Copied!"})]})]})}),t.jsx(cs,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:L(Ae.derived,{[Ae.copied]:i}),onClick:r,children:[t.jsx("span",{className:Ae.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:Ae.derivedAddress,children:[t.jsx("span",{className:Ae.hexAddress,children:j.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Ae.derivedCopy}),i&&t.jsx("span",{className:Ae.copiedText,children:"Copied!"})]})]})})]})})};function Xx(){const e=te(),n=de();return T.useQueries({queries:n.map(s=>({queryKey:vn.grants(s.chainId,e).queryKey,queryFn:async()=>{const{grants:o}=await z.create({prefixUrl:s.restUrl}).get(`cosmos/authz/v1beta1/grants/granter/${e}`).json();return{chainId:s.chainId,grants:o}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const e1="_countdown_vfms8_1",t1={countdown:e1},n1=({expiration:e})=>{const n=()=>{const a=new Date,r=Ge.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),l=Math.floor(r%(1440*60)/3600),c=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(l>0||i>0)&&u.push(`${l}h`),(c>0||l>0||i>0)&&u.push(`${c}m`),u.push(`${d}s`),u.join(" ")},[s,o]=_.useState(n());return Le.useInterval(()=>{o(n())},1e3),Ge.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:t1.countdown,children:s})]})},s1="_container_1l528_1",o1="_info_1l528_11",a1="_header_1l528_17",r1="_chainName_1l528_23",i1="_expiration_1l528_29",c1="_revokeButton_1l528_35",Yt={container:s1,info:o1,header:a1,chainName:r1,expiration:i1,revokeButton:c1},l1=({chainId:e,grantee:n,messageTypes:s,expiration:o})=>{const a=Ze(e),{mutate:r,isPending:i}=Er({grantee:n,internal:!0});return t.jsxs("div",{className:Yt.container,children:[t.jsxs("div",{className:Yt.info,children:[t.jsxs("div",{className:Yt.header,children:[t.jsx(X,{src:a.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:Yt.chainName,children:a.name})]}),t.jsx("div",{className:Yt.expiration,children:o?t.jsx(n1,{expiration:o}):"Until revoked"})]}),t.jsx("button",{className:Yt.revokeButton,onClick:()=>r(e),disabled:i,children:i?"Revoking...":"Revoke"})]})},d1=({chainId:e,grants:n})=>Object.values(n.reduce((o,a)=>{const r=o[a.grantee];return r?{...o,[a.grantee]:{...r,messageTypes:[...r.messageTypes,a.authorization.msg],expiration:qo([r.expiration,a.expiration?new Date(a.expiration):void 0])}}:{...o,[a.grantee]:{grantee:a.grantee,messageTypes:[a.authorization.msg],expiration:a.expiration?new Date(a.expiration):void 0}}},{})).map(o=>_.createElement(l1,{...o,chainId:e,key:o.grantee})),u1="_content_q36qs_1",m1={content:u1},h1=()=>{const e=Xx(),n=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?t.jsx(he,{children:"No permissions found"}):t.jsx("div",{className:m1.content,children:s.map(({chainId:o,grants:a})=>t.jsx(d1,{chainId:o,grants:a},o))})};return t.jsx(dt,{title:"Manage auto-signing",backButton:"/settings",children:n()})},p1="_version_1sf5y_1",f1={version:p1},g1=()=>t.jsxs("aside",{className:f1.version,children:["v","2.3.0"]}),_1="_link_se23z_1",x1="_title_se23z_17",y1="_subtitle_se23z_23",j1="_icon_se23z_30",ts={link:_1,title:x1,subtitle:y1,icon:j1},Pi=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:ts.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:ts.title,children:e}),n&&t.jsx("p",{className:ts.subtitle,children:n})]}),t.jsx("div",{className:ts.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),b1="https://export.initia.xyz/",w1=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(Pi,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(b1,"_blank",e)})},v1="_container_1vxr7_1",C1="_separator_1vxr7_7",Fa={container:v1,separator:C1},N1=()=>{const e=Ce(),{connector:n}=ve.useAccount();return t.jsx(dt,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Fa.container,children:[t.jsx(Pi,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===vo&&t.jsx(w1,{}),t.jsx(ht.Separator,{className:Fa.separator}),t.jsx(g1,{})]})})},I1="_trigger_1yjkd_1",k1="_icon_1yjkd_23",S1="_full_1yjkd_27",A1="_triggerContent_1yjkd_32",T1="_triggerText_1yjkd_40",$1="_popoverBackdrop_1yjkd_51",E1="_popoverPositioner_1yjkd_70",q1="_popoverPopup_1yjkd_74",L1="_search_1yjkd_99",M1="_viewport_1yjkd_105",P1="_item_1yjkd_111",D1="_highlighted_1yjkd_127",B1="_active_1yjkd_131",R1="_itemContent_1yjkd_136",F1="_extra_1yjkd_142",U1="_connectedTag_1yjkd_149",ge={trigger:I1,icon:k1,full:S1,triggerContent:A1,triggerText:T1,popoverBackdrop:$1,popoverPositioner:E1,popoverPopup:q1,search:L1,viewport:M1,item:P1,highlighted:D1,active:B1,itemContent:R1,extra:F1,connectedTag:U1},qs=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=Y(),[i,l]=_.useState(""),[c,d]=_.useState(!1),[u,h]=_.useState(0),[m,f]=_.useState(),p=_.useRef([]),g=_.useRef(null),x=de(),y=s.map(I=>x.find(w=>w.chainId===I)).filter(Boolean),b=I=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:I,height:I,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),C=_.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),v=_.useMemo(()=>{const I=[C,...y];if(!i)return I;const w=i.toLowerCase();return I.filter(E=>E.name.toLowerCase().includes(w)||E.chainId.toLowerCase().includes(w))},[y,i,C]),N=y.find(I=>I.chainId===e)||C,k=parseInt(Yr("--drawer-offset")),$=6,q=()=>{if(l(""),h(-1),g.current){const w=g.current.getBoundingClientRect().bottom+$,E=window.innerHeight-w-2*k;f(E)}d(!0)};_.useEffect(()=>{u>=0&&u<p.current.length&&p.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const V=_.useCallback(I=>{switch(I.key){case"ArrowDown":I.preventDefault(),h(w=>(w+1)%v.length);break;case"ArrowUp":I.preventDefault(),h(w=>(w-1+v.length)%v.length);break;case"Enter":I.preventDefault(),v[u]&&(n(v[u].chainId),d(!1));break;case"Escape":I.preventDefault(),d(!1);break}},[v,u,n,d]),M=I=>{n(I),d(!1)};return t.jsxs(Qt.Popover.Root,{open:c,onOpenChange:q,modal:"trap-focus",children:[t.jsx(Qt.Popover.Trigger,{render:t.jsxs("button",{className:L(ge.trigger,{[ge.full]:a}),"aria-expanded":c,role:"listbox",ref:g,children:[t.jsxs("div",{className:ge.triggerContent,children:[typeof N.logoUrl=="string"?t.jsx(X,{src:N.logoUrl,width:14,height:14,logo:!0}):N.logoUrl(14),t.jsx("span",{className:ge.triggerText,children:N.name})]}),t.jsx(S.IconChevronDown,{size:16,className:ge.icon})]})}),t.jsxs(Qt.Popover.Portal,{container:Ot(),children:[t.jsx(Qt.Popover.Backdrop,{className:ge.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Qt.Popover.Positioner,{className:ge.popoverPositioner,align:"end",side:"bottom",sideOffset:$,collisionAvoidance:{side:"none"},children:t.jsxs(Qt.Popover.Popup,{className:L(ge.popoverPopup,{[ge.full]:a}),style:{maxHeight:m},children:[t.jsx(Un,{value:i,onChange:I=>{l(I.target.value),h(0)},onClear:()=>l(""),onKeyDown:V,placeholder:"Search appchains",rootClassName:ge.search,ref:Rn()}),t.jsx("div",{className:ge.viewport,role:"listbox",children:v.length===0?t.jsx(he,{children:"No appchains found"}):v.map(({chainId:I,name:w,logoUrl:E},U)=>t.jsxs("div",{className:L(ge.item,{[ge.highlighted]:U===u,[ge.active]:e===I}),onClick:()=>M(I),onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),M(I))},onMouseEnter:()=>h(U),role:"option","aria-selected":e===I,tabIndex:-1,ref:F=>{F&&(p.current[U]=F)},children:[t.jsxs("div",{className:ge.itemContent,children:[typeof E=="string"?t.jsx(X,{src:E,width:16,height:16,logo:!0}):E(16),t.jsx("span",{className:ge.name,children:w}),I===r&&t.jsx("span",{className:ge.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:ge.extra,children:o(I)})]},I))})]})})]})]})},O1="_container_1nap1_1",V1="_controls_1nap1_7",K1="_search_1nap1_13",ta={container:O1,controls:V1,search:K1},z1=({children:e})=>t.jsx("div",{className:ta.container,children:e}),W1=({children:e})=>t.jsx("div",{className:ta.controls,children:e}),H1=e=>t.jsx(Un,{...e,rootClassName:ta.search}),Qe={Root:z1,Controls:W1,SearchInput:H1},Di=W.atom(""),Bi=W.atom(""),Q1=W.atom(""),G1=W.atom(""),Y1=W.atom(""),Z1="_change_1x9v4_1",J1="_positive_1x9v4_10",X1="_negative_1x9v4_14",no={change:Z1,positive:J1,negative:X1},Ri=({amount:e,asset:n})=>{const{denom:s,symbol:o,decimals:a}=n,r=new B(e).isPositive(),i=new B(e).abs().toString();return t.jsxs("div",{className:L(no.change,r?no.positive:no.negative),children:[r?"+":"-",j.formatAmount(i,{decimals:a})," ",o||s]})},ey=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(Ri,{amount:o,asset:s(a)},r))},ty=({changes:e,chain:n})=>{const s=lt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(oi,{metadata:a,chain:n,children:i=>t.jsx(Ri,{amount:o,asset:s(i)})},r))},ny=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=De();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(ty,{changes:si(e,o),chain:n}):t.jsx(ey,{changes:ni(e,s),chain:n})},sy="_message_1g2hc_1",oy="_more_1g2hc_8",Ua={message:sy,more:oy},ay=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Ua.message,children:hs.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Ua.more,children:`+${e.length-3} more`})]}),ry="_link_fuhbt_1",iy="_inner_fuhbt_16",cy="_header_fuhbt_21",ly="_time_fuhbt_30",dy="_error_fuhbt_36",uy="_timestamp_fuhbt_40",my="_chainInfo_fuhbt_45",hy="_content_fuhbt_53",py="_messages_fuhbt_61",fy="_changes_fuhbt_67",at={link:ry,inner:iy,header:cy,time:ly,error:dy,timestamp:uy,chainInfo:my,content:hy,messages:py,changes:fy},gy=({txItem:e,chain:n})=>t.jsx(ks,{txHash:e.txhash,chainId:n.chainId,className:at.link,children:t.jsxs("div",{className:at.inner,children:[t.jsxs("div",{className:at.header,children:[t.jsxs("div",{className:at.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:at.error}),t.jsx("span",{className:at.timestamp,children:Ge.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:at.chainInfo,children:[t.jsx(X,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:at.content,children:[t.jsx("div",{className:at.messages,children:t.jsx(ay,{messages:e.tx.body.messages})}),t.jsx("div",{className:at.changes,children:t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(ny,{...e,chain:n})})})]})]})}),_y="_list_1mv55_1",xy="_dateGroup_1mv55_7",yy="_dateHeader_1mv55_12",jy="_more_1mv55_18",ns={list:_y,dateGroup:xy,dateHeader:yy,more:jy},by=({list:e,chainId:n})=>{const s=te(),o=_.useMemo(()=>xi(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?t.jsx(he,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ns.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:ns.dateGroup,children:[t.jsx("div",{className:ns.dateHeader,children:a}),r.map(i=>t.jsx(me,{errorBoundaryProps:{fallback:null},children:t.jsx(gy,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(ks,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:ns.more,showIcon:!0,children:"View more on Initia Scan"})]})},wy=()=>{const{activities:e,isLoading:n}=tu(),[s,o]=W.useAtom(Y1),a=ae(),r=_.useMemo(()=>Array.from(new Set(e.map(l=>l.chain.chainId))),[e]),i=_.useMemo(()=>s?e.filter(l=>l.chain.chainId===s):e,[e,s]);return n&&e.length===0?t.jsx(he,{children:"Loading activities..."}):!e.length&&!n?t.jsx(he,{children:"No activity yet"}):t.jsxs(Qe.Root,{children:[t.jsx(Qe.Controls,{children:t.jsx(qs,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(by,{list:i,chainId:s||a.chainId})]})},vy="_thumbnail_1xyqw_1",Cy="_placeholder_1xyqw_18",Ny="_clickable_1xyqw_24",xn={thumbnail:vy,placeholder:Cy,clickable:Ny},Iy=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:l}=Y(),c=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,l).toString();return s?t.jsx("button",{className:L(xn.thumbnail,xn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})}):t.jsx("div",{className:xn.thumbnail,style:{width:n,height:n},children:t.jsx(X,{src:c,classNames:{placeholder:xn.placeholder}})})},ky="_collectionName_qs5tw_1",Sy="_nftName_qs5tw_6",Ay="_chainInfo_qs5tw_10",so={collectionName:ky,nftName:Sy,chainInfo:Ay},na=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:l}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(Iy,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:L(so.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:L(so.nftName,a?.nftName),children:i}),t.jsxs("div",{className:L(so.chainInfo,a?.chainInfo),children:[t.jsx(X,{src:l.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:l.name})]})]})]})},sa=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function Ty(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function $y(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const Ey=()=>{const e=te(),n=de(),s=T.useQueries({queries:n.map(c=>({queryKey:sa.nfts(c.indexerUrl,e).queryKey,queryFn:()=>ar(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:c.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map(A.prop("data")),a=$y(n,o),r=a.reduce((c,{chain:d})=>({...c,[d.chainId]:(c[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((c,d)=>c+d,0),l=s.some(c=>c.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}};function qy(e){const n=Oa(e);return T.useQuery({queryKey:sa.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await z.get(n).json();return{...s,image:Oa(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function Oa(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Ly=({nftInfo:e,children:n})=>{const{data:s={}}=qy(e.nft.uri),o=Ty(e,s);return n(o)},My="_grid_1wwdn_1",Py="_root_1wwdn_7",Dy="_collectionName_1wwdn_15",By="_nftName_1wwdn_23",Ry="_chainInfo_1wwdn_32",Va={grid:My,root:Py,collectionName:Dy,nftName:By,chainInfo:Ry},Fy=()=>{const[e,n]=W.useAtom(Q1),[s,o]=W.useAtom(G1),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:l}=Ey(),c=Ce(),d=_.useMemo(()=>a.filter(({collection_addr:h,collection_name:m,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const x=e.trim().toLowerCase();return h.toLowerCase().includes(x)||m.toLowerCase().includes(x)||f.token_id.toLowerCase().includes(x)||p.toLowerCase().includes(x)}return!0}),[a,s,e]),u=_.useMemo(()=>Array.from(new Set(a.map(({chain:h})=>h.chainId))),[a]);return l&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!l?t.jsx(he,{children:"No NFTs"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(qs,{value:s,onChange:o,chainIds:u,renderExtra:h=>h?r[h]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:Va.grid,children:d.map(h=>{const{collection_addr:m,nft:f}=h;return t.jsx(Ly,{nftInfo:h,children:p=>t.jsx(na,{normalizedNft:p,onThumbnailClick:()=>c("/nft",p),classNames:Va})},m+f.token_id)})})]})},Fi=_.createContext(null);function Ui(){return _.useContext(Fi)}const Uy="_popup_nbecp_1",Oy="_item_nbecp_19",ss={popup:Uy,item:Oy},Oi=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:l,chain:c}=e,{chainId:d}=c,[u,h]=_.useState(!1),m=Ce(),f=Ui(),{showNotification:p}=Ss(),{defaultChainId:g}=Y(),{evm_chain_id:x}=Vt(),y=ve.useChainId(),{switchChainAsync:b}=ve.useSwitchChain(),{watchAssetAsync:C}=ve.useWatchAsset(),v=()=>{h(!1),m("/send",{denom:s,chain:c})},N=()=>{h(!1),m("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=T.useMutation({mutationFn:async()=>{if(!l)throw new Error("Address is required");const $=r;return await b({chainId:Number(x)}),C({type:"ERC20",options:{address:l,symbol:a,decimals:o,image:$}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:$=>{p({type:"error",title:"Asset addition failed",description:$.message})}});return t.jsxs(ht.Menu.Root,{open:u,onOpenChange:h,modal:!1,children:[t.jsx(ht.Menu.Trigger,{render:n}),t.jsx(ht.Menu.Portal,{container:f,children:t.jsx(ht.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(ht.Menu.Popup,{className:ss.popup,children:[t.jsxs(ht.Menu.Item,{className:ss.item,onClick:v,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(ht.Menu.Item,{className:ss.item,onClick:N,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&x===y&&!!l&&t.jsxs(ht.Menu.Item,{className:ss.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},Vy="_item_38qhm_1",Ky="_info_38qhm_23",zy="_images_38qhm_29",Wy="_name_38qhm_33",Hy="_value_38qhm_39",Qy="_amount_38qhm_47",Gy="_usd_38qhm_53",Mt={item:Vy,info:Ky,images:zy,name:Wy,value:Hy,amount:Qy,usd:Gy},Yy=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=j.formatAmount(n,{decimals:e.decimals});return t.jsx(Oi,{asset:e,children:t.jsxs("button",{className:Mt.item,children:[t.jsxs("div",{className:Mt.info,children:[t.jsx(Ts,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Mt.images}),t.jsx("span",{className:Mt.name,children:a.name})]}),t.jsxs("div",{className:Mt.value,children:[t.jsx("span",{className:Mt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Mt.usd,children:ee(s)})]})]})})},Zy="_container_ytg3p_1",Jy="_assetItem_ytg3p_6",Xy="_expandIcon_ytg3p_22",e2="_assetInfo_ytg3p_27",t2="_logo_ytg3p_33",n2="_details_ytg3p_37",s2="_symbol_ytg3p_42",o2="_chainName_ytg3p_53",a2="_chainInfos_ytg3p_59",r2="_chainLogos_ytg3p_65",i2="_chainLogo_ytg3p_65",c2="_moreChains_ytg3p_76",l2="_expanded_ytg3p_93",d2="_valueColumn_ytg3p_98",u2="_amount_ytg3p_108",m2="_value_ytg3p_98",h2="_collapsibleContent_ytg3p_121",p2="_chainsList_ytg3p_151",pe={container:Zy,assetItem:Jy,expandIcon:Xy,assetInfo:e2,logo:t2,details:n2,symbol:s2,chainName:o2,chainInfos:a2,chainLogos:r2,chainLogo:i2,moreChains:c2,expanded:l2,valueColumn:d2,amount:u2,value:m2,collapsibleContent:h2,chainsList:p2},f2=W.atom([]),oa=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=W.useAtom(f2),l=_.useMemo(()=>Oc(e),[e]),c=_.useMemo(()=>qr(e),[e]),d=r.includes(n),u=()=>{i(m=>d?m.filter(f=>f!==n):[...new Set([...m,n])])},h=()=>t.jsxs("button",{className:pe.assetItem,children:[t.jsxs("div",{className:pe.assetInfo,children:[s&&t.jsx(X,{src:s,width:32,height:32,className:pe.logo,logo:!0}),t.jsxs("div",{className:pe.details,children:[t.jsx("div",{className:pe.symbol,children:n}),a?t.jsx("div",{className:pe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:pe.chainInfos,children:[t.jsx("div",{className:pe.chainLogos,children:o.slice(0,5).map(({chain:m})=>t.jsx(X,{src:m.logoUrl,width:16,height:16,className:pe.chainLogo,logo:!0},m.chainId))}),o.length>5&&t.jsxs("span",{className:pe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:L(pe.expandIcon,{[pe.expanded]:d})})]})]})]}),t.jsxs("div",{className:pe.valueColumn,children:[t.jsx("div",{className:pe.amount,children:j.formatNumber(l,{dp:o[0].unlisted?0:6})}),c>0&&t.jsx("div",{className:pe.value,children:ee(c)})]})]});if(a){const[m]=o;return t.jsx("div",{className:pe.container,children:t.jsx(Oi,{asset:m,children:h()})})}return t.jsx("div",{className:pe.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:h()}),t.jsx(J.Collapsible.Content,{className:pe.collapsibleContent,children:t.jsx("div",{className:pe.chainsList,children:o.map(m=>t.jsx(Yy,{asset:m},m.chain.chainId))})})]})})},g2="_collapsible_1g7rh_1",_2="_trigger_1g7rh_5",x2="_divider_1g7rh_20",y2="_label_1g7rh_28",j2="_chevron_1g7rh_33",b2="_content_1g7rh_41",w2="_list_1g7rh_45",Nt={collapsible:g2,trigger:_2,divider:x2,label:y2,chevron:j2,content:b2,list:w2},Vi=({unlistedAssets:e})=>{const[n,s]=_.useState(!1),o=Ui(),a=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{if(a.current){const h=a.current.scrollHeight;i(h)}},[e]);const l=_.useRef(null),c=h=>{s(h),h&&l.current&&o?.current&&window.setTimeout(()=>{if(!l.current||!a.current||!o?.current)return;const m=o.current,f=m.getBoundingClientRect(),p=l.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const y=p.top-f.top+m.scrollTop-16;m.scrollTo({top:y,behavior:"smooth"})}},50)},d=rt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),u=_.useMemo(()=>e.map(h=>({...h,assets:[h],totalValue:h.value??0,totalAmount:Number(h.quantity)})),[e]);return e.length===0?null:t.jsxs(J.Collapsible.Root,{open:n,onOpenChange:c,className:Nt.collapsible,children:[t.jsxs(J.Collapsible.Trigger,{ref:l,className:Nt.trigger,children:[t.jsx("div",{className:Nt.divider}),t.jsxs("span",{className:Nt.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:Nt.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:Nt.divider})]}),t.jsx(J.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(rt.animated.div,{className:Nt.content,style:d,children:t.jsx("div",{className:Nt.list,ref:a,children:u.map(h=>t.jsx(oa,{assetGroup:h},h.assets[0].denom))})})})]})},v2="_container_15xfg_1",C2="_header_15xfg_7",N2="_title_15xfg_13",I2="_totalValue_15xfg_19",k2="_list_15xfg_26",tn={container:v2,header:C2,title:N2,totalValue:I2,list:k2},S2=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:l,isLoading:c}=Lo(),d=i.map(({chainId:m})=>m),u=_.useMemo(()=>{const m=e?a.filter(p=>{const{symbol:g,assets:x}=p;return g.toLowerCase().includes(e.toLowerCase())||x.some(({denom:y,address:b})=>y.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?m.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===s)})).filter(p=>p.assets.length>0):m},[a,e,s]),h=_.useMemo(()=>{const m=e?r.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):r;return s?m.filter(({chain:p})=>p.chainId===s):m},[r,e,s]);return c&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!u.length&&!h.length&&!e&&!s&&!c?t.jsx(he,{children:"No assets"}):t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:m=>n(m.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(qs,{value:s,onChange:o,chainIds:d,renderExtra:m=>{if(!m)return ee(l);const f=i.find(p=>p.chainId===m);return f?ee(f.value):null}})]}),t.jsx("div",{children:u.length===0&&h.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:tn.list,children:u.map(m=>t.jsx(oa,{assetGroup:m},m.symbol))}),t.jsx(Vi,{unlistedAssets:h})]})})]})},A2="_container_11k2x_1",T2={container:A2},He=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Ut,{height:e,width:s}):t.jsx("div",{className:T2.container,children:o.map(a=>t.jsx(Ut,{height:e,width:s},a))})},$2=_.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:l}=Pn(),c=ae(),{listedGroups:d,unlistedAssets:u}=_.useMemo(()=>kl(i,a,r,c.chainId),[i,a,r,c.chainId]),h=_.useMemo(()=>vl(d,s,o),[d,s,o]),{filteredAssets:m,totalAssetsValue:f,filteredUnlistedAssets:p}=_.useMemo(()=>Il(h,u,e,n),[h,u,e,n]);return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.header,children:[t.jsx("span",{className:tn.title,children:"Assets"}),m.length>0&&t.jsx("span",{className:tn.totalValue,children:ee(f)})]}),m.length>0?t.jsxs("div",{children:[t.jsx("div",{className:tn.list,children:m.map(g=>t.jsx(oa,{assetGroup:g},g.symbol))}),t.jsx(Vi,{unlistedAssets:p})]}):h.length===0&&l?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),E2=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function Ki(){const{civitiaUrl:e}=Y(),n=te();return T.useQuery({enabled:!!n,queryKey:E2.player(e,n??"").queryKey,queryFn:async()=>{if(!n)throw new Error("address is not available");return z.get(`${e}/players/${n}`).json()},staleTime:K.MINUTE,throwOnError:!1})}const q2="_section_xdyfz_2",L2="_row_xdyfz_15",M2="_rowLeft_xdyfz_23",P2="_rowIcon_xdyfz_29",D2="_goldIcon_xdyfz_38",B2="_silverIcon_xdyfz_46",R2="_rowTitle_xdyfz_54",F2="_rowValue_xdyfz_60",U2="_rowSubtitle_xdyfz_67",Ie={section:q2,row:L2,rowLeft:M2,rowIcon:P2,goldIcon:D2,silverIcon:B2,rowTitle:R2,rowValue:F2,rowSubtitle:U2},O2=()=>{const{data:e,isLoading:n}=Ki();if(n)return t.jsx(He,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ie.section,children:[t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.goldIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Gold"})]}),t.jsx("span",{className:L(Ie.rowValue,s===0&&Ie.rowSubtitle),children:s===0?"—":j.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ie.row,children:[t.jsxs("div",{className:Ie.rowLeft,children:[t.jsx("div",{className:L(Ie.rowIcon,Ie.silverIcon)}),t.jsx("span",{className:Ie.rowTitle,children:"Silver"})]}),t.jsx("span",{className:L(Ie.rowValue,o===0&&Ie.rowSubtitle),children:o===0?"—":j.formatNumber(o,{dp:6})})]})]})},V2="_container_1n61l_1",K2="_section_1n61l_7",z2="_sectionHeader_1n61l_19",W2="_sectionTitle_1n61l_25",H2="_sectionLabel_1n61l_31",Q2="_externalLink_1n61l_37",G2="_sectionValue_1n61l_49",Y2="_tokenList_1n61l_56",Z2="_stakingTokenList_1n61l_62",J2="_tokenRow_1n61l_72",X2="_tokenMain_1n61l_78",e0="_tokenTrigger_1n61l_84",t0="_tokenChevron_1n61l_100",n0="_expanded_1n61l_111",s0="_triggerValue_1n61l_115",o0="_tokenInfo_1n61l_122",a0="_tokenInfoLabel_1n61l_128",r0="_tokenLogo_1n61l_134",i0="_tokenSymbol_1n61l_138",c0="_tokenValues_1n61l_144",l0="_tokenAmount_1n61l_150",d0="_tokenValue_1n61l_144",u0="_typeBreakdown_1n61l_164",m0="_typeRow_1n61l_172",h0="_typeLabel_1n61l_180",p0="_typeValues_1n61l_186",f0="_typeAmount_1n61l_192",g0="_typeValue_1n61l_186",_0="_collapsibleContent_1n61l_206",G={container:V2,section:K2,sectionHeader:z2,sectionTitle:W2,sectionLabel:H2,externalLink:Q2,sectionValue:G2,tokenList:Y2,stakingTokenList:Z2,tokenRow:J2,tokenMain:X2,tokenTrigger:e0,tokenChevron:t0,expanded:n0,triggerValue:s0,tokenInfo:o0,tokenInfoLabel:a0,tokenLogo:r0,tokenSymbol:i0,tokenValues:c0,tokenAmount:l0,tokenValue:d0,typeBreakdown:u0,typeRow:m0,typeLabel:h0,typeValues:p0,typeAmount:f0,typeValue:g0,collapsibleContent:_0},zi=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=_.useMemo(()=>{const l=e.flatMap(c=>c.positions);return hl(l)},[e]);return i.size===0?null:t.jsx("div",{className:G.container,children:Array.from(i.entries()).map(([l,c])=>t.jsx(x0,{sectionKey:l,sectionGroup:c,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},l))})},x0=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:l,totalValue:c}=n,d=ml(e,o),u=_.useMemo(()=>jl(l),[l]),h=e==="staking";return t.jsxs("div",{className:G.section,children:[t.jsxs("div",{className:G.sectionHeader,children:[t.jsxs("div",{className:G.sectionTitle,children:[t.jsx("span",{className:G.sectionLabel,children:d}),h&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:G.externalLink,onClick:m=>m.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:G.sectionValue,children:ee(c)})]}),t.jsx("div",{className:L(G.tokenList,{[G.stakingTokenList]:h}),children:u.map(m=>t.jsx(y0,{group:m,showTypeBreakdown:h,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},m.denom))})]})},y0=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:l,totalValue:c,positions:d}=e,u=s.get(r),[h,m]=_.useState(!1),f=_.useMemo(()=>{if(!n)return null;const p=xl(d);return p.size>0?p:null},[d,n]);return f?t.jsxs(J.Collapsible.Root,{open:h,onOpenChange:m,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:G.tokenTrigger,children:[t.jsxs("div",{className:G.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(G.tokenChevron,{[G.expanded]:h})}),t.jsxs("div",{className:G.tokenInfoLabel,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]})]}),t.jsx("span",{className:G.triggerValue,children:ee(c)})]})}),t.jsx(J.Collapsible.Content,{className:G.collapsibleContent,children:t.jsx(j0,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:G.tokenRow,children:t.jsxs("div",{className:G.tokenMain,children:[t.jsxs("div",{className:G.tokenInfo,children:[u?.assetLogo&&t.jsx(X,{src:u.assetLogo,width:20,height:20,className:G.tokenLogo}),t.jsx("span",{className:G.tokenSymbol,children:i})]}),t.jsxs("div",{className:G.tokenValues,children:[t.jsx("span",{className:G.tokenAmount,children:j.formatNumber(l,{dp:6})}),t.jsx("span",{className:G.tokenValue,children:ee(c)})]})]})})},j0=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=_.useMemo(()=>Array.from(e.entries()).map(([c,d])=>{const u=d.reduce((m,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?m:m+f.balance.formattedAmount,0),h=d.reduce((m,f)=>m+an(f),0);return{type:c,typeAmount:u,typeValue:h}}),[e]),i=_.useMemo(()=>{if(!o)return 0;let c=0;for(const{type:d}of r){const u=o(s,d);c+=Number(u)}return c},[s,o,r]),l=i>0;return t.jsxs("div",{className:G.typeBreakdown,children:[r.map(({type:c,typeAmount:d,typeValue:u})=>t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:_l(c)}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:G.typeValue,children:ee(u)})]})]},c)),l&&t.jsxs("div",{className:G.typeRow,children:[t.jsx("span",{className:G.typeLabel,children:"Claimable"}),t.jsxs("div",{className:G.typeValues,children:[t.jsxs("span",{className:G.typeAmount,children:[j.formatNumber(i,{dp:6})," ",We]}),t.jsx("span",{className:G.typeValue,children:ee(i*(a??0))})]})]})]})},b0="_container_ymkoc_1",w0="_trigger_ymkoc_6",v0="_expandIcon_ymkoc_22",C0="_chainInfo_ymkoc_27",N0="_logo_ymkoc_33",I0="_chainNameContainer_ymkoc_37",k0="_chainName_ymkoc_37",S0="_externalLink_ymkoc_49",A0="_externalIcon_ymkoc_53",T0="_valueColumn_ymkoc_63",$0="_value_ymkoc_63",E0="_expanded_ymkoc_80",q0="_collapsibleContent_ymkoc_85",L0="_content_ymkoc_97",Te={container:b0,trigger:w0,expandIcon:v0,chainInfo:C0,logo:N0,chainNameContainer:I0,chainName:k0,externalLink:S0,externalIcon:A0,valueColumn:T0,value:$0,expanded:E0,collapsibleContent:q0,content:L0},M0=W.atom([]),P0=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=_.useMemo(()=>{const d=new Map;for(const u of o)for(const h of u.positions){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:m,symbol:f}=h.balance,p=f.toUpperCase(),g=`${n}:${m}`,x=i.get(g)??l.get(p);x&&d.set(m,{assetLogo:x,chainLogo:s??""})}return d},[o,i,l,n,s]);return t.jsx(zi,{protocols:o,denomLogoMap:c})},D0=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=W.useAtom(M0),l=_.useMemo(()=>o.reduce((p,g)=>p+g.positions.reduce((x,y)=>x+an(y),0),0),[o]),c=["civitia","yominet"],d=r.includes(n),u=n?.toLowerCase(),h=u==="civitia",m=c.includes(u),f=()=>{i(p=>d?p.filter(g=>g!==n):[...new Set([...p,n])])};return t.jsx("div",{className:Te.container,children:t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[s&&t.jsx(X,{src:s,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:p=>p.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[!m&&t.jsx("span",{className:Te.value,children:ee(l)}),t.jsx(S.IconChevronDown,{size:16,className:L(Te.expandIcon,{[Te.expanded]:d})})]})]})}),t.jsx(J.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(P0,{chainGroup:e}),h&&t.jsx(O2,{})]})})]})})},B0="_container_1gqx9_1",R0="_section_1gqx9_6",F0="_sectionHeader_1gqx9_14",U0="_sectionTitle_1gqx9_20",O0="_sectionLabel_1gqx9_26",V0="_externalLink_1gqx9_32",K0="_sectionValue_1gqx9_44",z0="_tokenList_1gqx9_51",W0="_tokenTrigger_1gqx9_63",H0="_tokenChevron_1gqx9_79",Q0="_expanded_1gqx9_90",G0="_tokenInfo_1gqx9_94",Y0="_tokenInfoLabel_1gqx9_100",Z0="_tokenLogo_1gqx9_106",J0="_pairedLogos_1gqx9_110",X0="_coinLogo_1gqx9_115",ej="_tokenSymbol_1gqx9_133",tj="_triggerValue_1gqx9_139",nj="_breakdownContent_1gqx9_146",sj="_breakdownRow_1gqx9_154",oj="_breakdownLabel_1gqx9_162",aj="_breakdownValues_1gqx9_168",rj="_breakdownAmount_1gqx9_174",ij="_breakdownValue_1gqx9_168",cj="_collapsibleContent_1gqx9_195",se={container:B0,section:R0,sectionHeader:F0,sectionTitle:U0,sectionLabel:O0,externalLink:V0,sectionValue:K0,tokenList:z0,tokenTrigger:W0,tokenChevron:H0,expanded:Q0,tokenInfo:G0,tokenInfoLabel:Y0,tokenLogo:Z0,pairedLogos:J0,coinLogo:X0,tokenSymbol:ej,triggerValue:tj,breakdownContent:nj,breakdownRow:sj,breakdownLabel:oj,breakdownValues:aj,breakdownAmount:rj,breakdownValue:ij,collapsibleContent:cj},lj=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:se.container,children:t.jsxs("div",{className:se.section,children:[t.jsxs("div",{className:se.sectionHeader,children:[t.jsxs("div",{className:se.sectionTitle,children:[t.jsx("span",{className:se.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:se.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:se.sectionValue,children:ee(s)})]}),t.jsx("div",{className:se.tokenList,children:o.map(a=>t.jsx(uj,{row:a,denomLogoMap:n},a.denom))})]})})},dj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},uj=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:l,claimableInit:c}=e,[d,u]=_.useState(!1),h=n.get(s),m=i||h?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=_.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),g=l&&l.length>0&&l.some(y=>y),x=c&&Number(c.total)>0;return t.jsxs(J.Collapsible.Root,{open:d,onOpenChange:u,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:se.tokenTrigger,children:[t.jsxs("div",{className:se.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(se.tokenChevron,{[se.expanded]:d})}),t.jsxs("div",{className:se.tokenInfoLabel,children:[g?t.jsx("div",{className:se.pairedLogos,children:l.map((y,b)=>t.jsx(X,{src:y,width:20,height:20,className:se.coinLogo,logo:!0},b))}):m&&t.jsx(X,{src:m,width:20,height:20,className:se.tokenLogo}),t.jsx("span",{className:se.tokenSymbol,children:o})]})]}),t.jsx("span",{className:se.triggerValue,children:ee(a)})]})}),t.jsx(J.Collapsible.Content,{className:se.collapsibleContent,children:t.jsxs("div",{className:se.breakdownContent,children:[p.map(([y,b])=>{const C=b*f;return t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:dj[y]}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(b,{dp:6})," LP"]}),t.jsx("span",{className:se.breakdownValue,children:ee(C)})]})]},y)}),x&&t.jsxs("div",{className:se.breakdownRow,children:[t.jsx("span",{className:se.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:se.breakdownValues,children:[t.jsxs("span",{className:se.breakdownAmount,children:[j.formatNumber(Number(c.total),{dp:6})," ",We]}),t.jsx("span",{className:se.breakdownValue,children:ee(c.totalValue)})]})]})]})})]})},mj="_container_1nijk_1",hj="_section_1nijk_6",pj="_sectionHeader_1nijk_14",fj="_sectionTitle_1nijk_20",gj="_sectionLabel_1nijk_26",_j="_externalLink_1nijk_32",xj="_sectionValue_1nijk_44",yj="_tokenList_1nijk_51",jj="_tokenTrigger_1nijk_63",bj="_tokenChevron_1nijk_79",wj="_expanded_1nijk_90",vj="_tokenInfo_1nijk_94",Cj="_tokenInfoLabel_1nijk_100",Nj="_tokenLogo_1nijk_106",Ij="_tokenName_1nijk_110",kj="_triggerValue_1nijk_116",Sj="_breakdownContent_1nijk_123",Aj="_breakdownRow_1nijk_131",Tj="_breakdownLabel_1nijk_139",$j="_breakdownValues_1nijk_145",Ej="_breakdownAmount_1nijk_151",qj="_breakdownValue_1nijk_145",Lj="_collapsibleContent_1nijk_165",ce={container:mj,section:hj,sectionHeader:pj,sectionTitle:fj,sectionLabel:gj,externalLink:_j,sectionValue:xj,tokenList:yj,tokenTrigger:jj,tokenChevron:bj,expanded:wj,tokenInfo:vj,tokenInfoLabel:Cj,tokenLogo:Nj,tokenName:Ij,triggerValue:kj,breakdownContent:Sj,breakdownRow:Aj,breakdownLabel:Tj,breakdownValues:$j,breakdownAmount:Ej,breakdownValue:qj,collapsibleContent:Lj},Mj=({data:e})=>{const{totalValue:n,rows:s}=e;return s.length===0?null:t.jsx("div",{className:ce.container,children:t.jsxs("div",{className:ce.section,children:[t.jsxs("div",{className:ce.sectionHeader,children:[t.jsxs("div",{className:ce.sectionTitle,children:[t.jsx("span",{className:ce.sectionLabel,children:"VIP"}),t.jsx("a",{href:Cc,target:"_blank",rel:"noopener noreferrer",className:ce.externalLink,onClick:o=>o.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:ce.sectionValue,children:ee(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(Pj,{row:o},`${o.bridgeId}-${o.version}`))})]})})},Pj=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[l,c]=_.useState(!1),d=a+i;return t.jsxs(J.Collapsible.Root,{open:l,onOpenChange:c,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:ce.tokenTrigger,children:[t.jsxs("div",{className:ce.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:L(ce.tokenChevron,{[ce.expanded]:l})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(X,{src:s,width:20,height:20,className:ce.tokenLogo,logo:!0}),t.jsx("span",{className:ce.tokenName,children:n})]})]}),t.jsx("span",{className:ce.triggerValue,children:ee(d)})]})}),t.jsx(J.Collapsible.Content,{className:ce.collapsibleContent,children:t.jsxs("div",{className:ce.breakdownContent,children:[o>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Locked"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[j.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(a)})]})]}),r>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[j.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:ee(i)})]})]})]})})]})},Dj="_container_ymkoc_1",Bj="_trigger_ymkoc_6",Rj="_expandIcon_ymkoc_22",Fj="_chainInfo_ymkoc_27",Uj="_logo_ymkoc_33",Oj="_chainNameContainer_ymkoc_37",Vj="_chainName_ymkoc_37",Kj="_externalLink_ymkoc_49",zj="_externalIcon_ymkoc_53",Wj="_valueColumn_ymkoc_63",Hj="_value_ymkoc_63",Qj="_expanded_ymkoc_80",Gj="_collapsibleContent_ymkoc_85",Yj="_content_ymkoc_97",$e={container:Dj,trigger:Bj,expandIcon:Rj,chainInfo:Fj,logo:Uj,chainNameContainer:Oj,chainName:Vj,externalLink:Kj,externalIcon:zj,valueColumn:Wj,value:Hj,expanded:Qj,collapsibleContent:Gj,content:Yj},Zj=W.atom(!1),Jj=()=>{const{totalValue:e}=Bo(),{totalValue:n}=Fo(),{totalValue:s}=Cs(),o=e+n+s;return t.jsx("span",{className:$e.value,children:ee(o)})},Xj=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Bo(),{data:i}=Dr(),{data:l}=Br(),c=_.useMemo(()=>{const h=new Map;for(const m of r){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:f,symbol:p}=m.balance,g=p.toUpperCase(),x=`${e}:${f}`,y=s.get(x)??o.get(g);y&&h.set(f,{assetLogo:y,chainLogo:n})}return h},[r,s,o,e,n]),d=_.useMemo(()=>(h,m)=>{const f=j.denomToMetadata(h);if(m==="staking"){const p=i?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}if(m==="lockstaking"){const p=l?.get(f);return p?j.fromBaseUnit(p.amount,{decimals:Pe}):"0"}return"0"},[i,l]),u=_.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:So,positions:r}],[r]);return u.length===0?null:t.jsx(zi,{protocols:u,denomLogoMap:c,isInitia:!0,getClaimableInitByType:d,initPrice:a})},eb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=Fo(),r=_.useMemo(()=>{const i=new Map;for(const l of a.rows){const{denom:c,symbol:d}=l,u=d.toUpperCase(),h=`${e}:${c}`,m=s.get(h)??o.get(u);m&&i.set(c,{assetLogo:m,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(lj,{data:a,denomLogoMap:r})},tb=()=>{const e=Cs();return e.rows.length===0?null:t.jsx(Mj,{data:e})},nb=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=W.useAtom(Zj),i=de(),l=Sn(),{denomLogos:c,symbolLogos:d}=_.useMemo(()=>Uo(l,i),[l,i]),u=ae(),{data:h}=_t(u),m=_.useMemo(()=>h?.find(p=>p.id===Se)?.price??0,[h]);return t.jsx("div",{className:$e.container,children:t.jsxs(J.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(J.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:$e.trigger,children:[t.jsxs("div",{className:$e.chainInfo,children:[o&&t.jsx(X,{src:o,width:32,height:32,className:$e.logo,logo:!0}),t.jsxs("div",{className:$e.chainNameContainer,children:[t.jsx("span",{className:$e.chainName,children:s}),t.jsx("a",{href:So,target:"_blank",rel:"noopener noreferrer",className:$e.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:$e.externalIcon})})]})]}),t.jsxs("div",{className:$e.valueColumn,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(Jj,{})}),t.jsx(S.IconChevronDown,{size:16,className:L($e.expandIcon,{[$e.expanded]:a})})]})]})}),t.jsx(J.Collapsible.Content,{className:$e.collapsibleContent,children:t.jsxs("div",{className:$e.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(Xj,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d,initPrice:m})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:2}),children:t.jsx(eb,{chainId:n,chainLogo:o,denomLogos:c,symbolLogos:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:36,length:1}),children:t.jsx(tb,{})})]})})]})})},sb="_totalValue_1v2ca_1",ob={totalValue:sb},ab=({filteredChainGroups:e})=>{const{totalValue:n}=Bo(),{totalValue:s}=Fo(),{totalValue:o}=Cs(),a=n+s+o,r=_.useMemo(()=>{const i=e.some(c=>c.isInitia);return e.reduce((c,d)=>d.isInitia?c:c+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:ob.totalValue,children:ee(r)})},rb="_container_1eubu_1",ib="_header_1eubu_7",cb="_title_1eubu_13",lb="_list_1eubu_19",db="_skeletonWrapper_1eubu_24",yn={container:rb,header:ib,title:cb,list:lb,skeletonWrapper:db},ub=_.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Pn(),r=ae(),{data:i,isLoading:l}=Ki(),c=_.useMemo(()=>{const u=[];for(const m of o){if(!Array.isArray(m.positions))continue;const f=s.get(m.chainName.toLowerCase()),p=m.chainName.toLowerCase(),g=p==="civitia";if(n&&f?.chainId!==n)continue;const x=m.positions.some(N=>N.positions.some(k=>k.type!=="fungible-position")),y=g&&!l&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!x&&!y||e&&!p.includes(e.toLowerCase()))continue;const b=m.positions.filter(N=>e&&!N.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(N.positions)&&N.positions.length>0),C=r.chainId===f?.chainId,v=b.reduce((N,k)=>N+k.positions.reduce(($,q)=>$+an(q),0),0);u.push({chainId:f?.chainId??"",chainName:f?.prettyName??m.chainName,chainLogo:f?.logoUrl??"",protocols:b,isInitia:C,totalValue:v})}const h=["civitia","yominet"];return A.sortWith([A.descend(m=>m.isInitia??!1),A.ascend(m=>h.includes(m.chainName.toLowerCase())),A.descend(m=>m.totalValue??0),A.ascend(m=>m.chainName.toLowerCase())],u)},[o,s,e,n,r.chainId,i,l]),d=c.length>0;return t.jsxs("div",{className:yn.container,children:[t.jsxs("div",{className:yn.header,children:[t.jsx("span",{className:yn.title,children:"Positions"}),d&&t.jsx(me,{suspenseFallback:t.jsx(He,{height:16,width:60,length:1}),children:t.jsx(ab,{filteredChainGroups:c})})]}),d?t.jsx("div",{className:yn.list,children:c.map(u=>u.isInitia?t.jsx(me,{suspenseFallback:t.jsx("div",{className:yn.skeletonWrapper,children:t.jsx(He,{height:56,length:1})}),children:t.jsx(nb,{chainGroup:u})},u.chainName):t.jsx(D0,{chainGroup:u},u.chainName))}):o.length===0&&a?t.jsx(He,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),mb="_content_1w1ad_1",hb={content:mb},pb=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=Y(),o=ae(),a=Ll(),{totalValue:r}=Cs(),{chainIds:i,chainIdToValueMap:l,totalBalance:c}=_.useMemo(()=>{const d=new Map;let u=0;for(const m of a)d.set(m.chainId,m.totalBalance),u+=m.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),u+=r),{chainIds:A.sortWith([A.descend(m=>m===s),A.descend(m=>m===o.chainId),A.descend(m=>d.get(m)??0)],a.map(m=>m.chainId)),chainIdToValueMap:d,totalBalance:u}},[a,s,o,r]);return t.jsx(qs,{value:e,onChange:n,chainIds:i,renderExtra:d=>ee(d?l.get(d)??0:c)})},fb=()=>{const[e,n]=W.useAtom(Di),[s,o]=W.useAtom(Bi),a=de(),r=Sn(),{denomLogos:i,symbolLogos:l}=_.useMemo(()=>Uo(r,a),[r,a]),c=Co(),d=_.useMemo(()=>Vr(a,c),[a,c]),u=ql();return t.jsxs(Qe.Root,{children:[t.jsxs(Qe.Controls,{children:[t.jsx(Qe.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(me,{suspenseFallback:t.jsx(Ut,{height:44,width:132}),children:t.jsx(pb,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:hb.content,children:[t.jsx(me,{suspenseFallback:t.jsx(He,{height:48,length:5}),children:t.jsx($2,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:l,chainInfoMap:u,chainPrices:d})}),t.jsx(me,{suspenseFallback:t.jsx(He,{height:56,length:3}),children:t.jsx(ub,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},gb="_totalValue_5pf7e_1",_b="_totalLabel_5pf7e_7",xb="_totalAmount_5pf7e_13",yb="_loading_5pf7e_18",jb="_skeletonWrapper_5pf7e_23",bb="_nav_5pf7e_28",wb="_item_5pf7e_34",vb="_tabs_5pf7e_59",Cb="_tab_5pf7e_59",Ee={totalValue:gb,totalLabel:_b,totalAmount:xb,loading:yb,skeletonWrapper:jb,nav:bb,item:wb,tabs:vb,tab:Cb},Nb=()=>{const{totalValue:e,isLoading:n}=Lo();return t.jsx("div",{className:L(Ee.totalAmount,{[Ee.loading]:n}),children:ee(e)})},Ib=()=>{const e=Ml(),n=Pl(),s=Or(),o=e+s+n;return t.jsx("div",{className:Ee.totalAmount,children:ee(o)})},kb=()=>{mi(),$l();const e=Oo(),n=Ce(),s=_s(),o=_.useRef(null);return t.jsx(Fi.Provider,{value:o,children:t.jsxs(et,{ref:o,children:[t.jsxs("div",{className:Ee.totalValue,children:[t.jsx("div",{className:Ee.totalLabel,children:"Total value"}),t.jsx(me,{suspenseFallback:t.jsx("div",{className:Ee.skeletonWrapper,children:t.jsx(Ut,{height:48,width:120})}),children:e?t.jsx(Nb,{}):t.jsx(Ib,{})})]}),t.jsxs("div",{className:Ee.nav,children:[t.jsxs(nn,{to:"/send",className:Ee.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(nn,{to:"/bridge",className:Ee.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(nn,{to:"/receive",className:Ee.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(wt.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(wt.Tabs.List,{className:Ee.tabs,children:[t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/nfts",children:"NFTs"}),t.jsx(wt.Tabs.Tab,{className:Ee.tab,value:"/activity",children:"Activity"})]}),t.jsx(wt.Tabs.Panel,{value:"/",children:e?t.jsx(S2,{}):t.jsx(fb,{})}),t.jsx(wt.Tabs.Panel,{value:"/nfts",children:t.jsx(Fy,{})}),t.jsx(wt.Tabs.Panel,{value:"/activity",children:t.jsx(wy,{})})]})]})})},Sb="_root_th990_1",Ab="_collectionName_th990_9",Tb="_nftName_th990_13",$b="_chainInfo_th990_17",Eb="_attributes_th990_21",qb="_title_th990_24",Lb="_count_th990_29",Mb="_item_th990_33",Pb="_type_th990_39",Db="_value_th990_45",Pt={root:Sb,collectionName:Ab,nftName:Tb,chainInfo:$b,attributes:Eb,title:qb,count:Lb,item:Mb,type:Pb,value:Db},Bb=()=>{const e=Ce(),n=Je(),{attributes:s}=n;return t.jsxs(dt,{title:"NFT details",children:[t.jsx(na,{normalizedNft:n,chainIconSize:14,classNames:Pt}),t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Pt.attributes,children:[t.jsxs("header",{className:Pt.title,children:["Traits ",t.jsxs("span",{className:Pt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Pt.item,children:[t.jsx("div",{className:Pt.type,children:o}),t.jsx("div",{className:Pt.value,children:a})]},o))})]})]})};function Rb({balances:e,gasPrices:n,gas:s}){return n.map(({denom:o,amount:a})=>{const r=B(a).times(s).toFixed(0,B.ROUND_CEIL),i=e.find(l=>l.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>B(a).gte(o))}function Fb({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=Rb({balances:n,gasPrices:s,gas:a}),l=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&l){const d=B(r).minus(l.amount);return B.max(d,0).toString()}const c=i.find(d=>d.denom!==e)||i[0];if(!l&&e===c.denom){const d=B(r).minus(c.amount);return B.max(d,0).toString()}return B(r).toString()}const Ub=({chain:e,onSelect:n})=>{const s=xc(e);return t.jsx(On,{assets:s,onSelect:n})},Ob=({afterSelect:e})=>{const{watch:n,setValue:s}=_e.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,l]=_.useState(r),c=Ze(i),d=de(),u=h=>{if(o===i&&a===h){e();return}s("chainId",i),s("denom",h),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Ft.Stack,{children:t.jsx(Ft,{chains:d,value:i,onSelect:l})}),t.jsx(me,{suspenseFallback:t.jsx(On.Placeholder,{}),children:t.jsx(Ub,{chain:c,onSelect:u})},i)]})},Vb="_fields_brpej_1",Kb="_divider_brpej_11",Ka={fields:Vb,divider:Kb},zb=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),Wb=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=De(),{register:a,watch:r,setValue:i,handleSubmit:l,formState:c}=_e.useFormContext(),{errors:d}=c,{chainId:u,denom:h,recipient:m,quantity:f,memo:p}=r(),g=Ze(u),x=An(g),y=Vo(g),b=Ko(g),C=sr(h,g),{data:v}=_t(g),{decimals:N}=C,k=x.find(R=>R.denom===h)?.amount??"0",$=v?.find(({id:R})=>R===h)?.price,{data:q=0,isLoading:V}=T.useQuery({queryKey:zb.gas({chainId:u,denom:h,recipient:m,initiaAddress:n}).queryKey,queryFn:()=>{const R=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(m).bech32,amount:[{denom:h,amount:"1"}]})}];return s({messages:R,chainId:u})},enabled:j.InitiaAddress.validate(m),staleTime:K.INFINITY}),M=Math.ceil(q*on),I=Fb({denom:h,balances:x,gasPrices:y,lastFeeDenom:b,gas:M}),w=B(k).isZero(),U=y.some(({denom:R})=>R===h)&&V,F=w||U,{mutate:O,isPending:Z}=T.useMutation({mutationFn:({chainId:R,denom:P,quantity:Ne,recipient:je,memo:tt})=>{const Be=j.toBaseUnit(Ne,{decimals:N}),Wt=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ua.MsgSend.fromPartial({fromAddress:n,toAddress:j.InitiaAddress(je).bech32,amount:[{denom:P,amount:Be}]})}];return o({messages:Wt,memo:tt,chainId:R,gas:q,gasAdjustment:on,gasPrices:y,spendCoins:[{denom:P,amount:Be}],internal:"/"})}}),H=_.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!m)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,m,d.quantity,d.recipient,d.memo]);return t.jsx(dt,{title:"Send",children:t.jsxs("form",{onSubmit:l(R=>O(R)),children:[t.jsxs("div",{className:Ka.fields,children:[t.jsx(mo,{selectButton:t.jsx(rn,{title:"Select chain and asset",content:R=>t.jsx(Ob,{afterSelect:R}),children:t.jsx(gi,{asset:C,chain:g})}),quantityInput:t.jsx(In,{balance:k,decimals:N}),balanceButton:t.jsx(hi,{onClick:()=>i("quantity",j.fromBaseUnit(I,{decimals:N}),{shouldValidate:!0}),disabled:F,children:j.formatAmount(k??"0",{decimals:N})}),value:f?$?ee(B(f).times($)):"$-":"$0"}),t.jsx("div",{className:Ka.divider}),t.jsx(Qo,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:R=>!R||new Blob([R]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(fe.Stack,{children:!p&&t.jsx(fe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:(V?"Estimating gas...":!1)||Z,disabled:!!H,children:H??"Confirm"})})]})})},Hb=()=>{const e=Je(),n=Vt(),s=gt(n),{chain:o=n}=e,a=A.head(s);if(!e.denom&&!a)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const r=e.denom??a?.denom,i=_e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(_e.FormProvider,{...i,children:t.jsx(Wb,{})})};async function yo(e,n){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function Qb(e,n){const s=new pt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:j.InitiaAddress("0x1").bech32,contract_addr:j.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function Gb(e,n,s){if(n.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function Yb({collection_addr:e},{restUrl:n}){const s=await Qb(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await yo(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${j.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function Zb(e,n){const{data:s}=await z.create({prefixUrl:n}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function Jb({object_addr:e,collection_addr:n},{restUrl:s}){const o=await Zb(n,s);return o.startsWith("ibc/")?j.InitiaAddress.equals(j.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await yo(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await yo(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function Xb(e,n){const s=ie.toBase64(Dt.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function ew(e,n){const{collection:s}=await z.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function tw(e,n){const s=ie.toBase64(Dt.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function za(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function nw({collection_addr:e},n,s){const o=j.InitiaAddress(e).bech32,a=await Xb(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:g,version:x})=>g===s.chain_id&&x.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,l=i.split(".")[1],c=ie.toBase64(Dt.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${l}/smart/${c}`).json(),u=d??o,h=await tw(l,n.restUrl),m=await ew(o,n.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:h};if(d&&m!==i.replace("wasm.","")){const[g,x]=za(d);return{class_id:o,class_trace:{path:g,base_class_id:x},outgoing_proxy:h}}const[f,p]=za(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:h}}const sw={minimove:Jb,minievm:Yb,miniwasm:nw};async function ow({nft:e,srcChain:n,intermediaryChain:s}){const o=n.metadata?.is_l1?"minimove":n.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await sw[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await Gb([e.token_id],a.class_id,n.restUrl)})}const aw="_root_1tyvn_1",rw="_collectionName_1tyvn_10",iw="_nftName_1tyvn_15",cw="_chainInfo_1tyvn_19",lw="_fields_1tyvn_24",dw="_chain_1tyvn_19",oo={root:aw,collectionName:rw,nftName:iw,chainInfo:cw,fields:lw,chain:dw},uw=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),mw=()=>{const e=de(),n=Je(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=Y(),r=En(),i=ae(),{address:l,initiaAddress:c,requestTxSync:d}=De(),{watch:u,setValue:h,handleSubmit:m,formState:f}=_e.useFormContext(),{errors:p}=f,g=u(),{recipient:x,dstChainId:y}=g,b=Ze(y),C=T.useQuery({queryKey:uw.simulation({collection_addr:o,nft:n,sender:c,recipient:x,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const I=Object.assign({from_address:c,from_chain_id:s.chainId,to_address:j.InitiaAddress(x).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==b.chainId&&await ow({nft:n,srcChain:s,intermediaryChain:i})),{msgs:w}=await z.create({prefixUrl:a}).post("nft",{json:I}).json();return w.map(E=>r.fromAmino(E))},enabled:j.InitiaAddress.validate(x)}),{data:v,isLoading:N,error:k}=C,$=T.useQueryClient(),{mutate:q,isPending:V}=T.useMutation({mutationFn:async()=>{if(!v)throw new Error("Route not found");await d({messages:v,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{$.invalidateQueries({queryKey:sa.nfts._def})}}),M=_.useMemo(()=>{if(!x)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(k)return"Route not found"},[x,p.recipient,k]);return t.jsxs("form",{onSubmit:m(()=>q()),children:[t.jsx(na,{normalizedNft:n,thumbnailSize:80,classNames:oo}),t.jsxs("div",{className:oo.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(rn,{title:"Destination appchain",content:I=>t.jsx(fi,{onSelect:({chainId:w})=>{h("dstChainId",w),I()},list:e,getImage:w=>w.logoUrl,getName:w=>w.name,getKey:w=>w.chainId}),className:L("input",oo.chain),children:[t.jsx(X,{src:b.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:b.name})]})]}),t.jsx(Qo,{myAddress:l,ref:Rn()})]}),t.jsx(xe,{children:t.jsx(le.White,{loading:(N?"Finding route...":!1)||V,disabled:!!M,children:M??"Confirm"})})]})},hw=()=>{const{chain:e}=Je(),n=_e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(dt,{title:"Send NFT",children:t.jsx(_e.FormProvider,{...n,children:t.jsx(mw,{})})})},jo=()=>{const e=Ce(),n=_s(),s=kt(),{closeDrawer:o}=xt(),{closeModal:a}=bs();_.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=Tn();if(_.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ba,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ba,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(kb,{});case"/send":return t.jsx(Hb,{},s);case"/receive":return t.jsx(Jx,{});case"/nft":return t.jsx(Bb,{});case"/nft/send":return t.jsx(hw,{},s);case"/bridge":return t.jsx(Yp,{},s);case"/bridge/preview":return t.jsx(cg,{});case"/bridge/history":return t.jsx(Kf,{});case"/op/withdrawals":return t.jsx(Mg,{});case"/tx":return t.jsx(ri,{});case"/autosign/enable":return t.jsx(Dm,{});case"/settings":return t.jsx(N1,{});case"/settings/autosign":return t.jsx(h1,{});case"/deposit":return t.jsx(Bx,{});case"/deposit/completed":return t.jsx(xo,{type:"deposit"});case"/withdraw":return t.jsx(Rx,{});case"/withdraw/completed":return t.jsx(xo,{type:"withdraw"})}},pw="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",fw=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:pw}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),gw=()=>(Sc(),Mc(),de(),El(),Or(),Sn(),Bn(),Kt(),null),_w=({children:e,...n})=>(_.useEffect(()=>{dl()},[]),Le.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(fw,{}),t.jsx(Xa.Provider,{value:{...Ja,...n},children:t.jsx(ur,{children:t.jsx(um,{children:t.jsx(J.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(dm,{children:t.jsxs(Ju,{children:[e,t.jsx(Dl,{}),t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(gw,{})}),t.jsx(Id,{children:t.jsx(jo,{})}),t.jsx(wd,{children:t.jsx(jo,{})})]})})})})})})]}):null),xw=({bridge:e})=>t.jsx(ur,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Xr.Provider,{value:!!e,children:t.jsx(me,{children:t.jsx(jo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=on;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Za;exports.InterwovenKit=xw;exports.InterwovenKitProvider=_w;exports.MAINNET=Ja;exports.MoveError=Ir;exports.PRIVY_APP_ID=vo;exports.TESTNET=ic;exports.initiaPrivyWallet=lc;exports.initiaPrivyWalletConnector=cc;exports.initiaPrivyWalletOptions=bn;exports.injectStyles=Jl;exports.useAddress=kt;exports.useHexAddress=ln;exports.useInitiaAddress=te;exports.useInterwovenKit=De;exports.usePortfolio=Lo;exports.useUsernameQuery=Lr;
4
+ </svg>`,Oc=encodeURIComponent(Uc),Do=`data:image/svg+xml;utf8,${Oc}`,In=ye.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,n)=>[e,n],resource:(e,n)=>[e.chainId,n.denom],denom:(e,n)=>[e,n],metadata:(e,n)=>[e,n]});function Vc(e){const{base:n,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,d=o.find(u=>u.denom===a)?.exponent??o.find(u=>u.denom===n)?.exponent??T.head(o)?.exponent??0,m=r?.png??"";return{denom:n,symbol:s,decimals:d,logoUrl:m,name:i,address:c,traces:l}}function pr(){const e=$.useQueryClient();return n=>{const s=n?.metadata?.assetlist;return $.queryOptions({queryKey:In.list(s).queryKey,queryFn:async()=>s?z.get(s).json():{assets:[]},select:({assets:o})=>{if(!n)return[];const a=o.map(Vc);for(const r of a)e.setQueryData(In.item(n.chainId,r.denom).queryKey,r);return a},staleTime:K.MINUTE})}}function xt(e){const n=pr(),{data:s}=$.useSuspenseQuery(n(e));return s}function Ln(){const e=de(),n=pr();return $.useQueries({queries:e.map(s=>n(s))})}function mt(e){const n=xt(e),s=re(),o=xt(s),a=_r(e);return r=>{const i=n.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:Do}}}function gr(e,n){const s=mt(n),a=$.useQueryClient().getQueryData(In.item(n.chainId,e).queryKey);return a||s(e)}function _r(e){const n=re(),s=xt(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??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===n.chain_name)return i.counterparty.base_denom}}const a=n.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?v.getIbcDenom(a,o):""}}function Bo(e){const n=re(),s=z.create({prefixUrl:n.restUrl}),o=$.useSuspenseQueries({queries:e.map(a=>({queryFn:()=>s.get("initia/move/v1/denom",{searchParams:{metadata:a}}).json(),queryKey:In.denom(n.restUrl,a).queryKey,select:r=>[a,r.denom],staleTime:K.INFINITY}))});return new Map(o.map(({data:a})=>a))}function Kc(e){return e.pagination?.next_key??null}async function Is(e,n,s){const o=z.create(n),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],d=Kc(c),m=[...r,...l];return d?a(m,d):m};return a([],null)}const Ca="usernames";function Wc({restUrl:e,moduleAddress:n}){const{viewFunction:s}=v.createMoveClient(e);async function o(i){if(!v.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:n,moduleName:Ca,functionName:"get_name_from_address",typeArgs:[],args:[se.toBase64(v.InitiaAddress(i,32).bytes)]});return c?c+".init":null}function a(i){return/^[A-Za-z0-9-]{3,64}\.init$/.test(i)}async function r(i){if(!a(i))return null;const c=await s({moduleAddress:n,moduleName:Ca,functionName:"get_address_from_name",typeArgs:[],args:[Cc.bcs.string().serialize(i.toLowerCase().replace(".init","")).toBase64()]});return c?v.InitiaAddress(c).bech32:null}return{restUrl:e,getUsername:o,getAddress:r,validateUsername:a}}const As=ye.createQueryKeys("interwovenkit:account",{username:(e,n)=>[e,n],address:(e,n)=>[e,n],balances:(e,n)=>[e,n],txs:(e,n)=>[e,n]});function xr(){const{restUrl:e}=re(),{usernamesModuleAddress:n}=ee();return Wc({restUrl:e,moduleAddress:n})}function yr(){const e=X();return n=>$.queryOptions({queryKey:As.balances(n.restUrl,e||"").queryKey,queryFn:()=>e?Is(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:n.restUrl},"balances"):[],staleTime:K.SECOND})}function qn(e){const n=yr(),{data:s}=$.useSuspenseQuery(n(e));return s}function zc(){const e=de(),n=yr();return $.useQueries({queries:e.map(s=>n(s))})}function Hc(e){const n=qn(e),s=xt(e),o=mt(e),a=_r(e),{data:r}=yt(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>s.some(d=>d.denom===l);return T.sortWith([T.descend(({denom:l})=>a(l)==="uinit"),T.descend(({denom:l})=>i(l)),T.descend(({value:l})=>l),T.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>B(d).comparedTo(l)??0,T.descend(({symbol:l})=>l.toLowerCase())],n.filter(({amount:l})=>!B(l).isZero()).map(({amount:l,denom:d})=>{const m=o(d),u=r?.find(({id:f})=>f===m?.denom)?.price??0,h=B(l).times(u).div(B(10).pow(m.decimals)).toNumber();return{...m,balance:l,price:u,value:h}}))}const jr=x.createContext(null);function Ss(){return x.useContext(jr)}function wr(){const{location:e}=Ss();return e}function Ts(){const{path:e}=wr();return e}function et(){const{state:e={}}=wr();return e}function br(){const{history:e}=Ss();return e}function Ce(){const{navigate:e}=Ss();return e}function Ro(){const{reset:e}=Ss();return e}const cn=({to:e,state:n,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ce(),c=Ro(),l=d=>{d.preventDefault(),a?.(d),s?c(e,n):i(e,n)};return t.jsx("button",{type:"button",...r,onClick:l,children:o})},vr=({children:e,initialEntry:n})=>{const[s,o]=x.useState([n??{path:"/"}]),a=s[s.length-1],r=x.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const m=d.length+c;if(m<1)return d;const u=T.take(m,d);return l!==void 0?T.adjust(m-1,h=>({...h,state:l}),u):u})},[]),i=x.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return t.jsx(jr.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},Gc="c33b940c24c17e95f7d9d525d508ac61";function Qc(){const{disableAnalytics:e}=ee();x.useEffect(()=>{e||Lo.init(Gc,{autocapture:!1})},[e])}function Yc(){const{connector:e}=Ee.useAccount(),{defaultChainId:n,disableAnalytics:s}=ee();x.useEffect(()=>{const o=new ar.Identify;e?.name&&o.set("connector",e.name),n&&o.set("defaultChainId",n),Lo.identify(o)},[n,e?.name,s])}function un(){const e=Ts();return x.useCallback((s,o)=>{Lo.track(s,{path:e,...o})},[e])}function Zc(e){return e.type==="initia/PubKeyEthSecp256k1"}const Jc={...Nn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function Cr(e){if(Zc(e)){const n=yo.PubKey.fromPartial({key:se.fromBase64(e.value)});return Nc.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(yo.PubKey.encode(n).finish())})}return Cs.encodePubkey(e)}function Fo(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:Jc.ethsecp256k1,value:se.toBase64(e)}}function Nr(e,n){if(n.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:Fo(e),signature:se.toBase64(n)}}function Xc(e){return`Enable Auto-Sign for InterwovenKit
5
+
6
+ Origin: ${e}
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 el(e,n){const s=Et.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=Et.hexToBytes(Et.keccak256(Et.bytesToHex(o))),r=Qe.Bip39.encode(a),i=await Qe.Bip39.mnemonicToSeed(r),c=Qe.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=Qe.Slip10.derivePath(Qe.Slip10Curve.Secp256k1,i,c),d=await Qe.Secp256k1.makeKeypair(l),m=Qe.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=Et.bytesToHex(h),p=Et.keccak256(f),g=Et.hexToBytes(p).slice(-20),_=se.toBech32(n,g);return{privateKey:l,publicKey:m,address:_}}function es(e,n){return`${e}:${n}`}const Pn=U.atom(null),An=U.atom({}),Sn=U.atom({}),$s=U.atom({}),Na=U.atom(0),tl="autosign:";function nl(e,n){const s=e.get(Na)+1;return e.set(Na,s),`${n}:${s}`}function ps(e,n){return e.get($s)[n]}function sl(e,n,s){e.set($s,o=>({...o,[n]:s}))}function kr(e,n){e.set($s,s=>{const o={...s};return delete o[n],o})}function ol(e,n,s){const o=ps(e,n);!o||o.token!==s||kr(e,n)}function al(e,n,s){const o=ps(e,n);return!!o&&o.token===s}function ts(e,n){return e.get(Sn)[n]}function rl(e,n,s){e.set(Sn,o=>({...o,[n]:s}))}function il(e,n){e.set(Sn,s=>{const o={...s};return delete o[n],o})}function cl(e,n,s){e.set(An,o=>({...o,[n]:s}))}function ll(e,n){e.set(An,s=>{const o={...s};return delete o[n],o})}function Ir(e,n){return`${tl}${e}:${n}`}function dl(e,n,s){try{return e.getItem(Ir(n,s))}catch{return null}}function ul(e,n,s,o){try{e.setItem(Ir(n,s),o)}catch{}}function Ar(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function Uo(e,n){const s=Ar();if(s)return dl(s,e,n)}function ml(e,n,s){const o=Ar();o&&ul(o,e,n,s)}function hl(e){return{publicKey:e.publicKey,address:e.address}}function gs(e){e&&e.fill(0)}function Sr(e){e.set($s,{});const n=e.get(Sn);for(const s of Object.values(n))gs(s);e.set(Sn,{}),e.set(An,{})}function fl(e,n){return e!==""&&e!==n}function pl(){const e=X(),n=U.useStore(),s=x.useRef(e);x.useEffect(()=>{const o=s.current;fl(o,e)&&Sr(n),s.current=e},[n,e])}class gl{constructor(n,s){this.wallet=n,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(n,s){if(this.wallet.address!==n)throw new Error("Signer address does not match the derived wallet address");const o=Cn.escapeCharacters(Cn.sortedJsonStringify(s)),a=ct.ethers.hashMessage(o),r=se.fromHex(a.replace("0x","")),i=await Qe.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=Nr(this.wallet.publicKey,c);return{signed:s,signature:l}}}function Es(){const e=U.useStore(),{signMessageAsync:n}=Ee.useSignMessage(),s=Fe(),o=X();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const m=s(d),u=es(o,m.bech32_prefix),h=e.get(An)[u];if(h&&ts(e,u))return h;const f=ps(e,u);if(f)return f.promise;const p=nl(e,u),g=(async()=>{try{const _=window.location.origin,y=Xc(_),j=await n({message:y}),b=await el(j,m.bech32_prefix),w=hl(b);if(al(e,u,p))return rl(e,u,b.privateKey),cl(e,u,w),w;throw gs(b.privateKey),new Error("Wallet derivation was cancelled")}finally{ol(e,u,p)}})();return sl(e,u,{promise:g,token:p}),g},getWallet:d=>{if(!o)return;const m=s(d),u=es(o,m.bech32_prefix);if(ts(e,u))return e.get(An)[u]},getWalletPrivateKey:d=>{if(!o)return;const m=s(d),u=es(o,m.bech32_prefix);return ts(e,u)},clearWallet:d=>{if(!o)return;const m=s(d),u=es(o,m.bech32_prefix),h=ts(e,u);ps(e,u)&&kr(e,u),gs(h),il(e,u),ll(e,u)},clearAllWallets:()=>{Sr(e)}}}function Tr({granteeAddress:e,messages:n,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:Mo.MsgExec.fromPartial({grantee:e,msgs:n.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function _l({chainId:e,granterAddress:n,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=Tr({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:n},u=new Uint8Array(i),h=new gl(r,u);try{return await l(e,r.address,d,m,a,{customSigner:h})}finally{gs(u)}}const at="interwovenkit",Ie="uinit",Ye="INIT",Be=6,xl="uoinit",yl="omniINIT",$r="https://app.initia.xyz",Oo=`${$r}/liquidity/my`,jl=`${$r}/vip/my`,wl=1e3,Er=60*wl,Mr=60*Er,ka=24*Mr,ae={PUBLIC_KEY:`${at}:public-key`,BRIDGE_SRC_CHAIN_ID:`${at}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${at}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${at}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${at}:bridge:dst-denom`,BRIDGE_QUANTITY:`${at}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${at}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${at}:bridge:route-type`,BRIDGE_HISTORY:`${at}:bridge:history`,OP_REMINDER:`${at}:op:reminder`},Lr=U.atom(!1),qr=U.atom(!1);function jt(){const e=Ro(),[n,s]=U.useAtom(Lr),o=U.useSetAtom(qr),a=un();return{isDrawerOpen:n,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function mn(){const e=Ro(),[n,s]=U.useAtom(qr),o=U.useSetAtom(Lr),a=un();return{isModalOpen:n,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Pr(){const e=Ce(),{closeDrawer:n}=jt(),{closeModal:s}=mn(),{disconnect:o}=Ee.useDisconnect(),{clearAllWallets:a}=Es();return()=>{e("/blank"),n(),s(),o(),a(),localStorage.removeItem(ae.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_SRC_DENOM),localStorage.removeItem(ae.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_DST_DENOM),localStorage.removeItem(ae.BRIDGE_QUANTITY),localStorage.removeItem(ae.BRIDGE_SLIPPAGE_PERCENT)}}function bl(){const e=At(),n=Gt(),{openModal:s}=mn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function vl(){const e=At(),n=Gt(),{openModal:s}=mn();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??n.chainId,d=a.map(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Cl(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:n}=yo.PubKey.decode(e.value);return Nn.encodeSecp256k1Pubkey(n)}return Cs.decodeOptionalPubkey(e)}function Nl({typeUrl:e,value:n}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=kc.BaseAccount.decode(n),i=Cl(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return je.accountFromAny({typeUrl:e,value:n})}const Dr="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Br="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Rr="cosmos-sdk/AllowedMsgAllowance";function kl(){const e=Wt.aminoConverters[Dr];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const _s=kl();function Fr(e){if(e.typeUrl===Br){const n=Rt.AllowedMsgAllowance.decode(e.value);if(!n.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Rr,value:{allowance:Fr(n.allowance),allowed_messages:n.allowedMessages}}}return _s.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Ur(e){if(e.type===Rr){const n=e.value;if(!n.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Ur(n.allowance);return{typeUrl:Br,value:Rt.AllowedMsgAllowance.encode(Rt.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:n.allowed_messages??n.allowedMessages??[]})).finish()}}return _s.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Il={...Wt.aminoConverters,[Dr]:{..._s,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Fr(e.allowance)}:_s.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Ur(e.allowance)})}},Dn=()=>{const e=ee();return new Cs.Registry([...Wt.protoRegistry,...e.protoTypes??[]])},Bn=()=>{const e=ee();return new je.AminoTypes({...Il,...e.aminoConverters})};class Al{constructor(n,s,o){this.address=n,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const n=`${ae.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(n);if(s)return this.cachedPublicKey=se.fromHex(s),se.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(n,se.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(n,se.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?se.fromBase64(s):null}catch{return null}}async getPublicKey(){const n="Sign this message to identify your Initia account.",s=await this.signMessage(n),o=ct.ethers.hashMessage(n),a=ct.ethers.SigningKey.recoverPublicKey(o,s);return Qe.Secp256k1.compressPubkey(se.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(n,s){if(this.address!==n)throw new Error("Signer address does not match the provided address");const o=Cn.escapeCharacters(Cn.sortedJsonStringify(s)),a=await this.signMessage(o),r=se.fromHex(a.replace("0x","")).subarray(0,-1),c=Qe.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=Nr(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Or(){const e=Dn(),n=Bn(),s=Rn(),o=Ms();return async function(a,r,i,c,l,d){const m=d?.customSigner??s;if(!m)throw new Error("Signer not initialized");const u=await o(a),{accountNumber:h,sequence:f}=await Vr({getSequence:N=>u.getSequence(N),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[p]=await m.getAccounts(),g=Cr(Fo(p.pubkey)),_=rr.SignMode.SIGN_MODE_EIP_191,y=i.map(N=>n.toAmino(N)),j=Cn.makeSignDoc(y,c,a,l,h,f),{signature:b,signed:w}=await m.signAmino(r,j),I={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:w.msgs.map(N=>n.fromAmino(N)),memo:l}},E=e.encode(I),M=xa.Int53.fromString(w.fee.gas).toNumber(),A=xa.Int53.fromString(w.sequence).toNumber(),L=Cs.makeAuthInfoBytes([{pubkey:g,sequence:A}],w.fee.amount,M,w.fee.granter,w.fee.payer,_);return De.TxRaw.fromPartial({bodyBytes:E,authInfoBytes:L,signatures:[se.fromBase64(b.signature)]})}}function Sl(e,n){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(n):!1}async function Vr({getSequence:e,signerAddress:n,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(n);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&Sl(a,n))return{accountNumber:0,sequence:s};throw a}}function Rn(){const e=X(),{signMessageAsync:n}=Ee.useSignMessage(),s=re();return x.useMemo(()=>new Al(e,o=>n({message:o}),s.restUrl),[e,n,s.restUrl])}const Zs=new Map,us=new Map;function Tl(e,n){const s=`${e}:${n}`;us.delete(s)}function Vo(){const e=Fe();return async n=>{if(Zs.has(n))return Zs.get(n);const{rpcUrl:s}=e(n),o=await ya.Comet38Client.create(new ya.HttpClient(s));return Zs.set(n,o),o}}function Ms(){const e=Dn(),n=Bn(),s=Rn(),o=X(),a=Vo();return async r=>{const i=`${o}:${r}`;if(us.has(i))return us.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await je.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:n,accountParser:Nl,broadcastPollIntervalMs:500});return us.set(i,l),l}}function Kr(){const{connector:e}=Ee.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new ct.BrowserProvider(await e.getProvider())}}function Wr(e){return e.filter(n=>n.authorization["@type"].includes("GenericAuthorization")).filter(n=>!!n.authorization.msg)}function zr(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function $l(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Hr(){const e=X(),n=Fe();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=n(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:d}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return d}catch(d){if(d instanceof z.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=n(r),l=z.create({prefixUrl:c.restUrl}),{grants:d}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return d},fetchAllGrants:async r=>{const i=n(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Is(l,{prefixUrl:i.restUrl},"grants");return Wr(d)}}}const xs=ye.createQueryKeys("interwovenkit:autosign",{expirations:(e,n,s)=>[e,n,s],grants:(e,n)=>[e,n]}),El=4,Gr=4;function Ml(e){return Object.entries(e).sort(([n],[s])=>n.localeCompare(s)).map(([n,s])=>`${n}:${[...s].sort().join(",")}`).join("|")}function Ko(){const e=ee(),n=Gt(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(n.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function Ll(){const{data:e}=Ls(),n=Ko();return(s,o)=>{const a=o.every(i=>{const c=n[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function Ls(){const e=X(),n=Ko(),s=Ml(n),{fetchFeegrant:o,fetchAllGrants:a}=Hr();return $.useQuery({queryKey:xs.expirations(e,s,n).queryKey,queryFn:()=>ql({initiaAddress:e,messageTypes:n,fetchAllGrants:a,fetchFeegrant:o}),staleTime:K.MINUTE,retry:1})}async function ql(e){const{initiaAddress:n,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!n)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},d=[];for(const[u,h]of Object.entries(s))r[u]=null,i[u]=void 0,c[u]=!1,h.length>0&&d.push([u,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await Qr(d,El,async([u,h])=>{const f=Uo(n,u);try{const p=await o(u),g=f===void 0?p:f===null?[]:p.filter(I=>I.grantee===f),_=Bl(g,h);if(_.length===0)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const y=await Dl({chainId:u,candidates:_,fetchFeegrant:a,concurrency:Gr});if(!y)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const j=y.grantee.grants.filter(I=>h.includes(I.authorization.msg)).map(I=>I.expiration),b=zr(y.feegrant.allowance),w=[...j,b],C=Wo(w);return{chainId:u,expectedAddress:f,expiration:C?new Date(C):void 0,grantee:y.grantee.grantee}}catch{return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0}}});for(const u of m)l[u.chainId]=u.expectedAddress,r[u.chainId]=u.expiration,i[u.chainId]=u.grantee;for(const[u]of d)c[u]=Rl({expiration:r[u],grantee:i[u],expectedAddress:l[u]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function Qr(e,n,s){const o=new Array(e.length),a=Math.max(1,n);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 Pl(e){const n=$l(e.allowance);if(!(!n||n.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=zr(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Re.isFuture(a)}async function Dl(e){const{chainId:n,candidates:s,fetchFeegrant:o,concurrency:a=Gr}=e,r=await Qr(s,a,async i=>{const c=await o(n,i.grantee);return c&&Pl(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function Bl(e,n){if(n.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(d=>!d.expiration||Re.isFuture(new Date(d.expiration))),c=i.map(d=>d.authorization.msg);n.every(d=>c.includes(d))&&o.push({grantee:a,grants:i})}return o}function Rl(e){const{expiration:n,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(n){case null:return!1;case void 0:return a;default:return a&&Re.isFuture(n)}}function Fl(){const{data:e,refetch:n}=Ls();x.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Re.isFuture(c));if(o.length===0)return;const a=Wo(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{n()},r+100);return()=>clearTimeout(i)},[e,n])}function Wo(e){const n=e.filter(s=>s!==void 0);if(n.length!==0)return[...n].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const Yr=x.createContext(null),qs=()=>x.useContext(Yr);class Zr extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(n,s,o,a,r,i,c){super(n),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const Ul=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,Js=new Map;function Ol(e){const n=e.match(Ul);if(!n)return null;const[,s,o,a]=n;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Vl(e,n,s){const o=`${e}:${n}`;if(Js.has(o))return Js.get(o);try{const a=n==="0x1"?"0x1.json":`${e}/${n}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await z.get(r).json();return Js.set(o,i),i}catch{return null}}function Kl(e,n,s,o,a,r,i){return new Zr(e,n,s,o,a,r,i)}async function nn(e,n,s){if(!n.metadata?.is_l1&&n.metadata?.minitia?.type!=="minimove")return await _t(e);const o=Ol(e.message);if(!o)return await _t(e);const a=await Vl(n.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return Kl(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Wl=10;function Jr(){const e=X();return(n,s)=>$.queryOptions({queryKey:As.txs(n.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Wl},{txs:a}=await z.create({prefixUrl:n.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:K.SECOND})}function zl(e,n){const s=Jr();return $.useSuspenseQuery(s(e,n))}function Hl(e,n){const s=e.flatMap((o,a)=>(n[a]??[]).map(i=>({...i,chain:o})));return T.sortWith([T.descend(o=>new Date(o.timestamp).getTime())])(s)}const Gl=()=>{const e=de(),n=Jr(),s=$.useQueries({queries:e.map(i=>n(i,{enabled:!0}))}),o=s.map(T.prop("data")),a=Hl(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Xr(e){if(e.metadata?.is_l1){const{restUrl:n}=e,{gas_prices:s}=await z.create({prefixUrl:n}).get("initia/tx/v1/gas_prices").json();return s.toSorted(T.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:dr;return{amount:B(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:n,fixed_min_gas_price:s})=>{if(T.isNil(s))throw new Error(`${n} has no price`);return{amount:String(s),denom:n}})}function zo(e){const{data:n}=$.useSuspenseQuery({queryKey:ks.gasPrices(e).queryKey,queryFn:()=>Xr(e),staleTime:K.SECOND});return n}function Ho(e){const n=X(),{data:s}=zl(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=>v.InitiaAddress.equals(n,ct.computeAddress(`0x${se.toHex(Qe.Secp256k1.uncompressPubkey(se.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const ei="approve",Ps=U.atom(),ti=U.atom(null),Ql=zt,Yl=1.5;function Zl({gasPrices:e,preferredFeeDenom:n,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(n)??r(s)??a[0]}function Jl({simulatedGas:e,gasPrices:n,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),d=Zl({gasPrices:n,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return je.calculateFee(l,je.GasPrice.fromString(`${d.amount}${d.denom}`))}function Xl({derivedAddress:e,messages:n,encoder:s}){return{messages:Tr({granteeAddress:e,messages:n,encoder:s})}}function ed(e){if(!(e instanceof Error))return!1;const n=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=n.includes("user rejected")||n.includes("rejected the request")||n.includes("user denied")||n.includes("denied by user")||n.includes("user cancelled")||n.includes("user canceled")||n.includes("cancelled by user")||n.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function td({queryClient:e,messages:n,memo:s,pubkey:o,sequence:a}){const r=je.createProtobufRpcClient(e),i=new ja.ServiceClientImpl(r),c=De.Tx.fromPartial({authInfo:De.AuthInfo.fromPartial({fee:De.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:rr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:De.TxBody.fromPartial({messages:Array.from(n),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(ja.SimulateRequest.fromPartial({txBytes:De.Tx.encode(c).finish()}))}function nd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function sd({address:e,chainId:n,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const m=async()=>d.signWithEthSecp256k1(n,e,s,a,o),u=(_,y)=>{d.onAutoSignFallback?.({chainId:n,reason:_,errorMessage:nd(y)})};if(!c)return m();if(!d.validateAutoSign(n,s))return u("validation_failed"),m();let f=d.getWallet(n),p=!1;if(!f&&l)try{f=await d.deriveWallet(n)}catch(_){if(ed(_))throw _;u("derive_wallet_failed",_),p=!0,f=void 0}if(!f)return p||u("missing_derived_wallet"),m();let g;try{const _=i??await d.getSigningClient(n);g=await d.computeAutoSignFee({chainId:n,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return u("fee_computation_failed",_),m()}try{return await d.signWithDerivedWallet(n,e,s,g,o,f)}catch(_){return u("derived_wallet_sign_failed",_),m()}}function ni(){const e=X(),{autoSignFeePolicy:n}=ee(),s=Fe(),o=Vo(),a=Ms(),r=Dn(),i=Ll(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=Es(),m=Or(),u=un(),h=g=>{const _=n?.[g];return{gasMultiplier:_?.gasMultiplier??Ql,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??Yl,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:g,messages:_,memo:y,derivedWallet:j,preferredFeeDenom:b,fallbackFeeDenom:w,client:C})=>{const I=s(g),E=await Xr(I),A=Xl({derivedAddress:j.address,messages:_,encoder:r}).messages.map(H=>r.encodeAsAny(H)),L=Cr(Fo(j.publicKey)),{sequence:N}=await Vr({getSequence:H=>C.getSequence(H),signerAddress:j.address,incrementSequence:0,allowMissingAccount:!0}),k=await o(g),P=je.QueryClient.withExtensions(k,je.setupTxExtension),{gasInfo:R}=await td({queryClient:P,messages:A,memo:y,pubkey:L,sequence:N}),O=R?Number(R.gasUsed.toString()):0,V=h(g);return Jl({simulatedGas:O,gasPrices:E,preferredFeeDenom:b,fallbackFeeDenom:w,policy:V})},p=async(g,_,y,j,b,w)=>{let C=w??c(g);C||(C=await l(g));const I=d(g);if(!I)throw new Error("Derived wallet key not initialized");return await _l({chainId:g,granterAddress:_,messages:y,fee:j,memo:b,derivedWallet:C,privateKey:I,encoder:r,signWithEthSecp256k1:m})};return g=>sd({...g,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:p,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:_,reason:y,errorMessage:j})=>{u("AutoSign Fallback",{chainId:_,reason:y,errorMessage:j})}})}function si(){const e=U.useAtomValue(Ps);if(!e)throw new Error("Tx request not found");return e}function Ds(){const e=Ce(),n=X(),{defaultChainId:s,registryUrl:o}=ee(),a=Fe(),{openDrawer:r,closeDrawer:i}=jt(),{openModal:c,closeModal:l}=qs(),d=U.useSetAtom(Ps),m=U.useSetAtom(ti),u=Vo(),h=Ms(),f=Rn(),p=Dn(),g=ni(),_=async({messages:A,memo:L,chainId:N=s})=>{try{return await(await h(N)).simulate(n,A,L)}catch(k){throw await nn(k,a(N),o)}},y=async({messages:A,memo:L,chainId:N=s})=>{const k=await u(N),P=je.QueryClient.withExtensions(k,je.setupTxExtension),R=A.map(F=>p.encodeAsAny(F)),[O]=await f.getAccounts(),V=Nn.encodeSecp256k1Pubkey(O.pubkey),H=await h(N),{sequence:Q}=await H.getSequence(n);return P.tx.simulate(R,L,V,Q)},j=async({txRequest:A,broadcaster:L})=>{const k={...{memo:"",chainId:s,gas:A.gas||await _(A),gasAdjustment:zt,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((P,R)=>{d({txRequest:k,resolve:async V=>{try{const H=await h(k.chainId),Q=await L(H,De.TxRaw.encode(V).finish());P(Q),typeof k.internal=="string"&&e(k.internal)}catch(H){R(await nn(H,a(k.chainId),o))}finally{O()}},reject:V=>{R(V),O()}}),k.internal?c({path:"/tx"}):r("/tx");const O=()=>{if(!k.internal){e("/blank"),i();return}l()}})},b=async A=>{const L=A.chainId??s;try{const N=await j({txRequest:A,broadcaster:async(k,P)=>await k.broadcastTxSync(P)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:L,status:"loading"}),M({txHash:N,chainId:A.chainId}).then(k=>{m({status:k.code===0?"success":"error",chainId:L,txHash:N})}).catch(()=>{m({status:"error",chainId:L,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:L,error:N}),N}},w=(A,L=30*1e3,N=.5*1e3)=>j({txRequest:A,broadcaster:async(k,P)=>{const R=await k.broadcastTx(P,L,N);if(R.code!==0)throw new Error(R.rawLog);return R}}),C=async({chainId:A,messages:L,memo:N="",fee:k,preferredFeeDenom:P})=>{const R=await h(A),O=await g({chainId:A,messages:L,memo:N,fee:k,preferredFeeDenom:P,client:R,allowWalletDerivation:!1});return{client:R,signedTx:O}},I=async A=>{const L=A.chainId??s;try{const{client:N,signedTx:k}=await C({...A,chainId:L});return await N.broadcastTxSync(De.TxRaw.encode(k).finish())}catch(N){throw await nn(N,a(L),o)}},E=async(A,L=30*1e3,N=.5*1e3)=>{const k=A.chainId??s;try{const{client:P,signedTx:R}=await C({...A,chainId:k}),O=await P.broadcastTx(De.TxRaw.encode(R).finish(),L,N);if(O.code!==0)throw new Error(O.rawLog);return O}catch(P){throw await nn(P,a(k),o)}},M=async({chainId:A=s,...L})=>{try{const N=await h(A);return await oi({...L,client:N})}catch(N){throw await nn(N,a(A),o)}};return{estimateGas:_,simulateTx:y,requestTxSync:b,requestTxBlock:w,submitTxSync:I,submitTxBlock:E,waitForTxConfirmation:M}}async function oi({txHash:e,client:n,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await n.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const od="/cosmos.authz.v1beta1.MsgExec";function ad(e){if(e.explicitGrantee)return[e.explicitGrantee];const n=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(n)]}function rd(e){const n=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(n)]}function id(e){const{isEnabledOnTargetChain:n,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:n===!1?!0:n===void 0&&o&&!a}function cd(e){return[...new Set(e.map(n=>n.authorization.msg))].filter(n=>!!n)}async function ai(e){const n=[xs.expirations._def,xs.grants._def];for(const s of n)await e.invalidateQueries({queryKey:s})}function ri(){const e=X(),{fetchFeegrant:n,fetchGrants:s}=Hr();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await n(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:ir.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=cd(c).map(u=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:Mo.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:u})}));return[...l,...m]}}function ld(){const e=X(),n=Ko(),{requestTxBlock:s}=Ds(),o=$.useQueryClient(),[a,r]=U.useAtom(Pn),{closeDrawer:i}=jt(),c=ri(),{deriveWallet:l}=Es();return $.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const u=n[m];if(!u||u.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Tl(e,m);const f=Uo(e,m),p=rd({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(p.map(I=>c({chainId:m,grantee:I})))).flat(),y=d===0?void 0:Re.addMilliseconds(new Date,d),j={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:Rt.BasicAllowance.encode(Rt.BasicAllowance.fromPartial({expiration:y})).finish()},b={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:ir.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:Rt.AllowedMsgAllowance.encode(Rt.AllowedMsgAllowance.fromPartial({allowance:j,allowedMessages:[od]})).finish()}})},w=u.map(I=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:Mo.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:wa.GenericAuthorization.encode(wa.GenericAuthorization.fromPartial({msg:I})).finish()},expiration:y}})})),C=[..._,b,...w];return await s({messages:C,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:m})=>{e&&ml(e,d,m.address),await ai(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function ii(e){const n=ee(),s=de(),o=Fe(),{getWallet:a,clearWallet:r}=Es(),{requestTxBlock:i}=Ds(),c=$.useQueryClient(),l=ri(),{data:d,refetch:m}=Ls();return $.useMutation({mutationFn:async(u=n.defaultChainId)=>{const h=a(u),f=d?.granteeByChain[u];let p;e?.grantee||(p=(await m()).data?.granteeByChain[u]);const g=ad({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:p});if(g.length===0)throw new Error("No grantee address available");const y=(await Promise.all(g.map(j=>l({chainId:u,grantee:j})))).flat();return y.length===0?{chainId:u,didBroadcast:!1}:(await i({messages:y,chainId:u,internal:e?.internal}),{chainId:u,didBroadcast:!0})},onSuccess:async({chainId:u,didBroadcast:h})=>{await ai(c);const f=o(u),p=s.filter(w=>w.bech32_prefix===f.bech32_prefix).map(w=>w.chain_id).filter(w=>w!==u);let g;try{g=(await m()).data}catch{g=void 0}const _=g??d;let y=!1;p.length>0&&_&&(y=p.some(w=>_?.isEnabledByChain[w]));const j=h?g?.isEnabledByChain[u]:(g??d)?.isEnabledByChain[u];id({isEnabledOnTargetChain:j,hasEnabledSibling:y,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(u)}})}function dd(){const{defaultChainId:e}=ee(),{openDrawer:n}=jt(),s=U.useSetAtom(Pn),o=ii(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=Ls();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,m)=>{s({chainId:l,resolve:d,reject:m}),n("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function ci(e){return e.assets.reduce((n,{value:s})=>n+(s??0),0)}function ud(e){return e.assets.reduce((n,{quantity:s})=>n.plus(s),B(0)).toString()}function md(e,n){return{symbol:n?.symbol??e,logoUrl:n?.logoUrl??Do}}function Ia(e){return T.pick(["chainId","name","logoUrl"],e)}function hd(e){return T.sortWith([T.descend(({symbol:n})=>n===Ye),T.descend(ci),T.descend(({assets:n})=>n.length),T.ascend(({symbol:n})=>n)])(e)}function fd(e){return T.sortWith([T.descend(({value:n})=>n??0),T.descend(({quantity:n})=>Number(n)),T.ascend(({chain:n})=>n.name)])(e)}function pd(e,n){return T.sortWith([T.descend(({chain:s})=>s.chainId===n),T.ascend(({chain:s})=>s.name),T.ascend(({denom:s})=>s)])(e)}function gd(e,n){return T.sortWith([T.descend(({chainId:s})=>s===n),T.descend(T.prop("value"))])(e)}function _d(e,n,s,o,a){const r=e.find(u=>u.metadata?.is_l1)?.chainId,i={};for(const u of e){const h=u.chainId,f=n[h]??[],p=s[h],g=o[h],_=[];for(const{amount:y,denom:j}of f){if(!B(y).gt(0))continue;const b=p?.find(M=>M.denom===j),w=g?.find(M=>M.id===j)?.price,C=b?.decimals??0,I=v.fromBaseUnit(y,{decimals:C}),E=w?B(I).times(w).toNumber():void 0;_.push({...md(j,b),amount:y,denom:j,decimals:C,quantity:I,price:w,value:E,address:b?.address,unlisted:!b,chain:Ia(u)})}i[h]=_}const c=new Map;for(const[u,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(g=>g.chainId===u);if(!f)continue;const p=h.reduce((g,{value:_})=>g+(_??0),0);c.set(u,{...Ia(f),value:p})}const l=new Map;for(const u of Object.values(i))for(const h of u)if(!h.unlisted){const{symbol:f}=h,p=l.get(f)??[];l.set(f,[...p,h])}const d=[];for(const[u,h]of l){const f=T.head(h);if(!f)continue;const p=fd(h),g=p.reduce((y,{value:j})=>y+(j??0),0),_=p.reduce((y,{quantity:j})=>y.plus(j),B(0)).toNumber();d.push({symbol:u,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:_})}const m=[];for(const u of Object.values(i))for(const h of u)h.unlisted&&m.push(h);return{chainsByValue:gd(Array.from(c.values()),a),assetGroups:hd(d),unlistedAssets:pd(m,r),totalValue:d.reduce((u,h)=>u+h.totalValue,0)}}function Go(){const{defaultChainId:e}=ee(),n=de(),s=zc(),o=Ln(),a=Po(),r=n.map(h=>h.chainId),i=T.zipObj(r,s.map(T.prop("data"))),c=T.zipObj(r,o.map(T.prop("data"))),l=T.zipObj(r,a.map(T.prop("data"))),d=_d(n,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function X(){const e=hn();return e?v.InitiaAddress(e).bech32:""}function hn(){const{address:e}=Ee.useAccount();return e?v.InitiaAddress(e).hex:""}function At(){const e=Gt(),n=X(),s=hn();return e.metadata?.minitia?.type==="minievm"?s:n}function li(){const e=At(),n=xr();return $.useQuery({queryKey:As.username(n.restUrl,e).queryKey,queryFn:()=>n.getUsername(e),enabled:!!e,staleTime:K.MINUTE})}function Ue(){const e=At(),n=X(),s=hn(),{data:o}=li(),a=Rn(),r=Pr(),i=dd(),{isDrawerOpen:c,openDrawer:l}=jt(),{isModalOpen:d}=mn(),m=()=>{l("/")},u=()=>{l("/connect")},h=j=>{l("/bridge",j)},f=bl(),p=vl(),g=Ds();return{address:e,initiaAddress:n,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:u,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const xd="_status_tn9m1_1",yd="_error_tn9m1_9",Aa={status:xd,error:yd},he=({error:e,children:n})=>t.jsx("p",{className:q(Aa.status,{[Aa.error]:e}),children:n}),me=({errorBoundaryProps:e={fallbackRender:({error:o})=>t.jsx(he,{error:!0,children:o.message})},suspenseFallback:n=t.jsx(he,{children:"Loading..."}),children:s})=>t.jsx(cr.ErrorBoundary,{...e,children:t.jsx(x.Suspense,{fallback:n,children:s})}),jd="lock_staking";function di(e,n){const s=`${n}::lock_staking::StakingAccount`,o=v.createObjectAddress(e,s);return v.InitiaAddress(o).bech32}const Fn=ye.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,n)=>[e,n],undelegations:(e,n,s)=>[e,n,s],lockStaking:(e,n,s)=>[e,n,s],stakingRewards:(e,n)=>[e,n],lockStakingRewards:(e,n,s)=>[e,n,s]});function Qo(){const{restUrl:e}=re(),n=X();return $.useSuspenseQuery({queryKey:Fn.delegations(e,n||"").queryKey,queryFn:async()=>n?(await z.get(`${e}/initia/mstaking/v1/delegations/${n}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=v.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},d=o.get(c)??[];d.push(l),o.set(c,d)}}return o},staleTime:K.MINUTE})}function Yo(){const{restUrl:e}=re(),{lockStakeModuleAddress:n}=ee(),s=X(),o=s?di(s,n):"";return $.useSuspenseQuery({queryKey:Fn.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 d of l.balance){const m=v.denomToMetadata(d.denom),u={denom:d.denom,metadata:m,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(u),r.set(m,h)}}return r},staleTime:K.MINUTE})}function Zo(){const{restUrl:e}=re(),{lockStakeModuleAddress:n}=ee(),s=X();return $.useSuspenseQuery({queryKey:Fn.lockStaking(e,s||"",n).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=v.createMoveClient(e);return await o({moduleAddress:n,moduleName:jd,functionName:"get_locked_delegations",typeArgs:[],args:[se.toBase64(v.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:K.MINUTE})}function ui(e){const n=new Map;if(!e.total||!Array.isArray(e.total))return n;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=v.denomToMetadata(s.denom);let a=new B(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=n.get(o);if(r){const i=new B(r.amount);a=a.plus(i)}n.set(o,{denom:s.denom,amount:a.toString()})}return n}function mi(){const{restUrl:e}=re(),n=X();return $.useSuspenseQuery({queryKey:Fn.stakingRewards(e,n||"").queryKey,queryFn:async()=>n?await z.get(`${e}/initia/distribution/v1/delegators/${n}/rewards`).json():{rewards:[],total:[]},select:ui,staleTime:K.MINUTE})}function hi(){const{restUrl:e}=re(),{lockStakeModuleAddress:n}=ee(),s=X(),o=s?di(s,n):"";return $.useSuspenseQuery({queryKey:Fn.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:ui,staleTime:K.MINUTE})}function Jo(){const e=re(),n=xt(e),{data:s,isLoading:o}=yt(e),{data:a}=Qo(),{data:r}=Yo(),{data:i}=Zo(),c=x.useMemo(()=>{const f=new Set;for(const p of a.keys())f.add(p);for(const p of i.keys())f.add(p);for(const p of r.keys())f.add(p);return Array.from(f)},[a,i,r]),l=Bo(c),d=x.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),m=x.useMemo(()=>{const f=new Map;for(const p of n)f.set(p.denom,p);return f},[n]),u=x.useMemo(()=>{const f=[],p=g=>{const _=m.get(g);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[g,_]of a){const y=l.get(g)??_[0]?.denom;if(!y)continue;const j=p(y);if(!j)continue;const b=d.get(y)??0;for(const w of _){const{symbol:C,decimals:I}=j,E=Number(v.fromBaseUnit(w.amount,{decimals:I})),M={type:"asset",denom:y,symbol:C,amount:w.amount,formattedAmount:E,decimals:I,value:E*b};f.push({type:"staking",validator:w.validator,balance:M})}}for(const[g,_]of i){const y=l.get(g);if(!y)continue;const j=p(y);if(!j)continue;const b=d.get(y)??0;for(const w of _){const{symbol:C,decimals:I}=j,E=Number(v.fromBaseUnit(w.amount,{decimals:I})),M={type:"asset",denom:y,symbol:C,amount:w.amount,formattedAmount:E,decimals:I,value:E*b},A=Number(w.releaseTime);f.push({type:"lockstaking",validator:w.validator,releaseTime:Number.isNaN(A)?0:A,balance:M})}}for(const[g,_]of r){const y=l.get(g)??_[0]?.denom;if(!y)continue;const j=p(y);if(!j)continue;const b=d.get(y)??0;for(const w of _){const{symbol:C,decimals:I}=j,E=Number(v.fromBaseUnit(w.amount,{decimals:I})),M={type:"asset",denom:y,symbol:C,amount:w.amount,formattedAmount:E,decimals:I,value:E*b},A=new Date(w.completionTime).getTime(),L=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:w.validator,completionTime:L,balance:M})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Ie)},[a,i,r,l,m,d]),h=x.useMemo(()=>u.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[u]);return{positions:u,totalValue:h,isLoading:o}}const Xo=ye.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,n)=>[e,n],lpPrices:(e,n)=>[e,n],pool:(e,n)=>[e,n]});function wd(e){const n=new Map;for(const s of e){const o=v.denomToMetadata(s.denom),a={...s,metadata:o},r=n.get(o)??[];r.push(a),n.set(o,r)}return n}function bd(e){const{dexUrl:n}=ee();return $.useSuspenseQuery({queryKey:Xo.checkLpTokens(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${n}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:K.MINUTE})}function fi(){const e=re(),n=qn(e),s=x.useMemo(()=>n.map(a=>a.denom),[n]),{data:o}=bd(s);return x.useMemo(()=>{const a=n.filter(r=>o.get(r.denom)===!0);return wd(a)},[n,o])}function pi(e){const{dexUrl:n}=ee();return $.useSuspenseQuery({queryKey:Xo.lpPrices(n,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${n}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:K.MINUTE})}function vd(e){const{dexUrl:n}=ee(),s=re(),o=xt(s),a=x.useMemo(()=>{const c=new Map;for(const l of o)c.set(l.denom,l);return c},[o]),i=$.useSuspenseQueries({queries:e.map(c=>({queryKey:Xo.pool(n,c).queryKey,queryFn:async()=>{try{const l=v.denomToMetadata(c);return(await z.get(`${n}/indexer/dex/v2/pools/${encodeURIComponent(l)}`).json()).pool}catch{return null}},staleTime:K.MINUTE}))}).map(c=>c.data);return x.useMemo(()=>{const c=new Map;return e.forEach((l,d)=>{const m=i[d];if(!m){c.set(l,null);return}if(l===xl){c.set(l,{...m,symbol:yl});return}const u=m.coins.map(h=>a.get(h.denom)?.symbol||h.denom).join("-");c.set(l,{...m,symbol:u})}),c},[e,i,a])}function Cd(e,n,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of n){const c=i[0]?.denom;c&&c!==Ie&&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!==Ie&&a.add(r)}return Array.from(a)}function Nd(e){const n=[];for(const[,s]of e)s&&s!==Ie&&n.push(s);return n}function kd(e,n){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>n.get(s.denom)?.logoUrl||"")}function Id(e,n,s){const o=n.get(e)??null,a=o?.symbol||e,r=kd(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 Xs(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r)??i[0]?.denom;if(!c||c===Ie)continue;const l=o.get(c);if(l)for(const d of i){const m=String(d.amount),u=l.decimals,h=Number(v.fromBaseUnit(m,{decimals:u})),f=s.get(c)??0,p=h*f;l.breakdown[a]+=h,l.totalAmount+=h,l.totalValue+=p}}}function Ad(e,n,s,o,a){for(const[r,i]of e){const c=n.get(r);if(!c||c===Ie)continue;const l=o.get(c);if(l)for(const d of i){const m=String(d.amount),u=l.decimals,h=Number(v.fromBaseUnit(m,{decimals:u})),f=s.get(c)??0,p=h*f;l.breakdown[a]+=h,l.totalAmount+=h,l.totalValue+=p}}}function Sd(e,n,s,o){for(const[a,r]of e){const i=v.denomToMetadata(a),c=n?.get(i),l=c?v.fromBaseUnit(c.amount,{decimals:Be}):"0",d=s?.get(i),m=d?v.fromBaseUnit(d.amount,{decimals:Be}):"0",u=Number(l)+Number(m);u>0&&(r.claimableInit={staking:l,lockStaking:m,total:String(u),totalValue:u*o})}}function ea(){const e=re(),n=xt(e),s=fi(),{data:o}=Qo(),{data:a}=Zo(),{data:r}=Yo(),{data:i}=mi(),{data:c}=hi(),{data:l}=yt(e),d=x.useMemo(()=>{const y=new Map;for(const j of n)y.set(j.denom,j);return y},[n]),m=x.useMemo(()=>Cd(s,o,a,r),[s,o,a,r]),u=Bo(m),h=x.useMemo(()=>Nd(u),[u]),{data:f}=pi(h),p=vd(h),{rows:g,totalValue:_}=x.useMemo(()=>{const y=l?.find(C=>C.id===Ie)?.price??0,j=new Map;for(const C of h)j.set(C,Id(C,p,d));Xs(s,u,f,j,"deposit"),Xs(o,u,f,j,"staking"),Ad(a,u,f,j,"lockStaking"),Xs(r,u,f,j,"unstaking"),Sd(j,i,c,y);const b=Array.from(j.values()).filter(C=>C.totalAmount>0).sort((C,I)=>I.totalValue-C.totalValue),w=b.reduce((C,I)=>C+I.totalValue,0);return{rows:b,totalValue:w}},[h,p,d,s,o,a,r,u,f,i,c,l]);return{totalValue:_,rows:g}}const Td=ye.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,n)=>[e,n]});function $d(e){return e.filter(n=>n.data.length>0).map(n=>{const s=n.data[0].bridge_id,o=n.data[0].version,a=n.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:n.total_claimable_reward,claimedReward:a,initialReward:n.total_vesting_reward,lockedReward:n.total_locked_reward,requiredScore:n.required_score,rollup:{bridgeId:s,version:o}}}).filter(n=>n.initialReward>0).toSorted((n,s)=>s.initialReward-n.initialReward)}function gi(){const{vipUrl:e}=ee(),n=X();return $.useQuery({queryKey:Td.allVestingPositions(e,n).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${n}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:K.MINUTE,enabled:!!n})}function Ed(){const e=de();return x.useCallback(n=>e.find(({metadata:s})=>s?.op_bridge_id===String(n)),[e])}function Bs(){const{data:e}=gi(),n=re(),{data:s}=yt(n),o=Ed(),a=x.useMemo(()=>s?.find(l=>l.id===Ie)?.price??0,[s]),r=x.useMemo(()=>e?$d(e).map(l=>{const d=o(l.rollup.bridgeId),m=Number(v.fromBaseUnit(String(l.lockedReward),{decimals:Be})),u=Number(v.fromBaseUnit(String(l.claimableReward),{decimals:Be})),h=B(v.fromBaseUnit(String(l.lockedReward),{decimals:Be})).times(a).toNumber(),f=B(v.fromBaseUnit(String(l.claimableReward),{decimals:Be})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:u,claimableRewardValue:f}}):[],[e,a,o]),i=x.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function _i(){const e=fi(),{data:n}=Qo(),{data:s}=Zo(),{data:o}=Yo(),{data:a}=gi(),r=re(),{data:i}=yt(r),c=x.useMemo(()=>i?.find(g=>g.id===Ie)?.price??0,[i]),l=x.useMemo(()=>{const p=new Set;for(const[g]of e)p.add(g);for(const[g]of n)p.add(g);for(const[g]of s)p.add(g);for(const[g]of o)p.add(g);return Array.from(p)},[e,n,s,o]),d=Bo(l),m=x.useMemo(()=>Array.from(d.values()).filter(p=>p!==Ie),[d]),{data:u}=pi(m),h=xt(r),f=x.useMemo(()=>{const p=new Map;for(const g of h)p.set(g.denom,{decimals:g.decimals});return p},[h]);return x.useMemo(()=>{let p=0,g=0;const _=c??0,y=(b,w)=>{const C=d.get(b)??b;if(C===Ie)return 0;const I=f.get(C)?.decimals??Be;return Number(v.fromBaseUnit(w,{decimals:I}))*(u.get(C)??0)};for(const[,b]of n)for(const{denom:w,metadata:C,amount:I}of b)w===Ie?p+=Number(v.fromBaseUnit(I,{decimals:Be}))*_:g+=y(C,I);for(const[b,w]of s){const I=(d.get(b)??b)===Ie;for(const{amount:E}of w)I?p+=Number(v.fromBaseUnit(E,{decimals:Be}))*_:g+=y(b,E)}for(const[,b]of o)for(const{denom:w,metadata:C,amount:I}of b)w===Ie?p+=Number(v.fromBaseUnit(I,{decimals:Be}))*_:g+=y(C,I);for(const[b,w]of e)for(const{amount:C}of w)g+=y(b,String(C));let j=0;if(a)for(const b of a){const w=b.total_locked_reward??0,C=b.total_claimable_reward??0;j+=Number(v.fromBaseUnit(String(w+C),{decimals:Be}))*_}return p+g+j},[n,s,o,e,a,c,d,u,f])}function Md(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],n={"initia-wallet-widget:ethereum-public-keys":{prefix:ae.PUBLIC_KEY,getSuffix:s=>v.InitiaAddress(s).bech32}};for(const s of e)localStorage.removeItem(s);for(const[s,{prefix:o,getSuffix:a}]of Object.entries(n)){const r=localStorage.getItem(s);if(r)try{const i=JSON.parse(r);for(const[c,l]of Object.entries(i)){const d=`${o}:${a(c)}`;localStorage.setItem(d,l)}localStorage.removeItem(s)}catch{}}}const jo=ye.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,n)=>[e,n],balances:(e,n,s)=>[e,n,s],initiaPositions:(e,n)=>[e,"initia",n],echelonPositions:(e,n)=>[e,"echelon",n],inertiaPositions:(e,n)=>[e,"inertia",n],ravePositions:(e,n,s)=>[e,"rave",n,s],civitiaPositions:(e,n)=>[e,"civitia",n],yominetPositions:(e,n)=>[e,"yominet",n],chainPositions:(e,n,s)=>[e,n,s]});function ta(e,n){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=n[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const d=`${i.chainId}:${l.denom}`;s.has(d)||s.set(d,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 n=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-n:n}function Ld(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 qd(e,n=!1){switch(e){case"staking":return n?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function Pd(e){const n=new Map;for(const d of e){const m=Ld(d);if(!m)continue;const u=n.get(m)??[];u.push(d),n.set(m,u)}const s=new Map,o=new Map;for(const[d,m]of n){const u=m.reduce((f,p)=>f+ln(p),0),h=m.reduce((f,p)=>f+Math.abs(ln(p)),0);s.set(d,u),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...n.keys()].sort((d,m)=>{const u=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(d==="lending"||d==="borrowing")&&(m==="lending"||m==="borrowing")?d==="lending"?-1:1:h-u}),l=new Map;for(const d of c)l.set(d,{positions:n.get(d),totalValue:s.get(d)??0});return l}function Dd(e){return e.type==="fungible-position"?e.title:e.balance.denom}function Bd(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function Rd(e){return e.type==="fungible-position"?null:e.balance}function Fd(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 Ud(e){const n=new Map;for(const s of e){const o=n.get(s.type)??[];o.push(s),n.set(s.type,o)}return n}function Od(e,n){return e.symbol===Ye&&n.symbol===Ye?0:e.symbol===Ye?-1:n.symbol===Ye?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function Vd(e){const n=new Map;for(const o of e){const a=Dd(o),r=n.get(a)??[];r.push(o),n.set(a,r)}return Array.from(n.entries()).map(([o,a])=>{const r=Rd(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:Bd(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+ln(l),0),totalAmount:i,balance:r}}).toSorted(Od)}function xi(e,n){const s=new Map;return e.forEach((o,a)=>{const r=n[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function Kd(e,n){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=n.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function Wd(e,n){return e.symbol===Ye&&n.symbol===Ye?0:e.symbol===Ye?-1:n.symbol===Ye?1:n.totalValue!==e.totalValue?n.totalValue-e.totalValue:e.symbol.localeCompare(n.symbol,void 0,{sensitivity:"base"})}function zd(e,n,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,d=n.get(l)??s.get(c)??"";return d!==i.logoUrl?{...i,logoUrl:d}:i});let r="";for(const i of a)if(i.logoUrl){r=i.logoUrl;break}return r||(r=s.get(o.symbol.toUpperCase())??""),r!==o.logoUrl||a!==o.assets?{...o,logoUrl:r,assets:a}:o})}function Hd(e,n,s){const o=n?e.filter(i=>{const{symbol:c,assets:l}=i,d=n.toLowerCase();return c.toLowerCase().includes(d)||l.some(({denom:m})=>m.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Gd(e,n,s){const o=n?e.filter(({denom:a,address:r})=>{const i=n.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function Qd(e,n,s,o){const{filteredAssets:a,totalAssetsValue:r}=Hd(e,s,o),i=Gd(n,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Yd(e,n,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:d,balances:m}=c;if(!Array.isArray(m))continue;const u=n.get(l.toLowerCase()),h=u?.chainId??d??l,f=u?.prettyName??l,p=u?.logoUrl??"",g=s.get(h);for(const _ of m){if(_.type==="unknown"){if(!_.amount||_.amount==="0")continue;r.push({symbol:_.denom,logoUrl:"",denom:_.denom,amount:_.amount,decimals:0,quantity:_.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:p}});continue}if(_.type==="lp"||(_.value??0)<=0&&(_.formattedAmount??0)<=0)continue;let y=_.value;if((y==null||y<=0)&&g){const w=g.get(_.denom)??0;w>0&&(y=_.formattedAmount*w)}const j={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:y,chain:{chainId:h,name:f,logoUrl:p}},b=a.get(_.symbol);b?b.push(j):a.set(_.symbol,[j])}}r.sort((c,l)=>{const d=c.chain.chainId===o,m=l.chain.chainId===o;if(d&&!m)return-1;if(!d&&m)return 1;const u=c.chain.name.localeCompare(l.chain.name);if(u!==0)return u;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((u,h)=>(h.value??0)-(u.value??0));let d=0,m=0;for(const u of l)d+=u.value??0,m+=Number(u.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:m})}return i.sort(Wd),{listedGroups:i,unlistedAssets:r}}function na(){return re().network_type==="testnet"}function St(){return _e.useFormContext()}function Zd(){const e=et(),n=na(),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=T.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(ae.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(ae.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(ae.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(ae.BRIDGE_DST_DENOM),quantity:localStorage.getItem(ae.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(ae.BRIDGE_SLIPPAGE_PERCENT)});return{...n?o:a,...r,...e}}const Jd={balances:[],positions:[],isLoading:!0,isComplete:!1},yi=U.atom(0),Xd=1e3;let Sa=0;function eu(){const e=U.useSetAtom(yi);x.useEffect(()=>{const n=Date.now();n-Sa>=Xd&&(Sa=n,e(s=>s+1))},[e])}function tu(){const e=$.useQueryClient(),n=X(),{minityUrl:s}=ee(),o=na(),a=U.useAtomValue(yi),r=x.useEffectEvent((l,d)=>{const m=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=x.useEffectEvent((l,d)=>{const m=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=x.useEffectEvent((l,d)=>{const m=jo.ssePortfolio(n??"",s).queryKey,u=e.getQueryData(m)??Jd,h=l.size>0||d.size>0;e.setQueryData(m,{...u,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:u.isLoading,isComplete:!1})});x.useEffect(()=>{if(!n||o)return;const l=jo.ssePortfolio(n,s).queryKey,d=e.getQueryData(l),m=new Map,u=new Map;for(const _ of d?.balances??[])m.set(_.chainName,_);for(const _ of d?.positions??[])u.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(n)}`;let p=null,g=!1;return e.setQueryData(l,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),p=new EventSource(f),p.onmessage=_=>{if(!g)try{const y=JSON.parse(_.data);y.type==="balances"?r(y,m):y.type==="positions"&&i(y,u),c(m,u)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[n,o,a])}const Ta={balances:[],positions:[],isLoading:!0,isComplete:!1};function Un(){const e=X(),{minityUrl:n}=ee(),s=jo.ssePortfolio(e??"",n).queryKey,{data:o}=$.useQuery({queryKey:s,queryFn:()=>Ta,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??Ta}function nu(){const e=de();return x.useMemo(()=>{const n=new Map;for(const s of e){const o=s.chain_name.toLowerCase();n.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return n},[e])}function su(){const{balances:e,positions:n}=Un(),s=de(),o=x.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return x.useMemo(()=>{const r=f=>f.type==="unknown"?0:f.value??0,i=f=>f.positions.reduce((p,g)=>{if(g.type==="fungible-position")return p+(g.value??0);if(g.balance.type==="unknown")return p;const _=g.balance.value??0;return g.type==="lending"&&g.direction==="borrow"?p-_:p+_},0),c=new Map,l=Array.isArray(e)?e:[],d=Array.isArray(n)?n:[];for(const{chainName:f,balances:p}of l){if(!Array.isArray(p))continue;const g=p.reduce((_,y)=>_+r(y),0);c.set(f,(c.get(f)||0)+g)}for(const{chainName:f,positions:p}of d){if(!Array.isArray(p))continue;const g=p.reduce((_,y)=>_+i(y),0);c.set(f,(c.get(f)||0)+g)}const m=Array.from(c.values()).reduce((f,p)=>f+p,0),u=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,p])=>{const g=o.get(f.toLowerCase());return{chainId:g?.chainId||"",chainName:g?.name||f,logoUrl:g?.logoUrl||"",totalBalance:p,percentage:m>0?p/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return T.sortWith([T.descend(h),T.descend(T.prop("totalBalance"))],u)},[e,n,o])}function ou(){const{balances:e}=Un(),n=de(),s=Po(),o=x.useMemo(()=>xi(n,s),[n,s]);return x.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=Kd(i,o);for(const{balances:l}of c)if(Array.isArray(l))for(const d of l)d.type!=="lp"&&(r+=a(d));return r},[e,o])}function au(){const{positions:e}=Un();return x.useMemo(()=>{const n=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,d)=>l+n(d),0))}return o},[e])}const Me=ye.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,n)=>[e,n],allBalances:(e,n)=>[e,n],balances:(e,n)=>[e,n],route:(e,n)=>[{...e,quantity:B(e.quantity||0).toString()},n],routeErrorInfo:e=>[e],txTrack:(e,n)=>[e,n],txStatus:(e,n)=>[e,n]});function tt(){const{routerApiUrl:e}=ee();return x.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.4.0"}}),[e])}function ji(){const e=de();return n=>e.some(s=>s.chain_id===n)}function On(){const e=ji();return n=>e(n.chain_id)?"initia":n.chain_type}function Tn(e){return On()(e)}function Vn(){const e=tt(),{data:n}=$.useSuspenseQuery({queryKey:Me.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>T.sortWith([T.descend(({chain_name:o})=>o==="initia"),T.ascend(({pretty_name:o})=>o)],s),staleTime:K.MINUTE});return n}function wt(){const e=Vn(),n=hr();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=n.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function Ge(e){return wt()(e)}function Qt(){const e=tt(),n=Vn(),s=$.useQueryClient(),{data:o}=$.useSuspenseQuery({queryKey:Me.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),select:({chain_to_assets_map:a})=>{const r=[];for(const i in a){if(!n.find(l=>l.chain_id===i))continue;const{assets:c}=a[i]??{assets:[]};s.setQueryData(Me.assets(i).queryKey,{chain_to_assets_map:a}),r.push(...c);for(const l of c)s.setQueryData(Me.asset(i,l.denom).queryKey,l)}return r},staleTime:K.MINUTE});return o}function ys(e){const n=tt(),s=$.useQueryClient(),{data:o}=$.useSuspenseQuery({queryKey:Me.assets(e).queryKey,queryFn:()=>n.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(Me.asset(e,i.denom).queryKey,i);return r.toSorted(T.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function wi(e){const n=ys(e);return s=>{const o=n.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function dt(e,n){return wi(n)(e)}const ru=()=>(Qc(),Yc(),null),iu="_loader_1vxch_1",cu={loader:iu},ut=({size:e=24,color:n="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${n} ${n} transparent ${n}`,borderWidth:`${s}px`};return t.jsx("div",{className:cu.loader,style:o})},lu="_button_1q027_1",du="_outline_1q027_28",uu="_sm_1q027_46",mu="_full_1q027_53",hu="_small_1q027_57",fu="_unpadded_1q027_88",Ut={button:lu,outline:du,sm:uu,full:mu,small:hu,unpadded:fu},bi=e=>{const{sm:n,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return t.jsx("button",{...c,className:q(Ut.button,{[Ut.sm]:n,[Ut.full]:s},a),disabled:!!o||i,children:o?t.jsxs(t.Fragment,{children:[t.jsx(ut,{color:"currentColor",size:16}),typeof o=="string"&&t.jsx("span",{className:Ut.loading,children:o})]}):r})},pu=({className:e,...n})=>t.jsx(bi,{...n,className:q(Ut.outline,e)}),gu=({className:e,unpadded:n,...s})=>t.jsx("button",{...s,className:q(Ut.small,{[Ut.unpadded]:n},e)}),le={White:bi,Outline:pu,Small:gu},_u="_footer_1vp4h_1",xu="_actions_1vp4h_10",$a={footer:_u,actions:xu},xe=({extra:e,className:n,children:s})=>t.jsxs("footer",{className:q($a.footer,n),children:[e,t.jsx("div",{className:$a.actions,children:s})]}),yu="_scrollable_13su7_1",ju={scrollable:yu},nt=({className:e,children:n,ref:s})=>t.jsx("div",{ref:s,className:q(ju.scrollable,e),children:n});function Rs(){return Le.useMediaQuery("(max-width: 576px)")}const wo="interwoven-kit";function vi(){const e=document.querySelector(wo)||document.body.appendChild(document.createElement(wo));return e.shadowRoot||e.attachShadow({mode:"open"})}function Ci(){const{theme:e,container:n}=ee();return x.useEffect(()=>{document.querySelector(wo)?.setAttribute("data-theme",e)},[e]),n??vi()}function wu(e){const n=vi(),s=document.createElement("style");s.textContent=e,n.appendChild(s)}const Fs=x.createContext(null);function Ht(){const{container:e}=x.useContext(Fs);return e}function Ni(e){const n=Ht();return n?getComputedStyle(n).getPropertyValue(e):""}function bu(){return Le.useScrollLock(),null}function vu(e){return/^[A-F0-9]{64}$/i.test(e)}function Cu(e,n){const{txHash:s,accountAddress:o,pathSuffix:a}=n;if(s)return vu(s)?T.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!v.InitiaAddress.validate(o))return;const i=T.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Nu(e){try{const n=new URL(e,window.location.href);if(!["http:","https:"].includes(n.protocol))throw new Error("Invalid protocol");return n.toString()}catch{return"#"}}const ku="_link_j1lkz_1",Ea={link:ku},Us=({chainId:e,txHash:n,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,m=Xe(e),u=Cu(m,{txHash:n,accountAddress:s,pathSuffix:o}),h=n?v.truncate(n):s?v.truncate(s):"",f=c??h;return u?t.jsxs("a",{...d,href:Ic(Nu(u)),className:q(Ea.link,i),onClick:l,target:"_blank",children:[f,r&&t.jsx(S.IconExternalLink,{size:12})]}):t.jsx("span",{...d,className:q(Ea.link,i),children:f})},ki=x.createContext(null),Os=()=>x.useContext(ki),Iu=()=>{const[e,n]=U.useAtom(ti),{showNotification:s,updateNotification:o,hideNotification:a}=Os();return x.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?t.jsx(Us,{txHash:c,chainId:i,onClick:a,showIcon:!0,children:"View on Initia Scan"}):null;switch(r){case"loading":s({type:"loading",title:"Transaction is pending..."});break;case"error":o({type:"error",title:"Transaction failed",description:d}),n(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),n(null);break}},[e,n,s,o,a]),null},js=({value:e,children:n})=>{const[s,o]=x.useState(!1);return n({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Au="_placeholder_10r3x_1",Su="_logo_10r3x_5",Ma={placeholder:Au,logo:Su},J=({src:e,alt:n,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=x.useState(void 0),{width:d,height:m}=i,u=s??t.jsx("div",{className:q(Ma.placeholder,o?.placeholder),style:{width:d,height:m,...a}});return!e||c===e?u:t.jsx("img",{...i,className:q(i.className,{[Ma.logo]:r}),style:{width:d,height:m,...a},src:e,alt:n,loading:"lazy",onError:()=>l(e)})};function Ii(){const{connector:e}=Ee.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Tu="_header_1q8ju_1",$u="_account_1q8ju_17",Eu="_name_1q8ju_28",Mu="_address_1q8ju_32",Lu="_icon_1q8ju_36",qu="_copied_1q8ju_43",Pu="_button_1q8ju_58",Du="_settings_1q8ju_69",Bu="_disconnect_1q8ju_73",Ru="_label_1q8ju_83",Fu="_expanded_1q8ju_91",Ke={header:Tu,account:$u,name:Eu,address:Mu,icon:Lu,copied:qu,button:Pu,settings:Du,disconnect:Bu,label:Ru,expanded:Fu},Uu=()=>{const e=Pr(),{address:n,username:s}=Ue(),o=Ii(),a=s??n,[r,i]=x.useState(!1),c=x.useRef(null),l=lt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},u=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return x.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),n?t.jsxs("header",{className:Ke.header,children:[t.jsx(js,{value:n,children:({copy:h,copied:f})=>t.jsxs("button",{className:q(Ke.account,{[Ke.copied]:f}),onClick:h,children:[t.jsx(J,{src:o,width:18,height:18}),t.jsx("div",{className:Ke.address,children:v.truncate(n)}),t.jsx("div",{className:Ke.name,children:v.truncate(a)}),t.jsx(S.IconCopy,{className:Ke.icon,size:12}),f?"Copied!":""]})}),t.jsx(cn,{to:"/settings",className:q(Ke.button,Ke.settings),"aria-label":"Open settings",children:t.jsx(S.IconSettingFilled,{size:16})}),t.jsxs(lt.animated.button,{className:q(Ke.button,Ke.disconnect,{[Ke.expanded]:r}),style:l,onClick:d,onMouseLeave:m,onMouseEnter:u,children:[t.jsx(S.IconSignOut,{size:16}),t.jsx("span",{className:Ke.label,children:"Disconnect"})]})]}):null},Ou="_overlay_jij9g_1",Vu="_content_jij9g_28",Ku="_inner_jij9g_60",eo={overlay:Ou,content:Vu,inner:Ku},Wu=({children:e})=>{const{isDrawerOpen:n,closeDrawer:s}=jt(),{setContainer:o}=x.useContext(Fs),a=Rs(),r=Ci(),i=U.useAtomValue(Ps),c=U.useAtomValue(Pn),l=$.useIsMutating({mutationKey:[ei]}),d=()=>{const p=l?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),i?.reject(new Error(p)),c?.reject(new Error("User rejected"))},m=Ts(),u=Ce(),h=$.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const _=()=>{m==="/bridge"&&(localStorage.removeItem(ae.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_SRC_DENOM),localStorage.removeItem(ae.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ae.BRIDGE_DST_DENOM)),u("/"),h.clear(),g()};return t.jsxs(nt,{children:[t.jsx(he,{error:!0,children:p.message}),t.jsx(xe,{children:t.jsx(le.White,{onClick:_,children:"Retry"})})]})}};return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:p=>!p&&d(),modal:!1,children:t.jsxs(ke.Dialog.Portal,{container:r,children:[a&&t.jsx(ke.Dialog.Backdrop,{className:eo.overlay,onClick:d,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[t.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),t.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),t.jsx(ke.Dialog.Popup,{className:eo.content,children:t.jsxs("div",{className:q(eo.inner,"body"),ref:o,children:[a&&t.jsx(bu,{}),t.jsx(Iu,{}),t.jsx(Uu,{}),t.jsx(me,{errorBoundaryProps:f,children:e})]})})]})})},zu="_backdrop_1bqx9_1",Hu="_modal_1bqx9_12",Gu="_closeButton_1bqx9_44",to={backdrop:zu,modal:Hu,closeButton:Gu},Qu=({children:e})=>{const{isModalOpen:n,closeModal:s}=mn(),{setContainer:o}=x.useContext(Fs),a=Ci();return t.jsx(ke.Dialog.Root,{open:n,onOpenChange:r=>!r&&s(),children:t.jsxs(ke.Dialog.Portal,{container:a,children:[t.jsx(ke.Dialog.Backdrop,{className:to.backdrop,onClick:s}),t.jsxs(ke.Dialog.Popup,{className:q(to.modal),ref:o,children:[t.jsx("button",{className:to.closeButton,onClick:s,"aria-label":"Close",children:t.jsx(S.IconClose,{size:20})}),e]})]})})},Ai=x.createContext(!1),Yu="_overlay_1iyfl_1",Zu="_fullscreen_1iyfl_15",Ju="_content_1iyfl_19",Xu="_header_1iyfl_56",em="_title_1iyfl_65",tm="_close_1iyfl_70",Mt={overlay:Yu,fullscreen:Zu,content:Ju,header:Xu,title:em,close:tm},Si=({title:e,children:n,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=Ht(),c=x.useContext(Ai);return i?t.jsxs(ke.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&t.jsx(ke.Dialog.Trigger,{className:o,children:s}),t.jsxs(ke.Dialog.Portal,{container:i,children:[t.jsx(ke.Dialog.Backdrop,{className:q(Mt.overlay,{[Mt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),t.jsxs(ke.Dialog.Popup,{className:q(Mt.content,{[Mt.fullscreen]:c}),children:[e&&t.jsxs("header",{className:Mt.header,children:[t.jsx(ke.Dialog.Title,{className:Mt.title,children:e}),t.jsx(ke.Dialog.Close,{className:Mt.close,children:t.jsx(S.IconClose,{size:20})})]}),n]})]})]}):null},$n=({children:e})=>{const n=x.useRef(null),[s,o]=x.useState(0),[a,r]=x.useState(!1),i=lt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return x.useEffect(()=>{const c=n.current;if(!c)return;const l=()=>{const{height:m}=c.getBoundingClientRect();o(m),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?t.jsx(lt.animated.div,{style:{overflow:"hidden",...i},children:t.jsx("div",{ref:n,children:e})}):null},nm="_help_qcmtq_1",sm="_icon_qcmtq_10",om="_info_qcmtq_19",am="_warning_qcmtq_23",rm="_error_qcmtq_27",im="_success_qcmtq_33",no={help:nm,icon:sm,info:om,warning:am,error:rm,success:im},sn=({level:e,className:n,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return t.jsx(ut,{size:12});case"info":return t.jsx(S.IconInfoFilled,{size:12});case"warning":case"error":return t.jsx(S.IconWarningFilled,{size:12});default:return t.jsx(S.IconCheckCircleFilled,{size:12})}};return t.jsxs("div",{className:q(no.help,e&&no[e],n),style:{marginTop:s},children:[t.jsx("div",{className:no.icon,children:a()}),o]})},cm="_stack_a6m7u_1",lm="_help_a6m7u_6",dm="_info_a6m7u_14",um="_warning_a6m7u_19",mm="_error_a6m7u_24",hm="_success_a6m7u_29",bo={stack:cm,help:lm,info:dm,warning:um,error:mm,success:hm},fm=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:t.jsx($n,{children:t.jsx("div",{className:bo.stack,children:e})}),fe=({mt:e=0,...n})=>t.jsx(sn,{...n,className:q(bo.help,bo[n.level]),mt:e});fe.Stack=fm;const pm="_root_16p5j_1",gm="_item_16p5j_10",_m="_chevron_16p5j_14",xm="_trigger_16p5j_19",ym="_content_16p5j_39",gn={root:pm,item:gm,chevron:_m,trigger:xm,content:ym};function jm(e){const{list:n,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return t.jsxs(Z.Accordion.Root,{className:gn.root,type:"multiple",...i,children:[n.map((c,l)=>t.jsxs(Z.Accordion.Item,{className:gn.item,value:s?.(c)??String(l),children:[t.jsx(Z.Accordion.Header,{children:t.jsxs(Z.Accordion.Trigger,{className:gn.trigger,children:[o(c),t.jsx(S.IconChevronDown,{className:gn.chevron,size:16})]})}),t.jsx(Z.Accordion.Content,{className:gn.content,children:a(c)})]},s?.(c)??l)),r]})}const wm="_trigger_u613p_1",bm="_icon_u613p_18",vm="_content_u613p_27",Cm="_item_u613p_36",Nm="_itemText_u613p_52",km="_itemIndicator_u613p_57",Im="_active_u613p_60",Nt={trigger:wm,icon:bm,content:vm,item:Cm,itemText:Nm,itemIndicator:km,active:Im};function sa({options:e,value:n,onChange:s,classNames:o}){const a=Ht(),r=e.find(c=>c.value===n);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return t.jsxs(ft.Select.Root,{value:String(n),onValueChange:i,modal:!1,children:[t.jsxs(ft.Select.Trigger,{className:q(Nt.trigger,o?.trigger),children:[t.jsx(ft.Select.Value,{children:r.triggerLabel||r.label}),t.jsx(ft.Select.Icon,{className:Nt.icon,children:t.jsx(S.IconChevronDown,{size:12})})]}),t.jsx(ft.Select.Portal,{container:a,children:t.jsx(ft.Select.Positioner,{className:Nt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:t.jsx(ft.Select.Popup,{className:Nt.popup,children:e.map(c=>t.jsxs(ft.Select.Item,{className:q(Nt.item,o?.item),value:String(c.value),children:[t.jsx(ft.Select.ItemText,{className:q(Nt.itemText,o?.itemText),children:c.label}),t.jsx(S.IconCheck,{size:12,className:q(Nt.itemIndicator,{[Nt.active]:c.value===n})})]},String(c.value)))})})})]})}const Am="_root_1t37n_1",Sm="_trigger_1t37n_7",Tm="_item_1t37n_11",$m="_itemText_1t37n_17",La={root:Am,trigger:Sm,item:Tm,itemText:$m},Em=({options:e,value:n,onChange:s})=>{const{txRequest:o}=si(),a=Xe(o.chainId),r=mt(a),i=(p,g)=>{if(v.formatAmount(p,{decimals:g})==="0.000000")return 8},c=({amount:[{amount:p,denom:g}]})=>{if(B(p).isZero())return"0";const{symbol:_,decimals:y}=r(g),j=i(p,y);return`${v.formatAmount(p,{decimals:y,dp:j})} ${_}`},l=e.map(p=>{const[{denom:g}]=p.amount,{symbol:_}=r(g);return{value:g,label:c(p),triggerLabel:_}});if(e.length===1)return t.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===n);if(!d)throw new Error("Fee option not found");const[{amount:m,denom:u}]=d.amount,{decimals:h}=r(u),f=i(m,h);return t.jsxs("div",{className:La.root,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(m,{decimals:h,dp:f})}),t.jsx(sa,{options:l,value:n,onChange:s,classNames:La})]})},Mm="_root_16nr2_1",Lm="_trigger_16nr2_5",qm="_chevron_16nr2_13",Pm="_panel_16nr2_27",Dm="_details_16nr2_39",Bm="_row_16nr2_48",en={root:Mm,trigger:Lm,chevron:qm,panel:Pm,details:Dm,row:Bm},Rm=({spend:e,fee:n,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:n},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return t.jsxs(Ys.Collapsible.Root,{className:en.root,children:[t.jsxs(Ys.Collapsible.Trigger,{className:en.trigger,children:[t.jsx("span",{children:"Insufficient balance for fee"}),t.jsx(S.IconChevronDown,{className:en.chevron,size:16})]}),t.jsx(Ys.Collapsible.Panel,{className:en.panel,children:t.jsx("div",{className:en.details,children:i.map(({label:l,value:d})=>t.jsxs("div",{className:en.row,children:[t.jsx("span",{children:l}),t.jsxs("span",{children:[v.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function ws(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?se.toBase64(e):Array.isArray(e)?`[${e.map(ws).join(",")}]`:JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const Fm="_container_1xzyq_1",Um="_toggle_1xzyq_5",Om="_list_1xzyq_11",Vm="_arg_1xzyq_16",Km="_type_1xzyq_21",_n={container:Fm,toggle:Um,list:Om,arg:Vm,type:Km},Wm=ye.createQueryKeys("interwovenkit:move",{abi:(e,n,s,o)=>[e,n,s,o]}),zm=({type:e,arg:n})=>ws(v.resolveBcsType(e).parse(n)),Hm=({msg:e,chainId:n,fallback:s})=>{const[o,a]=Le.useToggle(!1),{restUrl:r}=Xe(n),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:m}=$.useQuery({queryKey:Wm.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),p=JSON.parse(h.module.abi).exposed_functions.find(({name:g})=>g===l);if(!p)throw new Error(`Function ${l} not found in module ${c}`);return p.params.filter(g=>!g.startsWith("&"))},staleTime:K.INFINITY});if(!m)return s;const u=(h,f)=>{const p=m[f];return t.jsxs("div",{className:_n.arg,children:[t.jsx("div",{className:_n.type,children:p}),t.jsx(cr.ErrorBoundary,{fallback:t.jsx("div",{className:"error",children:"Error decoding argument"}),children:t.jsx(zm,{type:p,arg:h})})]},f)};return t.jsxs("div",{className:_n.container,children:[t.jsx(le.Small,{className:_n.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?t.jsx("div",{className:_n.list,children:d.map(u)}):s]})},Gm="_list_oip9m_1",Qm="_key_oip9m_9",Ym="_value_oip9m_14",so={list:Gm,key:Qm,value:Ym},Zm=({message:e,chainId:n})=>{const{typeUrl:s,value:o}=e;return t.jsx("div",{className:so.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{children:[t.jsx("div",{className:so.key,children:a}),t.jsx("div",{className:so.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?t.jsx(Hm,{msg:o,chainId:n,fallback:ws(r)}):ws(r)})]},a))})},Jm="_item_1n572_1",Xm="_title_1n572_10",eh="_content_1n572_14",oo={item:Jm,title:Xm,content:eh},ao=({title:e,content:n})=>t.jsxs("div",{className:oo.item,children:[t.jsx("div",{className:oo.title,children:e}),t.jsx("div",{className:oo.content,children:n})]});function te(e){const n=e?B(e).abs():void 0;if(n&&n.gt(0)&&n.lt(.01))return"< $0.01";const s=e&&B(e).lt(0),o=v.formatNumber(n?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ti(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d-BigInt(c)}}}if(o.type==="coin_received"){const r=o.attributes.find(c=>c.key==="receiver")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===n&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const d=s[l]||BigInt(0);s[l]=d+BigInt(c)}}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),denom:o}))}function $i(e,n){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&v.createUserDerivedObjectAddress(n,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&v.createUserDerivedObjectAddress(n,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Ei=({metadata:e,chain:n,children:s})=>{const{restUrl:o}=n,{data:a}=$.useSuspenseQuery({queryKey:In.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:K.INFINITY});return s(a)},th="_root_1p8a4_1",nh="_title_1p8a4_8",sh="_changes_1p8a4_14",oh="_change_1p8a4_14",ah="_amount_1p8a4_35",rh="_text_1p8a4_42",ih="_value_1p8a4_49",Ot={root:th,title:nh,changes:sh,change:oh,amount:ah,text:rh,value:ih},Mi=({amount:e,asset:n,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=n,c=v.formatAmount(e,{decimals:r}),l=s&&B(v.fromBaseUnit(e,{decimals:r})).times(s).abs();return t.jsxs("div",{className:Ot.change,children:[t.jsxs("div",{className:Ot.amount,children:[t.jsx(J,{src:i,width:14,height:14,logo:!0}),t.jsxs("span",{className:Ot.text,children:[c," ",a||o]})]}),l&&t.jsx("div",{className:Ot.value,children:te(l)})]})},ch=({changes:e,chain:n})=>{const s=mt(n),{data:o}=yt(n);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return t.jsx(Mi,{amount:a,asset:c,price:l},i)})},lh=({changes:e,chain:n})=>{const s=mt(n),{data:o}=yt(n);return e.map(({amount:a,metadata:r},i)=>t.jsx(Ei,{metadata:r,chain:n,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return t.jsx(Mi,{amount:a,asset:s(c),price:l})}},i))};function dh(e,n){return typeof n=="bigint"?n.toString():n}const uh=ye.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,dh)]}),mh=({messages:e,memo:n,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=Ue(),r=Xe(s),{simulateTx:i}=Ds(),{data:c}=$.useSuspenseQuery({queryKey:uh.simulate({messages:e,memo:n,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:n,chainId:s}),staleTime:K.SECOND}),l=h=>t.jsxs("div",{className:Ot.root,children:[t.jsx("h2",{className:Ot.title,children:"Estimated changes"}),t.jsx("div",{className:Ot.changes,children:h})]});if(!c)return null;const d=c.result?.events??[];if(d.length===0)return null;if(r.metadata?.is_l1||r.metadata?.minitia?.type==="minimove"){const h=$i(d,a),[f]=qa(h);return f.length===0?null:l(t.jsx(lh,{changes:f,chain:r}))}const m=Ti(d,o),[u]=qa(m);return u.length===0?null:l(t.jsx(ch,{changes:u,chain:r}))};function qa(e){return T.partition(n=>new B(n.amount).isNegative(),e)}const hh="_title_1d032_1",fh="_meta_1d032_7",ph="_footer_1d032_14",gh="_rejectButton_1d032_19",ns={title:hh,meta:fh,footer:ph,rejectButton:gh},Li=()=>{const{txRequest:e,resolve:n,reject:s}=si(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=Xe(r),m=qn(d),u=zo(d),h=Ho(d),f=mt(d),p=ni(),g=(e.gasPrices??u).map(({amount:A,denom:L})=>je.calculateFee(Math.ceil(i*c),je.GasPrice.fromString(A+L))),_=g.map(A=>A.amount[0]),y=A=>{const L=m.find(H=>H.denom===A)?.amount??"0",N=_.find(H=>H.denom===A)?.amount??"0",k=l.filter(H=>H.denom===A).reduce((H,Q)=>B(H).plus(Q.amount),B("0")),P=B(N).plus(k),R=B(L).gte(P),{symbol:O,decimals:V}=f(A);return{symbol:O,decimals:V,spend:k.gt(0)?k.toFixed():null,fee:N,total:P.toFixed(),balance:L,isSufficient:R}},j=()=>{if(h&&y(h).isSufficient)return h;for(const{denom:A}of _)if(y(A).isSufficient)return A;return _[0]?.denom},[b,w]=x.useState(j),{mutate:C,isPending:I}=$.useMutation({mutationKey:[ei],mutationFn:async()=>{const A=g.find(N=>N.amount[0].denom===b);if(!A)throw new Error("Fee not found");const L=await p({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:b,allowAutoSign:!e.internal,allowWalletDerivation:!0});await n(L)},onError:async A=>{s(A)}}),E=y(b),M=!E.isSufficient;return t.jsxs(t.Fragment,{children:[t.jsxs(nt,{children:[t.jsx("h1",{className:ns.title,children:"Confirm tx"}),t.jsxs("div",{className:ns.meta,children:[t.jsx(ao,{title:"Chain",content:r}),t.jsx(ao,{title:"Tx fee",content:t.jsx(Em,{options:g,value:b,onChange:w})}),a&&t.jsx(ao,{title:"Memo",content:a}),M&&t.jsx(fe,{level:"error",children:t.jsx(Rm,{...E})})]}),t.jsx(mh,{messages:o,memo:a,chainId:r}),t.jsx(jm,{list:o,renderHeader:({typeUrl:A})=>Ns.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>t.jsx(Zm,{message:A,chainId:r})})]}),t.jsxs(xe,{className:ns.footer,children:[t.jsx(le.Outline,{onClick:()=>s(new Error("User rejected")),disabled:I,className:ns.rejectButton,"aria-label":"Reject",children:t.jsx(S.IconClose,{size:16})}),t.jsx(le.White,{onClick:()=>C(),disabled:M,loading:I,children:"Approve"})]})]})},_h=({children:e})=>{const[{title:n,content:s,path:o},a]=x.useState({}),[r,i]=x.useState(!1),c=U.useAtomValue(Ps),l=x.useCallback(u=>{a(u),i(!0)},[]),d=x.useCallback(()=>{a({}),i(!1)},[]),m=x.useCallback(u=>{u||(c?.reject(new Error("User rejected")),a({})),i(u)},[c]);return t.jsxs(Yr.Provider,{value:{openModal:l,closeModal:d},children:[e,t.jsx(Si,{title:n,open:r,onOpenChange:m,children:t.jsx(me,{children:o==="/tx"?t.jsx(Li,{}):s})})]})},xh="_container_1w1hx_1",yh="_toast_1w1hx_11",jh="_info_1w1hx_24",wh="_success_1w1hx_28",bh="_error_1w1hx_32",vh="_icon_1w1hx_37",Ch="_content_1w1hx_45",Nh="_title_1w1hx_48",kh="_description_1w1hx_53",Ih="_close_1w1hx_75",kt={container:xh,toast:yh,info:jh,success:wh,error:bh,icon:vh,content:Ch,title:Nh,description:kh,close:Ih},Ah=({notification:e,onClose:n,...s})=>{const o=lt.useTransition(e,{keys:r=>r?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),a=r=>{switch(r){case"loading":return t.jsx(ut,{size:16});case"info":case"success":return t.jsx(S.IconCheckCircleFilled,{size:16});case"error":return t.jsx(S.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,m=a(c);return t.jsx(lt.animated.div,{style:r,className:kt.container,children:t.jsxs("div",{className:q(kt.toast,c&&kt[c]),...s,children:[m&&t.jsx("div",{className:kt.icon,children:m}),t.jsxs("div",{className:kt.content,children:[t.jsx("p",{className:kt.title,children:l}),d&&t.jsx("div",{className:kt.description,children:d})]}),t.jsx("button",{className:kt.close,onClick:n,children:t.jsx(S.IconClose,{size:14})})]})})})},ro=5e3,Sh=({children:e})=>{const n=Ht(),[s,o]=x.useState(null),a=x.useRef(null),r=x.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=x.useCallback(()=>{i(),o(null)},[]),l=x.useCallback(h=>{i(),o({...h,id:ba.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),ro))},[c]),d=x.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:ba.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),ro))},[c]),m=()=>{i(),r.current=!0},u=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),ro))};return x.useEffect(()=>()=>i(),[]),t.jsxs(ki.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,n&&Ac.createPortal(t.jsx(Ah,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:u}),n)]})},Th=({children:e})=>{const[n,s]=x.useState(null);return t.jsx(Fs.Provider,{value:{container:n,setContainer:s},children:e})},qi=[{value:10*Er,label:"for 10 minutes"},{value:Mr,label:"for 1 hour"},{value:ka,label:"for 1 day"},{value:7*ka,label:"for 7 days"},{value:0,label:"until revoked"}],$h=qi[0].value;function Eh(e){const n=e.split(".");return n.length!==4?!1:n.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function Pi(e){return Eh(e)||e.includes(":")}function vo(e){const n=Sc.parse(e);return"error"in n?null:n.domain}function Mh(e){if(e.protocol!=="https:")return!1;const n=e.hostname.toLowerCase();return!n||!n.includes(".")||n==="localhost"||Pi(n)?!1:vo(n)!==null}function Lh(e,n){try{const s=new URL(e);if(!Mh(s))return!1;const o=s.hostname.toLowerCase(),a=n.toLowerCase();if(!o||!a||Pi(a)||a==="localhost")return!1;const r=vo(o);if(!r)return!1;const i=vo(a);return!i||i!==r?!1:a===o||a.endsWith(`.${o}`)}catch{return!1}}const qh="_container_1422v_1",Ph="_title_1422v_7",Dh="_description_1422v_14",Bh="_sectionTitle_1422v_20",Rh="_websiteInfo_1422v_27",Fh="_favicon_1422v_37",Uh="_websiteTitle_1422v_42",Oh="_websiteHost_1422v_48",Vh="_warningContent_1422v_54",Kh="_ignoreButton_1422v_61",Wh="_infoList_1422v_65",zh="_infoItem_1422v_75",Hh="_label_1422v_84",Gh="_infoValue_1422v_94",Qh="_durationTrigger_1422v_100",Yh="_durationItem_1422v_101",Zh="_featureList_1422v_105",Jh="_featureItem_1422v_113",Xh="_checkIcon_1422v_123",ef="_learnMoreLink_1422v_127",tf="_feedbackContainer_1422v_140",nf="_footer_1422v_146",ie={container:qh,title:Ph,description:Dh,sectionTitle:Bh,websiteInfo:Rh,favicon:Fh,websiteTitle:Uh,websiteHost:Oh,warningContent:Vh,ignoreButton:Kh,infoList:Wh,infoItem:zh,label:Hh,infoValue:Gh,durationTrigger:Qh,durationItem:Yh,featureList:Zh,featureItem:Jh,checkIcon:Xh,learnMoreLink:ef,feedbackContainer:tf,footer:nf};function sf(e){return e instanceof z.HTTPError&&e.response.status===404}const of=ye.createQueryKeys("interwovenkit:account",{info:(e,n)=>({queryKey:[e,n],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${n}`;try{return await s.get(o).json(),!0}catch(a){if(sf(a))return!1;throw a}}})}),af=()=>{const[e,n]=x.useState($h),[s,o]=U.useAtom(Pn),[a,r]=x.useState(!1),i=Fe(),c=de(),{address:l,username:d}=Ue(),{mutate:m,isPending:u}=ld(),{closeDrawer:h}=jt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:_,isLoading:y,isError:j}=$.useQuery(of.info(g,l)),b={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(k=>k.chainId===s.chainId),C=w?.website?Lh(w.website,window.location.hostname):!1,I=()=>{m(e)},E=()=>{s?.reject(new Error("User cancelled")),o(null),h()},M=!C&&!a,A=!y&&!j&&_===!1,L=!y&&j,N=M||y||j||_===!1;return t.jsxs(t.Fragment,{children:[t.jsxs(nt,{className:ie.container,children:[t.jsxs("header",{children:[t.jsx("h1",{className:ie.title,children:"Enable auto-signing"}),t.jsx("p",{className:ie.description,children:"An application is requesting to enable auto-signing"})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ie.sectionTitle,children:"Requested by"}),t.jsxs("div",{className:ie.websiteInfo,children:[t.jsx("img",{src:b.favicon,alt:"",className:ie.favicon}),t.jsxs("div",{children:[t.jsx("div",{className:ie.websiteTitle,children:b.title}),t.jsx("div",{className:ie.websiteHost,children:b.hostname})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ie.sectionTitle,children:"Applies to"}),t.jsxs("div",{className:ie.infoList,children:[t.jsxs("div",{className:ie.infoItem,children:[t.jsx("div",{className:ie.label,children:"Address"}),t.jsxs("div",{className:ie.infoValue,children:[t.jsx(S.IconWallet,{size:14}),t.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),t.jsxs("div",{className:ie.infoItem,children:[t.jsx("div",{className:ie.label,children:"Chain"}),t.jsxs("div",{className:ie.infoValue,children:[t.jsx(J,{src:f,width:14,height:14,logo:!0}),t.jsx("span",{children:p})]})]}),t.jsxs("div",{className:ie.infoItem,children:[t.jsx("div",{className:ie.label,children:"Duration"}),t.jsx(sa,{options:qi,value:e,onChange:n,classNames:{trigger:ie.durationTrigger,item:ie.durationItem}})]})]})]}),t.jsxs("section",{children:[t.jsx("h2",{className:ie.sectionTitle,children:"About auto-signing"}),t.jsx("ul",{className:ie.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(k=>t.jsxs("li",{className:ie.featureItem,children:[t.jsx(S.IconCheckCircle,{size:12,className:ie.checkIcon}),t.jsx("span",{children:k})]},k))}),t.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:ie.learnMoreLink,children:["Learn more ",t.jsx(S.IconExternalLink,{size:12})]})]})]}),t.jsxs(xe,{className:ie.footer,extra:t.jsxs("div",{className:ie.feedbackContainer,children:[A&&t.jsx(fe,{level:"error",children:"Insufficient balance for fee"}),L&&t.jsx(fe,{level:"warning",children:"Unable to verify account status. Try again."}),!C&&!a&&t.jsx(fe,{level:"warning",children:t.jsxs("div",{className:ie.warningContent,children:[t.jsx("span",{children:"You are on an unverified website"}),t.jsx("button",{onClick:()=>r(!0),className:ie.ignoreButton,children:"Ignore"})]})})]}),children:[t.jsx(le.Outline,{onClick:E,children:"Cancel"}),t.jsx(le.White,{onClick:I,disabled:N,loading:u,children:"Enable"})]})]})},rf=()=>U.useAtomValue(Pn)?t.jsx(af,{}):null,cf="_container_mqvhs_1",lf="_badge_mqvhs_5",Pa={container:cf,badge:lf},Di=e=>{const{offset:n=-4,disabled:s,children:o,className:a}=e;return t.jsxs("div",{className:q(Pa.container,a),children:[o,!s&&t.jsx("div",{className:Pa.badge,style:{right:n,top:n}})]})},df="_header_s7mee_1",uf="_back_s7mee_12",mf="_title_s7mee_24",io={header:df,back:uf,title:mf},ht=({title:e,backButton:n,extra:s,children:o})=>{const a=br();return t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:io.header,children:[t.jsx(cn,{to:n??(a.length>1?-1:"/"),className:io.back,shouldReset:!!n,children:t.jsx(S.IconBack,{size:16})}),t.jsx("h1",{className:io.title,children:e}),s]}),t.jsx(nt,{children:o})]})};function Bi(){const{initiaAddress:e,hexAddress:n}=Ue(),s=wt(),o=On();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return n;default:return""}}}function Ri(){const e=wt(),n=On();return(s,o)=>{const a=e(o);switch(n(a)){case"initia":return v.InitiaAddress.validate(s);case"evm":return ct.isAddress(s);case"cosmos":try{return se.fromBech32(s).prefix===a.bech32_prefix}catch{return!1}default:return!1}}}function hf(){const e=wt(),n=On();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=n(i),l=e(a),d=n(l);if(c==="evm"&&d==="initia")return v.InitiaAddress(s).bech32;if(c==="initia"&&d==="evm")return v.InitiaAddress(s).hex;if(c===d)return s;if(r){if(d==="initia")return v.InitiaAddress(r).bech32;if(d==="evm")return v.InitiaAddress(r).hex}return""}}const ff="_root_ekn9t_1",pf="_header_ekn9t_6",gf="_title_ekn9t_12",_f="_warning_ekn9t_18",xf="_content_ekn9t_22",yf="_footer_ekn9t_26",jf="_secondary_ekn9t_36",Lt={root:ff,header:pf,title:gf,warning:_f,content:xf,footer:yf,secondary:jf},Fi=e=>{const{type:n,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return t.jsxs(nt,{className:Lt.root,children:[t.jsxs("header",{className:q(Lt.header,n&&Lt[n]),children:[s,t.jsx("h1",{className:Lt.title,children:o})]}),t.jsx("div",{className:Lt.content,children:a}),t.jsxs("footer",{className:Lt.footer,children:[t.jsx(le.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),t.jsxs("button",{className:Lt.secondary,onClick:i.onClick,children:[t.jsx("span",{children:i.label}),t.jsx(S.IconChevronRight,{size:14})]})]})]})},wf="_list_k4n3k_1",bf="_row_k4n3k_9",vf="_dt_k4n3k_20",Cf="_asset_k4n3k_26",ss={list:wf,row:bf,dt:vf,asset:Cf},Nf=({list:e,onNavigate:n,onDismiss:s})=>{const o=re(),a=Fe(),r=mt(o);return t.jsx(Fi,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:n},secondaryButton:{label:"Do not show again",onClick:s},children:t.jsx("div",{className:ss.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const m=a(c),{decimals:u,symbol:h}=r(d),f=v.formatAmount(l,{decimals:u});return t.jsxs("div",{className:ss.row,children:[t.jsxs("div",{className:ss.dt,children:[t.jsx(J,{src:m.logoUrl,width:16,height:16,logo:!0}),t.jsx("span",{children:m.name})]}),t.jsxs("span",{className:ss.asset,children:[f," ",h]})]},i)})})})};function co(e,n){return e.chainId===n.chainId&&e.txHash===n.txHash}const os=({chainId:e,txHash:n})=>`${ae.OP_REMINDER}:${e}:${n}`,kf=Tc.atomWithStorage(ae.OP_REMINDER,[]);function fn(){const e=X(),[n=[],s]=U.useAtom(kf),o=x.useMemo(()=>n.map(l=>{const d=localStorage.getItem(os(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:m}=l;return d!==e?!1:Re.isPast(m)}),[e,n]),a=x.useCallback((l,d)=>{n.some(m=>co(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(os(l),JSON.stringify(d)))},[n,s]),r=x.useCallback(l=>{s((d=[])=>d.filter(m=>!co(m,l))),localStorage.removeItem(os(l))},[s]),i=x.useCallback(l=>{const d=l.filter(m=>!n.some(u=>co(u,m)));d.length!==0&&s((m=[])=>[...m,...d])},[n,s]),c=x.useCallback((l,d)=>{localStorage.setItem(os(l),JSON.stringify(d)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Ui(){const e=Ce(),{openModal:n,closeModal:s}=qs(),{reminders:o,setReminder:a}=fn();x.useEffect(()=>{const r=o.filter(l=>!l.dismissed);if(r.length===0)return;const i=()=>{const l=r.every(d=>d.chainId===r[0].chainId)?r[0].chainId:void 0;e("/op/withdrawals",{chainId:l}),c()},c=()=>{s();for(const l of r)a(l,{...l,dismissed:!0})};n({content:x.createElement(Nf,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,n,a])}const If="_wrapper_5ssm8_1",Af="_balance_5ssm8_11",Sf="_button_5ssm8_15",lo={wrapper:If,balance:Af,button:Sf},Oi=({onClick:e,children:n,disabled:s})=>t.jsxs("div",{className:lo.wrapper,children:[t.jsx(S.IconWallet,{size:16}),t.jsx("span",{className:lo.balance,children:n}),t.jsx("button",{type:"button",tabIndex:-1,className:lo.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),Tf="_fieldset_up6fh_1",$f="_upper_up6fh_9",Ef="_select_up6fh_14",Mf="_account_up6fh_20",Lf="_lower_up6fh_25",qf="_wrapper_up6fh_26",Pf="_balance_up6fh_33",Df="_value_up6fh_37",Bf="_error_up6fh_50",pt={fieldset:Tf,upper:$f,select:Ef,account:Mf,lower:Lf,wrapper:qf,balance:Pf,value:Df,error:Bf},Co=e=>{const{selectButton:n,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return t.jsxs("div",{className:pt.fieldset,children:[t.jsxs("div",{className:pt.upper,children:[t.jsx("div",{className:pt.select,children:n}),t.jsx("div",{className:pt.account,children:s})]}),!c&&t.jsxs("div",{className:pt.lower,children:[o,t.jsxs("div",{className:pt.wrapper,children:[t.jsx("div",{className:pt.balance,children:a}),r&&t.jsx("div",{className:pt.value,children:r})]}),i&&t.jsxs("footer",{className:pt.error,children:[t.jsx(S.IconWarningFilled,{size:12}),t.jsx("p",{children:i})]})]})]})};function Kn(){const e=x.useRef(null),n=Rs();return x.useEffect(()=>{n||e.current?.focus()},[n]),e}const Rf="_input_h8073_1",Ff={input:Rf};function Vi(e){const{name:n,control:s,dp:o=6,className:a,rules:r,...i}=e,c=Kn();return t.jsx(_e.Controller,{name:n,control:s,rules:r,render:({field:l})=>t.jsx($c.NumericFormat,{value:l.value,getInputRef:lr.mergeRefs([l.ref,c]),className:q(Ff.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Uf="_input_19r9r_1",Of="_placeholder_19r9r_18",No={input:Uf,placeholder:Of},Vf=({children:e})=>t.jsx("p",{className:q(No.input,{[No.placeholder]:B(e).isZero()}),children:e}),En=({balance:e,decimals:n,className:s})=>{const{control:o}=_e.useFormContext(),a={required:"Enter amount",validate:r=>B(r).isZero()?"Enter amount":B(v.toBaseUnit(r,{decimals:n})).gt(e??0)?"Insufficient balance":!0};return t.jsx(Vi,{name:"quantity",control:o,className:q(No.input,s),rules:a})};En.ReadOnly=Vf;const dn=({title:e,content:n,children:s,className:o})=>{const[a,r]=x.useState(!1),i=()=>r(!1);return t.jsx(Si,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:n(i)})},Kf="_tooltip_19kvs_1",Wf="_arrow_19kvs_44",Da={tooltip:Kf,arrow:Wf},Wn=({label:e,children:n,small:s,...o})=>t.jsxs(Z.Tooltip.Root,{...o,children:[t.jsx(Z.Tooltip.Trigger,{asChild:!0,children:n}),t.jsx(Z.Tooltip.Portal,{container:Ht(),children:t.jsxs(Z.Tooltip.Content,{className:q(Da.tooltip,{small:s}),collisionBoundary:Ht(),collisionPadding:8,sideOffset:4,children:[e,t.jsx(Z.Tooltip.Arrow,{className:Da.arrow})]})})]});function oa(e,n){const s=tt();return $.useQuery({queryKey:Me.balances(n,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[n]:{address:e,denoms:[]}}}}).json(),select:({chains:o})=>e?o?o[n].denoms??{}:{}:{},enabled:!!e,staleTime:K.SECOND})}function zf(e,n,s){const{data:o={}}=oa(e,n);return T.path([s],o)}const Hf=[["d",1440*60],["h",3600],["m",60],["s",1]];function Mn(e){if(!e)return;const{formattedParts:n}=Hf.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return n.join(" ")}function aa(e){return e?.map(n=>{const{amount:s,origin_asset:o}=n;return`${v.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function ko(e,n){const{watch:s}=St(),o=s(),a=tt(),r=un(),i={...o,quantity:e},c=!o.srcChainId||!o.srcDenom||!o.dstChainId||!o.dstDenom,l=B(i.quantity||0),d=l.isFinite()&&l.gt(0),m=$.useQueryClient();return $.useQuery({queryKey:Me.route(i,n?.isOpWithdraw).queryKey,queryFn:async()=>{const{srcChainId:u,srcDenom:h,quantity:f,dstChainId:p,dstDenom:g}=i,{decimals:_}=m.getQueryData(Me.asset(u,h).queryKey)??{decimals:0},y={amount_in:v.toBaseUnit(f,{decimals:_}),source_asset_chain_id:u,source_asset_denom:h,dest_asset_chain_id:p,dest_asset_denom:g,is_op_withdraw:n?.isOpWithdraw},j=await a.post("v2/fungible/route",{json:y}).json(),b={quantity:i.quantity,srcChainId:i.srcChainId,srcDenom:i.srcDenom,dstChainId:i.dstChainId,dstDenom:i.dstDenom};return r("Bridge Simulation Success",b),j},enabled:d&&!n?.disabled&&!c,staleTime:K.MINUTE})}function Gf(e){return $.useQuery({queryKey:Me.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:n}=e;return(n.headers.get("content-type")??"").includes("application/json")?(await n.json()).info??null:null},enabled:!!e})}function Qf(){const{watch:e}=St(),{srcChainId:n,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=Ge(n),i=Tn(r),c=dt(s,n),l=dt(a,o),d=re(),m=de();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&m.find(u=>u.chainId===n)?.metadata?.op_denoms?.includes(l.denom)}const Yf="_label_t93ix_1",Zf="_wrapper_t93ix_7",Jf="_input_t93ix_10",Xf="_clear_t93ix_18",as={label:Yf,wrapper:Zf,input:Jf,clear:Xf},ra=({mode:e="onChange",myAddress:n,...s})=>{const{validate:o=v.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=Kn(),{control:l,getValues:d,setValue:m,formState:u}=_e.useFormContext(),h=d("recipient"),[f,p]=x.useState(h),g=xr(),{data:_,isLoading:y,error:j}=$.useQuery({queryKey:As.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:K.MINUTE,enabled:g.validateUsername(f)}),b=_??(o(f)?f:""),w=n&&v.InitiaAddress.equals(b,n),C=async()=>{try{const M=await navigator.clipboard.readText();p(M.trim())}catch{}};x.useEffect(()=>{e==="onChange"&&(!f&&!u.dirtyFields.recipient||m("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[u.dirtyFields.recipient,f,e,m,_]);const I=()=>{y||j||(m("recipient",b,{shouldValidate:!0,shouldDirty:!0}),r?.())},E=()=>{if(y)return t.jsx(sn,{level:"loading",children:"Resolving username..."});if(j)return t.jsx(sn,{level:"error",children:j.message});if(_)return t.jsx(sn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!b)return t.jsx(sn,{level:"error",children:"Invalid address"})};return t.jsxs("div",{children:[t.jsxs("label",{htmlFor:"recipient",className:as.label,children:[t.jsx("span",{children:"Recipient"}),t.jsx(le.Small,{type:"button",tabIndex:-1,onClick:C,children:"Paste"})]}),t.jsxs("div",{className:as.wrapper,children:[t.jsx(_e.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:M=>o(M)||"Invalid address"},render:()=>t.jsx("input",{id:"recipient",className:q(as.input,"monospace"),value:f,onChange:M=>p(M.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?lr.mergeRefs([i,c]):i})}),!!f&&t.jsx("button",{type:"button",className:as.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:t.jsx(S.IconCloseCircleFilled,{size:16})})]}),E(),w&&t.jsx(sn,{children:"This is my address"}),e==="onSubmit"&&t.jsx(xe,{extra:(!n||!!b&&!w)&&t.jsx(fe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:t.jsx(le.White,{type:"button",onClick:I,disabled:y||!!j||!b,children:"Apply"})})]})},ep="_scrollable_vgj3r_1",tp="_list_vgj3r_5",np="_item_vgj3r_9",sp="_name_vgj3r_22",rs={scrollable:ep,list:tp,item:np,name:sp};function Ki({onSelect:e,list:n,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return t.jsx(nt,{className:rs.scrollable,children:t.jsx("div",{className:rs.list,children:n.map(l=>t.jsxs("button",{className:rs.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[t.jsx(J,{src:o(l),width:28,height:28}),t.jsx("span",{className:rs.name,children:a(l)}),i?.(l)&&t.jsx(ut,{size:16})]},r(l)))})})}function Vs(){const e=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}];return{list:e,find:s=>e.find(o=>o.name===s)}}const op="_account_h04x1_8",ap="_clear_h04x1_28",rp="_white_h04x1_39",xn={account:op,clear:ap,white:rp},Ba=({type:e})=>{const{watch:n,setValue:s}=St(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=n(),c=n(e==="src"?"sender":"recipient"),l=Tn(Ge(a)),{list:d,find:m}=Vs(),u=m(r),h=Bi(),f=Ri(),p=h(a),g=v.InitiaAddress.equals(c,p),_=()=>t.jsx(dn,{title:"Connect wallet",content:b=>t.jsx(Ki,{onSelect:async w=>{const C=w.getProvider();if(!C)return window.open(w.fallbackUrl,"_blank");const I=C.getOfflineSigner(o),[{address:E}]=await I.getAccounts();s("sender",E),s("cosmosWalletName",w.name),b()},list:d,getImage:w=>w.image,getName:w=>w.name,getKey:w=>w.name}),className:q(xn.account,{[xn.white]:!c}),children:c?t.jsxs(t.Fragment,{children:[u&&t.jsx(J,{src:u.image,width:18,height:18}),t.jsx("span",{className:"monospace",children:v.truncate(c)})]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"Connect wallet"}),t.jsx(S.IconChevronRight,{size:14})]})}),y=b=>t.jsx(dn,{title:"Recipient",content:w=>t.jsx(nt,{children:t.jsx(ra,{mode:"onSubmit",myAddress:p,chainType:l,validate:C=>f(C,a),onApply:w})}),className:xn.account,children:b}),j=()=>{switch(l){case"initia":case"evm":return g?y(t.jsx(S.IconWallet,{size:14})):t.jsxs("div",{className:xn.account,children:[t.jsx("span",{className:"monospace",children:v.truncate(c)}),t.jsx("button",{type:"button",className:xn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:t.jsx(S.IconCloseCircleFilled,{size:14})})]});case"cosmos":return y(t.jsxs(t.Fragment,{children:[c?t.jsx("span",{className:"monospace",children:v.truncate(c)}):t.jsx("span",{children:"Recipient"}),t.jsx(S.IconEdit,{size:14})]}))}};switch(e){case"src":return _();case"dst":return j()}},ip="_images_cj4xz_1",uo={images:ip},Ks=({assetLogoUrl:e,assetLogoSize:n=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>t.jsxs("div",{className:q(uo.images,r),style:{position:"relative"},children:[t.jsx(J,{src:e,width:n,height:n,className:uo.asset,logo:!0}),t.jsx(J,{src:s,width:o,height:o,className:uo.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),cp="_root_6187w_1",lp="_content_6187w_10",dp="_details_6187w_20",up="_symbol_6187w_26",mp="_chain_6187w_34",hp="_chevron_6187w_43",qt={root:cp,content:lp,details:dp,symbol:up,chain:mp,chevron:hp},Wi=({asset:e,chain:n,readOnly:s})=>{const o=t.jsxs("div",{className:qt.content,children:[t.jsx(Ks,{assetLogoUrl:e.logoUrl,chainLogoUrl:n.logoUrl}),t.jsxs("div",{className:qt.details,children:[t.jsx("div",{className:qt.symbol,children:e.symbol||e.denom}),t.jsxs("div",{className:qt.chain,children:["on ",n.name]})]})]});return s?t.jsx("div",{className:qt.root,children:o}):t.jsxs("div",{className:qt.root,children:[o,t.jsx(S.IconChevronDown,{size:16,className:qt.chevron})]})};function fp(e,n,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return T.any(T.includes(n.toLowerCase()),a)})}const pp="_root_1sh27_1",gp="_label_1sh27_8",_p="_input_1sh27_21",xp="_hasValue_1sh27_31",yp="_clear_1sh27_35",yn={root:pp,label:gp,input:_p,hasValue:xp,clear:yp},zn=e=>{const{rootClassName:n,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return t.jsxs("div",{className:q(yn.root,n,{[yn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[t.jsx("label",{htmlFor:"search",className:yn.label,children:t.jsx(S.IconSearch,{size:o})}),t.jsx("input",{className:yn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&t.jsx("button",{type:"button",className:yn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:t.jsx(S.IconCloseCircleFilled,{size:o})})]})},jp="_container_5tajg_1",wp="_search_5tajg_7",bp="_list_5tajg_11",vp="_item_5tajg_15",Cp="_logo_5tajg_37",Np="_info_5tajg_41",kp="_symbol_5tajg_47",Ip="_name_5tajg_56",Ap="_balance_5tajg_62",Sp="_value_5tajg_69",He={container:jp,search:wp,list:bp,item:vp,logo:Cp,info:Np,symbol:kp,name:Ip,balance:Ap,value:Sp},Hn=e=>{const{assets:n,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=x.useState(""),i=fp(["symbol"],a,n);return t.jsxs("div",{className:He.container,children:[t.jsx(zn,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:He.search,padding:20,ref:Kn()}),i.length===0?t.jsx(he,{children:"No assets"}):t.jsx("div",{className:He.list,children:i.map(c=>t.jsx("button",{type:"button",className:He.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:m,symbol:u,name:h,balance:f,decimals:p,value:g=0}=l;return t.jsxs(t.Fragment,{children:[t.jsx(J,{src:m,width:32,height:32,className:He.logo,logo:!0}),t.jsxs("div",{className:He.info,children:[t.jsx("div",{className:He.symbol,children:u||d}),t.jsx("div",{className:He.name,children:h})]}),t.jsxs("div",{className:He.balance,children:[f&&t.jsx("div",{children:v.formatAmount(f,{decimals:p})}),g>0&&t.jsx("div",{className:He.value,children:te(g)})]})]})})},c.denom))})]})},Tp=()=>t.jsxs("div",{className:He.container,children:[t.jsx(zn,{rootClassName:He.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),t.jsx(he,{children:"Loading..."})]});Hn.Placeholder=Tp;const $p="_stack_16oqn_1",Ep="_title_16oqn_9",Mp="_grid_16oqn_16",Lp="_item_16oqn_22",qp="_button_16oqn_26",Pp="_active_16oqn_44",on={stack:$p,title:Ep,grid:Mp,item:Lp,button:qp,active:Pp},Vt=({label:e,chains:n,value:s,onSelect:o,getShowIndicator:a})=>t.jsxs("div",{children:[e&&t.jsx("h2",{className:on.title,children:e}),t.jsx("div",{className:on.grid,children:n.map(({chainId:r,name:i,logoUrl:c})=>t.jsx(Di,{offset:-2,disabled:!a?.(r),className:on.item,children:t.jsx(Wn,{label:i,disableHoverableContent:!0,children:t.jsx("button",{type:"button",className:q(on.button,{[on.active]:r===s}),onClick:()=>o(r),children:t.jsx(J,{src:c,width:28,height:28,logo:!0})})})},r))})]}),Dp=({children:e})=>t.jsx("div",{className:on.stack,children:e});Vt.Stack=Dp;const Bp=({address:e,chain:n,onSelect:s})=>{const o=ys(n.chain_id),{data:a={}}=oa(e,n.chain_id);return t.jsx(Hn,{assets:T.sortWith([T.descend(r=>r.symbol==="INIT"),T.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>B(i).comparedTo(r)??0,T.ascend(r=>r.symbol.toLowerCase())],o.filter(r=>!r.hidden).map(r=>{const{denom:i,symbol:c=v.truncate(i),logo_uri:l}=r,d=a[i]??{};return{...r,symbol:c,decimals:r.decimals??0,logoUrl:l??"",name:r.name??"",balance:d.amount,value:Number(d.value_usd??0)}})),onSelect:s})},Rp=({type:e,afterSelect:n})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=At(),i=Vn(),{watch:c,setValue:l}=St(),d=c(a),m=c(s),u=c(o),[h,f]=x.useState(m),p=Ge(h),g=hf(),_=ji(),[y,j]=T.partition(w=>_(w.chain_id),i.filter(w=>!w.hidden)),b=w=>{if(m===h&&u===w){n();return}l(s,h),l(o,w),n()};return t.jsxs(t.Fragment,{children:[t.jsxs(Vt.Stack,{children:[t.jsx(Vt,{label:"Interwoven Economy",chains:y.map(({chain_id:w,chain_name:C,pretty_name:I,logo_uri:E})=>({chainId:w,name:I||C,logoUrl:E??""})),value:h,onSelect:f}),t.jsx(Vt,{label:"Chains",chains:j.map(({chain_id:w,chain_name:C,pretty_name:I,logo_uri:E})=>({chainId:w,name:I||C,logoUrl:E??""})),value:h,onSelect:f})]}),t.jsx(me,{suspenseFallback:t.jsx(Hn.Placeholder,{}),children:t.jsx(Bp,{address:g({initialAddress:d,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:b})},h)]})},Ra=({type:e})=>{const n=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=St(),r=a(n),i=a(s),c=Ge(r),l=dt(i,r);return t.jsx(dn,{title:o,content:d=>t.jsx(Rp,{type:e,afterSelect:d}),children:t.jsx(Wi,{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??""}})})},Fp="_skeleton_1l4jn_1",Up={skeleton:Fp},Kt=({width:e="100%",height:n})=>t.jsx("div",{className:Up.skeleton,style:{width:e,height:n}}),Op="_stack_oq1ir_1",Vp="_button_oq1ir_6",Kp="_isLoading_oq1ir_19",Wp="_disabled_oq1ir_19",zp="_checked_oq1ir_23",Hp="_header_oq1ir_37",Gp="_title_oq1ir_43",Qp="_duration_oq1ir_52",Yp="_warning_oq1ir_62",Zp="_amount_oq1ir_66",Jp="_value_oq1ir_67",ze={stack:Op,button:Vp,isLoading:Kp,disabled:Wp,checked:zp,header:Hp,title:Gp,duration:Qp,warning:Yp,amount:Zp,value:Jp},Xp=({children:e})=>t.jsx("div",{className:ze.stack,children:e}),ms=({label:e,query:n,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=n,{watch:c}=St(),{dstChainId:l,dstDenom:d}=c(),m=dt(d,l),u=!i&&a.checked,h=!i&&!r;return t.jsxs("button",{type:"button",className:q(ze.button,{[ze.isLoading]:i,[ze.disabled]:h,[ze.checked]:u}),onClick:()=>{i||h||o(s)},children:[t.jsxs("div",{className:ze.header,children:[t.jsxs("div",{className:ze.title,children:[t.jsx("span",{children:e}),u&&t.jsx(S.IconCheck,{size:14})]}),i?t.jsx(Kt,{width:80,height:16}):r?t.jsxs("div",{className:q(ze.duration,{[ze.warning]:s==="op"}),children:[t.jsx(S.IconClockFilled,{size:12}),t.jsx("span",{children:Mn(r.estimated_route_duration_seconds)})]}):t.jsx("div",{className:ze.duration,children:"Not available"})]}),(i||r)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ze.amount,children:i?t.jsx(Kt,{width:260,height:40}):r?v.formatAmount(r.amount_out,{decimals:m.decimals}):null}),t.jsx("div",{className:ze.value,children:i?t.jsx(Kt,{width:120,height:16}):r?r.usd_amount_out?te(r.usd_amount_out):"$-":null})]})]})};ms.Stack=Xp;const eg="_description_nuyvt_1",tg="_presets_nuyvt_8",ng="_preset_nuyvt_8",sg="_active_nuyvt_29",og="_custom_nuyvt_40",ag="_wrapper_nuyvt_47",rg="_percent_nuyvt_58",rt={description:eg,presets:tg,preset:ng,active:sg,custom:og,wrapper:ag,percent:rg},Fa=["0.1","0.5","1.0"],ig=({afterConfirm:e})=>{const n=St(),s=n.getValues("slippagePercent"),[o,a]=x.useState(null),{control:r,watch:i,getValues:c,setValue:l}=_e.useForm({defaultValues:{value:s}}),d=i("value");x.useEffect(()=>{const g=Fa.findIndex(_=>_===s);a(g>=0?g:null)},[s]);const m=(g,_)=>{l("value",g),a(_)},u=()=>{a(null)},h=x.useMemo(()=>Number(d)>100?{type:"error",text:"Slippage must be less than 100%"}:Number(d)>5?{type:"warning",text:"Your transaction may be frontrun"}:Number(d)<.1?{type:"warning",text:"Your transaction may fail"}:null,[d]),f=h?.type==="error",p=({value:g})=>{n.setValue("slippagePercent",g),e()};return t.jsxs(nt,{children:[t.jsx("p",{className:rt.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),t.jsxs("div",{className:rt.presets,children:[Fa.map((g,_)=>t.jsxs("button",{type:"button",className:q(rt.preset,{[rt.active]:o===_}),onClick:()=>m(g,_),children:[g,"%"]},g)),o!==null?t.jsx("button",{type:"button",className:q(rt.preset,rt.custom),onClick:()=>a(null),children:"Custom"}):t.jsxs("div",{className:rt.wrapper,children:[t.jsx(Vi,{name:"value",control:r,dp:2,onFocus:u,placeholder:"",className:q(rt.preset,rt.active)}),t.jsx("span",{className:rt.percent,children:"%"})]})]}),h&&t.jsx(fe,{level:h.type,children:h.text}),t.jsx(xe,{children:t.jsx(le.White,{type:"button",onClick:()=>p(c()),disabled:f,children:"Confirm"})})]})},cg="_form_1owk5_1",lg="_arrow_1owk5_5",dg="_divider_1owk5_14",ug="_flip_1owk5_23",mg="_meta_1owk5_41",hg="_row_1owk5_54",fg="_title_1owk5_60",pg="_description_1owk5_64",gg="_icon_1owk5_71",_g="_edit_1owk5_76",xg="_warning_1owk5_99",Pe={form:cg,arrow:lg,divider:dg,flip:ug,meta:mg,row:hg,title:fg,description:pg,icon:gg,edit:_g,warning:xg},yg=()=>{const e=Ce(),n=Rs(),[s,o]=Le.useLocalStorage(ae.BRIDGE_ROUTE_TYPE,"default"),{watch:a,setValue:r,handleSubmit:i,formState:c}=St(),l=a(),{srcChainId:d,srcDenom:m,dstChainId:u,dstDenom:h,quantity:f,sender:p,slippagePercent:g}=l,_=Fe(),y=Ge(d),j=Tn(y),b=Ge(u),w=Tn(b),C=dt(m,d),I=dt(h,u),{data:E}=oa(p,d),M=zf(p,d,m),A=!M?.amount||B(M.amount).isZero(),[L]=Le.useDebounceValue(f,300),N=j!=="initia"&&w!=="initia",k=Qf(),P=ko(L,{disabled:N}),R=ko(L,{isOpWithdraw:!0,disabled:!k}),O=k&&s==="op",V=O?R:P,H=O?P:R,Q=O?!N:k,F=V.error&&Q?H:V,{data:W,isLoading:qe,isFetching:we,error:st}=F,{data:Oe}=Gf(st),Zt=L&&(qe||we),pn=()=>{r("srcChainId",u),r("srcDenom",h),r("dstChainId",d),r("dstDenom",m),r("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:Qn,closeModal:Yn}=qs(),ot=i(ne=>{if(W?.warning){const{type:$t="",message:Qs}=W.warning??{};Qn({content:t.jsx(Fi,{type:"warning",icon:t.jsx(S.IconWarningFilled,{size:40}),title:Ns.sentenceCase($t),primaryButton:{label:"Cancel",onClick:Yn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:W,values:ne}),Yn()}},children:t.jsx("p",{className:Pe.warning,children:Qs})})});return}e("/bridge/preview",{route:W,values:ne})}),Ve=x.useMemo(()=>W?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[W]),vt=x.useMemo(()=>W?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[W]),Jt=x.useMemo(()=>{for(const ne of vt){const $t=E?.[ne.origin_asset.denom]?.amount??"0",Qs=W?.source_asset_denom===ne.origin_asset.denom?W.amount_in:"0";if(B($t).lt(B(Qs).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[E,W,vt]),Zn=x.useMemo(()=>{if(!l.sender)return"Connect wallet";if(!l.quantity||!L)return"Enter amount";if(!l.recipient)return"Enter recipient address";if(c.errors.quantity)return c.errors.quantity.message;if(!W)return"Route not found";if(Jt)return Jt},[L,Jt,c,W,l]),wc=W?v.formatAmount(W.amount_out,{decimals:I.decimals}):"0",bc=B(f).gt(0)&&B(f).isEqualTo(v.fromBaseUnit(M?.amount,{decimals:M?.decimals??0})),vc=(()=>{switch(j){case"initia":return _(d).fees.fee_tokens.some(({denom:ne})=>ne===m);case"cosmos":return y.fee_assets.some(({denom:ne})=>ne===m);case"evm":return!ct.isAddress(m);default:return!1}})(),Gs=x.useCallback((ne,$t)=>ne.length?t.jsxs("div",{className:Pe.description,children:[aa(ne),!n&&t.jsx(Wn,{label:$t,children:t.jsx("span",{className:Pe.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]}):null,[n]),Jn=B(f).gt(0)&&k&&P.data&&R.data&&R.data.estimated_route_duration_seconds>P.data.estimated_route_duration_seconds,_a=x.useMemo(()=>W?[{condition:!!W.estimated_fees?.length,title:"Fees",content:t.jsxs("div",{children:[Gs(Ve,"Fee deducted from the amount you receive"),Gs(vt,"Fee charged in addition to the amount you enter")]})},{condition:!Jn&&!!Mn(W.estimated_route_duration_seconds),title:"Estimated time",content:t.jsx("span",{className:Pe.description,children:Mn(W.estimated_route_duration_seconds)})},{condition:W.does_swap,title:"Slippage",content:t.jsxs("span",{className:Pe.description,children:[t.jsxs("span",{children:[g,"%"]}),t.jsx(dn,{title:"Slippage tolerance",content:ne=>t.jsx(ig,{afterConfirm:ne}),className:Pe.edit,children:t.jsx(S.IconSettingFilled,{size:12})})]})}].filter(ne=>ne.condition):[],[vt,Ve,Gs,W,Jn,g]);return t.jsxs("form",{className:Pe.form,onSubmit:ot,children:[t.jsx(Co,{selectButton:t.jsx(Ra,{type:"src"}),accountButton:j==="cosmos"&&t.jsx(Ba,{type:"src"}),quantityInput:t.jsx(En,{balance:M?.amount,decimals:C?.decimals}),balanceButton:t.jsx(Oi,{onClick:()=>r("quantity",v.fromBaseUnit(M?.amount,{decimals:C?.decimals??0}),{shouldValidate:!0}),disabled:A,children:v.formatAmount(M?.amount??"0",{decimals:C.decimals})}),value:W?te(W.usd_amount_in):"$-"}),t.jsxs("div",{className:Pe.arrow,children:[t.jsx("div",{className:Pe.divider}),t.jsx("button",{type:"button",className:Pe.flip,onClick:()=>pn(),children:t.jsx(S.IconChevronDown,{size:16})})]}),t.jsx(Co,{selectButton:t.jsx(Ra,{type:"dst"}),accountButton:t.jsx(Ba,{type:"dst"}),quantityInput:t.jsx(En.ReadOnly,{children:wc}),value:W?te(W.usd_amount_out):"$-",hideNumbers:Jn}),t.jsx($n,{children:Jn?t.jsxs(ms.Stack,{children:[t.jsx(ms,{label:"Fast",query:P,value:"default",onSelect:o,checked:s==="default"}),t.jsx(ms,{label:"Lossless",query:R,value:"op",onSelect:o,checked:s==="op"})]}):null}),t.jsx(xe,{extra:t.jsxs(t.Fragment,{children:[t.jsxs(fe.Stack,{children:[W?.extra_infos?.map(ne=>t.jsx(fe,{level:"info",children:ne},ne)),Oe&&t.jsx(fe,{level:"info",children:Oe}),bc&&vc&&t.jsx(fe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),W?.warning&&t.jsx(fe,{level:"warning",children:W.warning.message}),W?.extra_warnings?.map(ne=>t.jsx(fe,{level:"warning",children:ne},ne))]}),t.jsx($n,{children:_a.length>0&&t.jsx("div",{className:Pe.meta,children:_a.map((ne,$t)=>t.jsxs("div",{className:Pe.row,children:[t.jsx("span",{className:Pe.title,children:ne.title}),ne.content]},$t))})})]}),children:t.jsx(le.White,{loading:Zt&&"Simulating...",disabled:!!Zn,children:Zn??"Preview route"})})]})},jg=()=>{Ui();const e=br(),n=Ce(),s=At(),o=Zd(),a=_e.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:m,quantity:u,slippagePercent:h,recipient:f}=r();r((k,{name:P})=>{(P==="srcChainId"||P==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=Bi(),g=p(c),_=p(l),j=Ri()(f,l);x.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[c,g,i]),x.useEffect(()=>{j||i("recipient",_)},[_,j,i]);const{showNotification:b}=Os(),w=Ge(c),C=Ge(l),I=ys(c),E=ys(l),M=I.some(k=>k.denom===d),A=E.some(k=>k.denom===m);x.useEffect(()=>{I.length>0&&!M&&(i("srcDenom",I[0].denom),b({type:"info",title:`Switched to ${I[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[I,M,i,b,w.pretty_name]),x.useEffect(()=>{E.length>0&&!A&&(i("dstDenom",E[0].denom),b({type:"info",title:`Switched to ${E[0].symbol}`,description:`The selected asset is not available on ${C.pretty_name}.`,autoHide:!0}))},[E,A,i,b,C.pretty_name]),x.useEffect(()=>{!M||!A||(localStorage.setItem(ae.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(ae.BRIDGE_SRC_DENOM,d),localStorage.setItem(ae.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(ae.BRIDGE_DST_DENOM,m),localStorage.setItem(ae.BRIDGE_QUANTITY,u),localStorage.setItem(ae.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,m,u,h,M,A]);const L=e[0].path==="/bridge",{reminders:N}=fn();return t.jsx(ht,{title:"Bridge/Swap",backButton:L?"/":void 0,extra:t.jsxs(t.Fragment,{children:[t.jsx(le.Small,{onClick:()=>n("/bridge/history"),unpadded:!0,children:t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[t.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),t.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),t.jsx(Di,{offset:0,disabled:N.length===0,children:t.jsx(le.Small,{onClick:()=>n("/op/withdrawals"),disabled:!s,children:t.jsx("span",{children:"Withdrawal status"})})})]}),children:M&&A&&t.jsx(_e.FormProvider,{...a,children:t.jsx(me,{children:t.jsx(yg,{})})})})},wg="_button_1crvp_1",bg="_checkbox_1crvp_11",vg="_checked_1crvp_25",is={button:wg,checkbox:bg,checked:vg},Cg=({checked:e,onClick:n,label:s,className:o})=>t.jsxs("button",{type:"button",className:q(is.button,o),onClick:n,children:[t.jsx("div",{className:q(is.checkbox,{[is.checked]:e}),children:e&&t.jsx(S.IconCheck,{size:12})}),t.jsx("span",{className:is.label,children:s})]}),Ng="_button_aoxv2_1",kg={button:Ng},zi=({onClick:e,disabled:n})=>{const{ref:s,inView:o}=Ec.useInView();return x.useEffect(()=>{o&&e()},[o,e]),t.jsxs("button",{className:kg.button,onClick:e,disabled:n,ref:s,children:[t.jsx("span",{children:"Load more"}),t.jsx(S.IconChevronDown,{size:12})]})};function Hi(e,n){return e.reduce((s,o)=>{const a=n(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const hs=({chainId:e,txHash:n})=>`${ae.BRIDGE_HISTORY}:${e}:${n}`,bs=100,Ua=10;function Gi(){const[e,n]=Le.useLocalStorage(ae.BRIDGE_HISTORY,[]),s=x.useCallback((a,r)=>{localStorage.setItem(hs(a),JSON.stringify(r));for(const i of e.slice(bs-1))localStorage.removeItem(hs(i));n((i=[])=>[a,...i.slice(0,bs-1)])},[e,n]),o=x.useCallback(a=>{const r=localStorage.getItem(hs(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function Qi(e){return Le.useLocalStorage(hs(e),null)}const Yt=ye.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,n)=>[e,n],latestOutput:e=>[e],output:(e,n)=>[e,n],outputResponse:(e,n)=>[e,n],withdrawalClaimed:(e,n)=>[e,n]});function Ws(){const{restUrl:e}=re();return x.useMemo(()=>z.create({prefixUrl:e}),[e])}function Ig(e){const n=Ws(),{data:s}=$.useSuspenseQuery({queryKey:Yt.bridge(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Oa=20;function Ag(e){const n=X();return $.useSuspenseInfiniteQuery({queryKey:Yt.withdrawals(e,n).queryKey,queryFn:async({pageParam:s})=>{if(!n)return[];const o={limit:Oa,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${n}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=T.last(s)?.sequence;return s.length<Oa||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function Sg(e){const n=Ws(),{data:s}=$.useSuspenseQuery({queryKey:Yt.latestOutput(e).queryKey,queryFn:()=>n.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:K.SECOND});return s}function Tg({bridge_id:e,output_index:n}){const s=Ws(),{data:o}=$.useSuspenseQuery({queryKey:Yt.output(e,n).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${n}`).json()}catch{return null}},staleTime:K.SECOND});return o}function $g({bridge_id:e,sequence:n}){const o=de().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=Fe()(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}=$.useSuspenseQuery({queryKey:Yt.outputResponse(i,n).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${n}`).json(),staleTime:K.SECOND});return c}function Yi(e,n){const{bridge_id:s}=e,o=Ws(),{data:a}=$.useSuspenseQuery({queryKey:Yt.withdrawalClaimed(s,n).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:n}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:K.SECOND});return a}function jn(e){return Mc.sha3_256.create().update(e).digest()}function mo(e,n){const s=new ArrayBuffer(n);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function Zi(e){const{bridge_id:n,sequence:s,amount:o,from:a,to:r}=e,i=mo(n.toString(),8),c=mo(s.toString(),8),l=mo(o.amount,8),d=Ft.concatBytes(i,c,jn(Ft.utf8ToBytes(a)),jn(Ft.utf8ToBytes(r)),jn(Ft.utf8ToBytes(o.denom)),l);return jn(jn(d))}async function Eg(e,n,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${n}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function Mg(e,n){const s=z.create({prefixUrl:n}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Io(e,n){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=n;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if(T.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 bt(){return et()}function Lg(e,n){const{customFee:s,onCompleted:o}=n??{},a=Ce(),{showNotification:r,updateNotification:i,hideNotification:c}=Os(),{addHistoryItem:l}=Gi(),d=un(),{route:m,values:u}=bt(),{srcChainId:h,sender:f,recipient:p,cosmosWalletName:g}=u,_=Kr(),{requestTxSync:y,submitTxSync:j,waitForTxConfirmation:b}=Ue(),{find:w}=Vs(),C=Dn(),I=Bn(),E=Ge(h),M=Tn(E),A=wi(h),L=$.useQueryClient(),{registryUrl:N}=ee(),k=Fe(),P=re(),{addReminder:R}=fn(),O=tt();return $.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const V=e.cosmos_tx.msgs.map(({msg_type_url:ot,msg:Ve})=>{if(!(ot&&Ve))throw new Error("Invalid transaction data");return I.fromAmino({type:Wt.aminoConverters[ot].aminoType,value:JSON.parse(Ve)})});if(M==="initia"){const{srcDenom:ot,quantity:Ve}=u,{decimals:vt}=A(ot),Jt=s?await j({messages:V,chainId:h,fee:s}):await y({messages:V,chainId:h,internal:1,spendCoins:[{denom:ot,amount:v.toBaseUnit(Ve,{decimals:vt})}]}),Zn=b({txHash:Jt,chainId:h});return{txHash:Jt,wait:Zn}}const H=w(g)?.getProvider();if(!H)throw new Error("Wallet not connected");const Q=H.getOfflineSignerOnlyAmino(h),F=await je.SigningStargateClient.connectWithSigner(E.rpc,Q,{registry:C,aminoTypes:I}),W=await F.getAllBalances(f),qe=E.fee_assets.find(ot=>W.some(Ve=>Ve.denom===ot.denom&&B(Ve.amount).gt(0)));if(!qe){const Ve=["Insufficient balance for fees.",`Available fee assets: ${E.fee_assets.map(vt=>A(vt.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Ve)}const{denom:we,gas_price:st}=qe;if(!st)throw new Error(`Gas price not found for ${we}`);const Oe=await F.simulate(f,V,""),Zt=je.GasPrice.fromString(st.average+we),pn=je.calculateFee(Math.ceil(Oe*zt),Zt),Qn=await F.signAndBroadcastSync(f,V,pn),Yn=oi({txHash:Qn,client:F});return{txHash:Qn,wait:Yn}}if("evm_tx"in e){const{chain_id:V,to:H,value:Q,data:F}=e.evm_tx,W=await _(),qe=await W.getSigner();await Io(W,E);const we=await qe.sendTransaction({chainId:V,to:H,value:Q,data:`0x${F}`});return{txHash:we.hash,wait:we.wait()}}throw new Error("Unlisted chain type")}catch(V){throw await _t(V)}},onSuccess:async({txHash:V,wait:H})=>{localStorage.removeItem(ae.BRIDGE_QUANTITY),o?o({txhash:V,chainId:h,timestamp:Date.now(),success:!0,route:m,values:u}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await H;const Q=ia(m)==="OP Bridge withdrawal",F=Q?{success:!0,error:null}:await Rg(O,V,h);if(!o&&!F.success&&F.error){const Oe=F.error instanceof Error?F.error.message:String(F.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${Oe}. The transaction may still be processing.`,autoHide:!0})}const W=F.success,we=Dg({txHash:V,srcChainId:h,route:m,values:u,recipient:p},W);l(we.tx,we.details),o||i(Pg(c));const st=ho(u,V);if(d("Bridge Transaction Success",st),Q){const Oe=k(h).metadata?.op_bridge_id;if(Oe&&!await Eg(P.restUrl,Number(Oe),m.dest_asset_denom)){const pn=Bg(we.tx,m,p);R(we.tx,pn)}}}catch(Q){const F=Q instanceof Error?Q.message:String(Q);o?o({success:!1,error:F,route:m,values:u}):i({type:"error",title:"Transaction not confirmed",description:F});const W={...ho(u,V),error:F};d("Bridge Confirmation Failed",W)}finally{L.invalidateQueries({queryKey:Me.balances(h,f).queryKey})}},onError:async V=>{const H=M==="initia"?await nn(V,k(h),N):V;o?o({success:!1,error:H.message,route:m,values:u}):r({type:"error",title:"Transaction failed",description:H.message});const Q=ho(u);d("Bridge Transaction Failed",{...Q,error:H.message})}})}function qg(){const e=tt(),n=X(),s=Or(),{route:o,values:a}=bt(),r=wt();return $.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:n,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:v.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await Mg(n,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:u,msg:h})=>Wt.aminoTypes.fromAmino({type:Wt.aminoConverters[u].aminoType,value:JSON.parse(h)})),d=await s(i,n,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),m=De.Tx.fromPartial({body:De.TxBody.decode(d.bodyBytes),authInfo:De.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:n,hook:se.toBase64(De.Tx.encode(m).finish())}}catch(i){throw await _t(i)}}})}function Pg(e){return{type:"info",title:"Transaction submitted",description:x.createElement(x.Fragment,null,"Check ",x.createElement(cn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function ho(e,n){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:n}}function Dg(e,n){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=ia(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:n},isOpWithdraw:c}}function Bg(e,n,s){return{...e,recipient:v.InitiaAddress(s).bech32,claimableAt:Date.now()+n.estimated_route_duration_seconds*1e3,amount:n.amount_out,denom:n.dest_asset_denom}}async function Rg(e,n,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:n,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await _t(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Ji(e){const{chainId:n,txHash:s,tracked:o}=e,a=tt();return $.useQuery({queryKey:Me.txTrack(n,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:n}}).json()}catch(r){throw await _t(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Xi(e){const{timestamp:n,chainId:s,txHash:o,tracked:a,state:r}=e,i=tt();return $.useQuery({queryKey:Me.txStatus(s,o).queryKey,queryFn:()=>i.get("v2/tx/status",{searchParams:{tx_hash:o,chain_id:s}}).json(),enabled:!!o&&a&&!r,refetchInterval:({state:{data:c}})=>{if(!c)return!1;const{status:l}=c;if(l==="STATE_COMPLETED")return!1;const d=n+e.route.estimated_route_duration_seconds*1e3,m=Date.now(),u=Math.floor((d-m)/1e3);return u<=0?1e3:u<=300?5e3:60*1e3},staleTime:K.INFINITY})}var fs=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(fs||{});function ia(e){const{operations:n,dest_asset_denom:s}=e;return T.has("op_init_transfer",T.head(n))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Fg="_success_t4dfk_1",Ug="_error_t4dfk_5",Va={success:Fg,error:Ug},Og=({tx:e})=>{const[n,s]=Qi(e);if(!n)throw new Error("Bridge history details not found");const{data:o}=Xi(n),a=n.state??Vg(o);switch(x.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return t.jsx("div",{className:Va.error,children:t.jsx(S.IconCloseCircleFilled,{size:14})});case"success":return t.jsx("div",{className:Va.success,children:t.jsx(S.IconCheckCircleFilled,{size:14})});default:return t.jsx(ut,{size:14})}};function Vg(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 Kg="_link_104m3_1",Wg="_header_104m3_23",zg="_title_104m3_31",Hg="_date_104m3_37",Gg="_explorer_104m3_41",Qg="_fees_104m3_57",Yg="_label_104m3_65",Zg="_content_104m3_69",Jg="_route_104m3_75",Xg="_row_104m3_80",e_="_asset_104m3_86",t_="_amount_104m3_94",n_="_chain_104m3_99",s_="_account_104m3_108",o_="_arrow_104m3_115",be={link:Kg,header:Wg,title:zg,date:Hg,explorer:Gg,fees:Qg,label:Yg,content:Zg,route:Jg,row:Xg,asset:e_,amount:t_,chain:n_,account:s_,arrow:o_},a_=({tx:e})=>{const[n,s]=Qi(e);if(!n)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=n,{data:d}=Ji(n),{address:m="",connector:u}=Ee.useAccount(),{find:h}=Vs();x.useEffect(()=>{d&&s(O=>{if(!O)throw new Error("Bridge history details not found");return{...O,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:_,dest_asset_chain_id:y,dest_asset_denom:j,estimated_fees:b=[]}=r,w=Ge(g),C=Ge(y),I=dt(_,g),E=dt(j,y),M=(O,V)=>V?t.jsx(J,{src:V,width:12,height:12}):v.InitiaAddress.equals(O,m)?t.jsx(J,{src:u?.icon,width:12,height:12}):t.jsx(S.IconWallet,{size:12}),A=(O,{symbol:V,decimals:H,logo_uri:Q},{chain_name:F,pretty_name:W,...qe},we,st)=>t.jsxs("div",{className:be.row,children:[t.jsx(Ks,{assetLogoUrl:Q,chainLogoUrl:qe.logo_uri??void 0}),t.jsxs("div",{children:[t.jsxs("div",{className:be.asset,children:[t.jsx("span",{className:be.amount,children:v.formatAmount(O,{decimals:H})}),t.jsx("span",{children:V})]}),t.jsxs("div",{className:be.chain,children:[t.jsxs("span",{children:["on ",W||F]}),t.jsxs("div",{className:be.account,children:[st,t.jsx("span",{className:"monospace",children:v.truncate(we)})]})]})]})]}),L=ia(r),N=x.useMemo(()=>{switch(L){case fs.SKIP:return"Skip Explorer";case fs.OP_WITHDRAW:return"Initia Scan"}},[L]),k=t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:be.header,children:[t.jsxs("div",{className:be.title,children:[l?t.jsx(Og,{tx:e}):t.jsx(ut,{size:14}),t.jsx("div",{className:be.date,children:Re.format(new Date(c),"h:mm a")})]}),t.jsxs("div",{className:be.explorer,children:[t.jsx("span",{children:N}),t.jsx(S.IconExternalLink,{size:12})]})]}),t.jsxs("div",{className:be.route,children:[A(f,I,w,i.sender,M(i.sender,h(i.cosmosWalletName)?.image)),t.jsx("div",{className:be.arrow,children:t.jsx(S.IconArrowDown,{size:12})}),A(p,E,C,i.recipient,M(i.recipient))]}),b.length>0&&t.jsxs("div",{className:be.fees,children:[t.jsx("span",{className:be.label,children:"Fees"}),t.jsx("span",{className:be.content,children:aa(b)})]})]});if(L===fs.OP_WITHDRAW)return t.jsx(Us,{chainId:o,txHash:a,className:be.link,children:k});const P=new URLSearchParams({tx_hash:a,chain_id:o}),R=new URL(`?${P.toString()}`,"https://explorer.skip.build");return t.jsx("a",{href:R.toString(),className:be.link,target:"_blank",children:k})},r_="_history_13u9z_1",i_="_header_13u9z_5",c_="_checkbox_13u9z_9",l_="_groups_13u9z_13",d_="_dateGroup_13u9z_21",u_="_dateHeader_13u9z_26",m_="_list_13u9z_32",Pt={history:r_,header:i_,checkbox:c_,groups:l_,dateGroup:d_,dateHeader:u_,list:m_},h_=()=>{const{initiaAddress:e,hexAddress:n}=Ue(),{history:s,getHistoryDetails:o}=Gi(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:_,recipient:y}=g;return[_,y].some(j=>[e,n].includes(j))}),[i,c]=x.useState(1),[l,d]=Le.useToggle(!r.length),m=l?a:r,u=m.slice(0,i*Ua),h=x.useMemo(()=>Hi(u,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[u,o]);return t.jsx(ht,{title:"Bridge/Swap activity",children:t.jsxs("div",{className:Pt.history,children:[a.length>0&&a.length!==r.length&&t.jsx("header",{className:Pt.header,children:t.jsx(Cg,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:Pt.checkbox})}),m.length===0?t.jsx(he,{children:"No bridge/swap activity"}):t.jsx("div",{className:Pt.groups,children:Object.entries(h).map(([f,p])=>t.jsxs("div",{className:Pt.dateGroup,children:[t.jsx("div",{className:Pt.dateHeader,children:f}),t.jsx("div",{className:Pt.list,children:p.map(g=>t.jsx(me,{children:t.jsx(a_,{tx:g})},g.txHash))})]},f))}),m.length>i*Ua?t.jsx(zi,{onClick:()=>c(f=>f+1)}):s.length>=bs&&t.jsxs(he,{children:["Only the latest ",bs," items are stored. Older entries will be removed automatically."]})]})})},ca=({tx:e,fee:n,onCompleted:s,confirmMessage:o,error:a})=>{const{mutate:r,isPending:i}=Lg(e,{customFee:n,onCompleted:s});return t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>r(),loading:i&&"Signing transaction...",disabled:!!a,children:a||o||"Confirm"})})},f_="_content_1hzj2_1",p_="_info_1hzj2_6",g_="_arrow_1hzj2_11",__="_divider_1hzj2_19",x_="_type_1hzj2_27",y_="_asset_1hzj2_47",j_="_amount_1hzj2_55",w_="_lower_1hzj2_60",b_="_chain_1hzj2_66",v_="_address_1hzj2_72",We={content:f_,info:p_,arrow:g_,divider:__,type:x_,asset:y_,amount:j_,lower:w_,chain:b_,address:v_},ec=e=>{const{source:n,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=v.truncate(a),decimals:d=0,logo_uri:m=Do}=e,{chain_name:u,pretty_name:h,...f}=Ge(r);return t.jsxs("div",{children:[!n&&t.jsxs("div",{className:We.arrow,children:[t.jsx("div",{className:We.divider}),s?t.jsx(Wn,{label:s,children:t.jsx("button",{className:We.type,children:t.jsx(S.IconArrowDown,{size:12})})}):t.jsx("span",{className:We.type,children:t.jsx(S.IconArrowDown,{size:12})}),t.jsx("div",{className:We.divider})]}),t.jsxs("div",{className:We.content,children:[t.jsx(Ks,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),t.jsxs("div",{className:We.info,children:[t.jsxs("div",{className:We.asset,children:[t.jsx("span",{className:We.amount,children:v.formatAmount(o,{decimals:d})}),t.jsx("span",{children:l})]}),t.jsxs("div",{className:We.lower,children:[t.jsxs("div",{className:We.chain,children:["on ",h||u]}),i&&t.jsx(js,{value:i,children:({copy:p,copied:g})=>t.jsxs("button",{className:We.address,onClick:p,children:[c,g?t.jsx("span",{children:"Copied!"}):t.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},an=e=>{const n=dt(e.denom,e.chainId);return t.jsx(ec,{...e,...n})};an.Placeholder=ec;const C_="_root_1hbar_1",N_="_flexEnd_1hbar_6",k_="_toggle_1hbar_11",I_="_route_1hbar_36",A_="_content_1hbar_43",wn={root:C_,flexEnd:N_,toggle:k_,route:I_,content:A_};function S_(e){const n=({name:s})=>s==="initia-dex"?"Initia DEX":Ns.capitalCase(T.head(s?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const s=e.swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const s=e.evm_swap?.swap_venues?.map(n).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const T_=({addressList:e})=>{const{values:n,route:s}=bt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=T.zipObj(s.required_chain_addresses,e),{find:l}=Vs(),{connector:d,address:m=""}=Ee.useAccount(),[u,h]=Le.useToggle(!1),f=i.length>1,p=t.jsx(J,{src:n.cosmosWalletName?l(n.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:n.sender,walletIcon:p},_=C=>v.InitiaAddress.equals(C,m)?p:t.jsx(S.IconWallet,{size:11}),y=C=>{const{label:I,amount_out:E,denom:M,denom_out:A=M,chain_id:L,from_chain_id:N,to_chain_id:k=L??N}=C,P=c[k];return{label:f&&!u?void 0:I,amount:E,denom:A,chainId:k,address:P,walletIcon:_(P)}},j=i.map(S_).map(y),b=j.slice(0,-1),w=j[j.length-1];return t.jsxs(Z.Collapsible.Root,{className:wn.root,open:u,onOpenChange:h,children:[f&&t.jsx("div",{className:wn.flexEnd,children:t.jsx(Z.Collapsible.Trigger,{className:wn.toggle,children:u?t.jsxs(t.Fragment,{children:[t.jsx(S.IconMinus,{size:12}),t.jsx("span",{children:"Hide details"})]}):t.jsxs(t.Fragment,{children:[t.jsx(S.IconList,{size:12}),t.jsx("span",{children:"Show details"})]})})}),t.jsxs("div",{className:wn.route,children:[t.jsx(an,{...g,source:!0}),t.jsx(Z.Collapsible.Content,{className:wn.content,children:b.map((C,I)=>t.jsx(me,{suspenseFallback:t.jsx(an.Placeholder,{...C}),errorBoundaryProps:{fallback:t.jsx(an.Placeholder,{...C})},children:t.jsx(an,{...C})},I))}),t.jsx(an,{...w})]})]})},tc=({error:e})=>{const n=Ce();return t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:e.message}),children:t.jsx(le.White,{onClick:()=>n("/bridge"),children:"Home"})})},nc=({children:e})=>{const n=bt(),{route:s,values:o}=n,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:m}=Ue(),u=Rn(),h=wt(),f=On(),p=h(r),g=f(p),_=a.slice(0,-1).some(E=>{const M=h(E);return f(M)==="cosmos"})&&g!=="cosmos",[y,j]=x.useState(void 0),[b,w]=x.useState(!1),[C,I]=x.useState(null);if(x.useEffect(()=>{(async()=>{try{if(!_)return;if(!u)throw new Error("Wallet not connected");w(!0),I(null);const[{pubkey:M}]=await u.getAccounts();j(M)}catch(M){I(await _t(M))}finally{w(!1)}})()},[_,u]),C)return t.jsx(tc,{error:C});if(b)return t.jsx(xe,{children:t.jsx(le.White,{loading:b&&"Generating intermediary addresses..."})});if(!_||y){const E=a.map((M,A)=>{if(A===a.length-1){const R=h(i);return f(R)==="initia"?v.InitiaAddress(l).bech32:l}const L=h(M),N=f(L),k=h(r),P=f(k);switch(N){case"initia":return d;case"evm":return m;case"cosmos":{if(P==="cosmos")return se.toBech32(L.bech32_prefix,se.fromBech32(c).data);if(!y)throw new Error("Pubkey not found");return Nn.pubkeyToAddress(Nn.encodeSecp256k1Pubkey(y),L.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(E)}return null},la=({tx:e,children:n})=>{const s=Kr(),o=wt(),{data:a,isLoading:r}=$.useQuery({queryKey:["erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:m,signer_address:u}=e.evm_tx,h=await s();await Io(h,o(m));const f=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async g=>{const{token_contract:_,spender:y}=g,b=await new ct.ethers.Contract(_,f,h).allowance(u,y);return{approval:g,currentAllowance:BigInt(b.toString())}}))).filter(({approval:g,currentAllowance:_})=>_<BigInt(g.amount)).map(({approval:g})=>g)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:i,data:c,isPending:l,error:d}=$.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:m}=e.evm_tx,u=await s(),h=await u.getSigner();await Io(u,o(m));for(const f of a){const{token_contract:p,spender:g,amount:_}=f,y=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new ct.ethers.Contract(p,y,h).approve(g,_)).wait()}return!0}catch(m){throw await _t(m)}}});return r?t.jsx(xe,{children:t.jsx(le.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!c?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:d?.message}),children:t.jsx(le.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):n},sc=({addressList:e,signedOpHook:n,children:s})=>{const o=tt(),{route:a,values:r}=bt(),[i,c]=x.useState(void 0),[l,d]=x.useState(!1),[m,u]=x.useState(null);return x.useEffect(()=>{(async()=>{try{if(a.required_op_hook&&!n)throw new Error("Op hook is required");d(!0),u(null);const f={address_list:e,amount_in:a.amount_in,amount_out:a.amount_out,source_asset_chain_id:a.source_asset_chain_id,source_asset_denom:a.source_asset_denom,dest_asset_chain_id:a.dest_asset_chain_id,dest_asset_denom:a.dest_asset_denom,slippage_tolerance_percent:r.slippagePercent,operations:a.operations,signed_op_hook:n},{txs:p}=await o.post("v2/fungible/msgs",{json:f}).json();if(!p||p.length===0)throw new Error("No transaction data found");const[g]=p;c(g)}catch(f){u(f)}finally{d(!1)}})()},[a,r,JSON.stringify(e),n,o]),m?t.jsx(tc,{error:m}):l||!i?t.jsx(xe,{children:t.jsx(le.White,{loading:"Fetching messages..."})}):s(i)},oc=({children:e})=>{const{route:n}=bt(),s=qg();return n.required_op_hook&&!s.data?t.jsx(xe,{extra:t.jsx(fe,{level:"error",children:s.error?.message}),children:t.jsx(le.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},$_=()=>t.jsx(ht,{title:"Route preview",children:t.jsx(nc,{children:e=>t.jsxs(t.Fragment,{children:[t.jsx(T_,{addressList:e}),t.jsx(oc,{children:n=>t.jsx(sc,{addressList:e,signedOpHook:n,children:s=>t.jsx(la,{tx:s,children:t.jsx(ca,{tx:s})})})})]})})}),ac=x.createContext(null);function zs(){return x.useContext(ac)}const E_="_button_17r1o_1",M_="_claimed_17r1o_24",Ka={button:E_,claimed:M_},L_=()=>{const{withdrawalTx:e}=zs(),{bridge_id:n,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,m=re(),u=X(),{requestTxSync:h,waitForTxConfirmation:f}=Ue(),p=$g(e),g=se.toBase64(Zi(e)),_=Yi(e,g),y=$.useQueryClient(),{mutate:j,isPending:b}=$.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:w}=p;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:u,bridgeId:BigInt(n),outputIndex:BigInt(a),withdrawalProofs:r.map(se.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:se.fromBase64(d),storageRoot:se.fromBase64(i),lastBlockHash:se.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:m.chain_id,txHash:w}),y.invalidateQueries({queryKey:Yt.withdrawalClaimed(n,g).queryKey})}});return _?t.jsxs("div",{className:Ka.claimed,children:[t.jsx(S.IconCheckCircleFilled,{size:14}),t.jsx("span",{children:"Claimed"})]}):t.jsx("button",{className:Ka.button,onClick:()=>j(),disabled:b,children:"Claim"})},q_=({children:e})=>{const{withdrawalTx:n}=zs(),s=Ig(n.bridge_id),o=Tg(n),a=x.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Re.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},rc=1e3,P_=60,D_=60,B_=24,Ao=rc*P_,So=Ao*D_,Wa=So*B_,R_=({date:e})=>{const n=x.useCallback(()=>{const d=new Date().getTime(),u=e.getTime()-d;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(u/Wa),f=Math.floor(u%Wa/So),p=Math.floor(u%So/Ao),g=Math.floor(u%Ao/rc);return{days:h,hours:f,minutes:p,seconds:g}},[e]),[s,o]=x.useState(n());x.useEffect(()=>{const d=window.setInterval(()=>{o(n())},1e3);return()=>window.clearInterval(d)},[n,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return t.jsx(Wn,{label:e.toLocaleString(),children:t.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},F_="_container_1lz3w_1",U_="_title_1lz3w_5",za={container:F_,title:U_},O_=({date:e})=>t.jsxs("div",{className:za.container,children:[t.jsx("div",{className:za.title,children:"Claimable in"}),t.jsx(R_,{date:e})]}),V_="_container_1oldz_1",K_="_icon_1oldz_7",Ha={container:V_,icon:K_},W_="Withdrawal will begin within an hour",Ga=()=>{const e=Rs();return t.jsxs("div",{className:Ha.container,children:[t.jsx("span",{children:"In progress"}),!e&&t.jsx(Wn,{label:W_,children:t.jsx("span",{className:Ha.icon,children:t.jsx(S.IconInfoFilled,{size:12})})})]})},z_=({children:e})=>{const{withdrawalTx:n}=zs(),s=Sg(n.bridge_id),o=n.output_index>Number(s?.output_index);return e(o)},H_=({date:e,children:n})=>{const{chainId:s,withdrawalTx:o}=zs(),a=se.toBase64(Zi(o)),r=Yi(o,a),{setReminder:i,removeReminder:c}=fn();return x.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:Re.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),n},G_=()=>t.jsx(z_,{children:e=>e?t.jsx(Ga,{}):t.jsx(q_,{children:n=>n?t.jsx(H_,{date:n,children:Re.isFuture(n)?t.jsx(O_,{date:n}):t.jsx(L_,{})}):t.jsx(Ga,{})})}),Q_="_asset_6h8u2_1",Y_="_info_6h8u2_7",Z_="_symbol_6h8u2_11",fo={asset:Q_,info:Y_,symbol:Z_},J_=({amount:e,denom:n})=>{const s=re(),o=gr(n,s),{symbol:a,logoUrl:r,decimals:i}=o;return t.jsxs("div",{className:fo.asset,children:[t.jsx(J,{src:r,width:32,height:32,logo:!0}),t.jsxs("div",{className:fo.info,children:[t.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),t.jsx("span",{className:fo.symbol,children:a})]})]})},X_="_item_km5w2_1",ex={item:X_},tx=({chain:e})=>{const n=e.metadata?.executor_uri;if(!n)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=Ag(n),i=x.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=fn();return x.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?t.jsxs(t.Fragment,{children:[i.map(l=>{const{amount:d}=l;return t.jsxs("div",{className:ex.item,children:[t.jsx(J_,{...d}),t.jsx(me,{suspenseFallback:null,children:t.jsx(ac.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:t.jsx(G_,{})})})]},l.sequence)}),a&&t.jsx(zi,{onClick:()=>o(),disabled:r})]}):t.jsx(he,{children:"No withdrawals"})},nx="_content_dj1qm_1",sx="_title_dj1qm_5",Qa={content:nx,title:sx},ox=()=>{const{chainId:e}=et(),n=de(),s=Gt(),[o,a]=x.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Fe(),{reminders:i}=fn(),c=o?r(o):void 0;return t.jsxs(ht,{title:"OP Bridge withdrawals",children:[t.jsx(Vt,{chains:n.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(d=>d.chainId===l)}),t.jsx("div",{className:Qa.content,children:c?t.jsxs(t.Fragment,{children:[t.jsx("h2",{className:Qa.title,children:c.name}),t.jsx(me,{children:t.jsx(tx,{chain:c})},o)]}):t.jsx(fe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},vs=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),ax="5722e7dffb709492cf5312446ceeff73",rx=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${ax}`,ic=["walletconnect-wallets"],ix=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",cc=async e=>{const n=await z.get(rx,{signal:e}).json(),s=n!==null&&typeof n=="object"&&"listings"in n?n.listings:n;return Object.values(s??{}).filter(ix)},cx=()=>$.useQuery({queryKey:ic,queryFn:({signal:e})=>cc(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),lx="_page_13y8q_1",dx="_pageTop_13y8q_19",ux="_backButtonFixed_13y8q_63",mx="_listItem_13y8q_64",hx="_socialButton_13y8q_65",fx="_arrowIcon_13y8q_66",px="_searchInputUnderline_13y8q_67",gx="_header_13y8q_72",_x="_title_13y8q_81",xx="_headerSpacer_13y8q_116",yx="_icon_13y8q_120",jx="_installedText_13y8q_124",wx="_divider_13y8q_131",bx="_dividerText_13y8q_152",vx="_loading_13y8q_193",Cx="_socialIcons_13y8q_198",Nx="_socialText_13y8q_204",kx="_searchWrapper_13y8q_214",Ix="_scrollable_13y8q_248",Ax="_list_13y8q_64",Sx="_listIconWrapper_13y8q_332",Tx="_moreIconSmall_13y8q_342",$x="_externalLinkIcon_13y8q_364",Ex="_listName_13y8q_368",Mx="_listNameMuted_13y8q_381",Lx="_recentBadge_13y8q_394",qx="_learnMoreLink_13y8q_408",D={page:lx,pageTop:dx,backButtonFixed:ux,listItem:mx,socialButton:hx,arrowIcon:fx,searchInputUnderline:px,header:gx,title:_x,headerSpacer:xx,icon:yx,installedText:jx,divider:wx,dividerText:bx,loading:vx,socialIcons:Cx,socialText:Nx,searchWrapper:kx,scrollable:Ix,list:Ax,listIconWrapper:Sx,moreIconSmall:Tx,externalLinkIcon:$x,listName:Ex,listNameMuted:Mx,recentBadge:Lx,learnMoreLink:qx},Px=e=>{try{const n=new URL(e.trim());return n.protocol==="https:"&&!n.username&&!n.password}catch{return!1}},Dx=({walletConnectors:e,isPending:n,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=x.useState(""),{data:l=[],isError:d,isLoading:m,isFetching:u}=cx(),h=m||u&&l.length===0,f=x.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(g))},[e,i]),p=x.useMemo(()=>{const g=new Set(e.map(y=>vs(y.name))),_=i.toLowerCase();return l.filter(y=>!g.has(vs(y.name))).filter(y=>!i||y.name.toLowerCase().includes(_)).sort((y,j)=>y.name.localeCompare(j.name))},[l,e,i]);return t.jsxs("div",{className:D.pageTop,children:[t.jsx("button",{type:"button",className:D.backButtonFixed,onClick:r,"aria-label":"Back",children:t.jsx(S.IconBack,{size:16,"aria-hidden":"true"})}),t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"All Wallets"}),t.jsx("div",{className:D.headerSpacer})]}),t.jsx("div",{className:D.searchWrapper,children:t.jsx(zn,{rootClassName:D.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>c(g.target.value),onClear:()=>c("")})}),t.jsx(nt,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[f.map(g=>{const{name:_,icon:y,id:j}=g,b=o===j,w=s===j,C="ready"in g?!!g.ready:!0;return t.jsxs("button",{type:"button",className:q(D.listItem,{[D.loading]:w}),onClick:()=>a(g),disabled:n||!C,"aria-busy":w,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(J,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:_}),w?t.jsx(ut,{size:16}):b?t.jsx("span",{className:D.recentBadge,children:"Recent"}):C?t.jsx("span",{className:D.installedText,children:"Installed"}):null]},`connector:${j}`)}),h&&t.jsxs("div",{className:q(D.listItem,D.loading),role:"status","aria-live":"polite",children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(ut,{size:16})}),t.jsx("span",{className:D.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const _=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,y=_&&Px(_)?_:void 0;return t.jsxs("button",{type:"button",className:D.listItem,disabled:!0,"aria-label":`${g.name} (not installed)`,children:[t.jsx("div",{className:D.listIconWrapper,children:y&&t.jsx(J,{src:y,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:g.name})]},`wc:${g.id}`)}),d&&t.jsx(fe,{level:"error",children:"Couldn't load additional wallets."})]})})]})},Bx=()=>t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[t.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),t.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),Rx=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),Fx=()=>t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),Ux=()=>t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),t.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),Ox=[{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"}],Vx=({walletConnectors:e,privyConnector:n,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(p=>!("ready"in p)||!!p.ready),d=l.slice(0,5),m=new Set(l.map(p=>p.id)),u=new Set(l.map(p=>vs(p.name))),h=Math.max(0,5-d.length),f=Ox.filter(p=>!m.has(p.id)&&!u.has(vs(p.name))).slice(0,h);return t.jsxs("div",{className:D.page,children:[t.jsxs("header",{className:D.header,children:[t.jsx("div",{className:D.headerSpacer}),t.jsx("h1",{className:D.title,children:"Sign In"}),t.jsx("div",{className:D.headerSpacer})]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",className:q(D.socialButton,{[D.loading]:o===n.id}),onClick:()=>r(n),disabled:s,"aria-busy":o===n.id,children:[t.jsx("span",{className:D.socialText,children:"Email / Socials"}),o===n.id?t.jsx(ut,{size:16}):t.jsxs("div",{className:D.socialIcons,children:[t.jsx(Rx,{}),t.jsx(Ux,{}),t.jsx(Fx,{})]})]}),t.jsx("div",{className:D.divider,children:t.jsx("span",{className:D.dividerText,children:"or"})})]}),t.jsx(nt,{className:D.scrollable,children:t.jsxs("div",{className:D.list,children:[d.map(p=>{const{name:g,icon:_,id:y}=p,j=o===y,b=a===y;return t.jsxs("button",{type:"button",className:q(D.listItem,{[D.loading]:j}),onClick:()=>r(p),disabled:s,"aria-busy":j,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(J,{src:_,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listName,children:g}),j?t.jsx(ut,{size:16}):b?t.jsx("span",{className:D.recentBadge,children:"Recent"}):t.jsx("span",{className:D.installedText,children:"Installed"})]},y)}),f.map(p=>t.jsxs("a",{className:D.listItem,href:p.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${p.name} (opens in new tab)`,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx(J,{src:p.icon,width:26,height:26,alt:"",className:D.icon})}),t.jsx("span",{className:D.listNameMuted,children:p.name}),t.jsx(S.IconExternalLink,{size:10,className:D.externalLinkIcon,"aria-hidden":"true"})]},p.id)),t.jsxs("button",{type:"button",className:D.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[t.jsx("div",{className:D.listIconWrapper,children:t.jsx("div",{className:D.moreIconSmall,children:t.jsx(Bx,{})})}),t.jsx("span",{className:D.listNameMuted,children:"More wallets"}),t.jsx("span",{className:D.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),t.jsxs("a",{className:D.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",t.jsx(S.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Ya=({onSuccess:e})=>{const{connectors:n,connectAsync:s}=Ee.useConnect(),o=Le.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=x.useState(null),[i,c]=x.useState("signin"),l=$.useQueryClient(),d=()=>l.prefetchQuery({queryKey:ic,queryFn:({signal:g})=>cc(g),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:m,isPending:u}=$.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(_){throw await _t(_)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=x.useMemo(()=>[...n].sort((g,_)=>g.id===o?-1:_.id===o?1:g.name.localeCompare(_.name)),[n,o]),f=x.useMemo(()=>h.find(g=>g.id===kn.id),[h]),p=x.useMemo(()=>h.filter(g=>g.id!==kn.id),[h]);return i==="all"?t.jsx(Dx,{walletConnectors:p,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):t.jsx(Vx,{walletConnectors:p,privyConnector:f,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:d})},Kx={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 Gn(e){return Kx[e]}function da(){const e=tt(),n=hn(),s=X(),o=Vn(),a=Object.fromEntries(o.filter(({chain_type:r,bech32_prefix:i})=>r==="evm"||r==="cosmos"&&i==="init").map(r=>[r.chain_id,{address:r.chain_type==="evm"?n:s,denoms:[]}]));return $.useQuery({queryKey:Me.allBalances(Object.keys(a),[n,s]).queryKey,queryFn:()=>e.post("v2/info/balances",{json:{chains:a}}).json(),select:({chains:r})=>r?Object.fromEntries(Object.entries(r).map(([i,{denoms:c}])=>[i,c||{}])):{},enabled:!!s,staleTime:K.SECOND})}function ua(){const{localOptions:e=[]}=et();return Qt().filter(({denom:s,chain_id:o})=>e.some(a=>a.denom===s&&a.chainId===o))}function ma(e){const{local:n}=Gn(e),s=Qt(),{watch:o}=Tt(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function Wx(e){const{external:n}=Gn(e),s=Qt(),{watch:o}=Tt(),a=o(),r=a[n.chainIdKey],i=a[n.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function zx(e){const n=Qt(),s=wt(),{data:o,isLoading:a}=da(),{remoteOptions:r=[]}=et(),i=ma(e);return i?{data:n.filter(({symbol:l,denom:d,chain_id:m})=>r.length?r.some(u=>u.denom===d&&u.chainId===m):l===i.symbol).map(l=>{if(l.hidden||l.chain_id===i.chain_id)return null;const d=s(l.chain_id);if(!d||d.chain_type==="cosmos"&&d.bech32_prefix!=="init")return null;const m=o?.[d.chain_id]?.[l.denom];return e==="deposit"&&(!m||!Number(m.amount))?null:{asset:l,chain:d,balance:m}}).filter(l=>l!==null),isLoading:a}:{data:[],isLoading:a}}function Tt(){return _e.useFormContext()}const Hx="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",Gx="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",Qx="_container_uxgnj_1",Yx="_title_uxgnj_5",Zx="_close_uxgnj_12",Jx="_emptyIcon_uxgnj_24",Xx="_empty_uxgnj_24",ey="_list_uxgnj_51",ty="_asset_uxgnj_66",ny="_placeholder_uxgnj_82",sy="_activeAsset_uxgnj_95",oy="_iconContainer_uxgnj_99",ay="_assetIcon_uxgnj_109",ry="_chainIcon_uxgnj_119",iy="_assetPlaceholder_uxgnj_133",cy="_assetName_uxgnj_154",ly="_assetChain_uxgnj_169",dy="_balance_uxgnj_177",uy="_value_uxgnj_186",ue={container:Qx,title:Yx,close:Zx,emptyIcon:Jx,empty:Xx,list:ey,asset:ty,placeholder:ny,activeAsset:sy,iconContainer:oy,assetIcon:ay,chainIcon:ry,assetPlaceholder:iy,assetName:cy,assetChain:ly,balance:dy,value:uy},my=({mode:e})=>{const{external:n}=Gn(e),{data:s,isLoading:o}=zx(e),{setValue:a,watch:r}=Tt(),i=ma(e),c=ua(),{theme:l}=ee(),d=r(),m=d[n.denomKey],u=d[n.chainIdKey];function h(){const f=m&&u;return!f&&c.length<=1&&e==="deposit"?null:t.jsx("button",{className:ue.close,onClick:()=>{e==="withdraw"||f?a("page","fields"):a("page","select-local")},children:t.jsx(S.IconBack,{size:20})})}return i?!o&&!s.length?t.jsxs("div",{className:ue.container,children:[h(),t.jsx("h4",{className:ue.title,children:"No available assets"}),t.jsx("img",{src:l==="dark"?Hx:Gx,alt:"No assets",className:ue.emptyIcon}),t.jsx("p",{className:ue.empty,children:e==="withdraw"?`No supported destinations to withdraw ${i.symbol}.`:`No supported assets to deposit ${i.symbol}.`})]}):t.jsxs("div",{className:ue.container,children:[h(),t.jsxs("h4",{className:ue.title,children:[e==="withdraw"?"Select destination":`Deposit ${i.symbol}`," "]}),t.jsxs("div",{className:ue.list,children:[o&&Array.from({length:5}).map((f,p)=>t.jsxs("div",{className:q(ue.asset,ue.placeholder),children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("div",{className:ue.assetIcon}),t.jsx("div",{className:ue.chainIcon})]}),t.jsx("div",{className:ue.assetPlaceholder})]},p)),!o&&s.sort(({balance:f},{balance:p})=>Number(p?.value_usd??0)-Number(f?.value_usd??0)).map(({asset:f,chain:p,balance:g})=>{const _=m===f.denom&&u===p.chain_id;return t.jsxs("button",{className:q(ue.asset,_&&ue.activeAsset),onClick:()=>{a(n.denomKey,f.denom),a(n.chainIdKey,p.chain_id),e==="deposit"&&a("quantity",""),a("page","fields")},children:[t.jsxs("div",{className:ue.iconContainer,children:[t.jsx("img",{src:f.logo_uri,alt:f.symbol,className:ue.assetIcon}),t.jsx("img",{src:p.logo_uri||"",alt:p.chain_name,className:ue.chainIcon})]}),t.jsxs("p",{className:ue.assetName,children:[f.symbol," ",_&&t.jsx("span",{children:t.jsx(S.IconCheck,{size:16})})]}),t.jsxs("p",{className:ue.assetChain,children:["on ",p.pretty_name]}),g&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:ue.balance,children:v.formatAmount(g.amount,{decimals:g.decimals||6})}),t.jsx("p",{className:ue.value,children:te(g.value_usd||0)})]})]},`${f.chain_id}-${f.denom}`)})]})]}):t.jsx("div",{children:"No assets found"})},hy="_title_9ovji_1",fy="_list_9ovji_7",py="_asset_9ovji_15",po={title:hy,list:fy,asset:py},gy=({mode:e})=>{const{local:n,external:s}=Gn(e),{setValue:o}=Tt(),a=ua(),r=(c,l)=>{o(n.denomKey,c),o(n.chainIdKey,l),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),o("page",e==="withdraw"?"fields":"select-external")},i=x.useEffectEvent(()=>{const{denom:c,chain_id:l}=a[0];r(c,l)});return x.useEffect(()=>{a.length===1&&i()},[a]),a.length?t.jsxs(t.Fragment,{children:[t.jsx("h3",{className:po.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),t.jsx("div",{className:po.list,children:a.map(({denom:c,chain_id:l,symbol:d,logo_uri:m})=>t.jsxs("button",{className:po.asset,onClick:()=>r(c,l),children:[t.jsx("img",{src:m,alt:d}),d]},`${c}-${l}`))})]}):t.jsx("div",{children:"No assets found"})},_y="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M29%202.71875C43.5%202.71875%2055.2812%2014.5%2055.2812%2029C55.2812%2043.5%2043.5%2055.2812%2029%2055.2812C14.5%2055.2812%202.71875%2043.5%202.71875%2029C2.71875%2014.5%2014.5%202.71875%2029%202.71875ZM29%206.34375C16.4937%206.34375%206.34375%2016.4937%206.34375%2029C6.34375%2041.5062%2016.4937%2051.6562%2029%2051.6562C41.5062%2051.6562%2051.6562%2041.5062%2051.6562%2029C51.6562%2016.4937%2041.5062%206.34375%2029%206.34375Z'%20fill='%23F85454'/%3e%3cpath%20d='M36.1616%2018.7623C37.0109%2017.9129%2038.3885%2017.9129%2039.2378%2018.7623C40.087%2019.6117%2040.0871%2020.9893%2039.2378%2021.8386L32.0763%2029.0001L39.2378%2036.1616L39.3865%2036.3279C40.083%2037.1822%2040.034%2038.4417%2039.2378%2039.2378C38.4417%2040.034%2037.1822%2040.083%2036.3279%2039.3865L36.1616%2039.2378L29.0001%2032.0763L21.8386%2039.2378C20.9893%2040.0871%2019.6117%2040.087%2018.7623%2039.2378C17.9129%2038.3885%2017.9129%2037.0109%2018.7623%2036.1616L25.9238%2029.0001L18.7623%2021.8386C17.9129%2020.9892%2017.9129%2019.6116%2018.7623%2018.7623C19.6116%2017.9129%2020.9892%2017.9129%2021.8386%2018.7623L29.0001%2025.9238L36.1616%2018.7623Z'%20fill='%23F85454'/%3e%3c/svg%3e",xy="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",yy="_container_9k4hs_1",jy="_title_9k4hs_8",wy="_subtitle_9k4hs_14",by="_linkContainer_9k4hs_30",vy="_link_9k4hs_30",Cy="_separator_9k4hs_51",Ny="_errorIcon_9k4hs_62",ky="_error_9k4hs_62",ve={container:yy,title:jy,subtitle:wy,linkContainer:by,link:vy,separator:Cy,errorIcon:Ny,error:ky};function Iy(e){if(!e)return"pending";const n=e.state;return n==="STATE_COMPLETED_SUCCESS"?"success":n==="STATE_ABANDONED"||n==="STATE_COMPLETED_ERROR"||n==="STATE_PENDING_ERROR"?"failed":"pending"}function To({type:e}){const{closeModal:n}=mn(),{theme:s}=ee(),{watch:o}=Tt(),{result:a}=o(),{openDrawer:r}=jt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:m,values:u}=a,{srcDenom:h,srcChainId:f,quantity:p}=u,g=dt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:y}=Ji({chainId:l,txHash:c,tracked:!1}),{data:j}=Xi({chainId:l,txHash:c,tracked:!!y,timestamp:d,route:m}),b=Iy(j),w=s==="dark"?_y:xy,C=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,I=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return t.jsxs("div",{className:ve.container,children:[t.jsxs("h3",{className:ve.title,children:[_," failed"]}),t.jsx("img",{src:w,alt:"Failed",className:ve.errorIcon}),t.jsx("p",{className:ve.error,children:a?.error}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]});const E=Mn(m.estimated_route_duration_seconds),M=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${M.toString()}`,"https://explorer.skip.build"),L=()=>t.jsxs("div",{className:ve.linkContainer,children:[t.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:ve.link,children:"View transaction"}),t.jsx("div",{className:ve.separator}),t.jsx("button",{className:ve.link,onClick:()=>{n(),r("/bridge/history")},children:"Go to history"})]});return t.jsxs("div",{className:ve.container,children:[b==="pending"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),t.jsx("video",{src:C,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),t.jsxs("p",{className:ve.subtitle,children:["Estimated time: ",t.jsx("span",{children:E})]}),L(),t.jsx("p",{className:ve.subtitle,children:"Your transaction will continue even if you close this"})]}),b==="success"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[_," complete"]}),t.jsx("video",{src:I,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const k=N.currentTarget;k.duration-k.currentTime<.1&&k.pause()}}),L(),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]}),b==="failed"&&t.jsxs(t.Fragment,{children:[t.jsxs("h3",{className:ve.title,children:[_," failed"]}),t.jsx("img",{src:w,alt:"Failed",className:ve.errorIcon}),t.jsx("p",{className:ve.error,children:"Your transaction could not be completed"}),t.jsx(le.White,{fullWidth:!0,onClick:n,children:"Close"})]})]})}const Ay=ye.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),Sy=({tx:e,children:n})=>{const{values:s}=bt(),{srcChainId:o}=s,a=X(),r=Bn(),i=Ms(),{data:c,isLoading:l}=$.useQuery({queryKey:Ay.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const m=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:p})=>{if(!(f&&p))throw new Error("Invalid transaction data");return r.fromAmino({type:Wt.aminoConverters[f].aminoType,value:JSON.parse(p)})});return{estimatedGas:await(await i(o)).simulate(a,m,""),messages:m}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(l)return t.jsx(xe,{children:t.jsx(le.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return t.jsx(t.Fragment,{children:n(d)})},Ty="_container_eg177_1",$y="_back_eg177_6",Ey="_title_eg177_18",My="_divider_eg177_26",Ly="_label_eg177_30",qy="_asset_eg177_37",Py="_assetIcon_eg177_55",Dy="_chainIcon_eg177_67",By="_assetName_eg177_80",Ry="_chevron_eg177_92",Fy="_input_eg177_96",Uy="_balanceContainer_eg177_108",Oy="_value_eg177_116",Vy="_maxButton_eg177_126",Ky="_detail_eg177_142",Wy="_detailsContainer_eg177_153",zy="_detailsButton_eg177_163",Hy="_detailValue_eg177_180",Gy="_detailToken_eg177_190",Qy="_minimumReceived_eg177_198",G={container:Ty,back:$y,title:Ey,divider:My,label:Ly,asset:qy,assetIcon:Py,chainIcon:Dy,assetName:By,chevron:Ry,input:Fy,balanceContainer:Uy,value:Oy,maxButton:Vy,detail:Ky,detailsContainer:Wy,detailsButton:zy,detailValue:Hy,detailToken:Gy,minimumReceived:Qy},lc=({renderFee:e})=>{const{route:n}=et(),{values:s}=bt(),{dstDenom:o,dstChainId:a}=s,i=Qt().find(({denom:f,chain_id:p})=>f===o&&p===a),c=X(),l=Ii(),[d,m]=Le.useToggle(!1),u=n&&n.estimated_route_duration_seconds>60;if(!n||!i)return null;const h=n.does_swap?BigInt(n.amount_out||n.estimated_amount_out)*BigInt(1e4-Number(s.slippagePercent)*100)/BigInt(1e4):BigInt(n.amount_out||n.estimated_amount_out);return t.jsx($n,{children:t.jsxs("div",{className:G.detailsContainer,children:[t.jsxs("button",{className:G.detailsButton,onClick:m,children:["Transaction details"," ",t.jsx(S.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&t.jsxs(t.Fragment,{children:[n.does_swap&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Slippage"}),t.jsxs("p",{className:G.detailValue,children:[s.slippagePercent,"%"]})]}),!!n.estimated_fees?.length&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Bridge fee"}),t.jsx("div",{className:G.detailValue,children:aa(n.estimated_fees)})]}),e&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Tx fee"}),t.jsx("div",{className:G.detailValue,children:e()})]}),c&&t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Receiving address"}),t.jsxs("p",{className:G.detailValue,children:[t.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",v.truncate(c)]})]})]}),t.jsxs("div",{className:G.detail,children:[t.jsx("p",{className:G.detailLabel,children:"Estimated time"}),t.jsx("p",{className:q(G.detailValue),style:u?{color:"var(--warning)"}:void 0,children:Mn(n.estimated_route_duration_seconds)})]}),t.jsxs("div",{className:q(G.detail,G.minimumReceived),children:[t.jsx("p",{className:G.detailLabel,children:"Minimum received"}),t.jsxs("p",{className:G.detailValue,children:[t.jsx("img",{src:i.logo_uri,alt:i.symbol,className:G.detailToken})," ",v.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]})})},Yy="_trigger_1c7d7_1",Zy="_item_1c7d7_5",Jy="_itemText_1c7d7_13",Xy={trigger:Yy,item:Zy,itemText:Jy},e1=({tx:e,gas:n,confirmMessage:s,onCompleted:o})=>{const{values:a}=bt(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=Qt().find(({denom:N,chain_id:k})=>N===i&&k===r),m=Xe(r),u=qn(m),h=zo(m),f=Ho(m),p=mt(m),g=h.map(({amount:N,denom:k})=>je.calculateFee(Math.ceil(n*zt),je.GasPrice.fromString(N+k))),_=g.map(N=>N.amount[0]),y=N=>{const k=u.find(F=>F.denom===N)?.amount??"0",P=_.find(F=>F.denom===N)?.amount??"0",R=d&&i===N?B(c||"0").times(B(10).pow(d.decimals)).toFixed(0):"0",O=B(P).plus(R),V=B(k).gte(O),{symbol:H,decimals:Q}=p(N);return{symbol:H,decimals:Q,spend:B(R).gt(0)?R:null,fee:P,total:O.toFixed(),balance:k,isSufficient:V}},j=()=>{if(!_.length)return null;if(f&&y(f).isSufficient)return f;for(const{denom:N}of _)if(y(N).isSufficient)return N;return _[0]?.denom},[b,w]=x.useState(j),C=g.find(N=>N.amount[0].denom===b)??void 0,I=b?y(b):null,E=I&&!I.isSufficient?"Insufficient balance":void 0,M=(N,k)=>{if(v.formatAmount(N,{decimals:k})==="0.000000")return 8},A=N=>{const[{amount:k,denom:P}]=N.amount;if(B(k).isZero())return"0";const{symbol:R,decimals:O}=p(P),V=M(k,O);return`${v.formatAmount(k,{decimals:O,dp:V})} ${R}`},L=()=>{if(g.length===0)return null;if(g.length===1)return t.jsx("span",{className:"monospace",children:A(g[0])});if(!C||!b)return null;const N=g.map(V=>{const[{denom:H}]=V.amount,{symbol:Q}=p(H);return{value:H,label:A(V),triggerLabel:Q}}),[{amount:k,denom:P}]=C.amount,{decimals:R}=p(P),O=M(k,R);return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{className:"monospace",children:v.formatAmount(k,{decimals:R,dp:O})}),t.jsx(sa,{options:N,value:b,onChange:w,classNames:Xy})]})};return t.jsxs(t.Fragment,{children:[t.jsx(lc,{renderFee:g.length>0?L:void 0}),t.jsx(la,{tx:e,children:t.jsx(ca,{tx:e,fee:C,onCompleted:o,confirmMessage:s,error:E})})]})},t1=({tx:e,confirmMessage:n,onCompleted:s})=>t.jsxs(t.Fragment,{children:[t.jsx(lc,{}),t.jsx(la,{tx:e,children:t.jsx(ca,{tx:e,fee:void 0,onCompleted:s,confirmMessage:n})})]}),n1=({tx:e,gas:n,mode:s})=>{const{setValue:o}=Tt(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!n||!("cosmos_tx"in e)?t.jsx(t1,{tx:e,onCompleted:a,confirmMessage:r}):t.jsx(e1,{tx:e,gas:n,onCompleted:a,confirmMessage:r})},s1=({mode:e})=>{const n=Gn(e),s=Ce(),o=et(),a=ua(),r=wt(),{data:i}=da(),c=hn(),{watch:l,setValue:d,getValues:m}=Tt(),u=l(),{srcChainId:h,srcDenom:f,quantity:p=""}=u,g=ma(e),_=Wx(e),y=u[n.external.chainIdKey],j=y?r(y):null,b=i?.[h]?.[f]?.amount,w=i?.[h]?.[f]?.price||0,C=B(w||0).times(p||0),[I]=Le.useDebounceValue(p,300),E=e==="withdraw"?g:_,M=x.useMemo(()=>{if(e==="deposit"&&!_)return"Select asset";const Q=B(p||0);if(!Q.isFinite()||Q.lte(0))return"Enter amount";const F=v.fromBaseUnit(b??"0",{decimals:E?.decimals||6});if(Q.gt(F))return"Insufficient balance";if(e==="withdraw"&&!_)return"Select destination"},[e,p,b,E,_]),{data:A,error:L}=ko(I,{disabled:!!M}),N=!L&&!M?A:void 0,k=x.useEffectEvent(()=>{s(0,{...o,route:N,values:{sender:c,recipient:o.recipientAddress?v.InitiaAddress(o.recipientAddress).hex:c,slippagePercent:"1",...m()}})});if(x.useEffect(()=>{k()},[N,c]),!g||e==="deposit"&&!_)return null;const P=E?.decimals||6,R=e==="withdraw"?"Select chain":"Select asset",O=()=>{d("quantity",""),d(n.external.denomKey,""),d(n.external.chainIdKey,""),e==="withdraw"&&(d(n.local.denomKey,""),d(n.local.chainIdKey,"")),d("page",e==="withdraw"?"select-local":"select-external")},V=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:G.label,children:e==="withdraw"?"Destination":"From"}),t.jsxs("button",{className:G.asset,onClick:()=>{d("page","select-external")},children:[t.jsx("div",{className:G.assetIcon,children:_?t.jsxs(t.Fragment,{children:[t.jsx("img",{src:_.logo_uri,alt:_.symbol}),t.jsx("img",{src:j?.logo_uri||"",alt:j?.pretty_name,className:G.chainIcon})]}):e==="withdraw"&&t.jsx("div",{className:G.chainIcon})}),t.jsx("p",{className:G.assetName,children:_?t.jsxs(t.Fragment,{children:[_.symbol,t.jsx("br",{}),t.jsxs("span",{children:["on ",j?.pretty_name]})]}):R}),t.jsx(S.IconChevronDown,{className:G.chevron,size:16})]})]}),H=t.jsxs(t.Fragment,{children:[t.jsx("p",{className:G.label,children:"Amount"}),t.jsx(En,{balance:b,decimals:P,className:G.input}),Number(b)>0&&t.jsxs("div",{className:G.balanceContainer,children:[t.jsx("p",{className:G.value,children:C.gt(0)?te(C.toString()):"$-"}),t.jsxs("button",{className:G.maxButton,onClick:()=>{const Q=v.fromBaseUnit(b??"0",{decimals:P});B(p||0).eq(Q)||d("quantity",Q)},children:[t.jsx(S.IconWallet,{size:16})," ",v.formatAmount(b,{decimals:P})," ",t.jsx("span",{children:"MAX"})]})]})]});return t.jsxs("div",{className:G.container,children:[a.length>1&&t.jsx("button",{type:"button","aria-label":"Back",className:G.back,onClick:O,children:t.jsx(S.IconBack,{size:20})}),t.jsxs("h3",{className:G.title,children:[n.label," ",g.symbol]}),e==="withdraw"?t.jsxs(t.Fragment,{children:[H,t.jsx("div",{className:G.divider}),V]}):t.jsxs(t.Fragment,{children:[V,t.jsx("div",{className:G.divider}),H]}),!o.route||M?t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:!L&&!M&&"Fetching route...",disabled:!0,fullWidth:!0,children:L?"No route found":M})}):t.jsx(nc,{children:Q=>t.jsx(oc,{children:F=>t.jsx(sc,{addressList:Q,signedOpHook:F,children:W=>t.jsx(Sy,{tx:W,children:qe=>t.jsx(n1,{tx:W,gas:qe,mode:e})})})})})]})},o1="_container_7nl9j_1",a1="_page_7nl9j_5",Za={container:o1,page:a1},dc=({mode:e})=>{const n=_e.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return da(),t.jsx(_e.FormProvider,{...n,children:t.jsx(r1,{mode:e})})},r1=({mode:e})=>{const{watch:n}=Tt(),s=n("page"),o=lt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return t.jsx(gy,{mode:e});case"select-external":return t.jsx(my,{mode:e});case"fields":return t.jsx(s1,{mode:e});case"completed":return t.jsx(To,{type:e})}};return t.jsx($n,{children:t.jsx("div",{className:Za.container,children:o((r,i)=>t.jsx(lt.animated.div,{style:r,className:Za.page,children:a(i)}))})})},i1=()=>t.jsx(dc,{mode:"deposit"}),c1=()=>t.jsx(dc,{mode:"withdraw"}),l1="_root_1lo0i_1",d1="_address_1lo0i_9",u1="_copy_1lo0i_19",m1="_labelWrapper_1lo0i_33",h1="_labelCopy_1lo0i_43",f1="_labelCopied_1lo0i_47",p1="_copied_1lo0i_55",g1="_derived_1lo0i_65",_1="_derivedLabel_1lo0i_79",x1="_derivedAddress_1lo0i_83",y1="_hexAddress_1lo0i_89",j1="_derivedCopy_1lo0i_94",Ae={root:l1,address:d1,copy:u1,labelWrapper:m1,labelCopy:h1,labelCopied:f1,copied:p1,derived:g1,derivedLabel:_1,derivedAddress:x1,hexAddress:y1,derivedCopy:j1},w1=()=>{const e=x.useRef(null),n=x.useRef(null),{initiaAddress:s,hexAddress:o}=Ue(),a=Ni("--gray-0");return x.useEffect(()=>{e.current&&(n.current?n.current.update({data:s}):(n.current=new Lc({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),n.current.append(e.current)))},[s,a]),t.jsx(ht,{title:"Receive",children:t.jsxs("div",{className:Ae.root,children:[t.jsx("div",{ref:e,style:{width:200,height:200}}),t.jsx("span",{className:Ae.address,children:s}),t.jsx(js,{value:s,children:({copy:r,copied:i})=>t.jsxs("button",{className:q(Ae.copy,{[Ae.copied]:i}),onClick:r,children:[t.jsx(S.IconCopy,{size:12}),t.jsxs("div",{className:Ae.labelWrapper,children:[t.jsx("span",{className:Ae.labelCopy,children:"Copy address"}),t.jsx("span",{className:Ae.labelCopied,children:"Copied!"})]})]})}),t.jsx(js,{value:o,children:({copy:r,copied:i})=>t.jsxs("button",{className:q(Ae.derived,{[Ae.copied]:i}),onClick:r,children:[t.jsx("span",{className:Ae.derivedLabel,children:"Derived from"}),t.jsxs("span",{className:Ae.derivedAddress,children:[t.jsx("span",{className:Ae.hexAddress,children:v.truncate(o)}),t.jsx(S.IconCopy,{size:12,className:Ae.derivedCopy}),i&&t.jsx("span",{className:Ae.copiedText,children:"Copied!"})]})]})})]})})};function b1(e,n){return n==null?e:e.filter(s=>s.grantee===n)}function v1(){const e=X(),n=de();return $.useQueries({queries:n.map(s=>({queryKey:xs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Is(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Wr(o),r=e?Uo(e,s.chainId):null,i=b1(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const C1="_countdown_vfms8_1",N1={countdown:C1},k1=({expiration:e})=>{const n=()=>{const a=new Date,r=Re.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,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(`${d}s`),m.join(" ")},[s,o]=x.useState(n());return Le.useInterval(()=>{o(n())},1e3),Re.isPast(e)?"Expired":t.jsxs(t.Fragment,{children:["Expires in ",t.jsx("span",{className:N1.countdown,children:s})]})},I1="_container_1l528_1",A1="_info_1l528_11",S1="_header_1l528_17",T1="_chainName_1l528_23",$1="_expiration_1l528_29",E1="_revokeButton_1l528_35",tn={container:I1,info:A1,header:S1,chainName:T1,expiration:$1,revokeButton:E1},M1=({chainId:e,grantee:n,expiration:s})=>{const o=Xe(e),{mutate:a,isPending:r}=ii({grantee:n,internal:!0});return t.jsxs("div",{className:tn.container,children:[t.jsxs("div",{className:tn.info,children:[t.jsxs("div",{className:tn.header,children:[t.jsx(J,{src:o.logoUrl,width:16,height:16,logo:!0}),t.jsx("div",{className:tn.chainName,children:o.name})]}),t.jsx("div",{className:tn.expiration,children:s?t.jsx(k1,{expiration:s}):"Until revoked"})]}),t.jsx("button",{className:tn.revokeButton,onClick:()=>a(e),disabled:r,children:r?"Revoking...":"Revoke"})]})},L1=({chainId:e,grants:n})=>{const s=new Map;for(const a of n){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=Wo([r.expiration,i])}return[...s.values()].map(a=>x.createElement(M1,{...a,chainId:e,key:a.grantee}))},q1="_content_q36qs_1",P1={content:q1},D1=()=>{const e=v1(),n=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?t.jsx(he,{children:"No permissions found"}):t.jsx("div",{className:P1.content,children:s.map(({chainId:o,grants:a})=>t.jsx(L1,{chainId:o,grants:a},o))})};return t.jsx(ht,{title:"Manage auto-signing",backButton:"/settings",children:n()})},B1="_version_1sf5y_1",R1={version:B1},F1=()=>t.jsxs("aside",{className:R1.version,children:["v","2.4.0"]}),U1="_link_se23z_1",O1="_title_se23z_17",V1="_subtitle_se23z_23",K1="_icon_se23z_30",cs={link:U1,title:O1,subtitle:V1,icon:K1},uc=({title:e,subtitle:n,rightSection:s,onClick:o})=>t.jsxs("button",{className:cs.link,onClick:o,children:[t.jsxs("div",{children:[t.jsx("p",{className:cs.title,children:e}),n&&t.jsx("p",{className:cs.subtitle,children:n})]}),t.jsx("div",{className:cs.icon,children:s??t.jsx(S.IconChevronRight,{size:16})})]}),W1="https://export.initia.xyz/",z1=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return t.jsx(uc,{title:"Export private key",rightSection:t.jsx(S.IconExternalLink,{size:16}),onClick:()=>window.open(W1,"_blank",e)})},H1="_container_1vxr7_1",G1="_separator_1vxr7_7",Ja={container:H1,separator:G1},Q1=()=>{const e=Ce(),{connector:n}=Ee.useAccount();return t.jsx(ht,{title:"Settings",backButton:"/",children:t.jsxs("div",{className:Ja.container,children:[t.jsx(uc,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),n?.id===qo&&t.jsx(z1,{}),t.jsx(gt.Separator,{className:Ja.separator}),t.jsx(F1,{})]})})},Y1="_trigger_1yjkd_1",Z1="_icon_1yjkd_23",J1="_full_1yjkd_27",X1="_triggerContent_1yjkd_32",e2="_triggerText_1yjkd_40",t2="_popoverBackdrop_1yjkd_51",n2="_popoverPositioner_1yjkd_70",s2="_popoverPopup_1yjkd_74",o2="_search_1yjkd_99",a2="_viewport_1yjkd_105",r2="_item_1yjkd_111",i2="_highlighted_1yjkd_127",c2="_active_1yjkd_131",l2="_itemContent_1yjkd_136",d2="_extra_1yjkd_142",u2="_connectedTag_1yjkd_149",ge={trigger:Y1,icon:Z1,full:J1,triggerContent:X1,triggerText:e2,popoverBackdrop:t2,popoverPositioner:n2,popoverPopup:s2,search:o2,viewport:a2,item:r2,highlighted:i2,active:c2,itemContent:l2,extra:d2,connectedTag:u2},Hs=({value:e,onChange:n,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=ee(),[i,c]=x.useState(""),[l,d]=x.useState(!1),[m,u]=x.useState(0),[h,f]=x.useState(),p=x.useRef([]),g=x.useRef(null),_=de(),y=s.map(N=>_.find(k=>k.chainId===N)).filter(Boolean),j=N=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[t.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),t.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),b=x.useMemo(()=>({chainId:"",name:"All",logoUrl:j}),[]),w=x.useMemo(()=>{const N=[b,...y];if(!i)return N;const k=i.toLowerCase();return N.filter(P=>P.name.toLowerCase().includes(k)||P.chainId.toLowerCase().includes(k))},[y,i,b]),C=y.find(N=>N.chainId===e)||b,I=parseInt(Ni("--drawer-offset")),E=6,M=()=>{if(c(""),u(-1),g.current){const k=g.current.getBoundingClientRect().bottom+E,P=window.innerHeight-k-2*I;f(P)}d(!0)};x.useEffect(()=>{m>=0&&m<p.current.length&&p.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=x.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),u(k=>(k+1)%w.length);break;case"ArrowUp":N.preventDefault(),u(k=>(k-1+w.length)%w.length);break;case"Enter":N.preventDefault(),w[m]&&(n(w[m].chainId),d(!1));break;case"Escape":N.preventDefault(),d(!1);break}},[w,m,n,d]),L=N=>{n(N),d(!1)};return t.jsxs(Xt.Popover.Root,{open:l,onOpenChange:M,modal:"trap-focus",children:[t.jsx(Xt.Popover.Trigger,{render:t.jsxs("button",{className:q(ge.trigger,{[ge.full]:a}),"aria-expanded":l,role:"listbox",ref:g,children:[t.jsxs("div",{className:ge.triggerContent,children:[typeof C.logoUrl=="string"?t.jsx(J,{src:C.logoUrl,width:14,height:14,logo:!0}):C.logoUrl(14),t.jsx("span",{className:ge.triggerText,children:C.name})]}),t.jsx(S.IconChevronDown,{size:16,className:ge.icon})]})}),t.jsxs(Xt.Popover.Portal,{container:Ht(),children:[t.jsx(Xt.Popover.Backdrop,{className:ge.popoverBackdrop,onClick:()=>d(!1)}),t.jsx(Xt.Popover.Positioner,{className:ge.popoverPositioner,align:"end",side:"bottom",sideOffset:E,collisionAvoidance:{side:"none"},children:t.jsxs(Xt.Popover.Popup,{className:q(ge.popoverPopup,{[ge.full]:a}),style:{maxHeight:h},children:[t.jsx(zn,{value:i,onChange:N=>{c(N.target.value),u(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search appchains",rootClassName:ge.search,ref:Kn()}),t.jsx("div",{className:ge.viewport,role:"listbox",children:w.length===0?t.jsx(he,{children:"No appchains found"}):w.map(({chainId:N,name:k,logoUrl:P},R)=>t.jsxs("div",{className:q(ge.item,{[ge.highlighted]:R===m,[ge.active]:e===N}),onClick:()=>L(N),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),L(N))},onMouseEnter:()=>u(R),role:"option","aria-selected":e===N,tabIndex:-1,ref:O=>{O&&(p.current[R]=O)},children:[t.jsxs("div",{className:ge.itemContent,children:[typeof P=="string"?t.jsx(J,{src:P,width:16,height:16,logo:!0}):P(16),t.jsx("span",{className:ge.name,children:k}),N===r&&t.jsx("span",{className:ge.connectedTag,children:"Connected"})]}),o&&t.jsx("span",{className:ge.extra,children:o(N)})]},N))})]})})]})]})},m2="_container_1nap1_1",h2="_controls_1nap1_7",f2="_search_1nap1_13",ha={container:m2,controls:h2,search:f2},p2=({children:e})=>t.jsx("div",{className:ha.container,children:e}),g2=({children:e})=>t.jsx("div",{className:ha.controls,children:e}),_2=e=>t.jsx(zn,{...e,rootClassName:ha.search}),Je={Root:p2,Controls:g2,SearchInput:_2},mc=U.atom(""),hc=U.atom(""),x2=U.atom(""),y2=U.atom(""),j2=U.atom(""),w2="_change_1x9v4_1",b2="_positive_1x9v4_10",v2="_negative_1x9v4_14",go={change:w2,positive:b2,negative:v2},fc=({amount:e,asset:n})=>{const{denom:s,symbol:o,decimals:a}=n,r=new B(e).isPositive(),i=new B(e).abs().toString();return t.jsxs("div",{className:q(go.change,r?go.positive:go.negative),children:[r?"+":"-",v.formatAmount(i,{decimals:a})," ",o||s]})},C2=({changes:e,chain:n})=>{const s=mt(n);return e.map(({amount:o,denom:a},r)=>t.jsx(fc,{amount:o,asset:s(a)},r))},N2=({changes:e,chain:n})=>{const s=mt(n);return e.map(({amount:o,metadata:a},r)=>t.jsx(Ei,{metadata:a,chain:n,children:i=>t.jsx(fc,{amount:o,asset:s(i)})},r))},k2=({events:e,chain:n})=>{const{initiaAddress:s,hexAddress:o}=Ue();return n.metadata?.is_l1||n.metadata?.minitia?.type==="minimove"?t.jsx(N2,{changes:$i(e,o),chain:n}):t.jsx(C2,{changes:Ti(e,s),chain:n})},I2="_message_1g2hc_1",A2="_more_1g2hc_8",Xa={message:I2,more:A2},S2=({messages:e})=>t.jsxs(t.Fragment,{children:[e.slice(0,3).map((n,s)=>t.jsx("p",{className:Xa.message,children:Ns.sentenceCase(n["@type"].split("Msg")[1])},s)),e.length>3&&t.jsx("footer",{className:Xa.more,children:`+${e.length-3} more`})]}),T2="_link_fuhbt_1",$2="_inner_fuhbt_16",E2="_header_fuhbt_21",M2="_time_fuhbt_30",L2="_error_fuhbt_36",q2="_timestamp_fuhbt_40",P2="_chainInfo_fuhbt_45",D2="_content_fuhbt_53",B2="_messages_fuhbt_61",R2="_changes_fuhbt_67",it={link:T2,inner:$2,header:E2,time:M2,error:L2,timestamp:q2,chainInfo:P2,content:D2,messages:B2,changes:R2},F2=({txItem:e,chain:n})=>t.jsx(Us,{txHash:e.txhash,chainId:n.chainId,className:it.link,children:t.jsxs("div",{className:it.inner,children:[t.jsxs("div",{className:it.header,children:[t.jsxs("div",{className:it.time,children:[e.code!==0&&t.jsx(S.IconWarningFilled,{size:14,className:it.error}),t.jsx("span",{className:it.timestamp,children:Re.format(new Date(e.timestamp),"h:mm a")})]}),t.jsxs("div",{className:it.chainInfo,children:[t.jsx(J,{src:n.logoUrl,width:12,height:12,logo:!0}),t.jsx("span",{children:n.name})]})]}),t.jsxs("div",{className:it.content,children:[t.jsx("div",{className:it.messages,children:t.jsx(S2,{messages:e.tx.body.messages})}),t.jsx("div",{className:it.changes,children:t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(k2,{...e,chain:n})})})]})]})}),U2="_list_1mv55_1",O2="_dateGroup_1mv55_7",V2="_dateHeader_1mv55_12",K2="_more_1mv55_18",ls={list:U2,dateGroup:O2,dateHeader:V2,more:K2},W2=({list:e,chainId:n})=>{const s=X(),o=x.useMemo(()=>Hi(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?t.jsx(he,{children:"No activity found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:ls.list,children:Object.entries(o).map(([a,r])=>t.jsxs("div",{className:ls.dateGroup,children:[t.jsx("div",{className:ls.dateHeader,children:a}),r.map(i=>t.jsx(me,{errorBoundaryProps:{fallback:null},children:t.jsx(F2,{txItem:i,chain:i.chain})},i.txhash))]},a))}),t.jsx(Us,{chainId:n,accountAddress:s,pathSuffix:"/txs",className:ls.more,showIcon:!0,children:"View more on Initia Scan"})]})},z2=()=>{const{activities:e,isLoading:n}=Gl(),[s,o]=U.useAtom(j2),a=re(),r=x.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=x.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return n&&e.length===0?t.jsx(he,{children:"Loading activities..."}):!e.length&&!n?t.jsx(he,{children:"No activity yet"}):t.jsxs(Je.Root,{children:[t.jsx(Je.Controls,{children:t.jsx(Hs,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),t.jsx(W2,{list:i,chainId:s||a.chainId})]})},H2="_thumbnail_1xyqw_1",G2="_placeholder_1xyqw_18",Q2="_clickable_1xyqw_24",bn={thumbnail:H2,placeholder:G2,clickable:Q2},Y2=({nftInfo:e,size:n,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=ee(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?t.jsx("button",{className:q(bn.thumbnail,bn.clickable),onClick:s,style:{width:n,height:n},children:t.jsx(J,{src:l,classNames:{placeholder:bn.placeholder}})}):t.jsx("div",{className:bn.thumbnail,style:{width:n,height:n},children:t.jsx(J,{src:l,classNames:{placeholder:bn.placeholder}})})},Z2="_collectionName_qs5tw_1",J2="_nftName_qs5tw_6",X2="_chainInfo_qs5tw_10",_o={collectionName:Z2,nftName:J2,chainInfo:X2},fa=({normalizedNft:e,onThumbnailClick:n,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return t.jsxs("div",{className:a?.root,children:[t.jsx(Y2,{nftInfo:e,onClick:n,size:s}),t.jsxs("div",{children:[t.jsx("div",{className:q(_o.collectionName,a?.collectionName),children:r}),t.jsx("div",{className:q(_o.nftName,a?.nftName),children:i}),t.jsxs("div",{className:q(_o.chainInfo,a?.chainInfo),children:[t.jsx(J,{src:c.logoUrl,width:o,height:o,logo:!0}),t.jsx("span",{children:c.name})]})]})]})},pa=ye.createQueryKeys("interwovenkit:nft",{nfts:(e,n)=>[e,n],metadata:e=>[e]});function e0(e,n){const{nft:s}=e,o=n.name??s.token_id;return{...e,...s,...n,name:o}}function t0(e,n){return e.flatMap((s,o)=>(n[o]??[]).map(r=>({...r,chain:s})))}const n0=()=>{const e=X(),n=de(),s=$.useQueries({queries:n.map(l=>({queryKey:pa.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Is(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map(T.prop("data")),a=t0(n,o),r=a.reduce((l,{chain:d})=>({...l,[d.chainId]:(l[d.chainId]||0)+1}),{}),i=Object.values(r).reduce((l,d)=>l+d,0),c=s.some(l=>l.isLoading);return{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}};function s0(e){const n=er(e);return $.useQuery({queryKey:pa.metadata(n).queryKey,queryFn:async()=>{try{if(!n)return{};const s=await z.get(n).json();return{...s,image:er(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function er(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const o0=({nftInfo:e,children:n})=>{const{data:s={}}=s0(e.nft.uri),o=e0(e,s);return n(o)},a0="_grid_1wwdn_1",r0="_root_1wwdn_7",i0="_collectionName_1wwdn_15",c0="_nftName_1wwdn_23",l0="_chainInfo_1wwdn_32",tr={grid:a0,root:r0,collectionName:i0,nftName:c0,chainInfo:l0},d0=()=>{const[e,n]=U.useAtom(x2),[s,o]=U.useAtom(y2),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=n0(),l=Ce(),d=x.useMemo(()=>a.filter(({collection_addr:u,collection_name:h,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return u.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||p.toLowerCase().includes(_)}return!0}),[a,s,e]),m=x.useMemo(()=>Array.from(new Set(a.map(({chain:u})=>u.chainId))),[a]);return c&&a.length===0?t.jsx(he,{children:"Loading NFTs..."}):!a.length&&!e&&!c?t.jsx(he,{children:"No NFTs"}):t.jsxs(Je.Root,{children:[t.jsxs(Je.Controls,{children:[t.jsx(Je.SearchInput,{value:e,onChange:u=>n(u.target.value),onClear:()=>n(""),placeholder:"Search NFTs"}),t.jsx(Hs,{value:s,onChange:o,chainIds:m,renderExtra:u=>u?r[u]||0:i})]}),d.length===0?t.jsx(he,{children:"No NFTs found"}):t.jsx("div",{className:tr.grid,children:d.map(u=>{const{collection_addr:h,nft:f}=u;return t.jsx(o0,{nftInfo:u,children:p=>t.jsx(fa,{normalizedNft:p,onThumbnailClick:()=>l("/nft",p),classNames:tr})},h+f.token_id)})})]})},pc=x.createContext(null);function gc(){return x.useContext(pc)}const u0="_popup_nbecp_1",m0="_item_nbecp_19",ds={popup:u0,item:m0},_c=({asset:e,children:n})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[m,u]=x.useState(!1),h=Ce(),f=gc(),{showNotification:p}=Os(),{defaultChainId:g}=ee(),{evm_chain_id:_}=Gt(),y=Ee.useChainId(),{switchChainAsync:j}=Ee.useSwitchChain(),{watchAssetAsync:b}=Ee.useWatchAsset(),w=()=>{u(!1),h("/send",{denom:s,chain:l})},C=()=>{u(!1),h("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},I=$.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const E=r;return await j({chainId:Number(_)}),b({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:E}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:E=>{p({type:"error",title:"Asset addition failed",description:E.message})}});return t.jsxs(gt.Menu.Root,{open:m,onOpenChange:u,modal:!1,children:[t.jsx(gt.Menu.Trigger,{render:n}),t.jsx(gt.Menu.Portal,{container:f,children:t.jsx(gt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:t.jsxs(gt.Menu.Popup,{className:ds.popup,children:[t.jsxs(gt.Menu.Item,{className:ds.item,onClick:w,children:[t.jsx(S.IconArrowRight,{size:16}),t.jsx("span",{children:"Send"})]}),t.jsxs(gt.Menu.Item,{className:ds.item,onClick:C,disabled:i,children:[t.jsx(S.IconSwap,{size:16}),t.jsx("span",{children:"Bridge/Swap"})]}),d===g&&_===y&&!!c&&t.jsxs(gt.Menu.Item,{className:ds.item,onClick:()=>I.mutate(),disabled:I.isPending||I.data,children:[I.data?t.jsx(S.IconCheck,{size:16}):t.jsx(S.IconPlus,{size:16}),t.jsx("span",{children:"Add to Wallet"})]})]})})})]})},h0="_item_38qhm_1",f0="_info_38qhm_23",p0="_images_38qhm_29",g0="_name_38qhm_33",_0="_value_38qhm_39",x0="_amount_38qhm_47",y0="_usd_38qhm_53",Dt={item:h0,info:f0,images:p0,name:g0,value:_0,amount:x0,usd:y0},j0=({asset:e})=>{const{amount:n,value:s,logoUrl:o,chain:a}=e,r=v.formatAmount(n,{decimals:e.decimals});return t.jsx(_c,{asset:e,children:t.jsxs("button",{className:Dt.item,children:[t.jsxs("div",{className:Dt.info,children:[t.jsx(Ks,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Dt.images}),t.jsx("span",{className:Dt.name,children:a.name})]}),t.jsxs("div",{className:Dt.value,children:[t.jsx("span",{className:Dt.amount,children:r}),Number(s)>0&&t.jsx("span",{className:Dt.usd,children:te(s)})]})]})})},w0="_container_ytg3p_1",b0="_assetItem_ytg3p_6",v0="_expandIcon_ytg3p_22",C0="_assetInfo_ytg3p_27",N0="_logo_ytg3p_33",k0="_details_ytg3p_37",I0="_symbol_ytg3p_42",A0="_chainName_ytg3p_53",S0="_chainInfos_ytg3p_59",T0="_chainLogos_ytg3p_65",$0="_chainLogo_ytg3p_65",E0="_moreChains_ytg3p_76",M0="_expanded_ytg3p_93",L0="_valueColumn_ytg3p_98",q0="_amount_ytg3p_108",P0="_value_ytg3p_98",D0="_collapsibleContent_ytg3p_121",B0="_chainsList_ytg3p_151",pe={container:w0,assetItem:b0,expandIcon:v0,assetInfo:C0,logo:N0,details:k0,symbol:I0,chainName:A0,chainInfos:S0,chainLogos:T0,chainLogo:$0,moreChains:E0,expanded:M0,valueColumn:L0,amount:q0,value:P0,collapsibleContent:D0,chainsList:B0},R0=U.atom([]),ga=({assetGroup:e})=>{const{symbol:n,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=U.useAtom(R0),c=x.useMemo(()=>ud(e),[e]),l=x.useMemo(()=>ci(e),[e]),d=r.includes(n),m=()=>{i(h=>d?h.filter(f=>f!==n):[...new Set([...h,n])])},u=()=>t.jsxs("button",{className:pe.assetItem,children:[t.jsxs("div",{className:pe.assetInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:pe.logo,logo:!0}),t.jsxs("div",{className:pe.details,children:[t.jsx("div",{className:pe.symbol,children:n}),a?t.jsx("div",{className:pe.chainName,children:o[0].chain.name}):t.jsxs("div",{className:pe.chainInfos,children:[t.jsx("div",{className:pe.chainLogos,children:o.slice(0,5).map(({chain:h})=>t.jsx(J,{src:h.logoUrl,width:16,height:16,className:pe.chainLogo,logo:!0},h.chainId))}),o.length>5&&t.jsxs("span",{className:pe.moreChains,children:["+",o.length-5]}),t.jsx(S.IconChevronDown,{size:16,className:q(pe.expandIcon,{[pe.expanded]:d})})]})]})]}),t.jsxs("div",{className:pe.valueColumn,children:[t.jsx("div",{className:pe.amount,children:v.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&t.jsx("div",{className:pe.value,children:te(l)})]})]});if(a){const[h]=o;return t.jsx("div",{className:pe.container,children:t.jsx(_c,{asset:h,children:u()})})}return t.jsx("div",{className:pe.container,children:t.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:u()}),t.jsx(Z.Collapsible.Content,{className:pe.collapsibleContent,children:t.jsx("div",{className:pe.chainsList,children:o.map(h=>t.jsx(j0,{asset:h},h.chain.chainId))})})]})})},F0="_collapsible_1g7rh_1",U0="_trigger_1g7rh_5",O0="_divider_1g7rh_20",V0="_label_1g7rh_28",K0="_chevron_1g7rh_33",W0="_content_1g7rh_41",z0="_list_1g7rh_45",It={collapsible:F0,trigger:U0,divider:O0,label:V0,chevron:K0,content:W0,list:z0},xc=({unlistedAssets:e})=>{const[n,s]=x.useState(!1),o=gc(),a=x.useRef(null),[r,i]=x.useState(0);x.useEffect(()=>{if(a.current){const u=a.current.scrollHeight;i(u)}},[e]);const c=x.useRef(null),l=u=>{s(u),u&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),p=c.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const y=p.top-f.top+h.scrollTop-16;h.scrollTo({top:y,behavior:"smooth"})}},50)},d=lt.useSpring({height:n?r:0,opacity:n?1:0,config:{tension:500,friction:30,clamp:!0}}),m=x.useMemo(()=>e.map(u=>({...u,assets:[u],totalValue:u.value??0,totalAmount:Number(u.quantity)})),[e]);return e.length===0?null:t.jsxs(Z.Collapsible.Root,{open:n,onOpenChange:l,className:It.collapsible,children:[t.jsxs(Z.Collapsible.Trigger,{ref:c,className:It.trigger,children:[t.jsx("div",{className:It.divider}),t.jsxs("span",{className:It.label,children:["Unlisted assets (",e.length,")"]}),t.jsx(S.IconChevronDown,{className:It.chevron,size:12,"data-state":n?"open":"closed"}),t.jsx("div",{className:It.divider})]}),t.jsx(Z.Collapsible.Content,{forceMount:!0,asChild:!0,children:t.jsx(lt.animated.div,{className:It.content,style:d,children:t.jsx("div",{className:It.list,ref:a,children:m.map(u=>t.jsx(ga,{assetGroup:u},u.assets[0].denom))})})})]})},H0="_container_15xfg_1",G0="_header_15xfg_7",Q0="_title_15xfg_13",Y0="_totalValue_15xfg_19",Z0="_list_15xfg_26",rn={container:H0,header:G0,title:Q0,totalValue:Y0,list:Z0},J0=()=>{const[e,n]=U.useAtom(mc),[s,o]=U.useAtom(hc),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=Go(),d=i.map(({chainId:h})=>h),m=x.useMemo(()=>{const h=e?a.filter(p=>{const{symbol:g,assets:_}=p;return g.toLowerCase().includes(e.toLowerCase())||_.some(({denom:y,address:j})=>y.toLowerCase().includes(e.toLowerCase())||j?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(p=>({...p,assets:p.assets.filter(({chain:g})=>g.chainId===s)})).filter(p=>p.assets.length>0):h},[a,e,s]),u=x.useMemo(()=>{const h=e?r.filter(({denom:p,address:g})=>p.toLowerCase().includes(e.toLowerCase())||g?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:p})=>p.chainId===s):h},[r,e,s]);return l&&a.length===0?t.jsx(he,{children:"Loading assets..."}):!m.length&&!u.length&&!e&&!s&&!l?t.jsx(he,{children:"No assets"}):t.jsxs(Je.Root,{children:[t.jsxs(Je.Controls,{children:[t.jsx(Je.SearchInput,{value:e,onChange:h=>n(h.target.value),onClear:()=>n(""),placeholder:"Search assets"}),t.jsx(Hs,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return te(c);const f=i.find(p=>p.chainId===h);return f?te(f.value):null}})]}),t.jsx("div",{children:m.length===0&&u.length===0?t.jsx(he,{children:"No assets found"}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:rn.list,children:m.map(h=>t.jsx(ga,{assetGroup:h},h.symbol))}),t.jsx(xc,{unlistedAssets:u})]})})]})},X0="_container_11k2x_1",ej={container:X0},Ze=({height:e,length:n=1,width:s="100%"})=>{const o=Array.from({length:n},(a,r)=>r);return n===1?t.jsx(Kt,{height:e,width:s}):t.jsx("div",{className:ej.container,children:o.map(a=>t.jsx(Kt,{height:e,width:s},a))})},tj=x.memo(({searchQuery:e,selectedChain:n,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=Un(),l=re(),{listedGroups:d,unlistedAssets:m}=x.useMemo(()=>Yd(i,a,r,l.chainId),[i,a,r,l.chainId]),u=x.useMemo(()=>zd(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:p}=x.useMemo(()=>Qd(u,m,e,n),[u,m,e,n]);return t.jsxs("div",{className:rn.container,children:[t.jsxs("div",{className:rn.header,children:[t.jsx("span",{className:rn.title,children:"Assets"}),h.length>0&&t.jsx("span",{className:rn.totalValue,children:te(f)})]}),h.length>0?t.jsxs("div",{children:[t.jsx("div",{className:rn.list,children:h.map(g=>t.jsx(ga,{assetGroup:g},g.symbol))}),t.jsx(xc,{unlistedAssets:p})]}):u.length===0&&c?t.jsx(Ze,{height:56,length:3}):t.jsx(he,{children:"No liquid assets"})]})}),nj=ye.createQueryKeys("interwovenkit:civitia",{player:(e,n)=>[e,n]});function yc(){const{civitiaUrl:e}=ee(),n=X();return $.useQuery({enabled:!!n,queryKey:nj.player(e,n??"").queryKey,queryFn:async()=>{if(!n)throw new Error("address is not available");return z.get(`${e}/players/${n}`).json()},staleTime:K.MINUTE,throwOnError:!1})}const sj="_section_xdyfz_2",oj="_row_xdyfz_15",aj="_rowLeft_xdyfz_23",rj="_rowIcon_xdyfz_29",ij="_goldIcon_xdyfz_38",cj="_silverIcon_xdyfz_46",lj="_rowTitle_xdyfz_54",dj="_rowValue_xdyfz_60",uj="_rowSubtitle_xdyfz_67",Ne={section:sj,row:oj,rowLeft:aj,rowIcon:rj,goldIcon:ij,silverIcon:cj,rowTitle:lj,rowValue:dj,rowSubtitle:uj},mj=()=>{const{data:e,isLoading:n}=yc();if(n)return t.jsx(Ze,{height:36,length:2});const s=e?.gold_balance??0,o=e?.silver_balance??0;return t.jsxs("div",{className:Ne.section,children:[t.jsxs("div",{className:Ne.row,children:[t.jsxs("div",{className:Ne.rowLeft,children:[t.jsx("div",{className:q(Ne.rowIcon,Ne.goldIcon)}),t.jsx("span",{className:Ne.rowTitle,children:"Gold"})]}),t.jsx("span",{className:q(Ne.rowValue,s===0&&Ne.rowSubtitle),children:s===0?"—":v.formatNumber(s,{dp:6})})]}),t.jsxs("div",{className:Ne.row,children:[t.jsxs("div",{className:Ne.rowLeft,children:[t.jsx("div",{className:q(Ne.rowIcon,Ne.silverIcon)}),t.jsx("span",{className:Ne.rowTitle,children:"Silver"})]}),t.jsx("span",{className:q(Ne.rowValue,o===0&&Ne.rowSubtitle),children:o===0?"—":v.formatNumber(o,{dp:6})})]})]})},hj="_container_1n61l_1",fj="_section_1n61l_7",pj="_sectionHeader_1n61l_19",gj="_sectionTitle_1n61l_25",_j="_sectionLabel_1n61l_31",xj="_externalLink_1n61l_37",yj="_sectionValue_1n61l_49",jj="_tokenList_1n61l_56",wj="_stakingTokenList_1n61l_62",bj="_tokenRow_1n61l_72",vj="_tokenMain_1n61l_78",Cj="_tokenTrigger_1n61l_84",Nj="_tokenChevron_1n61l_100",kj="_expanded_1n61l_111",Ij="_triggerValue_1n61l_115",Aj="_tokenInfo_1n61l_122",Sj="_tokenInfoLabel_1n61l_128",Tj="_tokenLogo_1n61l_134",$j="_tokenSymbol_1n61l_138",Ej="_tokenValues_1n61l_144",Mj="_tokenAmount_1n61l_150",Lj="_tokenValue_1n61l_144",qj="_typeBreakdown_1n61l_164",Pj="_typeRow_1n61l_172",Dj="_typeLabel_1n61l_180",Bj="_typeValues_1n61l_186",Rj="_typeAmount_1n61l_192",Fj="_typeValue_1n61l_186",Uj="_collapsibleContent_1n61l_206",Y={container:hj,section:fj,sectionHeader:pj,sectionTitle:gj,sectionLabel:_j,externalLink:xj,sectionValue:yj,tokenList:jj,stakingTokenList:wj,tokenRow:bj,tokenMain:vj,tokenTrigger:Cj,tokenChevron:Nj,expanded:kj,triggerValue:Ij,tokenInfo:Aj,tokenInfoLabel:Sj,tokenLogo:Tj,tokenSymbol:$j,tokenValues:Ej,tokenAmount:Mj,tokenValue:Lj,typeBreakdown:qj,typeRow:Pj,typeLabel:Dj,typeValues:Bj,typeAmount:Rj,typeValue:Fj,collapsibleContent:Uj},jc=({protocols:e,denomLogoMap:n,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=x.useMemo(()=>{const c=e.flatMap(l=>l.positions);return Pd(c)},[e]);return i.size===0?null:t.jsx("div",{className:Y.container,children:Array.from(i.entries()).map(([c,l])=>t.jsx(Oj,{sectionKey:c,sectionGroup:l,denomLogoMap:n,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Oj=({sectionKey:e,sectionGroup:n,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=n,d=qd(e,o),m=x.useMemo(()=>Vd(c),[c]),u=e==="staking";return t.jsxs("div",{className:Y.section,children:[t.jsxs("div",{className:Y.sectionHeader,children:[t.jsxs("div",{className:Y.sectionTitle,children:[t.jsx("span",{className:Y.sectionLabel,children:d}),u&&a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Y.externalLink,onClick:h=>h.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:Y.sectionValue,children:te(l)})]}),t.jsx("div",{className:q(Y.tokenList,{[Y.stakingTokenList]:u}),children:m.map(h=>t.jsx(Vj,{group:h,showTypeBreakdown:u,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},Vj=({group:e,showTypeBreakdown:n,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,m=s.get(r),[u,h]=x.useState(!1),f=x.useMemo(()=>{if(!n)return null;const p=Ud(d);return p.size>0?p:null},[d,n]);return f?t.jsxs(Z.Collapsible.Root,{open:u,onOpenChange:h,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Y.tokenTrigger,children:[t.jsxs("div",{className:Y.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(Y.tokenChevron,{[Y.expanded]:u})}),t.jsxs("div",{className:Y.tokenInfoLabel,children:[m?.assetLogo&&t.jsx(J,{src:m.assetLogo,width:20,height:20,className:Y.tokenLogo}),t.jsx("span",{className:Y.tokenSymbol,children:i})]})]}),t.jsx("span",{className:Y.triggerValue,children:te(l)})]})}),t.jsx(Z.Collapsible.Content,{className:Y.collapsibleContent,children:t.jsx(Kj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):t.jsx("div",{className:Y.tokenRow,children:t.jsxs("div",{className:Y.tokenMain,children:[t.jsxs("div",{className:Y.tokenInfo,children:[m?.assetLogo&&t.jsx(J,{src:m.assetLogo,width:20,height:20,className:Y.tokenLogo}),t.jsx("span",{className:Y.tokenSymbol,children:i})]}),t.jsxs("div",{className:Y.tokenValues,children:[t.jsx("span",{className:Y.tokenAmount,children:v.formatNumber(c,{dp:6})}),t.jsx("span",{className:Y.tokenValue,children:te(l)})]})]})})},Kj=({typeGroups:e,symbol:n,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=x.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const m=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),u=d.reduce((h,f)=>h+ln(f),0);return{type:l,typeAmount:m,typeValue:u}}),[e]),i=x.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const m=o(s,d);l+=Number(m)}return l},[s,o,r]),c=i>0;return t.jsxs("div",{className:Y.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:m})=>t.jsxs("div",{className:Y.typeRow,children:[t.jsx("span",{className:Y.typeLabel,children:Fd(l)}),t.jsxs("div",{className:Y.typeValues,children:[t.jsxs("span",{className:Y.typeAmount,children:[v.formatNumber(d,{dp:6})," ",n]}),t.jsx("span",{className:Y.typeValue,children:te(m)})]})]},l)),c&&t.jsxs("div",{className:Y.typeRow,children:[t.jsx("span",{className:Y.typeLabel,children:"Claimable"}),t.jsxs("div",{className:Y.typeValues,children:[t.jsxs("span",{className:Y.typeAmount,children:[v.formatNumber(i,{dp:6})," ",Ye]}),t.jsx("span",{className:Y.typeValue,children:te(i*(a??0))})]})]})]})},Wj="_container_ymkoc_1",zj="_trigger_ymkoc_6",Hj="_expandIcon_ymkoc_22",Gj="_chainInfo_ymkoc_27",Qj="_logo_ymkoc_33",Yj="_chainNameContainer_ymkoc_37",Zj="_chainName_ymkoc_37",Jj="_externalLink_ymkoc_49",Xj="_externalIcon_ymkoc_53",ew="_valueColumn_ymkoc_63",tw="_value_ymkoc_63",nw="_expanded_ymkoc_80",sw="_collapsibleContent_ymkoc_85",ow="_content_ymkoc_97",Se={container:Wj,trigger:zj,expandIcon:Hj,chainInfo:Gj,logo:Qj,chainNameContainer:Yj,chainName:Zj,externalLink:Jj,externalIcon:Xj,valueColumn:ew,value:tw,expanded:nw,collapsibleContent:sw,content:ow},aw=U.atom([]),rw=({chainGroup:e})=>{const{chainId:n,chainLogo:s,protocols:o}=e,a=de(),r=Ln(),{denomLogos:i,symbolLogos:c}=x.useMemo(()=>ta(r,a),[r,a]),l=x.useMemo(()=>{const d=new Map;for(const m of o)for(const u of m.positions){if(u.type==="fungible-position"||u.balance.type==="unknown")continue;const{denom:h,symbol:f}=u.balance,p=f.toUpperCase(),g=`${n}:${h}`,_=i.get(g)??c.get(p);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,n,s]);return t.jsx(jc,{protocols:o,denomLogoMap:l})},iw=({chainGroup:e})=>{const{chainName:n,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=U.useAtom(aw),c=x.useMemo(()=>o.reduce((p,g)=>p+g.positions.reduce((_,y)=>_+ln(y),0),0),[o]),l=["civitia","yominet"],d=r.includes(n),m=n?.toLowerCase(),u=m==="civitia",h=l.includes(m),f=()=>{i(p=>d?p.filter(g=>g!==n):[...new Set([...p,n])])};return t.jsx("div",{className:Se.container,children:t.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:f,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Se.trigger,children:[t.jsxs("div",{className:Se.chainInfo,children:[s&&t.jsx(J,{src:s,width:32,height:32,className:Se.logo,logo:!0}),t.jsxs("div",{className:Se.chainNameContainer,children:[t.jsx("span",{className:Se.chainName,children:n}),a&&t.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Se.externalLink,onClick:p=>p.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Se.externalIcon})})]})]}),t.jsxs("div",{className:Se.valueColumn,children:[!h&&t.jsx("span",{className:Se.value,children:te(c)}),t.jsx(S.IconChevronDown,{size:16,className:q(Se.expandIcon,{[Se.expanded]:d})})]})]})}),t.jsx(Z.Collapsible.Content,{className:Se.collapsibleContent,children:t.jsxs("div",{className:Se.content,children:[t.jsx(rw,{chainGroup:e}),u&&t.jsx(mj,{})]})})]})})},cw="_container_1gqx9_1",lw="_section_1gqx9_6",dw="_sectionHeader_1gqx9_14",uw="_sectionTitle_1gqx9_20",mw="_sectionLabel_1gqx9_26",hw="_externalLink_1gqx9_32",fw="_sectionValue_1gqx9_44",pw="_tokenList_1gqx9_51",gw="_tokenTrigger_1gqx9_63",_w="_tokenChevron_1gqx9_79",xw="_expanded_1gqx9_90",yw="_tokenInfo_1gqx9_94",jw="_tokenInfoLabel_1gqx9_100",ww="_tokenLogo_1gqx9_106",bw="_pairedLogos_1gqx9_110",vw="_coinLogo_1gqx9_115",Cw="_tokenSymbol_1gqx9_133",Nw="_triggerValue_1gqx9_139",kw="_breakdownContent_1gqx9_146",Iw="_breakdownRow_1gqx9_154",Aw="_breakdownLabel_1gqx9_162",Sw="_breakdownValues_1gqx9_168",Tw="_breakdownAmount_1gqx9_174",$w="_breakdownValue_1gqx9_168",Ew="_collapsibleContent_1gqx9_195",oe={container:cw,section:lw,sectionHeader:dw,sectionTitle:uw,sectionLabel:mw,externalLink:hw,sectionValue:fw,tokenList:pw,tokenTrigger:gw,tokenChevron:_w,expanded:xw,tokenInfo:yw,tokenInfoLabel:jw,tokenLogo:ww,pairedLogos:bw,coinLogo:vw,tokenSymbol:Cw,triggerValue:Nw,breakdownContent:kw,breakdownRow:Iw,breakdownLabel:Aw,breakdownValues:Sw,breakdownAmount:Tw,breakdownValue:$w,collapsibleContent:Ew},Mw=({data:e,denomLogoMap:n})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:t.jsx("div",{className:oe.container,children:t.jsxs("div",{className:oe.section,children:[t.jsxs("div",{className:oe.sectionHeader,children:[t.jsxs("div",{className:oe.sectionTitle,children:[t.jsx("span",{className:oe.sectionLabel,children:"Liquidity"}),t.jsx("a",{href:Oo,target:"_blank",rel:"noopener noreferrer",className:oe.externalLink,onClick:a=>a.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:oe.sectionValue,children:te(s)})]}),t.jsx("div",{className:oe.tokenList,children:o.map(a=>t.jsx(qw,{row:a,denomLogoMap:n},a.denom))})]})})},Lw={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"},qw=({row:e,denomLogoMap:n})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,m]=x.useState(!1),u=n.get(s),h=i||u?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=x.useMemo(()=>Object.entries(r).filter(([,y])=>y>0),[r]),g=c&&c.length>0&&c.some(y=>y),_=l&&Number(l.total)>0;return t.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:oe.tokenTrigger,children:[t.jsxs("div",{className:oe.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(oe.tokenChevron,{[oe.expanded]:d})}),t.jsxs("div",{className:oe.tokenInfoLabel,children:[g?t.jsx("div",{className:oe.pairedLogos,children:c.map((y,j)=>t.jsx(J,{src:y,width:20,height:20,className:oe.coinLogo,logo:!0},j))}):h&&t.jsx(J,{src:h,width:20,height:20,className:oe.tokenLogo}),t.jsx("span",{className:oe.tokenSymbol,children:o})]})]}),t.jsx("span",{className:oe.triggerValue,children:te(a)})]})}),t.jsx(Z.Collapsible.Content,{className:oe.collapsibleContent,children:t.jsxs("div",{className:oe.breakdownContent,children:[p.map(([y,j])=>{const b=j*f;return t.jsxs("div",{className:oe.breakdownRow,children:[t.jsx("span",{className:oe.breakdownLabel,children:Lw[y]}),t.jsxs("div",{className:oe.breakdownValues,children:[t.jsxs("span",{className:oe.breakdownAmount,children:[v.formatNumber(j,{dp:6})," LP"]}),t.jsx("span",{className:oe.breakdownValue,children:te(b)})]})]},y)}),_&&t.jsxs("div",{className:oe.breakdownRow,children:[t.jsx("span",{className:oe.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:oe.breakdownValues,children:[t.jsxs("span",{className:oe.breakdownAmount,children:[v.formatNumber(Number(l.total),{dp:6})," ",Ye]}),t.jsx("span",{className:oe.breakdownValue,children:te(l.totalValue)})]})]})]})})]})},Pw="_container_1nijk_1",Dw="_section_1nijk_6",Bw="_sectionHeader_1nijk_14",Rw="_sectionTitle_1nijk_20",Fw="_sectionLabel_1nijk_26",Uw="_externalLink_1nijk_32",Ow="_sectionValue_1nijk_44",Vw="_tokenList_1nijk_51",Kw="_tokenTrigger_1nijk_63",Ww="_tokenChevron_1nijk_79",zw="_expanded_1nijk_90",Hw="_tokenInfo_1nijk_94",Gw="_tokenInfoLabel_1nijk_100",Qw="_tokenLogo_1nijk_106",Yw="_tokenName_1nijk_110",Zw="_triggerValue_1nijk_116",Jw="_breakdownContent_1nijk_123",Xw="_breakdownRow_1nijk_131",eb="_breakdownLabel_1nijk_139",tb="_breakdownValues_1nijk_145",nb="_breakdownAmount_1nijk_151",sb="_breakdownValue_1nijk_145",ob="_collapsibleContent_1nijk_165",ce={container:Pw,section:Dw,sectionHeader:Bw,sectionTitle:Rw,sectionLabel:Fw,externalLink:Uw,sectionValue:Ow,tokenList:Vw,tokenTrigger:Kw,tokenChevron:Ww,expanded:zw,tokenInfo:Hw,tokenInfoLabel:Gw,tokenLogo:Qw,tokenName:Yw,triggerValue:Zw,breakdownContent:Jw,breakdownRow:Xw,breakdownLabel:eb,breakdownValues:tb,breakdownAmount:nb,breakdownValue:sb,collapsibleContent:ob},ab=({data:e})=>{const{totalValue:n,rows:s}=e;return s.length===0?null:t.jsx("div",{className:ce.container,children:t.jsxs("div",{className:ce.section,children:[t.jsxs("div",{className:ce.sectionHeader,children:[t.jsxs("div",{className:ce.sectionTitle,children:[t.jsx("span",{className:ce.sectionLabel,children:"VIP"}),t.jsx("a",{href:jl,target:"_blank",rel:"noopener noreferrer",className:ce.externalLink,onClick:o=>o.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12})})]}),t.jsx("span",{className:ce.sectionValue,children:te(n)})]}),t.jsx("div",{className:ce.tokenList,children:s.map(o=>t.jsx(rb,{row:o},`${o.bridgeId}-${o.version}`))})]})})},rb=({row:e})=>{const{name:n,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=x.useState(!1),d=a+i;return t.jsxs(Z.Collapsible.Root,{open:c,onOpenChange:l,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:ce.tokenTrigger,children:[t.jsxs("div",{className:ce.tokenInfo,children:[t.jsx(S.IconChevronDown,{size:14,className:q(ce.tokenChevron,{[ce.expanded]:c})}),t.jsxs("div",{className:ce.tokenInfoLabel,children:[s&&t.jsx(J,{src:s,width:20,height:20,className:ce.tokenLogo,logo:!0}),t.jsx("span",{className:ce.tokenName,children:n})]})]}),t.jsx("span",{className:ce.triggerValue,children:te(d)})]})}),t.jsx(Z.Collapsible.Content,{className:ce.collapsibleContent,children:t.jsxs("div",{className:ce.breakdownContent,children:[o>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Locked"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[v.formatNumber(o,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:te(a)})]})]}),r>0&&t.jsxs("div",{className:ce.breakdownRow,children:[t.jsx("span",{className:ce.breakdownLabel,children:"Claimable"}),t.jsxs("div",{className:ce.breakdownValues,children:[t.jsxs("span",{className:ce.breakdownAmount,children:[v.formatNumber(r,{dp:2})," INIT"]}),t.jsx("span",{className:ce.breakdownValue,children:te(i)})]})]})]})})]})},ib="_container_ymkoc_1",cb="_trigger_ymkoc_6",lb="_expandIcon_ymkoc_22",db="_chainInfo_ymkoc_27",ub="_logo_ymkoc_33",mb="_chainNameContainer_ymkoc_37",hb="_chainName_ymkoc_37",fb="_externalLink_ymkoc_49",pb="_externalIcon_ymkoc_53",gb="_valueColumn_ymkoc_63",_b="_value_ymkoc_63",xb="_expanded_ymkoc_80",yb="_collapsibleContent_ymkoc_85",jb="_content_ymkoc_97",Te={container:ib,trigger:cb,expandIcon:lb,chainInfo:db,logo:ub,chainNameContainer:mb,chainName:hb,externalLink:fb,externalIcon:pb,valueColumn:gb,value:_b,expanded:xb,collapsibleContent:yb,content:jb},wb=U.atom(!1),bb=()=>{const{totalValue:e}=Jo(),{totalValue:n}=ea(),{totalValue:s}=Bs(),o=e+n+s;return t.jsx("span",{className:Te.value,children:te(o)})},vb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Jo(),{data:i}=mi(),{data:c}=hi(),l=x.useMemo(()=>{const u=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:p}=h.balance,g=p.toUpperCase(),_=`${e}:${f}`,y=s.get(_)??o.get(g);y&&u.set(f,{assetLogo:y,chainLogo:n})}return u},[r,s,o,e,n]),d=x.useMemo(()=>(u,h)=>{const f=v.denomToMetadata(u);if(h==="staking"){const p=i?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:Be}):"0"}if(h==="lockstaking"){const p=c?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:Be}):"0"}return"0"},[i,c]),m=x.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:Oo,positions:r}],[r]);return m.length===0?null:t.jsx(jc,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},Cb=({chainId:e,chainLogo:n,denomLogos:s,symbolLogos:o})=>{const a=ea(),r=x.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,m=d.toUpperCase(),u=`${e}:${l}`,h=s.get(u)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:n})}return i},[a.rows,s,o,e,n]);return a.rows.length===0?null:t.jsx(Mw,{data:a,denomLogoMap:r})},Nb=()=>{const e=Bs();return e.rows.length===0?null:t.jsx(ab,{data:e})},kb=({chainGroup:e})=>{const{chainId:n,chainName:s,chainLogo:o}=e,[a,r]=U.useAtom(wb),i=de(),c=Ln(),{denomLogos:l,symbolLogos:d}=x.useMemo(()=>ta(c,i),[c,i]),m=re(),{data:u}=yt(m),h=x.useMemo(()=>u?.find(p=>p.id===Ie)?.price??0,[u]);return t.jsx("div",{className:Te.container,children:t.jsxs(Z.Collapsible.Root,{open:a,onOpenChange:r,children:[t.jsx(Z.Collapsible.Trigger,{asChild:!0,children:t.jsxs("button",{className:Te.trigger,children:[t.jsxs("div",{className:Te.chainInfo,children:[o&&t.jsx(J,{src:o,width:32,height:32,className:Te.logo,logo:!0}),t.jsxs("div",{className:Te.chainNameContainer,children:[t.jsx("span",{className:Te.chainName,children:s}),t.jsx("a",{href:Oo,target:"_blank",rel:"noopener noreferrer",className:Te.externalLink,onClick:f=>f.stopPropagation(),children:t.jsx(S.IconExternalLink,{size:12,className:Te.externalIcon})})]})]}),t.jsxs("div",{className:Te.valueColumn,children:[t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:16,width:60,length:1}),children:t.jsx(bb,{})}),t.jsx(S.IconChevronDown,{size:16,className:q(Te.expandIcon,{[Te.expanded]:a})})]})]})}),t.jsx(Z.Collapsible.Content,{className:Te.collapsibleContent,children:t.jsxs("div",{className:Te.content,children:[t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:36,length:2}),children:t.jsx(vb,{chainId:n,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:36,length:2}),children:t.jsx(Cb,{chainId:n,chainLogo:o,denomLogos:l,symbolLogos:d})}),t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:36,length:1}),children:t.jsx(Nb,{})})]})})]})})},Ib="_totalValue_1v2ca_1",Ab={totalValue:Ib},Sb=({filteredChainGroups:e})=>{const{totalValue:n}=Jo(),{totalValue:s}=ea(),{totalValue:o}=Bs(),a=n+s+o,r=x.useMemo(()=>{const i=e.some(l=>l.isInitia);return e.reduce((l,d)=>d.isInitia?l:l+d.totalValue,0)+(i?a:0)},[e,a]);return t.jsx("span",{className:Ab.totalValue,children:te(r)})},Tb="_container_1eubu_1",$b="_header_1eubu_7",Eb="_title_1eubu_13",Mb="_list_1eubu_19",Lb="_skeletonWrapper_1eubu_24",vn={container:Tb,header:$b,title:Eb,list:Mb,skeletonWrapper:Lb},qb=x.memo(({searchQuery:e,selectedChain:n,chainInfoMap:s})=>{const{positions:o,isLoading:a}=Un(),r=re(),{data:i,isLoading:c}=yc(),l=x.useMemo(()=>{const m=[];for(const h of o){if(!Array.isArray(h.positions))continue;const f=s.get(h.chainName.toLowerCase()),p=h.chainName.toLowerCase(),g=p==="civitia";if(n&&f?.chainId!==n)continue;const _=h.positions.some(C=>C.positions.some(I=>I.type!=="fungible-position")),y=g&&!c&&i&&((i.gold_balance??0)>0||(i.silver_balance??0)>0);if(!_&&!y||e&&!p.includes(e.toLowerCase()))continue;const j=h.positions.filter(C=>e&&!C.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(C.positions)&&C.positions.length>0),b=r.chainId===f?.chainId,w=j.reduce((C,I)=>C+I.positions.reduce((E,M)=>E+ln(M),0),0);m.push({chainId:f?.chainId??"",chainName:f?.prettyName??h.chainName,chainLogo:f?.logoUrl??"",protocols:j,isInitia:b,totalValue:w})}const u=["civitia","yominet"];return T.sortWith([T.descend(h=>h.isInitia??!1),T.ascend(h=>u.includes(h.chainName.toLowerCase())),T.descend(h=>h.totalValue??0),T.ascend(h=>h.chainName.toLowerCase())],m)},[o,s,e,n,r.chainId,i,c]),d=l.length>0;return t.jsxs("div",{className:vn.container,children:[t.jsxs("div",{className:vn.header,children:[t.jsx("span",{className:vn.title,children:"Positions"}),d&&t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:16,width:60,length:1}),children:t.jsx(Sb,{filteredChainGroups:l})})]}),d?t.jsx("div",{className:vn.list,children:l.map(m=>m.isInitia?t.jsx(me,{suspenseFallback:t.jsx("div",{className:vn.skeletonWrapper,children:t.jsx(Ze,{height:56,length:1})}),children:t.jsx(kb,{chainGroup:m})},m.chainName):t.jsx(iw,{chainGroup:m},m.chainName))}):o.length===0&&a?t.jsx(Ze,{height:56,length:3}):t.jsx(he,{children:"No positions"})]})}),Pb="_content_1w1ad_1",Db={content:Pb},Bb=({selectedChain:e,setSelectedChain:n})=>{const{defaultChainId:s}=ee(),o=re(),a=su(),{totalValue:r}=Bs(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=x.useMemo(()=>{const d=new Map;let m=0;for(const h of a)d.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),m+=r),{chainIds:T.sortWith([T.descend(h=>h===s),T.descend(h=>h===o.chainId),T.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:m}},[a,s,o,r]);return t.jsx(Hs,{value:e,onChange:n,chainIds:i,renderExtra:d=>te(d?c.get(d)??0:l)})},Rb=()=>{const[e,n]=U.useAtom(mc),[s,o]=U.useAtom(hc),a=de(),r=Ln(),{denomLogos:i,symbolLogos:c}=x.useMemo(()=>ta(r,a),[r,a]),l=Po(),d=x.useMemo(()=>xi(a,l),[a,l]),m=nu();return t.jsxs(Je.Root,{children:[t.jsxs(Je.Controls,{children:[t.jsx(Je.SearchInput,{value:e,onChange:u=>n(u.target.value),onClear:()=>n(""),placeholder:"Search portfolio"}),t.jsx(me,{suspenseFallback:t.jsx(Kt,{height:44,width:132}),children:t.jsx(Bb,{selectedChain:s,setSelectedChain:o})})]}),t.jsxs("div",{className:Db.content,children:[t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:48,length:5}),children:t.jsx(tj,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:d})}),t.jsx(me,{suspenseFallback:t.jsx(Ze,{height:56,length:3}),children:t.jsx(qb,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},Fb="_totalValue_5pf7e_1",Ub="_totalLabel_5pf7e_7",Ob="_totalAmount_5pf7e_13",Vb="_loading_5pf7e_18",Kb="_skeletonWrapper_5pf7e_23",Wb="_nav_5pf7e_28",zb="_item_5pf7e_34",Hb="_tabs_5pf7e_59",Gb="_tab_5pf7e_59",$e={totalValue:Fb,totalLabel:Ub,totalAmount:Ob,loading:Vb,skeletonWrapper:Kb,nav:Wb,item:zb,tabs:Hb,tab:Gb},Qb=()=>{const{totalValue:e,isLoading:n}=Go();return t.jsx("div",{className:q($e.totalAmount,{[$e.loading]:n}),children:te(e)})},Yb=()=>{const e=ou(),n=au(),s=_i(),o=e+s+n;return t.jsx("div",{className:$e.totalAmount,children:te(o)})},Zb=()=>{Ui(),eu();const e=na(),n=Ce(),s=Ts(),o=x.useRef(null);return t.jsx(pc.Provider,{value:o,children:t.jsxs(nt,{ref:o,children:[t.jsxs("div",{className:$e.totalValue,children:[t.jsx("div",{className:$e.totalLabel,children:"Total value"}),t.jsx(me,{suspenseFallback:t.jsx("div",{className:$e.skeletonWrapper,children:t.jsx(Kt,{height:48,width:120})}),children:e?t.jsx(Qb,{}):t.jsx(Yb,{})})]}),t.jsxs("div",{className:$e.nav,children:[t.jsxs(cn,{to:"/send",className:$e.item,children:[t.jsx(S.IconSend,{size:20}),t.jsx("span",{children:"Send"})]}),t.jsxs(cn,{to:"/bridge",className:$e.item,children:[t.jsx(S.IconBridge,{size:20}),t.jsx("span",{children:"Bridge/Swap"})]}),t.jsxs(cn,{to:"/receive",className:$e.item,children:[t.jsx(S.IconQrCode,{size:20}),t.jsx("span",{children:"Receive"})]})]}),t.jsxs(Ct.Tabs.Root,{value:s,onValueChange:n,children:[t.jsxs(Ct.Tabs.List,{className:$e.tabs,children:[t.jsx(Ct.Tabs.Tab,{className:$e.tab,value:"/",children:e?"Assets":"Portfolio"}),t.jsx(Ct.Tabs.Tab,{className:$e.tab,value:"/nfts",children:"NFTs"}),t.jsx(Ct.Tabs.Tab,{className:$e.tab,value:"/activity",children:"Activity"})]}),t.jsx(Ct.Tabs.Panel,{value:"/",children:e?t.jsx(J0,{}):t.jsx(Rb,{})}),t.jsx(Ct.Tabs.Panel,{value:"/nfts",children:t.jsx(d0,{})}),t.jsx(Ct.Tabs.Panel,{value:"/activity",children:t.jsx(z2,{})})]})]})})},Jb="_root_th990_1",Xb="_collectionName_th990_9",ev="_nftName_th990_13",tv="_chainInfo_th990_17",nv="_attributes_th990_21",sv="_title_th990_24",ov="_count_th990_29",av="_item_th990_33",rv="_type_th990_39",iv="_value_th990_45",Bt={root:Jb,collectionName:Xb,nftName:ev,chainInfo:tv,attributes:nv,title:sv,count:ov,item:av,type:rv,value:iv},cv=()=>{const e=Ce(),n=et(),{attributes:s}=n;return t.jsxs(ht,{title:"NFT details",children:[t.jsx(fa,{normalizedNft:n,chainIconSize:14,classNames:Bt}),t.jsx(xe,{children:t.jsx(le.White,{onClick:()=>e("/nft/send",n),sm:!0,children:"Send"})}),s&&t.jsxs("div",{className:Bt.attributes,children:[t.jsxs("header",{className:Bt.title,children:["Traits ",t.jsxs("span",{className:Bt.count,children:["(",s.length,")"]})]}),t.jsx("div",{children:s.map(({trait_type:o,value:a})=>t.jsxs("div",{className:Bt.item,children:[t.jsx("div",{className:Bt.type,children:o}),t.jsx("div",{className:Bt.value,children:a})]},o))})]})]})};function lv({balances:e,gasPrices:n,gas:s}){return n.map(({denom:o,amount:a})=>{const r=B(a).times(s).toFixed(0,B.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>B(a).gte(o))}function dv({denom:e,balances:n,gasPrices:s,lastFeeDenom:o,gas:a}){const r=n.find(d=>d.denom===e)?.amount??"0",i=lv({balances:n,gasPrices:s,gas:a}),c=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&c){const d=B(r).minus(c.amount);return B.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=B(r).minus(l.amount);return B.max(d,0).toString()}return B(r).toString()}const uv=({chain:e,onSelect:n})=>{const s=Hc(e);return t.jsx(Hn,{assets:s,onSelect:n})},mv=({afterSelect:e})=>{const{watch:n,setValue:s}=_e.useFormContext(),{chainId:o,denom:a}=n(),{chainId:r}=n(),[i,c]=x.useState(r),l=Xe(i),d=de(),m=u=>{if(o===i&&a===u){e();return}s("chainId",i),s("denom",u),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return t.jsxs(t.Fragment,{children:[t.jsx(Vt.Stack,{children:t.jsx(Vt,{chains:d,value:i,onSelect:c})}),t.jsx(me,{suspenseFallback:t.jsx(Hn.Placeholder,{}),children:t.jsx(uv,{chain:l,onSelect:m})},i)]})},hv="_fields_brpej_1",fv="_divider_brpej_11",nr={fields:hv,divider:fv},pv=ye.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),gv=()=>{const{address:e,initiaAddress:n,estimateGas:s,requestTxSync:o}=Ue(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=_e.useFormContext(),{errors:d}=l,{chainId:m,denom:u,recipient:h,quantity:f,memo:p}=r(),g=Xe(m),_=qn(g),y=zo(g),j=Ho(g),b=gr(u,g),{data:w}=yt(g),{decimals:C}=b,I=_.find(F=>F.denom===u)?.amount??"0",E=w?.find(({id:F})=>F===u)?.price,{data:M=0,isLoading:A}=$.useQuery({queryKey:pv.gas({chainId:m,denom:u,recipient:h,initiaAddress:n}).queryKey,queryFn:()=>{const F=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:va.MsgSend.fromPartial({fromAddress:n,toAddress:v.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return s({messages:F,chainId:m})},enabled:v.InitiaAddress.validate(h),staleTime:K.INFINITY}),L=Math.ceil(M*zt),N=dv({denom:u,balances:_,gasPrices:y,lastFeeDenom:j,gas:L}),k=B(I).isZero(),R=y.some(({denom:F})=>F===u)&&A,O=k||R,{mutate:V,isPending:H}=$.useMutation({mutationFn:({chainId:F,denom:W,quantity:qe,recipient:we,memo:st})=>{const Oe=v.toBaseUnit(qe,{decimals:C}),Zt=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:va.MsgSend.fromPartial({fromAddress:n,toAddress:v.InitiaAddress(we).bech32,amount:[{denom:W,amount:Oe}]})}];return o({messages:Zt,memo:st,chainId:F,gas:M,gasAdjustment:zt,gasPrices:y,spendCoins:[{denom:W,amount:Oe}],internal:"/"})}}),Q=x.useMemo(()=>{if(!f)return"Enter amount";if(d.quantity)return d.quantity.message;if(!h)return"Enter recipient address";if(d.recipient)return d.recipient.message;if(d.memo)return d.memo.message},[f,h,d.quantity,d.recipient,d.memo]);return t.jsx(ht,{title:"Send",children:t.jsxs("form",{onSubmit:c(F=>V(F)),children:[t.jsxs("div",{className:nr.fields,children:[t.jsx(Co,{selectButton:t.jsx(dn,{title:"Select chain and asset",content:F=>t.jsx(mv,{afterSelect:F}),children:t.jsx(Wi,{asset:b,chain:g})}),quantityInput:t.jsx(En,{balance:I,decimals:C}),balanceButton:t.jsx(Oi,{onClick:()=>i("quantity",v.fromBaseUnit(N,{decimals:C}),{shouldValidate:!0}),disabled:O,children:v.formatAmount(I??"0",{decimals:C})}),value:f?E?te(B(f).times(E)):"$-":"$0"}),t.jsx("div",{className:nr.divider}),t.jsx(ra,{myAddress:e}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),t.jsx("input",{...a("memo",{validate:F=>!F||new Blob([F]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),t.jsx(fe.Stack,{children:!p&&t.jsx(fe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),t.jsx(xe,{children:t.jsx(le.White,{type:"submit",loading:(A?"Estimating gas...":!1)||H,disabled:!!Q,children:Q??"Confirm"})})]})})},_v=()=>{const e=et(),n=Gt(),s=xt(n),{chain:o=n}=e,a=T.head(s);if(!e.denom&&!a)throw new Error("Asset list not found. This occurs during local development when asset list is not configured. Use asset-specific send buttons instead of the default send button, or register chain in Initia Registry with at least one asset defined.");const r=e.denom??a?.denom,i=_e.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return t.jsx(_e.FormProvider,{...i,children:t.jsx(gv,{})})};async function $o(e,n){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:n}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function xv(e,n){const s=new ct.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:n}).post("minievm/evm/v1/call",{json:{sender:v.InitiaAddress("0x1").bech32,contract_addr:v.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function yv(e,n,s){if(n.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${n}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function jv({collection_addr:e},{restUrl:n}){const s=await xv(e,n);if(!s.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await $o(s,n);return o?{class_id:s,class_trace:o}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function wv(e,n){const{data:s}=await z.create({prefixUrl:n}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function bv({object_addr:e,collection_addr:n},{restUrl:s}){const o=await wv(n,s);return o.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",o),n)?{class_id:o,class_trace:await $o(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await $o(o,s)}:{class_id:`move/${n.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function vv(e,n){const s=se.toBase64(Ft.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function Cv(e,n){const{collection:s}=await z.create({prefixUrl:n}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function Nv(e,n){const s=se.toBase64(Ft.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:n}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function sr(e){const n=/^(.*channel-\d+)\/(.*)$/,s=e.match(n);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function kv({collection_addr:e},n,s){const o=v.InitiaAddress(e).bech32,a=await vv(o,n.restUrl),r=n.metadata?.ibc_channels?.find(({chain_id:g,version:_})=>g===s.chain_id&&_.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=se.toBase64(Ft.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:n.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=d??o,u=await Nv(c,n.restUrl),h=await Cv(o,n.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:u};if(d&&h!==i.replace("wasm.","")){const[g,_]=sr(d);return{class_id:o,class_trace:{path:g,base_class_id:_},outgoing_proxy:u}}const[f,p]=sr(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:u}}const Iv={minimove:bv,minievm:jv,miniwasm:kv};async function Av({nft:e,srcChain:n,intermediaryChain:s}){const o=n.metadata?.is_l1?"minimove":n.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await Iv[o](e,n,s);return Object.assign(a,o==="minievm"&&{token_ids:await yv([e.token_id],a.class_id,n.restUrl)})}const Sv="_root_1tyvn_1",Tv="_collectionName_1tyvn_10",$v="_nftName_1tyvn_15",Ev="_chainInfo_1tyvn_19",Mv="_fields_1tyvn_24",Lv="_chain_1tyvn_19",xo={root:Sv,collectionName:Tv,nftName:$v,chainInfo:Ev,fields:Mv,chain:Lv},qv=ye.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),Pv=()=>{const e=de(),n=et(),{chain:s,collection_addr:o}=n,{routerApiUrl:a}=ee(),r=Bn(),i=re(),{address:c,initiaAddress:l,requestTxSync:d}=Ue(),{watch:m,setValue:u,handleSubmit:h,formState:f}=_e.useFormContext(),{errors:p}=f,g=m(),{recipient:_,dstChainId:y}=g,j=Xe(y),b=$.useQuery({queryKey:qv.simulation({collection_addr:o,nft:n,sender:l,recipient:_,srcChain:s,dstChain:j,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:v.InitiaAddress(_).bech32,to_chain_id:j.chainId,collection_address:o,token_ids:[n.token_id],object_addresses:[n.object_addr]},s.chainId!==j.chainId&&await Av({nft:n,srcChain:s,intermediaryChain:i})),{msgs:k}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return k.map(P=>r.fromAmino(P))},enabled:v.InitiaAddress.validate(_)}),{data:w,isLoading:C,error:I}=b,E=$.useQueryClient(),{mutate:M,isPending:A}=$.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{E.invalidateQueries({queryKey:pa.nfts._def})}}),L=x.useMemo(()=>{if(!_)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(I)return"Route not found"},[_,p.recipient,I]);return t.jsxs("form",{onSubmit:h(()=>M()),children:[t.jsx(fa,{normalizedNft:n,thumbnailSize:80,classNames:xo}),t.jsxs("div",{className:xo.fields,children:[t.jsxs("div",{children:[t.jsx("div",{className:"label",children:"Destination appchain"}),t.jsxs(dn,{title:"Destination appchain",content:N=>t.jsx(Ki,{onSelect:({chainId:k})=>{u("dstChainId",k),N()},list:e,getImage:k=>k.logoUrl,getName:k=>k.name,getKey:k=>k.chainId}),className:q("input",xo.chain),children:[t.jsx(J,{src:j.logoUrl,width:20,height:20,logo:!0}),t.jsx("span",{children:j.name})]})]}),t.jsx(ra,{myAddress:c,ref:Kn()})]}),t.jsx(xe,{children:t.jsx(le.White,{loading:(C?"Finding route...":!1)||A,disabled:!!L,children:L??"Confirm"})})]})},Dv=()=>{const{chain:e}=et(),n=_e.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return t.jsx(ht,{title:"Send NFT",children:t.jsx(_e.FormProvider,{...n,children:t.jsx(Pv,{})})})},Eo=()=>{const e=Ce(),n=Ts(),s=At(),{closeDrawer:o}=jt(),{closeModal:a}=qs();x.useEffect(()=>{a(),n.startsWith("/bridge/")&&n!=="/bridge/history"&&e("/bridge"),(n==="/collection"||n.startsWith("/nft"))&&e("/nfts")},[s]);const r=un();if(x.useEffect(()=>{r("Page View")},[n,r]),n==="/connect")return s?null:t.jsx(Ya,{onSuccess:o});if(n==="/blank")return null;if(!s)return t.jsx(Ya,{});switch(n){case"/":case"/nfts":case"/activity":return t.jsx(Zb,{});case"/send":return t.jsx(_v,{},s);case"/receive":return t.jsx(w1,{});case"/nft":return t.jsx(cv,{});case"/nft/send":return t.jsx(Dv,{},s);case"/bridge":return t.jsx(jg,{},s);case"/bridge/preview":return t.jsx($_,{});case"/bridge/history":return t.jsx(h_,{});case"/op/withdrawals":return t.jsx(ox,{});case"/tx":return t.jsx(Li,{});case"/autosign/enable":return t.jsx(rf,{});case"/settings":return t.jsx(Q1,{});case"/settings/autosign":return t.jsx(D1,{});case"/deposit":return t.jsx(i1,{});case"/deposit/completed":return t.jsx(To,{type:"deposit"});case"/withdraw":return t.jsx(c1,{});case"/withdraw/completed":return t.jsx(To,{type:"withdraw"})}},Bv="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",Rv=()=>t.jsxs(t.Fragment,{children:[t.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),t.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),t.jsx("link",{rel:"stylesheet",href:Bv}),t.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),Fv=()=>(pl(),Fl(),de(),tu(),_i(),Ln(),Vn(),Qt(),null),Uv=({children:e,...n})=>(x.useEffect(()=>{Md()},[]),Le.useIsClient()?t.jsxs(t.Fragment,{children:[t.jsx(Rv,{}),t.jsx(mr.Provider,{value:{...ur,...n},children:t.jsx(vr,{children:t.jsx(Th,{children:t.jsx(Z.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:t.jsx(Sh,{children:t.jsxs(_h,{children:[e,t.jsx(ru,{}),t.jsx(me,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:t.jsx(Fv,{})}),t.jsx(Qu,{children:t.jsx(Eo,{})}),t.jsx(Wu,{children:t.jsx(Eo,{})})]})})})})})})]}):null),Ov=({bridge:e})=>t.jsx(vr,{initialEntry:{path:e?"/bridge":"/",state:e},children:t.jsx("div",{className:"body",children:t.jsx(Ai.Provider,{value:!!e,children:t.jsx(me,{children:t.jsx(Eo,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=zt;exports.DEFAULT_GAS_PRICE_MULTIPLIER=dr;exports.InterwovenKit=Ov;exports.InterwovenKitProvider=Uv;exports.MAINNET=ur;exports.MoveError=Zr;exports.PRIVY_APP_ID=qo;exports.TESTNET=Pc;exports.initiaPrivyWallet=Bc;exports.initiaPrivyWalletConnector=Dc;exports.initiaPrivyWalletOptions=kn;exports.injectStyles=wu;exports.useAddress=At;exports.useHexAddress=hn;exports.useInitiaAddress=X;exports.useInterwovenKit=Ue;exports.usePortfolio=Go;exports.useUsernameQuery=li;