@initia/interwovenkit-react 2.5.0 → 2.5.1
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 +1 -1
- package/dist/index.js +123 -123
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
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 ed(e,t){const s=ut.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=ut.hexToBytes(ut.keccak256(ut.bytesToHex(o))),r=dt.Bip39.encode(a),i=await dt.Bip39.mnemonicToSeed(r),c=dt.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=dt.Slip10.derivePath(dt.Slip10Curve.Secp256k1,i,c),d=await dt.Secp256k1.makeKeypair(l),m=dt.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=ut.bytesToHex(h),g=ut.keccak256(f),p=ut.hexToBytes(g).slice(-20),_=ae.toBech32(t,p);return{privateKey:l,publicKey:m,address:_}}function ws(e,t){return`${e}:${t}`}const as=H.atom(null),Zn=H.atom({}),Jn=H.atom({}),eo=H.atom({}),nr=H.atom(0),td="autosign:";function nd(e,t){const s=e.get(nr)+1;return e.set(nr,s),`${t}:${s}`}function Rs(e,t){return e.get(eo)[t]}function sd(e,t,s){e.set(eo,o=>({...o,[t]:s}))}function _i(e,t){e.set(eo,s=>{const o={...s};return delete o[t],o})}function od(e,t,s){const o=Rs(e,t);!o||o.token!==s||_i(e,t)}function ad(e,t,s){const o=Rs(e,t);return!!o&&o.token===s}function vs(e,t){return e.get(Jn)[t]}function rd(e,t,s){e.set(Jn,o=>({...o,[t]:s}))}function id(e,t){e.set(Jn,s=>{const o={...s};return delete o[t],o})}function cd(e,t,s){e.set(Zn,o=>({...o,[t]:s}))}function ld(e,t){e.set(Zn,s=>{const o={...s};return delete o[t],o})}function yi(e,t){return`${td}${e}:${t}`}function dd(e,t,s){try{return e.getItem(yi(t,s))}catch{return null}}function ud(e,t,s,o){try{e.setItem(yi(t,s),o)}catch{}}function xi(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ha(e,t){const s=xi();if(s)return dd(s,e,t)}function md(e,t,s){const o=xi();o&&ud(o,e,t,s)}function hd(e){return{publicKey:e.publicKey,address:e.address}}function Ds(e){e&&e.fill(0)}function bi(e){e.set(eo,{});const t=e.get(Jn);for(const s of Object.values(t))Ds(s);e.set(Jn,{}),e.set(Zn,{})}function fd(e,t){return e!==""&&e!==t}function pd(){const e=se(),t=H.useStore(),s=y.useRef(e);y.useEffect(()=>{const o=s.current;fd(o,e)&&bi(t),s.current=e},[t,e])}class gd{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=Gn.escapeCharacters(Gn.sortedJsonStringify(s)),a=vt.ethers.hashMessage(o),r=ae.fromHex(a.replace("0x","")),i=await dt.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=gi(this.wallet.publicKey,c);return{signed:s,signature:l}}}function to(){const e=H.useStore(),{signMessageAsync:t}=We.useSignMessage(),s=Je(),o=se();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const m=s(d),u=ws(o,m.bech32_prefix),h=e.get(Zn)[u];if(h&&vs(e,u))return h;const f=Rs(e,u);if(f)return f.promise;const g=nd(e,u),p=(async()=>{try{const _=window.location.origin,x=Xl(_),b=await t({message:x}),j=await ed(b,m.bech32_prefix),w=hd(j);if(ad(e,u,g))return rd(e,u,j.privateKey),cd(e,u,w),w;throw Ds(j.privateKey),new Error("Wallet derivation was cancelled")}finally{od(e,u,g)}})();return sd(e,u,{promise:p,token:g}),p},getWallet:d=>{if(!o)return;const m=s(d),u=ws(o,m.bech32_prefix);if(vs(e,u))return e.get(Zn)[u]},getWalletPrivateKey:d=>{if(!o)return;const m=s(d),u=ws(o,m.bech32_prefix);return vs(e,u)},clearWallet:d=>{if(!o)return;const m=s(d),u=ws(o,m.bech32_prefix),h=vs(e,u);Rs(e,u)&&_i(e,u),Ds(h),id(e,u),ld(e,u)},clearAllWallets:()=>{bi(e)}}}function wi({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:ra.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function _d({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=wi({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:t},u=new Uint8Array(i),h=new gd(r,u);try{return await l(e,r.address,d,m,a,{customSigner:h})}finally{Ds(u)}}const yt="interwovenkit",Ye="uinit",mt="INIT",rt=6,yd="uoinit",xd="omniINIT",vi="https://app.initia.xyz",fa=`${vi}/liquidity/my`,bd=`${vi}/vip/my`,wd=1e3,ji=60*wd,Ci=60*ji,sr=24*Ci,ie={PUBLIC_KEY:`${yt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${yt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${yt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${yt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${yt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${yt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${yt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${yt}:bridge:route-type`,BRIDGE_HISTORY:`${yt}:bridge:history`,OP_REMINDER:`${yt}:op:reminder`},Ni=H.atom(!1),ki=H.atom(!1);function qt(){const e=ua(),[t,s]=H.useAtom(Ni),o=H.useSetAtom(ki),a=qn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function Pn(){const e=ua(),[t,s]=H.useAtom(ki),o=H.useSetAtom(Ni),a=qn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ii(){const e=Se(),{closeDrawer:t}=qt(),{closeModal:s}=Pn(),{disconnect:o}=We.useDisconnect(),{clearAllWallets:a}=to();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 vd(){const e=Qt(),t=yn(),{openModal:s}=Pn();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(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function jd(){const e=Qt(),t=yn(),{openModal:s}=Pn();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(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Cd(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Ko.PubKey.decode(e.value);return Tn.encodeSecp256k1Pubkey(t)}return Hs.decodeOptionalPubkey(e)}function Nd({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Cl.BaseAccount.decode(t),i=Cd(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ee.accountFromAny({typeUrl:e,value:t})}const Ai="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Si="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Ti="cosmos-sdk/AllowedMsgAllowance";function kd(){const e=fn.aminoConverters[Ai];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Bs=kd();function Ei(e){if(e.typeUrl===Si){const t=an.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Ti,value:{allowance:Ei(t.allowance),allowed_messages:t.allowedMessages}}}return Bs.toAmino({granter:"",grantee:"",allowance:e}).allowance}function $i(e){if(e.type===Ti){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=$i(t.allowance);return{typeUrl:Si,value:an.AllowedMsgAllowance.encode(an.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Bs.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Id={...fn.aminoConverters,[Ai]:{...Bs,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Ei(e.allowance)}:Bs.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:$i(e.allowance)})}},rs=()=>{const e=ne();return new Hs.Registry([...fn.protoRegistry,...e.protoTypes??[]])},is=()=>{const e=ne();return new Ee.AminoTypes({...Id,...e.aminoConverters})};class Ad{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=ae.fromHex(s),ae.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,ae.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,ae.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?ae.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=vt.ethers.hashMessage(t),a=vt.ethers.SigningKey.recoverPublicKey(o,s);return dt.Secp256k1.compressPubkey(ae.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=Gn.escapeCharacters(Gn.sortedJsonStringify(s)),a=await this.signMessage(o),r=ae.fromHex(a.replace("0x","")).subarray(0,-1),c=dt.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=gi(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Mi(){const e=rs(),t=is(),s=cs(),o=no();return async function(a,r,i,c,l,d){const m=d?.customSigner??s;if(!m)throw new Error("Signer not initialized");const u=await o(a),{accountNumber:h,sequence:f}=await Li({getSequence:N=>u.getSequence(N),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[g]=await m.getAccounts(),p=pi(ma(g.pubkey)),_=Zr.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),b=Gn.makeSignDoc(x,c,a,l,h,f),{signature:j,signed:w}=await m.signAmino(r,b),k={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:w.msgs.map(N=>t.fromAmino(N)),memo:l}},T=e.encode(k),M=Qa.Int53.fromString(w.fee.gas).toNumber(),A=Qa.Int53.fromString(w.sequence).toNumber(),L=Hs.makeAuthInfoBytes([{pubkey:p,sequence:A}],w.fee.amount,M,w.fee.granter,w.fee.payer,_);return Ge.TxRaw.fromPartial({bodyBytes:T,authInfoBytes:L,signatures:[ae.fromBase64(j.signature)]})}}function Sd(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Li({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&&Sd(a,t))return{accountNumber:0,sequence:s};throw a}}function cs(){const e=se(),{signMessageAsync:t}=We.useSignMessage(),s=oe();return y.useMemo(()=>new Ad(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const vo=new Map,Ms=new Map;function Td(e,t){const s=`${e}:${t}`;Ms.delete(s)}function pa(){const e=Je();return async t=>{if(vo.has(t))return vo.get(t);const{rpcUrl:s}=e(t),o=await Ga.Comet38Client.create(new Ga.HttpClient(s));return vo.set(t,o),o}}function no(){const e=rs(),t=is(),s=cs(),o=se(),a=pa();return async r=>{const i=`${o}:${r}`;if(Ms.has(i))return Ms.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Ee.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:Nd,broadcastPollIntervalMs:500});return Ms.set(i,l),l}}function qi(){const{connector:e}=We.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new vt.BrowserProvider(await e.getProvider())}}class un extends Error{constructor(t){super(t),this.name="TimeoutError"}}function Pi(e,t,s){let o;const a=new Promise((r,i)=>{o=setTimeout(()=>i(new un(s)),t)});return Promise.race([e,a]).finally(()=>{clearTimeout(o)})}function Ri(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Di(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function Ed(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Bi(){const e=se(),t=Je();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:d}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return d}catch(d){if(d instanceof z.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=z.create({prefixUrl:c.restUrl}),{grants:d}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return d},fetchAllGrants:async r=>{const i=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Ys(l,{prefixUrl:i.restUrl},"grants");return Ri(d)}}}const Fs=$e.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),$d=4,Fi=4;function Md(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function ga(){const e=ne(),t=yn(),{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 Ld(){const{data:e}=so(),t=ga();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 so(){const e=se(),t=ga(),s=Md(t),{fetchFeegrant:o,fetchAllGrants:a}=Bi();return S.useQuery({queryKey:Fs.expirations(e,s,t).queryKey,queryFn:()=>qd({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:K.MINUTE,retry:1})}async function qd(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[u,h]of Object.entries(s))r[u]=null,i[u]=void 0,c[u]=!1,h.length>0&&d.push([u,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await Ui(d,$d,async([u,h])=>{const f=ha(t,u);try{const g=await o(u),p=f===void 0?g:f===null?[]:g.filter(k=>k.grantee===f),_=Dd(p,h);if(_.length===0)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const x=await Rd({chainId:u,candidates:_,fetchFeegrant:a,concurrency:Fi});if(!x)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const b=x.grantee.grants.filter(k=>h.includes(k.authorization.msg)).map(k=>k.expiration),j=Di(x.feegrant.allowance),w=[...b,j],v=_a(w);return{chainId:u,expectedAddress:f,expiration:v?new Date(v):void 0,grantee:x.grantee.grantee}}catch{return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0}}});for(const u of m)l[u.chainId]=u.expectedAddress,r[u.chainId]=u.expiration,i[u.chainId]=u.grantee;for(const[u]of d)c[u]=Bd({expiration:r[u],grantee:i[u],expectedAddress:l[u]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function Ui(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 Pd(e){const t=Ed(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Di(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Ze.isFuture(a)}async function Rd(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Fi}=e,r=await Ui(s,a,async i=>{const c=await o(t,i.grantee);return c&&Pd(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function Dd(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||Ze.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 Bd(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&&Ze.isFuture(t)}}function Fd(){const{data:e,refetch:t}=so();y.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Ze.isFuture(c));if(o.length===0)return;const a=_a(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 _a(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 Oi=y.createContext(null),oo=()=>y.useContext(Oi);class Vi 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 Ud=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,jo=new Map;function Od(e){const t=e.match(Ud);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 Vd(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 z.get(r).json();return jo.set(o,i),i}catch{return null}}function Kd(e,t,s,o,a,r,i){return new Vi(e,t,s,o,a,r,i)}async function Nn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await Ct(e);const o=Od(e.message);if(!o)return await Ct(e);const a=await Vd(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 Kd(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Wd=10;function Ki(){const e=se();return(t,s)=>S.queryOptions({queryKey:Zs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Wd},{txs:a}=await z.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:K.SECOND})}function zd(e,t){const s=Ki();return S.useSuspenseQuery(s(e,t))}function Hd(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 Qd=()=>{const e=he(),t=Ki(),s=S.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map($.prop("data")),a=Hd(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Wi(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await z.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.toSorted($.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:ti;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 ya(e){const{data:t}=S.useSuspenseQuery({queryKey:Gs.gasPrices(e).queryKey,queryFn:()=>Wi(e),staleTime:K.SECOND});return t}function xa(e){const t=se(),{data:s}=zd(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>C.InitiaAddress.equals(t,vt.computeAddress(`0x${ae.toHex(dt.Secp256k1.uncompressPubkey(ae.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const zi="approve",ao=H.atom(),Hi=H.atom(null),Gd=pn,Yd=1.5;function Zd({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 Jd({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=Zd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Ee.calculateFee(l,Ee.GasPrice.fromString(`${d.amount}${d.denom}`))}function Xd({derivedAddress:e,messages:t,encoder:s}){return{messages:wi({granteeAddress:e,messages:t,encoder:s})}}function eu(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 tu({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Ee.createProtobufRpcClient(e),i=new Ya.ServiceClientImpl(r),c=Ge.Tx.fromPartial({authInfo:Ge.AuthInfo.fromPartial({fee:Ge.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:Zr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ge.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(Ya.SimulateRequest.fromPartial({txBytes:Ge.Tx.encode(c).finish()}))}function nu(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function su({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const m=async()=>d.signWithEthSecp256k1(t,e,s,a,o),u=(_,x)=>{d.onAutoSignFallback?.({chainId:t,reason:_,errorMessage:nu(x)})};if(!c)return m();if(!d.validateAutoSign(t,s))return u("validation_failed"),m();let f=d.getWallet(t),g=!1;if(!f&&l)try{f=await d.deriveWallet(t)}catch(_){if(eu(_))throw _;u("derive_wallet_failed",_),g=!0,f=void 0}if(!f)return g||u("missing_derived_wallet"),m();let p;try{const _=i??await d.getSigningClient(t);p=await d.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return u("fee_computation_failed",_),m()}try{return await d.signWithDerivedWallet(t,e,s,p,o,f)}catch(_){return u("derived_wallet_sign_failed",_),m()}}function Qi(){const e=se(),{autoSignFeePolicy:t}=ne(),s=Je(),o=pa(),a=no(),r=rs(),i=Ld(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=to(),m=Mi(),u=qn(),h=p=>{const _=t?.[p];return{gasMultiplier:_?.gasMultiplier??Gd,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??Yd,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:p,messages:_,memo:x,derivedWallet:b,preferredFeeDenom:j,fallbackFeeDenom:w,client:v})=>{const k=s(p),T=await Wi(k),A=Xd({derivedAddress:b.address,messages:_,encoder:r}).messages.map(Q=>r.encodeAsAny(Q)),L=pi(ma(b.publicKey)),{sequence:N}=await Li({getSequence:Q=>v.getSequence(Q),signerAddress:b.address,incrementSequence:0,allowMissingAccount:!0}),I=await o(p),F=Ee.QueryClient.withExtensions(I,Ee.setupTxExtension),{gasInfo:q}=await tu({queryClient:F,messages:A,memo:x,pubkey:L,sequence:N}),P=q?Number(q.gasUsed.toString()):0,B=h(p);return Jd({simulatedGas:P,gasPrices:T,preferredFeeDenom:j,fallbackFeeDenom:w,policy:B})},g=async(p,_,x,b,j,w)=>{let v=w??c(p);v||(v=await l(p));const k=d(p);if(!k)throw new Error("Derived wallet key not initialized");return await _d({chainId:p,granterAddress:_,messages:x,fee:b,memo:j,derivedWallet:v,privateKey:k,encoder:r,signWithEthSecp256k1:m})};return p=>su({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:_,reason:x,errorMessage:b})=>{u("AutoSign Fallback",{chainId:_,reason:x,errorMessage:b})}})}function Gi(){const e=H.useAtomValue(ao);if(!e)throw new Error("Tx request not found");return e}function ro(){const e=Se(),t=se(),{defaultChainId:s,registryUrl:o}=ne(),a=Je(),{openDrawer:r,closeDrawer:i}=qt(),{openModal:c,closeModal:l}=oo(),d=H.useSetAtom(ao),m=H.useSetAtom(Hi),u=pa(),h=no(),f=cs(),g=rs(),p=Qi(),_=async({messages:A,memo:L,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,L)}catch(I){throw await Nn(I,a(N),o)}},x=async({messages:A,memo:L,chainId:N=s})=>{const I=await u(N),F=Ee.QueryClient.withExtensions(I,Ee.setupTxExtension),q=A.map(O=>g.encodeAsAny(O)),[P]=await f.getAccounts(),B=Tn.encodeSecp256k1Pubkey(P.pubkey),Q=await h(N),{sequence:W}=await Q.getSequence(t);return F.tx.simulate(q,L,B,W)},b=async({txRequest:A,broadcaster:L})=>{const I={...{memo:"",chainId:s,gas:A.gas||await _(A),gasAdjustment:pn,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((F,q)=>{d({txRequest:I,resolve:async B=>{try{const Q=await h(I.chainId),W=await L(Q,Ge.TxRaw.encode(B).finish());F(W),typeof I.internal=="string"&&e(I.internal)}catch(Q){q(await Nn(Q,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()}})},j=async A=>{const L=A.chainId??s;try{const N=await b({txRequest:A,broadcaster:async(I,F)=>await I.broadcastTxSync(F)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:L,status:"loading"}),M({txHash:N,chainId:A.chainId}).then(I=>{m({status:I.code===0?"success":"error",chainId:L,txHash:N})}).catch(()=>{m({status:"error",chainId:L,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:L,error:N}),N}},w=(A,L=30*1e3,N=.5*1e3)=>b({txRequest:A,broadcaster:async(I,F)=>{const q=await I.broadcastTx(F,L,N);if(q.code!==0)throw new Error(q.rawLog);return q}}),v=async({chainId:A,messages:L,memo:N="",fee:I,preferredFeeDenom:F})=>{const q=await h(A),P=await p({chainId:A,messages:L,memo:N,fee:I,preferredFeeDenom:F,client:q,allowWalletDerivation:!0});return{client:q,signedTx:P}},k=async A=>{const L=A.chainId??s;try{const{client:N,signedTx:I}=await v({...A,chainId:L});return await N.broadcastTxSync(Ge.TxRaw.encode(I).finish())}catch(N){throw await Nn(N,a(L),o)}},T=async(A,L=30*1e3,N=.5*1e3)=>{const I=A.chainId??s;try{const{client:F,signedTx:q}=await v({...A,chainId:I}),P=await F.broadcastTx(Ge.TxRaw.encode(q).finish(),L,N);if(P.code!==0)throw new Error(P.rawLog);return P}catch(F){throw await Nn(F,a(I),o)}},M=async({chainId:A=s,...L})=>{try{const N=await h(A);return await Yi({...L,client:N})}catch(N){throw N instanceof un?N:await Nn(N,a(A),o)}};return{estimateGas:_,simulateTx:x,requestTxSync:j,requestTxBlock:w,submitTxSync:k,submitTxBlock:T,waitForTxConfirmation:M}}async function Yi({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 un(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const ou="/cosmos.authz.v1beta1.MsgExec";function au(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function ru(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function iu(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function cu(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function Zi(e){const t=[Fs.expirations._def,Fs.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function Ji(){const e=se(),{fetchFeegrant:t,fetchGrants:s}=Bi();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:Jr.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=cu(c).map(u=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:ra.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:u})}));return[...l,...m]}}function lu(){const e=se(),t=ga(),{requestTxBlock:s}=ro(),o=S.useQueryClient(),[a,r]=H.useAtom(as),{closeDrawer:i}=qt(),c=Ji(),{deriveWallet:l}=to();return S.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const u=t[m];if(!u||u.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Td(e,m);const f=ha(e,m),g=ru({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(g.map(k=>c({chainId:m,grantee:k})))).flat(),x=d===0?void 0:Ze.addMilliseconds(new Date,d),b={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:an.BasicAllowance.encode(an.BasicAllowance.fromPartial({expiration:x})).finish()},j={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Jr.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:an.AllowedMsgAllowance.encode(an.AllowedMsgAllowance.fromPartial({allowance:b,allowedMessages:[ou]})).finish()}})},w=u.map(k=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:ra.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:Za.GenericAuthorization.encode(Za.GenericAuthorization.fromPartial({msg:k})).finish()},expiration:x}})})),v=[..._,j,...w];return await s({messages:v,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:m})=>{e&&md(e,d,m.address),await Zi(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function Xi(e){const t=ne(),s=he(),o=Je(),{getWallet:a,clearWallet:r}=to(),{requestTxBlock:i}=ro(),c=S.useQueryClient(),l=Ji(),{data:d,refetch:m}=so();return S.useMutation({mutationFn:async(u=t.defaultChainId)=>{const h=a(u),f=d?.granteeByChain[u];let g;e?.grantee||(g=(await m()).data?.granteeByChain[u]);const p=au({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const x=(await Promise.all(p.map(b=>l({chainId:u,grantee:b})))).flat();return x.length===0?{chainId:u,didBroadcast:!1}:(await i({messages:x,chainId:u,internal:e?.internal}),{chainId:u,didBroadcast:!0})},onSuccess:async({chainId:u,didBroadcast:h})=>{await Zi(c);const f=o(u),g=s.filter(w=>w.bech32_prefix===f.bech32_prefix).map(w=>w.chain_id).filter(w=>w!==u);let p;try{p=(await m()).data}catch{p=void 0}const _=p??d;let x=!1;g.length>0&&_&&(x=g.some(w=>_?.isEnabledByChain[w]));const b=h?p?.isEnabledByChain[u]:(p??d)?.isEnabledByChain[u];iu({isEnabledOnTargetChain:b,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(u)}})}function du(){const{defaultChainId:e}=ne(),{openDrawer:t}=qt(),s=H.useSetAtom(as),o=Xi(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=so();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,m)=>{s({chainId:l,resolve:d,reject:m}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function ec(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function uu(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),U(0)).toString()}function mu(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??da}}function or(e){return $.pick(["chainId","name","logoUrl"],e)}function hu(e){return $.sortWith([$.descend(({symbol:t})=>t===mt),$.descend(ec),$.descend(({assets:t})=>t.length),$.ascend(({symbol:t})=>t)])(e)}function fu(e){return $.sortWith([$.descend(({value:t})=>t??0),$.descend(({quantity:t})=>Number(t)),$.ascend(({chain:t})=>t.name)])(e)}function pu(e,t){return $.sortWith([$.descend(({chain:s})=>s.chainId===t),$.ascend(({chain:s})=>s.name),$.ascend(({denom:s})=>s)])(e)}function gu(e,t){return $.sortWith([$.descend(({chainId:s})=>s===t),$.descend($.prop("value"))])(e)}function _u(e,t,s,o,a){const r=e.find(u=>u.metadata?.is_l1)?.chainId,i={};for(const u of e){const h=u.chainId,f=t[h]??[],g=s[h],p=o[h],_=[];for(const{amount:x,denom:b}of f){if(!U(x).gt(0))continue;const j=g?.find(M=>M.denom===b),w=p?.find(M=>M.id===b)?.price,v=j?.decimals??0,k=C.fromBaseUnit(x,{decimals:v}),T=w?U(k).times(w).toNumber():void 0;_.push({...mu(b,j),amount:x,denom:b,decimals:v,quantity:k,price:w,value:T,address:j?.address,unlisted:!j,chain:or(u)})}i[h]=_}const c=new Map;for(const[u,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===u);if(!f)continue;const g=h.reduce((p,{value:_})=>p+(_??0),0);c.set(u,{...or(f),value:g})}const l=new Map;for(const u of Object.values(i))for(const h of u)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const d=[];for(const[u,h]of l){const f=$.head(h);if(!f)continue;const g=fu(h),p=g.reduce((x,{value:b})=>x+(b??0),0),_=g.reduce((x,{quantity:b})=>x.plus(b),U(0)).toNumber();d.push({symbol:u,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:_})}const m=[];for(const u of Object.values(i))for(const h of u)h.unlisted&&m.push(h);return{chainsByValue:gu(Array.from(c.values()),a),assetGroups:hu(d),unlistedAssets:pu(m,r),totalValue:d.reduce((u,h)=>u+h.totalValue,0)}}function ba(){const{defaultChainId:e}=ne(),t=he(),s=zl(),o=ss(),a=la(),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=_u(t,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function se(){const e=Rn();return e?C.InitiaAddress(e).bech32:""}function Rn(){const{address:e}=We.useAccount();return e?C.InitiaAddress(e).hex:""}function Qt(){const e=yn(),t=se(),s=Rn();return e.metadata?.minitia?.type==="minievm"?s:t}function tc(e){const t=Qt(),s=e??t,o=li();return S.useQuery({queryKey:Zs.username(o.restUrl,s).queryKey,queryFn:()=>o.getUsername(s),enabled:!!s,staleTime:K.MINUTE})}function et(){const e=Qt(),t=se(),s=Rn(),{data:o}=tc(),a=cs(),r=Ii(),i=du(),{isDrawerOpen:c,openDrawer:l}=qt(),{isModalOpen:d}=Pn(),m=()=>{l("/")},u=()=>{l("/connect")},h=b=>{l("/bridge",b)},f=vd(),g=jd(),p=ro();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:u,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const yu="_status_tn9m1_1",xu="_error_tn9m1_9",ar={status:yu,error:xu},be=({error:e,children:t})=>n.jsx("p",{className:D(ar.status,{[ar.error]:e}),role:e?"alert":"status",children:t}),pe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(be,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(be,{children:"Loading..."}),children:s})=>n.jsx(Xr.ErrorBoundary,{...e,children:n.jsx(y.Suspense,{fallback:t,children:s})}),gn=1n<<64n,bu=1n<<63n,nc=(1n<<128n)-1n;function Ht(e){const t=BigInt(e);return t>=bu?t-gn:t}const wu=(1n<<256n)-1n,Kt=443636n,vu=4295048017n,ju=18446744073709551616n,Cu=79226673515401279992447579062n,Nu=255738958999603826347141n;function ku(e,t,s){const o=Number(Ht(e)),a=Number(Ht(t)),r=Math.floor(-Number(Kt)/s)*s,i=Math.floor(Number(Kt)/s)*s;return o===r&&a===i}function sc(e){return e>>64n}function Iu(e){const t=e>>64n;return e%gn!==0n?t+1n:t}function $n(e){if(e<0n||e>nc)throw new Error("INPUT_OUT_OF_RANGE");return e}function Au(e,t){const s=e*t>>64n;if(s>nc)throw new Error("OVERFLOW");return s}function wa(e,t){return e>t?[t,e]:[e,t]}function Su(e,t,s,o){if(e===t)return 0n;const[a,r]=wa(e,t);if(a===0n||r===0n)return 0n;const i=s*gn,c=r-a,l=i*c;if(l===0n)return 0n;const d=a*r;return o?(l-1n)/d+1n:l/d}function Tu(e,t,s,o){if(e===t)return 0n;const[a,r]=wa(e,t),c=(r-a)*s;return o?Iu($n(c)):sc($n(c))}function rr(e,t,s){return Su(e,t,s<0n?-s:s,s>=0n)}function ir(e,t,s){return Tu(e,t,s<0n?-s:s,s>=0n)}const Co=1n<<64n,cr=1n<<65n,Eu=64n;function $u(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<Eu-1n,r=0n,i=1;for(;t>=cr;)t>>=1n,s+=Co;for(;t<Co;)i=0,t<<=1n,o+=Co;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=cr&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?$n(s):$n(o-s);return[i,c]}function Wt(e){const t=e<0n?-e:e;if(t>Kt)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=wu/s);const o=s/gn;return s%gn!==0n?o+1n:o}function Mu(e){if(e<vu||e>=Cu)throw new Error("INVALID_SQRT_PRICE");const[,t]=$u($n(e)),s=Au(t,$n(Nu)),o=sc(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<ju?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Kt&&(a=-Kt),i>Kt&&(i=Kt),Wt(i)<=e){if(i>=Kt)throw new Error("GTE_MAX_TICK");if(Wt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(Wt(r)<=e)return r;if(Wt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function Lu(e,t,s,o){const[a,r]=wa(t,s);return e<a?[rr(a,r,o),0n]:e<r?[rr(e,r,o),ir(a,e,o)]:[0n,ir(a,r,o)]}function qu({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=Wt(Ht(e)),r=Wt(Ht(t));return Lu(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const No=gn*gn,Pu=1e-300,Ru=BigInt(Number.MAX_SAFE_INTEGER);function lr(e){const t=e*e,s=t/No,o=t%No;return s>Ru?Number(s):Number(s)+Number(o)/Number(No)}function dr(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,Pu)}function Du({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=Wt(Ht(e)),a=Wt(Ht(t)),r=lr(o),i=lr(a);return s?{min:dr(i),max:dr(r)}:{min:r,max:i}}const xn=$e.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]}),va={lens:"lens",pool:"pool",farming:"farming"},ja={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function Bu(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:C.InitiaAddress(e).hex}function Us(e){return ae.toBase64(C.InitiaAddress(Bu(e),32).bytes)}function oc(e,t){return`${e}:${t}`}function Fu(e){return`clamm:${e}`}function Uu(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function Ou(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 Vu(e){const{dexUrl:t}=ne();return S.useSuspenseQuery({queryKey:xn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await z.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...Uu(r.positions)),o=r.pagination.next_key||void 0}while(o);return Ou(s)},staleTime:K.MINUTE})}function Ku(e){const t=oe(),{viewFunction:s}=C.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:xn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=ja[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:va.lens,functionName:"get_pool_info",typeArgs:[],args:[Us(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:K.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 Wu(e){const t=oe(),{viewFunction:s}=C.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:xn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=ja[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:va.pool,functionName:"fees_available",typeArgs:[],args:[Us(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:K.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 zu(e){const t=oe(),{viewFunction:s}=C.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:xn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=ja[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:va.farming,functionName:"pending_reward_info",typeArgs:[],args:[Us(r.tokenAddress),Us(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:K.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(oc(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function ac(e){const{dexUrl:t}=ne(),o=S.useSuspenseQueries({queries:e.map(a=>({queryKey:xn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await z.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:K.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 rc(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function Hu(e){return ac(e)}function Qu(e){const t=oe(),s=zt(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=>C.denomToMetadata(i)),[e]),r=ac(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 m=r.get(d);if(!m){i.set(c,null);return}if(c===yd){i.set(c,{...m,symbol:xd});return}const u=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:u})}),i},[e,a,r,o])}const Gu="lock_staking";function ic(e,t){const s=`${t}::lock_staking::StakingAccount`,o=C.createObjectAddress(e,s);return C.InitiaAddress(o).bech32}const ls=$e.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 Ca(){const{restUrl:e}=oe(),t=se();return S.useSuspenseQuery({queryKey:ls.delegations(e,t||"").queryKey,queryFn:async()=>t?(await z.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=C.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},d=o.get(c)??[];d.push(l),o.set(c,d)}}return o},staleTime:K.MINUTE})}function Na(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=ne(),s=se(),o=s?ic(s,t):"";return S.useSuspenseQuery({queryKey:ls.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const m=C.denomToMetadata(d.denom),u={denom:d.denom,metadata:m,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(u),r.set(m,h)}}return r},staleTime:K.MINUTE})}function ka(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=ne(),s=se();return S.useSuspenseQuery({queryKey:ls.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=C.createMoveClient(e);return await o({moduleAddress:t,moduleName:Gu,functionName:"get_locked_delegations",typeArgs:[],args:[ae.toBase64(C.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:K.MINUTE})}function cc(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=C.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 lc(){const{restUrl:e}=oe(),t=se();return S.useSuspenseQuery({queryKey:ls.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await z.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:cc,staleTime:K.MINUTE})}function dc(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=ne(),s=se(),o=s?ic(s,t):"";return S.useSuspenseQuery({queryKey:ls.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:cc,staleTime:K.MINUTE})}function Ia(){const e=oe(),t=zt(e),{data:s,isLoading:o}=Lt(e),{data:a}=Ca(),{data:r}=Na(),{data:i}=ka(),c=y.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Ps(c),d=y.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=y.useMemo(()=>{const f=new Map;for(const g of t)f.set(g.denom,g);return f},[t]),u=y.useMemo(()=>{const f=[],g=p=>{const _=m.get(p);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[p,_]of a){const x=l.get(p)??_[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=d.get(x)??0;for(const w of _){const{symbol:v,decimals:k}=b,T=Number(C.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:x,symbol:v,amount:w.amount,formattedAmount:T,decimals:k,value:T*j};f.push({type:"staking",validator:w.validator,balance:M})}}for(const[p,_]of i){const x=l.get(p);if(!x)continue;const b=g(x);if(!b)continue;const j=d.get(x)??0;for(const w of _){const{symbol:v,decimals:k}=b,T=Number(C.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:x,symbol:v,amount:w.amount,formattedAmount:T,decimals:k,value:T*j},A=Number(w.releaseTime);f.push({type:"lockstaking",validator:w.validator,releaseTime:Number.isNaN(A)?0:A,balance:M})}}for(const[p,_]of r){const x=l.get(p)??_[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=d.get(x)??0;for(const w of _){const{symbol:v,decimals:k}=b,T=Number(C.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:x,symbol:v,amount:w.amount,formattedAmount:T,decimals:k,value:T*j},A=new Date(w.completionTime).getTime(),L=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:w.validator,completionTime:L,balance:M})}}return f.filter(p=>p.type!=="fungible-position"&&p.balance.denom===Ye)},[a,i,r,l,m,d]),h=y.useMemo(()=>u.reduce((f,g)=>g.type==="fungible-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[u]);return{positions:u,totalValue:h,isLoading:o}}function Yu(e){const t=new Map;for(const s of e){const o=C.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function Zu(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function Ju(e){const{dexUrl:t}=ne();return S.useSuspenseQuery({queryKey:xn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:K.MINUTE})}function Xu(){const e=oe(),t=os(e),s=y.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=Ju(s);return y.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return Yu(a)},[t,o])}function em(e){const{dexUrl:t}=ne();return S.useSuspenseQuery({queryKey:xn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${t}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:K.MINUTE})}function tm(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!==Ye&&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!==Ye&&a.add(r)}return Array.from(a)}function nm(e){const t=[];for(const[,s]of e)s&&s!==Ye&&t.push(s);return t}function sm(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=rc(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 ko(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Ye)continue;const l=o.get(c);if(l)for(const d of i){const m=l.decimals,u=Number(C.fromBaseUnit(String(d.amount),{decimals:m})),h=s.get(c)??0,f=u*h;l.breakdown[a]+=u,l.totalAmount+=u,l.totalValue+=f}}}function om(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Ye)continue;const l=o.get(c);if(l)for(const d of i){const m=l.decimals,u=Number(C.fromBaseUnit(String(d.amount),{decimals:m})),h=s.get(c)??0,f=u*h;l.breakdown[a]+=u,l.totalAmount+=u,l.totalValue+=f}}}function am(e,t,s,o){for(const[a,r]of e){const i=C.denomToMetadata(a),c=t?.get(i),l=c?C.fromBaseUnit(c.amount,{decimals:rt}):"0",d=s?.get(i),m=d?C.fromBaseUnit(d.amount,{decimals:rt}):"0",u=Number(l)+Number(m);u<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(u),totalValue:u*o})}}function rm(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function io(){const e=oe(),t=zt(e),s=se(),o=Xu(),{data:a}=Ca(),{data:r}=ka(),{data:i}=Na(),{data:c}=lc(),{data:l}=dc(),{data:d}=Lt(e),{data:m}=Vu(s),u=y.useMemo(()=>{const q=new Map;for(const P of m){const B=q.get(P.lpMetadata)??[];B.push(P),q.set(P.lpMetadata,B)}return q},[m]),h=y.useMemo(()=>Array.from(u.keys()),[u]),f=Hu(h),g=Ku(h),p=y.useMemo(()=>m.map(q=>q.tokenAddress),[m]),_=Wu(p),x=y.useMemo(()=>{const q=[];for(const P of m)for(const B of P.incentives)q.push({tokenAddress:P.tokenAddress,incentiveAddress:B.incentiveAddress});return q},[m]),b=zu(x),j=y.useMemo(()=>{const q=new Set;for(const P of m)for(const B of P.incentives)q.add(B.rewardMetadata);return Array.from(q)},[m]),w=Ps(j,{failSoft:!0}),v=y.useMemo(()=>tm(o,a,r,i),[o,a,r,i]),k=Ps(v),T=y.useMemo(()=>nm(k),[k]),{data:M}=em(T),A=Qu(T),L=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(W=>W.id===Ye)?.price??0,P=new Map;for(const W of T)P.set(W,sm(W,A,L));ko(o,k,M,P,"deposit"),ko(a,k,M,P,"staking"),om(r,k,M,P,"lockStaking"),ko(i,k,M,P,"unstaking"),am(P,c,l,q);for(const W of h){const O=u.get(W)??[];if(O.length===0)continue;const me=f.get(W),ge=g.get(W),ce=Fu(W),ye=me?.coins.map(re=>re.denom)??[],we=me?rc(me,L).filter(Boolean):[],ve=ye.map(re=>L.get(re)?.symbol||re),tt=me?.symbol||ve.join("-")||ce,Rt=Zu(ye,L),Tt=O.map(re=>{let Be,Dt,Bt,_e=!1,Pe=0,gt=0;try{const He=Du({tickLower:re.tickLower,tickUpper:re.tickUpper});Be=He.min,Dt=He.max}catch{Be=void 0,Dt=void 0}if(ge){try{const He=Mu(BigInt(ge.sqrtPrice)),Qe=Ht(re.tickLower),lt=Ht(re.tickUpper),Ne=Number(ge.tickSpacing);_e=Number.isFinite(Ne)&&Ne>0?ku(re.tickLower,re.tickUpper,Ne):!1,Bt=_e||He>=Qe&&He<lt}catch{Bt=void 0,_e=!1}if(me&&ye.length>0)try{qu({sqrtPrice:ge.sqrtPrice,tickLower:re.tickLower,tickUpper:re.tickUpper,liquidity:re.liquidity}).forEach((Qe,lt)=>{const Ne=me.coins[lt];if(!Ne)return;const Zt=L.get(Ne.denom)?.decimals??6,Jt=N.get(Ne.denom)??0,wn=Number(C.fromBaseUnit(String(Qe),{decimals:Zt}));Pe+=wn*Jt})}catch{Pe=0}}return me&&((_.get(re.tokenAddress)??[]).forEach((Qe,lt)=>{const Ne=me.coins[lt];if(!Ne)return;const Zt=L.get(Ne.denom)?.decimals??6,Jt=N.get(Ne.denom)??0,wn=Number(C.fromBaseUnit(Qe,{decimals:Zt}));gt+=wn*Jt}),re.incentives.forEach(Qe=>{const lt=b.get(oc(re.tokenAddress,Qe.incentiveAddress))??"0",Ne=w.get(Qe.rewardMetadata);if(!Ne)return;const Zt=L.get(Ne)?.decimals??6,Jt=N.get(Ne)??0,wn=Number(C.fromBaseUnit(lt,{decimals:Zt}));gt+=wn*Jt})),{tokenAddress:re.tokenAddress,positionId:rm(re.tokenAddress),inRange:Bt,isFullRange:_e,minPrice:Be,maxPrice:Dt,pricePairLabel:Rt,rewardValue:gt,value:Pe}}),qe=Tt.reduce((re,Be)=>re+Be.value,0),Y=Tt.reduce((re,Be)=>re+Be.rewardValue,0),ct=we.length>0;P.set(ce,{denom:ce,symbol:tt,totalAmount:0,totalValue:qe,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:ct?we:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:W,totalRewardValue:Y,positions:Tt}})}const B=Array.from(P.values()).filter(W=>W.totalAmount>0||W.isClamm).sort((W,O)=>O.totalValue-W.totalValue),Q=B.reduce((W,O)=>W+O.totalValue,0);return{rows:B,totalValue:Q}},[d,T,A,L,o,a,r,i,k,M,c,l,h,u,f,g,_,b,w,N]);return{totalValue:F,rows:I}}const im=$e.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function cm(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 uc(){const{vipUrl:e}=ne(),t=se();return S.useQuery({queryKey:im.allVestingPositions(e,t).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:K.MINUTE,enabled:!!t})}function lm(){const e=he();return y.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function co(){const{data:e}=uc(),t=oe(),{data:s}=Lt(t),o=lm(),a=y.useMemo(()=>s?.find(l=>l.id===Ye)?.price??0,[s]),r=y.useMemo(()=>e?cm(e).map(l=>{const d=o(l.rollup.bridgeId),m=Number(C.fromBaseUnit(String(l.lockedReward),{decimals:rt})),u=Number(C.fromBaseUnit(String(l.claimableReward),{decimals:rt})),h=U(C.fromBaseUnit(String(l.lockedReward),{decimals:rt})).times(a).toNumber(),f=U(C.fromBaseUnit(String(l.claimableReward),{decimals:rt})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:u,claimableRewardValue:f}}).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 mc(){const{totalValue:e}=io(),{data:t}=Ca(),{data:s}=ka(),{data:o}=Na(),{data:a}=uc(),r=y.useMemo(()=>Array.from(s.keys()),[s]),i=Ps(r),c=oe(),{data:l}=Lt(c),d=y.useMemo(()=>l?.find(u=>u.id===Ye)?.price??0,[l]);return y.useMemo(()=>{let m=0,u=0;const h=d??0;for(const[,g]of t)for(const{denom:p,amount:_}of g)p===Ye&&(m+=Number(C.fromBaseUnit(_,{decimals:rt}))*h);for(const[g,p]of s)if(i.get(g)===Ye)for(const{amount:_}of p)u+=Number(C.fromBaseUnit(_,{decimals:rt}))*h;for(const[,g]of o)for(const{denom:p,amount:_}of g)p===Ye&&(m+=Number(C.fromBaseUnit(_,{decimals:rt}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,_=g.total_claimable_reward??0;f+=Number(C.fromBaseUnit(String(p+_),{decimals:rt}))*h}return m+u+e+f},[t,s,i,o,a,d,e])}function dm(){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=>C.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 Wo=$e.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 Aa(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 m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Mn(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 um(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 mm(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 hm(e){const t=new Map;for(const d of e){const m=um(d);if(!m)continue;const u=t.get(m)??[];u.push(d),t.set(m,u)}const s=new Map,o=new Map;for(const[d,m]of t){const u=m.reduce((f,g)=>f+Mn(g),0),h=m.reduce((f,g)=>f+Math.abs(Mn(g)),0);s.set(d,u),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((d,m)=>{const u=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(d==="lending"||d==="borrowing")&&(m==="lending"||m==="borrowing")?d==="lending"?-1:1:h-u}),l=new Map;for(const d of c)l.set(d,{positions:t.get(d),totalValue:s.get(d)??0});return l}function fm(e){return e.type==="fungible-position"?e.title:e.balance.denom}function pm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function gm(e){return e.type==="fungible-position"?null:e.balance}function _m(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 ym(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 xm(e,t){return e.symbol===mt&&t.symbol===mt?0:e.symbol===mt?-1:t.symbol===mt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function bm(e){const t=new Map;for(const o of e){const a=fm(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=gm(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:pm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+Mn(l),0),totalAmount:i,balance:r}}).toSorted(xm)}function hc(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 wm(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 vm(e,t){return e.symbol===mt&&t.symbol===mt?0:e.symbol===mt?-1:t.symbol===mt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function jm(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 Cm(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:m})=>m.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Nm(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 km(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=Cm(e,s,o),i=Nm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Im(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:m}=c;if(!Array.isArray(m))continue;const u=t.get(l.toLowerCase()),h=u?.chainId??d??l,f=u?.prettyName??l,g=u?.logoUrl??"",p=s.get(h);for(const _ of m){if(_.type==="unknown"){if(!_.amount||_.amount==="0")continue;r.push({symbol:_.denom,logoUrl:"",denom:_.denom,amount:_.amount,decimals:0,quantity:_.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(_.type==="lp"||(_.value??0)<=0&&(_.formattedAmount??0)<=0)continue;let x=_.value;if((x==null||x<=0)&&p){const w=p.get(_.denom)??0;w>0&&(x=_.formattedAmount*w)}const b={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:g}},j=a.get(_.symbol);j?j.push(b):a.set(_.symbol,[b])}}r.sort((c,l)=>{const d=c.chain.chainId===o,m=l.chain.chainId===o;if(d&&!m)return-1;if(!d&&m)return 1;const u=c.chain.name.localeCompare(l.chain.name);if(u!==0)return u;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((u,h)=>(h.value??0)-(u.value??0));let d=0,m=0;for(const u of l)d+=u.value??0,m+=Number(u.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:m})}return i.sort(vm),{listedGroups:i,unlistedAssets:r}}function Sa(){return oe().network_type==="testnet"}function Gt(){return Ie.useFormContext()}function Am(){const e=Xe(),t=Sa(),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 Sm={balances:[],positions:[],isLoading:!0,isComplete:!1},fc=H.atom(0),Tm=1e3;let ur=0;function Em(){const e=H.useSetAtom(fc);y.useEffect(()=>{const t=Date.now();t-ur>=Tm&&(ur=t,e(s=>s+1))},[e])}function $m(){const e=S.useQueryClient(),t=se(),{minityUrl:s}=ne(),o=Sa(),a=H.useAtomValue(fc),r=y.useEffectEvent((l,d)=>{const m=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=y.useEffectEvent((l,d)=>{const m=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=y.useEffectEvent((l,d)=>{const m=Wo.ssePortfolio(t??"",s).queryKey,u=e.getQueryData(m)??Sm,h=l.size>0||d.size>0;e.setQueryData(m,{...u,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:u.isLoading,isComplete:!1})});y.useEffect(()=>{if(!t||o)return;const l=Wo.ssePortfolio(t,s).queryKey,d=e.getQueryData(l),m=new Map,u=new Map;for(const _ of d?.balances??[])m.set(_.chainName,_);for(const _ of d?.positions??[])u.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;let g=null,p=!1;return e.setQueryData(l,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=_=>{if(!p)try{const x=JSON.parse(_.data);x.type==="balances"?r(x,m):x.type==="positions"&&i(x,u),c(m,u)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[t,o,a])}const mr={balances:[],positions:[],isLoading:!0,isComplete:!1};function ds(){const e=se(),{minityUrl:t}=ne(),s=Wo.ssePortfolio(e??"",t).queryKey,{data:o}=S.useQuery({queryKey:s,queryFn:()=>mr,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??mr}function Mm(){const e=he();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 Lm(){const{balances:e,positions:t}=ds(),s=he(),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((g,p)=>{if(p.type==="fungible-position")return g+(p.value??0);if(p.balance.type==="unknown")return g;const _=p.balance.value??0;return p.type==="lending"&&p.direction==="borrow"?g-_:g+_},0),c=new Map,l=Array.isArray(e)?e:[],d=Array.isArray(t)?t:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((_,x)=>_+r(x),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of d){if(!Array.isArray(g))continue;const p=g.reduce((_,x)=>_+i(x),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),u=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return $.sortWith([$.descend(h),$.descend($.prop("totalBalance"))],u)},[e,t,o])}function qm(){const{balances:e}=ds(),t=he(),s=la(),o=y.useMemo(()=>hc(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=wm(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 Pm(){const{positions:e}=ds();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 je=$e.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 De(){const{routerApiUrl:e}=ne();return y.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.5.0"}}),[e])}function Rm(){const e=De();S.usePrefetchQuery({queryKey:je.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:K.MINUTE}),S.usePrefetchQuery({queryKey:je.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:K.MINUTE})}const Dm=()=>(Gl(),Yl(),null),Bm="_loader_1vxch_1",Fm={loader:Bm},Nt=({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:Fm.loader,style:o,role:"status","aria-label":"Loading"})},Um="_button_1q027_1",Om="_outline_1q027_28",Vm="_sm_1q027_46",Km="_full_1q027_53",Wm="_small_1q027_57",zm="_unpadded_1q027_88",cn={button:Um,outline:Om,sm:Vm,full:Km,small:Wm,unpadded:zm},pc=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:D(cn.button,{[cn.sm]:t,[cn.full]:s},a),disabled:!!o||i,"aria-busy":!!o,children:o?n.jsxs(n.Fragment,{children:[n.jsx(Nt,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:cn.loading,children:o})]}):r})},Hm=({className:e,...t})=>n.jsx(pc,{...t,className:D(cn.outline,e)}),Qm=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:D(cn.small,{[cn.unpadded]:t},e)}),ue={White:pc,Outline:Hm,Small:Qm},Gm="_footer_1vp4h_1",Ym="_actions_1vp4h_10",hr={footer:Gm,actions:Ym},Ae=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:D(hr.footer,t),children:[e,n.jsx("div",{className:hr.actions,children:s})]}),Zm="_scrollable_13su7_1",Jm={scrollable:Zm},pt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:D(Jm.scrollable,e),children:t}),Xm="interwovenkit:";function eh(e){const[t]=e;return typeof t=="string"&&t.startsWith(Xm)}function th(e){e.removeQueries({predicate:t=>eh(t.queryKey)})}function lo(){return ze.useMediaQuery("(max-width: 576px)")}const zo="interwoven-kit";function gc(){const e=document.querySelector(zo)||document.body.appendChild(document.createElement(zo));return e.shadowRoot||e.attachShadow({mode:"open"})}function _c(){const{theme:e,container:t}=ne();return y.useEffect(()=>{document.querySelector(zo)?.setAttribute("data-theme",e)},[e]),t??gc()}function nh(e){const t=gc(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const uo=y.createContext(null);function _n(){const{container:e}=y.useContext(uo);return e}function yc(e){const t=_n();return t?getComputedStyle(t).getPropertyValue(e):""}function sh(){return ze.useScrollLock(),null}function oh(e){return/^[A-F0-9]{64}$/i.test(e)}function ah(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return oh(s)?$.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!C.InitiaAddress.validate(o))return;const i=$.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function rh(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const ih="_link_j1lkz_1",fr={link:ih},mo=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,m=ft(e),u=ah(m,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?C.truncate(t):s?C.truncate(s):"",f=c??h;return u?n.jsxs("a",{...d,href:Nl(rh(u)),className:D(fr.link,i),onClick:l,target:"_blank",rel:"noopener noreferrer",children:[f,r&&n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})]}):n.jsx("span",{...d,className:D(fr.link,i),children:f})},xc=y.createContext(null),us=()=>y.useContext(xc),ch=()=>{const[e,t]=H.useAtom(Hi),{showNotification:s,updateNotification:o,hideNotification:a}=us();return y.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?n.jsx(mo,{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},Os=({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})},lh="_placeholder_10r3x_1",dh="_logo_10r3x_5",pr={placeholder:lh,logo:dh},te=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=y.useState(void 0),{width:d,height:m}=i,u=s??n.jsx("div",{className:D(pr.placeholder,o?.placeholder),style:{width:d,height:m,...a},"aria-hidden":"true"});return!e||c===e?u:n.jsx("img",{...i,className:D(i.className,{[pr.logo]:r}),style:{width:d,height:m,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function bc(){const{connector:e}=We.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const uh="_header_1q8ju_1",mh="_account_1q8ju_17",hh="_name_1q8ju_28",fh="_address_1q8ju_32",ph="_icon_1q8ju_36",gh="_copied_1q8ju_43",_h="_button_1q8ju_58",yh="_settings_1q8ju_69",xh="_disconnect_1q8ju_73",bh="_label_1q8ju_83",wh="_expanded_1q8ju_91",nt={header:uh,account:mh,name:hh,address:fh,icon:ph,copied:gh,button:_h,settings:yh,disconnect:xh,label:bh,expanded:wh},vh=()=>{const e=Ii(),{address:t,username:s}=et(),o=bc(),a=s??t,[r,i]=y.useState(!1),c=y.useRef(null),l=jt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},u=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:nt.header,children:[n.jsx(Os,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:D(nt.account,{[nt.copied]:f}),onClick:h,"aria-label":f?"Copied":"Copy address",children:[n.jsx(te,{src:o,width:18,height:18}),n.jsx("div",{className:nt.address,children:C.truncate(t)}),n.jsx("div",{className:nt.name,children:C.truncate(a)}),n.jsx(E.IconCopy,{className:nt.icon,size:12,"aria-hidden":"true"}),f?"Copied!":""]})}),n.jsx(dn,{to:"/settings",className:D(nt.button,nt.settings),"aria-label":"Open settings",children:n.jsx(E.IconSettingFilled,{size:16,"aria-hidden":"true"})}),n.jsxs(jt.animated.button,{className:D(nt.button,nt.disconnect,{[nt.expanded]:r}),style:l,onClick:d,onMouseLeave:m,onMouseEnter:u,"aria-label":"Disconnect wallet",children:[n.jsx(E.IconSignOut,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:nt.label,children:"Disconnect"})]})]}):null},jh="_overlay_jij9g_1",Ch="_content_jij9g_28",Nh="_inner_jij9g_60",Io={overlay:jh,content:Ch,inner:Nh},kh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=qt(),{setContainer:o}=y.useContext(uo),a=y.useCallback(p=>{p&&o(p)},[o]),r=lo(),i=_c(),c=H.useAtomValue(ao),l=H.useAtomValue(as),d=S.useIsMutating({mutationKey:[zi]}),m=()=>{const p=d?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),c?.reject(new Error(p)),l?.reject(new Error("User rejected"))},u=Xs(),h=Se(),f=S.useQueryClient(),g={fallbackRender:({error:p,resetErrorBoundary:_})=>{const x=()=>{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)),h("/"),th(f),_()};return n.jsxs(pt,{children:[n.jsx(be,{error:!0,children:p.message}),n.jsx(Ae,{children:n.jsx(ue.White,{onClick:x,children:"Retry"})})]})}};return n.jsx(Re.Dialog.Root,{open:t,onOpenChange:p=>!p&&m(),modal:!1,children:n.jsxs(Re.Dialog.Portal,{container:i,children:[r&&n.jsx(Re.Dialog.Backdrop,{className:Io.overlay,onClick:m,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[n.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),n.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),n.jsx(Re.Dialog.Popup,{className:Io.content,children:n.jsxs("div",{className:D(Io.inner,"body"),ref:a,children:[r&&n.jsx(sh,{}),n.jsx(ch,{}),n.jsx(vh,{}),n.jsx(pe,{errorBoundaryProps:g,children:e})]})})]})})},Ih="_backdrop_1bqx9_1",Ah="_modal_1bqx9_12",Sh="_closeButton_1bqx9_44",Ao={backdrop:Ih,modal:Ah,closeButton:Sh},Th=({children:e})=>{const{isModalOpen:t,closeModal:s}=Pn(),{setContainer:o}=y.useContext(uo),a=y.useCallback(i=>{i&&o(i)},[o]),r=_c();return n.jsx(Re.Dialog.Root,{open:t,onOpenChange:i=>!i&&s(),children:n.jsxs(Re.Dialog.Portal,{container:r,children:[n.jsx(Re.Dialog.Backdrop,{className:Ao.backdrop,onClick:s}),n.jsxs(Re.Dialog.Popup,{className:Ao.modal,ref:a,children:[n.jsx("button",{className:Ao.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(E.IconClose,{size:20})}),n.jsx(pe,{children:e})]})]})})},wc=y.createContext(!1),Eh="_overlay_1iyfl_1",$h="_fullscreen_1iyfl_15",Mh="_content_1iyfl_19",Lh="_header_1iyfl_56",qh="_title_1iyfl_65",Ph="_close_1iyfl_70",Xt={overlay:Eh,fullscreen:$h,content:Mh,header:Lh,title:qh,close:Ph},vc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=_n(),c=y.useContext(wc);return i?n.jsxs(Re.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Re.Dialog.Trigger,{className:o,children:s}),n.jsxs(Re.Dialog.Portal,{container:i,children:[n.jsx(Re.Dialog.Backdrop,{className:D(Xt.overlay,{[Xt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Re.Dialog.Popup,{className:D(Xt.content,{[Xt.fullscreen]:c}),children:[e&&n.jsxs("header",{className:Xt.header,children:[n.jsx(Re.Dialog.Title,{className:Xt.title,children:e}),n.jsx(Re.Dialog.Close,{className:Xt.close,"aria-label":"Close",children:n.jsx(E.IconClose,{size:20,"aria-hidden":"true"})})]}),t]})]})]}):null},Xn=({children:e})=>{const t=y.useRef(null),[s,o]=y.useState(0),[a,r]=y.useState(!1),i=jt.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:m}=c.getBoundingClientRect();o(m),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?n.jsx(jt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},Rh="_help_qcmtq_1",Dh="_icon_qcmtq_10",Bh="_info_qcmtq_19",Fh="_warning_qcmtq_23",Uh="_error_qcmtq_27",Oh="_success_qcmtq_33",So={help:Rh,icon:Dh,info:Bh,warning:Fh,error:Uh,success:Oh},kn=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(Nt,{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(So.help,e&&So[e],t),style:{marginTop:s},role:e==="error"?"alert":"status",children:[n.jsx("div",{className:So.icon,"aria-hidden":"true",children:a()}),o]})},Vh="_stack_a6m7u_1",Kh="_help_a6m7u_6",Wh="_info_a6m7u_14",zh="_warning_a6m7u_19",Hh="_error_a6m7u_24",Qh="_success_a6m7u_29",Ho={stack:Vh,help:Kh,info:Wh,warning:zh,error:Hh,success:Qh},Gh=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(Xn,{children:n.jsx("div",{className:Ho.stack,children:e})}),xe=({mt:e=0,...t})=>n.jsx(kn,{...t,className:D(Ho.help,Ho[t.level]),mt:e});xe.Stack=Gh;const Yh="_root_16p5j_1",Zh="_item_16p5j_10",Jh="_chevron_16p5j_14",Xh="_trigger_16p5j_19",ef="_content_16p5j_39",Fn={root:Yh,item:Zh,chevron:Jh,trigger:Xh,content:ef};function tf(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(Z.Accordion.Root,{className:Fn.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(Z.Accordion.Item,{className:Fn.item,value:s?.(c)??String(l),children:[n.jsx(Z.Accordion.Header,{children:n.jsxs(Z.Accordion.Trigger,{className:Fn.trigger,children:[o(c),n.jsx(E.IconChevronDown,{className:Fn.chevron,size:16,"aria-hidden":"true"})]})}),n.jsx(Z.Accordion.Content,{className:Fn.content,children:a(c)})]},s?.(c)??l)),r]})}const nf="_trigger_u613p_1",sf="_icon_u613p_18",of="_content_u613p_27",af="_item_u613p_36",rf="_itemText_u613p_52",cf="_itemIndicator_u613p_57",lf="_active_u613p_60",Ut={trigger:nf,icon:sf,content:of,item:af,itemText:rf,itemIndicator:cf,active:lf};function Ta({options:e,value:t,onChange:s,classNames:o}){const a=_n(),r=e.find(c=>c.value===t);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return n.jsxs(Et.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(Et.Select.Trigger,{className:D(Ut.trigger,o?.trigger),children:[n.jsx(Et.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(Et.Select.Icon,{className:Ut.icon,children:n.jsx(E.IconChevronDown,{size:12,"aria-hidden":"true"})})]}),n.jsx(Et.Select.Portal,{container:a,children:n.jsx(Et.Select.Positioner,{className:Ut.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(Et.Select.Popup,{className:Ut.popup,children:e.map(c=>n.jsxs(Et.Select.Item,{className:D(Ut.item,o?.item),value:String(c.value),children:[n.jsx(Et.Select.ItemText,{className:D(Ut.itemText,o?.itemText),children:c.label}),n.jsx(E.IconCheck,{size:12,className:D(Ut.itemIndicator,{[Ut.active]:c.value===t}),"aria-hidden":"true"})]},String(c.value)))})})})]})}const df="_root_1t37n_1",uf="_trigger_1t37n_7",mf="_item_1t37n_11",hf="_itemText_1t37n_17",gr={root:df,trigger:uf,item:mf,itemText:hf},ff=({options:e,value:t,onChange:s})=>{const{txRequest:o}=Gi(),a=ft(o.chainId),r=It(a),i=(g,p)=>{if(C.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(U(g).isZero())return"0";const{symbol:_,decimals:x}=r(p),b=i(g,x);return`${C.formatAmount(g,{decimals:x,dp:b})} ${_}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:_}=r(p);return{value:p,label:c(g),triggerLabel:_}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(g=>g.amount[0].denom===t);if(!d)throw new Error("Fee option not found");const[{amount:m,denom:u}]=d.amount,{decimals:h}=r(u),f=i(m,h);return n.jsxs("div",{className:gr.root,children:[n.jsx("span",{className:"monospace",children:C.formatAmount(m,{decimals:h,dp:f})}),n.jsx(Ta,{options:l,value:t,onChange:s,classNames:gr})]})},pf="_root_16nr2_1",gf="_trigger_16nr2_5",_f="_chevron_16nr2_13",yf="_panel_16nr2_27",xf="_details_16nr2_39",bf="_row_16nr2_48",jn={root:pf,trigger:gf,chevron:_f,panel:yf,details:xf,row:bf},wf=({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(wo.Collapsible.Root,{className:jn.root,children:[n.jsxs(wo.Collapsible.Trigger,{className:jn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(E.IconChevronDown,{className:jn.chevron,size:16})]}),n.jsx(wo.Collapsible.Panel,{className:jn.panel,children:n.jsx("div",{className:jn.details,children:i.map(({label:l,value:d})=>n.jsxs("div",{className:jn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[C.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function Vs(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?ae.toBase64(e):Array.isArray(e)?`[${e.map(Vs).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const vf="_container_1xzyq_1",jf="_toggle_1xzyq_5",Cf="_list_1xzyq_11",Nf="_arg_1xzyq_16",kf="_type_1xzyq_21",Un={container:vf,toggle:jf,list:Cf,arg:Nf,type:kf},If=$e.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),Af=({type:e,arg:t})=>Vs(C.resolveBcsType(e).parse(t)),Sf=({msg:e,chainId:t,fallback:s})=>{const[o,a]=ze.useToggle(!1),{restUrl:r}=ft(t),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:m}=S.useQuery({queryKey:If.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:K.INFINITY});if(!m)return s;const u=(h,f)=>{const g=m[f];return n.jsxs("div",{className:Un.arg,children:[n.jsx("div",{className:Un.type,children:g}),n.jsx(Xr.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(Af,{type:g,arg:h})})]},f)};return n.jsxs("div",{className:Un.container,children:[n.jsx(ue.Small,{className:Un.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Un.list,children:d.map(u)}):s]})},Tf="_list_oip9m_1",Ef="_key_oip9m_9",$f="_value_oip9m_14",To={list:Tf,key:Ef,value:$f},Mf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:To.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:To.key,children:a}),n.jsx("div",{className:To.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(Sf,{msg:o,chainId:t,fallback:Vs(r)}):Vs(r)})]},a))})},Lf="_item_1n572_1",qf="_title_1n572_10",Pf="_content_1n572_14",Eo={item:Lf,title:qf,content:Pf},$o=({title:e,content:t})=>n.jsxs("div",{className:Eo.item,children:[n.jsx("div",{className:Eo.title,children:e}),n.jsx("div",{className:Eo.content,children:t})]});function ee(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=C.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ea(e,t){return t==null?"$-":ee(e??0)}function jc(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 Cc(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,m=c.metadata_addr;if(l&&d&&m&&C.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&C.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Nc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=S.useSuspenseQuery({queryKey:En.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:K.INFINITY});return s(a)},Rf="_root_1p8a4_1",Df="_title_1p8a4_8",Bf="_changes_1p8a4_14",Ff="_change_1p8a4_14",Uf="_amount_1p8a4_35",Of="_text_1p8a4_42",Vf="_value_1p8a4_49",ln={root:Rf,title:Df,changes:Bf,change:Ff,amount:Uf,text:Of,value:Vf},kc=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=C.formatAmount(e,{decimals:r}),l=s&&U(C.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:ln.change,children:[n.jsxs("div",{className:ln.amount,children:[n.jsx(te,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:ln.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:ln.value,children:ee(l)})]})},Kf=({changes:e,chain:t})=>{const s=It(t),{data:o}=Lt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return n.jsx(kc,{amount:a,asset:c,price:l},i)})},Wf=({changes:e,chain:t})=>{const s=It(t),{data:o}=Lt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(Nc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return n.jsx(kc,{amount:a,asset:s(c),price:l})}},i))};function zf(e,t){return typeof t=="bigint"?t.toString():t}const Hf=$e.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,zf)]}),Qf=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=et(),r=ft(s),{simulateTx:i}=ro(),{data:c}=S.useSuspenseQuery({queryKey:Hf.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:K.SECOND}),l=h=>n.jsxs("div",{className:ln.root,children:[n.jsx("h2",{className:ln.title,children:"Estimated changes"}),n.jsx("div",{className:ln.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=Cc(d,a),[f]=_r(h);return f.length===0?null:l(n.jsx(Wf,{changes:f,chain:r}))}const m=jc(d,o),[u]=_r(m);return u.length===0?null:l(n.jsx(Kf,{changes:u,chain:r}))};function _r(e){return $.partition(t=>new U(t.amount).isNegative(),e)}const Gf="_title_1d032_1",Yf="_meta_1d032_7",Zf="_footer_1d032_14",Jf="_rejectButton_1d032_19",js={title:Gf,meta:Yf,footer:Zf,rejectButton:Jf},Ic=()=>{const{txRequest:e,resolve:t,reject:s}=Gi(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=ft(r),m=os(d),u=ya(d),h=xa(d),f=It(d),g=Qi(),p=(e.gasPrices??u).map(({amount:A,denom:L})=>Ee.calculateFee(Math.ceil(i*c),Ee.GasPrice.fromString(A+L))),_=p.map(A=>A.amount[0]),x=A=>{const L=m.find(Q=>Q.denom===A)?.amount??"0",N=_.find(Q=>Q.denom===A)?.amount??"0",I=l.filter(Q=>Q.denom===A).reduce((Q,W)=>U(Q).plus(W.amount),U("0")),F=U(N).plus(I),q=U(L).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:L,isSufficient:q}},b=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of _)if(x(A).isSufficient)return A;return _[0]?.denom},[j,w]=y.useState(b),{mutate:v,isPending:k}=S.useMutation({mutationKey:[zi],mutationFn:async()=>{const A=p.find(N=>N.amount[0].denom===j);if(!A)throw new Error("Fee not found");const L=await g({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:j,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t(L)},onError:async A=>{s(A)}}),T=x(j),M=!T.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(pt,{children:[n.jsx("h1",{className:js.title,children:"Confirm tx"}),n.jsxs("section",{className:js.meta,"aria-label":"Transaction metadata",children:[n.jsx($o,{title:"Chain",content:r}),n.jsx($o,{title:"Tx fee",content:n.jsx(ff,{options:p,value:j,onChange:w})}),a&&n.jsx($o,{title:"Memo",content:a}),M&&n.jsx(xe,{level:"error",children:n.jsx(wf,{...T})})]}),n.jsx(Qf,{messages:o,memo:a,chainId:r}),n.jsx(tf,{list:o,renderHeader:({typeUrl:A})=>Qs.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(Mf,{message:A,chainId:r})})]}),n.jsxs(Ae,{className:js.footer,children:[n.jsx(ue.Outline,{onClick:()=>s(new Error("User rejected")),disabled:k,className:js.rejectButton,"aria-label":"Reject",children:n.jsx(E.IconClose,{size:16})}),n.jsx(ue.White,{onClick:()=>v(),disabled:M,loading:k,children:"Approve"})]})]})},Xf=({children:e})=>{const[{title:t,content:s,path:o},a]=y.useState({}),[r,i]=y.useState(!1),c=H.useAtomValue(ao),l=y.useCallback(u=>{a(u),i(!0)},[]),d=y.useCallback(()=>{a({}),i(!1)},[]),m=y.useCallback(u=>{u||(c?.reject(new Error("User rejected")),a({})),i(u)},[c]);return n.jsxs(Oi.Provider,{value:{openModal:l,closeModal:d},children:[e,n.jsx(vc,{title:t,open:r,onOpenChange:m,children:n.jsx(pe,{children:o==="/tx"?n.jsx(Ic,{}):s})})]})},ep="_container_1w1hx_1",tp="_toast_1w1hx_11",np="_info_1w1hx_24",sp="_success_1w1hx_28",op="_error_1w1hx_32",ap="_icon_1w1hx_37",rp="_content_1w1hx_45",ip="_title_1w1hx_48",cp="_description_1w1hx_53",lp="_close_1w1hx_75",Ot={container:ep,toast:tp,info:np,success:sp,error:op,icon:ap,content:rp,title:ip,description:cp,close:lp},dp=({notification:e,onClose:t,...s})=>{const o=jt.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(Nt,{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,m=a(c);return n.jsx(jt.animated.div,{style:r,className:Ot.container,children:n.jsxs("div",{className:D(Ot.toast,c&&Ot[c]),role:"alert",...s,children:[m&&n.jsx("div",{className:Ot.icon,"aria-hidden":"true",children:m}),n.jsxs("div",{className:Ot.content,children:[n.jsx("p",{className:Ot.title,children:l}),d&&n.jsx("div",{className:Ot.description,children:d})]}),n.jsx("button",{className:Ot.close,onClick:t,"aria-label":"Dismiss notification",children:n.jsx(E.IconClose,{size:14,"aria-hidden":"true"})})]})})})},Mo=5e3,up=({children:e})=>{const t=_n(),[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:Ja.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Mo))},[c]),d=y.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:Ja.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Mo))},[c]),m=()=>{i(),r.current=!0},u=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Mo))};return y.useEffect(()=>()=>i(),[]),n.jsxs(xc.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,t&&kl.createPortal(n.jsx(dp,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:u}),t)]})},mp=({children:e})=>{const[t,s]=y.useState(null);return n.jsx(uo.Provider,{value:{container:t,setContainer:s},children:e})},Ac=[{value:10*ji,label:"for 10 minutes"},{value:Ci,label:"for 1 hour"},{value:sr,label:"for 1 day"},{value:7*sr,label:"for 7 days"},{value:0,label:"until revoked"}],hp=Ac[0].value;function fp(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 Sc(e){return fp(e)||e.includes(":")}function Qo(e){const t=Il.parse(e);return"error"in t?null:t.domain}function pp(e,t){return e===t||e===`www.${t}`}function gp(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||Sc(t)?!1:Qo(t)!==null}function _p(e,t){try{const s=new URL(e);if(!gp(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||Sc(a)||a==="localhost")return!1;const r=Qo(o);if(!r)return!1;const i=Qo(a);return!i||i!==r?!1:pp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const yp="_container_1422v_1",xp="_title_1422v_7",bp="_description_1422v_14",wp="_sectionTitle_1422v_20",vp="_websiteInfo_1422v_27",jp="_favicon_1422v_37",Cp="_websiteTitle_1422v_42",Np="_websiteHost_1422v_48",kp="_warningContent_1422v_54",Ip="_ignoreButton_1422v_61",Ap="_infoList_1422v_65",Sp="_infoItem_1422v_75",Tp="_label_1422v_84",Ep="_infoValue_1422v_94",$p="_durationTrigger_1422v_100",Mp="_durationItem_1422v_101",Lp="_featureList_1422v_105",qp="_featureItem_1422v_113",Pp="_checkIcon_1422v_123",Rp="_learnMoreLink_1422v_127",Dp="_feedbackContainer_1422v_140",Bp="_footer_1422v_146",le={container:yp,title:xp,description:bp,sectionTitle:wp,websiteInfo:vp,favicon:jp,websiteTitle:Cp,websiteHost:Np,warningContent:kp,ignoreButton:Ip,infoList:Ap,infoItem:Sp,label:Tp,infoValue:Ep,durationTrigger:$p,durationItem:Mp,featureList:Lp,featureItem:qp,checkIcon:Pp,learnMoreLink:Rp,feedbackContainer:Dp,footer:Bp};function Fp(e){return e instanceof z.HTTPError&&e.response.status===404}const Up=$e.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(Fp(a))return!1;throw a}}})}),Op=()=>{const[e,t]=y.useState(hp),[s,o]=H.useAtom(as),[a,r]=y.useState(!1),i=Je(),c=he(),{address:l,username:d}=et(),{mutate:m,isPending:u}=lu(),{closeDrawer:h}=qt();if(!s)throw new Error("Pending request not found");const{logoUrl:f,name:g,restUrl:p}=i(s.chainId),{data:_,isLoading:x,isError:b}=S.useQuery(Up.info(p,l)),j={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},w=c.find(I=>I.chainId===s.chainId),v=w?.website?_p(w.website,window.location.hostname):!1,k=()=>{m(e)},T=()=>{s?.reject(new Error("User cancelled")),o(null),h()},M=!v&&!a,A=!x&&!b&&_===!1,L=!x&&b,N=M||x||b||_===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(pt,{className:le.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:le.title,children:"Enable auto-signing"}),n.jsx("p",{className:le.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:le.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:le.websiteInfo,children:[n.jsx("img",{src:j.favicon,alt:"",className:le.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:le.websiteTitle,children:j.title}),n.jsx("div",{className:le.websiteHost,children:j.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:le.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:le.infoList,children:[n.jsxs("div",{className:le.infoItem,children:[n.jsx("div",{className:le.label,children:"Address"}),n.jsxs("div",{className:le.infoValue,children:[n.jsx(E.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:C.truncate(d??l)})]})]}),n.jsxs("div",{className:le.infoItem,children:[n.jsx("div",{className:le.label,children:"Chain"}),n.jsxs("div",{className:le.infoValue,children:[n.jsx(te,{src:f,width:14,height:14,logo:!0}),n.jsx("span",{children:g})]})]}),n.jsxs("div",{className:le.infoItem,children:[n.jsx("div",{className:le.label,children:"Duration"}),n.jsx(Ta,{options:Ac,value:e,onChange:t,classNames:{trigger:le.durationTrigger,item:le.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:le.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:le.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:le.featureItem,children:[n.jsx(E.IconCheckCircle,{size:12,className:le.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:le.learnMoreLink,children:["Learn more ",n.jsx(E.IconExternalLink,{size:12})]})]})]}),n.jsxs(Ae,{className:le.footer,extra:n.jsxs("div",{className:le.feedbackContainer,children:[A&&n.jsx(xe,{level:"error",children:"Insufficient balance for fee"}),L&&n.jsx(xe,{level:"warning",children:"Unable to verify account status. Try again."}),!v&&!a&&n.jsx(xe,{level:"warning",children:n.jsxs("div",{className:le.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:le.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(ue.Outline,{onClick:T,children:"Cancel"}),n.jsx(ue.White,{onClick:k,disabled:N,loading:u,children:"Enable"})]})]})},Vp=()=>H.useAtomValue(as)?n.jsx(Op,{}):null,Kp="_container_mqvhs_1",Wp="_badge_mqvhs_5",yr={container:Kp,badge:Wp},Tc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:D(yr.container,a),children:[o,!s&&n.jsx("div",{className:yr.badge,style:{right:t,top:t},"aria-hidden":"true"})]})},zp="_header_s7mee_1",Hp="_back_s7mee_12",Qp="_title_s7mee_24",Lo={header:zp,back:Hp,title:Qp},At=({title:e,backButton:t,extra:s,children:o})=>{const a=hi();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Lo.header,children:[n.jsx(dn,{to:t??(a.length>1?-1:"/"),className:Lo.back,shouldReset:!!t,"aria-label":"Go back",children:n.jsx(E.IconBack,{size:16,"aria-hidden":"true"})}),n.jsx("h1",{className:Lo.title,children:e}),s]}),n.jsx(pt,{children:o})]})};function $a(){const e=he();return t=>e.some(s=>s.chain_id===t)}function Gp(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function ms(){const e=$a();return t=>e(t.chain_id)?"initia":t.chain_type}function es(e){return ms()(e)}function ho(){const e=De(),{data:t}=S.useSuspenseQuery({queryKey:je.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:K.MINUTE});return t}function Pt(){const e=ho(),t=oi();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 it(e){return Pt()(e)}function xr(e,t){try{return ae.fromBech32(e).prefix===t}catch{return!1}}function Ec(){const{initiaAddress:e,hexAddress:t}=et(),s=Pt(),o=ms();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Ma(){const e=Pt(),t=ms();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return xr(s,a.bech32_prefix??"init");case"evm":return vt.isAddress(s);case"cosmos":return a.bech32_prefix?xr(s,a.bech32_prefix):!1;default:return!1}}}function Yp(){const e=Pt(),t=ms();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 C.InitiaAddress(s).bech32;if(c==="initia"&&d==="evm")return C.InitiaAddress(s).hex;if(c===d)return s;if(r){if(d==="initia")return C.InitiaAddress(r).bech32;if(d==="evm")return C.InitiaAddress(r).hex}return""}}function Zp(){const e=De();return S.useSuspenseQuery({queryKey:je.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:K.MINUTE})}function hs(){const{data:{chain_to_assets_map:e}}=Zp(),t=ho(),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(je.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(je.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Ks(e){const t=De(),s=S.useQueryClient(),{data:o}=S.useSuspenseQuery({queryKey:je.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(je.asset(e,i.denom).queryKey,i);return r.toSorted($.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function $c(e){const t=Ks(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function kt(e,t){return $c(t)(e)}const Jp="_root_ekn9t_1",Xp="_header_ekn9t_6",eg="_title_ekn9t_12",tg="_warning_ekn9t_18",ng="_content_ekn9t_22",sg="_footer_ekn9t_26",og="_secondary_ekn9t_36",en={root:Jp,header:Xp,title:eg,warning:tg,content:ng,footer:sg,secondary:og},Mc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(pt,{className:en.root,children:[n.jsxs("header",{className:D(en.header,t&&en[t]),children:[s,n.jsx("h1",{className:en.title,children:o})]}),n.jsx("div",{className:en.content,children:a}),n.jsxs("footer",{className:en.footer,children:[n.jsx(ue.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:en.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(E.IconChevronRight,{size:14,"aria-hidden":"true"})]})]})]})},ag="_list_k4n3k_1",rg="_row_k4n3k_9",ig="_dt_k4n3k_20",cg="_asset_k4n3k_26",Cs={list:ag,row:rg,dt:ig,asset:cg},lg=({list:e,onNavigate:t,onDismiss:s})=>{const o=oe(),a=Je(),r=It(o);return n.jsx(Mc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:Cs.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const m=a(c),{decimals:u,symbol:h}=r(d),f=C.formatAmount(l,{decimals:u});return n.jsxs("div",{className:Cs.row,children:[n.jsxs("div",{className:Cs.dt,children:[n.jsx(te,{src:m.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:m.name})]}),n.jsxs("span",{className:Cs.asset,children:[f," ",h]})]},i)})})})};function qo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const Ns=({chainId:e,txHash:t})=>`${ie.OP_REMINDER}:${e}:${t}`,dg=Al.atomWithStorage(ie.OP_REMINDER,[]);function Dn(){const e=se(),[t=[],s]=H.useAtom(dg),o=y.useMemo(()=>t.map(l=>{const d=localStorage.getItem(Ns(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:m}=l;return d!==e?!1:Ze.isPast(m)}),[e,t]),a=y.useCallback((l,d)=>{t.some(m=>qo(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(Ns(l),JSON.stringify(d)))},[t,s]),r=y.useCallback(l=>{s((d=[])=>d.filter(m=>!qo(m,l))),localStorage.removeItem(Ns(l))},[s]),i=y.useCallback(l=>{const d=l.filter(m=>!t.some(u=>qo(u,m)));d.length!==0&&s((m=[])=>[...m,...d])},[t,s]),c=y.useCallback((l,d)=>{localStorage.setItem(Ns(l),JSON.stringify(d)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Lc(){const e=Se(),{openModal:t,closeModal:s}=oo(),{reminders:o,setReminder:a}=Dn();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(lg,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const ug="_wrapper_5ssm8_1",mg="_balance_5ssm8_11",hg="_button_5ssm8_15",Po={wrapper:ug,balance:mg,button:hg},qc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:Po.wrapper,children:[n.jsx(E.IconWallet,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:Po.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:Po.button,onClick:()=>e(),disabled:s,"aria-label":"Use maximum balance",children:"MAX"})]}),fg="_fieldset_up6fh_1",pg="_upper_up6fh_9",gg="_select_up6fh_14",_g="_account_up6fh_20",yg="_lower_up6fh_25",xg="_wrapper_up6fh_26",bg="_balance_up6fh_33",wg="_value_up6fh_37",vg="_error_up6fh_50",$t={fieldset:fg,upper:pg,select:gg,account:_g,lower:yg,wrapper:xg,balance:bg,value:wg,error:vg},Go=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:$t.fieldset,children:[n.jsxs("div",{className:$t.upper,children:[n.jsx("div",{className:$t.select,children:t}),n.jsx("div",{className:$t.account,children:s})]}),!c&&n.jsxs("div",{className:$t.lower,children:[o,n.jsxs("div",{className:$t.wrapper,children:[n.jsx("div",{className:$t.balance,children:a}),r&&n.jsx("div",{className:$t.value,children:r})]}),i&&n.jsxs("footer",{className:$t.error,children:[n.jsx(E.IconWarningFilled,{size:12,"aria-hidden":"true"}),n.jsx("p",{role:"alert",children:i})]})]})]})};function fs(){const e=y.useRef(null),t=lo();return y.useEffect(()=>{t||e.current?.focus()},[t]),e}const jg="_input_h8073_1",Cg={input:jg};function Pc(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=fs();return n.jsx(Ie.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(Sl.NumericFormat,{value:l.value,getInputRef:ei.mergeRefs([l.ref,c]),className:D(Cg.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Ng="_input_19r9r_1",kg="_placeholder_19r9r_18",Yo={input:Ng,placeholder:kg},Ig=({children:e})=>n.jsx("p",{className:D(Yo.input,{[Yo.placeholder]:U(e).isZero()}),children:e}),ts=({balance:e,decimals:t,className:s})=>{const{control:o}=Ie.useFormContext(),a={required:"Enter amount",validate:r=>U(r).isZero()?"Enter amount":e!==void 0&&U(C.toBaseUnit(r,{decimals:t})).gt(e)?"Insufficient balance":!0};return n.jsx(Pc,{name:"quantity",control:o,className:D(Yo.input,s),rules:a})};ts.ReadOnly=Ig;const Ln=({title:e,content:t,children:s,className:o})=>{const[a,r]=y.useState(!1),i=()=>r(!1);return n.jsx(vc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},Ag="_tooltip_19kvs_1",Sg="_arrow_19kvs_44",br={tooltip:Ag,arrow:Sg},ps=({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:_n(),children:n.jsxs(Z.Tooltip.Content,{className:D(br.tooltip,{small:s}),collisionBoundary:_n(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(Z.Tooltip.Arrow,{className:br.arrow})]})})]});function La(e,t){const s=De(),o=Ma(),a=!!t&&!!e&&o(e,t);return S.useQuery({queryKey:je.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:K.SECOND})}function Tg(e,t,s){const{data:o={}}=La(e,t);return $.path([s],o)}const Eg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ns(e){if(!e)return;const{formattedParts:t}=Eg.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 Rc(e,t){return U(e).times(U(100).minus(t)).div(100).integerValue(U.ROUND_FLOOR).toFixed(0)}function qa(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${C.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Dc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,d=t.getQueryData(je.asset(a,r).queryKey);if(!d||d.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const m=d.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:C.toBaseUnit(i,{decimals:m}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function Zo(e,t){const{watch:s}=Gt(),o=s(),a=De(),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,m=l&&!t?.disabled&&!i,u=S.useQueryClient();return S.useQuery({queryKey:je.route(r,t?.isOpWithdraw).queryKey,queryFn:async({signal:h})=>Dc(a,u,r,{isOpWithdraw:t?.isOpWithdraw,signal:h}),enabled:m,staleTime:d,refetchInterval:m?d:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function $g(e){return S.useQuery({queryKey:je.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function Mg(){const{watch:e}=Gt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=it(t),i=es(r),c=kt(s,t),l=kt(a,o),d=oe(),m=he();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&m.find(u=>u.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const Lg="_label_t93ix_1",qg="_wrapper_t93ix_7",Pg="_input_t93ix_10",Rg="_clear_t93ix_18",ks={label:Lg,wrapper:qg,input:Pg,clear:Rg},Pa=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=C.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=fs(),{control:l,getValues:d,setValue:m,formState:u}=Ie.useFormContext(),h=d("recipient"),[f,g]=y.useState(h),p=li(),{data:_,isLoading:x,error:b}=S.useQuery({queryKey:Zs.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:K.MINUTE,enabled:p.validateUsername(f)}),j=_??(o(f)?f:""),w=t&&C.InitiaAddress.equals(j,t),v=async()=>{try{const M=await navigator.clipboard.readText();g(M.trim())}catch{}};y.useEffect(()=>{e==="onChange"&&(!f&&!u.dirtyFields.recipient||m("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[u.dirtyFields.recipient,f,e,m,_]);const k=()=>{x||b||(m("recipient",j,{shouldValidate:!0,shouldDirty:!0}),r?.())},T=()=>{if(x)return n.jsx(kn,{level:"loading",children:"Resolving username..."});if(b)return n.jsx(kn,{level:"error",children:b.message});if(_)return n.jsx(kn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!j)return n.jsx(kn,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:ks.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(ue.Small,{type:"button",tabIndex:-1,onClick:v,children:"Paste"})]}),n.jsxs("div",{className:ks.wrapper,children:[n.jsx(Ie.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:M=>o(M)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:D(ks.input,"monospace"),value:f,onChange:M=>g(M.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?ei.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:ks.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:n.jsx(E.IconCloseCircleFilled,{size:16})})]}),T(),w&&n.jsx(kn,{children:"This is my address"}),e==="onSubmit"&&n.jsx(Ae,{extra:(!t||!!j&&!w)&&n.jsx(xe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(ue.White,{type:"button",onClick:k,disabled:x||!!b||!j,children:"Apply"})})]})},Dg="_scrollable_vgj3r_1",Bg="_list_vgj3r_5",Fg="_item_vgj3r_9",Ug="_name_vgj3r_22",Is={scrollable:Dg,list:Bg,item:Fg,name:Ug};function Bc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(pt,{className:Is.scrollable,children:n.jsx("div",{className:Is.list,children:t.map(l=>n.jsxs("button",{className:Is.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),"aria-busy":!!i?.(l),children:[n.jsx(te,{src:o(l),width:28,height:28}),n.jsx("span",{className:Is.name,children:a(l)}),i?.(l)&&n.jsx(Nt,{size:16})]},r(l)))})})}function fo(){const{cosmosWallets:e=[]}=ne(),t=y.useMemo(()=>{const a=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}].filter(r=>!e.some(i=>i.name===r.name));return[...e,...a]},[e]);return{list:t,find:o=>t.find(a=>a.name===o)}}const Og="_account_h04x1_8",Vg="_clear_h04x1_28",Kg="_white_h04x1_39",On={account:Og,clear:Vg,white:Kg},wr=({type:e})=>{const{watch:t,setValue:s}=Gt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=es(it(a)),{showNotification:d}=us(),{list:m,find:u}=fo(),h=u(r),f=Ec(),g=Ma(),p=f(a),_=C.InitiaAddress.equals(c,p),x=()=>n.jsx(Ln,{title:"Connect wallet",content:w=>n.jsx(Bc,{onSelect:async v=>{const k=v.getProvider();if(!k){v.fallbackUrl?window.open(v.fallbackUrl,"_blank"):d({type:"error",title:`${v.name} not available`,description:"Please install the wallet extension and try again."});return}try{const M=await k.getOfflineSigner(o).getAccounts();if(M.length===0)throw new Error("No accounts found");s("sender",M[0].address),s("cosmosWalletName",v.name),w()}catch(T){const M=T instanceof Error?T.message:"Unknown error";d({type:"error",title:`Failed to connect ${v.name}`,description:M})}},list:m,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:D(On.account,{[On.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[h&&n.jsx(te,{src:h.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:C.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(E.IconChevronRight,{size:14,"aria-hidden":"true"})]})}),b=w=>n.jsx(Ln,{title:"Recipient",content:v=>n.jsx(pt,{children:n.jsx(Pa,{mode:"onSubmit",myAddress:p,chainType:l,validate:k=>g(k,a),onApply:v})}),className:On.account,children:w}),j=()=>{switch(l){case"initia":case"evm":return _?b(n.jsx(E.IconWallet,{size:14})):n.jsxs("div",{className:On.account,children:[n.jsx("span",{className:"monospace",children:C.truncate(c)}),n.jsx("button",{type:"button",className:On.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(E.IconCloseCircleFilled,{size:14})})]});case"cosmos":return b(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:C.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(E.IconEdit,{size:14,"aria-hidden":"true"})]}))}};switch(e){case"src":return x();case"dst":return j()}},Wg="_images_cj4xz_1",Ro={images:Wg},po=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:D(Ro.images,r),style:{position:"relative"},"aria-hidden":"true",children:[n.jsx(te,{src:e,width:t,height:t,className:Ro.asset,logo:!0}),n.jsx(te,{src:s,width:o,height:o,className:Ro.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),zg="_root_6187w_1",Hg="_content_6187w_10",Qg="_details_6187w_20",Gg="_symbol_6187w_26",Yg="_chain_6187w_34",Zg="_chevron_6187w_43",tn={root:zg,content:Hg,details:Qg,symbol:Gg,chain:Yg,chevron:Zg},Fc=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:tn.content,children:[n.jsx(po,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:tn.details,children:[n.jsx("div",{className:tn.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:tn.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:tn.root,children:o}):n.jsxs("div",{className:tn.root,children:[o,n.jsx(E.IconChevronDown,{size:16,className:tn.chevron,"aria-hidden":"true"})]})};function Jg(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 Xg="_root_1sh27_1",e_="_label_1sh27_8",t_="_input_1sh27_21",n_="_hasValue_1sh27_31",s_="_clear_1sh27_35",Vn={root:Xg,label:e_,input:t_,hasValue:n_,clear:s_},gs=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:D(Vn.root,t,{[Vn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Vn.label,children:n.jsx(E.IconSearch,{size:o})}),n.jsx("input",{className:Vn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Vn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(E.IconCloseCircleFilled,{size:o})})]})},o_="_container_5tajg_1",a_="_search_5tajg_7",r_="_list_5tajg_11",i_="_item_5tajg_15",c_="_logo_5tajg_37",l_="_info_5tajg_41",d_="_symbol_5tajg_47",u_="_name_5tajg_56",m_="_balance_5tajg_62",h_="_value_5tajg_69",at={container:o_,search:a_,list:r_,item:i_,logo:c_,info:l_,symbol:d_,name:u_,balance:m_,value:h_},_s=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=y.useState(""),i=Jg(["symbol"],a,t);return n.jsxs("div",{className:at.container,children:[n.jsx(gs,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:at.search,padding:20,ref:fs()}),i.length===0?n.jsx(be,{children:"No assets"}):n.jsx("div",{className:at.list,children:i.map(c=>n.jsx("button",{type:"button",className:at.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:m,symbol:u,name:h,balance:f,decimals:g,value:p=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(te,{src:m,width:32,height:32,className:at.logo,logo:!0}),n.jsxs("div",{className:at.info,children:[n.jsx("div",{className:at.symbol,children:u||d}),n.jsx("div",{className:at.name,children:h})]}),n.jsxs("div",{className:at.balance,children:[f&&n.jsx("div",{children:C.formatAmount(f,{decimals:g})}),p>0&&n.jsx("div",{className:at.value,children:ee(p)})]})]})})},c.denom))})]})},f_=()=>n.jsxs("div",{className:at.container,children:[n.jsx(gs,{rootClassName:at.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(be,{children:"Loading..."})]});_s.Placeholder=f_;const p_="_stack_16oqn_1",g_="_title_16oqn_9",__="_grid_16oqn_16",y_="_item_16oqn_22",x_="_button_16oqn_26",b_="_active_16oqn_44",In={stack:p_,title:g_,grid:__,item:y_,button:x_,active:b_},mn=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:In.title,children:e}),n.jsx("div",{className:In.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(Tc,{offset:-2,disabled:!a?.(r),className:In.item,children:n.jsx(ps,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button","aria-label":i,className:D(In.button,{[In.active]:r===s}),onClick:()=>o(r),children:n.jsx(te,{src:c,width:28,height:28,logo:!0})})})},r))})]}),w_=({children:e})=>n.jsx("div",{className:In.stack,children:e});mn.Stack=w_;const v_=({address:e,chain:t,onSelect:s})=>{const o=Ks(t.chain_id),{data:a={}}=La(e,t.chain_id);return n.jsx(_s,{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=C.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})},j_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Qt(),i=ho(),{watch:c,setValue:l}=Gt(),d=c(a),m=c(s),u=c(o),[h,f]=y.useState(m),g=it(h),p=Yp(),_=$a(),[x,b]=$.partition(w=>_(w.chain_id),i.filter(w=>!w.hidden)),j=w=>{if(m===h&&u===w){t();return}l(s,h),l(o,w),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(mn.Stack,{children:[n.jsx(mn,{label:"Interwoven Economy",chains:x.map(({chain_id:w,chain_name:v,pretty_name:k,logo_uri:T})=>({chainId:w,name:k||v,logoUrl:T??""})),value:h,onSelect:f}),n.jsx(mn,{label:"Chains",chains:b.map(({chain_id:w,chain_name:v,pretty_name:k,logo_uri:T})=>({chainId:w,name:k||v,logoUrl:T??""})),value:h,onSelect:f})]}),n.jsx(pe,{suspenseFallback:n.jsx(_s.Placeholder,{}),children:n.jsx(v_,{address:p({initialAddress:d,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:j})},h)]})},vr=({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}=Gt(),r=a(t),i=a(s),c=it(r),l=kt(i,r);return n.jsx(Ln,{title:o,content:d=>n.jsx(j_,{type:e,afterSelect:d}),children:n.jsx(Fc,{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??""}})})},C_="_skeleton_1l4jn_1",N_={skeleton:C_},hn=({width:e="100%",height:t})=>n.jsx("div",{className:N_.skeleton,style:{width:e,height:t},"aria-hidden":"true"}),k_="_stack_oq1ir_1",I_="_button_oq1ir_6",A_="_isLoading_oq1ir_19",S_="_disabled_oq1ir_19",T_="_checked_oq1ir_23",E_="_header_oq1ir_37",$_="_title_oq1ir_43",M_="_duration_oq1ir_52",L_="_warning_oq1ir_62",q_="_amount_oq1ir_66",P_="_value_oq1ir_67",ot={stack:k_,button:I_,isLoading:A_,disabled:S_,checked:T_,header:E_,title:$_,duration:M_,warning:L_,amount:q_,value:P_},R_=({children:e})=>n.jsx("div",{className:ot.stack,role:"radiogroup","aria-label":"Route options",children:e}),Ls=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Gt(),{dstChainId:l,dstDenom:d}=c(),m=kt(d,l),u=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:D(ot.button,{[ot.isLoading]:i,[ot.disabled]:h,[ot.checked]:u}),onClick:()=>{i||h||o(s)},role:"radio","aria-checked":u,"aria-disabled":h,children:[n.jsxs("div",{className:ot.header,children:[n.jsxs("div",{className:ot.title,children:[n.jsx("span",{children:e}),u&&n.jsx(E.IconCheck,{size:14,"aria-hidden":"true"})]}),i?n.jsx(hn,{width:80,height:16}):r?n.jsxs("div",{className:D(ot.duration,{[ot.warning]:s==="op"}),children:[n.jsx(E.IconClockFilled,{size:12,"aria-hidden":"true"}),n.jsx("span",{children:ns(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:ot.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:ot.amount,children:i?n.jsx(hn,{width:260,height:40}):r?C.formatAmount(r.amount_out,{decimals:m.decimals}):null}),n.jsx("div",{className:ot.value,children:i?n.jsx(hn,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};Ls.Stack=R_;const D_="_description_nuyvt_1",B_="_presets_nuyvt_8",F_="_preset_nuyvt_8",U_="_active_nuyvt_29",O_="_custom_nuyvt_40",V_="_wrapper_nuyvt_47",K_="_percent_nuyvt_58",xt={description:D_,presets:B_,preset:F_,active:U_,custom:O_,wrapper:V_,percent:K_},jr=["0.1","0.5","1.0"],W_=({afterConfirm:e})=>{const t=Gt(),s=t.getValues("slippagePercent"),[o,a]=y.useState(null),{control:r,watch:i,getValues:c,setValue:l}=Ie.useForm({defaultValues:{value:s}}),d=i("value");y.useEffect(()=>{const p=jr.findIndex(_=>_===s);a(p>=0?p:null)},[s]);const m=(p,_)=>{l("value",p),a(_)},u=()=>{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",g=({value:p})=>{t.setValue("slippagePercent",p),e()};return n.jsxs(pt,{children:[n.jsx("p",{className:xt.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:xt.presets,role:"radiogroup","aria-label":"Slippage presets",children:[jr.map((p,_)=>n.jsxs("button",{type:"button",className:D(xt.preset,{[xt.active]:o===_}),onClick:()=>m(p,_),role:"radio","aria-checked":o===_,children:[p,"%"]},p)),o!==null?n.jsx("button",{type:"button",className:D(xt.preset,xt.custom),onClick:()=>a(null),role:"radio","aria-checked":o===null,children:"Custom"}):n.jsxs("div",{className:xt.wrapper,children:[n.jsx(Pc,{name:"value",control:r,dp:2,onFocus:u,placeholder:"",className:D(xt.preset,xt.active)}),n.jsx("span",{className:xt.percent,children:"%"})]})]}),h&&n.jsx(xe,{level:h.type,children:h.text}),n.jsx(Ae,{children:n.jsx(ue.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},z_="_form_1owk5_1",H_="_arrow_1owk5_5",Q_="_divider_1owk5_14",G_="_flip_1owk5_23",Y_="_meta_1owk5_41",Z_="_row_1owk5_54",J_="_title_1owk5_60",X_="_description_1owk5_64",ey="_icon_1owk5_71",ty="_edit_1owk5_76",ny="_warning_1owk5_99",Fe={form:z_,arrow:H_,divider:Q_,flip:G_,meta:Y_,row:Z_,title:J_,description:X_,icon:ey,edit:ty,warning:ny};function sy({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}const oy=()=>{const e=Se(),t=lo(),s=qn(),[o,a]=y.useState(void 0),[r,i]=y.useState(!1),[c,l]=ze.useLocalStorage(ie.BRIDGE_ROUTE_TYPE,"default"),{watch:d,setValue:m,handleSubmit:u,formState:h}=Gt(),f=d(),{srcChainId:g,srcDenom:p,dstChainId:_,dstDenom:x,quantity:b,sender:j,slippagePercent:w}=f,v=Je(),k=oe(),T=it(g),M=es(T),A=it(_),L=es(A),N=kt(p,g),I=kt(x,_),{data:F}=La(j,g),q=Tg(j,g,p),P=!q?.amount||U(q.amount).isZero(),[B]=ze.useDebounceValue(b,300),Q=g===_,W=Q&&g===k.chainId,me=sy({isLayer1Swap:W,isL2Swap:Q&&M==="initia"&&!W}),ge=M!=="initia"&&L!=="initia",ce=Mg(),ye=Zo(B,{disabled:ge,refreshMs:me}),we=Zo(B,{isOpWithdraw:!0,disabled:!ce,refreshMs:me}),ve=ce&&c==="op",tt=ve?we:ye,Rt=ve?ye:we,Tt=ve?!ge:ce,qe=tt.error&&Tt?Rt:tt,{data:Y,isLoading:ct,error:re}=qe,{data:Be}=$g(re),Dt=B&&ct&&!r,Bt=()=>{m("srcChainId",_),m("srcDenom",x),m("dstChainId",g),m("dstDenom",p),m("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:_e,closeModal:Pe}=oo(),gt=u(async J=>{a(void 0),i(!0);let Te,Bn;try{const _t=await qe.refetch();if(_t.error||!_t.data||!_t.dataUpdatedAt){a(_t.error instanceof Error?_t.error.message:"Failed to refresh route. Please try again.");return}Te=_t.data,Bn=_t.dataUpdatedAt}finally{i(!1)}if(s("Bridge Simulation Success",{quantity:J.quantity,srcChainId:J.srcChainId,srcDenom:J.srcDenom,dstChainId:J.dstChainId,dstDenom:J.dstDenom}),Te.warning){const{type:_t="",message:wl}=Te.warning??{};_e({content:n.jsx(Mc,{type:"warning",icon:n.jsx(E.IconWarningFilled,{size:40}),title:Qs.sentenceCase(_t),primaryButton:{label:"Cancel",onClick:Pe},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:Te,values:J,quoteVerifiedAt:Bn}),Pe()}},children:n.jsx("p",{className:Fe.warning,children:wl})})});return}e("/bridge/preview",{route:Te,values:J,quoteVerifiedAt:Bn})}),He=y.useMemo(()=>Y?.estimated_fees?.filter(({fee_behavior:J})=>J==="FEE_BEHAVIOR_DEDUCTED")??[],[Y]),Qe=y.useMemo(()=>Y?.estimated_fees?.filter(({fee_behavior:J})=>J==="FEE_BEHAVIOR_ADDITIONAL")??[],[Y]),lt=y.useMemo(()=>{for(const J of Qe){const Te=F?.[J.origin_asset.denom]?.amount??"0",Bn=Y?.source_asset_denom===J.origin_asset.denom?Y.amount_in:"0";if(U(Te).lt(U(Bn).plus(J.amount??"0")))return`Insufficient ${J.origin_asset.symbol} for fees`}},[F,Y,Qe]),Ne=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(!Y)return"Route not found";if(lt)return lt},[B,lt,h,Y,f]),Zt=Y?C.formatAmount(Y.amount_out,{decimals:I.decimals}):"0",Jt=U(b).gt(0)&&U(b).isEqualTo(C.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),za=(()=>{switch(M){case"initia":return v(g).fees.fee_tokens.map(({denom:J})=>J);case"cosmos":return T.fee_assets.map(({denom:J})=>J);case"evm":return vt.isAddress(p)?[]:[p];default:return[]}})(),yl=za.includes(p),xl=za.some(J=>{if(J===p)return!1;const Te=F?.[J]?.amount??"0";return U(Te).gt(0)}),bl=Jt&&yl&&!xl,bo=y.useCallback((J,Te)=>J.length?n.jsxs("div",{className:Fe.description,children:[qa(J),!t&&n.jsx(ps,{label:Te,children:n.jsx("span",{className:Fe.icon,children:n.jsx(E.IconInfoFilled,{size:12,"aria-hidden":"true"})})})]}):null,[t]),xs=U(b).gt(0)&&ce&&ye.data&&we.data&&we.data.estimated_route_duration_seconds>ye.data.estimated_route_duration_seconds,Ha=y.useMemo(()=>{if(!Y)return[];const J=Rc(Y.amount_out,w);return[{condition:!!Y.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[bo(He,"Fee deducted from the amount you receive"),bo(Qe,"Fee charged in addition to the amount you enter")]})},{condition:!xs&&!!ns(Y.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Fe.description,children:ns(Y.estimated_route_duration_seconds)})},{condition:Y.does_swap,title:"Slippage",content:n.jsxs("span",{className:Fe.description,children:[n.jsxs("span",{children:[w,"%"]}),n.jsx(Ln,{title:"Slippage tolerance",content:Te=>n.jsx(W_,{afterConfirm:Te}),className:Fe.edit,children:n.jsx(E.IconSettingFilled,{size:12,"aria-hidden":"true"})})]})},{condition:Y.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Fe.description,children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol,width:12,height:12}),C.formatAmount(J,{decimals:I.decimals})," ",I.symbol]})}].filter(Te=>Te.condition)},[Qe,He,I,bo,Y,xs,w]);return n.jsxs("form",{className:Fe.form,onSubmit:gt,"aria-label":"Bridge and swap form",children:[n.jsx(Go,{selectButton:n.jsx(vr,{type:"src"}),accountButton:M==="cosmos"&&n.jsx(wr,{type:"src"}),quantityInput:n.jsx(ts,{balance:q?.amount,decimals:N?.decimals}),balanceButton:n.jsx(qc,{onClick:()=>m("quantity",C.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:P,children:C.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:Y?ee(Y.usd_amount_in):"$-"}),n.jsxs("div",{className:Fe.arrow,children:[n.jsx("div",{className:Fe.divider}),n.jsx("button",{type:"button",className:Fe.flip,onClick:()=>Bt(),"aria-label":"Swap source and destination",children:n.jsx(E.IconChevronDown,{size:16,"aria-hidden":"true"})})]}),n.jsx(Go,{selectButton:n.jsx(vr,{type:"dst"}),accountButton:n.jsx(wr,{type:"dst"}),quantityInput:n.jsx(ts.ReadOnly,{children:Zt}),value:Y?ee(Y.usd_amount_out):"$-",hideNumbers:xs}),n.jsx(Xn,{children:xs?n.jsxs(Ls.Stack,{children:[n.jsx(Ls,{label:"Fast",query:ye,value:"default",onSelect:l,checked:c==="default"}),n.jsx(Ls,{label:"Lossless",query:we,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(Ae,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(xe.Stack,{children:[o&&n.jsx(xe,{level:"error",children:o}),Y?.extra_infos?.map(J=>n.jsx(xe,{level:"info",children:J},J)),Be&&n.jsx(xe,{level:"info",children:Be}),bl&&n.jsx(xe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),Y?.warning&&n.jsx(xe,{level:"warning",children:Y.warning.message}),Y?.extra_warnings?.map(J=>n.jsx(xe,{level:"warning",children:J},J))]}),n.jsx(Xn,{children:Ha.length>0&&n.jsx("section",{className:Fe.meta,"aria-label":"Route details",children:Ha.map((J,Te)=>n.jsxs("div",{className:Fe.row,children:[n.jsx("span",{className:Fe.title,children:J.title}),J.content]},Te))})})]}),children:n.jsx(ue.White,{loading:r?"Refreshing route...":Dt&&"Simulating...",disabled:!!Ne||r,children:Ne??"Preview route"})})]})},ay=()=>{Lc();const e=hi(),t=Se(),s=Qt(),o=Am(),a=Ie.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:m,quantity:u,slippagePercent:h,recipient:f}=r();r((I,{name:F})=>{(F==="srcChainId"||F==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Ec(),p=g(c),_=g(l),b=Ma()(f,l);y.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),y.useEffect(()=>{b||i("recipient",_)},[_,b,i]);const{showNotification:j}=us(),w=it(c),v=it(l),k=Ks(c),T=Ks(l),M=k.some(I=>I.denom===d),A=T.some(I=>I.denom===m);y.useEffect(()=>{k.length>0&&!M&&(i("srcDenom",k[0].denom),j({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[k,M,i,j,w.pretty_name]),y.useEffect(()=>{T.length>0&&!A&&(i("dstDenom",T[0].denom),j({type:"info",title:`Switched to ${T[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[T,A,i,j,v.pretty_name]),y.useEffect(()=>{!M||!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,m),localStorage.setItem(ie.BRIDGE_QUANTITY,u),localStorage.setItem(ie.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,m,u,h,M,A]);const L=e[0].path==="/bridge",{reminders:N}=Dn();return n.jsx(At,{title:"Bridge/Swap",backButton:L?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(ue.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,"aria-label":"Bridge/Swap history",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:[n.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(Tc,{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:M&&A&&n.jsx(Ie.FormProvider,{...a,children:n.jsx(pe,{children:n.jsx(oy,{})})})})},ry="_button_1crvp_1",iy="_checkbox_1crvp_11",cy="_checked_1crvp_25",As={button:ry,checkbox:iy,checked:cy},ly=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:D(As.button,o),onClick:t,role:"checkbox","aria-checked":e,children:[n.jsx("div",{className:D(As.checkbox,{[As.checked]:e}),children:e&&n.jsx(E.IconCheck,{size:12,"aria-hidden":"true"})}),n.jsx("span",{className:As.label,children:s})]}),dy="_button_aoxv2_1",uy={button:dy},Uc=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=Tl.useInView();return y.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:uy.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(E.IconChevronDown,{size:12,"aria-hidden":"true"})]})};function Oc(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 qs=({chainId:e,txHash:t})=>`${ie.BRIDGE_HISTORY}:${e}:${t}`,Ws=100,Cr=10;function Vc(){const[e,t]=ze.useLocalStorage(ie.BRIDGE_HISTORY,[]),s=y.useCallback((a,r)=>{localStorage.setItem(qs(a),JSON.stringify(r));for(const i of e.slice(Ws-1))localStorage.removeItem(qs(i));t((i=[])=>[a,...i.slice(0,Ws-1)])},[e,t]),o=y.useCallback(a=>{const r=localStorage.getItem(qs(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function Kc(e){return ze.useLocalStorage(qs(e),null)}const bn=$e.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 go(){const{restUrl:e}=oe();return y.useMemo(()=>z.create({prefixUrl:e}),[e])}function my(e){const t=go(),{data:s}=S.useSuspenseQuery({queryKey:bn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Nr=20;function hy(e){const t=se();return S.useSuspenseInfiniteQuery({queryKey:bn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:Nr,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=$.last(s)?.sequence;return s.length<Nr||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function fy(e){const t=go(),{data:s}=S.useSuspenseQuery({queryKey:bn.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:K.SECOND});return s}function py({bridge_id:e,output_index:t}){const s=go(),{data:o}=S.useSuspenseQuery({queryKey:bn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:K.SECOND});return o}function gy({bridge_id:e,sequence:t}){const o=he().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Je()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=S.useSuspenseQuery({queryKey:bn.outputResponse(i,t).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:K.SECOND});return c}function Wc(e,t){const{bridge_id:s}=e,o=go(),{data:a}=S.useSuspenseQuery({queryKey:bn.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:K.SECOND});return a}function Kn(e){return El.sha3_256.create().update(e).digest()}function Do(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function zc(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Do(t.toString(),8),c=Do(s.toString(),8),l=Do(o.amount,8),d=rn.concatBytes(i,c,Kn(rn.utf8ToBytes(a)),Kn(rn.utf8ToBytes(r)),Kn(rn.utf8ToBytes(o.denom)),l);return Kn(Kn(d))}async function _y(e,t,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function yy(e,t){const s=z.create({prefixUrl:t}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Jo(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 St(){return Xe()}function xy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Se(),{showNotification:r,updateNotification:i,hideNotification:c}=us(),{addHistoryItem:l}=Vc(),d=qn(),{route:m,values:u}=St(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=u,_=qi(),{requestTxSync:x,submitTxSync:b,waitForTxConfirmation:j}=et(),{find:w}=fo(),v=rs(),k=is(),T=it(h),M=es(T),A=$c(h),L=S.useQueryClient(),{registryUrl:N}=ne(),I=Je(),F=oe(),{addReminder:q}=Dn(),P=De();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:qe,msg:Y})=>{if(!(qe&&Y))throw new Error("Invalid transaction data");return k.fromAmino({type:fn.aminoConverters[qe].aminoType,value:JSON.parse(Y)})});if(M==="initia"){const{srcDenom:qe,quantity:Y}=u,{decimals:ct}=A(qe),re=s?await b({messages:B,chainId:h,fee:s}):await x({messages:B,chainId:h,internal:1,spendCoins:[{denom:qe,amount:C.toBaseUnit(Y,{decimals:ct})}]}),Be=j({txHash:re,chainId:h});return{txHash:re,wait:Be}}const Q=w(p)?.getProvider();if(!Q)throw new Error("Wallet not connected");const W=Q.getOfflineSignerOnlyAmino(h),O=await Ee.SigningStargateClient.connectWithSigner(T.rpc,W,{registry:v,aminoTypes:k}),me=await O.getAllBalances(f),ge=T.fee_assets.find(qe=>me.some(Y=>Y.denom===qe.denom&&U(Y.amount).gt(0)));if(!ge){const Y=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(ct=>A(ct.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Y)}const{denom:ce,gas_price:ye}=ge;if(!ye)throw new Error(`Gas price not found for ${ce}`);const we=await O.simulate(f,B,""),ve=Ee.GasPrice.fromString(ye.average+ce),tt=Ee.calculateFee(Math.ceil(we*pn),ve),Rt=await O.signAndBroadcastSync(f,B,tt),Tt=Yi({txHash:Rt,client:O});return{txHash:Rt,wait:Tt}}if("evm_tx"in e){const{chain_id:B,to:Q,value:W,data:O}=e.evm_tx,me=await _(),ge=await me.getSigner();await Jo(me,T);const ce=await ge.sendTransaction({chainId:B,to:Q,value:W,data:`0x${O}`}),ye=Pi(ce.wait(),3e4,"Transaction was not confirmed in time. It may still be processing.");return{txHash:ce.hash,wait:ye}}throw new Error("Unlisted chain type")}catch(B){throw B instanceof un?B:await Ct(B)}},onSuccess:async({txHash:B,wait:Q})=>{localStorage.removeItem(ie.BRIDGE_QUANTITY),L.removeQueries({queryKey:je.route._def}),L.removeQueries({queryKey:je.routeErrorInfo._def}),o?o({txhash:B,chainId:h,timestamp:Date.now(),success:!0,route:m,values:u}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Q;const W=_o(m)==="OP Bridge withdrawal",O=W?{success:!0,error:null}:await Cy(P,B,h);if(!o&&!O.success&&O.error){const we=O.error instanceof Error?O.error.message:String(O.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${we}. The transaction may still be processing.`,autoHide:!0})}const me=O.success,ce=kr({txHash:B,srcChainId:h,route:m,values:u,recipient:g},me);l(ce.tx,ce.details),o||i(wy(c));const ye=Bo(u,B);if(d("Bridge Transaction Success",ye),W){const we=I(h).metadata?.op_bridge_id;if(we&&!await _y(F.restUrl,Number(we),m.dest_asset_denom)){const tt=jy(ce.tx,m,g);q(ce.tx,tt)}}}catch(W){const O=W instanceof Error?W.message:String(W);if(W instanceof un){const ge=kr({txHash:B,srcChainId:h,route:m,values:u},!1);l(ge.tx,ge.details),o||i(vy(c))}else o?o({success:!1,error:O,route:m,values:u}):i({type:"error",title:"Transaction not confirmed",description:O});d("Bridge Confirmation Failed",{...Bo(u,B),error:O,type:W instanceof un?"timeout":"error"})}finally{L.invalidateQueries({queryKey:je.balances(h,f).queryKey})}},onError:async B=>{const Q=M==="initia"?await Nn(B,I(h),N):B;o?o({success:!1,error:Q.message,route:m,values:u}):r({type:"error",title:"Transaction failed",description:Q.message});const W=Bo(u);d("Bridge Transaction Failed",{...W,error:Q.message})}})}function by(){const e=De(),t=se(),s=Mi(),{route:o,values:a}=St(),r=Pt();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:C.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await yy(t,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:u,msg:h})=>fn.aminoTypes.fromAmino({type:fn.aminoConverters[u].aminoType,value:JSON.parse(h)})),d=await s(i,t,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),m=Ge.Tx.fromPartial({body:Ge.TxBody.decode(d.bodyBytes),authInfo:Ge.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:ae.toBase64(Ge.Tx.encode(m).finish())}}catch(i){throw await Ct(i)}}})}function wy(e){return{type:"info",title:"Transaction submitted",description:y.createElement(y.Fragment,null,"Check ",y.createElement(dn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function vy(e){return{type:"info",title:"Transaction pending",description:y.createElement(y.Fragment,null,"Confirmation is taking longer than expected. Check ",y.createElement(dn,{to:"/bridge/history",onClick:e},"the activity page")," for updates"),autoHide:!0}}function Bo(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function kr(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=_o(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 jy(e,t,s){return{...e,recipient:C.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function Cy(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await Ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Hc(e){const{chainId:t,txHash:s,tracked:o}=e,a=De();return S.useQuery({queryKey:je.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await Ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Qc(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=De();return S.useQuery({queryKey:je.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,m=Date.now(),u=Math.floor((d-m)/1e3);return u<=0?1e3:u<=300?5e3:60*1e3},staleTime:K.INFINITY})}var Qn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Qn||{});function _o(e){const{operations:t,dest_asset_denom:s}=e;return $.has("op_init_transfer",$.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Ny="_success_t4dfk_1",ky="_error_t4dfk_5",Ir={success:Ny,error:ky},Iy=({tx:e})=>{const[t,s]=Kc(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=Qc(t),a=t.state??Ay(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:Ir.error,children:n.jsx(E.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:Ir.success,children:n.jsx(E.IconCheckCircleFilled,{size:14})});default:return n.jsx(Nt,{size:14})}};function Ay(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 Sy="_link_104m3_1",Ty="_header_104m3_23",Ey="_title_104m3_31",$y="_date_104m3_37",My="_explorer_104m3_41",Ly="_fees_104m3_57",qy="_label_104m3_65",Py="_content_104m3_69",Ry="_route_104m3_75",Dy="_row_104m3_80",By="_asset_104m3_86",Fy="_amount_104m3_94",Uy="_chain_104m3_99",Oy="_account_104m3_108",Vy="_arrow_104m3_115",Me={link:Sy,header:Ty,title:Ey,date:$y,explorer:My,fees:Ly,label:qy,content:Py,route:Ry,row:Dy,asset:By,amount:Fy,chain:Uy,account:Oy,arrow:Vy},Ky=({tx:e})=>{const[t,s]=Kc(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}=Hc(t),{address:m="",connector:u}=We.useAccount(),{find:h}=fo();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:g,source_asset_chain_id:p,source_asset_denom:_,dest_asset_chain_id:x,dest_asset_denom:b,estimated_fees:j=[]}=r,w=it(p),v=it(x),k=kt(_,p),T=kt(b,x),M=(P,B)=>B?n.jsx(te,{src:B,width:12,height:12}):C.InitiaAddress.equals(P,m)?n.jsx(te,{src:u?.icon,width:12,height:12}):n.jsx(E.IconWallet,{size:12}),A=(P,{symbol:B,decimals:Q,logo_uri:W},{chain_name:O,pretty_name:me,...ge},ce,ye)=>n.jsxs("div",{className:Me.row,children:[n.jsx(po,{assetLogoUrl:W,chainLogoUrl:ge.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:Me.asset,children:[n.jsx("span",{className:Me.amount,children:C.formatAmount(P,{decimals:Q})}),n.jsx("span",{children:B})]}),n.jsxs("div",{className:Me.chain,children:[n.jsxs("span",{children:["on ",me||O]}),n.jsxs("div",{className:Me.account,children:[ye,n.jsx("span",{className:"monospace",children:C.truncate(ce)})]})]})]})]}),L=_o(r),N=y.useMemo(()=>{switch(L){case Qn.SKIP:return"Skip Explorer";case Qn.OP_WITHDRAW:return"Initia Scan"}},[L]),I=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Me.header,children:[n.jsxs("div",{className:Me.title,children:[l?n.jsx(Iy,{tx:e}):n.jsx(Nt,{size:14}),n.jsx("div",{className:Me.date,children:Ze.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:Me.explorer,children:[n.jsx("span",{children:N}),n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})]})]}),n.jsxs("div",{className:Me.route,children:[A(f,k,w,i.sender,M(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:Me.arrow,children:n.jsx(E.IconArrowDown,{size:12,"aria-hidden":"true"})}),A(g,T,v,i.recipient,M(i.recipient))]}),j.length>0&&n.jsxs("div",{className:Me.fees,children:[n.jsx("span",{className:Me.label,children:"Fees"}),n.jsx("span",{className:Me.content,children:qa(j)})]})]});if(L===Qn.OP_WITHDRAW)return n.jsx(mo,{chainId:o,txHash:a,className:Me.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:Me.link,target:"_blank",rel:"noopener noreferrer",children:I})},Wy="_history_13u9z_1",zy="_header_13u9z_5",Hy="_checkbox_13u9z_9",Qy="_groups_13u9z_13",Gy="_dateGroup_13u9z_21",Yy="_dateHeader_13u9z_26",Zy="_list_13u9z_32",nn={history:Wy,header:zy,checkbox:Hy,groups:Qy,dateGroup:Gy,dateHeader:Yy,list:Zy},Jy=()=>{const{initiaAddress:e,hexAddress:t}=et(),{history:s,getHistoryDetails:o}=Vc(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:_,recipient:x}=p;return[_,x].some(b=>[e,t].includes(b))}),[i,c]=y.useState(1),[l,d]=ze.useToggle(!r.length),m=l?a:r,u=m.slice(0,i*Cr),h=y.useMemo(()=>Oc(u,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[u,o]);return n.jsx(At,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:nn.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:nn.header,children:n.jsx(ly,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:nn.checkbox})}),m.length===0?n.jsx(be,{children:"No bridge/swap activity"}):n.jsx("div",{className:nn.groups,children:Object.entries(h).map(([f,g])=>n.jsxs("div",{className:nn.dateGroup,children:[n.jsx("div",{className:nn.dateHeader,children:f}),n.jsx("div",{className:nn.list,children:g.map(p=>n.jsx(pe,{children:n.jsx(Ky,{tx:p})},p.txHash))})]},f))}),m.length>i*Cr?n.jsx(Uc,{onClick:()=>c(f=>f+1)}):s.length>=Ws&&n.jsxs(be,{children:["Only the latest ",Ws," items are stored. Older entries will be removed automatically."]})]})})};function Gc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Xy({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Gc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function ex({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Gc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const tx=1e4;function Xo(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Xo).join(",")}]`:`{${Object.entries(e).toSorted(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${Xo(s)}`).join(",")}}`}function Ar(e){return Xo({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 nx(e,t,s){const o=Se(),a=Xe(),r=S.useQueryClient(),i=De(),[c,l]=y.useState(!1),[d,m]=y.useState(void 0),[u,h]=y.useState(s??0),f=y.useRef(null);return y.useEffect(()=>{h(s??0)},[s]),y.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const p=Math.max(s??0,u);if(Date.now()-p<=tx)return!1;l(!0),m(void 0);const _=new AbortController;f.current=_;try{const x=await Dc(i,r,t,{isOpWithdraw:_o(e)===Qn.OP_WITHDRAW,signal:_.signal});if(_.signal.aborted)return!0;const b=Ar(x)!==Ar(e),j=Date.now();return b?(o(0,Xy({currentState:a,route:x,values:t,quoteVerifiedAt:j})),!0):(h(j),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||_.signal.aborted||m((await Ct(x)).message),!0}finally{f.current===_&&(f.current=null),_.signal.aborted||l(!1)}},isRefreshing:c,refreshError:d,clearRefreshError:()=>m(void 0)}}function sx(e,t){return t?"Confirm updated route":e||"Confirm"}const Ra=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a})=>{const r=Se(),i=Xe(),{route:c,values:l,quoteVerifiedAt:d,requiresReconfirm:m}=St(),{mutate:u,isPending:h}=xy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:f,isRefreshing:g,refreshError:p,clearRefreshError:_}=nx(c,l,d),x=async()=>{if(!(h||g)){if(m){r(0,ex({currentState:i,route:c,values:l,quoteVerifiedAt:d??Date.now()}));return}await f()||(_(),u())}},b=a??p??(m?"Route updated. Please review and confirm again.":void 0);return n.jsx(Ae,{extra:b&&n.jsx(xe,{level:a||p?"error":"info",children:b}),children:n.jsx(ue.White,{onClick:x,loading:g?"Refreshing route...":h&&"Signing transaction...",disabled:!!a,children:sx(o,!!m)})})},ox="_content_1hzj2_1",ax="_info_1hzj2_6",rx="_arrow_1hzj2_11",ix="_divider_1hzj2_19",cx="_type_1hzj2_27",lx="_asset_1hzj2_47",dx="_amount_1hzj2_55",ux="_lower_1hzj2_60",mx="_chain_1hzj2_66",hx="_address_1hzj2_72",st={content:ox,info:ax,arrow:rx,divider:ix,type:cx,asset:lx,amount:dx,lower:ux,chain:mx,address:hx},Yc=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=C.truncate(a),decimals:d=0,logo_uri:m=da}=e,{chain_name:u,pretty_name:h,...f}=it(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:st.arrow,children:[n.jsx("div",{className:st.divider}),s?n.jsx(ps,{label:s,children:n.jsx("button",{className:st.type,children:n.jsx(E.IconArrowDown,{size:12})})}):n.jsx("span",{className:st.type,children:n.jsx(E.IconArrowDown,{size:12})}),n.jsx("div",{className:st.divider})]}),n.jsxs("div",{className:st.content,children:[n.jsx(po,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:st.info,children:[n.jsxs("div",{className:st.asset,children:[n.jsx("span",{className:st.amount,children:C.formatAmount(o,{decimals:d})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:st.lower,children:[n.jsxs("div",{className:st.chain,children:["on ",h||u]}),i&&n.jsx(Os,{value:i,children:({copy:g,copied:p})=>n.jsxs("button",{className:st.address,onClick:g,children:[c,p?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:C.truncate(i)})]})})]})]})]})]})},An=e=>{const t=kt(e.denom,e.chainId);return n.jsx(Yc,{...e,...t})};An.Placeholder=Yc;const fx="_root_1hbar_1",px="_flexEnd_1hbar_6",gx="_toggle_1hbar_11",_x="_route_1hbar_36",yx="_content_1hbar_43",Wn={root:fx,flexEnd:px,toggle:gx,route:_x,content:yx};function xx(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":Qs.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 bx=({addressList:e})=>{const{values:t,route:s}=St(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=$.zipObj(s.required_chain_addresses,e),{find:l}=fo(),{connector:d,address:m=""}=We.useAccount(),[u,h]=ze.useToggle(!1),f=i.length>1,g=n.jsx(te,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:d?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:g},_=v=>C.InitiaAddress.equals(v,m)?g:n.jsx(E.IconWallet,{size:11}),x=v=>{const{label:k,amount_out:T,denom:M,denom_out:A=M,chain_id:L,from_chain_id:N,to_chain_id:I=L??N}=v,F=c[I];return{label:f&&!u?void 0:k,amount:T,denom:A,chainId:I,address:F,walletIcon:_(F)}},b=i.map(xx).map(x),j=b.slice(0,-1),w=b[b.length-1];return n.jsxs(Z.Collapsible.Root,{className:Wn.root,open:u,onOpenChange:h,children:[f&&n.jsx("div",{className:Wn.flexEnd,children:n.jsx(Z.Collapsible.Trigger,{className:Wn.toggle,children:u?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:Wn.route,children:[n.jsx(An,{...p,source:!0}),n.jsx(Z.Collapsible.Content,{className:Wn.content,children:j.map((v,k)=>n.jsx(pe,{suspenseFallback:n.jsx(An.Placeholder,{...v}),errorBoundaryProps:{fallback:n.jsx(An.Placeholder,{...v})},children:n.jsx(An,{...v})},k))}),n.jsx(An,{...w})]})]})},Zc=({error:e})=>{const t=Se();return n.jsx(Ae,{extra:n.jsx(xe,{level:"error",children:e.message}),children:n.jsx(ue.White,{onClick:()=>t("/bridge"),children:"Home"})})},Jc=({children:e})=>{const t=St(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:m}=et(),u=cs(),h=Pt(),f=ms(),g=h(r),p=f(g),_=a.slice(0,-1).some(T=>{const M=h(T);return f(M)==="cosmos"})&&p!=="cosmos",[x,b]=y.useState(void 0),[j,w]=y.useState(!1),[v,k]=y.useState(null);if(y.useEffect(()=>{(async()=>{try{if(!_)return;if(!u)throw new Error("Wallet not connected");w(!0),k(null);const[{pubkey:M}]=await u.getAccounts();b(M)}catch(M){k(await Ct(M))}finally{w(!1)}})()},[_,u]),v)return n.jsx(Zc,{error:v});if(j)return n.jsx(Ae,{children:n.jsx(ue.White,{loading:j&&"Generating intermediary addresses..."})});if(!_||x){const T=a.map((M,A)=>{if(A===a.length-1){const q=h(i);return f(q)==="initia"?C.InitiaAddress(l).bech32:l}const L=h(M),N=f(L),I=h(r),F=f(I);switch(N){case"initia":return d;case"evm":return m;case"cosmos":{if(F==="cosmos")return ae.toBech32(L.bech32_prefix,ae.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return Tn.pubkeyToAddress(Tn.encodeSecp256k1Pubkey(x),L.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(T)}return null},Da=({tx:e,children:t})=>{const s=qi(),o=Pt(),a=S.useQueryClient(),{data:r,isLoading:i}=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:h}=e.evm_tx,f=await s();await Jo(f,o(u));const g=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async _=>{const{token_contract:x,spender:b}=_,w=await new vt.ethers.Contract(x,g,f).allowance(h,b);return{approval:_,currentAllowance:BigInt(w.toString())}}))).filter(({approval:_,currentAllowance:x})=>x<BigInt(_.amount)).map(({approval:_})=>_)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:c,data:l,isPending:d,error:m}=S.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!r||r.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,h=await s(),f=await h.getSigner();await Jo(h,o(u));for(const g of r){const{token_contract:p,spender:_,amount:x}=g,b=["function approve(address spender, uint256 amount) external returns (bool)"],w=await new vt.ethers.Contract(p,b,f).approve(_,x);await Pi(w.wait(),3e4,"Approval was not confirmed in time. It may still be processing.")}return!0}catch(u){throw u instanceof un?(a.invalidateQueries({queryKey:["interwovenkit:erc20-approvals-needed",e]}),u):await Ct(u)}}});return i?n.jsx(Ae,{children:n.jsx(ue.White,{loading:"Checking approvals..."})}):r&&r.length>0&&!l?n.jsx(Ae,{extra:n.jsx(xe,{level:"error",children:m?.message}),children:n.jsx(ue.White,{onClick:()=>c(),loading:d&&"Approving tokens...",children:"Approve tokens"})}):t},Xc=({addressList:e,signedOpHook:t,children:s})=>{const o=De(),{route:a,values:r}=St(),[i,c]=y.useState(void 0),[l,d]=y.useState(!1),[m,u]=y.useState(null),h=JSON.stringify(e),f=JSON.stringify(a.operations),g=JSON.stringify(t??null),p=y.useMemo(()=>e,[h]),_=y.useMemo(()=>a.operations,[f]),x=y.useMemo(()=>t,[g]);return y.useEffect(()=>{let b=!1;return(async()=>{try{if(a.required_op_hook&&!x)throw new Error("Op hook is required");d(!0),u(null);const w={address_list:p,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:v}=await o.post("v2/fungible/msgs",{json:w}).json();if(b)return;if(!v||v.length===0)throw new Error("No transaction data found");const[k]=v;c(k)}catch(w){if(b)return;u(w)}finally{b||d(!1)}})(),()=>{b=!0}},[p,_,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]),m?n.jsx(Zc,{error:m}):l||!i?n.jsx(Ae,{children:n.jsx(ue.White,{loading:"Fetching messages..."})}):s(i)},el=({children:e})=>{const{route:t}=St(),s=by();return t.required_op_hook&&!s.data?n.jsx(Ae,{extra:n.jsx(xe,{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)},wx=()=>n.jsx(At,{title:"Route preview",children:n.jsx(Jc,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(bx,{addressList:e}),n.jsx(el,{children:t=>n.jsx(Xc,{addressList:e,signedOpHook:t,children:s=>n.jsx(Da,{tx:s,children:n.jsx(Ra,{tx:s})})})})]})})}),tl=y.createContext(null);function yo(){return y.useContext(tl)}const vx="_button_17r1o_1",jx="_claimed_17r1o_24",Sr={button:vx,claimed:jx},Cx=()=>{const{withdrawalTx:e}=yo(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,m=oe(),u=se(),{requestTxSync:h,waitForTxConfirmation:f}=et(),g=gy(e),p=ae.toBase64(zc(e)),_=Wc(e,p),x=S.useQueryClient(),{mutate:b,isPending:j}=S.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:w}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:u,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(ae.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:ae.fromBase64(d),storageRoot:ae.fromBase64(i),lastBlockHash:ae.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:m.chain_id,txHash:w}),x.invalidateQueries({queryKey:bn.withdrawalClaimed(t,p).queryKey})}});return _?n.jsxs("div",{className:Sr.claimed,children:[n.jsx(E.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:Sr.button,onClick:()=>b(),disabled:j,children:"Claim"})},Nx=({children:e})=>{const{withdrawalTx:t}=yo(),s=my(t.bridge_id),o=py(t),a=y.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ze.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},nl=1e3,kx=60,Ix=60,Ax=24,ea=nl*kx,ta=ea*Ix,Tr=ta*Ax,Sx=({date:e})=>{const t=y.useCallback(()=>{const d=new Date().getTime(),u=e.getTime()-d;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(u/Tr),f=Math.floor(u%Tr/ta),g=Math.floor(u%ta/ea),p=Math.floor(u%ea/nl);return{days:h,hours:f,minutes:g,seconds:p}},[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(ps,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},Tx="_container_1lz3w_1",Ex="_title_1lz3w_5",Er={container:Tx,title:Ex},$x=({date:e})=>n.jsxs("div",{className:Er.container,children:[n.jsx("div",{className:Er.title,children:"Claimable in"}),n.jsx(Sx,{date:e})]}),Mx="_container_1oldz_1",Lx="_icon_1oldz_7",$r={container:Mx,icon:Lx},qx="Withdrawal will begin within an hour",Mr=()=>{const e=lo();return n.jsxs("div",{className:$r.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(ps,{label:qx,children:n.jsx("span",{className:$r.icon,children:n.jsx(E.IconInfoFilled,{size:12})})})]})},Px=({children:e})=>{const{withdrawalTx:t}=yo(),s=fy(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},Rx=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=yo(),a=ae.toBase64(zc(o)),r=Wc(o,a),{setReminder:i,removeReminder:c}=Dn();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:Ze.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},Dx=()=>n.jsx(Px,{children:e=>e?n.jsx(Mr,{}):n.jsx(Nx,{children:t=>t?n.jsx(Rx,{date:t,children:Ze.isFuture(t)?n.jsx($x,{date:t}):n.jsx(Cx,{})}):n.jsx(Mr,{})})}),Bx="_asset_6h8u2_1",Fx="_info_6h8u2_7",Ux="_symbol_6h8u2_11",Fo={asset:Bx,info:Fx,symbol:Ux},Ox=({amount:e,denom:t})=>{const s=oe(),o=ii(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:Fo.asset,children:[n.jsx(te,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:Fo.info,children:[n.jsx("span",{className:"monospace",children:C.formatAmount(e,{decimals:i})}),n.jsx("span",{className:Fo.symbol,children:a})]})]})},Vx="_item_km5w2_1",Kx={item:Vx},Wx=({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}=hy(t),i=y.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Dn();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:Kx.item,children:[n.jsx(Ox,{...d}),n.jsx(pe,{suspenseFallback:null,children:n.jsx(tl.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(Dx,{})})})]},l.sequence)}),a&&n.jsx(Uc,{onClick:()=>o(),disabled:r})]}):n.jsx(be,{children:"No withdrawals"})},zx="_content_dj1qm_1",Hx="_title_dj1qm_5",Lr={content:zx,title:Hx},Qx=()=>{const{chainId:e}=Xe(),t=he(),s=yn(),[o,a]=y.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Je(),{reminders:i}=Dn(),c=o?r(o):void 0;return n.jsxs(At,{title:"OP Bridge withdrawals",children:[n.jsx(mn,{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:Lr.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Lr.title,children:c.name}),n.jsx(pe,{children:n.jsx(Wx,{chain:c})},o)]}):n.jsx(xe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},zs=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Gx="5722e7dffb709492cf5312446ceeff73",Yx=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Gx}`,sl=["interwovenkit:walletconnect-wallets"],Zx=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",ol=async e=>{const t=await z.get(Yx,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(Zx)},Jx=()=>S.useQuery({queryKey:sl,queryFn:({signal:e})=>ol(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),Xx="_page_13y8q_1",e1="_pageTop_13y8q_19",t1="_backButtonFixed_13y8q_63",n1="_listItem_13y8q_64",s1="_socialButton_13y8q_65",o1="_arrowIcon_13y8q_66",a1="_searchInputUnderline_13y8q_67",r1="_header_13y8q_72",i1="_title_13y8q_81",c1="_headerSpacer_13y8q_116",l1="_icon_13y8q_120",d1="_installedText_13y8q_124",u1="_divider_13y8q_131",m1="_dividerText_13y8q_152",h1="_loading_13y8q_193",f1="_socialIcons_13y8q_198",p1="_socialText_13y8q_204",g1="_searchWrapper_13y8q_214",_1="_scrollable_13y8q_248",y1="_list_13y8q_64",x1="_listIconWrapper_13y8q_332",b1="_moreIconSmall_13y8q_342",w1="_externalLinkIcon_13y8q_364",v1="_listName_13y8q_368",j1="_listNameMuted_13y8q_381",C1="_recentBadge_13y8q_394",N1="_learnMoreLink_13y8q_408",V={page:Xx,pageTop:e1,backButtonFixed:t1,listItem:n1,socialButton:s1,arrowIcon:o1,searchInputUnderline:a1,header:r1,title:i1,headerSpacer:c1,icon:l1,installedText:d1,divider:u1,dividerText:m1,loading:h1,socialIcons:f1,socialText:p1,searchWrapper:g1,scrollable:_1,list:y1,listIconWrapper:x1,moreIconSmall:b1,externalLinkIcon:w1,listName:v1,listNameMuted:j1,recentBadge:C1,learnMoreLink:N1},k1=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},I1=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=y.useState(""),{data:l=[],isError:d,isLoading:m,isFetching:u}=Jx(),h=m||u&&l.length===0,f=y.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(p))},[e,i]),g=y.useMemo(()=>{const p=new Set(e.map(x=>zs(x.name))),_=i.toLowerCase();return l.filter(x=>!p.has(zs(x.name))).filter(x=>!i||x.name.toLowerCase().includes(_)).sort((x,b)=>x.name.localeCompare(b.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(gs,{rootClassName:V.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),n.jsx(pt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[f.map(p=>{const{name:_,icon:x,id:b}=p,j=o===b,w=s===b,v="ready"in p?!!p.ready:!0;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:w}),onClick:()=>a(p),disabled:t||!v,"aria-busy":w,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(te,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:_}),w?n.jsx(Nt,{size:16}):j?n.jsx("span",{className:V.recentBadge,children:"Recent"}):v?n.jsx("span",{className:V.installedText,children:"Installed"}):null]},`connector:${b}`)}),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(Nt,{size:16})}),n.jsx("span",{className:V.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const _=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,x=_&&k1(_)?_:void 0;return n.jsxs("button",{type:"button",className:V.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[n.jsx("div",{className:V.listIconWrapper,children:x&&n.jsx(te,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:p.name})]},`wc:${p.id}`)}),d&&n.jsx(xe,{level:"error",children:"Couldn't load additional wallets."})]})})]})},A1=()=>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"})]}),S1=()=>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"})]}),T1=()=>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"})}),E1=()=>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"})]}),$1=[{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"}],M1=({walletConnectors:e,privyConnector:t,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),d=l.slice(0,5),m=new Set(l.map(g=>g.id)),u=new Set(l.map(g=>zs(g.name))),h=Math.max(0,5-d.length),f=$1.filter(g=>!m.has(g.id)&&!u.has(zs(g.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(Nt,{size:16}):n.jsxs("div",{className:V.socialIcons,children:[n.jsx(S1,{}),n.jsx(E1,{}),n.jsx(T1,{})]})]}),n.jsx("div",{className:V.divider,children:n.jsx("span",{className:V.dividerText,children:"or"})})]}),n.jsx(pt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[d.map(g=>{const{name:p,icon:_,id:x}=g,b=o===x,j=a===x;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:b}),onClick:()=>r(g),disabled:s,"aria-busy":b,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(te,{src:_,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:p}),b?n.jsx(Nt,{size:16}):j?n.jsx("span",{className:V.recentBadge,children:"Recent"}):n.jsx("span",{className:V.installedText,children:"Installed"})]},x)}),f.map(g=>n.jsxs("a",{className:V.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(te,{src:g.icon,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:g.name}),n.jsx(E.IconExternalLink,{size:10,className:V.externalLinkIcon,"aria-hidden":"true"})]},g.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(A1,{})})}),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"})]})]})},qr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=We.useConnect(),o=ze.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=y.useState(null),[i,c]=y.useState("signin"),l=S.useQueryClient(),d=()=>l.prefetchQuery({queryKey:sl,queryFn:({signal:p})=>ol(p),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:m,isPending:u}=S.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(_){throw await Ct(_)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=y.useMemo(()=>[...t].sort((p,_)=>p.id===o?-1:_.id===o?1:p.name.localeCompare(_.name)),[t,o]),f=y.useMemo(()=>h.find(p=>p.id===Yn.id),[h]),g=y.useMemo(()=>h.filter(p=>p.id!==Yn.id),[h]);return i==="all"?n.jsx(I1,{walletConnectors:g,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):n.jsx(M1,{walletConnectors:g,privyConnector:f,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:d})},L1="iUSD",Pr="1",q1="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",P1="0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",R1={[L1]:{externalSourceSymbols:["USDC","AUSD"],extraExternalOptions:[{chainId:Pr,denom:q1},{chainId:Pr,denom:P1}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Rr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function D1(e){return R1[e]}function Dr(e){return e.pretty_name||e.chain_name}function Br(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const B1={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:""},F1={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 ys(e){return F1[e]}function U1(){const e=De(),{data:t,error:s}=S.useQuery({queryKey:je.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:K.MINUTE});return{chains:t??[],error:s}}function Ba(){const e=De(),t=Rn(),s=se(),{chains:o,error:a}=U1(),r=y.useMemo(()=>o.map(({chain_id:d})=>d),[o]),{data:i,error:c,isLoading:l}=S.useQuery({queryKey:je.allBalances(r,[t,s]).queryKey,queryFn:()=>{const d=Object.fromEntries(o.map(m=>[m.chain_id,{address:m.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(([m,{denoms:u}])=>[m,u||{}])):{},enabled:!!s&&r.length>0,staleTime:K.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Fa(){const{localOptions:e=[]}=Xe(),t=S.useQueryClient(),s=De(),{data:o,isLoading:a}=S.useQuery({queryKey:je.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:K.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 m=c.get(`${d}:${l}`);return{denom:l,chain_id:d,symbol:m?.symbol??"",logo_uri:m?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData(En.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Ua(e){const{local:t}=ys(e),s=hs(),{watch:o}=Yt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function O1(e){const{external:t}=ys(e),s=hs(),{watch:o}=Yt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function al(e){const t=hs(),s=ho(),o=Pt(),a=$a(),{data:r,isLoading:i}=Ba(),{remoteOptions:c=[]}=Xe(),l=Ua(e);if(!l)return{...B1,isLoading:i};const d=D1(l.symbol),m=d?.externalSourceSymbols??[l.symbol],u=c.length>0,h=d?.extraExternalOptions??[],f=d?.extraInitiaSourceSymbols??[],g=d?.externalChainListSource??"supported-assets",p=new Map(s.map(v=>[v.chain_id,v])),_=t.filter(({symbol:v,denom:k,chain_id:T})=>{if(u)return c.some(F=>Rr(F,T,k));const M=h.some(F=>Rr(F,T,k)),A=p.get(T),L=!!A&&a(A.chain_id)&&f.includes(v),N=M||L;return v===l.symbol||N}).map(v=>{if(v.hidden||v.chain_id===l.chain_id)return null;const k=o(v.chain_id);if(!k||!Br(k))return null;const T=r?.[k.chain_id]?.[v.denom];return{asset:v,chain:k,balance:T}}).filter(v=>v!==null),x=_.filter(({balance:v})=>e!=="deposit"||!!v&&Number(v.amount)>0),b=new Map;if(g==="extra-options")for(const{chainId:v}of h){const k=p.get(v);k&&Br(k)&&(a(k.chain_id)||b.set(k.chain_id,k))}else for(const{chain:v}of x)a(v.chain_id)||b.set(v.chain_id,v);const j=Array.from(b.values()).sort((v,k)=>Dr(v).localeCompare(Dr(k))),w=[...new Set(_.filter(({chain:v})=>Gp(v,a)).map(({asset:v})=>v.symbol))];return{data:x,isLoading:i,supportedExternalChains:j,appchainSourceSymbols:w,externalSourceSymbols:m,localSymbol:l.symbol}}function Yt(){return Ie.useFormContext()}const V1="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",K1="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 na(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 W1(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 z1(e,t,s){if(!e.length)return"";const o=W1(e,t,s);return o.length===1&&o[0]===t?"from any app":`using ${na(o)} from any app`}function H1({localSymbol:e,externalSourceSymbols:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=na(s),c=[...new Set(t)],l=na(c),d=z1(o,e,c),m=!!d,u=c.length!==1||c[0]!==e;if(r&&m){const h=u?`using ${l} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${h}, or ${d}.`}}return r?u?{title:a,description:`You can deposit ${e} using ${l} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:m?{title:a,description:`You can deposit ${e} ${d}.`}:{title:a,description:"No deposit sources are currently available."}}const Q1="_container_pjkfr_1",G1="_title_pjkfr_5",Y1="_close_pjkfr_12",Z1="_emptyIcon_pjkfr_24",J1="_empty_pjkfr_24",X1="_emptyDescription_pjkfr_39",e0="_list_pjkfr_60",t0="_asset_pjkfr_75",n0="_placeholder_pjkfr_91",s0="_activeAsset_pjkfr_104",o0="_iconContainer_pjkfr_108",a0="_assetIcon_pjkfr_118",r0="_chainIcon_pjkfr_128",i0="_assetPlaceholder_pjkfr_142",c0="_assetName_pjkfr_163",l0="_assetChain_pjkfr_178",d0="_balance_pjkfr_186",u0="_value_pjkfr_195",fe={container:Q1,title:G1,close:Y1,emptyIcon:Z1,empty:J1,emptyDescription:X1,list:e0,asset:t0,placeholder:n0,activeAsset:s0,iconContainer:o0,assetIcon:a0,chainIcon:r0,assetPlaceholder:i0,assetName:c0,assetChain:l0,balance:d0,value:u0},m0=({mode:e})=>{const{external:t}=ys(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbols:i,localSymbol:c}=al(e),{setValue:l,watch:d}=Yt(),m=Ua(e),{data:u}=Fa(),{theme:h}=ne(),f=d(),g=f[t.denomKey],p=f[t.chainIdKey],_=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"",x=y.useEffectEvent(()=>{if(!_)return;const[{asset:j,chain:w}]=s;if(g===j.denom&&p===w.chain_id){l("page","fields");return}l(t.denomKey,j.denom),l(t.chainIdKey,w.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")});y.useEffect(()=>{x()},[_]);function b(){const j=g&&p;return!j&&u.length<=1&&e==="deposit"?null:n.jsx("button",{className:fe.close,onClick:()=>{e==="withdraw"||j?l("page","fields"):l("page","select-local")},children:n.jsx(E.IconBack,{size:20})})}if(!m)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const j=a.map(k=>k.pretty_name||k.chain_name).filter(k=>!!k),w=H1({localSymbol:c,externalSourceSymbols:i,externalChainNames:j,appchainSourceSymbols:r}),v=e==="withdraw"?`No supported destinations to withdraw ${m.symbol}.`:w.title;return n.jsxs("div",{className:fe.container,children:[b(),n.jsx("h4",{className:fe.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?V1:K1,alt:"No assets",className:fe.emptyIcon}),n.jsx("p",{className:fe.empty,children:v}),e==="deposit"&&n.jsx("p",{className:fe.emptyDescription,children:w.description})]})}return n.jsxs("div",{className:fe.container,children:[b(),n.jsxs("h4",{className:fe.title,children:[e==="withdraw"?"Select destination":`Deposit ${m.symbol}`," "]}),n.jsxs("div",{className:fe.list,children:[o&&Array.from({length:5}).map((j,w)=>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})]},w)),!o&&s.sort(({balance:j},{balance:w})=>Number(w?.value_usd??0)-Number(j?.value_usd??0)).map(({asset:j,chain:w,balance:v})=>{const k=g===j.denom&&p===w.chain_id,T=Ea(v?.value_usd,v?.price);return n.jsxs("button",{className:D(fe.asset,k&&fe.activeAsset),onClick:()=>{l(t.denomKey,j.denom),l(t.chainIdKey,w.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")},children:[n.jsxs("div",{className:fe.iconContainer,children:[n.jsx("img",{src:j.logo_uri,alt:j.symbol,className:fe.assetIcon}),n.jsx("img",{src:w.logo_uri||"",alt:w.chain_name,className:fe.chainIcon})]}),n.jsxs("p",{className:fe.assetName,children:[j.symbol," ",k&&n.jsx("span",{children:n.jsx(E.IconCheck,{size:16})})]}),n.jsxs("p",{className:fe.assetChain,children:["on ",w.pretty_name]}),v&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:fe.balance,children:C.formatAmount(v.amount,{decimals:v.decimals||6})}),n.jsx("p",{className:fe.value,children:T})]})]},`${j.chain_id}-${j.denom}`)})]})]})},h0="_title_iequo_1",f0="_list_iequo_7",p0="_asset_iequo_15",g0="_imgPlaceholder_iequo_40",Ss={title:h0,list:f0,asset:p0,imgPlaceholder:g0},_0=({mode:e})=>{const{local:t,external:s}=ys(e),{setValue:o}=Yt(),{data:a,isLoading:r}=Fa(),[i,c]=y.useTransition(),l=(m,u)=>{o(t.denomKey,m),o(t.chainIdKey,u),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},d=y.useEffectEvent(()=>{const{denom:m,chain_id:u}=a[0];l(m,u)});return y.useEffect(()=>{!r&&a.length===1&&d()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:Ss.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:Ss.list,"aria-busy":i,children:a.map(({denom:m,chain_id:u,symbol:h,logo_uri:f})=>n.jsxs("button",{className:Ss.asset,onClick:()=>l(m,u),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:Ss.imgPlaceholder,"aria-hidden":"true"}),h]},`${m}-${u}`))})]}):n.jsx("div",{children:"No assets found"})},y0="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",x0="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",b0="_container_9k4hs_1",w0="_title_9k4hs_8",v0="_subtitle_9k4hs_14",j0="_linkContainer_9k4hs_30",C0="_link_9k4hs_30",N0="_separator_9k4hs_51",k0="_errorIcon_9k4hs_62",I0="_error_9k4hs_62",Le={container:b0,title:w0,subtitle:v0,linkContainer:j0,link:C0,separator:N0,errorIcon:k0,error:I0};function A0(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 sa({type:e}){const{closeModal:t}=Pn(),{theme:s}=ne(),{watch:o}=Yt(),{result:a}=o(),{openDrawer:r}=qt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:m,values:u}=a,{srcDenom:h,srcChainId:f,quantity:g}=u,p=kt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:x}=Hc({chainId:l,txHash:c,tracked:!1}),{data:b}=Qc({chainId:l,txHash:c,tracked:!!x,timestamp:d,route:m}),j=A0(b),w=s==="dark"?y0:x0,v=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return n.jsxs("div",{className:Le.container,children:[n.jsxs("h3",{className:Le.title,children:[_," failed"]}),n.jsx("img",{src:w,alt:"Failed",className:Le.errorIcon}),n.jsx("p",{className:Le.error,children:a?.error}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]});const T=ns(m.estimated_route_duration_seconds),M=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${M.toString()}`,"https://explorer.skip.build"),L=()=>n.jsxs("div",{className:Le.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:Le.link,children:"View transaction"}),n.jsx("div",{className:Le.separator}),n.jsx("button",{className:Le.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:Le.container,children:[j==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Le.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),n.jsx("video",{src:v,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:Le.subtitle,children:["Estimated time: ",n.jsx("span",{children:T})]}),L(),n.jsx("p",{className:Le.subtitle,children:"Your transaction will continue even if you close this"})]}),j==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Le.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()}}),L(),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]}),j==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Le.title,children:[_," failed"]}),n.jsx("img",{src:w,alt:"Failed",className:Le.errorIcon}),n.jsx("p",{className:Le.error,children:"Your transaction could not be completed"}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const S0=$e.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),T0=({tx:e,children:t})=>{const{values:s}=St(),{srcChainId:o}=s,a=se(),r=is(),i=no(),{data:c,isLoading:l}=S.useQuery({queryKey:S0.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const m=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:g})=>{if(!(f&&g))throw new Error("Invalid transaction data");return r.fromAmino({type:fn.aminoConverters[f].aminoType,value:JSON.parse(g)})});return{estimatedGas:await(await i(o)).simulate(a,m,""),messages:m}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(l)return n.jsx(Ae,{children:n.jsx(ue.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return n.jsx(n.Fragment,{children:t(d)})};function E0(e,t){return e?C.InitiaAddress(e).hex:t}function $0({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:E0(e.recipientAddress,o),slippagePercent:"0.1",...a}}}const M0="_container_oh9og_1",L0="_back_oh9og_6",q0="_title_oh9og_18",P0="_divider_oh9og_26",R0="_label_oh9og_30",D0="_asset_oh9og_37",B0="_assetIcon_oh9og_55",F0="_chainIcon_oh9og_67",U0="_assetName_oh9og_80",O0="_chevron_oh9og_92",V0="_input_oh9og_96",K0="_balanceContainer_oh9og_108",W0="_value_oh9og_116",z0="_maxButton_oh9og_126",H0="_detail_oh9og_142",Q0="_detailsContainer_oh9og_153",G0="_detailsButton_oh9og_163",Y0="_detailValue_oh9og_180",Z0="_detailToken_oh9og_190",J0="_receiveSummary_oh9og_198",G={container:M0,back:L0,title:q0,divider:P0,label:R0,asset:D0,assetIcon:B0,chainIcon:F0,assetName:U0,chevron:O0,input:V0,balanceContainer:K0,value:W0,maxButton:z0,detail:H0,detailsContainer:Q0,detailsButton:G0,detailValue:Y0,detailToken:Z0,receiveSummary:J0},rl=({renderFee:e})=>{const{route:t}=Xe(),{values:s}=St(),{dstDenom:o,dstChainId:a}=s,i=hs().find(({denom:f,chain_id:g})=>f===o&&g===a),c=se(),l=bc(),[d,m]=ze.useToggle(!1),u=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const h=Rc(t.amount_out,s.slippagePercent);return n.jsx(Xn,{children:n.jsxs("div",{className:G.detailsContainer,children:[n.jsxs("button",{className:G.detailsButton,onClick:m,"aria-expanded":d,children:["Transaction details"," ",n.jsx(E.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"},"aria-hidden":"true"})]}),d&&n.jsxs(n.Fragment,{children:[t.does_swap&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Slippage"}),n.jsxs("p",{className:G.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:G.detailValue,children:qa(t.estimated_fees)})]}),e&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Tx fee"}),n.jsx("div",{className:G.detailValue,children:e()})]}),c&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:G.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",C.truncate(c)]})]}),t.does_swap&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:G.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:G.detailToken})," ",C.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]}),n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Estimated time"}),n.jsx("p",{className:D(G.detailValue),style:u?{color:"var(--warning)"}:void 0,children:ns(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:D(G.detail,G.receiveSummary),children:[n.jsx("p",{className:G.detailLabel,children:"Estimated received"}),n.jsxs("p",{className:G.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:G.detailToken})," ",C.formatAmount(t.amount_out,{decimals:i.decimals})," ",i.symbol]})]})]})})},X0="_trigger_1c7d7_1",e2="_item_1c7d7_5",t2="_itemText_1c7d7_13",n2={trigger:X0,item:e2,itemText:t2},s2=({tx:e,gas:t,confirmMessage:s,onCompleted:o})=>{const{values:a}=St(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=hs().find(({denom:N,chain_id:I})=>N===i&&I===r),m=ft(r),u=os(m),h=ya(m),f=xa(m),g=It(m),p=h.map(({amount:N,denom:I})=>Ee.calculateFee(Math.ceil(t*pn),Ee.GasPrice.fromString(N+I))),_=p.map(N=>N.amount[0]),x=N=>{const I=u.find(O=>O.denom===N)?.amount??"0",F=_.find(O=>O.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:Q,decimals:W}=g(N);return{symbol:Q,decimals:W,spend:U(q).gt(0)?q:null,fee:F,total:P.toFixed(),balance:I,isSufficient:B}},b=()=>{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},[j,w]=y.useState(b),v=p.find(N=>N.amount[0].denom===j)??void 0,k=j?x(j):null,T=k&&!k.isSufficient?"Insufficient balance":void 0,M=(N,I)=>{if(C.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}=g(F),B=M(I,P);return`${C.formatAmount(I,{decimals:P,dp:B})} ${q}`},L=()=>{if(p.length===0)return null;if(p.length===1)return n.jsx("span",{className:"monospace",children:A(p[0])});if(!v||!j)return null;const N=p.map(B=>{const[{denom:Q}]=B.amount,{symbol:W}=g(Q);return{value:Q,label:A(B),triggerLabel:W}}),[{amount:I,denom:F}]=v.amount,{decimals:q}=g(F),P=M(I,q);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:C.formatAmount(I,{decimals:q,dp:P})}),n.jsx(Ta,{options:N,value:j,onChange:w,classNames:n2})]})};return n.jsxs(n.Fragment,{children:[n.jsx(rl,{renderFee:p.length>0?L:void 0}),n.jsx(Da,{tx:e,children:n.jsx(Ra,{tx:e,fee:v,onCompleted:o,confirmMessage:s,error:T})})]})},o2=({tx:e,confirmMessage:t,onCompleted:s})=>n.jsxs(n.Fragment,{children:[n.jsx(rl,{}),n.jsx(Da,{tx:e,children:n.jsx(Ra,{tx:e,fee:void 0,onCompleted:s,confirmMessage:t})})]}),a2=({tx:e,gas:t,mode:s})=>{const{setValue:o}=Yt(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!t||!("cosmos_tx"in e)?n.jsx(o2,{tx:e,onCompleted:a,confirmMessage:r}):n.jsx(s2,{tx:e,gas:t,onCompleted:a,confirmMessage:r})},r2=({mode:e})=>{const t=ys(e),s=Se(),o=Xe(),{data:a}=Fa(),r=Pt(),{data:i,error:c,chainsError:l}=Ba(),d=Rn(),{watch:m,setValue:u,getValues:h}=Yt(),f=m(),{srcChainId:g,srcDenom:p,quantity:_=""}=f,x=f[t.external.denomKey],b=f[t.external.chainIdKey],j=Ua(e),w=O1(e),{data:v,isLoading:k}=al(e),T=!k&&v.length===1,M=e==="withdraw"&&!k&&v.length>0&&new Set(v.map(({chain:_e})=>_e.chain_id)).size===1,A=k||!v.length?null:T?v[0]:M?v.reduce((_e,Pe)=>{const gt=Number(_e.balance?.value_usd??0);return Number(Pe.balance?.value_usd??0)>gt?Pe:_e},v[0]):null,L=A?`${A.chain.chain_id}:${A.asset.denom}`:"",N=b?r(b):null,I=i?.[g]?.[p]?.amount,F=i?.[g]?.[p]?.price,q=U(F??0).times(_||0),[P]=ze.useDebounceValue(_,300),B=e==="withdraw"?j:w,Q=y.useMemo(()=>{if(e==="deposit"&&!w)return"Select asset";const _e=U(_||0);if(!_e.isFinite()||_e.lte(0))return"Enter amount";if(I!==void 0){const Pe=C.fromBaseUnit(I,{decimals:B?.decimals||6});if(_e.gt(Pe))return"Insufficient balance"}if(e==="withdraw"&&!w)return"Select destination"},[e,_,I,B,w]),{data:W,error:O,dataUpdatedAt:me}=Zo(P,{disabled:!!Q}),ge=O instanceof z.HTTPError&&O.response.status===400,ce=!Q&&!ge?W:void 0,ye=ce&&me>0?me:void 0,we=O instanceof z.HTTPError&&O.response.status===500,ve=Q?"disabled":ce?"ready":O?ge?"no-route":we?"server-error":"refresh-failed":"loading",tt=ve==="ready"&&o.route===ce,Rt=ve==="loading"||ve==="ready"&&!tt,Tt=(()=>{if(ve==="disabled")return Q;if(ve==="loading"||ve==="ready"&&!tt)return"Fetching route...";if(ve==="no-route")return"No route found";if(ve==="server-error")return"Server error";if(ve==="refresh-failed")return"Failed to refresh route"})(),qe=y.useEffectEvent(()=>{s(0,$0({currentState:o,route:ce,quoteVerifiedAt:ye,hexAddress:d,values:h()}))});y.useEffect(()=>{qe()},[ce,d]);const Y=y.useEffectEvent(()=>{if(!A||x&&b)return;const{asset:_e,chain:Pe}=A;u(t.external.denomKey,_e.denom),u(t.external.chainIdKey,Pe.chain_id),e==="deposit"&&u("quantity","")});if(y.useEffect(()=>{Y()},[L]),!j||e==="deposit"&&!w)return null;const ct=B?.decimals||6,re=e==="withdraw"?"Select chain":"Select asset",Be=()=>{u("quantity",""),u(t.external.denomKey,""),u(t.external.chainIdKey,""),(e==="withdraw"||T)&&(u(t.local.denomKey,""),u(t.local.chainIdKey,"")),u("page",e==="withdraw"||T?"select-local":"select-external")},Dt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:G.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:G.asset,disabled:T,onClick:()=>u("page","select-external"),children:[n.jsx("div",{className:G.assetIcon,children:w?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:w.logo_uri,alt:w.symbol}),n.jsx("img",{src:N?.logo_uri||"",alt:N?.pretty_name,className:G.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:G.chainIcon})}),n.jsx("p",{className:G.assetName,children:w?n.jsxs(n.Fragment,{children:[w.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",N?.pretty_name]})]}):re}),!T&&n.jsx(E.IconChevronDown,{className:G.chevron,size:16})]})]}),Bt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:G.label,children:"Amount"}),n.jsx(ts,{balance:I,decimals:ct,className:G.input}),Number(I)>0&&n.jsxs("div",{className:G.balanceContainer,children:[n.jsx("p",{className:G.value,children:_?Ea(q.toString(),F):"$-"}),n.jsxs("button",{className:G.maxButton,onClick:()=>{const _e=C.fromBaseUnit(I??"0",{decimals:ct});U(_||0).eq(_e)||u("quantity",_e)},children:[n.jsx(E.IconWallet,{size:16})," ",C.formatAmount(I,{decimals:ct})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("section",{className:G.container,"aria-label":"Transfer form",children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:G.back,onClick:Be,children:n.jsx(E.IconBack,{size:20})}),n.jsxs("h3",{className:G.title,children:[t.label," ",j.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[Bt,n.jsx("div",{className:G.divider}),Dt]}):n.jsxs(n.Fragment,{children:[Dt,n.jsx("div",{className:G.divider}),Bt]}),(l||c)&&n.jsx(be,{error:!0,children:"Failed to load balances"}),tt?n.jsx(Jc,{children:_e=>n.jsx(el,{children:Pe=>n.jsx(Xc,{addressList:_e,signedOpHook:Pe,children:gt=>n.jsx(T0,{tx:gt,children:He=>n.jsx(a2,{tx:gt,gas:He,mode:e})})})})}):n.jsx(Ae,{children:n.jsx(ue.White,{type:"submit",loading:Rt&&"Fetching route...",disabled:!0,fullWidth:!0,children:Tt})})]})},i2="_container_7nl9j_1",c2="_page_7nl9j_5",Fr={container:i2,page:c2},il=({mode:e})=>{const t=Ie.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Ba(),n.jsx(Ie.FormProvider,{...t,children:n.jsx(l2,{mode:e})})},l2=({mode:e})=>{const{watch:t}=Yt(),s=t("page"),o=jt.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(_0,{mode:e});case"select-external":return n.jsx(m0,{mode:e});case"fields":return n.jsx(r2,{mode:e});case"completed":return n.jsx(sa,{type:e})}};return n.jsx(Xn,{children:n.jsx("div",{className:Fr.container,children:o((r,i)=>n.jsx(jt.animated.div,{style:r,className:Fr.page,children:a(i)}))})})},d2=()=>n.jsx(il,{mode:"deposit"}),u2=()=>n.jsx(il,{mode:"withdraw"}),m2="_root_1lo0i_1",h2="_address_1lo0i_9",f2="_copy_1lo0i_19",p2="_labelWrapper_1lo0i_33",g2="_labelCopy_1lo0i_43",_2="_labelCopied_1lo0i_47",y2="_copied_1lo0i_55",x2="_derived_1lo0i_65",b2="_derivedLabel_1lo0i_79",w2="_derivedAddress_1lo0i_83",v2="_hexAddress_1lo0i_89",j2="_derivedCopy_1lo0i_94",Ue={root:m2,address:h2,copy:f2,labelWrapper:p2,labelCopy:g2,labelCopied:_2,copied:y2,derived:x2,derivedLabel:b2,derivedAddress:w2,hexAddress:v2,derivedCopy:j2},C2=()=>{const e=y.useRef(null),t=y.useRef(null),{initiaAddress:s,hexAddress:o}=et(),a=yc("--gray-0");return y.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new $l({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(At,{title:"Receive",children:n.jsxs("div",{className:Ue.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Ue.address,children:s}),n.jsx(Os,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Ue.copy,{[Ue.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy address",children:[n.jsx(E.IconCopy,{size:12,"aria-hidden":"true"}),n.jsxs("div",{className:Ue.labelWrapper,children:[n.jsx("span",{className:Ue.labelCopy,children:"Copy address"}),n.jsx("span",{className:Ue.labelCopied,children:"Copied!"})]})]})}),n.jsx(Os,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Ue.derived,{[Ue.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy derived address",children:[n.jsx("span",{className:Ue.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Ue.derivedAddress,children:[n.jsx("span",{className:Ue.hexAddress,children:C.truncate(o)}),n.jsx(E.IconCopy,{size:12,className:Ue.derivedCopy,"aria-hidden":"true"}),i&&n.jsx("span",{className:Ue.copiedText,children:"Copied!"})]})]})})]})})};function N2(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function k2(){const e=se(),t=he();return S.useQueries({queries:t.map(s=>({queryKey:Fs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Ys(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Ri(o),r=e?ha(e,s.chainId):null,i=N2(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const I2="_countdown_vfms8_1",A2={countdown:I2},S2=({expiration:e})=>{const t=()=>{const a=new Date,r=Ze.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${d}s`),m.join(" ")},[s,o]=y.useState(t());return ze.useInterval(()=>{o(t())},1e3),Ze.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:A2.countdown,children:s})]})},T2="_container_1l528_1",E2="_info_1l528_11",$2="_header_1l528_17",M2="_chainName_1l528_23",L2="_expiration_1l528_29",q2="_revokeButton_1l528_35",Cn={container:T2,info:E2,header:$2,chainName:M2,expiration:L2,revokeButton:q2},P2=({chainId:e,grantee:t,expiration:s})=>{const o=ft(e),{mutate:a,isPending:r}=Xi({grantee:t,internal:!0});return n.jsxs("div",{className:Cn.container,children:[n.jsxs("div",{className:Cn.info,children:[n.jsxs("div",{className:Cn.header,children:[n.jsx(te,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:Cn.chainName,children:o.name})]}),n.jsx("div",{className:Cn.expiration,children:s?n.jsx(S2,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:Cn.revokeButton,onClick:()=>a(e),disabled:r,"aria-busy":r,children:r?"Revoking...":"Revoke"})]})},R2=({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=_a([r.expiration,i])}return[...s.values()].map(a=>y.createElement(P2,{...a,chainId:e,key:a.grantee}))},D2="_content_q36qs_1",B2={content:D2},F2=()=>{const e=k2(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(be,{children:"No permissions found"}):n.jsx("div",{className:B2.content,children:s.map(({chainId:o,grants:a})=>n.jsx(R2,{chainId:o,grants:a},o))})};return n.jsx(At,{title:"Manage auto-signing",backButton:"/settings",children:t()})},U2="_version_1sf5y_1",O2={version:U2},V2=()=>n.jsxs("aside",{className:O2.version,children:["v","2.5.0"]}),K2="_link_se23z_1",W2="_title_se23z_17",z2="_subtitle_se23z_23",H2="_icon_se23z_30",Ts={link:K2,title:W2,subtitle:z2,icon:H2},cl=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:Ts.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:Ts.title,children:e}),t&&n.jsx("p",{className:Ts.subtitle,children:t})]}),n.jsx("div",{className:Ts.icon,children:s??n.jsx(E.IconChevronRight,{size:16,"aria-hidden":"true"})})]}),Q2="https://export.initia.xyz/",G2=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(cl,{title:"Export private key",rightSection:n.jsx(E.IconExternalLink,{size:16}),onClick:()=>window.open(Q2,"_blank",e)})},Y2="_container_1vxr7_1",Z2="_separator_1vxr7_7",Ur={container:Y2,separator:Z2},J2=()=>{const e=Se(),{connector:t}=We.useAccount();return n.jsx(At,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Ur.container,children:[n.jsx(cl,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ca&&n.jsx(G2,{}),n.jsx(Mt.Separator,{className:Ur.separator}),n.jsx(V2,{})]})})},X2="_trigger_1yjkd_1",eb="_icon_1yjkd_23",tb="_full_1yjkd_27",nb="_triggerContent_1yjkd_32",sb="_triggerText_1yjkd_40",ob="_popoverBackdrop_1yjkd_51",ab="_popoverPositioner_1yjkd_70",rb="_popoverPopup_1yjkd_74",ib="_search_1yjkd_99",cb="_viewport_1yjkd_105",lb="_item_1yjkd_111",db="_highlighted_1yjkd_127",ub="_active_1yjkd_131",mb="_itemContent_1yjkd_136",hb="_extra_1yjkd_142",fb="_connectedTag_1yjkd_149",ke={trigger:X2,icon:eb,full:tb,triggerContent:nb,triggerText:sb,popoverBackdrop:ob,popoverPositioner:ab,popoverPopup:rb,search:ib,viewport:cb,item:lb,highlighted:db,active:ub,itemContent:mb,extra:hb,connectedTag:fb},xo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=ne(),[i,c]=y.useState(""),[l,d]=y.useState(!1),[m,u]=y.useState(0),[h,f]=y.useState(),g=y.useRef([]),p=y.useRef(null),_=he(),x=s.map(N=>_.find(I=>I.chainId===N)).filter(Boolean),b=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),n.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),j=y.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),w=y.useMemo(()=>{const N=[j,...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,j]),v=x.find(N=>N.chainId===e)||j,k=parseInt(yc("--drawer-offset")),T=6,M=()=>{if(c(""),u(-1),p.current){const I=p.current.getBoundingClientRect().bottom+T,F=window.innerHeight-I-2*k;f(F)}d(!0)};y.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=y.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),u(I=>(I+1)%w.length);break;case"ArrowUp":N.preventDefault(),u(I=>(I-1+w.length)%w.length);break;case"Enter":N.preventDefault(),w[m]&&(t(w[m].chainId),d(!1));break;case"Escape":N.preventDefault(),d(!1);break}},[w,m,t,d]),L=N=>{t(N),d(!1)};return n.jsxs(vn.Popover.Root,{open:l,onOpenChange:M,modal:"trap-focus",children:[n.jsx(vn.Popover.Trigger,{render:n.jsxs("button",{className:D(ke.trigger,{[ke.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[n.jsxs("div",{className:ke.triggerContent,children:[typeof v.logoUrl=="string"?n.jsx(te,{src:v.logoUrl,width:14,height:14,logo:!0}):v.logoUrl(14),n.jsx("span",{className:ke.triggerText,children:v.name})]}),n.jsx(E.IconChevronDown,{size:16,className:ke.icon})]})}),n.jsxs(vn.Popover.Portal,{container:_n(),children:[n.jsx(vn.Popover.Backdrop,{className:ke.popoverBackdrop,onClick:()=>d(!1)}),n.jsx(vn.Popover.Positioner,{className:ke.popoverPositioner,align:"end",side:"bottom",sideOffset:T,collisionAvoidance:{side:"none"},children:n.jsxs(vn.Popover.Popup,{className:D(ke.popoverPopup,{[ke.full]:a}),style:{maxHeight:h},children:[n.jsx(gs,{value:i,onChange:N=>{c(N.target.value),u(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search apps",rootClassName:ke.search,ref:fs()}),n.jsx("div",{className:ke.viewport,role:"listbox",children:w.length===0?n.jsx(be,{children:"No apps found"}):w.map(({chainId:N,name:I,logoUrl:F},q)=>n.jsxs("div",{className:D(ke.item,{[ke.highlighted]:q===m,[ke.active]:e===N}),onClick:()=>L(N),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),L(N))},onMouseEnter:()=>u(q),role:"option","aria-selected":e===N,tabIndex:-1,ref:P=>{P&&(g.current[q]=P)},children:[n.jsxs("div",{className:ke.itemContent,children:[typeof F=="string"?n.jsx(te,{src:F,width:16,height:16,logo:!0}):F(16),n.jsx("span",{className:ke.name,children:I}),N===r&&n.jsx("span",{className:ke.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:ke.extra,children:o(N)})]},N))})]})})]})]})},pb="_container_1nap1_1",gb="_controls_1nap1_7",_b="_search_1nap1_13",Oa={container:pb,controls:gb,search:_b},yb=({children:e})=>n.jsx("div",{className:Oa.container,children:e}),xb=({children:e})=>n.jsx("div",{className:Oa.controls,children:e}),bb=e=>n.jsx(gs,{...e,rootClassName:Oa.search}),ht={Root:yb,Controls:xb,SearchInput:bb},ll=H.atom(""),dl=H.atom(""),wb=H.atom(""),vb=H.atom(""),jb=H.atom(""),Cb="_change_1nm9m_1",Nb="_positive_1nm9m_8",kb="_negative_1nm9m_12",Uo={change:Cb,positive:Nb,negative:kb},ul=({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(Uo.change,r?Uo.positive:Uo.negative),children:[r?"+":"-",C.formatAmount(i,{decimals:a})," ",o||s]})},Ib=({changes:e,chain:t})=>{const s=It(t);return e.map(({amount:o,denom:a},r)=>n.jsx(ul,{amount:o,asset:s(a)},r))},Ab=({changes:e,chain:t})=>{const s=It(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(Nc,{metadata:a,chain:t,children:i=>n.jsx(ul,{amount:o,asset:s(i)})},r))},Sb=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=et();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(Ab,{changes:Cc(e,o),chain:t}):n.jsx(Ib,{changes:jc(e,s),chain:t})},Tb="_message_1qc8m_1",Eb="_more_1qc8m_9",Or={message:Tb,more:Eb},$b=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:Or.message,children:Qs.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:Or.more,children:`+${e.length-3} more`})]}),Mb="_link_1vbb0_1",Lb="_inner_1vbb0_16",qb="_header_1vbb0_21",Pb="_time_1vbb0_30",Rb="_error_1vbb0_36",Db="_timestamp_1vbb0_40",Bb="_chainInfo_1vbb0_45",Fb="_content_1vbb0_53",Ub="_messages_1vbb0_61",Ob="_changes_1vbb0_67",bt={link:Mb,inner:Lb,header:qb,time:Pb,error:Rb,timestamp:Db,chainInfo:Bb,content:Fb,messages:Ub,changes:Ob},Vb=({txItem:e,chain:t})=>n.jsx(mo,{txHash:e.txhash,chainId:t.chainId,className:bt.link,children:n.jsxs("div",{className:bt.inner,children:[n.jsxs("div",{className:bt.header,children:[n.jsxs("div",{className:bt.time,children:[e.code!==0&&n.jsx(E.IconWarningFilled,{size:14,className:bt.error}),n.jsx("span",{className:bt.timestamp,children:Ze.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:bt.chainInfo,children:[n.jsx(te,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:bt.content,children:[n.jsx("div",{className:bt.messages,children:n.jsx($b,{messages:e.tx.body.messages})}),n.jsx("div",{className:bt.changes,children:n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(Sb,{...e,chain:t})})})]})]})}),Kb="_list_1mv55_1",Wb="_dateGroup_1mv55_7",zb="_dateHeader_1mv55_12",Hb="_more_1mv55_18",Es={list:Kb,dateGroup:Wb,dateHeader:zb,more:Hb},Qb=({list:e,chainId:t})=>{const s=se(),o=y.useMemo(()=>Oc(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(be,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Es.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Es.dateGroup,children:[n.jsx("div",{className:Es.dateHeader,children:a}),r.map(i=>n.jsx(pe,{errorBoundaryProps:{fallback:null},children:n.jsx(Vb,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(mo,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Es.more,showIcon:!0,children:"View more on Initia Scan"})]})},Gb=()=>{const{activities:e,isLoading:t}=Qd(),[s,o]=H.useAtom(jb),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(be,{children:"Loading activities..."}):!e.length&&!t?n.jsx(be,{children:"No activity yet"}):n.jsxs(ht.Root,{children:[n.jsx(ht.Controls,{children:n.jsx(xo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Qb,{list:i,chainId:s||a.chainId})]})},Yb="_thumbnail_1xyqw_1",Zb="_placeholder_1xyqw_18",Jb="_clickable_1xyqw_24",zn={thumbnail:Yb,placeholder:Zb,clickable:Jb},Xb=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=ne(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:D(zn.thumbnail,zn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(te,{src:l,classNames:{placeholder:zn.placeholder}})}):n.jsx("div",{className:zn.thumbnail,style:{width:t,height:t},children:n.jsx(te,{src:l,classNames:{placeholder:zn.placeholder}})})},ew="_collectionName_qs5tw_1",tw="_nftName_qs5tw_6",nw="_chainInfo_qs5tw_10",Oo={collectionName:ew,nftName:tw,chainInfo:nw},Va=({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(Xb,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:D(Oo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:D(Oo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:D(Oo.chainInfo,a?.chainInfo),children:[n.jsx(te,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ka=$e.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function sw(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function ow(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const aw=()=>{const e=se(),t=he(),s=S.useQueries({queries:t.map(l=>({queryKey:Ka.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Ys(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map($.prop("data")),a=ow(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 rw(e){const t=Vr(e);return S.useQuery({queryKey:Ka.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await z.get(t).json();return{...s,image:Vr(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function Vr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const iw=({nftInfo:e,children:t})=>{const{data:s={}}=rw(e.nft.uri),o=sw(e,s);return t(o)},cw="_grid_1wwdn_1",lw="_root_1wwdn_7",dw="_collectionName_1wwdn_15",uw="_nftName_1wwdn_23",mw="_chainInfo_1wwdn_32",Kr={grid:cw,root:lw,collectionName:dw,nftName:uw,chainInfo:mw},hw=()=>{const[e,t]=H.useAtom(wb),[s,o]=H.useAtom(vb),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=aw(),l=Se(),d=y.useMemo(()=>a.filter(({collection_addr:u,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return u.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||g.toLowerCase().includes(_)}return!0}),[a,s,e]),m=y.useMemo(()=>Array.from(new Set(a.map(({chain:u})=>u.chainId))),[a]);return c&&a.length===0?n.jsx(be,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(be,{children:"No NFTs"}):n.jsxs(ht.Root,{children:[n.jsxs(ht.Controls,{children:[n.jsx(ht.SearchInput,{value:e,onChange:u=>t(u.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(xo,{value:s,onChange:o,chainIds:m,renderExtra:u=>u?r[u]||0:i})]}),d.length===0?n.jsx(be,{children:"No NFTs found"}):n.jsx("div",{className:Kr.grid,children:d.map(u=>{const{collection_addr:h,nft:f}=u;return n.jsx(iw,{nftInfo:u,children:g=>n.jsx(Va,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:Kr})},h+f.token_id)})})]})},ml=y.createContext(null);function hl(){return y.useContext(ml)}const fw="_popup_nbecp_1",pw="_item_nbecp_19",$s={popup:fw,item:pw},fl=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[m,u]=y.useState(!1),h=Se(),f=hl(),{showNotification:g}=us(),{defaultChainId:p}=ne(),{evm_chain_id:_}=yn(),x=We.useChainId(),{switchChainAsync:b}=We.useSwitchChain(),{watchAssetAsync:j}=We.useWatchAsset(),w=()=>{u(!1),h("/send",{denom:s,chain:l})},v=()=>{u(!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 b({chainId:Number(_)}),j({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:T}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:T=>{g({type:"error",title:"Asset addition failed",description:T.message})}});return n.jsxs(Mt.Menu.Root,{open:m,onOpenChange:u,modal:!1,children:[n.jsx(Mt.Menu.Trigger,{render:t}),n.jsx(Mt.Menu.Portal,{container:f,children:n.jsx(Mt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(Mt.Menu.Popup,{className:$s.popup,children:[n.jsxs(Mt.Menu.Item,{className:$s.item,onClick:w,children:[n.jsx(E.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(Mt.Menu.Item,{className:$s.item,onClick:v,disabled:i,children:[n.jsx(E.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),d===p&&_===x&&!!c&&n.jsxs(Mt.Menu.Item,{className:$s.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"})]})]})})})]})},gw="_item_38qhm_1",_w="_info_38qhm_23",yw="_images_38qhm_29",xw="_name_38qhm_33",bw="_value_38qhm_39",ww="_amount_38qhm_47",vw="_usd_38qhm_53",sn={item:gw,info:_w,images:yw,name:xw,value:bw,amount:ww,usd:vw},jw=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=C.formatAmount(t,{decimals:e.decimals});return n.jsx(fl,{asset:e,children:n.jsxs("button",{className:sn.item,children:[n.jsxs("div",{className:sn.info,children:[n.jsx(po,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:sn.images}),n.jsx("span",{className:sn.name,children:a.name})]}),n.jsxs("div",{className:sn.value,children:[n.jsx("span",{className:sn.amount,children:r}),Number(s)>0&&n.jsx("span",{className:sn.usd,children:ee(s)})]})]})})},Cw="_container_ytg3p_1",Nw="_assetItem_ytg3p_6",kw="_expandIcon_ytg3p_22",Iw="_assetInfo_ytg3p_27",Aw="_logo_ytg3p_33",Sw="_details_ytg3p_37",Tw="_symbol_ytg3p_42",Ew="_chainName_ytg3p_53",$w="_chainInfos_ytg3p_59",Mw="_chainLogos_ytg3p_65",Lw="_chainLogo_ytg3p_65",qw="_moreChains_ytg3p_76",Pw="_expanded_ytg3p_93",Rw="_valueColumn_ytg3p_98",Dw="_amount_ytg3p_108",Bw="_value_ytg3p_98",Fw="_collapsibleContent_ytg3p_121",Uw="_chainsList_ytg3p_151",Ce={container:Cw,assetItem:Nw,expandIcon:kw,assetInfo:Iw,logo:Aw,details:Sw,symbol:Tw,chainName:Ew,chainInfos:$w,chainLogos:Mw,chainLogo:Lw,moreChains:qw,expanded:Pw,valueColumn:Rw,amount:Dw,value:Bw,collapsibleContent:Fw,chainsList:Uw},Ow=H.atom([]),Wa=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(Ow),c=y.useMemo(()=>uu(e),[e]),l=y.useMemo(()=>ec(e),[e]),d=r.includes(t),m=()=>{i(h=>d?h.filter(f=>f!==t):[...new Set([...h,t])])},u=()=>n.jsxs("button",{className:Ce.assetItem,children:[n.jsxs("div",{className:Ce.assetInfo,children:[s&&n.jsx(te,{src:s,width:32,height:32,className:Ce.logo,logo:!0}),n.jsxs("div",{className:Ce.details,children:[n.jsx("div",{className:Ce.symbol,children:t}),a?n.jsx("div",{className:Ce.chainName,children:o[0].chain.name}):n.jsxs("div",{className:Ce.chainInfos,children:[n.jsx("div",{className:Ce.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(te,{src:h.logoUrl,width:16,height:16,className:Ce.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:Ce.moreChains,children:["+",o.length-5]}),n.jsx(E.IconChevronDown,{size:16,className:D(Ce.expandIcon,{[Ce.expanded]:d})})]})]})]}),n.jsxs("div",{className:Ce.valueColumn,children:[n.jsx("div",{className:Ce.amount,children:C.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:Ce.value,children:ee(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:Ce.container,children:n.jsx(fl,{asset:h,children:u()})})}return n.jsx("div",{className:Ce.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:u()}),n.jsx(Z.Collapsible.Content,{className:Ce.collapsibleContent,children:n.jsx("div",{className:Ce.chainsList,children:o.map(h=>n.jsx(jw,{asset:h},h.chain.chainId))})})]})})},Vw="_collapsible_1g7rh_1",Kw="_trigger_1g7rh_5",Ww="_divider_1g7rh_20",zw="_label_1g7rh_28",Hw="_chevron_1g7rh_33",Qw="_content_1g7rh_41",Gw="_list_1g7rh_45",Vt={collapsible:Vw,trigger:Kw,divider:Ww,label:zw,chevron:Hw,content:Qw,list:Gw},pl=({unlistedAssets:e})=>{const[t,s]=y.useState(!1),o=hl(),a=y.useRef(null),[r,i]=y.useState(0);y.useEffect(()=>{if(a.current){const u=a.current.scrollHeight;i(u)}},[e]);const c=y.useRef(null),l=u=>{s(u),u&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const x=g.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},d=jt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),m=y.useMemo(()=>e.map(u=>({...u,assets:[u],totalValue:u.value??0,totalAmount:Number(u.quantity)})),[e]);return e.length===0?null:n.jsxs(Z.Collapsible.Root,{open:t,onOpenChange:l,className:Vt.collapsible,children:[n.jsxs(Z.Collapsible.Trigger,{ref:c,className:Vt.trigger,children:[n.jsx("div",{className:Vt.divider}),n.jsxs("span",{className:Vt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(E.IconChevronDown,{className:Vt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Vt.divider})]}),n.jsx(Z.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(jt.animated.div,{className:Vt.content,style:d,children:n.jsx("div",{className:Vt.list,ref:a,children:m.map(u=>n.jsx(Wa,{assetGroup:u},u.assets[0].denom))})})})]})},Yw="_container_15xfg_1",Zw="_header_15xfg_7",Jw="_title_15xfg_13",Xw="_totalValue_15xfg_19",ev="_list_15xfg_26",Sn={container:Yw,header:Zw,title:Jw,totalValue:Xw,list:ev},tv=()=>{const[e,t]=H.useAtom(ll),[s,o]=H.useAtom(dl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=ba(),d=i.map(({chainId:h})=>h),m=y.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:_}=g;return p.toLowerCase().includes(e.toLowerCase())||_.some(({denom:x,address:b})=>x.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),u=y.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?n.jsx(be,{children:"Loading assets..."}):!m.length&&!u.length&&!e&&!s&&!l?n.jsx(be,{children:"No assets"}):n.jsxs(ht.Root,{children:[n.jsxs(ht.Controls,{children:[n.jsx(ht.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(xo,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return ee(c);const f=i.find(g=>g.chainId===h);return f?ee(f.value):null}})]}),n.jsx("div",{children:m.length===0&&u.length===0?n.jsx(be,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Sn.list,children:m.map(h=>n.jsx(Wa,{assetGroup:h},h.symbol))}),n.jsx(pl,{unlistedAssets:u})]})})]})},nv="_container_11k2x_1",sv={container:nv},wt=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(hn,{height:e,width:s}):n.jsx("div",{className:sv.container,"aria-hidden":"true",children:o.map(a=>n.jsx(hn,{height:e,width:s},a))})},ov=y.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ds(),l=oe(),{listedGroups:d,unlistedAssets:m}=y.useMemo(()=>Im(i,a,r,l.chainId),[i,a,r,l.chainId]),u=y.useMemo(()=>jm(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=y.useMemo(()=>km(u,m,e,t),[u,m,e,t]);return n.jsxs("div",{className:Sn.container,children:[n.jsxs("div",{className:Sn.header,children:[n.jsx("span",{className:Sn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Sn.totalValue,children:ee(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Sn.list,children:h.map(p=>n.jsx(Wa,{assetGroup:p},p.symbol))}),n.jsx(pl,{unlistedAssets:g})]}):u.length===0&&c?n.jsx(wt,{height:56,length:3}):n.jsx(be,{children:"No liquid assets"})]})}),av="_container_1n61l_1",rv="_section_1n61l_7",iv="_sectionHeader_1n61l_19",cv="_sectionTitle_1n61l_25",lv="_sectionLabel_1n61l_31",dv="_externalLink_1n61l_37",uv="_sectionValue_1n61l_49",mv="_tokenList_1n61l_56",hv="_stakingTokenList_1n61l_62",fv="_tokenRow_1n61l_72",pv="_tokenMain_1n61l_78",gv="_tokenTrigger_1n61l_84",_v="_tokenChevron_1n61l_100",yv="_expanded_1n61l_111",xv="_triggerValue_1n61l_115",bv="_tokenInfo_1n61l_122",wv="_tokenInfoLabel_1n61l_128",vv="_tokenLogo_1n61l_134",jv="_tokenSymbol_1n61l_138",Cv="_tokenValues_1n61l_144",Nv="_tokenAmount_1n61l_150",kv="_tokenValue_1n61l_144",Iv="_typeBreakdown_1n61l_164",Av="_typeRow_1n61l_172",Sv="_typeLabel_1n61l_180",Tv="_typeValues_1n61l_186",Ev="_typeAmount_1n61l_192",$v="_typeValue_1n61l_186",Mv="_collapsibleContent_1n61l_206",X={container:av,section:rv,sectionHeader:iv,sectionTitle:cv,sectionLabel:lv,externalLink:dv,sectionValue:uv,tokenList:mv,stakingTokenList:hv,tokenRow:fv,tokenMain:pv,tokenTrigger:gv,tokenChevron:_v,expanded:yv,triggerValue:xv,tokenInfo:bv,tokenInfoLabel:wv,tokenLogo:vv,tokenSymbol:jv,tokenValues:Cv,tokenAmount:Nv,tokenValue:kv,typeBreakdown:Iv,typeRow:Av,typeLabel:Sv,typeValues:Tv,typeAmount:Ev,typeValue:$v,collapsibleContent:Mv},gl=({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 hm(c)},[e]);return i.size===0?null:n.jsx("div",{className:X.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(Lv,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Lv=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,d=mm(e,o),m=y.useMemo(()=>bm(c),[c]),u=e==="staking";return n.jsxs("section",{className:X.section,"aria-label":d,children:[n.jsxs("div",{className:X.sectionHeader,children:[n.jsxs("div",{className:X.sectionTitle,children:[n.jsx("span",{className:X.sectionLabel,children:d}),u&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:X.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:X.sectionValue,children:ee(l)})]}),n.jsx("div",{className:D(X.tokenList,{[X.stakingTokenList]:u}),children:m.map(h=>n.jsx(qv,{group:h,showTypeBreakdown:u,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},qv=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,m=s.get(r),[u,h]=y.useState(!1),f=y.useMemo(()=>{if(!t)return null;const g=ym(d);return g.size>0?g:null},[d,t]);return f?n.jsxs(Z.Collapsible.Root,{open:u,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:X.tokenTrigger,children:[n.jsxs("div",{className:X.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(X.tokenChevron,{[X.expanded]:u}),"aria-hidden":"true"}),n.jsxs("div",{className:X.tokenInfoLabel,children:[m?.assetLogo&&n.jsx(te,{src:m.assetLogo,width:20,height:20,className:X.tokenLogo}),n.jsx("span",{className:X.tokenSymbol,children:i})]})]}),n.jsx("span",{className:X.triggerValue,children:ee(l)})]})}),n.jsx(Z.Collapsible.Content,{className:X.collapsibleContent,children:n.jsx(Pv,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:X.tokenRow,children:n.jsxs("div",{className:X.tokenMain,children:[n.jsxs("div",{className:X.tokenInfo,children:[m?.assetLogo&&n.jsx(te,{src:m.assetLogo,width:20,height:20,className:X.tokenLogo}),n.jsx("span",{className:X.tokenSymbol,children:i})]}),n.jsxs("div",{className:X.tokenValues,children:[n.jsx("span",{className:X.tokenAmount,children:C.formatNumber(c,{dp:6})}),n.jsx("span",{className:X.tokenValue,children:ee(l)})]})]})})},Pv=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=y.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const m=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),u=d.reduce((h,f)=>h+Mn(f),0);return{type:l,typeAmount:m,typeValue:u}}),[e]),i=y.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const m=o(s,d);l+=Number(m)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:X.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:m})=>n.jsxs("div",{className:X.typeRow,children:[n.jsx("span",{className:X.typeLabel,children:_m(l)}),n.jsxs("div",{className:X.typeValues,children:[n.jsxs("span",{className:X.typeAmount,children:[C.formatNumber(d,{dp:6})," ",t]}),n.jsx("span",{className:X.typeValue,children:ee(m)})]})]},l)),c&&n.jsxs("div",{className:X.typeRow,children:[n.jsx("span",{className:X.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:X.typeValues,children:[n.jsxs("span",{className:X.typeAmount,children:[C.formatNumber(i,{dp:6})," ",mt]}),n.jsx("span",{className:X.typeValue,children:ee(i*(a??0))})]})]})]})},Rv="_container_ymkoc_1",Dv="_trigger_ymkoc_6",Bv="_expandIcon_ymkoc_22",Fv="_chainInfo_ymkoc_27",Uv="_logo_ymkoc_33",Ov="_chainNameContainer_ymkoc_37",Vv="_chainName_ymkoc_37",Kv="_externalLink_ymkoc_49",Wv="_externalIcon_ymkoc_53",zv="_valueColumn_ymkoc_63",Hv="_value_ymkoc_63",Qv="_expanded_ymkoc_80",Gv="_collapsibleContent_ymkoc_85",Yv="_content_ymkoc_97",Oe={container:Rv,trigger:Dv,expandIcon:Bv,chainInfo:Fv,logo:Uv,chainNameContainer:Ov,chainName:Vv,externalLink:Kv,externalIcon:Wv,valueColumn:zv,value:Hv,expanded:Qv,collapsibleContent:Gv,content:Yv},Zv=H.atom([]),Jv=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=he(),r=ss(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>Aa(r,a),[r,a]),l=y.useMemo(()=>{const d=new Map;for(const m of o)for(const u of m.positions){if(u.type==="fungible-position"||u.balance.type==="unknown")continue;const{denom:h,symbol:f}=u.balance,g=f.toUpperCase(),p=`${t}:${h}`,_=i.get(p)??c.get(g);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,t,s]);return n.jsx(gl,{protocols:o,denomLogoMap:l})},Xv=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(Zv),c=y.useMemo(()=>o.reduce((f,g)=>f+g.positions.reduce((p,_)=>p+Mn(_),0),0),[o]),l=["civitia","yominet"],d=r.includes(t),m=t?.toLowerCase(),u=l.includes(m),h=()=>{i(f=>d?f.filter(g=>g!==t):[...new Set([...f,t])])};return n.jsx("div",{className:Oe.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Oe.trigger,children:[n.jsxs("div",{className:Oe.chainInfo,children:[s&&n.jsx(te,{src:s,width:32,height:32,className:Oe.logo,logo:!0}),n.jsxs("div",{className:Oe.chainNameContainer,children:[n.jsx("span",{className:Oe.chainName,children:t}),a&&n.jsx("a",{href:a,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:[!u&&n.jsx("span",{className:Oe.value,children:ee(c)}),n.jsx(E.IconChevronDown,{size:16,className:D(Oe.expandIcon,{[Oe.expanded]:d})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Oe.collapsibleContent,children:n.jsx("div",{className:Oe.content,children:n.jsx(Jv,{chainGroup:e})})})]})})},ej="_container_g7q2b_1",tj="_section_g7q2b_6",nj="_sectionHeader_g7q2b_14",sj="_sectionTitle_g7q2b_20",oj="_sectionLabel_g7q2b_26",aj="_externalLink_g7q2b_32",rj="_sectionValue_g7q2b_44",ij="_tokenList_g7q2b_51",cj="_tokenTrigger_g7q2b_63",lj="_tokenChevron_g7q2b_79",dj="_expanded_g7q2b_90",uj="_tokenInfo_g7q2b_94",mj="_tokenInfoLabel_g7q2b_100",hj="_tokenLogo_g7q2b_106",fj="_pairedLogos_g7q2b_110",pj="_coinLogo_g7q2b_115",gj="_tokenSymbol_g7q2b_133",_j="_triggerValue_g7q2b_139",yj="_clammBreakdownContent_g7q2b_146",xj="_clammPositionRow_g7q2b_154",bj="_statusDot_g7q2b_163",wj="_inRange_g7q2b_170",vj="_outRange_g7q2b_174",jj="_unknown_g7q2b_178",Cj="_clammStatusValue_g7q2b_182",Nj="_breakdownContent_g7q2b_192",kj="_breakdownRow_g7q2b_200",Ij="_breakdownLabel_g7q2b_208",Aj="_breakdownValues_g7q2b_214",Sj="_breakdownAmount_g7q2b_220",Tj="_breakdownValue_g7q2b_214",Ej="_collapsibleContent_g7q2b_241",R={container:ej,section:tj,sectionHeader:nj,sectionTitle:sj,sectionLabel:oj,externalLink:aj,sectionValue:rj,tokenList:ij,tokenTrigger:cj,tokenChevron:lj,expanded:dj,tokenInfo:uj,tokenInfoLabel:mj,tokenLogo:hj,pairedLogos:fj,coinLogo:pj,tokenSymbol:gj,triggerValue:_j,clammBreakdownContent:yj,clammPositionRow:xj,statusDot:bj,inRange:wj,outRange:vj,unknown:jj,clammStatusValue:Cj,breakdownContent:Nj,breakdownRow:kj,breakdownLabel:Ij,breakdownValues:Aj,breakdownAmount:Sj,breakdownValue:Tj,collapsibleContent:Ej},$j=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("section",{className:R.section,"aria-label":"Liquidity positions",children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:fa,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:R.sectionValue,children:ee(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(Bj,{row:a,denomLogoMap:t},a.denom))})]})})},Mj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function Lj(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function qj(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function Wr(e,t){return e===void 0?"-":`${C.formatNumber(e,{dp:6})} ${t}`}function _l({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}),"aria-hidden":"true"}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(te,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(te,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const Pj=({position:e})=>{const t=Lj(e.inRange),s=qj(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:ee(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:Wr(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:Wr(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:ee(e.rewardValue)})})]})]})},Rj=({row:e,denomLogoMap:t})=>{const[s,o]=y.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:d}=e,m=t.get(a);if(!d)return null;const u=l||m?.assetLogo;return n.jsxs(Z.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:_l({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:u,rightContent:n.jsx("span",{className:R.triggerValue,children:ee(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:ee(d.totalRewardValue)})})]}),d.positions.map(h=>n.jsx(Pj,{position:h},h.tokenAddress))]})})]})},Dj=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,m]=y.useState(!1),u=t.get(s),h=i||u?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=y.useMemo(()=>Object.entries(r).filter(([,_])=>_>0),[r]),p=l&&Number(l.total)>0;return n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:_l({isOpen:d,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:ee(a)})})}),n.jsx(Z.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[g.map(([_,x])=>{const b=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:Mj[_]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[C.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:ee(b)})]})]},_)}),p&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[C.formatNumber(Number(l.total),{dp:6})," ",mt]}),n.jsx("span",{className:R.breakdownValue,children:ee(l.totalValue)})]})]})]})})]})},Bj=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(Rj,{row:e,denomLogoMap:t}):n.jsx(Dj,{row:e,denomLogoMap:t}),Fj="_container_1nijk_1",Uj="_section_1nijk_6",Oj="_sectionHeader_1nijk_14",Vj="_sectionTitle_1nijk_20",Kj="_sectionLabel_1nijk_26",Wj="_externalLink_1nijk_32",zj="_sectionValue_1nijk_44",Hj="_tokenList_1nijk_51",Qj="_tokenTrigger_1nijk_63",Gj="_tokenChevron_1nijk_79",Yj="_expanded_1nijk_90",Zj="_tokenInfo_1nijk_94",Jj="_tokenInfoLabel_1nijk_100",Xj="_tokenLogo_1nijk_106",eC="_tokenName_1nijk_110",tC="_triggerValue_1nijk_116",nC="_breakdownContent_1nijk_123",sC="_breakdownRow_1nijk_131",oC="_breakdownLabel_1nijk_139",aC="_breakdownValues_1nijk_145",rC="_breakdownAmount_1nijk_151",iC="_breakdownValue_1nijk_145",cC="_collapsibleContent_1nijk_165",de={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,tokenName:eC,triggerValue:tC,breakdownContent:nC,breakdownRow:sC,breakdownLabel:oC,breakdownValues:aC,breakdownAmount:rC,breakdownValue:iC,collapsibleContent:cC},lC=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:de.container,children:n.jsxs("section",{className:de.section,"aria-label":"VIP rewards",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:bd,target:"_blank",rel:"noopener noreferrer",className:de.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:de.sectionValue,children:ee(t)})]}),n.jsx("div",{className:de.tokenList,children:s.map(o=>n.jsx(dC,{row:o},`${o.bridgeId}-${o.version}`))})]})})},dC=({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}),"aria-hidden":"true"}),n.jsxs("div",{className:de.tokenInfoLabel,children:[s&&n.jsx(te,{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:ee(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:[C.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:ee(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:[C.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:ee(i)})]})]})]})})]})},uC="_container_ymkoc_1",mC="_trigger_ymkoc_6",hC="_expandIcon_ymkoc_22",fC="_chainInfo_ymkoc_27",pC="_logo_ymkoc_33",gC="_chainNameContainer_ymkoc_37",_C="_chainName_ymkoc_37",yC="_externalLink_ymkoc_49",xC="_externalIcon_ymkoc_53",bC="_valueColumn_ymkoc_63",wC="_value_ymkoc_63",vC="_expanded_ymkoc_80",jC="_collapsibleContent_ymkoc_85",CC="_content_ymkoc_97",Ve={container:uC,trigger:mC,expandIcon:hC,chainInfo:fC,logo:pC,chainNameContainer:gC,chainName:_C,externalLink:yC,externalIcon:xC,valueColumn:bC,value:wC,expanded:vC,collapsibleContent:jC,content:CC},NC=H.atom(!1),kC=()=>{const{totalValue:e}=Ia(),{totalValue:t}=io(),{totalValue:s}=co(),o=e+t+s;return n.jsx("span",{className:Ve.value,children:ee(o)})},IC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Ia(),{data:i}=lc(),{data:c}=dc(),l=y.useMemo(()=>{const u=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),_=`${e}:${f}`,x=s.get(_)??o.get(p);x&&u.set(f,{assetLogo:x,chainLogo:t})}return u},[r,s,o,e,t]),d=y.useMemo(()=>(u,h)=>{const f=C.denomToMetadata(u);if(h==="staking"){const g=i?.get(f);return g?C.fromBaseUnit(g.amount,{decimals:rt}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?C.fromBaseUnit(g.amount,{decimals:rt}):"0"}return"0"},[i,c]),m=y.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:fa,positions:r}],[r]);return m.length===0?null:n.jsx(gl,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},AC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=io(),r=y.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,m=d.toUpperCase(),u=`${e}:${l}`,h=s.get(u)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx($j,{data:a,denomLogoMap:r})},SC=()=>{const e=co();return e.rows.length===0?null:n.jsx(lC,{data:e})},TC=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=H.useAtom(NC),i=he(),c=ss(),{denomLogos:l,symbolLogos:d}=y.useMemo(()=>Aa(c,i),[c,i]),m=oe(),{data:u}=Lt(m),h=y.useMemo(()=>u?.find(g=>g.id===Ye)?.price??0,[u]);return n.jsx("div",{className:Ve.container,children:n.jsxs(Z.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Ve.trigger,children:[n.jsxs("div",{className:Ve.chainInfo,children:[o&&n.jsx(te,{src:o,width:32,height:32,className:Ve.logo,logo:!0}),n.jsxs("div",{className:Ve.chainNameContainer,children:[n.jsx("span",{className:Ve.chainName,children:s}),n.jsx("a",{href:fa,target:"_blank",rel:"noopener noreferrer",className:Ve.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,className:Ve.externalIcon})})]})]}),n.jsxs("div",{className:Ve.valueColumn,children:[n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:16,width:60,length:1}),children:n.jsx(kC,{})}),n.jsx(E.IconChevronDown,{size:16,className:D(Ve.expandIcon,{[Ve.expanded]:a})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Ve.collapsibleContent,children:n.jsxs("div",{className:Ve.content,children:[n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:36,length:2}),children:n.jsx(IC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:36,length:2}),children:n.jsx(AC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d})}),n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:36,length:1}),children:n.jsx(SC,{})})]})})]})})},EC="_totalValue_1v2ca_1",$C={totalValue:EC},MC=({filteredChainGroups:e})=>{const{totalValue:t}=Ia(),{totalValue:s}=io(),{totalValue:o}=co(),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:$C.totalValue,children:ee(r)})},LC="_container_1eubu_1",qC="_header_1eubu_7",PC="_title_1eubu_13",RC="_list_1eubu_19",DC="_skeletonWrapper_1eubu_24",Hn={container:LC,header:qC,title:PC,list:RC,skeletonWrapper:DC},BC=y.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ds(),r=oe(),i=y.useMemo(()=>{const l=[];for(const m of o){if(!Array.isArray(m.positions))continue;const u=s.get(m.chainName.toLowerCase()),h=m.chainName.toLowerCase();if(t&&u?.chainId!==t||!m.positions.some(x=>x.positions.some(b=>b.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const g=m.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),p=r.chainId===u?.chainId,_=g.reduce((x,b)=>x+b.positions.reduce((j,w)=>j+Mn(w),0),0);l.push({chainId:u?.chainId??"",chainName:u?.prettyName??m.chainName,chainLogo:u?.logoUrl??"",protocols:g,isInitia:p,totalValue:_})}const d=["civitia","yominet"];return $.sortWith([$.descend(m=>m.isInitia??!1),$.ascend(m=>d.includes(m.chainName.toLowerCase())),$.descend(m=>m.totalValue??0),$.ascend(m=>m.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Hn.container,children:[n.jsxs("div",{className:Hn.header,children:[n.jsx("span",{className:Hn.title,children:"Positions"}),c&&n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:16,width:60,length:1}),children:n.jsx(MC,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Hn.list,children:i.map(l=>l.isInitia?n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Hn.skeletonWrapper,children:n.jsx(wt,{height:56,length:1})}),children:n.jsx(TC,{chainGroup:l})},l.chainName):n.jsx(Xv,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(wt,{height:56,length:3}):n.jsx(be,{children:"No positions"})]})}),FC="_content_1w1ad_1",UC={content:FC},OC=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=ne(),o=oe(),a=Lm(),{totalValue:r}=co(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=y.useMemo(()=>{const d=new Map;let m=0;for(const h of a)d.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),m+=r),{chainIds:$.sortWith([$.descend(h=>h===s),$.descend(h=>h===o.chainId),$.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:m}},[a,s,o,r]);return n.jsx(xo,{value:e,onChange:t,chainIds:i,renderExtra:d=>ee(d?c.get(d)??0:l)})},VC=()=>{const[e,t]=H.useAtom(ll),[s,o]=H.useAtom(dl),a=he(),r=ss(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>Aa(r,a),[r,a]),l=la(),d=y.useMemo(()=>hc(a,l),[a,l]),m=Mm();return n.jsxs(ht.Root,{children:[n.jsxs(ht.Controls,{children:[n.jsx(ht.SearchInput,{value:e,onChange:u=>t(u.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(pe,{suspenseFallback:n.jsx(hn,{height:44,width:132}),children:n.jsx(OC,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("section",{className:UC.content,"aria-label":"Assets and positions",children:[n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:48,length:5}),children:n.jsx(ov,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:d})}),n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:56,length:3}),children:n.jsx(BC,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},KC="_totalValue_5pf7e_1",WC="_totalLabel_5pf7e_7",zC="_totalAmount_5pf7e_13",HC="_loading_5pf7e_18",QC="_skeletonWrapper_5pf7e_23",GC="_nav_5pf7e_28",YC="_item_5pf7e_34",ZC="_tabs_5pf7e_59",JC="_tab_5pf7e_59",Ke={totalValue:KC,totalLabel:WC,totalAmount:zC,loading:HC,skeletonWrapper:QC,nav:GC,item:YC,tabs:ZC,tab:JC},XC=()=>{const{totalValue:e,isLoading:t}=ba();return n.jsx("div",{className:D(Ke.totalAmount,{[Ke.loading]:t}),children:ee(e)})},eN=()=>{const e=qm(),t=Pm(),s=mc(),o=e+s+t;return n.jsx("div",{className:Ke.totalAmount,children:ee(o)})},tN=()=>{Lc(),Em();const e=Sa(),t=Se(),s=Xs(),o=y.useRef(null);return n.jsx(ml.Provider,{value:o,children:n.jsxs(pt,{ref:o,children:[n.jsxs("div",{className:Ke.totalValue,children:[n.jsx("div",{className:Ke.totalLabel,children:"Total value"}),n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Ke.skeletonWrapper,children:n.jsx(hn,{height:48,width:120})}),children:e?n.jsx(XC,{}):n.jsx(eN,{})})]}),n.jsxs("nav",{className:Ke.nav,"aria-label":"Quick actions",children:[n.jsxs(dn,{to:"/send",className:Ke.item,children:[n.jsx(E.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(dn,{to:"/bridge",className:Ke.item,children:[n.jsx(E.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(dn,{to:"/receive",className:Ke.item,children:[n.jsx(E.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Ft.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Ft.Tabs.List,{className:Ke.tabs,children:[n.jsx(Ft.Tabs.Tab,{className:Ke.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Ft.Tabs.Tab,{className:Ke.tab,value:"/nfts",children:"NFTs"}),n.jsx(Ft.Tabs.Tab,{className:Ke.tab,value:"/activity",children:"Activity"})]}),n.jsx(Ft.Tabs.Panel,{value:"/",children:e?n.jsx(tv,{}):n.jsx(VC,{})}),n.jsx(Ft.Tabs.Panel,{value:"/nfts",children:n.jsx(hw,{})}),n.jsx(Ft.Tabs.Panel,{value:"/activity",children:n.jsx(Gb,{})})]})]})})},nN="_root_th990_1",sN="_collectionName_th990_9",oN="_nftName_th990_13",aN="_chainInfo_th990_17",rN="_attributes_th990_21",iN="_title_th990_24",cN="_count_th990_29",lN="_item_th990_33",dN="_type_th990_39",uN="_value_th990_45",on={root:nN,collectionName:sN,nftName:oN,chainInfo:aN,attributes:rN,title:iN,count:cN,item:lN,type:dN,value:uN},mN=()=>{const e=Se(),t=Xe(),{attributes:s}=t;return n.jsxs(At,{title:"NFT details",children:[n.jsx(Va,{normalizedNft:t,chainIconSize:14,classNames:on}),n.jsx(Ae,{children:n.jsx(ue.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:on.attributes,children:[n.jsxs("header",{className:on.title,children:["Traits ",n.jsxs("span",{className:on.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:on.item,children:[n.jsx("div",{className:on.type,children:o}),n.jsx("div",{className:on.value,children:a})]},o))})]})]})};function hN({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 fN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(d=>d.denom===e)?.amount??"0",i=hN({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 pN=({chain:e,onSelect:t})=>{const s=Hl(e);return n.jsx(_s,{assets:s,onSelect:t})},gN=({afterSelect:e})=>{const{watch:t,setValue:s}=Ie.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=y.useState(r),l=ft(i),d=he(),m=u=>{if(o===i&&a===u){e();return}s("chainId",i),s("denom",u),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(mn.Stack,{children:n.jsx(mn,{chains:d,value:i,onSelect:c})}),n.jsx(pe,{suspenseFallback:n.jsx(_s.Placeholder,{}),children:n.jsx(pN,{chain:l,onSelect:m})},i)]})},_N="_fields_brpej_1",yN="_divider_brpej_11",zr={fields:_N,divider:yN},xN=$e.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),bN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=et(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=Ie.useFormContext(),{errors:d}=l,{chainId:m,denom:u,recipient:h,quantity:f,memo:g}=r(),p=ft(m),_=os(p),x=ya(p),b=xa(p),j=ii(u,p),{data:w}=Lt(p),{decimals:v}=j,k=_.find(O=>O.denom===u)?.amount??"0",T=w?.find(({id:O})=>O===u)?.price,{data:M=0,isLoading:A}=S.useQuery({queryKey:xN.gas({chainId:m,denom:u,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Xa.MsgSend.fromPartial({fromAddress:t,toAddress:C.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return s({messages:O,chainId:m})},enabled:C.InitiaAddress.validate(h),staleTime:K.INFINITY}),L=Math.ceil(M*pn),N=fN({denom:u,balances:_,gasPrices:x,lastFeeDenom:b,gas:L}),I=U(k).isZero(),q=x.some(({denom:O})=>O===u)&&A,P=I||q,{mutate:B,isPending:Q}=S.useMutation({mutationFn:({chainId:O,denom:me,quantity:ge,recipient:ce,memo:ye})=>{const we=C.toBaseUnit(ge,{decimals:v}),ve=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Xa.MsgSend.fromPartial({fromAddress:t,toAddress:C.InitiaAddress(ce).bech32,amount:[{denom:me,amount:we}]})}];return o({messages:ve,memo:ye,chainId:O,gas:M,gasAdjustment:pn,gasPrices:x,spendCoins:[{denom:me,amount:we}],internal:"/"})}}),W=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(At,{title:"Send",children:n.jsxs("form",{onSubmit:c(O=>B(O)),"aria-label":"Send token form",children:[n.jsxs("div",{className:zr.fields,children:[n.jsx(Go,{selectButton:n.jsx(Ln,{title:"Select chain and asset",content:O=>n.jsx(gN,{afterSelect:O}),children:n.jsx(Fc,{asset:j,chain:p})}),quantityInput:n.jsx(ts,{balance:k,decimals:v}),balanceButton:n.jsx(qc,{onClick:()=>i("quantity",C.fromBaseUnit(N,{decimals:v}),{shouldValidate:!0}),disabled:P,children:C.formatAmount(k??"0",{decimals:v})}),value:f?Ea(U(f).times(T??0),T):"$0"}),n.jsx("div",{className:zr.divider}),n.jsx(Pa,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(xe.Stack,{children:!g&&n.jsx(xe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(Ae,{children:n.jsx(ue.White,{type:"submit",loading:(A?"Estimating gas...":!1)||Q,disabled:!!W,children:W??"Confirm"})})]})})},wN=()=>{const e=Xe(),t=yn(),s=zt(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=Ie.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return n.jsx(Ie.FormProvider,{...i,children:n.jsx(bN,{})})};async function oa(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function vN(e,t){const s=new vt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:t}).post("minievm/evm/v1/call",{json:{sender:C.InitiaAddress("0x1").bech32,contract_addr:C.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function jN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function CN({collection_addr:e},{restUrl:t}){const s=await vN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${C.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await oa(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${C.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function NN(e,t){const{data:s}=await z.create({prefixUrl:t}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function kN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await NN(t,s);return o.startsWith("ibc/")?C.InitiaAddress.equals(C.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await oa(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await oa(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function IN(e,t){const s=ae.toBase64(rn.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function AN(e,t){const{collection:s}=await z.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function SN(e,t){const s=ae.toBase64(rn.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function Hr(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 TN({collection_addr:e},t,s){const o=C.InitiaAddress(e).bech32,a=await IN(o,t.restUrl),r=t.metadata?.ibc_channels?.find(({chain_id:p,version:_})=>p===s.chain_id&&_.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=ae.toBase64(rn.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=d??o,u=await SN(c,t.restUrl),h=await AN(o,t.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:u};if(d&&h!==i.replace("wasm.","")){const[p,_]=Hr(d);return{class_id:o,class_trace:{path:p,base_class_id:_},outgoing_proxy:u}}const[f,g]=Hr(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:u}}const EN={minimove:kN,minievm:CN,miniwasm:TN};async function $N({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 EN[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await jN([e.token_id],a.class_id,t.restUrl)})}const MN="_root_1tyvn_1",LN="_collectionName_1tyvn_10",qN="_nftName_1tyvn_15",PN="_chainInfo_1tyvn_19",RN="_fields_1tyvn_24",DN="_chain_1tyvn_19",Vo={root:MN,collectionName:LN,nftName:qN,chainInfo:PN,fields:RN,chain:DN},BN=$e.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),FN=()=>{const e=he(),t=Xe(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=ne(),r=is(),i=oe(),{address:c,initiaAddress:l,requestTxSync:d}=et(),{watch:m,setValue:u,handleSubmit:h,formState:f}=Ie.useFormContext(),{errors:g}=f,p=m(),{recipient:_,dstChainId:x}=p,b=ft(x),j=S.useQuery({queryKey:BN.simulation({collection_addr:o,nft:t,sender:l,recipient:_,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:C.InitiaAddress(_).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==b.chainId&&await $N({nft:t,srcChain:s,intermediaryChain:i})),{msgs:I}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return I.map(F=>r.fromAmino(F))},enabled:C.InitiaAddress.validate(_)}),{data:w,isLoading:v,error:k}=j,T=S.useQueryClient(),{mutate:M,isPending:A}=S.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{T.invalidateQueries({queryKey:Ka.nfts._def})}}),L=y.useMemo(()=>{if(!_)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(k)return"Route not found"},[_,g.recipient,k]);return n.jsxs("form",{onSubmit:h(()=>M()),children:[n.jsx(Va,{normalizedNft:t,thumbnailSize:80,classNames:Vo}),n.jsxs("div",{className:Vo.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination app"}),n.jsxs(Ln,{title:"Destination app",content:N=>n.jsx(Bc,{onSelect:({chainId:I})=>{u("dstChainId",I),N()},list:e,getImage:I=>I.logoUrl,getName:I=>I.name,getKey:I=>I.chainId}),className:D("input",Vo.chain),children:[n.jsx(te,{src:b.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:b.name})]})]}),n.jsx(Pa,{myAddress:c,ref:fs()})]}),n.jsx(Ae,{children:n.jsx(ue.White,{loading:(v?"Finding route...":!1)||A,disabled:!!L,children:L??"Confirm"})})]})},UN=()=>{const{chain:e}=Xe(),t=Ie.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(At,{title:"Send NFT",children:n.jsx(Ie.FormProvider,{...t,children:n.jsx(FN,{})})})},aa=()=>{const e=Se(),t=Xs(),s=Qt(),{closeDrawer:o}=qt(),{closeModal:a}=oo();y.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=qn();if(y.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(qr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(qr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(tN,{});case"/send":return n.jsx(wN,{},s);case"/receive":return n.jsx(C2,{});case"/nft":return n.jsx(mN,{});case"/nft/send":return n.jsx(UN,{},s);case"/bridge":return n.jsx(ay,{},s);case"/bridge/preview":return n.jsx(wx,{});case"/bridge/history":return n.jsx(Jy,{});case"/op/withdrawals":return n.jsx(Qx,{});case"/tx":return n.jsx(Ic,{});case"/autosign/enable":return n.jsx(Vp,{});case"/settings":return n.jsx(J2,{});case"/settings/autosign":return n.jsx(F2,{});case"/deposit":return n.jsx(d2,{});case"/deposit/completed":return n.jsx(sa,{type:"deposit"});case"/withdraw":return n.jsx(u2,{});case"/withdraw/completed":return n.jsx(sa,{type:"withdraw"})}},ON="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",VN=()=>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:ON}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),KN=()=>(Rm(),pd(),Fd(),he(),$m(),mc(),ss(),null),WN=({children:e,...t})=>(y.useEffect(()=>{dm()},[]),ze.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(VN,{}),n.jsx(si.Provider,{value:{...ni,...t},children:n.jsx(fi,{children:n.jsx(mp,{children:n.jsx(Z.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(up,{children:n.jsxs(Xf,{children:[e,n.jsx(Dm,{}),n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(KN,{})}),n.jsx(Th,{children:n.jsx(aa,{})}),n.jsx(kh,{children:n.jsx(aa,{})})]})})})})})})]}):null),zN=({bridge:e})=>n.jsx(fi,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(wc.Provider,{value:!!e,children:n.jsx(pe,{children:n.jsx(aa,{})})})})}),HN={1:"https://ethereum-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com"};function QN(e){const{id:t="testWallet",name:s="Test Wallet",rpcUrls:o,debug:a=!1,sendTransactionOverrides:r}=e;if("mnemonic"in e&&e.mnemonic==="")throw new Error("mnemonic must not be empty");if(!("mnemonic"in e&&e.mnemonic)&&!("privateKey"in e&&e.privateKey))throw new Error("Either mnemonic or privateKey is required");let i;try{i=e.mnemonic?er.mnemonicToAccount(e.mnemonic):er.privateKeyToAccount(e.privateKey)}catch(p){throw new Error(`[${t}] Failed to create account from ${e.mnemonic?"mnemonic":"privateKey"}`,{cause:p})}let c=1;const l={};function d(p,..._){l[p]?.forEach(x=>{x(..._)})}const m={...HN,...o},u={1:Ml.mainnet};function h(p){if(m[p])return m[p];const _=u[p];if(_)return _.rpcUrls.default.http[0];throw new Error(`[${t}] No RPC configured for chain ${p}`)}async function f(p,_){const x=h(c),b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p,params:_??[]})});if(!b.ok)throw new Error(`[${t}] RPC "${p}" failed: HTTP ${b.status} ${b.statusText} (${x})`);let j;try{j=await b.json()}catch(w){throw new Error(`[${t}] RPC "${p}" returned non-JSON response (${x})`,{cause:w})}if(j.error)throw new ut.EIP1193ProviderRpcError(j.error.code,j.error.message);return j.result}const g={request:async({method:p,params:_})=>{switch(a&&console.log(`[${t}] ${p}`,_),p){case"eth_requestAccounts":case"eth_accounts":return[i.address];case"eth_chainId":return`0x${c.toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:x}]=_,b=Number(x);if(!u[b]&&!m[b])throw new ut.EIP1193ProviderRpcError(4902,"Unrecognized chain ID");return!u[b]&&m[b]&&(u[b]={id:b,name:`Chain ${b}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[m[b]]}}}),c=b,d("chainChanged",x),null}case"wallet_addEthereumChain":{const[x]=_,b=x.rpcUrls?.[0];if(!b)throw new Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);const j=Number(x.chainId);return u[j]?a&&console.log(`[${t}] Chain ${j} already registered, skipping`):u[j]={id:j,name:x.chainName??`Chain ${j}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[b]}}},null}case"personal_sign":{const[x]=_;return i.signMessage({message:{raw:x}})}case"eth_signTypedData":case"eth_signTypedData_v4":{const[,x]=_;return i.signMessage({message:{raw:x}})}case"wallet_getPermissions":case"wallet_requestPermissions":return[{parentCapability:"eth_accounts"}];case"eth_sendTransaction":{const[x]=_,b=u[c];if(!b)throw new Error(`[${t}] No chain registered for chain ${c}. Call wallet_switchEthereumChain first.`);return ut.createWalletClient({account:i,chain:b,transport:ut.http(h(c))}).sendTransaction({to:x.to,value:x.value?BigInt(x.value):void 0,data:x.data,chainId:c,...r})}default:return f(p,_)}},on:(p,_)=>{(l[p]??=new Set).add(_)},removeListener:(p,_)=>{l[p]?.delete(_)},removeAllListeners:()=>{for(const p of Object.keys(l))delete l[p]}};return Ll.injected({target:()=>({id:t,name:s,provider:g})})}const Qr={"noble-1":"noble",celestia:"celestia","neutron-1":"neutron","osmosis-1":"osmo"};function GN(e){const{mnemonic:t,name:s="Test Cosmos Wallet",image:o,chains:a,debug:r=!1}=e;if(!t)throw new Error("mnemonic is required");const i=new Map;function c(u){return a?.[u]?a[u].prefix:Qr[u]?Qr[u]:u.replace(/-\d+$/,"")}function l(u){const h=c(u),f=i.get(h);if(f)return f;r&&console.log(`[${s}] Creating wallet for chain ${u} (prefix: ${h})`);const g=Tn.Secp256k1HdWallet.fromMnemonic(t,{prefix:h});return g.catch(p=>{i.delete(h),console.error(`[${s}] Failed to create wallet for prefix "${h}":`,p)}),i.set(h,g),g}function d(u){return{async getAccounts(){return(await l(u)).getAccounts()},async signAmino(h,f){return(await l(u)).signAmino(h,f)}}}const m={getOfflineSigner(u){return d(u)},getOfflineSignerOnlyAmino(u){return d(u)}};return{name:s,image:o,getProvider:()=>m}}exports.DEFAULT_GAS_ADJUSTMENT=pn;exports.DEFAULT_GAS_PRICE_MULTIPLIER=ti;exports.InterwovenKit=zN;exports.InterwovenKitProvider=WN;exports.MAINNET=ni;exports.MoveError=Vi;exports.PRIVY_APP_ID=ca;exports.TESTNET=Pl;exports.createTestCosmosWallet=GN;exports.createTestWalletConnector=QN;exports.initiaPrivyWallet=Dl;exports.initiaPrivyWalletConnector=Rl;exports.initiaPrivyWalletOptions=Yn;exports.injectStyles=nh;exports.useAddress=Qt;exports.useHexAddress=Rn;exports.useInitiaAddress=se;exports.useInterwovenKit=et;exports.usePortfolio=ba;exports.useUsernameQuery=tc;
|
|
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 ed(e,t){const s=ut.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=ut.hexToBytes(ut.keccak256(ut.bytesToHex(o))),r=dt.Bip39.encode(a),i=await dt.Bip39.mnemonicToSeed(r),c=dt.stringToPath("m/44'/60'/0'/0/0"),{privkey:l}=dt.Slip10.derivePath(dt.Slip10Curve.Secp256k1,i,c),d=await dt.Secp256k1.makeKeypair(l),m=dt.Secp256k1.compressPubkey(d.pubkey),h=d.pubkey.slice(1),f=ut.bytesToHex(h),g=ut.keccak256(f),p=ut.hexToBytes(g).slice(-20),_=ae.toBech32(t,p);return{privateKey:l,publicKey:m,address:_}}function ws(e,t){return`${e}:${t}`}const as=H.atom(null),Zn=H.atom({}),Jn=H.atom({}),eo=H.atom({}),nr=H.atom(0),td="autosign:";function nd(e,t){const s=e.get(nr)+1;return e.set(nr,s),`${t}:${s}`}function Rs(e,t){return e.get(eo)[t]}function sd(e,t,s){e.set(eo,o=>({...o,[t]:s}))}function _i(e,t){e.set(eo,s=>{const o={...s};return delete o[t],o})}function od(e,t,s){const o=Rs(e,t);!o||o.token!==s||_i(e,t)}function ad(e,t,s){const o=Rs(e,t);return!!o&&o.token===s}function vs(e,t){return e.get(Jn)[t]}function rd(e,t,s){e.set(Jn,o=>({...o,[t]:s}))}function id(e,t){e.set(Jn,s=>{const o={...s};return delete o[t],o})}function cd(e,t,s){e.set(Zn,o=>({...o,[t]:s}))}function ld(e,t){e.set(Zn,s=>{const o={...s};return delete o[t],o})}function yi(e,t){return`${td}${e}:${t}`}function dd(e,t,s){try{return e.getItem(yi(t,s))}catch{return null}}function ud(e,t,s,o){try{e.setItem(yi(t,s),o)}catch{}}function xi(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function ha(e,t){const s=xi();if(s)return dd(s,e,t)}function md(e,t,s){const o=xi();o&&ud(o,e,t,s)}function hd(e){return{publicKey:e.publicKey,address:e.address}}function Ds(e){e&&e.fill(0)}function bi(e){e.set(eo,{});const t=e.get(Jn);for(const s of Object.values(t))Ds(s);e.set(Jn,{}),e.set(Zn,{})}function fd(e,t){return e!==""&&e!==t}function pd(){const e=se(),t=H.useStore(),s=y.useRef(e);y.useEffect(()=>{const o=s.current;fd(o,e)&&bi(t),s.current=e},[t,e])}class gd{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=Gn.escapeCharacters(Gn.sortedJsonStringify(s)),a=vt.ethers.hashMessage(o),r=ae.fromHex(a.replace("0x","")),i=await dt.Secp256k1.createSignature(r,this.privateKey),c=new Uint8Array([...i.r(32),...i.s(32)]),l=gi(this.wallet.publicKey,c);return{signed:s,signature:l}}}function to(){const e=H.useStore(),{signMessageAsync:t}=We.useSignMessage(),s=Je(),o=se();return{deriveWallet:async d=>{if(!o)throw new Error("User address not available");const m=s(d),u=ws(o,m.bech32_prefix),h=e.get(Zn)[u];if(h&&vs(e,u))return h;const f=Rs(e,u);if(f)return f.promise;const g=nd(e,u),p=(async()=>{try{const _=window.location.origin,x=Xl(_),b=await t({message:x}),j=await ed(b,m.bech32_prefix),w=hd(j);if(ad(e,u,g))return rd(e,u,j.privateKey),cd(e,u,w),w;throw Ds(j.privateKey),new Error("Wallet derivation was cancelled")}finally{od(e,u,g)}})();return sd(e,u,{promise:p,token:g}),p},getWallet:d=>{if(!o)return;const m=s(d),u=ws(o,m.bech32_prefix);if(vs(e,u))return e.get(Zn)[u]},getWalletPrivateKey:d=>{if(!o)return;const m=s(d),u=ws(o,m.bech32_prefix);return vs(e,u)},clearWallet:d=>{if(!o)return;const m=s(d),u=ws(o,m.bech32_prefix),h=vs(e,u);Rs(e,u)&&_i(e,u),Ds(h),id(e,u),ld(e,u)},clearAllWallets:()=>{bi(e)}}}function wi({granteeAddress:e,messages:t,encoder:s}){return[{typeUrl:"/cosmos.authz.v1beta1.MsgExec",value:ra.MsgExec.fromPartial({grantee:e,msgs:t.map(o=>({typeUrl:o.typeUrl,value:s.encode(o)}))})}]}async function _d({chainId:e,granterAddress:t,messages:s,fee:o,memo:a,derivedWallet:r,privateKey:i,encoder:c,signWithEthSecp256k1:l}){const d=wi({granteeAddress:r.address,messages:s,encoder:c}),m={...o,granter:t},u=new Uint8Array(i),h=new gd(r,u);try{return await l(e,r.address,d,m,a,{customSigner:h})}finally{Ds(u)}}const yt="interwovenkit",Ye="uinit",mt="INIT",rt=6,yd="uoinit",xd="omniINIT",vi="https://app.initia.xyz",fa=`${vi}/liquidity/my`,bd=`${vi}/vip/my`,wd=1e3,ji=60*wd,Ci=60*ji,sr=24*Ci,ie={PUBLIC_KEY:`${yt}:public-key`,BRIDGE_SRC_CHAIN_ID:`${yt}:bridge:src-chain-id`,BRIDGE_SRC_DENOM:`${yt}:bridge:src-denom`,BRIDGE_DST_CHAIN_ID:`${yt}:bridge:dst-chain-id`,BRIDGE_DST_DENOM:`${yt}:bridge:dst-denom`,BRIDGE_QUANTITY:`${yt}:bridge:quantity`,BRIDGE_SLIPPAGE_PERCENT:`${yt}:bridge:slippage-percent`,BRIDGE_ROUTE_TYPE:`${yt}:bridge:route-type`,BRIDGE_HISTORY:`${yt}:bridge:history`,OP_REMINDER:`${yt}:op:reminder`},Ni=H.atom(!1),ki=H.atom(!1);function qt(){const e=ua(),[t,s]=H.useAtom(Ni),o=H.useSetAtom(ki),a=qn();return{isDrawerOpen:t,openDrawer:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeDrawer:()=>{s(!1),a("Widget Closed")}}}function Pn(){const e=ua(),[t,s]=H.useAtom(ki),o=H.useSetAtom(Ni),a=qn();return{isModalOpen:t,openModal:(c,l)=>{c&&e(c,l),o(!1),s(!0),a("Widget Opened")},closeModal:()=>{s(!1),a("Widget Closed")}}}function Ii(){const e=Se(),{closeDrawer:t}=qt(),{closeModal:s}=Pn(),{disconnect:o}=We.useDisconnect(),{clearAllWallets:a}=to();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 vd(){const e=Qt(),t=yn(),{openModal:s}=Pn();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(m=>({denom:m,chainId:l}));s("/deposit",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function jd(){const e=Qt(),t=yn(),{openModal:s}=Pn();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(m=>({denom:m,chainId:l}));s("/withdraw",{localOptions:d,remoteOptions:i,recipientAddress:c})}}function Cd(e){if(e?.typeUrl==="/initia.crypto.v1beta1.ethsecp256k1.PubKey"){const{key:t}=Ko.PubKey.decode(e.value);return Tn.encodeSecp256k1Pubkey(t)}return Hs.decodeOptionalPubkey(e)}function Nd({typeUrl:e,value:t}){if(e==="/cosmos.auth.v1beta1.BaseAccount"){const{address:s,pubKey:o,accountNumber:a,sequence:r}=Cl.BaseAccount.decode(t),i=Cd(o);return{address:s,pubkey:i,accountNumber:Number(a),sequence:Number(r)}}return Ee.accountFromAny({typeUrl:e,value:t})}const Ai="/cosmos.feegrant.v1beta1.MsgGrantAllowance",Si="/cosmos.feegrant.v1beta1.AllowedMsgAllowance",Ti="cosmos-sdk/AllowedMsgAllowance";function kd(){const e=fn.aminoConverters[Ai];if(!e)throw new Error("Missing base converter for MsgGrantAllowance");return e}const Bs=kd();function Ei(e){if(e.typeUrl===Si){const t=an.AllowedMsgAllowance.decode(e.value);if(!t.allowance)throw new Error("AllowedMsgAllowance is missing nested allowance");return{type:Ti,value:{allowance:Ei(t.allowance),allowed_messages:t.allowedMessages}}}return Bs.toAmino({granter:"",grantee:"",allowance:e}).allowance}function $i(e){if(e.type===Ti){const t=e.value;if(!t.allowance)throw new Error("AllowedMsgAllowance amino value is missing nested allowance");const s=$i(t.allowance);return{typeUrl:Si,value:an.AllowedMsgAllowance.encode(an.AllowedMsgAllowance.fromPartial({allowance:s,allowedMessages:t.allowed_messages??t.allowedMessages??[]})).finish()}}return Bs.fromAmino({granter:"",grantee:"",allowance:e}).allowance}const Id={...fn.aminoConverters,[Ai]:{...Bs,toAmino:e=>e.allowance?{granter:e.granter,grantee:e.grantee,allowance:Ei(e.allowance)}:Bs.toAmino(e),fromAmino:e=>({granter:e.granter,grantee:e.grantee,allowance:$i(e.allowance)})}},rs=()=>{const e=ne();return new Hs.Registry([...fn.protoRegistry,...e.protoTypes??[]])},is=()=>{const e=ne();return new Ee.AminoTypes({...Id,...e.aminoConverters})};class Ad{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=ae.fromHex(s),ae.fromHex(s);const o=await this.getPublicKeyFromRestApi();if(o)return this.cachedPublicKey=o,localStorage.setItem(t,ae.toHex(o)),o;const a=await this.getPublicKey();return this.cachedPublicKey=a,localStorage.setItem(t,ae.toHex(a)),a}async getPublicKeyFromRestApi(){try{const s=(await z.create({prefixUrl:this.restUrl}).get(`cosmos/auth/v1beta1/account_info/${this.address}`).json())?.info?.pub_key?.key;return s?ae.fromBase64(s):null}catch{return null}}async getPublicKey(){const t="Sign this message to identify your Initia account.",s=await this.signMessage(t),o=vt.ethers.hashMessage(t),a=vt.ethers.SigningKey.recoverPublicKey(o,s);return dt.Secp256k1.compressPubkey(ae.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=Gn.escapeCharacters(Gn.sortedJsonStringify(s)),a=await this.signMessage(o),r=ae.fromHex(a.replace("0x","")).subarray(0,-1),c=dt.Secp256k1Signature.fromFixedLength(r).toFixedLength(),l=gi(await this.getCachedPublicKey(),c);return{signed:s,signature:l}}}function Mi(){const e=rs(),t=is(),s=cs(),o=no();return async function(a,r,i,c,l,d){const m=d?.customSigner??s;if(!m)throw new Error("Signer not initialized");const u=await o(a),{accountNumber:h,sequence:f}=await Li({getSequence:N=>u.getSequence(N),signerAddress:r,incrementSequence:d?.incrementSequence??0,allowMissingAccount:!!d?.customSigner}),[g]=await m.getAccounts(),p=pi(ma(g.pubkey)),_=Zr.SignMode.SIGN_MODE_EIP_191,x=i.map(N=>t.toAmino(N)),b=Gn.makeSignDoc(x,c,a,l,h,f),{signature:j,signed:w}=await m.signAmino(r,b),k={typeUrl:"/cosmos.tx.v1beta1.TxBody",value:{messages:w.msgs.map(N=>t.fromAmino(N)),memo:l}},T=e.encode(k),M=Qa.Int53.fromString(w.fee.gas).toNumber(),A=Qa.Int53.fromString(w.sequence).toNumber(),L=Hs.makeAuthInfoBytes([{pubkey:p,sequence:A}],w.fee.amount,M,w.fee.granter,w.fee.payer,_);return Ge.TxRaw.fromPartial({bodyBytes:T,authInfoBytes:L,signatures:[ae.fromBase64(j.signature)]})}}function Sd(e,t){return e instanceof Error?/does not exist on chain/i.test(e.message)&&e.message.includes(t):!1}async function Li({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&&Sd(a,t))return{accountNumber:0,sequence:s};throw a}}function cs(){const e=se(),{signMessageAsync:t}=We.useSignMessage(),s=oe();return y.useMemo(()=>new Ad(e,o=>t({message:o}),s.restUrl),[e,t,s.restUrl])}const vo=new Map,Ms=new Map;function Td(e,t){const s=`${e}:${t}`;Ms.delete(s)}function pa(){const e=Je();return async t=>{if(vo.has(t))return vo.get(t);const{rpcUrl:s}=e(t),o=await Ga.Comet38Client.create(new Ga.HttpClient(s));return vo.set(t,o),o}}function no(){const e=rs(),t=is(),s=cs(),o=se(),a=pa();return async r=>{const i=`${o}:${r}`;if(Ms.has(i))return Ms.get(i);if(!s)throw new Error("Signer not initialized");const c=await a(r),l=await Ee.SigningStargateClient.createWithSigner(c,s,{registry:e,aminoTypes:t,accountParser:Nd,broadcastPollIntervalMs:500});return Ms.set(i,l),l}}function qi(){const{connector:e}=We.useAccount();return async()=>{if(!e)throw new Error("Wallet not connected");return new vt.BrowserProvider(await e.getProvider())}}class un extends Error{constructor(t){super(t),this.name="TimeoutError"}}function Pi(e,t,s){let o;const a=new Promise((r,i)=>{o=setTimeout(()=>i(new un(s)),t)});return Promise.race([e,a]).finally(()=>{clearTimeout(o)})}function Ri(e){return e.filter(t=>t.authorization["@type"].includes("GenericAuthorization")).filter(t=>!!t.authorization.msg)}function Di(e){return e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance"?e.allowance?.expiration:e.expiration}function Ed(e){if(e["@type"]==="/cosmos.feegrant.v1beta1.AllowedMsgAllowance")return e.allowedMessages??e.allowed_messages??[]}function Bi(){const e=se(),t=Je();return{fetchFeegrant:async(r,i)=>{if(!e)return null;const c=t(r),l=z.create({prefixUrl:c.restUrl});try{const{allowance:d}=await l.get(`cosmos/feegrant/v1beta1/allowance/${e}/${i}`).json();return d}catch(d){if(d instanceof z.HTTPError&&[404,500].includes(d.response.status))return null;throw d}},fetchGrants:async(r,i)=>{if(!e)return[];const c=t(r),l=z.create({prefixUrl:c.restUrl}),{grants:d}=await l.get("cosmos/authz/v1beta1/grants",{searchParams:{granter:e,grantee:i}}).json();return d},fetchAllGrants:async r=>{const i=t(r),c=e;if(!c)return[];const l=`cosmos/authz/v1beta1/grants/granter/${c}`,d=await Ys(l,{prefixUrl:i.restUrl},"grants");return Ri(d)}}}const Fs=$e.createQueryKeys("interwovenkit:autosign",{expirations:(e,t,s)=>[e,t,s],grants:(e,t)=>[e,t]}),$d=4,Fi=4;function Md(e){return Object.entries(e).sort(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${t}:${[...s].sort().join(",")}`).join("|")}function ga(){const e=ne(),t=yn(),{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 Ld(){const{data:e}=so(),t=ga();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 so(){const e=se(),t=ga(),s=Md(t),{fetchFeegrant:o,fetchAllGrants:a}=Bi();return S.useQuery({queryKey:Fs.expirations(e,s,t).queryKey,queryFn:()=>qd({initiaAddress:e,messageTypes:t,fetchAllGrants:a,fetchFeegrant:o}),staleTime:K.MINUTE,retry:1})}async function qd(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[u,h]of Object.entries(s))r[u]=null,i[u]=void 0,c[u]=!1,h.length>0&&d.push([u,h]);if(d.length===0)return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i};const m=await Ui(d,$d,async([u,h])=>{const f=ha(t,u);try{const g=await o(u),p=f===void 0?g:f===null?[]:g.filter(k=>k.grantee===f),_=Dd(p,h);if(_.length===0)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const x=await Rd({chainId:u,candidates:_,fetchFeegrant:a,concurrency:Fi});if(!x)return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0};const b=x.grantee.grants.filter(k=>h.includes(k.authorization.msg)).map(k=>k.expiration),j=Di(x.feegrant.allowance),w=[...b,j],v=_a(w);return{chainId:u,expectedAddress:f,expiration:v?new Date(v):void 0,grantee:x.grantee.grantee}}catch{return{chainId:u,expectedAddress:f,expiration:null,grantee:void 0}}});for(const u of m)l[u.chainId]=u.expectedAddress,r[u.chainId]=u.expiration,i[u.chainId]=u.grantee;for(const[u]of d)c[u]=Bd({expiration:r[u],grantee:i[u],expectedAddress:l[u]});return{expiredAtByChain:r,isEnabledByChain:c,granteeByChain:i}}async function Ui(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 Pd(e){const t=Ed(e.allowance);if(!(!t||t.includes("/cosmos.authz.v1beta1.MsgExec")))return!1;const o=Di(e.allowance);if(!o)return!0;const a=new Date(o);return!Number.isNaN(a.getTime())&&Ze.isFuture(a)}async function Rd(e){const{chainId:t,candidates:s,fetchFeegrant:o,concurrency:a=Fi}=e,r=await Ui(s,a,async i=>{const c=await o(t,i.grantee);return c&&Pd(c)?{grantee:i,feegrant:c}:null});for(const i of r)if(i)return i;return null}function Dd(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||Ze.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 Bd(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&&Ze.isFuture(t)}}function Fd(){const{data:e,refetch:t}=so();y.useEffect(()=>{if(!e)return;const s=new Date,o=Object.values(e.expiredAtByChain).filter(c=>c instanceof Date&&Ze.isFuture(c));if(o.length===0)return;const a=_a(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 _a(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 Oi=y.createContext(null),oo=()=>y.useContext(Oi);class Vi 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 Ud=/VM aborted: location=([0-9A-Fa-f]+)::(\w+), code=(\d+)/,jo=new Map;function Od(e){const t=e.match(Ud);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 Vd(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 z.get(r).json();return jo.set(o,i),i}catch{return null}}function Kd(e,t,s,o,a,r,i){return new Vi(e,t,s,o,a,r,i)}async function Nn(e,t,s){if(!t.metadata?.is_l1&&t.metadata?.minitia?.type!=="minimove")return await Ct(e);const o=Od(e.message);if(!o)return await Ct(e);const a=await Vd(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 Kd(l,e,o.moduleAddress,o.moduleName,o.errorCode,r,d)}const Wd=10;function Ki(){const e=se();return(t,s)=>S.queryOptions({queryKey:Zs.txs(t.indexerUrl,e).queryKey,queryFn:async()=>{if(!s.enabled)return[];const o={"pagination.reverse":!0,"pagination.limit":Wd},{txs:a}=await z.create({prefixUrl:t.indexerUrl}).get(`indexer/tx/v1/txs/by_account/${e}`,{searchParams:o}).json();return a},staleTime:K.SECOND})}function zd(e,t){const s=Ki();return S.useSuspenseQuery(s(e,t))}function Hd(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 Qd=()=>{const e=he(),t=Ki(),s=S.useQueries({queries:e.map(i=>t(i,{enabled:!0}))}),o=s.map($.prop("data")),a=Hd(e,o),r=s.some(i=>i.isLoading);return{activities:a,isLoading:r}};async function Wi(e){if(e.metadata?.is_l1){const{restUrl:t}=e,{gas_prices:s}=await z.create({prefixUrl:t}).get("initia/tx/v1/gas_prices").json();return s.toSorted($.descend(({denom:o})=>o==="uinit")).map(({denom:o,amount:a})=>{const r=o==="uinit"?1:ti;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 ya(e){const{data:t}=S.useSuspenseQuery({queryKey:Gs.gasPrices(e).queryKey,queryFn:()=>Wi(e),staleTime:K.SECOND});return t}function xa(e){const t=se(),{data:s}=zd(e,{enabled:e.fees.fee_tokens.length>=2});if(e.fees.fee_tokens.length===0)return null;const o=e.fees.fee_tokens[0].denom;if(e.fees.fee_tokens.length===1)return o;try{return s.find(({tx:r})=>r.auth_info.signer_infos.some(i=>C.InitiaAddress.equals(t,vt.computeAddress(`0x${ae.toHex(dt.Secp256k1.uncompressPubkey(ae.fromBase64(i.public_key.key)))}`))))?.tx.auth_info.fee.amount[0]?.denom??o}catch{return o}}const zi="approve",ao=H.atom(),Hi=H.atom(null),Gd=pn,Yd=1.5;function Zd({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 Jd({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=Zd({gasPrices:t,preferredFeeDenom:s,fallbackFeeDenom:o,allowedFeeDenoms:c});return Ee.calculateFee(l,Ee.GasPrice.fromString(`${d.amount}${d.denom}`))}function Xd({derivedAddress:e,messages:t,encoder:s}){return{messages:wi({granteeAddress:e,messages:t,encoder:s})}}function eu(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 tu({queryClient:e,messages:t,memo:s,pubkey:o,sequence:a}){const r=Ee.createProtobufRpcClient(e),i=new Ya.ServiceClientImpl(r),c=Ge.Tx.fromPartial({authInfo:Ge.AuthInfo.fromPartial({fee:Ge.Fee.fromPartial({}),signerInfos:[{publicKey:o,sequence:BigInt(a),modeInfo:{single:{mode:Zr.SignMode.SIGN_MODE_UNSPECIFIED}}}]}),body:Ge.TxBody.fromPartial({messages:Array.from(t),memo:s}),signatures:[new Uint8Array]});return await i.Simulate(Ya.SimulateRequest.fromPartial({txBytes:Ge.Tx.encode(c).finish()}))}function nu(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e}async function su({address:e,chainId:t,messages:s,memo:o,fee:a,preferredFeeDenom:r,client:i,allowAutoSign:c=!0,allowWalletDerivation:l=!1},d){const m=async()=>d.signWithEthSecp256k1(t,e,s,a,o),u=(_,x)=>{d.onAutoSignFallback?.({chainId:t,reason:_,errorMessage:nu(x)})};if(!c)return m();if(!d.validateAutoSign(t,s))return u("validation_failed"),m();let f=d.getWallet(t),g=!1;if(!f&&l)try{f=await d.deriveWallet(t)}catch(_){if(eu(_))throw _;u("derive_wallet_failed",_),g=!0,f=void 0}if(!f)return g||u("missing_derived_wallet"),m();let p;try{const _=i??await d.getSigningClient(t);p=await d.computeAutoSignFee({chainId:t,messages:s,memo:o,derivedWallet:f,preferredFeeDenom:r,fallbackFeeDenom:a.amount[0]?.denom,client:_})}catch(_){return u("fee_computation_failed",_),m()}try{return await d.signWithDerivedWallet(t,e,s,p,o,f)}catch(_){return u("derived_wallet_sign_failed",_),m()}}function Qi(){const e=se(),{autoSignFeePolicy:t}=ne(),s=Je(),o=pa(),a=no(),r=rs(),i=Ld(),{getWallet:c,deriveWallet:l,getWalletPrivateKey:d}=to(),m=Mi(),u=qn(),h=p=>{const _=t?.[p];return{gasMultiplier:_?.gasMultiplier??Gd,maxGasMultiplierFromSim:_?.maxGasMultiplierFromSim??Yd,allowedFeeDenoms:_?.allowedFeeDenoms}},f=async({chainId:p,messages:_,memo:x,derivedWallet:b,preferredFeeDenom:j,fallbackFeeDenom:w,client:v})=>{const k=s(p),T=await Wi(k),A=Xd({derivedAddress:b.address,messages:_,encoder:r}).messages.map(Q=>r.encodeAsAny(Q)),L=pi(ma(b.publicKey)),{sequence:N}=await Li({getSequence:Q=>v.getSequence(Q),signerAddress:b.address,incrementSequence:0,allowMissingAccount:!0}),I=await o(p),B=Ee.QueryClient.withExtensions(I,Ee.setupTxExtension),{gasInfo:q}=await tu({queryClient:B,messages:A,memo:x,pubkey:L,sequence:N}),P=q?Number(q.gasUsed.toString()):0,F=h(p);return Jd({simulatedGas:P,gasPrices:T,preferredFeeDenom:j,fallbackFeeDenom:w,policy:F})},g=async(p,_,x,b,j,w)=>{let v=w??c(p);v||(v=await l(p));const k=d(p);if(!k)throw new Error("Derived wallet key not initialized");return await _d({chainId:p,granterAddress:_,messages:x,fee:b,memo:j,derivedWallet:v,privateKey:k,encoder:r,signWithEthSecp256k1:m})};return p=>su({...p,address:e},{validateAutoSign:i,getWallet:c,deriveWallet:l,getSigningClient:a,computeAutoSignFee:f,signWithDerivedWallet:g,signWithEthSecp256k1:m,onAutoSignFallback:({chainId:_,reason:x,errorMessage:b})=>{u("AutoSign Fallback",{chainId:_,reason:x,errorMessage:b})}})}function Gi(){const e=H.useAtomValue(ao);if(!e)throw new Error("Tx request not found");return e}function ro(){const e=Se(),t=se(),{defaultChainId:s,registryUrl:o}=ne(),a=Je(),{openDrawer:r,closeDrawer:i}=qt(),{openModal:c,closeModal:l}=oo(),d=H.useSetAtom(ao),m=H.useSetAtom(Hi),u=pa(),h=no(),f=cs(),g=rs(),p=Qi(),_=async({messages:A,memo:L,chainId:N=s})=>{try{return await(await h(N)).simulate(t,A,L)}catch(I){throw await Nn(I,a(N),o)}},x=async({messages:A,memo:L,chainId:N=s})=>{const I=await u(N),B=Ee.QueryClient.withExtensions(I,Ee.setupTxExtension),q=A.map(O=>g.encodeAsAny(O)),[P]=await f.getAccounts(),F=Tn.encodeSecp256k1Pubkey(P.pubkey),Q=await h(N),{sequence:W}=await Q.getSequence(t);return B.tx.simulate(q,L,F,W)},b=async({txRequest:A,broadcaster:L})=>{const I={...{memo:"",chainId:s,gas:A.gas||await _(A),gasAdjustment:pn,gasPrices:null,spendCoins:[],internal:!1},...A};return new Promise((B,q)=>{d({txRequest:I,resolve:async F=>{try{const Q=await h(I.chainId),W=await L(Q,Ge.TxRaw.encode(F).finish());B(W),typeof I.internal=="string"&&e(I.internal)}catch(Q){q(await Nn(Q,a(I.chainId),o))}finally{P()}},reject:F=>{q(F),P()}}),I.internal?c({path:"/tx"}):r("/tx");const P=()=>{if(!I.internal){e("/blank"),i();return}l()}})},j=async A=>{const L=A.chainId??s;try{const N=await b({txRequest:A,broadcaster:async(I,B)=>await I.broadcastTxSync(B)});return A.internal&&typeof A.internal!="number"&&(m({txHash:N,chainId:L,status:"loading"}),M({txHash:N,chainId:A.chainId}).then(I=>{m({status:I.code===0?"success":"error",chainId:L,txHash:N})}).catch(()=>{m({status:"error",chainId:L,txHash:N})})),N}catch(N){throw A.internal&&typeof A.internal!="number"&&m({status:"error",chainId:L,error:N}),N}},w=(A,L=30*1e3,N=.5*1e3)=>b({txRequest:A,broadcaster:async(I,B)=>{const q=await I.broadcastTx(B,L,N);if(q.code!==0)throw new Error(q.rawLog);return q}}),v=async({chainId:A,messages:L,memo:N="",fee:I,preferredFeeDenom:B})=>{const q=await h(A),P=await p({chainId:A,messages:L,memo:N,fee:I,preferredFeeDenom:B,client:q,allowWalletDerivation:!0});return{client:q,signedTx:P}},k=async A=>{const L=A.chainId??s;try{const{client:N,signedTx:I}=await v({...A,chainId:L});return await N.broadcastTxSync(Ge.TxRaw.encode(I).finish())}catch(N){throw await Nn(N,a(L),o)}},T=async(A,L=30*1e3,N=.5*1e3)=>{const I=A.chainId??s;try{const{client:B,signedTx:q}=await v({...A,chainId:I}),P=await B.broadcastTx(Ge.TxRaw.encode(q).finish(),L,N);if(P.code!==0)throw new Error(P.rawLog);return P}catch(B){throw await Nn(B,a(I),o)}},M=async({chainId:A=s,...L})=>{try{const N=await h(A);return await Yi({...L,client:N})}catch(N){throw N instanceof un?N:await Nn(N,a(A),o)}};return{estimateGas:_,simulateTx:x,requestTxSync:j,requestTxBlock:w,submitTxSync:k,submitTxBlock:T,waitForTxConfirmation:M}}async function Yi({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 un(`Transaction was submitted, but not found on the chain within ${s/1e3} seconds.`);await new Promise(i=>setTimeout(i,o))}}const ou="/cosmos.authz.v1beta1.MsgExec";function au(e){if(e.explicitGrantee)return[e.explicitGrantee];const t=[e.cachedDerivedAddress,e.statusGrantee,e.refetchedStatusGrantee].filter(s=>!!s);return[...new Set(t)]}function ru(e){const t=[e.currentGrantee,e.expectedGrantee].filter(s=>!!s);return[...new Set(t)]}function iu(e){const{isEnabledOnTargetChain:t,hasEnabledSibling:s,didBroadcast:o,hasExplicitGrantee:a}=e;return s?!1:t===!1?!0:t===void 0&&o&&!a}function cu(e){return[...new Set(e.map(t=>t.authorization.msg))].filter(t=>!!t)}async function Zi(e){const t=[Fs.expirations._def,Fs.grants._def];for(const s of t)await e.invalidateQueries({queryKey:s})}function Ji(){const e=se(),{fetchFeegrant:t,fetchGrants:s}=Bi();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:Jr.MsgRevokeAllowance.fromPartial({granter:e,grantee:r})}]:[],m=cu(c).map(u=>({typeUrl:"/cosmos.authz.v1beta1.MsgRevoke",value:ra.MsgRevoke.fromPartial({granter:e,grantee:r,msgTypeUrl:u})}));return[...l,...m]}}function lu(){const e=se(),t=ga(),{requestTxBlock:s}=ro(),o=S.useQueryClient(),[a,r]=H.useAtom(as),{closeDrawer:i}=qt(),c=Ji(),{deriveWallet:l}=to();return S.useMutation({mutationFn:async d=>{if(!a)throw new Error("No pending request");const{chainId:m}=a;if(!e)throw new Error("Wallet not connected");const u=t[m];if(!u||u.length===0)throw new Error(`No message types configured for chain ${m}`);const h=await l(m);Td(e,m);const f=ha(e,m),g=ru({currentGrantee:h.address,expectedGrantee:f}),_=(await Promise.all(g.map(k=>c({chainId:m,grantee:k})))).flat(),x=d===0?void 0:Ze.addMilliseconds(new Date,d),b={typeUrl:"/cosmos.feegrant.v1beta1.BasicAllowance",value:an.BasicAllowance.encode(an.BasicAllowance.fromPartial({expiration:x})).finish()},j={typeUrl:"/cosmos.feegrant.v1beta1.MsgGrantAllowance",value:Jr.MsgGrantAllowance.fromPartial({granter:e,grantee:h.address,allowance:{typeUrl:"/cosmos.feegrant.v1beta1.AllowedMsgAllowance",value:an.AllowedMsgAllowance.encode(an.AllowedMsgAllowance.fromPartial({allowance:b,allowedMessages:[ou]})).finish()}})},w=u.map(k=>({typeUrl:"/cosmos.authz.v1beta1.MsgGrant",value:ra.MsgGrant.fromPartial({granter:e,grantee:h.address,grant:{authorization:{typeUrl:"/cosmos.authz.v1beta1.GenericAuthorization",value:Za.GenericAuthorization.encode(Za.GenericAuthorization.fromPartial({msg:k})).finish()},expiration:x}})})),v=[..._,j,...w];return await s({messages:v,chainId:m,internal:!0}),{chainId:m,derivedWallet:h}},onSuccess:async({chainId:d,derivedWallet:m})=>{e&&md(e,d,m.address),await Zi(o),a?.resolve()},onError:d=>{a?.reject(d)},onSettled:()=>{r(null),i()}})}function Xi(e){const t=ne(),s=he(),o=Je(),{getWallet:a,clearWallet:r}=to(),{requestTxBlock:i}=ro(),c=S.useQueryClient(),l=Ji(),{data:d,refetch:m}=so();return S.useMutation({mutationFn:async(u=t.defaultChainId)=>{const h=a(u),f=d?.granteeByChain[u];let g;e?.grantee||(g=(await m()).data?.granteeByChain[u]);const p=au({explicitGrantee:e?.grantee,cachedDerivedAddress:h?.address,statusGrantee:f,refetchedStatusGrantee:g});if(p.length===0)throw new Error("No grantee address available");const x=(await Promise.all(p.map(b=>l({chainId:u,grantee:b})))).flat();return x.length===0?{chainId:u,didBroadcast:!1}:(await i({messages:x,chainId:u,internal:e?.internal}),{chainId:u,didBroadcast:!0})},onSuccess:async({chainId:u,didBroadcast:h})=>{await Zi(c);const f=o(u),g=s.filter(w=>w.bech32_prefix===f.bech32_prefix).map(w=>w.chain_id).filter(w=>w!==u);let p;try{p=(await m()).data}catch{p=void 0}const _=p??d;let x=!1;g.length>0&&_&&(x=g.some(w=>_?.isEnabledByChain[w]));const b=h?p?.isEnabledByChain[u]:(p??d)?.isEnabledByChain[u];iu({isEnabledOnTargetChain:b,hasEnabledSibling:x,didBroadcast:h,hasExplicitGrantee:!!e?.grantee})&&r(u)}})}function du(){const{defaultChainId:e}=ne(),{openDrawer:t}=qt(),s=H.useSetAtom(as),o=Xi(),{data:a={expiredAtByChain:{},isEnabledByChain:{},granteeByChain:{}},isLoading:r}=so();return{...a,isLoading:r,enable:async(l=e)=>new Promise((d,m)=>{s({chainId:l,resolve:d,reject:m}),t("/autosign/enable")}),disable:async(l=e)=>{await o.mutateAsync(l)}}}function ec(e){return e.assets.reduce((t,{value:s})=>t+(s??0),0)}function uu(e){return e.assets.reduce((t,{quantity:s})=>t.plus(s),U(0)).toString()}function mu(e,t){return{symbol:t?.symbol??e,logoUrl:t?.logoUrl??da}}function or(e){return $.pick(["chainId","name","logoUrl"],e)}function hu(e){return $.sortWith([$.descend(({symbol:t})=>t===mt),$.descend(ec),$.descend(({assets:t})=>t.length),$.ascend(({symbol:t})=>t)])(e)}function fu(e){return $.sortWith([$.descend(({value:t})=>t??0),$.descend(({quantity:t})=>Number(t)),$.ascend(({chain:t})=>t.name)])(e)}function pu(e,t){return $.sortWith([$.descend(({chain:s})=>s.chainId===t),$.ascend(({chain:s})=>s.name),$.ascend(({denom:s})=>s)])(e)}function gu(e,t){return $.sortWith([$.descend(({chainId:s})=>s===t),$.descend($.prop("value"))])(e)}function _u(e,t,s,o,a){const r=e.find(u=>u.metadata?.is_l1)?.chainId,i={};for(const u of e){const h=u.chainId,f=t[h]??[],g=s[h],p=o[h],_=[];for(const{amount:x,denom:b}of f){if(!U(x).gt(0))continue;const j=g?.find(M=>M.denom===b),w=p?.find(M=>M.id===b)?.price,v=j?.decimals??0,k=C.fromBaseUnit(x,{decimals:v}),T=w?U(k).times(w).toNumber():void 0;_.push({...mu(b,j),amount:x,denom:b,decimals:v,quantity:k,price:w,value:T,address:j?.address,unlisted:!j,chain:or(u)})}i[h]=_}const c=new Map;for(const[u,h]of Object.entries(i)){if(h.length===0)continue;const f=e.find(p=>p.chainId===u);if(!f)continue;const g=h.reduce((p,{value:_})=>p+(_??0),0);c.set(u,{...or(f),value:g})}const l=new Map;for(const u of Object.values(i))for(const h of u)if(!h.unlisted){const{symbol:f}=h,g=l.get(f)??[];l.set(f,[...g,h])}const d=[];for(const[u,h]of l){const f=$.head(h);if(!f)continue;const g=fu(h),p=g.reduce((x,{value:b})=>x+(b??0),0),_=g.reduce((x,{quantity:b})=>x.plus(b),U(0)).toNumber();d.push({symbol:u,logoUrl:f.logoUrl,assets:g,totalValue:p,totalAmount:_})}const m=[];for(const u of Object.values(i))for(const h of u)h.unlisted&&m.push(h);return{chainsByValue:gu(Array.from(c.values()),a),assetGroups:hu(d),unlistedAssets:pu(m,r),totalValue:d.reduce((u,h)=>u+h.totalValue,0)}}function ba(){const{defaultChainId:e}=ne(),t=he(),s=zl(),o=ss(),a=la(),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=_u(t,i,c,l,e),m=[s,o,a].flat().some(({isLoading:h})=>h);return{...d,isLoading:m,refetch:()=>{s.forEach(({refetch:h})=>h()),o.forEach(({refetch:h})=>h()),a.forEach(({refetch:h})=>h())}}}function se(){const e=Rn();return e?C.InitiaAddress(e).bech32:""}function Rn(){const{address:e}=We.useAccount();return e?C.InitiaAddress(e).hex:""}function Qt(){const e=yn(),t=se(),s=Rn();return e.metadata?.minitia?.type==="minievm"?s:t}function tc(e){const t=Qt(),s=e??t,o=li();return S.useQuery({queryKey:Zs.username(o.restUrl,s).queryKey,queryFn:()=>o.getUsername(s),enabled:!!s,staleTime:K.MINUTE})}function et(){const e=Qt(),t=se(),s=Rn(),{data:o}=tc(),a=cs(),r=Ii(),i=du(),{isDrawerOpen:c,openDrawer:l}=qt(),{isModalOpen:d}=Pn(),m=()=>{l("/")},u=()=>{l("/connect")},h=b=>{l("/bridge",b)},f=vd(),g=jd(),p=ro();return{address:e,initiaAddress:t,hexAddress:s,username:o,offlineSigner:a,isConnected:!!e,isOpen:c||d,openConnect:u,openWallet:m,openBridge:h,openDeposit:f,openWithdraw:g,disconnect:r,autoSign:i,...p}}const yu="_status_tn9m1_1",xu="_error_tn9m1_9",ar={status:yu,error:xu},be=({error:e,children:t})=>n.jsx("p",{className:D(ar.status,{[ar.error]:e}),role:e?"alert":"status",children:t}),pe=({errorBoundaryProps:e={fallbackRender:({error:o})=>n.jsx(be,{error:!0,children:o.message})},suspenseFallback:t=n.jsx(be,{children:"Loading..."}),children:s})=>n.jsx(Xr.ErrorBoundary,{...e,children:n.jsx(y.Suspense,{fallback:t,children:s})}),gn=1n<<64n,bu=1n<<63n,nc=(1n<<128n)-1n;function Ht(e){const t=BigInt(e);return t>=bu?t-gn:t}const wu=(1n<<256n)-1n,Kt=443636n,vu=4295048017n,ju=18446744073709551616n,Cu=79226673515401279992447579062n,Nu=255738958999603826347141n;function ku(e,t,s){const o=Number(Ht(e)),a=Number(Ht(t)),r=Math.floor(-Number(Kt)/s)*s,i=Math.floor(Number(Kt)/s)*s;return o===r&&a===i}function sc(e){return e>>64n}function Iu(e){const t=e>>64n;return e%gn!==0n?t+1n:t}function $n(e){if(e<0n||e>nc)throw new Error("INPUT_OUT_OF_RANGE");return e}function Au(e,t){const s=e*t>>64n;if(s>nc)throw new Error("OVERFLOW");return s}function wa(e,t){return e>t?[t,e]:[e,t]}function Su(e,t,s,o){if(e===t)return 0n;const[a,r]=wa(e,t);if(a===0n||r===0n)return 0n;const i=s*gn,c=r-a,l=i*c;if(l===0n)return 0n;const d=a*r;return o?(l-1n)/d+1n:l/d}function Tu(e,t,s,o){if(e===t)return 0n;const[a,r]=wa(e,t),c=(r-a)*s;return o?Iu($n(c)):sc($n(c))}function rr(e,t,s){return Su(e,t,s<0n?-s:s,s>=0n)}function ir(e,t,s){return Tu(e,t,s<0n?-s:s,s>=0n)}const Co=1n<<64n,cr=1n<<65n,Eu=64n;function $u(e){if(e<=0n)throw new Error("LOG_2_ZERO_UNBOUNDED");let t=e,s=0n,o=0n,a=1n<<Eu-1n,r=0n,i=1;for(;t>=cr;)t>>=1n,s+=Co;for(;t<Co;)i=0,t<<=1n,o+=Co;for(;r<62n;){const l=t>>1n;t=l*l>>62n,t>=cr&&(t>>=1n,s+=a),a>>=1n,r+=1n}const c=i>0?$n(s):$n(o-s);return[i,c]}function Wt(e){const t=e<0n?-e:e;if(t>Kt)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=wu/s);const o=s/gn;return s%gn!==0n?o+1n:o}function Mu(e){if(e<vu||e>=Cu)throw new Error("INVALID_SQRT_PRICE");const[,t]=$u($n(e)),s=Au(t,$n(Nu)),o=sc(s);let a,r,i;if(o===0n?(a=-1n,r=0n,i=1n):e<ju?(a=-o-1n,r=-o,i=-o+1n):(a=o-1n,r=o,i=o+1n),a<-Kt&&(a=-Kt),i>Kt&&(i=Kt),Wt(i)<=e){if(i>=Kt)throw new Error("GTE_MAX_TICK");if(Wt(i+1n)<=e)throw new Error("NO_SAFE_TICK_FOUND");return i}if(Wt(r)<=e)return r;if(Wt(a)<=e)return a;throw new Error("NO_SAFE_TICK_FOUND")}function Lu(e,t,s,o){const[a,r]=wa(t,s);return e<a?[rr(a,r,o),0n]:e<r?[rr(e,r,o),ir(a,e,o)]:[0n,ir(a,r,o)]}function qu({tickLower:e,tickUpper:t,liquidity:s,sqrtPrice:o}){const a=Wt(Ht(e)),r=Wt(Ht(t));return Lu(BigInt(o),BigInt(a),BigInt(r),BigInt(s))}const No=gn*gn,Pu=1e-300,Ru=BigInt(Number.MAX_SAFE_INTEGER);function lr(e){const t=e*e,s=t/No,o=t%No;return s>Ru?Number(s):Number(s)+Number(o)/Number(No)}function dr(e){if(!Number.isFinite(e)||e<0)throw new Error("calculateTokens: price must be finite and non-negative");return 1/Math.max(e,Pu)}function Du({tickLower:e,tickUpper:t,isReversed:s=!1}){const o=Wt(Ht(e)),a=Wt(Ht(t)),r=lr(o),i=lr(a);return s?{min:dr(i),max:dr(r)}:{min:r,max:i}}const xn=$e.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]}),va={lens:"lens",pool:"pool",farming:"farming"},ja={"interwoven-1":{clammModuleAddress:"0xd78a3b72c7ef0cfba7286bfb8c618aa4d6011dce05a832871cc9ab323c25f55e",incentiveModuleAddress:"0xcb2999c70a9b8db7cb473255bb01f956f0726087f08b04ece50844a6d8167351"},"initiation-2":{clammModuleAddress:"0x6b41bf295bc31cd9bef75a9a5a67e5a8d6749b34a7ab3105808251fa2697823d",incentiveModuleAddress:"0xf8ef0cb7c73607b7658524565015ce2aadc45ccf7164e5351959a4d7a1c37753"}};function Bu(e){return e.startsWith("0x")?`0x${e.replace(/^0x/,"").padStart(64,"0")}`:C.InitiaAddress(e).hex}function Us(e){return ae.toBase64(C.InitiaAddress(Bu(e),32).bytes)}function oc(e,t){return`${e}:${t}`}function Fu(e){return`clamm:${e}`}function Uu(e){return!Array.isArray(e)||e.length===0?[]:Array.isArray(e[0])?e.flat():e}function Ou(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 Vu(e){const{dexUrl:t}=ne();return S.useSuspenseQuery({queryKey:xn.clammPositions(t,e).queryKey,queryFn:async()=>{if(!e)return[];const s=[];let o;do{const a={"pagination.limit":"100"};o&&(a["pagination.key"]=o);const r=await z.get(`${t}/indexer/clamm/v1/positions/${e}`,{searchParams:a}).json().catch(()=>({positions:[],pagination:{next_key:null,total:"0"}}));s.push(...Uu(r.positions)),o=r.pagination.next_key||void 0}while(o);return Ou(s)},staleTime:K.MINUTE})}function Ku(e){const t=oe(),{viewFunction:s}=C.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:xn.clammPoolInfo(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=ja[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:va.lens,functionName:"get_pool_info",typeArgs:[],args:[Us(r)]});return!c?.sqrt_price||!c?.tick_spacing?null:{sqrtPrice:c.sqrt_price,tickSpacing:c.tick_spacing}}catch{return null}},staleTime:K.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 Wu(e){const t=oe(),{viewFunction:s}=C.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:xn.clammFees(t.restUrl,t.chainId,r).queryKey,queryFn:async()=>{const i=ja[t.chainId];if(!i)return null;try{const c=await s({moduleAddress:i.clammModuleAddress,moduleName:va.pool,functionName:"fees_available",typeArgs:[],args:[Us(r)]});return Array.isArray(c)?c:null}catch{return null}},staleTime:K.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 zu(e){const t=oe(),{viewFunction:s}=C.createMoveClient(t.restUrl),a=S.useSuspenseQueries({queries:e.map(r=>({queryKey:xn.clammIncentive(t.restUrl,t.chainId,r.tokenAddress,r.incentiveAddress).queryKey,queryFn:async()=>{const i=ja[t.chainId];if(!i)return"0";try{const c=await s({moduleAddress:i.incentiveModuleAddress,moduleName:va.farming,functionName:"pending_reward_info",typeArgs:[],args:[Us(r.tokenAddress),Us(r.incentiveAddress)]});return typeof c=="string"?c:Array.isArray(c)&&typeof c[0]=="string"?c[0]:"0"}catch{return"0"}},staleTime:K.MINUTE}))}).map(r=>r.data);return y.useMemo(()=>{const r=new Map;return e.forEach((i,c)=>{r.set(oc(i.tokenAddress,i.incentiveAddress),a[c]||"0")}),r},[e,a])}function ac(e){const{dexUrl:t}=ne(),o=S.useSuspenseQueries({queries:e.map(a=>({queryKey:xn.poolByMetadata(t,a).queryKey,queryFn:async()=>{try{return(await z.get(`${t}/indexer/dex/v2/pools/${encodeURIComponent(a)}`).json()).pool}catch{return null}},staleTime:K.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 rc(e,t){return!e?.coins||e.coins.length===0?[]:e.coins.map(s=>t.get(s.denom)?.logoUrl||"")}function Hu(e){return ac(e)}function Qu(e){const t=oe(),s=zt(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=>C.denomToMetadata(i)),[e]),r=ac(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 m=r.get(d);if(!m){i.set(c,null);return}if(c===yd){i.set(c,{...m,symbol:xd});return}const u=m.coins.map(h=>o.get(h.denom)?.symbol||h.denom).join("-");i.set(c,{...m,symbol:u})}),i},[e,a,r,o])}const Gu="lock_staking";function ic(e,t){const s=`${t}::lock_staking::StakingAccount`,o=C.createObjectAddress(e,s);return C.InitiaAddress(o).bech32}const ls=$e.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 Ca(){const{restUrl:e}=oe(),t=se();return S.useSuspenseQuery({queryKey:ls.delegations(e,t||"").queryKey,queryFn:async()=>t?(await z.get(`${e}/initia/mstaking/v1/delegations/${t}`).json()).delegation_responses:[],select:s=>{const o=new Map;for(const a of s){const r=a.delegation.validator_address;for(const i of a.balance){const c=C.denomToMetadata(i.denom),l={denom:i.denom,metadata:c,amount:i.amount,validator:r},d=o.get(c)??[];d.push(l),o.set(c,d)}}return o},staleTime:K.MINUTE})}function Na(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=ne(),s=se(),o=s?ic(s,t):"";return S.useSuspenseQuery({queryKey:ls.undelegations(e,s||"",o).queryKey,queryFn:async()=>{if(!s)return[];const a=await z.get(`${e}/initia/mstaking/v1/delegators/${s}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]})),r=await z.get(`${e}/initia/mstaking/v1/delegators/${o}/unbonding_delegations`).json().catch(()=>({unbonding_responses:[]}));return[...a.unbonding_responses,...r.unbonding_responses]},select:a=>{const r=new Map;for(const i of a){const c=i.validator_address;for(const l of i.entries)for(const d of l.balance){const m=C.denomToMetadata(d.denom),u={denom:d.denom,metadata:m,amount:d.amount,validator:c,completionTime:l.completion_time},h=r.get(m)??[];h.push(u),r.set(m,h)}}return r},staleTime:K.MINUTE})}function ka(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=ne(),s=se();return S.useSuspenseQuery({queryKey:ls.lockStaking(e,s||"",t).queryKey,queryFn:async()=>{if(!s)return[];const{viewFunction:o}=C.createMoveClient(e);return await o({moduleAddress:t,moduleName:Gu,functionName:"get_locked_delegations",typeArgs:[],args:[ae.toBase64(C.InitiaAddress(s,32).bytes)]})??[]},select:o=>{const a=new Map;for(const r of o){const i={metadata:r.metadata,amount:r.amount,validator:r.validator,releaseTime:r.release_time},c=a.get(r.metadata)??[];c.push(i),a.set(r.metadata,c)}return a},staleTime:K.MINUTE})}function cc(e){const t=new Map;if(!e.total||!Array.isArray(e.total))return t;for(const s of e.total){if(!s?.denom||!s?.dec_coins)continue;const o=C.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 lc(){const{restUrl:e}=oe(),t=se();return S.useSuspenseQuery({queryKey:ls.stakingRewards(e,t||"").queryKey,queryFn:async()=>t?await z.get(`${e}/initia/distribution/v1/delegators/${t}/rewards`).json():{rewards:[],total:[]},select:cc,staleTime:K.MINUTE})}function dc(){const{restUrl:e}=oe(),{lockStakeModuleAddress:t}=ne(),s=se(),o=s?ic(s,t):"";return S.useSuspenseQuery({queryKey:ls.lockStakingRewards(e,s??"",o).queryKey,queryFn:async()=>s?await z.get(`${e}/initia/distribution/v1/delegators/${o}/rewards`).json():{rewards:[],total:[]},select:cc,staleTime:K.MINUTE})}function Ia(){const e=oe(),t=zt(e),{data:s,isLoading:o}=Lt(e),{data:a}=Ca(),{data:r}=Na(),{data:i}=ka(),c=y.useMemo(()=>{const f=new Set;for(const g of a.keys())f.add(g);for(const g of i.keys())f.add(g);for(const g of r.keys())f.add(g);return Array.from(f)},[a,i,r]),l=Ps(c),d=y.useMemo(()=>{const f=new Map;if(s)for(const g of s)f.set(g.id,g.price);return f},[s]),m=y.useMemo(()=>{const f=new Map;for(const g of t)f.set(g.denom,g);return f},[t]),u=y.useMemo(()=>{const f=[],g=p=>{const _=m.get(p);return _?{symbol:_.symbol,decimals:_.decimals}:null};for(const[p,_]of a){const x=l.get(p)??_[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=d.get(x)??0;for(const w of _){const{symbol:v,decimals:k}=b,T=Number(C.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:x,symbol:v,amount:w.amount,formattedAmount:T,decimals:k,value:T*j};f.push({type:"staking",validator:w.validator,balance:M})}}for(const[p,_]of i){const x=l.get(p);if(!x)continue;const b=g(x);if(!b)continue;const j=d.get(x)??0;for(const w of _){const{symbol:v,decimals:k}=b,T=Number(C.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:x,symbol:v,amount:w.amount,formattedAmount:T,decimals:k,value:T*j},A=Number(w.releaseTime);f.push({type:"lockstaking",validator:w.validator,releaseTime:Number.isNaN(A)?0:A,balance:M})}}for(const[p,_]of r){const x=l.get(p)??_[0]?.denom;if(!x)continue;const b=g(x);if(!b)continue;const j=d.get(x)??0;for(const w of _){const{symbol:v,decimals:k}=b,T=Number(C.fromBaseUnit(w.amount,{decimals:k})),M={type:"asset",denom:x,symbol:v,amount:w.amount,formattedAmount:T,decimals:k,value:T*j},A=new Date(w.completionTime).getTime(),L=Number.isNaN(A)?0:Math.floor(A/1e3);f.push({type:"unstaking",validator:w.validator,completionTime:L,balance:M})}}return f.filter(p=>p.type!=="fungible-position"&&p.balance.denom===Ye)},[a,i,r,l,m,d]),h=y.useMemo(()=>u.reduce((f,g)=>g.type==="fungible-position"||g.balance.type==="unknown"?f:f+(g.balance.value??0),0),[u]);return{positions:u,totalValue:h,isLoading:o}}function Yu(e){const t=new Map;for(const s of e){const o=C.denomToMetadata(s.denom),a={...s,metadata:o},r=t.get(o)??[];r.push(a),t.set(o,r)}return t}function Zu(e,t){return e.map(s=>t.get(s)?.symbol||s).join("/")}function Ju(e){const{dexUrl:t}=ne();return S.useSuspenseQuery({queryKey:xn.checkLpTokens(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.post(`${t}/indexer/dex/v1/check_lp_tokens`,{json:{denoms:e}}).json();return new Map(Object.entries(s.data))},staleTime:K.MINUTE})}function Xu(){const e=oe(),t=os(e),s=y.useMemo(()=>t.map(a=>a.denom),[t]),{data:o}=Ju(s);return y.useMemo(()=>{const a=t.filter(r=>o.get(r.denom)===!0);return Yu(a)},[t,o])}function em(e){const{dexUrl:t}=ne();return S.useSuspenseQuery({queryKey:xn.lpPrices(t,e).queryKey,queryFn:async()=>{if(e.length===0)return new Map;const s=await z.get(`${t}/indexer/price/v1/lp_prices/${encodeURIComponent(e.join(","))}`).json(),{prices:o}=s;return Array.isArray(o)?new Map(o.map(({denom:a,price:r})=>[a,r])):new Map(Object.entries(o))},staleTime:K.MINUTE})}function tm(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!==Ye&&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!==Ye&&a.add(r)}return Array.from(a)}function nm(e){const t=[];for(const[,s]of e)s&&s!==Ye&&t.push(s);return t}function sm(e,t,s){const o=t.get(e)??null,a=o?.symbol||e,r=rc(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 ko(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r)??i[0]?.denom;if(!c||c===Ye)continue;const l=o.get(c);if(l)for(const d of i){const m=l.decimals,u=Number(C.fromBaseUnit(String(d.amount),{decimals:m})),h=s.get(c)??0,f=u*h;l.breakdown[a]+=u,l.totalAmount+=u,l.totalValue+=f}}}function om(e,t,s,o,a){for(const[r,i]of e){const c=t.get(r);if(!c||c===Ye)continue;const l=o.get(c);if(l)for(const d of i){const m=l.decimals,u=Number(C.fromBaseUnit(String(d.amount),{decimals:m})),h=s.get(c)??0,f=u*h;l.breakdown[a]+=u,l.totalAmount+=u,l.totalValue+=f}}}function am(e,t,s,o){for(const[a,r]of e){const i=C.denomToMetadata(a),c=t?.get(i),l=c?C.fromBaseUnit(c.amount,{decimals:rt}):"0",d=s?.get(i),m=d?C.fromBaseUnit(d.amount,{decimals:rt}):"0",u=Number(l)+Number(m);u<=0||(r.claimableInit={staking:l,lockStaking:m,total:String(u),totalValue:u*o})}}function rm(e){return`#${e.replace(/^0x/,"").slice(-6)}`}function io(){const e=oe(),t=zt(e),s=se(),o=Xu(),{data:a}=Ca(),{data:r}=ka(),{data:i}=Na(),{data:c}=lc(),{data:l}=dc(),{data:d}=Lt(e),{data:m}=Vu(s),u=y.useMemo(()=>{const q=new Map;for(const P of m){const F=q.get(P.lpMetadata)??[];F.push(P),q.set(P.lpMetadata,F)}return q},[m]),h=y.useMemo(()=>Array.from(u.keys()),[u]),f=Hu(h),g=Ku(h),p=y.useMemo(()=>m.map(q=>q.tokenAddress),[m]),_=Wu(p),x=y.useMemo(()=>{const q=[];for(const P of m)for(const F of P.incentives)q.push({tokenAddress:P.tokenAddress,incentiveAddress:F.incentiveAddress});return q},[m]),b=zu(x),j=y.useMemo(()=>{const q=new Set;for(const P of m)for(const F of P.incentives)q.add(F.rewardMetadata);return Array.from(q)},[m]),w=Ps(j,{failSoft:!0}),v=y.useMemo(()=>tm(o,a,r,i),[o,a,r,i]),k=Ps(v),T=y.useMemo(()=>nm(k),[k]),{data:M}=em(T),A=Qu(T),L=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:B}=y.useMemo(()=>{const q=d?.find(W=>W.id===Ye)?.price??0,P=new Map;for(const W of T)P.set(W,sm(W,A,L));ko(o,k,M,P,"deposit"),ko(a,k,M,P,"staking"),om(r,k,M,P,"lockStaking"),ko(i,k,M,P,"unstaking"),am(P,c,l,q);for(const W of h){const O=u.get(W)??[];if(O.length===0)continue;const me=f.get(W),ge=g.get(W),ce=Fu(W),ye=me?.coins.map(re=>re.denom)??[],we=me?rc(me,L).filter(Boolean):[],ve=ye.map(re=>L.get(re)?.symbol||re),tt=me?.symbol||ve.join("-")||ce,Rt=Zu(ye,L),Tt=O.map(re=>{let Be,Dt,Bt,_e=!1,Pe=0,gt=0;try{const He=Du({tickLower:re.tickLower,tickUpper:re.tickUpper});Be=He.min,Dt=He.max}catch{Be=void 0,Dt=void 0}if(ge){try{const He=Mu(BigInt(ge.sqrtPrice)),Qe=Ht(re.tickLower),lt=Ht(re.tickUpper),Ne=Number(ge.tickSpacing);_e=Number.isFinite(Ne)&&Ne>0?ku(re.tickLower,re.tickUpper,Ne):!1,Bt=_e||He>=Qe&&He<lt}catch{Bt=void 0,_e=!1}if(me&&ye.length>0)try{qu({sqrtPrice:ge.sqrtPrice,tickLower:re.tickLower,tickUpper:re.tickUpper,liquidity:re.liquidity}).forEach((Qe,lt)=>{const Ne=me.coins[lt];if(!Ne)return;const Zt=L.get(Ne.denom)?.decimals??6,Jt=N.get(Ne.denom)??0,wn=Number(C.fromBaseUnit(String(Qe),{decimals:Zt}));Pe+=wn*Jt})}catch{Pe=0}}return me&&((_.get(re.tokenAddress)??[]).forEach((Qe,lt)=>{const Ne=me.coins[lt];if(!Ne)return;const Zt=L.get(Ne.denom)?.decimals??6,Jt=N.get(Ne.denom)??0,wn=Number(C.fromBaseUnit(Qe,{decimals:Zt}));gt+=wn*Jt}),re.incentives.forEach(Qe=>{const lt=b.get(oc(re.tokenAddress,Qe.incentiveAddress))??"0",Ne=w.get(Qe.rewardMetadata);if(!Ne)return;const Zt=L.get(Ne)?.decimals??6,Jt=N.get(Ne)??0,wn=Number(C.fromBaseUnit(lt,{decimals:Zt}));gt+=wn*Jt})),{tokenAddress:re.tokenAddress,positionId:rm(re.tokenAddress),inRange:Bt,isFullRange:_e,minPrice:Be,maxPrice:Dt,pricePairLabel:Rt,rewardValue:gt,value:Pe}}),qe=Tt.reduce((re,Be)=>re+Be.value,0),Y=Tt.reduce((re,Be)=>re+Be.rewardValue,0),ct=we.length>0;P.set(ce,{denom:ce,symbol:tt,totalAmount:0,totalValue:qe,decimals:6,poolType:"CLAMM",logoUrl:void 0,coinLogos:ct?we:void 0,breakdown:{deposit:0,staking:0,lockStaking:0,unstaking:0},isClamm:!0,clamm:{lpMetadata:W,totalRewardValue:Y,positions:Tt}})}const F=Array.from(P.values()).filter(W=>W.totalAmount>0||W.isClamm).sort((W,O)=>O.totalValue-W.totalValue),Q=F.reduce((W,O)=>W+O.totalValue,0);return{rows:F,totalValue:Q}},[d,T,A,L,o,a,r,i,k,M,c,l,h,u,f,g,_,b,w,N]);return{totalValue:B,rows:I}}const im=$e.createQueryKeys("interwovenkit:initia-vip",{allVestingPositions:(e,t)=>[e,t]});function cm(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 uc(){const{vipUrl:e}=ne(),t=se();return S.useQuery({queryKey:im.allVestingPositions(e,t).queryKey,queryFn:async()=>(await z.get(`${e}/vesting/positions/${t}`).json()).filter(({total_vesting_reward:o})=>o>0),staleTime:K.MINUTE,enabled:!!t})}function lm(){const e=he();return y.useCallback(t=>e.find(({metadata:s})=>s?.op_bridge_id===String(t)),[e])}function co(){const{data:e}=uc(),t=oe(),{data:s}=Lt(t),o=lm(),a=y.useMemo(()=>s?.find(l=>l.id===Ye)?.price??0,[s]),r=y.useMemo(()=>e?cm(e).map(l=>{const d=o(l.rollup.bridgeId),m=Number(C.fromBaseUnit(String(l.lockedReward),{decimals:rt})),u=Number(C.fromBaseUnit(String(l.claimableReward),{decimals:rt})),h=U(C.fromBaseUnit(String(l.lockedReward),{decimals:rt})).times(a).toNumber(),f=U(C.fromBaseUnit(String(l.claimableReward),{decimals:rt})).times(a).toNumber();return{bridgeId:l.rollup.bridgeId,version:l.rollup.version,name:d?.name??"",logoUrl:d?.logoUrl,lockedReward:m,lockedRewardValue:h,claimableReward:u,claimableRewardValue:f}}).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 mc(){const{totalValue:e}=io(),{data:t}=Ca(),{data:s}=ka(),{data:o}=Na(),{data:a}=uc(),r=y.useMemo(()=>Array.from(s.keys()),[s]),i=Ps(r),c=oe(),{data:l}=Lt(c),d=y.useMemo(()=>l?.find(u=>u.id===Ye)?.price??0,[l]);return y.useMemo(()=>{let m=0,u=0;const h=d??0;for(const[,g]of t)for(const{denom:p,amount:_}of g)p===Ye&&(m+=Number(C.fromBaseUnit(_,{decimals:rt}))*h);for(const[g,p]of s)if(i.get(g)===Ye)for(const{amount:_}of p)u+=Number(C.fromBaseUnit(_,{decimals:rt}))*h;for(const[,g]of o)for(const{denom:p,amount:_}of g)p===Ye&&(m+=Number(C.fromBaseUnit(_,{decimals:rt}))*h);let f=0;if(a)for(const g of a){const p=g.total_locked_reward??0,_=g.total_claimable_reward??0;f+=Number(C.fromBaseUnit(String(p+_),{decimals:rt}))*h}return m+u+e+f},[t,s,i,o,a,d,e])}function dm(){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=>C.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 Wo=$e.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 Aa(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 m=l.symbol.toUpperCase();o.has(m)||o.set(m,l.logoUrl)}}}return{denomLogos:s,symbolLogos:o}}function Mn(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 um(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 mm(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 hm(e){const t=new Map;for(const d of e){const m=um(d);if(!m)continue;const u=t.get(m)??[];u.push(d),t.set(m,u)}const s=new Map,o=new Map;for(const[d,m]of t){const u=m.reduce((f,g)=>f+Mn(g),0),h=m.reduce((f,g)=>f+Math.abs(Mn(g)),0);s.set(d,u),o.set(d,h)}const a=o.get("lending")??0,r=o.get("borrowing")??0,i=a+r,c=[...t.keys()].sort((d,m)=>{const u=d==="lending"||d==="borrowing"?i:o.get(d)??0,h=m==="lending"||m==="borrowing"?i:o.get(m)??0;return(d==="lending"||d==="borrowing")&&(m==="lending"||m==="borrowing")?d==="lending"?-1:1:h-u}),l=new Map;for(const d of c)l.set(d,{positions:t.get(d),totalValue:s.get(d)??0});return l}function fm(e){return e.type==="fungible-position"?e.title:e.balance.denom}function pm(e){return e.type==="fungible-position"?e.title:e.balance.type==="unknown"?e.balance.denom:e.balance.symbol}function gm(e){return e.type==="fungible-position"?null:e.balance}function _m(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 ym(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 xm(e,t){return e.symbol===mt&&t.symbol===mt?0:e.symbol===mt?-1:t.symbol===mt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function bm(e){const t=new Map;for(const o of e){const a=fm(o),r=t.get(a)??[];r.push(o),t.set(a,r)}return Array.from(t.entries()).map(([o,a])=>{const r=gm(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:pm(a[0]),positions:a,totalValue:a.reduce((c,l)=>c+Mn(l),0),totalAmount:i,balance:r}}).toSorted(xm)}function hc(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 wm(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 vm(e,t){return e.symbol===mt&&t.symbol===mt?0:e.symbol===mt?-1:t.symbol===mt?1:t.totalValue!==e.totalValue?t.totalValue-e.totalValue:e.symbol.localeCompare(t.symbol,void 0,{sensitivity:"base"})}function jm(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 Cm(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:m})=>m.toLowerCase().includes(d))}):e,a=s?o.map(i=>{const c=i.assets.filter(({chain:l})=>l.chainId===s);return{...i,assets:c,totalValue:c.reduce((l,d)=>l+(d.value??0),0),totalAmount:c.reduce((l,d)=>l+Number(d.quantity),0)}}).filter(i=>i.assets.length>0):o,r=a.reduce((i,c)=>i+c.assets.reduce((l,d)=>l+(d.value??0),0),0);return{filteredAssets:a,totalAssetsValue:r}}function Nm(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 km(e,t,s,o){const{filteredAssets:a,totalAssetsValue:r}=Cm(e,s,o),i=Nm(t,s,o);return{filteredAssets:a,totalAssetsValue:r,filteredUnlistedAssets:i}}function Im(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:m}=c;if(!Array.isArray(m))continue;const u=t.get(l.toLowerCase()),h=u?.chainId??d??l,f=u?.prettyName??l,g=u?.logoUrl??"",p=s.get(h);for(const _ of m){if(_.type==="unknown"){if(!_.amount||_.amount==="0")continue;r.push({symbol:_.denom,logoUrl:"",denom:_.denom,amount:_.amount,decimals:0,quantity:_.amount,value:void 0,unlisted:!0,chain:{chainId:h,name:f,logoUrl:g}});continue}if(_.type==="lp"||(_.value??0)<=0&&(_.formattedAmount??0)<=0)continue;let x=_.value;if((x==null||x<=0)&&p){const w=p.get(_.denom)??0;w>0&&(x=_.formattedAmount*w)}const b={symbol:_.symbol,logoUrl:"",denom:_.denom,amount:_.amount,decimals:_.decimals,quantity:String(_.formattedAmount),value:x,chain:{chainId:h,name:f,logoUrl:g}},j=a.get(_.symbol);j?j.push(b):a.set(_.symbol,[b])}}r.sort((c,l)=>{const d=c.chain.chainId===o,m=l.chain.chainId===o;if(d&&!m)return-1;if(!d&&m)return 1;const u=c.chain.name.localeCompare(l.chain.name);if(u!==0)return u;try{const h=BigInt(c.amount),f=BigInt(l.amount);if(h>f)return-1;if(h<f)return 1}catch{const h=c.amount.localeCompare(l.amount);if(h!==0)return-h}return c.denom.localeCompare(l.denom)});const i=[];for(const[c,l]of a){l.sort((u,h)=>(h.value??0)-(u.value??0));let d=0,m=0;for(const u of l)d+=u.value??0,m+=Number(u.quantity);i.push({symbol:c,logoUrl:"",assets:l,totalValue:d,totalAmount:m})}return i.sort(vm),{listedGroups:i,unlistedAssets:r}}function Sa(){return oe().network_type==="testnet"}function Gt(){return Ie.useFormContext()}function Am(){const e=Xe(),t=Sa(),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 Sm={balances:[],positions:[],isLoading:!0,isComplete:!1},fc=H.atom(0),Tm=1e3;let ur=0;function Em(){const e=H.useSetAtom(fc);y.useEffect(()=>{const t=Date.now();t-ur>=Tm&&(ur=t,e(s=>s+1))},[e])}function $m(){const e=S.useQueryClient(),t=se(),{minityUrl:s}=ne(),o=Sa(),a=H.useAtomValue(fc),r=y.useEffectEvent((l,d)=>{const m=Array.isArray(l.balances)?l.balances:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,balances:m})}),i=y.useEffectEvent((l,d)=>{const m=Array.isArray(l.positions)?l.positions:[];d.set(l.chain,{chainName:l.chain,chainId:l.chainId,positions:m})}),c=y.useEffectEvent((l,d)=>{const m=Wo.ssePortfolio(t??"",s).queryKey,u=e.getQueryData(m)??Sm,h=l.size>0||d.size>0;e.setQueryData(m,{...u,balances:Array.from(l.values()),positions:Array.from(d.values()),isLoading:h?!1:u.isLoading,isComplete:!1})});y.useEffect(()=>{if(!t||o)return;const l=Wo.ssePortfolio(t,s).queryKey,d=e.getQueryData(l),m=new Map,u=new Map;for(const _ of d?.balances??[])m.set(_.chainName,_);for(const _ of d?.positions??[])u.set(_.chainName,_);const f=`${s}/v1/chain/all/${encodeURIComponent(t)}`;let g=null,p=!1;return e.setQueryData(l,{balances:d?.balances??[],positions:d?.positions??[],isLoading:!0,isComplete:!1}),g=new EventSource(f),g.onmessage=_=>{if(!p)try{const x=JSON.parse(_.data);x.type==="balances"?r(x,m):x.type==="positions"&&i(x,u),c(m,u)}catch{}},g.onerror=()=>{g?.close()},()=>{p=!0,g?.close()}},[t,o,a])}const mr={balances:[],positions:[],isLoading:!0,isComplete:!1};function ds(){const e=se(),{minityUrl:t}=ne(),s=Wo.ssePortfolio(e??"",t).queryKey,{data:o}=S.useQuery({queryKey:s,queryFn:()=>mr,enabled:!!e,staleTime:K.MINUTE,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1});return o??mr}function Mm(){const e=he();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 Lm(){const{balances:e,positions:t}=ds(),s=he(),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((g,p)=>{if(p.type==="fungible-position")return g+(p.value??0);if(p.balance.type==="unknown")return g;const _=p.balance.value??0;return p.type==="lending"&&p.direction==="borrow"?g-_:g+_},0),c=new Map,l=Array.isArray(e)?e:[],d=Array.isArray(t)?t:[];for(const{chainName:f,balances:g}of l){if(!Array.isArray(g))continue;const p=g.reduce((_,x)=>_+r(x),0);c.set(f,(c.get(f)||0)+p)}for(const{chainName:f,positions:g}of d){if(!Array.isArray(g))continue;const p=g.reduce((_,x)=>_+i(x),0);c.set(f,(c.get(f)||0)+p)}const m=Array.from(c.values()).reduce((f,g)=>f+g,0),u=Array.from(c.entries()).filter(([,f])=>f>0).map(([f,g])=>{const p=o.get(f.toLowerCase());return{chainId:p?.chainId||"",chainName:p?.name||f,logoUrl:p?.logoUrl||"",totalBalance:g,percentage:m>0?g/m:0}}).filter(f=>f.chainId!==""),h=f=>f.chainName.toLowerCase()==="initia";return $.sortWith([$.descend(h),$.descend($.prop("totalBalance"))],u)},[e,t,o])}function qm(){const{balances:e}=ds(),t=he(),s=la(),o=y.useMemo(()=>hc(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=wm(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 Pm(){const{positions:e}=ds();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 je=$e.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 De(){const{routerApiUrl:e}=ne();return y.useMemo(()=>z.create({prefixUrl:e,headers:{"InterwovenKit-Version":"2.5.1"}}),[e])}function Rm(){const e=De();S.usePrefetchQuery({queryKey:je.chains.queryKey,queryFn:()=>e.get("v2/info/chains").json(),staleTime:K.MINUTE}),S.usePrefetchQuery({queryKey:je.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:K.MINUTE})}const Dm=()=>(Gl(),Yl(),null),Bm="_loader_1vxch_1",Fm={loader:Bm},Nt=({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:Fm.loader,style:o,role:"status","aria-label":"Loading"})},Um="_button_1q027_1",Om="_outline_1q027_28",Vm="_sm_1q027_46",Km="_full_1q027_53",Wm="_small_1q027_57",zm="_unpadded_1q027_88",cn={button:Um,outline:Om,sm:Vm,full:Km,small:Wm,unpadded:zm},pc=e=>{const{sm:t,fullWidth:s,loading:o,className:a,children:r,disabled:i,...c}=e;return n.jsx("button",{...c,className:D(cn.button,{[cn.sm]:t,[cn.full]:s},a),disabled:!!o||i,"aria-busy":!!o,children:o?n.jsxs(n.Fragment,{children:[n.jsx(Nt,{color:"currentColor",size:16}),typeof o=="string"&&n.jsx("span",{className:cn.loading,children:o})]}):r})},Hm=({className:e,...t})=>n.jsx(pc,{...t,className:D(cn.outline,e)}),Qm=({className:e,unpadded:t,...s})=>n.jsx("button",{...s,className:D(cn.small,{[cn.unpadded]:t},e)}),ue={White:pc,Outline:Hm,Small:Qm},Gm="_footer_1vp4h_1",Ym="_actions_1vp4h_10",hr={footer:Gm,actions:Ym},Ae=({extra:e,className:t,children:s})=>n.jsxs("footer",{className:D(hr.footer,t),children:[e,n.jsx("div",{className:hr.actions,children:s})]}),Zm="_scrollable_13su7_1",Jm={scrollable:Zm},pt=({className:e,children:t,ref:s})=>n.jsx("div",{ref:s,className:D(Jm.scrollable,e),children:t}),Xm="interwovenkit:";function eh(e){const[t]=e;return typeof t=="string"&&t.startsWith(Xm)}function th(e){e.removeQueries({predicate:t=>eh(t.queryKey)})}function lo(){return ze.useMediaQuery("(max-width: 576px)")}const zo="interwoven-kit";function gc(){const e=document.querySelector(zo)||document.body.appendChild(document.createElement(zo));return e.shadowRoot||e.attachShadow({mode:"open"})}function _c(){const{theme:e,container:t}=ne();return y.useEffect(()=>{document.querySelector(zo)?.setAttribute("data-theme",e)},[e]),t??gc()}function nh(e){const t=gc(),s=document.createElement("style");s.textContent=e,t.appendChild(s)}const uo=y.createContext(null);function _n(){const{container:e}=y.useContext(uo);return e}function yc(e){const t=_n();return t?getComputedStyle(t).getPropertyValue(e):""}function sh(){return ze.useScrollLock(),null}function oh(e){return/^[A-F0-9]{64}$/i.test(e)}function ah(e,t){const{txHash:s,accountAddress:o,pathSuffix:a}=t;if(s)return oh(s)?$.path(["explorers",0,"tx_page"],e)?.replace(/\$\{txHash\}/g,s):void 0;if(o){if(!C.InitiaAddress.validate(o))return;const i=$.path(["explorers",0,"account_page"],e)?.replace(/\$\{accountAddress\}/g,o);return i&&a?i+a:i}}function rh(e){try{const t=new URL(e,window.location.href);if(!["http:","https:"].includes(t.protocol))throw new Error("Invalid protocol");return t.toString()}catch{return"#"}}const ih="_link_j1lkz_1",fr={link:ih},mo=({chainId:e,txHash:t,accountAddress:s,pathSuffix:o,...a})=>{const{showIcon:r,className:i,children:c,onClick:l,...d}=a,m=ft(e),u=ah(m,{txHash:t,accountAddress:s,pathSuffix:o}),h=t?C.truncate(t):s?C.truncate(s):"",f=c??h;return u?n.jsxs("a",{...d,href:Nl(rh(u)),className:D(fr.link,i),onClick:l,target:"_blank",rel:"noopener noreferrer",children:[f,r&&n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})]}):n.jsx("span",{...d,className:D(fr.link,i),children:f})},xc=y.createContext(null),us=()=>y.useContext(xc),ch=()=>{const[e,t]=H.useAtom(Hi),{showNotification:s,updateNotification:o,hideNotification:a}=us();return y.useEffect(()=>{if(!e)return;const{status:r,chainId:i,txHash:c,error:l}=e,d=l?l.message:c?n.jsx(mo,{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},Os=({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})},lh="_placeholder_10r3x_1",dh="_logo_10r3x_5",pr={placeholder:lh,logo:dh},te=({src:e,alt:t,placeholder:s,classNames:o,style:a,logo:r,...i})=>{const[c,l]=y.useState(void 0),{width:d,height:m}=i,u=s??n.jsx("div",{className:D(pr.placeholder,o?.placeholder),style:{width:d,height:m,...a},"aria-hidden":"true"});return!e||c===e?u:n.jsx("img",{...i,className:D(i.className,{[pr.logo]:r}),style:{width:d,height:m,...a},src:e,alt:t,loading:"lazy",onError:()=>l(e)})};function bc(){const{connector:e}=We.useAccount();if(e)return e.id==="io.privy.wallet"?"https://assets.initia.xyz/images/wallets/Privy.webp":e.icon}const uh="_header_1q8ju_1",mh="_account_1q8ju_17",hh="_name_1q8ju_28",fh="_address_1q8ju_32",ph="_icon_1q8ju_36",gh="_copied_1q8ju_43",_h="_button_1q8ju_58",yh="_settings_1q8ju_69",xh="_disconnect_1q8ju_73",bh="_label_1q8ju_83",wh="_expanded_1q8ju_91",nt={header:uh,account:mh,name:hh,address:fh,icon:ph,copied:gh,button:_h,settings:yh,disconnect:xh,label:bh,expanded:wh},vh=()=>{const e=Ii(),{address:t,username:s}=et(),o=bc(),a=s??t,[r,i]=y.useState(!1),c=y.useRef(null),l=jt.useSpring({width:r?140:52,config:{tension:500,friction:30,clamp:!0}}),d=()=>{r?e():i(!0)},m=()=>{r&&(c.current=setTimeout(()=>{i(!1)},500))},u=()=>{c.current&&(clearTimeout(c.current),c.current=null)};return y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),t?n.jsxs("header",{className:nt.header,children:[n.jsx(Os,{value:t,children:({copy:h,copied:f})=>n.jsxs("button",{className:D(nt.account,{[nt.copied]:f}),onClick:h,"aria-label":f?"Copied":"Copy address",children:[n.jsx(te,{src:o,width:18,height:18}),n.jsx("div",{className:nt.address,children:C.truncate(t)}),n.jsx("div",{className:nt.name,children:C.truncate(a)}),n.jsx(E.IconCopy,{className:nt.icon,size:12,"aria-hidden":"true"}),f?"Copied!":""]})}),n.jsx(dn,{to:"/settings",className:D(nt.button,nt.settings),"aria-label":"Open settings",children:n.jsx(E.IconSettingFilled,{size:16,"aria-hidden":"true"})}),n.jsxs(jt.animated.button,{className:D(nt.button,nt.disconnect,{[nt.expanded]:r}),style:l,onClick:d,onMouseLeave:m,onMouseEnter:u,"aria-label":"Disconnect wallet",children:[n.jsx(E.IconSignOut,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:nt.label,children:"Disconnect"})]})]}):null},jh="_overlay_jij9g_1",Ch="_content_jij9g_28",Nh="_inner_jij9g_60",Io={overlay:jh,content:Ch,inner:Nh},kh=({children:e})=>{const{isDrawerOpen:t,closeDrawer:s}=qt(),{setContainer:o}=y.useContext(uo),a=y.useCallback(p=>{p&&o(p)},[o]),r=lo(),i=_c(),c=H.useAtomValue(ao),l=H.useAtomValue(as),d=S.useIsMutating({mutationKey:[zi]}),m=()=>{const p=d?"User exited before response arrived. Transaction may succeed or fail.":"User rejected";s(),c?.reject(new Error(p)),l?.reject(new Error("User rejected"))},u=Xs(),h=Se(),f=S.useQueryClient(),g={fallbackRender:({error:p,resetErrorBoundary:_})=>{const x=()=>{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)),h("/"),th(f),_()};return n.jsxs(pt,{children:[n.jsx(be,{error:!0,children:p.message}),n.jsx(Ae,{children:n.jsx(ue.White,{onClick:x,children:"Retry"})})]})}};return n.jsx(Re.Dialog.Root,{open:t,onOpenChange:p=>!p&&m(),modal:!1,children:n.jsxs(Re.Dialog.Portal,{container:i,children:[r&&n.jsx(Re.Dialog.Backdrop,{className:Io.overlay,onClick:m,children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true",children:[n.jsx("path",{d:"M7.168 14.04 l 6.028 -6.028 l -6.028 -6.028 L8.57 .582 L16 8.012 l -7.43 7.43 l -1.402 -1.402 Z"}),n.jsx("path",{d:"M0.028 14.04 l 6.028 -6.028 L0.028 1.984 L1.43 .582 l 7.43 7.43 l -7.43 7.43 L0.028 14.04 Z"})]})}),n.jsx(Re.Dialog.Popup,{className:Io.content,children:n.jsxs("div",{className:D(Io.inner,"body"),ref:a,children:[r&&n.jsx(sh,{}),n.jsx(ch,{}),n.jsx(vh,{}),n.jsx(pe,{errorBoundaryProps:g,children:e})]})})]})})},Ih="_backdrop_1bqx9_1",Ah="_modal_1bqx9_12",Sh="_closeButton_1bqx9_44",Ao={backdrop:Ih,modal:Ah,closeButton:Sh},Th=({children:e})=>{const{isModalOpen:t,closeModal:s}=Pn(),{setContainer:o}=y.useContext(uo),a=y.useCallback(i=>{i&&o(i)},[o]),r=_c();return n.jsx(Re.Dialog.Root,{open:t,onOpenChange:i=>!i&&s(),children:n.jsxs(Re.Dialog.Portal,{container:r,children:[n.jsx(Re.Dialog.Backdrop,{className:Ao.backdrop,onClick:s}),n.jsxs(Re.Dialog.Popup,{className:Ao.modal,ref:a,children:[n.jsx("button",{className:Ao.closeButton,onClick:s,"aria-label":"Close",children:n.jsx(E.IconClose,{size:20})}),n.jsx(pe,{children:e})]})]})})},wc=y.createContext(!1),Eh="_overlay_1iyfl_1",$h="_fullscreen_1iyfl_15",Mh="_content_1iyfl_19",Lh="_header_1iyfl_56",qh="_title_1iyfl_65",Ph="_close_1iyfl_70",Xt={overlay:Eh,fullscreen:$h,content:Mh,header:Lh,title:qh,close:Ph},vc=({title:e,children:t,trigger:s,className:o,open:a,onOpenChange:r})=>{const i=_n(),c=y.useContext(wc);return i?n.jsxs(Re.Dialog.Root,{open:a,onOpenChange:r,modal:!1,children:[s&&n.jsx(Re.Dialog.Trigger,{className:o,children:s}),n.jsxs(Re.Dialog.Portal,{container:i,children:[n.jsx(Re.Dialog.Backdrop,{className:D(Xt.overlay,{[Xt.fullscreen]:c}),onClick:()=>r(!1),forceRender:!0}),n.jsxs(Re.Dialog.Popup,{className:D(Xt.content,{[Xt.fullscreen]:c}),children:[e&&n.jsxs("header",{className:Xt.header,children:[n.jsx(Re.Dialog.Title,{className:Xt.title,children:e}),n.jsx(Re.Dialog.Close,{className:Xt.close,"aria-label":"Close",children:n.jsx(E.IconClose,{size:20,"aria-hidden":"true"})})]}),t]})]})]}):null},Xn=({children:e})=>{const t=y.useRef(null),[s,o]=y.useState(0),[a,r]=y.useState(!1),i=jt.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:m}=c.getBoundingClientRect();o(m),r(!0)};l();const d=new ResizeObserver(l);return d.observe(c),()=>d.disconnect()},[e]),e?n.jsx(jt.animated.div,{style:{overflow:"hidden",...i},children:n.jsx("div",{ref:t,children:e})}):null},Rh="_help_qcmtq_1",Dh="_icon_qcmtq_10",Bh="_info_qcmtq_19",Fh="_warning_qcmtq_23",Uh="_error_qcmtq_27",Oh="_success_qcmtq_33",So={help:Rh,icon:Dh,info:Bh,warning:Fh,error:Uh,success:Oh},kn=({level:e,className:t,mt:s=8,children:o})=>{if(!o)return null;const a=()=>{switch(e){case"loading":return n.jsx(Nt,{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(So.help,e&&So[e],t),style:{marginTop:s},role:e==="error"?"alert":"status",children:[n.jsx("div",{className:So.icon,"aria-hidden":"true",children:a()}),o]})},Vh="_stack_a6m7u_1",Kh="_help_a6m7u_6",Wh="_info_a6m7u_14",zh="_warning_a6m7u_19",Hh="_error_a6m7u_24",Qh="_success_a6m7u_29",Ho={stack:Vh,help:Kh,info:Wh,warning:zh,error:Hh,success:Qh},Gh=({children:e})=>!e||Array.isArray(e)&&e.filter(Boolean).length===0?null:n.jsx(Xn,{children:n.jsx("div",{className:Ho.stack,children:e})}),xe=({mt:e=0,...t})=>n.jsx(kn,{...t,className:D(Ho.help,Ho[t.level]),mt:e});xe.Stack=Gh;const Yh="_root_16p5j_1",Zh="_item_16p5j_10",Jh="_chevron_16p5j_14",Xh="_trigger_16p5j_19",ef="_content_16p5j_39",Fn={root:Yh,item:Zh,chevron:Jh,trigger:Xh,content:ef};function tf(e){const{list:t,getKey:s,renderHeader:o,renderContent:a,footer:r,...i}=e;return n.jsxs(Z.Accordion.Root,{className:Fn.root,type:"multiple",...i,children:[t.map((c,l)=>n.jsxs(Z.Accordion.Item,{className:Fn.item,value:s?.(c)??String(l),children:[n.jsx(Z.Accordion.Header,{children:n.jsxs(Z.Accordion.Trigger,{className:Fn.trigger,children:[o(c),n.jsx(E.IconChevronDown,{className:Fn.chevron,size:16,"aria-hidden":"true"})]})}),n.jsx(Z.Accordion.Content,{className:Fn.content,children:a(c)})]},s?.(c)??l)),r]})}const nf="_trigger_u613p_1",sf="_icon_u613p_18",of="_content_u613p_27",af="_item_u613p_36",rf="_itemText_u613p_52",cf="_itemIndicator_u613p_57",lf="_active_u613p_60",Ut={trigger:nf,icon:sf,content:of,item:af,itemText:rf,itemIndicator:cf,active:lf};function Ta({options:e,value:t,onChange:s,classNames:o}){const a=_n(),r=e.find(c=>c.value===t);if(!r)throw new Error("Selected option not found");const i=c=>{const l=e.find(d=>String(d.value)===c);if(!l)throw new Error(`Option not found: ${c}`);s(l.value)};return n.jsxs(Et.Select.Root,{value:String(t),onValueChange:i,modal:!1,children:[n.jsxs(Et.Select.Trigger,{className:D(Ut.trigger,o?.trigger),children:[n.jsx(Et.Select.Value,{children:r.triggerLabel||r.label}),n.jsx(Et.Select.Icon,{className:Ut.icon,children:n.jsx(E.IconChevronDown,{size:12,"aria-hidden":"true"})})]}),n.jsx(Et.Select.Portal,{container:a,children:n.jsx(Et.Select.Positioner,{className:Ut.content,alignItemWithTrigger:!1,sideOffset:6,align:"end",children:n.jsx(Et.Select.Popup,{className:Ut.popup,children:e.map(c=>n.jsxs(Et.Select.Item,{className:D(Ut.item,o?.item),value:String(c.value),children:[n.jsx(Et.Select.ItemText,{className:D(Ut.itemText,o?.itemText),children:c.label}),n.jsx(E.IconCheck,{size:12,className:D(Ut.itemIndicator,{[Ut.active]:c.value===t}),"aria-hidden":"true"})]},String(c.value)))})})})]})}const df="_root_1t37n_1",uf="_trigger_1t37n_7",mf="_item_1t37n_11",hf="_itemText_1t37n_17",gr={root:df,trigger:uf,item:mf,itemText:hf},ff=({options:e,value:t,onChange:s})=>{const{txRequest:o}=Gi(),a=ft(o.chainId),r=It(a),i=(g,p)=>{if(C.formatAmount(g,{decimals:p})==="0.000000")return 8},c=({amount:[{amount:g,denom:p}]})=>{if(U(g).isZero())return"0";const{symbol:_,decimals:x}=r(p),b=i(g,x);return`${C.formatAmount(g,{decimals:x,dp:b})} ${_}`},l=e.map(g=>{const[{denom:p}]=g.amount,{symbol:_}=r(p);return{value:p,label:c(g),triggerLabel:_}});if(e.length===1)return n.jsx("span",{className:"monospace",children:c(e[0])});const d=e.find(g=>g.amount[0].denom===t);if(!d)throw new Error("Fee option not found");const[{amount:m,denom:u}]=d.amount,{decimals:h}=r(u),f=i(m,h);return n.jsxs("div",{className:gr.root,children:[n.jsx("span",{className:"monospace",children:C.formatAmount(m,{decimals:h,dp:f})}),n.jsx(Ta,{options:l,value:t,onChange:s,classNames:gr})]})},pf="_root_16nr2_1",gf="_trigger_16nr2_5",_f="_chevron_16nr2_13",yf="_panel_16nr2_27",xf="_details_16nr2_39",bf="_row_16nr2_48",jn={root:pf,trigger:gf,chevron:_f,panel:yf,details:xf,row:bf},wf=({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(wo.Collapsible.Root,{className:jn.root,children:[n.jsxs(wo.Collapsible.Trigger,{className:jn.trigger,children:[n.jsx("span",{children:"Insufficient balance for fee"}),n.jsx(E.IconChevronDown,{className:jn.chevron,size:16})]}),n.jsx(wo.Collapsible.Panel,{className:jn.panel,children:n.jsx("div",{className:jn.details,children:i.map(({label:l,value:d})=>n.jsxs("div",{className:jn.row,children:[n.jsx("span",{children:l}),n.jsxs("span",{children:[C.formatAmount(d,{decimals:r,dp:c})," ",a]})]},l))})})]})};function Vs(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?ae.toBase64(e):Array.isArray(e)?`[${e.map(Vs).join(",")}]`:JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s);default:return"unknown"}}const vf="_container_1xzyq_1",jf="_toggle_1xzyq_5",Cf="_list_1xzyq_11",Nf="_arg_1xzyq_16",kf="_type_1xzyq_21",Un={container:vf,toggle:jf,list:Cf,arg:Nf,type:kf},If=$e.createQueryKeys("interwovenkit:move",{abi:(e,t,s,o)=>[e,t,s,o]}),Af=({type:e,arg:t})=>Vs(C.resolveBcsType(e).parse(t)),Sf=({msg:e,chainId:t,fallback:s})=>{const[o,a]=ze.useToggle(!1),{restUrl:r}=ft(t),{moduleAddress:i,moduleName:c,functionName:l,args:d}=e,{data:m}=S.useQuery({queryKey:If.abi(r,i,c,l).queryKey,queryFn:async()=>{const h=await z.create({prefixUrl:r}).get(`initia/move/v1/accounts/${i}/modules/${c}`).json(),g=JSON.parse(h.module.abi).exposed_functions.find(({name:p})=>p===l);if(!g)throw new Error(`Function ${l} not found in module ${c}`);return g.params.filter(p=>!p.startsWith("&"))},staleTime:K.INFINITY});if(!m)return s;const u=(h,f)=>{const g=m[f];return n.jsxs("div",{className:Un.arg,children:[n.jsx("div",{className:Un.type,children:g}),n.jsx(Xr.ErrorBoundary,{fallback:n.jsx("div",{className:"error",children:"Error decoding argument"}),children:n.jsx(Af,{type:g,arg:h})})]},f)};return n.jsxs("div",{className:Un.container,children:[n.jsx(ue.Small,{className:Un.toggle,onClick:a,disabled:!m,children:o?"Encode":"Decode"}),o?n.jsx("div",{className:Un.list,children:d.map(u)}):s]})},Tf="_list_oip9m_1",Ef="_key_oip9m_9",$f="_value_oip9m_14",To={list:Tf,key:Ef,value:$f},Mf=({message:e,chainId:t})=>{const{typeUrl:s,value:o}=e;return n.jsx("div",{className:To.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{children:[n.jsx("div",{className:To.key,children:a}),n.jsx("div",{className:To.value,children:s==="/initia.move.v1.MsgExecute"&&a==="args"?n.jsx(Sf,{msg:o,chainId:t,fallback:Vs(r)}):Vs(r)})]},a))})},Lf="_item_1n572_1",qf="_title_1n572_10",Pf="_content_1n572_14",Eo={item:Lf,title:qf,content:Pf},$o=({title:e,content:t})=>n.jsxs("div",{className:Eo.item,children:[n.jsx("div",{className:Eo.title,children:e}),n.jsx("div",{className:Eo.content,children:t})]});function ee(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=C.formatNumber(t?.toString()??e,{dp:2});return o?s?`-$${o}`:`$${o}`:""}function Ea(e,t){return t==null?"$-":ee(e??0)}function jc(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 Cc(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,m=c.metadata_addr;if(l&&d&&m&&C.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h-BigInt(d)}}if(r==="0x1::fungible_asset::DepositEvent"){const l=c.store_addr,d=c.amount,m=c.metadata_addr;if(l&&d&&m&&C.createUserDerivedObjectAddress(t,m)===l){const h=s[m]||BigInt(0);s[m]=h+BigInt(d)}}}return Object.entries(s).filter(([,o])=>o!==BigInt(0)).map(([o,a])=>({amount:a.toString(),metadata:o}))}const Nc=({metadata:e,chain:t,children:s})=>{const{restUrl:o}=t,{data:a}=S.useSuspenseQuery({queryKey:En.denom(o,e).queryKey,queryFn:()=>z.create({prefixUrl:o}).get("initia/move/v1/denom",{searchParams:{metadata:e}}).json(),select:({denom:r})=>r,staleTime:K.INFINITY});return s(a)},Rf="_root_1p8a4_1",Df="_title_1p8a4_8",Bf="_changes_1p8a4_14",Ff="_change_1p8a4_14",Uf="_amount_1p8a4_35",Of="_text_1p8a4_42",Vf="_value_1p8a4_49",ln={root:Rf,title:Df,changes:Bf,change:Ff,amount:Uf,text:Of,value:Vf},kc=({amount:e,asset:t,price:s})=>{const{denom:o,symbol:a,decimals:r,logoUrl:i}=t,c=C.formatAmount(e,{decimals:r}),l=s&&U(C.fromBaseUnit(e,{decimals:r})).times(s).abs();return n.jsxs("div",{className:ln.change,children:[n.jsxs("div",{className:ln.amount,children:[n.jsx(te,{src:i,width:14,height:14,logo:!0}),n.jsxs("span",{className:ln.text,children:[c," ",a||o]})]}),l&&n.jsx("div",{className:ln.value,children:ee(l)})]})},Kf=({changes:e,chain:t})=>{const s=It(t),{data:o}=Lt(t);return e.map(({amount:a,denom:r},i)=>{const c=s(r),l=o?.find(({id:d})=>d===r)?.price;return n.jsx(kc,{amount:a,asset:c,price:l},i)})},Wf=({changes:e,chain:t})=>{const s=It(t),{data:o}=Lt(t);return e.map(({amount:a,metadata:r},i)=>n.jsx(Nc,{metadata:r,chain:t,children:c=>{const l=o?.find(({id:d})=>d===c)?.price;return n.jsx(kc,{amount:a,asset:s(c),price:l})}},i))};function zf(e,t){return typeof t=="bigint"?t.toString():t}const Hf=$e.createQueryKeys("interwovenkit:tx",{simulate:e=>[JSON.stringify(e,zf)]}),Qf=({messages:e,memo:t,chainId:s})=>{const{initiaAddress:o,hexAddress:a}=et(),r=ft(s),{simulateTx:i}=ro(),{data:c}=S.useSuspenseQuery({queryKey:Hf.simulate({messages:e,memo:t,chainId:s}).queryKey,queryFn:()=>i({messages:e,memo:t,chainId:s}),staleTime:K.SECOND}),l=h=>n.jsxs("div",{className:ln.root,children:[n.jsx("h2",{className:ln.title,children:"Estimated changes"}),n.jsx("div",{className:ln.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=Cc(d,a),[f]=_r(h);return f.length===0?null:l(n.jsx(Wf,{changes:f,chain:r}))}const m=jc(d,o),[u]=_r(m);return u.length===0?null:l(n.jsx(Kf,{changes:u,chain:r}))};function _r(e){return $.partition(t=>new U(t.amount).isNegative(),e)}const Gf="_title_1d032_1",Yf="_meta_1d032_7",Zf="_footer_1d032_14",Jf="_rejectButton_1d032_19",js={title:Gf,meta:Yf,footer:Zf,rejectButton:Jf},Ic=()=>{const{txRequest:e,resolve:t,reject:s}=Gi(),{messages:o,memo:a,chainId:r,gas:i,gasAdjustment:c,spendCoins:l}=e,d=ft(r),m=os(d),u=ya(d),h=xa(d),f=It(d),g=Qi(),p=(e.gasPrices??u).map(({amount:A,denom:L})=>Ee.calculateFee(Math.ceil(i*c),Ee.GasPrice.fromString(A+L))),_=p.map(A=>A.amount[0]),x=A=>{const L=m.find(Q=>Q.denom===A)?.amount??"0",N=_.find(Q=>Q.denom===A)?.amount??"0",I=l.filter(Q=>Q.denom===A).reduce((Q,W)=>U(Q).plus(W.amount),U("0")),B=U(N).plus(I),q=U(L).gte(B),{symbol:P,decimals:F}=f(A);return{symbol:P,decimals:F,spend:I.gt(0)?I.toFixed():null,fee:N,total:B.toFixed(),balance:L,isSufficient:q}},b=()=>{if(h&&x(h).isSufficient)return h;for(const{denom:A}of _)if(x(A).isSufficient)return A;return _[0]?.denom},[j,w]=y.useState(b),{mutate:v,isPending:k}=S.useMutation({mutationKey:[zi],mutationFn:async()=>{const A=p.find(N=>N.amount[0].denom===j);if(!A)throw new Error("Fee not found");const L=await g({chainId:r,messages:o,memo:a||"",fee:A,preferredFeeDenom:j,allowAutoSign:!e.internal,allowWalletDerivation:!0});await t(L)},onError:async A=>{s(A)}}),T=x(j),M=!T.isSufficient;return n.jsxs(n.Fragment,{children:[n.jsxs(pt,{children:[n.jsx("h1",{className:js.title,children:"Confirm tx"}),n.jsxs("section",{className:js.meta,"aria-label":"Transaction metadata",children:[n.jsx($o,{title:"Chain",content:r}),n.jsx($o,{title:"Tx fee",content:n.jsx(ff,{options:p,value:j,onChange:w})}),a&&n.jsx($o,{title:"Memo",content:a}),M&&n.jsx(xe,{level:"error",children:n.jsx(wf,{...T})})]}),n.jsx(Qf,{messages:o,memo:a,chainId:r}),n.jsx(tf,{list:o,renderHeader:({typeUrl:A})=>Qs.sentenceCase(A.split(".").pop().replace(/^Msg/,"")),renderContent:A=>n.jsx(Mf,{message:A,chainId:r})})]}),n.jsxs(Ae,{className:js.footer,children:[n.jsx(ue.Outline,{onClick:()=>s(new Error("User rejected")),disabled:k,className:js.rejectButton,"aria-label":"Reject",children:n.jsx(E.IconClose,{size:16})}),n.jsx(ue.White,{onClick:()=>v(),disabled:M,loading:k,children:"Approve"})]})]})},Xf=({children:e})=>{const[{title:t,content:s,path:o},a]=y.useState({}),[r,i]=y.useState(!1),c=H.useAtomValue(ao),l=y.useCallback(u=>{a(u),i(!0)},[]),d=y.useCallback(()=>{a({}),i(!1)},[]),m=y.useCallback(u=>{u||(c?.reject(new Error("User rejected")),a({})),i(u)},[c]);return n.jsxs(Oi.Provider,{value:{openModal:l,closeModal:d},children:[e,n.jsx(vc,{title:t,open:r,onOpenChange:m,children:n.jsx(pe,{children:o==="/tx"?n.jsx(Ic,{}):s})})]})},ep="_container_1w1hx_1",tp="_toast_1w1hx_11",np="_info_1w1hx_24",sp="_success_1w1hx_28",op="_error_1w1hx_32",ap="_icon_1w1hx_37",rp="_content_1w1hx_45",ip="_title_1w1hx_48",cp="_description_1w1hx_53",lp="_close_1w1hx_75",Ot={container:ep,toast:tp,info:np,success:sp,error:op,icon:ap,content:rp,title:ip,description:cp,close:lp},dp=({notification:e,onClose:t,...s})=>{const o=jt.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(Nt,{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,m=a(c);return n.jsx(jt.animated.div,{style:r,className:Ot.container,children:n.jsxs("div",{className:D(Ot.toast,c&&Ot[c]),role:"alert",...s,children:[m&&n.jsx("div",{className:Ot.icon,"aria-hidden":"true",children:m}),n.jsxs("div",{className:Ot.content,children:[n.jsx("p",{className:Ot.title,children:l}),d&&n.jsx("div",{className:Ot.description,children:d})]}),n.jsx("button",{className:Ot.close,onClick:t,"aria-label":"Dismiss notification",children:n.jsx(E.IconClose,{size:14,"aria-hidden":"true"})})]})})})},Mo=5e3,up=({children:e})=>{const t=_n(),[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:Ja.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Mo))},[c]),d=y.useCallback(h=>{i(),o(f=>f?{...f,...h}:{...h,id:Ja.nanoid()}),h.autoHide&&!r.current&&(a.current=setTimeout(()=>c(),Mo))},[c]),m=()=>{i(),r.current=!0},u=()=>{i(),r.current=!1,s?.autoHide&&(a.current=setTimeout(()=>c(),Mo))};return y.useEffect(()=>()=>i(),[]),n.jsxs(xc.Provider,{value:{showNotification:l,updateNotification:d,hideNotification:c},children:[e,t&&kl.createPortal(n.jsx(dp,{notification:s,onClose:c,onMouseEnter:m,onMouseLeave:u}),t)]})},mp=({children:e})=>{const[t,s]=y.useState(null);return n.jsx(uo.Provider,{value:{container:t,setContainer:s},children:e})},Ac=[{value:10*ji,label:"for 10 minutes"},{value:Ci,label:"for 1 hour"},{value:sr,label:"for 1 day"},{value:7*sr,label:"for 7 days"},{value:0,label:"until revoked"}],hp=Ac[0].value;function fp(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 Sc(e){return fp(e)||e.includes(":")}function Qo(e){const t=Il.parse(e);return"error"in t?null:t.domain}function pp(e,t){return e===t||e===`www.${t}`}function gp(e){if(e.protocol!=="https:")return!1;const t=e.hostname.toLowerCase();return!t||!t.includes(".")||t==="localhost"||Sc(t)?!1:Qo(t)!==null}function _p(e,t){try{const s=new URL(e);if(!gp(s))return!1;const o=s.hostname.toLowerCase(),a=t.toLowerCase();if(!o||!a||Sc(a)||a==="localhost")return!1;const r=Qo(o);if(!r)return!1;const i=Qo(a);return!i||i!==r?!1:pp(o,r)?a===r||a.endsWith(`.${r}`):a===o||a.endsWith(`.${o}`)}catch{return!1}}const yp="_container_1422v_1",xp="_title_1422v_7",bp="_description_1422v_14",wp="_sectionTitle_1422v_20",vp="_websiteInfo_1422v_27",jp="_favicon_1422v_37",Cp="_websiteTitle_1422v_42",Np="_websiteHost_1422v_48",kp="_warningContent_1422v_54",Ip="_ignoreButton_1422v_61",Ap="_infoList_1422v_65",Sp="_infoItem_1422v_75",Tp="_label_1422v_84",Ep="_infoValue_1422v_94",$p="_durationTrigger_1422v_100",Mp="_durationItem_1422v_101",Lp="_featureList_1422v_105",qp="_featureItem_1422v_113",Pp="_checkIcon_1422v_123",Rp="_learnMoreLink_1422v_127",Dp="_feedbackContainer_1422v_140",Bp="_footer_1422v_146",le={container:yp,title:xp,description:bp,sectionTitle:wp,websiteInfo:vp,favicon:jp,websiteTitle:Cp,websiteHost:Np,warningContent:kp,ignoreButton:Ip,infoList:Ap,infoItem:Sp,label:Tp,infoValue:Ep,durationTrigger:$p,durationItem:Mp,featureList:Lp,featureItem:qp,checkIcon:Pp,learnMoreLink:Rp,feedbackContainer:Dp,footer:Bp};function Fp(e){return e instanceof z.HTTPError&&e.response.status===404}const Up=$e.createQueryKeys("interwovenkit:account",{info:(e,t)=>({queryKey:[e,t],queryFn:async()=>{const s=z.create({prefixUrl:e}),o=`cosmos/auth/v1beta1/account_info/${t}`;try{return await s.get(o).json(),!0}catch(a){if(Fp(a))return!1;throw a}}})}),Op=()=>{const[e,t]=y.useState(hp),[s,o]=H.useAtom(as),[a,r]=y.useState(!1),i=Je(),c=he(),{address:l,initiaAddress:d,username:m}=et(),{mutate:u,isPending:h}=lu(),{closeDrawer:f}=qt();if(!s)throw new Error("Pending request not found");const{logoUrl:g,name:p,restUrl:_}=i(s.chainId),{data:x,isLoading:b,isError:j}=S.useQuery(Up.info(_,d)),w={favicon:document.querySelector('link[rel="icon"]')?.getAttribute("href")||"",title:document.title,hostname:window.location.hostname},v=c.find(B=>B.chainId===s.chainId),k=v?.website?_p(v.website,window.location.hostname):!1,T=()=>{u(e)},M=()=>{s?.reject(new Error("User cancelled")),o(null),f()},A=!k&&!a,L=!b&&!j&&x===!1,N=!b&&j,I=A||b||j||x===!1;return n.jsxs(n.Fragment,{children:[n.jsxs(pt,{className:le.container,children:[n.jsxs("header",{children:[n.jsx("h1",{className:le.title,children:"Enable auto-signing"}),n.jsx("p",{className:le.description,children:"An application is requesting to enable auto-signing"})]}),n.jsxs("section",{children:[n.jsx("h2",{className:le.sectionTitle,children:"Requested by"}),n.jsxs("div",{className:le.websiteInfo,children:[n.jsx("img",{src:w.favicon,alt:"",className:le.favicon}),n.jsxs("div",{children:[n.jsx("div",{className:le.websiteTitle,children:w.title}),n.jsx("div",{className:le.websiteHost,children:w.hostname})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:le.sectionTitle,children:"Applies to"}),n.jsxs("div",{className:le.infoList,children:[n.jsxs("div",{className:le.infoItem,children:[n.jsx("div",{className:le.label,children:"Address"}),n.jsxs("div",{className:le.infoValue,children:[n.jsx(E.IconWallet,{size:14}),n.jsx("span",{className:"monospace",children:C.truncate(m??l)})]})]}),n.jsxs("div",{className:le.infoItem,children:[n.jsx("div",{className:le.label,children:"Chain"}),n.jsxs("div",{className:le.infoValue,children:[n.jsx(te,{src:g,width:14,height:14,logo:!0}),n.jsx("span",{children:p})]})]}),n.jsxs("div",{className:le.infoItem,children:[n.jsx("div",{className:le.label,children:"Duration"}),n.jsx(Ta,{options:Ac,value:e,onChange:t,classNames:{trigger:le.durationTrigger,item:le.durationItem}})]})]})]}),n.jsxs("section",{children:[n.jsx("h2",{className:le.sectionTitle,children:"About auto-signing"}),n.jsx("ul",{className:le.featureList,children:["Send transactions without confirmation pop-ups","Secured by your wallet signature","Revoke permissions any time in settings"].map(B=>n.jsxs("li",{className:le.featureItem,children:[n.jsx(E.IconCheckCircle,{size:12,className:le.checkIcon}),n.jsx("span",{children:B})]},B))}),n.jsxs("a",{href:"https://docs.initia.xyz/user-guides/wallet/auto-signing/introduction",target:"_blank",rel:"noopener noreferrer",className:le.learnMoreLink,children:["Learn more ",n.jsx(E.IconExternalLink,{size:12})]})]})]}),n.jsxs(Ae,{className:le.footer,extra:n.jsxs("div",{className:le.feedbackContainer,children:[L&&n.jsx(xe,{level:"error",children:"Insufficient balance for fee"}),N&&n.jsx(xe,{level:"warning",children:"Unable to verify account status. Try again."}),!k&&!a&&n.jsx(xe,{level:"warning",children:n.jsxs("div",{className:le.warningContent,children:[n.jsx("span",{children:"You are on an unverified website"}),n.jsx("button",{onClick:()=>r(!0),className:le.ignoreButton,children:"Ignore"})]})})]}),children:[n.jsx(ue.Outline,{onClick:M,children:"Cancel"}),n.jsx(ue.White,{onClick:T,disabled:I,loading:h,children:"Enable"})]})]})},Vp=()=>H.useAtomValue(as)?n.jsx(Op,{}):null,Kp="_container_mqvhs_1",Wp="_badge_mqvhs_5",yr={container:Kp,badge:Wp},Tc=e=>{const{offset:t=-4,disabled:s,children:o,className:a}=e;return n.jsxs("div",{className:D(yr.container,a),children:[o,!s&&n.jsx("div",{className:yr.badge,style:{right:t,top:t},"aria-hidden":"true"})]})},zp="_header_s7mee_1",Hp="_back_s7mee_12",Qp="_title_s7mee_24",Lo={header:zp,back:Hp,title:Qp},At=({title:e,backButton:t,extra:s,children:o})=>{const a=hi();return n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Lo.header,children:[n.jsx(dn,{to:t??(a.length>1?-1:"/"),className:Lo.back,shouldReset:!!t,"aria-label":"Go back",children:n.jsx(E.IconBack,{size:16,"aria-hidden":"true"})}),n.jsx("h1",{className:Lo.title,children:e}),s]}),n.jsx(pt,{children:o})]})};function $a(){const e=he();return t=>e.some(s=>s.chain_id===t)}function Gp(e,t){return t(e.chain_id)&&e.chain_name.toLowerCase()!=="initia"}function ms(){const e=$a();return t=>e(t.chain_id)?"initia":t.chain_type}function es(e){return ms()(e)}function ho(){const e=De(),{data:t}=S.useSuspenseQuery({queryKey:je.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:K.MINUTE});return t}function Pt(){const e=ho(),t=oi();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 it(e){return Pt()(e)}function xr(e,t){try{return ae.fromBech32(e).prefix===t}catch{return!1}}function Ec(){const{initiaAddress:e,hexAddress:t}=et(),s=Pt(),o=ms();return a=>{const r=s(a);switch(o(r)){case"initia":return e;case"evm":return t;default:return""}}}function Ma(){const e=Pt(),t=ms();return(s,o)=>{const a=e(o);switch(t(a)){case"initia":return xr(s,a.bech32_prefix??"init");case"evm":return vt.isAddress(s);case"cosmos":return a.bech32_prefix?xr(s,a.bech32_prefix):!1;default:return!1}}}function Yp(){const e=Pt(),t=ms();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 C.InitiaAddress(s).bech32;if(c==="initia"&&d==="evm")return C.InitiaAddress(s).hex;if(c===d)return s;if(r){if(d==="initia")return C.InitiaAddress(r).bech32;if(d==="evm")return C.InitiaAddress(r).hex}return""}}function Zp(){const e=De();return S.useSuspenseQuery({queryKey:je.allAssets().queryKey,queryFn:()=>e.get("v2/fungible/assets").json(),staleTime:K.MINUTE})}function hs(){const{data:{chain_to_assets_map:e}}=Zp(),t=ho(),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(je.assets(a).queryKey,{chain_to_assets_map:{[a]:e[a]}});for(const i of r)s.setQueryData(je.asset(a,i.denom).queryKey,i);o.push(...r)}return o},[e,t,s])}function Ks(e){const t=De(),s=S.useQueryClient(),{data:o}=S.useSuspenseQuery({queryKey:je.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(je.asset(e,i.denom).queryKey,i);return r.toSorted($.descend(i=>i.symbol==="INIT"))},staleTime:K.MINUTE});return o}function $c(e){const t=Ks(e);return s=>{const o=t.find(a=>a.denom===s);if(!o)throw new Error(`Asset not found: ${s}`);return o}}function kt(e,t){return $c(t)(e)}const Jp="_root_ekn9t_1",Xp="_header_ekn9t_6",eg="_title_ekn9t_12",tg="_warning_ekn9t_18",ng="_content_ekn9t_22",sg="_footer_ekn9t_26",og="_secondary_ekn9t_36",en={root:Jp,header:Xp,title:eg,warning:tg,content:ng,footer:sg,secondary:og},Mc=e=>{const{type:t,icon:s,title:o,children:a,primaryButton:r,secondaryButton:i}=e;return n.jsxs(pt,{className:en.root,children:[n.jsxs("header",{className:D(en.header,t&&en[t]),children:[s,n.jsx("h1",{className:en.title,children:o})]}),n.jsx("div",{className:en.content,children:a}),n.jsxs("footer",{className:en.footer,children:[n.jsx(ue.White,{onClick:r.onClick,sm:!0,fullWidth:!0,children:r.label}),n.jsxs("button",{className:en.secondary,onClick:i.onClick,children:[n.jsx("span",{children:i.label}),n.jsx(E.IconChevronRight,{size:14,"aria-hidden":"true"})]})]})]})},ag="_list_k4n3k_1",rg="_row_k4n3k_9",ig="_dt_k4n3k_20",cg="_asset_k4n3k_26",Cs={list:ag,row:rg,dt:ig,asset:cg},lg=({list:e,onNavigate:t,onDismiss:s})=>{const o=oe(),a=Je(),r=It(o);return n.jsx(Mc,{title:"Ready to claim",primaryButton:{label:"View withdrawal status",onClick:t},secondaryButton:{label:"Do not show again",onClick:s},children:n.jsx("div",{className:Cs.list,children:e.toSorted((i,c)=>i.chainId.localeCompare(c.chainId)).map(({txHash:i,chainId:c,amount:l,denom:d})=>{const m=a(c),{decimals:u,symbol:h}=r(d),f=C.formatAmount(l,{decimals:u});return n.jsxs("div",{className:Cs.row,children:[n.jsxs("div",{className:Cs.dt,children:[n.jsx(te,{src:m.logoUrl,width:16,height:16,logo:!0}),n.jsx("span",{children:m.name})]}),n.jsxs("span",{className:Cs.asset,children:[f," ",h]})]},i)})})})};function qo(e,t){return e.chainId===t.chainId&&e.txHash===t.txHash}const Ns=({chainId:e,txHash:t})=>`${ie.OP_REMINDER}:${e}:${t}`,dg=Al.atomWithStorage(ie.OP_REMINDER,[]);function Dn(){const e=se(),[t=[],s]=H.useAtom(dg),o=y.useMemo(()=>t.map(l=>{const d=localStorage.getItem(Ns(l));return d?JSON.parse(d):null}).filter(l=>{if(!l)return!1;const{recipient:d,claimableAt:m}=l;return d!==e?!1:Ze.isPast(m)}),[e,t]),a=y.useCallback((l,d)=>{t.some(m=>qo(m,l))||(s((m=[])=>[...m,l]),localStorage.setItem(Ns(l),JSON.stringify(d)))},[t,s]),r=y.useCallback(l=>{s((d=[])=>d.filter(m=>!qo(m,l))),localStorage.removeItem(Ns(l))},[s]),i=y.useCallback(l=>{const d=l.filter(m=>!t.some(u=>qo(u,m)));d.length!==0&&s((m=[])=>[...m,...d])},[t,s]),c=y.useCallback((l,d)=>{localStorage.setItem(Ns(l),JSON.stringify(d)),s((m=[])=>[...m])},[s]);return{reminders:o,addReminder:a,removeReminder:r,syncReminders:i,setReminder:c}}function Lc(){const e=Se(),{openModal:t,closeModal:s}=oo(),{reminders:o,setReminder:a}=Dn();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(lg,{list:r,onNavigate:i,onDismiss:c})})},[o,s,e,t,a])}const ug="_wrapper_5ssm8_1",mg="_balance_5ssm8_11",hg="_button_5ssm8_15",Po={wrapper:ug,balance:mg,button:hg},qc=({onClick:e,children:t,disabled:s})=>n.jsxs("div",{className:Po.wrapper,children:[n.jsx(E.IconWallet,{size:16,"aria-hidden":"true"}),n.jsx("span",{className:Po.balance,children:t}),n.jsx("button",{type:"button",tabIndex:-1,className:Po.button,onClick:()=>e(),disabled:s,"aria-label":"Use maximum balance",children:"MAX"})]}),fg="_fieldset_up6fh_1",pg="_upper_up6fh_9",gg="_select_up6fh_14",_g="_account_up6fh_20",yg="_lower_up6fh_25",xg="_wrapper_up6fh_26",bg="_balance_up6fh_33",wg="_value_up6fh_37",vg="_error_up6fh_50",$t={fieldset:fg,upper:pg,select:gg,account:_g,lower:yg,wrapper:xg,balance:bg,value:wg,error:vg},Go=e=>{const{selectButton:t,accountButton:s,quantityInput:o,balanceButton:a,value:r,errorMessage:i,hideNumbers:c}=e;return n.jsxs("div",{className:$t.fieldset,children:[n.jsxs("div",{className:$t.upper,children:[n.jsx("div",{className:$t.select,children:t}),n.jsx("div",{className:$t.account,children:s})]}),!c&&n.jsxs("div",{className:$t.lower,children:[o,n.jsxs("div",{className:$t.wrapper,children:[n.jsx("div",{className:$t.balance,children:a}),r&&n.jsx("div",{className:$t.value,children:r})]}),i&&n.jsxs("footer",{className:$t.error,children:[n.jsx(E.IconWarningFilled,{size:12,"aria-hidden":"true"}),n.jsx("p",{role:"alert",children:i})]})]})]})};function fs(){const e=y.useRef(null),t=lo();return y.useEffect(()=>{t||e.current?.focus()},[t]),e}const jg="_input_h8073_1",Cg={input:jg};function Pc(e){const{name:t,control:s,dp:o=6,className:a,rules:r,...i}=e,c=fs();return n.jsx(Ie.Controller,{name:t,control:s,rules:r,render:({field:l})=>n.jsx(Sl.NumericFormat,{value:l.value,getInputRef:ei.mergeRefs([l.ref,c]),className:D(Cg.input,a),onValueChange:d=>{l.onChange(d.value)},onBlur:l.onBlur,decimalScale:o,allowNegative:!1,placeholder:"0",inputMode:"decimal",autoComplete:"off",...i})})}const Ng="_input_19r9r_1",kg="_placeholder_19r9r_18",Yo={input:Ng,placeholder:kg},Ig=({children:e})=>n.jsx("p",{className:D(Yo.input,{[Yo.placeholder]:U(e).isZero()}),children:e}),ts=({balance:e,decimals:t,className:s})=>{const{control:o}=Ie.useFormContext(),a={required:"Enter amount",validate:r=>U(r).isZero()?"Enter amount":e!==void 0&&U(C.toBaseUnit(r,{decimals:t})).gt(e)?"Insufficient balance":!0};return n.jsx(Pc,{name:"quantity",control:o,className:D(Yo.input,s),rules:a})};ts.ReadOnly=Ig;const Ln=({title:e,content:t,children:s,className:o})=>{const[a,r]=y.useState(!1),i=()=>r(!1);return n.jsx(vc,{title:e,trigger:s,className:o,open:a,onOpenChange:r,children:t(i)})},Ag="_tooltip_19kvs_1",Sg="_arrow_19kvs_44",br={tooltip:Ag,arrow:Sg},ps=({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:_n(),children:n.jsxs(Z.Tooltip.Content,{className:D(br.tooltip,{small:s}),collisionBoundary:_n(),collisionPadding:8,sideOffset:4,children:[e,n.jsx(Z.Tooltip.Arrow,{className:br.arrow})]})})]});function La(e,t){const s=De(),o=Ma(),a=!!t&&!!e&&o(e,t);return S.useQuery({queryKey:je.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:K.SECOND})}function Tg(e,t,s){const{data:o={}}=La(e,t);return $.path([s],o)}const Eg=[["d",1440*60],["h",3600],["m",60],["s",1]];function ns(e){if(!e)return;const{formattedParts:t}=Eg.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 Rc(e,t){return U(e).times(U(100).minus(t)).div(100).integerValue(U.ROUND_FLOOR).toFixed(0)}function qa(e){return e?.map(t=>{const{amount:s,origin_asset:o}=t;return`${C.formatAmount(s,{decimals:o.decimals??0})} ${o.symbol}`}).join(", ")}function Dc(e,t,s,o){const{srcChainId:a,srcDenom:r,quantity:i,dstChainId:c,dstDenom:l}=s,d=t.getQueryData(je.asset(a,r).queryKey);if(!d||d.decimals==null)throw new Error("Failed to refresh route: source asset metadata is unavailable.");const m=d.decimals;return e.post("v2/fungible/route",{signal:o?.signal,json:{amount_in:C.toBaseUnit(i,{decimals:m}),source_asset_chain_id:a,source_asset_denom:r,dest_asset_chain_id:c,dest_asset_denom:l,is_op_withdraw:o?.isOpWithdraw}}).json()}function Zo(e,t){const{watch:s}=Gt(),o=s(),a=De(),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,m=l&&!t?.disabled&&!i,u=S.useQueryClient();return S.useQuery({queryKey:je.route(r,t?.isOpWithdraw).queryKey,queryFn:async({signal:h})=>Dc(a,u,r,{isOpWithdraw:t?.isOpWithdraw,signal:h}),enabled:m,staleTime:d,refetchInterval:m?d:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,refetchOnMount:"always"})}function $g(e){return S.useQuery({queryKey:je.routeErrorInfo(e??void 0).queryKey,queryFn:async()=>{if(!e||!(e instanceof z.HTTPError))return null;const{response:t}=e;return(t.headers.get("content-type")??"").includes("application/json")?(await t.json()).info??null:null},enabled:!!e})}function Mg(){const{watch:e}=Gt(),{srcChainId:t,srcDenom:s,dstChainId:o,dstDenom:a}=e(),r=it(t),i=es(r),c=kt(s,t),l=kt(a,o),d=oe(),m=he();return i==="initia"&&o===d.chainId&&c.symbol===l.symbol&&m.find(u=>u.chainId===t)?.metadata?.op_denoms?.includes(l.denom)}const Lg="_label_t93ix_1",qg="_wrapper_t93ix_7",Pg="_input_t93ix_10",Rg="_clear_t93ix_18",ks={label:Lg,wrapper:qg,input:Pg,clear:Rg},Pa=({mode:e="onChange",myAddress:t,...s})=>{const{validate:o=C.InitiaAddress.validate,chainType:a="initia",onApply:r,ref:i}=s,c=fs(),{control:l,getValues:d,setValue:m,formState:u}=Ie.useFormContext(),h=d("recipient"),[f,g]=y.useState(h),p=li(),{data:_,isLoading:x,error:b}=S.useQuery({queryKey:Zs.address(p.restUrl,f).queryKey,queryFn:()=>p.getAddress(f),staleTime:K.MINUTE,enabled:p.validateUsername(f)}),j=_??(o(f)?f:""),w=t&&C.InitiaAddress.equals(j,t),v=async()=>{try{const M=await navigator.clipboard.readText();g(M.trim())}catch{}};y.useEffect(()=>{e==="onChange"&&(!f&&!u.dirtyFields.recipient||m("recipient",_??f,{shouldValidate:!0,shouldDirty:!0}))},[u.dirtyFields.recipient,f,e,m,_]);const k=()=>{x||b||(m("recipient",j,{shouldValidate:!0,shouldDirty:!0}),r?.())},T=()=>{if(x)return n.jsx(kn,{level:"loading",children:"Resolving username..."});if(b)return n.jsx(kn,{level:"error",children:b.message});if(_)return n.jsx(kn,{level:"success",className:"monospace",children:_});if(e==="onSubmit"&&f&&!j)return n.jsx(kn,{level:"error",children:"Invalid address"})};return n.jsxs("div",{children:[n.jsxs("label",{htmlFor:"recipient",className:ks.label,children:[n.jsx("span",{children:"Recipient"}),n.jsx(ue.Small,{type:"button",tabIndex:-1,onClick:v,children:"Paste"})]}),n.jsxs("div",{className:ks.wrapper,children:[n.jsx(Ie.Controller,{name:"recipient",control:l,rules:{required:"Recipient address is required",validate:M=>o(M)||"Invalid address"},render:()=>n.jsx("input",{id:"recipient",className:D(ks.input,"monospace"),value:f,onChange:M=>g(M.target.value.trim()),placeholder:a==="initia"?"Address or username":"Enter address",autoComplete:"off","data-has-value":f?"true":void 0,ref:e==="onSubmit"?ei.mergeRefs([i,c]):i})}),!!f&&n.jsx("button",{type:"button",className:ks.clear,onClick:()=>g(""),"aria-label":"Clear recipient",children:n.jsx(E.IconCloseCircleFilled,{size:16})})]}),T(),w&&n.jsx(kn,{children:"This is my address"}),e==="onSubmit"&&n.jsx(Ae,{extra:(!t||!!j&&!w)&&n.jsx(xe,{level:"warning",children:"Do not enter an exchange address. Tokens sent to an address that does not support bridge transfer will be irretrievable."}),children:n.jsx(ue.White,{type:"button",onClick:k,disabled:x||!!b||!j,children:"Apply"})})]})},Dg="_scrollable_vgj3r_1",Bg="_list_vgj3r_5",Fg="_item_vgj3r_9",Ug="_name_vgj3r_22",Is={scrollable:Dg,list:Bg,item:Fg,name:Ug};function Bc({onSelect:e,list:t,...s}){const{getImage:o,getName:a,getKey:r,getIsLoading:i,getDisabled:c}=s;return n.jsx(pt,{className:Is.scrollable,children:n.jsx("div",{className:Is.list,children:t.map(l=>n.jsxs("button",{className:Is.item,onClick:()=>e(l),disabled:i?.(l)||c?.(l),"aria-busy":!!i?.(l),children:[n.jsx(te,{src:o(l),width:28,height:28}),n.jsx("span",{className:Is.name,children:a(l)}),i?.(l)&&n.jsx(Nt,{size:16})]},r(l)))})})}function fo(){const{cosmosWallets:e=[]}=ne(),t=y.useMemo(()=>{const a=[{name:"Keplr",image:"https://assets.initia.xyz/images/wallets/Keplr.webp",getProvider:()=>window.keplr,fallbackUrl:"https://keplr.app/get"},{name:"Leap",image:"https://assets.initia.xyz/images/wallets/Leap.webp",getProvider:()=>window.leap,fallbackUrl:"https://leapwallet.io/download"}].filter(r=>!e.some(i=>i.name===r.name));return[...e,...a]},[e]);return{list:t,find:o=>t.find(a=>a.name===o)}}const Og="_account_h04x1_8",Vg="_clear_h04x1_28",Kg="_white_h04x1_39",On={account:Og,clear:Vg,white:Kg},wr=({type:e})=>{const{watch:t,setValue:s}=Gt(),{srcChainId:o,dstChainId:a,cosmosWalletName:r}=t(),c=t(e==="src"?"sender":"recipient"),l=es(it(a)),{showNotification:d}=us(),{list:m,find:u}=fo(),h=u(r),f=Ec(),g=Ma(),p=f(a),_=C.InitiaAddress.equals(c,p),x=()=>n.jsx(Ln,{title:"Connect wallet",content:w=>n.jsx(Bc,{onSelect:async v=>{const k=v.getProvider();if(!k){v.fallbackUrl?window.open(v.fallbackUrl,"_blank"):d({type:"error",title:`${v.name} not available`,description:"Please install the wallet extension and try again."});return}try{const M=await k.getOfflineSigner(o).getAccounts();if(M.length===0)throw new Error("No accounts found");s("sender",M[0].address),s("cosmosWalletName",v.name),w()}catch(T){const M=T instanceof Error?T.message:"Unknown error";d({type:"error",title:`Failed to connect ${v.name}`,description:M})}},list:m,getImage:v=>v.image,getName:v=>v.name,getKey:v=>v.name}),className:D(On.account,{[On.white]:!c}),children:c?n.jsxs(n.Fragment,{children:[h&&n.jsx(te,{src:h.image,width:18,height:18}),n.jsx("span",{className:"monospace",children:C.truncate(c)})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"Connect wallet"}),n.jsx(E.IconChevronRight,{size:14,"aria-hidden":"true"})]})}),b=w=>n.jsx(Ln,{title:"Recipient",content:v=>n.jsx(pt,{children:n.jsx(Pa,{mode:"onSubmit",myAddress:p,chainType:l,validate:k=>g(k,a),onApply:v})}),className:On.account,children:w}),j=()=>{switch(l){case"initia":case"evm":return _?b(n.jsx(E.IconWallet,{size:14})):n.jsxs("div",{className:On.account,children:[n.jsx("span",{className:"monospace",children:C.truncate(c)}),n.jsx("button",{type:"button",className:On.clear,onClick:()=>s("recipient",p,{shouldValidate:!0}),"aria-label":"Reset to my address",children:n.jsx(E.IconCloseCircleFilled,{size:14})})]});case"cosmos":return b(n.jsxs(n.Fragment,{children:[c?n.jsx("span",{className:"monospace",children:C.truncate(c)}):n.jsx("span",{children:"Recipient"}),n.jsx(E.IconEdit,{size:14,"aria-hidden":"true"})]}))}};switch(e){case"src":return x();case"dst":return j()}},Wg="_images_cj4xz_1",Ro={images:Wg},po=({assetLogoUrl:e,assetLogoSize:t=36,chainLogoUrl:s,chainLogoSize:o=18,chainLogoOffset:a=6,className:r})=>n.jsxs("div",{className:D(Ro.images,r),style:{position:"relative"},"aria-hidden":"true",children:[n.jsx(te,{src:e,width:t,height:t,className:Ro.asset,logo:!0}),n.jsx(te,{src:s,width:o,height:o,className:Ro.chain,style:{position:"absolute",bottom:0,right:-1*a},logo:!0})]}),zg="_root_6187w_1",Hg="_content_6187w_10",Qg="_details_6187w_20",Gg="_symbol_6187w_26",Yg="_chain_6187w_34",Zg="_chevron_6187w_43",tn={root:zg,content:Hg,details:Qg,symbol:Gg,chain:Yg,chevron:Zg},Fc=({asset:e,chain:t,readOnly:s})=>{const o=n.jsxs("div",{className:tn.content,children:[n.jsx(po,{assetLogoUrl:e.logoUrl,chainLogoUrl:t.logoUrl}),n.jsxs("div",{className:tn.details,children:[n.jsx("div",{className:tn.symbol,children:e.symbol||e.denom}),n.jsxs("div",{className:tn.chain,children:["on ",t.name]})]})]});return s?n.jsx("div",{className:tn.root,children:o}):n.jsxs("div",{className:tn.root,children:[o,n.jsx(E.IconChevronDown,{size:16,className:tn.chevron,"aria-hidden":"true"})]})};function Jg(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 Xg="_root_1sh27_1",e_="_label_1sh27_8",t_="_input_1sh27_21",n_="_hasValue_1sh27_31",s_="_clear_1sh27_35",Vn={root:Xg,label:e_,input:t_,hasValue:n_,clear:s_},gs=e=>{const{rootClassName:t,padding:s=16,iconSize:o=16,onClear:a,ref:r,...i}=e;return n.jsxs("div",{className:D(Vn.root,t,{[Vn.hasValue]:i.value}),style:{"--search-input-padding":`${s}px`,"--search-input-icon-size":`${o}px`},children:[n.jsx("label",{htmlFor:"search",className:Vn.label,children:n.jsx(E.IconSearch,{size:o})}),n.jsx("input",{className:Vn.input,id:"search",type:"text",maxLength:100,ref:r,...i}),i.value&&n.jsx("button",{type:"button",className:Vn.clear,"aria-label":"Clear search",onMouseDown:c=>c.preventDefault(),onClick:a,children:n.jsx(E.IconCloseCircleFilled,{size:o})})]})},o_="_container_5tajg_1",a_="_search_5tajg_7",r_="_list_5tajg_11",i_="_item_5tajg_15",c_="_logo_5tajg_37",l_="_info_5tajg_41",d_="_symbol_5tajg_47",u_="_name_5tajg_56",m_="_balance_5tajg_62",h_="_value_5tajg_69",at={container:o_,search:a_,list:r_,item:i_,logo:c_,info:l_,symbol:d_,name:u_,balance:m_,value:h_},_s=e=>{const{assets:t,onSelect:s,renderAsset:o=(c,l)=>l(c)}=e,[a,r]=y.useState(""),i=Jg(["symbol"],a,t);return n.jsxs("div",{className:at.container,children:[n.jsx(gs,{value:a,onChange:c=>r(c.target.value),onClear:()=>r(""),placeholder:"Search by symbol",rootClassName:at.search,padding:20,ref:fs()}),i.length===0?n.jsx(be,{children:"No assets"}):n.jsx("div",{className:at.list,children:i.map(c=>n.jsx("button",{type:"button",className:at.item,onClick:()=>s(c.denom),children:o(c,l=>{const{denom:d,logoUrl:m,symbol:u,name:h,balance:f,decimals:g,value:p=0}=l;return n.jsxs(n.Fragment,{children:[n.jsx(te,{src:m,width:32,height:32,className:at.logo,logo:!0}),n.jsxs("div",{className:at.info,children:[n.jsx("div",{className:at.symbol,children:u||d}),n.jsx("div",{className:at.name,children:h})]}),n.jsxs("div",{className:at.balance,children:[f&&n.jsx("div",{children:C.formatAmount(f,{decimals:g})}),p>0&&n.jsx("div",{className:at.value,children:ee(p)})]})]})})},c.denom))})]})},f_=()=>n.jsxs("div",{className:at.container,children:[n.jsx(gs,{rootClassName:at.search,padding:20,placeholder:"Search by symbol",readOnly:!0}),n.jsx(be,{children:"Loading..."})]});_s.Placeholder=f_;const p_="_stack_16oqn_1",g_="_title_16oqn_9",__="_grid_16oqn_16",y_="_item_16oqn_22",x_="_button_16oqn_26",b_="_active_16oqn_44",In={stack:p_,title:g_,grid:__,item:y_,button:x_,active:b_},mn=({label:e,chains:t,value:s,onSelect:o,getShowIndicator:a})=>n.jsxs("div",{children:[e&&n.jsx("h2",{className:In.title,children:e}),n.jsx("div",{className:In.grid,children:t.map(({chainId:r,name:i,logoUrl:c})=>n.jsx(Tc,{offset:-2,disabled:!a?.(r),className:In.item,children:n.jsx(ps,{label:i,disableHoverableContent:!0,children:n.jsx("button",{type:"button","aria-label":i,className:D(In.button,{[In.active]:r===s}),onClick:()=>o(r),children:n.jsx(te,{src:c,width:28,height:28,logo:!0})})})},r))})]}),w_=({children:e})=>n.jsx("div",{className:In.stack,children:e});mn.Stack=w_;const v_=({address:e,chain:t,onSelect:s})=>{const o=Ks(t.chain_id),{data:a={}}=La(e,t.chain_id);return n.jsx(_s,{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=C.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})},j_=({type:e,afterSelect:t})=>{const s=e==="src"?"srcChainId":"dstChainId",o=e==="src"?"srcDenom":"dstDenom",a=e==="src"?"sender":"recipient",r=Qt(),i=ho(),{watch:c,setValue:l}=Gt(),d=c(a),m=c(s),u=c(o),[h,f]=y.useState(m),g=it(h),p=Yp(),_=$a(),[x,b]=$.partition(w=>_(w.chain_id),i.filter(w=>!w.hidden)),j=w=>{if(m===h&&u===w){t();return}l(s,h),l(o,w),t()};return n.jsxs(n.Fragment,{children:[n.jsxs(mn.Stack,{children:[n.jsx(mn,{label:"Interwoven Economy",chains:x.map(({chain_id:w,chain_name:v,pretty_name:k,logo_uri:T})=>({chainId:w,name:k||v,logoUrl:T??""})),value:h,onSelect:f}),n.jsx(mn,{label:"Chains",chains:b.map(({chain_id:w,chain_name:v,pretty_name:k,logo_uri:T})=>({chainId:w,name:k||v,logoUrl:T??""})),value:h,onSelect:f})]}),n.jsx(pe,{suspenseFallback:n.jsx(_s.Placeholder,{}),children:n.jsx(v_,{address:p({initialAddress:d,initialChainId:m,chainId:h,fallbackAddress:e==="src"?r:void 0}),chain:g,onSelect:j})},h)]})},vr=({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}=Gt(),r=a(t),i=a(s),c=it(r),l=kt(i,r);return n.jsx(Ln,{title:o,content:d=>n.jsx(j_,{type:e,afterSelect:d}),children:n.jsx(Fc,{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??""}})})},C_="_skeleton_1l4jn_1",N_={skeleton:C_},hn=({width:e="100%",height:t})=>n.jsx("div",{className:N_.skeleton,style:{width:e,height:t},"aria-hidden":"true"}),k_="_stack_oq1ir_1",I_="_button_oq1ir_6",A_="_isLoading_oq1ir_19",S_="_disabled_oq1ir_19",T_="_checked_oq1ir_23",E_="_header_oq1ir_37",$_="_title_oq1ir_43",M_="_duration_oq1ir_52",L_="_warning_oq1ir_62",q_="_amount_oq1ir_66",P_="_value_oq1ir_67",ot={stack:k_,button:I_,isLoading:A_,disabled:S_,checked:T_,header:E_,title:$_,duration:M_,warning:L_,amount:q_,value:P_},R_=({children:e})=>n.jsx("div",{className:ot.stack,role:"radiogroup","aria-label":"Route options",children:e}),Ls=({label:e,query:t,value:s,onSelect:o,...a})=>{const{data:r,isLoading:i}=t,{watch:c}=Gt(),{dstChainId:l,dstDenom:d}=c(),m=kt(d,l),u=!i&&a.checked,h=!i&&!r;return n.jsxs("button",{type:"button",className:D(ot.button,{[ot.isLoading]:i,[ot.disabled]:h,[ot.checked]:u}),onClick:()=>{i||h||o(s)},role:"radio","aria-checked":u,"aria-disabled":h,children:[n.jsxs("div",{className:ot.header,children:[n.jsxs("div",{className:ot.title,children:[n.jsx("span",{children:e}),u&&n.jsx(E.IconCheck,{size:14,"aria-hidden":"true"})]}),i?n.jsx(hn,{width:80,height:16}):r?n.jsxs("div",{className:D(ot.duration,{[ot.warning]:s==="op"}),children:[n.jsx(E.IconClockFilled,{size:12,"aria-hidden":"true"}),n.jsx("span",{children:ns(r.estimated_route_duration_seconds)})]}):n.jsx("div",{className:ot.duration,children:"Not available"})]}),(i||r)&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:ot.amount,children:i?n.jsx(hn,{width:260,height:40}):r?C.formatAmount(r.amount_out,{decimals:m.decimals}):null}),n.jsx("div",{className:ot.value,children:i?n.jsx(hn,{width:120,height:16}):r?r.usd_amount_out?ee(r.usd_amount_out):"$-":null})]})]})};Ls.Stack=R_;const D_="_description_nuyvt_1",B_="_presets_nuyvt_8",F_="_preset_nuyvt_8",U_="_active_nuyvt_29",O_="_custom_nuyvt_40",V_="_wrapper_nuyvt_47",K_="_percent_nuyvt_58",xt={description:D_,presets:B_,preset:F_,active:U_,custom:O_,wrapper:V_,percent:K_},jr=["0.1","0.5","1.0"],W_=({afterConfirm:e})=>{const t=Gt(),s=t.getValues("slippagePercent"),[o,a]=y.useState(null),{control:r,watch:i,getValues:c,setValue:l}=Ie.useForm({defaultValues:{value:s}}),d=i("value");y.useEffect(()=>{const p=jr.findIndex(_=>_===s);a(p>=0?p:null)},[s]);const m=(p,_)=>{l("value",p),a(_)},u=()=>{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",g=({value:p})=>{t.setValue("slippagePercent",p),e()};return n.jsxs(pt,{children:[n.jsx("p",{className:xt.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:xt.presets,role:"radiogroup","aria-label":"Slippage presets",children:[jr.map((p,_)=>n.jsxs("button",{type:"button",className:D(xt.preset,{[xt.active]:o===_}),onClick:()=>m(p,_),role:"radio","aria-checked":o===_,children:[p,"%"]},p)),o!==null?n.jsx("button",{type:"button",className:D(xt.preset,xt.custom),onClick:()=>a(null),role:"radio","aria-checked":o===null,children:"Custom"}):n.jsxs("div",{className:xt.wrapper,children:[n.jsx(Pc,{name:"value",control:r,dp:2,onFocus:u,placeholder:"",className:D(xt.preset,xt.active)}),n.jsx("span",{className:xt.percent,children:"%"})]})]}),h&&n.jsx(xe,{level:h.type,children:h.text}),n.jsx(Ae,{children:n.jsx(ue.White,{type:"button",onClick:()=>g(c()),disabled:f,children:"Confirm"})})]})},z_="_form_1owk5_1",H_="_arrow_1owk5_5",Q_="_divider_1owk5_14",G_="_flip_1owk5_23",Y_="_meta_1owk5_41",Z_="_row_1owk5_54",J_="_title_1owk5_60",X_="_description_1owk5_64",ey="_icon_1owk5_71",ty="_edit_1owk5_76",ny="_warning_1owk5_99",Fe={form:z_,arrow:H_,divider:Q_,flip:G_,meta:Y_,row:Z_,title:J_,description:X_,icon:ey,edit:ty,warning:ny};function sy({isLayer1Swap:e,isL2Swap:t}){return e?5e3:t?2e3:1e4}const oy=()=>{const e=Se(),t=lo(),s=qn(),[o,a]=y.useState(void 0),[r,i]=y.useState(!1),[c,l]=ze.useLocalStorage(ie.BRIDGE_ROUTE_TYPE,"default"),{watch:d,setValue:m,handleSubmit:u,formState:h}=Gt(),f=d(),{srcChainId:g,srcDenom:p,dstChainId:_,dstDenom:x,quantity:b,sender:j,slippagePercent:w}=f,v=Je(),k=oe(),T=it(g),M=es(T),A=it(_),L=es(A),N=kt(p,g),I=kt(x,_),{data:B}=La(j,g),q=Tg(j,g,p),P=!q?.amount||U(q.amount).isZero(),[F]=ze.useDebounceValue(b,300),Q=g===_,W=Q&&g===k.chainId,me=sy({isLayer1Swap:W,isL2Swap:Q&&M==="initia"&&!W}),ge=M!=="initia"&&L!=="initia",ce=Mg(),ye=Zo(F,{disabled:ge,refreshMs:me}),we=Zo(F,{isOpWithdraw:!0,disabled:!ce,refreshMs:me}),ve=ce&&c==="op",tt=ve?we:ye,Rt=ve?ye:we,Tt=ve?!ge:ce,qe=tt.error&&Tt?Rt:tt,{data:Y,isLoading:ct,error:re}=qe,{data:Be}=$g(re),Dt=F&&ct&&!r,Bt=()=>{m("srcChainId",_),m("srcDenom",x),m("dstChainId",g),m("dstDenom",p),m("quantity","",{shouldTouch:!1,shouldDirty:!1})},{openModal:_e,closeModal:Pe}=oo(),gt=u(async J=>{a(void 0),i(!0);let Te,Bn;try{const _t=await qe.refetch();if(_t.error||!_t.data||!_t.dataUpdatedAt){a(_t.error instanceof Error?_t.error.message:"Failed to refresh route. Please try again.");return}Te=_t.data,Bn=_t.dataUpdatedAt}finally{i(!1)}if(s("Bridge Simulation Success",{quantity:J.quantity,srcChainId:J.srcChainId,srcDenom:J.srcDenom,dstChainId:J.dstChainId,dstDenom:J.dstDenom}),Te.warning){const{type:_t="",message:wl}=Te.warning??{};_e({content:n.jsx(Mc,{type:"warning",icon:n.jsx(E.IconWarningFilled,{size:40}),title:Qs.sentenceCase(_t),primaryButton:{label:"Cancel",onClick:Pe},secondaryButton:{label:"Proceed anyway",onClick:()=>{e("/bridge/preview",{route:Te,values:J,quoteVerifiedAt:Bn}),Pe()}},children:n.jsx("p",{className:Fe.warning,children:wl})})});return}e("/bridge/preview",{route:Te,values:J,quoteVerifiedAt:Bn})}),He=y.useMemo(()=>Y?.estimated_fees?.filter(({fee_behavior:J})=>J==="FEE_BEHAVIOR_DEDUCTED")??[],[Y]),Qe=y.useMemo(()=>Y?.estimated_fees?.filter(({fee_behavior:J})=>J==="FEE_BEHAVIOR_ADDITIONAL")??[],[Y]),lt=y.useMemo(()=>{for(const J of Qe){const Te=B?.[J.origin_asset.denom]?.amount??"0",Bn=Y?.source_asset_denom===J.origin_asset.denom?Y.amount_in:"0";if(U(Te).lt(U(Bn).plus(J.amount??"0")))return`Insufficient ${J.origin_asset.symbol} for fees`}},[B,Y,Qe]),Ne=y.useMemo(()=>{if(!f.sender)return"Connect wallet";if(!f.quantity||!F)return"Enter amount";if(!f.recipient)return"Enter recipient address";if(h.errors.quantity)return h.errors.quantity.message;if(!Y)return"Route not found";if(lt)return lt},[F,lt,h,Y,f]),Zt=Y?C.formatAmount(Y.amount_out,{decimals:I.decimals}):"0",Jt=U(b).gt(0)&&U(b).isEqualTo(C.fromBaseUnit(q?.amount,{decimals:q?.decimals??0})),za=(()=>{switch(M){case"initia":return v(g).fees.fee_tokens.map(({denom:J})=>J);case"cosmos":return T.fee_assets.map(({denom:J})=>J);case"evm":return vt.isAddress(p)?[]:[p];default:return[]}})(),yl=za.includes(p),xl=za.some(J=>{if(J===p)return!1;const Te=B?.[J]?.amount??"0";return U(Te).gt(0)}),bl=Jt&&yl&&!xl,bo=y.useCallback((J,Te)=>J.length?n.jsxs("div",{className:Fe.description,children:[qa(J),!t&&n.jsx(ps,{label:Te,children:n.jsx("span",{className:Fe.icon,children:n.jsx(E.IconInfoFilled,{size:12,"aria-hidden":"true"})})})]}):null,[t]),xs=U(b).gt(0)&&ce&&ye.data&&we.data&&we.data.estimated_route_duration_seconds>ye.data.estimated_route_duration_seconds,Ha=y.useMemo(()=>{if(!Y)return[];const J=Rc(Y.amount_out,w);return[{condition:!!Y.estimated_fees?.length,title:"Fees",content:n.jsxs("div",{children:[bo(He,"Fee deducted from the amount you receive"),bo(Qe,"Fee charged in addition to the amount you enter")]})},{condition:!xs&&!!ns(Y.estimated_route_duration_seconds),title:"Estimated time",content:n.jsx("span",{className:Fe.description,children:ns(Y.estimated_route_duration_seconds)})},{condition:Y.does_swap,title:"Slippage",content:n.jsxs("span",{className:Fe.description,children:[n.jsxs("span",{children:[w,"%"]}),n.jsx(Ln,{title:"Slippage tolerance",content:Te=>n.jsx(W_,{afterConfirm:Te}),className:Fe.edit,children:n.jsx(E.IconSettingFilled,{size:12,"aria-hidden":"true"})})]})},{condition:Y.does_swap,title:"Minimum received",content:n.jsxs("span",{className:Fe.description,children:[n.jsx("img",{src:I.logo_uri,alt:I.symbol,width:12,height:12}),C.formatAmount(J,{decimals:I.decimals})," ",I.symbol]})}].filter(Te=>Te.condition)},[Qe,He,I,bo,Y,xs,w]);return n.jsxs("form",{className:Fe.form,onSubmit:gt,"aria-label":"Bridge and swap form",children:[n.jsx(Go,{selectButton:n.jsx(vr,{type:"src"}),accountButton:M==="cosmos"&&n.jsx(wr,{type:"src"}),quantityInput:n.jsx(ts,{balance:q?.amount,decimals:N?.decimals}),balanceButton:n.jsx(qc,{onClick:()=>m("quantity",C.fromBaseUnit(q?.amount,{decimals:N?.decimals??0}),{shouldValidate:!0}),disabled:P,children:C.formatAmount(q?.amount??"0",{decimals:N.decimals})}),value:Y?ee(Y.usd_amount_in):"$-"}),n.jsxs("div",{className:Fe.arrow,children:[n.jsx("div",{className:Fe.divider}),n.jsx("button",{type:"button",className:Fe.flip,onClick:()=>Bt(),"aria-label":"Swap source and destination",children:n.jsx(E.IconChevronDown,{size:16,"aria-hidden":"true"})})]}),n.jsx(Go,{selectButton:n.jsx(vr,{type:"dst"}),accountButton:n.jsx(wr,{type:"dst"}),quantityInput:n.jsx(ts.ReadOnly,{children:Zt}),value:Y?ee(Y.usd_amount_out):"$-",hideNumbers:xs}),n.jsx(Xn,{children:xs?n.jsxs(Ls.Stack,{children:[n.jsx(Ls,{label:"Fast",query:ye,value:"default",onSelect:l,checked:c==="default"}),n.jsx(Ls,{label:"Lossless",query:we,value:"op",onSelect:l,checked:c==="op"})]}):null}),n.jsx(Ae,{extra:n.jsxs(n.Fragment,{children:[n.jsxs(xe.Stack,{children:[o&&n.jsx(xe,{level:"error",children:o}),Y?.extra_infos?.map(J=>n.jsx(xe,{level:"info",children:J},J)),Be&&n.jsx(xe,{level:"info",children:Be}),bl&&n.jsx(xe,{level:"warning",children:"Make sure to leave enough for transaction fee"}),Y?.warning&&n.jsx(xe,{level:"warning",children:Y.warning.message}),Y?.extra_warnings?.map(J=>n.jsx(xe,{level:"warning",children:J},J))]}),n.jsx(Xn,{children:Ha.length>0&&n.jsx("section",{className:Fe.meta,"aria-label":"Route details",children:Ha.map((J,Te)=>n.jsxs("div",{className:Fe.row,children:[n.jsx("span",{className:Fe.title,children:J.title}),J.content]},Te))})})]}),children:n.jsx(ue.White,{loading:r?"Refreshing route...":Dt&&"Simulating...",disabled:!!Ne||r,children:Ne??"Preview route"})})]})},ay=()=>{Lc();const e=hi(),t=Se(),s=Qt(),o=Am(),a=Ie.useForm({mode:"onChange",defaultValues:o}),{watch:r,setValue:i}=a,{srcChainId:c,dstChainId:l,srcDenom:d,dstDenom:m,quantity:u,slippagePercent:h,recipient:f}=r();r((I,{name:B})=>{(B==="srcChainId"||B==="srcDenom")&&i("quantity","",{shouldTouch:!1,shouldDirty:!1})});const g=Ec(),p=g(c),_=g(l),b=Ma()(f,l);y.useEffect(()=>{i("cosmosWalletName",void 0),i("sender",p)},[c,p,i]),y.useEffect(()=>{b||i("recipient",_)},[_,b,i]);const{showNotification:j}=us(),w=it(c),v=it(l),k=Ks(c),T=Ks(l),M=k.some(I=>I.denom===d),A=T.some(I=>I.denom===m);y.useEffect(()=>{k.length>0&&!M&&(i("srcDenom",k[0].denom),j({type:"info",title:`Switched to ${k[0].symbol}`,description:`The selected asset is not available on ${w.pretty_name}.`,autoHide:!0}))},[k,M,i,j,w.pretty_name]),y.useEffect(()=>{T.length>0&&!A&&(i("dstDenom",T[0].denom),j({type:"info",title:`Switched to ${T[0].symbol}`,description:`The selected asset is not available on ${v.pretty_name}.`,autoHide:!0}))},[T,A,i,j,v.pretty_name]),y.useEffect(()=>{!M||!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,m),localStorage.setItem(ie.BRIDGE_QUANTITY,u),localStorage.setItem(ie.BRIDGE_SLIPPAGE_PERCENT,h))},[c,d,l,m,u,h,M,A]);const L=e[0].path==="/bridge",{reminders:N}=Dn();return n.jsx(At,{title:"Bridge/Swap",backButton:L?"/":void 0,extra:n.jsxs(n.Fragment,{children:[n.jsx(ue.Small,{onClick:()=>t("/bridge/history"),unpadded:!0,"aria-label":"Bridge/Swap history",children:n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":"true",children:[n.jsx("path",{d:"m0 9.818 1.414-1.414 L2 8.99 V8 a7 7 0 1 1 7 7 v-2 a5 5 0 1 0-5-5 v1.354 l.95-.95 1.414 1.414 L3.182 13 0 9.818 Z"}),n.jsx("path",{d:"M9 5.5 H7.5 v3.75 h3.75 v-1.5 H9 V5.5 Z"})]})}),n.jsx(Tc,{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:M&&A&&n.jsx(Ie.FormProvider,{...a,children:n.jsx(pe,{children:n.jsx(oy,{})})})})},ry="_button_1crvp_1",iy="_checkbox_1crvp_11",cy="_checked_1crvp_25",As={button:ry,checkbox:iy,checked:cy},ly=({checked:e,onClick:t,label:s,className:o})=>n.jsxs("button",{type:"button",className:D(As.button,o),onClick:t,role:"checkbox","aria-checked":e,children:[n.jsx("div",{className:D(As.checkbox,{[As.checked]:e}),children:e&&n.jsx(E.IconCheck,{size:12,"aria-hidden":"true"})}),n.jsx("span",{className:As.label,children:s})]}),dy="_button_aoxv2_1",uy={button:dy},Uc=({onClick:e,disabled:t})=>{const{ref:s,inView:o}=Tl.useInView();return y.useEffect(()=>{o&&e()},[o,e]),n.jsxs("button",{className:uy.button,onClick:e,disabled:t,ref:s,children:[n.jsx("span",{children:"Load more"}),n.jsx(E.IconChevronDown,{size:12,"aria-hidden":"true"})]})};function Oc(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 qs=({chainId:e,txHash:t})=>`${ie.BRIDGE_HISTORY}:${e}:${t}`,Ws=100,Cr=10;function Vc(){const[e,t]=ze.useLocalStorage(ie.BRIDGE_HISTORY,[]),s=y.useCallback((a,r)=>{localStorage.setItem(qs(a),JSON.stringify(r));for(const i of e.slice(Ws-1))localStorage.removeItem(qs(i));t((i=[])=>[a,...i.slice(0,Ws-1)])},[e,t]),o=y.useCallback(a=>{const r=localStorage.getItem(qs(a));return r?JSON.parse(r):null},[]);return{history:e,addHistoryItem:s,getHistoryDetails:o}}function Kc(e){return ze.useLocalStorage(qs(e),null)}const bn=$e.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 go(){const{restUrl:e}=oe();return y.useMemo(()=>z.create({prefixUrl:e}),[e])}function my(e){const t=go(),{data:s}=S.useSuspenseQuery({queryKey:bn.bridge(e).queryKey,queryFn:()=>t.get(`opinit/ophost/v1/bridges/${e}`).json(),staleTime:K.INFINITY});return s}const Nr=20;function hy(e){const t=se();return S.useSuspenseInfiniteQuery({queryKey:bn.withdrawals(e,t).queryKey,queryFn:async({pageParam:s})=>{if(!t)return[];const o={limit:Nr,offset:s,order:"desc"},{withdrawals:a}=await z.create({prefixUrl:e}).get(`withdrawals/${t}`,{searchParams:o}).json();return a},getNextPageParam:s=>{const o=$.last(s)?.sequence;return s.length<Nr||!o||o<=1?null:o-1},initialPageParam:0,staleTime:K.SECOND})}function fy(e){const t=go(),{data:s}=S.useSuspenseQuery({queryKey:bn.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:K.SECOND});return s}function py({bridge_id:e,output_index:t}){const s=go(),{data:o}=S.useSuspenseQuery({queryKey:bn.output(e,t).queryKey,queryFn:async()=>{try{return await s.get(`opinit/ophost/v1/bridges/${e}/outputs/${t}`).json()}catch{return null}},staleTime:K.SECOND});return o}function gy({bridge_id:e,sequence:t}){const o=he().find(({metadata:l})=>l?.op_bridge_id===e.toString())?.chain_id;if(!o)throw new Error(`Chain not found for bridge_id: ${e}`);const r=Je()(o);if(!r)throw new Error(`Chain not found: ${o}`);const i=r.metadata?.executor_uri;if(!i)throw new Error(`Executor URL not found: ${o}`);const{data:c}=S.useSuspenseQuery({queryKey:bn.outputResponse(i,t).queryKey,queryFn:()=>z.create({prefixUrl:i}).get(`withdrawal/${t}`).json(),staleTime:K.SECOND});return c}function Wc(e,t){const{bridge_id:s}=e,o=go(),{data:a}=S.useSuspenseQuery({queryKey:bn.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:K.SECOND});return a}function Kn(e){return El.sha3_256.create().update(e).digest()}function Do(e,t){const s=new ArrayBuffer(t);return new DataView(s).setBigUint64(0,BigInt(e),!1),new Uint8Array(s)}function zc(e){const{bridge_id:t,sequence:s,amount:o,from:a,to:r}=e,i=Do(t.toString(),8),c=Do(s.toString(),8),l=Do(o.amount,8),d=rn.concatBytes(i,c,Kn(rn.utf8ToBytes(a)),Kn(rn.utf8ToBytes(r)),Kn(rn.utf8ToBytes(o.denom)),l);return Kn(Kn(d))}async function _y(e,t,s){try{return await z.get(`${e}/opinit/ophost/v1/bridges/${t}/migration_info/by_l1_denom`,{searchParams:{l1_denom:s}}).json(),!0}catch{return!1}}async function yy(e,t){const s=z.create({prefixUrl:t}),o=`cosmos/auth/v1beta1/account_info/${e}`;for(let a=1;a<=24;a++)try{return await s.get(o).json()}catch{await new Promise(r=>setTimeout(r,5e3))}throw new Error(`Timeout: ${e} not found`)}async function Jo(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 St(){return Xe()}function xy(e,t){const{customFee:s,onCompleted:o}=t??{},a=Se(),{showNotification:r,updateNotification:i,hideNotification:c}=us(),{addHistoryItem:l}=Vc(),d=qn(),{route:m,values:u}=St(),{srcChainId:h,sender:f,recipient:g,cosmosWalletName:p}=u,_=qi(),{requestTxSync:x,submitTxSync:b,waitForTxConfirmation:j}=et(),{find:w}=fo(),v=rs(),k=is(),T=it(h),M=es(T),A=$c(h),L=S.useQueryClient(),{registryUrl:N}=ne(),I=Je(),B=oe(),{addReminder:q}=Dn(),P=De();return S.useMutation({mutationFn:async()=>{try{if("cosmos_tx"in e){if(!e.cosmos_tx.msgs)throw new Error("Invalid transaction data");const F=e.cosmos_tx.msgs.map(({msg_type_url:qe,msg:Y})=>{if(!(qe&&Y))throw new Error("Invalid transaction data");return k.fromAmino({type:fn.aminoConverters[qe].aminoType,value:JSON.parse(Y)})});if(M==="initia"){const{srcDenom:qe,quantity:Y}=u,{decimals:ct}=A(qe),re=s?await b({messages:F,chainId:h,fee:s}):await x({messages:F,chainId:h,internal:1,spendCoins:[{denom:qe,amount:C.toBaseUnit(Y,{decimals:ct})}]}),Be=j({txHash:re,chainId:h});return{txHash:re,wait:Be}}const Q=w(p)?.getProvider();if(!Q)throw new Error("Wallet not connected");const W=Q.getOfflineSignerOnlyAmino(h),O=await Ee.SigningStargateClient.connectWithSigner(T.rpc,W,{registry:v,aminoTypes:k}),me=await O.getAllBalances(f),ge=T.fee_assets.find(qe=>me.some(Y=>Y.denom===qe.denom&&U(Y.amount).gt(0)));if(!ge){const Y=["Insufficient balance for fees.",`Available fee assets: ${T.fee_assets.map(ct=>A(ct.denom).symbol).join(", ")}`,"(note: asset symbols may refer to different tokens across chains)"].join(" ");throw new Error(Y)}const{denom:ce,gas_price:ye}=ge;if(!ye)throw new Error(`Gas price not found for ${ce}`);const we=await O.simulate(f,F,""),ve=Ee.GasPrice.fromString(ye.average+ce),tt=Ee.calculateFee(Math.ceil(we*pn),ve),Rt=await O.signAndBroadcastSync(f,F,tt),Tt=Yi({txHash:Rt,client:O});return{txHash:Rt,wait:Tt}}if("evm_tx"in e){const{chain_id:F,to:Q,value:W,data:O}=e.evm_tx,me=await _(),ge=await me.getSigner();await Jo(me,T);const ce=await ge.sendTransaction({chainId:F,to:Q,value:W,data:`0x${O}`}),ye=Pi(ce.wait(),3e4,"Transaction was not confirmed in time. It may still be processing.");return{txHash:ce.hash,wait:ye}}throw new Error("Unlisted chain type")}catch(F){throw F instanceof un?F:await Ct(F)}},onSuccess:async({txHash:F,wait:Q})=>{localStorage.removeItem(ie.BRIDGE_QUANTITY),L.removeQueries({queryKey:je.route._def}),L.removeQueries({queryKey:je.routeErrorInfo._def}),o?o({txhash:F,chainId:h,timestamp:Date.now(),success:!0,route:m,values:u}):(a(-1),r({type:"loading",title:"Transaction is pending..."}));try{await Q;const W=_o(m)==="OP Bridge withdrawal",O=W?{success:!0,error:null}:await Cy(P,F,h);if(!o&&!O.success&&O.error){const we=O.error instanceof Error?O.error.message:String(O.error);r({type:"error",title:"Transaction tracking failed",description:`Failed to track transaction: ${we}. The transaction may still be processing.`,autoHide:!0})}const me=O.success,ce=kr({txHash:F,srcChainId:h,route:m,values:u,recipient:g},me);l(ce.tx,ce.details),o||i(wy(c));const ye=Bo(u,F);if(d("Bridge Transaction Success",ye),W){const we=I(h).metadata?.op_bridge_id;if(we&&!await _y(B.restUrl,Number(we),m.dest_asset_denom)){const tt=jy(ce.tx,m,g);q(ce.tx,tt)}}}catch(W){const O=W instanceof Error?W.message:String(W);if(W instanceof un){const ge=kr({txHash:F,srcChainId:h,route:m,values:u},!1);l(ge.tx,ge.details),o||i(vy(c))}else o?o({success:!1,error:O,route:m,values:u}):i({type:"error",title:"Transaction not confirmed",description:O});d("Bridge Confirmation Failed",{...Bo(u,F),error:O,type:W instanceof un?"timeout":"error"})}finally{L.invalidateQueries({queryKey:je.balances(h,f).queryKey})}},onError:async F=>{const Q=M==="initia"?await Nn(F,I(h),N):F;o?o({success:!1,error:Q.message,route:m,values:u}):r({type:"error",title:"Transaction failed",description:Q.message});const W=Bo(u);d("Bridge Transaction Failed",{...W,error:Q.message})}})}function by(){const e=De(),t=se(),s=Mi(),{route:o,values:a}=St(),r=Pt();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:C.InitiaAddress(a.recipient).bech32,dest_asset_chain_id:o.dest_asset_chain_id,dest_asset_denom:o.dest_asset_denom}}).json();await yy(t,r(o.dest_asset_chain_id).rest);const l=c.map(({msg_type_url:u,msg:h})=>fn.aminoTypes.fromAmino({type:fn.aminoConverters[u].aminoType,value:JSON.parse(h)})),d=await s(i,t,l,{amount:[],gas:"1"},"",{incrementSequence:i===a.srcChainId?2:0}),m=Ge.Tx.fromPartial({body:Ge.TxBody.decode(d.bodyBytes),authInfo:Ge.AuthInfo.decode(d.authInfoBytes),signatures:d.signatures});return{signer:t,hook:ae.toBase64(Ge.Tx.encode(m).finish())}}catch(i){throw await Ct(i)}}})}function wy(e){return{type:"info",title:"Transaction submitted",description:y.createElement(y.Fragment,null,"Check ",y.createElement(dn,{to:"/bridge/history",onClick:e},"the activity page")," for transaction status"),autoHide:!0}}function vy(e){return{type:"info",title:"Transaction pending",description:y.createElement(y.Fragment,null,"Confirmation is taking longer than expected. Check ",y.createElement(dn,{to:"/bridge/history",onClick:e},"the activity page")," for updates"),autoHide:!0}}function Bo(e,t){return{quantity:e.quantity,srcChainId:e.srcChainId,srcDenom:e.srcDenom,dstChainId:e.dstChainId,dstDenom:e.dstDenom,txHash:t}}function kr(e,t){const{txHash:s,srcChainId:o,route:a,values:r}=e,i={chainId:o,txHash:s},c=_o(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 jy(e,t,s){return{...e,recipient:C.InitiaAddress(s).bech32,claimableAt:Date.now()+t.estimated_route_duration_seconds*1e3,amount:t.amount_out,denom:t.dest_asset_denom}}async function Cy(e,t,s){for(let r=0;r<=30;r++)try{return await e.post("v2/tx/track",{json:{tx_hash:t,chain_id:s}}).json(),{success:!0,error:null}}catch(i){if(r===30)return{success:!1,error:await Ct(i)};await new Promise(c=>setTimeout(c,1e3))}return{success:!1,error:new Error("Maximum retries exceeded")}}function Hc(e){const{chainId:t,txHash:s,tracked:o}=e,a=De();return S.useQuery({queryKey:je.txTrack(t,s).queryKey,queryFn:async()=>{try{return await a.post("v2/tx/track",{json:{tx_hash:s,chain_id:t}}).json()}catch(r){throw await Ct(r)}},select:({tx_hash:r})=>r,retry:6,retryDelay:5e3,staleTime:K.INFINITY,enabled:!o})}function Qc(e){const{timestamp:t,chainId:s,txHash:o,tracked:a,state:r}=e,i=De();return S.useQuery({queryKey:je.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,m=Date.now(),u=Math.floor((d-m)/1e3);return u<=0?1e3:u<=300?5e3:60*1e3},staleTime:K.INFINITY})}var Qn=(e=>(e.OP_WITHDRAW="OP Bridge withdrawal",e.SKIP="Skip",e))(Qn||{});function _o(e){const{operations:t,dest_asset_denom:s}=e;return $.has("op_init_transfer",$.head(t))&&s==="uinit"?"OP Bridge withdrawal":"Skip"}const Ny="_success_t4dfk_1",ky="_error_t4dfk_5",Ir={success:Ny,error:ky},Iy=({tx:e})=>{const[t,s]=Kc(e);if(!t)throw new Error("Bridge history details not found");const{data:o}=Qc(t),a=t.state??Ay(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:Ir.error,children:n.jsx(E.IconCloseCircleFilled,{size:14})});case"success":return n.jsx("div",{className:Ir.success,children:n.jsx(E.IconCheckCircleFilled,{size:14})});default:return n.jsx(Nt,{size:14})}};function Ay(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 Sy="_link_104m3_1",Ty="_header_104m3_23",Ey="_title_104m3_31",$y="_date_104m3_37",My="_explorer_104m3_41",Ly="_fees_104m3_57",qy="_label_104m3_65",Py="_content_104m3_69",Ry="_route_104m3_75",Dy="_row_104m3_80",By="_asset_104m3_86",Fy="_amount_104m3_94",Uy="_chain_104m3_99",Oy="_account_104m3_108",Vy="_arrow_104m3_115",Me={link:Sy,header:Ty,title:Ey,date:$y,explorer:My,fees:Ly,label:qy,content:Py,route:Ry,row:Dy,asset:By,amount:Fy,chain:Uy,account:Oy,arrow:Vy},Ky=({tx:e})=>{const[t,s]=Kc(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}=Hc(t),{address:m="",connector:u}=We.useAccount(),{find:h}=fo();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:g,source_asset_chain_id:p,source_asset_denom:_,dest_asset_chain_id:x,dest_asset_denom:b,estimated_fees:j=[]}=r,w=it(p),v=it(x),k=kt(_,p),T=kt(b,x),M=(P,F)=>F?n.jsx(te,{src:F,width:12,height:12}):C.InitiaAddress.equals(P,m)?n.jsx(te,{src:u?.icon,width:12,height:12}):n.jsx(E.IconWallet,{size:12}),A=(P,{symbol:F,decimals:Q,logo_uri:W},{chain_name:O,pretty_name:me,...ge},ce,ye)=>n.jsxs("div",{className:Me.row,children:[n.jsx(po,{assetLogoUrl:W,chainLogoUrl:ge.logo_uri??void 0}),n.jsxs("div",{children:[n.jsxs("div",{className:Me.asset,children:[n.jsx("span",{className:Me.amount,children:C.formatAmount(P,{decimals:Q})}),n.jsx("span",{children:F})]}),n.jsxs("div",{className:Me.chain,children:[n.jsxs("span",{children:["on ",me||O]}),n.jsxs("div",{className:Me.account,children:[ye,n.jsx("span",{className:"monospace",children:C.truncate(ce)})]})]})]})]}),L=_o(r),N=y.useMemo(()=>{switch(L){case Qn.SKIP:return"Skip Explorer";case Qn.OP_WITHDRAW:return"Initia Scan"}},[L]),I=n.jsxs(n.Fragment,{children:[n.jsxs("header",{className:Me.header,children:[n.jsxs("div",{className:Me.title,children:[l?n.jsx(Iy,{tx:e}):n.jsx(Nt,{size:14}),n.jsx("div",{className:Me.date,children:Ze.format(new Date(c),"h:mm a")})]}),n.jsxs("div",{className:Me.explorer,children:[n.jsx("span",{children:N}),n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})]})]}),n.jsxs("div",{className:Me.route,children:[A(f,k,w,i.sender,M(i.sender,h(i.cosmosWalletName)?.image)),n.jsx("div",{className:Me.arrow,children:n.jsx(E.IconArrowDown,{size:12,"aria-hidden":"true"})}),A(g,T,v,i.recipient,M(i.recipient))]}),j.length>0&&n.jsxs("div",{className:Me.fees,children:[n.jsx("span",{className:Me.label,children:"Fees"}),n.jsx("span",{className:Me.content,children:qa(j)})]})]});if(L===Qn.OP_WITHDRAW)return n.jsx(mo,{chainId:o,txHash:a,className:Me.link,children:I});const B=new URLSearchParams({tx_hash:a,chain_id:o}),q=new URL(`?${B.toString()}`,"https://explorer.skip.build");return n.jsx("a",{href:q.toString(),className:Me.link,target:"_blank",rel:"noopener noreferrer",children:I})},Wy="_history_13u9z_1",zy="_header_13u9z_5",Hy="_checkbox_13u9z_9",Qy="_groups_13u9z_13",Gy="_dateGroup_13u9z_21",Yy="_dateHeader_13u9z_26",Zy="_list_13u9z_32",nn={history:Wy,header:zy,checkbox:Hy,groups:Qy,dateGroup:Gy,dateHeader:Yy,list:Zy},Jy=()=>{const{initiaAddress:e,hexAddress:t}=et(),{history:s,getHistoryDetails:o}=Vc(),a=s.filter(f=>o(f)),r=a.filter(f=>{const g=o(f);if(!g)return!1;const{values:p}=g,{sender:_,recipient:x}=p;return[_,x].some(b=>[e,t].includes(b))}),[i,c]=y.useState(1),[l,d]=ze.useToggle(!r.length),m=l?a:r,u=m.slice(0,i*Cr),h=y.useMemo(()=>Oc(u,f=>{const g=o(f);if(g)return new Date(g.timestamp)}),[u,o]);return n.jsx(At,{title:"Bridge/Swap activity",children:n.jsxs("div",{className:nn.history,children:[a.length>0&&a.length!==r.length&&n.jsx("header",{className:nn.header,children:n.jsx(ly,{checked:l,onClick:d,label:"Show all transactions stored in this browser",className:nn.checkbox})}),m.length===0?n.jsx(be,{children:"No bridge/swap activity"}):n.jsx("div",{className:nn.groups,children:Object.entries(h).map(([f,g])=>n.jsxs("div",{className:nn.dateGroup,children:[n.jsx("div",{className:nn.dateHeader,children:f}),n.jsx("div",{className:nn.list,children:g.map(p=>n.jsx(pe,{children:n.jsx(Ky,{tx:p})},p.txHash))})]},f))}),m.length>i*Cr?n.jsx(Uc,{onClick:()=>c(f=>f+1)}):s.length>=Ws&&n.jsxs(be,{children:["Only the latest ",Ws," items are stored. Older entries will be removed automatically."]})]})})};function Gc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}){return{...e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:a}}function Xy({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Gc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!0})}function ex({currentState:e,route:t,values:s,quoteVerifiedAt:o}){return Gc({currentState:e,route:t,values:s,quoteVerifiedAt:o,requiresReconfirm:!1})}const tx=1e4;function Xo(e){return e===void 0?"undefined":e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Xo).join(",")}]`:`{${Object.entries(e).toSorted(([t],[s])=>t.localeCompare(s)).map(([t,s])=>`${JSON.stringify(t)}:${Xo(s)}`).join(",")}}`}function Ar(e){return Xo({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 nx(e,t,s){const o=Se(),a=Xe(),r=S.useQueryClient(),i=De(),[c,l]=y.useState(!1),[d,m]=y.useState(void 0),[u,h]=y.useState(s??0),f=y.useRef(null);return y.useEffect(()=>{h(s??0)},[s]),y.useEffect(()=>()=>{f.current?.abort()},[]),{refreshRouteIfNeeded:async()=>{const p=Math.max(s??0,u);if(Date.now()-p<=tx)return!1;l(!0),m(void 0);const _=new AbortController;f.current=_;try{const x=await Dc(i,r,t,{isOpWithdraw:_o(e)===Qn.OP_WITHDRAW,signal:_.signal});if(_.signal.aborted)return!0;const b=Ar(x)!==Ar(e),j=Date.now();return b?(o(0,Xy({currentState:a,route:x,values:t,quoteVerifiedAt:j})),!0):(h(j),!1)}catch(x){return x instanceof DOMException&&x.name==="AbortError"||_.signal.aborted||m((await Ct(x)).message),!0}finally{f.current===_&&(f.current=null),_.signal.aborted||l(!1)}},isRefreshing:c,refreshError:d,clearRefreshError:()=>m(void 0)}}function sx(e,t){return t?"Confirm updated route":e||"Confirm"}const Ra=({tx:e,fee:t,onCompleted:s,confirmMessage:o,error:a})=>{const r=Se(),i=Xe(),{route:c,values:l,quoteVerifiedAt:d,requiresReconfirm:m}=St(),{mutate:u,isPending:h}=xy(e,{customFee:t,onCompleted:s}),{refreshRouteIfNeeded:f,isRefreshing:g,refreshError:p,clearRefreshError:_}=nx(c,l,d),x=async()=>{if(!(h||g)){if(m){r(0,ex({currentState:i,route:c,values:l,quoteVerifiedAt:d??Date.now()}));return}await f()||(_(),u())}},b=a??p??(m?"Route updated. Please review and confirm again.":void 0);return n.jsx(Ae,{extra:b&&n.jsx(xe,{level:a||p?"error":"info",children:b}),children:n.jsx(ue.White,{onClick:x,loading:g?"Refreshing route...":h&&"Signing transaction...",disabled:!!a,children:sx(o,!!m)})})},ox="_content_1hzj2_1",ax="_info_1hzj2_6",rx="_arrow_1hzj2_11",ix="_divider_1hzj2_19",cx="_type_1hzj2_27",lx="_asset_1hzj2_47",dx="_amount_1hzj2_55",ux="_lower_1hzj2_60",mx="_chain_1hzj2_66",hx="_address_1hzj2_72",st={content:ox,info:ax,arrow:rx,divider:ix,type:cx,asset:lx,amount:dx,lower:ux,chain:mx,address:hx},Yc=e=>{const{source:t,label:s,amount:o,denom:a,chainId:r,address:i,walletIcon:c}=e,{symbol:l=C.truncate(a),decimals:d=0,logo_uri:m=da}=e,{chain_name:u,pretty_name:h,...f}=it(r);return n.jsxs("div",{children:[!t&&n.jsxs("div",{className:st.arrow,children:[n.jsx("div",{className:st.divider}),s?n.jsx(ps,{label:s,children:n.jsx("button",{className:st.type,children:n.jsx(E.IconArrowDown,{size:12})})}):n.jsx("span",{className:st.type,children:n.jsx(E.IconArrowDown,{size:12})}),n.jsx("div",{className:st.divider})]}),n.jsxs("div",{className:st.content,children:[n.jsx(po,{assetLogoUrl:m,chainLogoUrl:f.logo_uri??void 0}),n.jsxs("div",{className:st.info,children:[n.jsxs("div",{className:st.asset,children:[n.jsx("span",{className:st.amount,children:C.formatAmount(o,{decimals:d})}),n.jsx("span",{children:l})]}),n.jsxs("div",{className:st.lower,children:[n.jsxs("div",{className:st.chain,children:["on ",h||u]}),i&&n.jsx(Os,{value:i,children:({copy:g,copied:p})=>n.jsxs("button",{className:st.address,onClick:g,children:[c,p?n.jsx("span",{children:"Copied!"}):n.jsx("span",{className:"monospace",children:C.truncate(i)})]})})]})]})]})]})},An=e=>{const t=kt(e.denom,e.chainId);return n.jsx(Yc,{...e,...t})};An.Placeholder=Yc;const fx="_root_1hbar_1",px="_flexEnd_1hbar_6",gx="_toggle_1hbar_11",_x="_route_1hbar_36",yx="_content_1hbar_43",Wn={root:fx,flexEnd:px,toggle:gx,route:_x,content:yx};function xx(e){const t=({name:s})=>s==="initia-dex"?"Initia DEX":Qs.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 bx=({addressList:e})=>{const{values:t,route:s}=St(),{source_asset_denom:o,source_asset_chain_id:a,amount_in:r,operations:i}=s,c=$.zipObj(s.required_chain_addresses,e),{find:l}=fo(),{connector:d,address:m=""}=We.useAccount(),[u,h]=ze.useToggle(!1),f=i.length>1,g=n.jsx(te,{src:t.cosmosWalletName?l(t.cosmosWalletName)?.image:d?.icon,width:12,height:12}),p={amount:r,denom:o,chainId:a,address:t.sender,walletIcon:g},_=v=>C.InitiaAddress.equals(v,m)?g:n.jsx(E.IconWallet,{size:11}),x=v=>{const{label:k,amount_out:T,denom:M,denom_out:A=M,chain_id:L,from_chain_id:N,to_chain_id:I=L??N}=v,B=c[I];return{label:f&&!u?void 0:k,amount:T,denom:A,chainId:I,address:B,walletIcon:_(B)}},b=i.map(xx).map(x),j=b.slice(0,-1),w=b[b.length-1];return n.jsxs(Z.Collapsible.Root,{className:Wn.root,open:u,onOpenChange:h,children:[f&&n.jsx("div",{className:Wn.flexEnd,children:n.jsx(Z.Collapsible.Trigger,{className:Wn.toggle,children:u?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:Wn.route,children:[n.jsx(An,{...p,source:!0}),n.jsx(Z.Collapsible.Content,{className:Wn.content,children:j.map((v,k)=>n.jsx(pe,{suspenseFallback:n.jsx(An.Placeholder,{...v}),errorBoundaryProps:{fallback:n.jsx(An.Placeholder,{...v})},children:n.jsx(An,{...v})},k))}),n.jsx(An,{...w})]})]})},Zc=({error:e})=>{const t=Se();return n.jsx(Ae,{extra:n.jsx(xe,{level:"error",children:e.message}),children:n.jsx(ue.White,{onClick:()=>t("/bridge"),children:"Home"})})},Jc=({children:e})=>{const t=St(),{route:s,values:o}=t,{required_chain_addresses:a}=s,{srcChainId:r,dstChainId:i,sender:c,recipient:l}=o,{initiaAddress:d,hexAddress:m}=et(),u=cs(),h=Pt(),f=ms(),g=h(r),p=f(g),_=a.slice(0,-1).some(T=>{const M=h(T);return f(M)==="cosmos"})&&p!=="cosmos",[x,b]=y.useState(void 0),[j,w]=y.useState(!1),[v,k]=y.useState(null);if(y.useEffect(()=>{(async()=>{try{if(!_)return;if(!u)throw new Error("Wallet not connected");w(!0),k(null);const[{pubkey:M}]=await u.getAccounts();b(M)}catch(M){k(await Ct(M))}finally{w(!1)}})()},[_,u]),v)return n.jsx(Zc,{error:v});if(j)return n.jsx(Ae,{children:n.jsx(ue.White,{loading:j&&"Generating intermediary addresses..."})});if(!_||x){const T=a.map((M,A)=>{if(A===a.length-1){const q=h(i);return f(q)==="initia"?C.InitiaAddress(l).bech32:l}const L=h(M),N=f(L),I=h(r),B=f(I);switch(N){case"initia":return d;case"evm":return m;case"cosmos":{if(B==="cosmos")return ae.toBech32(L.bech32_prefix,ae.fromBech32(c).data);if(!x)throw new Error("Pubkey not found");return Tn.pubkeyToAddress(Tn.encodeSecp256k1Pubkey(x),L.bech32_prefix)}default:throw new Error("Unlisted chain type")}});return e(T)}return null},Da=({tx:e,children:t})=>{const s=qi(),o=Pt(),a=S.useQueryClient(),{data:r,isLoading:i}=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:h}=e.evm_tx,f=await s();await Jo(f,o(u));const g=["function allowance(address owner, address spender) view returns (uint256)"];return(await Promise.all(e.evm_tx.required_erc20_approvals.map(async _=>{const{token_contract:x,spender:b}=_,w=await new vt.ethers.Contract(x,g,f).allowance(h,b);return{approval:_,currentAllowance:BigInt(w.toString())}}))).filter(({approval:_,currentAllowance:x})=>x<BigInt(_.amount)).map(({approval:_})=>_)},enabled:!!e&&"evm_tx"in e&&!!e.evm_tx.required_erc20_approvals}),{mutate:c,data:l,isPending:d,error:m}=S.useMutation({mutationFn:async()=>{try{if(!("evm_tx"in e))throw new Error("Transaction is not EVM");if(!r||r.length===0)throw new Error("No approvals needed");const{chain_id:u}=e.evm_tx,h=await s(),f=await h.getSigner();await Jo(h,o(u));for(const g of r){const{token_contract:p,spender:_,amount:x}=g,b=["function approve(address spender, uint256 amount) external returns (bool)"],w=await new vt.ethers.Contract(p,b,f).approve(_,x);await Pi(w.wait(),3e4,"Approval was not confirmed in time. It may still be processing.")}return!0}catch(u){throw u instanceof un?(a.invalidateQueries({queryKey:["interwovenkit:erc20-approvals-needed",e]}),u):await Ct(u)}}});return i?n.jsx(Ae,{children:n.jsx(ue.White,{loading:"Checking approvals..."})}):r&&r.length>0&&!l?n.jsx(Ae,{extra:n.jsx(xe,{level:"error",children:m?.message}),children:n.jsx(ue.White,{onClick:()=>c(),loading:d&&"Approving tokens...",children:"Approve tokens"})}):t},Xc=({addressList:e,signedOpHook:t,children:s})=>{const o=De(),{route:a,values:r}=St(),[i,c]=y.useState(void 0),[l,d]=y.useState(!1),[m,u]=y.useState(null),h=JSON.stringify(e),f=JSON.stringify(a.operations),g=JSON.stringify(t??null),p=y.useMemo(()=>e,[h]),_=y.useMemo(()=>a.operations,[f]),x=y.useMemo(()=>t,[g]);return y.useEffect(()=>{let b=!1;return(async()=>{try{if(a.required_op_hook&&!x)throw new Error("Op hook is required");d(!0),u(null);const w={address_list:p,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:v}=await o.post("v2/fungible/msgs",{json:w}).json();if(b)return;if(!v||v.length===0)throw new Error("No transaction data found");const[k]=v;c(k)}catch(w){if(b)return;u(w)}finally{b||d(!1)}})(),()=>{b=!0}},[p,_,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]),m?n.jsx(Zc,{error:m}):l||!i?n.jsx(Ae,{children:n.jsx(ue.White,{loading:"Fetching messages..."})}):s(i)},el=({children:e})=>{const{route:t}=St(),s=by();return t.required_op_hook&&!s.data?n.jsx(Ae,{extra:n.jsx(xe,{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)},wx=()=>n.jsx(At,{title:"Route preview",children:n.jsx(Jc,{children:e=>n.jsxs(n.Fragment,{children:[n.jsx(bx,{addressList:e}),n.jsx(el,{children:t=>n.jsx(Xc,{addressList:e,signedOpHook:t,children:s=>n.jsx(Da,{tx:s,children:n.jsx(Ra,{tx:s})})})})]})})}),tl=y.createContext(null);function yo(){return y.useContext(tl)}const vx="_button_17r1o_1",jx="_claimed_17r1o_24",Sr={button:vx,claimed:jx},Cx=()=>{const{withdrawalTx:e}=yo(),{bridge_id:t,sequence:s,amount:o,output_index:a,withdrawal_proofs:r,storage_root:i,from:c,to:l,version:d}=e,m=oe(),u=se(),{requestTxSync:h,waitForTxConfirmation:f}=et(),g=gy(e),p=ae.toBase64(zc(e)),_=Wc(e,p),x=S.useQueryClient(),{mutate:b,isPending:j}=S.useMutation({mutationFn:async()=>{if(!g)throw new Error("Output not found");const{last_block_hash:w}=g;return h({chainId:m.chain_id,messages:[{typeUrl:"/opinit.ophost.v1.MsgFinalizeTokenWithdrawal",value:{sender:u,bridgeId:BigInt(t),outputIndex:BigInt(a),withdrawalProofs:r.map(ae.fromBase64),from:c,to:l,sequence:BigInt(s),amount:o,version:ae.fromBase64(d),storageRoot:ae.fromBase64(i),lastBlockHash:ae.fromBase64(w)}}],internal:!0})},onSuccess:async w=>{await f({chainId:m.chain_id,txHash:w}),x.invalidateQueries({queryKey:bn.withdrawalClaimed(t,p).queryKey})}});return _?n.jsxs("div",{className:Sr.claimed,children:[n.jsx(E.IconCheckCircleFilled,{size:14}),n.jsx("span",{children:"Claimed"})]}):n.jsx("button",{className:Sr.button,onClick:()=>b(),disabled:j,children:"Claim"})},Nx=({children:e})=>{const{withdrawalTx:t}=yo(),s=my(t.bridge_id),o=py(t),a=y.useMemo(()=>{if(!o)return null;const{bridge_config:r}=s,{output_proposal:i}=o;return Ze.addSeconds(new Date(i.l1_block_time),parseFloat(r.finalization_period))},[s,o]);return e(a)},nl=1e3,kx=60,Ix=60,Ax=24,ea=nl*kx,ta=ea*Ix,Tr=ta*Ax,Sx=({date:e})=>{const t=y.useCallback(()=>{const d=new Date().getTime(),u=e.getTime()-d;if(u<=0)return{days:0,hours:0,minutes:0,seconds:0};const h=Math.floor(u/Tr),f=Math.floor(u%Tr/ta),g=Math.floor(u%ta/ea),p=Math.floor(u%ea/nl);return{days:h,hours:f,minutes:g,seconds:p}},[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(ps,{label:e.toLocaleString(),children:n.jsxs("span",{className:"monospace",children:[r,"d ",a(i),"h ",a(c),"m ",a(l),"s"]})})},Tx="_container_1lz3w_1",Ex="_title_1lz3w_5",Er={container:Tx,title:Ex},$x=({date:e})=>n.jsxs("div",{className:Er.container,children:[n.jsx("div",{className:Er.title,children:"Claimable in"}),n.jsx(Sx,{date:e})]}),Mx="_container_1oldz_1",Lx="_icon_1oldz_7",$r={container:Mx,icon:Lx},qx="Withdrawal will begin within an hour",Mr=()=>{const e=lo();return n.jsxs("div",{className:$r.container,children:[n.jsx("span",{children:"In progress"}),!e&&n.jsx(ps,{label:qx,children:n.jsx("span",{className:$r.icon,children:n.jsx(E.IconInfoFilled,{size:12})})})]})},Px=({children:e})=>{const{withdrawalTx:t}=yo(),s=fy(t.bridge_id),o=t.output_index>Number(s?.output_index);return e(o)},Rx=({date:e,children:t})=>{const{chainId:s,withdrawalTx:o}=yo(),a=ae.toBase64(zc(o)),r=Wc(o,a),{setReminder:i,removeReminder:c}=Dn();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:Ze.isPast(e.getTime())?!0:void 0})},[s,r,e,c,i,o]),t},Dx=()=>n.jsx(Px,{children:e=>e?n.jsx(Mr,{}):n.jsx(Nx,{children:t=>t?n.jsx(Rx,{date:t,children:Ze.isFuture(t)?n.jsx($x,{date:t}):n.jsx(Cx,{})}):n.jsx(Mr,{})})}),Bx="_asset_6h8u2_1",Fx="_info_6h8u2_7",Ux="_symbol_6h8u2_11",Fo={asset:Bx,info:Fx,symbol:Ux},Ox=({amount:e,denom:t})=>{const s=oe(),o=ii(t,s),{symbol:a,logoUrl:r,decimals:i}=o;return n.jsxs("div",{className:Fo.asset,children:[n.jsx(te,{src:r,width:32,height:32,logo:!0}),n.jsxs("div",{className:Fo.info,children:[n.jsx("span",{className:"monospace",children:C.formatAmount(e,{decimals:i})}),n.jsx("span",{className:Fo.symbol,children:a})]})]})},Vx="_item_km5w2_1",Kx={item:Vx},Wx=({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}=hy(t),i=y.useMemo(()=>s?.pages.flat()??[],[s]),{syncReminders:c}=Dn();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:Kx.item,children:[n.jsx(Ox,{...d}),n.jsx(pe,{suspenseFallback:null,children:n.jsx(tl.Provider,{value:{chainId:e.chainId,withdrawalTx:l},children:n.jsx(Dx,{})})})]},l.sequence)}),a&&n.jsx(Uc,{onClick:()=>o(),disabled:r})]}):n.jsx(be,{children:"No withdrawals"})},zx="_content_dj1qm_1",Hx="_title_dj1qm_5",Lr={content:zx,title:Hx},Qx=()=>{const{chainId:e}=Xe(),t=he(),s=yn(),[o,a]=y.useState(e??(s.metadata?.is_l1?"":s.chainId)),r=Je(),{reminders:i}=Dn(),c=o?r(o):void 0;return n.jsxs(At,{title:"OP Bridge withdrawals",children:[n.jsx(mn,{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:Lr.content,children:c?n.jsxs(n.Fragment,{children:[n.jsx("h2",{className:Lr.title,children:c.name}),n.jsx(pe,{children:n.jsx(Wx,{chain:c})},o)]}):n.jsx(xe,{level:"info",children:"Select a chain to display your OP Bridge withdrawals"})})]})},zs=e=>e.toLowerCase().trim().replace(/\s+(wallet|extension|app)$/,""),Gx="5722e7dffb709492cf5312446ceeff73",Yx=`https://explorer-api.walletconnect.com/v3/wallets?projectId=${Gx}`,sl=["interwovenkit:walletconnect-wallets"],Zx=e=>e!==null&&typeof e=="object"&&"id"in e&&typeof e.id=="string"&&"name"in e&&typeof e.name=="string",ol=async e=>{const t=await z.get(Yx,{signal:e}).json(),s=t!==null&&typeof t=="object"&&"listings"in t?t.listings:t;return Object.values(s??{}).filter(Zx)},Jx=()=>S.useQuery({queryKey:sl,queryFn:({signal:e})=>ol(e),staleTime:K.INFINITY,gcTime:K.INFINITY,retry:2}),Xx="_page_13y8q_1",e1="_pageTop_13y8q_19",t1="_backButtonFixed_13y8q_63",n1="_listItem_13y8q_64",s1="_socialButton_13y8q_65",o1="_arrowIcon_13y8q_66",a1="_searchInputUnderline_13y8q_67",r1="_header_13y8q_72",i1="_title_13y8q_81",c1="_headerSpacer_13y8q_116",l1="_icon_13y8q_120",d1="_installedText_13y8q_124",u1="_divider_13y8q_131",m1="_dividerText_13y8q_152",h1="_loading_13y8q_193",f1="_socialIcons_13y8q_198",p1="_socialText_13y8q_204",g1="_searchWrapper_13y8q_214",_1="_scrollable_13y8q_248",y1="_list_13y8q_64",x1="_listIconWrapper_13y8q_332",b1="_moreIconSmall_13y8q_342",w1="_externalLinkIcon_13y8q_364",v1="_listName_13y8q_368",j1="_listNameMuted_13y8q_381",C1="_recentBadge_13y8q_394",N1="_learnMoreLink_13y8q_408",V={page:Xx,pageTop:e1,backButtonFixed:t1,listItem:n1,socialButton:s1,arrowIcon:o1,searchInputUnderline:a1,header:r1,title:i1,headerSpacer:c1,icon:l1,installedText:d1,divider:u1,dividerText:m1,loading:h1,socialIcons:f1,socialText:p1,searchWrapper:g1,scrollable:_1,list:y1,listIconWrapper:x1,moreIconSmall:b1,externalLinkIcon:w1,listName:v1,listNameMuted:j1,recentBadge:C1,learnMoreLink:N1},k1=e=>{try{const t=new URL(e.trim());return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}},I1=({walletConnectors:e,isPending:t,pendingConnectorId:s,recentConnectorId:o,onConnect:a,onBack:r})=>{const[i,c]=y.useState(""),{data:l=[],isError:d,isLoading:m,isFetching:u}=Jx(),h=m||u&&l.length===0,f=y.useMemo(()=>{if(!i)return e;const p=i.toLowerCase();return e.filter(_=>_.name.toLowerCase().includes(p))},[e,i]),g=y.useMemo(()=>{const p=new Set(e.map(x=>zs(x.name))),_=i.toLowerCase();return l.filter(x=>!p.has(zs(x.name))).filter(x=>!i||x.name.toLowerCase().includes(_)).sort((x,b)=>x.name.localeCompare(b.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(gs,{rootClassName:V.searchInputUnderline,placeholder:"Search Wallet","aria-label":"Search wallets",value:i,onChange:p=>c(p.target.value),onClear:()=>c("")})}),n.jsx(pt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[f.map(p=>{const{name:_,icon:x,id:b}=p,j=o===b,w=s===b,v="ready"in p?!!p.ready:!0;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:w}),onClick:()=>a(p),disabled:t||!v,"aria-busy":w,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(te,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:_}),w?n.jsx(Nt,{size:16}):j?n.jsx("span",{className:V.recentBadge,children:"Recent"}):v?n.jsx("span",{className:V.installedText,children:"Installed"}):null]},`connector:${b}`)}),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(Nt,{size:16})}),n.jsx("span",{className:V.listNameMuted,children:"Loading more wallets..."})]}),g.map(p=>{const _=p.image_url?.sm||p.image_url?.md||p.image_url?.lg,x=_&&k1(_)?_:void 0;return n.jsxs("button",{type:"button",className:V.listItem,disabled:!0,"aria-label":`${p.name} (not installed)`,children:[n.jsx("div",{className:V.listIconWrapper,children:x&&n.jsx(te,{src:x,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:p.name})]},`wc:${p.id}`)}),d&&n.jsx(xe,{level:"error",children:"Couldn't load additional wallets."})]})})]})},A1=()=>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"})]}),S1=()=>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"})]}),T1=()=>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"})}),E1=()=>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"})]}),$1=[{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"}],M1=({walletConnectors:e,privyConnector:t,isPending:s,pendingConnectorId:o,recentConnectorId:a,onConnect:r,onShowAll:i,onPrefetchWallets:c})=>{const l=e.filter(g=>!("ready"in g)||!!g.ready),d=l.slice(0,5),m=new Set(l.map(g=>g.id)),u=new Set(l.map(g=>zs(g.name))),h=Math.max(0,5-d.length),f=$1.filter(g=>!m.has(g.id)&&!u.has(zs(g.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(Nt,{size:16}):n.jsxs("div",{className:V.socialIcons,children:[n.jsx(S1,{}),n.jsx(E1,{}),n.jsx(T1,{})]})]}),n.jsx("div",{className:V.divider,children:n.jsx("span",{className:V.dividerText,children:"or"})})]}),n.jsx(pt,{className:V.scrollable,children:n.jsxs("div",{className:V.list,children:[d.map(g=>{const{name:p,icon:_,id:x}=g,b=o===x,j=a===x;return n.jsxs("button",{type:"button",className:D(V.listItem,{[V.loading]:b}),onClick:()=>r(g),disabled:s,"aria-busy":b,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(te,{src:_,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listName,children:p}),b?n.jsx(Nt,{size:16}):j?n.jsx("span",{className:V.recentBadge,children:"Recent"}):n.jsx("span",{className:V.installedText,children:"Installed"})]},x)}),f.map(g=>n.jsxs("a",{className:V.listItem,href:g.url,target:"_blank",rel:"noopener noreferrer","aria-label":`${g.name} (opens in new tab)`,children:[n.jsx("div",{className:V.listIconWrapper,children:n.jsx(te,{src:g.icon,width:26,height:26,alt:"",className:V.icon})}),n.jsx("span",{className:V.listNameMuted,children:g.name}),n.jsx(E.IconExternalLink,{size:10,className:V.externalLinkIcon,"aria-hidden":"true"})]},g.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(A1,{})})}),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"})]})]})},qr=({onSuccess:e})=>{const{connectors:t,connectAsync:s}=We.useConnect(),o=ze.useReadLocalStorage("wagmi.recentConnectorId"),[a,r]=y.useState(null),[i,c]=y.useState("signin"),l=S.useQueryClient(),d=()=>l.prefetchQuery({queryKey:sl,queryFn:({signal:p})=>ol(p),staleTime:K.INFINITY,gcTime:K.INFINITY}),{mutate:m,isPending:u}=S.useMutation({mutationFn:async p=>{try{await s({connector:p})}catch(_){throw await Ct(_)}},onMutate:p=>{r(p.id)},onSettled:()=>{r(null)},onSuccess:()=>{e?.()}}),h=y.useMemo(()=>[...t].sort((p,_)=>p.id===o?-1:_.id===o?1:p.name.localeCompare(_.name)),[t,o]),f=y.useMemo(()=>h.find(p=>p.id===Yn.id),[h]),g=y.useMemo(()=>h.filter(p=>p.id!==Yn.id),[h]);return i==="all"?n.jsx(I1,{walletConnectors:g,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onBack:()=>c("signin")}):n.jsx(M1,{walletConnectors:g,privyConnector:f,isPending:u,pendingConnectorId:a,recentConnectorId:o,onConnect:m,onShowAll:()=>c("all"),onPrefetchWallets:d})},L1="iUSD",Pr="1",q1="0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",P1="0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a",R1={[L1]:{externalSourceSymbols:["USDC","AUSD"],extraExternalOptions:[{chainId:Pr,denom:q1},{chainId:Pr,denom:P1}],extraInitiaSourceSymbols:["USDC"],externalChainListSource:"extra-options"}};function Rr(e,t,s){return e.chainId!==t?!1:e.denom.startsWith("0x")&&s.startsWith("0x")?e.denom.toLowerCase()===s.toLowerCase():e.denom===s}function D1(e){return R1[e]}function Dr(e){return e.pretty_name||e.chain_name}function Br(e){return e.chain_type!=="cosmos"||e.bech32_prefix==="init"}const B1={data:[],isLoading:!1,supportedExternalChains:[],appchainSourceSymbols:[],externalSourceSymbols:[],localSymbol:""},F1={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 ys(e){return F1[e]}function U1(){const e=De(),{data:t,error:s}=S.useQuery({queryKey:je.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:K.MINUTE});return{chains:t??[],error:s}}function Ba(){const e=De(),t=Rn(),s=se(),{chains:o,error:a}=U1(),r=y.useMemo(()=>o.map(({chain_id:d})=>d),[o]),{data:i,error:c,isLoading:l}=S.useQuery({queryKey:je.allBalances(r,[t,s]).queryKey,queryFn:()=>{const d=Object.fromEntries(o.map(m=>[m.chain_id,{address:m.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(([m,{denoms:u}])=>[m,u||{}])):{},enabled:!!s&&r.length>0,staleTime:K.SECOND});return{data:i,error:c,isLoading:l,chainsError:a}}function Fa(){const{localOptions:e=[]}=Xe(),t=S.useQueryClient(),s=De(),{data:o,isLoading:a}=S.useQuery({queryKey:je.allAssets().queryKey,queryFn:()=>s.get("v2/fungible/assets").json(),staleTime:K.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 m=c.get(`${d}:${l}`);return{denom:l,chain_id:d,symbol:m?.symbol??"",logo_uri:m?.logo_uri??""}})}return e.map(({denom:i,chainId:c})=>{const l=t.getQueryData(En.item(c,i).queryKey);return{denom:i,chain_id:c,symbol:l?.symbol??"",logo_uri:l?.logoUrl??""}})},[e,o,t]),isLoading:a}}function Ua(e){const{local:t}=ys(e),s=hs(),{watch:o}=Yt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function O1(e){const{external:t}=ys(e),s=hs(),{watch:o}=Yt(),a=o(),r=a[t.chainIdKey],i=a[t.denomKey];return s.find(({denom:c,chain_id:l})=>i===c&&l===r)||null}function al(e){const t=hs(),s=ho(),o=Pt(),a=$a(),{data:r,isLoading:i}=Ba(),{remoteOptions:c=[]}=Xe(),l=Ua(e);if(!l)return{...B1,isLoading:i};const d=D1(l.symbol),m=d?.externalSourceSymbols??[l.symbol],u=c.length>0,h=d?.extraExternalOptions??[],f=d?.extraInitiaSourceSymbols??[],g=d?.externalChainListSource??"supported-assets",p=new Map(s.map(v=>[v.chain_id,v])),_=t.filter(({symbol:v,denom:k,chain_id:T})=>{if(u)return c.some(B=>Rr(B,T,k));const M=h.some(B=>Rr(B,T,k)),A=p.get(T),L=!!A&&a(A.chain_id)&&f.includes(v),N=M||L;return v===l.symbol||N}).map(v=>{if(v.hidden||v.chain_id===l.chain_id)return null;const k=o(v.chain_id);if(!k||!Br(k))return null;const T=r?.[k.chain_id]?.[v.denom];return{asset:v,chain:k,balance:T}}).filter(v=>v!==null),x=_.filter(({balance:v})=>e!=="deposit"||!!v&&Number(v.amount)>0),b=new Map;if(g==="extra-options")for(const{chainId:v}of h){const k=p.get(v);k&&Br(k)&&(a(k.chain_id)||b.set(k.chain_id,k))}else for(const{chain:v}of x)a(v.chain_id)||b.set(v.chain_id,v);const j=Array.from(b.values()).sort((v,k)=>Dr(v).localeCompare(Dr(k))),w=[...new Set(_.filter(({chain:v})=>Gp(v,a)).map(({asset:v})=>v.symbol))];return{data:x,isLoading:i,supportedExternalChains:j,appchainSourceSymbols:w,externalSourceSymbols:m,localSymbol:l.symbol}}function Yt(){return Ie.useFormContext()}const V1="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",K1="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 na(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 W1(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 z1(e,t,s){if(!e.length)return"";const o=W1(e,t,s);return o.length===1&&o[0]===t?"from any app":`using ${na(o)} from any app`}function H1({localSymbol:e,externalSourceSymbols:t,externalChainNames:s,appchainSourceSymbols:o}){const a=`No ${e} available to deposit.`,r=s.length>0,i=na(s),c=[...new Set(t)],l=na(c),d=z1(o,e,c),m=!!d,u=c.length!==1||c[0]!==e;if(r&&m){const h=u?`using ${l} from ${i}`:`from ${i}`;return{title:a,description:`You can deposit ${e} ${h}, or ${d}.`}}return r?u?{title:a,description:`You can deposit ${e} using ${l} from ${i}.`}:{title:a,description:`You can deposit ${e} from ${i}.`}:m?{title:a,description:`You can deposit ${e} ${d}.`}:{title:a,description:"No deposit sources are currently available."}}const Q1="_container_pjkfr_1",G1="_title_pjkfr_5",Y1="_close_pjkfr_12",Z1="_emptyIcon_pjkfr_24",J1="_empty_pjkfr_24",X1="_emptyDescription_pjkfr_39",e0="_list_pjkfr_60",t0="_asset_pjkfr_75",n0="_placeholder_pjkfr_91",s0="_activeAsset_pjkfr_104",o0="_iconContainer_pjkfr_108",a0="_assetIcon_pjkfr_118",r0="_chainIcon_pjkfr_128",i0="_assetPlaceholder_pjkfr_142",c0="_assetName_pjkfr_163",l0="_assetChain_pjkfr_178",d0="_balance_pjkfr_186",u0="_value_pjkfr_195",fe={container:Q1,title:G1,close:Y1,emptyIcon:Z1,empty:J1,emptyDescription:X1,list:e0,asset:t0,placeholder:n0,activeAsset:s0,iconContainer:o0,assetIcon:a0,chainIcon:r0,assetPlaceholder:i0,assetName:c0,assetChain:l0,balance:d0,value:u0},m0=({mode:e})=>{const{external:t}=ys(e),{data:s,isLoading:o,supportedExternalChains:a,appchainSourceSymbols:r,externalSourceSymbols:i,localSymbol:c}=al(e),{setValue:l,watch:d}=Yt(),m=Ua(e),{data:u}=Fa(),{theme:h}=ne(),f=d(),g=f[t.denomKey],p=f[t.chainIdKey],_=!o&&s.length===1?`${s[0].chain.chain_id}:${s[0].asset.denom}`:"",x=y.useEffectEvent(()=>{if(!_)return;const[{asset:j,chain:w}]=s;if(g===j.denom&&p===w.chain_id){l("page","fields");return}l(t.denomKey,j.denom),l(t.chainIdKey,w.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")});y.useEffect(()=>{x()},[_]);function b(){const j=g&&p;return!j&&u.length<=1&&e==="deposit"?null:n.jsx("button",{className:fe.close,onClick:()=>{e==="withdraw"||j?l("page","fields"):l("page","select-local")},children:n.jsx(E.IconBack,{size:20})})}if(!m)return n.jsx("div",{children:"No assets found"});if(!o&&!s.length){const j=a.map(k=>k.pretty_name||k.chain_name).filter(k=>!!k),w=H1({localSymbol:c,externalSourceSymbols:i,externalChainNames:j,appchainSourceSymbols:r}),v=e==="withdraw"?`No supported destinations to withdraw ${m.symbol}.`:w.title;return n.jsxs("div",{className:fe.container,children:[b(),n.jsx("h4",{className:fe.title,children:"No available assets"}),n.jsx("img",{src:h==="dark"?V1:K1,alt:"No assets",className:fe.emptyIcon}),n.jsx("p",{className:fe.empty,children:v}),e==="deposit"&&n.jsx("p",{className:fe.emptyDescription,children:w.description})]})}return n.jsxs("div",{className:fe.container,children:[b(),n.jsxs("h4",{className:fe.title,children:[e==="withdraw"?"Select destination":`Deposit ${m.symbol}`," "]}),n.jsxs("div",{className:fe.list,children:[o&&Array.from({length:5}).map((j,w)=>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})]},w)),!o&&s.sort(({balance:j},{balance:w})=>Number(w?.value_usd??0)-Number(j?.value_usd??0)).map(({asset:j,chain:w,balance:v})=>{const k=g===j.denom&&p===w.chain_id,T=Ea(v?.value_usd,v?.price);return n.jsxs("button",{className:D(fe.asset,k&&fe.activeAsset),onClick:()=>{l(t.denomKey,j.denom),l(t.chainIdKey,w.chain_id),e==="deposit"&&l("quantity",""),l("page","fields")},children:[n.jsxs("div",{className:fe.iconContainer,children:[n.jsx("img",{src:j.logo_uri,alt:j.symbol,className:fe.assetIcon}),n.jsx("img",{src:w.logo_uri||"",alt:w.chain_name,className:fe.chainIcon})]}),n.jsxs("p",{className:fe.assetName,children:[j.symbol," ",k&&n.jsx("span",{children:n.jsx(E.IconCheck,{size:16})})]}),n.jsxs("p",{className:fe.assetChain,children:["on ",w.pretty_name]}),v&&n.jsxs(n.Fragment,{children:[n.jsx("p",{className:fe.balance,children:C.formatAmount(v.amount,{decimals:v.decimals||6})}),n.jsx("p",{className:fe.value,children:T})]})]},`${j.chain_id}-${j.denom}`)})]})]})},h0="_title_iequo_1",f0="_list_iequo_7",p0="_asset_iequo_15",g0="_imgPlaceholder_iequo_40",Ss={title:h0,list:f0,asset:p0,imgPlaceholder:g0},_0=({mode:e})=>{const{local:t,external:s}=ys(e),{setValue:o}=Yt(),{data:a,isLoading:r}=Fa(),[i,c]=y.useTransition(),l=(m,u)=>{o(t.denomKey,m),o(t.chainIdKey,u),o("quantity",""),o(s.denomKey,""),o(s.chainIdKey,""),c(()=>{o("page",e==="withdraw"?"fields":"select-external")})},d=y.useEffectEvent(()=>{const{denom:m,chain_id:u}=a[0];l(m,u)});return y.useEffect(()=>{!r&&a.length===1&&d()},[a,r]),a.length?n.jsxs(n.Fragment,{children:[n.jsx("h3",{className:Ss.title,children:e==="withdraw"?"Select an asset to withdraw":"Select an asset to receive"}),n.jsx("div",{className:Ss.list,"aria-busy":i,children:a.map(({denom:m,chain_id:u,symbol:h,logo_uri:f})=>n.jsxs("button",{className:Ss.asset,onClick:()=>l(m,u),disabled:i,children:[f?n.jsx("img",{src:f,alt:h}):n.jsx("div",{className:Ss.imgPlaceholder,"aria-hidden":"true"}),h]},`${m}-${u}`))})]}):n.jsx("div",{children:"No assets found"})},y0="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",x0="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",b0="_container_9k4hs_1",w0="_title_9k4hs_8",v0="_subtitle_9k4hs_14",j0="_linkContainer_9k4hs_30",C0="_link_9k4hs_30",N0="_separator_9k4hs_51",k0="_errorIcon_9k4hs_62",I0="_error_9k4hs_62",Le={container:b0,title:w0,subtitle:v0,linkContainer:j0,link:C0,separator:N0,errorIcon:k0,error:I0};function A0(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 sa({type:e}){const{closeModal:t}=Pn(),{theme:s}=ne(),{watch:o}=Yt(),{result:a}=o(),{openDrawer:r}=qt();if(!a)throw new Error("Transfer is completed but result is missing");const i=!a.success,c=i?"":a.txhash,l=i?"":a.chainId,d=i?0:a.timestamp??0,{route:m,values:u}=a,{srcDenom:h,srcChainId:f,quantity:g}=u,p=kt(h,f),_=e==="deposit"?"Deposit":"Withdraw",{data:x}=Hc({chainId:l,txHash:c,tracked:!1}),{data:b}=Qc({chainId:l,txHash:c,tracked:!!x,timestamp:d,route:m}),j=A0(b),w=s==="dark"?y0:x0,v=`https://assets.initia.xyz/videos/Loading${s==="dark"?"Dark":"Light"}.mp4`,k=`https://assets.initia.xyz/videos/Completed${s==="dark"?"Dark":"Light"}.mp4`;if(i)return n.jsxs("div",{className:Le.container,children:[n.jsxs("h3",{className:Le.title,children:[_," failed"]}),n.jsx("img",{src:w,alt:"Failed",className:Le.errorIcon}),n.jsx("p",{className:Le.error,children:a?.error}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]});const T=ns(m.estimated_route_duration_seconds),M=new URLSearchParams({tx_hash:c,chain_id:l}),A=new URL(`?${M.toString()}`,"https://explorer.skip.build"),L=()=>n.jsxs("div",{className:Le.linkContainer,children:[n.jsx("a",{href:A.toString(),target:"_blank",rel:"noopener noreferrer",className:Le.link,children:"View transaction"}),n.jsx("div",{className:Le.separator}),n.jsx("button",{className:Le.link,onClick:()=>{t(),r("/bridge/history")},children:"Go to history"})]});return n.jsxs("div",{className:Le.container,children:[j==="pending"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Le.title,children:[e==="deposit"?"Depositing":"Withdrawing"," ",g," ",p.symbol]}),n.jsx("video",{src:v,autoPlay:!0,muted:!0,loop:!0,playsInline:!0,style:{width:"72px",height:"72px",marginBottom:"12px"}}),n.jsxs("p",{className:Le.subtitle,children:["Estimated time: ",n.jsx("span",{children:T})]}),L(),n.jsx("p",{className:Le.subtitle,children:"Your transaction will continue even if you close this"})]}),j==="success"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Le.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()}}),L(),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]}),j==="failed"&&n.jsxs(n.Fragment,{children:[n.jsxs("h3",{className:Le.title,children:[_," failed"]}),n.jsx("img",{src:w,alt:"Failed",className:Le.errorIcon}),n.jsx("p",{className:Le.error,children:"Your transaction could not be completed"}),n.jsx(ue.White,{fullWidth:!0,onClick:t,children:"Close"})]})]})}const S0=$e.createQueryKeys("interwovenkit:tx-gas-estimate",{estimate:e=>[e]}),T0=({tx:e,children:t})=>{const{values:s}=St(),{srcChainId:o}=s,a=se(),r=is(),i=no(),{data:c,isLoading:l}=S.useQuery({queryKey:S0.estimate({tx:e,address:a,chainId:o}).queryKey,queryFn:async()=>{if(!("cosmos_tx"in e)||!e.cosmos_tx.msgs)return null;try{const m=e.cosmos_tx.msgs.map(({msg_type_url:f,msg:g})=>{if(!(f&&g))throw new Error("Invalid transaction data");return r.fromAmino({type:fn.aminoConverters[f].aminoType,value:JSON.parse(g)})});return{estimatedGas:await(await i(o)).simulate(a,m,""),messages:m}}catch{return null}},enabled:!!e&&"cosmos_tx"in e&&!!a&&!!o});if(l)return n.jsx(Ae,{children:n.jsx(ue.White,{loading:"Estimating gas..."})});const d=c?.estimatedGas??null;return n.jsx(n.Fragment,{children:t(d)})};function E0(e,t){return e?C.InitiaAddress(e).hex:t}function $0({currentState:e,route:t,quoteVerifiedAt:s,hexAddress:o,values:a}){return{...e,route:t,quoteVerifiedAt:s,values:{sender:o,recipient:E0(e.recipientAddress,o),slippagePercent:"0.1",...a}}}const M0="_container_oh9og_1",L0="_back_oh9og_6",q0="_title_oh9og_18",P0="_divider_oh9og_26",R0="_label_oh9og_30",D0="_asset_oh9og_37",B0="_assetIcon_oh9og_55",F0="_chainIcon_oh9og_67",U0="_assetName_oh9og_80",O0="_chevron_oh9og_92",V0="_input_oh9og_96",K0="_balanceContainer_oh9og_108",W0="_value_oh9og_116",z0="_maxButton_oh9og_126",H0="_detail_oh9og_142",Q0="_detailsContainer_oh9og_153",G0="_detailsButton_oh9og_163",Y0="_detailValue_oh9og_180",Z0="_detailToken_oh9og_190",J0="_receiveSummary_oh9og_198",G={container:M0,back:L0,title:q0,divider:P0,label:R0,asset:D0,assetIcon:B0,chainIcon:F0,assetName:U0,chevron:O0,input:V0,balanceContainer:K0,value:W0,maxButton:z0,detail:H0,detailsContainer:Q0,detailsButton:G0,detailValue:Y0,detailToken:Z0,receiveSummary:J0},rl=({renderFee:e})=>{const{route:t}=Xe(),{values:s}=St(),{dstDenom:o,dstChainId:a}=s,i=hs().find(({denom:f,chain_id:g})=>f===o&&g===a),c=se(),l=bc(),[d,m]=ze.useToggle(!1),u=t&&t.estimated_route_duration_seconds>60;if(!t||!i)return null;const h=Rc(t.amount_out,s.slippagePercent);return n.jsx(Xn,{children:n.jsxs("div",{className:G.detailsContainer,children:[n.jsxs("button",{className:G.detailsButton,onClick:m,"aria-expanded":d,children:["Transaction details"," ",n.jsx(E.IconChevronDown,{size:12,style:{transform:d?"rotate(180deg)":"rotate(0deg)"},"aria-hidden":"true"})]}),d&&n.jsxs(n.Fragment,{children:[t.does_swap&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Slippage"}),n.jsxs("p",{className:G.detailValue,children:[s.slippagePercent,"%"]})]}),!!t.estimated_fees?.length&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Bridge fee"}),n.jsx("div",{className:G.detailValue,children:qa(t.estimated_fees)})]}),e&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Tx fee"}),n.jsx("div",{className:G.detailValue,children:e()})]}),c&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Receiving address"}),n.jsxs("p",{className:G.detailValue,children:[n.jsx("img",{src:l,alt:"Wallet",height:12,width:12})," ",C.truncate(c)]})]}),t.does_swap&&n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Minimum received"}),n.jsxs("p",{className:G.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:G.detailToken})," ",C.formatAmount(h,{decimals:i.decimals})," ",i.symbol]})]})]}),n.jsxs("div",{className:G.detail,children:[n.jsx("p",{className:G.detailLabel,children:"Estimated time"}),n.jsx("p",{className:D(G.detailValue),style:u?{color:"var(--warning)"}:void 0,children:ns(t.estimated_route_duration_seconds)})]}),n.jsxs("div",{className:D(G.detail,G.receiveSummary),children:[n.jsx("p",{className:G.detailLabel,children:"Estimated received"}),n.jsxs("p",{className:G.detailValue,children:[n.jsx("img",{src:i.logo_uri,alt:i.symbol,className:G.detailToken})," ",C.formatAmount(t.amount_out,{decimals:i.decimals})," ",i.symbol]})]})]})})},X0="_trigger_1c7d7_1",e2="_item_1c7d7_5",t2="_itemText_1c7d7_13",n2={trigger:X0,item:e2,itemText:t2},s2=({tx:e,gas:t,confirmMessage:s,onCompleted:o})=>{const{values:a}=St(),{srcChainId:r,srcDenom:i,quantity:c}=a,d=hs().find(({denom:N,chain_id:I})=>N===i&&I===r),m=ft(r),u=os(m),h=ya(m),f=xa(m),g=It(m),p=h.map(({amount:N,denom:I})=>Ee.calculateFee(Math.ceil(t*pn),Ee.GasPrice.fromString(N+I))),_=p.map(N=>N.amount[0]),x=N=>{const I=u.find(O=>O.denom===N)?.amount??"0",B=_.find(O=>O.denom===N)?.amount??"0",q=d&&i===N?U(c||"0").times(U(10).pow(d.decimals)).toFixed(0):"0",P=U(B).plus(q),F=U(I).gte(P),{symbol:Q,decimals:W}=g(N);return{symbol:Q,decimals:W,spend:U(q).gt(0)?q:null,fee:B,total:P.toFixed(),balance:I,isSufficient:F}},b=()=>{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},[j,w]=y.useState(b),v=p.find(N=>N.amount[0].denom===j)??void 0,k=j?x(j):null,T=k&&!k.isSufficient?"Insufficient balance":void 0,M=(N,I)=>{if(C.formatAmount(N,{decimals:I})==="0.000000")return 8},A=N=>{const[{amount:I,denom:B}]=N.amount;if(U(I).isZero())return"0";const{symbol:q,decimals:P}=g(B),F=M(I,P);return`${C.formatAmount(I,{decimals:P,dp:F})} ${q}`},L=()=>{if(p.length===0)return null;if(p.length===1)return n.jsx("span",{className:"monospace",children:A(p[0])});if(!v||!j)return null;const N=p.map(F=>{const[{denom:Q}]=F.amount,{symbol:W}=g(Q);return{value:Q,label:A(F),triggerLabel:W}}),[{amount:I,denom:B}]=v.amount,{decimals:q}=g(B),P=M(I,q);return n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{className:"monospace",children:C.formatAmount(I,{decimals:q,dp:P})}),n.jsx(Ta,{options:N,value:j,onChange:w,classNames:n2})]})};return n.jsxs(n.Fragment,{children:[n.jsx(rl,{renderFee:p.length>0?L:void 0}),n.jsx(Da,{tx:e,children:n.jsx(Ra,{tx:e,fee:v,onCompleted:o,confirmMessage:s,error:T})})]})},o2=({tx:e,confirmMessage:t,onCompleted:s})=>n.jsxs(n.Fragment,{children:[n.jsx(rl,{}),n.jsx(Da,{tx:e,children:n.jsx(Ra,{tx:e,fee:void 0,onCompleted:s,confirmMessage:t})})]}),a2=({tx:e,gas:t,mode:s})=>{const{setValue:o}=Yt(),a=i=>{o("page","completed"),o("result",i)},r=s==="withdraw"?"Withdraw":"Deposit";return!t||!("cosmos_tx"in e)?n.jsx(o2,{tx:e,onCompleted:a,confirmMessage:r}):n.jsx(s2,{tx:e,gas:t,onCompleted:a,confirmMessage:r})},r2=({mode:e})=>{const t=ys(e),s=Se(),o=Xe(),{data:a}=Fa(),r=Pt(),{data:i,error:c,chainsError:l}=Ba(),d=Rn(),{watch:m,setValue:u,getValues:h}=Yt(),f=m(),{srcChainId:g,srcDenom:p,quantity:_=""}=f,x=f[t.external.denomKey],b=f[t.external.chainIdKey],j=Ua(e),w=O1(e),{data:v,isLoading:k}=al(e),T=!k&&v.length===1,M=e==="withdraw"&&!k&&v.length>0&&new Set(v.map(({chain:_e})=>_e.chain_id)).size===1,A=k||!v.length?null:T?v[0]:M?v.reduce((_e,Pe)=>{const gt=Number(_e.balance?.value_usd??0);return Number(Pe.balance?.value_usd??0)>gt?Pe:_e},v[0]):null,L=A?`${A.chain.chain_id}:${A.asset.denom}`:"",N=b?r(b):null,I=i?.[g]?.[p]?.amount,B=i?.[g]?.[p]?.price,q=U(B??0).times(_||0),[P]=ze.useDebounceValue(_,300),F=e==="withdraw"?j:w,Q=y.useMemo(()=>{if(e==="deposit"&&!w)return"Select asset";const _e=U(_||0);if(!_e.isFinite()||_e.lte(0))return"Enter amount";if(I!==void 0){const Pe=C.fromBaseUnit(I,{decimals:F?.decimals||6});if(_e.gt(Pe))return"Insufficient balance"}if(e==="withdraw"&&!w)return"Select destination"},[e,_,I,F,w]),{data:W,error:O,dataUpdatedAt:me}=Zo(P,{disabled:!!Q}),ge=O instanceof z.HTTPError&&O.response.status===400,ce=!Q&&!ge?W:void 0,ye=ce&&me>0?me:void 0,we=O instanceof z.HTTPError&&O.response.status===500,ve=Q?"disabled":ce?"ready":O?ge?"no-route":we?"server-error":"refresh-failed":"loading",tt=ve==="ready"&&o.route===ce,Rt=ve==="loading"||ve==="ready"&&!tt,Tt=(()=>{if(ve==="disabled")return Q;if(ve==="loading"||ve==="ready"&&!tt)return"Fetching route...";if(ve==="no-route")return"No route found";if(ve==="server-error")return"Server error";if(ve==="refresh-failed")return"Failed to refresh route"})(),qe=y.useEffectEvent(()=>{s(0,$0({currentState:o,route:ce,quoteVerifiedAt:ye,hexAddress:d,values:h()}))});y.useEffect(()=>{qe()},[ce,d]);const Y=y.useEffectEvent(()=>{if(!A||x&&b)return;const{asset:_e,chain:Pe}=A;u(t.external.denomKey,_e.denom),u(t.external.chainIdKey,Pe.chain_id),e==="deposit"&&u("quantity","")});if(y.useEffect(()=>{Y()},[L]),!j||e==="deposit"&&!w)return null;const ct=F?.decimals||6,re=e==="withdraw"?"Select chain":"Select asset",Be=()=>{u("quantity",""),u(t.external.denomKey,""),u(t.external.chainIdKey,""),(e==="withdraw"||T)&&(u(t.local.denomKey,""),u(t.local.chainIdKey,"")),u("page",e==="withdraw"||T?"select-local":"select-external")},Dt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:G.label,children:e==="withdraw"?"Destination":"From"}),n.jsxs("button",{className:G.asset,disabled:T,onClick:()=>u("page","select-external"),children:[n.jsx("div",{className:G.assetIcon,children:w?n.jsxs(n.Fragment,{children:[n.jsx("img",{src:w.logo_uri,alt:w.symbol}),n.jsx("img",{src:N?.logo_uri||"",alt:N?.pretty_name,className:G.chainIcon})]}):e==="withdraw"&&n.jsx("div",{className:G.chainIcon})}),n.jsx("p",{className:G.assetName,children:w?n.jsxs(n.Fragment,{children:[w.symbol,n.jsx("br",{}),n.jsxs("span",{children:["on ",N?.pretty_name]})]}):re}),!T&&n.jsx(E.IconChevronDown,{className:G.chevron,size:16})]})]}),Bt=n.jsxs(n.Fragment,{children:[n.jsx("p",{className:G.label,children:"Amount"}),n.jsx(ts,{balance:I,decimals:ct,className:G.input}),Number(I)>0&&n.jsxs("div",{className:G.balanceContainer,children:[n.jsx("p",{className:G.value,children:_?Ea(q.toString(),B):"$-"}),n.jsxs("button",{className:G.maxButton,onClick:()=>{const _e=C.fromBaseUnit(I??"0",{decimals:ct});U(_||0).eq(_e)||u("quantity",_e)},children:[n.jsx(E.IconWallet,{size:16})," ",C.formatAmount(I,{decimals:ct})," ",n.jsx("span",{children:"MAX"})]})]})]});return n.jsxs("section",{className:G.container,"aria-label":"Transfer form",children:[a.length>1&&n.jsx("button",{type:"button","aria-label":"Back",className:G.back,onClick:Be,children:n.jsx(E.IconBack,{size:20})}),n.jsxs("h3",{className:G.title,children:[t.label," ",j.symbol]}),e==="withdraw"?n.jsxs(n.Fragment,{children:[Bt,n.jsx("div",{className:G.divider}),Dt]}):n.jsxs(n.Fragment,{children:[Dt,n.jsx("div",{className:G.divider}),Bt]}),(l||c)&&n.jsx(be,{error:!0,children:"Failed to load balances"}),tt?n.jsx(Jc,{children:_e=>n.jsx(el,{children:Pe=>n.jsx(Xc,{addressList:_e,signedOpHook:Pe,children:gt=>n.jsx(T0,{tx:gt,children:He=>n.jsx(a2,{tx:gt,gas:He,mode:e})})})})}):n.jsx(Ae,{children:n.jsx(ue.White,{type:"submit",loading:Rt&&"Fetching route...",disabled:!0,fullWidth:!0,children:Tt})})]})},i2="_container_7nl9j_1",c2="_page_7nl9j_5",Fr={container:i2,page:c2},il=({mode:e})=>{const t=Ie.useForm({mode:"onChange",defaultValues:{page:"select-local",quantity:"",srcDenom:"",srcChainId:"",dstDenom:"",dstChainId:""}});return Ba(),n.jsx(Ie.FormProvider,{...t,children:n.jsx(l2,{mode:e})})},l2=({mode:e})=>{const{watch:t}=Yt(),s=t("page"),o=jt.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(_0,{mode:e});case"select-external":return n.jsx(m0,{mode:e});case"fields":return n.jsx(r2,{mode:e});case"completed":return n.jsx(sa,{type:e})}};return n.jsx(Xn,{children:n.jsx("div",{className:Fr.container,children:o((r,i)=>n.jsx(jt.animated.div,{style:r,className:Fr.page,children:a(i)}))})})},d2=()=>n.jsx(il,{mode:"deposit"}),u2=()=>n.jsx(il,{mode:"withdraw"}),m2="_root_1lo0i_1",h2="_address_1lo0i_9",f2="_copy_1lo0i_19",p2="_labelWrapper_1lo0i_33",g2="_labelCopy_1lo0i_43",_2="_labelCopied_1lo0i_47",y2="_copied_1lo0i_55",x2="_derived_1lo0i_65",b2="_derivedLabel_1lo0i_79",w2="_derivedAddress_1lo0i_83",v2="_hexAddress_1lo0i_89",j2="_derivedCopy_1lo0i_94",Ue={root:m2,address:h2,copy:f2,labelWrapper:p2,labelCopy:g2,labelCopied:_2,copied:y2,derived:x2,derivedLabel:b2,derivedAddress:w2,hexAddress:v2,derivedCopy:j2},C2=()=>{const e=y.useRef(null),t=y.useRef(null),{initiaAddress:s,hexAddress:o}=et(),a=yc("--gray-0");return y.useEffect(()=>{e.current&&(t.current?t.current.update({data:s}):(t.current=new $l({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(At,{title:"Receive",children:n.jsxs("div",{className:Ue.root,children:[n.jsx("div",{ref:e,style:{width:200,height:200}}),n.jsx("span",{className:Ue.address,children:s}),n.jsx(Os,{value:s,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Ue.copy,{[Ue.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy address",children:[n.jsx(E.IconCopy,{size:12,"aria-hidden":"true"}),n.jsxs("div",{className:Ue.labelWrapper,children:[n.jsx("span",{className:Ue.labelCopy,children:"Copy address"}),n.jsx("span",{className:Ue.labelCopied,children:"Copied!"})]})]})}),n.jsx(Os,{value:o,children:({copy:r,copied:i})=>n.jsxs("button",{className:D(Ue.derived,{[Ue.copied]:i}),onClick:r,"aria-label":i?"Copied":"Copy derived address",children:[n.jsx("span",{className:Ue.derivedLabel,children:"Derived from"}),n.jsxs("span",{className:Ue.derivedAddress,children:[n.jsx("span",{className:Ue.hexAddress,children:C.truncate(o)}),n.jsx(E.IconCopy,{size:12,className:Ue.derivedCopy,"aria-hidden":"true"}),i&&n.jsx("span",{className:Ue.copiedText,children:"Copied!"})]})]})})]})})};function N2(e,t){return t==null?e:e.filter(s=>s.grantee===t)}function k2(){const e=se(),t=he();return S.useQueries({queries:t.map(s=>({queryKey:Fs.grants(s.chainId,e).queryKey,queryFn:async()=>{const o=await Ys(`cosmos/authz/v1beta1/grants/granter/${e}`,{prefixUrl:s.restUrl},"grants"),a=Ri(o),r=e?ha(e,s.chainId):null,i=N2(a,r);return{chainId:s.chainId,grants:i}},enabled:!!e,staleTime:K.SECOND,retry:!1}))})}const I2="_countdown_vfms8_1",A2={countdown:I2},S2=({expiration:e})=>{const t=()=>{const a=new Date,r=Ze.differenceInSeconds(e,a),i=Math.floor(r/(1440*60)),c=Math.floor(r%(1440*60)/3600),l=Math.floor(r%3600/60),d=r%60,m=[];return i>0&&m.push(`${i}d`),(c>0||i>0)&&m.push(`${c}h`),(l>0||c>0||i>0)&&m.push(`${l}m`),m.push(`${d}s`),m.join(" ")},[s,o]=y.useState(t());return ze.useInterval(()=>{o(t())},1e3),Ze.isPast(e)?"Expired":n.jsxs(n.Fragment,{children:["Expires in ",n.jsx("span",{className:A2.countdown,children:s})]})},T2="_container_1l528_1",E2="_info_1l528_11",$2="_header_1l528_17",M2="_chainName_1l528_23",L2="_expiration_1l528_29",q2="_revokeButton_1l528_35",Cn={container:T2,info:E2,header:$2,chainName:M2,expiration:L2,revokeButton:q2},P2=({chainId:e,grantee:t,expiration:s})=>{const o=ft(e),{mutate:a,isPending:r}=Xi({grantee:t,internal:!0});return n.jsxs("div",{className:Cn.container,children:[n.jsxs("div",{className:Cn.info,children:[n.jsxs("div",{className:Cn.header,children:[n.jsx(te,{src:o.logoUrl,width:16,height:16,logo:!0}),n.jsx("div",{className:Cn.chainName,children:o.name})]}),n.jsx("div",{className:Cn.expiration,children:s?n.jsx(S2,{expiration:s}):"Until revoked"})]}),n.jsx("button",{className:Cn.revokeButton,onClick:()=>a(e),disabled:r,"aria-busy":r,children:r?"Revoking...":"Revoke"})]})},R2=({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=_a([r.expiration,i])}return[...s.values()].map(a=>y.createElement(P2,{...a,chainId:e,key:a.grantee}))},D2="_content_q36qs_1",B2={content:D2},F2=()=>{const e=k2(),t=()=>{const s=e.filter(o=>o.data&&o.data.grants.length>0).map(o=>o.data);return s.length===0?n.jsx(be,{children:"No permissions found"}):n.jsx("div",{className:B2.content,children:s.map(({chainId:o,grants:a})=>n.jsx(R2,{chainId:o,grants:a},o))})};return n.jsx(At,{title:"Manage auto-signing",backButton:"/settings",children:t()})},U2="_version_1sf5y_1",O2={version:U2},V2=()=>n.jsxs("aside",{className:O2.version,children:["v","2.5.1"]}),K2="_link_se23z_1",W2="_title_se23z_17",z2="_subtitle_se23z_23",H2="_icon_se23z_30",Ts={link:K2,title:W2,subtitle:z2,icon:H2},cl=({title:e,subtitle:t,rightSection:s,onClick:o})=>n.jsxs("button",{className:Ts.link,onClick:o,children:[n.jsxs("div",{children:[n.jsx("p",{className:Ts.title,children:e}),t&&n.jsx("p",{className:Ts.subtitle,children:t})]}),n.jsx("div",{className:Ts.icon,children:s??n.jsx(E.IconChevronRight,{size:16,"aria-hidden":"true"})})]}),Q2="https://export.initia.xyz/",G2=()=>{const e="width=600,height=768,scrollbars=yes,resizable=yes";return n.jsx(cl,{title:"Export private key",rightSection:n.jsx(E.IconExternalLink,{size:16}),onClick:()=>window.open(Q2,"_blank",e)})},Y2="_container_1vxr7_1",Z2="_separator_1vxr7_7",Ur={container:Y2,separator:Z2},J2=()=>{const e=Se(),{connector:t}=We.useAccount();return n.jsx(At,{title:"Settings",backButton:"/",children:n.jsxs("div",{className:Ur.container,children:[n.jsx(cl,{title:"Manage auto-signing",subtitle:"Manage chain auto-signing permissions by apps",onClick:()=>e("/settings/autosign")}),t?.id===ca&&n.jsx(G2,{}),n.jsx(Mt.Separator,{className:Ur.separator}),n.jsx(V2,{})]})})},X2="_trigger_1yjkd_1",eb="_icon_1yjkd_23",tb="_full_1yjkd_27",nb="_triggerContent_1yjkd_32",sb="_triggerText_1yjkd_40",ob="_popoverBackdrop_1yjkd_51",ab="_popoverPositioner_1yjkd_70",rb="_popoverPopup_1yjkd_74",ib="_search_1yjkd_99",cb="_viewport_1yjkd_105",lb="_item_1yjkd_111",db="_highlighted_1yjkd_127",ub="_active_1yjkd_131",mb="_itemContent_1yjkd_136",hb="_extra_1yjkd_142",fb="_connectedTag_1yjkd_149",ke={trigger:X2,icon:eb,full:tb,triggerContent:nb,triggerText:sb,popoverBackdrop:ob,popoverPositioner:ab,popoverPopup:rb,search:ib,viewport:cb,item:lb,highlighted:db,active:ub,itemContent:mb,extra:hb,connectedTag:fb},xo=({value:e,onChange:t,chainIds:s,renderExtra:o,fullWidth:a})=>{const{defaultChainId:r}=ne(),[i,c]=y.useState(""),[l,d]=y.useState(!1),[m,u]=y.useState(0),[h,f]=y.useState(),g=y.useRef([]),p=y.useRef(null),_=he(),x=s.map(N=>_.find(I=>I.chainId===N)).filter(Boolean),b=N=>n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:N,height:N,viewBox:"0 0 14 14",children:[n.jsx("path",{fill:"var(--dimmed)",d:"M5.69625 12.04C8.47976 12.04 10.7362 9.78348 10.7362 6.99996C10.7362 4.21645 8.47976 1.95996 5.69625 1.95996C2.91273 1.95996 0.65625 4.21645 0.65625 6.99996C0.65625 9.78348 2.91273 12.04 5.69625 12.04Z"}),n.jsx("path",{fill:"var(--dimmed)",d:"M9.66003 2.63379C10.85 3.71879 11.6025 5.26754 11.6025 7.00004C11.6025 8.73254 10.85 10.2813 9.66003 11.3663C11.7513 10.99 13.3438 9.19629 13.3438 7.00004C13.3438 4.80379 11.7513 3.00129 9.66003 2.63379Z"})]}),j=y.useMemo(()=>({chainId:"",name:"All",logoUrl:b}),[]),w=y.useMemo(()=>{const N=[j,...x];if(!i)return N;const I=i.toLowerCase();return N.filter(B=>B.name.toLowerCase().includes(I)||B.chainId.toLowerCase().includes(I))},[x,i,j]),v=x.find(N=>N.chainId===e)||j,k=parseInt(yc("--drawer-offset")),T=6,M=()=>{if(c(""),u(-1),p.current){const I=p.current.getBoundingClientRect().bottom+T,B=window.innerHeight-I-2*k;f(B)}d(!0)};y.useEffect(()=>{m>=0&&m<g.current.length&&g.current[m]?.scrollIntoView({block:"nearest",behavior:"auto"})},[m]);const A=y.useCallback(N=>{switch(N.key){case"ArrowDown":N.preventDefault(),u(I=>(I+1)%w.length);break;case"ArrowUp":N.preventDefault(),u(I=>(I-1+w.length)%w.length);break;case"Enter":N.preventDefault(),w[m]&&(t(w[m].chainId),d(!1));break;case"Escape":N.preventDefault(),d(!1);break}},[w,m,t,d]),L=N=>{t(N),d(!1)};return n.jsxs(vn.Popover.Root,{open:l,onOpenChange:M,modal:"trap-focus",children:[n.jsx(vn.Popover.Trigger,{render:n.jsxs("button",{className:D(ke.trigger,{[ke.full]:a}),"aria-expanded":l,role:"listbox",ref:p,children:[n.jsxs("div",{className:ke.triggerContent,children:[typeof v.logoUrl=="string"?n.jsx(te,{src:v.logoUrl,width:14,height:14,logo:!0}):v.logoUrl(14),n.jsx("span",{className:ke.triggerText,children:v.name})]}),n.jsx(E.IconChevronDown,{size:16,className:ke.icon})]})}),n.jsxs(vn.Popover.Portal,{container:_n(),children:[n.jsx(vn.Popover.Backdrop,{className:ke.popoverBackdrop,onClick:()=>d(!1)}),n.jsx(vn.Popover.Positioner,{className:ke.popoverPositioner,align:"end",side:"bottom",sideOffset:T,collisionAvoidance:{side:"none"},children:n.jsxs(vn.Popover.Popup,{className:D(ke.popoverPopup,{[ke.full]:a}),style:{maxHeight:h},children:[n.jsx(gs,{value:i,onChange:N=>{c(N.target.value),u(0)},onClear:()=>c(""),onKeyDown:A,placeholder:"Search apps",rootClassName:ke.search,ref:fs()}),n.jsx("div",{className:ke.viewport,role:"listbox",children:w.length===0?n.jsx(be,{children:"No apps found"}):w.map(({chainId:N,name:I,logoUrl:B},q)=>n.jsxs("div",{className:D(ke.item,{[ke.highlighted]:q===m,[ke.active]:e===N}),onClick:()=>L(N),onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),L(N))},onMouseEnter:()=>u(q),role:"option","aria-selected":e===N,tabIndex:-1,ref:P=>{P&&(g.current[q]=P)},children:[n.jsxs("div",{className:ke.itemContent,children:[typeof B=="string"?n.jsx(te,{src:B,width:16,height:16,logo:!0}):B(16),n.jsx("span",{className:ke.name,children:I}),N===r&&n.jsx("span",{className:ke.connectedTag,children:"Connected"})]}),o&&n.jsx("span",{className:ke.extra,children:o(N)})]},N))})]})})]})]})},pb="_container_1nap1_1",gb="_controls_1nap1_7",_b="_search_1nap1_13",Oa={container:pb,controls:gb,search:_b},yb=({children:e})=>n.jsx("div",{className:Oa.container,children:e}),xb=({children:e})=>n.jsx("div",{className:Oa.controls,children:e}),bb=e=>n.jsx(gs,{...e,rootClassName:Oa.search}),ht={Root:yb,Controls:xb,SearchInput:bb},ll=H.atom(""),dl=H.atom(""),wb=H.atom(""),vb=H.atom(""),jb=H.atom(""),Cb="_change_1nm9m_1",Nb="_positive_1nm9m_8",kb="_negative_1nm9m_12",Uo={change:Cb,positive:Nb,negative:kb},ul=({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(Uo.change,r?Uo.positive:Uo.negative),children:[r?"+":"-",C.formatAmount(i,{decimals:a})," ",o||s]})},Ib=({changes:e,chain:t})=>{const s=It(t);return e.map(({amount:o,denom:a},r)=>n.jsx(ul,{amount:o,asset:s(a)},r))},Ab=({changes:e,chain:t})=>{const s=It(t);return e.map(({amount:o,metadata:a},r)=>n.jsx(Nc,{metadata:a,chain:t,children:i=>n.jsx(ul,{amount:o,asset:s(i)})},r))},Sb=({events:e,chain:t})=>{const{initiaAddress:s,hexAddress:o}=et();return t.metadata?.is_l1||t.metadata?.minitia?.type==="minimove"?n.jsx(Ab,{changes:Cc(e,o),chain:t}):n.jsx(Ib,{changes:jc(e,s),chain:t})},Tb="_message_1qc8m_1",Eb="_more_1qc8m_9",Or={message:Tb,more:Eb},$b=({messages:e})=>n.jsxs(n.Fragment,{children:[e.slice(0,3).map((t,s)=>n.jsx("p",{className:Or.message,children:Qs.sentenceCase(t["@type"].split("Msg")[1])},s)),e.length>3&&n.jsx("footer",{className:Or.more,children:`+${e.length-3} more`})]}),Mb="_link_1vbb0_1",Lb="_inner_1vbb0_16",qb="_header_1vbb0_21",Pb="_time_1vbb0_30",Rb="_error_1vbb0_36",Db="_timestamp_1vbb0_40",Bb="_chainInfo_1vbb0_45",Fb="_content_1vbb0_53",Ub="_messages_1vbb0_61",Ob="_changes_1vbb0_67",bt={link:Mb,inner:Lb,header:qb,time:Pb,error:Rb,timestamp:Db,chainInfo:Bb,content:Fb,messages:Ub,changes:Ob},Vb=({txItem:e,chain:t})=>n.jsx(mo,{txHash:e.txhash,chainId:t.chainId,className:bt.link,children:n.jsxs("div",{className:bt.inner,children:[n.jsxs("div",{className:bt.header,children:[n.jsxs("div",{className:bt.time,children:[e.code!==0&&n.jsx(E.IconWarningFilled,{size:14,className:bt.error}),n.jsx("span",{className:bt.timestamp,children:Ze.format(new Date(e.timestamp),"h:mm a")})]}),n.jsxs("div",{className:bt.chainInfo,children:[n.jsx(te,{src:t.logoUrl,width:12,height:12,logo:!0}),n.jsx("span",{children:t.name})]})]}),n.jsxs("div",{className:bt.content,children:[n.jsx("div",{className:bt.messages,children:n.jsx($b,{messages:e.tx.body.messages})}),n.jsx("div",{className:bt.changes,children:n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(Sb,{...e,chain:t})})})]})]})}),Kb="_list_1mv55_1",Wb="_dateGroup_1mv55_7",zb="_dateHeader_1mv55_12",Hb="_more_1mv55_18",Es={list:Kb,dateGroup:Wb,dateHeader:zb,more:Hb},Qb=({list:e,chainId:t})=>{const s=se(),o=y.useMemo(()=>Oc(e,a=>{if(a.timestamp)return new Date(a.timestamp)}),[e]);return e.length===0?n.jsx(be,{children:"No activity found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Es.list,children:Object.entries(o).map(([a,r])=>n.jsxs("div",{className:Es.dateGroup,children:[n.jsx("div",{className:Es.dateHeader,children:a}),r.map(i=>n.jsx(pe,{errorBoundaryProps:{fallback:null},children:n.jsx(Vb,{txItem:i,chain:i.chain})},i.txhash))]},a))}),n.jsx(mo,{chainId:t,accountAddress:s,pathSuffix:"/txs",className:Es.more,showIcon:!0,children:"View more on Initia Scan"})]})},Gb=()=>{const{activities:e,isLoading:t}=Qd(),[s,o]=H.useAtom(jb),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(be,{children:"Loading activities..."}):!e.length&&!t?n.jsx(be,{children:"No activity yet"}):n.jsxs(ht.Root,{children:[n.jsx(ht.Controls,{children:n.jsx(xo,{value:s,onChange:o,chainIds:r,fullWidth:!0})}),n.jsx(Qb,{list:i,chainId:s||a.chainId})]})},Yb="_thumbnail_1xyqw_1",Zb="_placeholder_1xyqw_18",Jb="_clickable_1xyqw_24",zn={thumbnail:Yb,placeholder:Zb,clickable:Jb},Xb=({nftInfo:e,size:t,onClick:s})=>{const{collection_addr:o,object_addr:a,nft:r,chain:i}=e,{glyphUrl:c}=ne(),l=new URL(`/v1/${i.chainId}/${o}/${a||r.token_id}`,c).toString();return s?n.jsx("button",{className:D(zn.thumbnail,zn.clickable),onClick:s,style:{width:t,height:t},children:n.jsx(te,{src:l,classNames:{placeholder:zn.placeholder}})}):n.jsx("div",{className:zn.thumbnail,style:{width:t,height:t},children:n.jsx(te,{src:l,classNames:{placeholder:zn.placeholder}})})},ew="_collectionName_qs5tw_1",tw="_nftName_qs5tw_6",nw="_chainInfo_qs5tw_10",Oo={collectionName:ew,nftName:tw,chainInfo:nw},Va=({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(Xb,{nftInfo:e,onClick:t,size:s}),n.jsxs("div",{children:[n.jsx("div",{className:D(Oo.collectionName,a?.collectionName),children:r}),n.jsx("div",{className:D(Oo.nftName,a?.nftName),children:i}),n.jsxs("div",{className:D(Oo.chainInfo,a?.chainInfo),children:[n.jsx(te,{src:c.logoUrl,width:o,height:o,logo:!0}),n.jsx("span",{children:c.name})]})]})]})},Ka=$e.createQueryKeys("interwovenkit:nft",{nfts:(e,t)=>[e,t],metadata:e=>[e]});function sw(e,t){const{nft:s}=e,o=t.name??s.token_id;return{...e,...s,...t,name:o}}function ow(e,t){return e.flatMap((s,o)=>(t[o]??[]).map(r=>({...r,chain:s})))}const aw=()=>{const e=se(),t=he(),s=S.useQueries({queries:t.map(l=>({queryKey:Ka.nfts(l.indexerUrl,e).queryKey,queryFn:()=>Ys(`indexer/nft/v1/tokens/by_account/${e}`,{prefixUrl:l.indexerUrl},"tokens"),staleTime:K.SECOND}))}),o=s.map($.prop("data")),a=ow(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 rw(e){const t=Vr(e);return S.useQuery({queryKey:Ka.metadata(t).queryKey,queryFn:async()=>{try{if(!t)return{};const s=await z.get(t).json();return{...s,image:Vr(s.image)}}catch{return{}}},staleTime:K.INFINITY})}function Vr(e){return e?.replace("ipfs://","https://ipfs.io/ipfs/")}const iw=({nftInfo:e,children:t})=>{const{data:s={}}=rw(e.nft.uri),o=sw(e,s);return t(o)},cw="_grid_1wwdn_1",lw="_root_1wwdn_7",dw="_collectionName_1wwdn_15",uw="_nftName_1wwdn_23",mw="_chainInfo_1wwdn_32",Kr={grid:cw,root:lw,collectionName:dw,nftName:uw,chainInfo:mw},hw=()=>{const[e,t]=H.useAtom(wb),[s,o]=H.useAtom(vb),{nftInfos:a,chainCounts:r,totalCount:i,isLoading:c}=aw(),l=Se(),d=y.useMemo(()=>a.filter(({collection_addr:u,collection_name:h,nft:f,object_addr:g,chain:p})=>{if(s&&p.chainId!==s)return!1;if(e){const _=e.trim().toLowerCase();return u.toLowerCase().includes(_)||h.toLowerCase().includes(_)||f.token_id.toLowerCase().includes(_)||g.toLowerCase().includes(_)}return!0}),[a,s,e]),m=y.useMemo(()=>Array.from(new Set(a.map(({chain:u})=>u.chainId))),[a]);return c&&a.length===0?n.jsx(be,{children:"Loading NFTs..."}):!a.length&&!e&&!c?n.jsx(be,{children:"No NFTs"}):n.jsxs(ht.Root,{children:[n.jsxs(ht.Controls,{children:[n.jsx(ht.SearchInput,{value:e,onChange:u=>t(u.target.value),onClear:()=>t(""),placeholder:"Search NFTs"}),n.jsx(xo,{value:s,onChange:o,chainIds:m,renderExtra:u=>u?r[u]||0:i})]}),d.length===0?n.jsx(be,{children:"No NFTs found"}):n.jsx("div",{className:Kr.grid,children:d.map(u=>{const{collection_addr:h,nft:f}=u;return n.jsx(iw,{nftInfo:u,children:g=>n.jsx(Va,{normalizedNft:g,onThumbnailClick:()=>l("/nft",g),classNames:Kr})},h+f.token_id)})})]})},ml=y.createContext(null);function hl(){return y.useContext(ml)}const fw="_popup_nbecp_1",pw="_item_nbecp_19",$s={popup:fw,item:pw},fl=({asset:e,children:t})=>{const{denom:s,decimals:o,symbol:a,logoUrl:r,unlisted:i,address:c,chain:l}=e,{chainId:d}=l,[m,u]=y.useState(!1),h=Se(),f=hl(),{showNotification:g}=us(),{defaultChainId:p}=ne(),{evm_chain_id:_}=yn(),x=We.useChainId(),{switchChainAsync:b}=We.useSwitchChain(),{watchAssetAsync:j}=We.useWatchAsset(),w=()=>{u(!1),h("/send",{denom:s,chain:l})},v=()=>{u(!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 b({chainId:Number(_)}),j({type:"ERC20",options:{address:c,symbol:a,decimals:o,image:T}})},onSuccess:()=>{g({type:"success",title:"Asset added",description:"Asset added to wallet"})},onError:T=>{g({type:"error",title:"Asset addition failed",description:T.message})}});return n.jsxs(Mt.Menu.Root,{open:m,onOpenChange:u,modal:!1,children:[n.jsx(Mt.Menu.Trigger,{render:t}),n.jsx(Mt.Menu.Portal,{container:f,children:n.jsx(Mt.Menu.Positioner,{side:"bottom",sideOffset:-6,align:"end",children:n.jsxs(Mt.Menu.Popup,{className:$s.popup,children:[n.jsxs(Mt.Menu.Item,{className:$s.item,onClick:w,children:[n.jsx(E.IconArrowRight,{size:16}),n.jsx("span",{children:"Send"})]}),n.jsxs(Mt.Menu.Item,{className:$s.item,onClick:v,disabled:i,children:[n.jsx(E.IconSwap,{size:16}),n.jsx("span",{children:"Bridge/Swap"})]}),d===p&&_===x&&!!c&&n.jsxs(Mt.Menu.Item,{className:$s.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"})]})]})})})]})},gw="_item_38qhm_1",_w="_info_38qhm_23",yw="_images_38qhm_29",xw="_name_38qhm_33",bw="_value_38qhm_39",ww="_amount_38qhm_47",vw="_usd_38qhm_53",sn={item:gw,info:_w,images:yw,name:xw,value:bw,amount:ww,usd:vw},jw=({asset:e})=>{const{amount:t,value:s,logoUrl:o,chain:a}=e,r=C.formatAmount(t,{decimals:e.decimals});return n.jsx(fl,{asset:e,children:n.jsxs("button",{className:sn.item,children:[n.jsxs("div",{className:sn.info,children:[n.jsx(po,{assetLogoUrl:o,chainLogoUrl:a.logoUrl,assetLogoSize:24,chainLogoSize:14,chainLogoOffset:4,className:sn.images}),n.jsx("span",{className:sn.name,children:a.name})]}),n.jsxs("div",{className:sn.value,children:[n.jsx("span",{className:sn.amount,children:r}),Number(s)>0&&n.jsx("span",{className:sn.usd,children:ee(s)})]})]})})},Cw="_container_ytg3p_1",Nw="_assetItem_ytg3p_6",kw="_expandIcon_ytg3p_22",Iw="_assetInfo_ytg3p_27",Aw="_logo_ytg3p_33",Sw="_details_ytg3p_37",Tw="_symbol_ytg3p_42",Ew="_chainName_ytg3p_53",$w="_chainInfos_ytg3p_59",Mw="_chainLogos_ytg3p_65",Lw="_chainLogo_ytg3p_65",qw="_moreChains_ytg3p_76",Pw="_expanded_ytg3p_93",Rw="_valueColumn_ytg3p_98",Dw="_amount_ytg3p_108",Bw="_value_ytg3p_98",Fw="_collapsibleContent_ytg3p_121",Uw="_chainsList_ytg3p_151",Ce={container:Cw,assetItem:Nw,expandIcon:kw,assetInfo:Iw,logo:Aw,details:Sw,symbol:Tw,chainName:Ew,chainInfos:$w,chainLogos:Mw,chainLogo:Lw,moreChains:qw,expanded:Pw,valueColumn:Rw,amount:Dw,value:Bw,collapsibleContent:Fw,chainsList:Uw},Ow=H.atom([]),Wa=({assetGroup:e})=>{const{symbol:t,logoUrl:s,assets:o}=e,a=o.length===1,[r,i]=H.useAtom(Ow),c=y.useMemo(()=>uu(e),[e]),l=y.useMemo(()=>ec(e),[e]),d=r.includes(t),m=()=>{i(h=>d?h.filter(f=>f!==t):[...new Set([...h,t])])},u=()=>n.jsxs("button",{className:Ce.assetItem,children:[n.jsxs("div",{className:Ce.assetInfo,children:[s&&n.jsx(te,{src:s,width:32,height:32,className:Ce.logo,logo:!0}),n.jsxs("div",{className:Ce.details,children:[n.jsx("div",{className:Ce.symbol,children:t}),a?n.jsx("div",{className:Ce.chainName,children:o[0].chain.name}):n.jsxs("div",{className:Ce.chainInfos,children:[n.jsx("div",{className:Ce.chainLogos,children:o.slice(0,5).map(({chain:h})=>n.jsx(te,{src:h.logoUrl,width:16,height:16,className:Ce.chainLogo,logo:!0},h.chainId))}),o.length>5&&n.jsxs("span",{className:Ce.moreChains,children:["+",o.length-5]}),n.jsx(E.IconChevronDown,{size:16,className:D(Ce.expandIcon,{[Ce.expanded]:d})})]})]})]}),n.jsxs("div",{className:Ce.valueColumn,children:[n.jsx("div",{className:Ce.amount,children:C.formatNumber(c,{dp:o[0].unlisted?0:6})}),l>0&&n.jsx("div",{className:Ce.value,children:ee(l)})]})]});if(a){const[h]=o;return n.jsx("div",{className:Ce.container,children:n.jsx(fl,{asset:h,children:u()})})}return n.jsx("div",{className:Ce.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:u()}),n.jsx(Z.Collapsible.Content,{className:Ce.collapsibleContent,children:n.jsx("div",{className:Ce.chainsList,children:o.map(h=>n.jsx(jw,{asset:h},h.chain.chainId))})})]})})},Vw="_collapsible_1g7rh_1",Kw="_trigger_1g7rh_5",Ww="_divider_1g7rh_20",zw="_label_1g7rh_28",Hw="_chevron_1g7rh_33",Qw="_content_1g7rh_41",Gw="_list_1g7rh_45",Vt={collapsible:Vw,trigger:Kw,divider:Ww,label:zw,chevron:Hw,content:Qw,list:Gw},pl=({unlistedAssets:e})=>{const[t,s]=y.useState(!1),o=hl(),a=y.useRef(null),[r,i]=y.useState(0);y.useEffect(()=>{if(a.current){const u=a.current.scrollHeight;i(u)}},[e]);const c=y.useRef(null),l=u=>{s(u),u&&c.current&&o?.current&&window.setTimeout(()=>{if(!c.current||!a.current||!o?.current)return;const h=o.current,f=h.getBoundingClientRect(),g=c.current.getBoundingClientRect(),p=a.current.scrollHeight;if(g.bottom+p>f.bottom){const x=g.top-f.top+h.scrollTop-16;h.scrollTo({top:x,behavior:"smooth"})}},50)},d=jt.useSpring({height:t?r:0,opacity:t?1:0,config:{tension:500,friction:30,clamp:!0}}),m=y.useMemo(()=>e.map(u=>({...u,assets:[u],totalValue:u.value??0,totalAmount:Number(u.quantity)})),[e]);return e.length===0?null:n.jsxs(Z.Collapsible.Root,{open:t,onOpenChange:l,className:Vt.collapsible,children:[n.jsxs(Z.Collapsible.Trigger,{ref:c,className:Vt.trigger,children:[n.jsx("div",{className:Vt.divider}),n.jsxs("span",{className:Vt.label,children:["Unlisted assets (",e.length,")"]}),n.jsx(E.IconChevronDown,{className:Vt.chevron,size:12,"data-state":t?"open":"closed"}),n.jsx("div",{className:Vt.divider})]}),n.jsx(Z.Collapsible.Content,{forceMount:!0,asChild:!0,children:n.jsx(jt.animated.div,{className:Vt.content,style:d,children:n.jsx("div",{className:Vt.list,ref:a,children:m.map(u=>n.jsx(Wa,{assetGroup:u},u.assets[0].denom))})})})]})},Yw="_container_15xfg_1",Zw="_header_15xfg_7",Jw="_title_15xfg_13",Xw="_totalValue_15xfg_19",ev="_list_15xfg_26",Sn={container:Yw,header:Zw,title:Jw,totalValue:Xw,list:ev},tv=()=>{const[e,t]=H.useAtom(ll),[s,o]=H.useAtom(dl),{assetGroups:a,unlistedAssets:r,chainsByValue:i,totalValue:c,isLoading:l}=ba(),d=i.map(({chainId:h})=>h),m=y.useMemo(()=>{const h=e?a.filter(g=>{const{symbol:p,assets:_}=g;return p.toLowerCase().includes(e.toLowerCase())||_.some(({denom:x,address:b})=>x.toLowerCase().includes(e.toLowerCase())||b?.toLowerCase().includes(e.toLowerCase()))}):a;return s?h.map(g=>({...g,assets:g.assets.filter(({chain:p})=>p.chainId===s)})).filter(g=>g.assets.length>0):h},[a,e,s]),u=y.useMemo(()=>{const h=e?r.filter(({denom:g,address:p})=>g.toLowerCase().includes(e.toLowerCase())||p?.toLowerCase().includes(e.toLowerCase())):r;return s?h.filter(({chain:g})=>g.chainId===s):h},[r,e,s]);return l&&a.length===0?n.jsx(be,{children:"Loading assets..."}):!m.length&&!u.length&&!e&&!s&&!l?n.jsx(be,{children:"No assets"}):n.jsxs(ht.Root,{children:[n.jsxs(ht.Controls,{children:[n.jsx(ht.SearchInput,{value:e,onChange:h=>t(h.target.value),onClear:()=>t(""),placeholder:"Search assets"}),n.jsx(xo,{value:s,onChange:o,chainIds:d,renderExtra:h=>{if(!h)return ee(c);const f=i.find(g=>g.chainId===h);return f?ee(f.value):null}})]}),n.jsx("div",{children:m.length===0&&u.length===0?n.jsx(be,{children:"No assets found"}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:Sn.list,children:m.map(h=>n.jsx(Wa,{assetGroup:h},h.symbol))}),n.jsx(pl,{unlistedAssets:u})]})})]})},nv="_container_11k2x_1",sv={container:nv},wt=({height:e,length:t=1,width:s="100%"})=>{const o=Array.from({length:t},(a,r)=>r);return t===1?n.jsx(hn,{height:e,width:s}):n.jsx("div",{className:sv.container,"aria-hidden":"true",children:o.map(a=>n.jsx(hn,{height:e,width:s},a))})},ov=y.memo(({searchQuery:e,selectedChain:t,denomLogos:s,symbolLogos:o,chainInfoMap:a,chainPrices:r})=>{const{balances:i,isLoading:c}=ds(),l=oe(),{listedGroups:d,unlistedAssets:m}=y.useMemo(()=>Im(i,a,r,l.chainId),[i,a,r,l.chainId]),u=y.useMemo(()=>jm(d,s,o),[d,s,o]),{filteredAssets:h,totalAssetsValue:f,filteredUnlistedAssets:g}=y.useMemo(()=>km(u,m,e,t),[u,m,e,t]);return n.jsxs("div",{className:Sn.container,children:[n.jsxs("div",{className:Sn.header,children:[n.jsx("span",{className:Sn.title,children:"Assets"}),h.length>0&&n.jsx("span",{className:Sn.totalValue,children:ee(f)})]}),h.length>0?n.jsxs("div",{children:[n.jsx("div",{className:Sn.list,children:h.map(p=>n.jsx(Wa,{assetGroup:p},p.symbol))}),n.jsx(pl,{unlistedAssets:g})]}):u.length===0&&c?n.jsx(wt,{height:56,length:3}):n.jsx(be,{children:"No liquid assets"})]})}),av="_container_1n61l_1",rv="_section_1n61l_7",iv="_sectionHeader_1n61l_19",cv="_sectionTitle_1n61l_25",lv="_sectionLabel_1n61l_31",dv="_externalLink_1n61l_37",uv="_sectionValue_1n61l_49",mv="_tokenList_1n61l_56",hv="_stakingTokenList_1n61l_62",fv="_tokenRow_1n61l_72",pv="_tokenMain_1n61l_78",gv="_tokenTrigger_1n61l_84",_v="_tokenChevron_1n61l_100",yv="_expanded_1n61l_111",xv="_triggerValue_1n61l_115",bv="_tokenInfo_1n61l_122",wv="_tokenInfoLabel_1n61l_128",vv="_tokenLogo_1n61l_134",jv="_tokenSymbol_1n61l_138",Cv="_tokenValues_1n61l_144",Nv="_tokenAmount_1n61l_150",kv="_tokenValue_1n61l_144",Iv="_typeBreakdown_1n61l_164",Av="_typeRow_1n61l_172",Sv="_typeLabel_1n61l_180",Tv="_typeValues_1n61l_186",Ev="_typeAmount_1n61l_192",$v="_typeValue_1n61l_186",Mv="_collapsibleContent_1n61l_206",X={container:av,section:rv,sectionHeader:iv,sectionTitle:cv,sectionLabel:lv,externalLink:dv,sectionValue:uv,tokenList:mv,stakingTokenList:hv,tokenRow:fv,tokenMain:pv,tokenTrigger:gv,tokenChevron:_v,expanded:yv,triggerValue:xv,tokenInfo:bv,tokenInfoLabel:wv,tokenLogo:vv,tokenSymbol:jv,tokenValues:Cv,tokenAmount:Nv,tokenValue:kv,typeBreakdown:Iv,typeRow:Av,typeLabel:Sv,typeValues:Tv,typeAmount:Ev,typeValue:$v,collapsibleContent:Mv},gl=({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 hm(c)},[e]);return i.size===0?null:n.jsx("div",{className:X.container,children:Array.from(i.entries()).map(([c,l])=>n.jsx(Lv,{sectionKey:c,sectionGroup:l,denomLogoMap:t,isInitia:s,manageUrl:r,getClaimableInitByType:o,initPrice:a},c))})},Lv=({sectionKey:e,sectionGroup:t,denomLogoMap:s,isInitia:o,manageUrl:a,getClaimableInitByType:r,initPrice:i})=>{const{positions:c,totalValue:l}=t,d=mm(e,o),m=y.useMemo(()=>bm(c),[c]),u=e==="staking";return n.jsxs("section",{className:X.section,"aria-label":d,children:[n.jsxs("div",{className:X.sectionHeader,children:[n.jsxs("div",{className:X.sectionTitle,children:[n.jsx("span",{className:X.sectionLabel,children:d}),u&&a&&n.jsx("a",{href:a,target:"_blank",rel:"noopener noreferrer",className:X.externalLink,onClick:h=>h.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:X.sectionValue,children:ee(l)})]}),n.jsx("div",{className:D(X.tokenList,{[X.stakingTokenList]:u}),children:m.map(h=>n.jsx(qv,{group:h,showTypeBreakdown:u,denomLogoMap:s,getClaimableInitByType:r,initPrice:i},h.denom))})]})},qv=({group:e,showTypeBreakdown:t,denomLogoMap:s,getClaimableInitByType:o,initPrice:a})=>{const{denom:r,symbol:i,totalAmount:c,totalValue:l,positions:d}=e,m=s.get(r),[u,h]=y.useState(!1),f=y.useMemo(()=>{if(!t)return null;const g=ym(d);return g.size>0?g:null},[d,t]);return f?n.jsxs(Z.Collapsible.Root,{open:u,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:X.tokenTrigger,children:[n.jsxs("div",{className:X.tokenInfo,children:[n.jsx(E.IconChevronDown,{size:14,className:D(X.tokenChevron,{[X.expanded]:u}),"aria-hidden":"true"}),n.jsxs("div",{className:X.tokenInfoLabel,children:[m?.assetLogo&&n.jsx(te,{src:m.assetLogo,width:20,height:20,className:X.tokenLogo}),n.jsx("span",{className:X.tokenSymbol,children:i})]})]}),n.jsx("span",{className:X.triggerValue,children:ee(l)})]})}),n.jsx(Z.Collapsible.Content,{className:X.collapsibleContent,children:n.jsx(Pv,{typeGroups:f,symbol:i,denom:r,getClaimableInitByType:o,initPrice:a})})]}):n.jsx("div",{className:X.tokenRow,children:n.jsxs("div",{className:X.tokenMain,children:[n.jsxs("div",{className:X.tokenInfo,children:[m?.assetLogo&&n.jsx(te,{src:m.assetLogo,width:20,height:20,className:X.tokenLogo}),n.jsx("span",{className:X.tokenSymbol,children:i})]}),n.jsxs("div",{className:X.tokenValues,children:[n.jsx("span",{className:X.tokenAmount,children:C.formatNumber(c,{dp:6})}),n.jsx("span",{className:X.tokenValue,children:ee(l)})]})]})})},Pv=({typeGroups:e,symbol:t,denom:s,getClaimableInitByType:o,initPrice:a})=>{const r=y.useMemo(()=>Array.from(e.entries()).map(([l,d])=>{const m=d.reduce((h,f)=>f.type==="fungible-position"||f.balance.type==="unknown"?h:h+f.balance.formattedAmount,0),u=d.reduce((h,f)=>h+Mn(f),0);return{type:l,typeAmount:m,typeValue:u}}),[e]),i=y.useMemo(()=>{if(!o)return 0;let l=0;for(const{type:d}of r){const m=o(s,d);l+=Number(m)}return l},[s,o,r]),c=i>0;return n.jsxs("div",{className:X.typeBreakdown,children:[r.map(({type:l,typeAmount:d,typeValue:m})=>n.jsxs("div",{className:X.typeRow,children:[n.jsx("span",{className:X.typeLabel,children:_m(l)}),n.jsxs("div",{className:X.typeValues,children:[n.jsxs("span",{className:X.typeAmount,children:[C.formatNumber(d,{dp:6})," ",t]}),n.jsx("span",{className:X.typeValue,children:ee(m)})]})]},l)),c&&n.jsxs("div",{className:X.typeRow,children:[n.jsx("span",{className:X.typeLabel,children:"Claimable rewards"}),n.jsxs("div",{className:X.typeValues,children:[n.jsxs("span",{className:X.typeAmount,children:[C.formatNumber(i,{dp:6})," ",mt]}),n.jsx("span",{className:X.typeValue,children:ee(i*(a??0))})]})]})]})},Rv="_container_ymkoc_1",Dv="_trigger_ymkoc_6",Bv="_expandIcon_ymkoc_22",Fv="_chainInfo_ymkoc_27",Uv="_logo_ymkoc_33",Ov="_chainNameContainer_ymkoc_37",Vv="_chainName_ymkoc_37",Kv="_externalLink_ymkoc_49",Wv="_externalIcon_ymkoc_53",zv="_valueColumn_ymkoc_63",Hv="_value_ymkoc_63",Qv="_expanded_ymkoc_80",Gv="_collapsibleContent_ymkoc_85",Yv="_content_ymkoc_97",Oe={container:Rv,trigger:Dv,expandIcon:Bv,chainInfo:Fv,logo:Uv,chainNameContainer:Ov,chainName:Vv,externalLink:Kv,externalIcon:Wv,valueColumn:zv,value:Hv,expanded:Qv,collapsibleContent:Gv,content:Yv},Zv=H.atom([]),Jv=({chainGroup:e})=>{const{chainId:t,chainLogo:s,protocols:o}=e,a=he(),r=ss(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>Aa(r,a),[r,a]),l=y.useMemo(()=>{const d=new Map;for(const m of o)for(const u of m.positions){if(u.type==="fungible-position"||u.balance.type==="unknown")continue;const{denom:h,symbol:f}=u.balance,g=f.toUpperCase(),p=`${t}:${h}`,_=i.get(p)??c.get(g);_&&d.set(h,{assetLogo:_,chainLogo:s??""})}return d},[o,i,c,t,s]);return n.jsx(gl,{protocols:o,denomLogoMap:l})},Xv=({chainGroup:e})=>{const{chainName:t,chainLogo:s,protocols:o}=e,a=o[0]?.manageUrl,[r,i]=H.useAtom(Zv),c=y.useMemo(()=>o.reduce((f,g)=>f+g.positions.reduce((p,_)=>p+Mn(_),0),0),[o]),l=["civitia","yominet"],d=r.includes(t),m=t?.toLowerCase(),u=l.includes(m),h=()=>{i(f=>d?f.filter(g=>g!==t):[...new Set([...f,t])])};return n.jsx("div",{className:Oe.container,children:n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:h,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Oe.trigger,children:[n.jsxs("div",{className:Oe.chainInfo,children:[s&&n.jsx(te,{src:s,width:32,height:32,className:Oe.logo,logo:!0}),n.jsxs("div",{className:Oe.chainNameContainer,children:[n.jsx("span",{className:Oe.chainName,children:t}),a&&n.jsx("a",{href:a,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:[!u&&n.jsx("span",{className:Oe.value,children:ee(c)}),n.jsx(E.IconChevronDown,{size:16,className:D(Oe.expandIcon,{[Oe.expanded]:d})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Oe.collapsibleContent,children:n.jsx("div",{className:Oe.content,children:n.jsx(Jv,{chainGroup:e})})})]})})},ej="_container_g7q2b_1",tj="_section_g7q2b_6",nj="_sectionHeader_g7q2b_14",sj="_sectionTitle_g7q2b_20",oj="_sectionLabel_g7q2b_26",aj="_externalLink_g7q2b_32",rj="_sectionValue_g7q2b_44",ij="_tokenList_g7q2b_51",cj="_tokenTrigger_g7q2b_63",lj="_tokenChevron_g7q2b_79",dj="_expanded_g7q2b_90",uj="_tokenInfo_g7q2b_94",mj="_tokenInfoLabel_g7q2b_100",hj="_tokenLogo_g7q2b_106",fj="_pairedLogos_g7q2b_110",pj="_coinLogo_g7q2b_115",gj="_tokenSymbol_g7q2b_133",_j="_triggerValue_g7q2b_139",yj="_clammBreakdownContent_g7q2b_146",xj="_clammPositionRow_g7q2b_154",bj="_statusDot_g7q2b_163",wj="_inRange_g7q2b_170",vj="_outRange_g7q2b_174",jj="_unknown_g7q2b_178",Cj="_clammStatusValue_g7q2b_182",Nj="_breakdownContent_g7q2b_192",kj="_breakdownRow_g7q2b_200",Ij="_breakdownLabel_g7q2b_208",Aj="_breakdownValues_g7q2b_214",Sj="_breakdownAmount_g7q2b_220",Tj="_breakdownValue_g7q2b_214",Ej="_collapsibleContent_g7q2b_241",R={container:ej,section:tj,sectionHeader:nj,sectionTitle:sj,sectionLabel:oj,externalLink:aj,sectionValue:rj,tokenList:ij,tokenTrigger:cj,tokenChevron:lj,expanded:dj,tokenInfo:uj,tokenInfoLabel:mj,tokenLogo:hj,pairedLogos:fj,coinLogo:pj,tokenSymbol:gj,triggerValue:_j,clammBreakdownContent:yj,clammPositionRow:xj,statusDot:bj,inRange:wj,outRange:vj,unknown:jj,clammStatusValue:Cj,breakdownContent:Nj,breakdownRow:kj,breakdownLabel:Ij,breakdownValues:Aj,breakdownAmount:Sj,breakdownValue:Tj,collapsibleContent:Ej},$j=({data:e,denomLogoMap:t})=>{const{totalValue:s,rows:o}=e;return o.length===0?null:n.jsx("div",{className:R.container,children:n.jsxs("section",{className:R.section,"aria-label":"Liquidity positions",children:[n.jsxs("div",{className:R.sectionHeader,children:[n.jsxs("div",{className:R.sectionTitle,children:[n.jsx("span",{className:R.sectionLabel,children:"Liquidity"}),n.jsx("a",{href:fa,target:"_blank",rel:"noopener noreferrer",className:R.externalLink,onClick:a=>a.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:R.sectionValue,children:ee(s)})]}),n.jsx("div",{className:R.tokenList,children:o.map(a=>n.jsx(Bj,{row:a,denomLogoMap:t},a.denom))})]})})},Mj={deposit:"Deposit",staking:"Staking",lockStaking:"Lock staking",unstaking:"Unstaking"};function Lj(e){return e===void 0?R.unknown:e?R.inRange:R.outRange}function qj(e){return e===void 0?"Status unavailable":e?"In range":"Out of range"}function Wr(e,t){return e===void 0?"-":`${C.formatNumber(e,{dp:6})} ${t}`}function _l({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}),"aria-hidden":"true"}),n.jsxs("div",{className:R.tokenInfoLabel,children:[r?n.jsx("div",{className:R.pairedLogos,children:s.map((i,c)=>n.jsx(te,{src:i,width:20,height:20,className:R.coinLogo,logo:!0},c))}):o&&n.jsx(te,{src:o,width:20,height:20,className:R.tokenLogo}),n.jsx("span",{className:R.tokenSymbol,children:t})]})]}),a]})}const Pj=({position:e})=>{const t=Lj(e.inRange),s=qj(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:ee(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:Wr(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:Wr(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:ee(e.rewardValue)})})]})]})},Rj=({row:e,denomLogoMap:t})=>{const[s,o]=y.useState(!1),{denom:a,symbol:r,totalValue:i,coinLogos:c,logoUrl:l,clamm:d}=e,m=t.get(a);if(!d)return null;const u=l||m?.assetLogo;return n.jsxs(Z.Collapsible.Root,{open:s,onOpenChange:o,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:_l({isOpen:s,symbol:r,coinLogos:c,singleLogoUrl:u,rightContent:n.jsx("span",{className:R.triggerValue,children:ee(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:ee(d.totalRewardValue)})})]}),d.positions.map(h=>n.jsx(Pj,{position:h},h.tokenAddress))]})})]})},Dj=({row:e,denomLogoMap:t})=>{const{denom:s,symbol:o,totalValue:a,breakdown:r,logoUrl:i,coinLogos:c,claimableInit:l}=e,[d,m]=y.useState(!1),u=t.get(s),h=i||u?.assetLogo,f=e.totalAmount>0?e.totalValue/e.totalAmount:0,g=y.useMemo(()=>Object.entries(r).filter(([,_])=>_>0),[r]),p=l&&Number(l.total)>0;return n.jsxs(Z.Collapsible.Root,{open:d,onOpenChange:m,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:_l({isOpen:d,symbol:o,coinLogos:c,singleLogoUrl:h,rightContent:n.jsx("span",{className:R.triggerValue,children:ee(a)})})}),n.jsx(Z.Collapsible.Content,{className:R.collapsibleContent,children:n.jsxs("div",{className:R.breakdownContent,children:[g.map(([_,x])=>{const b=x*f;return n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:Mj[_]}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[C.formatNumber(x,{dp:6})," LP"]}),n.jsx("span",{className:R.breakdownValue,children:ee(b)})]})]},_)}),p&&n.jsxs("div",{className:R.breakdownRow,children:[n.jsx("span",{className:R.breakdownLabel,children:"Claimable rewards"}),n.jsxs("div",{className:R.breakdownValues,children:[n.jsxs("span",{className:R.breakdownAmount,children:[C.formatNumber(Number(l.total),{dp:6})," ",mt]}),n.jsx("span",{className:R.breakdownValue,children:ee(l.totalValue)})]})]})]})})]})},Bj=({row:e,denomLogoMap:t})=>e.clamm?n.jsx(Rj,{row:e,denomLogoMap:t}):n.jsx(Dj,{row:e,denomLogoMap:t}),Fj="_container_1nijk_1",Uj="_section_1nijk_6",Oj="_sectionHeader_1nijk_14",Vj="_sectionTitle_1nijk_20",Kj="_sectionLabel_1nijk_26",Wj="_externalLink_1nijk_32",zj="_sectionValue_1nijk_44",Hj="_tokenList_1nijk_51",Qj="_tokenTrigger_1nijk_63",Gj="_tokenChevron_1nijk_79",Yj="_expanded_1nijk_90",Zj="_tokenInfo_1nijk_94",Jj="_tokenInfoLabel_1nijk_100",Xj="_tokenLogo_1nijk_106",eC="_tokenName_1nijk_110",tC="_triggerValue_1nijk_116",nC="_breakdownContent_1nijk_123",sC="_breakdownRow_1nijk_131",oC="_breakdownLabel_1nijk_139",aC="_breakdownValues_1nijk_145",rC="_breakdownAmount_1nijk_151",iC="_breakdownValue_1nijk_145",cC="_collapsibleContent_1nijk_165",de={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,tokenName:eC,triggerValue:tC,breakdownContent:nC,breakdownRow:sC,breakdownLabel:oC,breakdownValues:aC,breakdownAmount:rC,breakdownValue:iC,collapsibleContent:cC},lC=({data:e})=>{const{totalValue:t,rows:s}=e;return s.length===0?null:n.jsx("div",{className:de.container,children:n.jsxs("section",{className:de.section,"aria-label":"VIP rewards",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:bd,target:"_blank",rel:"noopener noreferrer",className:de.externalLink,onClick:o=>o.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,"aria-hidden":"true"})})]}),n.jsx("span",{className:de.sectionValue,children:ee(t)})]}),n.jsx("div",{className:de.tokenList,children:s.map(o=>n.jsx(dC,{row:o},`${o.bridgeId}-${o.version}`))})]})})},dC=({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}),"aria-hidden":"true"}),n.jsxs("div",{className:de.tokenInfoLabel,children:[s&&n.jsx(te,{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:ee(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:[C.formatNumber(o,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:ee(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:[C.formatNumber(r,{dp:2})," INIT"]}),n.jsx("span",{className:de.breakdownValue,children:ee(i)})]})]})]})})]})},uC="_container_ymkoc_1",mC="_trigger_ymkoc_6",hC="_expandIcon_ymkoc_22",fC="_chainInfo_ymkoc_27",pC="_logo_ymkoc_33",gC="_chainNameContainer_ymkoc_37",_C="_chainName_ymkoc_37",yC="_externalLink_ymkoc_49",xC="_externalIcon_ymkoc_53",bC="_valueColumn_ymkoc_63",wC="_value_ymkoc_63",vC="_expanded_ymkoc_80",jC="_collapsibleContent_ymkoc_85",CC="_content_ymkoc_97",Ve={container:uC,trigger:mC,expandIcon:hC,chainInfo:fC,logo:pC,chainNameContainer:gC,chainName:_C,externalLink:yC,externalIcon:xC,valueColumn:bC,value:wC,expanded:vC,collapsibleContent:jC,content:CC},NC=H.atom(!1),kC=()=>{const{totalValue:e}=Ia(),{totalValue:t}=io(),{totalValue:s}=co(),o=e+t+s;return n.jsx("span",{className:Ve.value,children:ee(o)})},IC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o,initPrice:a})=>{const{positions:r}=Ia(),{data:i}=lc(),{data:c}=dc(),l=y.useMemo(()=>{const u=new Map;for(const h of r){if(h.type==="fungible-position"||h.balance.type==="unknown")continue;const{denom:f,symbol:g}=h.balance,p=g.toUpperCase(),_=`${e}:${f}`,x=s.get(_)??o.get(p);x&&u.set(f,{assetLogo:x,chainLogo:t})}return u},[r,s,o,e,t]),d=y.useMemo(()=>(u,h)=>{const f=C.denomToMetadata(u);if(h==="staking"){const g=i?.get(f);return g?C.fromBaseUnit(g.amount,{decimals:rt}):"0"}if(h==="lockstaking"){const g=c?.get(f);return g?C.fromBaseUnit(g.amount,{decimals:rt}):"0"}return"0"},[i,c]),m=y.useMemo(()=>r.length===0?[]:[{protocol:"Initia",manageUrl:fa,positions:r}],[r]);return m.length===0?null:n.jsx(gl,{protocols:m,denomLogoMap:l,isInitia:!0,getClaimableInitByType:d,initPrice:a})},AC=({chainId:e,chainLogo:t,denomLogos:s,symbolLogos:o})=>{const a=io(),r=y.useMemo(()=>{const i=new Map;for(const c of a.rows){const{denom:l,symbol:d}=c,m=d.toUpperCase(),u=`${e}:${l}`,h=s.get(u)??o.get(m);h&&i.set(l,{assetLogo:h,chainLogo:t})}return i},[a.rows,s,o,e,t]);return a.rows.length===0?null:n.jsx($j,{data:a,denomLogoMap:r})},SC=()=>{const e=co();return e.rows.length===0?null:n.jsx(lC,{data:e})},TC=({chainGroup:e})=>{const{chainId:t,chainName:s,chainLogo:o}=e,[a,r]=H.useAtom(NC),i=he(),c=ss(),{denomLogos:l,symbolLogos:d}=y.useMemo(()=>Aa(c,i),[c,i]),m=oe(),{data:u}=Lt(m),h=y.useMemo(()=>u?.find(g=>g.id===Ye)?.price??0,[u]);return n.jsx("div",{className:Ve.container,children:n.jsxs(Z.Collapsible.Root,{open:a,onOpenChange:r,children:[n.jsx(Z.Collapsible.Trigger,{asChild:!0,children:n.jsxs("button",{className:Ve.trigger,children:[n.jsxs("div",{className:Ve.chainInfo,children:[o&&n.jsx(te,{src:o,width:32,height:32,className:Ve.logo,logo:!0}),n.jsxs("div",{className:Ve.chainNameContainer,children:[n.jsx("span",{className:Ve.chainName,children:s}),n.jsx("a",{href:fa,target:"_blank",rel:"noopener noreferrer",className:Ve.externalLink,onClick:f=>f.stopPropagation(),children:n.jsx(E.IconExternalLink,{size:12,className:Ve.externalIcon})})]})]}),n.jsxs("div",{className:Ve.valueColumn,children:[n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:16,width:60,length:1}),children:n.jsx(kC,{})}),n.jsx(E.IconChevronDown,{size:16,className:D(Ve.expandIcon,{[Ve.expanded]:a})})]})]})}),n.jsx(Z.Collapsible.Content,{className:Ve.collapsibleContent,children:n.jsxs("div",{className:Ve.content,children:[n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:36,length:2}),children:n.jsx(IC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d,initPrice:h})}),n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:36,length:2}),children:n.jsx(AC,{chainId:t,chainLogo:o,denomLogos:l,symbolLogos:d})}),n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:36,length:1}),children:n.jsx(SC,{})})]})})]})})},EC="_totalValue_1v2ca_1",$C={totalValue:EC},MC=({filteredChainGroups:e})=>{const{totalValue:t}=Ia(),{totalValue:s}=io(),{totalValue:o}=co(),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:$C.totalValue,children:ee(r)})},LC="_container_1eubu_1",qC="_header_1eubu_7",PC="_title_1eubu_13",RC="_list_1eubu_19",DC="_skeletonWrapper_1eubu_24",Hn={container:LC,header:qC,title:PC,list:RC,skeletonWrapper:DC},BC=y.memo(({searchQuery:e,selectedChain:t,chainInfoMap:s})=>{const{positions:o,isLoading:a}=ds(),r=oe(),i=y.useMemo(()=>{const l=[];for(const m of o){if(!Array.isArray(m.positions))continue;const u=s.get(m.chainName.toLowerCase()),h=m.chainName.toLowerCase();if(t&&u?.chainId!==t||!m.positions.some(x=>x.positions.some(b=>b.type!=="fungible-position"))||e&&!h.includes(e.toLowerCase()))continue;const g=m.positions.filter(x=>e&&!x.protocol.toLowerCase().includes(e.toLowerCase())?!1:Array.isArray(x.positions)&&x.positions.length>0),p=r.chainId===u?.chainId,_=g.reduce((x,b)=>x+b.positions.reduce((j,w)=>j+Mn(w),0),0);l.push({chainId:u?.chainId??"",chainName:u?.prettyName??m.chainName,chainLogo:u?.logoUrl??"",protocols:g,isInitia:p,totalValue:_})}const d=["civitia","yominet"];return $.sortWith([$.descend(m=>m.isInitia??!1),$.ascend(m=>d.includes(m.chainName.toLowerCase())),$.descend(m=>m.totalValue??0),$.ascend(m=>m.chainName.toLowerCase())],l)},[o,s,e,t,r.chainId]),c=i.length>0;return n.jsxs("div",{className:Hn.container,children:[n.jsxs("div",{className:Hn.header,children:[n.jsx("span",{className:Hn.title,children:"Positions"}),c&&n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:16,width:60,length:1}),children:n.jsx(MC,{filteredChainGroups:i})})]}),c?n.jsx("div",{className:Hn.list,children:i.map(l=>l.isInitia?n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Hn.skeletonWrapper,children:n.jsx(wt,{height:56,length:1})}),children:n.jsx(TC,{chainGroup:l})},l.chainName):n.jsx(Xv,{chainGroup:l},l.chainName))}):o.length===0&&a?n.jsx(wt,{height:56,length:3}):n.jsx(be,{children:"No positions"})]})}),FC="_content_1w1ad_1",UC={content:FC},OC=({selectedChain:e,setSelectedChain:t})=>{const{defaultChainId:s}=ne(),o=oe(),a=Lm(),{totalValue:r}=co(),{chainIds:i,chainIdToValueMap:c,totalBalance:l}=y.useMemo(()=>{const d=new Map;let m=0;for(const h of a)d.set(h.chainId,h.totalBalance),m+=h.totalBalance;return r>0&&(d.set(o.chainId,(d.get(o.chainId)??0)+r),m+=r),{chainIds:$.sortWith([$.descend(h=>h===s),$.descend(h=>h===o.chainId),$.descend(h=>d.get(h)??0)],a.map(h=>h.chainId)),chainIdToValueMap:d,totalBalance:m}},[a,s,o,r]);return n.jsx(xo,{value:e,onChange:t,chainIds:i,renderExtra:d=>ee(d?c.get(d)??0:l)})},VC=()=>{const[e,t]=H.useAtom(ll),[s,o]=H.useAtom(dl),a=he(),r=ss(),{denomLogos:i,symbolLogos:c}=y.useMemo(()=>Aa(r,a),[r,a]),l=la(),d=y.useMemo(()=>hc(a,l),[a,l]),m=Mm();return n.jsxs(ht.Root,{children:[n.jsxs(ht.Controls,{children:[n.jsx(ht.SearchInput,{value:e,onChange:u=>t(u.target.value),onClear:()=>t(""),placeholder:"Search portfolio"}),n.jsx(pe,{suspenseFallback:n.jsx(hn,{height:44,width:132}),children:n.jsx(OC,{selectedChain:s,setSelectedChain:o})})]}),n.jsxs("section",{className:UC.content,"aria-label":"Assets and positions",children:[n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:48,length:5}),children:n.jsx(ov,{searchQuery:e,selectedChain:s,denomLogos:i,symbolLogos:c,chainInfoMap:m,chainPrices:d})}),n.jsx(pe,{suspenseFallback:n.jsx(wt,{height:56,length:3}),children:n.jsx(BC,{searchQuery:e,selectedChain:s,chainInfoMap:m})})]})]})},KC="_totalValue_5pf7e_1",WC="_totalLabel_5pf7e_7",zC="_totalAmount_5pf7e_13",HC="_loading_5pf7e_18",QC="_skeletonWrapper_5pf7e_23",GC="_nav_5pf7e_28",YC="_item_5pf7e_34",ZC="_tabs_5pf7e_59",JC="_tab_5pf7e_59",Ke={totalValue:KC,totalLabel:WC,totalAmount:zC,loading:HC,skeletonWrapper:QC,nav:GC,item:YC,tabs:ZC,tab:JC},XC=()=>{const{totalValue:e,isLoading:t}=ba();return n.jsx("div",{className:D(Ke.totalAmount,{[Ke.loading]:t}),children:ee(e)})},eN=()=>{const e=qm(),t=Pm(),s=mc(),o=e+s+t;return n.jsx("div",{className:Ke.totalAmount,children:ee(o)})},tN=()=>{Lc(),Em();const e=Sa(),t=Se(),s=Xs(),o=y.useRef(null);return n.jsx(ml.Provider,{value:o,children:n.jsxs(pt,{ref:o,children:[n.jsxs("div",{className:Ke.totalValue,children:[n.jsx("div",{className:Ke.totalLabel,children:"Total value"}),n.jsx(pe,{suspenseFallback:n.jsx("div",{className:Ke.skeletonWrapper,children:n.jsx(hn,{height:48,width:120})}),children:e?n.jsx(XC,{}):n.jsx(eN,{})})]}),n.jsxs("nav",{className:Ke.nav,"aria-label":"Quick actions",children:[n.jsxs(dn,{to:"/send",className:Ke.item,children:[n.jsx(E.IconSend,{size:20}),n.jsx("span",{children:"Send"})]}),n.jsxs(dn,{to:"/bridge",className:Ke.item,children:[n.jsx(E.IconBridge,{size:20}),n.jsx("span",{children:"Bridge/Swap"})]}),n.jsxs(dn,{to:"/receive",className:Ke.item,children:[n.jsx(E.IconQrCode,{size:20}),n.jsx("span",{children:"Receive"})]})]}),n.jsxs(Ft.Tabs.Root,{value:s,onValueChange:t,children:[n.jsxs(Ft.Tabs.List,{className:Ke.tabs,children:[n.jsx(Ft.Tabs.Tab,{className:Ke.tab,value:"/",children:e?"Assets":"Portfolio"}),n.jsx(Ft.Tabs.Tab,{className:Ke.tab,value:"/nfts",children:"NFTs"}),n.jsx(Ft.Tabs.Tab,{className:Ke.tab,value:"/activity",children:"Activity"})]}),n.jsx(Ft.Tabs.Panel,{value:"/",children:e?n.jsx(tv,{}):n.jsx(VC,{})}),n.jsx(Ft.Tabs.Panel,{value:"/nfts",children:n.jsx(hw,{})}),n.jsx(Ft.Tabs.Panel,{value:"/activity",children:n.jsx(Gb,{})})]})]})})},nN="_root_th990_1",sN="_collectionName_th990_9",oN="_nftName_th990_13",aN="_chainInfo_th990_17",rN="_attributes_th990_21",iN="_title_th990_24",cN="_count_th990_29",lN="_item_th990_33",dN="_type_th990_39",uN="_value_th990_45",on={root:nN,collectionName:sN,nftName:oN,chainInfo:aN,attributes:rN,title:iN,count:cN,item:lN,type:dN,value:uN},mN=()=>{const e=Se(),t=Xe(),{attributes:s}=t;return n.jsxs(At,{title:"NFT details",children:[n.jsx(Va,{normalizedNft:t,chainIconSize:14,classNames:on}),n.jsx(Ae,{children:n.jsx(ue.White,{onClick:()=>e("/nft/send",t),sm:!0,children:"Send"})}),s&&n.jsxs("div",{className:on.attributes,children:[n.jsxs("header",{className:on.title,children:["Traits ",n.jsxs("span",{className:on.count,children:["(",s.length,")"]})]}),n.jsx("div",{children:s.map(({trait_type:o,value:a})=>n.jsxs("div",{className:on.item,children:[n.jsx("div",{className:on.type,children:o}),n.jsx("div",{className:on.value,children:a})]},o))})]})]})};function hN({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 fN({denom:e,balances:t,gasPrices:s,lastFeeDenom:o,gas:a}){const r=t.find(d=>d.denom===e)?.amount??"0",i=hN({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 pN=({chain:e,onSelect:t})=>{const s=Hl(e);return n.jsx(_s,{assets:s,onSelect:t})},gN=({afterSelect:e})=>{const{watch:t,setValue:s}=Ie.useFormContext(),{chainId:o,denom:a}=t(),{chainId:r}=t(),[i,c]=y.useState(r),l=ft(i),d=he(),m=u=>{if(o===i&&a===u){e();return}s("chainId",i),s("denom",u),s("quantity","",{shouldTouch:!1,shouldDirty:!1}),e()};return n.jsxs(n.Fragment,{children:[n.jsx(mn.Stack,{children:n.jsx(mn,{chains:d,value:i,onSelect:c})}),n.jsx(pe,{suspenseFallback:n.jsx(_s.Placeholder,{}),children:n.jsx(pN,{chain:l,onSelect:m})},i)]})},_N="_fields_brpej_1",yN="_divider_brpej_11",zr={fields:_N,divider:yN},xN=$e.createQueryKeys("interwovenkit:send",{gas:e=>[e]}),bN=()=>{const{address:e,initiaAddress:t,estimateGas:s,requestTxSync:o}=et(),{register:a,watch:r,setValue:i,handleSubmit:c,formState:l}=Ie.useFormContext(),{errors:d}=l,{chainId:m,denom:u,recipient:h,quantity:f,memo:g}=r(),p=ft(m),_=os(p),x=ya(p),b=xa(p),j=ii(u,p),{data:w}=Lt(p),{decimals:v}=j,k=_.find(O=>O.denom===u)?.amount??"0",T=w?.find(({id:O})=>O===u)?.price,{data:M=0,isLoading:A}=S.useQuery({queryKey:xN.gas({chainId:m,denom:u,recipient:h,initiaAddress:t}).queryKey,queryFn:()=>{const O=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Xa.MsgSend.fromPartial({fromAddress:t,toAddress:C.InitiaAddress(h).bech32,amount:[{denom:u,amount:"1"}]})}];return s({messages:O,chainId:m})},enabled:C.InitiaAddress.validate(h),staleTime:K.INFINITY}),L=Math.ceil(M*pn),N=fN({denom:u,balances:_,gasPrices:x,lastFeeDenom:b,gas:L}),I=U(k).isZero(),q=x.some(({denom:O})=>O===u)&&A,P=I||q,{mutate:F,isPending:Q}=S.useMutation({mutationFn:({chainId:O,denom:me,quantity:ge,recipient:ce,memo:ye})=>{const we=C.toBaseUnit(ge,{decimals:v}),ve=[{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Xa.MsgSend.fromPartial({fromAddress:t,toAddress:C.InitiaAddress(ce).bech32,amount:[{denom:me,amount:we}]})}];return o({messages:ve,memo:ye,chainId:O,gas:M,gasAdjustment:pn,gasPrices:x,spendCoins:[{denom:me,amount:we}],internal:"/"})}}),W=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(At,{title:"Send",children:n.jsxs("form",{onSubmit:c(O=>F(O)),"aria-label":"Send token form",children:[n.jsxs("div",{className:zr.fields,children:[n.jsx(Go,{selectButton:n.jsx(Ln,{title:"Select chain and asset",content:O=>n.jsx(gN,{afterSelect:O}),children:n.jsx(Fc,{asset:j,chain:p})}),quantityInput:n.jsx(ts,{balance:k,decimals:v}),balanceButton:n.jsx(qc,{onClick:()=>i("quantity",C.fromBaseUnit(N,{decimals:v}),{shouldValidate:!0}),disabled:P,children:C.formatAmount(k??"0",{decimals:v})}),value:f?Ea(U(f).times(T??0),T):"$0"}),n.jsx("div",{className:zr.divider}),n.jsx(Pa,{myAddress:e}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"memo",children:"Memo (optional)"}),n.jsx("input",{...a("memo",{validate:O=>!O||new Blob([O]).size<=256||"Memo is too long"}),id:"memo",autoComplete:"off"})]}),n.jsx(xe.Stack,{children:!g&&n.jsx(xe,{level:"warning",children:"Check if the above transaction requires a memo"})})]}),n.jsx(Ae,{children:n.jsx(ue.White,{type:"submit",loading:(A?"Estimating gas...":!1)||Q,disabled:!!W,children:W??"Confirm"})})]})})},wN=()=>{const e=Xe(),t=yn(),s=zt(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=Ie.useForm({mode:"onChange",defaultValues:{chainId:o.chainId,denom:r,quantity:"",recipient:"",memo:""}});return n.jsx(Ie.FormProvider,{...i,children:n.jsx(bN,{})})};async function oa(e,t){const s=e.replace("ibc/",""),{class_trace:o}=await z.create({prefixUrl:t}).get(`ibc/apps/nft_transfer/v1/class_traces/${s}`).json();return o}async function vN(e,t){const s=new vt.Interface([{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"}]),{response:o}=await z.create({prefixUrl:t}).post("minievm/evm/v1/call",{json:{sender:C.InitiaAddress("0x1").bech32,contract_addr:C.InitiaAddress(e).hex,input:s.encodeFunctionData("name")}}).json();return s.decodeFunctionResult("name",o)[0]}async function jN(e,t,s){if(t.startsWith("evm/"))return e;const{token_infos:o}=await z.create({prefixUrl:s}).get(`minievm/evm/v1/erc721/origin_token_infos/${t}`,{searchParams:{token_ids:e.join(",")}}).json();return o.map(({token_origin_id:a})=>a)}async function CN({collection_addr:e},{restUrl:t}){const s=await vN(e,t);if(!s.startsWith("ibc/"))return{class_id:`evm/${C.InitiaAddress(e).rawHex}`,class_trace:void 0};const o=await oa(s,t);return o?{class_id:s,class_trace:o}:{class_id:`evm/${C.InitiaAddress(e).rawHex}`,class_trace:void 0}}async function NN(e,t){const{data:s}=await z.create({prefixUrl:t}).post("initia/move/v1/view/json",{json:{address:"0x1",module_name:"collection",function_name:"name",type_args:["0x1::collection::Collection"],args:[JSON.stringify(e)]}}).json();return JSON.parse(s)}async function kN({object_addr:e,collection_addr:t},{restUrl:s}){const o=await NN(t,s);return o.startsWith("ibc/")?C.InitiaAddress.equals(C.createObjectAddress("0x1",o),t)?{class_id:o,class_trace:await oa(o,s)}:{class_id:`move/${e.replace("0x","").padStart(64,"0")}`,class_trace:await oa(o,s)}:{class_id:`move/${t.replace("0x","").padStart(64,"0")}`,class_trace:void 0}}async function IN(e,t){const s=ae.toBase64(rn.utf8ToBytes(JSON.stringify({contract_info:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o.name}async function AN(e,t){const{collection:s}=await z.create({prefixUrl:t}).get(`indexer/nft/v1/collections/${e}`).json();return s.collection.creator}async function SN(e,t){const s=ae.toBase64(rn.toBytes(JSON.stringify({outgoing_proxy:{}}))),{data:o}=await z.create({prefixUrl:t}).get(`cosmwasm/wasm/v1/contract/${e}/smart/${s}`).json();return o}function Hr(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 TN({collection_addr:e},t,s){const o=C.InitiaAddress(e).bech32,a=await IN(o,t.restUrl),r=t.metadata?.ibc_channels?.find(({chain_id:p,version:_})=>p===s.chain_id&&_.includes("ics721-1"));if(!r)throw new Error("Channel not found");const i=r.port_id,c=i.split(".")[1],l=ae.toBase64(rn.toBytes(JSON.stringify({class_id:{contract:o}}))),{data:d}=await z.create({prefixUrl:t.restUrl}).get(`cosmwasm/wasm/v1/contract/${c}/smart/${l}`).json(),m=d??o,u=await SN(c,t.restUrl),h=await AN(o,t.indexerUrl);if(m===o)return{class_id:m,class_trace:void 0,outgoing_proxy:u};if(d&&h!==i.replace("wasm.","")){const[p,_]=Hr(d);return{class_id:o,class_trace:{path:p,base_class_id:_},outgoing_proxy:u}}const[f,g]=Hr(a);return{class_id:o,class_trace:{path:f,base_class_id:g},outgoing_proxy:u}}const EN={minimove:kN,minievm:CN,miniwasm:TN};async function $N({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 EN[o](e,t,s);return Object.assign(a,o==="minievm"&&{token_ids:await jN([e.token_id],a.class_id,t.restUrl)})}const MN="_root_1tyvn_1",LN="_collectionName_1tyvn_10",qN="_nftName_1tyvn_15",PN="_chainInfo_1tyvn_19",RN="_fields_1tyvn_24",DN="_chain_1tyvn_19",Vo={root:MN,collectionName:LN,nftName:qN,chainInfo:PN,fields:RN,chain:DN},BN=$e.createQueryKeys("interwovenkit:send-nft",{simulation:e=>[e]}),FN=()=>{const e=he(),t=Xe(),{chain:s,collection_addr:o}=t,{routerApiUrl:a}=ne(),r=is(),i=oe(),{address:c,initiaAddress:l,requestTxSync:d}=et(),{watch:m,setValue:u,handleSubmit:h,formState:f}=Ie.useFormContext(),{errors:g}=f,p=m(),{recipient:_,dstChainId:x}=p,b=ft(x),j=S.useQuery({queryKey:BN.simulation({collection_addr:o,nft:t,sender:l,recipient:_,srcChain:s,dstChain:b,layer1:i,routerApiUrl:a}).queryKey,queryFn:async()=>{const N=Object.assign({from_address:l,from_chain_id:s.chainId,to_address:C.InitiaAddress(_).bech32,to_chain_id:b.chainId,collection_address:o,token_ids:[t.token_id],object_addresses:[t.object_addr]},s.chainId!==b.chainId&&await $N({nft:t,srcChain:s,intermediaryChain:i})),{msgs:I}=await z.create({prefixUrl:a}).post("nft",{json:N}).json();return I.map(B=>r.fromAmino(B))},enabled:C.InitiaAddress.validate(_)}),{data:w,isLoading:v,error:k}=j,T=S.useQueryClient(),{mutate:M,isPending:A}=S.useMutation({mutationFn:async()=>{if(!w)throw new Error("Route not found");await d({messages:w,chainId:s.chainId,internal:"/nfts"})},onSuccess:()=>{T.invalidateQueries({queryKey:Ka.nfts._def})}}),L=y.useMemo(()=>{if(!_)return"Enter recipient address";if(g.recipient)return g.recipient.message;if(k)return"Route not found"},[_,g.recipient,k]);return n.jsxs("form",{onSubmit:h(()=>M()),children:[n.jsx(Va,{normalizedNft:t,thumbnailSize:80,classNames:Vo}),n.jsxs("div",{className:Vo.fields,children:[n.jsxs("div",{children:[n.jsx("div",{className:"label",children:"Destination app"}),n.jsxs(Ln,{title:"Destination app",content:N=>n.jsx(Bc,{onSelect:({chainId:I})=>{u("dstChainId",I),N()},list:e,getImage:I=>I.logoUrl,getName:I=>I.name,getKey:I=>I.chainId}),className:D("input",Vo.chain),children:[n.jsx(te,{src:b.logoUrl,width:20,height:20,logo:!0}),n.jsx("span",{children:b.name})]})]}),n.jsx(Pa,{myAddress:c,ref:fs()})]}),n.jsx(Ae,{children:n.jsx(ue.White,{loading:(v?"Finding route...":!1)||A,disabled:!!L,children:L??"Confirm"})})]})},UN=()=>{const{chain:e}=Xe(),t=Ie.useForm({mode:"onChange",defaultValues:{dstChainId:e.chainId,recipient:""}});return n.jsx(At,{title:"Send NFT",children:n.jsx(Ie.FormProvider,{...t,children:n.jsx(FN,{})})})},aa=()=>{const e=Se(),t=Xs(),s=Qt(),{closeDrawer:o}=qt(),{closeModal:a}=oo();y.useEffect(()=>{a(),t.startsWith("/bridge/")&&t!=="/bridge/history"&&e("/bridge"),(t==="/collection"||t.startsWith("/nft"))&&e("/nfts")},[s]);const r=qn();if(y.useEffect(()=>{r("Page View")},[t,r]),t==="/connect")return s?null:n.jsx(qr,{onSuccess:o});if(t==="/blank")return null;if(!s)return n.jsx(qr,{});switch(t){case"/":case"/nfts":case"/activity":return n.jsx(tN,{});case"/send":return n.jsx(wN,{},s);case"/receive":return n.jsx(C2,{});case"/nft":return n.jsx(mN,{});case"/nft/send":return n.jsx(UN,{},s);case"/bridge":return n.jsx(ay,{},s);case"/bridge/preview":return n.jsx(wx,{});case"/bridge/history":return n.jsx(Jy,{});case"/op/withdrawals":return n.jsx(Qx,{});case"/tx":return n.jsx(Ic,{});case"/autosign/enable":return n.jsx(Vp,{});case"/settings":return n.jsx(J2,{});case"/settings/autosign":return n.jsx(F2,{});case"/deposit":return n.jsx(d2,{});case"/deposit/completed":return n.jsx(sa,{type:"deposit"});case"/withdraw":return n.jsx(u2,{});case"/withdraw/completed":return n.jsx(sa,{type:"withdraw"})}},ON="https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@100..700&display=swap",VN=()=>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:ON}),n.jsx("link",{rel:"stylesheet",href:"https://assets.initia.xyz/fonts/PilatWide.css"})]}),KN=()=>(Rm(),pd(),Fd(),he(),$m(),mc(),ss(),null),WN=({children:e,...t})=>(y.useEffect(()=>{dm()},[]),ze.useIsClient()?n.jsxs(n.Fragment,{children:[n.jsx(VN,{}),n.jsx(si.Provider,{value:{...ni,...t},children:n.jsx(fi,{children:n.jsx(mp,{children:n.jsx(Z.Tooltip.Provider,{delayDuration:0,skipDelayDuration:0,children:n.jsx(up,{children:n.jsxs(Xf,{children:[e,n.jsx(Dm,{}),n.jsx(pe,{suspenseFallback:null,errorBoundaryProps:{fallback:null},children:n.jsx(KN,{})}),n.jsx(Th,{children:n.jsx(aa,{})}),n.jsx(kh,{children:n.jsx(aa,{})})]})})})})})})]}):null),zN=({bridge:e})=>n.jsx(fi,{initialEntry:{path:e?"/bridge":"/",state:e},children:n.jsx("div",{className:"body",children:n.jsx(wc.Provider,{value:!!e,children:n.jsx(pe,{children:n.jsx(aa,{})})})})}),HN={1:"https://ethereum-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com"};function QN(e){const{id:t="testWallet",name:s="Test Wallet",rpcUrls:o,debug:a=!1,sendTransactionOverrides:r}=e;if("mnemonic"in e&&e.mnemonic==="")throw new Error("mnemonic must not be empty");if(!("mnemonic"in e&&e.mnemonic)&&!("privateKey"in e&&e.privateKey))throw new Error("Either mnemonic or privateKey is required");let i;try{i=e.mnemonic?er.mnemonicToAccount(e.mnemonic):er.privateKeyToAccount(e.privateKey)}catch(p){throw new Error(`[${t}] Failed to create account from ${e.mnemonic?"mnemonic":"privateKey"}`,{cause:p})}let c=1;const l={};function d(p,..._){l[p]?.forEach(x=>{x(..._)})}const m={...HN,...o},u={1:Ml.mainnet};function h(p){if(m[p])return m[p];const _=u[p];if(_)return _.rpcUrls.default.http[0];throw new Error(`[${t}] No RPC configured for chain ${p}`)}async function f(p,_){const x=h(c),b=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:p,params:_??[]})});if(!b.ok)throw new Error(`[${t}] RPC "${p}" failed: HTTP ${b.status} ${b.statusText} (${x})`);let j;try{j=await b.json()}catch(w){throw new Error(`[${t}] RPC "${p}" returned non-JSON response (${x})`,{cause:w})}if(j.error)throw new ut.EIP1193ProviderRpcError(j.error.code,j.error.message);return j.result}const g={request:async({method:p,params:_})=>{switch(a&&console.log(`[${t}] ${p}`,_),p){case"eth_requestAccounts":case"eth_accounts":return[i.address];case"eth_chainId":return`0x${c.toString(16)}`;case"wallet_switchEthereumChain":{const[{chainId:x}]=_,b=Number(x);if(!u[b]&&!m[b])throw new ut.EIP1193ProviderRpcError(4902,"Unrecognized chain ID");return!u[b]&&m[b]&&(u[b]={id:b,name:`Chain ${b}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[m[b]]}}}),c=b,d("chainChanged",x),null}case"wallet_addEthereumChain":{const[x]=_,b=x.rpcUrls?.[0];if(!b)throw new Error(`[${t}] wallet_addEthereumChain requires at least one RPC URL`);const j=Number(x.chainId);return u[j]?a&&console.log(`[${t}] Chain ${j} already registered, skipping`):u[j]={id:j,name:x.chainName??`Chain ${j}`,nativeCurrency:{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[b]}}},null}case"personal_sign":{const[x]=_;return i.signMessage({message:{raw:x}})}case"eth_signTypedData":case"eth_signTypedData_v4":{const[,x]=_;return i.signMessage({message:{raw:x}})}case"wallet_getPermissions":case"wallet_requestPermissions":return[{parentCapability:"eth_accounts"}];case"eth_sendTransaction":{const[x]=_,b=u[c];if(!b)throw new Error(`[${t}] No chain registered for chain ${c}. Call wallet_switchEthereumChain first.`);return ut.createWalletClient({account:i,chain:b,transport:ut.http(h(c))}).sendTransaction({to:x.to,value:x.value?BigInt(x.value):void 0,data:x.data,chainId:c,...r})}default:return f(p,_)}},on:(p,_)=>{(l[p]??=new Set).add(_)},removeListener:(p,_)=>{l[p]?.delete(_)},removeAllListeners:()=>{for(const p of Object.keys(l))delete l[p]}};return Ll.injected({target:()=>({id:t,name:s,provider:g})})}const Qr={"noble-1":"noble",celestia:"celestia","neutron-1":"neutron","osmosis-1":"osmo"};function GN(e){const{mnemonic:t,name:s="Test Cosmos Wallet",image:o,chains:a,debug:r=!1}=e;if(!t)throw new Error("mnemonic is required");const i=new Map;function c(u){return a?.[u]?a[u].prefix:Qr[u]?Qr[u]:u.replace(/-\d+$/,"")}function l(u){const h=c(u),f=i.get(h);if(f)return f;r&&console.log(`[${s}] Creating wallet for chain ${u} (prefix: ${h})`);const g=Tn.Secp256k1HdWallet.fromMnemonic(t,{prefix:h});return g.catch(p=>{i.delete(h),console.error(`[${s}] Failed to create wallet for prefix "${h}":`,p)}),i.set(h,g),g}function d(u){return{async getAccounts(){return(await l(u)).getAccounts()},async signAmino(h,f){return(await l(u)).signAmino(h,f)}}}const m={getOfflineSigner(u){return d(u)},getOfflineSignerOnlyAmino(u){return d(u)}};return{name:s,image:o,getProvider:()=>m}}exports.DEFAULT_GAS_ADJUSTMENT=pn;exports.DEFAULT_GAS_PRICE_MULTIPLIER=ti;exports.InterwovenKit=zN;exports.InterwovenKitProvider=WN;exports.MAINNET=ni;exports.MoveError=Vi;exports.PRIVY_APP_ID=ca;exports.TESTNET=Pl;exports.createTestCosmosWallet=GN;exports.createTestWalletConnector=QN;exports.initiaPrivyWallet=Dl;exports.initiaPrivyWalletConnector=Rl;exports.initiaPrivyWalletOptions=Yn;exports.injectStyles=nh;exports.useAddress=Qt;exports.useHexAddress=Rn;exports.useInitiaAddress=se;exports.useInterwovenKit=et;exports.usePortfolio=ba;exports.useUsernameQuery=tc;
|