"use strict";var D=Object.defineProperty;var G=s=>{throw TypeError(s)};var O=(s,t,e)=>t in s?D(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var f=(s,t,e)=>O(s,typeof t!="symbol"?t+"":t,e),A=(s,t,e)=>t.has(s)||G("Cannot "+e);var l=(s,t,e)=>(A(s,t,"read from private field"),e?e.call(s):t.get(s)),p=(s,t,e)=>t.has(s)?G("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),c=(s,t,e,i)=>(A(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e);var F=(s,t,e,i)=>({set _(a){c(s,t,a,e)},get _(){return l(s,t,i)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-BLlpWXP6.js");var o,g;const v=class v extends r.AbstractSigner{constructor(e){super(e.provider);f(this,"signer");p(this,o);p(this,g);r.defineProperties(this,{signer:e}),c(this,o,null),c(this,g,0)}async getAddress(){return this.signer.getAddress()}connect(e){return new v(this.signer.connect(e))}async getNonce(e){if(e==="pending"){l(this,o)==null&&c(this,o,super.getNonce("pending"));const i=l(this,g);return await l(this,o)+i}return super.getNonce(e)}increment(){F(this,g)._++}reset(){c(this,g,0),c(this,o,null)}async sendTransaction(e){const i=this.getNonce("pending");return this.increment(),e=await this.signer.populateTransaction(e),e.nonce=await i,await this.signer.sendTransaction(e)}signTransaction(e){return this.signer.signTransaction(e)}signMessage(e){return this.signer.signMessage(e)}signTypedData(e,i,a){return this.signer.signTypedData(e,i,a)}};o=new WeakMap,g=new WeakMap;let P=v;async function b(s,t,e){const i=typeof t=="string"?new r.Wallet(t,s):t,a=(e==null?void 0:e.chain)??(await r.EvmPlatform.chainFromRpc(s))[1],n=new P(i);if(n.provider===null)try{n.connect(s)}catch(d){console.error("Cannot connect to network for signer",d)}return new B(a,await i.getAddress(),n,e)}class B extends r.PlatformNativeSigner{constructor(e,i,a,n){super(e,i,a);f(this,"opts");this.opts=n}chain(){return this._chain}address(){return this._address}async sign(e){var w,y,x,C,S,T,E;const i=this.chain(),a=[];let n=500000n,d=100000000000n,m=1500000000n,u=100000000n;if(((w=this.opts)==null?void 0:w.overrides)===void 0&&i!=="Celo"){const h=await this._signer.provider.getFeeData();d=h.gasPrice??d,m=h.maxFeePerGas??m,u=h.maxPriorityFeePerGas??u}((y=this.opts)==null?void 0:y.gasLimit)!==void 0&&(n=this.opts.gasLimit),((x=this.opts)==null?void 0:x.maxGasLimit)!==void 0&&(n=n>((C=this.opts)==null?void 0:C.maxGasLimit)?(S=this.opts)==null?void 0:S.maxGasLimit:n);const L=i==="Oasis"?{gasLimit:n,gasPrice:d,type:0}:{gasLimit:n,maxFeePerGas:m,maxPriorityFeePerGas:u};for(const h of e){const{transaction:N,description:q}=h;(T=this.opts)!=null&&T.debug&&console.log(`Signing: ${q} for ${this.address()}`);const _={...N,...L,from:this.address(),nonce:await this._signer.getNonce(),...(E=this.opts)==null?void 0:E.overrides};a.push(await this._signer.signTransaction(_))}return a}}const $={Address:r.EvmAddress,Platform:r.EvmPlatform,getSigner:b,protocols:{WormholeCore:()=>Promise.resolve().then(()=>require("./index-BLlpWXP6.js")).then(s=>s.index$1),TokenBridge:()=>Promise.resolve().then(()=>require("./index-BNKmpg6n.js")),PorticoBridge:()=>Promise.resolve().then(()=>require("./index-ayI3JKYy.js")),CircleBridge:()=>Promise.resolve().then(()=>require("./index-Dfw9KJ41.js"))},getChain:(s,t,e)=>new r.EvmChain(t,new r.EvmPlatform(s,r.applyChainsConfigConfigOverrides(s,r._platform,{[t]:e})))};exports.default=$;
