graz 0.1.27-alpha.2 → 0.1.27-alpha.4

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.js CHANGED
@@ -6,7 +6,7 @@ var amino = require('@cosmjs/amino');
6
6
  var encoding = require('@cosmjs/encoding');
7
7
  var cosmiframe = require('@dao-dao/cosmiframe');
8
8
  var snapper = require('@cosmsnap/snapper');
9
- var on = require('long');
9
+ var nn = require('long');
10
10
  var signClient = require('@walletconnect/sign-client');
11
11
  var utils = require('@walletconnect/utils');
12
12
  var modal = require('@walletconnect/modal');
@@ -20,80 +20,80 @@ var jsxRuntime = require('react/jsx-runtime');
20
20
 
21
21
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
22
22
 
23
- var on__default = /*#__PURE__*/_interopDefault(on);
23
+ var nn__default = /*#__PURE__*/_interopDefault(nn);
24
24
 
25
- var Bt=Object.defineProperty,Ut=Object.defineProperties;var Ft=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(ae)for(var n of ae(t))ze.call(t,n)&&qe(e,n,t[n]);return e},F=(e,t)=>Ut(e,Ft(t));var Qe=(e,t)=>{var n={};for(var o in e)Ge.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&ae)for(var o of ae(e))t.indexOf(o)<0&&ze.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(d){r(d);}},s=l=>{try{a(n.throw(l));}catch(d){r(d);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Gt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},zt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},f=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,zt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Gt,Qt)));var ce=()=>{var S,y;if(!((S=u.getState().capsuleConfig)!=null&&S.apiKey)||!((y=u.getState().capsuleConfig)!=null&&y.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var w,M;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,C=new m({apiKey:(w=u.getState().capsuleConfig)==null?void 0:w.apiKey,env:(M=u.getState().capsuleConfig)==null?void 0:M.env});return f.setState({capsuleClient:C}),C});return {init:e,enable:m=>c(void 0,null,function*(){let C=typeof m=="string"?[m]:m,w=f.getState().capsuleClient;w||(w=yield e()),u.setState({capsuleState:{showModal:!0,chainId:C}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var p;let m=f.getState().capsuleClient,{chains:C}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!C)throw new Error("Chains are not set");yield m.enable();let w=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!w)throw new Error("Chain ids are not set");let M=Object.fromEntries(yield Promise.all(w.map(A=>c(void 0,null,function*(){let b=yield m.getAccount(A);return [A,{address:encoding.fromBech32(b.address).data,bech32Address:b.address,algo:b.algo,name:b.username||"",pubKey:b.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));f.setState(A=>({accounts:x(x({},A.accounts||{}),M)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...w].filter((b,W,R)=>R.indexOf(b)===W)})),f.setState(A=>({activeChainIds:[...A.activeChainIds||[],...w].filter((b,W,R)=>R.indexOf(b)===W)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:m=>c(void 0,null,function*(){let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");let w=yield C.getAccount(m);return {address:encoding.fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>c(void 0,null,function*(){let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(m)},signDirect:(...m)=>c(void 0,null,function*(){let[C,w,M]=m,p=f.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(C,w,{bodyBytes:M.bodyBytes,authInfoBytes:M.authInfoBytes,chainId:M.chainId,accountNumber:M.accountNumber})}),signAmino:(...m)=>c(void 0,null,function*(){let[C,w,M,p]=m,A=f.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(C,w,M,p)}),signArbitrary:(m,C,w)=>c(void 0,null,function*(){let M=f.getState().capsuleClient;if(!M)throw new Error("Capsule client is not initialized");let p=yield M.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${C}`);let A=(()=>{switch(p.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield M.signArbitrary(m,C,w),pub_key:{type:p.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...m)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerAmino(m)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var O;let i=yield e.request({method:"web3_clientVersion"});if(!i.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(O=i.split("MetaMask/v")[1])==null?void 0:O.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:i=>c(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof tt[i]!="undefined"?tt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:i=>{let s=()=>{K(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var tn=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},nn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:g=>c(void 0,null,function*(){let S=e.getOfflineSigner(g),[y]=yield S.getAccounts();if(!y)throw new Error("Wallet connection failed");let m=(()=>{switch(y.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(y.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:nn(y.address),algo:y.algo,pubKey:y.pubkey,bech32Address:y.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:g=>{let S=e.getOfflineSigner(g),y=e.getOfflineSignerOnlyAmino(g);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:y.signAmino.bind(y)}},getOfflineSignerAuto:g=>Promise.resolve(e.getOfflineSigner(g)),getOfflineSignerOnlyAmino:g=>e.getOfflineSignerOnlyAmino(g),experimentalSuggestChain:g=>e.requestAddInitiaLayer({chain_id:g.chainId,chain_name:g.chainName,bech32_prefix:"init",bech32_config:g.bech32Config,slip44:g.bip44.coinType,logo_URIs:{png:g.chainSymbolImageUrl},fees:{fee_tokens:g.feeCurrencies.map(S=>{var y,m,C;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(y=S.gasPriceStep)==null?void 0:y.low,average_gas_price:(m=S.gasPriceStep)==null?void 0:m.average,high_gas_price:(C=S.gasPriceStep)==null?void 0:C.high}})},apis:{rpc:[{address:g.rpc}],rest:[{address:g.rest}]}}),signDirect:(...g)=>{let[S,y,m]=g;return e.getOfflineSigner(S).signDirect(y,tn(m))},signAmino:(...g)=>{let[S,y,m]=g;return e.getOfflineSignerOnlyAmino(S).signAmino(y,m)},signArbitrary:(g,S,y)=>c(void 0,null,function*(){let w=(yield e.getOfflineSigner(g).getAccounts()).find(A=>A.address===S);if(!w)throw new Error(`Wallet not connected to account ${S}`);let M=(()=>{switch(w.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(w.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(w.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(y),pub_key:{type:w.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:M.value}}}),subscription:g=>{let S=()=>{K(),g();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},rt=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=p=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(b=>b.id===e.id&&(!p||b.version===p))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var _;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(_=p.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=p=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(p,A,b)=>c(void 0,null,function*(){let W=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:b}}}}),R=b.accountNumber,_=new on__default.default(R.low,R.high,R.unsigned);return {signature:W.signature,signed:F(x({},W.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(W.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(W.signed.bodyBytes))})}}),l=(p,A,b)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:b}}}})}),d=p=>c(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[p]=A,fe[p]}),O=p=>c(void 0,null,function*(){let A=yield d(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),g=(...p)=>c(void 0,null,function*(){let[A,b,W,R]=p;return yield l(A,b,W)}),S=(...p)=>c(void 0,null,function*(){let[A,b,W]=p;return yield a(A,b,W)}),m=p=>({getAccounts:()=>c(void 0,null,function*(){return [yield O(p)]}),signAmino:(A,b)=>g(p,A,b)});return {enable:s,experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:d,getOfflineSigner:p=>({getAccounts:()=>c(void 0,null,function*(){return [yield O(p)]}),signDirect:(A,b)=>S(p,A,b),signAmino:(A,b)=>g(p,A,b)}),getOfflineSignerAuto:p=>c(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:i,signAmino:g,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:i=>{var a;let s=()=>{K(),i();};return (a=window.okxwallet)==null||a.on("accountsChanged",s),()=>{var l;(l=window.okxwallet)==null||l.removeListener("accountsChanged",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ye=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{K(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return x({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(d,O)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,d,O;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((d=a.gasPriceStep)==null?void 0:d.high)||0,low:((O=a.gasPriceStep)==null?void 0:O.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Se=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:encoding.fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{K(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,d=F(x({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([d])}),signDirect:(...a)=>c(void 0,null,function*(){var O;let{1:l,2:d}=a;return e.signDirect(l,{bodyBytes:d.bodyBytes||Uint8Array.from([]),authInfoBytes:d.authInfoBytes||Uint8Array.from([]),accountNumber:on__default.default.fromString(((O=d.accountNumber)==null?void 0:O.toString())||"",!1),chainId:d.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:d}=a;return e.signAmino(l,d)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var G=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},at=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ve=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var z=e=>{var _,J,ie;if(!((ie=(J=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:J.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",o=h=>{if(!e)return;let{appUrl:I,formatNativeUrl:E}=e;if(G()){if(at())if(!h)window.open(I.mobile.android,"_self","noreferrer noopener");else {let k=E(I.mobile.android,h,"android");window.open(k,"_self","noreferrer noopener");}if(ct())if(!h)window.open(I.mobile.ios,"_self","noreferrer noopener");else {let k=E(I.mobile.ios,h,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:h}=f.getState();if(!h.get(t))throw new Error("walletConnect.signClient is not defined");h.delete(t),f.setState({wcSignClients:h}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=h=>c(void 0,null,function*(){let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!h)throw new Error("No wallet connect session");yield E.disconnect({topic:h,reason:utils.getSdkError("USER_DISCONNECTED")}),yield l(E);}),s=h=>{try{let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let k=E.session.getAll().at(-1);if(!k)return;if(!(k.expiry*1e3>Date.now()+1e3))throw i(k.topic),new Error("invalid session");return k}catch(I){if(!I.message.toLowerCase().includes("no matching key"))throw I}},a=h=>{try{return s(h)}catch(I){return}},l=h=>c(void 0,null,function*(){try{let I=h.core.pairing.pairings.getAll({active:!1});if(!I.length)return;yield Promise.all(I.map(E=>c(void 0,null,function*(){yield h.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(I){if(!I.message.toLowerCase().includes("no matching key"))throw I}}),d=()=>c(void 0,null,function*(){let{walletConnect:h}=u.getState();if(!(h!=null&&h.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:I}=f.getState(),E=I.get(t);if(E)return E;let k=yield signClient.SignClient.init(h.options);return I.set(t,k),f.setState({wcSignClients:I}),k}),O=h=>{let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)return ()=>{};let k=v=>{let D=f.getState().accounts;if(v.params.event.name==="accountsChanged"&&D&&!Object.values(D).map(L=>L.bech32Address).includes(v.params.event.data[0])){console.log("accountsChanged",v);let L=v.params.chainId.split(":")[1];L&&g([L]);}else console.log("session_event",v),h();};return E.events.on("session_delete",r),E.events.on("session_expire",r),E.events.on("session_event",k),()=>{E.events.off("session_delete",r),E.events.off("session_expire",r),E.events.off("session_event",k);}},g=h=>c(void 0,null,function*(){var ee;let I=typeof h=="string"?[h]:h,{wcSignClients:E}=f.getState(),k=E.get(t);if(!k)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:v,chains:D}=u.getState();if(!((ee=v==null?void 0:v.options)!=null&&ee.projectId))throw new Error("walletConnect.options.projectId is not defined");let L=new modal.WalletConnectModal(x({projectId:v.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},v.walletConnectModal)),Z=a(I);if(!Z){let{uri:Q,approval:j}=yield ve(k.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:I.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!Q)throw new Error("No wallet connect uri");e?o(Q):yield L.openModal({uri:Q});let re=$=>c(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Me,te)=>{j().then(Fe=>{let xe=Fe.sessionProperties;if(console.log("sessionProperties",xe),!xe)return te(new Error("No session properties"));let se=JSON.parse(String(xe.keys));if(console.log("_acc",se),se.length===0)return te(new Error("No accounts"));if(!se[0])return te(new Error("No accounts"));let ke={};return se.forEach(H=>{ke[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),console.log("resAcc",ke),f.setState(H=>({accounts:x(x({},H.accounts||{}),ke)})),Me(Fe)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Me=$.signal;L.subscribeModal(te=>{te.open||$.abort();}),yield re(Me);}catch($){if(L.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||L.closeModal(),Promise.resolve()}try{yield ve((()=>c(void 0,null,function*(){let Q=Object.fromEntries(yield Promise.all(I.map(j=>c(void 0,null,function*(){return [j,yield y(j)]}))));f.setState({accounts:Q});}))(),15e3,new Error("Connection timeout"));}catch(Q){if(i(Z.topic),!Q.message.toLowerCase().includes("no matching key"))throw Q}}),S=h=>c(void 0,null,function*(){var D;let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let k=(D=s())==null?void 0:D.topic;if(!k)throw new Error("No wallet connect session");let v=yield E.request({topic:k,chainId:`cosmos:${h}`,request:{method:"cosmos_getAccounts",params:{}}});if(!v[0])throw new Error("No wallet connect account");return {address:v[0].address,algo:v[0].algo,pubkey:new Uint8Array(Buffer.from(v[0].pubkey,n))}}),y=h=>c(void 0,null,function*(){let I=s();if(!(I!=null&&I.topic))throw new Error("No wallet connect session");let E=I.sessionProperties&&JSON.parse(String(I.sessionProperties.keys))[0];if(!E)throw new Error("No wallet connect key");return E}),m=(...h)=>c(void 0,null,function*(){var j,re;let[I,E,k]=h,{accounts:v,wcSignClients:D}=f.getState(),L=D.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!v)throw new Error("account is not defined");let Z=(j=s())==null?void 0:j.topic;if(!Z)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");let ee={topic:Z,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:F(x({},k),{bodyBytes:Buffer.from(k.bodyBytes).toString(n),authInfoBytes:Buffer.from(k.authInfoBytes).toString(n),accountNumber:(re=k.accountNumber)==null?void 0:re.toString()})}}};return o(),yield L.request(ee)}),C=(...h)=>c(void 0,null,function*(){let[I,E,k]=h,{signature:v,signed:D}=yield m(I,E,k);return {signed:{chainId:D.chainId,accountNumber:on__default.default.fromString(D.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(D.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(D.bodyBytes,n))},signature:v}}),w=(...h)=>c(void 0,null,function*(){var j;let[I,E,k,v]=h,{wcSignClients:D}=f.getState(),L=D.get(t),{accounts:Z}=f.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!Z)throw new Error("account is not defined");let ee=(j=s())==null?void 0:j.topic;if(!ee)throw new Error("No wallet connect session");return o(),yield L.request({topic:ee,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:k}}})}),M=(...h)=>c(void 0,null,function*(){let[I,E,k,v]=h;return yield w(I,E,k)}),p=h=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(h)]}),signDirect:(I,E)=>C(h,I,E)}),A=h=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(h)]}),signAmino:(I,E)=>M(h,I,E)});return {enable:g,disable:h=>c(void 0,null,function*(){var k;let{wcSignClients:I}=f.getState(),E=I.get(t);if(h===void 0){let v=E==null?void 0:E.session.getAll();v!==void 0&&(yield Promise.all(v.map(D=>i(D.topic))));}else typeof h=="string"?yield i((k=s())==null?void 0:k.topic):yield Promise.all(h.map(v=>{var D;return i((D=s())==null?void 0:D.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...h)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:y,getOfflineSigner:h=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(h)]}),signDirect:(I,E)=>C(h,I,E),signAmino:(I,E)=>M(h,I,E)}),getOfflineSignerAuto:h=>c(void 0,null,function*(){return (yield y()).isNanoLedger?A(h):p(h)}),getOfflineSignerOnlyAmino:A,signAmino:M,signDirect:C,subscription:O,init:d}};var lt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return z(e)};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return z(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return z(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return z(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var N=(e=u.getState().walletType)=>{try{return P(e),!0}catch(t){return !1}},K=()=>{window.sessionStorage.removeItem(V),f.setState(ne);},P=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return Se();case"walletconnect":return z();case"wc_keplr_mobile":return pt();case"wc_leap_mobile":return mt();case"wc_cosmostation_mobile":return ut();case"wc_clot_mobile":return lt();case"metamask_snap_leap":return st();case"metamask_snap_cosmos":return nt();case"station":return ye();case"xdefi":return Ce();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return ot();case"okx":return ge();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},ir=()=>Object.fromEntries($e.map(e=>[e,N(e)])),We=e=>e==="capsule",dt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var X=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!N(i))throw new Error(`${i} is not available`);let a=P(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let d=o==null?void 0:o.map(y=>y.chainId);l.forEach(y=>{if(!(d!=null&&d.includes(y)))throw new Error(`Chain ${y} is not provided in GrazProvider`)}),f.setState(y=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return y.activeChainIds&&l.filter(w=>{var M;return !((M=y.activeChainIds)!=null&&M.includes(w))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:O}=f.getState();if(yield (t=a.init)==null?void 0:t.call(a),We(i)&&f.getState().capsuleClient&&Object.values(f.getState().accounts||[]).length>0){let y=l.map(w=>o.find(M=>M.chainId===w)),m=f.getState().accounts;f.setState({status:"connecting"});let C=Object.fromEntries(yield Promise.all(l.map(w=>c(void 0,null,function*(){return [w,yield a.getKey(w)]}))));return f.setState(w=>({accounts:x(x({},w.accounts||{}),C)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...l].filter((M,p,A)=>A.indexOf(M)===p)})),f.setState(w=>({activeChainIds:[...w.activeChainIds||[],...l].filter((M,p,A)=>A.indexOf(M)===p)})),f.setState({status:"connected"}),{accounts:m,walletType:i,chains:y}}if(yield a.enable(l),We(i)){let y=l.map(C=>o.find(w=>w.chainId===C)),m=f.getState().accounts;return f.setState({status:"connecting"}),{accounts:m,walletType:i,chains:y}}if(!dt(i)){let y=Object.fromEntries(yield Promise.all(l.map(m=>c(void 0,null,function*(){return [m,yield a.getKey(m)]}))));f.setState(m=>({accounts:x(x({},m.accounts||{}),y)}));}u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...l].filter((m,C,w)=>w.indexOf(m)===C)})),f.setState(y=>({activeChainIds:[...y.activeChainIds||[],...l].filter((m,C,w)=>w.indexOf(m)===C)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let g=l.map(y=>o.find(m=>m.chainId===y)),S=f.getState().accounts;return console.log("Connected",S),{accounts:S,walletType:i,chains:g}}catch(n){throw console.error("connect ",n),f.getState().accounts===null&&f.setState({status:"disconnected"}),f.getState().accounts&&f.getState().activeChainIds&&f.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=f.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(f.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(f.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else f.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=N(n||void 0);if(t&&i&&n)return yield X({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),oe();}}),ft=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!N(n))throw new Error(`${n} is not available`);let r=P(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var Pe=()=>{u.setState({recentChainIds:null});},gr=()=>u.getState().recentChainIds,yr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},Sr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},Cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Re=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=P(t);return t==="capsule"?yield X({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),gt=e=>c(void 0,null,function*(){var o;let t=u.getState().walletType;return yield Re({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield X({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var yt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var St=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),Ct=O=>c(void 0,[O],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:d}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,o,r,i,s,a,l,d)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),ht=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),At=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),It=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var xr=e=>e,kr=e=>e;var we=e=>e?Object.keys(e).length===0:!0;var De=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new De(e):new DOMException(e),Et=e=>{let t=e.reason===void 0?Ot("This operation was aborted."):e.reason;return t instanceof Error?t:Ot(t)};function _e(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let d=[],O=[],g=new Map,S=!1,y=!1,m=!1,C=0,w=0,M=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{S=!0,y=!0,l(b);};r&&(r.aborted&&p(Et(r)),r.addEventListener("abort",()=>{p(Et(r));}));let A=()=>c(this,null,function*(){if(y)return;let b=yield M.next(),W=w;if(w++,b.done){if(m=!0,C===0&&!y){if(!o&&O.length>0){p(new AggregateError(O));return}if(y=!0,g.size===0){a(d);return}let R=[];for(let[_,J]of d.entries())g.get(_)!==bt&&R.push(J);a(R);}return}C++,c(this,null,function*(){try{let R=yield b.value;if(y)return;let _=yield t(R,W);_===bt&&g.set(W,_),d[W]=_,C--,yield A();}catch(R){if(o)p(R);else {O.push(R),C--;try{yield A();}catch(_){p(_);}}}});});c(this,null,function*(){for(let b=0;b<n;b++){try{yield A();}catch(W){p(W);break}if(m||S)break}});})})}var bt=Symbol("skip");var U=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},q=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield _e(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Tt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var Le=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var O;let a=(O=u.getState().chainsConfig)==null?void 0:O[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Be=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var O;let a=(O=u.getState().chainsConfig)==null?void 0:O[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=U({chainId:t,multiChain:n}),i=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield q(!!n,a,O=>c(void 0,null,function*(){var C;let g=(C=u.getState().chainsConfig)==null?void 0:C[O.chainId],S={url:O.rpc,headers:x({},(g==null?void 0:g.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(S)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var ns=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),Ae=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>N(r))};var Y=e=>{let t=u(a=>a.walletType),n=f(a=>a.activeChainIds),o=U({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=f(a=>a.accounts),i=f(a=>a.status);return react.useEffect(()=>f.subscribe(a=>a.status,(a,l)=>{var d,O,g;if(a==="connected"){let{accounts:S,activeChainIds:y}=f.getState(),{chains:m}=u.getState(),{walletType:C}=u.getState();if(!S||!y||!m)return (d=e==null?void 0:e.onDisconnect)==null?void 0:d.call(e);(O=e==null?void 0:e.onConnect)==null||O.call(e,{accounts:S,chains:y.map(w=>m.find(M=>M.chainId===w)),walletType:C,isReconnect:l==="reconnecting"});}a==="disconnected"&&((g=e==null?void 0:e.onDisconnect)==null||g.call(e));}),[e]),{data:react.useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:B,status:i}},Cn=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Le({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=react.useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(i,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){let S=s==null?void 0:s[g.chainId];if(!S)throw new Error(`Client is not ready ${g.chainId}`);return yield S.getAllBalances(encoding.toBech32(g.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!we(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},gs=e=>{let t=U({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=Cn({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,l,d]})=>d==null?void 0:d.find(O=>O.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(x({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],X,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=Ae();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},Ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],oe,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},Cs=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!N(i))throw new Error(`${i} is not available`);return yield q(!!(e!=null&&e.multiChain),r,d=>c(void 0,null,function*(){return yield ft({chainId:d.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},ws=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:o}=Le({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=react.useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return reactQuery.useQuery(i,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){var y;if(!s)throw new Error("Client is not ready");return yield (y=s[g.chainId])==null?void 0:y.getBalanceStaked(encoding.toBech32(g.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Ts=()=>{let e=u(o=>o.capsuleState),t=f(o=>o.capsuleClient),n=ce();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var Rs=()=>f(e=>e.activeChainIds),wn=()=>{var e;return (e=f(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Ds=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},_s=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ks=({denom:e})=>{let t=wn();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Ns=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ls=()=>({data:u(t=>t.recentChainIds),clear:Pe}),Bs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:Pe}},Us=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],Re,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],gt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=Ae();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Vs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>St(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},Xs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>Ct(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Ys=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var O;if(!i)throw new Error("senderAddress is undefined");let d=F(x({},l),{fee:(O=l.fee)!=null?O:"auto",senderAddress:i,codeId:e});return wt(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Js=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var O,g,S;if(!i)throw new Error("senderAddress is undefined");let d=F(x({},l),{fee:(O=l.fee)!=null?O:"auto",senderAddress:i,contractAddress:e,memo:(g=l.memo)!=null?g:"",funds:(S=l.funds)!=null?S:[]});return ht(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Zs=e=>{let{data:t}=Be();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return At(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ea=e=>{let{data:t}=Be(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return It(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function da(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=f(i=>i.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,d=>c(this,null,function*(){var C,w;if(!(o!=null&&o.includes(d.chainId)))return null;if(!N(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(d.chainId);default:return P(s).getOfflineSignerAuto(d.chainId)}}))(),S=(C=u.getState().chainsConfig)==null?void 0:C[d.chainId],y={url:d.rpc,headers:x({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(y,g,e!=null&&e.multiChain?(w=e.opts)==null?void 0:w[d.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function fa(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=f(i=>i.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,d=>c(this,null,function*(){var w,M;if(!(o!=null&&o.includes(d.chainId)))return null;if(!N(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(d.chainId);default:return P(s).getOfflineSignerAuto(d.chainId)}}))(),S=(w=u.getState().chainsConfig)==null?void 0:w[d.chainId],y={url:d.rpc,headers:x({},(S==null?void 0:S.rpcHeaders)||{})},m=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(y,g,x({gasPrice:m},e!=null&&e.multiChain?(M=e.opts)==null?void 0:M[d.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ga(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=f(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,O=>c(this,null,function*(){var C;if(!(o!=null&&o.includes(O.chainId)))return null;if(!N(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let S=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(a).getOfflineSigner(O.chainId);case"offlineSignerAuto":return P(a).getOfflineSignerAuto(O.chainId);case"offlineSignerOnlyAmino":return P(a).getOfflineSignerOnlyAmino(O.chainId);default:return P(a).getOfflineSignerAuto(O.chainId)}}))(),y=e.multiChain?i[O.chainId]:i;return yield stargate.SigningStargateClient.createWithSigner(y,S,e.multiChain?(C=e.opts)==null?void 0:C[O.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ya(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=f(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:d=>c(this,[d],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,g=>c(this,null,function*(){var p,A;if(!(o!=null&&o.includes(g.chainId)))return null;if(!N(l))throw new Error(`${l} is not available`);let y=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(l).getOfflineSigner(g.chainId);case"offlineSignerAuto":return P(l).getOfflineSignerAuto(g.chainId);case"offlineSignerOnlyAmino":return P(l).getOfflineSignerOnlyAmino(g.chainId);default:return P(l).getOfflineSignerAuto(g.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[g.chainId],C=m!=null&&m.gas?stargate.GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,w=e.multiChain?s==null?void 0:s[g.chainId]:i;if(!w)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(w,y,x({gasPrice:C},e.multiChain?(A=e.opts)==null?void 0:A[g.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!we(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Kt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=f(),l=N(o||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(O=>{if(O)return X({chainId:i.map(g=>g.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(o){if(!l)return;e&&s?B({onError:n}):!e&&t&&B({onError:n});}},[l]),react.useEffect(()=>{var d,O,g,S,y,m,C,w,M,p,A,b,W,R,_,J,ie,h,I,E;if(o){if(!l)return;o==="cosmostation"&&((O=(d=pe()).subscription)==null||O.call(d,()=>{B({onError:n});})),o==="keplr"&&((S=(g=me()).subscription)==null||S.call(g,()=>{B({onError:n});})),o==="leap"&&((m=(y=de()).subscription)==null||m.call(y,()=>{B({onError:n});})),o==="compass"&&((w=(C=le()).subscription)==null||w.call(C,()=>{B({onError:n});})),o==="vectis"&&((p=(M=Se()).subscription)==null||p.call(M,()=>{B({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((b=(A=z()).subscription)==null||b.call(A,()=>{B({onError:n});})),o==="station"&&((R=(W=ye()).subscription)==null||R.call(W,()=>{B({onError:n});})),o==="xdefi"&&((J=(_=Ce()).subscription)==null||J.call(_,()=>{B({onError:n});})),o==="cosmiframe"&&((h=(ie=ue()).subscription)==null||h.call(ie,()=>{B({onError:n});})),o==="okx"&&((E=(I=ge()).subscription)==null||E.call(I,()=>{B({onError:n});}));}},[o,a,l]),null},Nt=()=>(bn(),null);var kn=new reactQuery.QueryClient({}),$a=o=>{var r=o,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return react.useEffect(()=>{yt(t);},[t]),jsxRuntime.jsx(reactQuery.QueryClientProvider,F(x({client:kn},n),{children:jsxRuntime.jsxs(Kt,{children:[e,jsxRuntime.jsx(Nt,{})]})}),"graz-provider")};
25
+ var Lt=Object.defineProperty,Bt=Object.defineProperties;var Ut=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(ae)for(var n of ae(t))ze.call(t,n)&&qe(e,n,t[n]);return e},F=(e,t)=>Bt(e,Ut(t));var Qe=(e,t)=>{var n={};for(var i in e)Ge.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&ae)for(var i of ae(e))t.indexOf(i)<0&&ze.call(e,i)&&(n[i]=e[i]);return n};var c=(e,t,n)=>new Promise((i,r)=>{var o=l=>{try{a(n.next(l));}catch(d){r(d);}},s=l=>{try{a(n.throw(l));}catch(d){r(d);}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Gt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},zt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},f=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,Gt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>qt,zt)));var ce=()=>{var S,E;if(!((S=u.getState().capsuleConfig)!=null&&S.apiKey)||!((E=u.getState().capsuleConfig)!=null&&E.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var O,b;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,y=new m({apiKey:(O=u.getState().capsuleConfig)==null?void 0:O.apiKey,env:(b=u.getState().capsuleConfig)==null?void 0:b.env});return f.setState({capsuleClient:y}),y});return {init:e,enable:m=>c(void 0,null,function*(){let y=typeof m=="string"?[m]:m,O=f.getState().capsuleClient;O||(O=yield e()),u.setState({capsuleState:{showModal:!0,chainId:y}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var p;let m=f.getState().capsuleClient,{chains:y}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!y)throw new Error("Chains are not set");yield m.enable();let O=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!O)throw new Error("Chain ids are not set");let b=Object.fromEntries(yield Promise.all(O.map(w=>c(void 0,null,function*(){let T=yield m.getAccount(w);return [w,{address:encoding.fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));f.setState(w=>({accounts:x(x({},w.accounts||{}),b)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...O].filter((T,P,D)=>D.indexOf(T)===P)})),f.setState(w=>({activeChainIds:[...w.activeChainIds||[],...O].filter((T,P,D)=>D.indexOf(T)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:m=>c(void 0,null,function*(){let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");let O=yield y.getAccount(m);return {address:encoding.fromBech32(O.address).data,bech32Address:O.address,algo:O.algo,name:O.username||"",pubKey:O.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>c(void 0,null,function*(){let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(m)},signDirect:(...m)=>c(void 0,null,function*(){let[y,O,b]=m,p=f.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(y,O,{bodyBytes:b.bodyBytes,authInfoBytes:b.authInfoBytes,chainId:b.chainId,accountNumber:b.accountNumber})}),signAmino:(...m)=>c(void 0,null,function*(){let[y,O,b,p]=m,w=f.getState().capsuleClient;if(!w)throw new Error("Capsule client is not initialized");return w.signAmino(y,O,b,p)}),signArbitrary:(m,y,O)=>c(void 0,null,function*(){let b=f.getState().capsuleClient;if(!b)throw new Error("Capsule client is not initialized");let p=yield b.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${y}`);let w=(()=>{switch(p.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield b.signArbitrary(m,y,O),pub_key:{type:p.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:w.value}}}),experimentalSuggestChain:(...m)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerAmino(m)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let o=()=>{K(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var A;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(A=o.split("MetaMask/v")[1])==null?void 0:A.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:o=>c(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>c(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,s,a)=>c(void 0,null,function*(){return t.signAmino(o,s,a)}),getKey:o=>c(void 0,null,function*(){return typeof tt[o]!="undefined"?tt[o]:t.getKey(o)}),getOfflineSignerAuto:o=>c(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,a)=>c(void 0,null,function*(){return t.signDirect(o,s,a)}),signArbitrary:(o,s,a)=>c(void 0,null,function*(){return t.signArbitrary(o,s,a)}),disable:o=>c(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{K(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var en=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:i,accountNumber:r}=e;if(!t||!n||!i||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:i,accountNumber:r}},tn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,it=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:g=>c(void 0,null,function*(){let S=e.getOfflineSigner(g),[E]=yield S.getAccounts();if(!E)throw new Error("Wallet connection failed");let m=(()=>{switch(E.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(E.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(E.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:tn(E.address),algo:E.algo,pubKey:E.pubkey,bech32Address:E.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:g=>{let S=e.getOfflineSigner(g),E=e.getOfflineSignerOnlyAmino(g);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:E.signAmino.bind(E)}},getOfflineSignerAuto:g=>Promise.resolve(e.getOfflineSigner(g)),getOfflineSignerOnlyAmino:g=>e.getOfflineSignerOnlyAmino(g),experimentalSuggestChain:g=>e.requestAddInitiaLayer({chain_id:g.chainId,chain_name:g.chainName,bech32_prefix:"init",bech32_config:g.bech32Config,slip44:g.bip44.coinType,logo_URIs:{png:g.chainSymbolImageUrl},fees:{fee_tokens:g.feeCurrencies.map(S=>{var E,m,y;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(E=S.gasPriceStep)==null?void 0:E.low,average_gas_price:(m=S.gasPriceStep)==null?void 0:m.average,high_gas_price:(y=S.gasPriceStep)==null?void 0:y.high}})},apis:{rpc:[{address:g.rpc}],rest:[{address:g.rest}]}}),signDirect:(...g)=>{let[S,E,m]=g;return e.getOfflineSigner(S).signDirect(E,en(m))},signAmino:(...g)=>{let[S,E,m]=g;return e.getOfflineSignerOnlyAmino(S).signAmino(E,m)},signArbitrary:(g,S,E)=>c(void 0,null,function*(){let O=(yield e.getOfflineSigner(g).getAccounts()).find(w=>w.address===S);if(!O)throw new Error(`Wallet not connected to account ${S}`);let b=(()=>{switch(O.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(O.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(O.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(E),pub_key:{type:O.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:b.value}}}),subscription:g=>{let S=()=>{K(),g();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{K(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},rt=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=p=>c(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(T=>T.id===e.id&&(!p||T.version===p))}catch(w){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>c(void 0,null,function*(){var _;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let T=(_=p.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=p=>c(void 0,null,function*(){(yield i())||(yield r());}),a=(p,w,T)=>c(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:w,signDoc:T}}}}),D=T.accountNumber,_=new nn__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:F(x({},P.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),l=(p,w,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:w,signDoc:T}}}})}),d=p=>c(void 0,null,function*(){if(typeof fe[p]!="undefined")return fe[p];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,fe[p]=w,fe[p]}),A=p=>c(void 0,null,function*(){let w=yield d(p);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),g=(...p)=>c(void 0,null,function*(){let[w,T,P,D]=p;return yield l(w,T,P)}),S=(...p)=>c(void 0,null,function*(){let[w,T,P]=p;return yield a(w,T,P)}),m=p=>({getAccounts:()=>c(void 0,null,function*(){return [yield A(p)]}),signAmino:(w,T)=>g(p,w,T)});return {enable:s,experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:d,getOfflineSigner:p=>({getAccounts:()=>c(void 0,null,function*(){return [yield A(p)]}),signDirect:(w,T)=>S(p,w,T),signAmino:(w,T)=>g(p,w,T)}),getOfflineSignerAuto:p=>c(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:o,signAmino:g,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var a;let s=()=>{K(),o();};return (a=window.okxwallet)==null||a.on("accountsChanged",s),()=>{var l;(l=window.okxwallet)==null||l.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ye=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{K(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>c(void 0,null,function*(){let s=yield e.getKey(o);return x({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(d,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>c(void 0,null,function*(){try{let s=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var l,d,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((d=a.gasPriceStep)==null?void 0:d.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,s,a,l)=>e.signAmino(o,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Se=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:encoding.fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{K(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,d=F(x({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([d])}),signDirect:(...a)=>c(void 0,null,function*(){var A;let{1:l,2:d}=a;return e.signDirect(l,{bodyBytes:d.bodyBytes||Uint8Array.from([]),authInfoBytes:d.authInfoBytes||Uint8Array.from([]),accountNumber:nn__default.default.fromString(((A=d.accountNumber)==null?void 0:A.toString())||"",!1),chainId:d.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:d}=a;return e.signAmino(l,d)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var G=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},at=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var ve=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var z=e=>{var _,J,oe;if(!((oe=(J=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:J.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=C=>{if(!e)return;let{appUrl:h,formatNativeUrl:I}=e;if(G()){if(at())if(!C)window.open(h.mobile.android,"_self","noreferrer noopener");else {let k=I(h.mobile.android,C,"android");window.open(k,"_self","noreferrer noopener");}if(ct())if(!C)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let k=I(h.mobile.ios,C,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:C}=f.getState();if(!C.get(t))throw new Error("walletConnect.signClient is not defined");C.delete(t),f.setState({wcSignClients:C}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=C=>c(void 0,null,function*(){let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!C)throw new Error("No wallet connect session");yield I.disconnect({topic:C,reason:utils.getSdkError("USER_DISCONNECTED")}),yield l(I);}),s=C=>{try{let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");console.log(I.session.getAll());let k=I.session.getAll().at(-1);if(!k)return;if(!(k.expiry*1e3>Date.now()+1e3))throw o(k.topic),new Error("invalid session");try{let W=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:C.map(N=>`cosmos:${N}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return k}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},a=C=>{try{return s(C)}catch(h){return}},l=C=>c(void 0,null,function*(){try{let h=C.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(I=>c(void 0,null,function*(){yield C.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),d=()=>c(void 0,null,function*(){let{walletConnect:C}=u.getState();if(!(C!=null&&C.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:h}=f.getState(),I=h.get(t);if(I)return I;let k=yield signClient.SignClient.init(C.options);return h.set(t,k),f.setState({wcSignClients:h}),k}),A=C=>{let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)return ()=>{};let k=v=>{let W=f.getState().accounts;if(v.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(N=>N.bech32Address).includes(v.params.event.data[0])){console.log("accountsChanged",v);let N=v.params.chainId.split(":")[1];N&&g([N]);}else console.log("session_event",v),C();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",k),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",k);}},g=C=>c(void 0,null,function*(){var ee;let h=typeof C=="string"?[C]:C,{wcSignClients:I}=f.getState(),k=I.get(t);if(!k)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:v,chains:W}=u.getState();if(!((ee=v==null?void 0:v.options)!=null&&ee.projectId))throw new Error("walletConnect.options.projectId is not defined");let N=new modal.WalletConnectModal(x({projectId:v.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},v.walletConnectModal)),Z=a(h);if(!Z){let{uri:Q,approval:j}=yield ve(k.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!Q)throw new Error("No wallet connect uri");e?i(Q):yield N.openModal({uri:Q});let re=$=>c(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Me,te)=>{j().then(Fe=>{let xe=Fe.sessionProperties;if(console.log("sessionProperties",xe),!xe)return te(new Error("No session properties"));let se=JSON.parse(String(xe.keys));if(console.log("_acc",se),se.length===0)return te(new Error("No accounts"));if(!se[0])return te(new Error("No accounts"));let ke={};return se.forEach(H=>{ke[H.chainId]={address:H.address,algo:H.algo,bech32Address:H.bech32Address,isNanoLedger:H.isNanoLedger,isKeystone:H.isKeystone,name:H.name,pubKey:H.pubKey};}),console.log("resAcc",ke),f.setState(H=>({accounts:x(x({},H.accounts||{}),ke)})),Me(Fe)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Me=$.signal;N.subscribeModal(te=>{te.open||$.abort();}),yield re(Me);}catch($){if(N.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||N.closeModal(),Promise.resolve()}try{yield ve((()=>c(void 0,null,function*(){let Q=Object.fromEntries(yield Promise.all(h.map(j=>c(void 0,null,function*(){return [j,yield E(j)]}))));f.setState({accounts:Q});}))(),15e3,new Error("Connection timeout"));}catch(Q){if(o(Z.topic),!Q.message.toLowerCase().includes("no matching key"))throw Q}}),S=C=>c(void 0,null,function*(){var W;let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let k=(W=s([C]))==null?void 0:W.topic;if(!k)throw new Error("No wallet connect session");let v=yield I.request({topic:k,chainId:`cosmos:${C}`,request:{method:"cosmos_getAccounts",params:{}}});if(!v[0])throw new Error("No wallet connect account");return {address:v[0].address,algo:v[0].algo,pubkey:new Uint8Array(Buffer.from(v[0].pubkey,n))}}),E=C=>c(void 0,null,function*(){let h=s([C]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let I=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),m=(...C)=>c(void 0,null,function*(){var j,re;let[h,I,k]=C,{accounts:v,wcSignClients:W}=f.getState(),N=W.get(t);if(!N)throw new Error("walletConnect.signClient is not defined");if(!v)throw new Error("account is not defined");let Z=(j=s([h]))==null?void 0:j.topic;if(!Z)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");let ee={topic:Z,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:F(x({},k),{bodyBytes:Buffer.from(k.bodyBytes).toString(n),authInfoBytes:Buffer.from(k.authInfoBytes).toString(n),accountNumber:(re=k.accountNumber)==null?void 0:re.toString()})}}};return i(),yield N.request(ee)}),y=(...C)=>c(void 0,null,function*(){let[h,I,k]=C,{signature:v,signed:W}=yield m(h,I,k);return {signed:{chainId:W.chainId,accountNumber:nn__default.default.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:v}}),O=(...C)=>c(void 0,null,function*(){var j;let[h,I,k,v]=C,{wcSignClients:W}=f.getState(),N=W.get(t),{accounts:Z}=f.getState();if(!N)throw new Error("walletConnect.signClient is not defined");if(!Z)throw new Error("account is not defined");let ee=(j=s([h]))==null?void 0:j.topic;if(!ee)throw new Error("No wallet connect session");return i(),yield N.request({topic:ee,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:k}}})}),b=(...C)=>c(void 0,null,function*(){let[h,I,k,v]=C;return yield O(h,I,k)}),p=C=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(C)]}),signDirect:(h,I)=>y(C,h,I)}),w=C=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(C)]}),signAmino:(h,I)=>b(C,h,I)});return {enable:g,disable:C=>c(void 0,null,function*(){var k;let{wcSignClients:h}=f.getState(),I=h.get(t);if(C===void 0){let v=I==null?void 0:I.session.getAll();v!==void 0&&(yield Promise.all(v.map(W=>o(W.topic))));}else typeof C=="string"?yield o((k=s([C]))==null?void 0:k.topic):yield Promise.all(C.map(v=>{var W;return o((W=s([v]))==null?void 0:W.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...C)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:E,getOfflineSigner:C=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(C)]}),signDirect:(h,I)=>y(C,h,I),signAmino:(h,I)=>b(C,h,I)}),getOfflineSignerAuto:C=>c(void 0,null,function*(){return (yield E(C)).isNanoLedger?w(C):p(C)}),getOfflineSignerOnlyAmino:w,signAmino:b,signDirect:y,subscription:A,init:d}};var lt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return z(e)};var ut=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return z(e)};var pt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return z(e)};var mt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return z(e)};var Ce=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var L=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},K=()=>{window.sessionStorage.removeItem(V),f.setState(ne);},R=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return Se();case"walletconnect":return z();case"wc_keplr_mobile":return pt();case"wc_leap_mobile":return mt();case"wc_cosmostation_mobile":return ut();case"wc_clot_mobile":return lt();case"metamask_snap_leap":return st();case"metamask_snap_cosmos":return nt();case"station":return ye();case"xdefi":return Ce();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return it();case"okx":return ge();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},nr=()=>Object.fromEntries($e.map(e=>[e,L(e)])),We=e=>e==="capsule",or=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var X=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!L(o))throw new Error(`${o} is not available`);let a=R(o),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let d=i==null?void 0:i.map(m=>m.chainId);l.forEach(m=>{if(!(d!=null&&d.includes(m)))throw new Error(`Chain ${m} is not provided in GrazProvider`)}),f.setState(m=>{let y=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return m.activeChainIds&&l.filter(b=>{var p;return !((p=m.activeChainIds)!=null&&p.includes(b))}).length>0?{status:"connecting"}:y?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=f.getState();if(yield (t=a.init)==null?void 0:t.call(a),We(o)&&f.getState().capsuleClient&&Object.values(f.getState().accounts||[]).length>0){let m=l.map(b=>i.find(p=>p.chainId===b)),y=f.getState().accounts;f.setState({status:"connecting"});let O=Object.fromEntries(yield Promise.all(l.map(b=>c(void 0,null,function*(){return [b,yield a.getKey(b)]}))));return f.setState(b=>({accounts:x(x({},b.accounts||{}),O)})),u.setState(b=>({recentChainIds:[...b.recentChainIds||[],...l].filter((p,w,T)=>T.indexOf(p)===w)})),f.setState(b=>({activeChainIds:[...b.activeChainIds||[],...l].filter((p,w,T)=>T.indexOf(p)===w)})),f.setState({status:"connected"}),{accounts:y,walletType:o,chains:m}}if(yield a.enable(l),We(o)){let m=l.map(O=>i.find(b=>b.chainId===O)),y=f.getState().accounts;return f.setState({status:"connecting"}),{accounts:y,walletType:o,chains:m}}let g=Object.fromEntries(yield Promise.all(l.map(m=>c(void 0,null,function*(){return [m,yield a.getKey(m)]}))));f.setState(m=>({accounts:x(x({},m.accounts||{}),g)})),u.setState(m=>({recentChainIds:[...m.recentChainIds||[],...l].filter((y,O,b)=>b.indexOf(y)===O)})),f.setState(m=>({activeChainIds:[...m.activeChainIds||[],...l].filter((y,O,b)=>b.indexOf(y)===O)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let S=l.map(m=>i.find(y=>y.chainId===m)),E=f.getState().accounts;return console.log("Connected",E),{accounts:E,walletType:o,chains:S}}catch(n){throw console.error("connect ",n),f.getState().accounts===null&&f.setState({status:"disconnected"}),f.getState().accounts&&f.getState().activeChainIds&&f.setState({status:"connected"}),n}}),ie=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=f.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(f.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(f.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else f.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},B=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=L(n||void 0);if(t&&o&&n)return yield X({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ie();}}),dt=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!L(n))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Pe=()=>{u.setState({recentChainIds:null});},yr=()=>u.getState().recentChainIds,Sr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},Cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},wr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Re=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let i=R(t);return t==="capsule"?yield X({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),ft=e=>c(void 0,null,function*(){var i;let t=u.getState().walletType;return yield Re({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield X({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var gt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var yt=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),St=A=>c(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:d}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,s,a,l,d)}),Ct=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),ht=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),At=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var kr=e=>e,vr=e=>e;var we=e=>e?Object.keys(e).length===0:!0;var De=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},It=e=>globalThis.DOMException===void 0?new De(e):new DOMException(e),Ot=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function _e(o,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,l)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let d=[],A=[],g=new Map,S=!1,E=!1,m=!1,y=0,O=0,b=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=T=>{S=!0,E=!0,l(T);};r&&(r.aborted&&p(Ot(r)),r.addEventListener("abort",()=>{p(Ot(r));}));let w=()=>c(this,null,function*(){if(E)return;let T=yield b.next(),P=O;if(O++,T.done){if(m=!0,y===0&&!E){if(!i&&A.length>0){p(new AggregateError(A));return}if(E=!0,g.size===0){a(d);return}let D=[];for(let[_,J]of d.entries())g.get(_)!==Et&&D.push(J);a(D);}return}y++,c(this,null,function*(){try{let D=yield T.value;if(E)return;let _=yield t(D,P);_===Et&&g.set(P,_),d[P]=_,y--,yield w();}catch(D){if(i)p(D);else {A.push(D),y--;try{yield w();}catch(_){p(_);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield w();}catch(P){p(P);break}if(m||S)break}});})})}var Et=Symbol("skip");var U=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},q=(e,t,n)=>c(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield _e(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),bt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Le=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,s=>c(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Be=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,s=>c(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=U({chainId:t,multiChain:n}),o=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:o,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield q(!!n,a,A=>c(void 0,null,function*(){var y;let g=(y=u.getState().chainsConfig)==null?void 0:y[A.chainId],S={url:A.rpc,headers:x({},(g==null?void 0:g.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(S)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var os=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),Ae=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>L(r))};var Y=e=>{let t=u(a=>a.walletType),n=f(a=>a.activeChainIds),i=U({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=f(a=>a.accounts),o=f(a=>a.status);return react.useEffect(()=>f.subscribe(a=>a.status,(a,l)=>{var d,A,g;if(a==="connected"){let{accounts:S,activeChainIds:E}=f.getState(),{chains:m}=u.getState(),{walletType:y}=u.getState();if(!S||!E||!m)return (d=e==null?void 0:e.onDisconnect)==null?void 0:d.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:S,chains:E.map(O=>m.find(b=>b.chainId===O)),walletType:y,isReconnect:l==="reconnecting"});}a==="disconnected"&&((g=e==null?void 0:e.onDisconnect)==null||g.call(e));}),[e]),{data:react.useMemo(()=>r?bt(!!(e!=null&&e.multiChain),i,a=>r[a.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:B,status:o}},Sn=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Le({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=react.useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(o,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){let S=s==null?void 0:s[g.chainId];if(!S)throw new Error(`Client is not ready ${g.chainId}`);return yield S.getAllBalances(encoding.toBech32(g.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!we(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ys=e=>{let t=U({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=Sn({chainId:t.map(l=>l.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,l,d]})=>d==null?void 0:d.find(A=>A.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(x({},a),{refetch:l=>c(void 0,null,function*(){return yield o(),a.refetch(l)})})},Ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],X,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Ae();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],ie,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},ws=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!L(o))throw new Error(`${o} is not available`);return yield q(!!(e!=null&&e.multiChain),r,d=>c(void 0,null,function*(){return yield dt({chainId:d.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},hs=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=Le({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return reactQuery.useQuery(o,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){var E;if(!s)throw new Error("Client is not ready");return yield (E=s[g.chainId])==null?void 0:E.getBalanceStaked(encoding.toBech32(g.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Ms=()=>{let e=u(i=>i.capsuleState),t=f(i=>i.capsuleClient),n=ce();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ie();}}};var Ds=()=>f(e=>e.activeChainIds),Cn=()=>{var e;return (e=f(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},_s=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ks=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ns=({denom:e})=>{let t=Cn();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},Ls=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>c(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Bs=()=>({data:u(t=>t.recentChainIds),clear:Pe}),Us=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:Pe}},Fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],Re,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},qs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ft,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Ae();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Xs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>yt(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>St(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Js=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],l=>{var A;if(!o)throw new Error("senderAddress is undefined");let d=F(x({},l),{fee:(A=l.fee)!=null?A:"auto",senderAddress:o,codeId:e});return Ct(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(i==null?void 0:i(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Zs=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],l=>{var A,g,S;if(!o)throw new Error("senderAddress is undefined");let d=F(x({},l),{fee:(A=l.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(g=l.memo)!=null?g:"",funds:(S=l.funds)!=null?S:[]});return wt(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(i==null?void 0:i(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ea=e=>{let{data:t}=Be();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return ht(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ta=e=>{let{data:t}=Be(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return At(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function fa(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=f(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,d=>c(this,null,function*(){var y,O;if(!(i!=null&&i.includes(d.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(d.chainId);default:return R(s).getOfflineSignerAuto(d.chainId)}}))(),S=(y=u.getState().chainsConfig)==null?void 0:y[d.chainId],E={url:d.rpc,headers:x({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(E,g,e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[d.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ga(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=f(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,d=>c(this,null,function*(){var O,b;if(!(i!=null&&i.includes(d.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(d.chainId);default:return R(s).getOfflineSignerAuto(d.chainId)}}))(),S=(O=u.getState().chainsConfig)==null?void 0:O[d.chainId],E={url:d.rpc,headers:x({},(S==null?void 0:S.rpcHeaders)||{})},m=S!=null&&S.gas?stargate.GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(E,g,x({gasPrice:m},e!=null&&e.multiChain?(b=e.opts)==null?void 0:b[d.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ya(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=f(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,A=>c(this,null,function*(){var y;if(!(i!=null&&i.includes(A.chainId)))return null;if(!L(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let S=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(A.chainId);default:return R(a).getOfflineSignerAuto(A.chainId)}}))(),E=e.multiChain?o[A.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(E,S,e.multiChain?(y=e.opts)==null?void 0:y[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Sa(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=f(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:d=>c(this,[d],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,g=>c(this,null,function*(){var p,w;if(!(i!=null&&i.includes(g.chainId)))return null;if(!L(l))throw new Error(`${l} is not available`);let E=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(l).getOfflineSigner(g.chainId);case"offlineSignerAuto":return R(l).getOfflineSignerAuto(g.chainId);case"offlineSignerOnlyAmino":return R(l).getOfflineSignerOnlyAmino(g.chainId);default:return R(l).getOfflineSignerAuto(g.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[g.chainId],y=m!=null&&m.gas?stargate.GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,O=e.multiChain?s==null?void 0:s[g.chainId]:o;if(!O)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(O,E,x({gasPrice:y},e.multiChain?(w=e.opts)==null?void 0:w[g.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!we(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var _t=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var En=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:s,wcSignClients:a}=f(),l=L(i||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(A=>{if(A)return X({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(i){if(!l)return;e&&s?(console.log("reconnect on refresh"),B({onError:n})):!e&&t&&(console.log("reconnect on autoReconnect"),B({onError:n}));}},[l]),react.useEffect(()=>{var d,A,g,S,E,m,y,O,b,p,w,T,P,D,_,J,oe,C,h,I;if(i){if(!l)return;i==="cosmostation"&&((A=(d=pe()).subscription)==null||A.call(d,()=>{B({onError:n});})),i==="keplr"&&((S=(g=me()).subscription)==null||S.call(g,()=>{B({onError:n});})),i==="leap"&&((m=(E=de()).subscription)==null||m.call(E,()=>{B({onError:n});})),i==="compass"&&((O=(y=le()).subscription)==null||O.call(y,()=>{B({onError:n});})),i==="vectis"&&((p=(b=Se()).subscription)==null||p.call(b,()=>{B({onError:n});})),i==="walletconnect"&&a.has("walletconnect")&&(console.log("reconnect on walletconnect subs"),(T=(w=z()).subscription)==null||T.call(w,()=>{B({onError:n});})),i==="station"&&((D=(P=ye()).subscription)==null||D.call(P,()=>{B({onError:n});})),i==="xdefi"&&((J=(_=Ce()).subscription)==null||J.call(_,()=>{B({onError:n});})),i==="cosmiframe"&&((C=(oe=ue()).subscription)==null||C.call(oe,()=>{B({onError:n});})),i==="okx"&&((I=(h=ge()).subscription)==null||I.call(h,()=>{B({onError:n});}));}},[i,a,l]),null},Kt=()=>(En(),null);var xn=new reactQuery.QueryClient({}),Ha=i=>{var r=i,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return react.useEffect(()=>{gt(t);},[t]),jsxRuntime.jsx(reactQuery.QueryClientProvider,F(x({client:xn},n),{children:jsxRuntime.jsxs(_t,{children:[e,jsxRuntime.jsx(Kt,{})]})}),"graz-provider")};
26
26
 
27
- exports.GrazEvents = Nt;
28
- exports.GrazProvider = $a;
27
+ exports.GrazEvents = Kt;
28
+ exports.GrazProvider = Ha;
29
29
  exports.WALLET_TYPES = $e;
30
30
  exports.WalletType = je;
31
- exports.checkWallet = N;
31
+ exports.checkWallet = L;
32
32
  exports.clearRecentChain = Pe;
33
33
  exports.clearSession = K;
34
- exports.configureGraz = yt;
34
+ exports.configureGraz = gt;
35
35
  exports.connect = X;
36
- exports.defineChainInfo = kr;
37
- exports.defineChains = xr;
38
- exports.disconnect = oe;
39
- exports.executeContract = ht;
40
- exports.getAvailableWallets = ir;
41
- exports.getChainInfo = Sr;
42
- exports.getChainInfos = Cr;
36
+ exports.defineChainInfo = vr;
37
+ exports.defineChains = kr;
38
+ exports.disconnect = ie;
39
+ exports.executeContract = wt;
40
+ exports.getAvailableWallets = nr;
41
+ exports.getChainInfo = Cr;
42
+ exports.getChainInfos = wr;
43
43
  exports.getCosmostation = pe;
44
44
  exports.getKeplr = me;
45
45
  exports.getLeap = de;
46
46
  exports.getMetamaskSnapLeap = st;
47
- exports.getOfflineSigners = ft;
48
- exports.getQueryRaw = It;
49
- exports.getQuerySmart = At;
50
- exports.getRecentChainIds = gr;
51
- exports.getRecentChains = yr;
47
+ exports.getOfflineSigners = dt;
48
+ exports.getQueryRaw = At;
49
+ exports.getQuerySmart = ht;
50
+ exports.getRecentChainIds = yr;
51
+ exports.getRecentChains = Sr;
52
52
  exports.getVectis = Se;
53
53
  exports.getWCCosmostation = ut;
54
54
  exports.getWCKeplr = pt;
55
55
  exports.getWCLeap = mt;
56
- exports.getWallet = P;
56
+ exports.getWallet = R;
57
57
  exports.getWalletConnect = z;
58
- exports.instantiateContract = wt;
58
+ exports.instantiateContract = Ct;
59
59
  exports.isCapsule = We;
60
- exports.isWalletConnect = dt;
60
+ exports.isWalletConnect = or;
61
61
  exports.reconnect = B;
62
- exports.sendIbcTokens = Ct;
63
- exports.sendTokens = St;
62
+ exports.sendIbcTokens = St;
63
+ exports.sendTokens = yt;
64
64
  exports.suggestChain = Re;
65
- exports.suggestChainAndConnect = gt;
65
+ exports.suggestChainAndConnect = ft;
66
66
  exports.useAccount = Y;
67
- exports.useActiveChainCurrency = Ks;
68
- exports.useActiveChainIds = Rs;
69
- exports.useActiveChains = wn;
70
- exports.useActiveWalletType = ns;
71
- exports.useBalance = gs;
72
- exports.useBalanceStaked = ws;
73
- exports.useBalances = Cn;
74
- exports.useCapsule = Ts;
75
- exports.useChainInfo = Ds;
76
- exports.useChainInfos = _s;
67
+ exports.useActiveChainCurrency = Ns;
68
+ exports.useActiveChainIds = Ds;
69
+ exports.useActiveChains = Cn;
70
+ exports.useActiveWalletType = os;
71
+ exports.useBalance = ys;
72
+ exports.useBalanceStaked = hs;
73
+ exports.useBalances = Sn;
74
+ exports.useCapsule = Ms;
75
+ exports.useChainInfo = _s;
76
+ exports.useChainInfos = Ks;
77
77
  exports.useCheckWallet = Ae;
78
- exports.useConnect = ys;
78
+ exports.useConnect = Ss;
79
79
  exports.useCosmWasmClient = Be;
80
- exports.useCosmWasmSigningClient = fa;
81
- exports.useCosmWasmTmSigningClient = ya;
82
- exports.useDisconnect = Ss;
83
- exports.useExecuteContract = Js;
84
- exports.useGrazEvents = bn;
85
- exports.useInstantiateContract = Ys;
86
- exports.useOfflineSigners = Cs;
87
- exports.useQueryClientValidators = Ns;
88
- exports.useQueryRaw = ea;
89
- exports.useQuerySmart = Zs;
90
- exports.useRecentChainIds = Ls;
91
- exports.useRecentChains = Bs;
92
- exports.useSendIbcTokens = Xs;
93
- exports.useSendTokens = Vs;
80
+ exports.useCosmWasmSigningClient = ga;
81
+ exports.useCosmWasmTmSigningClient = Sa;
82
+ exports.useDisconnect = Cs;
83
+ exports.useExecuteContract = Zs;
84
+ exports.useGrazEvents = En;
85
+ exports.useInstantiateContract = Js;
86
+ exports.useOfflineSigners = ws;
87
+ exports.useQueryClientValidators = Ls;
88
+ exports.useQueryRaw = ta;
89
+ exports.useQuerySmart = ea;
90
+ exports.useRecentChainIds = Bs;
91
+ exports.useRecentChains = Us;
92
+ exports.useSendIbcTokens = Ys;
93
+ exports.useSendTokens = Xs;
94
94
  exports.useStargateClient = Le;
95
- exports.useStargateSigningClient = da;
96
- exports.useStargateTmSigningClient = ga;
97
- exports.useSuggestChain = Us;
98
- exports.useSuggestChainAndConnect = Fs;
95
+ exports.useStargateSigningClient = fa;
96
+ exports.useStargateTmSigningClient = ya;
97
+ exports.useSuggestChain = Fs;
98
+ exports.useSuggestChainAndConnect = qs;
99
99
  exports.useTendermintClient = he;
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import { encodeEd25519Pubkey, encodeSecp256k1Pubkey, pubkeyType, rawEd25519Pubke
4
4
  import { fromBech32, toBech32 } from '@cosmjs/encoding';
5
5
  import { Cosmiframe, isInIframe } from '@dao-dao/cosmiframe';
6
6
  import { isSnapInstalled, installSnap, CosmosSnap } from '@cosmsnap/snapper';
7
- import rn from 'long';
7
+ import on from 'long';
8
8
  import { SignClient } from '@walletconnect/sign-client';
9
9
  import { getSdkError } from '@walletconnect/utils';
10
10
  import { WalletConnectModal } from '@walletconnect/modal';
@@ -16,6 +16,6 @@ import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
16
16
  import { shallow } from 'zustand/shallow';
17
17
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
18
18
 
19
- var Ut=Object.defineProperty,Ft=Object.defineProperties;var qt=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ce)for(var n of ce(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},q=(e,t)=>Ft(e,qt(t));var je=(e,t)=>{var n={};for(var o in e)ze.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&ce)for(var o of ce(e))t.indexOf(o)<0&&Qe.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(d){r(d);}},s=l=>{try{a(n.throw(l));}catch(d){r(d);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var X="graz-reconnect-session";var $e=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))($e||{}),He=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var zt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ie={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},jt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},f=create(subscribeWithSelector(persist(()=>ie,Qt))),u=create(subscribeWithSelector(persist(()=>zt,jt)));var le=()=>{var S,y;if(!((S=u.getState().capsuleConfig)!=null&&S.apiKey)||!((y=u.getState().capsuleConfig)!=null&&y.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var w,x;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,C=new m({apiKey:(w=u.getState().capsuleConfig)==null?void 0:w.apiKey,env:(x=u.getState().capsuleConfig)==null?void 0:x.env});return f.setState({capsuleClient:C}),C});return {init:e,enable:m=>c(void 0,null,function*(){let C=typeof m=="string"?[m]:m,w=f.getState().capsuleClient;w||(w=yield e()),u.setState({capsuleState:{showModal:!0,chainId:C}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var p;let m=f.getState().capsuleClient,{chains:C}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!C)throw new Error("Chains are not set");yield m.enable();let w=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!w)throw new Error("Chain ids are not set");let x=Object.fromEntries(yield Promise.all(w.map(A=>c(void 0,null,function*(){let b=yield m.getAccount(A);return [A,{address:fromBech32(b.address).data,bech32Address:b.address,algo:b.algo,name:b.username||"",pubKey:b.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));f.setState(A=>({accounts:k(k({},A.accounts||{}),x)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...w].filter((b,P,D)=>D.indexOf(b)===P)})),f.setState(A=>({activeChainIds:[...A.activeChainIds||[],...w].filter((b,P,D)=>D.indexOf(b)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(X,"Active"),u.setState({capsuleState:null});}),getKey:m=>c(void 0,null,function*(){let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");let w=yield C.getAccount(m);return {address:fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>c(void 0,null,function*(){let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerDirect(m)},signDirect:(...m)=>c(void 0,null,function*(){let[C,w,x]=m,p=f.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(C,w,{bodyBytes:x.bodyBytes,authInfoBytes:x.authInfoBytes,chainId:x.chainId,accountNumber:x.accountNumber})}),signAmino:(...m)=>c(void 0,null,function*(){let[C,w,x,p]=m,A=f.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(C,w,x,p)}),signArbitrary:(m,C,w)=>c(void 0,null,function*(){let x=f.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");let p=yield x.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${C}`);let A=(()=>{switch(p.algo){case"secp256k1":return encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield x.signArbitrary(m,C,w),pub_key:{type:p.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...m)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let C=f.getState().capsuleClient;if(!C)throw new Error("Capsule client is not initialized");return C.getOfflineSignerAmino(m)}}};var ue=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var pe=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var nt={},it=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var O;let i=yield e.request({method:"web3_clientVersion"});if(!i.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(O=i.split("MetaMask/v")[1])==null?void 0:O.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:i=>c(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof nt[i]!="undefined"?nt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var me=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:i=>{let s=()=>{N(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var nn=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},on=e=>`${e.slice(0,6)}...${e.slice(-6)}`,rt=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:g=>c(void 0,null,function*(){let S=e.getOfflineSigner(g),[y]=yield S.getAccounts();if(!y)throw new Error("Wallet connection failed");let m=(()=>{switch(y.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(y.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:on(y.address),algo:y.algo,pubKey:y.pubkey,bech32Address:y.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:g=>{let S=e.getOfflineSigner(g),y=e.getOfflineSignerOnlyAmino(g);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:y.signAmino.bind(y)}},getOfflineSignerAuto:g=>Promise.resolve(e.getOfflineSigner(g)),getOfflineSignerOnlyAmino:g=>e.getOfflineSignerOnlyAmino(g),experimentalSuggestChain:g=>e.requestAddInitiaLayer({chain_id:g.chainId,chain_name:g.chainName,bech32_prefix:"init",bech32_config:g.bech32Config,slip44:g.bip44.coinType,logo_URIs:{png:g.chainSymbolImageUrl},fees:{fee_tokens:g.feeCurrencies.map(S=>{var y,m,C;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(y=S.gasPriceStep)==null?void 0:y.low,average_gas_price:(m=S.gasPriceStep)==null?void 0:m.average,high_gas_price:(C=S.gasPriceStep)==null?void 0:C.high}})},apis:{rpc:[{address:g.rpc}],rest:[{address:g.rest}]}}),signDirect:(...g)=>{let[S,y,m]=g;return e.getOfflineSigner(S).signDirect(y,nn(m))},signAmino:(...g)=>{let[S,y,m]=g;return e.getOfflineSignerOnlyAmino(S).signAmino(y,m)},signArbitrary:(g,S,y)=>c(void 0,null,function*(){let w=(yield e.getOfflineSigner(g).getAccounts()).find(A=>A.address===S);if(!w)throw new Error(`Wallet not connected to account ${S}`);let x=(()=>{switch(w.algo){case"secp256k1":return encodeSecp256k1Pubkey(w.pubkey);case"ed25519":return encodeEd25519Pubkey(w.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(y),pub_key:{type:w.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:x.value}}}),subscription:g=>{let S=()=>{N(),g();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var fe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ge={},st=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=p=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(b=>b.id===e.id&&(!p||b.version===p))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var K;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(K=p.split("MetaMask/v")[1])==null?void 0:K.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=p=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(p,A,b)=>c(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:A,signDoc:b}}}}),D=b.accountNumber,K=new rn(D.low,D.high,D.unsigned);return {signature:P.signature,signed:q(k({},P.signed),{accountNumber:`${K.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),l=(p,A,b)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:A,signDoc:b}}}})}),d=p=>c(void 0,null,function*(){if(typeof ge[p]!="undefined")return ge[p];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,ge[p]=A,ge[p]}),O=p=>c(void 0,null,function*(){let A=yield d(p);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),g=(...p)=>c(void 0,null,function*(){let[A,b,P,D]=p;return yield l(A,b,P)}),S=(...p)=>c(void 0,null,function*(){let[A,b,P]=p;return yield a(A,b,P)}),m=p=>({getAccounts:()=>c(void 0,null,function*(){return [yield O(p)]}),signAmino:(A,b)=>g(p,A,b)});return {enable:s,experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:d,getOfflineSigner:p=>({getAccounts:()=>c(void 0,null,function*(){return [yield O(p)]}),signDirect:(A,b)=>S(p,A,b),signAmino:(A,b)=>g(p,A,b)}),getOfflineSignerAuto:p=>c(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:i,signAmino:g,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var at=()=>st({id:"npm:@leapwallet/metamask-cosmos-snap"});var ye=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:i=>{var a;let s=()=>{N(),i();};return (a=window.okxwallet)==null||a.on("accountsChanged",s),()=>{var l;(l=window.okxwallet)==null||l.removeListener("accountsChanged",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var Se=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{N(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return k({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(d,O)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,d,O;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((d=a.gasPriceStep)==null?void 0:d.high)||0,low:((O=a.gasPriceStep)==null?void 0:O.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{N(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,d=q(k({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([d])}),signDirect:(...a)=>c(void 0,null,function*(){var O;let{1:l,2:d}=a;return e.signDirect(l,{bodyBytes:d.bodyBytes||Uint8Array.from([]),authInfoBytes:d.authInfoBytes||Uint8Array.from([]),accountNumber:rn.fromString(((O=d.accountNumber)==null?void 0:O.toString())||"",!1),chainId:d.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:d}=a;return e.signAmino(l,d)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},ct=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),lt=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var We=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var Q=e=>{var K,Z,oe;if(!((oe=(Z=(K=u.getState().walletConnect)==null?void 0:K.options)==null?void 0:Z.projectId)!=null&&oe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",o=h=>{if(!e)return;let{appUrl:I,formatNativeUrl:E}=e;if(z()){if(ct())if(!h)window.open(I.mobile.android,"_self","noreferrer noopener");else {let v=E(I.mobile.android,h,"android");window.open(v,"_self","noreferrer noopener");}if(lt())if(!h)window.open(I.mobile.ios,"_self","noreferrer noopener");else {let v=E(I.mobile.ios,h,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:h}=f.getState();if(!h.get(t))throw new Error("walletConnect.signClient is not defined");h.delete(t),f.setState({wcSignClients:h}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=h=>c(void 0,null,function*(){let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!h)throw new Error("No wallet connect session");yield E.disconnect({topic:h,reason:getSdkError("USER_DISCONNECTED")}),yield l(E);}),s=h=>{try{let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let v=E.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw i(v.topic),new Error("invalid session");return v}catch(I){if(!I.message.toLowerCase().includes("no matching key"))throw I}},a=h=>{try{return s(h)}catch(I){return}},l=h=>c(void 0,null,function*(){try{let I=h.core.pairing.pairings.getAll({active:!1});if(!I.length)return;yield Promise.all(I.map(E=>c(void 0,null,function*(){yield h.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(I){if(!I.message.toLowerCase().includes("no matching key"))throw I}}),d=()=>c(void 0,null,function*(){let{walletConnect:h}=u.getState();if(!(h!=null&&h.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:I}=f.getState(),E=I.get(t);if(E)return E;let v=yield SignClient.init(h.options);return I.set(t,v),f.setState({wcSignClients:I}),v}),O=h=>{let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)return ()=>{};let v=W=>{let _=f.getState().accounts;if(W.params.event.name==="accountsChanged"&&_&&!Object.values(_).map(B=>B.bech32Address).includes(W.params.event.data[0])){console.log("accountsChanged",W);let B=W.params.chainId.split(":")[1];B&&g([B]);}else console.log("session_event",W),h();};return E.events.on("session_delete",r),E.events.on("session_expire",r),E.events.on("session_event",v),()=>{E.events.off("session_delete",r),E.events.off("session_expire",r),E.events.off("session_event",v);}},g=h=>c(void 0,null,function*(){var te;let I=typeof h=="string"?[h]:h,{wcSignClients:E}=f.getState(),v=E.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:_}=u.getState();if(!((te=W==null?void 0:W.options)!=null&&te.projectId))throw new Error("walletConnect.options.projectId is not defined");let B=new WalletConnectModal(k({projectId:W.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.walletConnectModal)),ee=a(I);if(!ee){let{uri:j,approval:$}=yield We(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:I.map(H=>`cosmos:${H}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!j)throw new Error("No wallet connect uri");e?o(j):yield B.openModal({uri:j});let se=H=>c(void 0,null,function*(){return H.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((xe,ne)=>{$().then(qe=>{let ke=qe.sessionProperties;if(console.log("sessionProperties",ke),!ke)return ne(new Error("No session properties"));let ae=JSON.parse(String(ke.keys));if(console.log("_acc",ae),ae.length===0)return ne(new Error("No accounts"));if(!ae[0])return ne(new Error("No accounts"));let ve={};return ae.forEach(V=>{ve[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),console.log("resAcc",ve),f.setState(V=>({accounts:k(k({},V.accounts||{}),ve)})),xe(qe)}).catch(ne),H.addEventListener("abort",()=>{ne(new Error("User closed wallet connect"));},{once:!0});})});try{let H=new AbortController,xe=H.signal;B.subscribeModal(ne=>{ne.open||H.abort();}),yield se(xe);}catch(H){if(B.closeModal(),!H.message.toLowerCase().includes("no matching key"))return Promise.reject(H)}return e||B.closeModal(),Promise.resolve()}try{yield We((()=>c(void 0,null,function*(){let j=Object.fromEntries(yield Promise.all(I.map($=>c(void 0,null,function*(){return [$,yield y($)]}))));f.setState({accounts:j});}))(),15e3,new Error("Connection timeout"));}catch(j){if(i(ee.topic),!j.message.toLowerCase().includes("no matching key"))throw j}}),S=h=>c(void 0,null,function*(){var _;let{wcSignClients:I}=f.getState(),E=I.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let v=(_=s())==null?void 0:_.topic;if(!v)throw new Error("No wallet connect session");let W=yield E.request({topic:v,chainId:`cosmos:${h}`,request:{method:"cosmos_getAccounts",params:{}}});if(!W[0])throw new Error("No wallet connect account");return {address:W[0].address,algo:W[0].algo,pubkey:new Uint8Array(Buffer.from(W[0].pubkey,n))}}),y=h=>c(void 0,null,function*(){let I=s();if(!(I!=null&&I.topic))throw new Error("No wallet connect session");let E=I.sessionProperties&&JSON.parse(String(I.sessionProperties.keys))[0];if(!E)throw new Error("No wallet connect key");return E}),m=(...h)=>c(void 0,null,function*(){var $,se;let[I,E,v]=h,{accounts:W,wcSignClients:_}=f.getState(),B=_.get(t);if(!B)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let ee=($=s())==null?void 0:$.topic;if(!ee)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let te={topic:ee,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:q(k({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(se=v.accountNumber)==null?void 0:se.toString()})}}};return o(),yield B.request(te)}),C=(...h)=>c(void 0,null,function*(){let[I,E,v]=h,{signature:W,signed:_}=yield m(I,E,v);return {signed:{chainId:_.chainId,accountNumber:rn.fromString(_.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(_.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(_.bodyBytes,n))},signature:W}}),w=(...h)=>c(void 0,null,function*(){var $;let[I,E,v,W]=h,{wcSignClients:_}=f.getState(),B=_.get(t),{accounts:ee}=f.getState();if(!B)throw new Error("walletConnect.signClient is not defined");if(!ee)throw new Error("account is not defined");let te=($=s())==null?void 0:$.topic;if(!te)throw new Error("No wallet connect session");return o(),yield B.request({topic:te,chainId:`cosmos:${I}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:v}}})}),x=(...h)=>c(void 0,null,function*(){let[I,E,v,W]=h;return yield w(I,E,v)}),p=h=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(h)]}),signDirect:(I,E)=>C(h,I,E)}),A=h=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(h)]}),signAmino:(I,E)=>x(h,I,E)});return {enable:g,disable:h=>c(void 0,null,function*(){var v;let{wcSignClients:I}=f.getState(),E=I.get(t);if(h===void 0){let W=E==null?void 0:E.session.getAll();W!==void 0&&(yield Promise.all(W.map(_=>i(_.topic))));}else typeof h=="string"?yield i((v=s())==null?void 0:v.topic):yield Promise.all(h.map(W=>{var _;return i((_=s())==null?void 0:_.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...h)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:y,getOfflineSigner:h=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(h)]}),signDirect:(I,E)=>C(h,I,E),signAmino:(I,E)=>x(h,I,E)}),getOfflineSignerAuto:h=>c(void 0,null,function*(){return (yield y()).isNanoLedger?A(h):p(h)}),getOfflineSignerOnlyAmino:A,signAmino:x,signDirect:C,subscription:O,init:d}};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return Q(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var dt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var we=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var L=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(X),f.setState(ie);},R=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return de();case"leap":return fe();case"cosmostation":return me();case"vectis":return Ce();case"walletconnect":return Q();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return at();case"metamask_snap_cosmos":return it();case"station":return Se();case"xdefi":return we();case"capsule":return le();case"cosmiframe":return pe();case"compass":return ue();case"initia":return rt();case"okx":return ye();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},or=()=>Object.fromEntries(He.map(e=>[e,L(e)])),Pe=e=>e==="capsule",ft=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!L(i))throw new Error(`${i} is not available`);let a=R(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let d=o==null?void 0:o.map(y=>y.chainId);l.forEach(y=>{if(!(d!=null&&d.includes(y)))throw new Error(`Chain ${y} is not provided in GrazProvider`)}),f.setState(y=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return y.activeChainIds&&l.filter(w=>{var x;return !((x=y.activeChainIds)!=null&&x.includes(w))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:O}=f.getState();if(yield (t=a.init)==null?void 0:t.call(a),Pe(i)&&f.getState().capsuleClient&&Object.values(f.getState().accounts||[]).length>0){let y=l.map(w=>o.find(x=>x.chainId===w)),m=f.getState().accounts;f.setState({status:"connecting"});let C=Object.fromEntries(yield Promise.all(l.map(w=>c(void 0,null,function*(){return [w,yield a.getKey(w)]}))));return f.setState(w=>({accounts:k(k({},w.accounts||{}),C)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...l].filter((x,p,A)=>A.indexOf(x)===p)})),f.setState(w=>({activeChainIds:[...w.activeChainIds||[],...l].filter((x,p,A)=>A.indexOf(x)===p)})),f.setState({status:"connected"}),{accounts:m,walletType:i,chains:y}}if(yield a.enable(l),Pe(i)){let y=l.map(C=>o.find(w=>w.chainId===C)),m=f.getState().accounts;return f.setState({status:"connecting"}),{accounts:m,walletType:i,chains:y}}if(!ft(i)){let y=Object.fromEntries(yield Promise.all(l.map(m=>c(void 0,null,function*(){return [m,yield a.getKey(m)]}))));f.setState(m=>({accounts:k(k({},m.accounts||{}),y)}));}u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...l].filter((m,C,w)=>w.indexOf(m)===C)})),f.setState(y=>({activeChainIds:[...y.activeChainIds||[],...l].filter((m,C,w)=>w.indexOf(m)===C)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(X,"Active");let g=l.map(y=>o.find(m=>m.chainId===y)),S=f.getState().accounts;return console.log("Connected",S),{accounts:S,walletType:i,chains:g}}catch(n){throw console.error("connect ",n),f.getState().accounts===null&&f.setState({status:"disconnected"}),f.getState().accounts&&f.getState().activeChainIds&&f.setState({status:"connected"}),n}}),re=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(X);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=f.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(f.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(f.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else f.setState(ie),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},U=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=L(n||void 0);if(t&&i&&n)return yield Y({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),re();}}),gt=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!L(n))throw new Error(`${n} is not available`);let r=R(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var Re=()=>{u.setState({recentChainIds:null});},yr=()=>u.getState().recentChainIds,Sr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},Cr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},wr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},De=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=R(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),yt=e=>c(void 0,null,function*(){var o;let t=u.getState().walletType;return yield De({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var St=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Ct=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),wt=O=>c(void 0,[O],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:d}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,o,r,i,s,a,l,d)}),ht=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),At=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),It=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ot=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var kr=e=>e,vr=e=>e;var he=e=>e?Object.keys(e).length===0:!0;var _e=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Et=e=>globalThis.DOMException===void 0?new _e(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?Et("This operation was aborted."):e.reason;return t instanceof Error?t:Et(t)};function Ke(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let d=[],O=[],g=new Map,S=!1,y=!1,m=!1,C=0,w=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{S=!0,y=!0,l(b);};r&&(r.aborted&&p(bt(r)),r.addEventListener("abort",()=>{p(bt(r));}));let A=()=>c(this,null,function*(){if(y)return;let b=yield x.next(),P=w;if(w++,b.done){if(m=!0,C===0&&!y){if(!o&&O.length>0){p(new AggregateError(O));return}if(y=!0,g.size===0){a(d);return}let D=[];for(let[K,Z]of d.entries())g.get(K)!==Tt&&D.push(Z);a(D);}return}C++,c(this,null,function*(){try{let D=yield b.value;if(y)return;let K=yield t(D,P);K===Tt&&g.set(P,K),d[P]=K,C--,yield A();}catch(D){if(o)p(D);else {O.push(D),C--;try{yield A();}catch(K){p(K);}}}});});c(this,null,function*(){for(let b=0;b<n;b++){try{yield A();}catch(P){p(P);break}if(m||S)break}});})})}var Tt=Symbol("skip");var F=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},G=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Ke(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Mt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var Be=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var O;let a=(O=u.getState().chainsConfig)==null?void 0:O[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ue=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var O;let a=(O=u.getState().chainsConfig)==null?void 0:O[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ae=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=F({chainId:t,multiChain:n}),i=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,O=>c(void 0,null,function*(){var C;let g=(C=u.getState().chainsConfig)==null?void 0:C[O.chainId],S={url:O.rpc,headers:k({},(g==null?void 0:g.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(S)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var is=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),Ie=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>L(r))};var J=e=>{let t=u(a=>a.walletType),n=f(a=>a.activeChainIds),o=F({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=f(a=>a.accounts),i=f(a=>a.status);return useEffect(()=>f.subscribe(a=>a.status,(a,l)=>{var d,O,g;if(a==="connected"){let{accounts:S,activeChainIds:y}=f.getState(),{chains:m}=u.getState(),{walletType:C}=u.getState();if(!S||!y||!m)return (d=e==null?void 0:e.onDisconnect)==null?void 0:d.call(e);(O=e==null?void 0:e.onConnect)==null||O.call(e,{accounts:S,chains:y.map(w=>m.find(x=>x.chainId===w)),walletType:C,isReconnect:l==="reconnecting"});}a==="disconnected"&&((g=e==null?void 0:e.onDisconnect)==null||g.call(e));}),[e]),{data:useMemo(()=>r?Mt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:U,status:i}},wn=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Be({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery(i,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){let S=s==null?void 0:s[g.chainId];if(!S)throw new Error(`Client is not ready ${g.chainId}`);return yield S.getAllBalances(toBech32(g.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!he(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ys=e=>{let t=F({chainId:e.chainId}),{data:n}=J({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=wn({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=useQuery(s,({queryKey:[,l,d]})=>d==null?void 0:d.find(O=>O.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(k({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},Ss=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=Ie();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},Cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],re,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},ws=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!L(i))throw new Error(`${i} is not available`);return yield G(!!(e!=null&&e.multiChain),r,d=>c(void 0,null,function*(){return yield gt({chainId:d.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},hs=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),{data:o}=Be({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery(i,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){var y;if(!s)throw new Error("Client is not ready");return yield (y=s[g.chainId])==null?void 0:y.getBalanceStaked(toBech32(g.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Ms=()=>{let e=u(o=>o.capsuleState),t=f(o=>o.capsuleClient),n=le();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{re();}}};var Ds=()=>f(e=>e.activeChainIds),hn=()=>{var e;return (e=f(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},_s=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ks=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ns=({denom:e})=>{let t=hn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Ls=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Bs=()=>({data:u(t=>t.recentChainIds),clear:Re}),Us=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:Re}},Fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],De,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},qs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],yt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=Ie();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Xs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=J(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>Ct(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},Ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=J(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>wt(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Js=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=J(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var O;if(!i)throw new Error("senderAddress is undefined");let d=q(k({},l),{fee:(O=l.fee)!=null?O:"auto",senderAddress:i,codeId:e});return ht(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Zs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=J(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var O,g,S;if(!i)throw new Error("senderAddress is undefined");let d=q(k({},l),{fee:(O=l.fee)!=null?O:"auto",senderAddress:i,contractAddress:e,memo:(g=l.memo)!=null?g:"",funds:(S=l.funds)!=null?S:[]});return At(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ea=e=>{let{data:t}=Ue();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return It(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ta=e=>{let{data:t}=Ue(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ot(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function fa(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=f(i=>i.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,d=>c(this,null,function*(){var C,w;if(!(o!=null&&o.includes(d.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(d.chainId);default:return R(s).getOfflineSignerAuto(d.chainId)}}))(),S=(C=u.getState().chainsConfig)==null?void 0:C[d.chainId],y={url:d.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(y,g,e!=null&&e.multiChain?(w=e.opts)==null?void 0:w[d.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ga(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=f(i=>i.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,d=>c(this,null,function*(){var w,x;if(!(o!=null&&o.includes(d.chainId)))return null;if(!L(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(d.chainId);default:return R(s).getOfflineSignerAuto(d.chainId)}}))(),S=(w=u.getState().chainsConfig)==null?void 0:w[d.chainId],y={url:d.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})},m=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(y,g,k({gasPrice:m},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[d.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ya(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=f(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ae({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,O=>c(this,null,function*(){var C;if(!(o!=null&&o.includes(O.chainId)))return null;if(!L(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let S=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(O.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(O.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(O.chainId);default:return R(a).getOfflineSignerAuto(O.chainId)}}))(),y=e.multiChain?i[O.chainId]:i;return yield SigningStargateClient.createWithSigner(y,S,e.multiChain?(C=e.opts)==null?void 0:C[O.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Sa(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=f(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ae({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=Ae({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:d=>c(this,[d],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,g=>c(this,null,function*(){var p,A;if(!(o!=null&&o.includes(g.chainId)))return null;if(!L(l))throw new Error(`${l} is not available`);let y=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(l).getOfflineSigner(g.chainId);case"offlineSignerAuto":return R(l).getOfflineSignerAuto(g.chainId);case"offlineSignerOnlyAmino":return R(l).getOfflineSignerOnlyAmino(g.chainId);default:return R(l).getOfflineSignerAuto(g.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[g.chainId],C=m!=null&&m.gas?GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,w=e.multiChain?s==null?void 0:s[g.chainId]:i;if(!w)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(w,y,k({gasPrice:C},e.multiChain?(A=e.opts)==null?void 0:A[g.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!he(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Nt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var Tn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(X)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=f(),l=L(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(O=>{if(O)return Y({chainId:i.map(g=>g.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!l)return;e&&s?U({onError:n}):!e&&t&&U({onError:n});}},[l]),useEffect(()=>{var d,O,g,S,y,m,C,w,x,p,A,b,P,D,K,Z,oe,h,I,E;if(o){if(!l)return;o==="cosmostation"&&((O=(d=me()).subscription)==null||O.call(d,()=>{U({onError:n});})),o==="keplr"&&((S=(g=de()).subscription)==null||S.call(g,()=>{U({onError:n});})),o==="leap"&&((m=(y=fe()).subscription)==null||m.call(y,()=>{U({onError:n});})),o==="compass"&&((w=(C=ue()).subscription)==null||w.call(C,()=>{U({onError:n});})),o==="vectis"&&((p=(x=Ce()).subscription)==null||p.call(x,()=>{U({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((b=(A=Q()).subscription)==null||b.call(A,()=>{U({onError:n});})),o==="station"&&((D=(P=Se()).subscription)==null||D.call(P,()=>{U({onError:n});})),o==="xdefi"&&((Z=(K=we()).subscription)==null||Z.call(K,()=>{U({onError:n});})),o==="cosmiframe"&&((h=(oe=pe()).subscription)==null||h.call(oe,()=>{U({onError:n});})),o==="okx"&&((E=(I=ye()).subscription)==null||E.call(I,()=>{U({onError:n});}));}},[o,a,l]),null},Lt=()=>(Tn(),null);var vn=new QueryClient({}),Ha=o=>{var r=o,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return useEffect(()=>{St(t);},[t]),jsx(QueryClientProvider,q(k({client:vn},n),{children:jsxs(Nt,{children:[e,jsx(Lt,{})]})}),"graz-provider")};
19
+ var Bt=Object.defineProperty,Ut=Object.defineProperties;var Ft=Object.getOwnPropertyDescriptors;var ce=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ce)for(var n of ce(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},q=(e,t)=>Ut(e,Ft(t));var je=(e,t)=>{var n={};for(var i in e)ze.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&ce)for(var i of ce(e))t.indexOf(i)<0&&Qe.call(e,i)&&(n[i]=e[i]);return n};var c=(e,t,n)=>new Promise((i,r)=>{var o=l=>{try{a(n.next(l));}catch(d){r(d);}},s=l=>{try{a(n.throw(l));}catch(d){r(d);}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(e,t)).next());});var X="graz-reconnect-session";var $e=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))($e||{}),He=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Gt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},oe={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},zt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},f=create(subscribeWithSelector(persist(()=>oe,zt))),u=create(subscribeWithSelector(persist(()=>Gt,Qt)));var le=()=>{var S,E;if(!((S=u.getState().capsuleConfig)!=null&&S.apiKey)||!((E=u.getState().capsuleConfig)!=null&&E.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var O,b;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,y=new m({apiKey:(O=u.getState().capsuleConfig)==null?void 0:O.apiKey,env:(b=u.getState().capsuleConfig)==null?void 0:b.env});return f.setState({capsuleClient:y}),y});return {init:e,enable:m=>c(void 0,null,function*(){let y=typeof m=="string"?[m]:m,O=f.getState().capsuleClient;O||(O=yield e()),u.setState({capsuleState:{showModal:!0,chainId:y}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var p;let m=f.getState().capsuleClient,{chains:y}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!y)throw new Error("Chains are not set");yield m.enable();let O=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!O)throw new Error("Chain ids are not set");let b=Object.fromEntries(yield Promise.all(O.map(w=>c(void 0,null,function*(){let T=yield m.getAccount(w);return [w,{address:fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));f.setState(w=>({accounts:k(k({},w.accounts||{}),b)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...O].filter((T,R,_)=>_.indexOf(T)===R)})),f.setState(w=>({activeChainIds:[...w.activeChainIds||[],...O].filter((T,R,_)=>_.indexOf(T)===R)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(X,"Active"),u.setState({capsuleState:null});}),getKey:m=>c(void 0,null,function*(){let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");let O=yield y.getAccount(m);return {address:fromBech32(O.address).data,bech32Address:O.address,algo:O.algo,name:O.username||"",pubKey:O.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>c(void 0,null,function*(){let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(m)},signDirect:(...m)=>c(void 0,null,function*(){let[y,O,b]=m,p=f.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(y,O,{bodyBytes:b.bodyBytes,authInfoBytes:b.authInfoBytes,chainId:b.chainId,accountNumber:b.accountNumber})}),signAmino:(...m)=>c(void 0,null,function*(){let[y,O,b,p]=m,w=f.getState().capsuleClient;if(!w)throw new Error("Capsule client is not initialized");return w.signAmino(y,O,b,p)}),signArbitrary:(m,y,O)=>c(void 0,null,function*(){let b=f.getState().capsuleClient;if(!b)throw new Error("Capsule client is not initialized");let p=yield b.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${y}`);let w=(()=>{switch(p.algo){case"secp256k1":return encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield b.signArbitrary(m,y,O),pub_key:{type:p.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:w.value}}}),experimentalSuggestChain:(...m)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let y=f.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerAmino(m)}}};var ue=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let o=()=>{N(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var pe=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var nt={},ot=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var A;let o=yield e.request({method:"web3_clientVersion"});if(!o.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(A=o.split("MetaMask/v")[1])==null?void 0:A.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:o=>c(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:o=>t.getOfflineSigner(o),experimentalSuggestChain:o=>c(void 0,null,function*(){yield t.experimentalSuggestChain(o);}),signAmino:(o,s,a)=>c(void 0,null,function*(){return t.signAmino(o,s,a)}),getKey:o=>c(void 0,null,function*(){return typeof nt[o]!="undefined"?nt[o]:t.getKey(o)}),getOfflineSignerAuto:o=>c(void 0,null,function*(){return (yield t.getKey(o)).isNanoLedger?t.getOfflineSignerOnlyAmino(o):t.getOfflineSigner(o)}),getOfflineSignerOnlyAmino:o=>t.getOfflineSignerOnlyAmino(o),signDirect:(o,s,a)=>c(void 0,null,function*(){return t.signDirect(o,s,a)}),signArbitrary:(o,s,a)=>c(void 0,null,function*(){return t.signArbitrary(o,s,a)}),disable:o=>c(void 0,null,function*(){o&&(yield t.deleteChain(o));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var me=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{let s=()=>{N(),o();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var tn=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:i,accountNumber:r}=e;if(!t||!n||!i||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:i,accountNumber:r}},nn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,rt=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:g=>c(void 0,null,function*(){let S=e.getOfflineSigner(g),[E]=yield S.getAccounts();if(!E)throw new Error("Wallet connection failed");let m=(()=>{switch(E.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(E.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(E.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:nn(E.address),algo:E.algo,pubKey:E.pubkey,bech32Address:E.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:g=>{let S=e.getOfflineSigner(g),E=e.getOfflineSignerOnlyAmino(g);return {getAccounts:S.getAccounts.bind(S),signDirect:S.signDirect.bind(S),signAmino:E.signAmino.bind(E)}},getOfflineSignerAuto:g=>Promise.resolve(e.getOfflineSigner(g)),getOfflineSignerOnlyAmino:g=>e.getOfflineSignerOnlyAmino(g),experimentalSuggestChain:g=>e.requestAddInitiaLayer({chain_id:g.chainId,chain_name:g.chainName,bech32_prefix:"init",bech32_config:g.bech32Config,slip44:g.bip44.coinType,logo_URIs:{png:g.chainSymbolImageUrl},fees:{fee_tokens:g.feeCurrencies.map(S=>{var E,m,y;return {denom:S.coinDenom,amount:S.coinMinimalDenom,low_gas_price:(E=S.gasPriceStep)==null?void 0:E.low,average_gas_price:(m=S.gasPriceStep)==null?void 0:m.average,high_gas_price:(y=S.gasPriceStep)==null?void 0:y.high}})},apis:{rpc:[{address:g.rpc}],rest:[{address:g.rest}]}}),signDirect:(...g)=>{let[S,E,m]=g;return e.getOfflineSigner(S).signDirect(E,tn(m))},signAmino:(...g)=>{let[S,E,m]=g;return e.getOfflineSignerOnlyAmino(S).signAmino(E,m)},signArbitrary:(g,S,E)=>c(void 0,null,function*(){let O=(yield e.getOfflineSigner(g).getAccounts()).find(w=>w.address===S);if(!O)throw new Error(`Wallet not connected to account ${S}`);let b=(()=>{switch(O.algo){case"secp256k1":return encodeSecp256k1Pubkey(O.pubkey);case"ed25519":return encodeEd25519Pubkey(O.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(E),pub_key:{type:O.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:b.value}}}),subscription:g=>{let S=()=>{N(),g();};return window.addEventListener("initia_keystorechange",S),()=>{window.removeEventListener("initia_keystorechange",S);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var de=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var fe=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{N(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ge={},st=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=p=>c(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(T=>T.id===e.id&&(!p||T.version===p))}catch(w){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>c(void 0,null,function*(){var K;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let T=(K=p.split("MetaMask/v")[1])==null?void 0:K.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=p=>c(void 0,null,function*(){(yield i())||(yield r());}),a=(p,w,T)=>c(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:w,signDoc:T}}}}),_=T.accountNumber,K=new on(_.low,_.high,_.unsigned);return {signature:R.signature,signed:q(k({},R.signed),{accountNumber:`${K.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),l=(p,w,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:w,signDoc:T}}}})}),d=p=>c(void 0,null,function*(){if(typeof ge[p]!="undefined")return ge[p];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,ge[p]=w,ge[p]}),A=p=>c(void 0,null,function*(){let w=yield d(p);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),g=(...p)=>c(void 0,null,function*(){let[w,T,R,_]=p;return yield l(w,T,R)}),S=(...p)=>c(void 0,null,function*(){let[w,T,R]=p;return yield a(w,T,R)}),m=p=>({getAccounts:()=>c(void 0,null,function*(){return [yield A(p)]}),signAmino:(w,T)=>g(p,w,T)});return {enable:s,experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:d,getOfflineSigner:p=>({getAccounts:()=>c(void 0,null,function*(){return [yield A(p)]}),signDirect:(w,T)=>S(p,w,T),signAmino:(w,T)=>g(p,w,T)}),getOfflineSignerAuto:p=>c(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:o,signAmino:g,signDirect:S}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var at=()=>st({id:"npm:@leapwallet/metamask-cosmos-snap"});var ye=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:o=>{var a;let s=()=>{N(),o();};return (a=window.okxwallet)==null||a.on("accountsChanged",s),()=>{var l;(l=window.okxwallet)==null||l.removeListener("accountsChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var Se=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{N(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>c(void 0,null,function*(){let s=yield e.getKey(o);return k({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(d,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>c(void 0,null,function*(){try{let s=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var l,d,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((d=a.gasPriceStep)==null?void 0:d.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,s,a,l)=>e.signAmino(o,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var Ce=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{N(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,d=q(k({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([d])}),signDirect:(...a)=>c(void 0,null,function*(){var A;let{1:l,2:d}=a;return e.signDirect(l,{bodyBytes:d.bodyBytes||Uint8Array.from([]),authInfoBytes:d.authInfoBytes||Uint8Array.from([]),accountNumber:on.fromString(((A=d.accountNumber)==null?void 0:A.toString())||"",!1),chainId:d.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:d}=a;return e.signAmino(l,d)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},ct=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),lt=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var We=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var Q=e=>{var K,Z,ie;if(!((ie=(Z=(K=u.getState().walletConnect)==null?void 0:K.options)==null?void 0:Z.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=C=>{if(!e)return;let{appUrl:h,formatNativeUrl:I}=e;if(z()){if(ct())if(!C)window.open(h.mobile.android,"_self","noreferrer noopener");else {let v=I(h.mobile.android,C,"android");window.open(v,"_self","noreferrer noopener");}if(lt())if(!C)window.open(h.mobile.ios,"_self","noreferrer noopener");else {let v=I(h.mobile.ios,C,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:C}=f.getState();if(!C.get(t))throw new Error("walletConnect.signClient is not defined");C.delete(t),f.setState({wcSignClients:C}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=C=>c(void 0,null,function*(){let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!C)throw new Error("No wallet connect session");yield I.disconnect({topic:C,reason:getSdkError("USER_DISCONNECTED")}),yield l(I);}),s=C=>{try{let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");console.log(I.session.getAll());let v=I.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw o(v.topic),new Error("invalid session");try{let P=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:C.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!P.length)throw new Error("no session");return P.at(-1)}catch(P){if(!P.message.toLowerCase().includes("no matching key"))throw P}return v}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}},a=C=>{try{return s(C)}catch(h){return}},l=C=>c(void 0,null,function*(){try{let h=C.core.pairing.pairings.getAll({active:!1});if(!h.length)return;yield Promise.all(h.map(I=>c(void 0,null,function*(){yield C.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(h){if(!h.message.toLowerCase().includes("no matching key"))throw h}}),d=()=>c(void 0,null,function*(){let{walletConnect:C}=u.getState();if(!(C!=null&&C.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:h}=f.getState(),I=h.get(t);if(I)return I;let v=yield SignClient.init(C.options);return h.set(t,v),f.setState({wcSignClients:h}),v}),A=C=>{let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)return ()=>{};let v=W=>{let P=f.getState().accounts;if(W.params.event.name==="accountsChanged"&&P&&!Object.values(P).map(L=>L.bech32Address).includes(W.params.event.data[0])){console.log("accountsChanged",W);let L=W.params.chainId.split(":")[1];L&&g([L]);}else console.log("session_event",W),C();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",v),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",v);}},g=C=>c(void 0,null,function*(){var te;let h=typeof C=="string"?[C]:C,{wcSignClients:I}=f.getState(),v=I.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:P}=u.getState();if(!((te=W==null?void 0:W.options)!=null&&te.projectId))throw new Error("walletConnect.options.projectId is not defined");let L=new WalletConnectModal(k({projectId:W.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.walletConnectModal)),ee=a(h);if(!ee){let{uri:j,approval:$}=yield We(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:h.map(H=>`cosmos:${H}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!j)throw new Error("No wallet connect uri");e?i(j):yield L.openModal({uri:j});let se=H=>c(void 0,null,function*(){return H.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((xe,ne)=>{$().then(qe=>{let ke=qe.sessionProperties;if(console.log("sessionProperties",ke),!ke)return ne(new Error("No session properties"));let ae=JSON.parse(String(ke.keys));if(console.log("_acc",ae),ae.length===0)return ne(new Error("No accounts"));if(!ae[0])return ne(new Error("No accounts"));let ve={};return ae.forEach(V=>{ve[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),console.log("resAcc",ve),f.setState(V=>({accounts:k(k({},V.accounts||{}),ve)})),xe(qe)}).catch(ne),H.addEventListener("abort",()=>{ne(new Error("User closed wallet connect"));},{once:!0});})});try{let H=new AbortController,xe=H.signal;L.subscribeModal(ne=>{ne.open||H.abort();}),yield se(xe);}catch(H){if(L.closeModal(),!H.message.toLowerCase().includes("no matching key"))return Promise.reject(H)}return e||L.closeModal(),Promise.resolve()}try{yield We((()=>c(void 0,null,function*(){let j=Object.fromEntries(yield Promise.all(h.map($=>c(void 0,null,function*(){return [$,yield E($)]}))));f.setState({accounts:j});}))(),15e3,new Error("Connection timeout"));}catch(j){if(o(ee.topic),!j.message.toLowerCase().includes("no matching key"))throw j}}),S=C=>c(void 0,null,function*(){var P;let{wcSignClients:h}=f.getState(),I=h.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=(P=s([C]))==null?void 0:P.topic;if(!v)throw new Error("No wallet connect session");let W=yield I.request({topic:v,chainId:`cosmos:${C}`,request:{method:"cosmos_getAccounts",params:{}}});if(!W[0])throw new Error("No wallet connect account");return {address:W[0].address,algo:W[0].algo,pubkey:new Uint8Array(Buffer.from(W[0].pubkey,n))}}),E=C=>c(void 0,null,function*(){let h=s([C]);if(!(h!=null&&h.topic))throw new Error("No wallet connect session");let I=h.sessionProperties&&JSON.parse(String(h.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),m=(...C)=>c(void 0,null,function*(){var $,se;let[h,I,v]=C,{accounts:W,wcSignClients:P}=f.getState(),L=P.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let ee=($=s([h]))==null?void 0:$.topic;if(!ee)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let te={topic:ee,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:q(k({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(se=v.accountNumber)==null?void 0:se.toString()})}}};return i(),yield L.request(te)}),y=(...C)=>c(void 0,null,function*(){let[h,I,v]=C,{signature:W,signed:P}=yield m(h,I,v);return {signed:{chainId:P.chainId,accountNumber:on.fromString(P.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(P.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(P.bodyBytes,n))},signature:W}}),O=(...C)=>c(void 0,null,function*(){var $;let[h,I,v,W]=C,{wcSignClients:P}=f.getState(),L=P.get(t),{accounts:ee}=f.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!ee)throw new Error("account is not defined");let te=($=s([h]))==null?void 0:$.topic;if(!te)throw new Error("No wallet connect session");return i(),yield L.request({topic:te,chainId:`cosmos:${h}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:v}}})}),b=(...C)=>c(void 0,null,function*(){let[h,I,v,W]=C;return yield O(h,I,v)}),p=C=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(C)]}),signDirect:(h,I)=>y(C,h,I)}),w=C=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(C)]}),signAmino:(h,I)=>b(C,h,I)});return {enable:g,disable:C=>c(void 0,null,function*(){var v;let{wcSignClients:h}=f.getState(),I=h.get(t);if(C===void 0){let W=I==null?void 0:I.session.getAll();W!==void 0&&(yield Promise.all(W.map(P=>o(P.topic))));}else typeof C=="string"?yield o((v=s([C]))==null?void 0:v.topic):yield Promise.all(C.map(W=>{var P;return o((P=s([W]))==null?void 0:P.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...C)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:E,getOfflineSigner:C=>({getAccounts:()=>c(void 0,null,function*(){return [yield S(C)]}),signDirect:(h,I)=>y(C,h,I),signAmino:(h,I)=>b(C,h,I)}),getOfflineSignerAuto:C=>c(void 0,null,function*(){return (yield E(C)).isNanoLedger?w(C):p(C)}),getOfflineSignerOnlyAmino:w,signAmino:b,signDirect:y,subscription:A,init:d}};var ut=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var pt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return Q(e)};var mt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var dt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var we=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(X),f.setState(oe);},D=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return de();case"leap":return fe();case"cosmostation":return me();case"vectis":return Ce();case"walletconnect":return Q();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return at();case"metamask_snap_cosmos":return ot();case"station":return Se();case"xdefi":return we();case"capsule":return le();case"cosmiframe":return pe();case"compass":return ue();case"initia":return rt();case"okx":return ye();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},or=()=>Object.fromEntries(He.map(e=>[e,B(e)])),Pe=e=>e==="capsule",ir=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!B(o))throw new Error(`${o} is not available`);let a=D(o),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let d=i==null?void 0:i.map(m=>m.chainId);l.forEach(m=>{if(!(d!=null&&d.includes(m)))throw new Error(`Chain ${m} is not provided in GrazProvider`)}),f.setState(m=>{let y=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return m.activeChainIds&&l.filter(b=>{var p;return !((p=m.activeChainIds)!=null&&p.includes(b))}).length>0?{status:"connecting"}:y?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=f.getState();if(yield (t=a.init)==null?void 0:t.call(a),Pe(o)&&f.getState().capsuleClient&&Object.values(f.getState().accounts||[]).length>0){let m=l.map(b=>i.find(p=>p.chainId===b)),y=f.getState().accounts;f.setState({status:"connecting"});let O=Object.fromEntries(yield Promise.all(l.map(b=>c(void 0,null,function*(){return [b,yield a.getKey(b)]}))));return f.setState(b=>({accounts:k(k({},b.accounts||{}),O)})),u.setState(b=>({recentChainIds:[...b.recentChainIds||[],...l].filter((p,w,T)=>T.indexOf(p)===w)})),f.setState(b=>({activeChainIds:[...b.activeChainIds||[],...l].filter((p,w,T)=>T.indexOf(p)===w)})),f.setState({status:"connected"}),{accounts:y,walletType:o,chains:m}}if(yield a.enable(l),Pe(o)){let m=l.map(O=>i.find(b=>b.chainId===O)),y=f.getState().accounts;return f.setState({status:"connecting"}),{accounts:y,walletType:o,chains:m}}let g=Object.fromEntries(yield Promise.all(l.map(m=>c(void 0,null,function*(){return [m,yield a.getKey(m)]}))));f.setState(m=>({accounts:k(k({},m.accounts||{}),g)})),u.setState(m=>({recentChainIds:[...m.recentChainIds||[],...l].filter((y,O,b)=>b.indexOf(y)===O)})),f.setState(m=>({activeChainIds:[...m.activeChainIds||[],...l].filter((y,O,b)=>b.indexOf(y)===O)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),f.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(X,"Active");let S=l.map(m=>i.find(y=>y.chainId===m)),E=f.getState().accounts;return console.log("Connected",E),{accounts:E,walletType:o,chains:S}}catch(n){throw console.error("connect ",n),f.getState().accounts===null&&f.setState({status:"disconnected"}),f.getState().accounts&&f.getState().activeChainIds&&f.setState({status:"connected"}),n}}),re=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(X);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=f.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(f.setState(oe),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(f.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else f.setState(oe),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},U=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=B(n||void 0);if(t&&o&&n)return yield Y({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),re();}}),ft=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!B(n))throw new Error(`${n} is not available`);let r=D(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Re=()=>{u.setState({recentChainIds:null});},Sr=()=>u.getState().recentChainIds,Cr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},wr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},hr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},De=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let i=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),gt=e=>c(void 0,null,function*(){var i;let t=u.getState().walletType;return yield De({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var yt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var St=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),Ct=A=>c(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:d}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,s,a,l,d)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),ht=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),At=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),It=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var vr=e=>e,Wr=e=>e;var he=e=>e?Object.keys(e).length===0:!0;var _e=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new _e(e):new DOMException(e),Et=e=>{let t=e.reason===void 0?Ot("This operation was aborted."):e.reason;return t instanceof Error?t:Ot(t)};function Ke(o,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,l)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let d=[],A=[],g=new Map,S=!1,E=!1,m=!1,y=0,O=0,b=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=T=>{S=!0,E=!0,l(T);};r&&(r.aborted&&p(Et(r)),r.addEventListener("abort",()=>{p(Et(r));}));let w=()=>c(this,null,function*(){if(E)return;let T=yield b.next(),R=O;if(O++,T.done){if(m=!0,y===0&&!E){if(!i&&A.length>0){p(new AggregateError(A));return}if(E=!0,g.size===0){a(d);return}let _=[];for(let[K,Z]of d.entries())g.get(K)!==bt&&_.push(Z);a(_);}return}y++,c(this,null,function*(){try{let _=yield T.value;if(E)return;let K=yield t(_,R);K===bt&&g.set(R,K),d[R]=K,y--,yield w();}catch(_){if(i)p(_);else {A.push(_),y--;try{yield w();}catch(K){p(K);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield w();}catch(R){p(R);break}if(m||S)break}});})})}var bt=Symbol("skip");var F=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},G=(e,t,n)=>c(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Ke(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Tt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Be=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,s=>c(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ue=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,s=>c(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ae=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=F({chainId:t,multiChain:n}),o=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:o,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,A=>c(void 0,null,function*(){var y;let g=(y=u.getState().chainsConfig)==null?void 0:y[A.chainId],S={url:A.rpc,headers:k({},(g==null?void 0:g.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(S)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var is=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow),Ie=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>B(r))};var J=e=>{let t=u(a=>a.walletType),n=f(a=>a.activeChainIds),i=F({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=f(a=>a.accounts),o=f(a=>a.status);return useEffect(()=>f.subscribe(a=>a.status,(a,l)=>{var d,A,g;if(a==="connected"){let{accounts:S,activeChainIds:E}=f.getState(),{chains:m}=u.getState(),{walletType:y}=u.getState();if(!S||!E||!m)return (d=e==null?void 0:e.onDisconnect)==null?void 0:d.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:S,chains:E.map(O=>m.find(b=>b.chainId===O)),walletType:y,isReconnect:l==="reconnecting"});}a==="disconnected"&&((g=e==null?void 0:e.onDisconnect)==null||g.call(e));}),[e]),{data:useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),i,a=>r[a.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:U,status:o}},Cn=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Be({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return useQuery(o,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){let S=s==null?void 0:s[g.chainId];if(!S)throw new Error(`Client is not ready ${g.chainId}`);return yield S.getAllBalances(toBech32(g.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!he(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Ss=e=>{let t=F({chainId:e.chainId}),{data:n}=J({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=Cn({chainId:t.map(l=>l.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=useQuery(s,({queryKey:[,l,d]})=>d==null?void 0:d.find(A=>A.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(k({},a),{refetch:l=>c(void 0,null,function*(){return yield o(),a.refetch(l)})})},Cs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Ie();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},ws=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],re,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},hs=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!B(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,d=>c(void 0,null,function*(){return yield ft({chainId:d.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},As=e=>{let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=J(),{data:i}=Be({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return useQuery(o,d=>c(void 0,[d],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,g=>c(void 0,null,function*(){var E;if(!s)throw new Error("Client is not ready");return yield (E=s[g.chainId])==null?void 0:E.getBalanceStaked(toBech32(g.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var xs=()=>{let e=u(i=>i.capsuleState),t=f(i=>i.capsuleClient),n=le();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{re();}}};var _s=()=>f(e=>e.activeChainIds),wn=()=>{var e;return (e=f(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Ks=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ns=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ls=({denom:e})=>{let t=wn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},Bs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>c(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Us=()=>({data:u(t=>t.recentChainIds),clear:Re}),Fs=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:Re}},qs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],De,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Gs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],gt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Ie();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Ys=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=J(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>St(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Js=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=J(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>Ct(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Zs=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=J(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],l=>{var A;if(!o)throw new Error("senderAddress is undefined");let d=q(k({},l),{fee:(A=l.fee)!=null?A:"auto",senderAddress:o,codeId:e});return wt(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(i==null?void 0:i(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},ea=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=J(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],l=>{var A,g,S;if(!o)throw new Error("senderAddress is undefined");let d=q(k({},l),{fee:(A=l.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(g=l.memo)!=null?g:"",funds:(S=l.funds)!=null?S:[]});return ht(d)},{onError:(l,d)=>Promise.resolve(t==null?void 0:t(l,d)),onMutate:n,onSuccess:l=>Promise.resolve(i==null?void 0:i(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ta=e=>{let{data:t}=Ue();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return At(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},na=e=>{let{data:t}=Ue(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return It(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ga(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=f(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,d=>c(this,null,function*(){var y,O;if(!(i!=null&&i.includes(d.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(d.chainId);default:return D(s).getOfflineSignerAuto(d.chainId)}}))(),S=(y=u.getState().chainsConfig)==null?void 0:y[d.chainId],E={url:d.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(E,g,e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[d.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ya(e){let t=F({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=f(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,d=>c(this,null,function*(){var O,b;if(!(i!=null&&i.includes(d.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let g=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(d.chainId);default:return D(s).getOfflineSignerAuto(d.chainId)}}))(),S=(O=u.getState().chainsConfig)==null?void 0:O[d.chainId],E={url:d.rpc,headers:k({},(S==null?void 0:S.rpcHeaders)||{})},m=S!=null&&S.gas?GasPrice.fromString(`${S.gas.price}${S.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(E,g,k({gasPrice:m},e!=null&&e.multiChain?(b=e.opts)==null?void 0:b[d.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Sa(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=f(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Ae({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,A=>c(this,null,function*(){var y;if(!(i!=null&&i.includes(A.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let S=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(A.chainId);default:return D(a).getOfflineSignerAuto(A.chainId)}}))(),E=e.multiChain?o[A.chainId]:o;return yield SigningStargateClient.createWithSigner(E,S,e.multiChain?(y=e.opts)==null?void 0:y[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ca(e){let t=F({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=f(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Ae({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=Ae({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:d=>c(this,[d],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,g=>c(this,null,function*(){var p,w;if(!(i!=null&&i.includes(g.chainId)))return null;if(!B(l))throw new Error(`${l} is not available`);let E=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(l).getOfflineSigner(g.chainId);case"offlineSignerAuto":return D(l).getOfflineSignerAuto(g.chainId);case"offlineSignerOnlyAmino":return D(l).getOfflineSignerOnlyAmino(g.chainId);default:return D(l).getOfflineSignerAuto(g.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[g.chainId],y=m!=null&&m.gas?GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,O=e.multiChain?s==null?void 0:s[g.chainId]:o;if(!O)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(O,E,k({gasPrice:y},e.multiChain?(w=e.opts)==null?void 0:w[g.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!he(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Kt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var bn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(X)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i,iframeOptions:r,chains:o}=u(),{activeChainIds:s,wcSignClients:a}=f(),l=B(i||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!o)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(A=>{if(A)return Y({chainId:o.map(g=>g.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(i){if(!l)return;e&&s?(console.log("reconnect on refresh"),U({onError:n})):!e&&t&&(console.log("reconnect on autoReconnect"),U({onError:n}));}},[l]),useEffect(()=>{var d,A,g,S,E,m,y,O,b,p,w,T,R,_,K,Z,ie,C,h,I;if(i){if(!l)return;i==="cosmostation"&&((A=(d=me()).subscription)==null||A.call(d,()=>{U({onError:n});})),i==="keplr"&&((S=(g=de()).subscription)==null||S.call(g,()=>{U({onError:n});})),i==="leap"&&((m=(E=fe()).subscription)==null||m.call(E,()=>{U({onError:n});})),i==="compass"&&((O=(y=ue()).subscription)==null||O.call(y,()=>{U({onError:n});})),i==="vectis"&&((p=(b=Ce()).subscription)==null||p.call(b,()=>{U({onError:n});})),i==="walletconnect"&&a.has("walletconnect")&&(console.log("reconnect on walletconnect subs"),(T=(w=Q()).subscription)==null||T.call(w,()=>{U({onError:n});})),i==="station"&&((_=(R=Se()).subscription)==null||_.call(R,()=>{U({onError:n});})),i==="xdefi"&&((Z=(K=we()).subscription)==null||Z.call(K,()=>{U({onError:n});})),i==="cosmiframe"&&((C=(ie=pe()).subscription)==null||C.call(ie,()=>{U({onError:n});})),i==="okx"&&((I=(h=ye()).subscription)==null||I.call(h,()=>{U({onError:n});}));}},[i,a,l]),null},Nt=()=>(bn(),null);var kn=new QueryClient({}),Va=i=>{var r=i,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return useEffect(()=>{yt(t);},[t]),jsx(QueryClientProvider,q(k({client:kn},n),{children:jsxs(Kt,{children:[e,jsx(Nt,{})]})}),"graz-provider")};
20
20
 
21
- export { Lt as GrazEvents, Ha as GrazProvider, He as WALLET_TYPES, $e as WalletType, L as checkWallet, Re as clearRecentChain, N as clearSession, St as configureGraz, Y as connect, vr as defineChainInfo, kr as defineChains, re as disconnect, At as executeContract, or as getAvailableWallets, Cr as getChainInfo, wr as getChainInfos, me as getCosmostation, de as getKeplr, fe as getLeap, at as getMetamaskSnapLeap, gt as getOfflineSigners, Ot as getQueryRaw, It as getQuerySmart, yr as getRecentChainIds, Sr as getRecentChains, Ce as getVectis, pt as getWCCosmostation, mt as getWCKeplr, dt as getWCLeap, R as getWallet, Q as getWalletConnect, ht as instantiateContract, Pe as isCapsule, ft as isWalletConnect, U as reconnect, wt as sendIbcTokens, Ct as sendTokens, De as suggestChain, yt as suggestChainAndConnect, J as useAccount, Ns as useActiveChainCurrency, Ds as useActiveChainIds, hn as useActiveChains, is as useActiveWalletType, ys as useBalance, hs as useBalanceStaked, wn as useBalances, Ms as useCapsule, _s as useChainInfo, Ks as useChainInfos, Ie as useCheckWallet, Ss as useConnect, Ue as useCosmWasmClient, ga as useCosmWasmSigningClient, Sa as useCosmWasmTmSigningClient, Cs as useDisconnect, Zs as useExecuteContract, Tn as useGrazEvents, Js as useInstantiateContract, ws as useOfflineSigners, Ls as useQueryClientValidators, ta as useQueryRaw, ea as useQuerySmart, Bs as useRecentChainIds, Us as useRecentChains, Ys as useSendIbcTokens, Xs as useSendTokens, Be as useStargateClient, fa as useStargateSigningClient, ya as useStargateTmSigningClient, Fs as useSuggestChain, qs as useSuggestChainAndConnect, Ae as useTendermintClient };
21
+ export { Nt as GrazEvents, Va as GrazProvider, He as WALLET_TYPES, $e as WalletType, B as checkWallet, Re as clearRecentChain, N as clearSession, yt as configureGraz, Y as connect, Wr as defineChainInfo, vr as defineChains, re as disconnect, ht as executeContract, or as getAvailableWallets, wr as getChainInfo, hr as getChainInfos, me as getCosmostation, de as getKeplr, fe as getLeap, at as getMetamaskSnapLeap, ft as getOfflineSigners, It as getQueryRaw, At as getQuerySmart, Sr as getRecentChainIds, Cr as getRecentChains, Ce as getVectis, pt as getWCCosmostation, mt as getWCKeplr, dt as getWCLeap, D as getWallet, Q as getWalletConnect, wt as instantiateContract, Pe as isCapsule, ir as isWalletConnect, U as reconnect, Ct as sendIbcTokens, St as sendTokens, De as suggestChain, gt as suggestChainAndConnect, J as useAccount, Ls as useActiveChainCurrency, _s as useActiveChainIds, wn as useActiveChains, is as useActiveWalletType, Ss as useBalance, As as useBalanceStaked, Cn as useBalances, xs as useCapsule, Ks as useChainInfo, Ns as useChainInfos, Ie as useCheckWallet, Cs as useConnect, Ue as useCosmWasmClient, ya as useCosmWasmSigningClient, Ca as useCosmWasmTmSigningClient, ws as useDisconnect, ea as useExecuteContract, bn as useGrazEvents, Zs as useInstantiateContract, hs as useOfflineSigners, Bs as useQueryClientValidators, na as useQueryRaw, ta as useQuerySmart, Us as useRecentChainIds, Fs as useRecentChains, Js as useSendIbcTokens, Ys as useSendTokens, Be as useStargateClient, ga as useStargateSigningClient, Sa as useStargateTmSigningClient, qs as useSuggestChain, Gs as useSuggestChainAndConnect, Ae as useTendermintClient };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graz",
3
3
  "description": "React hooks for Cosmos",
4
- "version": "0.1.27-alpha.2",
4
+ "version": "0.1.27-alpha.4",
5
5
  "author": "Griko Nibras <griko@strange.love>",
6
6
  "repository": "https://github.com/graz-sh/graz.git",
7
7
  "homepage": "https://github.com/graz-sh/graz",