@initia/interwovenkit-react 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ur=require("@privy-io/cross-app-connect/rainbow-kit"),Ke=require("wagmi"),S=require("@tanstack/react-query"),v=require("@initia/utils"),F=require("bignumber.js"),$=require("ramda"),Se=require("@lukemorales/query-key-factory"),G=require("ky"),y=require("react"),re=require("@cosmjs/encoding"),ml=require("@mysten/bcs"),Q=require("jotai"),Or=require("@amplitude/analytics-browser"),n=require("react/jsx-runtime"),Hn=require("@cosmjs/amino/build/signdoc"),rt=require("@cosmjs/crypto"),xt=require("ethers"),oa=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),Qn=require("@cosmjs/amino"),Ws=require("@cosmjs/proto-signing"),Vo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),hl=require("cosmjs-types/google/protobuf/any"),Ht=require("viem"),Ka=require("@cosmjs/math"),Ae=require("@cosmjs/stargate"),Wa=require("@cosmjs/tendermint-rpc"),Vr=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),He=require("cosmjs-types/cosmos/tx/v1beta1/tx"),rn=require("@initia/amino-converter"),fl=require("cosmjs-types/cosmos/auth/v1beta1/auth"),en=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),za=require("cosmjs-types/cosmos/tx/v1beta1/service"),Ge=require("date-fns"),Ha=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),Kr=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),Z=require("radix-ui"),We=require("usehooks-ts"),Wr=require("react-error-boundary"),D=require("clsx"),Ne=require("react-hook-form"),Pe=require("@base-ui/react/dialog"),pl=require("xss"),E=require("@initia/icons-react"),bt=require("@react-spring/web"),zs=require("change-case"),It=require("@base-ui/react/select"),bo=require("@base-ui/react/collapsible"),Qa=require("nanoid"),gl=require("react-dom"),_l=require("psl"),yl=require("jotai/utils"),zr=require("react-merge-refs"),xl=require("react-number-format"),bl=require("react-intersection-observer"),wl=require("@noble/hashes/sha3"),tn=require("@noble/hashes/utils"),jl=require("qr-code-styling"),St=require("@base-ui/react"),Lt=require("@base-ui/react/tabs"),_n=require("@base-ui/react/popover"),Ga=require("cosmjs-types/cosmos/bank/v1beta1/tx");function vl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const aa=vl(Or),cn=1.4,Hr=1.05,Qr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",lockStakeModuleAddress:"0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initia.xyz",vipUrl:"https://vip-api.initia.xyz",theme:"dark"},Cl={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",lockStakeModuleAddress:"0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initiation-2.initia.xyz",vipUrl:"https://vip-api.testnet.initia.xyz",theme:"dark",disableAnalytics:!0},ra="cmbq1ozyc006al70lx4uciz0q",Gn={id:ra,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Nl=Ur.toPrivyWalletConnector(Gn),kl=Ur.toPrivyWallet(Gn),Gr=y.createContext(null);function se(){const e=y.useContext(Gr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const W={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Il(e){if(e instanceof G.HTTPError){const{response:t}=e,s=t.headers.get("content-type")??"";if($.includes("application/json",s))try{const o=await t.json();if(o.message)return o.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if($.path(["code"],e)===4001||$.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const t=$.path(["error","message"],e),s=$.path(["cause","message"],e),o=$.path(["shortMessage"],e);return t||s||o||e.message}return String(e)}async function wt(e){return new Error(await Il(e))}const Hs=Se.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ys(e){const t=$.path([0,"address"],e);if(!t)throw new Error("URL not found");return t}function Al(e){const{chain_id:t,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:d,rest:u,["json-rpc"]:m,indexer:h}=r,f=ys(d),p=ys(u),g=ys(h),_=i?.minitia?.type==="minievm"?ys(m):void 0;return{...e,chainId:t,name:c,logoUrl:l,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:_}}function me(){const{defaultChainId:e,registryUrl:t,customChain:s}=se(),{data:o}=S.useSuspenseQuery({queryKey:Hs.list(t).queryKey,queryFn:()=>G.create({prefixUrl:t}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(Al).toSorted($.descend(i=>i.chainId===e)),staleTime:W.MINUTE});return o}function Yr(){const{registryUrl:e}=se(),{data:t}=S.useSuspenseQuery({queryKey:Hs.profiles(e).queryKey,queryFn:()=>G.create({prefixUrl:e}).get("profiles.json").json(),staleTime:W.MINUTE});return t}function Ye(){const e=oe(),t=me(),s=Yr();return o=>{const a=t.find(i=>i.chain_id===o);if(a)return a;const r=s.find(i=>i.chain_id===o);if(!r)throw new Error(`Chain not found: ${o}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:r.pretty_name,logoUrl:r.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function lt(e){return Ye()(e)}function un(){const{defaultChainId:e}=se();return lt(e)}function oe(){const t=me().find(s=>s.metadata?.is_l1);if(!t)throw new Error("Layer 1 not found");return t}function Zr(){return({chainId:e})=>S.queryOptions({queryKey:Hs.prices(e).queryKey,queryFn:()=>G.create({prefixUrl:"https://api.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:W.SECOND})}function Tt(e){const t=Zr();return S.useQuery(t(e))}function ia(){const e=me(),t=Zr();return S.useQueries({queries:e.map(s=>t(s))})}const Sl=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ur=require("@privy-io/cross-app-connect/rainbow-kit"),Ke=require("wagmi"),S=require("@tanstack/react-query"),v=require("@initia/utils"),U=require("bignumber.js"),$=require("ramda"),Se=require("@lukemorales/query-key-factory"),G=require("ky"),y=require("react"),re=require("@cosmjs/encoding"),ml=require("@mysten/bcs"),Q=require("jotai"),Or=require("@amplitude/analytics-browser"),n=require("react/jsx-runtime"),Hn=require("@cosmjs/amino/build/signdoc"),rt=require("@cosmjs/crypto"),xt=require("ethers"),oa=require("@initia/initia.proto/cosmos/authz/v1beta1/tx"),Qn=require("@cosmjs/amino"),Ws=require("@cosmjs/proto-signing"),Vo=require("cosmjs-types/cosmos/crypto/secp256k1/keys"),hl=require("cosmjs-types/google/protobuf/any"),Ht=require("viem"),Ka=require("@cosmjs/math"),Ae=require("@cosmjs/stargate"),Wa=require("@cosmjs/tendermint-rpc"),Vr=require("cosmjs-types/cosmos/tx/signing/v1beta1/signing"),He=require("cosmjs-types/cosmos/tx/v1beta1/tx"),rn=require("@initia/amino-converter"),fl=require("cosmjs-types/cosmos/auth/v1beta1/auth"),en=require("@initia/initia.proto/cosmos/feegrant/v1beta1/feegrant"),za=require("cosmjs-types/cosmos/tx/v1beta1/service"),Ge=require("date-fns"),Ha=require("@initia/initia.proto/cosmos/authz/v1beta1/authz"),Kr=require("@initia/initia.proto/cosmos/feegrant/v1beta1/tx"),Z=require("radix-ui"),We=require("usehooks-ts"),Wr=require("react-error-boundary"),D=require("clsx"),Ne=require("react-hook-form"),Pe=require("@base-ui/react/dialog"),pl=require("xss"),E=require("@initia/icons-react"),bt=require("@react-spring/web"),zs=require("change-case"),It=require("@base-ui/react/select"),bo=require("@base-ui/react/collapsible"),Qa=require("nanoid"),gl=require("react-dom"),_l=require("psl"),yl=require("jotai/utils"),zr=require("react-merge-refs"),xl=require("react-number-format"),bl=require("react-intersection-observer"),wl=require("@noble/hashes/sha3"),tn=require("@noble/hashes/utils"),jl=require("qr-code-styling"),St=require("@base-ui/react"),Lt=require("@base-ui/react/tabs"),_n=require("@base-ui/react/popover"),Ga=require("cosmjs-types/cosmos/bank/v1beta1/tx");function vl(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const o=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const aa=vl(Or),cn=1.4,Hr=1.05,Qr={defaultChainId:"interwoven-1",registryUrl:"https://registry.initia.xyz",routerApiUrl:"https://router-api.initia.xyz",glyphUrl:"https://glyph.initia.xyz",usernamesModuleAddress:"0x72ed9b26ecdcd6a21d304df50f19abfdbe31d2c02f60c84627844620a45940ef",lockStakeModuleAddress:"0x3a886b32a802582f2e446e74d4a24d1d7ed01adf46d2a8f65c5723887e708789",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initia.xyz",vipUrl:"https://vip-api.initia.xyz",theme:"dark"},Cl={defaultChainId:"initiation-2",registryUrl:"https://registry.testnet.initia.xyz",routerApiUrl:"https://router-api.initiation-2.initia.xyz",glyphUrl:"https://glyph.initiation-2.initia.xyz",usernamesModuleAddress:"0x42cd8467b1c86e59bf319e5664a09b6b5840bb3fac64f5ce690b5041c530565a",lockStakeModuleAddress:"0x81c3ea419d2fd3a27971021d9dd3cc708def05e5d6a09d39b2f1f9ba18312264",minityUrl:"https://portfolio-api.minity.xyz",dexUrl:"https://dex-api.initiation-2.initia.xyz",vipUrl:"https://vip-api.testnet.initia.xyz",theme:"dark",disableAnalytics:!0},ra="cmbq1ozyc006al70lx4uciz0q",Gn={id:ra,name:"Socials",iconUrl:"https://assets.initia.xyz/images/wallets/Privy.webp",iconBackground:"#ffffff"},Nl=Ur.toPrivyWalletConnector(Gn),kl=Ur.toPrivyWallet(Gn),Gr=y.createContext(null);function se(){const e=y.useContext(Gr);if(!e)throw new Error("Check if the InterwovenKitProvider is mounted");return e}const W={SECOND:1e3,MINUTE:1e3*60,INFINITY:1e3*60*60};async function Il(e){if(e instanceof G.HTTPError){const{response:t}=e,s=t.headers.get("content-type")??"";if($.includes("application/json",s))try{const o=await t.json();if(o.message)return o.message}catch{return e.message}try{return await t.text()}catch{return e.message}}if(e instanceof Error){if($.path(["code"],e)===4001||$.path(["code"],e)==="ACTION_REJECTED")return"User rejected";const t=$.path(["error","message"],e),s=$.path(["cause","message"],e),o=$.path(["shortMessage"],e);return t||s||o||e.message}return String(e)}async function wt(e){return new Error(await Il(e))}const Hs=Se.createQueryKeys("interwovenkit:chain",{list:e=>[e],profiles:e=>[e],prices:e=>[e],gasPrices:e=>[e]});function ys(e){const t=$.path([0,"address"],e);if(!t)throw new Error("URL not found");return t}function Al(e){const{chain_id:t,chain_name:s,pretty_name:o,logo_URIs:a,apis:r,metadata:i}=e,c=o||s,l=a?.png??"",{rpc:d,rest:u,["json-rpc"]:m,indexer:h}=r,f=ys(d),p=ys(u),g=ys(h),_=i?.minitia?.type==="minievm"?ys(m):void 0;return{...e,chainId:t,name:c,logoUrl:l,rpcUrl:f,restUrl:p,indexerUrl:g,jsonRpcUrl:_}}function me(){const{defaultChainId:e,registryUrl:t,customChain:s}=se(),{data:o}=S.useSuspenseQuery({queryKey:Hs.list(t).queryKey,queryFn:()=>G.create({prefixUrl:t}).get("chains.json").json(),select:a=>(s?[s,...a.filter(i=>i.chain_id!==s.chain_id)]:a).map(Al).toSorted($.descend(i=>i.chainId===e)),staleTime:W.MINUTE});return o}function Yr(){const{registryUrl:e}=se(),{data:t}=S.useSuspenseQuery({queryKey:Hs.profiles(e).queryKey,queryFn:()=>G.create({prefixUrl:e}).get("profiles.json").json(),staleTime:W.MINUTE});return t}function Ye(){const e=oe(),t=me(),s=Yr();return o=>{const a=t.find(i=>i.chain_id===o);if(a)return a;const r=s.find(i=>i.chain_id===o);if(!r)throw new Error(`Chain not found: ${o}`);return{chain_id:r.chain_id,chain_name:r.name,pretty_name:r.pretty_name,network_type:e.network_type,bech32_prefix:"init",fees:{fee_tokens:[]},apis:{rpc:[],rest:[],indexer:[]},chainId:o,name:r.pretty_name,logoUrl:r.logo,rpcUrl:"",restUrl:"",indexerUrl:"",jsonRpcUrl:""}}}function lt(e){return Ye()(e)}function un(){const{defaultChainId:e}=se();return lt(e)}function oe(){const t=me().find(s=>s.metadata?.is_l1);if(!t)throw new Error("Layer 1 not found");return t}function Zr(){return({chainId:e})=>S.queryOptions({queryKey:Hs.prices(e).queryKey,queryFn:()=>G.create({prefixUrl:"https://indexer.initia.xyz"}).get(`initia/${e}/assets`,{searchParams:{quote:"USD",with_prices:!0}}).json(),staleTime:W.SECOND})}function Tt(e){const t=Zr();return S.useQuery(t(e))}function ia(){const e=me(),t=Zr();return S.useQueries({queries:e.map(s=>t(s))})}const Sl=`<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>`,Tl=encodeURIComponent(Sl),ca=`data:image/svg+xml;utf8,${Tl}`,kn=Se.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function El(e){const{base:t,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,d=o.find(m=>m.denom===a)?.exponent??o.find(m=>m.denom===t)?.exponent??$.head(o)?.exponent??0,u=r?.png??"";return{denom:t,symbol:s,decimals:d,logoUrl:u,name:i,address:c,traces:l}}function Jr(){const e=S.useQueryClient();return t=>{const s=t?.metadata?.assetlist;return S.queryOptions({queryKey:kn.list(s).queryKey,queryFn:async()=>s?G.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(El);for(const r of a)e.setQueryData(kn.item(t.chainId,r.denom).queryKey,r);return a},staleTime:W.MINUTE})}}function Ft(e){const t=Jr(),{data:s}=S.useSuspenseQuery(t(e));return s}function ns(){const e=me(),t=Jr();return S.useQueries({queries:e.map(s=>t(s))})}function Ct(e){const t=Ft(e),s=oe(),o=Ft(s),a=ei(e);return r=>{const i=t.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:ca}}}function Xr(e,t){const s=Ct(t),a=S.useQueryClient().getQueryData(kn.item(t.chainId,e).queryKey);return a||s(e)}function ei(e){const t=oe(),s=Ft(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===t.chain_name)return i.counterparty.base_denom}}const a=t.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?v.getIbcDenom(a,o):""}}function Ls(e,t){const s=oe(),o=G.create({prefixUrl:s.restUrl}),a=t?.failSoft??!1,r=S.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...kn.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:W.INFINITY}))});return new Map(r.map(({data:i})=>i))}function $l(e){return e.pagination?.next_key??null}async function Qs(e,t,s){const o=G.create(t),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],d=$l(c),u=[...r,...l];return d?a(u,d):u};return a([],null)}const Ya="usernames";function Ml({restUrl:e,moduleAddress:t}){const{viewFunction:s}=v.createMoveClient(e);async function o(i){if(!v.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:t,moduleName:Ya,functionName:"get_name_from_address",typeArgs:[],args:[re.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:t,moduleName:Ya,functionName:"get_address_from_name",typeArgs:[],args:[ml.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 Gs=Se.createQueryKeys("interwovenkit:account",{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function ti(){const{restUrl:e}=oe(),{usernamesModuleAddress:t}=se();return Ml({restUrl:e,moduleAddress:t})}function ni(){const e=te();return t=>S.queryOptions({queryKey:Gs.balances(t.restUrl,e||"").queryKey,queryFn:()=>e?Qs(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},"balances"):[],staleTime:W.SECOND})}function ss(e){const t=ni(),{data:s}=S.useSuspenseQuery(t(e));return s}function Ll(){const e=me(),t=ni();return S.useQueries({queries:e.map(s=>t(s))})}function ql(e){const t=ss(e),s=Ft(e),o=Ct(e),a=ei(e),{data:r}=Tt(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>s.some(d=>d.denom===l);return $.sortWith([$.descend(({denom:l})=>a(l)==="uinit"),$.descend(({denom:l})=>i(l)),$.descend(({value:l})=>l),$.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>F(d).comparedTo(l)??0,$.descend(({symbol:l})=>l.toLowerCase())],t.filter(({amount:l})=>!F(l).isZero()).map(({amount:l,denom:d})=>{const u=o(d),m=r?.find(({id:f})=>f===u?.denom)?.price??0,h=F(l).times(m).div(F(10).pow(u.decimals)).toNumber();return{...u,balance:l,price:m,value:h}}))}const si=y.createContext(null);function Ys(){return y.useContext(si)}function oi(){const{location:e}=Ys();return e}function Zs(){const{path:e}=oi();return e}function Ze(){const{state:e={}}=oi();return e}function ai(){const{history:e}=Ys();return e}function Ie(){const{navigate:e}=Ys();return e}function la(){const{reset:e}=Ys();return e}const Nn=({to:e,state:t,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ie(),c=la(),l=d=>{d.preventDefault(),a?.(d),s?c(e,t):i(e,t)};return n.jsx("button",{type:"button",...r,onClick:l,children:o})},ri=({children:e,initialEntry:t})=>{const[s,o]=y.useState([t??{path:"/"}]),a=s[s.length-1],r=y.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const u=d.length+c;if(u<1)return d;const m=$.take(u,d);return l!==void 0?$.adjust(u-1,h=>({...h,state:l}),m):m})},[]),i=y.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return n.jsx(si.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},Pl="c33b940c24c17e95f7d9d525d508ac61";function Rl(){const{disableAnalytics:e}=se();y.useEffect(()=>{e||aa.init(Pl,{autocapture:!1})},[e])}function Dl(){const{connector:e}=Ke.useAccount(),{defaultChainId:t,disableAnalytics:s}=se();y.useEffect(()=>{const o=new Or.Identify;e?.name&&o.set("connector",e.name),t&&o.set("defaultChainId",t),aa.identify(o)},[t,e?.name,s])}function Tn(){const e=Zs();return y.useCallback((s,o)=>{aa.track(s,{path:e,...o})},[e])}function Bl(e){return e.type==="initia/PubKeyEthSecp256k1"}const Fl={...Qn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ii(e){if(Bl(e)){const t=Vo.PubKey.fromPartial({key:re.fromBase64(e.value)});return hl.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Vo.PubKey.encode(t).finish())})}return Ws.encodePubkey(e)}function da(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:Fl.ethsecp256k1,value:re.toBase64(e)}}function ci(e,t){if(t.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:da(e),signature:re.toBase64(t)}}function Ul(e){return`Enable Auto-Sign for InterwovenKit
4
+ </svg>`,Tl=encodeURIComponent(Sl),ca=`data:image/svg+xml;utf8,${Tl}`,kn=Se.createQueryKeys("interwovenkit:asset",{list:e=>[e],item:(e,t)=>[e,t],resource:(e,t)=>[e.chainId,t.denom],denom:(e,t)=>[e,t],metadata:(e,t)=>[e,t]});function El(e){const{base:t,symbol:s,denom_units:o=[],display:a,logo_URIs:r,name:i,address:c,traces:l}=e,d=o.find(m=>m.denom===a)?.exponent??o.find(m=>m.denom===t)?.exponent??$.head(o)?.exponent??0,u=r?.png??"";return{denom:t,symbol:s,decimals:d,logoUrl:u,name:i,address:c,traces:l}}function Jr(){const e=S.useQueryClient();return t=>{const s=t?.metadata?.assetlist;return S.queryOptions({queryKey:kn.list(s).queryKey,queryFn:async()=>s?G.get(s).json():{assets:[]},select:({assets:o})=>{if(!t)return[];const a=o.map(El);for(const r of a)e.setQueryData(kn.item(t.chainId,r.denom).queryKey,r);return a},staleTime:W.MINUTE})}}function Ft(e){const t=Jr(),{data:s}=S.useSuspenseQuery(t(e));return s}function ns(){const e=me(),t=Jr();return S.useQueries({queries:e.map(s=>t(s))})}function Ct(e){const t=Ft(e),s=oe(),o=Ft(s),a=ei(e);return r=>{const i=t.find(l=>l.denom===r);if(i)return i;const c=o.find(l=>l.denom===a(r));return c?{...c,denom:r}:{denom:r,symbol:"",decimals:0,logoUrl:ca}}}function Xr(e,t){const s=Ct(t),a=S.useQueryClient().getQueryData(kn.item(t.chainId,e).queryKey);return a||s(e)}function ei(e){const t=oe(),s=Ft(e);return o=>{if(e.metadata?.is_l1)return o;if(o.startsWith("l2/")||o.startsWith("ibc/")){const r=s.find(i=>i.denom===o)??s.find(i=>i.traces?.some(c=>c.counterparty.base_denom===o));if(r?.traces){for(const i of r.traces)if(i.counterparty.chain_name===t.chain_name)return i.counterparty.base_denom}}const a=t.metadata?.ibc_channels?.find(({chain_id:r,version:i})=>r===e.chain_id&&i==="ics20-1")?.channel_id;return a?v.getIbcDenom(a,o):""}}function Ls(e,t){const s=oe(),o=G.create({prefixUrl:s.restUrl}),a=t?.failSoft??!1,r=S.useSuspenseQueries({queries:e.map(i=>({queryFn:async()=>{try{return await o.get("initia/move/v1/denom",{searchParams:{metadata:i}}).json()}catch(c){if(a)return{denom:""};throw c}},queryKey:[...kn.denom(s.restUrl,i).queryKey,a],select:c=>[i,c.denom],staleTime:W.INFINITY}))});return new Map(r.map(({data:i})=>i))}function $l(e){return e.pagination?.next_key??null}async function Qs(e,t,s){const o=G.create(t),a=async(r,i)=>{const c=await o.extend(i?{searchParams:{"pagination.key":i}}:{}).get(e).json(),l=c[s]??[],d=$l(c),u=[...r,...l];return d?a(u,d):u};return a([],null)}const Ya="usernames";function Ml({restUrl:e,moduleAddress:t}){const{viewFunction:s}=v.createMoveClient(e);async function o(i){if(!v.InitiaAddress.validate(i))return null;const c=await s({moduleAddress:t,moduleName:Ya,functionName:"get_name_from_address",typeArgs:[],args:[re.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:t,moduleName:Ya,functionName:"get_address_from_name",typeArgs:[],args:[ml.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 Gs=Se.createQueryKeys("interwovenkit:account",{username:(e,t)=>[e,t],address:(e,t)=>[e,t],balances:(e,t)=>[e,t],txs:(e,t)=>[e,t]});function ti(){const{restUrl:e}=oe(),{usernamesModuleAddress:t}=se();return Ml({restUrl:e,moduleAddress:t})}function ni(){const e=te();return t=>S.queryOptions({queryKey:Gs.balances(t.restUrl,e||"").queryKey,queryFn:()=>e?Qs(`cosmos/bank/v1beta1/balances/${e}`,{prefixUrl:t.restUrl},"balances"):[],staleTime:W.SECOND})}function ss(e){const t=ni(),{data:s}=S.useSuspenseQuery(t(e));return s}function Ll(){const e=me(),t=ni();return S.useQueries({queries:e.map(s=>t(s))})}function ql(e){const t=ss(e),s=Ft(e),o=Ct(e),a=ei(e),{data:r}=Tt(e),i=l=>e.fees.fee_tokens.some(d=>d.denom===l),c=l=>s.some(d=>d.denom===l);return $.sortWith([$.descend(({denom:l})=>a(l)==="uinit"),$.descend(({denom:l})=>i(l)),$.descend(({value:l})=>l),$.descend(({denom:l})=>c(l)),({balance:l},{balance:d})=>U(d).comparedTo(l)??0,$.descend(({symbol:l})=>l.toLowerCase())],t.filter(({amount:l})=>!U(l).isZero()).map(({amount:l,denom:d})=>{const u=o(d),m=r?.find(({id:f})=>f===u?.denom)?.price??0,h=U(l).times(m).div(U(10).pow(u.decimals)).toNumber();return{...u,balance:l,price:m,value:h}}))}const si=y.createContext(null);function Ys(){return y.useContext(si)}function oi(){const{location:e}=Ys();return e}function Zs(){const{path:e}=oi();return e}function Ze(){const{state:e={}}=oi();return e}function ai(){const{history:e}=Ys();return e}function Ie(){const{navigate:e}=Ys();return e}function la(){const{reset:e}=Ys();return e}const Nn=({to:e,state:t,shouldReset:s,children:o,onClick:a,...r})=>{const i=Ie(),c=la(),l=d=>{d.preventDefault(),a?.(d),s?c(e,t):i(e,t)};return n.jsx("button",{type:"button",...r,onClick:l,children:o})},ri=({children:e,initialEntry:t})=>{const[s,o]=y.useState([t??{path:"/"}]),a=s[s.length-1],r=y.useCallback((c,l)=>{o(d=>{if(typeof c=="string")return[...d,{path:c,state:l}];const u=d.length+c;if(u<1)return d;const m=$.take(u,d);return l!==void 0?$.adjust(u-1,h=>({...h,state:l}),m):m})},[]),i=y.useCallback((c,l)=>{o([{path:c,state:l}])},[]);return n.jsx(si.Provider,{value:{location:a,history:s,navigate:r,reset:i},children:e})},Pl="c33b940c24c17e95f7d9d525d508ac61";function Rl(){const{disableAnalytics:e}=se();y.useEffect(()=>{e||aa.init(Pl,{autocapture:!1})},[e])}function Dl(){const{connector:e}=Ke.useAccount(),{defaultChainId:t,disableAnalytics:s}=se();y.useEffect(()=>{const o=new Or.Identify;e?.name&&o.set("connector",e.name),t&&o.set("defaultChainId",t),aa.identify(o)},[t,e?.name,s])}function Tn(){const e=Zs();return y.useCallback((s,o)=>{aa.track(s,{path:e,...o})},[e])}function Bl(e){return e.type==="initia/PubKeyEthSecp256k1"}const Fl={...Qn.pubkeyType,ethsecp256k1:"initia/PubKeyEthSecp256k1"};function ii(e){if(Bl(e)){const t=Vo.PubKey.fromPartial({key:re.fromBase64(e.value)});return hl.Any.fromPartial({typeUrl:"/initia.crypto.v1beta1.ethsecp256k1.PubKey",value:Uint8Array.from(Vo.PubKey.encode(t).finish())})}return Ws.encodePubkey(e)}function da(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:Fl.ethsecp256k1,value:re.toBase64(e)}}function ci(e,t){if(t.length!==64)throw new Error("Signature must be 64 bytes long. Cosmos SDK uses a 2x32 byte fixed length encoding for the secp256k1 signature integers r and s.");return{pub_key:da(e),signature:re.toBase64(t)}}function Ul(e){return`Enable Auto-Sign for InterwovenKit
5
5
 
6
6
  Origin: ${e}
7
7
 
8
- Sign this message to create a dedicated signing wallet for auto-sign transactions. This wallet will only be used to sign transactions on your behalf when auto-sign is enabled.`}async function Ol(e,t){const s=Ht.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=Ht.hexToBytes(Ht.keccak256(Ht.bytesToHex(o))),r=rt.Bip39.encode(a),i=await rt.Bip39.mnemonicToSeed(r),c=rt.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=rt.Slip10.derivePath(rt.Slip10Curve.Secp256k1,i,c),d=await rt.Secp256k1.makeKeypair(l),u=rt.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=Ht.bytesToHex(h),p=Ht.keccak256(f),g=Ht.hexToBytes(p).slice(-20),_=re.toBech32(t,g);return{privateKey:l,publicKey:u,address:_}}function xs(e,t){return`${e}:${t}`}const os=Q.atom(null),Yn=Q.atom({}),Zn=Q.atom({}),Js=Q.atom({}),Za=Q.atom(0),Vl="autosign:";function Kl(e,t){const s=e.get(Za)+1;return e.set(Za,s),`${t}:${s}`}function qs(e,t){return e.get(Js)[t]}function Wl(e,t,s){e.set(Js,o=>({...o,[t]:s}))}function li(e,t){e.set(Js,s=>{const o={...s};return delete o[t],o})}function zl(e,t,s){const o=qs(e,t);!o||o.token!==s||li(e,t)}function Hl(e,t,s){const o=qs(e,t);return!!o&&o.token===s}function bs(e,t){return e.get(Zn)[t]}function Ql(e,t,s){e.set(Zn,o=>({...o,[t]:s}))}function Gl(e,t){e.set(Zn,s=>{const o={...s};return delete o[t],o})}function Yl(e,t,s){e.set(Yn,o=>({...o,[t]:s}))}function Zl(e,t){e.set(Yn,s=>{const o={...s};return delete o[t],o})}function di(e,t){return`${Vl}${e}:${t}`}function Jl(e,t,s){try{return e.getItem(di(t,s))}catch{return null}}function Xl(e,t,s,o){try{e.setItem(di(t,s),o)}catch{}}function ui(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ua(e,t){const s=ui();if(s)return Jl(s,e,t)}function ed(e,t,s){const o=ui();o&&Xl(o,e,t,s)}function td(e){return{publicKey:e.publicKey,address:e.address}}function Ps(e){e&&e.fill(0)}function mi(e){e.set(Js,{});const t=e.get(Zn);for(const s of Object.values(t))Ps(s);e.set(Zn,{}),e.set(Yn,{})}function nd(e,t){return e!==""&&e!==t}function sd(){const e=te(),t=Q.useStore(),s=y.useRef(e);y.useEffect(()=>{const o=s.current;nd(o,e)&&mi(t),s.current=e},[t,e])}class od{constructor(t,s){this.wallet=t,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(t,s){if(this.wallet.address!==t)throw new Error("Signer address does not match the derived wallet address");const o=Hn.escapeCharacters(Hn.sortedJsonStringify(s)),a=xt.ethers.hashMessage(o),r=re.fromHex(a.replace("0x","")),i=await rt.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=ci(this.wallet.publicKey,c);return{signed:s,signature:l}}}function Xs(){const e=Q.useStore(),{signMessageAsync:t}=Ke.useSignMessage(),s=Ye(),o=te();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const u=s(d),m=xs(o,u.bech32_prefix),h=e.get(Yn)[m];if(h&&bs(e,m))return h;const f=qs(e,m);if(f)return f.promise;const p=Kl(e,m),g=(async()=>{try{const _=window.location.origin,x=Ul(_),w=await t({message:x}),C=await Ol(w,u.bech32_prefix),b=td(C);if(Hl(e,m,p))return Ql(e,m,C.privateKey),Yl(e,m,b),b;throw Ps(C.privateKey),new Error("Wallet derivation was cancelled")}finally{zl(e,m,p)}})();return Wl(e,m,{promise:g,token:p}),g},getWallet:d=>{if(!o)return;const u=s(d),m=xs(o,u.bech32_prefix);if(bs(e,m))return e.get(Yn)[m]},getWalletPrivateKey:d=>{if(!o)return;const u=s(d),m=xs(o,u.bech32_prefix);return bs(e,m)},clearWallet:d=>{if(!o)return;const u=s(d),m=xs(o,u.bech32_prefix),h=bs(e,m);qs(e,m)&&li(e,m),Ps(h),Gl(e,m),Zl(e,m)},clearAllWallets:()=>{mi(e)}}}function hi({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:oa.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function ad({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=hi({granteeAddress:r.address,messages:s,encoder:c}),u={...o,granter:t},m=new Uint8Array(i),h=new od(r,m);try{return await l(e,r.address,d,u,a,{customSigner:h})}finally{Ps(m)}}const pt="interwovenkit",Qe="uinit",it="INIT",st=6,rd="uoinit",id="omniINIT",fi="https://app.initia.xyz",ma=`${fi}/liquidity/my`,cd=`${fi}/vip/my`,ld=1e3,pi=60*ld,gi=60*pi,Ja=24*gi,ie={PUBLIC_KEY:`${pt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${pt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${pt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${pt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${pt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${pt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${pt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${pt}:bridge:route-type`,BRIDGE_HISTORY:`${pt}:bridge:history`,OP_REMINDER:`${pt}:op:reminder`},_i=Q.atom(!1),yi=Q.atom(!1);function Et(){const e=la(),[t,s]=Q.useAtom(_i),o=Q.useSetAtom(yi),a=Tn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function En(){const e=la(),[t,s]=Q.useAtom(yi),o=Q.useSetAtom(_i),a=Tn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function xi(){const e=Ie(),{closeDrawer:t}=Et(),{closeModal:s}=En(),{disconnect:o}=Ke.useDisconnect(),{clearAllWallets:a}=Xs();return()=>{e("/blank"),t(),s(),o(),a(),localStorage.removeItem(ie.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_SRC_DENOM),localStorage.removeItem(ie.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_DST_DENOM),localStorage.removeItem(ie.BRIDGE_QUANTITY),localStorage.removeItem(ie.BRIDGE_SLIPPAGE_PERCENT)}}function dd(){const e=Ot(),t=un(),{openModal:s}=En();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,d=a.map(u=>({denom:u,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function ud(){const e=Ot(),t=un(),{openModal:s}=En();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,d=a.map(u=>({denom:u,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function md(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Vo.PubKey.decode(e.value);return Qn.encodeSecp256k1Pubkey(t)}return Ws.decodeOptionalPubkey(e)}function hd({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=fl.BaseAccount.decode(t),i=md(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ae.accountFromAny({typeUrl:e,value:t})}const bi="/cosmos.feegrant.v1beta1.MsgGrantAllowance",wi="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",ji="cosmos-sdk/AllowedMsgAllowance";function fd(){const e=rn.aminoConverters[bi];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Rs=fd();function vi(e){if(e.typeUrl===wi){const t=en.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:ji,value:{allowance:vi(t.allowance),allowed_messages:t.allowedMessages}}}return Rs.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Ci(e){if(e.type===ji){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Ci(t.allowance);return{typeUrl:wi,value:en.AllowedMsgAllowance.encode(en.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Rs.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const pd={...rn.aminoConverters,[bi]:{...Rs,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:vi(e.allowance)}:Rs.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Ci(e.allowance)})}},as=()=>{const e=se();return new Ws.Registry([...rn.protoRegistry,...e.protoTypes??[]])},rs=()=>{const e=se();return new Ae.AminoTypes({...pd,...e.aminoConverters})};class gd{constructor(t,s,o){this.address=t,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const t=`${ie.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(t);if(s)return this.cachedPublicKey=re.fromHex(s),re.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,re.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,re.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await G.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?re.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=xt.ethers.hashMessage(t),a=xt.ethers.SigningKey.recoverPublicKey(o,s);return rt.Secp256k1.compressPubkey(re.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(t,s){if(this.address!==t)throw new Error("Signer address does not match the provided address");const o=Hn.escapeCharacters(Hn.sortedJsonStringify(s)),a=await this.signMessage(o),r=re.fromHex(a.replace("0x","")).subarray(0,-1),c=rt.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=ci(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Ni(){const e=as(),t=rs(),s=is(),o=eo();return async function(a,r,i,c,l,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const m=await o(a),{accountNumber:h,sequence:f}=await ki({getSequence:N=>m.getSequence(N),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[p]=await u.getAccounts(),g=ii(da(p.pubkey)),_=Vr.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),w=Hn.makeSignDoc(x,c,a,l,h,f),{signature:C,signed:b}=await u.signAmino(r,w),k={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:b.msgs.map(N=>t.fromAmino(N)),memo:l}},T=e.encode(k),L=Ka.Int53.fromString(b.fee.gas).toNumber(),A=Ka.Int53.fromString(b.sequence).toNumber(),M=Ws.makeAuthInfoBytes([{pubkey:g,sequence:A}],b.fee.amount,L,b.fee.granter,b.fee.payer,_);return He.TxRaw.fromPartial({bodyBytes:T,authInfoBytes:M,signatures:[re.fromBase64(C.signature)]})}}function _d(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function ki({getSequence:e,signerAddress:t,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(t);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&_d(a,t))return{accountNumber:0,sequence:s};throw a}}function is(){const e=te(),{signMessageAsync:t}=Ke.useSignMessage(),s=oe();return y.useMemo(()=>new gd(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const wo=new Map,Es=new Map;function yd(e,t){const s=`${e}:${t}`;Es.delete(s)}function ha(){const e=Ye();return async t=>{if(wo.has(t))return wo.get(t);const{rpcUrl:s}=e(t),o=await Wa.Comet38Client.create(new Wa.HttpClient(s));return wo.set(t,o),o}}function eo(){const e=as(),t=rs(),s=is(),o=te(),a=ha();return async r=>{const i=`${o}:${r}`;if(Es.has(i))return Es.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Ae.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:hd,broadcastPollIntervalMs:500});return Es.set(i,l),l}}function Ii(){const{connector:e}=Ke.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new xt.BrowserProvider(await e.getProvider())}}function Ai(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Si(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function xd(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Ti(){const e=te(),t=Ye();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=G.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 G.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=G.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=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Qs(l,{prefixUrl:i.restUrl},"grants");return Ai(d)}}}const Ds=Se.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),bd=4,Ei=4;function wd(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function fa(){const e=se(),t=un(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(t.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function jd(){const{data:e}=to(),t=fa();return(s,o)=>{const a=o.every(i=>{const c=t[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function to(){const e=te(),t=fa(),s=wd(t),{fetchFeegrant:o,fetchAllGrants:a}=Ti();return S.useQuery({queryKey:Ds.expirations(e,s,t).queryKey,queryFn:()=>vd({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:W.MINUTE,retry:1})}async function vd(e){const{initiaAddress:t,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},d=[];for(const[m,h]of Object.entries(s))r[m]=null,i[m]=void 0,c[m]=!1,h.length>0&&d.push([m,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const u=await $i(d,bd,async([m,h])=>{const f=ua(t,m);try{const p=await o(m),g=f===void 0?p:f===null?[]:p.filter(k=>k.grantee===f),_=kd(g,h);if(_.length===0)return{chainId:m,expectedAddress:f,expiration:null,grantee:void 0};const x=await Nd({chainId:m,candidates:_,fetchFeegrant:a,concurrency:Ei});if(!x)return{chainId:m,expectedAddress:f,expiration:null,grantee:void 0};const w=x.grantee.grants.filter(k=>h.includes(k.authorization.msg)).map(k=>k.expiration),C=Si(x.feegrant.allowance),b=[...w,C],j=pa(b);return{chainId:m,expectedAddress:f,expiration:j?new Date(j):void 0,grantee:x.grantee.grantee}}catch{return{chainId:m,expectedAddress:f,expiration:null,grantee:void 0}}});for(const m of u)l[m.chainId]=m.expectedAddress,r[m.chainId]=m.expiration,i[m.chainId]=m.grantee;for(const[m]of d)c[m]=Id({expiration:r[m],grantee:i[m],expectedAddress:l[m]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function $i(e,t,s){const o=new Array(e.length),a=Math.max(1,t);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function Cd(e){const t=xd(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Si(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Ge.isFuture(a)}async function Nd(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Ei}=e,r=await $i(s,a,async i=>{const c=await o(t,i.grantee);return c&&Cd(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function kd(e,t){if(t.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(d=>!d.expiration||Ge.isFuture(new Date(d.expiration))),c=i.map(d=>d.authorization.msg);t.every(d=>c.includes(d))&&o.push({grantee:a,grants:i})}return o}function Id(e){const{expiration:t,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(t){case null:return!1;case void 0:return a;default:return a&&Ge.isFuture(t)}}function Ad(){const{data:e,refetch:t}=to();y.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Ge.isFuture(c));if(o.length===0)return;const a=pa(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{t()},r+100);return()=>clearTimeout(i)},[e,t])}function pa(e){const t=e.filter(s=>s!==void 0);if(t.length!==0)return[...t].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const Mi=y.createContext(null),no=()=>y.useContext(Mi);class Li extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(t,s,o,a,r,i,c){super(t),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const Sd=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,jo=new Map;function Td(e){const t=e.match(Sd);if(!t)return null;const[,s,o,a]=t;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Ed(e,t,s){const o=`${e}:${t}`;if(jo.has(o))return jo.get(o);try{const a=t==="0x1"?"0x1.json":`${e}/${t}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await G.get(r).json();return jo.set(o,i),i}catch{return null}}function $d(e,t,s,o,a,r,i){return new Li(e,t,s,o,a,r,i)}async function bn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await wt(e);const o=Td(e.message);if(!o)return await wt(e);const a=await Ed(t.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return $d(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Md=10;function qi(){const e=te();return(t,s)=>S.queryOptions({queryKey:Gs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Md},{txs:a}=await G.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:W.SECOND})}function Ld(e,t){const s=qi();return S.useSuspenseQuery(s(e,t))}function qd(e,t){const s=e.flatMap((o,a)=>(t[a]??[]).map(i=>({...i,chain:o})));return $.sortWith([$.descend(o=>new Date(o.timestamp).getTime())])(s)}const Pd=()=>{const e=me(),t=qi(),s=S.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map($.prop("data")),a=qd(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Pi(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await G.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.toSorted($.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:Hr;return{amount:F(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:t,fixed_min_gas_price:s})=>{if($.isNil(s))throw new Error(`${t} has no price`);return{amount:String(s),denom:t}})}function ga(e){const{data:t}=S.useSuspenseQuery({queryKey:Hs.gasPrices(e).queryKey,queryFn:()=>Pi(e),staleTime:W.SECOND});return t}function _a(e){const t=te(),{data:s}=Ld(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(t,xt.computeAddress(`0x${re.toHex(rt.Secp256k1.uncompressPubkey(re.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const Ri="approve",so=Q.atom(),Di=Q.atom(null),Rd=cn,Dd=1.5;function Bd({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(t)??r(s)??a[0]}function Fd({simulatedGas:e,gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),d=Bd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Ae.calculateFee(l,Ae.GasPrice.fromString(`${d.amount}${d.denom}`))}function Ud({derivedAddress:e,messages:t,encoder:s}){return{messages:hi({granteeAddress:e,messages:t,encoder:s})}}function Od(e){if(!(e instanceof Error))return!1;const t=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=t.includes("user rejected")||t.includes("rejected the request")||t.includes("user denied")||t.includes("denied by user")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("cancelled by user")||t.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function Vd({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Ae.createProtobufRpcClient(e),i=new za.ServiceClientImpl(r),c=He.Tx.fromPartial({authInfo:He.AuthInfo.fromPartial({fee:He.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:Vr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:He.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(za.SimulateRequest.fromPartial({txBytes:He.Tx.encode(c).finish()}))}function Kd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function Wd({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const u=async()=>d.signWithEthSecp256k1(t,e,s,a,o),m=(_,x)=>{d.onAutoSignFallback?.({chainId:t,reason:_,errorMessage:Kd(x)})};if(!c)return u();if(!d.validateAutoSign(t,s))return m("validation_failed"),u();let f=d.getWallet(t),p=!1;if(!f&&l)try{f=await d.deriveWallet(t)}catch(_){if(Od(_))throw _;m("derive_wallet_failed",_),p=!0,f=void 0}if(!f)return p||m("missing_derived_wallet"),u();let g;try{const _=i??await d.getSigningClient(t);g=await d.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return m("fee_computation_failed",_),u()}try{return await d.signWithDerivedWallet(t,e,s,g,o,f)}catch(_){return m("derived_wallet_sign_failed",_),u()}}function Bi(){const e=te(),{autoSignFeePolicy:t}=se(),s=Ye(),o=ha(),a=eo(),r=as(),i=jd(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=Xs(),u=Ni(),m=Tn(),h=g=>{const _=t?.[g];return{gasMultiplier:_?.gasMultiplier??Rd,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??Dd,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:g,messages:_,memo:x,derivedWallet:w,preferredFeeDenom:C,fallbackFeeDenom:b,client:j})=>{const k=s(g),T=await Pi(k),A=Ud({derivedAddress:w.address,messages:_,encoder:r}).messages.map(H=>r.encodeAsAny(H)),M=ii(da(w.publicKey)),{sequence:N}=await ki({getSequence:H=>j.getSequence(H),signerAddress:w.address,incrementSequence:0,allowMissingAccount:!0}),I=await o(g),U=Ae.QueryClient.withExtensions(I,Ae.setupTxExtension),{gasInfo:q}=await Vd({queryClient:U,messages:A,memo:x,pubkey:M,sequence:N}),P=q?Number(q.gasUsed.toString()):0,B=h(g);return Fd({simulatedGas:P,gasPrices:T,preferredFeeDenom:C,fallbackFeeDenom:b,policy:B})},p=async(g,_,x,w,C,b)=>{let j=b??c(g);j||(j=await l(g));const k=d(g);if(!k)throw new Error("Derived wallet key not initialized");return await ad({chainId:g,granterAddress:_,messages:x,fee:w,memo:C,derivedWallet:j,privateKey:k,encoder:r,signWithEthSecp256k1:u})};return g=>Wd({...g,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:p,signWithEthSecp256k1:u,onAutoSignFallback:({chainId:_,reason:x,errorMessage:w})=>{m("AutoSign Fallback",{chainId:_,reason:x,errorMessage:w})}})}function Fi(){const e=Q.useAtomValue(so);if(!e)throw new Error("Tx request not found");return e}function oo(){const e=Ie(),t=te(),{defaultChainId:s,registryUrl:o}=se(),a=Ye(),{openDrawer:r,closeDrawer:i}=Et(),{openModal:c,closeModal:l}=no(),d=Q.useSetAtom(so),u=Q.useSetAtom(Di),m=ha(),h=eo(),f=is(),p=as(),g=Bi(),_=async({messages:A,memo:M,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,M)}catch(I){throw await bn(I,a(N),o)}},x=async({messages:A,memo:M,chainId:N=s})=>{const I=await m(N),U=Ae.QueryClient.withExtensions(I,Ae.setupTxExtension),q=A.map(K=>p.encodeAsAny(K)),[P]=await f.getAccounts(),B=Qn.encodeSecp256k1Pubkey(P.pubkey),H=await h(N),{sequence:z}=await H.getSequence(t);return U.tx.simulate(q,M,B,z)},w=async({txRequest:A,broadcaster:M})=>{const I={...{memo:"",chainId:s,gas:A.gas||await _(A),gasAdjustment:cn,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((U,q)=>{d({txRequest:I,resolve:async B=>{try{const H=await h(I.chainId),z=await M(H,He.TxRaw.encode(B).finish());U(z),typeof I.internal=="string"&&e(I.internal)}catch(H){q(await bn(H,a(I.chainId),o))}finally{P()}},reject:B=>{q(B),P()}}),I.internal?c({path:"/tx"}):r("/tx");const P=()=>{if(!I.internal){e("/blank"),i();return}l()}})},C=async A=>{const M=A.chainId??s;try{const N=await w({txRequest:A,broadcaster:async(I,U)=>await I.broadcastTxSync(U)});return A.internal&&typeof A.internal!="number"&&(u({txHash:N,chainId:M,status:"loading"}),L({txHash:N,chainId:A.chainId}).then(I=>{u({status:I.code===0?"success":"error",chainId:M,txHash:N})}).catch(()=>{u({status:"error",chainId:M,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&u({status:"error",chainId:M,error:N}),N}},b=(A,M=30*1e3,N=.5*1e3)=>w({txRequest:A,broadcaster:async(I,U)=>{const q=await I.broadcastTx(U,M,N);if(q.code!==0)throw new Error(q.rawLog);return q}}),j=async({chainId:A,messages:M,memo:N="",fee:I,preferredFeeDenom:U})=>{const q=await h(A),P=await g({chainId:A,messages:M,memo:N,fee:I,preferredFeeDenom:U,client:q,allowWalletDerivation:!0});return{client:q,signedTx:P}},k=async A=>{const M=A.chainId??s;try{const{client:N,signedTx:I}=await j({...A,chainId:M});return await N.broadcastTxSync(He.TxRaw.encode(I).finish())}catch(N){throw await bn(N,a(M),o)}},T=async(A,M=30*1e3,N=.5*1e3)=>{const I=A.chainId??s;try{const{client:U,signedTx:q}=await j({...A,chainId:I}),P=await U.broadcastTx(He.TxRaw.encode(q).finish(),M,N);if(P.code!==0)throw new Error(P.rawLog);return P}catch(U){throw await bn(U,a(I),o)}},L=async({chainId:A=s,...M})=>{try{const N=await h(A);return await Ui({...M,client:N})}catch(N){throw await bn(N,a(A),o)}};return{estimateGas:_,simulateTx:x,requestTxSync:C,requestTxBlock:b,submitTxSync:k,submitTxBlock:T,waitForTxConfirmation:L}}async function Ui({txHash:e,client:t,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await t.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const zd="/cosmos.authz.v1beta1.MsgExec";function Hd(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function Qd(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function Gd(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function Yd(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function Oi(e){const t=[Ds.expirations._def,Ds.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function Vi(){const e=te(),{fetchFeegrant:t,fetchGrants:s}=Ti();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await t(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Kr.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],u=Yd(c).map(m=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:oa.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:m})}));return[...l,...u]}}function Zd(){const e=te(),t=fa(),{requestTxBlock:s}=oo(),o=S.useQueryClient(),[a,r]=Q.useAtom(os),{closeDrawer:i}=Et(),c=Vi(),{deriveWallet:l}=Xs();return S.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:u}=a;if(!e)throw new Error("Wallet not connected");const m=t[u];if(!m||m.length===0)throw new Error(`No message types configured for chain ${u}`);const h=await l(u);yd(e,u);const f=ua(e,u),p=Qd({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(p.map(k=>c({chainId:u,grantee:k})))).flat(),x=d===0?void 0:Ge.addMilliseconds(new Date,d),w={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:en.BasicAllowance.encode(en.BasicAllowance.fromPartial({expiration:x})).finish()},C={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Kr.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:en.AllowedMsgAllowance.encode(en.AllowedMsgAllowance.fromPartial({allowance:w,allowedMessages:[zd]})).finish()}})},b=m.map(k=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:oa.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:Ha.GenericAuthorization.encode(Ha.GenericAuthorization.fromPartial({msg:k})).finish()},expiration:x}})})),j=[..._,C,...b];return await s({messages:j,chainId:u,internal:!0}),{chainId:u,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:u})=>{e&&ed(e,d,u.address),await Oi(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function Ki(e){const t=se(),s=me(),o=Ye(),{getWallet:a,clearWallet:r}=Xs(),{requestTxBlock:i}=oo(),c=S.useQueryClient(),l=Vi(),{data:d,refetch:u}=to();return S.useMutation({mutationFn:async(m=t.defaultChainId)=>{const h=a(m),f=d?.granteeByChain[m];let p;e?.grantee||(p=(await u()).data?.granteeByChain[m]);const g=Hd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:p});if(g.length===0)throw new Error("No grantee address available");const x=(await Promise.all(g.map(w=>l({chainId:m,grantee:w})))).flat();return x.length===0?{chainId:m,didBroadcast:!1}:(await i({messages:x,chainId:m,internal:e?.internal}),{chainId:m,didBroadcast:!0})},onSuccess:async({chainId:m,didBroadcast:h})=>{await Oi(c);const f=o(m),p=s.filter(b=>b.bech32_prefix===f.bech32_prefix).map(b=>b.chain_id).filter(b=>b!==m);let g;try{g=(await u()).data}catch{g=void 0}const _=g??d;let x=!1;p.length>0&&_&&(x=p.some(b=>_?.isEnabledByChain[b]));const w=h?g?.isEnabledByChain[m]:(g??d)?.isEnabledByChain[m];Gd({isEnabledOnTargetChain:w,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(m)}})}function Jd(){const{defaultChainId:e}=se(),{openDrawer:t}=Et(),s=Q.useSetAtom(os),o=Ki(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=to();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,u)=>{s({chainId:l,resolve:d,reject:u}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function Wi(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function Xd(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),F(0)).toString()}function eu(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??ca}}function Xa(e){return $.pick(["chainId","name","logoUrl"],e)}function tu(e){return $.sortWith([$.descend(({symbol:t})=>t===it),$.descend(Wi),$.descend(({assets:t})=>t.length),$.ascend(({symbol:t})=>t)])(e)}function nu(e){return $.sortWith([$.descend(({value:t})=>t??0),$.descend(({quantity:t})=>Number(t)),$.ascend(({chain:t})=>t.name)])(e)}function su(e,t){return $.sortWith([$.descend(({chain:s})=>s.chainId===t),$.ascend(({chain:s})=>s.name),$.ascend(({denom:s})=>s)])(e)}function ou(e,t){return $.sortWith([$.descend(({chainId:s})=>s===t),$.descend($.prop("value"))])(e)}function au(e,t,s,o,a){const r=e.find(m=>m.metadata?.is_l1)?.chainId,i={};for(const m of e){const h=m.chainId,f=t[h]??[],p=s[h],g=o[h],_=[];for(const{amount:x,denom:w}of f){if(!F(x).gt(0))continue;const C=p?.find(L=>L.denom===w),b=g?.find(L=>L.id===w)?.price,j=C?.decimals??0,k=v.fromBaseUnit(x,{decimals:j}),T=b?F(k).times(b).toNumber():void 0;_.push({...eu(w,C),amount:x,denom:w,decimals:j,quantity:k,price:b,value:T,address:C?.address,unlisted:!C,chain:Xa(m)})}i[h]=_}const c=new Map;for(const[m,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(g=>g.chainId===m);if(!f)continue;const p=h.reduce((g,{value:_})=>g+(_??0),0);c.set(m,{...Xa(f),value:p})}const l=new Map;for(const m of Object.values(i))for(const h of m)if(!h.unlisted){const{symbol:f}=h,p=l.get(f)??[];l.set(f,[...p,h])}const d=[];for(const[m,h]of l){const f=$.head(h);if(!f)continue;const p=nu(h),g=p.reduce((x,{value:w})=>x+(w??0),0),_=p.reduce((x,{quantity:w})=>x.plus(w),F(0)).toNumber();d.push({symbol:m,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:_})}const u=[];for(const m of Object.values(i))for(const h of m)h.unlisted&&u.push(h);return{chainsByValue:ou(Array.from(c.values()),a),assetGroups:tu(d),unlistedAssets:su(u,r),totalValue:d.reduce((m,h)=>m+h.totalValue,0)}}function ya(){const{defaultChainId:e}=se(),t=me(),s=Ll(),o=ns(),a=ia(),r=t.map(h=>h.chainId),i=$.zipObj(r,s.map($.prop("data"))),c=$.zipObj(r,o.map($.prop("data"))),l=$.zipObj(r,a.map($.prop("data"))),d=au(t,i,c,l,e),u=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function te(){const e=$n();return e?v.InitiaAddress(e).bech32:""}function $n(){const{address:e}=Ke.useAccount();return e?v.InitiaAddress(e).hex:""}function Ot(){const e=un(),t=te(),s=$n();return e.metadata?.minitia?.type==="minievm"?s:t}function zi(){const e=Ot(),t=ti();return S.useQuery({queryKey:Gs.username(t.restUrl,e).queryKey,queryFn:()=>t.getUsername(e),enabled:!!e,staleTime:W.MINUTE})}function Je(){const e=Ot(),t=te(),s=$n(),{data:o}=zi(),a=is(),r=xi(),i=Jd(),{isDrawerOpen:c,openDrawer:l}=Et(),{isModalOpen:d}=En(),u=()=>{l("/")},m=()=>{l("/connect")},h=w=>{l("/bridge",w)},f=dd(),p=ud(),g=oo();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:m,openWallet:u,openBridge:h,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const ru="_status_tn9m1_1",iu="_error_tn9m1_9",er={status:ru,error:iu},_e=({error:e,children:t})=>n.jsx("p",{className:D(er.status,{[er.error]:e}),children:t}),pe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(_e,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(_e,{children:"Loading..."}),children:s})=>n.jsx(Wr.ErrorBoundary,{...e,children:n.jsx(y.Suspense,{fallback:t,children:s})}),ln=1n<<64n,cu=1n<<63n,Hi=(1n<<128n)-1n;function Ut(e){const t=BigInt(e);return t>=cu?t-ln:t}const lu=(1n<<256n)-1n,Dt=443636n,du=4295048017n,uu=18446744073709551616n,mu=79226673515401279992447579062n,hu=255738958999603826347141n;function fu(e,t,s){const o=Number(Ut(e)),a=Number(Ut(t)),r=Math.floor(-Number(Dt)/s)*s,i=Math.floor(Number(Dt)/s)*s;return o===r&&a===i}function Qi(e){return e>>64n}function pu(e){const t=e>>64n;return e%ln!==0n?t+1n:t}function In(e){if(e<0n||e>Hi)throw new Error("INPUT_OUT_OF_RANGE");return e}function gu(e,t){const s=e*t>>64n;if(s>Hi)throw new Error("OVERFLOW");return s}function xa(e,t){return e>t?[t,e]:[e,t]}function _u(e,t,s,o){if(e===t)return 0n;const[a,r]=xa(e,t);if(a===0n||r===0n)return 0n;const i=s*ln,c=r-a,l=i*c;if(l===0n)return 0n;const d=a*r;return o?(l-1n)/d+1n:l/d}function yu(e,t,s,o){if(e===t)return 0n;const[a,r]=xa(e,t),c=(r-a)*s;return o?pu(In(c)):Qi(In(c))}function tr(e,t,s){return _u(e,t,s<0n?-s:s,s>=0n)}function nr(e,t,s){return yu(e,t,s<0n?-s:s,s>=0n)}const vo=1n<<64n,sr=1n<<65n,xu=64n;function bu(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<xu-1n,r=0n,i=1;for(;t>=sr;)t>>=1n,s+=vo;for(;t<vo;)i=0,t<<=1n,o+=vo;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=sr&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?In(s):In(o-s);return[i,c]}function Bt(e){const t=e<0n?-e:e;if(t>Dt)throw new Error("MAX_TICK");let s=(t&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(t&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(t&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(t&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(t&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(t&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(t&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(t&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(t&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(t&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(t&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(t&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(t&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(t&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(t&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(t&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(t&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(t&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(t&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=lu/s);const o=s/ln;return s%ln!==0n?o+1n:o}function wu(e){if(e<du||e>=mu)throw new Error("INVALID_SQRT_PRICE");const[,t]=bu(In(e)),s=gu(t,In(hu)),o=Qi(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<uu?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Dt&&(a=-Dt),i>Dt&&(i=Dt),Bt(i)<=e){if(i>=Dt)throw new Error("GTE_MAX_TICK");if(Bt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(Bt(r)<=e)return r;if(Bt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function ju(e,t,s,o){const[a,r]=xa(t,s);return e<a?[tr(a,r,o),0n]:e<r?[tr(e,r,o),nr(a,e,o)]:[0n,nr(a,r,o)]}function vu({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=Bt(Ut(e)),r=Bt(Ut(t));return ju(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const Co=ln*ln,Cu=1e-300,Nu=BigInt(Number.MAX_SAFE_INTEGER);function or(e){const t=e*e,s=t/Co,o=t%Co;return s>Nu?Number(s):Number(s)+Number(o)/Number(Co)}function ar(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,Cu)}function ku({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=Bt(Ut(e)),a=Bt(Ut(t)),r=or(o),i=or(a);return s?{min:ar(i),max:ar(r)}:{min:r,max:i}}const mn=Se.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,s)=>[e,t,s],clammFees:(e,t,s)=>[e,t,s],clammIncentive:(e,t,s,o)=>[e,t,s,o]}),ba={lens:"lens",pool:"pool",farming:"farming"},wa={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function Iu(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:v.InitiaAddress(e).hex}function Bs(e){return re.toBase64(v.InitiaAddress(Iu(e),32).bytes)}function Gi(e,t){return`${e}:${t}`}function Au(e){return`clamm:${e}`}function Su(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function Tu(e){return e.map(t=>({tokenAddress:t.token_address,lpMetadata:t.lp_metadata,tickLower:t.tick_lower,tickUpper:t.tick_upper,liquidity:t.liquidity,incentives:t.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function Eu(e){const{dexUrl:t}=se();return S.useSuspenseQuery({queryKey:mn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await G.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...Su(r.positions)),o=r.pagination.next_key||void 0}while(o);return Tu(s)},staleTime:W.MINUTE})}function $u(e){const t=oe(),{viewFunction:s}=v.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:mn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=wa[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:ba.lens,functionName:"get_pool_info",typeArgs:[],args:[Bs(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:W.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function Mu(e){const t=oe(),{viewFunction:s}=v.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:mn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=wa[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:ba.pool,functionName:"fees_available",typeArgs:[],args:[Bs(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:W.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function Lu(e){const t=oe(),{viewFunction:s}=v.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:mn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=wa[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:ba.farming,functionName:"pending_reward_info",typeArgs:[],args:[Bs(r.tokenAddress),Bs(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:W.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(Gi(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function Yi(e){const{dexUrl:t}=se(),o=S.useSuspenseQueries({queries:e.map(a=>({queryKey:mn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await G.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:W.MINUTE}))}).map(a=>a.data);return y.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function Zi(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function qu(e){return Yi(e)}function Pu(e){const t=oe(),s=Ft(t),o=y.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=y.useMemo(()=>e.map(i=>v.denomToMetadata(i)),[e]),r=Yi(a);return y.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const d=a[l];if(!d){i.set(c,null);return}const u=r.get(d);if(!u){i.set(c,null);return}if(c===rd){i.set(c,{...u,symbol:id});return}const m=u.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...u,symbol:m})}),i},[e,a,r,o])}const Ru="lock_staking";function Ji(e,t){const s=`${t}::lock_staking::StakingAccount`,o=v.createObjectAddress(e,s);return v.InitiaAddress(o).bech32}const cs=Se.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,t)=>[e,t],undelegations:(e,t,s)=>[e,t,s],lockStaking:(e,t,s)=>[e,t,s],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,s)=>[e,t,s]});function ja(){const{restUrl:e}=oe(),t=te();return S.useSuspenseQuery({queryKey:cs.delegations(e,t||"").queryKey,queryFn:async()=>t?(await G.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=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:W.MINUTE})}function va(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=se(),s=te(),o=s?Ji(s,t):"";return S.useSuspenseQuery({queryKey:cs.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await G.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await G.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const u=v.denomToMetadata(d.denom),m={denom:d.denom,metadata:u,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(u)??[];h.push(m),r.set(u,h)}}return r},staleTime:W.MINUTE})}function Ca(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=se(),s=te();return S.useSuspenseQuery({queryKey:cs.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=v.createMoveClient(e);return await o({moduleAddress:t,moduleName:Ru,functionName:"get_locked_delegations",typeArgs:[],args:[re.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:W.MINUTE})}function Xi(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=v.denomToMetadata(s.denom);let a=new F(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=t.get(o);if(r){const i=new F(r.amount);a=a.plus(i)}t.set(o,{denom:s.denom,amount:a.toString()})}return t}function ec(){const{restUrl:e}=oe(),t=te();return S.useSuspenseQuery({queryKey:cs.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await G.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:Xi,staleTime:W.MINUTE})}function tc(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=se(),s=te(),o=s?Ji(s,t):"";return S.useSuspenseQuery({queryKey:cs.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await G.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Xi,staleTime:W.MINUTE})}function Na(){const e=oe(),t=Ft(e),{data:s,isLoading:o}=Tt(e),{data:a}=ja(),{data:r}=va(),{data:i}=Ca(),c=y.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=Ls(c),d=y.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),u=y.useMemo(()=>{const f=new Map;for(const p of t)f.set(p.denom,p);return f},[t]),m=y.useMemo(()=>{const f=[],p=g=>{const _=u.get(g);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[g,_]of a){const x=l.get(g)??_[0]?.denom;if(!x)continue;const w=p(x);if(!w)continue;const C=d.get(x)??0;for(const b of _){const{symbol:j,decimals:k}=w,T=Number(v.fromBaseUnit(b.amount,{decimals:k})),L={type:"asset",denom:x,symbol:j,amount:b.amount,formattedAmount:T,decimals:k,value:T*C};f.push({type:"staking",validator:b.validator,balance:L})}}for(const[g,_]of i){const x=l.get(g);if(!x)continue;const w=p(x);if(!w)continue;const C=d.get(x)??0;for(const b of _){const{symbol:j,decimals:k}=w,T=Number(v.fromBaseUnit(b.amount,{decimals:k})),L={type:"asset",denom:x,symbol:j,amount:b.amount,formattedAmount:T,decimals:k,value:T*C},A=Number(b.releaseTime);f.push({type:"lockstaking",validator:b.validator,releaseTime:Number.isNaN(A)?0:A,balance:L})}}for(const[g,_]of r){const x=l.get(g)??_[0]?.denom;if(!x)continue;const w=p(x);if(!w)continue;const C=d.get(x)??0;for(const b of _){const{symbol:j,decimals:k}=w,T=Number(v.fromBaseUnit(b.amount,{decimals:k})),L={type:"asset",denom:x,symbol:j,amount:b.amount,formattedAmount:T,decimals:k,value:T*C},A=new Date(b.completionTime).getTime(),M=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:b.validator,completionTime:M,balance:L})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Qe)},[a,i,r,l,u,d]),h=y.useMemo(()=>m.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[m]);return{positions:m,totalValue:h,isLoading:o}}function Du(e){const t=new Map;for(const s of e){const o=v.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function Bu(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function Fu(e){const{dexUrl:t}=se();return S.useSuspenseQuery({queryKey:mn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await G.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:W.MINUTE})}function Uu(){const e=oe(),t=ss(e),s=y.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=Fu(s);return y.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return Du(a)},[t,o])}function Ou(e){const{dexUrl:t}=se();return S.useSuspenseQuery({queryKey:mn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await G.get(`${t}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:W.MINUTE})}function Vu(e,t,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of t){const c=i[0]?.denom;c&&c!==Qe&&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!==Qe&&a.add(r)}return Array.from(a)}function Ku(e){const t=[];for(const[,s]of e)s&&s!==Qe&&t.push(s);return t}function Wu(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=Zi(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 No(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Qe)continue;const l=o.get(c);if(l)for(const d of i){const u=l.decimals,m=Number(v.fromBaseUnit(String(d.amount),{decimals:u})),h=s.get(c)??0,f=m*h;l.breakdown[a]+=m,l.totalAmount+=m,l.totalValue+=f}}}function zu(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Qe)continue;const l=o.get(c);if(l)for(const d of i){const u=l.decimals,m=Number(v.fromBaseUnit(String(d.amount),{decimals:u})),h=s.get(c)??0,f=m*h;l.breakdown[a]+=m,l.totalAmount+=m,l.totalValue+=f}}}function Hu(e,t,s,o){for(const[a,r]of e){const i=v.denomToMetadata(a),c=t?.get(i),l=c?v.fromBaseUnit(c.amount,{decimals:st}):"0",d=s?.get(i),u=d?v.fromBaseUnit(d.amount,{decimals:st}):"0",m=Number(l)+Number(u);m<=0||(r.claimableInit={staking:l,lockStaking:u,total:String(m),totalValue:m*o})}}function Qu(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function ao(){const e=oe(),t=Ft(e),s=te(),o=Uu(),{data:a}=ja(),{data:r}=Ca(),{data:i}=va(),{data:c}=ec(),{data:l}=tc(),{data:d}=Tt(e),{data:u}=Eu(s),m=y.useMemo(()=>{const q=new Map;for(const P of u){const B=q.get(P.lpMetadata)??[];B.push(P),q.set(P.lpMetadata,B)}return q},[u]),h=y.useMemo(()=>Array.from(m.keys()),[m]),f=qu(h),p=$u(h),g=y.useMemo(()=>u.map(q=>q.tokenAddress),[u]),_=Mu(g),x=y.useMemo(()=>{const q=[];for(const P of u)for(const B of P.incentives)q.push({tokenAddress:P.tokenAddress,incentiveAddress:B.incentiveAddress});return q},[u]),w=Lu(x),C=y.useMemo(()=>{const q=new Set;for(const P of u)for(const B of P.incentives)q.add(B.rewardMetadata);return Array.from(q)},[u]),b=Ls(C,{failSoft:!0}),j=y.useMemo(()=>Vu(o,a,r,i),[o,a,r,i]),k=Ls(j),T=y.useMemo(()=>Ku(k),[k]),{data:L}=Ou(T),A=Pu(T),M=y.useMemo(()=>{const q=new Map;for(const P of t)q.set(P.denom,P);return q},[t]),N=y.useMemo(()=>{const q=new Map;for(const P of d??[])q.set(P.id,P.price);return q},[d]),{rows:I,totalValue:U}=y.useMemo(()=>{const q=d?.find(z=>z.id===Qe)?.price??0,P=new Map;for(const z of T)P.set(z,Wu(z,A,M));No(o,k,L,P,"deposit"),No(a,k,L,P,"staking"),zu(r,k,L,P,"lockStaking"),No(i,k,L,P,"unstaking"),Hu(P,c,l,q);for(const z of h){const K=m.get(z)??[];if(K.length===0)continue;const le=f.get(z),ye=p.get(z),he=Au(z),xe=le?.coins.map(ae=>ae.denom)??[],be=le?Zi(le,M).filter(Boolean):[],De=xe.map(ae=>M.get(ae)?.symbol||ae),ut=le?.symbol||De.join("-")||he,Mt=Bu(xe,M),mt=K.map(ae=>{let Le,Ln,qn,fn=!1,pn=0,Pn=0;try{const ht=ku({tickLower:ae.tickLower,tickUpper:ae.tickUpper});Le=ht.min,Ln=ht.max}catch{Le=void 0,Ln=void 0}if(ye){try{const ht=wu(BigInt(ye.sqrtPrice)),ze=Ut(ae.tickLower),at=Ut(ae.tickUpper),ve=Number(ye.tickSpacing);fn=Number.isFinite(ve)&&ve>0?fu(ae.tickLower,ae.tickUpper,ve):!1,qn=fn||ht>=ze&&ht<at}catch{qn=void 0,fn=!1}if(le&&xe.length>0)try{vu({sqrtPrice:ye.sqrtPrice,tickLower:ae.tickLower,tickUpper:ae.tickUpper,liquidity:ae.liquidity}).forEach((ze,at)=>{const ve=le.coins[at];if(!ve)return;const Wt=M.get(ve.denom)?.decimals??6,zt=N.get(ve.denom)??0,gn=Number(v.fromBaseUnit(String(ze),{decimals:Wt}));pn+=gn*zt})}catch{pn=0}}return le&&((_.get(ae.tokenAddress)??[]).forEach((ze,at)=>{const ve=le.coins[at];if(!ve)return;const Wt=M.get(ve.denom)?.decimals??6,zt=N.get(ve.denom)??0,gn=Number(v.fromBaseUnit(ze,{decimals:Wt}));Pn+=gn*zt}),ae.incentives.forEach(ze=>{const at=w.get(Gi(ae.tokenAddress,ze.incentiveAddress))??"0",ve=b.get(ze.rewardMetadata);if(!ve)return;const Wt=M.get(ve)?.decimals??6,zt=N.get(ve)??0,gn=Number(v.fromBaseUnit(at,{decimals:Wt}));Pn+=gn*zt})),{tokenAddress:ae.tokenAddress,positionId:Qu(ae.tokenAddress),inRange:qn,isFullRange:fn,minPrice:Le,maxPrice:Ln,pricePairLabel:Mt,rewardValue:Pn,value:pn}}),Te=mt.reduce((ae,Le)=>ae+Le.value,0),O=mt.reduce((ae,Le)=>ae+Le.rewardValue,0),Ee=be.length>0;P.set(he,{denom:he,symbol:ut,totalAmount:0,totalValue:Te,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:Ee?be:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:z,totalRewardValue:O,positions:mt}})}const B=Array.from(P.values()).filter(z=>z.totalAmount>0||z.isClamm).sort((z,K)=>K.totalValue-z.totalValue),H=B.reduce((z,K)=>z+K.totalValue,0);return{rows:B,totalValue:H}},[d,T,A,M,o,a,r,i,k,L,c,l,h,m,f,p,_,w,b,N]);return{totalValue:U,rows:I}}const Gu=Se.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function Yu(e){return e.filter(t=>t.data.length>0).map(t=>{const s=t.data[0].bridge_id,o=t.data[0].version,a=t.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:t.total_claimable_reward,claimedReward:a,initialReward:t.total_vesting_reward,lockedReward:t.total_locked_reward,requiredScore:t.required_score,rollup:{bridgeId:s,version:o}}}).filter(t=>t.initialReward>0).toSorted((t,s)=>s.initialReward-t.initialReward)}function nc(){const{vipUrl:e}=se(),t=te();return S.useQuery({queryKey:Gu.allVestingPositions(e,t).queryKey,queryFn:async()=>(await G.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:W.MINUTE,enabled:!!t})}function Zu(){const e=me();return y.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function ro(){const{data:e}=nc(),t=oe(),{data:s}=Tt(t),o=Zu(),a=y.useMemo(()=>s?.find(l=>l.id===Qe)?.price??0,[s]),r=y.useMemo(()=>e?Yu(e).map(l=>{const d=o(l.rollup.bridgeId),u=Number(v.fromBaseUnit(String(l.lockedReward),{decimals:st})),m=Number(v.fromBaseUnit(String(l.claimableReward),{decimals:st})),h=F(v.fromBaseUnit(String(l.lockedReward),{decimals:st})).times(a).toNumber(),f=F(v.fromBaseUnit(String(l.claimableReward),{decimals:st})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:h,claimableReward:m,claimableRewardValue:f}}).filter(l=>l.lockedReward+l.claimableReward>0):[],[e,a,o]),i=y.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function sc(){const{totalValue:e}=ao(),{data:t}=ja(),{data:s}=Ca(),{data:o}=va(),{data:a}=nc(),r=y.useMemo(()=>Array.from(s.keys()),[s]),i=Ls(r),c=oe(),{data:l}=Tt(c),d=y.useMemo(()=>l?.find(m=>m.id===Qe)?.price??0,[l]);return y.useMemo(()=>{let u=0,m=0;const h=d??0;for(const[,p]of t)for(const{denom:g,amount:_}of p)g===Qe&&(u+=Number(v.fromBaseUnit(_,{decimals:st}))*h);for(const[p,g]of s)if(i.get(p)===Qe)for(const{amount:_}of g)m+=Number(v.fromBaseUnit(_,{decimals:st}))*h;for(const[,p]of o)for(const{denom:g,amount:_}of p)g===Qe&&(u+=Number(v.fromBaseUnit(_,{decimals:st}))*h);let f=0;if(a)for(const p of a){const g=p.total_locked_reward??0,_=p.total_claimable_reward??0;f+=Number(v.fromBaseUnit(String(g+_),{decimals:st}))*h}return u+m+e+f},[t,s,i,o,a,d,e])}function Ju(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],t={"initia-wallet-widget:ethereum-public-keys":{prefix:ie.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(t)){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 Ko=Se.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,s)=>[e,t,s],initiaPositions:(e,t)=>[e,"initia",t],echelonPositions:(e,t)=>[e,"echelon",t],inertiaPositions:(e,t)=>[e,"inertia",t],ravePositions:(e,t,s)=>[e,"rave",t,s],yominetPositions:(e,t)=>[e,"yominet",t],chainPositions:(e,t,s)=>[e,t,s]});function ka(e,t){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=t[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const d=`${i.chainId}:${l.denom}`;s.has(d)||s.set(d,l.logoUrl);const u=l.symbol.toUpperCase();o.has(u)||o.set(u,l.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 t=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-t:t}function Xu(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 em(e,t=!1){switch(e){case"staking":return t?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function tm(e){const t=new Map;for(const d of e){const u=Xu(d);if(!u)continue;const m=t.get(u)??[];m.push(d),t.set(u,m)}const s=new Map,o=new Map;for(const[d,u]of t){const m=u.reduce((f,p)=>f+An(p),0),h=u.reduce((f,p)=>f+Math.abs(An(p)),0);s.set(d,m),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((d,u)=>{const m=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:h-m}),l=new Map;for(const d of c)l.set(d,{positions:t.get(d),totalValue:s.get(d)??0});return l}function nm(e){return e.type==="fungible-position"?e.title:e.balance.denom}function sm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function om(e){return e.type==="fungible-position"?null:e.balance}function am(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 rm(e){const t=new Map;for(const s of e){const o=t.get(s.type)??[];o.push(s),t.set(s.type,o)}return t}function im(e,t){return e.symbol===it&&t.symbol===it?0:e.symbol===it?-1:t.symbol===it?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function cm(e){const t=new Map;for(const o of e){const a=nm(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=om(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:sm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+An(l),0),totalAmount:i,balance:r}}).toSorted(im)}function oc(e,t){const s=new Map;return e.forEach((o,a)=>{const r=t[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function lm(e,t){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=t.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function dm(e,t){return e.symbol===it&&t.symbol===it?0:e.symbol===it?-1:t.symbol===it?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function um(e,t,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,d=t.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 mm(e,t,s){const o=t?e.filter(i=>{const{symbol:c,assets:l}=i,d=t.toLowerCase();return c.toLowerCase().includes(d)||l.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function hm(e,t,s){const o=t?e.filter(({denom:a,address:r})=>{const i=t.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function fm(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=mm(e,s,o),i=hm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function pm(e,t,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:d,balances:u}=c;if(!Array.isArray(u))continue;const m=t.get(l.toLowerCase()),h=m?.chainId??d??l,f=m?.prettyName??l,p=m?.logoUrl??"",g=s.get(h);for(const _ of u){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 x=_.value;if((x==null||x<=0)&&g){const b=g.get(_.denom)??0;b>0&&(x=_.formattedAmount*b)}const w={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:p}},C=a.get(_.symbol);C?C.push(w):a.set(_.symbol,[w])}}r.sort((c,l)=>{const d=c.chain.chainId===o,u=l.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const m=c.chain.name.localeCompare(l.chain.name);if(m!==0)return m;try{const h=BigInt(c.amount),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((m,h)=>(h.value??0)-(m.value??0));let d=0,u=0;for(const m of l)d+=m.value??0,u+=Number(m.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:u})}return i.sort(dm),{listedGroups:i,unlistedAssets:r}}function Ia(){return oe().network_type==="testnet"}function Vt(){return Ne.useFormContext()}function gm(){const e=Ze(),t=Ia(),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=$.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(ie.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(ie.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(ie.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(ie.BRIDGE_DST_DENOM),quantity:localStorage.getItem(ie.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(ie.BRIDGE_SLIPPAGE_PERCENT)});return{...t?o:a,...r,...e}}const _m={balances:[],positions:[],isLoading:!0,isComplete:!1},ac=Q.atom(0),ym=1e3;let rr=0;function xm(){const e=Q.useSetAtom(ac);y.useEffect(()=>{const t=Date.now();t-rr>=ym&&(rr=t,e(s=>s+1))},[e])}function bm(){const e=S.useQueryClient(),t=te(),{minityUrl:s}=se(),o=Ia(),a=Q.useAtomValue(ac),r=y.useEffectEvent((l,d)=>{const u=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:u})}),i=y.useEffectEvent((l,d)=>{const u=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:u})}),c=y.useEffectEvent((l,d)=>{const u=Ko.ssePortfolio(t??"",s).queryKey,m=e.getQueryData(u)??_m,h=l.size>0||d.size>0;e.setQueryData(u,{...m,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:m.isLoading,isComplete:!1})});y.useEffect(()=>{if(!t||o)return;const l=Ko.ssePortfolio(t,s).queryKey,d=e.getQueryData(l),u=new Map,m=new Map;for(const _ of d?.balances??[])u.set(_.chainName,_);for(const _ of d?.positions??[])m.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;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 x=JSON.parse(_.data);x.type==="balances"?r(x,u):x.type==="positions"&&i(x,m),c(u,m)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[t,o,a])}const ir={balances:[],positions:[],isLoading:!0,isComplete:!1};function ls(){const e=te(),{minityUrl:t}=se(),s=Ko.ssePortfolio(e??"",t).queryKey,{data:o}=S.useQuery({queryKey:s,queryFn:()=>ir,enabled:!!e,staleTime:W.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??ir}function wm(){const e=me();return y.useMemo(()=>{const t=new Map;for(const s of e){const o=s.chain_name.toLowerCase();t.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return t},[e])}function jm(){const{balances:e,positions:t}=ls(),s=me(),o=y.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return y.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(t)?t:[];for(const{chainName:f,balances:p}of l){if(!Array.isArray(p))continue;const g=p.reduce((_,x)=>_+r(x),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((_,x)=>_+i(x),0);c.set(f,(c.get(f)||0)+g)}const u=Array.from(c.values()).reduce((f,p)=>f+p,0),m=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:u>0?p/u:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return $.sortWith([$.descend(h),$.descend($.prop("totalBalance"))],m)},[e,t,o])}function vm(){const{balances:e}=ls(),t=me(),s=ia(),o=y.useMemo(()=>oc(t,s),[t,s]);return y.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=lm(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 Cm(){const{positions:e}=ls();return y.useMemo(()=>{const t=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,d)=>l+t(d),0))}return o},[e])}const we=Se.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:F(e.quantity||0).toString()},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function Re(){const{routerApiUrl:e}=se();return y.useMemo(()=>G.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.4.4"}}),[e])}function Nm(){const e=Re();S.usePrefetchQuery({queryKey:we.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:W.MINUTE}),S.usePrefetchQuery({queryKey:we.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:W.MINUTE})}const km=()=>(Rl(),Dl(),null),Im="_loader_1vxch_1",Am={loader:Im},jt=({size:e=24,color:t="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${s}px`};return n.jsx("div",{className:Am.loader,style:o})},Sm="_button_1q027_1",Tm="_outline_1q027_28",Em="_sm_1q027_46",$m="_full_1q027_53",Mm="_small_1q027_57",Lm="_unpadded_1q027_88",nn={button:Sm,outline:Tm,sm:Em,full:$m,small:Mm,unpadded:Lm},rc=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:D(nn.button,{[nn.sm]:t,[nn.full]:s},a),disabled:!!o||i,children:o?n.jsxs(n.Fragment,{children:[n.jsx(jt,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:nn.loading,children:o})]}):r})},qm=({className:e,...t})=>n.jsx(rc,{...t,className:D(nn.outline,e)}),Pm=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:D(nn.small,{[nn.unpadded]:t},e)}),ue={White:rc,Outline:qm,Small:Pm},Rm="_footer_1vp4h_1",Dm="_actions_1vp4h_10",cr={footer:Rm,actions:Dm},ke=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:D(cr.footer,t),children:[e,n.jsx("div",{className:cr.actions,children:s})]}),Bm="_scrollable_13su7_1",Fm={scrollable:Bm},dt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:D(Fm.scrollable,e),children:t}),Um="interwovenkit:";function Om(e){const[t]=e;return typeof t=="string"&&t.startsWith(Um)}function Vm(e){e.removeQueries({predicate:t=>Om(t.queryKey)})}function io(){return We.useMediaQuery("(max-width: 576px)")}const Wo="interwoven-kit";function ic(){const e=document.querySelector(Wo)||document.body.appendChild(document.createElement(Wo));return e.shadowRoot||e.attachShadow({mode:"open"})}function cc(){const{theme:e,container:t}=se();return y.useEffect(()=>{document.querySelector(Wo)?.setAttribute("data-theme",e)},[e]),t??ic()}function Km(e){const t=ic(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const co=y.createContext(null);function dn(){const{container:e}=y.useContext(co);return e}function lc(e){const t=dn();return t?getComputedStyle(t).getPropertyValue(e):""}function Wm(){return We.useScrollLock(),null}function zm(e){return/^[A-F0-9]{64}$/i.test(e)}function Hm(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return zm(s)?$.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!v.InitiaAddress.validate(o))return;const i=$.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Qm(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const Gm="_link_j1lkz_1",lr={link:Gm},lo=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,u=lt(e),m=Hm(u,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?v.truncate(t):s?v.truncate(s):"",f=c??h;return m?n.jsxs("a",{...d,href:pl(Qm(m)),className:D(lr.link,i),onClick:l,target:"_blank",children:[f,r&&n.jsx(E.IconExternalLink,{size:12})]}):n.jsx("span",{...d,className:D(lr.link,i),children:f})},dc=y.createContext(null),uo=()=>y.useContext(dc),Ym=()=>{const[e,t]=Q.useAtom(Di),{showNotification:s,updateNotification:o,hideNotification:a}=uo();return y.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?n.jsx(lo,{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}),t(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),t(null);break}},[e,t,s,o,a]),null},Fs=({value:e,children:t})=>{const[s,o]=y.useState(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Zm="_placeholder_10r3x_1",Jm="_logo_10r3x_5",dr={placeholder:Zm,logo:Jm},ee=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=y.useState(void 0),{width:d,height:u}=i,m=s??n.jsx("div",{className:D(dr.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||c===e?m:n.jsx("img",{...i,className:D(i.className,{[dr.logo]:r}),style:{width:d,height:u,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function uc(){const{connector:e}=Ke.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Xm="_header_1q8ju_1",eh="_account_1q8ju_17",th="_name_1q8ju_28",nh="_address_1q8ju_32",sh="_icon_1q8ju_36",oh="_copied_1q8ju_43",ah="_button_1q8ju_58",rh="_settings_1q8ju_69",ih="_disconnect_1q8ju_73",ch="_label_1q8ju_83",lh="_expanded_1q8ju_91",Xe={header:Xm,account:eh,name:th,address:nh,icon:sh,copied:oh,button:ah,settings:rh,disconnect:ih,label:ch,expanded:lh},dh=()=>{const e=xi(),{address:t,username:s}=Je(),o=uc(),a=s??t,[r,i]=y.useState(!1),c=y.useRef(null),l=bt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:Xe.header,children:[n.jsx(Fs,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:D(Xe.account,{[Xe.copied]:f}),onClick:h,children:[n.jsx(ee,{src:o,width:18,height:18}),n.jsx("div",{className:Xe.address,children:v.truncate(t)}),n.jsx("div",{className:Xe.name,children:v.truncate(a)}),n.jsx(E.IconCopy,{className:Xe.icon,size:12}),f?"Copied!":""]})}),n.jsx(Nn,{to:"/settings",className:D(Xe.button,Xe.settings),"aria-label":"Open settings",children:n.jsx(E.IconSettingFilled,{size:16})}),n.jsxs(bt.animated.button,{className:D(Xe.button,Xe.disconnect,{[Xe.expanded]:r}),style:l,onClick:d,onMouseLeave:u,onMouseEnter:m,children:[n.jsx(E.IconSignOut,{size:16}),n.jsx("span",{className:Xe.label,children:"Disconnect"})]})]}):null},uh="_overlay_jij9g_1",mh="_content_jij9g_28",hh="_inner_jij9g_60",ko={overlay:uh,content:mh,inner:hh},fh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=Et(),{setContainer:o}=y.useContext(co),a=io(),r=cc(),i=Q.useAtomValue(so),c=Q.useAtomValue(os),l=S.useIsMutating({mutationKey:[Ri]}),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"))},u=Zs(),m=Ie(),h=S.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const _=()=>{u==="/bridge"&&(localStorage.removeItem(ie.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_SRC_DENOM),localStorage.removeItem(ie.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_DST_DENOM)),m("/"),Vm(h),g()};return n.jsxs(dt,{children:[n.jsx(_e,{error:!0,children:p.message}),n.jsx(ke,{children:n.jsx(ue.White,{onClick:_,children:"Retry"})})]})}};return n.jsx(Pe.Dialog.Root,{open:t,onOpenChange:p=>!p&&d(),modal:!1,children:n.jsxs(Pe.Dialog.Portal,{container:r,children:[a&&n.jsx(Pe.Dialog.Backdrop,{className:ko.overlay,onClick:d,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[n.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),n.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),n.jsx(Pe.Dialog.Popup,{className:ko.content,children:n.jsxs("div",{className:D(ko.inner,"body"),ref:o,children:[a&&n.jsx(Wm,{}),n.jsx(Ym,{}),n.jsx(dh,{}),n.jsx(pe,{errorBoundaryProps:f,children:e})]})})]})})},ph="_backdrop_1bqx9_1",gh="_modal_1bqx9_12",_h="_closeButton_1bqx9_44",Io={backdrop:ph,modal:gh,closeButton:_h},yh=({children:e})=>{const{isModalOpen:t,closeModal:s}=En(),{setContainer:o}=y.useContext(co),a=cc();return n.jsx(Pe.Dialog.Root,{open:t,onOpenChange:r=>!r&&s(),children:n.jsxs(Pe.Dialog.Portal,{container:a,children:[n.jsx(Pe.Dialog.Backdrop,{className:Io.backdrop,onClick:s}),n.jsxs(Pe.Dialog.Popup,{className:Io.modal,ref:o,children:[n.jsx("button",{className:Io.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(E.IconClose,{size:20})}),n.jsx(pe,{children:e})]})]})})},mc=y.createContext(!1),xh="_overlay_1iyfl_1",bh="_fullscreen_1iyfl_15",wh="_content_1iyfl_19",jh="_header_1iyfl_56",vh="_title_1iyfl_65",Ch="_close_1iyfl_70",Qt={overlay:xh,fullscreen:bh,content:wh,header:jh,title:vh,close:Ch},hc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=dn(),c=y.useContext(mc);return i?n.jsxs(Pe.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Pe.Dialog.Trigger,{className:o,children:s}),n.jsxs(Pe.Dialog.Portal,{container:i,children:[n.jsx(Pe.Dialog.Backdrop,{className:D(Qt.overlay,{[Qt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Pe.Dialog.Popup,{className:D(Qt.content,{[Qt.fullscreen]:c}),children:[e&&n.jsxs("header",{className:Qt.header,children:[n.jsx(Pe.Dialog.Title,{className:Qt.title,children:e}),n.jsx(Pe.Dialog.Close,{className:Qt.close,children:n.jsx(E.IconClose,{size:20})})]}),t]})]})]}):null},Jn=({children:e})=>{const t=y.useRef(null),[s,o]=y.useState(0),[a,r]=y.useState(!1),i=bt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return y.useEffect(()=>{const c=t.current;if(!c)return;const l=()=>{const{height:u}=c.getBoundingClientRect();o(u),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?n.jsx(bt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},Nh="_help_qcmtq_1",kh="_icon_qcmtq_10",Ih="_info_qcmtq_19",Ah="_warning_qcmtq_23",Sh="_error_qcmtq_27",Th="_success_qcmtq_33",Ao={help:Nh,icon:kh,info:Ih,warning:Ah,error:Sh,success:Th},wn=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(jt,{size:12});case"info":return n.jsx(E.IconInfoFilled,{size:12});case"warning":case"error":return n.jsx(E.IconWarningFilled,{size:12});default:return n.jsx(E.IconCheckCircleFilled,{size:12})}};return n.jsxs("div",{className:D(Ao.help,e&&Ao[e],t),style:{marginTop:s},children:[n.jsx("div",{className:Ao.icon,children:a()}),o]})},Eh="_stack_a6m7u_1",$h="_help_a6m7u_6",Mh="_info_a6m7u_14",Lh="_warning_a6m7u_19",qh="_error_a6m7u_24",Ph="_success_a6m7u_29",zo={stack:Eh,help:$h,info:Mh,warning:Lh,error:qh,success:Ph},Rh=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(Jn,{children:n.jsx("div",{className:zo.stack,children:e})}),ge=({mt:e=0,...t})=>n.jsx(wn,{...t,className:D(zo.help,zo[t.level]),mt:e});ge.Stack=Rh;const Dh="_root_16p5j_1",Bh="_item_16p5j_10",Fh="_chevron_16p5j_14",Uh="_trigger_16p5j_19",Oh="_content_16p5j_39",Dn={root:Dh,item:Bh,chevron:Fh,trigger:Uh,content:Oh};function Vh(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(Z.Accordion.Root,{className:Dn.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(Z.Accordion.Item,{className:Dn.item,value:s?.(c)??String(l),children:[n.jsx(Z.Accordion.Header,{children:n.jsxs(Z.Accordion.Trigger,{className:Dn.trigger,children:[o(c),n.jsx(E.IconChevronDown,{className:Dn.chevron,size:16})]})}),n.jsx(Z.Accordion.Content,{className:Dn.content,children:a(c)})]},s?.(c)??l)),r]})}const Kh="_trigger_u613p_1",Wh="_icon_u613p_18",zh="_content_u613p_27",Hh="_item_u613p_36",Qh="_itemText_u613p_52",Gh="_itemIndicator_u613p_57",Yh="_active_u613p_60",qt={trigger:Kh,icon:Wh,content:zh,item:Hh,itemText:Qh,itemIndicator:Gh,active:Yh};function Aa({options:e,value:t,onChange:s,classNames:o}){const a=dn(),r=e.find(c=>c.value===t);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 n.jsxs(It.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(It.Select.Trigger,{className:D(qt.trigger,o?.trigger),children:[n.jsx(It.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(It.Select.Icon,{className:qt.icon,children:n.jsx(E.IconChevronDown,{size:12})})]}),n.jsx(It.Select.Portal,{container:a,children:n.jsx(It.Select.Positioner,{className:qt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(It.Select.Popup,{className:qt.popup,children:e.map(c=>n.jsxs(It.Select.Item,{className:D(qt.item,o?.item),value:String(c.value),children:[n.jsx(It.Select.ItemText,{className:D(qt.itemText,o?.itemText),children:c.label}),n.jsx(E.IconCheck,{size:12,className:D(qt.itemIndicator,{[qt.active]:c.value===t})})]},String(c.value)))})})})]})}const Zh="_root_1t37n_1",Jh="_trigger_1t37n_7",Xh="_item_1t37n_11",ef="_itemText_1t37n_17",ur={root:Zh,trigger:Jh,item:Xh,itemText:ef},tf=({options:e,value:t,onChange:s})=>{const{txRequest:o}=Fi(),a=lt(o.chainId),r=Ct(a),i=(p,g)=>{if(v.formatAmount(p,{decimals:g})==="0.000000")return 8},c=({amount:[{amount:p,denom:g}]})=>{if(F(p).isZero())return"0";const{symbol:_,decimals:x}=r(g),w=i(p,x);return`${v.formatAmount(p,{decimals:x,dp:w})} ${_}`},l=e.map(p=>{const[{denom:g}]=p.amount,{symbol:_}=r(g);return{value:g,label:c(p),triggerLabel:_}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===t);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:m}]=d.amount,{decimals:h}=r(m),f=i(u,h);return n.jsxs("div",{className:ur.root,children:[n.jsx("span",{className:"monospace",children:v.formatAmount(u,{decimals:h,dp:f})}),n.jsx(Aa,{options:l,value:t,onChange:s,classNames:ur})]})},nf="_root_16nr2_1",sf="_trigger_16nr2_5",of="_chevron_16nr2_13",af="_panel_16nr2_27",rf="_details_16nr2_39",cf="_row_16nr2_48",yn={root:nf,trigger:sf,chevron:of,panel:af,details:rf,row:cf},lf=({spend:e,fee:t,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:t},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return n.jsxs(bo.Collapsible.Root,{className:yn.root,children:[n.jsxs(bo.Collapsible.Trigger,{className:yn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(E.IconChevronDown,{className:yn.chevron,size:16})]}),n.jsx(bo.Collapsible.Panel,{className:yn.panel,children:n.jsx("div",{className:yn.details,children:i.map(({label:l,value:d})=>n.jsxs("div",{className:yn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[v.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function Us(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?re.toBase64(e):Array.isArray(e)?`[${e.map(Us).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const df="_container_1xzyq_1",uf="_toggle_1xzyq_5",mf="_list_1xzyq_11",hf="_arg_1xzyq_16",ff="_type_1xzyq_21",Bn={container:df,toggle:uf,list:mf,arg:hf,type:ff},pf=Se.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),gf=({type:e,arg:t})=>Us(v.resolveBcsType(e).parse(t)),_f=({msg:e,chainId:t,fallback:s})=>{const[o,a]=We.useToggle(!1),{restUrl:r}=lt(t),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:u}=S.useQuery({queryKey:pf.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await G.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:W.INFINITY});if(!u)return s;const m=(h,f)=>{const p=u[f];return n.jsxs("div",{className:Bn.arg,children:[n.jsx("div",{className:Bn.type,children:p}),n.jsx(Wr.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(gf,{type:p,arg:h})})]},f)};return n.jsxs("div",{className:Bn.container,children:[n.jsx(ue.Small,{className:Bn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Bn.list,children:d.map(m)}):s]})},yf="_list_oip9m_1",xf="_key_oip9m_9",bf="_value_oip9m_14",So={list:yf,key:xf,value:bf},wf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:So.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:So.key,children:a}),n.jsx("div",{className:So.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(_f,{msg:o,chainId:t,fallback:Us(r)}):Us(r)})]},a))})},jf="_item_1n572_1",vf="_title_1n572_10",Cf="_content_1n572_14",To={item:jf,title:vf,content:Cf},Eo=({title:e,content:t})=>n.jsxs("div",{className:To.item,children:[n.jsx("div",{className:To.title,children:e}),n.jsx("div",{className:To.content,children:t})]});function X(e){const t=e?F(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return"< $0.01";const s=e&&F(e).lt(0),o=v.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function fc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const 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===t&&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 pc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(t,u)===l){const h=s[u]||BigInt(0);s[u]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(t,u)===l){const h=s[u]||BigInt(0);s[u]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const gc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=S.useSuspenseQuery({queryKey:kn.denom(o,e).queryKey,queryFn:()=>G.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:W.INFINITY});return s(a)},Nf="_root_1p8a4_1",kf="_title_1p8a4_8",If="_changes_1p8a4_14",Af="_change_1p8a4_14",Sf="_amount_1p8a4_35",Tf="_text_1p8a4_42",Ef="_value_1p8a4_49",sn={root:Nf,title:kf,changes:If,change:Af,amount:Sf,text:Tf,value:Ef},_c=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=v.formatAmount(e,{decimals:r}),l=s&&F(v.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:sn.change,children:[n.jsxs("div",{className:sn.amount,children:[n.jsx(ee,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:sn.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:sn.value,children:X(l)})]})},$f=({changes:e,chain:t})=>{const s=Ct(t),{data:o}=Tt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return n.jsx(_c,{amount:a,asset:c,price:l},i)})},Mf=({changes:e,chain:t})=>{const s=Ct(t),{data:o}=Tt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(gc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return n.jsx(_c,{amount:a,asset:s(c),price:l})}},i))};function Lf(e,t){return typeof t=="bigint"?t.toString():t}const qf=Se.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Lf)]}),Pf=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=Je(),r=lt(s),{simulateTx:i}=oo(),{data:c}=S.useSuspenseQuery({queryKey:qf.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:W.SECOND}),l=h=>n.jsxs("div",{className:sn.root,children:[n.jsx("h2",{className:sn.title,children:"Estimated changes"}),n.jsx("div",{className:sn.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=pc(d,a),[f]=mr(h);return f.length===0?null:l(n.jsx(Mf,{changes:f,chain:r}))}const u=fc(d,o),[m]=mr(u);return m.length===0?null:l(n.jsx($f,{changes:m,chain:r}))};function mr(e){return $.partition(t=>new F(t.amount).isNegative(),e)}const Rf="_title_1d032_1",Df="_meta_1d032_7",Bf="_footer_1d032_14",Ff="_rejectButton_1d032_19",ws={title:Rf,meta:Df,footer:Bf,rejectButton:Ff},yc=()=>{const{txRequest:e,resolve:t,reject:s}=Fi(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=lt(r),u=ss(d),m=ga(d),h=_a(d),f=Ct(d),p=Bi(),g=(e.gasPrices??m).map(({amount:A,denom:M})=>Ae.calculateFee(Math.ceil(i*c),Ae.GasPrice.fromString(A+M))),_=g.map(A=>A.amount[0]),x=A=>{const M=u.find(H=>H.denom===A)?.amount??"0",N=_.find(H=>H.denom===A)?.amount??"0",I=l.filter(H=>H.denom===A).reduce((H,z)=>F(H).plus(z.amount),F("0")),U=F(N).plus(I),q=F(M).gte(U),{symbol:P,decimals:B}=f(A);return{symbol:P,decimals:B,spend:I.gt(0)?I.toFixed():null,fee:N,total:U.toFixed(),balance:M,isSufficient:q}},w=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of _)if(x(A).isSufficient)return A;return _[0]?.denom},[C,b]=y.useState(w),{mutate:j,isPending:k}=S.useMutation({mutationKey:[Ri],mutationFn:async()=>{const A=g.find(N=>N.amount[0].denom===C);if(!A)throw new Error("Fee not found");const M=await p({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:C,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t(M)},onError:async A=>{s(A)}}),T=x(C),L=!T.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(dt,{children:[n.jsx("h1",{className:ws.title,children:"Confirm tx"}),n.jsxs("div",{className:ws.meta,children:[n.jsx(Eo,{title:"Chain",content:r}),n.jsx(Eo,{title:"Tx fee",content:n.jsx(tf,{options:g,value:C,onChange:b})}),a&&n.jsx(Eo,{title:"Memo",content:a}),L&&n.jsx(ge,{level:"error",children:n.jsx(lf,{...T})})]}),n.jsx(Pf,{messages:o,memo:a,chainId:r}),n.jsx(Vh,{list:o,renderHeader:({typeUrl:A})=>zs.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(wf,{message:A,chainId:r})})]}),n.jsxs(ke,{className:ws.footer,children:[n.jsx(ue.Outline,{onClick:()=>s(new Error("User rejected")),disabled:k,className:ws.rejectButton,"aria-label":"Reject",children:n.jsx(E.IconClose,{size:16})}),n.jsx(ue.White,{onClick:()=>j(),disabled:L,loading:k,children:"Approve"})]})]})},Uf=({children:e})=>{const[{title:t,content:s,path:o},a]=y.useState({}),[r,i]=y.useState(!1),c=Q.useAtomValue(so),l=y.useCallback(m=>{a(m),i(!0)},[]),d=y.useCallback(()=>{a({}),i(!1)},[]),u=y.useCallback(m=>{m||(c?.reject(new Error("User rejected")),a({})),i(m)},[c]);return n.jsxs(Mi.Provider,{value:{openModal:l,closeModal:d},children:[e,n.jsx(hc,{title:t,open:r,onOpenChange:u,children:n.jsx(pe,{children:o==="/tx"?n.jsx(yc,{}):s})})]})},Of="_container_1w1hx_1",Vf="_toast_1w1hx_11",Kf="_info_1w1hx_24",Wf="_success_1w1hx_28",zf="_error_1w1hx_32",Hf="_icon_1w1hx_37",Qf="_content_1w1hx_45",Gf="_title_1w1hx_48",Yf="_description_1w1hx_53",Zf="_close_1w1hx_75",Pt={container:Of,toast:Vf,info:Kf,success:Wf,error:zf,icon:Hf,content:Qf,title:Gf,description:Yf,close:Zf},Jf=({notification:e,onClose:t,...s})=>{const o=bt.useTransition(e,{keys:r=>r?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),a=r=>{switch(r){case"loading":return n.jsx(jt,{size:16});case"info":case"success":return n.jsx(E.IconCheckCircleFilled,{size:16});case"error":return n.jsx(E.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,u=a(c);return n.jsx(bt.animated.div,{style:r,className:Pt.container,children:n.jsxs("div",{className:D(Pt.toast,c&&Pt[c]),...s,children:[u&&n.jsx("div",{className:Pt.icon,children:u}),n.jsxs("div",{className:Pt.content,children:[n.jsx("p",{className:Pt.title,children:l}),d&&n.jsx("div",{className:Pt.description,children:d})]}),n.jsx("button",{className:Pt.close,onClick:t,children:n.jsx(E.IconClose,{size:14})})]})})})},$o=5e3,Xf=({children:e})=>{const t=dn(),[s,o]=y.useState(null),a=y.useRef(null),r=y.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=y.useCallback(()=>{i(),o(null)},[]),l=y.useCallback(h=>{i(),o({...h,id:Qa.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),$o))},[c]),d=y.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:Qa.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),$o))},[c]),u=()=>{i(),r.current=!0},m=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),$o))};return y.useEffect(()=>()=>i(),[]),n.jsxs(dc.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,t&&gl.createPortal(n.jsx(Jf,{notification:s,onClose:c,onMouseEnter:u,onMouseLeave:m}),t)]})},ep=({children:e})=>{const[t,s]=y.useState(null);return n.jsx(co.Provider,{value:{container:t,setContainer:s},children:e})},xc=[{value:10*pi,label:"for 10 minutes"},{value:gi,label:"for 1 hour"},{value:Ja,label:"for 1 day"},{value:7*Ja,label:"for 7 days"},{value:0,label:"until revoked"}],tp=xc[0].value;function np(e){const t=e.split(".");return t.length!==4?!1:t.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function bc(e){return np(e)||e.includes(":")}function Ho(e){const t=_l.parse(e);return"error"in t?null:t.domain}function sp(e,t){return e===t||e===`www.${t}`}function op(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||bc(t)?!1:Ho(t)!==null}function ap(e,t){try{const s=new URL(e);if(!op(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||bc(a)||a==="localhost")return!1;const r=Ho(o);if(!r)return!1;const i=Ho(a);return!i||i!==r?!1:sp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const rp="_container_1422v_1",ip="_title_1422v_7",cp="_description_1422v_14",lp="_sectionTitle_1422v_20",dp="_websiteInfo_1422v_27",up="_favicon_1422v_37",mp="_websiteTitle_1422v_42",hp="_websiteHost_1422v_48",fp="_warningContent_1422v_54",pp="_ignoreButton_1422v_61",gp="_infoList_1422v_65",_p="_infoItem_1422v_75",yp="_label_1422v_84",xp="_infoValue_1422v_94",bp="_durationTrigger_1422v_100",wp="_durationItem_1422v_101",jp="_featureList_1422v_105",vp="_featureItem_1422v_113",Cp="_checkIcon_1422v_123",Np="_learnMoreLink_1422v_127",kp="_feedbackContainer_1422v_140",Ip="_footer_1422v_146",ce={container:rp,title:ip,description:cp,sectionTitle:lp,websiteInfo:dp,favicon:up,websiteTitle:mp,websiteHost:hp,warningContent:fp,ignoreButton:pp,infoList:gp,infoItem:_p,label:yp,infoValue:xp,durationTrigger:bp,durationItem:wp,featureList:jp,featureItem:vp,checkIcon:Cp,learnMoreLink:Np,feedbackContainer:kp,footer:Ip};function Ap(e){return e instanceof G.HTTPError&&e.response.status===404}const Sp=Se.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=G.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(Ap(a))return!1;throw a}}})}),Tp=()=>{const[e,t]=y.useState(tp),[s,o]=Q.useAtom(os),[a,r]=y.useState(!1),i=Ye(),c=me(),{address:l,username:d}=Je(),{mutate:u,isPending:m}=Zd(),{closeDrawer:h}=Et();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:_,isLoading:x,isError:w}=S.useQuery(Sp.info(g,l)),C={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},b=c.find(I=>I.chainId===s.chainId),j=b?.website?ap(b.website,window.location.hostname):!1,k=()=>{u(e)},T=()=>{s?.reject(new Error("User cancelled")),o(null),h()},L=!j&&!a,A=!x&&!w&&_===!1,M=!x&&w,N=L||x||w||_===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(dt,{className:ce.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:ce.title,children:"Enable auto-signing"}),n.jsx("p",{className:ce.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:ce.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:ce.websiteInfo,children:[n.jsx("img",{src:C.favicon,alt:"",className:ce.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:ce.websiteTitle,children:C.title}),n.jsx("div",{className:ce.websiteHost,children:C.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:ce.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:ce.infoList,children:[n.jsxs("div",{className:ce.infoItem,children:[n.jsx("div",{className:ce.label,children:"Address"}),n.jsxs("div",{className:ce.infoValue,children:[n.jsx(E.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),n.jsxs("div",{className:ce.infoItem,children:[n.jsx("div",{className:ce.label,children:"Chain"}),n.jsxs("div",{className:ce.infoValue,children:[n.jsx(ee,{src:f,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:ce.infoItem,children:[n.jsx("div",{className:ce.label,children:"Duration"}),n.jsx(Aa,{options:xc,value:e,onChange:t,classNames:{trigger:ce.durationTrigger,item:ce.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:ce.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:ce.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(I=>n.jsxs("li",{className:ce.featureItem,children:[n.jsx(E.IconCheckCircle,{size:12,className:ce.checkIcon}),n.jsx("span",{children:I})]},I))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:ce.learnMoreLink,children:["Learn more ",n.jsx(E.IconExternalLink,{size:12})]})]})]}),n.jsxs(ke,{className:ce.footer,extra:n.jsxs("div",{className:ce.feedbackContainer,children:[A&&n.jsx(ge,{level:"error",children:"Insufficient balance for fee"}),M&&n.jsx(ge,{level:"warning",children:"Unable to verify account status. Try again."}),!j&&!a&&n.jsx(ge,{level:"warning",children:n.jsxs("div",{className:ce.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:ce.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(ue.Outline,{onClick:T,children:"Cancel"}),n.jsx(ue.White,{onClick:k,disabled:N,loading:m,children:"Enable"})]})]})},Ep=()=>Q.useAtomValue(os)?n.jsx(Tp,{}):null,$p="_container_mqvhs_1",Mp="_badge_mqvhs_5",hr={container:$p,badge:Mp},wc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:D(hr.container,a),children:[o,!s&&n.jsx("div",{className:hr.badge,style:{right:t,top:t}})]})},Lp="_header_s7mee_1",qp="_back_s7mee_12",Pp="_title_s7mee_24",Mo={header:Lp,back:qp,title:Pp},Nt=({title:e,backButton:t,extra:s,children:o})=>{const a=ai();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Mo.header,children:[n.jsx(Nn,{to:t??(a.length>1?-1:"/"),className:Mo.back,shouldReset:!!t,children:n.jsx(E.IconBack,{size:16})}),n.jsx("h1",{className:Mo.title,children:e}),s]}),n.jsx(dt,{children:o})]})};function Sa(){const e=me();return t=>e.some(s=>s.chain_id===t)}function Rp(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function ds(){const e=Sa();return t=>e(t.chain_id)?"initia":t.chain_type}function Xn(e){return ds()(e)}function mo(){const e=Re(),{data:t}=S.useSuspenseQuery({queryKey:we.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>$.sortWith([$.descend(({chain_name:o})=>o==="initia"),$.ascend(({pretty_name:o})=>o)],s),staleTime:W.MINUTE});return t}function $t(){const e=mo(),t=Yr();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=t.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function ot(e){return $t()(e)}function fr(e,t){try{return re.fromBech32(e).prefix===t}catch{return!1}}function jc(){const{initiaAddress:e,hexAddress:t}=Je(),s=$t(),o=ds();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Ta(){const e=$t(),t=ds();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return fr(s,a.bech32_prefix??"init");case"evm":return xt.isAddress(s);case"cosmos":return a.bech32_prefix?fr(s,a.bech32_prefix):!1;default:return!1}}}function Dp(){const e=$t(),t=ds();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=t(i),l=e(a),d=t(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""}}function Bp(){const e=Re();return S.useSuspenseQuery({queryKey:we.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:W.MINUTE})}function us(){const{data:{chain_to_assets_map:e}}=Bp(),t=mo(),s=S.useQueryClient();return y.useMemo(()=>{const o=[];for(const a in e){if(!t.some(i=>i.chain_id===a))continue;const{assets:r}=e[a]??{assets:[]};s.setQueryData(we.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(we.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Os(e){const t=Re(),s=S.useQueryClient(),{data:o}=S.useSuspenseQuery({queryKey:we.assets(e).queryKey,queryFn:()=>t.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(we.asset(e,i.denom).queryKey,i);return r.toSorted($.descend(i=>i.symbol==="INIT"))},staleTime:W.MINUTE});return o}function vc(e){const t=Os(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function vt(e,t){return vc(t)(e)}const Fp="_root_ekn9t_1",Up="_header_ekn9t_6",Op="_title_ekn9t_12",Vp="_warning_ekn9t_18",Kp="_content_ekn9t_22",Wp="_footer_ekn9t_26",zp="_secondary_ekn9t_36",Gt={root:Fp,header:Up,title:Op,warning:Vp,content:Kp,footer:Wp,secondary:zp},Cc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(dt,{className:Gt.root,children:[n.jsxs("header",{className:D(Gt.header,t&&Gt[t]),children:[s,n.jsx("h1",{className:Gt.title,children:o})]}),n.jsx("div",{className:Gt.content,children:a}),n.jsxs("footer",{className:Gt.footer,children:[n.jsx(ue.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:Gt.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(E.IconChevronRight,{size:14})]})]})]})},Hp="_list_k4n3k_1",Qp="_row_k4n3k_9",Gp="_dt_k4n3k_20",Yp="_asset_k4n3k_26",js={list:Hp,row:Qp,dt:Gp,asset:Yp},Zp=({list:e,onNavigate:t,onDismiss:s})=>{const o=oe(),a=Ye(),r=Ct(o);return n.jsx(Cc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:js.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const u=a(c),{decimals:m,symbol:h}=r(d),f=v.formatAmount(l,{decimals:m});return n.jsxs("div",{className:js.row,children:[n.jsxs("div",{className:js.dt,children:[n.jsx(ee,{src:u.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:u.name})]}),n.jsxs("span",{className:js.asset,children:[f," ",h]})]},i)})})})};function Lo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const vs=({chainId:e,txHash:t})=>`${ie.OP_REMINDER}:${e}:${t}`,Jp=yl.atomWithStorage(ie.OP_REMINDER,[]);function Mn(){const e=te(),[t=[],s]=Q.useAtom(Jp),o=y.useMemo(()=>t.map(l=>{const d=localStorage.getItem(vs(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:u}=l;return d!==e?!1:Ge.isPast(u)}),[e,t]),a=y.useCallback((l,d)=>{t.some(u=>Lo(u,l))||(s((u=[])=>[...u,l]),localStorage.setItem(vs(l),JSON.stringify(d)))},[t,s]),r=y.useCallback(l=>{s((d=[])=>d.filter(u=>!Lo(u,l))),localStorage.removeItem(vs(l))},[s]),i=y.useCallback(l=>{const d=l.filter(u=>!t.some(m=>Lo(m,u)));d.length!==0&&s((u=[])=>[...u,...d])},[t,s]),c=y.useCallback((l,d)=>{localStorage.setItem(vs(l),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Nc(){const e=Ie(),{openModal:t,closeModal:s}=no(),{reminders:o,setReminder:a}=Mn();y.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})};t({content:y.createElement(Zp,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const Xp="_wrapper_5ssm8_1",eg="_balance_5ssm8_11",tg="_button_5ssm8_15",qo={wrapper:Xp,balance:eg,button:tg},kc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:qo.wrapper,children:[n.jsx(E.IconWallet,{size:16}),n.jsx("span",{className:qo.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:qo.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),ng="_fieldset_up6fh_1",sg="_upper_up6fh_9",og="_select_up6fh_14",ag="_account_up6fh_20",rg="_lower_up6fh_25",ig="_wrapper_up6fh_26",cg="_balance_up6fh_33",lg="_value_up6fh_37",dg="_error_up6fh_50",At={fieldset:ng,upper:sg,select:og,account:ag,lower:rg,wrapper:ig,balance:cg,value:lg,error:dg},Qo=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:At.fieldset,children:[n.jsxs("div",{className:At.upper,children:[n.jsx("div",{className:At.select,children:t}),n.jsx("div",{className:At.account,children:s})]}),!c&&n.jsxs("div",{className:At.lower,children:[o,n.jsxs("div",{className:At.wrapper,children:[n.jsx("div",{className:At.balance,children:a}),r&&n.jsx("div",{className:At.value,children:r})]}),i&&n.jsxs("footer",{className:At.error,children:[n.jsx(E.IconWarningFilled,{size:12}),n.jsx("p",{children:i})]})]})]})};function ms(){const e=y.useRef(null),t=io();return y.useEffect(()=>{t||e.current?.focus()},[t]),e}const ug="_input_h8073_1",mg={input:ug};function Ic(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=ms();return n.jsx(Ne.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(xl.NumericFormat,{value:l.value,getInputRef:zr.mergeRefs([l.ref,c]),className:D(mg.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const hg="_input_19r9r_1",fg="_placeholder_19r9r_18",Go={input:hg,placeholder:fg},pg=({children:e})=>n.jsx("p",{className:D(Go.input,{[Go.placeholder]:F(e).isZero()}),children:e}),es=({balance:e,decimals:t,className:s})=>{const{control:o}=Ne.useFormContext(),a={required:"Enter amount",validate:r=>F(r).isZero()?"Enter amount":F(v.toBaseUnit(r,{decimals:t})).gt(e??0)?"Insufficient balance":!0};return n.jsx(Ic,{name:"quantity",control:o,className:D(Go.input,s),rules:a})};es.ReadOnly=pg;const Sn=({title:e,content:t,children:s,className:o})=>{const[a,r]=y.useState(!1),i=()=>r(!1);return n.jsx(hc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},gg="_tooltip_19kvs_1",_g="_arrow_19kvs_44",pr={tooltip:gg,arrow:_g},hs=({label:e,children:t,small:s,...o})=>n.jsxs(Z.Tooltip.Root,{...o,children:[n.jsx(Z.Tooltip.Trigger,{asChild:!0,children:t}),n.jsx(Z.Tooltip.Portal,{container:dn(),children:n.jsxs(Z.Tooltip.Content,{className:D(pr.tooltip,{small:s}),collisionBoundary:dn(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(Z.Tooltip.Arrow,{className:pr.arrow})]})})]});function Ea(e,t){const s=Re(),o=Ta(),a=!!t&&!!e&&o(e,t);return S.useQuery({queryKey:we.balances(t,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>a?r?r[t].denoms??{}:{}:{},enabled:a,staleTime:W.SECOND})}function yg(e,t,s){const{data:o={}}=Ea(e,t);return $.path([s],o)}const xg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ts(e){if(!e)return;const{formattedParts:t}=xg.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return t.join(" ")}function Ac(e,t){return F(e).times(F(100).minus(t)).div(100).integerValue(F.ROUND_FLOOR).toFixed(0)}function $a(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${v.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Sc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,d=t.getQueryData(we.asset(a,r).queryKey);if(!d||d.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const u=d.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:v.toBaseUnit(i,{decimals:u}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function Yo(e,t){const{watch:s}=Vt(),o=s(),a=Re(),r={srcChainId:o.srcChainId,srcDenom:o.srcDenom,dstChainId:o.dstChainId,dstDenom:o.dstDenom,quantity:e},i=!r.srcChainId||!r.srcDenom||!r.dstChainId||!r.dstDenom,c=F(r.quantity||0),l=c.isFinite()&&c.gt(0),d=t?.refreshMs??1e4,u=l&&!t?.disabled&&!i,m=S.useQueryClient();return S.useQuery({queryKey:we.route(r,t?.isOpWithdraw).queryKey,queryFn:async()=>Sc(a,m,r,{isOpWithdraw:t?.isOpWithdraw}),enabled:u,staleTime:d,refetchInterval:u?d:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function bg(e){return S.useQuery({queryKey:we.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof G.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function wg(){const{watch:e}=Vt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=ot(t),i=Xn(r),c=vt(s,t),l=vt(a,o),d=oe(),u=me();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&u.find(m=>m.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const jg="_label_t93ix_1",vg="_wrapper_t93ix_7",Cg="_input_t93ix_10",Ng="_clear_t93ix_18",Cs={label:jg,wrapper:vg,input:Cg,clear:Ng},Ma=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=v.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=ms(),{control:l,getValues:d,setValue:u,formState:m}=Ne.useFormContext(),h=d("recipient"),[f,p]=y.useState(h),g=ti(),{data:_,isLoading:x,error:w}=S.useQuery({queryKey:Gs.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:W.MINUTE,enabled:g.validateUsername(f)}),C=_??(o(f)?f:""),b=t&&v.InitiaAddress.equals(C,t),j=async()=>{try{const L=await navigator.clipboard.readText();p(L.trim())}catch{}};y.useEffect(()=>{e==="onChange"&&(!f&&!m.dirtyFields.recipient||u("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,f,e,u,_]);const k=()=>{x||w||(u("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},T=()=>{if(x)return n.jsx(wn,{level:"loading",children:"Resolving username..."});if(w)return n.jsx(wn,{level:"error",children:w.message});if(_)return n.jsx(wn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!C)return n.jsx(wn,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:Cs.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(ue.Small,{type:"button",tabIndex:-1,onClick:j,children:"Paste"})]}),n.jsxs("div",{className:Cs.wrapper,children:[n.jsx(Ne.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:L=>o(L)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:D(Cs.input,"monospace"),value:f,onChange:L=>p(L.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?zr.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:Cs.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:n.jsx(E.IconCloseCircleFilled,{size:16})})]}),T(),b&&n.jsx(wn,{children:"This is my address"}),e==="onSubmit"&&n.jsx(ke,{extra:(!t||!!C&&!b)&&n.jsx(ge,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(ue.White,{type:"button",onClick:k,disabled:x||!!w||!C,children:"Apply"})})]})},kg="_scrollable_vgj3r_1",Ig="_list_vgj3r_5",Ag="_item_vgj3r_9",Sg="_name_vgj3r_22",Ns={scrollable:kg,list:Ig,item:Ag,name:Sg};function Tc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(dt,{className:Ns.scrollable,children:n.jsx("div",{className:Ns.list,children:t.map(l=>n.jsxs("button",{className:Ns.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[n.jsx(ee,{src:o(l),width:28,height:28}),n.jsx("span",{className:Ns.name,children:a(l)}),i?.(l)&&n.jsx(jt,{size:16})]},r(l)))})})}function ho(){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 Tg="_account_h04x1_8",Eg="_clear_h04x1_28",$g="_white_h04x1_39",Fn={account:Tg,clear:Eg,white:$g},gr=({type:e})=>{const{watch:t,setValue:s}=Vt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=Xn(ot(a)),{list:d,find:u}=ho(),m=u(r),h=jc(),f=Ta(),p=h(a),g=v.InitiaAddress.equals(c,p),_=()=>n.jsx(Sn,{title:"Connect wallet",content:C=>n.jsx(Tc,{onSelect:async b=>{const j=b.getProvider();if(!j)return window.open(b.fallbackUrl,"_blank");const k=j.getOfflineSigner(o),[{address:T}]=await k.getAccounts();s("sender",T),s("cosmosWalletName",b.name),C()},list:d,getImage:b=>b.image,getName:b=>b.name,getKey:b=>b.name}),className:D(Fn.account,{[Fn.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[m&&n.jsx(ee,{src:m.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:v.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(E.IconChevronRight,{size:14})]})}),x=C=>n.jsx(Sn,{title:"Recipient",content:b=>n.jsx(dt,{children:n.jsx(Ma,{mode:"onSubmit",myAddress:p,chainType:l,validate:j=>f(j,a),onApply:b})}),className:Fn.account,children:C}),w=()=>{switch(l){case"initia":case"evm":return g?x(n.jsx(E.IconWallet,{size:14})):n.jsxs("div",{className:Fn.account,children:[n.jsx("span",{className:"monospace",children:v.truncate(c)}),n.jsx("button",{type:"button",className:Fn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(E.IconCloseCircleFilled,{size:14})})]});case"cosmos":return x(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:v.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(E.IconEdit,{size:14})]}))}};switch(e){case"src":return _();case"dst":return w()}},Mg="_images_cj4xz_1",Po={images:Mg},fo=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:D(Po.images,r),style:{position:"relative"},children:[n.jsx(ee,{src:e,width:t,height:t,className:Po.asset,logo:!0}),n.jsx(ee,{src:s,width:o,height:o,className:Po.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Lg="_root_6187w_1",qg="_content_6187w_10",Pg="_details_6187w_20",Rg="_symbol_6187w_26",Dg="_chain_6187w_34",Bg="_chevron_6187w_43",Yt={root:Lg,content:qg,details:Pg,symbol:Rg,chain:Dg,chevron:Bg},Ec=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:Yt.content,children:[n.jsx(fo,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:Yt.details,children:[n.jsx("div",{className:Yt.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:Yt.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:Yt.root,children:o}):n.jsxs("div",{className:Yt.root,children:[o,n.jsx(E.IconChevronDown,{size:16,className:Yt.chevron})]})};function Fg(e,t,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return $.any($.includes(t.toLowerCase()),a)})}const Ug="_root_1sh27_1",Og="_label_1sh27_8",Vg="_input_1sh27_21",Kg="_hasValue_1sh27_31",Wg="_clear_1sh27_35",Un={root:Ug,label:Og,input:Vg,hasValue:Kg,clear:Wg},fs=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:D(Un.root,t,{[Un.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Un.label,children:n.jsx(E.IconSearch,{size:o})}),n.jsx("input",{className:Un.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Un.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(E.IconCloseCircleFilled,{size:o})})]})},zg="_container_5tajg_1",Hg="_search_5tajg_7",Qg="_list_5tajg_11",Gg="_item_5tajg_15",Yg="_logo_5tajg_37",Zg="_info_5tajg_41",Jg="_symbol_5tajg_47",Xg="_name_5tajg_56",e_="_balance_5tajg_62",t_="_value_5tajg_69",nt={container:zg,search:Hg,list:Qg,item:Gg,logo:Yg,info:Zg,symbol:Jg,name:Xg,balance:e_,value:t_},ps=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=y.useState(""),i=Fg(["symbol"],a,t);return n.jsxs("div",{className:nt.container,children:[n.jsx(fs,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:nt.search,padding:20,ref:ms()}),i.length===0?n.jsx(_e,{children:"No assets"}):n.jsx("div",{className:nt.list,children:i.map(c=>n.jsx("button",{type:"button",className:nt.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:f,decimals:p,value:g=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(ee,{src:u,width:32,height:32,className:nt.logo,logo:!0}),n.jsxs("div",{className:nt.info,children:[n.jsx("div",{className:nt.symbol,children:m||d}),n.jsx("div",{className:nt.name,children:h})]}),n.jsxs("div",{className:nt.balance,children:[f&&n.jsx("div",{children:v.formatAmount(f,{decimals:p})}),g>0&&n.jsx("div",{className:nt.value,children:X(g)})]})]})})},c.denom))})]})},n_=()=>n.jsxs("div",{className:nt.container,children:[n.jsx(fs,{rootClassName:nt.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(_e,{children:"Loading..."})]});ps.Placeholder=n_;const s_="_stack_16oqn_1",o_="_title_16oqn_9",a_="_grid_16oqn_16",r_="_item_16oqn_22",i_="_button_16oqn_26",c_="_active_16oqn_44",jn={stack:s_,title:o_,grid:a_,item:r_,button:i_,active:c_},on=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:jn.title,children:e}),n.jsx("div",{className:jn.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(wc,{offset:-2,disabled:!a?.(r),className:jn.item,children:n.jsx(hs,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button",className:D(jn.button,{[jn.active]:r===s}),onClick:()=>o(r),children:n.jsx(ee,{src:c,width:28,height:28,logo:!0})})})},r))})]}),l_=({children:e})=>n.jsx("div",{className:jn.stack,children:e});on.Stack=l_;const d_=({address:e,chain:t,onSelect:s})=>{const o=Os(t.chain_id),{data:a={}}=Ea(e,t.chain_id);return n.jsx(ps,{assets:$.sortWith([$.descend(r=>r.symbol==="INIT"),$.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>F(i).comparedTo(r)??0,$.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})},u_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Ot(),i=mo(),{watch:c,setValue:l}=Vt(),d=c(a),u=c(s),m=c(o),[h,f]=y.useState(u),p=ot(h),g=Dp(),_=Sa(),[x,w]=$.partition(b=>_(b.chain_id),i.filter(b=>!b.hidden)),C=b=>{if(u===h&&m===b){t();return}l(s,h),l(o,b),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(on.Stack,{children:[n.jsx(on,{label:"Interwoven Economy",chains:x.map(({chain_id:b,chain_name:j,pretty_name:k,logo_uri:T})=>({chainId:b,name:k||j,logoUrl:T??""})),value:h,onSelect:f}),n.jsx(on,{label:"Chains",chains:w.map(({chain_id:b,chain_name:j,pretty_name:k,logo_uri:T})=>({chainId:b,name:k||j,logoUrl:T??""})),value:h,onSelect:f})]}),n.jsx(pe,{suspenseFallback:n.jsx(ps.Placeholder,{}),children:n.jsx(d_,{address:g({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:C})},h)]})},_r=({type:e})=>{const t=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Vt(),r=a(t),i=a(s),c=ot(r),l=vt(i,r);return n.jsx(Sn,{title:o,content:d=>n.jsx(u_,{type:e,afterSelect:d}),children:n.jsx(Ec,{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??""}})})},m_="_skeleton_1l4jn_1",h_={skeleton:m_},an=({width:e="100%",height:t})=>n.jsx("div",{className:h_.skeleton,style:{width:e,height:t}}),f_="_stack_oq1ir_1",p_="_button_oq1ir_6",g_="_isLoading_oq1ir_19",__="_disabled_oq1ir_19",y_="_checked_oq1ir_23",x_="_header_oq1ir_37",b_="_title_oq1ir_43",w_="_duration_oq1ir_52",j_="_warning_oq1ir_62",v_="_amount_oq1ir_66",C_="_value_oq1ir_67",tt={stack:f_,button:p_,isLoading:g_,disabled:__,checked:y_,header:x_,title:b_,duration:w_,warning:j_,amount:v_,value:C_},N_=({children:e})=>n.jsx("div",{className:tt.stack,children:e}),$s=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Vt(),{dstChainId:l,dstDenom:d}=c(),u=vt(d,l),m=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:D(tt.button,{[tt.isLoading]:i,[tt.disabled]:h,[tt.checked]:m}),onClick:()=>{i||h||o(s)},children:[n.jsxs("div",{className:tt.header,children:[n.jsxs("div",{className:tt.title,children:[n.jsx("span",{children:e}),m&&n.jsx(E.IconCheck,{size:14})]}),i?n.jsx(an,{width:80,height:16}):r?n.jsxs("div",{className:D(tt.duration,{[tt.warning]:s==="op"}),children:[n.jsx(E.IconClockFilled,{size:12}),n.jsx("span",{children:ts(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:tt.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:tt.amount,children:i?n.jsx(an,{width:260,height:40}):r?v.formatAmount(r.amount_out,{decimals:u.decimals}):null}),n.jsx("div",{className:tt.value,children:i?n.jsx(an,{width:120,height:16}):r?r.usd_amount_out?X(r.usd_amount_out):"$-":null})]})]})};$s.Stack=N_;const k_="_description_nuyvt_1",I_="_presets_nuyvt_8",A_="_preset_nuyvt_8",S_="_active_nuyvt_29",T_="_custom_nuyvt_40",E_="_wrapper_nuyvt_47",$_="_percent_nuyvt_58",gt={description:k_,presets:I_,preset:A_,active:S_,custom:T_,wrapper:E_,percent:$_},yr=["0.1","0.5","1.0"],M_=({afterConfirm:e})=>{const t=Vt(),s=t.getValues("slippagePercent"),[o,a]=y.useState(null),{control:r,watch:i,getValues:c,setValue:l}=Ne.useForm({defaultValues:{value:s}}),d=i("value");y.useEffect(()=>{const g=yr.findIndex(_=>_===s);a(g>=0?g:null)},[s]);const u=(g,_)=>{l("value",g),a(_)},m=()=>{a(null)},h=y.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})=>{t.setValue("slippagePercent",g),e()};return n.jsxs(dt,{children:[n.jsx("p",{className:gt.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),n.jsxs("div",{className:gt.presets,children:[yr.map((g,_)=>n.jsxs("button",{type:"button",className:D(gt.preset,{[gt.active]:o===_}),onClick:()=>u(g,_),children:[g,"%"]},g)),o!==null?n.jsx("button",{type:"button",className:D(gt.preset,gt.custom),onClick:()=>a(null),children:"Custom"}):n.jsxs("div",{className:gt.wrapper,children:[n.jsx(Ic,{name:"value",control:r,dp:2,onFocus:m,placeholder:"",className:D(gt.preset,gt.active)}),n.jsx("span",{className:gt.percent,children:"%"})]})]}),h&&n.jsx(ge,{level:h.type,children:h.text}),n.jsx(ke,{children:n.jsx(ue.White,{type:"button",onClick:()=>p(c()),disabled:f,children:"Confirm"})})]})},L_="_form_1owk5_1",q_="_arrow_1owk5_5",P_="_divider_1owk5_14",R_="_flip_1owk5_23",D_="_meta_1owk5_41",B_="_row_1owk5_54",F_="_title_1owk5_60",U_="_description_1owk5_64",O_="_icon_1owk5_71",V_="_edit_1owk5_76",K_="_warning_1owk5_99",Be={form:L_,arrow:q_,divider:P_,flip:R_,meta:D_,row:B_,title:F_,description:U_,icon:O_,edit:V_,warning:K_};function W_({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}const z_=()=>{const e=Ie(),t=io(),s=Tn(),[o,a]=y.useState(void 0),[r,i]=y.useState(!1),[c,l]=We.useLocalStorage(ie.BRIDGE_ROUTE_TYPE,"default"),{watch:d,setValue:u,handleSubmit:m,formState:h}=Vt(),f=d(),{srcChainId:p,srcDenom:g,dstChainId:_,dstDenom:x,quantity:w,sender:C,slippagePercent:b}=f,j=Ye(),k=oe(),T=ot(p),L=Xn(T),A=ot(_),M=Xn(A),N=vt(g,p),I=vt(x,_),{data:U}=Ea(C,p),q=yg(C,p,g),P=!q?.amount||F(q.amount).isZero(),[B]=We.useDebounceValue(w,300),H=p===_,z=H&&p===k.chainId,le=W_({isLayer1Swap:z,isL2Swap:H&&L==="initia"&&!z}),ye=L!=="initia"&&M!=="initia",he=wg(),xe=Yo(B,{disabled:ye,refreshMs:le}),be=Yo(B,{isOpWithdraw:!0,disabled:!he,refreshMs:le}),De=he&&c==="op",ut=De?be:xe,Mt=De?xe:be,mt=De?!ye:he,Te=ut.error&&mt?Mt:ut,{data:O,isLoading:Ee,error:ae}=Te,{data:Le}=bg(ae),Ln=B&&Ee&&!r,qn=()=>{u("srcChainId",_),u("srcDenom",x),u("dstChainId",p),u("dstDenom",g),u("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:fn,closeModal:pn}=no(),Pn=m(async ne=>{a(void 0),i(!0);let qe,Rn;try{const ft=await Te.refetch();if(ft.error||!ft.data||!ft.dataUpdatedAt){a(ft.error instanceof Error?ft.error.message:"Failed to refresh route. Please try again.");return}qe=ft.data,Rn=ft.dataUpdatedAt}finally{i(!1)}if(s("Bridge Simulation Success",{quantity:ne.quantity,srcChainId:ne.srcChainId,srcDenom:ne.srcDenom,dstChainId:ne.dstChainId,dstDenom:ne.dstDenom}),qe.warning){const{type:ft="",message:ul}=qe.warning??{};fn({content:n.jsx(Cc,{type:"warning",icon:n.jsx(E.IconWarningFilled,{size:40}),title:zs.sentenceCase(ft),primaryButton:{label:"Cancel",onClick:pn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:qe,values:ne,quoteVerifiedAt:Rn}),pn()}},children:n.jsx("p",{className:Be.warning,children:ul})})});return}e("/bridge/preview",{route:qe,values:ne,quoteVerifiedAt:Rn})}),ht=y.useMemo(()=>O?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[O]),ze=y.useMemo(()=>O?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[O]),at=y.useMemo(()=>{for(const ne of ze){const qe=U?.[ne.origin_asset.denom]?.amount??"0",Rn=O?.source_asset_denom===ne.origin_asset.denom?O.amount_in:"0";if(F(qe).lt(F(Rn).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[U,O,ze]),ve=y.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!B)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(!O)return"Route not found";if(at)return at},[B,at,h,O,f]),Wt=O?v.formatAmount(O.amount_out,{decimals:I.decimals}):"0",zt=F(w).gt(0)&&F(w).isEqualTo(v.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),dl=(()=>{switch(L){case"initia":return j(p).fees.fee_tokens.some(({denom:ne})=>ne===g);case"cosmos":return T.fee_assets.some(({denom:ne})=>ne===g);case"evm":return!xt.isAddress(g);default:return!1}})(),xo=y.useCallback((ne,qe)=>ne.length?n.jsxs("div",{className:Be.description,children:[$a(ne),!t&&n.jsx(hs,{label:qe,children:n.jsx("span",{className:Be.icon,children:n.jsx(E.IconInfoFilled,{size:12})})})]}):null,[t]),_s=F(w).gt(0)&&he&&xe.data&&be.data&&be.data.estimated_route_duration_seconds>xe.data.estimated_route_duration_seconds,Va=y.useMemo(()=>{if(!O)return[];const ne=Ac(O.amount_out,b);return[{condition:!!O.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[xo(ht,"Fee deducted from the amount you receive"),xo(ze,"Fee charged in addition to the amount you enter")]})},{condition:!_s&&!!ts(O.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Be.description,children:ts(O.estimated_route_duration_seconds)})},{condition:O.does_swap,title:"Slippage",content:n.jsxs("span",{className:Be.description,children:[n.jsxs("span",{children:[b,"%"]}),n.jsx(Sn,{title:"Slippage tolerance",content:qe=>n.jsx(M_,{afterConfirm:qe}),className:Be.edit,children:n.jsx(E.IconSettingFilled,{size:12})})]})},{condition:O.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Be.description,children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol,width:12,height:12}),v.formatAmount(ne,{decimals:I.decimals})," ",I.symbol]})}].filter(qe=>qe.condition)},[ze,ht,I,xo,O,_s,b]);return n.jsxs("form",{className:Be.form,onSubmit:Pn,children:[n.jsx(Qo,{selectButton:n.jsx(_r,{type:"src"}),accountButton:L==="cosmos"&&n.jsx(gr,{type:"src"}),quantityInput:n.jsx(es,{balance:q?.amount,decimals:N?.decimals}),balanceButton:n.jsx(kc,{onClick:()=>u("quantity",v.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:P,children:v.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:O?X(O.usd_amount_in):"$-"}),n.jsxs("div",{className:Be.arrow,children:[n.jsx("div",{className:Be.divider}),n.jsx("button",{type:"button",className:Be.flip,onClick:()=>qn(),children:n.jsx(E.IconChevronDown,{size:16})})]}),n.jsx(Qo,{selectButton:n.jsx(_r,{type:"dst"}),accountButton:n.jsx(gr,{type:"dst"}),quantityInput:n.jsx(es.ReadOnly,{children:Wt}),value:O?X(O.usd_amount_out):"$-",hideNumbers:_s}),n.jsx(Jn,{children:_s?n.jsxs($s.Stack,{children:[n.jsx($s,{label:"Fast",query:xe,value:"default",onSelect:l,checked:c==="default"}),n.jsx($s,{label:"Lossless",query:be,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(ke,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(ge.Stack,{children:[o&&n.jsx(ge,{level:"error",children:o}),O?.extra_infos?.map(ne=>n.jsx(ge,{level:"info",children:ne},ne)),Le&&n.jsx(ge,{level:"info",children:Le}),zt&&dl&&n.jsx(ge,{level:"warning",children:"Make sure to leave enough for transaction fee"}),O?.warning&&n.jsx(ge,{level:"warning",children:O.warning.message}),O?.extra_warnings?.map(ne=>n.jsx(ge,{level:"warning",children:ne},ne))]}),n.jsx(Jn,{children:Va.length>0&&n.jsx("div",{className:Be.meta,children:Va.map((ne,qe)=>n.jsxs("div",{className:Be.row,children:[n.jsx("span",{className:Be.title,children:ne.title}),ne.content]},qe))})})]}),children:n.jsx(ue.White,{loading:r?"Refreshing route...":Ln&&"Simulating...",disabled:!!ve||r,children:ve??"Preview route"})})]})},H_=()=>{Nc();const e=ai(),t=Ie(),s=Ot(),o=gm(),a=Ne.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:u,quantity:m,slippagePercent:h,recipient:f}=r();r((I,{name:U})=>{(U==="srcChainId"||U==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=jc(),g=p(c),_=p(l),w=Ta()(f,l);y.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[c,g,i]),y.useEffect(()=>{w||i("recipient",_)},[_,w,i]);const{showNotification:C}=uo(),b=ot(c),j=ot(l),k=Os(c),T=Os(l),L=k.some(I=>I.denom===d),A=T.some(I=>I.denom===u);y.useEffect(()=>{k.length>0&&!L&&(i("srcDenom",k[0].denom),C({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${b.pretty_name}.`,autoHide:!0}))},[k,L,i,C,b.pretty_name]),y.useEffect(()=>{T.length>0&&!A&&(i("dstDenom",T[0].denom),C({type:"info",title:`Switched to ${T[0].symbol}`,description:`The selected asset is not available on ${j.pretty_name}.`,autoHide:!0}))},[T,A,i,C,j.pretty_name]),y.useEffect(()=>{!L||!A||(localStorage.setItem(ie.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(ie.BRIDGE_SRC_DENOM,d),localStorage.setItem(ie.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(ie.BRIDGE_DST_DENOM,u),localStorage.setItem(ie.BRIDGE_QUANTITY,m),localStorage.setItem(ie.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,u,m,h,L,A]);const M=e[0].path==="/bridge",{reminders:N}=Mn();return n.jsx(Nt,{title:"Bridge/Swap",backButton:M?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(ue.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[n.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(wc,{offset:0,disabled:N.length===0,children:n.jsx(ue.Small,{onClick:()=>t("/op/withdrawals"),disabled:!s,children:n.jsx("span",{children:"Withdrawal status"})})})]}),children:L&&A&&n.jsx(Ne.FormProvider,{...a,children:n.jsx(pe,{children:n.jsx(z_,{})})})})},Q_="_button_1crvp_1",G_="_checkbox_1crvp_11",Y_="_checked_1crvp_25",ks={button:Q_,checkbox:G_,checked:Y_},Z_=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:D(ks.button,o),onClick:t,children:[n.jsx("div",{className:D(ks.checkbox,{[ks.checked]:e}),children:e&&n.jsx(E.IconCheck,{size:12})}),n.jsx("span",{className:ks.label,children:s})]}),J_="_button_aoxv2_1",X_={button:J_},$c=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=bl.useInView();return y.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:X_.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(E.IconChevronDown,{size:12})]})};function Mc(e,t){return e.reduce((s,o)=>{const a=t(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const Ms=({chainId:e,txHash:t})=>`${ie.BRIDGE_HISTORY}:${e}:${t}`,Vs=100,xr=10;function Lc(){const[e,t]=We.useLocalStorage(ie.BRIDGE_HISTORY,[]),s=y.useCallback((a,r)=>{localStorage.setItem(Ms(a),JSON.stringify(r));for(const i of e.slice(Vs-1))localStorage.removeItem(Ms(i));t((i=[])=>[a,...i.slice(0,Vs-1)])},[e,t]),o=y.useCallback(a=>{const r=localStorage.getItem(Ms(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function qc(e){return We.useLocalStorage(Ms(e),null)}const hn=Se.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function po(){const{restUrl:e}=oe();return y.useMemo(()=>G.create({prefixUrl:e}),[e])}function ey(e){const t=po(),{data:s}=S.useSuspenseQuery({queryKey:hn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:W.INFINITY});return s}const br=20;function ty(e){const t=te();return S.useSuspenseInfiniteQuery({queryKey:hn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:br,offset:s,order:"desc"},{withdrawals:a}=await G.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=$.last(s)?.sequence;return s.length<br||!o||o<=1?null:o-1},initialPageParam:0,staleTime:W.SECOND})}function ny(e){const t=po(),{data:s}=S.useSuspenseQuery({queryKey:hn.latestOutput(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:W.SECOND});return s}function sy({bridge_id:e,output_index:t}){const s=po(),{data:o}=S.useSuspenseQuery({queryKey:hn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:W.SECOND});return o}function oy({bridge_id:e,sequence:t}){const o=me().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=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:c}=S.useSuspenseQuery({queryKey:hn.outputResponse(i,t).queryKey,queryFn:()=>G.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:W.SECOND});return c}function Pc(e,t){const{bridge_id:s}=e,o=po(),{data:a}=S.useSuspenseQuery({queryKey:hn.withdrawalClaimed(s,t).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:W.SECOND});return a}function On(e){return wl.sha3_256.create().update(e).digest()}function Ro(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function Rc(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Ro(t.toString(),8),c=Ro(s.toString(),8),l=Ro(o.amount,8),d=tn.concatBytes(i,c,On(tn.utf8ToBytes(a)),On(tn.utf8ToBytes(r)),On(tn.utf8ToBytes(o.denom)),l);return On(On(d))}async function ay(e,t,s){try{return await G.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function ry(e,t){const s=G.create({prefixUrl:t}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Zo(e,t){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=t;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if($.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 kt(){return Ze()}function iy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Ie(),{showNotification:r,updateNotification:i,hideNotification:c}=uo(),{addHistoryItem:l}=Lc(),d=Tn(),{route:u,values:m}=kt(),{srcChainId:h,sender:f,recipient:p,cosmosWalletName:g}=m,_=Ii(),{requestTxSync:x,submitTxSync:w,waitForTxConfirmation:C}=Je(),{find:b}=ho(),j=as(),k=rs(),T=ot(h),L=Xn(T),A=vc(h),M=S.useQueryClient(),{registryUrl:N}=se(),I=Ye(),U=oe(),{addReminder:q}=Mn(),P=Re();return S.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const B=e.cosmos_tx.msgs.map(({msg_type_url:Te,msg:O})=>{if(!(Te&&O))throw new Error("Invalid transaction data");return k.fromAmino({type:rn.aminoConverters[Te].aminoType,value:JSON.parse(O)})});if(L==="initia"){const{srcDenom:Te,quantity:O}=m,{decimals:Ee}=A(Te),ae=s?await w({messages:B,chainId:h,fee:s}):await x({messages:B,chainId:h,internal:1,spendCoins:[{denom:Te,amount:v.toBaseUnit(O,{decimals:Ee})}]}),Le=C({txHash:ae,chainId:h});return{txHash:ae,wait:Le}}const H=b(g)?.getProvider();if(!H)throw new Error("Wallet not connected");const z=H.getOfflineSignerOnlyAmino(h),K=await Ae.SigningStargateClient.connectWithSigner(T.rpc,z,{registry:j,aminoTypes:k}),le=await K.getAllBalances(f),ye=T.fee_assets.find(Te=>le.some(O=>O.denom===Te.denom&&F(O.amount).gt(0)));if(!ye){const O=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(Ee=>A(Ee.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(O)}const{denom:he,gas_price:xe}=ye;if(!xe)throw new Error(`Gas price not found for ${he}`);const be=await K.simulate(f,B,""),De=Ae.GasPrice.fromString(xe.average+he),ut=Ae.calculateFee(Math.ceil(be*cn),De),Mt=await K.signAndBroadcastSync(f,B,ut),mt=Ui({txHash:Mt,client:K});return{txHash:Mt,wait:mt}}if("evm_tx"in e){const{chain_id:B,to:H,value:z,data:K}=e.evm_tx,le=await _(),ye=await le.getSigner();await Zo(le,T);const he=await ye.sendTransaction({chainId:B,to:H,value:z,data:`0x${K}`});return{txHash:he.hash,wait:he.wait()}}throw new Error("Unlisted chain type")}catch(B){throw await wt(B)}},onSuccess:async({txHash:B,wait:H})=>{localStorage.removeItem(ie.BRIDGE_QUANTITY),M.removeQueries({queryKey:we.route._def}),M.removeQueries({queryKey:we.routeErrorInfo._def}),o?o({txhash:B,chainId:h,timestamp:Date.now(),success:!0,route:u,values:m}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await H;const z=go(u)==="OP Bridge withdrawal",K=z?{success:!0,error:null}:await my(P,B,h);if(!o&&!K.success&&K.error){const be=K.error instanceof Error?K.error.message:String(K.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${be}. The transaction may still be processing.`,autoHide:!0})}const le=K.success,he=dy({txHash:B,srcChainId:h,route:u,values:m,recipient:p},le);l(he.tx,he.details),o||i(ly(c));const xe=Do(m,B);if(d("Bridge Transaction Success",xe),z){const be=I(h).metadata?.op_bridge_id;if(be&&!await ay(U.restUrl,Number(be),u.dest_asset_denom)){const ut=uy(he.tx,u,p);q(he.tx,ut)}}}catch(z){const K=z instanceof Error?z.message:String(z);o?o({success:!1,error:K,route:u,values:m}):i({type:"error",title:"Transaction not confirmed",description:K});const le={...Do(m,B),error:K};d("Bridge Confirmation Failed",le)}finally{M.invalidateQueries({queryKey:we.balances(h,f).queryKey})}},onError:async B=>{const H=L==="initia"?await bn(B,I(h),N):B;o?o({success:!1,error:H.message,route:u,values:m}):r({type:"error",title:"Transaction failed",description:H.message});const z=Do(m);d("Bridge Transaction Failed",{...z,error:H.message})}})}function cy(){const e=Re(),t=te(),s=Ni(),{route:o,values:a}=kt(),r=$t();return S.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:t,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:v.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await ry(t,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:m,msg:h})=>rn.aminoTypes.fromAmino({type:rn.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await s(i,t,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=He.Tx.fromPartial({body:He.TxBody.decode(d.bodyBytes),authInfo:He.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:re.toBase64(He.Tx.encode(u).finish())}}catch(i){throw await wt(i)}}})}function ly(e){return{type:"info",title:"Transaction submitted",description:y.createElement(y.Fragment,null,"Check ",y.createElement(Nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Do(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function dy(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=go(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:t},isOpWithdraw:c}}function uy(e,t,s){return{...e,recipient:v.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function my(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await wt(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Dc(e){const{chainId:t,txHash:s,tracked:o}=e,a=Re();return S.useQuery({queryKey:we.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await wt(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:W.INFINITY,enabled:!o})}function Bc(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=Re();return S.useQuery({queryKey:we.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=t+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:W.INFINITY})}var zn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(zn||{});function go(e){const{operations:t,dest_asset_denom:s}=e;return $.has("op_init_transfer",$.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const hy="_success_t4dfk_1",fy="_error_t4dfk_5",wr={success:hy,error:fy},py=({tx:e})=>{const[t,s]=qc(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=Bc(t),a=t.state??gy(o);switch(y.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return n.jsx("div",{className:wr.error,children:n.jsx(E.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:wr.success,children:n.jsx(E.IconCheckCircleFilled,{size:14})});default:return n.jsx(jt,{size:14})}};function gy(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 _y="_link_104m3_1",yy="_header_104m3_23",xy="_title_104m3_31",by="_date_104m3_37",wy="_explorer_104m3_41",jy="_fees_104m3_57",vy="_label_104m3_65",Cy="_content_104m3_69",Ny="_route_104m3_75",ky="_row_104m3_80",Iy="_asset_104m3_86",Ay="_amount_104m3_94",Sy="_chain_104m3_99",Ty="_account_104m3_108",Ey="_arrow_104m3_115",$e={link:_y,header:yy,title:xy,date:by,explorer:wy,fees:jy,label:vy,content:Cy,route:Ny,row:ky,asset:Iy,amount:Ay,chain:Sy,account:Ty,arrow:Ey},$y=({tx:e})=>{const[t,s]=qc(e);if(!t)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=t,{data:d}=Dc(t),{address:u="",connector:m}=Ke.useAccount(),{find:h}=ho();y.useEffect(()=>{d&&s(P=>{if(!P)throw new Error("Bridge history details not found");return{...P,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:_,dest_asset_chain_id:x,dest_asset_denom:w,estimated_fees:C=[]}=r,b=ot(g),j=ot(x),k=vt(_,g),T=vt(w,x),L=(P,B)=>B?n.jsx(ee,{src:B,width:12,height:12}):v.InitiaAddress.equals(P,u)?n.jsx(ee,{src:m?.icon,width:12,height:12}):n.jsx(E.IconWallet,{size:12}),A=(P,{symbol:B,decimals:H,logo_uri:z},{chain_name:K,pretty_name:le,...ye},he,xe)=>n.jsxs("div",{className:$e.row,children:[n.jsx(fo,{assetLogoUrl:z,chainLogoUrl:ye.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:$e.asset,children:[n.jsx("span",{className:$e.amount,children:v.formatAmount(P,{decimals:H})}),n.jsx("span",{children:B})]}),n.jsxs("div",{className:$e.chain,children:[n.jsxs("span",{children:["on ",le||K]}),n.jsxs("div",{className:$e.account,children:[xe,n.jsx("span",{className:"monospace",children:v.truncate(he)})]})]})]})]}),M=go(r),N=y.useMemo(()=>{switch(M){case zn.SKIP:return"Skip Explorer";case zn.OP_WITHDRAW:return"Initia Scan"}},[M]),I=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:$e.header,children:[n.jsxs("div",{className:$e.title,children:[l?n.jsx(py,{tx:e}):n.jsx(jt,{size:14}),n.jsx("div",{className:$e.date,children:Ge.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:$e.explorer,children:[n.jsx("span",{children:N}),n.jsx(E.IconExternalLink,{size:12})]})]}),n.jsxs("div",{className:$e.route,children:[A(f,k,b,i.sender,L(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:$e.arrow,children:n.jsx(E.IconArrowDown,{size:12})}),A(p,T,j,i.recipient,L(i.recipient))]}),C.length>0&&n.jsxs("div",{className:$e.fees,children:[n.jsx("span",{className:$e.label,children:"Fees"}),n.jsx("span",{className:$e.content,children:$a(C)})]})]});if(M===zn.OP_WITHDRAW)return n.jsx(lo,{chainId:o,txHash:a,className:$e.link,children:I});const U=new URLSearchParams({tx_hash:a,chain_id:o}),q=new URL(`?${U.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:q.toString(),className:$e.link,target:"_blank",children:I})},My="_history_13u9z_1",Ly="_header_13u9z_5",qy="_checkbox_13u9z_9",Py="_groups_13u9z_13",Ry="_dateGroup_13u9z_21",Dy="_dateHeader_13u9z_26",By="_list_13u9z_32",Zt={history:My,header:Ly,checkbox:qy,groups:Py,dateGroup:Ry,dateHeader:Dy,list:By},Fy=()=>{const{initiaAddress:e,hexAddress:t}=Je(),{history:s,getHistoryDetails:o}=Lc(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:_,recipient:x}=g;return[_,x].some(w=>[e,t].includes(w))}),[i,c]=y.useState(1),[l,d]=We.useToggle(!r.length),u=l?a:r,m=u.slice(0,i*xr),h=y.useMemo(()=>Mc(m,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[m,o]);return n.jsx(Nt,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:Zt.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:Zt.header,children:n.jsx(Z_,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:Zt.checkbox})}),u.length===0?n.jsx(_e,{children:"No bridge/swap activity"}):n.jsx("div",{className:Zt.groups,children:Object.entries(h).map(([f,p])=>n.jsxs("div",{className:Zt.dateGroup,children:[n.jsx("div",{className:Zt.dateHeader,children:f}),n.jsx("div",{className:Zt.list,children:p.map(g=>n.jsx(pe,{children:n.jsx($y,{tx:g})},g.txHash))})]},f))}),u.length>i*xr?n.jsx($c,{onClick:()=>c(f=>f+1)}):s.length>=Vs&&n.jsxs(_e,{children:["Only the latest ",Vs," items are stored. Older entries will be removed automatically."]})]})})};function Fc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Uy({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Fc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function Oy({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Fc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const Vy=1e4;function Jo(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Jo).join(",")}]`:`{${Object.entries(e).toSorted(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${Jo(s)}`).join(",")}}`}function jr(e){return Jo({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Ky(e,t,s){const o=Ie(),a=Ze(),r=S.useQueryClient(),i=Re(),[c,l]=y.useState(!1),[d,u]=y.useState(void 0),[m,h]=y.useState(s??0),f=y.useRef(null);return y.useEffect(()=>{h(s??0)},[s]),y.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const g=Math.max(s??0,m);if(Date.now()-g<=Vy)return!1;l(!0),u(void 0);const _=new AbortController;f.current=_;try{const x=await Sc(i,r,t,{isOpWithdraw:go(e)===zn.OP_WITHDRAW,signal:_.signal});if(_.signal.aborted)return!0;const w=jr(x)!==jr(e),C=Date.now();return w?(o(0,Uy({currentState:a,route:x,values:t,quoteVerifiedAt:C})),!0):(h(C),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||_.signal.aborted||u((await wt(x)).message),!0}finally{f.current===_&&(f.current=null),_.signal.aborted||l(!1)}},isRefreshing:c,refreshError:d,clearRefreshError:()=>u(void 0)}}function Wy(e,t){return t?"Confirm updated route":e||"Confirm"}const La=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a})=>{const r=Ie(),i=Ze(),{route:c,values:l,quoteVerifiedAt:d,requiresReconfirm:u}=kt(),{mutate:m,isPending:h}=iy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:f,isRefreshing:p,refreshError:g,clearRefreshError:_}=Ky(c,l,d),x=async()=>{if(!(h||p)){if(u){r(0,Oy({currentState:i,route:c,values:l,quoteVerifiedAt:d??Date.now()}));return}await f()||(_(),m())}},w=a??g??(u?"Route updated. Please review and confirm again.":void 0);return n.jsx(ke,{extra:w&&n.jsx(ge,{level:a||g?"error":"info",children:w}),children:n.jsx(ue.White,{onClick:x,loading:p?"Refreshing route...":h&&"Signing transaction...",disabled:!!a,children:Wy(o,!!u)})})},zy="_content_1hzj2_1",Hy="_info_1hzj2_6",Qy="_arrow_1hzj2_11",Gy="_divider_1hzj2_19",Yy="_type_1hzj2_27",Zy="_asset_1hzj2_47",Jy="_amount_1hzj2_55",Xy="_lower_1hzj2_60",ex="_chain_1hzj2_66",tx="_address_1hzj2_72",et={content:zy,info:Hy,arrow:Qy,divider:Gy,type:Yy,asset:Zy,amount:Jy,lower:Xy,chain:ex,address:tx},Uc=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=v.truncate(a),decimals:d=0,logo_uri:u=ca}=e,{chain_name:m,pretty_name:h,...f}=ot(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:et.arrow,children:[n.jsx("div",{className:et.divider}),s?n.jsx(hs,{label:s,children:n.jsx("button",{className:et.type,children:n.jsx(E.IconArrowDown,{size:12})})}):n.jsx("span",{className:et.type,children:n.jsx(E.IconArrowDown,{size:12})}),n.jsx("div",{className:et.divider})]}),n.jsxs("div",{className:et.content,children:[n.jsx(fo,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:et.info,children:[n.jsxs("div",{className:et.asset,children:[n.jsx("span",{className:et.amount,children:v.formatAmount(o,{decimals:d})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:et.lower,children:[n.jsxs("div",{className:et.chain,children:["on ",h||m]}),i&&n.jsx(Fs,{value:i,children:({copy:p,copied:g})=>n.jsxs("button",{className:et.address,onClick:p,children:[c,g?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},vn=e=>{const t=vt(e.denom,e.chainId);return n.jsx(Uc,{...e,...t})};vn.Placeholder=Uc;const nx="_root_1hbar_1",sx="_flexEnd_1hbar_6",ox="_toggle_1hbar_11",ax="_route_1hbar_36",rx="_content_1hbar_43",Vn={root:nx,flexEnd:sx,toggle:ox,route:ax,content:rx};function ix(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":zs.capitalCase($.head(s?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const s=e.swap?.swap_venues?.map(t).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const s=e.evm_swap?.swap_venues?.map(t).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const cx=({addressList:e})=>{const{values:t,route:s}=kt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=$.zipObj(s.required_chain_addresses,e),{find:l}=ho(),{connector:d,address:u=""}=Ke.useAccount(),[m,h]=We.useToggle(!1),f=i.length>1,p=n.jsx(ee,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:p},_=j=>v.InitiaAddress.equals(j,u)?p:n.jsx(E.IconWallet,{size:11}),x=j=>{const{label:k,amount_out:T,denom:L,denom_out:A=L,chain_id:M,from_chain_id:N,to_chain_id:I=M??N}=j,U=c[I];return{label:f&&!m?void 0:k,amount:T,denom:A,chainId:I,address:U,walletIcon:_(U)}},w=i.map(ix).map(x),C=w.slice(0,-1),b=w[w.length-1];return n.jsxs(Z.Collapsible.Root,{className:Vn.root,open:m,onOpenChange:h,children:[f&&n.jsx("div",{className:Vn.flexEnd,children:n.jsx(Z.Collapsible.Trigger,{className:Vn.toggle,children:m?n.jsxs(n.Fragment,{children:[n.jsx(E.IconMinus,{size:12}),n.jsx("span",{children:"Hide details"})]}):n.jsxs(n.Fragment,{children:[n.jsx(E.IconList,{size:12}),n.jsx("span",{children:"Show details"})]})})}),n.jsxs("div",{className:Vn.route,children:[n.jsx(vn,{...g,source:!0}),n.jsx(Z.Collapsible.Content,{className:Vn.content,children:C.map((j,k)=>n.jsx(pe,{suspenseFallback:n.jsx(vn.Placeholder,{...j}),errorBoundaryProps:{fallback:n.jsx(vn.Placeholder,{...j})},children:n.jsx(vn,{...j})},k))}),n.jsx(vn,{...b})]})]})},Oc=({error:e})=>{const t=Ie();return n.jsx(ke,{extra:n.jsx(ge,{level:"error",children:e.message}),children:n.jsx(ue.White,{onClick:()=>t("/bridge"),children:"Home"})})},Vc=({children:e})=>{const t=kt(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:u}=Je(),m=is(),h=$t(),f=ds(),p=h(r),g=f(p),_=a.slice(0,-1).some(T=>{const L=h(T);return f(L)==="cosmos"})&&g!=="cosmos",[x,w]=y.useState(void 0),[C,b]=y.useState(!1),[j,k]=y.useState(null);if(y.useEffect(()=>{(async()=>{try{if(!_)return;if(!m)throw new Error("Wallet not connected");b(!0),k(null);const[{pubkey:L}]=await m.getAccounts();w(L)}catch(L){k(await wt(L))}finally{b(!1)}})()},[_,m]),j)return n.jsx(Oc,{error:j});if(C)return n.jsx(ke,{children:n.jsx(ue.White,{loading:C&&"Generating intermediary addresses..."})});if(!_||x){const T=a.map((L,A)=>{if(A===a.length-1){const q=h(i);return f(q)==="initia"?v.InitiaAddress(l).bech32:l}const M=h(L),N=f(M),I=h(r),U=f(I);switch(N){case"initia":return d;case"evm":return u;case"cosmos":{if(U==="cosmos")return re.toBech32(M.bech32_prefix,re.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return Qn.pubkeyToAddress(Qn.encodeSecp256k1Pubkey(x),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(T)}return null},qa=({tx:e,children:t})=>{const s=Ii(),o=$t(),{data:a,isLoading:r}=S.useQuery({queryKey:["interwovenkit:erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:m}=e.evm_tx,h=await s();await Zo(h,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:_,spender:x}=g,C=await new xt.ethers.Contract(_,f,h).allowance(m,x);return{approval:g,currentAllowance:BigInt(C.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}=S.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,m=await s(),h=await m.getSigner();await Zo(m,o(u));for(const f of a){const{token_contract:p,spender:g,amount:_}=f,x=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new xt.ethers.Contract(p,x,h).approve(g,_)).wait()}return!0}catch(u){throw await wt(u)}}});return r?n.jsx(ke,{children:n.jsx(ue.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!c?n.jsx(ke,{extra:n.jsx(ge,{level:"error",children:d?.message}),children:n.jsx(ue.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):t},Kc=({addressList:e,signedOpHook:t,children:s})=>{const o=Re(),{route:a,values:r}=kt(),[i,c]=y.useState(void 0),[l,d]=y.useState(!1),[u,m]=y.useState(null),h=JSON.stringify(e),f=JSON.stringify(a.operations),p=JSON.stringify(t??null),g=y.useMemo(()=>e,[h]),_=y.useMemo(()=>a.operations,[f]),x=y.useMemo(()=>t,[p]);return y.useEffect(()=>{let w=!1;return(async()=>{try{if(a.required_op_hook&&!x)throw new Error("Op hook is required");d(!0),m(null);const b={address_list:g,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:_,signed_op_hook:x},{txs:j}=await o.post("v2/fungible/msgs",{json:b}).json();if(w)return;if(!j||j.length===0)throw new Error("No transaction data found");const[k]=j;c(k)}catch(b){if(w)return;m(b)}finally{w||d(!1)}})(),()=>{w=!0}},[g,_,x,a.amount_in,a.amount_out,a.source_asset_chain_id,a.source_asset_denom,a.dest_asset_chain_id,a.dest_asset_denom,a.required_op_hook,r.slippagePercent,o]),u?n.jsx(Oc,{error:u}):l||!i?n.jsx(ke,{children:n.jsx(ue.White,{loading:"Fetching messages..."})}):s(i)},Wc=({children:e})=>{const{route:t}=kt(),s=cy();return t.required_op_hook&&!s.data?n.jsx(ke,{extra:n.jsx(ge,{level:"error",children:s.error?.message}),children:n.jsx(ue.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},lx=()=>n.jsx(Nt,{title:"Route preview",children:n.jsx(Vc,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(cx,{addressList:e}),n.jsx(Wc,{children:t=>n.jsx(Kc,{addressList:e,signedOpHook:t,children:s=>n.jsx(qa,{tx:s,children:n.jsx(La,{tx:s})})})})]})})}),zc=y.createContext(null);function _o(){return y.useContext(zc)}const dx="_button_17r1o_1",ux="_claimed_17r1o_24",vr={button:dx,claimed:ux},mx=()=>{const{withdrawalTx:e}=_o(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,u=oe(),m=te(),{requestTxSync:h,waitForTxConfirmation:f}=Je(),p=oy(e),g=re.toBase64(Rc(e)),_=Pc(e,g),x=S.useQueryClient(),{mutate:w,isPending:C}=S.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:b}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(re.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:re.fromBase64(d),storageRoot:re.fromBase64(i),lastBlockHash:re.fromBase64(b)}}],internal:!0})},onSuccess:async b=>{await f({chainId:u.chain_id,txHash:b}),x.invalidateQueries({queryKey:hn.withdrawalClaimed(t,g).queryKey})}});return _?n.jsxs("div",{className:vr.claimed,children:[n.jsx(E.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:vr.button,onClick:()=>w(),disabled:C,children:"Claim"})},hx=({children:e})=>{const{withdrawalTx:t}=_o(),s=ey(t.bridge_id),o=sy(t),a=y.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)},Hc=1e3,fx=60,px=60,gx=24,Xo=Hc*fx,ea=Xo*px,Cr=ea*gx,_x=({date:e})=>{const t=y.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/Cr),f=Math.floor(m%Cr/ea),p=Math.floor(m%ea/Xo),g=Math.floor(m%Xo/Hc);return{days:h,hours:f,minutes:p,seconds:g}},[e]),[s,o]=y.useState(t());y.useEffect(()=>{const d=window.setInterval(()=>{o(t())},1e3);return()=>window.clearInterval(d)},[t,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return n.jsx(hs,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},yx="_container_1lz3w_1",xx="_title_1lz3w_5",Nr={container:yx,title:xx},bx=({date:e})=>n.jsxs("div",{className:Nr.container,children:[n.jsx("div",{className:Nr.title,children:"Claimable in"}),n.jsx(_x,{date:e})]}),wx="_container_1oldz_1",jx="_icon_1oldz_7",kr={container:wx,icon:jx},vx="Withdrawal will begin within an hour",Ir=()=>{const e=io();return n.jsxs("div",{className:kr.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(hs,{label:vx,children:n.jsx("span",{className:kr.icon,children:n.jsx(E.IconInfoFilled,{size:12})})})]})},Cx=({children:e})=>{const{withdrawalTx:t}=_o(),s=ny(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},Nx=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=_o(),a=re.toBase64(Rc(o)),r=Pc(o,a),{setReminder:i,removeReminder:c}=Mn();return y.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:Ge.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},kx=()=>n.jsx(Cx,{children:e=>e?n.jsx(Ir,{}):n.jsx(hx,{children:t=>t?n.jsx(Nx,{date:t,children:Ge.isFuture(t)?n.jsx(bx,{date:t}):n.jsx(mx,{})}):n.jsx(Ir,{})})}),Ix="_asset_6h8u2_1",Ax="_info_6h8u2_7",Sx="_symbol_6h8u2_11",Bo={asset:Ix,info:Ax,symbol:Sx},Tx=({amount:e,denom:t})=>{const s=oe(),o=Xr(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:Bo.asset,children:[n.jsx(ee,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:Bo.info,children:[n.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),n.jsx("span",{className:Bo.symbol,children:a})]})]})},Ex="_item_km5w2_1",$x={item:Ex},Mx=({chain:e})=>{const t=e.metadata?.executor_uri;if(!t)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=ty(t),i=y.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Mn();return y.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?n.jsxs(n.Fragment,{children:[i.map(l=>{const{amount:d}=l;return n.jsxs("div",{className:$x.item,children:[n.jsx(Tx,{...d}),n.jsx(pe,{suspenseFallback:null,children:n.jsx(zc.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(kx,{})})})]},l.sequence)}),a&&n.jsx($c,{onClick:()=>o(),disabled:r})]}):n.jsx(_e,{children:"No withdrawals"})},Lx="_content_dj1qm_1",qx="_title_dj1qm_5",Ar={content:Lx,title:qx},Px=()=>{const{chainId:e}=Ze(),t=me(),s=un(),[o,a]=y.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ye(),{reminders:i}=Mn(),c=o?r(o):void 0;return n.jsxs(Nt,{title:"OP Bridge withdrawals",children:[n.jsx(on,{chains:t.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(d=>d.chainId===l)}),n.jsx("div",{className:Ar.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Ar.title,children:c.name}),n.jsx(pe,{children:n.jsx(Mx,{chain:c})},o)]}):n.jsx(ge,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Ks=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Rx="5722e7dffb709492cf5312446ceeff73",Dx=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Rx}`,Qc=["interwovenkit:walletconnect-wallets"],Bx=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",Gc=async e=>{const t=await G.get(Dx,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(Bx)},Fx=()=>S.useQuery({queryKey:Qc,queryFn:({signal:e})=>Gc(e),staleTime:W.INFINITY,gcTime:W.INFINITY,retry:2}),Ux="_page_13y8q_1",Ox="_pageTop_13y8q_19",Vx="_backButtonFixed_13y8q_63",Kx="_listItem_13y8q_64",Wx="_socialButton_13y8q_65",zx="_arrowIcon_13y8q_66",Hx="_searchInputUnderline_13y8q_67",Qx="_header_13y8q_72",Gx="_title_13y8q_81",Yx="_headerSpacer_13y8q_116",Zx="_icon_13y8q_120",Jx="_installedText_13y8q_124",Xx="_divider_13y8q_131",e1="_dividerText_13y8q_152",t1="_loading_13y8q_193",n1="_socialIcons_13y8q_198",s1="_socialText_13y8q_204",o1="_searchWrapper_13y8q_214",a1="_scrollable_13y8q_248",r1="_list_13y8q_64",i1="_listIconWrapper_13y8q_332",c1="_moreIconSmall_13y8q_342",l1="_externalLinkIcon_13y8q_364",d1="_listName_13y8q_368",u1="_listNameMuted_13y8q_381",m1="_recentBadge_13y8q_394",h1="_learnMoreLink_13y8q_408",V={page:Ux,pageTop:Ox,backButtonFixed:Vx,listItem:Kx,socialButton:Wx,arrowIcon:zx,searchInputUnderline:Hx,header:Qx,title:Gx,headerSpacer:Yx,icon:Zx,installedText:Jx,divider:Xx,dividerText:e1,loading:t1,socialIcons:n1,socialText:s1,searchWrapper:o1,scrollable:a1,list:r1,listIconWrapper:i1,moreIconSmall:c1,externalLinkIcon:l1,listName:d1,listNameMuted:u1,recentBadge:m1,learnMoreLink:h1},f1=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},p1=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=y.useState(""),{data:l=[],isError:d,isLoading:u,isFetching:m}=Fx(),h=u||m&&l.length===0,f=y.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(g))},[e,i]),p=y.useMemo(()=>{const g=new Set(e.map(x=>Ks(x.name))),_=i.toLowerCase();return l.filter(x=>!g.has(Ks(x.name))).filter(x=>!i||x.name.toLowerCase().includes(_)).sort((x,w)=>x.name.localeCompare(w.name))},[l,e,i]);return n.jsxs("div",{className:V.pageTop,children:[n.jsx("button",{type:"button",className:V.backButtonFixed,onClick:r,"aria-label":"Back",children:n.jsx(E.IconBack,{size:16,"aria-hidden":"true"})}),n.jsxs("header",{className:V.header,children:[n.jsx("div",{className:V.headerSpacer}),n.jsx("h1",{className:V.title,children:"All Wallets"}),n.jsx("div",{className:V.headerSpacer})]}),n.jsx("div",{className:V.searchWrapper,children:n.jsx(fs,{rootClassName:V.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>c(g.target.value),onClear:()=>c("")})}),n.jsx(dt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[f.map(g=>{const{name:_,icon:x,id:w}=g,C=o===w,b=s===w,j="ready"in g?!!g.ready:!0;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:b}),onClick:()=>a(g),disabled:t||!j,"aria-busy":b,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(ee,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:_}),b?n.jsx(jt,{size:16}):C?n.jsx("span",{className:V.recentBadge,children:"Recent"}):j?n.jsx("span",{className:V.installedText,children:"Installed"}):null]},`connector:${w}`)}),h&&n.jsxs("div",{className:D(V.listItem,V.loading),role:"status","aria-live":"polite",children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(jt,{size:16})}),n.jsx("span",{className:V.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const _=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,x=_&&f1(_)?_:void 0;return n.jsxs("button",{type:"button",className:V.listItem,disabled:!0,"aria-label":`${g.name} (not installed)`,children:[n.jsx("div",{className:V.listIconWrapper,children:x&&n.jsx(ee,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:g.name})]},`wc:${g.id}`)}),d&&n.jsx(ge,{level:"error",children:"Couldn't load additional wallets."})]})})]})},g1=()=>n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),_1=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[n.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),n.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),n.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),n.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),y1=()=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),x1=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),b1=[{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"}],w1=({walletConnectors:e,privyConnector:t,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),u=new Set(l.map(p=>p.id)),m=new Set(l.map(p=>Ks(p.name))),h=Math.max(0,5-d.length),f=b1.filter(p=>!u.has(p.id)&&!m.has(Ks(p.name))).slice(0,h);return n.jsxs("div",{className:V.page,children:[n.jsxs("header",{className:V.header,children:[n.jsx("div",{className:V.headerSpacer}),n.jsx("h1",{className:V.title,children:"Sign In"}),n.jsx("div",{className:V.headerSpacer})]}),t&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:D(V.socialButton,{[V.loading]:o===t.id}),onClick:()=>r(t),disabled:s,"aria-busy":o===t.id,children:[n.jsx("span",{className:V.socialText,children:"Email / Socials"}),o===t.id?n.jsx(jt,{size:16}):n.jsxs("div",{className:V.socialIcons,children:[n.jsx(_1,{}),n.jsx(x1,{}),n.jsx(y1,{})]})]}),n.jsx("div",{className:V.divider,children:n.jsx("span",{className:V.dividerText,children:"or"})})]}),n.jsx(dt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[d.map(p=>{const{name:g,icon:_,id:x}=p,w=o===x,C=a===x;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:w}),onClick:()=>r(p),disabled:s,"aria-busy":w,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(ee,{src:_,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:g}),w?n.jsx(jt,{size:16}):C?n.jsx("span",{className:V.recentBadge,children:"Recent"}):n.jsx("span",{className:V.installedText,children:"Installed"})]},x)}),f.map(p=>n.jsxs("a",{className:V.listItem,href:p.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${p.name} (opens in new tab)`,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(ee,{src:p.icon,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:p.name}),n.jsx(E.IconExternalLink,{size:10,className:V.externalLinkIcon,"aria-hidden":"true"})]},p.id)),n.jsxs("button",{type:"button",className:V.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx("div",{className:V.moreIconSmall,children:n.jsx(g1,{})})}),n.jsx("span",{className:V.listNameMuted,children:"More wallets"}),n.jsx("span",{className:V.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),n.jsxs("a",{className:V.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",n.jsx(E.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Sr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=Ke.useConnect(),o=We.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=y.useState(null),[i,c]=y.useState("signin"),l=S.useQueryClient(),d=()=>l.prefetchQuery({queryKey:Qc,queryFn:({signal:g})=>Gc(g),staleTime:W.INFINITY,gcTime:W.INFINITY}),{mutate:u,isPending:m}=S.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(_){throw await wt(_)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=y.useMemo(()=>[...t].sort((g,_)=>g.id===o?-1:_.id===o?1:g.name.localeCompare(_.name)),[t,o]),f=y.useMemo(()=>h.find(g=>g.id===Gn.id),[h]),p=y.useMemo(()=>h.filter(g=>g.id!==Gn.id),[h]);return i==="all"?n.jsx(p1,{walletConnectors:p,isPending:m,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onBack:()=>c("signin")}):n.jsx(w1,{walletConnectors:p,privyConnector:f,isPending:m,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onShowAll:()=>c("all"),onPrefetchWallets:d})},j1="iUSD",v1={[j1]:{sourceSymbol:"USDC",extraExternalOptions:[{chainId:"1",denom:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Tr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function C1(e){return v1[e]}function Er(e){return e.pretty_name||e.chain_name}function $r(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const N1={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbol:"",localSymbol:""},k1={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 gs(e){return k1[e]}function I1(){const e=Re(),{data:t,error:s}=S.useQuery({queryKey:we.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:o})=>o.filter(({chain_type:a,bech32_prefix:r})=>a==="evm"||a==="cosmos"&&r==="init"),staleTime:W.MINUTE});return{chains:t??[],error:s}}function Pa(){const e=Re(),t=$n(),s=te(),{chains:o,error:a}=I1(),r=y.useMemo(()=>o.map(({chain_id:d})=>d),[o]),{data:i,error:c,isLoading:l}=S.useQuery({queryKey:we.allBalances(r,[t,s]).queryKey,queryFn:()=>{const d=Object.fromEntries(o.map(u=>[u.chain_id,{address:u.chain_type==="evm"?t:s,denoms:[]}]));return e.post("v2/info/balances",{json:{chains:d}}).json()},select:({chains:d})=>d?Object.fromEntries(Object.entries(d).map(([u,{denoms:m}])=>[u,m||{}])):{},enabled:!!s&&r.length>0,staleTime:W.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Ra(){const{localOptions:e=[]}=Ze(),t=S.useQueryClient(),s=Re(),{data:o,isLoading:a}=S.useQuery({queryKey:we.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:W.MINUTE});return{data:y.useMemo(()=>{if(o){const i=Object.values(o.chain_to_assets_map).flatMap(l=>l?.assets??[]),c=new Map(i.map(l=>[`${l.chain_id}:${l.denom}`,l]));return e.map(({denom:l,chainId:d})=>{const u=c.get(`${d}:${l}`);return{denom:l,chain_id:d,symbol:u?.symbol??"",logo_uri:u?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData(kn.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Da(e){const{local:t}=gs(e),s=us(),{watch:o}=Kt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function A1(e){const{external:t}=gs(e),s=us(),{watch:o}=Kt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function Yc(e){const t=us(),s=mo(),o=$t(),a=Sa(),{data:r,isLoading:i}=Pa(),{remoteOptions:c=[]}=Ze(),l=Da(e);if(!l)return{...N1,isLoading:i};const d=C1(l.symbol),u=d?.sourceSymbol??l.symbol,m=c.length>0,h=d?.extraExternalOptions??[],f=d?.extraInitiaSourceSymbols??[],p=d?.externalChainListSource??"supported-assets",g=new Map(s.map(j=>[j.chain_id,j])),_=t.filter(({symbol:j,denom:k,chain_id:T})=>{const L=h.some(q=>Tr(q,T,k)),A=g.get(T),M=!!A&&a(A.chain_id)&&f.includes(j),N=L||M,I=j===l.symbol;return m?c.some(q=>Tr(q,T,k))||N:I||N}).map(j=>{if(j.hidden||j.chain_id===l.chain_id)return null;const k=o(j.chain_id);if(!k||!$r(k))return null;const T=r?.[k.chain_id]?.[j.denom];return{asset:j,chain:k,balance:T}}).filter(j=>j!==null),x=_.filter(({balance:j})=>e!=="deposit"||!!j&&Number(j.amount)>0),w=new Map;if(p==="extra-options")for(const{chainId:j}of h){const k=g.get(j);k&&$r(k)&&(a(k.chain_id)||w.set(k.chain_id,k))}else for(const{chain:j}of x)a(j.chain_id)||w.set(j.chain_id,j);const C=Array.from(w.values()).sort((j,k)=>Er(j).localeCompare(Er(k))),b=[...new Set(_.filter(({chain:j})=>Rp(j,a)).map(({asset:j})=>j.symbol))];return{data:x,isLoading:i,supportedExternalChains:C,appchainSourceSymbols:b,externalSourceSymbol:u,localSymbol:l.symbol}}function Kt(){return Ne.useFormContext()}const S1="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",T1="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e";function Zc(e){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(", ")}, or ${e[e.length-1]}`}function E1(e,t,s){const o=[...new Set(e)],a=[],r=[s,t];for(const c of r)o.includes(c)&&!a.includes(c)&&a.push(c);const i=o.filter(c=>!a.includes(c)).toSorted((c,l)=>c.localeCompare(l));return[...a,...i]}function $1(e,t,s){if(!e.length)return"";const o=E1(e,t,s);return o.length===1&&o[0]===t?"from any appchain":`using ${Zc(o)} from any appchain`}function M1({localSymbol:e,externalSourceSymbol:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=Zc(s),c=$1(o,e,t),l=!!c,d=t!==e;if(r&&l){const u=d?`using ${t} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${u}, or ${c}.`}}return r?d?{title:a,description:`You can deposit ${e} using ${t} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:l?{title:a,description:`You can deposit ${e} ${c}.`}:{title:a,description:"No deposit sources are currently available."}}const L1="_container_pjkfr_1",q1="_title_pjkfr_5",P1="_close_pjkfr_12",R1="_emptyIcon_pjkfr_24",D1="_empty_pjkfr_24",B1="_emptyDescription_pjkfr_39",F1="_list_pjkfr_60",U1="_asset_pjkfr_75",O1="_placeholder_pjkfr_91",V1="_activeAsset_pjkfr_104",K1="_iconContainer_pjkfr_108",W1="_assetIcon_pjkfr_118",z1="_chainIcon_pjkfr_128",H1="_assetPlaceholder_pjkfr_142",Q1="_assetName_pjkfr_163",G1="_assetChain_pjkfr_178",Y1="_balance_pjkfr_186",Z1="_value_pjkfr_195",fe={container:L1,title:q1,close:P1,emptyIcon:R1,empty:D1,emptyDescription:B1,list:F1,asset:U1,placeholder:O1,activeAsset:V1,iconContainer:K1,assetIcon:W1,chainIcon:z1,assetPlaceholder:H1,assetName:Q1,assetChain:G1,balance:Y1,value:Z1},J1=({mode:e})=>{const{external:t}=gs(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbol:i,localSymbol:c}=Yc(e),{setValue:l,watch:d}=Kt(),u=Da(e),{data:m}=Ra(),{theme:h}=se(),f=d(),p=f[t.denomKey],g=f[t.chainIdKey],_=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"",x=y.useEffectEvent(()=>{if(!_)return;const[{asset:C,chain:b}]=s;if(p===C.denom&&g===b.chain_id){l("page","fields");return}l(t.denomKey,C.denom),l(t.chainIdKey,b.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")});y.useEffect(()=>{x()},[_]);function w(){const C=p&&g;return!C&&m.length<=1&&e==="deposit"?null:n.jsx("button",{className:fe.close,onClick:()=>{e==="withdraw"||C?l("page","fields"):l("page","select-local")},children:n.jsx(E.IconBack,{size:20})})}if(!u)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const C=a.map(k=>k.pretty_name||k.chain_name).filter(k=>!!k),b=M1({localSymbol:c,externalSourceSymbol:i,externalChainNames:C,appchainSourceSymbols:r}),j=e==="withdraw"?`No supported destinations to withdraw ${u.symbol}.`:b.title;return n.jsxs("div",{className:fe.container,children:[w(),n.jsx("h4",{className:fe.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?S1:T1,alt:"No assets",className:fe.emptyIcon}),n.jsx("p",{className:fe.empty,children:j}),e==="deposit"&&n.jsx("p",{className:fe.emptyDescription,children:b.description})]})}return n.jsxs("div",{className:fe.container,children:[w(),n.jsxs("h4",{className:fe.title,children:[e==="withdraw"?"Select destination":`Deposit ${u.symbol}`," "]}),n.jsxs("div",{className:fe.list,children:[o&&Array.from({length:5}).map((C,b)=>n.jsxs("div",{className:D(fe.asset,fe.placeholder),children:[n.jsxs("div",{className:fe.iconContainer,children:[n.jsx("div",{className:fe.assetIcon}),n.jsx("div",{className:fe.chainIcon})]}),n.jsx("div",{className:fe.assetPlaceholder})]},b)),!o&&s.sort(({balance:C},{balance:b})=>Number(b?.value_usd??0)-Number(C?.value_usd??0)).map(({asset:C,chain:b,balance:j})=>{const k=p===C.denom&&g===b.chain_id;return n.jsxs("button",{className:D(fe.asset,k&&fe.activeAsset),onClick:()=>{l(t.denomKey,C.denom),l(t.chainIdKey,b.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")},children:[n.jsxs("div",{className:fe.iconContainer,children:[n.jsx("img",{src:C.logo_uri,alt:C.symbol,className:fe.assetIcon}),n.jsx("img",{src:b.logo_uri||"",alt:b.chain_name,className:fe.chainIcon})]}),n.jsxs("p",{className:fe.assetName,children:[C.symbol," ",k&&n.jsx("span",{children:n.jsx(E.IconCheck,{size:16})})]}),n.jsxs("p",{className:fe.assetChain,children:["on ",b.pretty_name]}),j&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:fe.balance,children:v.formatAmount(j.amount,{decimals:j.decimals||6})}),n.jsx("p",{className:fe.value,children:X(j.value_usd||0)})]})]},`${C.chain_id}-${C.denom}`)})]})]})},X1="_title_iequo_1",e0="_list_iequo_7",t0="_asset_iequo_15",n0="_imgPlaceholder_iequo_40",Is={title:X1,list:e0,asset:t0,imgPlaceholder:n0},s0=({mode:e})=>{const{local:t,external:s}=gs(e),{setValue:o}=Kt(),{data:a,isLoading:r}=Ra(),[i,c]=y.useTransition(),l=(u,m)=>{o(t.denomKey,u),o(t.chainIdKey,m),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},d=y.useEffectEvent(()=>{const{denom:u,chain_id:m}=a[0];l(u,m)});return y.useEffect(()=>{!r&&a.length===1&&d()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:Is.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:Is.list,"aria-busy":i,children:a.map(({denom:u,chain_id:m,symbol:h,logo_uri:f})=>n.jsxs("button",{className:Is.asset,onClick:()=>l(u,m),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:Is.imgPlaceholder,"aria-hidden":"true"}),h]},`${u}-${m}`))})]}):n.jsx("div",{children:"No assets found"})},o0="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",a0="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",r0="_container_9k4hs_1",i0="_title_9k4hs_8",c0="_subtitle_9k4hs_14",l0="_linkContainer_9k4hs_30",d0="_link_9k4hs_30",u0="_separator_9k4hs_51",m0="_errorIcon_9k4hs_62",h0="_error_9k4hs_62",Me={container:r0,title:i0,subtitle:c0,linkContainer:l0,link:d0,separator:u0,errorIcon:m0,error:h0};function f0(e){if(!e)return"pending";const t=e.state;return t==="STATE_COMPLETED_SUCCESS"?"success":t==="STATE_ABANDONED"||t==="STATE_COMPLETED_ERROR"||t==="STATE_PENDING_ERROR"?"failed":"pending"}function ta({type:e}){const{closeModal:t}=En(),{theme:s}=se(),{watch:o}=Kt(),{result:a}=o(),{openDrawer:r}=Et();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:m}=a,{srcDenom:h,srcChainId:f,quantity:p}=m,g=vt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:x}=Dc({chainId:l,txHash:c,tracked:!1}),{data:w}=Bc({chainId:l,txHash:c,tracked:!!x,timestamp:d,route:u}),C=f0(w),b=s==="dark"?o0:a0,j=`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 n.jsxs("div",{className:Me.container,children:[n.jsxs("h3",{className:Me.title,children:[_," failed"]}),n.jsx("img",{src:b,alt:"Failed",className:Me.errorIcon}),n.jsx("p",{className:Me.error,children:a?.error}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]});const T=ts(u.estimated_route_duration_seconds),L=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${L.toString()}`,"https://explorer.skip.build"),M=()=>n.jsxs("div",{className:Me.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:Me.link,children:"View transaction"}),n.jsx("div",{className:Me.separator}),n.jsx("button",{className:Me.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:Me.container,children:[C==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Me.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),n.jsx("video",{src:j,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:Me.subtitle,children:["Estimated time: ",n.jsx("span",{children:T})]}),M(),n.jsx("p",{className:Me.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Me.title,children:[_," complete"]}),n.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const I=N.currentTarget;I.duration-I.currentTime<.1&&I.pause()}}),M(),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]}),C==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Me.title,children:[_," failed"]}),n.jsx("img",{src:b,alt:"Failed",className:Me.errorIcon}),n.jsx("p",{className:Me.error,children:"Your transaction could not be completed"}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const p0=Se.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),g0=({tx:e,children:t})=>{const{values:s}=kt(),{srcChainId:o}=s,a=te(),r=rs(),i=eo(),{data:c,isLoading:l}=S.useQuery({queryKey:p0.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:rn.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(l)return n.jsx(ke,{children:n.jsx(ue.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return n.jsx(n.Fragment,{children:t(d)})};function _0(e,t){return e?v.InitiaAddress(e).hex:t}function y0({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:_0(e.recipientAddress,o),slippagePercent:"1",...a}}}const x0="_container_eg177_1",b0="_back_eg177_6",w0="_title_eg177_18",j0="_divider_eg177_26",v0="_label_eg177_30",C0="_asset_eg177_37",N0="_assetIcon_eg177_55",k0="_chainIcon_eg177_67",I0="_assetName_eg177_80",A0="_chevron_eg177_92",S0="_input_eg177_96",T0="_balanceContainer_eg177_108",E0="_value_eg177_116",$0="_maxButton_eg177_126",M0="_detail_eg177_142",L0="_detailsContainer_eg177_153",q0="_detailsButton_eg177_163",P0="_detailValue_eg177_180",R0="_detailToken_eg177_190",D0="_minimumReceived_eg177_198",Y={container:x0,back:b0,title:w0,divider:j0,label:v0,asset:C0,assetIcon:N0,chainIcon:k0,assetName:I0,chevron:A0,input:S0,balanceContainer:T0,value:E0,maxButton:$0,detail:M0,detailsContainer:L0,detailsButton:q0,detailValue:P0,detailToken:R0,minimumReceived:D0},Jc=({renderFee:e})=>{const{route:t}=Ze(),{values:s}=kt(),{dstDenom:o,dstChainId:a}=s,i=us().find(({denom:f,chain_id:p})=>f===o&&p===a),c=te(),l=uc(),[d,u]=We.useToggle(!1),m=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const h=t.does_swap?Ac(t.amount_out,s.slippagePercent):t.amount_out;return n.jsx(Jn,{children:n.jsxs("div",{className:Y.detailsContainer,children:[n.jsxs("button",{className:Y.detailsButton,onClick:u,children:["Transaction details"," ",n.jsx(E.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&n.jsxs(n.Fragment,{children:[t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Slippage"}),n.jsxs("p",{className:Y.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:Y.detailValue,children:$a(t.estimated_fees)})]}),e&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Tx fee"}),n.jsx("div",{className:Y.detailValue,children:e()})]}),c&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",v.truncate(c)]})]})]}),n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated time"}),n.jsx("p",{className:D(Y.detailValue),style:m?{color:"var(--warning)"}:void 0,children:ts(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:D(Y.detail,Y.minimumReceived),children:[n.jsx("p",{className:Y.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",v.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]})})},B0="_trigger_1c7d7_1",F0="_item_1c7d7_5",U0="_itemText_1c7d7_13",O0={trigger:B0,item:F0,itemText:U0},V0=({tx:e,gas:t,confirmMessage:s,onCompleted:o})=>{const{values:a}=kt(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=us().find(({denom:N,chain_id:I})=>N===i&&I===r),u=lt(r),m=ss(u),h=ga(u),f=_a(u),p=Ct(u),g=h.map(({amount:N,denom:I})=>Ae.calculateFee(Math.ceil(t*cn),Ae.GasPrice.fromString(N+I))),_=g.map(N=>N.amount[0]),x=N=>{const I=m.find(K=>K.denom===N)?.amount??"0",U=_.find(K=>K.denom===N)?.amount??"0",q=d&&i===N?F(c||"0").times(F(10).pow(d.decimals)).toFixed(0):"0",P=F(U).plus(q),B=F(I).gte(P),{symbol:H,decimals:z}=p(N);return{symbol:H,decimals:z,spend:F(q).gt(0)?q:null,fee:U,total:P.toFixed(),balance:I,isSufficient:B}},w=()=>{if(!_.length)return null;if(f&&x(f).isSufficient)return f;for(const{denom:N}of _)if(x(N).isSufficient)return N;return _[0]?.denom},[C,b]=y.useState(w),j=g.find(N=>N.amount[0].denom===C)??void 0,k=C?x(C):null,T=k&&!k.isSufficient?"Insufficient balance":void 0,L=(N,I)=>{if(v.formatAmount(N,{decimals:I})==="0.000000")return 8},A=N=>{const[{amount:I,denom:U}]=N.amount;if(F(I).isZero())return"0";const{symbol:q,decimals:P}=p(U),B=L(I,P);return`${v.formatAmount(I,{decimals:P,dp:B})} ${q}`},M=()=>{if(g.length===0)return null;if(g.length===1)return n.jsx("span",{className:"monospace",children:A(g[0])});if(!j||!C)return null;const N=g.map(B=>{const[{denom:H}]=B.amount,{symbol:z}=p(H);return{value:H,label:A(B),triggerLabel:z}}),[{amount:I,denom:U}]=j.amount,{decimals:q}=p(U),P=L(I,q);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:v.formatAmount(I,{decimals:q,dp:P})}),n.jsx(Aa,{options:N,value:C,onChange:b,classNames:O0})]})};return n.jsxs(n.Fragment,{children:[n.jsx(Jc,{renderFee:g.length>0?M:void 0}),n.jsx(qa,{tx:e,children:n.jsx(La,{tx:e,fee:j,onCompleted:o,confirmMessage:s,error:T})})]})},K0=({tx:e,confirmMessage:t,onCompleted:s})=>n.jsxs(n.Fragment,{children:[n.jsx(Jc,{}),n.jsx(qa,{tx:e,children:n.jsx(La,{tx:e,fee:void 0,onCompleted:s,confirmMessage:t})})]}),W0=({tx:e,gas:t,mode:s})=>{const{setValue:o}=Kt(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!t||!("cosmos_tx"in e)?n.jsx(K0,{tx:e,onCompleted:a,confirmMessage:r}):n.jsx(V0,{tx:e,gas:t,onCompleted:a,confirmMessage:r})},z0=({mode:e})=>{const t=gs(e),s=Ie(),o=Ze(),{data:a}=Ra(),r=$t(),{data:i,error:c,chainsError:l}=Pa(),d=$n(),{watch:u,setValue:m,getValues:h}=Kt(),f=u(),{srcChainId:p,srcDenom:g,quantity:_=""}=f,x=f[t.external.denomKey],w=f[t.external.chainIdKey],C=Da(e),b=A1(e),{data:j,isLoading:k}=Yc(e),T=!k&&j.length===1,L=e==="withdraw"&&!k&&j.length>0&&new Set(j.map(({chain:O})=>O.chain_id)).size===1,A=k||!j.length?null:T?j[0]:L?j.reduce((O,Ee)=>{const ae=Number(O.balance?.value_usd??0);return Number(Ee.balance?.value_usd??0)>ae?Ee:O},j[0]):null,M=A?`${A.chain.chain_id}:${A.asset.denom}`:"",N=w?r(w):null,I=i?.[p]?.[g]?.amount,U=i?.[p]?.[g]?.price||0,q=F(U||0).times(_||0),[P]=We.useDebounceValue(_,300),B=e==="withdraw"?C:b,H=y.useMemo(()=>{if(e==="deposit"&&!b)return"Select asset";const O=F(_||0);if(!O.isFinite()||O.lte(0))return"Enter amount";const Ee=v.fromBaseUnit(I??"0",{decimals:B?.decimals||6});if(O.gt(Ee))return"Insufficient balance";if(e==="withdraw"&&!b)return"Select destination"},[e,_,I,B,b]),{data:z,error:K,dataUpdatedAt:le}=Yo(P,{disabled:!!H}),ye=!K&&!H?z:void 0,he=ye&&le>0?le:void 0,xe=y.useEffectEvent(()=>{s(0,y0({currentState:o,route:ye,quoteVerifiedAt:he,hexAddress:d,values:h()}))});y.useEffect(()=>{xe()},[ye,d]);const be=y.useEffectEvent(()=>{if(!A||x&&w)return;const{asset:O,chain:Ee}=A;m(t.external.denomKey,O.denom),m(t.external.chainIdKey,Ee.chain_id),e==="deposit"&&m("quantity","")});if(y.useEffect(()=>{be()},[M]),!C||e==="deposit"&&!b)return null;const De=B?.decimals||6,ut=e==="withdraw"?"Select chain":"Select asset",Mt=()=>{m("quantity",""),m(t.external.denomKey,""),m(t.external.chainIdKey,""),(e==="withdraw"||T)&&(m(t.local.denomKey,""),m(t.local.chainIdKey,"")),m("page",e==="withdraw"||T?"select-local":"select-external")},mt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:Y.asset,disabled:T,onClick:()=>m("page","select-external"),children:[n.jsx("div",{className:Y.assetIcon,children:b?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:b.logo_uri,alt:b.symbol}),n.jsx("img",{src:N?.logo_uri||"",alt:N?.pretty_name,className:Y.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:Y.chainIcon})}),n.jsx("p",{className:Y.assetName,children:b?n.jsxs(n.Fragment,{children:[b.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",N?.pretty_name]})]}):ut}),!T&&n.jsx(E.IconChevronDown,{className:Y.chevron,size:16})]})]}),Te=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:"Amount"}),n.jsx(es,{balance:I,decimals:De,className:Y.input}),Number(I)>0&&n.jsxs("div",{className:Y.balanceContainer,children:[n.jsx("p",{className:Y.value,children:q.gt(0)?X(q.toString()):"$-"}),n.jsxs("button",{className:Y.maxButton,onClick:()=>{const O=v.fromBaseUnit(I??"0",{decimals:De});F(_||0).eq(O)||m("quantity",O)},children:[n.jsx(E.IconWallet,{size:16})," ",v.formatAmount(I,{decimals:De})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("div",{className:Y.container,children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:Y.back,onClick:Mt,children:n.jsx(E.IconBack,{size:20})}),n.jsxs("h3",{className:Y.title,children:[t.label," ",C.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[Te,n.jsx("div",{className:Y.divider}),mt]}):n.jsxs(n.Fragment,{children:[mt,n.jsx("div",{className:Y.divider}),Te]}),(l||c)&&n.jsx(_e,{error:!0,children:"Failed to load balances"}),!o.route||H?n.jsx(ke,{children:n.jsx(ue.White,{type:"submit",loading:!K&&!H&&"Fetching route...",disabled:!0,fullWidth:!0,children:K?"No route found":H})}):n.jsx(Vc,{children:O=>n.jsx(Wc,{children:Ee=>n.jsx(Kc,{addressList:O,signedOpHook:Ee,children:ae=>n.jsx(g0,{tx:ae,children:Le=>n.jsx(W0,{tx:ae,gas:Le,mode:e})})})})})]})},H0="_container_7nl9j_1",Q0="_page_7nl9j_5",Mr={container:H0,page:Q0},Xc=({mode:e})=>{const t=Ne.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Pa(),n.jsx(Ne.FormProvider,{...t,children:n.jsx(G0,{mode:e})})},G0=({mode:e})=>{const{watch:t}=Kt(),s=t("page"),o=bt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return n.jsx(s0,{mode:e});case"select-external":return n.jsx(J1,{mode:e});case"fields":return n.jsx(z0,{mode:e});case"completed":return n.jsx(ta,{type:e})}};return n.jsx(Jn,{children:n.jsx("div",{className:Mr.container,children:o((r,i)=>n.jsx(bt.animated.div,{style:r,className:Mr.page,children:a(i)}))})})},Y0=()=>n.jsx(Xc,{mode:"deposit"}),Z0=()=>n.jsx(Xc,{mode:"withdraw"}),J0="_root_1lo0i_1",X0="_address_1lo0i_9",e2="_copy_1lo0i_19",t2="_labelWrapper_1lo0i_33",n2="_labelCopy_1lo0i_43",s2="_labelCopied_1lo0i_47",o2="_copied_1lo0i_55",a2="_derived_1lo0i_65",r2="_derivedLabel_1lo0i_79",i2="_derivedAddress_1lo0i_83",c2="_hexAddress_1lo0i_89",l2="_derivedCopy_1lo0i_94",Fe={root:J0,address:X0,copy:e2,labelWrapper:t2,labelCopy:n2,labelCopied:s2,copied:o2,derived:a2,derivedLabel:r2,derivedAddress:i2,hexAddress:c2,derivedCopy:l2},d2=()=>{const e=y.useRef(null),t=y.useRef(null),{initiaAddress:s,hexAddress:o}=Je(),a=lc("--gray-0");return y.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new jl({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),t.current.append(e.current)))},[s,a]),n.jsx(Nt,{title:"Receive",children:n.jsxs("div",{className:Fe.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Fe.address,children:s}),n.jsx(Fs,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Fe.copy,{[Fe.copied]:i}),onClick:r,children:[n.jsx(E.IconCopy,{size:12}),n.jsxs("div",{className:Fe.labelWrapper,children:[n.jsx("span",{className:Fe.labelCopy,children:"Copy address"}),n.jsx("span",{className:Fe.labelCopied,children:"Copied!"})]})]})}),n.jsx(Fs,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Fe.derived,{[Fe.copied]:i}),onClick:r,children:[n.jsx("span",{className:Fe.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Fe.derivedAddress,children:[n.jsx("span",{className:Fe.hexAddress,children:v.truncate(o)}),n.jsx(E.IconCopy,{size:12,className:Fe.derivedCopy}),i&&n.jsx("span",{className:Fe.copiedText,children:"Copied!"})]})]})})]})})};function u2(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function m2(){const e=te(),t=me();return S.useQueries({queries:t.map(s=>({queryKey:Ds.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Qs(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Ai(o),r=e?ua(e,s.chainId):null,i=u2(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:W.SECOND,retry:!1}))})}const h2="_countdown_vfms8_1",f2={countdown:h2},p2=({expiration:e})=>{const t=()=>{const a=new Date,r=Ge.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(c>0||i>0)&&u.push(`${c}h`),(l>0||c>0||i>0)&&u.push(`${l}m`),u.push(`${d}s`),u.join(" ")},[s,o]=y.useState(t());return We.useInterval(()=>{o(t())},1e3),Ge.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:f2.countdown,children:s})]})},g2="_container_1l528_1",_2="_info_1l528_11",y2="_header_1l528_17",x2="_chainName_1l528_23",b2="_expiration_1l528_29",w2="_revokeButton_1l528_35",xn={container:g2,info:_2,header:y2,chainName:x2,expiration:b2,revokeButton:w2},j2=({chainId:e,grantee:t,expiration:s})=>{const o=lt(e),{mutate:a,isPending:r}=Ki({grantee:t,internal:!0});return n.jsxs("div",{className:xn.container,children:[n.jsxs("div",{className:xn.info,children:[n.jsxs("div",{className:xn.header,children:[n.jsx(ee,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:xn.chainName,children:o.name})]}),n.jsx("div",{className:xn.expiration,children:s?n.jsx(p2,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:xn.revokeButton,onClick:()=>a(e),disabled:r,children:r?"Revoking...":"Revoke"})]})},v2=({chainId:e,grants:t})=>{const s=new Map;for(const a of t){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=pa([r.expiration,i])}return[...s.values()].map(a=>y.createElement(j2,{...a,chainId:e,key:a.grantee}))},C2="_content_q36qs_1",N2={content:C2},k2=()=>{const e=m2(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(_e,{children:"No permissions found"}):n.jsx("div",{className:N2.content,children:s.map(({chainId:o,grants:a})=>n.jsx(v2,{chainId:o,grants:a},o))})};return n.jsx(Nt,{title:"Manage auto-signing",backButton:"/settings",children:t()})},I2="_version_1sf5y_1",A2={version:I2},S2=()=>n.jsxs("aside",{className:A2.version,children:["v","2.4.4"]}),T2="_link_se23z_1",E2="_title_se23z_17",$2="_subtitle_se23z_23",M2="_icon_se23z_30",As={link:T2,title:E2,subtitle:$2,icon:M2},el=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:As.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:As.title,children:e}),t&&n.jsx("p",{className:As.subtitle,children:t})]}),n.jsx("div",{className:As.icon,children:s??n.jsx(E.IconChevronRight,{size:16})})]}),L2="https://export.initia.xyz/",q2=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(el,{title:"Export private key",rightSection:n.jsx(E.IconExternalLink,{size:16}),onClick:()=>window.open(L2,"_blank",e)})},P2="_container_1vxr7_1",R2="_separator_1vxr7_7",Lr={container:P2,separator:R2},D2=()=>{const e=Ie(),{connector:t}=Ke.useAccount();return n.jsx(Nt,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Lr.container,children:[n.jsx(el,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ra&&n.jsx(q2,{}),n.jsx(St.Separator,{className:Lr.separator}),n.jsx(S2,{})]})})},B2="_trigger_1yjkd_1",F2="_icon_1yjkd_23",U2="_full_1yjkd_27",O2="_triggerContent_1yjkd_32",V2="_triggerText_1yjkd_40",K2="_popoverBackdrop_1yjkd_51",W2="_popoverPositioner_1yjkd_70",z2="_popoverPopup_1yjkd_74",H2="_search_1yjkd_99",Q2="_viewport_1yjkd_105",G2="_item_1yjkd_111",Y2="_highlighted_1yjkd_127",Z2="_active_1yjkd_131",J2="_itemContent_1yjkd_136",X2="_extra_1yjkd_142",eb="_connectedTag_1yjkd_149",Ce={trigger:B2,icon:F2,full:U2,triggerContent:O2,triggerText:V2,popoverBackdrop:K2,popoverPositioner:W2,popoverPopup:z2,search:H2,viewport:Q2,item:G2,highlighted:Y2,active:Z2,itemContent:J2,extra:X2,connectedTag:eb},yo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=se(),[i,c]=y.useState(""),[l,d]=y.useState(!1),[u,m]=y.useState(0),[h,f]=y.useState(),p=y.useRef([]),g=y.useRef(null),_=me(),x=s.map(N=>_.find(I=>I.chainId===N)).filter(Boolean),w=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),n.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),C=y.useMemo(()=>({chainId:"",name:"All",logoUrl:w}),[]),b=y.useMemo(()=>{const N=[C,...x];if(!i)return N;const I=i.toLowerCase();return N.filter(U=>U.name.toLowerCase().includes(I)||U.chainId.toLowerCase().includes(I))},[x,i,C]),j=x.find(N=>N.chainId===e)||C,k=parseInt(lc("--drawer-offset")),T=6,L=()=>{if(c(""),m(-1),g.current){const I=g.current.getBoundingClientRect().bottom+T,U=window.innerHeight-I-2*k;f(U)}d(!0)};y.useEffect(()=>{u>=0&&u<p.current.length&&p.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const A=y.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),m(I=>(I+1)%b.length);break;case"ArrowUp":N.preventDefault(),m(I=>(I-1+b.length)%b.length);break;case"Enter":N.preventDefault(),b[u]&&(t(b[u].chainId),d(!1));break;case"Escape":N.preventDefault(),d(!1);break}},[b,u,t,d]),M=N=>{t(N),d(!1)};return n.jsxs(_n.Popover.Root,{open:l,onOpenChange:L,modal:"trap-focus",children:[n.jsx(_n.Popover.Trigger,{render:n.jsxs("button",{className:D(Ce.trigger,{[Ce.full]:a}),"aria-expanded":l,role:"listbox",ref:g,children:[n.jsxs("div",{className:Ce.triggerContent,children:[typeof j.logoUrl=="string"?n.jsx(ee,{src:j.logoUrl,width:14,height:14,logo:!0}):j.logoUrl(14),n.jsx("span",{className:Ce.triggerText,children:j.name})]}),n.jsx(E.IconChevronDown,{size:16,className:Ce.icon})]})}),n.jsxs(_n.Popover.Portal,{container:dn(),children:[n.jsx(_n.Popover.Backdrop,{className:Ce.popoverBackdrop,onClick:()=>d(!1)}),n.jsx(_n.Popover.Positioner,{className:Ce.popoverPositioner,align:"end",side:"bottom",sideOffset:T,collisionAvoidance:{side:"none"},children:n.jsxs(_n.Popover.Popup,{className:D(Ce.popoverPopup,{[Ce.full]:a}),style:{maxHeight:h},children:[n.jsx(fs,{value:i,onChange:N=>{c(N.target.value),m(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search appchains",rootClassName:Ce.search,ref:ms()}),n.jsx("div",{className:Ce.viewport,role:"listbox",children:b.length===0?n.jsx(_e,{children:"No appchains found"}):b.map(({chainId:N,name:I,logoUrl:U},q)=>n.jsxs("div",{className:D(Ce.item,{[Ce.highlighted]:q===u,[Ce.active]:e===N}),onClick:()=>M(N),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),M(N))},onMouseEnter:()=>m(q),role:"option","aria-selected":e===N,tabIndex:-1,ref:P=>{P&&(p.current[q]=P)},children:[n.jsxs("div",{className:Ce.itemContent,children:[typeof U=="string"?n.jsx(ee,{src:U,width:16,height:16,logo:!0}):U(16),n.jsx("span",{className:Ce.name,children:I}),N===r&&n.jsx("span",{className:Ce.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:Ce.extra,children:o(N)})]},N))})]})})]})]})},tb="_container_1nap1_1",nb="_controls_1nap1_7",sb="_search_1nap1_13",Ba={container:tb,controls:nb,search:sb},ob=({children:e})=>n.jsx("div",{className:Ba.container,children:e}),ab=({children:e})=>n.jsx("div",{className:Ba.controls,children:e}),rb=e=>n.jsx(fs,{...e,rootClassName:Ba.search}),ct={Root:ob,Controls:ab,SearchInput:rb},tl=Q.atom(""),nl=Q.atom(""),ib=Q.atom(""),cb=Q.atom(""),lb=Q.atom(""),db="_change_1nm9m_1",ub="_positive_1nm9m_8",mb="_negative_1nm9m_12",Fo={change:db,positive:ub,negative:mb},sl=({amount:e,asset:t})=>{const{denom:s,symbol:o,decimals:a}=t,r=new F(e).isPositive(),i=new F(e).abs().toString();return n.jsxs("div",{className:D(Fo.change,r?Fo.positive:Fo.negative),children:[r?"+":"-",v.formatAmount(i,{decimals:a})," ",o||s]})},hb=({changes:e,chain:t})=>{const s=Ct(t);return e.map(({amount:o,denom:a},r)=>n.jsx(sl,{amount:o,asset:s(a)},r))},fb=({changes:e,chain:t})=>{const s=Ct(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(gc,{metadata:a,chain:t,children:i=>n.jsx(sl,{amount:o,asset:s(i)})},r))},pb=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=Je();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(fb,{changes:pc(e,o),chain:t}):n.jsx(hb,{changes:fc(e,s),chain:t})},gb="_message_1qc8m_1",_b="_more_1qc8m_9",qr={message:gb,more:_b},yb=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:qr.message,children:zs.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:qr.more,children:`+${e.length-3} more`})]}),xb="_link_1vbb0_1",bb="_inner_1vbb0_16",wb="_header_1vbb0_21",jb="_time_1vbb0_30",vb="_error_1vbb0_36",Cb="_timestamp_1vbb0_40",Nb="_chainInfo_1vbb0_45",kb="_content_1vbb0_53",Ib="_messages_1vbb0_61",Ab="_changes_1vbb0_67",_t={link:xb,inner:bb,header:wb,time:jb,error:vb,timestamp:Cb,chainInfo:Nb,content:kb,messages:Ib,changes:Ab},Sb=({txItem:e,chain:t})=>n.jsx(lo,{txHash:e.txhash,chainId:t.chainId,className:_t.link,children:n.jsxs("div",{className:_t.inner,children:[n.jsxs("div",{className:_t.header,children:[n.jsxs("div",{className:_t.time,children:[e.code!==0&&n.jsx(E.IconWarningFilled,{size:14,className:_t.error}),n.jsx("span",{className:_t.timestamp,children:Ge.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:_t.chainInfo,children:[n.jsx(ee,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:_t.content,children:[n.jsx("div",{className:_t.messages,children:n.jsx(yb,{messages:e.tx.body.messages})}),n.jsx("div",{className:_t.changes,children:n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(pb,{...e,chain:t})})})]})]})}),Tb="_list_1mv55_1",Eb="_dateGroup_1mv55_7",$b="_dateHeader_1mv55_12",Mb="_more_1mv55_18",Ss={list:Tb,dateGroup:Eb,dateHeader:$b,more:Mb},Lb=({list:e,chainId:t})=>{const s=te(),o=y.useMemo(()=>Mc(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(_e,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Ss.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Ss.dateGroup,children:[n.jsx("div",{className:Ss.dateHeader,children:a}),r.map(i=>n.jsx(pe,{errorBoundaryProps:{fallback:null},children:n.jsx(Sb,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(lo,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Ss.more,showIcon:!0,children:"View more on Initia Scan"})]})},qb=()=>{const{activities:e,isLoading:t}=Pd(),[s,o]=Q.useAtom(lb),a=oe(),r=y.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=y.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return t&&e.length===0?n.jsx(_e,{children:"Loading activities..."}):!e.length&&!t?n.jsx(_e,{children:"No activity yet"}):n.jsxs(ct.Root,{children:[n.jsx(ct.Controls,{children:n.jsx(yo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Lb,{list:i,chainId:s||a.chainId})]})},Pb="_thumbnail_1xyqw_1",Rb="_placeholder_1xyqw_18",Db="_clickable_1xyqw_24",Kn={thumbnail:Pb,placeholder:Rb,clickable:Db},Bb=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=se(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:D(Kn.thumbnail,Kn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(ee,{src:l,classNames:{placeholder:Kn.placeholder}})}):n.jsx("div",{className:Kn.thumbnail,style:{width:t,height:t},children:n.jsx(ee,{src:l,classNames:{placeholder:Kn.placeholder}})})},Fb="_collectionName_qs5tw_1",Ub="_nftName_qs5tw_6",Ob="_chainInfo_qs5tw_10",Uo={collectionName:Fb,nftName:Ub,chainInfo:Ob},Fa=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return n.jsxs("div",{className:a?.root,children:[n.jsx(Bb,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:D(Uo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:D(Uo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:D(Uo.chainInfo,a?.chainInfo),children:[n.jsx(ee,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ua=Se.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function Vb(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function Kb(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const Wb=()=>{const e=te(),t=me(),s=S.useQueries({queries:t.map(l=>({queryKey:Ua.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Qs(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:W.SECOND}))}),o=s.map($.prop("data")),a=Kb(t,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 zb(e){const t=Pr(e);return S.useQuery({queryKey:Ua.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await G.get(t).json();return{...s,image:Pr(s.image)}}catch{return{}}},staleTime:W.INFINITY})}function Pr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Hb=({nftInfo:e,children:t})=>{const{data:s={}}=zb(e.nft.uri),o=Vb(e,s);return t(o)},Qb="_grid_1wwdn_1",Gb="_root_1wwdn_7",Yb="_collectionName_1wwdn_15",Zb="_nftName_1wwdn_23",Jb="_chainInfo_1wwdn_32",Rr={grid:Qb,root:Gb,collectionName:Yb,nftName:Zb,chainInfo:Jb},Xb=()=>{const[e,t]=Q.useAtom(ib),[s,o]=Q.useAtom(cb),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=Wb(),l=Ie(),d=y.useMemo(()=>a.filter(({collection_addr:m,collection_name:h,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return m.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||p.toLowerCase().includes(_)}return!0}),[a,s,e]),u=y.useMemo(()=>Array.from(new Set(a.map(({chain:m})=>m.chainId))),[a]);return c&&a.length===0?n.jsx(_e,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(_e,{children:"No NFTs"}):n.jsxs(ct.Root,{children:[n.jsxs(ct.Controls,{children:[n.jsx(ct.SearchInput,{value:e,onChange:m=>t(m.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(yo,{value:s,onChange:o,chainIds:u,renderExtra:m=>m?r[m]||0:i})]}),d.length===0?n.jsx(_e,{children:"No NFTs found"}):n.jsx("div",{className:Rr.grid,children:d.map(m=>{const{collection_addr:h,nft:f}=m;return n.jsx(Hb,{nftInfo:m,children:p=>n.jsx(Fa,{normalizedNft:p,onThumbnailClick:()=>l("/nft",p),classNames:Rr})},h+f.token_id)})})]})},ol=y.createContext(null);function al(){return y.useContext(ol)}const ew="_popup_nbecp_1",tw="_item_nbecp_19",Ts={popup:ew,item:tw},rl=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[u,m]=y.useState(!1),h=Ie(),f=al(),{showNotification:p}=uo(),{defaultChainId:g}=se(),{evm_chain_id:_}=un(),x=Ke.useChainId(),{switchChainAsync:w}=Ke.useSwitchChain(),{watchAssetAsync:C}=Ke.useWatchAsset(),b=()=>{m(!1),h("/send",{denom:s,chain:l})},j=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=S.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const T=r;return await w({chainId:Number(_)}),C({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:T}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:T=>{p({type:"error",title:"Asset addition failed",description:T.message})}});return n.jsxs(St.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[n.jsx(St.Menu.Trigger,{render:t}),n.jsx(St.Menu.Portal,{container:f,children:n.jsx(St.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(St.Menu.Popup,{className:Ts.popup,children:[n.jsxs(St.Menu.Item,{className:Ts.item,onClick:b,children:[n.jsx(E.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(St.Menu.Item,{className:Ts.item,onClick:j,disabled:i,children:[n.jsx(E.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),d===g&&_===x&&!!c&&n.jsxs(St.Menu.Item,{className:Ts.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?n.jsx(E.IconCheck,{size:16}):n.jsx(E.IconPlus,{size:16}),n.jsx("span",{children:"Add to Wallet"})]})]})})})]})},nw="_item_38qhm_1",sw="_info_38qhm_23",ow="_images_38qhm_29",aw="_name_38qhm_33",rw="_value_38qhm_39",iw="_amount_38qhm_47",cw="_usd_38qhm_53",Jt={item:nw,info:sw,images:ow,name:aw,value:rw,amount:iw,usd:cw},lw=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=v.formatAmount(t,{decimals:e.decimals});return n.jsx(rl,{asset:e,children:n.jsxs("button",{className:Jt.item,children:[n.jsxs("div",{className:Jt.info,children:[n.jsx(fo,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Jt.images}),n.jsx("span",{className:Jt.name,children:a.name})]}),n.jsxs("div",{className:Jt.value,children:[n.jsx("span",{className:Jt.amount,children:r}),Number(s)>0&&n.jsx("span",{className:Jt.usd,children:X(s)})]})]})})},dw="_container_ytg3p_1",uw="_assetItem_ytg3p_6",mw="_expandIcon_ytg3p_22",hw="_assetInfo_ytg3p_27",fw="_logo_ytg3p_33",pw="_details_ytg3p_37",gw="_symbol_ytg3p_42",_w="_chainName_ytg3p_53",yw="_chainInfos_ytg3p_59",xw="_chainLogos_ytg3p_65",bw="_chainLogo_ytg3p_65",ww="_moreChains_ytg3p_76",jw="_expanded_ytg3p_93",vw="_valueColumn_ytg3p_98",Cw="_amount_ytg3p_108",Nw="_value_ytg3p_98",kw="_collapsibleContent_ytg3p_121",Iw="_chainsList_ytg3p_151",je={container:dw,assetItem:uw,expandIcon:mw,assetInfo:hw,logo:fw,details:pw,symbol:gw,chainName:_w,chainInfos:yw,chainLogos:xw,chainLogo:bw,moreChains:ww,expanded:jw,valueColumn:vw,amount:Cw,value:Nw,collapsibleContent:kw,chainsList:Iw},Aw=Q.atom([]),Oa=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=Q.useAtom(Aw),c=y.useMemo(()=>Xd(e),[e]),l=y.useMemo(()=>Wi(e),[e]),d=r.includes(t),u=()=>{i(h=>d?h.filter(f=>f!==t):[...new Set([...h,t])])},m=()=>n.jsxs("button",{className:je.assetItem,children:[n.jsxs("div",{className:je.assetInfo,children:[s&&n.jsx(ee,{src:s,width:32,height:32,className:je.logo,logo:!0}),n.jsxs("div",{className:je.details,children:[n.jsx("div",{className:je.symbol,children:t}),a?n.jsx("div",{className:je.chainName,children:o[0].chain.name}):n.jsxs("div",{className:je.chainInfos,children:[n.jsx("div",{className:je.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(ee,{src:h.logoUrl,width:16,height:16,className:je.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:je.moreChains,children:["+",o.length-5]}),n.jsx(E.IconChevronDown,{size:16,className:D(je.expandIcon,{[je.expanded]:d})})]})]})]}),n.jsxs("div",{className:je.valueColumn,children:[n.jsx("div",{className:je.amount,children:v.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:je.value,children:X(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:je.container,children:n.jsx(rl,{asset:h,children:m()})})}return n.jsx("div",{className:je.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:u,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:m()}),n.jsx(Z.Collapsible.Content,{className:je.collapsibleContent,children:n.jsx("div",{className:je.chainsList,children:o.map(h=>n.jsx(lw,{asset:h},h.chain.chainId))})})]})})},Sw="_collapsible_1g7rh_1",Tw="_trigger_1g7rh_5",Ew="_divider_1g7rh_20",$w="_label_1g7rh_28",Mw="_chevron_1g7rh_33",Lw="_content_1g7rh_41",qw="_list_1g7rh_45",Rt={collapsible:Sw,trigger:Tw,divider:Ew,label:$w,chevron:Mw,content:Lw,list:qw},il=({unlistedAssets:e})=>{const[t,s]=y.useState(!1),o=al(),a=y.useRef(null),[r,i]=y.useState(0);y.useEffect(()=>{if(a.current){const m=a.current.scrollHeight;i(m)}},[e]);const c=y.useRef(null),l=m=>{s(m),m&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),p=c.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const x=p.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},d=bt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),u=y.useMemo(()=>e.map(m=>({...m,assets:[m],totalValue:m.value??0,totalAmount:Number(m.quantity)})),[e]);return e.length===0?null:n.jsxs(Z.Collapsible.Root,{open:t,onOpenChange:l,className:Rt.collapsible,children:[n.jsxs(Z.Collapsible.Trigger,{ref:c,className:Rt.trigger,children:[n.jsx("div",{className:Rt.divider}),n.jsxs("span",{className:Rt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(E.IconChevronDown,{className:Rt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Rt.divider})]}),n.jsx(Z.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(bt.animated.div,{className:Rt.content,style:d,children:n.jsx("div",{className:Rt.list,ref:a,children:u.map(m=>n.jsx(Oa,{assetGroup:m},m.assets[0].denom))})})})]})},Pw="_container_15xfg_1",Rw="_header_15xfg_7",Dw="_title_15xfg_13",Bw="_totalValue_15xfg_19",Fw="_list_15xfg_26",Cn={container:Pw,header:Rw,title:Dw,totalValue:Bw,list:Fw},Uw=()=>{const[e,t]=Q.useAtom(tl),[s,o]=Q.useAtom(nl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=ya(),d=i.map(({chainId:h})=>h),u=y.useMemo(()=>{const h=e?a.filter(p=>{const{symbol:g,assets:_}=p;return g.toLowerCase().includes(e.toLowerCase())||_.some(({denom:x,address:w})=>x.toLowerCase().includes(e.toLowerCase())||w?.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]),m=y.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?n.jsx(_e,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!s&&!l?n.jsx(_e,{children:"No assets"}):n.jsxs(ct.Root,{children:[n.jsxs(ct.Controls,{children:[n.jsx(ct.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(yo,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return X(c);const f=i.find(p=>p.chainId===h);return f?X(f.value):null}})]}),n.jsx("div",{children:u.length===0&&m.length===0?n.jsx(_e,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Cn.list,children:u.map(h=>n.jsx(Oa,{assetGroup:h},h.symbol))}),n.jsx(il,{unlistedAssets:m})]})})]})},Ow="_container_11k2x_1",Vw={container:Ow},yt=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(an,{height:e,width:s}):n.jsx("div",{className:Vw.container,children:o.map(a=>n.jsx(an,{height:e,width:s},a))})},Kw=y.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ls(),l=oe(),{listedGroups:d,unlistedAssets:u}=y.useMemo(()=>pm(i,a,r,l.chainId),[i,a,r,l.chainId]),m=y.useMemo(()=>um(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:p}=y.useMemo(()=>fm(m,u,e,t),[m,u,e,t]);return n.jsxs("div",{className:Cn.container,children:[n.jsxs("div",{className:Cn.header,children:[n.jsx("span",{className:Cn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Cn.totalValue,children:X(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Cn.list,children:h.map(g=>n.jsx(Oa,{assetGroup:g},g.symbol))}),n.jsx(il,{unlistedAssets:p})]}):m.length===0&&c?n.jsx(yt,{height:56,length:3}):n.jsx(_e,{children:"No liquid assets"})]})}),Ww="_container_1n61l_1",zw="_section_1n61l_7",Hw="_sectionHeader_1n61l_19",Qw="_sectionTitle_1n61l_25",Gw="_sectionLabel_1n61l_31",Yw="_externalLink_1n61l_37",Zw="_sectionValue_1n61l_49",Jw="_tokenList_1n61l_56",Xw="_stakingTokenList_1n61l_62",ej="_tokenRow_1n61l_72",tj="_tokenMain_1n61l_78",nj="_tokenTrigger_1n61l_84",sj="_tokenChevron_1n61l_100",oj="_expanded_1n61l_111",aj="_triggerValue_1n61l_115",rj="_tokenInfo_1n61l_122",ij="_tokenInfoLabel_1n61l_128",cj="_tokenLogo_1n61l_134",lj="_tokenSymbol_1n61l_138",dj="_tokenValues_1n61l_144",uj="_tokenAmount_1n61l_150",mj="_tokenValue_1n61l_144",hj="_typeBreakdown_1n61l_164",fj="_typeRow_1n61l_172",pj="_typeLabel_1n61l_180",gj="_typeValues_1n61l_186",_j="_typeAmount_1n61l_192",yj="_typeValue_1n61l_186",xj="_collapsibleContent_1n61l_206",J={container:Ww,section:zw,sectionHeader:Hw,sectionTitle:Qw,sectionLabel:Gw,externalLink:Yw,sectionValue:Zw,tokenList:Jw,stakingTokenList:Xw,tokenRow:ej,tokenMain:tj,tokenTrigger:nj,tokenChevron:sj,expanded:oj,triggerValue:aj,tokenInfo:rj,tokenInfoLabel:ij,tokenLogo:cj,tokenSymbol:lj,tokenValues:dj,tokenAmount:uj,tokenValue:mj,typeBreakdown:hj,typeRow:fj,typeLabel:pj,typeValues:gj,typeAmount:_j,typeValue:yj,collapsibleContent:xj},cl=({protocols:e,denomLogoMap:t,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=y.useMemo(()=>{const c=e.flatMap(l=>l.positions);return tm(c)},[e]);return i.size===0?null:n.jsx("div",{className:J.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(bj,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},bj=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,d=em(e,o),u=y.useMemo(()=>cm(c),[c]),m=e==="staking";return n.jsxs("div",{className:J.section,children:[n.jsxs("div",{className:J.sectionHeader,children:[n.jsxs("div",{className:J.sectionTitle,children:[n.jsx("span",{className:J.sectionLabel,children:d}),m&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:J.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12})})]}),n.jsx("span",{className:J.sectionValue,children:X(l)})]}),n.jsx("div",{className:D(J.tokenList,{[J.stakingTokenList]:m}),children:u.map(h=>n.jsx(wj,{group:h,showTypeBreakdown:m,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},wj=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,u=s.get(r),[m,h]=y.useState(!1),f=y.useMemo(()=>{if(!t)return null;const p=rm(d);return p.size>0?p:null},[d,t]);return f?n.jsxs(Z.Collapsible.Root,{open:m,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:J.tokenTrigger,children:[n.jsxs("div",{className:J.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(J.tokenChevron,{[J.expanded]:m})}),n.jsxs("div",{className:J.tokenInfoLabel,children:[u?.assetLogo&&n.jsx(ee,{src:u.assetLogo,width:20,height:20,className:J.tokenLogo}),n.jsx("span",{className:J.tokenSymbol,children:i})]})]}),n.jsx("span",{className:J.triggerValue,children:X(l)})]})}),n.jsx(Z.Collapsible.Content,{className:J.collapsibleContent,children:n.jsx(jj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:J.tokenRow,children:n.jsxs("div",{className:J.tokenMain,children:[n.jsxs("div",{className:J.tokenInfo,children:[u?.assetLogo&&n.jsx(ee,{src:u.assetLogo,width:20,height:20,className:J.tokenLogo}),n.jsx("span",{className:J.tokenSymbol,children:i})]}),n.jsxs("div",{className:J.tokenValues,children:[n.jsx("span",{className:J.tokenAmount,children:v.formatNumber(c,{dp:6})}),n.jsx("span",{className:J.tokenValue,children:X(l)})]})]})})},jj=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=y.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const u=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),m=d.reduce((h,f)=>h+An(f),0);return{type:l,typeAmount:u,typeValue:m}}),[e]),i=y.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const u=o(s,d);l+=Number(u)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:J.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:u})=>n.jsxs("div",{className:J.typeRow,children:[n.jsx("span",{className:J.typeLabel,children:am(l)}),n.jsxs("div",{className:J.typeValues,children:[n.jsxs("span",{className:J.typeAmount,children:[v.formatNumber(d,{dp:6})," ",t]}),n.jsx("span",{className:J.typeValue,children:X(u)})]})]},l)),c&&n.jsxs("div",{className:J.typeRow,children:[n.jsx("span",{className:J.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:J.typeValues,children:[n.jsxs("span",{className:J.typeAmount,children:[v.formatNumber(i,{dp:6})," ",it]}),n.jsx("span",{className:J.typeValue,children:X(i*(a??0))})]})]})]})},vj="_container_ymkoc_1",Cj="_trigger_ymkoc_6",Nj="_expandIcon_ymkoc_22",kj="_chainInfo_ymkoc_27",Ij="_logo_ymkoc_33",Aj="_chainNameContainer_ymkoc_37",Sj="_chainName_ymkoc_37",Tj="_externalLink_ymkoc_49",Ej="_externalIcon_ymkoc_53",$j="_valueColumn_ymkoc_63",Mj="_value_ymkoc_63",Lj="_expanded_ymkoc_80",qj="_collapsibleContent_ymkoc_85",Pj="_content_ymkoc_97",Ue={container:vj,trigger:Cj,expandIcon:Nj,chainInfo:kj,logo:Ij,chainNameContainer:Aj,chainName:Sj,externalLink:Tj,externalIcon:Ej,valueColumn:$j,value:Mj,expanded:Lj,collapsibleContent:qj,content:Pj},Rj=Q.atom([]),Dj=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=me(),r=ns(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>ka(r,a),[r,a]),l=y.useMemo(()=>{const d=new Map;for(const u of o)for(const m of u.positions){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:h,symbol:f}=m.balance,p=f.toUpperCase(),g=`${t}:${h}`,_=i.get(g)??c.get(p);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,t,s]);return n.jsx(cl,{protocols:o,denomLogoMap:l})},Bj=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=Q.useAtom(Rj),c=y.useMemo(()=>o.reduce((f,p)=>f+p.positions.reduce((g,_)=>g+An(_),0),0),[o]),l=["civitia","yominet"],d=r.includes(t),u=t?.toLowerCase(),m=l.includes(u),h=()=>{i(f=>d?f.filter(p=>p!==t):[...new Set([...f,t])])};return n.jsx("div",{className:Ue.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Ue.trigger,children:[n.jsxs("div",{className:Ue.chainInfo,children:[s&&n.jsx(ee,{src:s,width:32,height:32,className:Ue.logo,logo:!0}),n.jsxs("div",{className:Ue.chainNameContainer,children:[n.jsx("span",{className:Ue.chainName,children:t}),a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Ue.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,className:Ue.externalIcon})})]})]}),n.jsxs("div",{className:Ue.valueColumn,children:[!m&&n.jsx("span",{className:Ue.value,children:X(c)}),n.jsx(E.IconChevronDown,{size:16,className:D(Ue.expandIcon,{[Ue.expanded]:d})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Ue.collapsibleContent,children:n.jsx("div",{className:Ue.content,children:n.jsx(Dj,{chainGroup:e})})})]})})},Fj="_container_g7q2b_1",Uj="_section_g7q2b_6",Oj="_sectionHeader_g7q2b_14",Vj="_sectionTitle_g7q2b_20",Kj="_sectionLabel_g7q2b_26",Wj="_externalLink_g7q2b_32",zj="_sectionValue_g7q2b_44",Hj="_tokenList_g7q2b_51",Qj="_tokenTrigger_g7q2b_63",Gj="_tokenChevron_g7q2b_79",Yj="_expanded_g7q2b_90",Zj="_tokenInfo_g7q2b_94",Jj="_tokenInfoLabel_g7q2b_100",Xj="_tokenLogo_g7q2b_106",ev="_pairedLogos_g7q2b_110",tv="_coinLogo_g7q2b_115",nv="_tokenSymbol_g7q2b_133",sv="_triggerValue_g7q2b_139",ov="_clammBreakdownContent_g7q2b_146",av="_clammPositionRow_g7q2b_154",rv="_statusDot_g7q2b_163",iv="_inRange_g7q2b_170",cv="_outRange_g7q2b_174",lv="_unknown_g7q2b_178",dv="_clammStatusValue_g7q2b_182",uv="_breakdownContent_g7q2b_192",mv="_breakdownRow_g7q2b_200",hv="_breakdownLabel_g7q2b_208",fv="_breakdownValues_g7q2b_214",pv="_breakdownAmount_g7q2b_220",gv="_breakdownValue_g7q2b_214",_v="_collapsibleContent_g7q2b_241",R={container:Fj,section:Uj,sectionHeader:Oj,sectionTitle:Vj,sectionLabel:Kj,externalLink:Wj,sectionValue:zj,tokenList:Hj,tokenTrigger:Qj,tokenChevron:Gj,expanded:Yj,tokenInfo:Zj,tokenInfoLabel:Jj,tokenLogo:Xj,pairedLogos:ev,coinLogo:tv,tokenSymbol:nv,triggerValue:sv,clammBreakdownContent:ov,clammPositionRow:av,statusDot:rv,inRange:iv,outRange:cv,unknown:lv,clammStatusValue:dv,breakdownContent:uv,breakdownRow:mv,breakdownLabel:hv,breakdownValues:fv,breakdownAmount:pv,breakdownValue:gv,collapsibleContent:_v},yv=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("div",{className:R.section,children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:ma,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12})})]}),n.jsx("span",{className:R.sectionValue,children:X(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(Nv,{row:a,denomLogoMap:t},a.denom))})]})})},xv={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function bv(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function wv(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function Dr(e,t){return e===void 0?"-":`${v.formatNumber(e,{dp:6})} ${t}`}function ll({isOpen:e,symbol:t,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return n.jsxs("button",{className:R.tokenTrigger,children:[n.jsxs("div",{className:R.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(R.tokenChevron,{[R.expanded]:e})}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(ee,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(ee,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const jv=({position:e})=>{const t=bv(e.inRange),s=wv(e.inRange);return n.jsxs("div",{className:R.clammPositionRow,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Position ID"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:e.positionId})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Deposit"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:X(e.value)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Status"}),n.jsxs("div",{className:R.clammStatusValue,children:[n.jsx("span",{className:D(R.statusDot,t)}),n.jsx("span",{children:s})]})]}),e.isFullRange?n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Range Bounds"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:"Full range"})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Min"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:Dr(e.minPrice,e.pricePairLabel)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Max"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:Dr(e.maxPrice,e.pricePairLabel)})})]})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:X(e.rewardValue)})})]})]})},vv=({row:e,denomLogoMap:t})=>{const[s,o]=y.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:d}=e,u=t.get(a);if(!d)return null;const m=l||u?.assetLogo;return n.jsxs(Z.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:ll({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:m,rightContent:n.jsx("span",{className:R.triggerValue,children:X(i)})})}),n.jsx(Z.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.clammBreakdownContent,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:X(d.totalRewardValue)})})]}),d.positions.map(h=>n.jsx(jv,{position:h},h.tokenAddress))]})})]})},Cv=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,u]=y.useState(!1),m=t.get(s),h=i||m?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=y.useMemo(()=>Object.entries(r).filter(([,_])=>_>0),[r]),g=l&&Number(l.total)>0;return n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:u,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:ll({isOpen:d,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:X(a)})})}),n.jsx(Z.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[p.map(([_,x])=>{const w=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:xv[_]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[v.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:X(w)})]})]},_)}),g&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[v.formatNumber(Number(l.total),{dp:6})," ",it]}),n.jsx("span",{className:R.breakdownValue,children:X(l.totalValue)})]})]})]})})]})},Nv=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(vv,{row:e,denomLogoMap:t}):n.jsx(Cv,{row:e,denomLogoMap:t}),kv="_container_1nijk_1",Iv="_section_1nijk_6",Av="_sectionHeader_1nijk_14",Sv="_sectionTitle_1nijk_20",Tv="_sectionLabel_1nijk_26",Ev="_externalLink_1nijk_32",$v="_sectionValue_1nijk_44",Mv="_tokenList_1nijk_51",Lv="_tokenTrigger_1nijk_63",qv="_tokenChevron_1nijk_79",Pv="_expanded_1nijk_90",Rv="_tokenInfo_1nijk_94",Dv="_tokenInfoLabel_1nijk_100",Bv="_tokenLogo_1nijk_106",Fv="_tokenName_1nijk_110",Uv="_triggerValue_1nijk_116",Ov="_breakdownContent_1nijk_123",Vv="_breakdownRow_1nijk_131",Kv="_breakdownLabel_1nijk_139",Wv="_breakdownValues_1nijk_145",zv="_breakdownAmount_1nijk_151",Hv="_breakdownValue_1nijk_145",Qv="_collapsibleContent_1nijk_165",de={container:kv,section:Iv,sectionHeader:Av,sectionTitle:Sv,sectionLabel:Tv,externalLink:Ev,sectionValue:$v,tokenList:Mv,tokenTrigger:Lv,tokenChevron:qv,expanded:Pv,tokenInfo:Rv,tokenInfoLabel:Dv,tokenLogo:Bv,tokenName:Fv,triggerValue:Uv,breakdownContent:Ov,breakdownRow:Vv,breakdownLabel:Kv,breakdownValues:Wv,breakdownAmount:zv,breakdownValue:Hv,collapsibleContent:Qv},Gv=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:de.container,children:n.jsxs("div",{className:de.section,children:[n.jsxs("div",{className:de.sectionHeader,children:[n.jsxs("div",{className:de.sectionTitle,children:[n.jsx("span",{className:de.sectionLabel,children:"VIP"}),n.jsx("a",{href:cd,target:"_blank",rel:"noopener noreferrer",className:de.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12})})]}),n.jsx("span",{className:de.sectionValue,children:X(t)})]}),n.jsx("div",{className:de.tokenList,children:s.map(o=>n.jsx(Yv,{row:o},`${o.bridgeId}-${o.version}`))})]})})},Yv=({row:e})=>{const{name:t,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=y.useState(!1),d=a+i;return n.jsxs(Z.Collapsible.Root,{open:c,onOpenChange:l,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:de.tokenTrigger,children:[n.jsxs("div",{className:de.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(de.tokenChevron,{[de.expanded]:c})}),n.jsxs("div",{className:de.tokenInfoLabel,children:[s&&n.jsx(ee,{src:s,width:20,height:20,className:de.tokenLogo,logo:!0}),n.jsx("span",{className:de.tokenName,children:t})]})]}),n.jsx("span",{className:de.triggerValue,children:X(d)})]})}),n.jsx(Z.Collapsible.Content,{className:de.collapsibleContent,children:n.jsxs("div",{className:de.breakdownContent,children:[o>0&&n.jsxs("div",{className:de.breakdownRow,children:[n.jsx("span",{className:de.breakdownLabel,children:"Locked"}),n.jsxs("div",{className:de.breakdownValues,children:[n.jsxs("span",{className:de.breakdownAmount,children:[v.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:X(a)})]})]}),r>0&&n.jsxs("div",{className:de.breakdownRow,children:[n.jsx("span",{className:de.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:de.breakdownValues,children:[n.jsxs("span",{className:de.breakdownAmount,children:[v.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:X(i)})]})]})]})})]})},Zv="_container_ymkoc_1",Jv="_trigger_ymkoc_6",Xv="_expandIcon_ymkoc_22",eC="_chainInfo_ymkoc_27",tC="_logo_ymkoc_33",nC="_chainNameContainer_ymkoc_37",sC="_chainName_ymkoc_37",oC="_externalLink_ymkoc_49",aC="_externalIcon_ymkoc_53",rC="_valueColumn_ymkoc_63",iC="_value_ymkoc_63",cC="_expanded_ymkoc_80",lC="_collapsibleContent_ymkoc_85",dC="_content_ymkoc_97",Oe={container:Zv,trigger:Jv,expandIcon:Xv,chainInfo:eC,logo:tC,chainNameContainer:nC,chainName:sC,externalLink:oC,externalIcon:aC,valueColumn:rC,value:iC,expanded:cC,collapsibleContent:lC,content:dC},uC=Q.atom(!1),mC=()=>{const{totalValue:e}=Na(),{totalValue:t}=ao(),{totalValue:s}=ro(),o=e+t+s;return n.jsx("span",{className:Oe.value,children:X(o)})},hC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Na(),{data:i}=ec(),{data:c}=tc(),l=y.useMemo(()=>{const m=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}`,x=s.get(_)??o.get(g);x&&m.set(f,{assetLogo:x,chainLogo:t})}return m},[r,s,o,e,t]),d=y.useMemo(()=>(m,h)=>{const f=v.denomToMetadata(m);if(h==="staking"){const p=i?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:st}):"0"}if(h==="lockstaking"){const p=c?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:st}):"0"}return"0"},[i,c]),u=y.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:ma,positions:r}],[r]);return u.length===0?null:n.jsx(cl,{protocols:u,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},fC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=ao(),r=y.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,u=d.toUpperCase(),m=`${e}:${l}`,h=s.get(m)??o.get(u);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx(yv,{data:a,denomLogoMap:r})},pC=()=>{const e=ro();return e.rows.length===0?null:n.jsx(Gv,{data:e})},gC=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=Q.useAtom(uC),i=me(),c=ns(),{denomLogos:l,symbolLogos:d}=y.useMemo(()=>ka(c,i),[c,i]),u=oe(),{data:m}=Tt(u),h=y.useMemo(()=>m?.find(p=>p.id===Qe)?.price??0,[m]);return n.jsx("div",{className:Oe.container,children:n.jsxs(Z.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Oe.trigger,children:[n.jsxs("div",{className:Oe.chainInfo,children:[o&&n.jsx(ee,{src:o,width:32,height:32,className:Oe.logo,logo:!0}),n.jsxs("div",{className:Oe.chainNameContainer,children:[n.jsx("span",{className:Oe.chainName,children:s}),n.jsx("a",{href:ma,target:"_blank",rel:"noopener noreferrer",className:Oe.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,className:Oe.externalIcon})})]})]}),n.jsxs("div",{className:Oe.valueColumn,children:[n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:16,width:60,length:1}),children:n.jsx(mC,{})}),n.jsx(E.IconChevronDown,{size:16,className:D(Oe.expandIcon,{[Oe.expanded]:a})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Oe.collapsibleContent,children:n.jsxs("div",{className:Oe.content,children:[n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:36,length:2}),children:n.jsx(hC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:36,length:2}),children:n.jsx(fC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d})}),n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:36,length:1}),children:n.jsx(pC,{})})]})})]})})},_C="_totalValue_1v2ca_1",yC={totalValue:_C},xC=({filteredChainGroups:e})=>{const{totalValue:t}=Na(),{totalValue:s}=ao(),{totalValue:o}=ro(),a=t+s+o,r=y.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 n.jsx("span",{className:yC.totalValue,children:X(r)})},bC="_container_1eubu_1",wC="_header_1eubu_7",jC="_title_1eubu_13",vC="_list_1eubu_19",CC="_skeletonWrapper_1eubu_24",Wn={container:bC,header:wC,title:jC,list:vC,skeletonWrapper:CC},NC=y.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ls(),r=oe(),i=y.useMemo(()=>{const l=[];for(const u of o){if(!Array.isArray(u.positions))continue;const m=s.get(u.chainName.toLowerCase()),h=u.chainName.toLowerCase();if(t&&m?.chainId!==t||!u.positions.some(x=>x.positions.some(w=>w.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const p=u.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),g=r.chainId===m?.chainId,_=p.reduce((x,w)=>x+w.positions.reduce((C,b)=>C+An(b),0),0);l.push({chainId:m?.chainId??"",chainName:m?.prettyName??u.chainName,chainLogo:m?.logoUrl??"",protocols:p,isInitia:g,totalValue:_})}const d=["civitia","yominet"];return $.sortWith([$.descend(u=>u.isInitia??!1),$.ascend(u=>d.includes(u.chainName.toLowerCase())),$.descend(u=>u.totalValue??0),$.ascend(u=>u.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Wn.container,children:[n.jsxs("div",{className:Wn.header,children:[n.jsx("span",{className:Wn.title,children:"Positions"}),c&&n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:16,width:60,length:1}),children:n.jsx(xC,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Wn.list,children:i.map(l=>l.isInitia?n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Wn.skeletonWrapper,children:n.jsx(yt,{height:56,length:1})}),children:n.jsx(gC,{chainGroup:l})},l.chainName):n.jsx(Bj,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(yt,{height:56,length:3}):n.jsx(_e,{children:"No positions"})]})}),kC="_content_1w1ad_1",IC={content:kC},AC=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=se(),o=oe(),a=jm(),{totalValue:r}=ro(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=y.useMemo(()=>{const d=new Map;let u=0;for(const h of a)d.set(h.chainId,h.totalBalance),u+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),u+=r),{chainIds:$.sortWith([$.descend(h=>h===s),$.descend(h=>h===o.chainId),$.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:u}},[a,s,o,r]);return n.jsx(yo,{value:e,onChange:t,chainIds:i,renderExtra:d=>X(d?c.get(d)??0:l)})},SC=()=>{const[e,t]=Q.useAtom(tl),[s,o]=Q.useAtom(nl),a=me(),r=ns(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>ka(r,a),[r,a]),l=ia(),d=y.useMemo(()=>oc(a,l),[a,l]),u=wm();return n.jsxs(ct.Root,{children:[n.jsxs(ct.Controls,{children:[n.jsx(ct.SearchInput,{value:e,onChange:m=>t(m.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(pe,{suspenseFallback:n.jsx(an,{height:44,width:132}),children:n.jsx(AC,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("div",{className:IC.content,children:[n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:48,length:5}),children:n.jsx(Kw,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:u,chainPrices:d})}),n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:56,length:3}),children:n.jsx(NC,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},TC="_totalValue_5pf7e_1",EC="_totalLabel_5pf7e_7",$C="_totalAmount_5pf7e_13",MC="_loading_5pf7e_18",LC="_skeletonWrapper_5pf7e_23",qC="_nav_5pf7e_28",PC="_item_5pf7e_34",RC="_tabs_5pf7e_59",DC="_tab_5pf7e_59",Ve={totalValue:TC,totalLabel:EC,totalAmount:$C,loading:MC,skeletonWrapper:LC,nav:qC,item:PC,tabs:RC,tab:DC},BC=()=>{const{totalValue:e,isLoading:t}=ya();return n.jsx("div",{className:D(Ve.totalAmount,{[Ve.loading]:t}),children:X(e)})},FC=()=>{const e=vm(),t=Cm(),s=sc(),o=e+s+t;return n.jsx("div",{className:Ve.totalAmount,children:X(o)})},UC=()=>{Nc(),xm();const e=Ia(),t=Ie(),s=Zs(),o=y.useRef(null);return n.jsx(ol.Provider,{value:o,children:n.jsxs(dt,{ref:o,children:[n.jsxs("div",{className:Ve.totalValue,children:[n.jsx("div",{className:Ve.totalLabel,children:"Total value"}),n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Ve.skeletonWrapper,children:n.jsx(an,{height:48,width:120})}),children:e?n.jsx(BC,{}):n.jsx(FC,{})})]}),n.jsxs("div",{className:Ve.nav,children:[n.jsxs(Nn,{to:"/send",className:Ve.item,children:[n.jsx(E.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(Nn,{to:"/bridge",className:Ve.item,children:[n.jsx(E.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(Nn,{to:"/receive",className:Ve.item,children:[n.jsx(E.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Lt.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Lt.Tabs.List,{className:Ve.tabs,children:[n.jsx(Lt.Tabs.Tab,{className:Ve.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Lt.Tabs.Tab,{className:Ve.tab,value:"/nfts",children:"NFTs"}),n.jsx(Lt.Tabs.Tab,{className:Ve.tab,value:"/activity",children:"Activity"})]}),n.jsx(Lt.Tabs.Panel,{value:"/",children:e?n.jsx(Uw,{}):n.jsx(SC,{})}),n.jsx(Lt.Tabs.Panel,{value:"/nfts",children:n.jsx(Xb,{})}),n.jsx(Lt.Tabs.Panel,{value:"/activity",children:n.jsx(qb,{})})]})]})})},OC="_root_th990_1",VC="_collectionName_th990_9",KC="_nftName_th990_13",WC="_chainInfo_th990_17",zC="_attributes_th990_21",HC="_title_th990_24",QC="_count_th990_29",GC="_item_th990_33",YC="_type_th990_39",ZC="_value_th990_45",Xt={root:OC,collectionName:VC,nftName:KC,chainInfo:WC,attributes:zC,title:HC,count:QC,item:GC,type:YC,value:ZC},JC=()=>{const e=Ie(),t=Ze(),{attributes:s}=t;return n.jsxs(Nt,{title:"NFT details",children:[n.jsx(Fa,{normalizedNft:t,chainIconSize:14,classNames:Xt}),n.jsx(ke,{children:n.jsx(ue.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:Xt.attributes,children:[n.jsxs("header",{className:Xt.title,children:["Traits ",n.jsxs("span",{className:Xt.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:Xt.item,children:[n.jsx("div",{className:Xt.type,children:o}),n.jsx("div",{className:Xt.value,children:a})]},o))})]})]})};function XC({balances:e,gasPrices:t,gas:s}){return t.map(({denom:o,amount:a})=>{const r=F(a).times(s).toFixed(0,F.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>F(a).gte(o))}function eN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(d=>d.denom===e)?.amount??"0",i=XC({balances:t,gasPrices:s,gas:a}),c=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&c){const d=F(r).minus(c.amount);return F.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=F(r).minus(l.amount);return F.max(d,0).toString()}return F(r).toString()}const tN=({chain:e,onSelect:t})=>{const s=ql(e);return n.jsx(ps,{assets:s,onSelect:t})},nN=({afterSelect:e})=>{const{watch:t,setValue:s}=Ne.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=y.useState(r),l=lt(i),d=me(),u=m=>{if(o===i&&a===m){e();return}s("chainId",i),s("denom",m),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(on.Stack,{children:n.jsx(on,{chains:d,value:i,onSelect:c})}),n.jsx(pe,{suspenseFallback:n.jsx(ps.Placeholder,{}),children:n.jsx(tN,{chain:l,onSelect:u})},i)]})},sN="_fields_brpej_1",oN="_divider_brpej_11",Br={fields:sN,divider:oN},aN=Se.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),rN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=Je(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=Ne.useFormContext(),{errors:d}=l,{chainId:u,denom:m,recipient:h,quantity:f,memo:p}=r(),g=lt(u),_=ss(g),x=ga(g),w=_a(g),C=Xr(m,g),{data:b}=Tt(g),{decimals:j}=C,k=_.find(K=>K.denom===m)?.amount??"0",T=b?.find(({id:K})=>K===m)?.price,{data:L=0,isLoading:A}=S.useQuery({queryKey:aN.gas({chainId:u,denom:m,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const K=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Ga.MsgSend.fromPartial({fromAddress:t,toAddress:v.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return s({messages:K,chainId:u})},enabled:v.InitiaAddress.validate(h),staleTime:W.INFINITY}),M=Math.ceil(L*cn),N=eN({denom:m,balances:_,gasPrices:x,lastFeeDenom:w,gas:M}),I=F(k).isZero(),q=x.some(({denom:K})=>K===m)&&A,P=I||q,{mutate:B,isPending:H}=S.useMutation({mutationFn:({chainId:K,denom:le,quantity:ye,recipient:he,memo:xe})=>{const be=v.toBaseUnit(ye,{decimals:j}),De=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Ga.MsgSend.fromPartial({fromAddress:t,toAddress:v.InitiaAddress(he).bech32,amount:[{denom:le,amount:be}]})}];return o({messages:De,memo:xe,chainId:K,gas:L,gasAdjustment:cn,gasPrices:x,spendCoins:[{denom:le,amount:be}],internal:"/"})}}),z=y.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 n.jsx(Nt,{title:"Send",children:n.jsxs("form",{onSubmit:c(K=>B(K)),children:[n.jsxs("div",{className:Br.fields,children:[n.jsx(Qo,{selectButton:n.jsx(Sn,{title:"Select chain and asset",content:K=>n.jsx(nN,{afterSelect:K}),children:n.jsx(Ec,{asset:C,chain:g})}),quantityInput:n.jsx(es,{balance:k,decimals:j}),balanceButton:n.jsx(kc,{onClick:()=>i("quantity",v.fromBaseUnit(N,{decimals:j}),{shouldValidate:!0}),disabled:P,children:v.formatAmount(k??"0",{decimals:j})}),value:f?T?X(F(f).times(T)):"$-":"$0"}),n.jsx("div",{className:Br.divider}),n.jsx(Ma,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:K=>!K||new Blob([K]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(ge.Stack,{children:!p&&n.jsx(ge,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(ke,{children:n.jsx(ue.White,{type:"submit",loading:(A?"Estimating gas...":!1)||H,disabled:!!z,children:z??"Confirm"})})]})})},iN=()=>{const e=Ze(),t=un(),s=Ft(t),{chain:o=t}=e,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=Ne.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return n.jsx(Ne.FormProvider,{...i,children:n.jsx(rN,{})})};async function na(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await G.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function cN(e,t){const s=new xt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await G.create({prefixUrl:t}).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 lN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await G.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function dN({collection_addr:e},{restUrl:t}){const s=await cN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await na(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function uN(e,t){const{data:s}=await G.create({prefixUrl:t}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function mN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await uN(t,s);return o.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await na(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await na(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function hN(e,t){const s=re.toBase64(tn.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await G.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function fN(e,t){const{collection:s}=await G.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function pN(e,t){const s=re.toBase64(tn.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await G.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function Fr(e){const t=/^(.*channel-\d+)\/(.*)$/,s=e.match(t);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function gN({collection_addr:e},t,s){const o=v.InitiaAddress(e).bech32,a=await hN(o,t.restUrl),r=t.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=re.toBase64(tn.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await G.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),u=d??o,m=await pN(c,t.restUrl),h=await fN(o,t.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:m};if(d&&h!==i.replace("wasm.","")){const[g,_]=Fr(d);return{class_id:o,class_trace:{path:g,base_class_id:_},outgoing_proxy:m}}const[f,p]=Fr(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:m}}const _N={minimove:mN,minievm:dN,miniwasm:gN};async function yN({nft:e,srcChain:t,intermediaryChain:s}){const o=t.metadata?.is_l1?"minimove":t.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await _N[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await lN([e.token_id],a.class_id,t.restUrl)})}const xN="_root_1tyvn_1",bN="_collectionName_1tyvn_10",wN="_nftName_1tyvn_15",jN="_chainInfo_1tyvn_19",vN="_fields_1tyvn_24",CN="_chain_1tyvn_19",Oo={root:xN,collectionName:bN,nftName:wN,chainInfo:jN,fields:vN,chain:CN},NN=Se.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),kN=()=>{const e=me(),t=Ze(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=se(),r=rs(),i=oe(),{address:c,initiaAddress:l,requestTxSync:d}=Je(),{watch:u,setValue:m,handleSubmit:h,formState:f}=Ne.useFormContext(),{errors:p}=f,g=u(),{recipient:_,dstChainId:x}=g,w=lt(x),C=S.useQuery({queryKey:NN.simulation({collection_addr:o,nft:t,sender:l,recipient:_,srcChain:s,dstChain:w,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:w.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==w.chainId&&await yN({nft:t,srcChain:s,intermediaryChain:i})),{msgs:I}=await G.create({prefixUrl:a}).post("nft",{json:N}).json();return I.map(U=>r.fromAmino(U))},enabled:v.InitiaAddress.validate(_)}),{data:b,isLoading:j,error:k}=C,T=S.useQueryClient(),{mutate:L,isPending:A}=S.useMutation({mutationFn:async()=>{if(!b)throw new Error("Route not found");await d({messages:b,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{T.invalidateQueries({queryKey:Ua.nfts._def})}}),M=y.useMemo(()=>{if(!_)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(k)return"Route not found"},[_,p.recipient,k]);return n.jsxs("form",{onSubmit:h(()=>L()),children:[n.jsx(Fa,{normalizedNft:t,thumbnailSize:80,classNames:Oo}),n.jsxs("div",{className:Oo.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination appchain"}),n.jsxs(Sn,{title:"Destination appchain",content:N=>n.jsx(Tc,{onSelect:({chainId:I})=>{m("dstChainId",I),N()},list:e,getImage:I=>I.logoUrl,getName:I=>I.name,getKey:I=>I.chainId}),className:D("input",Oo.chain),children:[n.jsx(ee,{src:w.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:w.name})]})]}),n.jsx(Ma,{myAddress:c,ref:ms()})]}),n.jsx(ke,{children:n.jsx(ue.White,{loading:(j?"Finding route...":!1)||A,disabled:!!M,children:M??"Confirm"})})]})},IN=()=>{const{chain:e}=Ze(),t=Ne.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(Nt,{title:"Send NFT",children:n.jsx(Ne.FormProvider,{...t,children:n.jsx(kN,{})})})},sa=()=>{const e=Ie(),t=Zs(),s=Ot(),{closeDrawer:o}=Et(),{closeModal:a}=no();y.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=Tn();if(y.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(Sr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(Sr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(UC,{});case"/send":return n.jsx(iN,{},s);case"/receive":return n.jsx(d2,{});case"/nft":return n.jsx(JC,{});case"/nft/send":return n.jsx(IN,{},s);case"/bridge":return n.jsx(H_,{},s);case"/bridge/preview":return n.jsx(lx,{});case"/bridge/history":return n.jsx(Fy,{});case"/op/withdrawals":return n.jsx(Px,{});case"/tx":return n.jsx(yc,{});case"/autosign/enable":return n.jsx(Ep,{});case"/settings":return n.jsx(D2,{});case"/settings/autosign":return n.jsx(k2,{});case"/deposit":return n.jsx(Y0,{});case"/deposit/completed":return n.jsx(ta,{type:"deposit"});case"/withdraw":return n.jsx(Z0,{});case"/withdraw/completed":return n.jsx(ta,{type:"withdraw"})}},AN="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",SN=()=>n.jsxs(n.Fragment,{children:[n.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),n.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),n.jsx("link",{rel:"stylesheet",href:AN}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),TN=()=>(Nm(),sd(),Ad(),me(),bm(),sc(),ns(),null),EN=({children:e,...t})=>(y.useEffect(()=>{Ju()},[]),We.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(SN,{}),n.jsx(Gr.Provider,{value:{...Qr,...t},children:n.jsx(ri,{children:n.jsx(ep,{children:n.jsx(Z.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(Xf,{children:n.jsxs(Uf,{children:[e,n.jsx(km,{}),n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(TN,{})}),n.jsx(yh,{children:n.jsx(sa,{})}),n.jsx(fh,{children:n.jsx(sa,{})})]})})})})})})]}):null),$N=({bridge:e})=>n.jsx(ri,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(mc.Provider,{value:!!e,children:n.jsx(pe,{children:n.jsx(sa,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=cn;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Hr;exports.InterwovenKit=$N;exports.InterwovenKitProvider=EN;exports.MAINNET=Qr;exports.MoveError=Li;exports.PRIVY_APP_ID=ra;exports.TESTNET=Cl;exports.initiaPrivyWallet=kl;exports.initiaPrivyWalletConnector=Nl;exports.initiaPrivyWalletOptions=Gn;exports.injectStyles=Km;exports.useAddress=Ot;exports.useHexAddress=$n;exports.useInitiaAddress=te;exports.useInterwovenKit=Je;exports.usePortfolio=ya;exports.useUsernameQuery=zi;
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 Ol(e,t){const s=Ht.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=Ht.hexToBytes(Ht.keccak256(Ht.bytesToHex(o))),r=rt.Bip39.encode(a),i=await rt.Bip39.mnemonicToSeed(r),c=rt.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=rt.Slip10.derivePath(rt.Slip10Curve.Secp256k1,i,c),d=await rt.Secp256k1.makeKeypair(l),u=rt.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=Ht.bytesToHex(h),p=Ht.keccak256(f),g=Ht.hexToBytes(p).slice(-20),_=re.toBech32(t,g);return{privateKey:l,publicKey:u,address:_}}function xs(e,t){return`${e}:${t}`}const os=Q.atom(null),Yn=Q.atom({}),Zn=Q.atom({}),Js=Q.atom({}),Za=Q.atom(0),Vl="autosign:";function Kl(e,t){const s=e.get(Za)+1;return e.set(Za,s),`${t}:${s}`}function qs(e,t){return e.get(Js)[t]}function Wl(e,t,s){e.set(Js,o=>({...o,[t]:s}))}function li(e,t){e.set(Js,s=>{const o={...s};return delete o[t],o})}function zl(e,t,s){const o=qs(e,t);!o||o.token!==s||li(e,t)}function Hl(e,t,s){const o=qs(e,t);return!!o&&o.token===s}function bs(e,t){return e.get(Zn)[t]}function Ql(e,t,s){e.set(Zn,o=>({...o,[t]:s}))}function Gl(e,t){e.set(Zn,s=>{const o={...s};return delete o[t],o})}function Yl(e,t,s){e.set(Yn,o=>({...o,[t]:s}))}function Zl(e,t){e.set(Yn,s=>{const o={...s};return delete o[t],o})}function di(e,t){return`${Vl}${e}:${t}`}function Jl(e,t,s){try{return e.getItem(di(t,s))}catch{return null}}function Xl(e,t,s,o){try{e.setItem(di(t,s),o)}catch{}}function ui(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ua(e,t){const s=ui();if(s)return Jl(s,e,t)}function ed(e,t,s){const o=ui();o&&Xl(o,e,t,s)}function td(e){return{publicKey:e.publicKey,address:e.address}}function Ps(e){e&&e.fill(0)}function mi(e){e.set(Js,{});const t=e.get(Zn);for(const s of Object.values(t))Ps(s);e.set(Zn,{}),e.set(Yn,{})}function nd(e,t){return e!==""&&e!==t}function sd(){const e=te(),t=Q.useStore(),s=y.useRef(e);y.useEffect(()=>{const o=s.current;nd(o,e)&&mi(t),s.current=e},[t,e])}class od{constructor(t,s){this.wallet=t,this.privateKey=s}async getAccounts(){return[{address:this.wallet.address,algo:"ethsecp256k1",pubkey:this.wallet.publicKey}]}async signAmino(t,s){if(this.wallet.address!==t)throw new Error("Signer address does not match the derived wallet address");const o=Hn.escapeCharacters(Hn.sortedJsonStringify(s)),a=xt.ethers.hashMessage(o),r=re.fromHex(a.replace("0x","")),i=await rt.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=ci(this.wallet.publicKey,c);return{signed:s,signature:l}}}function Xs(){const e=Q.useStore(),{signMessageAsync:t}=Ke.useSignMessage(),s=Ye(),o=te();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const u=s(d),m=xs(o,u.bech32_prefix),h=e.get(Yn)[m];if(h&&bs(e,m))return h;const f=qs(e,m);if(f)return f.promise;const p=Kl(e,m),g=(async()=>{try{const _=window.location.origin,x=Ul(_),w=await t({message:x}),C=await Ol(w,u.bech32_prefix),b=td(C);if(Hl(e,m,p))return Ql(e,m,C.privateKey),Yl(e,m,b),b;throw Ps(C.privateKey),new Error("Wallet derivation was cancelled")}finally{zl(e,m,p)}})();return Wl(e,m,{promise:g,token:p}),g},getWallet:d=>{if(!o)return;const u=s(d),m=xs(o,u.bech32_prefix);if(bs(e,m))return e.get(Yn)[m]},getWalletPrivateKey:d=>{if(!o)return;const u=s(d),m=xs(o,u.bech32_prefix);return bs(e,m)},clearWallet:d=>{if(!o)return;const u=s(d),m=xs(o,u.bech32_prefix),h=bs(e,m);qs(e,m)&&li(e,m),Ps(h),Gl(e,m),Zl(e,m)},clearAllWallets:()=>{mi(e)}}}function hi({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:oa.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function ad({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=hi({granteeAddress:r.address,messages:s,encoder:c}),u={...o,granter:t},m=new Uint8Array(i),h=new od(r,m);try{return await l(e,r.address,d,u,a,{customSigner:h})}finally{Ps(m)}}const pt="interwovenkit",Qe="uinit",it="INIT",st=6,rd="uoinit",id="omniINIT",fi="https://app.initia.xyz",ma=`${fi}/liquidity/my`,cd=`${fi}/vip/my`,ld=1e3,pi=60*ld,gi=60*pi,Ja=24*gi,ie={PUBLIC_KEY:`${pt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${pt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${pt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${pt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${pt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${pt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${pt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${pt}:bridge:route-type`,BRIDGE_HISTORY:`${pt}:bridge:history`,OP_REMINDER:`${pt}:op:reminder`},_i=Q.atom(!1),yi=Q.atom(!1);function Et(){const e=la(),[t,s]=Q.useAtom(_i),o=Q.useSetAtom(yi),a=Tn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function En(){const e=la(),[t,s]=Q.useAtom(yi),o=Q.useSetAtom(_i),a=Tn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function xi(){const e=Ie(),{closeDrawer:t}=Et(),{closeModal:s}=En(),{disconnect:o}=Ke.useDisconnect(),{clearAllWallets:a}=Xs();return()=>{e("/blank"),t(),s(),o(),a(),localStorage.removeItem(ie.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_SRC_DENOM),localStorage.removeItem(ie.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_DST_DENOM),localStorage.removeItem(ie.BRIDGE_QUANTITY),localStorage.removeItem(ie.BRIDGE_SLIPPAGE_PERCENT)}}function dd(){const e=Ot(),t=un(),{openModal:s}=En();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,srcOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,d=a.map(u=>({denom:u,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function ud(){const e=Ot(),t=un(),{openModal:s}=En();return o=>{if(!e)throw new Error("No wallet connected");const{denoms:a,chainId:r,dstOptions:i,recipientAddress:c}=o;if(a.length===0)throw new Error("denoms cannot be empty");const l=r??t.chainId,d=a.map(u=>({denom:u,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function md(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Vo.PubKey.decode(e.value);return Qn.encodeSecp256k1Pubkey(t)}return Ws.decodeOptionalPubkey(e)}function hd({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=fl.BaseAccount.decode(t),i=md(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ae.accountFromAny({typeUrl:e,value:t})}const bi="/cosmos.feegrant.v1beta1.MsgGrantAllowance",wi="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",ji="cosmos-sdk/AllowedMsgAllowance";function fd(){const e=rn.aminoConverters[bi];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Rs=fd();function vi(e){if(e.typeUrl===wi){const t=en.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:ji,value:{allowance:vi(t.allowance),allowed_messages:t.allowedMessages}}}return Rs.toAmino({granter:"",grantee:"",allowance:e}).allowance}function Ci(e){if(e.type===ji){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=Ci(t.allowance);return{typeUrl:wi,value:en.AllowedMsgAllowance.encode(en.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Rs.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const pd={...rn.aminoConverters,[bi]:{...Rs,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:vi(e.allowance)}:Rs.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:Ci(e.allowance)})}},as=()=>{const e=se();return new Ws.Registry([...rn.protoRegistry,...e.protoTypes??[]])},rs=()=>{const e=se();return new Ae.AminoTypes({...pd,...e.aminoConverters})};class gd{constructor(t,s,o){this.address=t,this.signMessage=s,this.restUrl=o}cachedPublicKey=null;async getCachedPublicKey(){if(this.cachedPublicKey)return this.cachedPublicKey;const t=`${ie.PUBLIC_KEY}:${this.address}`,s=localStorage.getItem(t);if(s)return this.cachedPublicKey=re.fromHex(s),re.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,re.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,re.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await G.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?re.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=xt.ethers.hashMessage(t),a=xt.ethers.SigningKey.recoverPublicKey(o,s);return rt.Secp256k1.compressPubkey(re.fromHex(a.replace("0x","")))}async getAccounts(){return[{address:this.address,algo:"ethsecp256k1",pubkey:await this.getCachedPublicKey()}]}async signAmino(t,s){if(this.address!==t)throw new Error("Signer address does not match the provided address");const o=Hn.escapeCharacters(Hn.sortedJsonStringify(s)),a=await this.signMessage(o),r=re.fromHex(a.replace("0x","")).subarray(0,-1),c=rt.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=ci(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Ni(){const e=as(),t=rs(),s=is(),o=eo();return async function(a,r,i,c,l,d){const u=d?.customSigner??s;if(!u)throw new Error("Signer not initialized");const m=await o(a),{accountNumber:h,sequence:f}=await ki({getSequence:N=>m.getSequence(N),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[p]=await u.getAccounts(),g=ii(da(p.pubkey)),_=Vr.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),w=Hn.makeSignDoc(x,c,a,l,h,f),{signature:C,signed:b}=await u.signAmino(r,w),k={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:b.msgs.map(N=>t.fromAmino(N)),memo:l}},T=e.encode(k),L=Ka.Int53.fromString(b.fee.gas).toNumber(),A=Ka.Int53.fromString(b.sequence).toNumber(),M=Ws.makeAuthInfoBytes([{pubkey:g,sequence:A}],b.fee.amount,L,b.fee.granter,b.fee.payer,_);return He.TxRaw.fromPartial({bodyBytes:T,authInfoBytes:M,signatures:[re.fromBase64(C.signature)]})}}function _d(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function ki({getSequence:e,signerAddress:t,incrementSequence:s,allowMissingAccount:o}){try{const{accountNumber:a,sequence:r}=await e(t);return{accountNumber:a,sequence:r+s}}catch(a){if(o&&_d(a,t))return{accountNumber:0,sequence:s};throw a}}function is(){const e=te(),{signMessageAsync:t}=Ke.useSignMessage(),s=oe();return y.useMemo(()=>new gd(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const wo=new Map,Es=new Map;function yd(e,t){const s=`${e}:${t}`;Es.delete(s)}function ha(){const e=Ye();return async t=>{if(wo.has(t))return wo.get(t);const{rpcUrl:s}=e(t),o=await Wa.Comet38Client.create(new Wa.HttpClient(s));return wo.set(t,o),o}}function eo(){const e=as(),t=rs(),s=is(),o=te(),a=ha();return async r=>{const i=`${o}:${r}`;if(Es.has(i))return Es.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Ae.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:hd,broadcastPollIntervalMs:500});return Es.set(i,l),l}}function Ii(){const{connector:e}=Ke.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new xt.BrowserProvider(await e.getProvider())}}function Ai(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Si(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function xd(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Ti(){const e=te(),t=Ye();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=G.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 G.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=G.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=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Qs(l,{prefixUrl:i.restUrl},"grants");return Ai(d)}}}const Ds=Se.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),bd=4,Ei=4;function wd(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function fa(){const e=se(),t=un(),{enableAutoSign:s,defaultChainId:o}=e;if(!s)return{[o]:[]};if(typeof s!="boolean")return s;switch(t.metadata?.minitia?.type){case"minievm":return{[o]:["/minievm.evm.v1.MsgCall"]};case"miniwasm":return{[o]:["/cosmwasm.wasm.v1.MsgExecuteContract"]};default:return{[o]:["/initia.move.v1.MsgExecute"]}}}function jd(){const{data:e}=to(),t=fa();return(s,o)=>{const a=o.every(i=>{const c=t[s];return c?c.includes(i.typeUrl):!1}),r=e?.isEnabledByChain[s]??!1;return a&&r}}function to(){const e=te(),t=fa(),s=wd(t),{fetchFeegrant:o,fetchAllGrants:a}=Ti();return S.useQuery({queryKey:Ds.expirations(e,s,t).queryKey,queryFn:()=>vd({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:W.MINUTE,retry:1})}async function vd(e){const{initiaAddress:t,messageTypes:s,fetchAllGrants:o,fetchFeegrant:a}=e;if(!t)return{expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}};const r={},i={},c={},l={},d=[];for(const[m,h]of Object.entries(s))r[m]=null,i[m]=void 0,c[m]=!1,h.length>0&&d.push([m,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const u=await $i(d,bd,async([m,h])=>{const f=ua(t,m);try{const p=await o(m),g=f===void 0?p:f===null?[]:p.filter(k=>k.grantee===f),_=kd(g,h);if(_.length===0)return{chainId:m,expectedAddress:f,expiration:null,grantee:void 0};const x=await Nd({chainId:m,candidates:_,fetchFeegrant:a,concurrency:Ei});if(!x)return{chainId:m,expectedAddress:f,expiration:null,grantee:void 0};const w=x.grantee.grants.filter(k=>h.includes(k.authorization.msg)).map(k=>k.expiration),C=Si(x.feegrant.allowance),b=[...w,C],j=pa(b);return{chainId:m,expectedAddress:f,expiration:j?new Date(j):void 0,grantee:x.grantee.grantee}}catch{return{chainId:m,expectedAddress:f,expiration:null,grantee:void 0}}});for(const m of u)l[m.chainId]=m.expectedAddress,r[m.chainId]=m.expiration,i[m.chainId]=m.grantee;for(const[m]of d)c[m]=Id({expiration:r[m],grantee:i[m],expectedAddress:l[m]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function $i(e,t,s){const o=new Array(e.length),a=Math.max(1,t);let r=0;const i=Array.from({length:Math.min(a,e.length)},async()=>{for(;;){const c=r;if(r+=1,c>=e.length)return;o[c]=await s(e[c],c)}});return await Promise.all(i),o}function Cd(e){const t=xd(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Si(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Ge.isFuture(a)}async function Nd(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Ei}=e,r=await $i(s,a,async i=>{const c=await o(t,i.grantee);return c&&Cd(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function kd(e,t){if(t.length===0)return[];const s=new Map;for(const a of e){const r=s.get(a.grantee)||[];r.push({authorization:a.authorization,expiration:a.expiration}),s.set(a.grantee,r)}const o=[];for(const[a,r]of s){const i=r.filter(d=>!d.expiration||Ge.isFuture(new Date(d.expiration))),c=i.map(d=>d.authorization.msg);t.every(d=>c.includes(d))&&o.push({grantee:a,grants:i})}return o}function Id(e){const{expiration:t,grantee:s,expectedAddress:o}=e,a=o===void 0?!!s:!!s&&o===s;switch(t){case null:return!1;case void 0:return a;default:return a&&Ge.isFuture(t)}}function Ad(){const{data:e,refetch:t}=to();y.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Ge.isFuture(c));if(o.length===0)return;const a=pa(o);if(!a)return;const r=a.getTime()-s.getTime();if(r<=0)return;const i=setTimeout(()=>{t()},r+100);return()=>clearTimeout(i)},[e,t])}function pa(e){const t=e.filter(s=>s!==void 0);if(t.length!==0)return[...t].sort((s,o)=>new Date(s).getTime()-new Date(o).getTime())[0]}const Mi=y.createContext(null),no=()=>y.useContext(Mi);class Li extends Error{originalError;moduleAddress;moduleName;errorCode;errorCodeHex;isFromRegistry;constructor(t,s,o,a,r,i,c){super(t),this.name="MoveError",this.originalError=s,this.moduleAddress=o,this.moduleName=a,this.errorCode=r,this.errorCodeHex=i,this.isFromRegistry=c}}const Sd=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,jo=new Map;function Td(e){const t=e.match(Sd);if(!t)return null;const[,s,o,a]=t;return{moduleAddress:`0x${s.replace(/^0+/,"")||"0"}`,moduleName:o,errorCode:a.replace(/^0+/,"")||"0"}}async function Ed(e,t,s){const o=`${e}:${t}`;if(jo.has(o))return jo.get(o);try{const a=t==="0x1"?"0x1.json":`${e}/${t}.json`,r=`${s}/errors/${a}`,{errors:i={}}=await G.get(r).json();return jo.set(o,i),i}catch{return null}}function $d(e,t,s,o,a,r,i){return new Li(e,t,s,o,a,r,i)}async function bn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await wt(e);const o=Td(e.message);if(!o)return await wt(e);const a=await Ed(t.chain_name,o.moduleAddress,s),r=`0x${parseInt(o.errorCode,10).toString(16)}`,i=`Failed with code ${r} in module ${o.moduleName} at ${o.moduleAddress}`,c=a?.[o.moduleName]?.[o.errorCode],l=c||i,d=!!c;return $d(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Md=10;function qi(){const e=te();return(t,s)=>S.queryOptions({queryKey:Gs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Md},{txs:a}=await G.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:W.SECOND})}function Ld(e,t){const s=qi();return S.useSuspenseQuery(s(e,t))}function qd(e,t){const s=e.flatMap((o,a)=>(t[a]??[]).map(i=>({...i,chain:o})));return $.sortWith([$.descend(o=>new Date(o.timestamp).getTime())])(s)}const Pd=()=>{const e=me(),t=qi(),s=S.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map($.prop("data")),a=qd(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Pi(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await G.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.toSorted($.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:Hr;return{amount:U(a).times(r).toFixed(18),denom:o}})}return e.fees.fee_tokens.map(({denom:t,fixed_min_gas_price:s})=>{if($.isNil(s))throw new Error(`${t} has no price`);return{amount:String(s),denom:t}})}function ga(e){const{data:t}=S.useSuspenseQuery({queryKey:Hs.gasPrices(e).queryKey,queryFn:()=>Pi(e),staleTime:W.SECOND});return t}function _a(e){const t=te(),{data:s}=Ld(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(t,xt.computeAddress(`0x${re.toHex(rt.Secp256k1.uncompressPubkey(re.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const Ri="approve",so=Q.atom(),Di=Q.atom(null),Rd=cn,Dd=1.5;function Bd({gasPrices:e,preferredFeeDenom:t,fallbackFeeDenom:s,allowedFeeDenoms:o}){const a=o?.length?e.filter(({denom:i})=>o.includes(i)):e;if(a.length===0)throw new Error("No allowed gas price tokens available for auto-sign");const r=i=>i?a.find(c=>c.denom===i):void 0;return r(t)??r(s)??a[0]}function Fd({simulatedGas:e,gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,policy:a}){if(!Number.isFinite(e)||e<=0)throw new Error("Auto-sign gas simulation failed");const{gasMultiplier:r,maxGasMultiplierFromSim:i,allowedFeeDenoms:c}=a;if(r<=0||i<=0||r>i)throw new Error("Invalid auto-sign gas multiplier policy");const l=Math.ceil(e*r),d=Bd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Ae.calculateFee(l,Ae.GasPrice.fromString(`${d.amount}${d.denom}`))}function Ud({derivedAddress:e,messages:t,encoder:s}){return{messages:hi({granteeAddress:e,messages:t,encoder:s})}}function Od(e){if(!(e instanceof Error))return!1;const t=e.message.toLowerCase(),s=e.code,o=e.cause?.code,a=t.includes("user rejected")||t.includes("rejected the request")||t.includes("user denied")||t.includes("denied by user")||t.includes("user cancelled")||t.includes("user canceled")||t.includes("cancelled by user")||t.includes("canceled by user");return s===4001||s==="ACTION_REJECTED"||o===4001||o==="ACTION_REJECTED"||a}async function Vd({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Ae.createProtobufRpcClient(e),i=new za.ServiceClientImpl(r),c=He.Tx.fromPartial({authInfo:He.AuthInfo.fromPartial({fee:He.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:Vr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:He.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(za.SimulateRequest.fromPartial({txBytes:He.Tx.encode(c).finish()}))}function Kd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function Wd({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const u=async()=>d.signWithEthSecp256k1(t,e,s,a,o),m=(_,x)=>{d.onAutoSignFallback?.({chainId:t,reason:_,errorMessage:Kd(x)})};if(!c)return u();if(!d.validateAutoSign(t,s))return m("validation_failed"),u();let f=d.getWallet(t),p=!1;if(!f&&l)try{f=await d.deriveWallet(t)}catch(_){if(Od(_))throw _;m("derive_wallet_failed",_),p=!0,f=void 0}if(!f)return p||m("missing_derived_wallet"),u();let g;try{const _=i??await d.getSigningClient(t);g=await d.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return m("fee_computation_failed",_),u()}try{return await d.signWithDerivedWallet(t,e,s,g,o,f)}catch(_){return m("derived_wallet_sign_failed",_),u()}}function Bi(){const e=te(),{autoSignFeePolicy:t}=se(),s=Ye(),o=ha(),a=eo(),r=as(),i=jd(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=Xs(),u=Ni(),m=Tn(),h=g=>{const _=t?.[g];return{gasMultiplier:_?.gasMultiplier??Rd,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??Dd,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:g,messages:_,memo:x,derivedWallet:w,preferredFeeDenom:C,fallbackFeeDenom:b,client:j})=>{const k=s(g),T=await Pi(k),A=Ud({derivedAddress:w.address,messages:_,encoder:r}).messages.map(H=>r.encodeAsAny(H)),M=ii(da(w.publicKey)),{sequence:N}=await ki({getSequence:H=>j.getSequence(H),signerAddress:w.address,incrementSequence:0,allowMissingAccount:!0}),I=await o(g),F=Ae.QueryClient.withExtensions(I,Ae.setupTxExtension),{gasInfo:q}=await Vd({queryClient:F,messages:A,memo:x,pubkey:M,sequence:N}),P=q?Number(q.gasUsed.toString()):0,B=h(g);return Fd({simulatedGas:P,gasPrices:T,preferredFeeDenom:C,fallbackFeeDenom:b,policy:B})},p=async(g,_,x,w,C,b)=>{let j=b??c(g);j||(j=await l(g));const k=d(g);if(!k)throw new Error("Derived wallet key not initialized");return await ad({chainId:g,granterAddress:_,messages:x,fee:w,memo:C,derivedWallet:j,privateKey:k,encoder:r,signWithEthSecp256k1:u})};return g=>Wd({...g,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:p,signWithEthSecp256k1:u,onAutoSignFallback:({chainId:_,reason:x,errorMessage:w})=>{m("AutoSign Fallback",{chainId:_,reason:x,errorMessage:w})}})}function Fi(){const e=Q.useAtomValue(so);if(!e)throw new Error("Tx request not found");return e}function oo(){const e=Ie(),t=te(),{defaultChainId:s,registryUrl:o}=se(),a=Ye(),{openDrawer:r,closeDrawer:i}=Et(),{openModal:c,closeModal:l}=no(),d=Q.useSetAtom(so),u=Q.useSetAtom(Di),m=ha(),h=eo(),f=is(),p=as(),g=Bi(),_=async({messages:A,memo:M,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,M)}catch(I){throw await bn(I,a(N),o)}},x=async({messages:A,memo:M,chainId:N=s})=>{const I=await m(N),F=Ae.QueryClient.withExtensions(I,Ae.setupTxExtension),q=A.map(K=>p.encodeAsAny(K)),[P]=await f.getAccounts(),B=Qn.encodeSecp256k1Pubkey(P.pubkey),H=await h(N),{sequence:z}=await H.getSequence(t);return F.tx.simulate(q,M,B,z)},w=async({txRequest:A,broadcaster:M})=>{const I={...{memo:"",chainId:s,gas:A.gas||await _(A),gasAdjustment:cn,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((F,q)=>{d({txRequest:I,resolve:async B=>{try{const H=await h(I.chainId),z=await M(H,He.TxRaw.encode(B).finish());F(z),typeof I.internal=="string"&&e(I.internal)}catch(H){q(await bn(H,a(I.chainId),o))}finally{P()}},reject:B=>{q(B),P()}}),I.internal?c({path:"/tx"}):r("/tx");const P=()=>{if(!I.internal){e("/blank"),i();return}l()}})},C=async A=>{const M=A.chainId??s;try{const N=await w({txRequest:A,broadcaster:async(I,F)=>await I.broadcastTxSync(F)});return A.internal&&typeof A.internal!="number"&&(u({txHash:N,chainId:M,status:"loading"}),L({txHash:N,chainId:A.chainId}).then(I=>{u({status:I.code===0?"success":"error",chainId:M,txHash:N})}).catch(()=>{u({status:"error",chainId:M,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&u({status:"error",chainId:M,error:N}),N}},b=(A,M=30*1e3,N=.5*1e3)=>w({txRequest:A,broadcaster:async(I,F)=>{const q=await I.broadcastTx(F,M,N);if(q.code!==0)throw new Error(q.rawLog);return q}}),j=async({chainId:A,messages:M,memo:N="",fee:I,preferredFeeDenom:F})=>{const q=await h(A),P=await g({chainId:A,messages:M,memo:N,fee:I,preferredFeeDenom:F,client:q,allowWalletDerivation:!0});return{client:q,signedTx:P}},k=async A=>{const M=A.chainId??s;try{const{client:N,signedTx:I}=await j({...A,chainId:M});return await N.broadcastTxSync(He.TxRaw.encode(I).finish())}catch(N){throw await bn(N,a(M),o)}},T=async(A,M=30*1e3,N=.5*1e3)=>{const I=A.chainId??s;try{const{client:F,signedTx:q}=await j({...A,chainId:I}),P=await F.broadcastTx(He.TxRaw.encode(q).finish(),M,N);if(P.code!==0)throw new Error(P.rawLog);return P}catch(F){throw await bn(F,a(I),o)}},L=async({chainId:A=s,...M})=>{try{const N=await h(A);return await Ui({...M,client:N})}catch(N){throw await bn(N,a(A),o)}};return{estimateGas:_,simulateTx:x,requestTxSync:C,requestTxBlock:b,submitTxSync:k,submitTxBlock:T,waitForTxConfirmation:L}}async function Ui({txHash:e,client:t,timeoutMs:s=30*1e3,intervalMs:o=.5*1e3}){const a=Date.now();for(;;){const r=await t.getTx(e);if(r){if(r.code!==0)throw new Error(r.rawLog);return r}if(Date.now()-a>=s)throw new Error(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const zd="/cosmos.authz.v1beta1.MsgExec";function Hd(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function Qd(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function Gd(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function Yd(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function Oi(e){const t=[Ds.expirations._def,Ds.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function Vi(){const e=te(),{fetchFeegrant:t,fetchGrants:s}=Ti();return async o=>{const{chainId:a,grantee:r}=o;if(!e)throw new Error("Granter wallet not initialized");const i=await t(a,r),c=await s(a,r),l=i?[{typeUrl:"/cosmos.feegrant.v1beta1.MsgRevokeAllowance",value:Kr.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],u=Yd(c).map(m=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:oa.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:m})}));return[...l,...u]}}function Zd(){const e=te(),t=fa(),{requestTxBlock:s}=oo(),o=S.useQueryClient(),[a,r]=Q.useAtom(os),{closeDrawer:i}=Et(),c=Vi(),{deriveWallet:l}=Xs();return S.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:u}=a;if(!e)throw new Error("Wallet not connected");const m=t[u];if(!m||m.length===0)throw new Error(`No message types configured for chain ${u}`);const h=await l(u);yd(e,u);const f=ua(e,u),p=Qd({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(p.map(k=>c({chainId:u,grantee:k})))).flat(),x=d===0?void 0:Ge.addMilliseconds(new Date,d),w={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:en.BasicAllowance.encode(en.BasicAllowance.fromPartial({expiration:x})).finish()},C={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Kr.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:en.AllowedMsgAllowance.encode(en.AllowedMsgAllowance.fromPartial({allowance:w,allowedMessages:[zd]})).finish()}})},b=m.map(k=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:oa.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:Ha.GenericAuthorization.encode(Ha.GenericAuthorization.fromPartial({msg:k})).finish()},expiration:x}})})),j=[..._,C,...b];return await s({messages:j,chainId:u,internal:!0}),{chainId:u,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:u})=>{e&&ed(e,d,u.address),await Oi(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function Ki(e){const t=se(),s=me(),o=Ye(),{getWallet:a,clearWallet:r}=Xs(),{requestTxBlock:i}=oo(),c=S.useQueryClient(),l=Vi(),{data:d,refetch:u}=to();return S.useMutation({mutationFn:async(m=t.defaultChainId)=>{const h=a(m),f=d?.granteeByChain[m];let p;e?.grantee||(p=(await u()).data?.granteeByChain[m]);const g=Hd({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:p});if(g.length===0)throw new Error("No grantee address available");const x=(await Promise.all(g.map(w=>l({chainId:m,grantee:w})))).flat();return x.length===0?{chainId:m,didBroadcast:!1}:(await i({messages:x,chainId:m,internal:e?.internal}),{chainId:m,didBroadcast:!0})},onSuccess:async({chainId:m,didBroadcast:h})=>{await Oi(c);const f=o(m),p=s.filter(b=>b.bech32_prefix===f.bech32_prefix).map(b=>b.chain_id).filter(b=>b!==m);let g;try{g=(await u()).data}catch{g=void 0}const _=g??d;let x=!1;p.length>0&&_&&(x=p.some(b=>_?.isEnabledByChain[b]));const w=h?g?.isEnabledByChain[m]:(g??d)?.isEnabledByChain[m];Gd({isEnabledOnTargetChain:w,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(m)}})}function Jd(){const{defaultChainId:e}=se(),{openDrawer:t}=Et(),s=Q.useSetAtom(os),o=Ki(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=to();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,u)=>{s({chainId:l,resolve:d,reject:u}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function Wi(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function Xd(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),U(0)).toString()}function eu(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??ca}}function Xa(e){return $.pick(["chainId","name","logoUrl"],e)}function tu(e){return $.sortWith([$.descend(({symbol:t})=>t===it),$.descend(Wi),$.descend(({assets:t})=>t.length),$.ascend(({symbol:t})=>t)])(e)}function nu(e){return $.sortWith([$.descend(({value:t})=>t??0),$.descend(({quantity:t})=>Number(t)),$.ascend(({chain:t})=>t.name)])(e)}function su(e,t){return $.sortWith([$.descend(({chain:s})=>s.chainId===t),$.ascend(({chain:s})=>s.name),$.ascend(({denom:s})=>s)])(e)}function ou(e,t){return $.sortWith([$.descend(({chainId:s})=>s===t),$.descend($.prop("value"))])(e)}function au(e,t,s,o,a){const r=e.find(m=>m.metadata?.is_l1)?.chainId,i={};for(const m of e){const h=m.chainId,f=t[h]??[],p=s[h],g=o[h],_=[];for(const{amount:x,denom:w}of f){if(!U(x).gt(0))continue;const C=p?.find(L=>L.denom===w),b=g?.find(L=>L.id===w)?.price,j=C?.decimals??0,k=v.fromBaseUnit(x,{decimals:j}),T=b?U(k).times(b).toNumber():void 0;_.push({...eu(w,C),amount:x,denom:w,decimals:j,quantity:k,price:b,value:T,address:C?.address,unlisted:!C,chain:Xa(m)})}i[h]=_}const c=new Map;for(const[m,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(g=>g.chainId===m);if(!f)continue;const p=h.reduce((g,{value:_})=>g+(_??0),0);c.set(m,{...Xa(f),value:p})}const l=new Map;for(const m of Object.values(i))for(const h of m)if(!h.unlisted){const{symbol:f}=h,p=l.get(f)??[];l.set(f,[...p,h])}const d=[];for(const[m,h]of l){const f=$.head(h);if(!f)continue;const p=nu(h),g=p.reduce((x,{value:w})=>x+(w??0),0),_=p.reduce((x,{quantity:w})=>x.plus(w),U(0)).toNumber();d.push({symbol:m,logoUrl:f.logoUrl,assets:p,totalValue:g,totalAmount:_})}const u=[];for(const m of Object.values(i))for(const h of m)h.unlisted&&u.push(h);return{chainsByValue:ou(Array.from(c.values()),a),assetGroups:tu(d),unlistedAssets:su(u,r),totalValue:d.reduce((m,h)=>m+h.totalValue,0)}}function ya(){const{defaultChainId:e}=se(),t=me(),s=Ll(),o=ns(),a=ia(),r=t.map(h=>h.chainId),i=$.zipObj(r,s.map($.prop("data"))),c=$.zipObj(r,o.map($.prop("data"))),l=$.zipObj(r,a.map($.prop("data"))),d=au(t,i,c,l,e),u=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:u,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function te(){const e=$n();return e?v.InitiaAddress(e).bech32:""}function $n(){const{address:e}=Ke.useAccount();return e?v.InitiaAddress(e).hex:""}function Ot(){const e=un(),t=te(),s=$n();return e.metadata?.minitia?.type==="minievm"?s:t}function zi(){const e=Ot(),t=ti();return S.useQuery({queryKey:Gs.username(t.restUrl,e).queryKey,queryFn:()=>t.getUsername(e),enabled:!!e,staleTime:W.MINUTE})}function Je(){const e=Ot(),t=te(),s=$n(),{data:o}=zi(),a=is(),r=xi(),i=Jd(),{isDrawerOpen:c,openDrawer:l}=Et(),{isModalOpen:d}=En(),u=()=>{l("/")},m=()=>{l("/connect")},h=w=>{l("/bridge",w)},f=dd(),p=ud(),g=oo();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:m,openWallet:u,openBridge:h,openDeposit:f,openWithdraw:p,disconnect:r,autoSign:i,...g}}const ru="_status_tn9m1_1",iu="_error_tn9m1_9",er={status:ru,error:iu},_e=({error:e,children:t})=>n.jsx("p",{className:D(er.status,{[er.error]:e}),children:t}),pe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(_e,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(_e,{children:"Loading..."}),children:s})=>n.jsx(Wr.ErrorBoundary,{...e,children:n.jsx(y.Suspense,{fallback:t,children:s})}),ln=1n<<64n,cu=1n<<63n,Hi=(1n<<128n)-1n;function Ut(e){const t=BigInt(e);return t>=cu?t-ln:t}const lu=(1n<<256n)-1n,Dt=443636n,du=4295048017n,uu=18446744073709551616n,mu=79226673515401279992447579062n,hu=255738958999603826347141n;function fu(e,t,s){const o=Number(Ut(e)),a=Number(Ut(t)),r=Math.floor(-Number(Dt)/s)*s,i=Math.floor(Number(Dt)/s)*s;return o===r&&a===i}function Qi(e){return e>>64n}function pu(e){const t=e>>64n;return e%ln!==0n?t+1n:t}function In(e){if(e<0n||e>Hi)throw new Error("INPUT_OUT_OF_RANGE");return e}function gu(e,t){const s=e*t>>64n;if(s>Hi)throw new Error("OVERFLOW");return s}function xa(e,t){return e>t?[t,e]:[e,t]}function _u(e,t,s,o){if(e===t)return 0n;const[a,r]=xa(e,t);if(a===0n||r===0n)return 0n;const i=s*ln,c=r-a,l=i*c;if(l===0n)return 0n;const d=a*r;return o?(l-1n)/d+1n:l/d}function yu(e,t,s,o){if(e===t)return 0n;const[a,r]=xa(e,t),c=(r-a)*s;return o?pu(In(c)):Qi(In(c))}function tr(e,t,s){return _u(e,t,s<0n?-s:s,s>=0n)}function nr(e,t,s){return yu(e,t,s<0n?-s:s,s>=0n)}const vo=1n<<64n,sr=1n<<65n,xu=64n;function bu(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<xu-1n,r=0n,i=1;for(;t>=sr;)t>>=1n,s+=vo;for(;t<vo;)i=0,t<<=1n,o+=vo;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=sr&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?In(s):In(o-s);return[i,c]}function Bt(e){const t=e<0n?-e:e;if(t>Dt)throw new Error("MAX_TICK");let s=(t&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;(t&0x2n)!==0n&&(s=s*0xfff97272373d413259a46990580e213an>>128n),(t&0x4n)!==0n&&(s=s*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(t&0x8n)!==0n&&(s=s*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(t&0x10n)!==0n&&(s=s*0xffcb9843d60f6159c9db58835c926644n>>128n),(t&0x20n)!==0n&&(s=s*0xff973b41fa98c081472e6896dfb254c0n>>128n),(t&0x40n)!==0n&&(s=s*0xff2ea16466c96a3843ec78b326b52861n>>128n),(t&0x80n)!==0n&&(s=s*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(t&0x100n)!==0n&&(s=s*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(t&0x200n)!==0n&&(s=s*0xf987a7253ac413176f2b074cf7815e54n>>128n),(t&0x400n)!==0n&&(s=s*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(t&0x800n)!==0n&&(s=s*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(t&0x1000n)!==0n&&(s=s*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(t&0x2000n)!==0n&&(s=s*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(t&0x4000n)!==0n&&(s=s*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(t&0x8000n)!==0n&&(s=s*0x31be135f97d08fd981231505542fcfa6n>>128n),(t&0x10000n)!==0n&&(s=s*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(t&0x20000n)!==0n&&(s=s*0x5d6af8dedb81196699c329225ee604n>>128n),(t&0x40000n)!==0n&&(s=s*0x2216e584f5fa1ea926041bedfe98n>>128n),e>=0n&&(s=lu/s);const o=s/ln;return s%ln!==0n?o+1n:o}function wu(e){if(e<du||e>=mu)throw new Error("INVALID_SQRT_PRICE");const[,t]=bu(In(e)),s=gu(t,In(hu)),o=Qi(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<uu?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Dt&&(a=-Dt),i>Dt&&(i=Dt),Bt(i)<=e){if(i>=Dt)throw new Error("GTE_MAX_TICK");if(Bt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(Bt(r)<=e)return r;if(Bt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function ju(e,t,s,o){const[a,r]=xa(t,s);return e<a?[tr(a,r,o),0n]:e<r?[tr(e,r,o),nr(a,e,o)]:[0n,nr(a,r,o)]}function vu({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=Bt(Ut(e)),r=Bt(Ut(t));return ju(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const Co=ln*ln,Cu=1e-300,Nu=BigInt(Number.MAX_SAFE_INTEGER);function or(e){const t=e*e,s=t/Co,o=t%Co;return s>Nu?Number(s):Number(s)+Number(o)/Number(Co)}function ar(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,Cu)}function ku({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=Bt(Ut(e)),a=Bt(Ut(t)),r=or(o),i=or(a);return s?{min:ar(i),max:ar(r)}:{min:r,max:i}}const mn=Se.createQueryKeys("interwovenkit:initia-liquidity",{checkLpTokens:(e,t)=>[e,t],lpPrices:(e,t)=>[e,t],poolByMetadata:(e,t)=>[e,t],clammPositions:(e,t)=>[e,t],clammPoolInfo:(e,t,s)=>[e,t,s],clammFees:(e,t,s)=>[e,t,s],clammIncentive:(e,t,s,o)=>[e,t,s,o]}),ba={lens:"lens",pool:"pool",farming:"farming"},wa={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function Iu(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:v.InitiaAddress(e).hex}function Bs(e){return re.toBase64(v.InitiaAddress(Iu(e),32).bytes)}function Gi(e,t){return`${e}:${t}`}function Au(e){return`clamm:${e}`}function Su(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function Tu(e){return e.map(t=>({tokenAddress:t.token_address,lpMetadata:t.lp_metadata,tickLower:t.tick_lower,tickUpper:t.tick_upper,liquidity:t.liquidity,incentives:t.incentives.map(s=>({incentiveAddress:s.incentive_address,rewardMetadata:s.reward_metadata}))}))}function Eu(e){const{dexUrl:t}=se();return S.useSuspenseQuery({queryKey:mn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await G.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...Su(r.positions)),o=r.pagination.next_key||void 0}while(o);return Tu(s)},staleTime:W.MINUTE})}function $u(e){const t=oe(),{viewFunction:s}=v.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:mn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=wa[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:ba.lens,functionName:"get_pool_info",typeArgs:[],args:[Bs(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:W.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(i,a[c]??null)}),r},[e,a])}function Mu(e){const t=oe(),{viewFunction:s}=v.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:mn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=wa[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:ba.pool,functionName:"fees_available",typeArgs:[],args:[Bs(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:W.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{const l=a[c];l&&r.set(i,l)}),r},[e,a])}function Lu(e){const t=oe(),{viewFunction:s}=v.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:mn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=wa[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:ba.farming,functionName:"pending_reward_info",typeArgs:[],args:[Bs(r.tokenAddress),Bs(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:W.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(Gi(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function Yi(e){const{dexUrl:t}=se(),o=S.useSuspenseQueries({queries:e.map(a=>({queryKey:mn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await G.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:W.MINUTE}))}).map(a=>a.data);return y.useMemo(()=>{const a=new Map;return e.forEach((r,i)=>{a.set(r,o[i]??null)}),a},[e,o])}function Zi(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function qu(e){return Yi(e)}function Pu(e){const t=oe(),s=Ft(t),o=y.useMemo(()=>{const i=new Map;for(const c of s)i.set(c.denom,c);return i},[s]),a=y.useMemo(()=>e.map(i=>v.denomToMetadata(i)),[e]),r=Yi(a);return y.useMemo(()=>{const i=new Map;return e.forEach((c,l)=>{const d=a[l];if(!d){i.set(c,null);return}const u=r.get(d);if(!u){i.set(c,null);return}if(c===rd){i.set(c,{...u,symbol:id});return}const m=u.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...u,symbol:m})}),i},[e,a,r,o])}const Ru="lock_staking";function Ji(e,t){const s=`${t}::lock_staking::StakingAccount`,o=v.createObjectAddress(e,s);return v.InitiaAddress(o).bech32}const cs=Se.createQueryKeys("interwovenkit:initia-staking",{delegations:(e,t)=>[e,t],undelegations:(e,t,s)=>[e,t,s],lockStaking:(e,t,s)=>[e,t,s],stakingRewards:(e,t)=>[e,t],lockStakingRewards:(e,t,s)=>[e,t,s]});function ja(){const{restUrl:e}=oe(),t=te();return S.useSuspenseQuery({queryKey:cs.delegations(e,t||"").queryKey,queryFn:async()=>t?(await G.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=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:W.MINUTE})}function va(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=se(),s=te(),o=s?Ji(s,t):"";return S.useSuspenseQuery({queryKey:cs.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await G.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await G.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const u=v.denomToMetadata(d.denom),m={denom:d.denom,metadata:u,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(u)??[];h.push(m),r.set(u,h)}}return r},staleTime:W.MINUTE})}function Ca(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=se(),s=te();return S.useSuspenseQuery({queryKey:cs.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=v.createMoveClient(e);return await o({moduleAddress:t,moduleName:Ru,functionName:"get_locked_delegations",typeArgs:[],args:[re.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:W.MINUTE})}function Xi(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=v.denomToMetadata(s.denom);let a=new U(0);for(const i of s.dec_coins)i?.amount&&(a=a.plus(i.amount));const r=t.get(o);if(r){const i=new U(r.amount);a=a.plus(i)}t.set(o,{denom:s.denom,amount:a.toString()})}return t}function ec(){const{restUrl:e}=oe(),t=te();return S.useSuspenseQuery({queryKey:cs.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await G.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:Xi,staleTime:W.MINUTE})}function tc(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=se(),s=te(),o=s?Ji(s,t):"";return S.useSuspenseQuery({queryKey:cs.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await G.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:Xi,staleTime:W.MINUTE})}function Na(){const e=oe(),t=Ft(e),{data:s,isLoading:o}=Tt(e),{data:a}=ja(),{data:r}=va(),{data:i}=Ca(),c=y.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=Ls(c),d=y.useMemo(()=>{const f=new Map;if(s)for(const p of s)f.set(p.id,p.price);return f},[s]),u=y.useMemo(()=>{const f=new Map;for(const p of t)f.set(p.denom,p);return f},[t]),m=y.useMemo(()=>{const f=[],p=g=>{const _=u.get(g);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[g,_]of a){const x=l.get(g)??_[0]?.denom;if(!x)continue;const w=p(x);if(!w)continue;const C=d.get(x)??0;for(const b of _){const{symbol:j,decimals:k}=w,T=Number(v.fromBaseUnit(b.amount,{decimals:k})),L={type:"asset",denom:x,symbol:j,amount:b.amount,formattedAmount:T,decimals:k,value:T*C};f.push({type:"staking",validator:b.validator,balance:L})}}for(const[g,_]of i){const x=l.get(g);if(!x)continue;const w=p(x);if(!w)continue;const C=d.get(x)??0;for(const b of _){const{symbol:j,decimals:k}=w,T=Number(v.fromBaseUnit(b.amount,{decimals:k})),L={type:"asset",denom:x,symbol:j,amount:b.amount,formattedAmount:T,decimals:k,value:T*C},A=Number(b.releaseTime);f.push({type:"lockstaking",validator:b.validator,releaseTime:Number.isNaN(A)?0:A,balance:L})}}for(const[g,_]of r){const x=l.get(g)??_[0]?.denom;if(!x)continue;const w=p(x);if(!w)continue;const C=d.get(x)??0;for(const b of _){const{symbol:j,decimals:k}=w,T=Number(v.fromBaseUnit(b.amount,{decimals:k})),L={type:"asset",denom:x,symbol:j,amount:b.amount,formattedAmount:T,decimals:k,value:T*C},A=new Date(b.completionTime).getTime(),M=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:b.validator,completionTime:M,balance:L})}}return f.filter(g=>g.type!=="fungible-position"&&g.balance.denom===Qe)},[a,i,r,l,u,d]),h=y.useMemo(()=>m.reduce((f,p)=>p.type==="fungible-position"||p.balance.type==="unknown"?f:f+(p.balance.value??0),0),[m]);return{positions:m,totalValue:h,isLoading:o}}function Du(e){const t=new Map;for(const s of e){const o=v.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function Bu(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function Fu(e){const{dexUrl:t}=se();return S.useSuspenseQuery({queryKey:mn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await G.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:W.MINUTE})}function Uu(){const e=oe(),t=ss(e),s=y.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=Fu(s);return y.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return Du(a)},[t,o])}function Ou(e){const{dexUrl:t}=se();return S.useSuspenseQuery({queryKey:mn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await G.get(`${t}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:W.MINUTE})}function Vu(e,t,s,o){const a=new Set;for(const r of e.keys())a.add(r);for(const[r,i]of t){const c=i[0]?.denom;c&&c!==Qe&&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!==Qe&&a.add(r)}return Array.from(a)}function Ku(e){const t=[];for(const[,s]of e)s&&s!==Qe&&t.push(s);return t}function Wu(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=Zi(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 No(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Qe)continue;const l=o.get(c);if(l)for(const d of i){const u=l.decimals,m=Number(v.fromBaseUnit(String(d.amount),{decimals:u})),h=s.get(c)??0,f=m*h;l.breakdown[a]+=m,l.totalAmount+=m,l.totalValue+=f}}}function zu(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Qe)continue;const l=o.get(c);if(l)for(const d of i){const u=l.decimals,m=Number(v.fromBaseUnit(String(d.amount),{decimals:u})),h=s.get(c)??0,f=m*h;l.breakdown[a]+=m,l.totalAmount+=m,l.totalValue+=f}}}function Hu(e,t,s,o){for(const[a,r]of e){const i=v.denomToMetadata(a),c=t?.get(i),l=c?v.fromBaseUnit(c.amount,{decimals:st}):"0",d=s?.get(i),u=d?v.fromBaseUnit(d.amount,{decimals:st}):"0",m=Number(l)+Number(u);m<=0||(r.claimableInit={staking:l,lockStaking:u,total:String(m),totalValue:m*o})}}function Qu(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function ao(){const e=oe(),t=Ft(e),s=te(),o=Uu(),{data:a}=ja(),{data:r}=Ca(),{data:i}=va(),{data:c}=ec(),{data:l}=tc(),{data:d}=Tt(e),{data:u}=Eu(s),m=y.useMemo(()=>{const q=new Map;for(const P of u){const B=q.get(P.lpMetadata)??[];B.push(P),q.set(P.lpMetadata,B)}return q},[u]),h=y.useMemo(()=>Array.from(m.keys()),[m]),f=qu(h),p=$u(h),g=y.useMemo(()=>u.map(q=>q.tokenAddress),[u]),_=Mu(g),x=y.useMemo(()=>{const q=[];for(const P of u)for(const B of P.incentives)q.push({tokenAddress:P.tokenAddress,incentiveAddress:B.incentiveAddress});return q},[u]),w=Lu(x),C=y.useMemo(()=>{const q=new Set;for(const P of u)for(const B of P.incentives)q.add(B.rewardMetadata);return Array.from(q)},[u]),b=Ls(C,{failSoft:!0}),j=y.useMemo(()=>Vu(o,a,r,i),[o,a,r,i]),k=Ls(j),T=y.useMemo(()=>Ku(k),[k]),{data:L}=Ou(T),A=Pu(T),M=y.useMemo(()=>{const q=new Map;for(const P of t)q.set(P.denom,P);return q},[t]),N=y.useMemo(()=>{const q=new Map;for(const P of d??[])q.set(P.id,P.price);return q},[d]),{rows:I,totalValue:F}=y.useMemo(()=>{const q=d?.find(z=>z.id===Qe)?.price??0,P=new Map;for(const z of T)P.set(z,Wu(z,A,M));No(o,k,L,P,"deposit"),No(a,k,L,P,"staking"),zu(r,k,L,P,"lockStaking"),No(i,k,L,P,"unstaking"),Hu(P,c,l,q);for(const z of h){const K=m.get(z)??[];if(K.length===0)continue;const le=f.get(z),ye=p.get(z),he=Au(z),xe=le?.coins.map(ae=>ae.denom)??[],be=le?Zi(le,M).filter(Boolean):[],De=xe.map(ae=>M.get(ae)?.symbol||ae),ut=le?.symbol||De.join("-")||he,Mt=Bu(xe,M),mt=K.map(ae=>{let Le,Ln,qn,fn=!1,pn=0,Pn=0;try{const ht=ku({tickLower:ae.tickLower,tickUpper:ae.tickUpper});Le=ht.min,Ln=ht.max}catch{Le=void 0,Ln=void 0}if(ye){try{const ht=wu(BigInt(ye.sqrtPrice)),ze=Ut(ae.tickLower),at=Ut(ae.tickUpper),ve=Number(ye.tickSpacing);fn=Number.isFinite(ve)&&ve>0?fu(ae.tickLower,ae.tickUpper,ve):!1,qn=fn||ht>=ze&&ht<at}catch{qn=void 0,fn=!1}if(le&&xe.length>0)try{vu({sqrtPrice:ye.sqrtPrice,tickLower:ae.tickLower,tickUpper:ae.tickUpper,liquidity:ae.liquidity}).forEach((ze,at)=>{const ve=le.coins[at];if(!ve)return;const Wt=M.get(ve.denom)?.decimals??6,zt=N.get(ve.denom)??0,gn=Number(v.fromBaseUnit(String(ze),{decimals:Wt}));pn+=gn*zt})}catch{pn=0}}return le&&((_.get(ae.tokenAddress)??[]).forEach((ze,at)=>{const ve=le.coins[at];if(!ve)return;const Wt=M.get(ve.denom)?.decimals??6,zt=N.get(ve.denom)??0,gn=Number(v.fromBaseUnit(ze,{decimals:Wt}));Pn+=gn*zt}),ae.incentives.forEach(ze=>{const at=w.get(Gi(ae.tokenAddress,ze.incentiveAddress))??"0",ve=b.get(ze.rewardMetadata);if(!ve)return;const Wt=M.get(ve)?.decimals??6,zt=N.get(ve)??0,gn=Number(v.fromBaseUnit(at,{decimals:Wt}));Pn+=gn*zt})),{tokenAddress:ae.tokenAddress,positionId:Qu(ae.tokenAddress),inRange:qn,isFullRange:fn,minPrice:Le,maxPrice:Ln,pricePairLabel:Mt,rewardValue:Pn,value:pn}}),Te=mt.reduce((ae,Le)=>ae+Le.value,0),O=mt.reduce((ae,Le)=>ae+Le.rewardValue,0),Ee=be.length>0;P.set(he,{denom:he,symbol:ut,totalAmount:0,totalValue:Te,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:Ee?be:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:z,totalRewardValue:O,positions:mt}})}const B=Array.from(P.values()).filter(z=>z.totalAmount>0||z.isClamm).sort((z,K)=>K.totalValue-z.totalValue),H=B.reduce((z,K)=>z+K.totalValue,0);return{rows:B,totalValue:H}},[d,T,A,M,o,a,r,i,k,L,c,l,h,m,f,p,_,w,b,N]);return{totalValue:F,rows:I}}const Gu=Se.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function Yu(e){return e.filter(t=>t.data.length>0).map(t=>{const s=t.data[0].bridge_id,o=t.data[0].version,a=t.data.reduce((r,i)=>r+i.claimed_reward,0);return{claimableReward:t.total_claimable_reward,claimedReward:a,initialReward:t.total_vesting_reward,lockedReward:t.total_locked_reward,requiredScore:t.required_score,rollup:{bridgeId:s,version:o}}}).filter(t=>t.initialReward>0).toSorted((t,s)=>s.initialReward-t.initialReward)}function nc(){const{vipUrl:e}=se(),t=te();return S.useQuery({queryKey:Gu.allVestingPositions(e,t).queryKey,queryFn:async()=>(await G.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:W.MINUTE,enabled:!!t})}function Zu(){const e=me();return y.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function ro(){const{data:e}=nc(),t=oe(),{data:s}=Tt(t),o=Zu(),a=y.useMemo(()=>s?.find(l=>l.id===Qe)?.price??0,[s]),r=y.useMemo(()=>e?Yu(e).map(l=>{const d=o(l.rollup.bridgeId),u=Number(v.fromBaseUnit(String(l.lockedReward),{decimals:st})),m=Number(v.fromBaseUnit(String(l.claimableReward),{decimals:st})),h=U(v.fromBaseUnit(String(l.lockedReward),{decimals:st})).times(a).toNumber(),f=U(v.fromBaseUnit(String(l.claimableReward),{decimals:st})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:u,lockedRewardValue:h,claimableReward:m,claimableRewardValue:f}}).filter(l=>l.lockedReward+l.claimableReward>0):[],[e,a,o]),i=y.useMemo(()=>r.reduce((c,l)=>c+l.lockedRewardValue+l.claimableRewardValue,0),[r]);return{rows:r,totalValue:i}}function sc(){const{totalValue:e}=ao(),{data:t}=ja(),{data:s}=Ca(),{data:o}=va(),{data:a}=nc(),r=y.useMemo(()=>Array.from(s.keys()),[s]),i=Ls(r),c=oe(),{data:l}=Tt(c),d=y.useMemo(()=>l?.find(m=>m.id===Qe)?.price??0,[l]);return y.useMemo(()=>{let u=0,m=0;const h=d??0;for(const[,p]of t)for(const{denom:g,amount:_}of p)g===Qe&&(u+=Number(v.fromBaseUnit(_,{decimals:st}))*h);for(const[p,g]of s)if(i.get(p)===Qe)for(const{amount:_}of g)m+=Number(v.fromBaseUnit(_,{decimals:st}))*h;for(const[,p]of o)for(const{denom:g,amount:_}of p)g===Qe&&(u+=Number(v.fromBaseUnit(_,{decimals:st}))*h);let f=0;if(a)for(const p of a){const g=p.total_locked_reward??0,_=p.total_claimable_reward??0;f+=Number(v.fromBaseUnit(String(g+_),{decimals:st}))*h}return u+m+e+f},[t,s,i,o,a,d,e])}function Ju(){const e=["initia-wallet-widget:last-connected-wallet","initia-wallet-widget:fee-denoms","initia-wallet-widget:chain-ids","initia-wallet-widget:opened-layers-assets","initia-wallet-widget:opened-layers-nft"],t={"initia-wallet-widget:ethereum-public-keys":{prefix:ie.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(t)){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 Ko=Se.createQueryKeys("interwovenkit:minity",{supportedChains:e=>[e],prices:e=>[e],ssePortfolio:(e,t)=>[e,t],balances:(e,t,s)=>[e,t,s],initiaPositions:(e,t)=>[e,"initia",t],echelonPositions:(e,t)=>[e,"echelon",t],inertiaPositions:(e,t)=>[e,"inertia",t],ravePositions:(e,t,s)=>[e,"rave",t,s],yominetPositions:(e,t)=>[e,"yominet",t],chainPositions:(e,t,s)=>[e,t,s]});function ka(e,t){const s=new Map,o=new Map;for(let a=0;a<e.length;a++){const r=e[a],i=t[a],c=r.data;if(!(!i||!c)){for(const l of c)if(l.logoUrl&&!l.logoUrl.includes("undefined")){const d=`${i.chainId}:${l.denom}`;s.has(d)||s.set(d,l.logoUrl);const u=l.symbol.toUpperCase();o.has(u)||o.set(u,l.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 t=e.balance.value??0;return e.type==="lending"&&e.direction==="borrow"?-t:t}function Xu(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 em(e,t=!1){switch(e){case"staking":return t?"INIT staking":"Staking";case"borrowing":return"Borrowing";case"lending":return"Lending";default:return e.charAt(0).toUpperCase()+e.slice(1)}}function tm(e){const t=new Map;for(const d of e){const u=Xu(d);if(!u)continue;const m=t.get(u)??[];m.push(d),t.set(u,m)}const s=new Map,o=new Map;for(const[d,u]of t){const m=u.reduce((f,p)=>f+An(p),0),h=u.reduce((f,p)=>f+Math.abs(An(p)),0);s.set(d,m),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((d,u)=>{const m=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=u==="lending"||u==="borrowing"?i:o.get(u)??0;return(d==="lending"||d==="borrowing")&&(u==="lending"||u==="borrowing")?d==="lending"?-1:1:h-m}),l=new Map;for(const d of c)l.set(d,{positions:t.get(d),totalValue:s.get(d)??0});return l}function nm(e){return e.type==="fungible-position"?e.title:e.balance.denom}function sm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function om(e){return e.type==="fungible-position"?null:e.balance}function am(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 rm(e){const t=new Map;for(const s of e){const o=t.get(s.type)??[];o.push(s),t.set(s.type,o)}return t}function im(e,t){return e.symbol===it&&t.symbol===it?0:e.symbol===it?-1:t.symbol===it?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function cm(e){const t=new Map;for(const o of e){const a=nm(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=om(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:sm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+An(l),0),totalAmount:i,balance:r}}).toSorted(im)}function oc(e,t){const s=new Map;return e.forEach((o,a)=>{const r=t[a]?.data;if(r&&r.length>0){const i=new Map(r.map(c=>[c.id,c.price]));s.set(o.chainId,i)}}),s}function lm(e,t){return e.map(s=>({...s,balances:s.balances.map(o=>{if(o.type==="unknown"||o.value!=null&&o.value>0)return o;const a=t.get(s.chainId);if(a){const r=a.get(o.denom)??0;if(r>0)return{...o,value:o.formattedAmount*r}}return o})}))}function dm(e,t){return e.symbol===it&&t.symbol===it?0:e.symbol===it?-1:t.symbol===it?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function um(e,t,s){return e.map(o=>{const a=o.assets.map(i=>{const c=i.symbol.toUpperCase(),l=`${i.chain.chainId}:${i.denom}`,d=t.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 mm(e,t,s){const o=t?e.filter(i=>{const{symbol:c,assets:l}=i,d=t.toLowerCase();return c.toLowerCase().includes(d)||l.some(({denom:u})=>u.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function hm(e,t,s){const o=t?e.filter(({denom:a,address:r})=>{const i=t.toLowerCase();return a.toLowerCase().includes(i)||r?.toLowerCase().includes(i)}):e;return s?o.filter(({chain:a})=>a.chainId===s):o}function fm(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=mm(e,s,o),i=hm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function pm(e,t,s,o){if(!Array.isArray(e))return{listedGroups:[],unlistedAssets:[]};const a=new Map,r=[];for(const c of e){const{chainName:l,chainId:d,balances:u}=c;if(!Array.isArray(u))continue;const m=t.get(l.toLowerCase()),h=m?.chainId??d??l,f=m?.prettyName??l,p=m?.logoUrl??"",g=s.get(h);for(const _ of u){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 x=_.value;if((x==null||x<=0)&&g){const b=g.get(_.denom)??0;b>0&&(x=_.formattedAmount*b)}const w={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:p}},C=a.get(_.symbol);C?C.push(w):a.set(_.symbol,[w])}}r.sort((c,l)=>{const d=c.chain.chainId===o,u=l.chain.chainId===o;if(d&&!u)return-1;if(!d&&u)return 1;const m=c.chain.name.localeCompare(l.chain.name);if(m!==0)return m;try{const h=BigInt(c.amount),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((m,h)=>(h.value??0)-(m.value??0));let d=0,u=0;for(const m of l)d+=m.value??0,u+=Number(m.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:u})}return i.sort(dm),{listedGroups:i,unlistedAssets:r}}function Ia(){return oe().network_type==="testnet"}function Vt(){return Ne.useFormContext()}function gm(){const e=Ze(),t=Ia(),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=$.pickBy(i=>i!==null,{srcChainId:localStorage.getItem(ie.BRIDGE_SRC_CHAIN_ID),srcDenom:localStorage.getItem(ie.BRIDGE_SRC_DENOM),dstChainId:localStorage.getItem(ie.BRIDGE_DST_CHAIN_ID),dstDenom:localStorage.getItem(ie.BRIDGE_DST_DENOM),quantity:localStorage.getItem(ie.BRIDGE_QUANTITY),slippagePercent:localStorage.getItem(ie.BRIDGE_SLIPPAGE_PERCENT)});return{...t?o:a,...r,...e}}const _m={balances:[],positions:[],isLoading:!0,isComplete:!1},ac=Q.atom(0),ym=1e3;let rr=0;function xm(){const e=Q.useSetAtom(ac);y.useEffect(()=>{const t=Date.now();t-rr>=ym&&(rr=t,e(s=>s+1))},[e])}function bm(){const e=S.useQueryClient(),t=te(),{minityUrl:s}=se(),o=Ia(),a=Q.useAtomValue(ac),r=y.useEffectEvent((l,d)=>{const u=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:u})}),i=y.useEffectEvent((l,d)=>{const u=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:u})}),c=y.useEffectEvent((l,d)=>{const u=Ko.ssePortfolio(t??"",s).queryKey,m=e.getQueryData(u)??_m,h=l.size>0||d.size>0;e.setQueryData(u,{...m,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:m.isLoading,isComplete:!1})});y.useEffect(()=>{if(!t||o)return;const l=Ko.ssePortfolio(t,s).queryKey,d=e.getQueryData(l),u=new Map,m=new Map;for(const _ of d?.balances??[])u.set(_.chainName,_);for(const _ of d?.positions??[])m.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;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 x=JSON.parse(_.data);x.type==="balances"?r(x,u):x.type==="positions"&&i(x,m),c(u,m)}catch{}},p.onerror=()=>{p?.close()},()=>{g=!0,p?.close()}},[t,o,a])}const ir={balances:[],positions:[],isLoading:!0,isComplete:!1};function ls(){const e=te(),{minityUrl:t}=se(),s=Ko.ssePortfolio(e??"",t).queryKey,{data:o}=S.useQuery({queryKey:s,queryFn:()=>ir,enabled:!!e,staleTime:W.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??ir}function wm(){const e=me();return y.useMemo(()=>{const t=new Map;for(const s of e){const o=s.chain_name.toLowerCase();t.set(o,{chainId:s.chainId,chainName:s.chain_name,prettyName:s.name||s.chain_name,logoUrl:s.logoUrl||""})}return t},[e])}function jm(){const{balances:e,positions:t}=ls(),s=me(),o=y.useMemo(()=>{const r=new Map;for(const i of s)r.set(i.chain_name.toLowerCase(),i);return r},[s]);return y.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(t)?t:[];for(const{chainName:f,balances:p}of l){if(!Array.isArray(p))continue;const g=p.reduce((_,x)=>_+r(x),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((_,x)=>_+i(x),0);c.set(f,(c.get(f)||0)+g)}const u=Array.from(c.values()).reduce((f,p)=>f+p,0),m=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:u>0?p/u:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return $.sortWith([$.descend(h),$.descend($.prop("totalBalance"))],m)},[e,t,o])}function vm(){const{balances:e}=ls(),t=me(),s=ia(),o=y.useMemo(()=>oc(t,s),[t,s]);return y.useMemo(()=>{const a=l=>l.type==="unknown"?0:l.value??0;let r=0;const i=Array.isArray(e)?e:[],c=lm(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 Cm(){const{positions:e}=ls();return y.useMemo(()=>{const t=r=>r.positions.reduce((i,c)=>{if(c.type==="fungible-position")return i+(c.value??0);if(c.balance.type==="unknown")return i;const l=c.balance.value??0;return c.type==="lending"&&c.direction==="borrow"?i-l:i+l},0),s=["initia","civitia","yominet"];let o=0;const a=Array.isArray(e)?e:[];for(const{chainName:r,positions:i}of a){const c=r.toLowerCase();s.includes(c)||Array.isArray(i)&&(o+=i.reduce((l,d)=>l+t(d),0))}return o},[e])}const we=Se.createQueryKeys("interwovenkit:skip",{chains:null,allAssets:()=>["allAssets"],assets:e=>[e],asset:(e,t)=>[e,t],allBalances:(e,t)=>[e,t],balances:(e,t)=>[e,t],route:(e,t)=>[{...e,quantity:U(e.quantity||0).toString()},t],routeErrorInfo:e=>[e],txTrack:(e,t)=>[e,t],txStatus:(e,t)=>[e,t]});function Re(){const{routerApiUrl:e}=se();return y.useMemo(()=>G.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.4.5"}}),[e])}function Nm(){const e=Re();S.usePrefetchQuery({queryKey:we.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:W.MINUTE}),S.usePrefetchQuery({queryKey:we.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:W.MINUTE})}const km=()=>(Rl(),Dl(),null),Im="_loader_1vxch_1",Am={loader:Im},jt=({size:e=24,color:t="currentColor",border:s=2})=>{const o={width:`${e}px`,height:`${e}px`,borderColor:`${t} ${t} transparent ${t}`,borderWidth:`${s}px`};return n.jsx("div",{className:Am.loader,style:o})},Sm="_button_1q027_1",Tm="_outline_1q027_28",Em="_sm_1q027_46",$m="_full_1q027_53",Mm="_small_1q027_57",Lm="_unpadded_1q027_88",nn={button:Sm,outline:Tm,sm:Em,full:$m,small:Mm,unpadded:Lm},rc=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:D(nn.button,{[nn.sm]:t,[nn.full]:s},a),disabled:!!o||i,children:o?n.jsxs(n.Fragment,{children:[n.jsx(jt,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:nn.loading,children:o})]}):r})},qm=({className:e,...t})=>n.jsx(rc,{...t,className:D(nn.outline,e)}),Pm=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:D(nn.small,{[nn.unpadded]:t},e)}),ue={White:rc,Outline:qm,Small:Pm},Rm="_footer_1vp4h_1",Dm="_actions_1vp4h_10",cr={footer:Rm,actions:Dm},ke=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:D(cr.footer,t),children:[e,n.jsx("div",{className:cr.actions,children:s})]}),Bm="_scrollable_13su7_1",Fm={scrollable:Bm},dt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:D(Fm.scrollable,e),children:t}),Um="interwovenkit:";function Om(e){const[t]=e;return typeof t=="string"&&t.startsWith(Um)}function Vm(e){e.removeQueries({predicate:t=>Om(t.queryKey)})}function io(){return We.useMediaQuery("(max-width: 576px)")}const Wo="interwoven-kit";function ic(){const e=document.querySelector(Wo)||document.body.appendChild(document.createElement(Wo));return e.shadowRoot||e.attachShadow({mode:"open"})}function cc(){const{theme:e,container:t}=se();return y.useEffect(()=>{document.querySelector(Wo)?.setAttribute("data-theme",e)},[e]),t??ic()}function Km(e){const t=ic(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const co=y.createContext(null);function dn(){const{container:e}=y.useContext(co);return e}function lc(e){const t=dn();return t?getComputedStyle(t).getPropertyValue(e):""}function Wm(){return We.useScrollLock(),null}function zm(e){return/^[A-F0-9]{64}$/i.test(e)}function Hm(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return zm(s)?$.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!v.InitiaAddress.validate(o))return;const i=$.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function Qm(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const Gm="_link_j1lkz_1",lr={link:Gm},lo=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,u=lt(e),m=Hm(u,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?v.truncate(t):s?v.truncate(s):"",f=c??h;return m?n.jsxs("a",{...d,href:pl(Qm(m)),className:D(lr.link,i),onClick:l,target:"_blank",children:[f,r&&n.jsx(E.IconExternalLink,{size:12})]}):n.jsx("span",{...d,className:D(lr.link,i),children:f})},dc=y.createContext(null),uo=()=>y.useContext(dc),Ym=()=>{const[e,t]=Q.useAtom(Di),{showNotification:s,updateNotification:o,hideNotification:a}=uo();return y.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?n.jsx(lo,{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}),t(null);break;case"success":o({type:"success",title:"Transaction is successful!",description:d,autoHide:!0}),t(null);break}},[e,t,s,o,a]),null},Fs=({value:e,children:t})=>{const[s,o]=y.useState(!1);return t({copy:async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1e3)}catch{}},copied:s})},Zm="_placeholder_10r3x_1",Jm="_logo_10r3x_5",dr={placeholder:Zm,logo:Jm},ee=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=y.useState(void 0),{width:d,height:u}=i,m=s??n.jsx("div",{className:D(dr.placeholder,o?.placeholder),style:{width:d,height:u,...a}});return!e||c===e?m:n.jsx("img",{...i,className:D(i.className,{[dr.logo]:r}),style:{width:d,height:u,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function uc(){const{connector:e}=Ke.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const Xm="_header_1q8ju_1",eh="_account_1q8ju_17",th="_name_1q8ju_28",nh="_address_1q8ju_32",sh="_icon_1q8ju_36",oh="_copied_1q8ju_43",ah="_button_1q8ju_58",rh="_settings_1q8ju_69",ih="_disconnect_1q8ju_73",ch="_label_1q8ju_83",lh="_expanded_1q8ju_91",Xe={header:Xm,account:eh,name:th,address:nh,icon:sh,copied:oh,button:ah,settings:rh,disconnect:ih,label:ch,expanded:lh},dh=()=>{const e=xi(),{address:t,username:s}=Je(),o=uc(),a=s??t,[r,i]=y.useState(!1),c=y.useRef(null),l=bt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},u=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},m=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:Xe.header,children:[n.jsx(Fs,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:D(Xe.account,{[Xe.copied]:f}),onClick:h,children:[n.jsx(ee,{src:o,width:18,height:18}),n.jsx("div",{className:Xe.address,children:v.truncate(t)}),n.jsx("div",{className:Xe.name,children:v.truncate(a)}),n.jsx(E.IconCopy,{className:Xe.icon,size:12}),f?"Copied!":""]})}),n.jsx(Nn,{to:"/settings",className:D(Xe.button,Xe.settings),"aria-label":"Open settings",children:n.jsx(E.IconSettingFilled,{size:16})}),n.jsxs(bt.animated.button,{className:D(Xe.button,Xe.disconnect,{[Xe.expanded]:r}),style:l,onClick:d,onMouseLeave:u,onMouseEnter:m,children:[n.jsx(E.IconSignOut,{size:16}),n.jsx("span",{className:Xe.label,children:"Disconnect"})]})]}):null},uh="_overlay_jij9g_1",mh="_content_jij9g_28",hh="_inner_jij9g_60",ko={overlay:uh,content:mh,inner:hh},fh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=Et(),{setContainer:o}=y.useContext(co),a=io(),r=cc(),i=Q.useAtomValue(so),c=Q.useAtomValue(os),l=S.useIsMutating({mutationKey:[Ri]}),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"))},u=Zs(),m=Ie(),h=S.useQueryClient(),f={fallbackRender:({error:p,resetErrorBoundary:g})=>{const _=()=>{u==="/bridge"&&(localStorage.removeItem(ie.BRIDGE_SRC_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_SRC_DENOM),localStorage.removeItem(ie.BRIDGE_DST_CHAIN_ID),localStorage.removeItem(ie.BRIDGE_DST_DENOM)),m("/"),Vm(h),g()};return n.jsxs(dt,{children:[n.jsx(_e,{error:!0,children:p.message}),n.jsx(ke,{children:n.jsx(ue.White,{onClick:_,children:"Retry"})})]})}};return n.jsx(Pe.Dialog.Root,{open:t,onOpenChange:p=>!p&&d(),modal:!1,children:n.jsxs(Pe.Dialog.Portal,{container:r,children:[a&&n.jsx(Pe.Dialog.Backdrop,{className:ko.overlay,onClick:d,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14",children:[n.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),n.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),n.jsx(Pe.Dialog.Popup,{className:ko.content,children:n.jsxs("div",{className:D(ko.inner,"body"),ref:o,children:[a&&n.jsx(Wm,{}),n.jsx(Ym,{}),n.jsx(dh,{}),n.jsx(pe,{errorBoundaryProps:f,children:e})]})})]})})},ph="_backdrop_1bqx9_1",gh="_modal_1bqx9_12",_h="_closeButton_1bqx9_44",Io={backdrop:ph,modal:gh,closeButton:_h},yh=({children:e})=>{const{isModalOpen:t,closeModal:s}=En(),{setContainer:o}=y.useContext(co),a=cc();return n.jsx(Pe.Dialog.Root,{open:t,onOpenChange:r=>!r&&s(),children:n.jsxs(Pe.Dialog.Portal,{container:a,children:[n.jsx(Pe.Dialog.Backdrop,{className:Io.backdrop,onClick:s}),n.jsxs(Pe.Dialog.Popup,{className:Io.modal,ref:o,children:[n.jsx("button",{className:Io.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(E.IconClose,{size:20})}),n.jsx(pe,{children:e})]})]})})},mc=y.createContext(!1),xh="_overlay_1iyfl_1",bh="_fullscreen_1iyfl_15",wh="_content_1iyfl_19",jh="_header_1iyfl_56",vh="_title_1iyfl_65",Ch="_close_1iyfl_70",Qt={overlay:xh,fullscreen:bh,content:wh,header:jh,title:vh,close:Ch},hc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=dn(),c=y.useContext(mc);return i?n.jsxs(Pe.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Pe.Dialog.Trigger,{className:o,children:s}),n.jsxs(Pe.Dialog.Portal,{container:i,children:[n.jsx(Pe.Dialog.Backdrop,{className:D(Qt.overlay,{[Qt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Pe.Dialog.Popup,{className:D(Qt.content,{[Qt.fullscreen]:c}),children:[e&&n.jsxs("header",{className:Qt.header,children:[n.jsx(Pe.Dialog.Title,{className:Qt.title,children:e}),n.jsx(Pe.Dialog.Close,{className:Qt.close,children:n.jsx(E.IconClose,{size:20})})]}),t]})]})]}):null},Jn=({children:e})=>{const t=y.useRef(null),[s,o]=y.useState(0),[a,r]=y.useState(!1),i=bt.useSpring({height:s,config:{tension:500,friction:30,clamp:!0},immediate:!a});return y.useEffect(()=>{const c=t.current;if(!c)return;const l=()=>{const{height:u}=c.getBoundingClientRect();o(u),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?n.jsx(bt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},Nh="_help_qcmtq_1",kh="_icon_qcmtq_10",Ih="_info_qcmtq_19",Ah="_warning_qcmtq_23",Sh="_error_qcmtq_27",Th="_success_qcmtq_33",Ao={help:Nh,icon:kh,info:Ih,warning:Ah,error:Sh,success:Th},wn=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(jt,{size:12});case"info":return n.jsx(E.IconInfoFilled,{size:12});case"warning":case"error":return n.jsx(E.IconWarningFilled,{size:12});default:return n.jsx(E.IconCheckCircleFilled,{size:12})}};return n.jsxs("div",{className:D(Ao.help,e&&Ao[e],t),style:{marginTop:s},children:[n.jsx("div",{className:Ao.icon,children:a()}),o]})},Eh="_stack_a6m7u_1",$h="_help_a6m7u_6",Mh="_info_a6m7u_14",Lh="_warning_a6m7u_19",qh="_error_a6m7u_24",Ph="_success_a6m7u_29",zo={stack:Eh,help:$h,info:Mh,warning:Lh,error:qh,success:Ph},Rh=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(Jn,{children:n.jsx("div",{className:zo.stack,children:e})}),ge=({mt:e=0,...t})=>n.jsx(wn,{...t,className:D(zo.help,zo[t.level]),mt:e});ge.Stack=Rh;const Dh="_root_16p5j_1",Bh="_item_16p5j_10",Fh="_chevron_16p5j_14",Uh="_trigger_16p5j_19",Oh="_content_16p5j_39",Dn={root:Dh,item:Bh,chevron:Fh,trigger:Uh,content:Oh};function Vh(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(Z.Accordion.Root,{className:Dn.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(Z.Accordion.Item,{className:Dn.item,value:s?.(c)??String(l),children:[n.jsx(Z.Accordion.Header,{children:n.jsxs(Z.Accordion.Trigger,{className:Dn.trigger,children:[o(c),n.jsx(E.IconChevronDown,{className:Dn.chevron,size:16})]})}),n.jsx(Z.Accordion.Content,{className:Dn.content,children:a(c)})]},s?.(c)??l)),r]})}const Kh="_trigger_u613p_1",Wh="_icon_u613p_18",zh="_content_u613p_27",Hh="_item_u613p_36",Qh="_itemText_u613p_52",Gh="_itemIndicator_u613p_57",Yh="_active_u613p_60",qt={trigger:Kh,icon:Wh,content:zh,item:Hh,itemText:Qh,itemIndicator:Gh,active:Yh};function Aa({options:e,value:t,onChange:s,classNames:o}){const a=dn(),r=e.find(c=>c.value===t);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 n.jsxs(It.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(It.Select.Trigger,{className:D(qt.trigger,o?.trigger),children:[n.jsx(It.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(It.Select.Icon,{className:qt.icon,children:n.jsx(E.IconChevronDown,{size:12})})]}),n.jsx(It.Select.Portal,{container:a,children:n.jsx(It.Select.Positioner,{className:qt.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(It.Select.Popup,{className:qt.popup,children:e.map(c=>n.jsxs(It.Select.Item,{className:D(qt.item,o?.item),value:String(c.value),children:[n.jsx(It.Select.ItemText,{className:D(qt.itemText,o?.itemText),children:c.label}),n.jsx(E.IconCheck,{size:12,className:D(qt.itemIndicator,{[qt.active]:c.value===t})})]},String(c.value)))})})})]})}const Zh="_root_1t37n_1",Jh="_trigger_1t37n_7",Xh="_item_1t37n_11",ef="_itemText_1t37n_17",ur={root:Zh,trigger:Jh,item:Xh,itemText:ef},tf=({options:e,value:t,onChange:s})=>{const{txRequest:o}=Fi(),a=lt(o.chainId),r=Ct(a),i=(p,g)=>{if(v.formatAmount(p,{decimals:g})==="0.000000")return 8},c=({amount:[{amount:p,denom:g}]})=>{if(U(p).isZero())return"0";const{symbol:_,decimals:x}=r(g),w=i(p,x);return`${v.formatAmount(p,{decimals:x,dp:w})} ${_}`},l=e.map(p=>{const[{denom:g}]=p.amount,{symbol:_}=r(g);return{value:g,label:c(p),triggerLabel:_}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(p=>p.amount[0].denom===t);if(!d)throw new Error("Fee option not found");const[{amount:u,denom:m}]=d.amount,{decimals:h}=r(m),f=i(u,h);return n.jsxs("div",{className:ur.root,children:[n.jsx("span",{className:"monospace",children:v.formatAmount(u,{decimals:h,dp:f})}),n.jsx(Aa,{options:l,value:t,onChange:s,classNames:ur})]})},nf="_root_16nr2_1",sf="_trigger_16nr2_5",of="_chevron_16nr2_13",af="_panel_16nr2_27",rf="_details_16nr2_39",cf="_row_16nr2_48",yn={root:nf,trigger:sf,chevron:of,panel:af,details:rf,row:cf},lf=({spend:e,fee:t,total:s,balance:o,symbol:a,decimals:r})=>{const i=[e&&{label:"Spend",value:e},{label:"Fee",value:t},e&&{label:"Required (spend + fee)",value:s},{label:"Balance",value:o}].filter(Boolean),c=r===6?void 0:8;return n.jsxs(bo.Collapsible.Root,{className:yn.root,children:[n.jsxs(bo.Collapsible.Trigger,{className:yn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(E.IconChevronDown,{className:yn.chevron,size:16})]}),n.jsx(bo.Collapsible.Panel,{className:yn.panel,children:n.jsx("div",{className:yn.details,children:i.map(({label:l,value:d})=>n.jsxs("div",{className:yn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[v.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function Us(e){switch(typeof e){case"string":return e;case"number":case"bigint":return e.toString();case"boolean":return e?"true":"false";case"object":return e===null?"null":e instanceof Uint8Array?re.toBase64(e):Array.isArray(e)?`[${e.map(Us).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const df="_container_1xzyq_1",uf="_toggle_1xzyq_5",mf="_list_1xzyq_11",hf="_arg_1xzyq_16",ff="_type_1xzyq_21",Bn={container:df,toggle:uf,list:mf,arg:hf,type:ff},pf=Se.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),gf=({type:e,arg:t})=>Us(v.resolveBcsType(e).parse(t)),_f=({msg:e,chainId:t,fallback:s})=>{const[o,a]=We.useToggle(!1),{restUrl:r}=lt(t),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:u}=S.useQuery({queryKey:pf.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await G.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:W.INFINITY});if(!u)return s;const m=(h,f)=>{const p=u[f];return n.jsxs("div",{className:Bn.arg,children:[n.jsx("div",{className:Bn.type,children:p}),n.jsx(Wr.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(gf,{type:p,arg:h})})]},f)};return n.jsxs("div",{className:Bn.container,children:[n.jsx(ue.Small,{className:Bn.toggle,onClick:a,disabled:!u,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Bn.list,children:d.map(m)}):s]})},yf="_list_oip9m_1",xf="_key_oip9m_9",bf="_value_oip9m_14",So={list:yf,key:xf,value:bf},wf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:So.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:So.key,children:a}),n.jsx("div",{className:So.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(_f,{msg:o,chainId:t,fallback:Us(r)}):Us(r)})]},a))})},jf="_item_1n572_1",vf="_title_1n572_10",Cf="_content_1n572_14",To={item:jf,title:vf,content:Cf},Eo=({title:e,content:t})=>n.jsxs("div",{className:To.item,children:[n.jsx("div",{className:To.title,children:e}),n.jsx("div",{className:To.content,children:t})]});function X(e){const t=e?U(e).abs():void 0;if(t&&t.gt(0)&&t.lt(.01))return"< $0.01";const s=e&&U(e).lt(0),o=v.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function fc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")){if(o.type==="coin_spent"){const r=o.attributes.find(c=>c.key==="spender")?.value,i=o.attributes.find(c=>c.key==="amount")?.value;if(r===t&&i){const[c,l]=i.match(/^(\d+)(.+)$/)?.slice(1)||[];if(c&&l){const 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===t&&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 pc(e,t){const s={};for(const o of e)if(o.attributes.some(r=>r.key==="msg_index")&&o.type==="move"){const r=o.attributes.find(l=>l.key==="type_tag")?.value,i=o.attributes.find(l=>l.key==="data")?.value;if(!r||!i)continue;let c;try{c=JSON.parse(i)}catch{continue}if(r==="0x1::fungible_asset::WithdrawEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(t,u)===l){const h=s[u]||BigInt(0);s[u]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,u=c.metadata_addr;if(l&&d&&u&&v.createUserDerivedObjectAddress(t,u)===l){const h=s[u]||BigInt(0);s[u]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const gc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=S.useSuspenseQuery({queryKey:kn.denom(o,e).queryKey,queryFn:()=>G.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:W.INFINITY});return s(a)},Nf="_root_1p8a4_1",kf="_title_1p8a4_8",If="_changes_1p8a4_14",Af="_change_1p8a4_14",Sf="_amount_1p8a4_35",Tf="_text_1p8a4_42",Ef="_value_1p8a4_49",sn={root:Nf,title:kf,changes:If,change:Af,amount:Sf,text:Tf,value:Ef},_c=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=v.formatAmount(e,{decimals:r}),l=s&&U(v.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:sn.change,children:[n.jsxs("div",{className:sn.amount,children:[n.jsx(ee,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:sn.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:sn.value,children:X(l)})]})},$f=({changes:e,chain:t})=>{const s=Ct(t),{data:o}=Tt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return n.jsx(_c,{amount:a,asset:c,price:l},i)})},Mf=({changes:e,chain:t})=>{const s=Ct(t),{data:o}=Tt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(gc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return n.jsx(_c,{amount:a,asset:s(c),price:l})}},i))};function Lf(e,t){return typeof t=="bigint"?t.toString():t}const qf=Se.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,Lf)]}),Pf=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=Je(),r=lt(s),{simulateTx:i}=oo(),{data:c}=S.useSuspenseQuery({queryKey:qf.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:W.SECOND}),l=h=>n.jsxs("div",{className:sn.root,children:[n.jsx("h2",{className:sn.title,children:"Estimated changes"}),n.jsx("div",{className:sn.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=pc(d,a),[f]=mr(h);return f.length===0?null:l(n.jsx(Mf,{changes:f,chain:r}))}const u=fc(d,o),[m]=mr(u);return m.length===0?null:l(n.jsx($f,{changes:m,chain:r}))};function mr(e){return $.partition(t=>new U(t.amount).isNegative(),e)}const Rf="_title_1d032_1",Df="_meta_1d032_7",Bf="_footer_1d032_14",Ff="_rejectButton_1d032_19",ws={title:Rf,meta:Df,footer:Bf,rejectButton:Ff},yc=()=>{const{txRequest:e,resolve:t,reject:s}=Fi(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=lt(r),u=ss(d),m=ga(d),h=_a(d),f=Ct(d),p=Bi(),g=(e.gasPrices??m).map(({amount:A,denom:M})=>Ae.calculateFee(Math.ceil(i*c),Ae.GasPrice.fromString(A+M))),_=g.map(A=>A.amount[0]),x=A=>{const M=u.find(H=>H.denom===A)?.amount??"0",N=_.find(H=>H.denom===A)?.amount??"0",I=l.filter(H=>H.denom===A).reduce((H,z)=>U(H).plus(z.amount),U("0")),F=U(N).plus(I),q=U(M).gte(F),{symbol:P,decimals:B}=f(A);return{symbol:P,decimals:B,spend:I.gt(0)?I.toFixed():null,fee:N,total:F.toFixed(),balance:M,isSufficient:q}},w=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of _)if(x(A).isSufficient)return A;return _[0]?.denom},[C,b]=y.useState(w),{mutate:j,isPending:k}=S.useMutation({mutationKey:[Ri],mutationFn:async()=>{const A=g.find(N=>N.amount[0].denom===C);if(!A)throw new Error("Fee not found");const M=await p({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:C,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t(M)},onError:async A=>{s(A)}}),T=x(C),L=!T.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(dt,{children:[n.jsx("h1",{className:ws.title,children:"Confirm tx"}),n.jsxs("div",{className:ws.meta,children:[n.jsx(Eo,{title:"Chain",content:r}),n.jsx(Eo,{title:"Tx fee",content:n.jsx(tf,{options:g,value:C,onChange:b})}),a&&n.jsx(Eo,{title:"Memo",content:a}),L&&n.jsx(ge,{level:"error",children:n.jsx(lf,{...T})})]}),n.jsx(Pf,{messages:o,memo:a,chainId:r}),n.jsx(Vh,{list:o,renderHeader:({typeUrl:A})=>zs.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(wf,{message:A,chainId:r})})]}),n.jsxs(ke,{className:ws.footer,children:[n.jsx(ue.Outline,{onClick:()=>s(new Error("User rejected")),disabled:k,className:ws.rejectButton,"aria-label":"Reject",children:n.jsx(E.IconClose,{size:16})}),n.jsx(ue.White,{onClick:()=>j(),disabled:L,loading:k,children:"Approve"})]})]})},Uf=({children:e})=>{const[{title:t,content:s,path:o},a]=y.useState({}),[r,i]=y.useState(!1),c=Q.useAtomValue(so),l=y.useCallback(m=>{a(m),i(!0)},[]),d=y.useCallback(()=>{a({}),i(!1)},[]),u=y.useCallback(m=>{m||(c?.reject(new Error("User rejected")),a({})),i(m)},[c]);return n.jsxs(Mi.Provider,{value:{openModal:l,closeModal:d},children:[e,n.jsx(hc,{title:t,open:r,onOpenChange:u,children:n.jsx(pe,{children:o==="/tx"?n.jsx(yc,{}):s})})]})},Of="_container_1w1hx_1",Vf="_toast_1w1hx_11",Kf="_info_1w1hx_24",Wf="_success_1w1hx_28",zf="_error_1w1hx_32",Hf="_icon_1w1hx_37",Qf="_content_1w1hx_45",Gf="_title_1w1hx_48",Yf="_description_1w1hx_53",Zf="_close_1w1hx_75",Pt={container:Of,toast:Vf,info:Kf,success:Wf,error:zf,icon:Hf,content:Qf,title:Gf,description:Yf,close:Zf},Jf=({notification:e,onClose:t,...s})=>{const o=bt.useTransition(e,{keys:r=>r?.id||"empty",from:{transform:"translateY(-52px)",opacity:0},enter:{transform:"translateY(0px)",opacity:1},leave:{transform:"translateY(-52px)",opacity:0},config:{tension:500,friction:30,clamp:!0}}),a=r=>{switch(r){case"loading":return n.jsx(jt,{size:16});case"info":case"success":return n.jsx(E.IconCheckCircleFilled,{size:16});case"error":return n.jsx(E.IconCloseCircleFilled,{size:16});default:return null}};return o((r,i)=>{if(!i)return null;const{type:c,title:l,description:d}=i,u=a(c);return n.jsx(bt.animated.div,{style:r,className:Pt.container,children:n.jsxs("div",{className:D(Pt.toast,c&&Pt[c]),...s,children:[u&&n.jsx("div",{className:Pt.icon,children:u}),n.jsxs("div",{className:Pt.content,children:[n.jsx("p",{className:Pt.title,children:l}),d&&n.jsx("div",{className:Pt.description,children:d})]}),n.jsx("button",{className:Pt.close,onClick:t,children:n.jsx(E.IconClose,{size:14})})]})})})},$o=5e3,Xf=({children:e})=>{const t=dn(),[s,o]=y.useState(null),a=y.useRef(null),r=y.useRef(!1),i=()=>{a.current&&(clearTimeout(a.current),a.current=null)},c=y.useCallback(()=>{i(),o(null)},[]),l=y.useCallback(h=>{i(),o({...h,id:Qa.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),$o))},[c]),d=y.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:Qa.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),$o))},[c]),u=()=>{i(),r.current=!0},m=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),$o))};return y.useEffect(()=>()=>i(),[]),n.jsxs(dc.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,t&&gl.createPortal(n.jsx(Jf,{notification:s,onClose:c,onMouseEnter:u,onMouseLeave:m}),t)]})},ep=({children:e})=>{const[t,s]=y.useState(null);return n.jsx(co.Provider,{value:{container:t,setContainer:s},children:e})},xc=[{value:10*pi,label:"for 10 minutes"},{value:gi,label:"for 1 hour"},{value:Ja,label:"for 1 day"},{value:7*Ja,label:"for 7 days"},{value:0,label:"until revoked"}],tp=xc[0].value;function np(e){const t=e.split(".");return t.length!==4?!1:t.every(s=>{if(!/^\d+$/.test(s))return!1;const o=Number(s);return o>=0&&o<=255})}function bc(e){return np(e)||e.includes(":")}function Ho(e){const t=_l.parse(e);return"error"in t?null:t.domain}function sp(e,t){return e===t||e===`www.${t}`}function op(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||bc(t)?!1:Ho(t)!==null}function ap(e,t){try{const s=new URL(e);if(!op(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||bc(a)||a==="localhost")return!1;const r=Ho(o);if(!r)return!1;const i=Ho(a);return!i||i!==r?!1:sp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const rp="_container_1422v_1",ip="_title_1422v_7",cp="_description_1422v_14",lp="_sectionTitle_1422v_20",dp="_websiteInfo_1422v_27",up="_favicon_1422v_37",mp="_websiteTitle_1422v_42",hp="_websiteHost_1422v_48",fp="_warningContent_1422v_54",pp="_ignoreButton_1422v_61",gp="_infoList_1422v_65",_p="_infoItem_1422v_75",yp="_label_1422v_84",xp="_infoValue_1422v_94",bp="_durationTrigger_1422v_100",wp="_durationItem_1422v_101",jp="_featureList_1422v_105",vp="_featureItem_1422v_113",Cp="_checkIcon_1422v_123",Np="_learnMoreLink_1422v_127",kp="_feedbackContainer_1422v_140",Ip="_footer_1422v_146",ce={container:rp,title:ip,description:cp,sectionTitle:lp,websiteInfo:dp,favicon:up,websiteTitle:mp,websiteHost:hp,warningContent:fp,ignoreButton:pp,infoList:gp,infoItem:_p,label:yp,infoValue:xp,durationTrigger:bp,durationItem:wp,featureList:jp,featureItem:vp,checkIcon:Cp,learnMoreLink:Np,feedbackContainer:kp,footer:Ip};function Ap(e){return e instanceof G.HTTPError&&e.response.status===404}const Sp=Se.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=G.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(Ap(a))return!1;throw a}}})}),Tp=()=>{const[e,t]=y.useState(tp),[s,o]=Q.useAtom(os),[a,r]=y.useState(!1),i=Ye(),c=me(),{address:l,username:d}=Je(),{mutate:u,isPending:m}=Zd(),{closeDrawer:h}=Et();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:p,restUrl:g}=i(s.chainId),{data:_,isLoading:x,isError:w}=S.useQuery(Sp.info(g,l)),C={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},b=c.find(I=>I.chainId===s.chainId),j=b?.website?ap(b.website,window.location.hostname):!1,k=()=>{u(e)},T=()=>{s?.reject(new Error("User cancelled")),o(null),h()},L=!j&&!a,A=!x&&!w&&_===!1,M=!x&&w,N=L||x||w||_===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(dt,{className:ce.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:ce.title,children:"Enable auto-signing"}),n.jsx("p",{className:ce.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:ce.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:ce.websiteInfo,children:[n.jsx("img",{src:C.favicon,alt:"",className:ce.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:ce.websiteTitle,children:C.title}),n.jsx("div",{className:ce.websiteHost,children:C.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:ce.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:ce.infoList,children:[n.jsxs("div",{className:ce.infoItem,children:[n.jsx("div",{className:ce.label,children:"Address"}),n.jsxs("div",{className:ce.infoValue,children:[n.jsx(E.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:v.truncate(d??l)})]})]}),n.jsxs("div",{className:ce.infoItem,children:[n.jsx("div",{className:ce.label,children:"Chain"}),n.jsxs("div",{className:ce.infoValue,children:[n.jsx(ee,{src:f,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:ce.infoItem,children:[n.jsx("div",{className:ce.label,children:"Duration"}),n.jsx(Aa,{options:xc,value:e,onChange:t,classNames:{trigger:ce.durationTrigger,item:ce.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:ce.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:ce.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(I=>n.jsxs("li",{className:ce.featureItem,children:[n.jsx(E.IconCheckCircle,{size:12,className:ce.checkIcon}),n.jsx("span",{children:I})]},I))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:ce.learnMoreLink,children:["Learn more ",n.jsx(E.IconExternalLink,{size:12})]})]})]}),n.jsxs(ke,{className:ce.footer,extra:n.jsxs("div",{className:ce.feedbackContainer,children:[A&&n.jsx(ge,{level:"error",children:"Insufficient balance for fee"}),M&&n.jsx(ge,{level:"warning",children:"Unable to verify account status. Try again."}),!j&&!a&&n.jsx(ge,{level:"warning",children:n.jsxs("div",{className:ce.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:ce.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(ue.Outline,{onClick:T,children:"Cancel"}),n.jsx(ue.White,{onClick:k,disabled:N,loading:m,children:"Enable"})]})]})},Ep=()=>Q.useAtomValue(os)?n.jsx(Tp,{}):null,$p="_container_mqvhs_1",Mp="_badge_mqvhs_5",hr={container:$p,badge:Mp},wc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:D(hr.container,a),children:[o,!s&&n.jsx("div",{className:hr.badge,style:{right:t,top:t}})]})},Lp="_header_s7mee_1",qp="_back_s7mee_12",Pp="_title_s7mee_24",Mo={header:Lp,back:qp,title:Pp},Nt=({title:e,backButton:t,extra:s,children:o})=>{const a=ai();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Mo.header,children:[n.jsx(Nn,{to:t??(a.length>1?-1:"/"),className:Mo.back,shouldReset:!!t,children:n.jsx(E.IconBack,{size:16})}),n.jsx("h1",{className:Mo.title,children:e}),s]}),n.jsx(dt,{children:o})]})};function Sa(){const e=me();return t=>e.some(s=>s.chain_id===t)}function Rp(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function ds(){const e=Sa();return t=>e(t.chain_id)?"initia":t.chain_type}function Xn(e){return ds()(e)}function mo(){const e=Re(),{data:t}=S.useSuspenseQuery({queryKey:we.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:s})=>$.sortWith([$.descend(({chain_name:o})=>o==="initia"),$.ascend(({pretty_name:o})=>o)],s),staleTime:W.MINUTE});return t}function $t(){const e=mo(),t=Yr();return s=>{const o=e.find(r=>r.chain_id===s);if(o)return o;const a=t.find(r=>r.chain_id===s);if(!a)throw new Error(`Chain not found: ${s}`);return{chain_id:a.chain_id,chain_name:a.name,pretty_name:a.pretty_name,logo_uri:a.logo,chain_type:"cosmos",rpc:"",rest:""}}}function ot(e){return $t()(e)}function fr(e,t){try{return re.fromBech32(e).prefix===t}catch{return!1}}function jc(){const{initiaAddress:e,hexAddress:t}=Je(),s=$t(),o=ds();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Ta(){const e=$t(),t=ds();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return fr(s,a.bech32_prefix??"init");case"evm":return xt.isAddress(s);case"cosmos":return a.bech32_prefix?fr(s,a.bech32_prefix):!1;default:return!1}}}function Dp(){const e=$t(),t=ds();return({initialAddress:s,initialChainId:o,chainId:a,fallbackAddress:r})=>{const i=e(o),c=t(i),l=e(a),d=t(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""}}function Bp(){const e=Re();return S.useSuspenseQuery({queryKey:we.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:W.MINUTE})}function us(){const{data:{chain_to_assets_map:e}}=Bp(),t=mo(),s=S.useQueryClient();return y.useMemo(()=>{const o=[];for(const a in e){if(!t.some(i=>i.chain_id===a))continue;const{assets:r}=e[a]??{assets:[]};s.setQueryData(we.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(we.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Os(e){const t=Re(),s=S.useQueryClient(),{data:o}=S.useSuspenseQuery({queryKey:we.assets(e).queryKey,queryFn:()=>t.get("v2/fungible/assets",{searchParams:{chain_ids:e}}).json(),select:({chain_to_assets_map:a})=>{const{assets:r}=a[e]??{assets:[]};for(const i of r)s.setQueryData(we.asset(e,i.denom).queryKey,i);return r.toSorted($.descend(i=>i.symbol==="INIT"))},staleTime:W.MINUTE});return o}function vc(e){const t=Os(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function vt(e,t){return vc(t)(e)}const Fp="_root_ekn9t_1",Up="_header_ekn9t_6",Op="_title_ekn9t_12",Vp="_warning_ekn9t_18",Kp="_content_ekn9t_22",Wp="_footer_ekn9t_26",zp="_secondary_ekn9t_36",Gt={root:Fp,header:Up,title:Op,warning:Vp,content:Kp,footer:Wp,secondary:zp},Cc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(dt,{className:Gt.root,children:[n.jsxs("header",{className:D(Gt.header,t&&Gt[t]),children:[s,n.jsx("h1",{className:Gt.title,children:o})]}),n.jsx("div",{className:Gt.content,children:a}),n.jsxs("footer",{className:Gt.footer,children:[n.jsx(ue.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:Gt.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(E.IconChevronRight,{size:14})]})]})]})},Hp="_list_k4n3k_1",Qp="_row_k4n3k_9",Gp="_dt_k4n3k_20",Yp="_asset_k4n3k_26",js={list:Hp,row:Qp,dt:Gp,asset:Yp},Zp=({list:e,onNavigate:t,onDismiss:s})=>{const o=oe(),a=Ye(),r=Ct(o);return n.jsx(Cc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:js.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const u=a(c),{decimals:m,symbol:h}=r(d),f=v.formatAmount(l,{decimals:m});return n.jsxs("div",{className:js.row,children:[n.jsxs("div",{className:js.dt,children:[n.jsx(ee,{src:u.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:u.name})]}),n.jsxs("span",{className:js.asset,children:[f," ",h]})]},i)})})})};function Lo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const vs=({chainId:e,txHash:t})=>`${ie.OP_REMINDER}:${e}:${t}`,Jp=yl.atomWithStorage(ie.OP_REMINDER,[]);function Mn(){const e=te(),[t=[],s]=Q.useAtom(Jp),o=y.useMemo(()=>t.map(l=>{const d=localStorage.getItem(vs(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:u}=l;return d!==e?!1:Ge.isPast(u)}),[e,t]),a=y.useCallback((l,d)=>{t.some(u=>Lo(u,l))||(s((u=[])=>[...u,l]),localStorage.setItem(vs(l),JSON.stringify(d)))},[t,s]),r=y.useCallback(l=>{s((d=[])=>d.filter(u=>!Lo(u,l))),localStorage.removeItem(vs(l))},[s]),i=y.useCallback(l=>{const d=l.filter(u=>!t.some(m=>Lo(m,u)));d.length!==0&&s((u=[])=>[...u,...d])},[t,s]),c=y.useCallback((l,d)=>{localStorage.setItem(vs(l),JSON.stringify(d)),s((u=[])=>[...u])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Nc(){const e=Ie(),{openModal:t,closeModal:s}=no(),{reminders:o,setReminder:a}=Mn();y.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})};t({content:y.createElement(Zp,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const Xp="_wrapper_5ssm8_1",eg="_balance_5ssm8_11",tg="_button_5ssm8_15",qo={wrapper:Xp,balance:eg,button:tg},kc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:qo.wrapper,children:[n.jsx(E.IconWallet,{size:16}),n.jsx("span",{className:qo.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:qo.button,onClick:()=>e(),disabled:s,children:"MAX"})]}),ng="_fieldset_up6fh_1",sg="_upper_up6fh_9",og="_select_up6fh_14",ag="_account_up6fh_20",rg="_lower_up6fh_25",ig="_wrapper_up6fh_26",cg="_balance_up6fh_33",lg="_value_up6fh_37",dg="_error_up6fh_50",At={fieldset:ng,upper:sg,select:og,account:ag,lower:rg,wrapper:ig,balance:cg,value:lg,error:dg},Qo=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:At.fieldset,children:[n.jsxs("div",{className:At.upper,children:[n.jsx("div",{className:At.select,children:t}),n.jsx("div",{className:At.account,children:s})]}),!c&&n.jsxs("div",{className:At.lower,children:[o,n.jsxs("div",{className:At.wrapper,children:[n.jsx("div",{className:At.balance,children:a}),r&&n.jsx("div",{className:At.value,children:r})]}),i&&n.jsxs("footer",{className:At.error,children:[n.jsx(E.IconWarningFilled,{size:12}),n.jsx("p",{children:i})]})]})]})};function ms(){const e=y.useRef(null),t=io();return y.useEffect(()=>{t||e.current?.focus()},[t]),e}const ug="_input_h8073_1",mg={input:ug};function Ic(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=ms();return n.jsx(Ne.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(xl.NumericFormat,{value:l.value,getInputRef:zr.mergeRefs([l.ref,c]),className:D(mg.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const hg="_input_19r9r_1",fg="_placeholder_19r9r_18",Go={input:hg,placeholder:fg},pg=({children:e})=>n.jsx("p",{className:D(Go.input,{[Go.placeholder]:U(e).isZero()}),children:e}),es=({balance:e,decimals:t,className:s})=>{const{control:o}=Ne.useFormContext(),a={required:"Enter amount",validate:r=>U(r).isZero()?"Enter amount":U(v.toBaseUnit(r,{decimals:t})).gt(e??0)?"Insufficient balance":!0};return n.jsx(Ic,{name:"quantity",control:o,className:D(Go.input,s),rules:a})};es.ReadOnly=pg;const Sn=({title:e,content:t,children:s,className:o})=>{const[a,r]=y.useState(!1),i=()=>r(!1);return n.jsx(hc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},gg="_tooltip_19kvs_1",_g="_arrow_19kvs_44",pr={tooltip:gg,arrow:_g},hs=({label:e,children:t,small:s,...o})=>n.jsxs(Z.Tooltip.Root,{...o,children:[n.jsx(Z.Tooltip.Trigger,{asChild:!0,children:t}),n.jsx(Z.Tooltip.Portal,{container:dn(),children:n.jsxs(Z.Tooltip.Content,{className:D(pr.tooltip,{small:s}),collisionBoundary:dn(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(Z.Tooltip.Arrow,{className:pr.arrow})]})})]});function Ea(e,t){const s=Re(),o=Ta(),a=!!t&&!!e&&o(e,t);return S.useQuery({queryKey:we.balances(t,e).queryKey,queryFn:()=>s.post("v2/info/balances",{json:{chains:{[t]:{address:e,denoms:[]}}}}).json(),select:({chains:r})=>a?r?r[t].denoms??{}:{}:{},enabled:a,staleTime:W.SECOND})}function yg(e,t,s){const{data:o={}}=Ea(e,t);return $.path([s],o)}const xg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ts(e){if(!e)return;const{formattedParts:t}=xg.reduce(({remainingSeconds:s,formattedParts:o},[a,r])=>{const i=Math.floor(s/r);return{remainingSeconds:s-i*r,formattedParts:i>0?[...o,`${i}${a}`]:o}},{remainingSeconds:e,formattedParts:[]});return t.join(" ")}function Ac(e,t){return U(e).times(U(100).minus(t)).div(100).integerValue(U.ROUND_FLOOR).toFixed(0)}function $a(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${v.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Sc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,d=t.getQueryData(we.asset(a,r).queryKey);if(!d||d.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const u=d.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:v.toBaseUnit(i,{decimals:u}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function Yo(e,t){const{watch:s}=Vt(),o=s(),a=Re(),r={srcChainId:o.srcChainId,srcDenom:o.srcDenom,dstChainId:o.dstChainId,dstDenom:o.dstDenom,quantity:e},i=!r.srcChainId||!r.srcDenom||!r.dstChainId||!r.dstDenom,c=U(r.quantity||0),l=c.isFinite()&&c.gt(0),d=t?.refreshMs??1e4,u=l&&!t?.disabled&&!i,m=S.useQueryClient();return S.useQuery({queryKey:we.route(r,t?.isOpWithdraw).queryKey,queryFn:async()=>Sc(a,m,r,{isOpWithdraw:t?.isOpWithdraw}),enabled:u,staleTime:d,refetchInterval:u?d:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function bg(e){return S.useQuery({queryKey:we.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof G.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function wg(){const{watch:e}=Vt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=ot(t),i=Xn(r),c=vt(s,t),l=vt(a,o),d=oe(),u=me();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&u.find(m=>m.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const jg="_label_t93ix_1",vg="_wrapper_t93ix_7",Cg="_input_t93ix_10",Ng="_clear_t93ix_18",Cs={label:jg,wrapper:vg,input:Cg,clear:Ng},Ma=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=v.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=ms(),{control:l,getValues:d,setValue:u,formState:m}=Ne.useFormContext(),h=d("recipient"),[f,p]=y.useState(h),g=ti(),{data:_,isLoading:x,error:w}=S.useQuery({queryKey:Gs.address(g.restUrl,f).queryKey,queryFn:()=>g.getAddress(f),staleTime:W.MINUTE,enabled:g.validateUsername(f)}),C=_??(o(f)?f:""),b=t&&v.InitiaAddress.equals(C,t),j=async()=>{try{const L=await navigator.clipboard.readText();p(L.trim())}catch{}};y.useEffect(()=>{e==="onChange"&&(!f&&!m.dirtyFields.recipient||u("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[m.dirtyFields.recipient,f,e,u,_]);const k=()=>{x||w||(u("recipient",C,{shouldValidate:!0,shouldDirty:!0}),r?.())},T=()=>{if(x)return n.jsx(wn,{level:"loading",children:"Resolving username..."});if(w)return n.jsx(wn,{level:"error",children:w.message});if(_)return n.jsx(wn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!C)return n.jsx(wn,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:Cs.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(ue.Small,{type:"button",tabIndex:-1,onClick:j,children:"Paste"})]}),n.jsxs("div",{className:Cs.wrapper,children:[n.jsx(Ne.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:L=>o(L)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:D(Cs.input,"monospace"),value:f,onChange:L=>p(L.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?zr.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:Cs.clear,onClick:()=>p(""),"aria-label":"Clear recipient",children:n.jsx(E.IconCloseCircleFilled,{size:16})})]}),T(),b&&n.jsx(wn,{children:"This is my address"}),e==="onSubmit"&&n.jsx(ke,{extra:(!t||!!C&&!b)&&n.jsx(ge,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(ue.White,{type:"button",onClick:k,disabled:x||!!w||!C,children:"Apply"})})]})},kg="_scrollable_vgj3r_1",Ig="_list_vgj3r_5",Ag="_item_vgj3r_9",Sg="_name_vgj3r_22",Ns={scrollable:kg,list:Ig,item:Ag,name:Sg};function Tc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(dt,{className:Ns.scrollable,children:n.jsx("div",{className:Ns.list,children:t.map(l=>n.jsxs("button",{className:Ns.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),children:[n.jsx(ee,{src:o(l),width:28,height:28}),n.jsx("span",{className:Ns.name,children:a(l)}),i?.(l)&&n.jsx(jt,{size:16})]},r(l)))})})}function ho(){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 Tg="_account_h04x1_8",Eg="_clear_h04x1_28",$g="_white_h04x1_39",Fn={account:Tg,clear:Eg,white:$g},gr=({type:e})=>{const{watch:t,setValue:s}=Vt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=Xn(ot(a)),{list:d,find:u}=ho(),m=u(r),h=jc(),f=Ta(),p=h(a),g=v.InitiaAddress.equals(c,p),_=()=>n.jsx(Sn,{title:"Connect wallet",content:C=>n.jsx(Tc,{onSelect:async b=>{const j=b.getProvider();if(!j)return window.open(b.fallbackUrl,"_blank");const k=j.getOfflineSigner(o),[{address:T}]=await k.getAccounts();s("sender",T),s("cosmosWalletName",b.name),C()},list:d,getImage:b=>b.image,getName:b=>b.name,getKey:b=>b.name}),className:D(Fn.account,{[Fn.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[m&&n.jsx(ee,{src:m.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:v.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(E.IconChevronRight,{size:14})]})}),x=C=>n.jsx(Sn,{title:"Recipient",content:b=>n.jsx(dt,{children:n.jsx(Ma,{mode:"onSubmit",myAddress:p,chainType:l,validate:j=>f(j,a),onApply:b})}),className:Fn.account,children:C}),w=()=>{switch(l){case"initia":case"evm":return g?x(n.jsx(E.IconWallet,{size:14})):n.jsxs("div",{className:Fn.account,children:[n.jsx("span",{className:"monospace",children:v.truncate(c)}),n.jsx("button",{type:"button",className:Fn.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(E.IconCloseCircleFilled,{size:14})})]});case"cosmos":return x(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:v.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(E.IconEdit,{size:14})]}))}};switch(e){case"src":return _();case"dst":return w()}},Mg="_images_cj4xz_1",Po={images:Mg},fo=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:D(Po.images,r),style:{position:"relative"},children:[n.jsx(ee,{src:e,width:t,height:t,className:Po.asset,logo:!0}),n.jsx(ee,{src:s,width:o,height:o,className:Po.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),Lg="_root_6187w_1",qg="_content_6187w_10",Pg="_details_6187w_20",Rg="_symbol_6187w_26",Dg="_chain_6187w_34",Bg="_chevron_6187w_43",Yt={root:Lg,content:qg,details:Pg,symbol:Rg,chain:Dg,chevron:Bg},Ec=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:Yt.content,children:[n.jsx(fo,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:Yt.details,children:[n.jsx("div",{className:Yt.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:Yt.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:Yt.root,children:o}):n.jsxs("div",{className:Yt.root,children:[o,n.jsx(E.IconChevronDown,{size:16,className:Yt.chevron})]})};function Fg(e,t,s){return s.filter(o=>{const a=e.map(r=>o[r]).map(r=>String(r??"").toLowerCase());return $.any($.includes(t.toLowerCase()),a)})}const Ug="_root_1sh27_1",Og="_label_1sh27_8",Vg="_input_1sh27_21",Kg="_hasValue_1sh27_31",Wg="_clear_1sh27_35",Un={root:Ug,label:Og,input:Vg,hasValue:Kg,clear:Wg},fs=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:D(Un.root,t,{[Un.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Un.label,children:n.jsx(E.IconSearch,{size:o})}),n.jsx("input",{className:Un.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Un.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(E.IconCloseCircleFilled,{size:o})})]})},zg="_container_5tajg_1",Hg="_search_5tajg_7",Qg="_list_5tajg_11",Gg="_item_5tajg_15",Yg="_logo_5tajg_37",Zg="_info_5tajg_41",Jg="_symbol_5tajg_47",Xg="_name_5tajg_56",e_="_balance_5tajg_62",t_="_value_5tajg_69",nt={container:zg,search:Hg,list:Qg,item:Gg,logo:Yg,info:Zg,symbol:Jg,name:Xg,balance:e_,value:t_},ps=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=y.useState(""),i=Fg(["symbol"],a,t);return n.jsxs("div",{className:nt.container,children:[n.jsx(fs,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:nt.search,padding:20,ref:ms()}),i.length===0?n.jsx(_e,{children:"No assets"}):n.jsx("div",{className:nt.list,children:i.map(c=>n.jsx("button",{type:"button",className:nt.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:u,symbol:m,name:h,balance:f,decimals:p,value:g=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(ee,{src:u,width:32,height:32,className:nt.logo,logo:!0}),n.jsxs("div",{className:nt.info,children:[n.jsx("div",{className:nt.symbol,children:m||d}),n.jsx("div",{className:nt.name,children:h})]}),n.jsxs("div",{className:nt.balance,children:[f&&n.jsx("div",{children:v.formatAmount(f,{decimals:p})}),g>0&&n.jsx("div",{className:nt.value,children:X(g)})]})]})})},c.denom))})]})},n_=()=>n.jsxs("div",{className:nt.container,children:[n.jsx(fs,{rootClassName:nt.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(_e,{children:"Loading..."})]});ps.Placeholder=n_;const s_="_stack_16oqn_1",o_="_title_16oqn_9",a_="_grid_16oqn_16",r_="_item_16oqn_22",i_="_button_16oqn_26",c_="_active_16oqn_44",jn={stack:s_,title:o_,grid:a_,item:r_,button:i_,active:c_},on=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:jn.title,children:e}),n.jsx("div",{className:jn.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(wc,{offset:-2,disabled:!a?.(r),className:jn.item,children:n.jsx(hs,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button",className:D(jn.button,{[jn.active]:r===s}),onClick:()=>o(r),children:n.jsx(ee,{src:c,width:28,height:28,logo:!0})})})},r))})]}),l_=({children:e})=>n.jsx("div",{className:jn.stack,children:e});on.Stack=l_;const d_=({address:e,chain:t,onSelect:s})=>{const o=Os(t.chain_id),{data:a={}}=Ea(e,t.chain_id);return n.jsx(ps,{assets:$.sortWith([$.descend(r=>r.symbol==="INIT"),$.descend(r=>r.value),({balance:r="0"},{balance:i="0"})=>U(i).comparedTo(r)??0,$.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})},u_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Ot(),i=mo(),{watch:c,setValue:l}=Vt(),d=c(a),u=c(s),m=c(o),[h,f]=y.useState(u),p=ot(h),g=Dp(),_=Sa(),[x,w]=$.partition(b=>_(b.chain_id),i.filter(b=>!b.hidden)),C=b=>{if(u===h&&m===b){t();return}l(s,h),l(o,b),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(on.Stack,{children:[n.jsx(on,{label:"Interwoven Economy",chains:x.map(({chain_id:b,chain_name:j,pretty_name:k,logo_uri:T})=>({chainId:b,name:k||j,logoUrl:T??""})),value:h,onSelect:f}),n.jsx(on,{label:"Chains",chains:w.map(({chain_id:b,chain_name:j,pretty_name:k,logo_uri:T})=>({chainId:b,name:k||j,logoUrl:T??""})),value:h,onSelect:f})]}),n.jsx(pe,{suspenseFallback:n.jsx(ps.Placeholder,{}),children:n.jsx(d_,{address:g({initialAddress:d,initialChainId:u,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:p,onSelect:C})},h)]})},_r=({type:e})=>{const t=e==="src"?"srcChainId":"dstChainId",s=e==="src"?"srcDenom":"dstDenom",o=e==="src"?"Select source chain and asset":"Select destination chain and asset",{watch:a}=Vt(),r=a(t),i=a(s),c=ot(r),l=vt(i,r);return n.jsx(Sn,{title:o,content:d=>n.jsx(u_,{type:e,afterSelect:d}),children:n.jsx(Ec,{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??""}})})},m_="_skeleton_1l4jn_1",h_={skeleton:m_},an=({width:e="100%",height:t})=>n.jsx("div",{className:h_.skeleton,style:{width:e,height:t}}),f_="_stack_oq1ir_1",p_="_button_oq1ir_6",g_="_isLoading_oq1ir_19",__="_disabled_oq1ir_19",y_="_checked_oq1ir_23",x_="_header_oq1ir_37",b_="_title_oq1ir_43",w_="_duration_oq1ir_52",j_="_warning_oq1ir_62",v_="_amount_oq1ir_66",C_="_value_oq1ir_67",tt={stack:f_,button:p_,isLoading:g_,disabled:__,checked:y_,header:x_,title:b_,duration:w_,warning:j_,amount:v_,value:C_},N_=({children:e})=>n.jsx("div",{className:tt.stack,children:e}),$s=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Vt(),{dstChainId:l,dstDenom:d}=c(),u=vt(d,l),m=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:D(tt.button,{[tt.isLoading]:i,[tt.disabled]:h,[tt.checked]:m}),onClick:()=>{i||h||o(s)},children:[n.jsxs("div",{className:tt.header,children:[n.jsxs("div",{className:tt.title,children:[n.jsx("span",{children:e}),m&&n.jsx(E.IconCheck,{size:14})]}),i?n.jsx(an,{width:80,height:16}):r?n.jsxs("div",{className:D(tt.duration,{[tt.warning]:s==="op"}),children:[n.jsx(E.IconClockFilled,{size:12}),n.jsx("span",{children:ts(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:tt.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:tt.amount,children:i?n.jsx(an,{width:260,height:40}):r?v.formatAmount(r.amount_out,{decimals:u.decimals}):null}),n.jsx("div",{className:tt.value,children:i?n.jsx(an,{width:120,height:16}):r?r.usd_amount_out?X(r.usd_amount_out):"$-":null})]})]})};$s.Stack=N_;const k_="_description_nuyvt_1",I_="_presets_nuyvt_8",A_="_preset_nuyvt_8",S_="_active_nuyvt_29",T_="_custom_nuyvt_40",E_="_wrapper_nuyvt_47",$_="_percent_nuyvt_58",gt={description:k_,presets:I_,preset:A_,active:S_,custom:T_,wrapper:E_,percent:$_},yr=["0.1","0.5","1.0"],M_=({afterConfirm:e})=>{const t=Vt(),s=t.getValues("slippagePercent"),[o,a]=y.useState(null),{control:r,watch:i,getValues:c,setValue:l}=Ne.useForm({defaultValues:{value:s}}),d=i("value");y.useEffect(()=>{const g=yr.findIndex(_=>_===s);a(g>=0?g:null)},[s]);const u=(g,_)=>{l("value",g),a(_)},m=()=>{a(null)},h=y.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})=>{t.setValue("slippagePercent",g),e()};return n.jsxs(dt,{children:[n.jsx("p",{className:gt.description,children:"Slippage is how much price movement you can tolerate between the time you send out a transaction and the time it's executed."}),n.jsxs("div",{className:gt.presets,children:[yr.map((g,_)=>n.jsxs("button",{type:"button",className:D(gt.preset,{[gt.active]:o===_}),onClick:()=>u(g,_),children:[g,"%"]},g)),o!==null?n.jsx("button",{type:"button",className:D(gt.preset,gt.custom),onClick:()=>a(null),children:"Custom"}):n.jsxs("div",{className:gt.wrapper,children:[n.jsx(Ic,{name:"value",control:r,dp:2,onFocus:m,placeholder:"",className:D(gt.preset,gt.active)}),n.jsx("span",{className:gt.percent,children:"%"})]})]}),h&&n.jsx(ge,{level:h.type,children:h.text}),n.jsx(ke,{children:n.jsx(ue.White,{type:"button",onClick:()=>p(c()),disabled:f,children:"Confirm"})})]})},L_="_form_1owk5_1",q_="_arrow_1owk5_5",P_="_divider_1owk5_14",R_="_flip_1owk5_23",D_="_meta_1owk5_41",B_="_row_1owk5_54",F_="_title_1owk5_60",U_="_description_1owk5_64",O_="_icon_1owk5_71",V_="_edit_1owk5_76",K_="_warning_1owk5_99",Be={form:L_,arrow:q_,divider:P_,flip:R_,meta:D_,row:B_,title:F_,description:U_,icon:O_,edit:V_,warning:K_};function W_({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}const z_=()=>{const e=Ie(),t=io(),s=Tn(),[o,a]=y.useState(void 0),[r,i]=y.useState(!1),[c,l]=We.useLocalStorage(ie.BRIDGE_ROUTE_TYPE,"default"),{watch:d,setValue:u,handleSubmit:m,formState:h}=Vt(),f=d(),{srcChainId:p,srcDenom:g,dstChainId:_,dstDenom:x,quantity:w,sender:C,slippagePercent:b}=f,j=Ye(),k=oe(),T=ot(p),L=Xn(T),A=ot(_),M=Xn(A),N=vt(g,p),I=vt(x,_),{data:F}=Ea(C,p),q=yg(C,p,g),P=!q?.amount||U(q.amount).isZero(),[B]=We.useDebounceValue(w,300),H=p===_,z=H&&p===k.chainId,le=W_({isLayer1Swap:z,isL2Swap:H&&L==="initia"&&!z}),ye=L!=="initia"&&M!=="initia",he=wg(),xe=Yo(B,{disabled:ye,refreshMs:le}),be=Yo(B,{isOpWithdraw:!0,disabled:!he,refreshMs:le}),De=he&&c==="op",ut=De?be:xe,Mt=De?xe:be,mt=De?!ye:he,Te=ut.error&&mt?Mt:ut,{data:O,isLoading:Ee,error:ae}=Te,{data:Le}=bg(ae),Ln=B&&Ee&&!r,qn=()=>{u("srcChainId",_),u("srcDenom",x),u("dstChainId",p),u("dstDenom",g),u("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:fn,closeModal:pn}=no(),Pn=m(async ne=>{a(void 0),i(!0);let qe,Rn;try{const ft=await Te.refetch();if(ft.error||!ft.data||!ft.dataUpdatedAt){a(ft.error instanceof Error?ft.error.message:"Failed to refresh route. Please try again.");return}qe=ft.data,Rn=ft.dataUpdatedAt}finally{i(!1)}if(s("Bridge Simulation Success",{quantity:ne.quantity,srcChainId:ne.srcChainId,srcDenom:ne.srcDenom,dstChainId:ne.dstChainId,dstDenom:ne.dstDenom}),qe.warning){const{type:ft="",message:ul}=qe.warning??{};fn({content:n.jsx(Cc,{type:"warning",icon:n.jsx(E.IconWarningFilled,{size:40}),title:zs.sentenceCase(ft),primaryButton:{label:"Cancel",onClick:pn},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:qe,values:ne,quoteVerifiedAt:Rn}),pn()}},children:n.jsx("p",{className:Be.warning,children:ul})})});return}e("/bridge/preview",{route:qe,values:ne,quoteVerifiedAt:Rn})}),ht=y.useMemo(()=>O?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_DEDUCTED")??[],[O]),ze=y.useMemo(()=>O?.estimated_fees?.filter(({fee_behavior:ne})=>ne==="FEE_BEHAVIOR_ADDITIONAL")??[],[O]),at=y.useMemo(()=>{for(const ne of ze){const qe=F?.[ne.origin_asset.denom]?.amount??"0",Rn=O?.source_asset_denom===ne.origin_asset.denom?O.amount_in:"0";if(U(qe).lt(U(Rn).plus(ne.amount??"0")))return`Insufficient ${ne.origin_asset.symbol} for fees`}},[F,O,ze]),ve=y.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!B)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(!O)return"Route not found";if(at)return at},[B,at,h,O,f]),Wt=O?v.formatAmount(O.amount_out,{decimals:I.decimals}):"0",zt=U(w).gt(0)&&U(w).isEqualTo(v.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),dl=(()=>{switch(L){case"initia":return j(p).fees.fee_tokens.some(({denom:ne})=>ne===g);case"cosmos":return T.fee_assets.some(({denom:ne})=>ne===g);case"evm":return!xt.isAddress(g);default:return!1}})(),xo=y.useCallback((ne,qe)=>ne.length?n.jsxs("div",{className:Be.description,children:[$a(ne),!t&&n.jsx(hs,{label:qe,children:n.jsx("span",{className:Be.icon,children:n.jsx(E.IconInfoFilled,{size:12})})})]}):null,[t]),_s=U(w).gt(0)&&he&&xe.data&&be.data&&be.data.estimated_route_duration_seconds>xe.data.estimated_route_duration_seconds,Va=y.useMemo(()=>{if(!O)return[];const ne=Ac(O.amount_out,b);return[{condition:!!O.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[xo(ht,"Fee deducted from the amount you receive"),xo(ze,"Fee charged in addition to the amount you enter")]})},{condition:!_s&&!!ts(O.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Be.description,children:ts(O.estimated_route_duration_seconds)})},{condition:O.does_swap,title:"Slippage",content:n.jsxs("span",{className:Be.description,children:[n.jsxs("span",{children:[b,"%"]}),n.jsx(Sn,{title:"Slippage tolerance",content:qe=>n.jsx(M_,{afterConfirm:qe}),className:Be.edit,children:n.jsx(E.IconSettingFilled,{size:12})})]})},{condition:O.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Be.description,children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol,width:12,height:12}),v.formatAmount(ne,{decimals:I.decimals})," ",I.symbol]})}].filter(qe=>qe.condition)},[ze,ht,I,xo,O,_s,b]);return n.jsxs("form",{className:Be.form,onSubmit:Pn,children:[n.jsx(Qo,{selectButton:n.jsx(_r,{type:"src"}),accountButton:L==="cosmos"&&n.jsx(gr,{type:"src"}),quantityInput:n.jsx(es,{balance:q?.amount,decimals:N?.decimals}),balanceButton:n.jsx(kc,{onClick:()=>u("quantity",v.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:P,children:v.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:O?X(O.usd_amount_in):"$-"}),n.jsxs("div",{className:Be.arrow,children:[n.jsx("div",{className:Be.divider}),n.jsx("button",{type:"button",className:Be.flip,onClick:()=>qn(),children:n.jsx(E.IconChevronDown,{size:16})})]}),n.jsx(Qo,{selectButton:n.jsx(_r,{type:"dst"}),accountButton:n.jsx(gr,{type:"dst"}),quantityInput:n.jsx(es.ReadOnly,{children:Wt}),value:O?X(O.usd_amount_out):"$-",hideNumbers:_s}),n.jsx(Jn,{children:_s?n.jsxs($s.Stack,{children:[n.jsx($s,{label:"Fast",query:xe,value:"default",onSelect:l,checked:c==="default"}),n.jsx($s,{label:"Lossless",query:be,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(ke,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(ge.Stack,{children:[o&&n.jsx(ge,{level:"error",children:o}),O?.extra_infos?.map(ne=>n.jsx(ge,{level:"info",children:ne},ne)),Le&&n.jsx(ge,{level:"info",children:Le}),zt&&dl&&n.jsx(ge,{level:"warning",children:"Make sure to leave enough for transaction fee"}),O?.warning&&n.jsx(ge,{level:"warning",children:O.warning.message}),O?.extra_warnings?.map(ne=>n.jsx(ge,{level:"warning",children:ne},ne))]}),n.jsx(Jn,{children:Va.length>0&&n.jsx("div",{className:Be.meta,children:Va.map((ne,qe)=>n.jsxs("div",{className:Be.row,children:[n.jsx("span",{className:Be.title,children:ne.title}),ne.content]},qe))})})]}),children:n.jsx(ue.White,{loading:r?"Refreshing route...":Ln&&"Simulating...",disabled:!!ve||r,children:ve??"Preview route"})})]})},H_=()=>{Nc();const e=ai(),t=Ie(),s=Ot(),o=gm(),a=Ne.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:u,quantity:m,slippagePercent:h,recipient:f}=r();r((I,{name:F})=>{(F==="srcChainId"||F==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const p=jc(),g=p(c),_=p(l),w=Ta()(f,l);y.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",g)},[c,g,i]),y.useEffect(()=>{w||i("recipient",_)},[_,w,i]);const{showNotification:C}=uo(),b=ot(c),j=ot(l),k=Os(c),T=Os(l),L=k.some(I=>I.denom===d),A=T.some(I=>I.denom===u);y.useEffect(()=>{k.length>0&&!L&&(i("srcDenom",k[0].denom),C({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${b.pretty_name}.`,autoHide:!0}))},[k,L,i,C,b.pretty_name]),y.useEffect(()=>{T.length>0&&!A&&(i("dstDenom",T[0].denom),C({type:"info",title:`Switched to ${T[0].symbol}`,description:`The selected asset is not available on ${j.pretty_name}.`,autoHide:!0}))},[T,A,i,C,j.pretty_name]),y.useEffect(()=>{!L||!A||(localStorage.setItem(ie.BRIDGE_SRC_CHAIN_ID,c),localStorage.setItem(ie.BRIDGE_SRC_DENOM,d),localStorage.setItem(ie.BRIDGE_DST_CHAIN_ID,l),localStorage.setItem(ie.BRIDGE_DST_DENOM,u),localStorage.setItem(ie.BRIDGE_QUANTITY,m),localStorage.setItem(ie.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,u,m,h,L,A]);const M=e[0].path==="/bridge",{reminders:N}=Mn();return n.jsx(Nt,{title:"Bridge/Swap",backButton:M?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(ue.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12",children:[n.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(wc,{offset:0,disabled:N.length===0,children:n.jsx(ue.Small,{onClick:()=>t("/op/withdrawals"),disabled:!s,children:n.jsx("span",{children:"Withdrawal status"})})})]}),children:L&&A&&n.jsx(Ne.FormProvider,{...a,children:n.jsx(pe,{children:n.jsx(z_,{})})})})},Q_="_button_1crvp_1",G_="_checkbox_1crvp_11",Y_="_checked_1crvp_25",ks={button:Q_,checkbox:G_,checked:Y_},Z_=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:D(ks.button,o),onClick:t,children:[n.jsx("div",{className:D(ks.checkbox,{[ks.checked]:e}),children:e&&n.jsx(E.IconCheck,{size:12})}),n.jsx("span",{className:ks.label,children:s})]}),J_="_button_aoxv2_1",X_={button:J_},$c=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=bl.useInView();return y.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:X_.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(E.IconChevronDown,{size:12})]})};function Mc(e,t){return e.reduce((s,o)=>{const a=t(o);if(!a)return s;const r=a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),i=s[r]||[];return{...s,[r]:[...i,o]}},{})}const Ms=({chainId:e,txHash:t})=>`${ie.BRIDGE_HISTORY}:${e}:${t}`,Vs=100,xr=10;function Lc(){const[e,t]=We.useLocalStorage(ie.BRIDGE_HISTORY,[]),s=y.useCallback((a,r)=>{localStorage.setItem(Ms(a),JSON.stringify(r));for(const i of e.slice(Vs-1))localStorage.removeItem(Ms(i));t((i=[])=>[a,...i.slice(0,Vs-1)])},[e,t]),o=y.useCallback(a=>{const r=localStorage.getItem(Ms(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function qc(e){return We.useLocalStorage(Ms(e),null)}const hn=Se.createQueryKeys("interwovenkit:op",{bridge:e=>[e],withdrawals:(e,t)=>[e,t],latestOutput:e=>[e],output:(e,t)=>[e,t],outputResponse:(e,t)=>[e,t],withdrawalClaimed:(e,t)=>[e,t]});function po(){const{restUrl:e}=oe();return y.useMemo(()=>G.create({prefixUrl:e}),[e])}function ey(e){const t=po(),{data:s}=S.useSuspenseQuery({queryKey:hn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:W.INFINITY});return s}const br=20;function ty(e){const t=te();return S.useSuspenseInfiniteQuery({queryKey:hn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:br,offset:s,order:"desc"},{withdrawals:a}=await G.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=$.last(s)?.sequence;return s.length<br||!o||o<=1?null:o-1},initialPageParam:0,staleTime:W.SECOND})}function ny(e){const t=po(),{data:s}=S.useSuspenseQuery({queryKey:hn.latestOutput(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}/outputs`,{searchParams:{"pagination.reverse":!0,"pagination.limit":1}}).json(),select:({output_proposals:o})=>{const[a]=o;return a||null},staleTime:W.SECOND});return s}function sy({bridge_id:e,output_index:t}){const s=po(),{data:o}=S.useSuspenseQuery({queryKey:hn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:W.SECOND});return o}function oy({bridge_id:e,sequence:t}){const o=me().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=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:c}=S.useSuspenseQuery({queryKey:hn.outputResponse(i,t).queryKey,queryFn:()=>G.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:W.SECOND});return c}function Pc(e,t){const{bridge_id:s}=e,o=po(),{data:a}=S.useSuspenseQuery({queryKey:hn.withdrawalClaimed(s,t).queryKey,queryFn:()=>o.get(`opinit/ophost/v1/bridges/${s}/withdrawals/claimed/by_hash`,{searchParams:{withdrawal_hash:t}}).json(),select:({claimed:r})=>r,staleTime:({state:{data:r}})=>r?.claimed?1/0:W.SECOND});return a}function On(e){return wl.sha3_256.create().update(e).digest()}function Ro(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function Rc(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Ro(t.toString(),8),c=Ro(s.toString(),8),l=Ro(o.amount,8),d=tn.concatBytes(i,c,On(tn.utf8ToBytes(a)),On(tn.utf8ToBytes(r)),On(tn.utf8ToBytes(o.denom)),l);return On(On(d))}async function ay(e,t,s){try{return await G.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function ry(e,t){const s=G.create({prefixUrl:t}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Zo(e,t){const{chain_type:s,chain_id:o,chain_name:a,evm_fee_asset:r,rpc:i}=t;if(s!=="evm")throw new Error(`Chain is not an EVM chain: ${a}`);try{await e.send("wallet_switchEthereumChain",[{chainId:`0x${Number(o).toString(16)}`}])}catch(c){if($.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 kt(){return Ze()}function iy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Ie(),{showNotification:r,updateNotification:i,hideNotification:c}=uo(),{addHistoryItem:l}=Lc(),d=Tn(),{route:u,values:m}=kt(),{srcChainId:h,sender:f,recipient:p,cosmosWalletName:g}=m,_=Ii(),{requestTxSync:x,submitTxSync:w,waitForTxConfirmation:C}=Je(),{find:b}=ho(),j=as(),k=rs(),T=ot(h),L=Xn(T),A=vc(h),M=S.useQueryClient(),{registryUrl:N}=se(),I=Ye(),F=oe(),{addReminder:q}=Mn(),P=Re();return S.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const B=e.cosmos_tx.msgs.map(({msg_type_url:Te,msg:O})=>{if(!(Te&&O))throw new Error("Invalid transaction data");return k.fromAmino({type:rn.aminoConverters[Te].aminoType,value:JSON.parse(O)})});if(L==="initia"){const{srcDenom:Te,quantity:O}=m,{decimals:Ee}=A(Te),ae=s?await w({messages:B,chainId:h,fee:s}):await x({messages:B,chainId:h,internal:1,spendCoins:[{denom:Te,amount:v.toBaseUnit(O,{decimals:Ee})}]}),Le=C({txHash:ae,chainId:h});return{txHash:ae,wait:Le}}const H=b(g)?.getProvider();if(!H)throw new Error("Wallet not connected");const z=H.getOfflineSignerOnlyAmino(h),K=await Ae.SigningStargateClient.connectWithSigner(T.rpc,z,{registry:j,aminoTypes:k}),le=await K.getAllBalances(f),ye=T.fee_assets.find(Te=>le.some(O=>O.denom===Te.denom&&U(O.amount).gt(0)));if(!ye){const O=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(Ee=>A(Ee.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(O)}const{denom:he,gas_price:xe}=ye;if(!xe)throw new Error(`Gas price not found for ${he}`);const be=await K.simulate(f,B,""),De=Ae.GasPrice.fromString(xe.average+he),ut=Ae.calculateFee(Math.ceil(be*cn),De),Mt=await K.signAndBroadcastSync(f,B,ut),mt=Ui({txHash:Mt,client:K});return{txHash:Mt,wait:mt}}if("evm_tx"in e){const{chain_id:B,to:H,value:z,data:K}=e.evm_tx,le=await _(),ye=await le.getSigner();await Zo(le,T);const he=await ye.sendTransaction({chainId:B,to:H,value:z,data:`0x${K}`});return{txHash:he.hash,wait:he.wait()}}throw new Error("Unlisted chain type")}catch(B){throw await wt(B)}},onSuccess:async({txHash:B,wait:H})=>{localStorage.removeItem(ie.BRIDGE_QUANTITY),M.removeQueries({queryKey:we.route._def}),M.removeQueries({queryKey:we.routeErrorInfo._def}),o?o({txhash:B,chainId:h,timestamp:Date.now(),success:!0,route:u,values:m}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await H;const z=go(u)==="OP Bridge withdrawal",K=z?{success:!0,error:null}:await my(P,B,h);if(!o&&!K.success&&K.error){const be=K.error instanceof Error?K.error.message:String(K.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${be}. The transaction may still be processing.`,autoHide:!0})}const le=K.success,he=dy({txHash:B,srcChainId:h,route:u,values:m,recipient:p},le);l(he.tx,he.details),o||i(ly(c));const xe=Do(m,B);if(d("Bridge Transaction Success",xe),z){const be=I(h).metadata?.op_bridge_id;if(be&&!await ay(F.restUrl,Number(be),u.dest_asset_denom)){const ut=uy(he.tx,u,p);q(he.tx,ut)}}}catch(z){const K=z instanceof Error?z.message:String(z);o?o({success:!1,error:K,route:u,values:m}):i({type:"error",title:"Transaction not confirmed",description:K});const le={...Do(m,B),error:K};d("Bridge Confirmation Failed",le)}finally{M.invalidateQueries({queryKey:we.balances(h,f).queryKey})}},onError:async B=>{const H=L==="initia"?await bn(B,I(h),N):B;o?o({success:!1,error:H.message,route:u,values:m}):r({type:"error",title:"Transaction failed",description:H.message});const z=Do(m);d("Bridge Transaction Failed",{...z,error:H.message})}})}function cy(){const e=Re(),t=te(),s=Ni(),{route:o,values:a}=kt(),r=$t();return S.useMutation({mutationFn:async()=>{try{const{chain_id:i,hook:c}=await e.post("op-hook",{json:{source_address:t,source_asset_chain_id:o.source_asset_chain_id,source_asset_denom:o.source_asset_denom,dest_address:v.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await ry(t,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:m,msg:h})=>rn.aminoTypes.fromAmino({type:rn.aminoConverters[m].aminoType,value:JSON.parse(h)})),d=await s(i,t,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),u=He.Tx.fromPartial({body:He.TxBody.decode(d.bodyBytes),authInfo:He.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:re.toBase64(He.Tx.encode(u).finish())}}catch(i){throw await wt(i)}}})}function ly(e){return{type:"info",title:"Transaction submitted",description:y.createElement(y.Fragment,null,"Check ",y.createElement(Nn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function Do(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function dy(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=go(a)==="OP Bridge withdrawal";return{tx:i,details:{...i,timestamp:Date.now(),route:a,values:r,state:c?"success":void 0,tracked:t},isOpWithdraw:c}}function uy(e,t,s){return{...e,recipient:v.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function my(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await wt(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Dc(e){const{chainId:t,txHash:s,tracked:o}=e,a=Re();return S.useQuery({queryKey:we.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await wt(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:W.INFINITY,enabled:!o})}function Bc(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=Re();return S.useQuery({queryKey:we.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=t+e.route.estimated_route_duration_seconds*1e3,u=Date.now(),m=Math.floor((d-u)/1e3);return m<=0?1e3:m<=300?5e3:60*1e3},staleTime:W.INFINITY})}var zn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(zn||{});function go(e){const{operations:t,dest_asset_denom:s}=e;return $.has("op_init_transfer",$.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const hy="_success_t4dfk_1",fy="_error_t4dfk_5",wr={success:hy,error:fy},py=({tx:e})=>{const[t,s]=qc(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=Bc(t),a=t.state??gy(o);switch(y.useEffect(()=>{a!=="loading"&&s(r=>{if(!r)throw new Error("Bridge history details not found");return{...r,tracked:!0,state:a}})},[s,a]),a){case"error":return n.jsx("div",{className:wr.error,children:n.jsx(E.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:wr.success,children:n.jsx(E.IconCheckCircleFilled,{size:14})});default:return n.jsx(jt,{size:14})}};function gy(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 _y="_link_104m3_1",yy="_header_104m3_23",xy="_title_104m3_31",by="_date_104m3_37",wy="_explorer_104m3_41",jy="_fees_104m3_57",vy="_label_104m3_65",Cy="_content_104m3_69",Ny="_route_104m3_75",ky="_row_104m3_80",Iy="_asset_104m3_86",Ay="_amount_104m3_94",Sy="_chain_104m3_99",Ty="_account_104m3_108",Ey="_arrow_104m3_115",$e={link:_y,header:yy,title:xy,date:by,explorer:wy,fees:jy,label:vy,content:Cy,route:Ny,row:ky,asset:Iy,amount:Ay,chain:Sy,account:Ty,arrow:Ey},$y=({tx:e})=>{const[t,s]=qc(e);if(!t)throw new Error("Bridge history details not found");const{chainId:o,txHash:a,route:r,values:i,timestamp:c,tracked:l}=t,{data:d}=Dc(t),{address:u="",connector:m}=Ke.useAccount(),{find:h}=ho();y.useEffect(()=>{d&&s(P=>{if(!P)throw new Error("Bridge history details not found");return{...P,tracked:!0}})},[s,d]);const{amount_in:f,amount_out:p,source_asset_chain_id:g,source_asset_denom:_,dest_asset_chain_id:x,dest_asset_denom:w,estimated_fees:C=[]}=r,b=ot(g),j=ot(x),k=vt(_,g),T=vt(w,x),L=(P,B)=>B?n.jsx(ee,{src:B,width:12,height:12}):v.InitiaAddress.equals(P,u)?n.jsx(ee,{src:m?.icon,width:12,height:12}):n.jsx(E.IconWallet,{size:12}),A=(P,{symbol:B,decimals:H,logo_uri:z},{chain_name:K,pretty_name:le,...ye},he,xe)=>n.jsxs("div",{className:$e.row,children:[n.jsx(fo,{assetLogoUrl:z,chainLogoUrl:ye.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:$e.asset,children:[n.jsx("span",{className:$e.amount,children:v.formatAmount(P,{decimals:H})}),n.jsx("span",{children:B})]}),n.jsxs("div",{className:$e.chain,children:[n.jsxs("span",{children:["on ",le||K]}),n.jsxs("div",{className:$e.account,children:[xe,n.jsx("span",{className:"monospace",children:v.truncate(he)})]})]})]})]}),M=go(r),N=y.useMemo(()=>{switch(M){case zn.SKIP:return"Skip Explorer";case zn.OP_WITHDRAW:return"Initia Scan"}},[M]),I=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:$e.header,children:[n.jsxs("div",{className:$e.title,children:[l?n.jsx(py,{tx:e}):n.jsx(jt,{size:14}),n.jsx("div",{className:$e.date,children:Ge.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:$e.explorer,children:[n.jsx("span",{children:N}),n.jsx(E.IconExternalLink,{size:12})]})]}),n.jsxs("div",{className:$e.route,children:[A(f,k,b,i.sender,L(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:$e.arrow,children:n.jsx(E.IconArrowDown,{size:12})}),A(p,T,j,i.recipient,L(i.recipient))]}),C.length>0&&n.jsxs("div",{className:$e.fees,children:[n.jsx("span",{className:$e.label,children:"Fees"}),n.jsx("span",{className:$e.content,children:$a(C)})]})]});if(M===zn.OP_WITHDRAW)return n.jsx(lo,{chainId:o,txHash:a,className:$e.link,children:I});const F=new URLSearchParams({tx_hash:a,chain_id:o}),q=new URL(`?${F.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:q.toString(),className:$e.link,target:"_blank",children:I})},My="_history_13u9z_1",Ly="_header_13u9z_5",qy="_checkbox_13u9z_9",Py="_groups_13u9z_13",Ry="_dateGroup_13u9z_21",Dy="_dateHeader_13u9z_26",By="_list_13u9z_32",Zt={history:My,header:Ly,checkbox:qy,groups:Py,dateGroup:Ry,dateHeader:Dy,list:By},Fy=()=>{const{initiaAddress:e,hexAddress:t}=Je(),{history:s,getHistoryDetails:o}=Lc(),a=s.filter(f=>o(f)),r=a.filter(f=>{const p=o(f);if(!p)return!1;const{values:g}=p,{sender:_,recipient:x}=g;return[_,x].some(w=>[e,t].includes(w))}),[i,c]=y.useState(1),[l,d]=We.useToggle(!r.length),u=l?a:r,m=u.slice(0,i*xr),h=y.useMemo(()=>Mc(m,f=>{const p=o(f);if(p)return new Date(p.timestamp)}),[m,o]);return n.jsx(Nt,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:Zt.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:Zt.header,children:n.jsx(Z_,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:Zt.checkbox})}),u.length===0?n.jsx(_e,{children:"No bridge/swap activity"}):n.jsx("div",{className:Zt.groups,children:Object.entries(h).map(([f,p])=>n.jsxs("div",{className:Zt.dateGroup,children:[n.jsx("div",{className:Zt.dateHeader,children:f}),n.jsx("div",{className:Zt.list,children:p.map(g=>n.jsx(pe,{children:n.jsx($y,{tx:g})},g.txHash))})]},f))}),u.length>i*xr?n.jsx($c,{onClick:()=>c(f=>f+1)}):s.length>=Vs&&n.jsxs(_e,{children:["Only the latest ",Vs," items are stored. Older entries will be removed automatically."]})]})})};function Fc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Uy({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Fc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function Oy({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Fc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const Vy=1e4;function Jo(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Jo).join(",")}]`:`{${Object.entries(e).toSorted(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${Jo(s)}`).join(",")}}`}function jr(e){return Jo({amount_in:e.amount_in,amount_out:e.amount_out,usd_amount_in:e.usd_amount_in,usd_amount_out:e.usd_amount_out,operations:e.operations,estimated_fees:e.estimated_fees,estimated_route_duration_seconds:e.estimated_route_duration_seconds,warning:e.warning,extra_infos:e.extra_infos,extra_warnings:e.extra_warnings,required_op_hook:e.required_op_hook})}function Ky(e,t,s){const o=Ie(),a=Ze(),r=S.useQueryClient(),i=Re(),[c,l]=y.useState(!1),[d,u]=y.useState(void 0),[m,h]=y.useState(s??0),f=y.useRef(null);return y.useEffect(()=>{h(s??0)},[s]),y.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const g=Math.max(s??0,m);if(Date.now()-g<=Vy)return!1;l(!0),u(void 0);const _=new AbortController;f.current=_;try{const x=await Sc(i,r,t,{isOpWithdraw:go(e)===zn.OP_WITHDRAW,signal:_.signal});if(_.signal.aborted)return!0;const w=jr(x)!==jr(e),C=Date.now();return w?(o(0,Uy({currentState:a,route:x,values:t,quoteVerifiedAt:C})),!0):(h(C),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||_.signal.aborted||u((await wt(x)).message),!0}finally{f.current===_&&(f.current=null),_.signal.aborted||l(!1)}},isRefreshing:c,refreshError:d,clearRefreshError:()=>u(void 0)}}function Wy(e,t){return t?"Confirm updated route":e||"Confirm"}const La=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a})=>{const r=Ie(),i=Ze(),{route:c,values:l,quoteVerifiedAt:d,requiresReconfirm:u}=kt(),{mutate:m,isPending:h}=iy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:f,isRefreshing:p,refreshError:g,clearRefreshError:_}=Ky(c,l,d),x=async()=>{if(!(h||p)){if(u){r(0,Oy({currentState:i,route:c,values:l,quoteVerifiedAt:d??Date.now()}));return}await f()||(_(),m())}},w=a??g??(u?"Route updated. Please review and confirm again.":void 0);return n.jsx(ke,{extra:w&&n.jsx(ge,{level:a||g?"error":"info",children:w}),children:n.jsx(ue.White,{onClick:x,loading:p?"Refreshing route...":h&&"Signing transaction...",disabled:!!a,children:Wy(o,!!u)})})},zy="_content_1hzj2_1",Hy="_info_1hzj2_6",Qy="_arrow_1hzj2_11",Gy="_divider_1hzj2_19",Yy="_type_1hzj2_27",Zy="_asset_1hzj2_47",Jy="_amount_1hzj2_55",Xy="_lower_1hzj2_60",ex="_chain_1hzj2_66",tx="_address_1hzj2_72",et={content:zy,info:Hy,arrow:Qy,divider:Gy,type:Yy,asset:Zy,amount:Jy,lower:Xy,chain:ex,address:tx},Uc=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=v.truncate(a),decimals:d=0,logo_uri:u=ca}=e,{chain_name:m,pretty_name:h,...f}=ot(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:et.arrow,children:[n.jsx("div",{className:et.divider}),s?n.jsx(hs,{label:s,children:n.jsx("button",{className:et.type,children:n.jsx(E.IconArrowDown,{size:12})})}):n.jsx("span",{className:et.type,children:n.jsx(E.IconArrowDown,{size:12})}),n.jsx("div",{className:et.divider})]}),n.jsxs("div",{className:et.content,children:[n.jsx(fo,{assetLogoUrl:u,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:et.info,children:[n.jsxs("div",{className:et.asset,children:[n.jsx("span",{className:et.amount,children:v.formatAmount(o,{decimals:d})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:et.lower,children:[n.jsxs("div",{className:et.chain,children:["on ",h||m]}),i&&n.jsx(Fs,{value:i,children:({copy:p,copied:g})=>n.jsxs("button",{className:et.address,onClick:p,children:[c,g?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:v.truncate(i)})]})})]})]})]})]})},vn=e=>{const t=vt(e.denom,e.chainId);return n.jsx(Uc,{...e,...t})};vn.Placeholder=Uc;const nx="_root_1hbar_1",sx="_flexEnd_1hbar_6",ox="_toggle_1hbar_11",ax="_route_1hbar_36",rx="_content_1hbar_43",Vn={root:nx,flexEnd:sx,toggle:ox,route:ax,content:rx};function ix(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":zs.capitalCase($.head(s?.split("-")??[])??"");if("transfer"in e)return{label:"Bridge via IBC",...e,...e.transfer};if("bank_send"in e)return{label:"Send",...e,...e.bank_send};if("swap"in e){const s=e.swap?.swap_venues?.map(t).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.swap}}if("axelar_transfer"in e)return{label:"Bridge via Axelar",...e,...e.axelar_transfer};if("cctp_transfer"in e)return{label:"Bridge via CCTP",...e,...e.cctp_transfer};if("hyperlane_transfer"in e)return{label:"Bridge via Hyperlane",...e,...e.hyperlane_transfer};if("evm_swap"in e){const s=e.evm_swap?.swap_venues?.map(t).join(", ");return{label:s?`Swap on ${s}`:"Swap",...e,...e.evm_swap}}if("op_init_transfer"in e)return{label:"Bridge via OP Bridge",...e,...e.op_init_transfer};if("go_fast_transfer"in e)return{label:"Bridge via Go Fast",...e,...e.go_fast_transfer};if("eureka_transfer"in e)return{label:"Bridge via Eureka",...e,...e.eureka_transfer};if("stargate_transfer"in e)return{label:"Bridge via Stargate",...e,...e.stargate_transfer};if("layer_zero_transfer"in e)return{label:"Bridge via LayerZero",...e,...e.layer_zero_transfer};throw new Error("Unknown operation type")}const cx=({addressList:e})=>{const{values:t,route:s}=kt(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=$.zipObj(s.required_chain_addresses,e),{find:l}=ho(),{connector:d,address:u=""}=Ke.useAccount(),[m,h]=We.useToggle(!1),f=i.length>1,p=n.jsx(ee,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:d?.icon,width:12,height:12}),g={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:p},_=j=>v.InitiaAddress.equals(j,u)?p:n.jsx(E.IconWallet,{size:11}),x=j=>{const{label:k,amount_out:T,denom:L,denom_out:A=L,chain_id:M,from_chain_id:N,to_chain_id:I=M??N}=j,F=c[I];return{label:f&&!m?void 0:k,amount:T,denom:A,chainId:I,address:F,walletIcon:_(F)}},w=i.map(ix).map(x),C=w.slice(0,-1),b=w[w.length-1];return n.jsxs(Z.Collapsible.Root,{className:Vn.root,open:m,onOpenChange:h,children:[f&&n.jsx("div",{className:Vn.flexEnd,children:n.jsx(Z.Collapsible.Trigger,{className:Vn.toggle,children:m?n.jsxs(n.Fragment,{children:[n.jsx(E.IconMinus,{size:12}),n.jsx("span",{children:"Hide details"})]}):n.jsxs(n.Fragment,{children:[n.jsx(E.IconList,{size:12}),n.jsx("span",{children:"Show details"})]})})}),n.jsxs("div",{className:Vn.route,children:[n.jsx(vn,{...g,source:!0}),n.jsx(Z.Collapsible.Content,{className:Vn.content,children:C.map((j,k)=>n.jsx(pe,{suspenseFallback:n.jsx(vn.Placeholder,{...j}),errorBoundaryProps:{fallback:n.jsx(vn.Placeholder,{...j})},children:n.jsx(vn,{...j})},k))}),n.jsx(vn,{...b})]})]})},Oc=({error:e})=>{const t=Ie();return n.jsx(ke,{extra:n.jsx(ge,{level:"error",children:e.message}),children:n.jsx(ue.White,{onClick:()=>t("/bridge"),children:"Home"})})},Vc=({children:e})=>{const t=kt(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:u}=Je(),m=is(),h=$t(),f=ds(),p=h(r),g=f(p),_=a.slice(0,-1).some(T=>{const L=h(T);return f(L)==="cosmos"})&&g!=="cosmos",[x,w]=y.useState(void 0),[C,b]=y.useState(!1),[j,k]=y.useState(null);if(y.useEffect(()=>{(async()=>{try{if(!_)return;if(!m)throw new Error("Wallet not connected");b(!0),k(null);const[{pubkey:L}]=await m.getAccounts();w(L)}catch(L){k(await wt(L))}finally{b(!1)}})()},[_,m]),j)return n.jsx(Oc,{error:j});if(C)return n.jsx(ke,{children:n.jsx(ue.White,{loading:C&&"Generating intermediary addresses..."})});if(!_||x){const T=a.map((L,A)=>{if(A===a.length-1){const q=h(i);return f(q)==="initia"?v.InitiaAddress(l).bech32:l}const M=h(L),N=f(M),I=h(r),F=f(I);switch(N){case"initia":return d;case"evm":return u;case"cosmos":{if(F==="cosmos")return re.toBech32(M.bech32_prefix,re.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return Qn.pubkeyToAddress(Qn.encodeSecp256k1Pubkey(x),M.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(T)}return null},qa=({tx:e,children:t})=>{const s=Ii(),o=$t(),{data:a,isLoading:r}=S.useQuery({queryKey:["interwovenkit:erc20-approvals-needed",e],queryFn:async()=>{if(!("evm_tx"in e))return[];if(!e.evm_tx.required_erc20_approvals)return[];const{chain_id:u,signer_address:m}=e.evm_tx,h=await s();await Zo(h,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:_,spender:x}=g,C=await new xt.ethers.Contract(_,f,h).allowance(m,x);return{approval:g,currentAllowance:BigInt(C.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}=S.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!a||a.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,m=await s(),h=await m.getSigner();await Zo(m,o(u));for(const f of a){const{token_contract:p,spender:g,amount:_}=f,x=["function approve(address spender, uint256 amount) external returns (bool)"];await(await new xt.ethers.Contract(p,x,h).approve(g,_)).wait()}return!0}catch(u){throw await wt(u)}}});return r?n.jsx(ke,{children:n.jsx(ue.White,{loading:"Checking approvals..."})}):a&&a.length>0&&!c?n.jsx(ke,{extra:n.jsx(ge,{level:"error",children:d?.message}),children:n.jsx(ue.White,{onClick:()=>i(),loading:l&&"Approving tokens...",children:"Approve tokens"})}):t},Kc=({addressList:e,signedOpHook:t,children:s})=>{const o=Re(),{route:a,values:r}=kt(),[i,c]=y.useState(void 0),[l,d]=y.useState(!1),[u,m]=y.useState(null),h=JSON.stringify(e),f=JSON.stringify(a.operations),p=JSON.stringify(t??null),g=y.useMemo(()=>e,[h]),_=y.useMemo(()=>a.operations,[f]),x=y.useMemo(()=>t,[p]);return y.useEffect(()=>{let w=!1;return(async()=>{try{if(a.required_op_hook&&!x)throw new Error("Op hook is required");d(!0),m(null);const b={address_list:g,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:_,signed_op_hook:x},{txs:j}=await o.post("v2/fungible/msgs",{json:b}).json();if(w)return;if(!j||j.length===0)throw new Error("No transaction data found");const[k]=j;c(k)}catch(b){if(w)return;m(b)}finally{w||d(!1)}})(),()=>{w=!0}},[g,_,x,a.amount_in,a.amount_out,a.source_asset_chain_id,a.source_asset_denom,a.dest_asset_chain_id,a.dest_asset_denom,a.required_op_hook,r.slippagePercent,o]),u?n.jsx(Oc,{error:u}):l||!i?n.jsx(ke,{children:n.jsx(ue.White,{loading:"Fetching messages..."})}):s(i)},Wc=({children:e})=>{const{route:t}=kt(),s=cy();return t.required_op_hook&&!s.data?n.jsx(ke,{extra:n.jsx(ge,{level:"error",children:s.error?.message}),children:n.jsx(ue.White,{onClick:()=>s.mutate(),loading:s.isPending&&"Awaiting signature...",children:"Authorize conversion"})}):e(s.data)},lx=()=>n.jsx(Nt,{title:"Route preview",children:n.jsx(Vc,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(cx,{addressList:e}),n.jsx(Wc,{children:t=>n.jsx(Kc,{addressList:e,signedOpHook:t,children:s=>n.jsx(qa,{tx:s,children:n.jsx(La,{tx:s})})})})]})})}),zc=y.createContext(null);function _o(){return y.useContext(zc)}const dx="_button_17r1o_1",ux="_claimed_17r1o_24",vr={button:dx,claimed:ux},mx=()=>{const{withdrawalTx:e}=_o(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,u=oe(),m=te(),{requestTxSync:h,waitForTxConfirmation:f}=Je(),p=oy(e),g=re.toBase64(Rc(e)),_=Pc(e,g),x=S.useQueryClient(),{mutate:w,isPending:C}=S.useMutation({mutationFn:async()=>{if(!p)throw new Error("Output not found");const{last_block_hash:b}=p;return h({chainId:u.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:m,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(re.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:re.fromBase64(d),storageRoot:re.fromBase64(i),lastBlockHash:re.fromBase64(b)}}],internal:!0})},onSuccess:async b=>{await f({chainId:u.chain_id,txHash:b}),x.invalidateQueries({queryKey:hn.withdrawalClaimed(t,g).queryKey})}});return _?n.jsxs("div",{className:vr.claimed,children:[n.jsx(E.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:vr.button,onClick:()=>w(),disabled:C,children:"Claim"})},hx=({children:e})=>{const{withdrawalTx:t}=_o(),s=ey(t.bridge_id),o=sy(t),a=y.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)},Hc=1e3,fx=60,px=60,gx=24,Xo=Hc*fx,ea=Xo*px,Cr=ea*gx,_x=({date:e})=>{const t=y.useCallback(()=>{const d=new Date().getTime(),m=e.getTime()-d;if(m<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(m/Cr),f=Math.floor(m%Cr/ea),p=Math.floor(m%ea/Xo),g=Math.floor(m%Xo/Hc);return{days:h,hours:f,minutes:p,seconds:g}},[e]),[s,o]=y.useState(t());y.useEffect(()=>{const d=window.setInterval(()=>{o(t())},1e3);return()=>window.clearInterval(d)},[t,e]);const a=d=>d.toString().padStart(2,"0"),{days:r,hours:i,minutes:c,seconds:l}=s;return n.jsx(hs,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},yx="_container_1lz3w_1",xx="_title_1lz3w_5",Nr={container:yx,title:xx},bx=({date:e})=>n.jsxs("div",{className:Nr.container,children:[n.jsx("div",{className:Nr.title,children:"Claimable in"}),n.jsx(_x,{date:e})]}),wx="_container_1oldz_1",jx="_icon_1oldz_7",kr={container:wx,icon:jx},vx="Withdrawal will begin within an hour",Ir=()=>{const e=io();return n.jsxs("div",{className:kr.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(hs,{label:vx,children:n.jsx("span",{className:kr.icon,children:n.jsx(E.IconInfoFilled,{size:12})})})]})},Cx=({children:e})=>{const{withdrawalTx:t}=_o(),s=ny(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},Nx=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=_o(),a=re.toBase64(Rc(o)),r=Pc(o,a),{setReminder:i,removeReminder:c}=Mn();return y.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:Ge.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},kx=()=>n.jsx(Cx,{children:e=>e?n.jsx(Ir,{}):n.jsx(hx,{children:t=>t?n.jsx(Nx,{date:t,children:Ge.isFuture(t)?n.jsx(bx,{date:t}):n.jsx(mx,{})}):n.jsx(Ir,{})})}),Ix="_asset_6h8u2_1",Ax="_info_6h8u2_7",Sx="_symbol_6h8u2_11",Bo={asset:Ix,info:Ax,symbol:Sx},Tx=({amount:e,denom:t})=>{const s=oe(),o=Xr(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:Bo.asset,children:[n.jsx(ee,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:Bo.info,children:[n.jsx("span",{className:"monospace",children:v.formatAmount(e,{decimals:i})}),n.jsx("span",{className:Bo.symbol,children:a})]})]})},Ex="_item_km5w2_1",$x={item:Ex},Mx=({chain:e})=>{const t=e.metadata?.executor_uri;if(!t)throw new Error("Executor URL is not defined");const{data:s,fetchNextPage:o,hasNextPage:a,isFetching:r}=ty(t),i=y.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Mn();return y.useEffect(()=>{const l=i.map(d=>({chainId:e.chainId,txHash:d.tx_hash}));c(l)},[e.chainId,i,c]),i.length?n.jsxs(n.Fragment,{children:[i.map(l=>{const{amount:d}=l;return n.jsxs("div",{className:$x.item,children:[n.jsx(Tx,{...d}),n.jsx(pe,{suspenseFallback:null,children:n.jsx(zc.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(kx,{})})})]},l.sequence)}),a&&n.jsx($c,{onClick:()=>o(),disabled:r})]}):n.jsx(_e,{children:"No withdrawals"})},Lx="_content_dj1qm_1",qx="_title_dj1qm_5",Ar={content:Lx,title:qx},Px=()=>{const{chainId:e}=Ze(),t=me(),s=un(),[o,a]=y.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Ye(),{reminders:i}=Mn(),c=o?r(o):void 0;return n.jsxs(Nt,{title:"OP Bridge withdrawals",children:[n.jsx(on,{chains:t.filter(({metadata:l})=>!l?.is_l1&&l?.op_denoms?.length),value:o,onSelect:a,getShowIndicator:l=>i.some(d=>d.chainId===l)}),n.jsx("div",{className:Ar.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Ar.title,children:c.name}),n.jsx(pe,{children:n.jsx(Mx,{chain:c})},o)]}):n.jsx(ge,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},Ks=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Rx="5722e7dffb709492cf5312446ceeff73",Dx=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Rx}`,Qc=["interwovenkit:walletconnect-wallets"],Bx=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",Gc=async e=>{const t=await G.get(Dx,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(Bx)},Fx=()=>S.useQuery({queryKey:Qc,queryFn:({signal:e})=>Gc(e),staleTime:W.INFINITY,gcTime:W.INFINITY,retry:2}),Ux="_page_13y8q_1",Ox="_pageTop_13y8q_19",Vx="_backButtonFixed_13y8q_63",Kx="_listItem_13y8q_64",Wx="_socialButton_13y8q_65",zx="_arrowIcon_13y8q_66",Hx="_searchInputUnderline_13y8q_67",Qx="_header_13y8q_72",Gx="_title_13y8q_81",Yx="_headerSpacer_13y8q_116",Zx="_icon_13y8q_120",Jx="_installedText_13y8q_124",Xx="_divider_13y8q_131",e1="_dividerText_13y8q_152",t1="_loading_13y8q_193",n1="_socialIcons_13y8q_198",s1="_socialText_13y8q_204",o1="_searchWrapper_13y8q_214",a1="_scrollable_13y8q_248",r1="_list_13y8q_64",i1="_listIconWrapper_13y8q_332",c1="_moreIconSmall_13y8q_342",l1="_externalLinkIcon_13y8q_364",d1="_listName_13y8q_368",u1="_listNameMuted_13y8q_381",m1="_recentBadge_13y8q_394",h1="_learnMoreLink_13y8q_408",V={page:Ux,pageTop:Ox,backButtonFixed:Vx,listItem:Kx,socialButton:Wx,arrowIcon:zx,searchInputUnderline:Hx,header:Qx,title:Gx,headerSpacer:Yx,icon:Zx,installedText:Jx,divider:Xx,dividerText:e1,loading:t1,socialIcons:n1,socialText:s1,searchWrapper:o1,scrollable:a1,list:r1,listIconWrapper:i1,moreIconSmall:c1,externalLinkIcon:l1,listName:d1,listNameMuted:u1,recentBadge:m1,learnMoreLink:h1},f1=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},p1=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=y.useState(""),{data:l=[],isError:d,isLoading:u,isFetching:m}=Fx(),h=u||m&&l.length===0,f=y.useMemo(()=>{if(!i)return e;const g=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(g))},[e,i]),p=y.useMemo(()=>{const g=new Set(e.map(x=>Ks(x.name))),_=i.toLowerCase();return l.filter(x=>!g.has(Ks(x.name))).filter(x=>!i||x.name.toLowerCase().includes(_)).sort((x,w)=>x.name.localeCompare(w.name))},[l,e,i]);return n.jsxs("div",{className:V.pageTop,children:[n.jsx("button",{type:"button",className:V.backButtonFixed,onClick:r,"aria-label":"Back",children:n.jsx(E.IconBack,{size:16,"aria-hidden":"true"})}),n.jsxs("header",{className:V.header,children:[n.jsx("div",{className:V.headerSpacer}),n.jsx("h1",{className:V.title,children:"All Wallets"}),n.jsx("div",{className:V.headerSpacer})]}),n.jsx("div",{className:V.searchWrapper,children:n.jsx(fs,{rootClassName:V.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:g=>c(g.target.value),onClear:()=>c("")})}),n.jsx(dt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[f.map(g=>{const{name:_,icon:x,id:w}=g,C=o===w,b=s===w,j="ready"in g?!!g.ready:!0;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:b}),onClick:()=>a(g),disabled:t||!j,"aria-busy":b,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(ee,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:_}),b?n.jsx(jt,{size:16}):C?n.jsx("span",{className:V.recentBadge,children:"Recent"}):j?n.jsx("span",{className:V.installedText,children:"Installed"}):null]},`connector:${w}`)}),h&&n.jsxs("div",{className:D(V.listItem,V.loading),role:"status","aria-live":"polite",children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(jt,{size:16})}),n.jsx("span",{className:V.listNameMuted,children:"Loading more wallets..."})]}),p.map(g=>{const _=g.image_url?.sm||g.image_url?.md||g.image_url?.lg,x=_&&f1(_)?_:void 0;return n.jsxs("button",{type:"button",className:V.listItem,disabled:!0,"aria-label":`${g.name} (not installed)`,children:[n.jsx("div",{className:V.listIconWrapper,children:x&&n.jsx(ee,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:g.name})]},`wc:${g.id}`)}),d&&n.jsx(ge,{level:"error",children:"Couldn't load additional wallets."})]})})]})},g1=()=>n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:[n.jsx("circle",{cx:"4",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"8",cy:"8",r:"1.5"}),n.jsx("circle",{cx:"12",cy:"8",r:"1.5"})]}),_1=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24","aria-hidden":"true",children:[n.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),n.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),n.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),n.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),y1=()=>n.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:n.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),x1=()=>n.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[n.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),n.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),b1=[{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"}],w1=({walletConnectors:e,privyConnector:t,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),u=new Set(l.map(p=>p.id)),m=new Set(l.map(p=>Ks(p.name))),h=Math.max(0,5-d.length),f=b1.filter(p=>!u.has(p.id)&&!m.has(Ks(p.name))).slice(0,h);return n.jsxs("div",{className:V.page,children:[n.jsxs("header",{className:V.header,children:[n.jsx("div",{className:V.headerSpacer}),n.jsx("h1",{className:V.title,children:"Sign In"}),n.jsx("div",{className:V.headerSpacer})]}),t&&n.jsxs(n.Fragment,{children:[n.jsxs("button",{type:"button",className:D(V.socialButton,{[V.loading]:o===t.id}),onClick:()=>r(t),disabled:s,"aria-busy":o===t.id,children:[n.jsx("span",{className:V.socialText,children:"Email / Socials"}),o===t.id?n.jsx(jt,{size:16}):n.jsxs("div",{className:V.socialIcons,children:[n.jsx(_1,{}),n.jsx(x1,{}),n.jsx(y1,{})]})]}),n.jsx("div",{className:V.divider,children:n.jsx("span",{className:V.dividerText,children:"or"})})]}),n.jsx(dt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[d.map(p=>{const{name:g,icon:_,id:x}=p,w=o===x,C=a===x;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:w}),onClick:()=>r(p),disabled:s,"aria-busy":w,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(ee,{src:_,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:g}),w?n.jsx(jt,{size:16}):C?n.jsx("span",{className:V.recentBadge,children:"Recent"}):n.jsx("span",{className:V.installedText,children:"Installed"})]},x)}),f.map(p=>n.jsxs("a",{className:V.listItem,href:p.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${p.name} (opens in new tab)`,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(ee,{src:p.icon,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:p.name}),n.jsx(E.IconExternalLink,{size:10,className:V.externalLinkIcon,"aria-hidden":"true"})]},p.id)),n.jsxs("button",{type:"button",className:V.listItem,onClick:i,onMouseEnter:c,onFocus:c,disabled:s,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx("div",{className:V.moreIconSmall,children:n.jsx(g1,{})})}),n.jsx("span",{className:V.listNameMuted,children:"More wallets"}),n.jsx("span",{className:V.arrowIcon,"aria-hidden":"true",children:"→"})]})]})}),n.jsxs("a",{className:V.learnMoreLink,href:"https://docs.initia.xyz/home/tools/wallet",target:"_blank",rel:"noopener noreferrer","aria-label":"Learn more (opens in new tab)",children:["Learn more",n.jsx(E.IconExternalLink,{size:14,"aria-hidden":"true"})]})]})},Sr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=Ke.useConnect(),o=We.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=y.useState(null),[i,c]=y.useState("signin"),l=S.useQueryClient(),d=()=>l.prefetchQuery({queryKey:Qc,queryFn:({signal:g})=>Gc(g),staleTime:W.INFINITY,gcTime:W.INFINITY}),{mutate:u,isPending:m}=S.useMutation({mutationFn:async g=>{try{await s({connector:g})}catch(_){throw await wt(_)}},onMutate:g=>{r(g.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=y.useMemo(()=>[...t].sort((g,_)=>g.id===o?-1:_.id===o?1:g.name.localeCompare(_.name)),[t,o]),f=y.useMemo(()=>h.find(g=>g.id===Gn.id),[h]),p=y.useMemo(()=>h.filter(g=>g.id!==Gn.id),[h]);return i==="all"?n.jsx(p1,{walletConnectors:p,isPending:m,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onBack:()=>c("signin")}):n.jsx(w1,{walletConnectors:p,privyConnector:f,isPending:m,pendingConnectorId:a,recentConnectorId:o,onConnect:u,onShowAll:()=>c("all"),onPrefetchWallets:d})},j1="iUSD",v1={[j1]:{sourceSymbol:"USDC",extraExternalOptions:[{chainId:"1",denom:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Tr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function C1(e){return v1[e]}function Er(e){return e.pretty_name||e.chain_name}function $r(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const N1={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbol:"",localSymbol:""},k1={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 gs(e){return k1[e]}function I1(){const e=Re(),{data:t,error:s}=S.useQuery({queryKey:we.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),select:({chains:o})=>o.filter(({chain_type:a,bech32_prefix:r})=>a==="evm"||a==="cosmos"&&r==="init"),staleTime:W.MINUTE});return{chains:t??[],error:s}}function Pa(){const e=Re(),t=$n(),s=te(),{chains:o,error:a}=I1(),r=y.useMemo(()=>o.map(({chain_id:d})=>d),[o]),{data:i,error:c,isLoading:l}=S.useQuery({queryKey:we.allBalances(r,[t,s]).queryKey,queryFn:()=>{const d=Object.fromEntries(o.map(u=>[u.chain_id,{address:u.chain_type==="evm"?t:s,denoms:[]}]));return e.post("v2/info/balances",{json:{chains:d}}).json()},select:({chains:d})=>d?Object.fromEntries(Object.entries(d).map(([u,{denoms:m}])=>[u,m||{}])):{},enabled:!!s&&r.length>0,staleTime:W.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Ra(){const{localOptions:e=[]}=Ze(),t=S.useQueryClient(),s=Re(),{data:o,isLoading:a}=S.useQuery({queryKey:we.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:W.MINUTE});return{data:y.useMemo(()=>{if(o){const i=Object.values(o.chain_to_assets_map).flatMap(l=>l?.assets??[]),c=new Map(i.map(l=>[`${l.chain_id}:${l.denom}`,l]));return e.map(({denom:l,chainId:d})=>{const u=c.get(`${d}:${l}`);return{denom:l,chain_id:d,symbol:u?.symbol??"",logo_uri:u?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData(kn.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Da(e){const{local:t}=gs(e),s=us(),{watch:o}=Kt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function A1(e){const{external:t}=gs(e),s=us(),{watch:o}=Kt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function Yc(e){const t=us(),s=mo(),o=$t(),a=Sa(),{data:r,isLoading:i}=Pa(),{remoteOptions:c=[]}=Ze(),l=Da(e);if(!l)return{...N1,isLoading:i};const d=C1(l.symbol),u=d?.sourceSymbol??l.symbol,m=c.length>0,h=d?.extraExternalOptions??[],f=d?.extraInitiaSourceSymbols??[],p=d?.externalChainListSource??"supported-assets",g=new Map(s.map(j=>[j.chain_id,j])),_=t.filter(({symbol:j,denom:k,chain_id:T})=>{if(m)return c.some(F=>Tr(F,T,k));const L=h.some(F=>Tr(F,T,k)),A=g.get(T),M=!!A&&a(A.chain_id)&&f.includes(j),N=L||M;return j===l.symbol||N}).map(j=>{if(j.hidden||j.chain_id===l.chain_id)return null;const k=o(j.chain_id);if(!k||!$r(k))return null;const T=r?.[k.chain_id]?.[j.denom];return{asset:j,chain:k,balance:T}}).filter(j=>j!==null),x=_.filter(({balance:j})=>e!=="deposit"||!!j&&Number(j.amount)>0),w=new Map;if(p==="extra-options")for(const{chainId:j}of h){const k=g.get(j);k&&$r(k)&&(a(k.chain_id)||w.set(k.chain_id,k))}else for(const{chain:j}of x)a(j.chain_id)||w.set(j.chain_id,j);const C=Array.from(w.values()).sort((j,k)=>Er(j).localeCompare(Er(k))),b=[...new Set(_.filter(({chain:j})=>Rp(j,a)).map(({asset:j})=>j.symbol))];return{data:x,isLoading:i,supportedExternalChains:C,appchainSourceSymbols:b,externalSourceSymbol:u,localSymbol:l.symbol}}function Kt(){return Ne.useFormContext()}const S1="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",T1="data:image/svg+xml,%3csvg%20width='158'%20height='106'%20viewBox='0%200%20158%20106'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42.7784%2037.4101C41.9166%2033.983%2043.9856%2030.4147%2047.3994%2029.4401L107.924%2012.1584C111.338%2011.1837%20114.804%2013.1716%20115.666%2016.5984L125.999%2057.6943C126.861%2061.1211%20124.792%2064.6894%20121.378%2065.6644L60.8535%2082.9461C57.4397%2083.9207%2053.9737%2081.9328%2053.1119%2078.5057L42.7784%2037.4101Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M39.217%2031.714C39.217%2028.1816%2042.0964%2025.3179%2045.6482%2025.3179H122.821C126.373%2025.3179%20129.252%2028.1816%20129.252%2031.714V85.0155C129.252%2088.5479%20126.373%2091.4116%20122.821%2091.4116H45.6482C42.0964%2091.4116%2039.217%2088.5479%2039.217%2085.0155V31.714Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M47.7915%2037.0445C47.7915%2035.2783%2049.2312%2033.8464%2051.007%2033.8464H117.461C119.237%2033.8464%20120.677%2035.2783%20120.677%2037.0445V79.6854C120.677%2081.4519%20119.237%2082.8837%20117.461%2082.8837H51.007C49.2312%2082.8837%2047.7915%2081.4519%2047.7915%2079.6854V37.0445Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M91.7373%2056.2323C91.7373%2052.6999%2094.6167%2049.8362%2098.1682%2049.8362H131.395C131.987%2049.8362%20132.467%2050.3136%20132.467%2050.9024V65.8267C132.467%2066.4155%20131.987%2066.8927%20131.395%2066.8927H98.1682C94.6167%2066.8927%2091.7373%2064.0289%2091.7373%2060.4965V56.2323Z'%20fill='%23F1F3F5'/%3e%3cpath%20d='M102.455%2058.3646C102.455%2060.1308%20101.016%2061.5626%2099.2399%2061.5626C97.4641%2061.5626%2096.0244%2060.1308%2096.0244%2058.3646C96.0244%2056.5984%2097.4641%2055.1665%2099.2399%2055.1665C101.016%2055.1665%20102.455%2056.5984%20102.455%2058.3646Z'%20fill='%239EA0A2'/%3e%3cpath%20d='M63.8692%2031.714C63.8692%2043.4892%2054.2717%2053.0347%2042.4325%2053.0347C30.5931%2053.0347%2020.9956%2043.4892%2020.9956%2031.714C20.9956%2019.9391%2030.5931%2010.3936%2042.4325%2010.3936C54.2717%2010.3936%2063.8692%2019.9391%2063.8692%2031.714Z'%20fill='%23E9EBED'/%3e%3cpath%20d='M44.9546%2034.2225C44.9546%2035.6079%2043.8254%2036.7308%2042.4327%2036.7308C41.0398%2036.7308%2039.9106%2035.6079%2039.9106%2034.2225V20.4267C39.9106%2019.0416%2041.0398%2017.9187%2042.4327%2017.9187C43.8254%2017.9187%2044.9546%2019.0416%2044.9546%2020.4267V34.2225Z'%20fill='%23797D81'/%3e%3cpath%20d='M44.9541%2043.0015C44.9541%2044.3866%2043.8249%2045.5095%2042.432%2045.5095C41.0393%2045.5095%2039.9102%2044.3866%2039.9102%2043.0015C39.9102%2041.6161%2041.0393%2040.4932%2042.432%2040.4932C43.8249%2040.4932%2044.9541%2041.6161%2044.9541%2043.0015Z'%20fill='%23797D81'/%3e%3c/svg%3e";function Zc(e){return e.length===0?"":e.length===1?e[0]:e.length===2?`${e[0]} or ${e[1]}`:`${e.slice(0,-1).join(", ")}, or ${e[e.length-1]}`}function E1(e,t,s){const o=[...new Set(e)],a=[],r=[s,t];for(const c of r)o.includes(c)&&!a.includes(c)&&a.push(c);const i=o.filter(c=>!a.includes(c)).toSorted((c,l)=>c.localeCompare(l));return[...a,...i]}function $1(e,t,s){if(!e.length)return"";const o=E1(e,t,s);return o.length===1&&o[0]===t?"from any appchain":`using ${Zc(o)} from any appchain`}function M1({localSymbol:e,externalSourceSymbol:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=Zc(s),c=$1(o,e,t),l=!!c,d=t!==e;if(r&&l){const u=d?`using ${t} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${u}, or ${c}.`}}return r?d?{title:a,description:`You can deposit ${e} using ${t} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:l?{title:a,description:`You can deposit ${e} ${c}.`}:{title:a,description:"No deposit sources are currently available."}}const L1="_container_pjkfr_1",q1="_title_pjkfr_5",P1="_close_pjkfr_12",R1="_emptyIcon_pjkfr_24",D1="_empty_pjkfr_24",B1="_emptyDescription_pjkfr_39",F1="_list_pjkfr_60",U1="_asset_pjkfr_75",O1="_placeholder_pjkfr_91",V1="_activeAsset_pjkfr_104",K1="_iconContainer_pjkfr_108",W1="_assetIcon_pjkfr_118",z1="_chainIcon_pjkfr_128",H1="_assetPlaceholder_pjkfr_142",Q1="_assetName_pjkfr_163",G1="_assetChain_pjkfr_178",Y1="_balance_pjkfr_186",Z1="_value_pjkfr_195",fe={container:L1,title:q1,close:P1,emptyIcon:R1,empty:D1,emptyDescription:B1,list:F1,asset:U1,placeholder:O1,activeAsset:V1,iconContainer:K1,assetIcon:W1,chainIcon:z1,assetPlaceholder:H1,assetName:Q1,assetChain:G1,balance:Y1,value:Z1},J1=({mode:e})=>{const{external:t}=gs(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbol:i,localSymbol:c}=Yc(e),{setValue:l,watch:d}=Kt(),u=Da(e),{data:m}=Ra(),{theme:h}=se(),f=d(),p=f[t.denomKey],g=f[t.chainIdKey],_=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"",x=y.useEffectEvent(()=>{if(!_)return;const[{asset:C,chain:b}]=s;if(p===C.denom&&g===b.chain_id){l("page","fields");return}l(t.denomKey,C.denom),l(t.chainIdKey,b.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")});y.useEffect(()=>{x()},[_]);function w(){const C=p&&g;return!C&&m.length<=1&&e==="deposit"?null:n.jsx("button",{className:fe.close,onClick:()=>{e==="withdraw"||C?l("page","fields"):l("page","select-local")},children:n.jsx(E.IconBack,{size:20})})}if(!u)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const C=a.map(k=>k.pretty_name||k.chain_name).filter(k=>!!k),b=M1({localSymbol:c,externalSourceSymbol:i,externalChainNames:C,appchainSourceSymbols:r}),j=e==="withdraw"?`No supported destinations to withdraw ${u.symbol}.`:b.title;return n.jsxs("div",{className:fe.container,children:[w(),n.jsx("h4",{className:fe.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?S1:T1,alt:"No assets",className:fe.emptyIcon}),n.jsx("p",{className:fe.empty,children:j}),e==="deposit"&&n.jsx("p",{className:fe.emptyDescription,children:b.description})]})}return n.jsxs("div",{className:fe.container,children:[w(),n.jsxs("h4",{className:fe.title,children:[e==="withdraw"?"Select destination":`Deposit ${u.symbol}`," "]}),n.jsxs("div",{className:fe.list,children:[o&&Array.from({length:5}).map((C,b)=>n.jsxs("div",{className:D(fe.asset,fe.placeholder),children:[n.jsxs("div",{className:fe.iconContainer,children:[n.jsx("div",{className:fe.assetIcon}),n.jsx("div",{className:fe.chainIcon})]}),n.jsx("div",{className:fe.assetPlaceholder})]},b)),!o&&s.sort(({balance:C},{balance:b})=>Number(b?.value_usd??0)-Number(C?.value_usd??0)).map(({asset:C,chain:b,balance:j})=>{const k=p===C.denom&&g===b.chain_id;return n.jsxs("button",{className:D(fe.asset,k&&fe.activeAsset),onClick:()=>{l(t.denomKey,C.denom),l(t.chainIdKey,b.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")},children:[n.jsxs("div",{className:fe.iconContainer,children:[n.jsx("img",{src:C.logo_uri,alt:C.symbol,className:fe.assetIcon}),n.jsx("img",{src:b.logo_uri||"",alt:b.chain_name,className:fe.chainIcon})]}),n.jsxs("p",{className:fe.assetName,children:[C.symbol," ",k&&n.jsx("span",{children:n.jsx(E.IconCheck,{size:16})})]}),n.jsxs("p",{className:fe.assetChain,children:["on ",b.pretty_name]}),j&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:fe.balance,children:v.formatAmount(j.amount,{decimals:j.decimals||6})}),n.jsx("p",{className:fe.value,children:X(j.value_usd||0)})]})]},`${C.chain_id}-${C.denom}`)})]})]})},X1="_title_iequo_1",e0="_list_iequo_7",t0="_asset_iequo_15",n0="_imgPlaceholder_iequo_40",Is={title:X1,list:e0,asset:t0,imgPlaceholder:n0},s0=({mode:e})=>{const{local:t,external:s}=gs(e),{setValue:o}=Kt(),{data:a,isLoading:r}=Ra(),[i,c]=y.useTransition(),l=(u,m)=>{o(t.denomKey,u),o(t.chainIdKey,m),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},d=y.useEffectEvent(()=>{const{denom:u,chain_id:m}=a[0];l(u,m)});return y.useEffect(()=>{!r&&a.length===1&&d()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:Is.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:Is.list,"aria-busy":i,children:a.map(({denom:u,chain_id:m,symbol:h,logo_uri:f})=>n.jsxs("button",{className:Is.asset,onClick:()=>l(u,m),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:Is.imgPlaceholder,"aria-hidden":"true"}),h]},`${u}-${m}`))})]}):n.jsx("div",{children:"No assets found"})},o0="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",a0="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",r0="_container_9k4hs_1",i0="_title_9k4hs_8",c0="_subtitle_9k4hs_14",l0="_linkContainer_9k4hs_30",d0="_link_9k4hs_30",u0="_separator_9k4hs_51",m0="_errorIcon_9k4hs_62",h0="_error_9k4hs_62",Me={container:r0,title:i0,subtitle:c0,linkContainer:l0,link:d0,separator:u0,errorIcon:m0,error:h0};function f0(e){if(!e)return"pending";const t=e.state;return t==="STATE_COMPLETED_SUCCESS"?"success":t==="STATE_ABANDONED"||t==="STATE_COMPLETED_ERROR"||t==="STATE_PENDING_ERROR"?"failed":"pending"}function ta({type:e}){const{closeModal:t}=En(),{theme:s}=se(),{watch:o}=Kt(),{result:a}=o(),{openDrawer:r}=Et();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:u,values:m}=a,{srcDenom:h,srcChainId:f,quantity:p}=m,g=vt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:x}=Dc({chainId:l,txHash:c,tracked:!1}),{data:w}=Bc({chainId:l,txHash:c,tracked:!!x,timestamp:d,route:u}),C=f0(w),b=s==="dark"?o0:a0,j=`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 n.jsxs("div",{className:Me.container,children:[n.jsxs("h3",{className:Me.title,children:[_," failed"]}),n.jsx("img",{src:b,alt:"Failed",className:Me.errorIcon}),n.jsx("p",{className:Me.error,children:a?.error}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]});const T=ts(u.estimated_route_duration_seconds),L=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${L.toString()}`,"https://explorer.skip.build"),M=()=>n.jsxs("div",{className:Me.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:Me.link,children:"View transaction"}),n.jsx("div",{className:Me.separator}),n.jsx("button",{className:Me.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:Me.container,children:[C==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Me.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",p," ",g.symbol]}),n.jsx("video",{src:j,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:Me.subtitle,children:["Estimated time: ",n.jsx("span",{children:T})]}),M(),n.jsx("p",{className:Me.subtitle,children:"Your transaction will continue even if you close this"})]}),C==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Me.title,children:[_," complete"]}),n.jsx("video",{src:k,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"72px",height:"72px"},onTimeUpdate:N=>{const I=N.currentTarget;I.duration-I.currentTime<.1&&I.pause()}}),M(),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]}),C==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Me.title,children:[_," failed"]}),n.jsx("img",{src:b,alt:"Failed",className:Me.errorIcon}),n.jsx("p",{className:Me.error,children:"Your transaction could not be completed"}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const p0=Se.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),g0=({tx:e,children:t})=>{const{values:s}=kt(),{srcChainId:o}=s,a=te(),r=rs(),i=eo(),{data:c,isLoading:l}=S.useQuery({queryKey:p0.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:rn.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(l)return n.jsx(ke,{children:n.jsx(ue.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return n.jsx(n.Fragment,{children:t(d)})};function _0(e,t){return e?v.InitiaAddress(e).hex:t}function y0({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:_0(e.recipientAddress,o),slippagePercent:"1",...a}}}const x0="_container_eg177_1",b0="_back_eg177_6",w0="_title_eg177_18",j0="_divider_eg177_26",v0="_label_eg177_30",C0="_asset_eg177_37",N0="_assetIcon_eg177_55",k0="_chainIcon_eg177_67",I0="_assetName_eg177_80",A0="_chevron_eg177_92",S0="_input_eg177_96",T0="_balanceContainer_eg177_108",E0="_value_eg177_116",$0="_maxButton_eg177_126",M0="_detail_eg177_142",L0="_detailsContainer_eg177_153",q0="_detailsButton_eg177_163",P0="_detailValue_eg177_180",R0="_detailToken_eg177_190",D0="_minimumReceived_eg177_198",Y={container:x0,back:b0,title:w0,divider:j0,label:v0,asset:C0,assetIcon:N0,chainIcon:k0,assetName:I0,chevron:A0,input:S0,balanceContainer:T0,value:E0,maxButton:$0,detail:M0,detailsContainer:L0,detailsButton:q0,detailValue:P0,detailToken:R0,minimumReceived:D0},Jc=({renderFee:e})=>{const{route:t}=Ze(),{values:s}=kt(),{dstDenom:o,dstChainId:a}=s,i=us().find(({denom:f,chain_id:p})=>f===o&&p===a),c=te(),l=uc(),[d,u]=We.useToggle(!1),m=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const h=t.does_swap?Ac(t.amount_out,s.slippagePercent):t.amount_out;return n.jsx(Jn,{children:n.jsxs("div",{className:Y.detailsContainer,children:[n.jsxs("button",{className:Y.detailsButton,onClick:u,children:["Transaction details"," ",n.jsx(E.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"}})]}),d&&n.jsxs(n.Fragment,{children:[t.does_swap&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Slippage"}),n.jsxs("p",{className:Y.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:Y.detailValue,children:$a(t.estimated_fees)})]}),e&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Tx fee"}),n.jsx("div",{className:Y.detailValue,children:e()})]}),c&&n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",v.truncate(c)]})]})]}),n.jsxs("div",{className:Y.detail,children:[n.jsx("p",{className:Y.detailLabel,children:"Estimated time"}),n.jsx("p",{className:D(Y.detailValue),style:m?{color:"var(--warning)"}:void 0,children:ts(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:D(Y.detail,Y.minimumReceived),children:[n.jsx("p",{className:Y.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:Y.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:Y.detailToken})," ",v.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]})})},B0="_trigger_1c7d7_1",F0="_item_1c7d7_5",U0="_itemText_1c7d7_13",O0={trigger:B0,item:F0,itemText:U0},V0=({tx:e,gas:t,confirmMessage:s,onCompleted:o})=>{const{values:a}=kt(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=us().find(({denom:N,chain_id:I})=>N===i&&I===r),u=lt(r),m=ss(u),h=ga(u),f=_a(u),p=Ct(u),g=h.map(({amount:N,denom:I})=>Ae.calculateFee(Math.ceil(t*cn),Ae.GasPrice.fromString(N+I))),_=g.map(N=>N.amount[0]),x=N=>{const I=m.find(K=>K.denom===N)?.amount??"0",F=_.find(K=>K.denom===N)?.amount??"0",q=d&&i===N?U(c||"0").times(U(10).pow(d.decimals)).toFixed(0):"0",P=U(F).plus(q),B=U(I).gte(P),{symbol:H,decimals:z}=p(N);return{symbol:H,decimals:z,spend:U(q).gt(0)?q:null,fee:F,total:P.toFixed(),balance:I,isSufficient:B}},w=()=>{if(!_.length)return null;if(f&&x(f).isSufficient)return f;for(const{denom:N}of _)if(x(N).isSufficient)return N;return _[0]?.denom},[C,b]=y.useState(w),j=g.find(N=>N.amount[0].denom===C)??void 0,k=C?x(C):null,T=k&&!k.isSufficient?"Insufficient balance":void 0,L=(N,I)=>{if(v.formatAmount(N,{decimals:I})==="0.000000")return 8},A=N=>{const[{amount:I,denom:F}]=N.amount;if(U(I).isZero())return"0";const{symbol:q,decimals:P}=p(F),B=L(I,P);return`${v.formatAmount(I,{decimals:P,dp:B})} ${q}`},M=()=>{if(g.length===0)return null;if(g.length===1)return n.jsx("span",{className:"monospace",children:A(g[0])});if(!j||!C)return null;const N=g.map(B=>{const[{denom:H}]=B.amount,{symbol:z}=p(H);return{value:H,label:A(B),triggerLabel:z}}),[{amount:I,denom:F}]=j.amount,{decimals:q}=p(F),P=L(I,q);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:v.formatAmount(I,{decimals:q,dp:P})}),n.jsx(Aa,{options:N,value:C,onChange:b,classNames:O0})]})};return n.jsxs(n.Fragment,{children:[n.jsx(Jc,{renderFee:g.length>0?M:void 0}),n.jsx(qa,{tx:e,children:n.jsx(La,{tx:e,fee:j,onCompleted:o,confirmMessage:s,error:T})})]})},K0=({tx:e,confirmMessage:t,onCompleted:s})=>n.jsxs(n.Fragment,{children:[n.jsx(Jc,{}),n.jsx(qa,{tx:e,children:n.jsx(La,{tx:e,fee:void 0,onCompleted:s,confirmMessage:t})})]}),W0=({tx:e,gas:t,mode:s})=>{const{setValue:o}=Kt(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!t||!("cosmos_tx"in e)?n.jsx(K0,{tx:e,onCompleted:a,confirmMessage:r}):n.jsx(V0,{tx:e,gas:t,onCompleted:a,confirmMessage:r})},z0=({mode:e})=>{const t=gs(e),s=Ie(),o=Ze(),{data:a}=Ra(),r=$t(),{data:i,error:c,chainsError:l}=Pa(),d=$n(),{watch:u,setValue:m,getValues:h}=Kt(),f=u(),{srcChainId:p,srcDenom:g,quantity:_=""}=f,x=f[t.external.denomKey],w=f[t.external.chainIdKey],C=Da(e),b=A1(e),{data:j,isLoading:k}=Yc(e),T=!k&&j.length===1,L=e==="withdraw"&&!k&&j.length>0&&new Set(j.map(({chain:O})=>O.chain_id)).size===1,A=k||!j.length?null:T?j[0]:L?j.reduce((O,Ee)=>{const ae=Number(O.balance?.value_usd??0);return Number(Ee.balance?.value_usd??0)>ae?Ee:O},j[0]):null,M=A?`${A.chain.chain_id}:${A.asset.denom}`:"",N=w?r(w):null,I=i?.[p]?.[g]?.amount,F=i?.[p]?.[g]?.price||0,q=U(F||0).times(_||0),[P]=We.useDebounceValue(_,300),B=e==="withdraw"?C:b,H=y.useMemo(()=>{if(e==="deposit"&&!b)return"Select asset";const O=U(_||0);if(!O.isFinite()||O.lte(0))return"Enter amount";const Ee=v.fromBaseUnit(I??"0",{decimals:B?.decimals||6});if(O.gt(Ee))return"Insufficient balance";if(e==="withdraw"&&!b)return"Select destination"},[e,_,I,B,b]),{data:z,error:K,dataUpdatedAt:le}=Yo(P,{disabled:!!H}),ye=!K&&!H?z:void 0,he=ye&&le>0?le:void 0,xe=y.useEffectEvent(()=>{s(0,y0({currentState:o,route:ye,quoteVerifiedAt:he,hexAddress:d,values:h()}))});y.useEffect(()=>{xe()},[ye,d]);const be=y.useEffectEvent(()=>{if(!A||x&&w)return;const{asset:O,chain:Ee}=A;m(t.external.denomKey,O.denom),m(t.external.chainIdKey,Ee.chain_id),e==="deposit"&&m("quantity","")});if(y.useEffect(()=>{be()},[M]),!C||e==="deposit"&&!b)return null;const De=B?.decimals||6,ut=e==="withdraw"?"Select chain":"Select asset",Mt=()=>{m("quantity",""),m(t.external.denomKey,""),m(t.external.chainIdKey,""),(e==="withdraw"||T)&&(m(t.local.denomKey,""),m(t.local.chainIdKey,"")),m("page",e==="withdraw"||T?"select-local":"select-external")},mt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:Y.asset,disabled:T,onClick:()=>m("page","select-external"),children:[n.jsx("div",{className:Y.assetIcon,children:b?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:b.logo_uri,alt:b.symbol}),n.jsx("img",{src:N?.logo_uri||"",alt:N?.pretty_name,className:Y.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:Y.chainIcon})}),n.jsx("p",{className:Y.assetName,children:b?n.jsxs(n.Fragment,{children:[b.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",N?.pretty_name]})]}):ut}),!T&&n.jsx(E.IconChevronDown,{className:Y.chevron,size:16})]})]}),Te=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:Y.label,children:"Amount"}),n.jsx(es,{balance:I,decimals:De,className:Y.input}),Number(I)>0&&n.jsxs("div",{className:Y.balanceContainer,children:[n.jsx("p",{className:Y.value,children:q.gt(0)?X(q.toString()):"$-"}),n.jsxs("button",{className:Y.maxButton,onClick:()=>{const O=v.fromBaseUnit(I??"0",{decimals:De});U(_||0).eq(O)||m("quantity",O)},children:[n.jsx(E.IconWallet,{size:16})," ",v.formatAmount(I,{decimals:De})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("div",{className:Y.container,children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:Y.back,onClick:Mt,children:n.jsx(E.IconBack,{size:20})}),n.jsxs("h3",{className:Y.title,children:[t.label," ",C.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[Te,n.jsx("div",{className:Y.divider}),mt]}):n.jsxs(n.Fragment,{children:[mt,n.jsx("div",{className:Y.divider}),Te]}),(l||c)&&n.jsx(_e,{error:!0,children:"Failed to load balances"}),!o.route||H?n.jsx(ke,{children:n.jsx(ue.White,{type:"submit",loading:!K&&!H&&"Fetching route...",disabled:!0,fullWidth:!0,children:K?"No route found":H})}):n.jsx(Vc,{children:O=>n.jsx(Wc,{children:Ee=>n.jsx(Kc,{addressList:O,signedOpHook:Ee,children:ae=>n.jsx(g0,{tx:ae,children:Le=>n.jsx(W0,{tx:ae,gas:Le,mode:e})})})})})]})},H0="_container_7nl9j_1",Q0="_page_7nl9j_5",Mr={container:H0,page:Q0},Xc=({mode:e})=>{const t=Ne.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Pa(),n.jsx(Ne.FormProvider,{...t,children:n.jsx(G0,{mode:e})})},G0=({mode:e})=>{const{watch:t}=Kt(),s=t("page"),o=bt.useTransition(s,{keys:s,from:{opacity:0},enter:{opacity:1},leave:{opacity:0,position:"absolute",inset:0},config:{tension:500,friction:30,clamp:!0,duration:150}}),a=r=>{switch(r){case"select-local":return n.jsx(s0,{mode:e});case"select-external":return n.jsx(J1,{mode:e});case"fields":return n.jsx(z0,{mode:e});case"completed":return n.jsx(ta,{type:e})}};return n.jsx(Jn,{children:n.jsx("div",{className:Mr.container,children:o((r,i)=>n.jsx(bt.animated.div,{style:r,className:Mr.page,children:a(i)}))})})},Y0=()=>n.jsx(Xc,{mode:"deposit"}),Z0=()=>n.jsx(Xc,{mode:"withdraw"}),J0="_root_1lo0i_1",X0="_address_1lo0i_9",e2="_copy_1lo0i_19",t2="_labelWrapper_1lo0i_33",n2="_labelCopy_1lo0i_43",s2="_labelCopied_1lo0i_47",o2="_copied_1lo0i_55",a2="_derived_1lo0i_65",r2="_derivedLabel_1lo0i_79",i2="_derivedAddress_1lo0i_83",c2="_hexAddress_1lo0i_89",l2="_derivedCopy_1lo0i_94",Fe={root:J0,address:X0,copy:e2,labelWrapper:t2,labelCopy:n2,labelCopied:s2,copied:o2,derived:a2,derivedLabel:r2,derivedAddress:i2,hexAddress:c2,derivedCopy:l2},d2=()=>{const e=y.useRef(null),t=y.useRef(null),{initiaAddress:s,hexAddress:o}=Je(),a=lc("--gray-0");return y.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new jl({type:"canvas",width:400,height:400,margin:0,data:s,image:"https://registry.initia.xyz/images/INIT.png",qrOptions:{mode:"Byte",errorCorrectionLevel:"H"},imageOptions:{crossOrigin:"anonymous",margin:12},dotsOptions:{type:"dots",color:a},cornersSquareOptions:{type:"extra-rounded",color:a},cornersDotOptions:{type:"dot",color:a},backgroundOptions:{color:"transparent"}}),t.current.append(e.current)))},[s,a]),n.jsx(Nt,{title:"Receive",children:n.jsxs("div",{className:Fe.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Fe.address,children:s}),n.jsx(Fs,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Fe.copy,{[Fe.copied]:i}),onClick:r,children:[n.jsx(E.IconCopy,{size:12}),n.jsxs("div",{className:Fe.labelWrapper,children:[n.jsx("span",{className:Fe.labelCopy,children:"Copy address"}),n.jsx("span",{className:Fe.labelCopied,children:"Copied!"})]})]})}),n.jsx(Fs,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Fe.derived,{[Fe.copied]:i}),onClick:r,children:[n.jsx("span",{className:Fe.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Fe.derivedAddress,children:[n.jsx("span",{className:Fe.hexAddress,children:v.truncate(o)}),n.jsx(E.IconCopy,{size:12,className:Fe.derivedCopy}),i&&n.jsx("span",{className:Fe.copiedText,children:"Copied!"})]})]})})]})})};function u2(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function m2(){const e=te(),t=me();return S.useQueries({queries:t.map(s=>({queryKey:Ds.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Qs(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Ai(o),r=e?ua(e,s.chainId):null,i=u2(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:W.SECOND,retry:!1}))})}const h2="_countdown_vfms8_1",f2={countdown:h2},p2=({expiration:e})=>{const t=()=>{const a=new Date,r=Ge.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,u=[];return i>0&&u.push(`${i}d`),(c>0||i>0)&&u.push(`${c}h`),(l>0||c>0||i>0)&&u.push(`${l}m`),u.push(`${d}s`),u.join(" ")},[s,o]=y.useState(t());return We.useInterval(()=>{o(t())},1e3),Ge.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:f2.countdown,children:s})]})},g2="_container_1l528_1",_2="_info_1l528_11",y2="_header_1l528_17",x2="_chainName_1l528_23",b2="_expiration_1l528_29",w2="_revokeButton_1l528_35",xn={container:g2,info:_2,header:y2,chainName:x2,expiration:b2,revokeButton:w2},j2=({chainId:e,grantee:t,expiration:s})=>{const o=lt(e),{mutate:a,isPending:r}=Ki({grantee:t,internal:!0});return n.jsxs("div",{className:xn.container,children:[n.jsxs("div",{className:xn.info,children:[n.jsxs("div",{className:xn.header,children:[n.jsx(ee,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:xn.chainName,children:o.name})]}),n.jsx("div",{className:xn.expiration,children:s?n.jsx(p2,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:xn.revokeButton,onClick:()=>a(e),disabled:r,children:r?"Revoking...":"Revoke"})]})},v2=({chainId:e,grants:t})=>{const s=new Map;for(const a of t){const r=s.get(a.grantee),i=a.expiration?new Date(a.expiration):void 0;if(!r){s.set(a.grantee,{grantee:a.grantee,expiration:i});continue}r.expiration=pa([r.expiration,i])}return[...s.values()].map(a=>y.createElement(j2,{...a,chainId:e,key:a.grantee}))},C2="_content_q36qs_1",N2={content:C2},k2=()=>{const e=m2(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(_e,{children:"No permissions found"}):n.jsx("div",{className:N2.content,children:s.map(({chainId:o,grants:a})=>n.jsx(v2,{chainId:o,grants:a},o))})};return n.jsx(Nt,{title:"Manage auto-signing",backButton:"/settings",children:t()})},I2="_version_1sf5y_1",A2={version:I2},S2=()=>n.jsxs("aside",{className:A2.version,children:["v","2.4.5"]}),T2="_link_se23z_1",E2="_title_se23z_17",$2="_subtitle_se23z_23",M2="_icon_se23z_30",As={link:T2,title:E2,subtitle:$2,icon:M2},el=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:As.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:As.title,children:e}),t&&n.jsx("p",{className:As.subtitle,children:t})]}),n.jsx("div",{className:As.icon,children:s??n.jsx(E.IconChevronRight,{size:16})})]}),L2="https://export.initia.xyz/",q2=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(el,{title:"Export private key",rightSection:n.jsx(E.IconExternalLink,{size:16}),onClick:()=>window.open(L2,"_blank",e)})},P2="_container_1vxr7_1",R2="_separator_1vxr7_7",Lr={container:P2,separator:R2},D2=()=>{const e=Ie(),{connector:t}=Ke.useAccount();return n.jsx(Nt,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Lr.container,children:[n.jsx(el,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ra&&n.jsx(q2,{}),n.jsx(St.Separator,{className:Lr.separator}),n.jsx(S2,{})]})})},B2="_trigger_1yjkd_1",F2="_icon_1yjkd_23",U2="_full_1yjkd_27",O2="_triggerContent_1yjkd_32",V2="_triggerText_1yjkd_40",K2="_popoverBackdrop_1yjkd_51",W2="_popoverPositioner_1yjkd_70",z2="_popoverPopup_1yjkd_74",H2="_search_1yjkd_99",Q2="_viewport_1yjkd_105",G2="_item_1yjkd_111",Y2="_highlighted_1yjkd_127",Z2="_active_1yjkd_131",J2="_itemContent_1yjkd_136",X2="_extra_1yjkd_142",eb="_connectedTag_1yjkd_149",Ce={trigger:B2,icon:F2,full:U2,triggerContent:O2,triggerText:V2,popoverBackdrop:K2,popoverPositioner:W2,popoverPopup:z2,search:H2,viewport:Q2,item:G2,highlighted:Y2,active:Z2,itemContent:J2,extra:X2,connectedTag:eb},yo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=se(),[i,c]=y.useState(""),[l,d]=y.useState(!1),[u,m]=y.useState(0),[h,f]=y.useState(),p=y.useRef([]),g=y.useRef(null),_=me(),x=s.map(N=>_.find(I=>I.chainId===N)).filter(Boolean),w=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),n.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),C=y.useMemo(()=>({chainId:"",name:"All",logoUrl:w}),[]),b=y.useMemo(()=>{const N=[C,...x];if(!i)return N;const I=i.toLowerCase();return N.filter(F=>F.name.toLowerCase().includes(I)||F.chainId.toLowerCase().includes(I))},[x,i,C]),j=x.find(N=>N.chainId===e)||C,k=parseInt(lc("--drawer-offset")),T=6,L=()=>{if(c(""),m(-1),g.current){const I=g.current.getBoundingClientRect().bottom+T,F=window.innerHeight-I-2*k;f(F)}d(!0)};y.useEffect(()=>{u>=0&&u<p.current.length&&p.current[u]?.scrollIntoView({block:"nearest",behavior:"auto"})},[u]);const A=y.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),m(I=>(I+1)%b.length);break;case"ArrowUp":N.preventDefault(),m(I=>(I-1+b.length)%b.length);break;case"Enter":N.preventDefault(),b[u]&&(t(b[u].chainId),d(!1));break;case"Escape":N.preventDefault(),d(!1);break}},[b,u,t,d]),M=N=>{t(N),d(!1)};return n.jsxs(_n.Popover.Root,{open:l,onOpenChange:L,modal:"trap-focus",children:[n.jsx(_n.Popover.Trigger,{render:n.jsxs("button",{className:D(Ce.trigger,{[Ce.full]:a}),"aria-expanded":l,role:"listbox",ref:g,children:[n.jsxs("div",{className:Ce.triggerContent,children:[typeof j.logoUrl=="string"?n.jsx(ee,{src:j.logoUrl,width:14,height:14,logo:!0}):j.logoUrl(14),n.jsx("span",{className:Ce.triggerText,children:j.name})]}),n.jsx(E.IconChevronDown,{size:16,className:Ce.icon})]})}),n.jsxs(_n.Popover.Portal,{container:dn(),children:[n.jsx(_n.Popover.Backdrop,{className:Ce.popoverBackdrop,onClick:()=>d(!1)}),n.jsx(_n.Popover.Positioner,{className:Ce.popoverPositioner,align:"end",side:"bottom",sideOffset:T,collisionAvoidance:{side:"none"},children:n.jsxs(_n.Popover.Popup,{className:D(Ce.popoverPopup,{[Ce.full]:a}),style:{maxHeight:h},children:[n.jsx(fs,{value:i,onChange:N=>{c(N.target.value),m(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search appchains",rootClassName:Ce.search,ref:ms()}),n.jsx("div",{className:Ce.viewport,role:"listbox",children:b.length===0?n.jsx(_e,{children:"No appchains found"}):b.map(({chainId:N,name:I,logoUrl:F},q)=>n.jsxs("div",{className:D(Ce.item,{[Ce.highlighted]:q===u,[Ce.active]:e===N}),onClick:()=>M(N),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),M(N))},onMouseEnter:()=>m(q),role:"option","aria-selected":e===N,tabIndex:-1,ref:P=>{P&&(p.current[q]=P)},children:[n.jsxs("div",{className:Ce.itemContent,children:[typeof F=="string"?n.jsx(ee,{src:F,width:16,height:16,logo:!0}):F(16),n.jsx("span",{className:Ce.name,children:I}),N===r&&n.jsx("span",{className:Ce.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:Ce.extra,children:o(N)})]},N))})]})})]})]})},tb="_container_1nap1_1",nb="_controls_1nap1_7",sb="_search_1nap1_13",Ba={container:tb,controls:nb,search:sb},ob=({children:e})=>n.jsx("div",{className:Ba.container,children:e}),ab=({children:e})=>n.jsx("div",{className:Ba.controls,children:e}),rb=e=>n.jsx(fs,{...e,rootClassName:Ba.search}),ct={Root:ob,Controls:ab,SearchInput:rb},tl=Q.atom(""),nl=Q.atom(""),ib=Q.atom(""),cb=Q.atom(""),lb=Q.atom(""),db="_change_1nm9m_1",ub="_positive_1nm9m_8",mb="_negative_1nm9m_12",Fo={change:db,positive:ub,negative:mb},sl=({amount:e,asset:t})=>{const{denom:s,symbol:o,decimals:a}=t,r=new U(e).isPositive(),i=new U(e).abs().toString();return n.jsxs("div",{className:D(Fo.change,r?Fo.positive:Fo.negative),children:[r?"+":"-",v.formatAmount(i,{decimals:a})," ",o||s]})},hb=({changes:e,chain:t})=>{const s=Ct(t);return e.map(({amount:o,denom:a},r)=>n.jsx(sl,{amount:o,asset:s(a)},r))},fb=({changes:e,chain:t})=>{const s=Ct(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(gc,{metadata:a,chain:t,children:i=>n.jsx(sl,{amount:o,asset:s(i)})},r))},pb=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=Je();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(fb,{changes:pc(e,o),chain:t}):n.jsx(hb,{changes:fc(e,s),chain:t})},gb="_message_1qc8m_1",_b="_more_1qc8m_9",qr={message:gb,more:_b},yb=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:qr.message,children:zs.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:qr.more,children:`+${e.length-3} more`})]}),xb="_link_1vbb0_1",bb="_inner_1vbb0_16",wb="_header_1vbb0_21",jb="_time_1vbb0_30",vb="_error_1vbb0_36",Cb="_timestamp_1vbb0_40",Nb="_chainInfo_1vbb0_45",kb="_content_1vbb0_53",Ib="_messages_1vbb0_61",Ab="_changes_1vbb0_67",_t={link:xb,inner:bb,header:wb,time:jb,error:vb,timestamp:Cb,chainInfo:Nb,content:kb,messages:Ib,changes:Ab},Sb=({txItem:e,chain:t})=>n.jsx(lo,{txHash:e.txhash,chainId:t.chainId,className:_t.link,children:n.jsxs("div",{className:_t.inner,children:[n.jsxs("div",{className:_t.header,children:[n.jsxs("div",{className:_t.time,children:[e.code!==0&&n.jsx(E.IconWarningFilled,{size:14,className:_t.error}),n.jsx("span",{className:_t.timestamp,children:Ge.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:_t.chainInfo,children:[n.jsx(ee,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:_t.content,children:[n.jsx("div",{className:_t.messages,children:n.jsx(yb,{messages:e.tx.body.messages})}),n.jsx("div",{className:_t.changes,children:n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(pb,{...e,chain:t})})})]})]})}),Tb="_list_1mv55_1",Eb="_dateGroup_1mv55_7",$b="_dateHeader_1mv55_12",Mb="_more_1mv55_18",Ss={list:Tb,dateGroup:Eb,dateHeader:$b,more:Mb},Lb=({list:e,chainId:t})=>{const s=te(),o=y.useMemo(()=>Mc(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(_e,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Ss.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Ss.dateGroup,children:[n.jsx("div",{className:Ss.dateHeader,children:a}),r.map(i=>n.jsx(pe,{errorBoundaryProps:{fallback:null},children:n.jsx(Sb,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(lo,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Ss.more,showIcon:!0,children:"View more on Initia Scan"})]})},qb=()=>{const{activities:e,isLoading:t}=Pd(),[s,o]=Q.useAtom(lb),a=oe(),r=y.useMemo(()=>Array.from(new Set(e.map(c=>c.chain.chainId))),[e]),i=y.useMemo(()=>s?e.filter(c=>c.chain.chainId===s):e,[e,s]);return t&&e.length===0?n.jsx(_e,{children:"Loading activities..."}):!e.length&&!t?n.jsx(_e,{children:"No activity yet"}):n.jsxs(ct.Root,{children:[n.jsx(ct.Controls,{children:n.jsx(yo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Lb,{list:i,chainId:s||a.chainId})]})},Pb="_thumbnail_1xyqw_1",Rb="_placeholder_1xyqw_18",Db="_clickable_1xyqw_24",Kn={thumbnail:Pb,placeholder:Rb,clickable:Db},Bb=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=se(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:D(Kn.thumbnail,Kn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(ee,{src:l,classNames:{placeholder:Kn.placeholder}})}):n.jsx("div",{className:Kn.thumbnail,style:{width:t,height:t},children:n.jsx(ee,{src:l,classNames:{placeholder:Kn.placeholder}})})},Fb="_collectionName_qs5tw_1",Ub="_nftName_qs5tw_6",Ob="_chainInfo_qs5tw_10",Uo={collectionName:Fb,nftName:Ub,chainInfo:Ob},Fa=({normalizedNft:e,onThumbnailClick:t,thumbnailSize:s,chainIconSize:o=12,classNames:a})=>{const{collection_name:r,name:i,chain:c}=e;return n.jsxs("div",{className:a?.root,children:[n.jsx(Bb,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:D(Uo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:D(Uo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:D(Uo.chainInfo,a?.chainInfo),children:[n.jsx(ee,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ua=Se.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function Vb(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function Kb(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const Wb=()=>{const e=te(),t=me(),s=S.useQueries({queries:t.map(l=>({queryKey:Ua.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Qs(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:W.SECOND}))}),o=s.map($.prop("data")),a=Kb(t,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 zb(e){const t=Pr(e);return S.useQuery({queryKey:Ua.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await G.get(t).json();return{...s,image:Pr(s.image)}}catch{return{}}},staleTime:W.INFINITY})}function Pr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const Hb=({nftInfo:e,children:t})=>{const{data:s={}}=zb(e.nft.uri),o=Vb(e,s);return t(o)},Qb="_grid_1wwdn_1",Gb="_root_1wwdn_7",Yb="_collectionName_1wwdn_15",Zb="_nftName_1wwdn_23",Jb="_chainInfo_1wwdn_32",Rr={grid:Qb,root:Gb,collectionName:Yb,nftName:Zb,chainInfo:Jb},Xb=()=>{const[e,t]=Q.useAtom(ib),[s,o]=Q.useAtom(cb),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=Wb(),l=Ie(),d=y.useMemo(()=>a.filter(({collection_addr:m,collection_name:h,nft:f,object_addr:p,chain:g})=>{if(s&&g.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return m.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||p.toLowerCase().includes(_)}return!0}),[a,s,e]),u=y.useMemo(()=>Array.from(new Set(a.map(({chain:m})=>m.chainId))),[a]);return c&&a.length===0?n.jsx(_e,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(_e,{children:"No NFTs"}):n.jsxs(ct.Root,{children:[n.jsxs(ct.Controls,{children:[n.jsx(ct.SearchInput,{value:e,onChange:m=>t(m.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(yo,{value:s,onChange:o,chainIds:u,renderExtra:m=>m?r[m]||0:i})]}),d.length===0?n.jsx(_e,{children:"No NFTs found"}):n.jsx("div",{className:Rr.grid,children:d.map(m=>{const{collection_addr:h,nft:f}=m;return n.jsx(Hb,{nftInfo:m,children:p=>n.jsx(Fa,{normalizedNft:p,onThumbnailClick:()=>l("/nft",p),classNames:Rr})},h+f.token_id)})})]})},ol=y.createContext(null);function al(){return y.useContext(ol)}const ew="_popup_nbecp_1",tw="_item_nbecp_19",Ts={popup:ew,item:tw},rl=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[u,m]=y.useState(!1),h=Ie(),f=al(),{showNotification:p}=uo(),{defaultChainId:g}=se(),{evm_chain_id:_}=un(),x=Ke.useChainId(),{switchChainAsync:w}=Ke.useSwitchChain(),{watchAssetAsync:C}=Ke.useWatchAsset(),b=()=>{m(!1),h("/send",{denom:s,chain:l})},j=()=>{m(!1),h("/bridge",{srcChainId:d,srcDenom:s,quantity:""})},k=S.useMutation({mutationFn:async()=>{if(!c)throw new Error("Address is required");const T=r;return await w({chainId:Number(_)}),C({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:T}})},onSuccess:()=>{p({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:T=>{p({type:"error",title:"Asset addition failed",description:T.message})}});return n.jsxs(St.Menu.Root,{open:u,onOpenChange:m,modal:!1,children:[n.jsx(St.Menu.Trigger,{render:t}),n.jsx(St.Menu.Portal,{container:f,children:n.jsx(St.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(St.Menu.Popup,{className:Ts.popup,children:[n.jsxs(St.Menu.Item,{className:Ts.item,onClick:b,children:[n.jsx(E.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(St.Menu.Item,{className:Ts.item,onClick:j,disabled:i,children:[n.jsx(E.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),d===g&&_===x&&!!c&&n.jsxs(St.Menu.Item,{className:Ts.item,onClick:()=>k.mutate(),disabled:k.isPending||k.data,children:[k.data?n.jsx(E.IconCheck,{size:16}):n.jsx(E.IconPlus,{size:16}),n.jsx("span",{children:"Add to Wallet"})]})]})})})]})},nw="_item_38qhm_1",sw="_info_38qhm_23",ow="_images_38qhm_29",aw="_name_38qhm_33",rw="_value_38qhm_39",iw="_amount_38qhm_47",cw="_usd_38qhm_53",Jt={item:nw,info:sw,images:ow,name:aw,value:rw,amount:iw,usd:cw},lw=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=v.formatAmount(t,{decimals:e.decimals});return n.jsx(rl,{asset:e,children:n.jsxs("button",{className:Jt.item,children:[n.jsxs("div",{className:Jt.info,children:[n.jsx(fo,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:Jt.images}),n.jsx("span",{className:Jt.name,children:a.name})]}),n.jsxs("div",{className:Jt.value,children:[n.jsx("span",{className:Jt.amount,children:r}),Number(s)>0&&n.jsx("span",{className:Jt.usd,children:X(s)})]})]})})},dw="_container_ytg3p_1",uw="_assetItem_ytg3p_6",mw="_expandIcon_ytg3p_22",hw="_assetInfo_ytg3p_27",fw="_logo_ytg3p_33",pw="_details_ytg3p_37",gw="_symbol_ytg3p_42",_w="_chainName_ytg3p_53",yw="_chainInfos_ytg3p_59",xw="_chainLogos_ytg3p_65",bw="_chainLogo_ytg3p_65",ww="_moreChains_ytg3p_76",jw="_expanded_ytg3p_93",vw="_valueColumn_ytg3p_98",Cw="_amount_ytg3p_108",Nw="_value_ytg3p_98",kw="_collapsibleContent_ytg3p_121",Iw="_chainsList_ytg3p_151",je={container:dw,assetItem:uw,expandIcon:mw,assetInfo:hw,logo:fw,details:pw,symbol:gw,chainName:_w,chainInfos:yw,chainLogos:xw,chainLogo:bw,moreChains:ww,expanded:jw,valueColumn:vw,amount:Cw,value:Nw,collapsibleContent:kw,chainsList:Iw},Aw=Q.atom([]),Oa=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=Q.useAtom(Aw),c=y.useMemo(()=>Xd(e),[e]),l=y.useMemo(()=>Wi(e),[e]),d=r.includes(t),u=()=>{i(h=>d?h.filter(f=>f!==t):[...new Set([...h,t])])},m=()=>n.jsxs("button",{className:je.assetItem,children:[n.jsxs("div",{className:je.assetInfo,children:[s&&n.jsx(ee,{src:s,width:32,height:32,className:je.logo,logo:!0}),n.jsxs("div",{className:je.details,children:[n.jsx("div",{className:je.symbol,children:t}),a?n.jsx("div",{className:je.chainName,children:o[0].chain.name}):n.jsxs("div",{className:je.chainInfos,children:[n.jsx("div",{className:je.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(ee,{src:h.logoUrl,width:16,height:16,className:je.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:je.moreChains,children:["+",o.length-5]}),n.jsx(E.IconChevronDown,{size:16,className:D(je.expandIcon,{[je.expanded]:d})})]})]})]}),n.jsxs("div",{className:je.valueColumn,children:[n.jsx("div",{className:je.amount,children:v.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:je.value,children:X(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:je.container,children:n.jsx(rl,{asset:h,children:m()})})}return n.jsx("div",{className:je.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:u,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:m()}),n.jsx(Z.Collapsible.Content,{className:je.collapsibleContent,children:n.jsx("div",{className:je.chainsList,children:o.map(h=>n.jsx(lw,{asset:h},h.chain.chainId))})})]})})},Sw="_collapsible_1g7rh_1",Tw="_trigger_1g7rh_5",Ew="_divider_1g7rh_20",$w="_label_1g7rh_28",Mw="_chevron_1g7rh_33",Lw="_content_1g7rh_41",qw="_list_1g7rh_45",Rt={collapsible:Sw,trigger:Tw,divider:Ew,label:$w,chevron:Mw,content:Lw,list:qw},il=({unlistedAssets:e})=>{const[t,s]=y.useState(!1),o=al(),a=y.useRef(null),[r,i]=y.useState(0);y.useEffect(()=>{if(a.current){const m=a.current.scrollHeight;i(m)}},[e]);const c=y.useRef(null),l=m=>{s(m),m&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),p=c.current.getBoundingClientRect(),g=a.current.scrollHeight;if(p.bottom+g>f.bottom){const x=p.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},d=bt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),u=y.useMemo(()=>e.map(m=>({...m,assets:[m],totalValue:m.value??0,totalAmount:Number(m.quantity)})),[e]);return e.length===0?null:n.jsxs(Z.Collapsible.Root,{open:t,onOpenChange:l,className:Rt.collapsible,children:[n.jsxs(Z.Collapsible.Trigger,{ref:c,className:Rt.trigger,children:[n.jsx("div",{className:Rt.divider}),n.jsxs("span",{className:Rt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(E.IconChevronDown,{className:Rt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Rt.divider})]}),n.jsx(Z.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(bt.animated.div,{className:Rt.content,style:d,children:n.jsx("div",{className:Rt.list,ref:a,children:u.map(m=>n.jsx(Oa,{assetGroup:m},m.assets[0].denom))})})})]})},Pw="_container_15xfg_1",Rw="_header_15xfg_7",Dw="_title_15xfg_13",Bw="_totalValue_15xfg_19",Fw="_list_15xfg_26",Cn={container:Pw,header:Rw,title:Dw,totalValue:Bw,list:Fw},Uw=()=>{const[e,t]=Q.useAtom(tl),[s,o]=Q.useAtom(nl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=ya(),d=i.map(({chainId:h})=>h),u=y.useMemo(()=>{const h=e?a.filter(p=>{const{symbol:g,assets:_}=p;return g.toLowerCase().includes(e.toLowerCase())||_.some(({denom:x,address:w})=>x.toLowerCase().includes(e.toLowerCase())||w?.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]),m=y.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?n.jsx(_e,{children:"Loading assets..."}):!u.length&&!m.length&&!e&&!s&&!l?n.jsx(_e,{children:"No assets"}):n.jsxs(ct.Root,{children:[n.jsxs(ct.Controls,{children:[n.jsx(ct.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(yo,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return X(c);const f=i.find(p=>p.chainId===h);return f?X(f.value):null}})]}),n.jsx("div",{children:u.length===0&&m.length===0?n.jsx(_e,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Cn.list,children:u.map(h=>n.jsx(Oa,{assetGroup:h},h.symbol))}),n.jsx(il,{unlistedAssets:m})]})})]})},Ow="_container_11k2x_1",Vw={container:Ow},yt=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(an,{height:e,width:s}):n.jsx("div",{className:Vw.container,children:o.map(a=>n.jsx(an,{height:e,width:s},a))})},Kw=y.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ls(),l=oe(),{listedGroups:d,unlistedAssets:u}=y.useMemo(()=>pm(i,a,r,l.chainId),[i,a,r,l.chainId]),m=y.useMemo(()=>um(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:p}=y.useMemo(()=>fm(m,u,e,t),[m,u,e,t]);return n.jsxs("div",{className:Cn.container,children:[n.jsxs("div",{className:Cn.header,children:[n.jsx("span",{className:Cn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Cn.totalValue,children:X(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Cn.list,children:h.map(g=>n.jsx(Oa,{assetGroup:g},g.symbol))}),n.jsx(il,{unlistedAssets:p})]}):m.length===0&&c?n.jsx(yt,{height:56,length:3}):n.jsx(_e,{children:"No liquid assets"})]})}),Ww="_container_1n61l_1",zw="_section_1n61l_7",Hw="_sectionHeader_1n61l_19",Qw="_sectionTitle_1n61l_25",Gw="_sectionLabel_1n61l_31",Yw="_externalLink_1n61l_37",Zw="_sectionValue_1n61l_49",Jw="_tokenList_1n61l_56",Xw="_stakingTokenList_1n61l_62",ej="_tokenRow_1n61l_72",tj="_tokenMain_1n61l_78",nj="_tokenTrigger_1n61l_84",sj="_tokenChevron_1n61l_100",oj="_expanded_1n61l_111",aj="_triggerValue_1n61l_115",rj="_tokenInfo_1n61l_122",ij="_tokenInfoLabel_1n61l_128",cj="_tokenLogo_1n61l_134",lj="_tokenSymbol_1n61l_138",dj="_tokenValues_1n61l_144",uj="_tokenAmount_1n61l_150",mj="_tokenValue_1n61l_144",hj="_typeBreakdown_1n61l_164",fj="_typeRow_1n61l_172",pj="_typeLabel_1n61l_180",gj="_typeValues_1n61l_186",_j="_typeAmount_1n61l_192",yj="_typeValue_1n61l_186",xj="_collapsibleContent_1n61l_206",J={container:Ww,section:zw,sectionHeader:Hw,sectionTitle:Qw,sectionLabel:Gw,externalLink:Yw,sectionValue:Zw,tokenList:Jw,stakingTokenList:Xw,tokenRow:ej,tokenMain:tj,tokenTrigger:nj,tokenChevron:sj,expanded:oj,triggerValue:aj,tokenInfo:rj,tokenInfoLabel:ij,tokenLogo:cj,tokenSymbol:lj,tokenValues:dj,tokenAmount:uj,tokenValue:mj,typeBreakdown:hj,typeRow:fj,typeLabel:pj,typeValues:gj,typeAmount:_j,typeValue:yj,collapsibleContent:xj},cl=({protocols:e,denomLogoMap:t,isInitia:s,getClaimableInitByType:o,initPrice:a})=>{const r=e[0]?.manageUrl,i=y.useMemo(()=>{const c=e.flatMap(l=>l.positions);return tm(c)},[e]);return i.size===0?null:n.jsx("div",{className:J.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(bj,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},bj=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,d=em(e,o),u=y.useMemo(()=>cm(c),[c]),m=e==="staking";return n.jsxs("div",{className:J.section,children:[n.jsxs("div",{className:J.sectionHeader,children:[n.jsxs("div",{className:J.sectionTitle,children:[n.jsx("span",{className:J.sectionLabel,children:d}),m&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:J.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12})})]}),n.jsx("span",{className:J.sectionValue,children:X(l)})]}),n.jsx("div",{className:D(J.tokenList,{[J.stakingTokenList]:m}),children:u.map(h=>n.jsx(wj,{group:h,showTypeBreakdown:m,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},wj=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,u=s.get(r),[m,h]=y.useState(!1),f=y.useMemo(()=>{if(!t)return null;const p=rm(d);return p.size>0?p:null},[d,t]);return f?n.jsxs(Z.Collapsible.Root,{open:m,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:J.tokenTrigger,children:[n.jsxs("div",{className:J.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(J.tokenChevron,{[J.expanded]:m})}),n.jsxs("div",{className:J.tokenInfoLabel,children:[u?.assetLogo&&n.jsx(ee,{src:u.assetLogo,width:20,height:20,className:J.tokenLogo}),n.jsx("span",{className:J.tokenSymbol,children:i})]})]}),n.jsx("span",{className:J.triggerValue,children:X(l)})]})}),n.jsx(Z.Collapsible.Content,{className:J.collapsibleContent,children:n.jsx(jj,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:J.tokenRow,children:n.jsxs("div",{className:J.tokenMain,children:[n.jsxs("div",{className:J.tokenInfo,children:[u?.assetLogo&&n.jsx(ee,{src:u.assetLogo,width:20,height:20,className:J.tokenLogo}),n.jsx("span",{className:J.tokenSymbol,children:i})]}),n.jsxs("div",{className:J.tokenValues,children:[n.jsx("span",{className:J.tokenAmount,children:v.formatNumber(c,{dp:6})}),n.jsx("span",{className:J.tokenValue,children:X(l)})]})]})})},jj=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=y.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const u=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),m=d.reduce((h,f)=>h+An(f),0);return{type:l,typeAmount:u,typeValue:m}}),[e]),i=y.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const u=o(s,d);l+=Number(u)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:J.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:u})=>n.jsxs("div",{className:J.typeRow,children:[n.jsx("span",{className:J.typeLabel,children:am(l)}),n.jsxs("div",{className:J.typeValues,children:[n.jsxs("span",{className:J.typeAmount,children:[v.formatNumber(d,{dp:6})," ",t]}),n.jsx("span",{className:J.typeValue,children:X(u)})]})]},l)),c&&n.jsxs("div",{className:J.typeRow,children:[n.jsx("span",{className:J.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:J.typeValues,children:[n.jsxs("span",{className:J.typeAmount,children:[v.formatNumber(i,{dp:6})," ",it]}),n.jsx("span",{className:J.typeValue,children:X(i*(a??0))})]})]})]})},vj="_container_ymkoc_1",Cj="_trigger_ymkoc_6",Nj="_expandIcon_ymkoc_22",kj="_chainInfo_ymkoc_27",Ij="_logo_ymkoc_33",Aj="_chainNameContainer_ymkoc_37",Sj="_chainName_ymkoc_37",Tj="_externalLink_ymkoc_49",Ej="_externalIcon_ymkoc_53",$j="_valueColumn_ymkoc_63",Mj="_value_ymkoc_63",Lj="_expanded_ymkoc_80",qj="_collapsibleContent_ymkoc_85",Pj="_content_ymkoc_97",Ue={container:vj,trigger:Cj,expandIcon:Nj,chainInfo:kj,logo:Ij,chainNameContainer:Aj,chainName:Sj,externalLink:Tj,externalIcon:Ej,valueColumn:$j,value:Mj,expanded:Lj,collapsibleContent:qj,content:Pj},Rj=Q.atom([]),Dj=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=me(),r=ns(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>ka(r,a),[r,a]),l=y.useMemo(()=>{const d=new Map;for(const u of o)for(const m of u.positions){if(m.type==="fungible-position"||m.balance.type==="unknown")continue;const{denom:h,symbol:f}=m.balance,p=f.toUpperCase(),g=`${t}:${h}`,_=i.get(g)??c.get(p);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,t,s]);return n.jsx(cl,{protocols:o,denomLogoMap:l})},Bj=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=Q.useAtom(Rj),c=y.useMemo(()=>o.reduce((f,p)=>f+p.positions.reduce((g,_)=>g+An(_),0),0),[o]),l=["civitia","yominet"],d=r.includes(t),u=t?.toLowerCase(),m=l.includes(u),h=()=>{i(f=>d?f.filter(p=>p!==t):[...new Set([...f,t])])};return n.jsx("div",{className:Ue.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Ue.trigger,children:[n.jsxs("div",{className:Ue.chainInfo,children:[s&&n.jsx(ee,{src:s,width:32,height:32,className:Ue.logo,logo:!0}),n.jsxs("div",{className:Ue.chainNameContainer,children:[n.jsx("span",{className:Ue.chainName,children:t}),a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:Ue.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,className:Ue.externalIcon})})]})]}),n.jsxs("div",{className:Ue.valueColumn,children:[!m&&n.jsx("span",{className:Ue.value,children:X(c)}),n.jsx(E.IconChevronDown,{size:16,className:D(Ue.expandIcon,{[Ue.expanded]:d})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Ue.collapsibleContent,children:n.jsx("div",{className:Ue.content,children:n.jsx(Dj,{chainGroup:e})})})]})})},Fj="_container_g7q2b_1",Uj="_section_g7q2b_6",Oj="_sectionHeader_g7q2b_14",Vj="_sectionTitle_g7q2b_20",Kj="_sectionLabel_g7q2b_26",Wj="_externalLink_g7q2b_32",zj="_sectionValue_g7q2b_44",Hj="_tokenList_g7q2b_51",Qj="_tokenTrigger_g7q2b_63",Gj="_tokenChevron_g7q2b_79",Yj="_expanded_g7q2b_90",Zj="_tokenInfo_g7q2b_94",Jj="_tokenInfoLabel_g7q2b_100",Xj="_tokenLogo_g7q2b_106",ev="_pairedLogos_g7q2b_110",tv="_coinLogo_g7q2b_115",nv="_tokenSymbol_g7q2b_133",sv="_triggerValue_g7q2b_139",ov="_clammBreakdownContent_g7q2b_146",av="_clammPositionRow_g7q2b_154",rv="_statusDot_g7q2b_163",iv="_inRange_g7q2b_170",cv="_outRange_g7q2b_174",lv="_unknown_g7q2b_178",dv="_clammStatusValue_g7q2b_182",uv="_breakdownContent_g7q2b_192",mv="_breakdownRow_g7q2b_200",hv="_breakdownLabel_g7q2b_208",fv="_breakdownValues_g7q2b_214",pv="_breakdownAmount_g7q2b_220",gv="_breakdownValue_g7q2b_214",_v="_collapsibleContent_g7q2b_241",R={container:Fj,section:Uj,sectionHeader:Oj,sectionTitle:Vj,sectionLabel:Kj,externalLink:Wj,sectionValue:zj,tokenList:Hj,tokenTrigger:Qj,tokenChevron:Gj,expanded:Yj,tokenInfo:Zj,tokenInfoLabel:Jj,tokenLogo:Xj,pairedLogos:ev,coinLogo:tv,tokenSymbol:nv,triggerValue:sv,clammBreakdownContent:ov,clammPositionRow:av,statusDot:rv,inRange:iv,outRange:cv,unknown:lv,clammStatusValue:dv,breakdownContent:uv,breakdownRow:mv,breakdownLabel:hv,breakdownValues:fv,breakdownAmount:pv,breakdownValue:gv,collapsibleContent:_v},yv=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("div",{className:R.section,children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:ma,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12})})]}),n.jsx("span",{className:R.sectionValue,children:X(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(Nv,{row:a,denomLogoMap:t},a.denom))})]})})},xv={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function bv(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function wv(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function Dr(e,t){return e===void 0?"-":`${v.formatNumber(e,{dp:6})} ${t}`}function ll({isOpen:e,symbol:t,coinLogos:s,singleLogoUrl:o,rightContent:a}){const r=s&&s.length>0&&s.some(i=>i);return n.jsxs("button",{className:R.tokenTrigger,children:[n.jsxs("div",{className:R.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(R.tokenChevron,{[R.expanded]:e})}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(ee,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(ee,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const jv=({position:e})=>{const t=bv(e.inRange),s=wv(e.inRange);return n.jsxs("div",{className:R.clammPositionRow,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Position ID"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:e.positionId})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Deposit"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:X(e.value)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Status"}),n.jsxs("div",{className:R.clammStatusValue,children:[n.jsx("span",{className:D(R.statusDot,t)}),n.jsx("span",{children:s})]})]}),e.isFullRange?n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Range Bounds"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:"Full range"})})]}):n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Min"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:Dr(e.minPrice,e.pricePairLabel)})})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Max"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownAmount,children:Dr(e.maxPrice,e.pricePairLabel)})})]})]}),n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:X(e.rewardValue)})})]})]})},vv=({row:e,denomLogoMap:t})=>{const[s,o]=y.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:d}=e,u=t.get(a);if(!d)return null;const m=l||u?.assetLogo;return n.jsxs(Z.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:ll({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:m,rightContent:n.jsx("span",{className:R.triggerValue,children:X(i)})})}),n.jsx(Z.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.clammBreakdownContent,children:[n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsx("div",{className:R.breakdownValues,children:n.jsx("span",{className:R.breakdownValue,children:X(d.totalRewardValue)})})]}),d.positions.map(h=>n.jsx(jv,{position:h},h.tokenAddress))]})})]})},Cv=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,u]=y.useState(!1),m=t.get(s),h=i||m?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,p=y.useMemo(()=>Object.entries(r).filter(([,_])=>_>0),[r]),g=l&&Number(l.total)>0;return n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:u,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:ll({isOpen:d,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:X(a)})})}),n.jsx(Z.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[p.map(([_,x])=>{const w=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:xv[_]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[v.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:X(w)})]})]},_)}),g&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[v.formatNumber(Number(l.total),{dp:6})," ",it]}),n.jsx("span",{className:R.breakdownValue,children:X(l.totalValue)})]})]})]})})]})},Nv=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(vv,{row:e,denomLogoMap:t}):n.jsx(Cv,{row:e,denomLogoMap:t}),kv="_container_1nijk_1",Iv="_section_1nijk_6",Av="_sectionHeader_1nijk_14",Sv="_sectionTitle_1nijk_20",Tv="_sectionLabel_1nijk_26",Ev="_externalLink_1nijk_32",$v="_sectionValue_1nijk_44",Mv="_tokenList_1nijk_51",Lv="_tokenTrigger_1nijk_63",qv="_tokenChevron_1nijk_79",Pv="_expanded_1nijk_90",Rv="_tokenInfo_1nijk_94",Dv="_tokenInfoLabel_1nijk_100",Bv="_tokenLogo_1nijk_106",Fv="_tokenName_1nijk_110",Uv="_triggerValue_1nijk_116",Ov="_breakdownContent_1nijk_123",Vv="_breakdownRow_1nijk_131",Kv="_breakdownLabel_1nijk_139",Wv="_breakdownValues_1nijk_145",zv="_breakdownAmount_1nijk_151",Hv="_breakdownValue_1nijk_145",Qv="_collapsibleContent_1nijk_165",de={container:kv,section:Iv,sectionHeader:Av,sectionTitle:Sv,sectionLabel:Tv,externalLink:Ev,sectionValue:$v,tokenList:Mv,tokenTrigger:Lv,tokenChevron:qv,expanded:Pv,tokenInfo:Rv,tokenInfoLabel:Dv,tokenLogo:Bv,tokenName:Fv,triggerValue:Uv,breakdownContent:Ov,breakdownRow:Vv,breakdownLabel:Kv,breakdownValues:Wv,breakdownAmount:zv,breakdownValue:Hv,collapsibleContent:Qv},Gv=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:de.container,children:n.jsxs("div",{className:de.section,children:[n.jsxs("div",{className:de.sectionHeader,children:[n.jsxs("div",{className:de.sectionTitle,children:[n.jsx("span",{className:de.sectionLabel,children:"VIP"}),n.jsx("a",{href:cd,target:"_blank",rel:"noopener noreferrer",className:de.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12})})]}),n.jsx("span",{className:de.sectionValue,children:X(t)})]}),n.jsx("div",{className:de.tokenList,children:s.map(o=>n.jsx(Yv,{row:o},`${o.bridgeId}-${o.version}`))})]})})},Yv=({row:e})=>{const{name:t,logoUrl:s,lockedReward:o,lockedRewardValue:a,claimableReward:r,claimableRewardValue:i}=e,[c,l]=y.useState(!1),d=a+i;return n.jsxs(Z.Collapsible.Root,{open:c,onOpenChange:l,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:de.tokenTrigger,children:[n.jsxs("div",{className:de.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(de.tokenChevron,{[de.expanded]:c})}),n.jsxs("div",{className:de.tokenInfoLabel,children:[s&&n.jsx(ee,{src:s,width:20,height:20,className:de.tokenLogo,logo:!0}),n.jsx("span",{className:de.tokenName,children:t})]})]}),n.jsx("span",{className:de.triggerValue,children:X(d)})]})}),n.jsx(Z.Collapsible.Content,{className:de.collapsibleContent,children:n.jsxs("div",{className:de.breakdownContent,children:[o>0&&n.jsxs("div",{className:de.breakdownRow,children:[n.jsx("span",{className:de.breakdownLabel,children:"Locked"}),n.jsxs("div",{className:de.breakdownValues,children:[n.jsxs("span",{className:de.breakdownAmount,children:[v.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:X(a)})]})]}),r>0&&n.jsxs("div",{className:de.breakdownRow,children:[n.jsx("span",{className:de.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:de.breakdownValues,children:[n.jsxs("span",{className:de.breakdownAmount,children:[v.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:X(i)})]})]})]})})]})},Zv="_container_ymkoc_1",Jv="_trigger_ymkoc_6",Xv="_expandIcon_ymkoc_22",eC="_chainInfo_ymkoc_27",tC="_logo_ymkoc_33",nC="_chainNameContainer_ymkoc_37",sC="_chainName_ymkoc_37",oC="_externalLink_ymkoc_49",aC="_externalIcon_ymkoc_53",rC="_valueColumn_ymkoc_63",iC="_value_ymkoc_63",cC="_expanded_ymkoc_80",lC="_collapsibleContent_ymkoc_85",dC="_content_ymkoc_97",Oe={container:Zv,trigger:Jv,expandIcon:Xv,chainInfo:eC,logo:tC,chainNameContainer:nC,chainName:sC,externalLink:oC,externalIcon:aC,valueColumn:rC,value:iC,expanded:cC,collapsibleContent:lC,content:dC},uC=Q.atom(!1),mC=()=>{const{totalValue:e}=Na(),{totalValue:t}=ao(),{totalValue:s}=ro(),o=e+t+s;return n.jsx("span",{className:Oe.value,children:X(o)})},hC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Na(),{data:i}=ec(),{data:c}=tc(),l=y.useMemo(()=>{const m=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}`,x=s.get(_)??o.get(g);x&&m.set(f,{assetLogo:x,chainLogo:t})}return m},[r,s,o,e,t]),d=y.useMemo(()=>(m,h)=>{const f=v.denomToMetadata(m);if(h==="staking"){const p=i?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:st}):"0"}if(h==="lockstaking"){const p=c?.get(f);return p?v.fromBaseUnit(p.amount,{decimals:st}):"0"}return"0"},[i,c]),u=y.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:ma,positions:r}],[r]);return u.length===0?null:n.jsx(cl,{protocols:u,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},fC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=ao(),r=y.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,u=d.toUpperCase(),m=`${e}:${l}`,h=s.get(m)??o.get(u);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx(yv,{data:a,denomLogoMap:r})},pC=()=>{const e=ro();return e.rows.length===0?null:n.jsx(Gv,{data:e})},gC=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=Q.useAtom(uC),i=me(),c=ns(),{denomLogos:l,symbolLogos:d}=y.useMemo(()=>ka(c,i),[c,i]),u=oe(),{data:m}=Tt(u),h=y.useMemo(()=>m?.find(p=>p.id===Qe)?.price??0,[m]);return n.jsx("div",{className:Oe.container,children:n.jsxs(Z.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Oe.trigger,children:[n.jsxs("div",{className:Oe.chainInfo,children:[o&&n.jsx(ee,{src:o,width:32,height:32,className:Oe.logo,logo:!0}),n.jsxs("div",{className:Oe.chainNameContainer,children:[n.jsx("span",{className:Oe.chainName,children:s}),n.jsx("a",{href:ma,target:"_blank",rel:"noopener noreferrer",className:Oe.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,className:Oe.externalIcon})})]})]}),n.jsxs("div",{className:Oe.valueColumn,children:[n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:16,width:60,length:1}),children:n.jsx(mC,{})}),n.jsx(E.IconChevronDown,{size:16,className:D(Oe.expandIcon,{[Oe.expanded]:a})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Oe.collapsibleContent,children:n.jsxs("div",{className:Oe.content,children:[n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:36,length:2}),children:n.jsx(hC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:36,length:2}),children:n.jsx(fC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d})}),n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:36,length:1}),children:n.jsx(pC,{})})]})})]})})},_C="_totalValue_1v2ca_1",yC={totalValue:_C},xC=({filteredChainGroups:e})=>{const{totalValue:t}=Na(),{totalValue:s}=ao(),{totalValue:o}=ro(),a=t+s+o,r=y.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 n.jsx("span",{className:yC.totalValue,children:X(r)})},bC="_container_1eubu_1",wC="_header_1eubu_7",jC="_title_1eubu_13",vC="_list_1eubu_19",CC="_skeletonWrapper_1eubu_24",Wn={container:bC,header:wC,title:jC,list:vC,skeletonWrapper:CC},NC=y.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ls(),r=oe(),i=y.useMemo(()=>{const l=[];for(const u of o){if(!Array.isArray(u.positions))continue;const m=s.get(u.chainName.toLowerCase()),h=u.chainName.toLowerCase();if(t&&m?.chainId!==t||!u.positions.some(x=>x.positions.some(w=>w.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const p=u.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),g=r.chainId===m?.chainId,_=p.reduce((x,w)=>x+w.positions.reduce((C,b)=>C+An(b),0),0);l.push({chainId:m?.chainId??"",chainName:m?.prettyName??u.chainName,chainLogo:m?.logoUrl??"",protocols:p,isInitia:g,totalValue:_})}const d=["civitia","yominet"];return $.sortWith([$.descend(u=>u.isInitia??!1),$.ascend(u=>d.includes(u.chainName.toLowerCase())),$.descend(u=>u.totalValue??0),$.ascend(u=>u.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Wn.container,children:[n.jsxs("div",{className:Wn.header,children:[n.jsx("span",{className:Wn.title,children:"Positions"}),c&&n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:16,width:60,length:1}),children:n.jsx(xC,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Wn.list,children:i.map(l=>l.isInitia?n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Wn.skeletonWrapper,children:n.jsx(yt,{height:56,length:1})}),children:n.jsx(gC,{chainGroup:l})},l.chainName):n.jsx(Bj,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(yt,{height:56,length:3}):n.jsx(_e,{children:"No positions"})]})}),kC="_content_1w1ad_1",IC={content:kC},AC=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=se(),o=oe(),a=jm(),{totalValue:r}=ro(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=y.useMemo(()=>{const d=new Map;let u=0;for(const h of a)d.set(h.chainId,h.totalBalance),u+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),u+=r),{chainIds:$.sortWith([$.descend(h=>h===s),$.descend(h=>h===o.chainId),$.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:u}},[a,s,o,r]);return n.jsx(yo,{value:e,onChange:t,chainIds:i,renderExtra:d=>X(d?c.get(d)??0:l)})},SC=()=>{const[e,t]=Q.useAtom(tl),[s,o]=Q.useAtom(nl),a=me(),r=ns(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>ka(r,a),[r,a]),l=ia(),d=y.useMemo(()=>oc(a,l),[a,l]),u=wm();return n.jsxs(ct.Root,{children:[n.jsxs(ct.Controls,{children:[n.jsx(ct.SearchInput,{value:e,onChange:m=>t(m.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(pe,{suspenseFallback:n.jsx(an,{height:44,width:132}),children:n.jsx(AC,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("div",{className:IC.content,children:[n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:48,length:5}),children:n.jsx(Kw,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:u,chainPrices:d})}),n.jsx(pe,{suspenseFallback:n.jsx(yt,{height:56,length:3}),children:n.jsx(NC,{searchQuery:e,selectedChain:s,chainInfoMap:u})})]})]})},TC="_totalValue_5pf7e_1",EC="_totalLabel_5pf7e_7",$C="_totalAmount_5pf7e_13",MC="_loading_5pf7e_18",LC="_skeletonWrapper_5pf7e_23",qC="_nav_5pf7e_28",PC="_item_5pf7e_34",RC="_tabs_5pf7e_59",DC="_tab_5pf7e_59",Ve={totalValue:TC,totalLabel:EC,totalAmount:$C,loading:MC,skeletonWrapper:LC,nav:qC,item:PC,tabs:RC,tab:DC},BC=()=>{const{totalValue:e,isLoading:t}=ya();return n.jsx("div",{className:D(Ve.totalAmount,{[Ve.loading]:t}),children:X(e)})},FC=()=>{const e=vm(),t=Cm(),s=sc(),o=e+s+t;return n.jsx("div",{className:Ve.totalAmount,children:X(o)})},UC=()=>{Nc(),xm();const e=Ia(),t=Ie(),s=Zs(),o=y.useRef(null);return n.jsx(ol.Provider,{value:o,children:n.jsxs(dt,{ref:o,children:[n.jsxs("div",{className:Ve.totalValue,children:[n.jsx("div",{className:Ve.totalLabel,children:"Total value"}),n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Ve.skeletonWrapper,children:n.jsx(an,{height:48,width:120})}),children:e?n.jsx(BC,{}):n.jsx(FC,{})})]}),n.jsxs("div",{className:Ve.nav,children:[n.jsxs(Nn,{to:"/send",className:Ve.item,children:[n.jsx(E.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(Nn,{to:"/bridge",className:Ve.item,children:[n.jsx(E.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(Nn,{to:"/receive",className:Ve.item,children:[n.jsx(E.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Lt.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Lt.Tabs.List,{className:Ve.tabs,children:[n.jsx(Lt.Tabs.Tab,{className:Ve.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Lt.Tabs.Tab,{className:Ve.tab,value:"/nfts",children:"NFTs"}),n.jsx(Lt.Tabs.Tab,{className:Ve.tab,value:"/activity",children:"Activity"})]}),n.jsx(Lt.Tabs.Panel,{value:"/",children:e?n.jsx(Uw,{}):n.jsx(SC,{})}),n.jsx(Lt.Tabs.Panel,{value:"/nfts",children:n.jsx(Xb,{})}),n.jsx(Lt.Tabs.Panel,{value:"/activity",children:n.jsx(qb,{})})]})]})})},OC="_root_th990_1",VC="_collectionName_th990_9",KC="_nftName_th990_13",WC="_chainInfo_th990_17",zC="_attributes_th990_21",HC="_title_th990_24",QC="_count_th990_29",GC="_item_th990_33",YC="_type_th990_39",ZC="_value_th990_45",Xt={root:OC,collectionName:VC,nftName:KC,chainInfo:WC,attributes:zC,title:HC,count:QC,item:GC,type:YC,value:ZC},JC=()=>{const e=Ie(),t=Ze(),{attributes:s}=t;return n.jsxs(Nt,{title:"NFT details",children:[n.jsx(Fa,{normalizedNft:t,chainIconSize:14,classNames:Xt}),n.jsx(ke,{children:n.jsx(ue.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:Xt.attributes,children:[n.jsxs("header",{className:Xt.title,children:["Traits ",n.jsxs("span",{className:Xt.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:Xt.item,children:[n.jsx("div",{className:Xt.type,children:o}),n.jsx("div",{className:Xt.value,children:a})]},o))})]})]})};function XC({balances:e,gasPrices:t,gas:s}){return t.map(({denom:o,amount:a})=>{const r=U(a).times(s).toFixed(0,U.ROUND_CEIL),i=e.find(c=>c.denom===o)?.amount??"0";return{amount:r,denom:o,balance:i}}).filter(({amount:o,balance:a})=>U(a).gte(o))}function eN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(d=>d.denom===e)?.amount??"0",i=XC({balances:t,gasPrices:s,gas:a}),c=i.find(d=>d.denom===o);if(i.length===0)return r;if(e===o&&c){const d=U(r).minus(c.amount);return U.max(d,0).toString()}const l=i.find(d=>d.denom!==e)||i[0];if(!c&&e===l.denom){const d=U(r).minus(l.amount);return U.max(d,0).toString()}return U(r).toString()}const tN=({chain:e,onSelect:t})=>{const s=ql(e);return n.jsx(ps,{assets:s,onSelect:t})},nN=({afterSelect:e})=>{const{watch:t,setValue:s}=Ne.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=y.useState(r),l=lt(i),d=me(),u=m=>{if(o===i&&a===m){e();return}s("chainId",i),s("denom",m),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(on.Stack,{children:n.jsx(on,{chains:d,value:i,onSelect:c})}),n.jsx(pe,{suspenseFallback:n.jsx(ps.Placeholder,{}),children:n.jsx(tN,{chain:l,onSelect:u})},i)]})},sN="_fields_brpej_1",oN="_divider_brpej_11",Br={fields:sN,divider:oN},aN=Se.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),rN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=Je(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=Ne.useFormContext(),{errors:d}=l,{chainId:u,denom:m,recipient:h,quantity:f,memo:p}=r(),g=lt(u),_=ss(g),x=ga(g),w=_a(g),C=Xr(m,g),{data:b}=Tt(g),{decimals:j}=C,k=_.find(K=>K.denom===m)?.amount??"0",T=b?.find(({id:K})=>K===m)?.price,{data:L=0,isLoading:A}=S.useQuery({queryKey:aN.gas({chainId:u,denom:m,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const K=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Ga.MsgSend.fromPartial({fromAddress:t,toAddress:v.InitiaAddress(h).bech32,amount:[{denom:m,amount:"1"}]})}];return s({messages:K,chainId:u})},enabled:v.InitiaAddress.validate(h),staleTime:W.INFINITY}),M=Math.ceil(L*cn),N=eN({denom:m,balances:_,gasPrices:x,lastFeeDenom:w,gas:M}),I=U(k).isZero(),q=x.some(({denom:K})=>K===m)&&A,P=I||q,{mutate:B,isPending:H}=S.useMutation({mutationFn:({chainId:K,denom:le,quantity:ye,recipient:he,memo:xe})=>{const be=v.toBaseUnit(ye,{decimals:j}),De=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Ga.MsgSend.fromPartial({fromAddress:t,toAddress:v.InitiaAddress(he).bech32,amount:[{denom:le,amount:be}]})}];return o({messages:De,memo:xe,chainId:K,gas:L,gasAdjustment:cn,gasPrices:x,spendCoins:[{denom:le,amount:be}],internal:"/"})}}),z=y.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 n.jsx(Nt,{title:"Send",children:n.jsxs("form",{onSubmit:c(K=>B(K)),children:[n.jsxs("div",{className:Br.fields,children:[n.jsx(Qo,{selectButton:n.jsx(Sn,{title:"Select chain and asset",content:K=>n.jsx(nN,{afterSelect:K}),children:n.jsx(Ec,{asset:C,chain:g})}),quantityInput:n.jsx(es,{balance:k,decimals:j}),balanceButton:n.jsx(kc,{onClick:()=>i("quantity",v.fromBaseUnit(N,{decimals:j}),{shouldValidate:!0}),disabled:P,children:v.formatAmount(k??"0",{decimals:j})}),value:f?T?X(U(f).times(T)):"$-":"$0"}),n.jsx("div",{className:Br.divider}),n.jsx(Ma,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:K=>!K||new Blob([K]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(ge.Stack,{children:!p&&n.jsx(ge,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(ke,{children:n.jsx(ue.White,{type:"submit",loading:(A?"Estimating gas...":!1)||H,disabled:!!z,children:z??"Confirm"})})]})})},iN=()=>{const e=Ze(),t=un(),s=Ft(t),{chain:o=t}=e,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=Ne.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return n.jsx(Ne.FormProvider,{...i,children:n.jsx(rN,{})})};async function na(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await G.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function cN(e,t){const s=new xt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await G.create({prefixUrl:t}).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 lN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await G.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function dN({collection_addr:e},{restUrl:t}){const s=await cN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await na(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${v.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function uN(e,t){const{data:s}=await G.create({prefixUrl:t}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function mN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await uN(t,s);return o.startsWith("ibc/")?v.InitiaAddress.equals(v.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await na(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await na(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function hN(e,t){const s=re.toBase64(tn.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await G.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function fN(e,t){const{collection:s}=await G.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function pN(e,t){const s=re.toBase64(tn.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await G.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function Fr(e){const t=/^(.*channel-\d+)\/(.*)$/,s=e.match(t);if(!s)throw new Error("Pattern `channel-{number}/` not found.");const[,o,a]=s;return[o,a]}async function gN({collection_addr:e},t,s){const o=v.InitiaAddress(e).bech32,a=await hN(o,t.restUrl),r=t.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=re.toBase64(tn.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await G.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),u=d??o,m=await pN(c,t.restUrl),h=await fN(o,t.indexerUrl);if(u===o)return{class_id:u,class_trace:void 0,outgoing_proxy:m};if(d&&h!==i.replace("wasm.","")){const[g,_]=Fr(d);return{class_id:o,class_trace:{path:g,base_class_id:_},outgoing_proxy:m}}const[f,p]=Fr(a);return{class_id:o,class_trace:{path:f,base_class_id:p},outgoing_proxy:m}}const _N={minimove:mN,minievm:dN,miniwasm:gN};async function yN({nft:e,srcChain:t,intermediaryChain:s}){const o=t.metadata?.is_l1?"minimove":t.metadata?.minitia?.type;if(!(o==="minimove"||o==="minievm"||o==="miniwasm"))throw new Error(`Unsupported minitia type: ${o}`);const a=await _N[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await lN([e.token_id],a.class_id,t.restUrl)})}const xN="_root_1tyvn_1",bN="_collectionName_1tyvn_10",wN="_nftName_1tyvn_15",jN="_chainInfo_1tyvn_19",vN="_fields_1tyvn_24",CN="_chain_1tyvn_19",Oo={root:xN,collectionName:bN,nftName:wN,chainInfo:jN,fields:vN,chain:CN},NN=Se.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),kN=()=>{const e=me(),t=Ze(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=se(),r=rs(),i=oe(),{address:c,initiaAddress:l,requestTxSync:d}=Je(),{watch:u,setValue:m,handleSubmit:h,formState:f}=Ne.useFormContext(),{errors:p}=f,g=u(),{recipient:_,dstChainId:x}=g,w=lt(x),C=S.useQuery({queryKey:NN.simulation({collection_addr:o,nft:t,sender:l,recipient:_,srcChain:s,dstChain:w,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:w.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==w.chainId&&await yN({nft:t,srcChain:s,intermediaryChain:i})),{msgs:I}=await G.create({prefixUrl:a}).post("nft",{json:N}).json();return I.map(F=>r.fromAmino(F))},enabled:v.InitiaAddress.validate(_)}),{data:b,isLoading:j,error:k}=C,T=S.useQueryClient(),{mutate:L,isPending:A}=S.useMutation({mutationFn:async()=>{if(!b)throw new Error("Route not found");await d({messages:b,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{T.invalidateQueries({queryKey:Ua.nfts._def})}}),M=y.useMemo(()=>{if(!_)return"Enter recipient address";if(p.recipient)return p.recipient.message;if(k)return"Route not found"},[_,p.recipient,k]);return n.jsxs("form",{onSubmit:h(()=>L()),children:[n.jsx(Fa,{normalizedNft:t,thumbnailSize:80,classNames:Oo}),n.jsxs("div",{className:Oo.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination appchain"}),n.jsxs(Sn,{title:"Destination appchain",content:N=>n.jsx(Tc,{onSelect:({chainId:I})=>{m("dstChainId",I),N()},list:e,getImage:I=>I.logoUrl,getName:I=>I.name,getKey:I=>I.chainId}),className:D("input",Oo.chain),children:[n.jsx(ee,{src:w.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:w.name})]})]}),n.jsx(Ma,{myAddress:c,ref:ms()})]}),n.jsx(ke,{children:n.jsx(ue.White,{loading:(j?"Finding route...":!1)||A,disabled:!!M,children:M??"Confirm"})})]})},IN=()=>{const{chain:e}=Ze(),t=Ne.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(Nt,{title:"Send NFT",children:n.jsx(Ne.FormProvider,{...t,children:n.jsx(kN,{})})})},sa=()=>{const e=Ie(),t=Zs(),s=Ot(),{closeDrawer:o}=Et(),{closeModal:a}=no();y.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=Tn();if(y.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(Sr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(Sr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(UC,{});case"/send":return n.jsx(iN,{},s);case"/receive":return n.jsx(d2,{});case"/nft":return n.jsx(JC,{});case"/nft/send":return n.jsx(IN,{},s);case"/bridge":return n.jsx(H_,{},s);case"/bridge/preview":return n.jsx(lx,{});case"/bridge/history":return n.jsx(Fy,{});case"/op/withdrawals":return n.jsx(Px,{});case"/tx":return n.jsx(yc,{});case"/autosign/enable":return n.jsx(Ep,{});case"/settings":return n.jsx(D2,{});case"/settings/autosign":return n.jsx(k2,{});case"/deposit":return n.jsx(Y0,{});case"/deposit/completed":return n.jsx(ta,{type:"deposit"});case"/withdraw":return n.jsx(Z0,{});case"/withdraw/completed":return n.jsx(ta,{type:"withdraw"})}},AN="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",SN=()=>n.jsxs(n.Fragment,{children:[n.jsx("link",{rel:"preconnect",href:"https://fonts.googleapis.com"}),n.jsx("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:""}),n.jsx("link",{rel:"stylesheet",href:AN}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),TN=()=>(Nm(),sd(),Ad(),me(),bm(),sc(),ns(),null),EN=({children:e,...t})=>(y.useEffect(()=>{Ju()},[]),We.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(SN,{}),n.jsx(Gr.Provider,{value:{...Qr,...t},children:n.jsx(ri,{children:n.jsx(ep,{children:n.jsx(Z.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(Xf,{children:n.jsxs(Uf,{children:[e,n.jsx(km,{}),n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(TN,{})}),n.jsx(yh,{children:n.jsx(sa,{})}),n.jsx(fh,{children:n.jsx(sa,{})})]})})})})})})]}):null),$N=({bridge:e})=>n.jsx(ri,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(mc.Provider,{value:!!e,children:n.jsx(pe,{children:n.jsx(sa,{})})})})});exports.DEFAULT_GAS_ADJUSTMENT=cn;exports.DEFAULT_GAS_PRICE_MULTIPLIER=Hr;exports.InterwovenKit=$N;exports.InterwovenKitProvider=EN;exports.MAINNET=Qr;exports.MoveError=Li;exports.PRIVY_APP_ID=ra;exports.TESTNET=Cl;exports.initiaPrivyWallet=kl;exports.initiaPrivyWalletConnector=Nl;exports.initiaPrivyWalletOptions=Gn;exports.injectStyles=Km;exports.useAddress=Ot;exports.useHexAddress=$n;exports.useInitiaAddress=te;exports.useInterwovenKit=Je;exports.usePortfolio=ya;exports.useUsernameQuery=zi;