@snapshot-labs/snapshot.js 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -229,4 +229,4 @@ const{fromCallback:Ij}=LA,Tj=$A.Store,Cj=UA.permuteDomain,zj=qA.pathMatch,{getCu
229
229
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
230
230
  * POSSIBILITY OF SUCH DAMAGE.
231
231
  */
232
- const Jj=$A.Store,Wj=Dj.MemoryCookieStore,Yj=qA.pathMatch,{fromCallback:Qj}=LA,{getCustomInspectSymbol:Xj}=Nj,tx=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/,ex=/[\x00-\x1F]/,rx=["\n","\r","\0"],ix=/[\x20-\x3A\x3C-\x7E]+/,nx=/[\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]/,ox={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},ax=2147483647e3,sx='Invalid sameSiteContext option for getCookies(); expected one of "strict", "lax", or "none"';function hx(t){Gj.validate(Gj.isNonEmptyString(t),t);const e=String(t).toLowerCase();return"none"===e||"lax"===e||"strict"===e?e:null}const ux=Object.freeze({SILENT:"silent",STRICT:"strict",DISABLED:"unsafe-disabled"}),lx=/(?:^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$)|(?:^(?:(?:[a-f\d]{1,4}:){7}(?:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,2}|:)|(?:[a-f\d]{1,4}:){4}(?:(?::[a-f\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,3}|:)|(?:[a-f\d]{1,4}:){3}(?:(?::[a-f\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,4}|:)|(?:[a-f\d]{1,4}:){2}(?:(?::[a-f\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,5}|:)|(?:[a-f\d]{1,4}:){1}(?:(?::[a-f\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,6}|:)|(?::(?:(?::[a-f\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,7}|:)))$)/,cx="\n\\[?(?:\n(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|\n(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,3}|:)|\n(?:[a-fA-F\\d]{1,4}:){3}(?:(?::[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|\n(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|\n(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:))\n)(?:%[0-9a-zA-Z]{1,})?\\]?\n".replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),dx=new RegExp(`^${cx}$`);function fx(t,e,r,i){let n=0;for(;n<t.length;){const e=t.charCodeAt(n);if(e<=47||e>=58)break;n++}return n<e||n>r?null:i||n==t.length?parseInt(t.substr(0,n),10):null}function mx(t){const e=t.split(":"),r=[0,0,0];if(3!==e.length)return null;for(let t=0;t<3;t++){const i=2==t,n=fx(e[t],1,2,i);if(null===n)return null;r[t]=n}return r}function px(t){t=String(t).substr(0,3).toLowerCase();const e=ox[t];return e>=0?e:null}function gx(t){if(!t)return;const e=t.split(nx);if(!e)return;let r=null,i=null,n=null,o=null,a=null,s=null;for(let t=0;t<e.length;t++){const h=e[t].trim();if(!h.length)continue;let u;null===n&&(u=mx(h),u)?(r=u[0],i=u[1],n=u[2]):null!==o||(u=fx(h,1,2,!0),null===u)?null!==a||(u=px(h),null===u)?null===s&&(u=fx(h,2,4,!0),null!==u&&(s=u,s>=70&&s<=99?s+=1900:s>=0&&s<=69&&(s+=2e3))):a=u:o=u}return null===o||null===a||null===s||null===n||o<1||o>31||s<1601||r>23||i>59||n>59?void 0:new Date(Date.UTC(s,a,o,r,i,n))}function yx(t){return Gj.validate(Gj.isDate(t),t),t.toUTCString()}function wx(t){return null==t?null:(t=t.trim().replace(/^\./,""),dx.test(t)&&(t=t.replace("[","").replace("]","")),Kj&&/[^\u0001-\u007f]/.test(t)&&(t=Kj.toASCII(t)),t.toLowerCase())}function vx(t,e,r){if(null==t||null==e)return null;if(!1!==r&&(t=wx(t),e=wx(e)),t==e)return!0;const i=t.lastIndexOf(e);return!(i<=0)&&(t.length===e.length+i&&("."===t.substr(i-1,1)&&!lx.test(t)))}function bx(t){if(!t||"/"!==t.substr(0,1))return"/";if("/"===t)return t;const e=t.lastIndexOf("/");return 0===e?"/":t.slice(0,e)}function kx(t,e){t=function(t){if(Gj.isEmptyString(t))return t;for(let e=0;e<rx.length;e++){const r=t.indexOf(rx[e]);-1!==r&&(t=t.substr(0,r))}return t}(t),Gj.validate(Gj.isString(t),t);let r,i,n=t.indexOf("=");if(e)0===n&&(n=(t=t.substr(1)).indexOf("="));else if(n<=0)return;if(n<=0?(r="",i=t.trim()):(r=t.substr(0,n).trim(),i=t.substr(n+1).trim()),ex.test(r)||ex.test(i))return;const o=new Sx;return o.key=r,o.value=i,o}function Mx(t,e){if(e&&"object"==typeof e||(e={}),Gj.isEmptyString(t)||!Gj.isString(t))return null;const r=(t=t.trim()).indexOf(";"),i=kx(-1===r?t:t.substr(0,r),!!e.loose);if(!i)return;if(-1===r)return i;const n=t.slice(r+1).trim();if(0===n.length)return i;const o=n.split(";");for(;o.length;){const t=o.shift().trim();if(0===t.length)continue;const e=t.indexOf("=");let r,n;switch(-1===e?(r=t,n=null):(r=t.substr(0,e),n=t.substr(e+1)),r=r.trim().toLowerCase(),n&&(n=n.trim()),r){case"expires":if(n){const t=gx(n);t&&(i.expires=t)}break;case"max-age":if(n&&/^-?[0-9]+$/.test(n)){const t=parseInt(n,10);i.setMaxAge(t)}break;case"domain":if(n){const t=n.trim().replace(/^\./,"");t&&(i.domain=t.toLowerCase())}break;case"path":i.path=n&&"/"===n[0]?n:null;break;case"secure":i.secure=!0;break;case"httponly":i.httpOnly=!0;break;case"samesite":switch(n?n.toLowerCase():""){case"strict":i.sameSite="strict";break;case"lax":i.sameSite="lax";break;case"none":i.sameSite="none";break;default:i.sameSite=void 0}break;default:i.extensions=i.extensions||[],i.extensions.push(t)}}return i}function _x(t){let e;try{e=JSON.parse(t)}catch(t){return t}return e}function Ex(t){if(!t||Gj.isEmptyString(t))return null;let e;if("string"==typeof t){if(e=_x(t),e instanceof Error)return null}else e=t;const r=new Sx;for(let t=0;t<Sx.serializableProperties.length;t++){const i=Sx.serializableProperties[t];void 0!==e[i]&&e[i]!==xx[i]&&("expires"===i||"creation"===i||"lastAccessed"===i?null===e[i]?r[i]=null:r[i]="Infinity"==e[i]?"Infinity":new Date(e[i]):r[i]=e[i])}return r}function Ax(t,e){Gj.validate(Gj.isObject(t),t),Gj.validate(Gj.isObject(e),e);let r=0;const i=t.path?t.path.length:0;if(r=(e.path?e.path.length:0)-i,0!==r)return r;return r=(t.creation?t.creation.getTime():ax)-(e.creation?e.creation.getTime():ax),0!==r||(r=t.creationIndex-e.creationIndex),r}function jx(t){if(t instanceof Object)return t;try{t=decodeURI(t)}catch(t){}return zA(t)}const xx={key:"",value:"",expires:"Infinity",maxAge:null,domain:null,path:null,secure:!1,httpOnly:!1,extensions:null,hostOnly:null,pathIsDefault:null,creation:null,lastAccessed:null,sameSite:void 0};class Sx{constructor(t={}){const e=Xj();e&&(this[e]=this.inspect),Object.assign(this,xx,t),this.creation=this.creation||new Date,Object.defineProperty(this,"creationIndex",{configurable:!1,enumerable:!1,writable:!0,value:++Sx.cookiesCreated})}inspect(){const t=Date.now(),e=null!=this.hostOnly?this.hostOnly:"?",r=this.creation?t-this.creation.getTime()+"ms":"?",i=this.lastAccessed?t-this.lastAccessed.getTime()+"ms":"?";return`Cookie="${this.toString()}; hostOnly=${e}; aAge=${i}; cAge=${r}"`}toJSON(){const t={};for(const e of Sx.serializableProperties)this[e]!==xx[e]&&("expires"===e||"creation"===e||"lastAccessed"===e?null===this[e]?t[e]=null:t[e]="Infinity"==this[e]?"Infinity":this[e].toISOString():"maxAge"===e?null!==this[e]&&(t[e]=this[e]==1/0||this[e]==-1/0?this[e].toString():this[e]):this[e]!==xx[e]&&(t[e]=this[e]));return t}clone(){return Ex(this.toJSON())}validate(){if(!tx.test(this.value))return!1;if(!(this.expires==1/0||this.expires instanceof Date||gx(this.expires)))return!1;if(null!=this.maxAge&&this.maxAge<=0)return!1;if(null!=this.path&&!ix.test(this.path))return!1;const t=this.cdomain();if(t){if(t.match(/\.$/))return!1;if(null==DA.getPublicSuffix(t))return!1}return!0}setExpires(t){t instanceof Date?this.expires=t:this.expires=gx(t)||"Infinity"}setMaxAge(t){this.maxAge=t===1/0||t===-1/0?t.toString():t}cookieString(){let t=this.value;return null==t&&(t=""),""===this.key?t:`${this.key}=${t}`}toString(){let t=this.cookieString();if(this.expires!=1/0&&(this.expires instanceof Date?t+=`; Expires=${yx(this.expires)}`:t+=`; Expires=${this.expires}`),null!=this.maxAge&&this.maxAge!=1/0&&(t+=`; Max-Age=${this.maxAge}`),this.domain&&!this.hostOnly&&(t+=`; Domain=${this.domain}`),this.path&&(t+=`; Path=${this.path}`),this.secure&&(t+="; Secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&"none"!==this.sameSite){const e=Sx.sameSiteCanonical[this.sameSite.toLowerCase()];t+=`; SameSite=${e||this.sameSite}`}return this.extensions&&this.extensions.forEach((e=>{t+=`; ${e}`})),t}TTL(t){if(null!=this.maxAge)return this.maxAge<=0?0:1e3*this.maxAge;let e=this.expires;return e!=1/0?(e instanceof Date||(e=gx(e)||1/0),e==1/0?1/0:e.getTime()-(t||Date.now())):1/0}expiryTime(t){if(null!=this.maxAge){const e=t||this.creation||new Date,r=this.maxAge<=0?-1/0:1e3*this.maxAge;return e.getTime()+r}return this.expires==1/0?1/0:this.expires.getTime()}expiryDate(t){const e=this.expiryTime(t);return e==1/0?new Date(ax):e==-1/0?new Date(0):new Date(e)}isPersistent(){return null!=this.maxAge||this.expires!=1/0}canonicalizedDomain(){return null==this.domain?null:wx(this.domain)}cdomain(){return this.canonicalizedDomain()}}function Nx(t){if(null!=t){const e=t.toLowerCase();switch(e){case ux.STRICT:case ux.SILENT:case ux.DISABLED:return e}}return ux.SILENT}Sx.cookiesCreated=0,Sx.parse=Mx,Sx.fromJSON=Ex,Sx.serializableProperties=Object.keys(xx),Sx.sameSiteLevel={strict:3,lax:2,none:1},Sx.sameSiteCanonical={strict:"Strict",lax:"Lax"};class Ix{constructor(t,e={rejectPublicSuffixes:!0}){"boolean"==typeof e&&(e={rejectPublicSuffixes:e}),Gj.validate(Gj.isObject(e),e),this.rejectPublicSuffixes=e.rejectPublicSuffixes,this.enableLooseMode=!!e.looseMode,this.allowSpecialUseDomain="boolean"!=typeof e.allowSpecialUseDomain||e.allowSpecialUseDomain,this.store=t||new Wj,this.prefixSecurity=Nx(e.prefixSecurity),this._cloneSync=Tx("clone"),this._importCookiesSync=Tx("_importCookies"),this.getCookiesSync=Tx("getCookies"),this.getCookieStringSync=Tx("getCookieString"),this.getSetCookieStringsSync=Tx("getSetCookieStrings"),this.removeAllCookiesSync=Tx("removeAllCookies"),this.setCookieSync=Tx("setCookie"),this.serializeSync=Tx("serialize")}setCookie(t,e,r,i){let n;if(Gj.validate(Gj.isUrlStringOrObject(e),i,r),Gj.isFunction(e))return(i=e)(new Error("No URL was specified"));const o=jx(e);if(Gj.isFunction(r)&&(i=r,r={}),Gj.validate(Gj.isFunction(i),i),!Gj.isNonEmptyString(t)&&!Gj.isObject(t)&&t instanceof String&&0==t.length)return i(null);const a=wx(o.hostname),s=r.loose||this.enableLooseMode;let h=null;if(r.sameSiteContext&&(h=hx(r.sameSiteContext),!h))return i(new Error(sx));if("string"==typeof t||t instanceof String){if(!(t=Sx.parse(t,{loose:s})))return n=new Error("Cookie failed to parse"),i(r.ignoreError?null:n)}else if(!(t instanceof Sx))return n=new Error("First argument to setCookie must be a Cookie object or string"),i(r.ignoreError?null:n);const u=r.now||new Date;if(this.rejectPublicSuffixes&&t.domain){if(null==DA.getPublicSuffix(t.cdomain(),{allowSpecialUseDomain:this.allowSpecialUseDomain,ignoreError:r.ignoreError})&&!dx.test(t.domain))return n=new Error("Cookie has domain set to a public suffix"),i(r.ignoreError?null:n)}if(t.domain){if(!vx(a,t.cdomain(),!1))return n=new Error(`Cookie not in this host's domain. Cookie:${t.cdomain()} Request:${a}`),i(r.ignoreError?null:n);null==t.hostOnly&&(t.hostOnly=!1)}else t.hostOnly=!0,t.domain=a;if(t.path&&"/"===t.path[0]||(t.path=bx(o.pathname),t.pathIsDefault=!0),!1===r.http&&t.httpOnly)return n=new Error("Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:n);if("none"!==t.sameSite&&void 0!==t.sameSite&&h&&"none"===h)return n=new Error("Cookie is SameSite but this is a cross-origin request"),i(r.ignoreError?null:n);const l=this.prefixSecurity===ux.SILENT;if(!(this.prefixSecurity===ux.DISABLED)){let e,n=!1;if(!function(t){return Gj.validate(Gj.isObject(t),t),!t.key.startsWith("__Secure-")||t.secure}(t)?(n=!0,e="Cookie has __Secure prefix but Secure attribute is not set"):function(t){return Gj.validate(Gj.isObject(t)),!t.key.startsWith("__Host-")||t.secure&&t.hostOnly&&null!=t.path&&"/"===t.path}(t)||(n=!0,e="Cookie has __Host prefix but either Secure or HostOnly attribute is not set or Path is not '/'"),n)return i(r.ignoreError||l?null:new Error(e))}const c=this.store;c.updateCookie||(c.updateCookie=function(t,e,r){this.putCookie(e,r)}),c.findCookie(t.domain,t.path,t.key,(function(e,n){if(e)return i(e);const o=function(e){if(e)return i(e);i(null,t)};if(n){if(!1===r.http&&n.httpOnly)return e=new Error("old Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:e);t.creation=n.creation,t.creationIndex=n.creationIndex,t.lastAccessed=u,c.updateCookie(n,t,o)}else t.creation=t.lastAccessed=u,c.putCookie(t,o)}))}getCookies(t,e,r){Gj.validate(Gj.isUrlStringOrObject(t),r,t);const i=jx(t);Gj.isFunction(e)&&(r=e,e={}),Gj.validate(Gj.isObject(e),r,e),Gj.validate(Gj.isFunction(r),r);const n=wx(i.hostname),o=i.pathname||"/";let a=e.secure;null!=a||!i.protocol||"https:"!=i.protocol&&"wss:"!=i.protocol||(a=!0);let s=0;if(e.sameSiteContext){const t=hx(e.sameSiteContext);if(s=Sx.sameSiteLevel[t],!s)return r(new Error(sx))}let h=e.http;null==h&&(h=!0);const u=e.now||Date.now(),l=!1!==e.expire,c=!!e.allPaths,d=this.store;function f(t){if(t.hostOnly){if(t.domain!=n)return!1}else if(!vx(n,t.domain,!1))return!1;if(!c&&!Yj(o,t.path))return!1;if(t.secure&&!a)return!1;if(t.httpOnly&&!h)return!1;if(s){if(Sx.sameSiteLevel[t.sameSite||"none"]>s)return!1}return!(l&&t.expiryTime()<=u)||(d.removeCookie(t.domain,t.path,t.key,(()=>{})),!1)}d.findCookies(n,c?null:o,this.allowSpecialUseDomain,((t,i)=>{if(t)return r(t);i=i.filter(f),!1!==e.sort&&(i=i.sort(Ax));const n=new Date;for(const t of i)t.lastAccessed=n;r(null,i)}))}getCookieString(...t){const e=t.pop();Gj.validate(Gj.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.sort(Ax).map((t=>t.cookieString())).join("; "))})),this.getCookies.apply(this,t)}getSetCookieStrings(...t){const e=t.pop();Gj.validate(Gj.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.map((t=>t.toString())))})),this.getCookies.apply(this,t)}serialize(t){Gj.validate(Gj.isFunction(t),t);let e=this.store.constructor.name;Gj.isObject(e)&&(e=null);const r={version:"tough-cookie@4.1.4",storeType:e,rejectPublicSuffixes:!!this.rejectPublicSuffixes,enableLooseMode:!!this.enableLooseMode,allowSpecialUseDomain:!!this.allowSpecialUseDomain,prefixSecurity:Nx(this.prefixSecurity),cookies:[]};if(!this.store.getAllCookies||"function"!=typeof this.store.getAllCookies)return t(new Error("store does not support getAllCookies and cannot be serialized"));this.store.getAllCookies(((e,i)=>e?t(e):(r.cookies=i.map((t=>(delete(t=t instanceof Sx?t.toJSON():t).creationIndex,t))),t(null,r))))}toJSON(){return this.serializeSync()}_importCookies(t,e){let r=t.cookies;if(!r||!Array.isArray(r))return e(new Error("serialized jar has no cookies array"));r=r.slice();const i=t=>{if(t)return e(t);if(!r.length)return e(t,this);let n;try{n=Ex(r.shift())}catch(t){return e(t)}if(null===n)return i(null);this.store.putCookie(n,i)};i()}clone(t,e){1===arguments.length&&(e=t,t=null),this.serialize(((r,i)=>{if(r)return e(r);Ix.deserialize(i,t,e)}))}cloneSync(t){if(0===arguments.length)return this._cloneSync();if(!t.synchronous)throw new Error("CookieJar clone destination store is not synchronous; use async API instead.");return this._cloneSync(t)}removeAllCookies(t){Gj.validate(Gj.isFunction(t),t);const e=this.store;if("function"==typeof e.removeAllCookies&&e.removeAllCookies!==Jj.prototype.removeAllCookies)return e.removeAllCookies(t);e.getAllCookies(((r,i)=>{if(r)return t(r);if(0===i.length)return t(null);let n=0;const o=[];function a(e){if(e&&o.push(e),n++,n===i.length)return t(o.length?o[0]:null)}i.forEach((t=>{e.removeCookie(t.domain,t.path,t.key,a)}))}))}static deserialize(t,e,r){let i;if(3!==arguments.length&&(r=e,e=null),Gj.validate(Gj.isFunction(r),r),"string"==typeof t){if(i=_x(t),i instanceof Error)return r(i)}else i=t;const n=new Ix(e,{rejectPublicSuffixes:i.rejectPublicSuffixes,looseMode:i.enableLooseMode,allowSpecialUseDomain:i.allowSpecialUseDomain,prefixSecurity:i.prefixSecurity});n._importCookies(i,(t=>{if(t)return r(t);r(null,n)}))}static deserializeSync(t,e){const r="string"==typeof t?JSON.parse(t):t,i=new Ix(e,{rejectPublicSuffixes:r.rejectPublicSuffixes,looseMode:r.enableLooseMode});if(!i.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");return i._importCookiesSync(r),i}}function Tx(t){return function(...e){if(!this.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");let r,i;if(this[t](...e,((t,e)=>{r=t,i=e})),r)throw r;return i}}Ix.fromJSON=Ix.deserializeSync,["_importCookies","clone","getCookies","getCookieString","getSetCookieStrings","removeAllCookies","serialize","setCookie"].forEach((t=>{Ix.prototype[t]=Qj(Ix.prototype[t])})),Ix.deserialize=Qj(Ix.deserialize);var Cx=Zj,zx=Ix,Ox=Sx,Rx=Jj,Px=Wj,Bx=gx,Dx=yx,$x=Mx,Lx=Ex,Fx=vx,Ux=bx,qx=Yj,Vx=DA.getPublicSuffix,Hx=Ax,Gx=UA.permuteDomain,Zx=function(t){if(Gj.validate(Gj.isString(t)),"/"===t)return["/"];const e=[t];for(;t.length>1;){const r=t.lastIndexOf("/");if(0===r)break;t=t.substr(0,r),e.push(t)}return e.push("/"),e},Kx=wx,Jx=ux,Wx=Gj.ParameterError,Yx={version:Cx,CookieJar:zx,Cookie:Ox,Store:Rx,MemoryCookieStore:Px,parseDate:Bx,formatDate:Dx,parse:$x,fromJSON:Lx,domainMatch:Fx,defaultPath:Ux,pathMatch:qx,getPublicSuffix:Vx,cookieCompare:Hx,permuteDomain:Gx,permutePath:Zx,canonicalDomain:Kx,PrefixSecurityEnum:Jx,ParameterError:Wx},Qx=Object.freeze(Object.assign(Object.create(null),Yx,{default:Yx,version:Cx,CookieJar:zx,Cookie:Ox,Store:Rx,MemoryCookieStore:Px,parseDate:Bx,formatDate:Dx,parse:$x,fromJSON:Lx,domainMatch:Fx,defaultPath:Ux,pathMatch:qx,getPublicSuffix:Vx,cookieCompare:Hx,permuteDomain:Gx,permutePath:Zx,canonicalDomain:Kx,PrefixSecurityEnum:Jx,ParameterError:Wx}));var Xx=function(t){if(Array.isArray(t))return t;if("string"!=typeof t)return[];var e,r,i,n,o,a=[],s=0;function h(){for(;s<t.length&&/\s/.test(t.charAt(s));)s+=1;return s<t.length}for(;s<t.length;){for(e=s,o=!1;h();)if(","===(r=t.charAt(s))){for(i=s,s+=1,h(),n=s;s<t.length&&"="!==(r=t.charAt(s))&&";"!==r&&","!==r;)s+=1;s<t.length&&"="===t.charAt(s)?(o=!0,s=n,a.push(t.substring(e,i)),e=s):s=i+1}else s+=1;(!o||s>=t.length)&&a.push(t.substring(e,t.length))}return a};const tS=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);function eS(t,e){}function rS(t,e){t.headers.delete(e)}function iS(t,e){const r=t.headers;for(const t of Object.keys(r))t.toLowerCase()===e&&delete r[t]}const nS=new Set([301,302,303,307,308]);async function oS(t,e,r){switch(e.redirect??"follow"){case"error":throw new TypeError(`URI requested responded with a redirect and redirect mode is set to error: ${r.url}`);case"manual":return r;case"follow":break;default:throw new TypeError(`Invalid redirect option: ${e.redirect}`)}const i=r.headers.get("location");if(null===i)return r;const n=r.url,o=new URL(i,n).toString(),a=e.redirectCount??0,s=e.maxRedirect??20;if(a>=s)throw new TypeError(`Reached maximum redirect of ${s} for URL: ${n}`);const h=function(t){return null==t.headers?eS:"function"==typeof t.headers.delete?rS:iS}(e={...e,redirectCount:a+1});if(!function(t,e){const r=new URL(e).hostname,i=new URL(t).hostname;return r===i||r.endsWith(`.${i}`)}(n,o))for(const t of["authorization","www-authenticate","cookie","cookie2"])h(e,t);const u=e.body,l=e.body;if(303!==r.status&&null!=e.body&&("function"==typeof u.pipe||"function"==typeof l.pipeTo))throw new TypeError("Cannot follow redirect with body being a readable stream");return 303!==r.status&&(301!==r.status&&302!==r.status||"POST"!==e.method)||(e.method="GET",e.body=void 0,h(e,"content-length")),r.headers.has("referrer-policy")&&(e.referrerPolicy=function(t){const e=t.split(/[,\s]+/);let r="";for(const t of e)""!==t&&tS.has(t)&&(r=t);return r}(r.headers.get("referrer-policy"))),await t(o,e)}function aS(t,e,r=!0){const i=t,n=e??new zx;async function o(t,e){const a=e??{};e={...e,redirect:"manual"};const s="string"==typeof t?t:t.url??t.href;e=function(t,e,r){if(""===r)return e;const i=t,n=e.headers;return i.headers&&"function"==typeof i.headers.append?i.headers.append("cookie",r):n&&"function"==typeof n.append?n.append("cookie",r):e={...e,headers:{...e.headers,cookie:r}},e}(t,e,await n.getCookieString(s));const h=await i(t,e),u=function(t){const e=t.headers;if("function"==typeof e.getAll)return e.getAll("set-cookie");if("function"==typeof e.raw){const t=e.raw();return Array.isArray(t["set-cookie"])?t["set-cookie"]:[]}const r=t.headers.get("set-cookie");return null!==r?Xx(r):[]}(h);return await Promise.all(u.map((async t=>await n.setCookie(t,h.url,{ignoreError:r})))),(e.redirectCount??0)>0&&Object.defineProperty(h,"redirected",{value:!0}),l=h.status,nS.has(l)?await oS(o,a,h):h;var l}return o.toughCookie=Qx,o}aS.toughCookie=Qx;var sS="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t||{},hS="URLSearchParams"in sS,uS="Symbol"in sS&&"iterator"in Symbol,lS="FileReader"in sS&&"Blob"in sS&&function(){try{return new Blob,!0}catch(t){return!1}}(),cS="FormData"in sS,dS="ArrayBuffer"in sS;if(dS)var fS=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],mS=ArrayBuffer.isView||function(t){return t&&fS.indexOf(Object.prototype.toString.call(t))>-1};function pS(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function gS(t){return"string"!=typeof t&&(t=String(t)),t}function yS(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return uS&&(e[Symbol.iterator]=function(){return e}),e}function wS(t){this.map={},t instanceof wS?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function vS(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function bS(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function kS(t){var e=new FileReader,r=bS(e);return e.readAsArrayBuffer(t),r}function MS(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function _S(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:lS&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:cS&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:hS&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():dS&&lS&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=MS(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):dS&&(ArrayBuffer.prototype.isPrototypeOf(t)||mS(t))?this._bodyArrayBuffer=MS(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):hS&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},lS&&(this.blob=function(){var t=vS(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=vS(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(lS)return this.blob().then(kS);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,i,n,o=vS(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=bS(e),i=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=i?i[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},cS&&(this.formData=function(){return this.text().then(jS)}),this.json=function(){return this.text().then(JSON.parse)},this}wS.prototype.append=function(t,e){t=pS(t),e=gS(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},wS.prototype.delete=function(t){delete this.map[pS(t)]},wS.prototype.get=function(t){return t=pS(t),this.has(t)?this.map[t]:null},wS.prototype.has=function(t){return this.map.hasOwnProperty(pS(t))},wS.prototype.set=function(t,e){this.map[pS(t)]=gS(e)},wS.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},wS.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),yS(t)},wS.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),yS(t)},wS.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),yS(t)},uS&&(wS.prototype[Symbol.iterator]=wS.prototype.entries);var ES=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function AS(t,e){if(!(this instanceof AS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,n=(e=e||{}).body;if(t instanceof AS){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new wS(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new wS(e.headers)),this.method=(r=e.method||this.method||"GET",i=r.toUpperCase(),ES.indexOf(i)>-1?i:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in sS)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function jS(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),e}function xS(t,e){if(!(this instanceof xS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new wS(e.headers),this.url=e.url||"",this._initBody(t)}AS.prototype.clone=function(){return new AS(this,{body:this._bodyInit})},_S.call(AS.prototype),_S.call(xS.prototype),xS.prototype.clone=function(){return new xS(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new wS(this.headers),url:this.url})},xS.error=function(){var t=new xS(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var SS=[301,302,303,307,308];xS.redirect=function(t,e){if(-1===SS.indexOf(e))throw new RangeError("Invalid status code");return new xS(null,{status:e,headers:{location:t}})};var NS=sS.DOMException;try{new NS}catch(PM){NS=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},NS.prototype=Object.create(Error.prototype),NS.prototype.constructor=NS}function IS(t,e){return new Promise((function(r,i){var n=new AS(t,e);if(n.signal&&n.signal.aborted)return i(new NS("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}if(o.onload=function(){var t,e,i={statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new wS,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();try{e.append(i,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===n.url.indexOf("file://")&&(o.status<200||o.status>599)?i.status=200:i.status=o.status,i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var a="response"in o?o.response:o.responseText;setTimeout((function(){r(new xS(a,i))}),0)},o.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},o.onabort=function(){setTimeout((function(){i(new NS("Aborted","AbortError"))}),0)},o.open(n.method,function(t){try{return""===t&&sS.location.href?sS.location.href:t}catch(e){return t}}(n.url),!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&(lS?o.responseType="blob":dS&&(o.responseType="arraybuffer")),e&&"object"==typeof e.headers&&!(e.headers instanceof wS||sS.Headers&&e.headers instanceof sS.Headers)){var s=[];Object.getOwnPropertyNames(e.headers).forEach((function(t){s.push(pS(t)),o.setRequestHeader(t,gS(e.headers[t]))})),n.headers.forEach((function(t,e){-1===s.indexOf(e)&&o.setRequestHeader(e,t)}))}else n.headers.forEach((function(t,e){o.setRequestHeader(e,t)}));n.signal&&(n.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",a)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}IS.polyfill=!0,sS.fetch||(sS.fetch=IS,sS.Headers=wS,sS.Request=AS,sS.Response=xS);var TS=self.fetch.bind(self);const CS=(t,e,r=[])=>{const i=Object.getOwnPropertyDescriptors(e);for(let t of r)delete i[t];Object.defineProperties(t,i)},zS=(t,e=[t])=>{const r=Object.getPrototypeOf(t);return null===r?e:zS(r,[...e,r])},OS=(t,e,r=[])=>{var i;const n=null!==(i=((...t)=>{if(0===t.length)return;let e;const r=t.map((t=>zS(t)));for(;r.every((t=>t.length>0));){const t=r.map((t=>t.pop())),i=t[0];if(!t.every((t=>t===i)))break;e=i}return e})(...t))&&void 0!==i?i:Object.prototype,o=Object.create(n),a=zS(n);for(let e of t){let t=zS(e);for(let e=t.length-1;e>=0;e--){let i=t[e];-1===a.indexOf(i)&&(CS(o,i,["constructor",...r]),a.push(i))}}return o.constructor=e,o},RS=t=>t.filter(((e,r)=>t.indexOf(e)==r)),PS=new WeakMap,BS=t=>PS.get(t),DS=(t,e)=>{var r,i;const n=RS([...Object.getOwnPropertyNames(t),...Object.getOwnPropertyNames(e)]),o={};for(let a of n)o[a]=RS([...null!==(r=null==t?void 0:t[a])&&void 0!==r?r:[],...null!==(i=null==e?void 0:e[a])&&void 0!==i?i:[]]);return o},$S=(t,e)=>{var r,i,n,o;return{property:DS(null!==(r=null==t?void 0:t.property)&&void 0!==r?r:{},null!==(i=null==e?void 0:e.property)&&void 0!==i?i:{}),method:DS(null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.method)&&void 0!==o?o:{})}},LS=new Map,FS=(...t)=>{const e=((...t)=>{var e;const r=new Set,i=new Set([...t]);for(;i.size>0;)for(let t of i){const n=[...zS(t.prototype).map((t=>t.constructor)),...null!==(e=BS(t))&&void 0!==e?e:[]].filter((t=>!r.has(t)));for(let t of n)i.add(t);r.add(t),i.delete(t)}return[...r]})(...t).map((t=>LS.get(t))).filter((t=>!!t));return 0==e.length?{}:1==e.length?e[0]:e.reduce(((t,e)=>((t,e)=>{var r,i,n,o,a,s;return{class:RS([...null!==(r=null==t?void 0:t.class)&&void 0!==r?r:[],...null!==(i=null==e?void 0:e.class)&&void 0!==i?i:[]]),static:$S(null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.static)&&void 0!==o?o:{}),instance:$S(null!==(a=null==t?void 0:t.instance)&&void 0!==a?a:{},null!==(s=null==e?void 0:e.instance)&&void 0!==s?s:{})}})(t,e)))};function US(...t){var e,r,i;const n=t.map((t=>t.prototype));function o(...e){for(const r of t)CS(this,new r(...e))}o.prototype=OS(n,o),Object.setPrototypeOf(o,OS(t,null,["prototype"]));let a=o;{const n=FS(...t);for(let t of null!==(e=null==n?void 0:n.class)&&void 0!==e?e:[]){const e=t(a);e&&(a=e)}qS(null!==(r=null==n?void 0:n.static)&&void 0!==r?r:{},a),qS(null!==(i=null==n?void 0:n.instance)&&void 0!==i?i:{},a.prototype)}var s,h;return s=a,h=t,PS.set(s,h),a}const qS=(t,e)=>{const r=t.property,i=t.method;if(r)for(let t in r)for(let i of r[t])i(e,t);if(i)for(let t in i)for(let r of i[t])r(e,t,Object.getOwnPropertyDescriptor(e,t))};var VS=Object.defineProperty,HS=Object.getOwnPropertyDescriptor,GS=Object.getOwnPropertyNames,ZS=Object.prototype.hasOwnProperty,KS=(t,e)=>{for(var r in e)VS(t,r,{get:e[r],enumerable:!0})},JS=(t,e,r,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of GS(e))ZS.call(t,n)||n===r||VS(t,n,{get:()=>e[n],enumerable:!(i=HS(e,n))||i.enumerable});return t};KS({},{ADDR_BOUND:()=>ON,API_VERSION:()=>TN,BaseUrl:()=>$N,DEFAULT_GLOBAL_CONFIG:()=>QN,FeeMarginPercentage:()=>qN,HARDENING_4BYTES:()=>YN,HARDENING_BYTE:()=>WN,IS_BROWSER:()=>dN,MASK_250:()=>NN,MASK_31:()=>IN,MAX_STORAGE_ITEM_SIZE:()=>zN,NetworkName:()=>LN,OutsideExecutionCallerAny:()=>ZN,PRIME:()=>CN,RANGE_FELT:()=>PN,RANGE_I128:()=>BN,RANGE_U128:()=>DN,RPC_DEFAULT_VERSION:()=>HN,RPC_NODES:()=>GN,SNIP9_V1_INTERFACE_ID:()=>KN,SNIP9_V2_INTERFACE_ID:()=>JN,SYSTEM_MESSAGES:()=>XN,StarknetChainId:()=>FN,TEXT_TO_FELT_MAX_LEN:()=>xN,TRANSACTION_VERSION:()=>WS.ETransactionVersion,TransactionHashPrefix:()=>UN,UDC:()=>VN,ZERO:()=>SN});var WS={};KS(WS,{JRPC:()=>YS,RPCSPEC06:()=>QS,RPCSPEC07:()=>sg});var YS={},QS={};KS(QS,{EBlockTag:()=>aN,EDAMode:()=>hN,EDataAvailabilityMode:()=>sN,ESimulationFlag:()=>rN,ETransactionExecutionStatus:()=>oN,ETransactionFinalityStatus:()=>nN,ETransactionStatus:()=>iN,ETransactionType:()=>eN,ETransactionVersion:()=>uN,ETransactionVersion2:()=>lN,ETransactionVersion3:()=>cN,Errors:()=>XS,SPEC:()=>tN});var XS={},tN={},eN={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE",L1_HANDLER:"L1_HANDLER"},rN={SKIP_VALIDATE:"SKIP_VALIDATE",SKIP_FEE_CHARGE:"SKIP_FEE_CHARGE"},iN={RECEIVED:"RECEIVED",REJECTED:"REJECTED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},nN={ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},oN={SUCCEEDED:"SUCCEEDED",REVERTED:"REVERTED"},aN={PENDING:"pending",LATEST:"latest"},sN={L1:"L1",L2:"L2"},hN={L1:0,L2:1},uN={V0:"0x0",V1:"0x1",V2:"0x2",V3:"0x3",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002",F3:"0x100000000000000000000000000000003"},lN={V0:"0x0",V1:"0x1",V2:"0x2",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002"},cN={V3:"0x3",F3:"0x100000000000000000000000000000003"};((t,e,r)=>{JS(t,e,"default"),r&&JS(r,e,"default")})(WS,sg);KS({},{IS_BROWSER:()=>dN,addHexPrefix:()=>bN,arrayBufferToString:()=>fN,atobUniversal:()=>gN,btoaUniversal:()=>yN,buf2hex:()=>wN,calcByteLength:()=>MN,concatenateArrayBuffer:()=>jN,padLeft:()=>kN,pascalToSnake:()=>AN,removeHexPrefix:()=>vN,sanitizeBytes:()=>_N,sanitizeHex:()=>EN,stringToArrayBuffer:()=>pN,utf8ToArray:()=>mN});var dN="undefined"!=typeof window;function fN(t){return new Uint8Array(t).reduce(((t,e)=>t+String.fromCharCode(e)),"")}function mN(t){return(new TextEncoder).encode(t)}function pN(t){return mN(t)}function gN(t){return Sg.decode(t)}function yN(t){return Sg.encode(new Uint8Array(t))}function wN(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}function vN(t){return t.replace(/^0x/i,"")}function bN(t){return`0x${vN(t)}`}function kN(t,e,r="0"){return function(t,e,r,i="0"){const n=e-t.length;let o=t;if(n>0){const e=i.repeat(n);o=r?e+t:t+e}return o}(t,e,!0,r)}function MN(t,e=8){const{length:r}=t,i=r%e;return i?(r-i)/e*e+e:r}function _N(t,e=8,r="0"){return kN(t,MN(t,e),r)}function EN(t){const e=_N(vN(t),2);return e?bN(e):e}var AN=t=>/[a-z]/.test(t)?t.split(/(?=[A-Z])/).join("_").toUpperCase():t;function jN(t){const e=t.reduce(((t,e)=>t+e.byteLength),0),r=new Uint8Array(e);let i=0;return t.forEach((t=>{r.set(t,i),i+=t.byteLength})),r}var xN=31,SN=0n,NN=2n**250n-1n,IN=2n**31n-1n,TN=SN,CN=2n**251n+17n*2n**192n+1n,zN=256n,ON=2n**251n-zN,RN=(t,e)=>({min:t,max:e}),PN=RN(SN,CN-1n),BN=RN(-(2n**127n),2n**127n-1n),DN=RN(SN,2n**128n-1n),$N=(t=>(t.SN_MAIN="https://alpha-mainnet.starknet.io",t.SN_SEPOLIA="https://alpha-sepolia.starknet.io",t))($N||{}),LN=(t=>(t.SN_MAIN="SN_MAIN",t.SN_SEPOLIA="SN_SEPOLIA",t))(LN||{}),FN=(t=>(t.SN_MAIN="0x534e5f4d41494e",t.SN_SEPOLIA="0x534e5f5345504f4c4941",t))(FN||{}),UN=(t=>(t.DECLARE="0x6465636c617265",t.DEPLOY="0x6465706c6f79",t.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",t.INVOKE="0x696e766f6b65",t.L1_HANDLER="0x6c315f68616e646c6572",t))(UN||{}),qN=(t=>(t[t.L1_BOUND_MAX_AMOUNT=50]="L1_BOUND_MAX_AMOUNT",t[t.L1_BOUND_MAX_PRICE_PER_UNIT=50]="L1_BOUND_MAX_PRICE_PER_UNIT",t[t.MAX_FEE=50]="MAX_FEE",t))(qN||{}),VN={ADDRESS:"0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",ENTRYPOINT:"deployContract"},HN="v0_7",GN={SN_MAIN:[`https://starknet-mainnet.public.blastapi.io/rpc/${HN}`,`https://free-rpc.nethermind.io/mainnet-juno/${HN}`],SN_SEPOLIA:[`https://starknet-sepolia.public.blastapi.io/rpc/${HN}`,`https://free-rpc.nethermind.io/sepolia-juno/${HN}`]},ZN="0x414e595f43414c4c4552",KN="0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181",JN="0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872",WN=128,YN=2147483648n,QN={legacyMode:!1,logLevel:"INFO",accountTxVersion:WS.ETransactionVersion.V2},XN={legacyTxWarningMessage:"You are using a deprecated transaction version (V0,V1,V2)!\nUpdate to the latest V3 transactions!"},tI={};KS(tI,{RpcChannel:()=>oO});KS({},{parse:()=>rI,parseAlwaysAsBig:()=>iI,stringify:()=>nI,stringifyAlwaysAsBig:()=>oI});var eI=t=>{if(!Rg(t))return parseFloat(t);const e=parseInt(t,10);return Number.isSafeInteger(e)?e:BigInt(t)},rI=t=>Yg(String(t),void 0,eI),iI=t=>Yg(String(t),void 0,Kg),nI=(t,e,r,i)=>Iy(t,e,r,i),oI=nI,aI={FAILED_TO_RECEIVE_TXN:1,NO_TRACE_AVAILABLE:10,CONTRACT_NOT_FOUND:20,BLOCK_NOT_FOUND:24,INVALID_TXN_INDEX:27,CLASS_HASH_NOT_FOUND:28,TXN_HASH_NOT_FOUND:29,PAGE_SIZE_TOO_BIG:31,NO_BLOCKS:32,INVALID_CONTINUATION_TOKEN:33,TOO_MANY_KEYS_IN_FILTER:34,CONTRACT_ERROR:40,TRANSACTION_EXECUTION_ERROR:41,CLASS_ALREADY_DECLARED:51,INVALID_TRANSACTION_NONCE:52,INSUFFICIENT_MAX_FEE:53,INSUFFICIENT_ACCOUNT_BALANCE:54,VALIDATION_FAILURE:55,COMPILATION_FAILED:56,CONTRACT_CLASS_SIZE_IS_TOO_LARGE:57,NON_ACCOUNT:58,DUPLICATE_TX:59,COMPILED_CLASS_HASH_MISMATCH:60,UNSUPPORTED_TX_VERSION:61,UNSUPPORTED_CONTRACT_CLASS_VERSION:62,UNEXPECTED_ERROR:63};var sI=class extends Error{name;constructor(t){super(t),Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0}),function(t,e){const{setPrototypeOf:r}=Object;r?r(t,e):t.__proto__=e}(this,new.target.prototype),function(t,e=t.constructor){const{captureStackTrace:r}=Error;r&&r(t,e)}(this)}},hI=class extends sI{},uI=class extends hI{constructor(t,e,r){super(`RPC: ${e} with params ${nI(r,null,2)}\n\n ${t.code}: ${t.message}: ${nI(t.data)}`),this.baseError=t,this.request={method:e,params:r}}request;get code(){return this.baseError.code}isType(t){return aI[t]===this.code}};KS({},{BlockStatus:()=>pI,BlockTag:()=>gI,ETH_ADDRESS:()=>bI,EntryPointType:()=>lI,Literal:()=>vI,NON_ZERO_PREFIX:()=>kI,OutsideExecutionTypesV1:()=>MI,OutsideExecutionTypesV2:()=>_I,OutsideExecutionVersion:()=>EI,RPC:()=>WS,TransactionExecutionStatus:()=>mI,TransactionFinalityStatus:()=>fI,TransactionStatus:()=>dI,TransactionType:()=>cI,TypedDataRevision:()=>og,Uint:()=>wI,ValidateType:()=>yI});var lI={EXTERNAL:"EXTERNAL",L1_HANDLER:"L1_HANDLER",CONSTRUCTOR:"CONSTRUCTOR"},cI={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE_FUNCTION"},dI={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",REJECTED:"REJECTED",REVERTED:"REVERTED"},fI={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},mI={REJECTED:"REJECTED",REVERTED:"REVERTED",SUCCEEDED:"SUCCEEDED"},pI={PENDING:"PENDING",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",REJECTED:"REJECTED"},gI={PENDING:"pending",LATEST:"latest"},yI={DEPLOY:"DEPLOY",CALL:"CALL",INVOKE:"INVOKE"},wI={u8:"core::integer::u8",u16:"core::integer::u16",u32:"core::integer::u32",u64:"core::integer::u64",u128:"core::integer::u128",u256:"core::integer::u256",u512:"core::integer::u512"},vI={ClassHash:"core::starknet::class_hash::ClassHash",ContractAddress:"core::starknet::contract_address::ContractAddress",Secp256k1Point:"core::starknet::secp256k1::Secp256k1Point",U96:"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"},bI="core::starknet::eth_address::EthAddress",kI="core::zeroable::NonZero::",MI={StarkNetDomain:[{name:"name",type:"felt"},{name:"version",type:"felt"},{name:"chainId",type:"felt"}],OutsideExecution:[{name:"caller",type:"felt"},{name:"nonce",type:"felt"},{name:"execute_after",type:"felt"},{name:"execute_before",type:"felt"},{name:"calls_len",type:"felt"},{name:"calls",type:"OutsideCall*"}],OutsideCall:[{name:"to",type:"felt"},{name:"selector",type:"felt"},{name:"calldata_len",type:"felt"},{name:"calldata",type:"felt*"}]},_I={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],OutsideExecution:[{name:"Caller",type:"ContractAddress"},{name:"Nonce",type:"felt"},{name:"Execute After",type:"u128"},{name:"Execute Before",type:"u128"},{name:"Calls",type:"Call*"}],Call:[{name:"To",type:"ContractAddress"},{name:"Selector",type:"selector"},{name:"Calldata",type:"felt*"}]},EI=(t=>(t.UNSUPPORTED="0",t.V1="1",t.V2="2",t))(EI||{}),AI=class{nodeUrl;headers;interval;requestId=0;pendingRequests={};batchPromises={};delayTimer;delayPromise;delayPromiseResolve;baseFetch;constructor(t){this.nodeUrl=t.nodeUrl,this.headers=t.headers,this.interval=t.interval,this.baseFetch=t.baseFetch}async wait(){return this.delayPromise&&this.delayPromiseResolve||(this.delayPromise=new Promise((t=>{this.delayPromiseResolve=t}))),this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=void 0),this.delayTimer=setTimeout((()=>{this.delayPromiseResolve&&(this.delayPromiseResolve(),this.delayPromise=void 0,this.delayPromiseResolve=void 0)}),this.interval),this.delayPromise}addPendingRequest(t,e,r){const i={id:r??`batched_${this.requestId+=1}`,jsonrpc:"2.0",method:t,params:e??void 0};return this.pendingRequests[i.id]=i,i.id}async sendBatch(t){return(await this.baseFetch(this.nodeUrl,{method:"POST",body:nI(t),headers:this.headers})).json()}async fetch(t,e,r){const i=this.addPendingRequest(t,e,r);await this.wait();const n=this.pendingRequests;if(this.pendingRequests={},!this.batchPromises[i]){const t=this.sendBatch(Object.values(n));Object.keys(n).forEach((e=>{this.batchPromises[e]=t}))}const o=await this.batchPromises[i];delete this.batchPromises[i];const a=o.find((t=>t.id===i));if(!a)throw new Error(`Couldn't find the result for the request. Method: ${t}`);return a}};function jI(t,e){if(!t)throw new Error(e||"Assertion failure")}KS({},{addPercent:()=>WI,assertInRange:()=>FI,bigNumberishArrayToDecimalStringArray:()=>UI,bigNumberishArrayToHexadecimalStringArray:()=>qI,cleanHex:()=>LI,getDecimalString:()=>HI,getHexString:()=>GI,getHexStringArray:()=>ZI,hexToBytes:()=>JI,hexToDecimalString:()=>$I,isBigNumberish:()=>QI,isHex:()=>zI,isStringWholeNumber:()=>VI,stringToSha256ToArrayBuff4:()=>YI,toBigInt:()=>OI,toCairoBool:()=>KI,toHex:()=>RI,toHex64:()=>DI,toHexString:()=>PI,toStorageKey:()=>BI});var xI=t=>void 0===t||void 0===t;function SI(t){return"number"==typeof t}function NI(t){return"boolean"==typeof t}function II(t){return"bigint"==typeof t}function TI(t){return"string"==typeof t}function CI(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function zI(t){return/^0x[0-9a-f]*$/i.test(t)}function OI(t){return BigInt(t)}function RI(t){return bN(OI(t).toString(16))}var PI=RI;function BI(t){return bN(OI(t).toString(16).padStart(64,"0"))}function DI(t){const e=bN(OI(t).toString(16).padStart(64,"0"));if(66!==e.length)throw TypeError("number is too big for hex 0x(64) representation");return e}function $I(t){return BigInt(bN(t)).toString(10)}function LI(t){return t.toLowerCase().replace(/^(0x)0+/,"$1")}function FI(t,e,r,i=""){const n=""===i?"invalid length":`invalid ${i} length`,o=BigInt(t),a=BigInt(e),s=BigInt(r);jI(o>=a&&o<=s,`Message not signable, ${n}.`)}function UI(t){return t.map((t=>OI(t).toString(10)))}function qI(t){return t.map((t=>RI(t)))}function VI(t){return/^\d+$/.test(t)}function HI(t){if(zI(t))return $I(t);if(VI(t))return t;throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function GI(t){if(zI(t))return t;if(VI(t))return PI(t);throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function ZI(t){return t.map(GI)}function KI(t){return(+t).toString()}function JI(t){if(!zI(t))throw new Error(`${t} needs to be a hex-string`);let e=vN(t);return e.length%2!=0&&(e=`0${e}`),Ky(e)}function WI(t,e){const r=BigInt(t);return r+r*BigInt(e)/100n}function YI(t){var e;return JI(RI((e=BigInt(bN(wN(zw(t)))),Number(e&IN))))}function QI(t){return SI(t)||II(t)||TI(t)&&(zI(t)||VI(t))}function XI(t){const e=vN(RI(BigInt(t))),r=e.length%2==0?e:`0${e}`;return bN(Fb(JI(bN(r))).toString(16))}function tT(t){const e=BigInt(function(t){return bN(Fb(mN(t)).toString(16))}(t));return e&NN}function eT(t){return RI(tT(t))}function rT(t){return SI(t)||II(t)?RI(t):zI(t)?t:VI(t)?RI(t):eT(t)}function iT(t){const e=bN(t.reduce(((t,e)=>t+vN(RI(e)).padStart(64,"0")),""));return bN(Dy(pk(JI(e))))}function nT(t,e,r,i,n){return iT([t,e,n,r,i.length,...i])}KS({},{getL2MessageHash:()=>nT,getSelector:()=>rT,getSelectorFromName:()=>eT,keccakBn:()=>XI,solidityUint256PackedKeccak256:()=>iT,starknetKeccak:()=>tT});function oT(t){return/^[\x00-\x7F]*$/.test(t)}function aT(t){return t.length<=xN}function sT(t){return/^[0-9]*$/i.test(t)}function hT(t){return TI(t)&&!zI(t)&&!VI(t)}KS({},{decodeShortString:()=>fT,encodeShortString:()=>dT,isASCII:()=>oT,isDecimalString:()=>sT,isLongText:()=>lT,isShortString:()=>aT,isShortText:()=>uT,isText:()=>hT,splitLongString:()=>cT});var uT=t=>hT(t)&&aT(t),lT=t=>hT(t)&&!aT(t);function cT(t){const e=RegExp(`[^]{1,${xN}}`,"g");return t.match(e)||[]}function dT(t){if(!oT(t))throw new Error(`${t} is not an ASCII string`);if(!aT(t))throw new Error(`${t} is too long`);return bN(t.replace(/./g,(t=>t.charCodeAt(0).toString(16))))}function fT(t){if(!oT(t))throw new Error(`${t} is not an ASCII string`);if(zI(t))return vN(t).replace(/.{2}/g,(t=>String.fromCharCode(parseInt(t,16))));if(sT(t))return fT("0X".concat(BigInt(t).toString(16)));throw new Error(`${t} is not Hex or decimal`)}function mT(t){const e=0n===BigInt(t.pending_word)?"":fT(RI(t.pending_word));return t.data.reduce(((t,e)=>t+(0n===BigInt(e)?"":fT(RI(e)))),"")+e}function pT(t){const e=cT(t),r=e[e.length-1],i=e.map(dT),[n,o]=void 0===r||31===r.length?["0x00",0]:[i.pop(),r.length];return{data:0===i.length?[]:i,pending_word:n,pending_word_len:o}}KS({},{byteArrayFromString:()=>pT,stringFromByteArray:()=>mT});var gT={};function yT(t){if(II(t)||Number.isInteger(t))return t.toString();if(TI(t)){if(zI(t))return BigInt(t).toString();if(hT(t)){if(!aT(t))throw new Error(`${t} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt(dT(t)).toString()}if(VI(t))return t}if(NI(t))return""+ +t;throw new Error(`${t} can't be computed by felt()`)}KS(gT,{felt:()=>iC,getAbiContractVersion:()=>XT,getArrayType:()=>WT,isCairo1Abi:()=>YT,isCairo1Type:()=>JT,isLen:()=>IT,isTypeArray:()=>CT,isTypeBool:()=>UT,isTypeByteArray:()=>GT,isTypeBytes31:()=>HT,isTypeContractAddress:()=>qT,isTypeEnum:()=>PT,isTypeEthAddress:()=>VT,isTypeFelt:()=>TT,isTypeLiteral:()=>FT,isTypeNamedTuple:()=>OT,isTypeNonZero:()=>QT,isTypeOption:()=>BT,isTypeResult:()=>DT,isTypeSecp256k1Point:()=>KT,isTypeStruct:()=>RT,isTypeTuple:()=>zT,isTypeU96:()=>ZT,isTypeUint:()=>$T,isTypeUint256:()=>LT,tuple:()=>rC,uint256:()=>tC,uint512:()=>eC});var wT=(1n<<128n)-1n,vT=(1n<<256n)-1n,bT=0n,kT=340282366920938463463374607431768211455n,MT=340282366920938463463374607431768211455n,_T=0n,ET=0n,AT=class t{low;high;static abiSelector="core::integer::u256";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"low"in e[0]&&"high"in e[0]){const r=t.validateProps(e[0].low,e[0].high);this.low=r.low,this.high=r.high}else if(1===e.length){const r=t.validate(e[0]);this.low=r&wT,this.high=r>>128n}else{if(2!==e.length)throw Error("Incorrect constructor parameters");{const r=t.validateProps(e[0],e[1]);this.low=r.low,this.high=r.high}}}static validate(t){const e=BigInt(t);if(e<bT)throw Error("bigNumberish is smaller than UINT_256_MIN");if(e>vT)throw new Error("bigNumberish is bigger than UINT_256_MAX");return e}static validateProps(t,e){const r=BigInt(t),i=BigInt(e);if(r<_T||r>kT)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(i<ET||i>MT)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:r,high:i}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:bN(this.low.toString(16)),high:bN(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[yT(this.low),yT(this.high)]}},jT=(1n<<512n)-1n,xT=0n,ST=0n,NT=class t{limb0;limb1;limb2;limb3;static abiSelector="core::integer::u512";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const r=t.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}else if(1===e.length){const r=t.validate(e[0]);this.limb0=r&wT,this.limb1=(r&wT<<128n)>>128n,this.limb2=(r&wT<<256n)>>256n,this.limb3=r>>384n}else{if(4!==e.length)throw Error("Incorrect Uint512 constructor parameters");{const r=t.validateProps(e[0],e[1],e[2],e[3]);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}}}static validate(t){const e=BigInt(t);if(e<xT)throw Error("bigNumberish is smaller than UINT_512_MIN.");if(e>jT)throw Error("bigNumberish is bigger than UINT_512_MAX.");return e}static validateProps(t,e,r,i){const n=BigInt(t),o=BigInt(e),a=BigInt(r),s=BigInt(i);return[n,o,a,s].forEach(((t,e)=>{if(t<ST||t>wT)throw Error(`limb${e} is not in the range of a u128 number`)})),{limb0:n,limb1:o,limb2:a,limb3:s}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:bN(this.limb0.toString(16)),limb1:bN(this.limb1.toString(16)),limb2:bN(this.limb2.toString(16)),limb3:bN(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[yT(this.limb0),yT(this.limb1),yT(this.limb2),yT(this.limb3)]}},IT=t=>/_len$/.test(t),TT=t=>"felt"===t||"core::felt252"===t,CT=t=>/\*/.test(t)||t.startsWith("core::array::Array::")||t.startsWith("core::array::Span::"),zT=t=>/^\(.*\)$/i.test(t),OT=t=>/\(.*\)/i.test(t)&&t.includes(":"),RT=(t,e)=>t in e,PT=(t,e)=>t in e,BT=t=>t.startsWith("core::option::Option::"),DT=t=>t.startsWith("core::result::Result::"),$T=t=>Object.values(wI).includes(t),LT=t=>AT.isAbiType(t),FT=t=>Object.values(vI).includes(t),UT=t=>"core::bool"===t,qT=t=>t===vI.ContractAddress,VT=t=>t===bI,HT=t=>"core::bytes_31::bytes31"===t,GT=t=>"core::byte_array::ByteArray"===t,ZT=t=>"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"===t,KT=t=>t===vI.Secp256k1Point,JT=t=>t.includes("::"),WT=t=>JT(t)?t.substring(t.indexOf("<")+1,t.lastIndexOf(">")):t.replace("*","");function YT(t){const{cairo:e}=XT(t);if(void 0===e)throw Error("Unable to determine Cairo version");return"1"===e}function QT(t){return t.startsWith(kI)}function XT(t){if(t.find((t=>"interface"===t.type)))return{cairo:"1",compiler:"2"};const e=t.find((t=>("function"===t.type||"constructor"===t.type)&&(t.inputs.length||t.outputs.length)));if(!e)return{cairo:void 0,compiler:void 0};const r=e.inputs.length?e.inputs:e.outputs;return JT(r[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}var tC=t=>new AT(t).toUint256DecimalString(),eC=t=>new NT(t).toUint512DecimalString(),rC=(...t)=>({...t});function iC(t){return yT(t)}var nC=class{variant;constructor(t){const e=Object.values(t);if(0===e.length)throw new Error("This Enum must have at least 1 variant");if(1!==e.filter((t=>!xI(t))).length)throw new Error("This Enum must have exactly one active variant");this.variant=t}unwrap(){return Object.values(this.variant).find((t=>!xI(t)))}activeVariant(){const t=Object.entries(this.variant).find((t=>!xI(t[1])));return xI(t)?"":t[0]}},oC={Some:0,None:1},aC=class{Some;None;constructor(t,e){if(!(t in Object.values(oC)))throw new Error("Wrong variant! It should be CairoOptionVariant.Some or .None.");if(t===oC.Some){if(xI(e))throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=e,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){return this.None?void 0:this.Some}isSome(){return!xI(this.Some)}isNone(){return!0===this.None}},sC={Ok:0,Err:1},hC=class{Ok;Err;constructor(t,e){if(!(t in Object.values(sC)))throw new Error("Wrong variant! It should be CairoResultVariant.Ok or .Err.");t===sC.Ok?(this.Ok=e,this.Err=void 0):(this.Ok=void 0,this.Err=e)}unwrap(){if(!xI(this.Ok))return this.Ok;if(!xI(this.Err))return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!xI(this.Ok)}isErr(){return!xI(this.Err)}},uC=(t,e,r)=>{if(!II(t[r]))throw new Error(`Data and formatter mismatch on ${r}:${e[r]}, expected response data ${r}:${t[r]} to be BN instead it is ${typeof t[r]}`)},lC=(t,e,r)=>{throw new Error(`Unhandled formatter type on ${r}:${e[r]} for data ${r}:${t[r]}`)};function cC(t,e,r){return Object.entries(t).reduce(((i,[n,o])=>{const a=r??e[n];if(!(n in e)&&!r)return i[n]=o,i;if("string"===a){if(Array.isArray(t[n])){const e=cC(t[n],t[n].map((t=>a)));return i[n]=Object.values(e).join(""),i}return uC(t,e,n),i[n]=fT(o),i}if("number"===a)return uC(t,e,n),i[n]=Number(o),i;if("function"==typeof a)return i[n]=a(o),i;if(Array.isArray(a)){const e=cC(t[n],a,a[0]);return i[n]=Object.values(e),i}return CI(a)?(i[n]=cC(t[n],a),i):(lC(t,e,n),i)}),{})}function dC(t){const e=function(t){return t.find((t=>"interface"===t.type))?2:YT(t)?1:0}(t);if(0===e||1===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.reduce(((t,e)=>IT(e.name)?t:t+1),0)}getMethod(t){return this.abi.find((e=>e.name===t))}getLegacyFormat(){return this.abi}}(t);if(2===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.length}getMethod(t){return this.abi.find((t=>"interface"===t.type))?.items?.find((e=>e.name===t))}getLegacyFormat(){return this.abi.flatMap((t=>"interface"===t.type?t.items:t))}}(t);throw Error(`Unsupported ABI version ${e}`)}function fC(t,e,r){return"constructor"===t&&!r&&!e.length}function mC(t,e,r){for(let i=0,n=0;i<t.length;i++)if(t[i]===e)n++;else if(t[i]===r&&0==--n)return i;return Number.POSITIVE_INFINITY}function pC(t){return JT(t)?function(t){const e=t.slice(1,-1),r=[];let i,n=0;for(;n<e.length;){switch(!0){case"("===e[n]:i=n+mC(e.slice(n),"(",")")+1;break;case e.startsWith("core::result::Result::<",n)||e.startsWith("core::array::Array::<",n)||e.startsWith("core::option::Option::<",n):i=n+mC(e.slice(n),"<",">")+1;break;default:{const t=e.indexOf(",",n);i=-1!==t?t:Number.POSITIVE_INFINITY}}r.push(e.slice(n,i)),n=i+2}return r}(t):function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:i}=function(t){if(!t.includes("("))return{subTuple:[],result:t};const e=[];let r="",i=0;for(;i<t.length;){if("("===t[i]){let n=1;const o=i;for(i++;n;)")"===t[i]&&n--,"("===t[i]&&n++,i++;e.push(t.substring(o,i)),r+=" ",i--}else r+=t[i];i++}return{subTuple:e,result:r}}(e);let n=i.split(",").map((t=>r.length?t.replace(" ",r.shift()):t));return OT(t)&&(n=n.reduce(((t,e)=>t.concat(function(t){const e=t.substring(0,t.indexOf(":"));return{name:e,type:t.substring(e.length+":".length)}}(e))),[])),n}(t)}var gC=class t{content;arrayType;constructor(e,r){jI(t.isTypeFixedArray(r),`The type ${r} is not a Cairo fixed array. Needs [type; length].`);try{t.getFixedArrayType(r)}catch{throw new Error(`The type ${r} do not includes any content type. Needs [type; length].`)}try{t.getFixedArraySize(r)}catch{throw new Error(`The type ${r} type do not includes any length. Needs [type; length].`)}jI(t.getFixedArraySize(r)===e.length,`The ABI type ${r} is expecting ${t.getFixedArraySize(r)} items. ${e.length} items provided.`),this.content=e,this.arrayType=r}static getFixedArraySize(t){const e=t.match(/(?<=; )\d+(?=\])/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid number after ';' character.`);return Number(e[0])}getFixedArraySize(){return t.getFixedArraySize(this.arrayType)}static getFixedArrayType=t=>{const e=t.match(/(?<=\[).+(?=;)/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid type of data.`);return e[0]};getFixedArrayType(){return t.getFixedArrayType(this.arrayType)}static compile(t){return t.reduce(((t,e,r)=>(t[r]=e,t)),{})}compile(){return t.compile(this.content)}static isTypeFixedArray(t){return/^\[.*;\s.*\]$/.test(t)&&/(?<=\[).+(?=;)/.test(t)&&/(?<=; )\d+(?=\])/.test(t)}};function yC(t,e,r,i){const n=(t,e)=>{if(gC.isTypeFixedArray(e))return function(t,e){const r=gC.getFixedArrayType(e),i=gC.getFixedArraySize(e);if(Array.isArray(t)){if(i!==t.length)throw new Error(`ABI type ${e}: array provided do not includes ${i} items. ${t.length} items provided.`);return t.map((t=>n(t,r)))}if(i!==Object.keys(t).length)throw new Error(`ABI type ${e}: object provided do not includes ${i} properties. ${Object.keys(t).length} items provided.`);return n(t,r)}(t,e);if(CT(e))return function(t,e){const r=WT(e);if(TI(t))return t;return t.map((t=>n(t,r)))}(t,e);if(PT(e,i)){const r=i[e];return a(t,r)}if(zT(e))return function(t,e){const r=pC(e).reduce(((e,r,i)=>{const o=Object.keys(t),a=r=>Object.defineProperty(e,i.toString(),{enumerable:!0,value:r??t[o[i]]}),s=r?.type?r.type:r;return a(n(t[o[i]],s)),e}),{});return r}(t,e);if(VT(e))return t;if(QT(e))return t;if(GT(e))return t;if(ZT(e))return t;if(KT(e))return t;if(AT.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!("low"in r)||!("high"in r))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`)}(e);return{low:r.low,high:r.high}}if(NT.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!["limb0","limb1","limb2","limb3"].every((t=>t in r)))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}(e);return{limb0:r.limb0,limb1:r.limb1,limb2:r.limb2,limb3:r.limb3}}if(RT(e,r)){const i=r[e].members;return o(t,i)}return t},o=(t,e)=>e.reduce(((e,r)=>{if("undefined"===t[r.name]&&(JT(r.type)||!IT(r.name)))throw Error(`Your object needs a property with key : ${r.name} .`);var i;return i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i??t[r.name]}),e}),{});const a=(t,e)=>{if(DT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(",")),o=e.name.substring(e.name.indexOf(",")+1,e.name.lastIndexOf(">"));return r.isOk()?new hC(sC.Ok,n(t.unwrap(),i)):new hC(sC.Err,n(t.unwrap(),o))}if(BT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(">"));return r.isSome()?new aC(oC.Some,n(r.unwrap(),i)):new aC(oC.None,{})}const r=t,i=Object.entries(r.variant).map((t=>{if(xI(t[1]))return t;const i=e.type.substring(e.type.lastIndexOf("<")+1,e.type.lastIndexOf(">"));return"()"===i?t:[t[0],n(r.unwrap(),i)]}));return new nC(Object.fromEntries(i))};return e.reduce(((e,r)=>{return IT(r.name)&&!JT(r.type)||(i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i})),e;var i}),{})}function wC(t,e){switch(!0){case AT.isAbiType(t):return new AT(e).toApiRequest();case NT.isAbiType(t):return new NT(e).toApiRequest();case HT(t):return dT(e.toString());case KT(t):{const t=vN(RI(e)).padStart(128,"0"),r=tC(bN(t.slice(-64))),i=tC(bN(t.slice(0,-64)));return[iC(i.low),iC(i.high),iC(r.low),iC(r.high)]}default:return iC(e)}}function vC(t,e,r,i){if(void 0===t)throw Error(`Missing parameter for type ${e}`);if(gC.isTypeFixedArray(e)){const n=gC.getFixedArrayType(e);let o=[];if(Array.isArray(t)){o=new gC(t,e).content}else{if("object"!=typeof t)throw new Error(`ABI type ${e}: not an Array representing a cairo.fixedArray() provided.`);o=Object.values(t),jI(o.length===gC.getFixedArraySize(e),`ABI type ${e}: object provided do not includes ${gC.getFixedArraySize(e)} items. ${o.length} items provided.`)}return o.reduce(((t,e)=>t.concat(vC(e,n,r,i))),[])}if(Array.isArray(t)){const n=[];n.push(iC(t.length));const o=WT(e);return t.reduce(((t,e)=>t.concat(vC(e,o,r,i))),n)}if(r[e]&&r[e].members.length){if(AT.isAbiType(e))return new AT(t).toApiRequest();if(NT.isAbiType(e))return new NT(t).toApiRequest();if(VT(e))return wC(e,t);if(GT(e))return function(t){const e=pT(t);return[e.data.length.toString(),...e.data.map((t=>t.toString())),e.pending_word.toString(),e.pending_word_len.toString()]}(t);const{members:n}=r[e],o=t;return n.reduce(((t,e)=>t.concat(vC(o[e.name],e.type,r,i))),[])}if(zT(e)){const n=function(t,e){const r=pC(e),i=Object.values(t);if(i.length!==r.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${i}\n expected: ${r}`);return r.map(((t,e)=>({element:i[e],type:t.type??t})))}(t,e);return n.reduce(((t,e)=>{const n=vC(e.element,e.type,r,i);return t.concat(n)}),[])}if(AT.isAbiType(e))return new AT(t).toApiRequest();if(NT.isAbiType(e))return new NT(t).toApiRequest();if(PT(e,i)){const{variants:n}=i[e];if(BT(e)){const e=t;if(e.isSome()){const t=n.find((t=>"Some"===t.name));if(xI(t))throw Error("Error in abi : Option has no 'Some' variant.");const o=t.type;if("()"===o)return oC.Some.toString();const a=vC(e.unwrap(),o,r,i);return Array.isArray(a)?[oC.Some.toString(),...a]:[oC.Some.toString(),a]}return oC.None.toString()}if(DT(e)){const e=t;if(e.isOk()){const t=n.find((t=>"Ok"===t.name));if(xI(t))throw Error("Error in abi : Result has no 'Ok' variant.");const o=t.type;if("()"===o)return sC.Ok.toString();const a=vC(e.unwrap(),o,r,i);return Array.isArray(a)?[sC.Ok.toString(),...a]:[sC.Ok.toString(),a]}const o=n.find((t=>"Err"===t.name));if(xI(o))throw Error("Error in abi : Result has no 'Err' variant.");const a=o.type;if("()"===a)return sC.Err.toString();const s=vC(e.unwrap(),a,r,i);return Array.isArray(s)?[sC.Err.toString(),...s]:[sC.Err.toString(),s]}const o=t,a=o.activeVariant(),s=n.find((t=>t.name===a));if(xI(s))throw Error(`Not find in abi : Enum has no '${a}' variant.`);const h=s.type,u=n.findIndex((t=>t.name===a));if("()"===h)return u.toString();const l=vC(o.unwrap(),h,r,i);return Array.isArray(l)?[u.toString(),...l]:[u.toString(),l]}if(QT(e))return wC(WT(e),t);if("object"==typeof t)throw Error(`Parameter ${t} do not align with abi parameter ${e}`);return wC(e,t)}function bC(t,e){let r;switch(!0){case UT(t):return r=e.next().value,Boolean(BigInt(r));case AT.isAbiType(t):const i=e.next().value,n=e.next().value;return new AT(i,n).toBigInt();case NT.isAbiType(t):const o=e.next().value,a=e.next().value,s=e.next().value,h=e.next().value;return new NT(o,a,s,h).toBigInt();case VT(t):return r=e.next().value,BigInt(r);case HT(t):return r=e.next().value,fT(r);case KT(t):const u=vN(e.next().value).padStart(32,"0"),l=vN(e.next().value).padStart(32,"0"),c=vN(e.next().value).padStart(32,"0"),d=vN(e.next().value).padStart(32,"0");return BigInt(bN(l+u+d+c));default:return r=e.next().value,BigInt(r)}}function kC(t,e,r,i){if("()"===e.type)return{};if(AT.isAbiType(e.type)){const e=t.next().value,r=t.next().value;return new AT(e,r).toBigInt()}if(NT.isAbiType(e.type)){const e=t.next().value,r=t.next().value,i=t.next().value,n=t.next().value;return new NT(e,r,i,n).toBigInt()}if(GT(e.type)){const e=[],r=BigInt(t.next().value);for(;e.length<r;)e.push(RI(t.next().value));return mT({data:e,pending_word:RI(t.next().value),pending_word_len:BigInt(t.next().value)})}if(gC.isTypeFixedArray(e.type)){const n=[],o={name:"",type:gC.getFixedArrayType(e.type)},a=gC.getFixedArraySize(e.type);for(;n.length<a;)n.push(kC(t,o,r,i));return n}if(CT(e.type)){const n=[],o={name:"",type:WT(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(kC(t,o,r,i));return n}if(QT(e.type)){const n={name:"",type:WT(e.type)};return kC(t,n,r,i)}if(r&&e.type in r&&r[e.type])return VT(e.type)?bC(e.type,t):r[e.type].members.reduce(((e,n)=>(e[n.name]=kC(t,n,r,i),e)),{});if(i&&e.type in i&&i[e.type]){const n=Number(t.next().value),o=i[e.type].variants.reduce(((e,o,a)=>a===n?(e[o.name]=kC(t,{name:"",type:o.type},r,i),e):(e[o.name]=void 0,e)),{});if(e.type.startsWith("core::option::Option")){const t=n===oC.Some?o.Some:void 0;return new aC(n,t)}if(e.type.startsWith("core::result::Result")){let t;return t=n===sC.Ok?o.Ok:o.Err,new hC(n,t)}return new nC(o)}if(zT(e.type)){return pC(e.type).reduce(((e,n,o)=>{const a=n?.name?n.name:o,s={name:a,type:n?.type?n.type:n};return e[a]=kC(t,s,r,i),e}),{})}if(CT(e.type)){const n=[],o={name:"",type:WT(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(kC(t,o,r,i));return n}return bC(e.type,t)}function MC(t,e,r,i,n){const{name:o,type:a}=e;let s;switch(!0){case IT(o):return s=t.next().value,BigInt(s);case r&&a in r||zT(a):case i&&PT(a,i):case gC.isTypeFixedArray(a):return kC(t,e,r,i);case CT(a):if(JT(a))return kC(t,e,r,i);const h=[];if(n&&n[`${o}_len`]){const a=n[`${o}_len`];for(;h.length<a;)h.push(kC(t,{name:o,type:e.type.replace("*","")},r,i))}return h;case QT(a):return kC(t,e,r,i);default:return bC(a,t)}}var _C=(t,e)=>{if(jI(TI(t)||SI(t)||II(t),`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),TI(t)&&!zI(t))return;const r=BigInt(t.toString(10));jI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},EC=(t,e)=>{let r;switch(SI(t)&&jI(t<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is too large to be typed as Number use (BigInt or String)"),jI(TI(t)||SI(t)||II(t)||CI(t)&&"low"in t&&"high"in t||CI(t)&&["limb0","limb1","limb2","limb3"].every((e=>e in t)),`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof t} ${t}.`),e.type){case wI.u256:r=new AT(t).toBigInt();break;case wI.u512:r=new NT(t).toBigInt();break;default:r=OI(t)}switch(e.type){case wI.u8:jI(r>=0n&&r<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case wI.u16:jI(r>=0n&&r<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case wI.u32:jI(r>=0n&&r<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case wI.u64:jI(r>=0n&&r<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case wI.u128:jI(r>=0n&&r<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case wI.u256:jI(r>=0n&&r<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^256-1`);break;case wI.u512:jI(NT.is(r),`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^512-1`);break;case vI.ClassHash:case vI.ContractAddress:jI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case vI.Secp256k1Point:jI(r>=0n&&r<=2n**512n-1n,`Validate: arg ${e.name} must be ${e.type} : a 512 bits number.`);break;case vI.U96:jI(r>=0n&&r<=2n**96n-1n,`Validate: arg ${e.name} must be ${e.type} : a 96 bits number.`)}},AC=(t,e)=>{jI(NI(t),`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},jC=(t,e,r)=>{if(e.type!==wI.u256&&e.type!==wI.u512)if(VT(e.type)){jI(!CI(t),`EthAddress type is waiting a BigNumberish. Got "${t}"`);const r=BigInt(t.toString(10));jI(r>=0n&&r<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`)}else jI(CI(t),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as a js object (not array)`),r[e.type].members.forEach((({name:r})=>{jI(Object.keys(t).includes(r),`Validate: arg ${e.name} should have a property ${r}`)}));else EC(t,e)},xC=(t,e)=>{jI(CI(t),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as a js object (not array)`);const r=Object.getOwnPropertyNames(Object.getPrototypeOf(t)),i=[...Object.getOwnPropertyNames(t),...r];if(!(BT(e.type)&&i.includes("isSome")&&i.includes("isNone")||DT(e.type)&&i.includes("isOk")&&i.includes("isErr")||i.includes("variant")&&i.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received "${t}", is not an Enum.`)},SC=(t,e)=>{jI(CI(t),`Validate: arg ${e.name} should be a tuple (defined as object)`)},NC=(t,e,r,i)=>{const n=CT(e.type),o=n?WT(e.type):gC.getFixedArrayType(e.type);if(n&&TT(o)&&lT(t))return;let a=[];if(n)jI(Array.isArray(t),`Validate: arg ${e.name} should be an Array`),a=t;else switch(!0){case Array.isArray(t):a=t;break;case"object"==typeof t:a=Object.values(t);break;default:throw new Error(`Validate: arg ${e.name} should be an Array or an object.`)}switch(!0){case TT(o):a.forEach((t=>_C(t,e)));break;case zT(o):a.forEach((t=>SC(t,{name:e.name,type:o})));break;case CT(o):a.forEach((t=>NC(t,{name:"",type:o},r,i)));break;case RT(o,r):a.forEach((t=>jC(t,{name:e.name,type:o},r)));break;case PT(o,i):a.forEach((t=>xC(t,{name:e.name,type:o})));break;case $T(o)||FT(o):a.forEach((t=>EC(t,{name:"",type:o})));break;case UT(o):a.forEach((t=>AC(t,e)));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${a}`)}};function IC(t,e,r,i){t.inputs.reduce(((t,n)=>{const o=e[t];switch(!0){case IT(n.name):return t;case TT(n.type):_C(o,n);break;case HT(n.type):((t,e)=>{jI(TI(t),`Validate: arg ${e.name} should be a string.`),jI(t.length<32,`Validate: arg ${e.name} cairo typed ${e.type} should be a string of less than 32 characters.`)})(o,n);break;case $T(n.type)||FT(n.type):EC(o,n);break;case UT(n.type):AC(o,n);break;case GT(n.type):((t,e)=>{jI(TI(t),`Validate: arg ${e.name} should be a string.`)})(o,n);break;case CT(n.type)||gC.isTypeFixedArray(n.type):NC(o,n,r,i);break;case RT(n.type,r):jC(o,n,r);break;case PT(n.type,i):xC(o,n);break;case zT(n.type):SC(o,n);break;case QT(n.type):((t,e)=>{const r=WT(e.type);switch(jI($T(r)&&r!==NT.abiSelector||TT(r),`Validate: ${e.name} type is not authorized for NonZero type.`),!0){case TT(r):_C(t,e),jI(BigInt(t.toString(10))>0,"Validate: value 0 is not authorized in NonZero felt252 type.");break;case $T(r):EC(t,{name:"",type:r}),r===wI.u256?jI(new AT(t).toBigInt()>0,"Validate: value 0 is not authorized in NonZero uint256 type."):jI(OI(t)>0,"Validate: value 0 is not authorized in NonZero uint type.");break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value "${t}"`)}})(o,n);break;default:throw new Error(`Validate Unhandled: argument ${n.name}, type ${n.type}, value ${o}`)}return t+1}),0)}var TC=class t{abi;parser;structs;enums;constructor(e){this.structs=t.getAbiStruct(e),this.enums=t.getAbiEnum(e),this.parser=dC(e),this.abi=this.parser.getLegacyFormat()}validate(t,e,r=[]){if(t!==yI.DEPLOY){jI(this.abi.filter((e=>{if("function"!==e.type)return!1;const r="view"===e.stateMutability||"view"===e.state_mutability;return t===yI.INVOKE?!r:r})).map((t=>t.name)).includes(e),(t===yI.INVOKE?"invocable":"viewable")+" method not found in abi")}const i=this.abi.find((r=>t===yI.DEPLOY?r.name===e&&"constructor"===r.type:r.name===e&&"function"===r.type));if(fC(e,r,i))return;const n=this.parser.methodInputsLength(i);if(r.length!==n)throw Error(`Invalid number of arguments, expected ${n} arguments, but got ${r.length}`);IC(i,r,this.structs,this.enums)}compile(t,e){const r=this.abi.find((e=>e.name===t));if(fC(t,e,r))return[];let i;if(Array.isArray(e))i=e;else{const t=yC(e,r.inputs,this.structs,this.enums);i=Object.values(t),IC(r,i,this.structs,this.enums)}const n=i[Symbol.iterator](),o=r.inputs.reduce(((t,e)=>IT(e.name)&&!JT(e.type)?t:t.concat(function(t,e,r,i){const{name:n,type:o}=e;let{value:a}=t.next();switch(!0){case gC.isTypeFixedArray(o):if(!Array.isArray(a)&&"object"!=typeof a)throw Error(`ABI expected parameter ${n} to be an array or an object, got ${a}`);return vC(a,e.type,r,i);case CT(o):if(!Array.isArray(a)&&!hT(a))throw Error(`ABI expected parameter ${n} to be array or long string, got ${a}`);return TI(a)&&(a=cT(a)),vC(a,e.type,r,i);case QT(o):return wC(WT(o),a);case VT(o):return wC(o,a);case RT(o,r)||zT(o)||AT.isAbiType(o):case PT(o,i):return vC(a,o,r,i);default:return wC(o,a)}}(n,e,this.structs,this.enums))),[]);return Object.defineProperty(o,"__compiled__",{enumerable:!1,writable:!1,value:!0}),o}static compile(t){const e=t=>{const e=(t,r=".")=>{const i=Array.isArray(t)?[t.length.toString(),...t]:t;return Object.entries(i).flatMap((([t,n])=>{let o=n;"entrypoint"===t?o=eT(o):lT(o)&&(o=pT(o));const a=Array.isArray(i)&&"0"===t?"$$len":t;if(II(o))return[[`${r}${a}`,iC(o)]];if(Object(o)===o){const t=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),i=[...Object.getOwnPropertyNames(o),...t];if(i.includes("isSome")&&i.includes("isNone")){const t=o,i=t.isSome()?oC.Some:oC.None;return t.isSome()?e({0:i,1:t.unwrap()},`${r}${a}.`):[[`${r}${a}`,iC(i)]]}if(i.includes("isOk")&&i.includes("isErr")){const t=o,i=t.isOk()?sC.Ok:sC.Err;return e({0:i,1:t.unwrap()},`${r}${a}.`)}if(i.includes("variant")&&i.includes("activeVariant")){const t=o,i=t.activeVariant(),n=Object.keys(t.variant).findIndex((t=>t===i));return"object"==typeof t.unwrap()&&0===Object.keys(t.unwrap()).length?[[`${r}${a}`,iC(n)]]:e({0:n,1:t.unwrap()},`${r}${a}.`)}return e(o,`${r}${a}.`)}return[[`${r}${a}`,iC(o)]]}))};return Object.fromEntries(e(t))};let r;if(Array.isArray(t)){const i=e({...t});r=Object.values(i)}else{const i=e(t);r=Object.values(i)}return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}parse(t,e){const{outputs:r}=this.abi.find((e=>e.name===t)),i=e.flat()[Symbol.iterator](),n=r.flat().reduce(((t,e,r)=>{const n=e.name??r;return t[n]=MC(i,e,this.structs,this.enums,t),t[n]&&t[`${n}_len`]&&delete t[`${n}_len`],t}),{});return 1===Object.keys(n).length&&0 in n?n[0]:n}format(t,e,r){return cC(this.parse(t,e),r)}static getAbiStruct(t){return t.filter((t=>"struct"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{})}static getAbiEnum(t){const e=t.filter((t=>"enum"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{});return delete e["core::bool"],e}static toCalldata(e=[]){return t.compile(e)}static toHex(e=[]){return t.compile(e).map((t=>RI(t)))}decodeParameters(t,e){const r=Array.isArray(t)?t:[t],i=e.flat()[Symbol.iterator](),n=r.map((t=>MC(i,{name:"",type:t},this.structs,this.enums)));return 1===n.length?n[0]:n}};KS({},{calculateContractAddressFromHash:()=>az,calculateDeclareTransactionHash:()=>XC,calculateDeployAccountTransactionHash:()=>tz,calculateInvokeTransactionHash:()=>QC,calculateL2MessageTxHash:()=>BC,computeCompiledClassHash:()=>fz,computeContractClassHash:()=>gz,computeHashOnElements:()=>iz,computeHintedClassHash:()=>uz,computeLegacyContractClassHash:()=>lz,computePedersenHash:()=>ez,computePedersenHashOnElements:()=>nz,computePoseidonHash:()=>rz,computePoseidonHashOnElements:()=>oz,computeSierraContractClassHash:()=>pz,formatSpaces:()=>hz,getL2MessageHash:()=>nT,getSelector:()=>rT,getSelectorFromName:()=>eT,hashByteCodeSegments:()=>dz,keccakBn:()=>XI,poseidon:()=>$v,solidityUint256PackedKeccak256:()=>iT,starknetKeccak:()=>tT});KS({},{calculateDeclareTransactionHash:()=>OC,calculateDeployAccountTransactionHash:()=>RC,calculateL2MessageTxHash:()=>BC,calculateTransactionHash:()=>PC,calculateTransactionHashCommon:()=>zC,computeHashOnElements:()=>CC});function CC(t){return[...t,t.length].reduce(((t,e)=>$b(OI(t),OI(e))),0).toString()}function zC(t,e,r,i,n,o,a,s=[]){const h=CC(n);return CC([t,e,r,i,h,o,a,...s])}function OC(t,e,r,i,n,o,a){return zC("0x6465636c617265",r,e,0,[t],i,n,[o,...a?[a]:[]])}function RC(t,e,r,i,n,o,a,s){return zC("0x6465706c6f795f6163636f756e74",n,t,0,[e,i,...r],o,a,[s])}function PC(t,e,r,i,n,o){return zC("0x696e766f6b65",e,t,0,r,i,n,[o])}function BC(t,e,r,i,n,o){const a=[t,...i];return zC("0x6c315f68616e646c6572",0,e,rT(r),a,0,n,[o])}KS({},{starkCurve:()=>Wb,weierstrass:()=>hb});KS({},{calculateDeclareTransactionHash:()=>WC,calculateDeployAccountTransactionHash:()=>JC,calculateInvokeTransactionHash:()=>YC,calculateTransactionHashCommon:()=>KC,encodeResourceBoundsL1:()=>HC,encodeResourceBoundsL2:()=>GC,hashDAMode:()=>VC,hashFeeField:()=>ZC});var DC=t=>t.map((t=>BigInt(t))),$C=32n,LC=128n,FC=64n+LC,UC=BigInt(dT("L1_GAS")),qC=BigInt(dT("L2_GAS"));function VC(t,e){return(BigInt(t)<<$C)+BigInt(e)}function HC(t){return(UC<<FC)+(BigInt(t.l1_gas.max_amount)<<LC)+BigInt(t.l1_gas.max_price_per_unit)}function GC(t){return(qC<<FC)+(BigInt(t.l2_gas.max_amount)<<LC)+BigInt(t.l2_gas.max_price_per_unit)}function ZC(t,e){const r=HC(e),i=GC(e);return Jb([BigInt(t),r,i])}function KC(t,e,r,i,n,o,a,s,h,u,l=[]){const c=ZC(o,u),d=VC(s,h),f=DC([t,e,r,c,Jb(DC(a)),i,n,d,...DC(l)]);return RI(Jb(f))}function JC(t,e,r,i,n,o,a,s,h,u,l,c){return KC("0x6465706c6f795f6163636f756e74",n,t,o,a,l,c,s,h,u,[Jb(DC(r)),e,i])}function WC(t,e,r,i,n,o,a,s,h,u,l,c){return KC("0x6465636c617265",i,r,n,o,l,DC(c),s,h,u,[Jb(DC(a)),t,e])}function YC(t,e,r,i,n,o,a,s,h,u,l){return KC("0x696e766f6b65",e,t,i,n,u,l,a,s,h,[Jb(DC(o)),Jb(DC(r))])}function QC(t){return function(t){return[WS.ETransactionVersion.V3,WS.ETransactionVersion.F3].includes(t.version)}(t)?YC(t.senderAddress,t.version,t.compiledCalldata,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):PC(t.senderAddress,t.version,t.compiledCalldata,t.maxFee,t.chainId,t.nonce)}function XC(t){return function(t){return[WS.ETransactionVersion.V3,WS.ETransactionVersion.F3].includes(t.version)}(t)?WC(t.classHash,t.compiledClassHash,t.senderAddress,t.version,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):OC(t.classHash,t.senderAddress,t.version,t.maxFee,t.chainId,t.nonce,t.compiledClassHash)}function tz(t){return function(t){return[WS.ETransactionVersion.V3,WS.ETransactionVersion.F3].includes(t.version)}(t)?JC(t.contractAddress,t.classHash,t.compiledConstructorCalldata,t.salt,t.version,t.chainId,t.nonce,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):RC(t.contractAddress,t.classHash,t.constructorCalldata,t.salt,t.version,t.maxFee,t.chainId,t.nonce)}function ez(t,e){return $b(BigInt(t),BigInt(e))}function rz(t,e){return RI(Kb(BigInt(t),BigInt(e)))}function iz(t){return[...t,t.length].reduce(((t,e)=>$b(BigInt(t),BigInt(e))),0).toString()}var nz=iz;function oz(t){return RI(Jb(t.map((t=>BigInt(t)))))}function az(t,e,r,i){const n=iz(TC.compile(r)),o=iz([iC("0x535441524b4e45545f434f4e54524143545f41444452455353"),i,t,e,n]);return RI(BigInt(o)%ON)}function sz(t,e){return"attributes"===t||"accessible_scopes"===t?Array.isArray(e)&&0===e.length?void 0:e:"debug_info"===t?null:null===e?void 0:e}function hz(t){let e=!1;const r=[];for(const i of t)'"'===i&&!1==(r.length>0&&"\\"===r.slice(-1)[0])&&(e=!e),e?r.push(i):r.push(":"===i?": ":","===i?", ":i);return r.join("")}function uz(t){const{abi:e,program:r}=t,i=hz(nI({abi:e,program:r},sz));return bN(Fb(mN(i)).toString(16))}function lz(t){const e=TI(t)?rI(t):t,r=RI(TN),i=iz(e.entry_points_by_type.EXTERNAL.flatMap((t=>[t.selector,t.offset]))),n=iz(e.entry_points_by_type.L1_HANDLER.flatMap((t=>[t.selector,t.offset]))),o=iz(e.entry_points_by_type.CONSTRUCTOR.flatMap((t=>[t.selector,t.offset]))),a=iz(e.program.builtins.map((t=>dT(t)))),s=uz(e),h=iz(e.program.data);return iz([r,i,n,o,a,s,h])}function cz(t){const e=t.flatMap((t=>{return[BigInt(t.selector),BigInt(t.offset),(e=t.builtins,Jb(e.flatMap((t=>BigInt(dT(t))))))];var e}));return Jb(e)}function dz(t){const e=t.bytecode.map((t=>BigInt(t))),r=t.bytecode_segment_lengths??[];let i=0;const n=r.flatMap((t=>{const r=e.slice(i,i+=t);return[BigInt(t),Jb(r)]}));return 1n+Jb(n)}function fz(t){const e=BigInt(dT("COMPILED_CLASS_V1")),r=cz(t.entry_points_by_type.EXTERNAL),i=cz(t.entry_points_by_type.L1_HANDLER),n=cz(t.entry_points_by_type.CONSTRUCTOR),o=t.bytecode_segment_lengths?dz(t):Jb(t.bytecode.map((t=>BigInt(t))));return RI(Jb([e,r,i,n,o]))}function mz(t){return Jb(t.flatMap((t=>[BigInt(t.selector),BigInt(t.function_idx)])))}function pz(t){const e=BigInt(dT("CONTRACT_CLASS_V0.1.0")),r=mz(t.entry_points_by_type.EXTERNAL),i=mz(t.entry_points_by_type.L1_HANDLER),n=mz(t.entry_points_by_type.CONSTRUCTOR),o=function(t){const e=hz(nI(t.abi,null));return BigInt(bN(Fb(mN(e)).toString(16)))}(t),a=Jb(t.sierra_program.map((t=>BigInt(t))));return RI(Jb([e,r,i,n,o,a]))}function gz(t){const e=TI(t)?rI(t):t;return"sierra_program"in e?pz(e):lz(e)}function yz(t){const e=TI(t)?t:nI(t);return yN(DE(e))}function wz(t){if(Array.isArray(t))return t;const e=fN($E(gN(t)));return rI(e)}function vz(){return Tb(xb.randomPrivateKey())}function bz(t){return bN(t).toLowerCase()}function kz(t){if(!t)throw Error("formatSignature: provided signature is undefined");if(Array.isArray(t))return t.map((t=>RI(t)));try{const{r:e,s:r}=t;return[RI(e),RI(r)]}catch(t){throw new Error("Signature need to be weierstrass.SignatureType or an array for custom")}}function Mz(t){return UI(kz(t))}function _z(t){return qI(kz(t))}function Ez(t,e=50){return WI(t,e)}function Az(t,e=50,r=50){if(II(t))return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}};if(xI(t.gas_consumed)||xI(t.gas_price))throw Error("estimateFeeToBounds: estimate is undefined");return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:void 0!==t.data_gas_consumed&&void 0!==t.data_gas_price?RI(WI(BigInt(t.overall_fee)/BigInt(t.gas_price),e)):RI(WI(t.gas_consumed,e)),max_price_per_unit:RI(WI(t.gas_price,r))}}}function jz(t){if(t===WS.EDataAvailabilityMode.L1)return WS.EDAMode.L1;if(t===WS.EDataAvailabilityMode.L2)return WS.EDAMode.L2;throw Error("EDAM conversion")}function xz(t,e){const r=e?RI(e):void 0,i=RI(t);if(e&&!Object.values(WS.ETransactionVersion).includes(r))throw Error(`providedVersion ${e} is not ETransactionVersion`);if(!Object.values(WS.ETransactionVersion).includes(i))throw Error(`defaultVersion ${t} is not ETransactionVersion`);return e?r:i}function Sz(t){if(!t)return;const e=RI(t);if(e===WS.ETransactionVersion.V0)return WS.ETransactionVersion.F0;if(e===WS.ETransactionVersion.V1)return WS.ETransactionVersion.F1;if(e===WS.ETransactionVersion.V2)return WS.ETransactionVersion.F2;if(e===WS.ETransactionVersion.V3)return WS.ETransactionVersion.F3;throw Error(`toFeeVersion: ${e} is not supported`)}function Nz(t){return{tip:t.tip||0,paymasterData:t.paymasterData||[],accountDeploymentData:t.accountDeploymentData||[],nonceDataAvailabilityMode:t.nonceDataAvailabilityMode||WS.EDataAvailabilityMode.L1,feeDataAvailabilityMode:t.feeDataAvailabilityMode||WS.EDataAvailabilityMode.L1,resourceBounds:t.resourceBounds??Az(SN)}}function Iz(t){return t===WS.ETransactionVersion.F2?WS.ETransactionVersion.F1:t===WS.ETransactionVersion.V2?WS.ETransactionVersion.V1:t}function Tz(t){return bN(wN(bb(RI(t),!1)))}function Cz(t){return"sierra_program"in(TI(t)?rI(t):t)}KS({},{compressProgram:()=>yz,decompressProgram:()=>wz,estimateFeeToBounds:()=>Az,estimatedFeeToMaxFee:()=>Ez,formatSignature:()=>kz,getFullPublicKey:()=>Tz,intDAM:()=>jz,makeAddress:()=>bz,randomAddress:()=>vz,reduceV2:()=>Iz,signatureToDecimalArray:()=>Mz,signatureToHexArray:()=>_z,toFeeVersion:()=>Sz,toTransactionVersion:()=>xz,v3Details:()=>Nz});function zz(){return EN(wN(GE.utils.randomPrivateKey()))}function Oz(t){FI(t,SN,2n**160n-1n,"Ethereum Address ");const e=bN(vN(RI(t)).padStart(40,"0"));return jI(Boolean(e.match(/^(0x)?[0-9a-f]{40}$/)),"Invalid Ethereum Address Format"),e}KS({},{ethRandomPrivateKey:()=>zz,validateAndParseEthAddress:()=>Oz});var Rz=dN&&window.fetch.bind(window)||!xI(t)&&aS(t.fetch)||TS;KS({},{Block:()=>Vz,createSierraContractClass:()=>Lz,getDefaultNodeUrl:()=>Uz,isPendingBlock:()=>Zz,isPendingStateUpdate:()=>Jz,isPendingTransaction:()=>Kz,isV3Tx:()=>Hz,isVersion:()=>Gz,parseContract:()=>Fz,validBlockTags:()=>qz,wait:()=>$z});var Pz=class t{static instance;config;constructor(){this.initialize()}initialize(){this.config={...QN}}static getInstance(){return t.instance||(t.instance=new t),t.instance}get(t,e){return this.config[t]??e}set(t,e){this.config[t]=e}update(t){this.config={...this.config,...t}}getAll(){return{...this.config}}reset(){this.initialize()}delete(t){delete this.config[t]}hasKey(t){return t in this.config}}.getInstance(),Bz={DEBUG:5,INFO:4,WARN:3,ERROR:2,FATAL:1,OFF:0},Dz=class t{static instance;config;constructor(){this.config=Pz}static getInstance(){return t.instance||(t.instance=new t),t.instance}getTimestamp(){return(new Date).toISOString()}shouldLog(t){const e=this.config.get("logLevel","INFO");return t<=Bz[e]}formatMessage(t){const{level:e,message:r,timestamp:i,data:n}=t;let o=`[${i}] ${e}: ${r}`;if(n)try{o+=`\n${JSON.stringify(n,null,2)}`}catch(t){o+=`\n[JSON.stringify Error/Circular]: ${t}`}return o}log(t,e,r){if(!this.shouldLog(Bz[t]))return;const i={level:t,message:e,timestamp:this.getTimestamp(),data:r},n=this.formatMessage(i);switch(t){case"DEBUG":console.debug(n);break;case"INFO":console.info(n);break;case"WARN":console.warn(n);break;case"ERROR":case"FATAL":console.error(n);break;case"OFF":break;default:console.log(n)}}debug(t,e){this.log("DEBUG",t,e)}info(t,e){this.log("INFO",t,e)}warn(t,e){this.log("WARN",t,e)}error(t,e){this.log("ERROR",t,e)}fatal(t,e){this.log("FATAL",t,e)}setLogLevel(t){this.config.set("logLevel",t)}getLogLevel(){return this.config.get("logLevel","INFO")}getEnabledLogLevels(){return Object.keys(Bz).filter((t=>this.shouldLog(Bz[t])&&"OFF"!==t))}}.getInstance();function $z(t){return new Promise((e=>{setTimeout(e,t)}))}function Lz(t){const e={...t};return delete e.sierra_program_debug_info,e.abi=hz(nI(t.abi)),e.sierra_program=hz(nI(t.sierra_program)),e.sierra_program=yz(e.sierra_program),e}function Fz(t){const e=TI(t)?rI(t):t;return Cz(t)?Lz(e):{...e,..."program"in e&&{program:yz(e.program)}}}var Uz=(t,e=!1)=>{e||Dz.info("Using default public node url, please provide nodeUrl in provider options!");const r=GN[t??"SN_SEPOLIA"];return r[Math.floor(Math.random()*r.length)]},qz=Object.values(gI),Vz=class{hash=null;number=null;tag=null;setIdentifier(t){if(TI(t))if(sT(t))this.number=parseInt(t,10);else if(zI(t))this.hash=t;else{if(!qz.includes(t))throw TypeError(`Block identifier unmanaged: ${t}`);this.tag=t}else II(t)?this.hash=RI(t):SI(t)?this.number=t:this.tag=gI.PENDING;if(SI(this.number)&&this.number<0)throw TypeError(`Block number (${this.number}) can't be negative`)}constructor(t){this.setIdentifier(t)}get queryIdentifier(){return null!==this.number?`blockNumber=${this.number}`:null!==this.hash?`blockHash=${this.hash}`:`blockNumber=${this.tag}`}get identifier(){return null!==this.number?{block_number:this.number}:null!==this.hash?{block_hash:this.hash}:this.tag}set identifier(t){this.setIdentifier(t)}valueOf=()=>this.number;toString=()=>this.hash};function Hz(t){const e=t.version?RI(t.version):WS.ETransactionVersion.V3;return e===WS.ETransactionVersion.V3||e===WS.ETransactionVersion.F3}function Gz(t,e){const[r,i]=t.split("."),[n,o]=e.split(".");return r===n&&i===o}function Zz(t){return"PENDING"===t.status}function Kz(t){return!("block_hash"in t)}function Jz(t){return!("block_hash"in t)}KS({},{buildUDCCall:()=>rO,fromCallsToExecuteCalldata:()=>Yz,fromCallsToExecuteCalldataWithNonce:()=>Qz,fromCallsToExecuteCalldata_cairo1:()=>tO,getExecuteCalldata:()=>eO,getVersionsByType:()=>iO,transformCallsToMulticallArrays:()=>Wz,transformCallsToMulticallArrays_cairo1:()=>Xz});var Wz=t=>{const e=[],r=[];return t.forEach((t=>{const i=TC.compile(t.calldata||[]);e.push({to:OI(t.contractAddress).toString(10),selector:OI(eT(t.entrypoint)).toString(10),data_offset:r.length.toString(),data_len:i.length.toString()}),r.push(...i)})),{callArray:e,calldata:TC.compile({calldata:r})}},Yz=t=>{const{callArray:e,calldata:r}=Wz(t);return[...TC.compile({callArray:e}),...r]},Qz=(t,e)=>[...Yz(t),OI(e).toString()],Xz=t=>{const e=t.map((t=>({to:OI(t.contractAddress).toString(10),selector:OI(eT(t.entrypoint)).toString(10),calldata:TC.compile(t.calldata||[])})));return e},tO=t=>{const e=t.map((t=>({contractAddress:t.contractAddress,entrypoint:t.entrypoint,calldata:Array.isArray(t.calldata)&&"__compiled__"in t.calldata?t.calldata:TC.compile(t.calldata)})));return TC.compile({orderCalls:e})},eO=(t,e="0")=>"1"===e?tO(t):Yz(t);function rO(t,e){const r=[].concat(t).map((t=>{const{classHash:r,salt:i,unique:n=!0,constructorCalldata:o=[]}=t,a=TC.compile(o),s=i??vz();return{call:{contractAddress:VN.ADDRESS,entrypoint:VN.ENTRYPOINT,calldata:[r,s,KI(n),a.length,...a]},address:az(n?$b(e,s):s,r,a,n?VN.ADDRESS:0)}}));return{calls:r.map((t=>t.call)),addresses:r.map((t=>t.address))}}function iO(t){return"fee"===t?{v1:WS.ETransactionVersion.F1,v2:WS.ETransactionVersion.F2,v3:WS.ETransactionVersion.F3}:{v1:WS.ETransactionVersion.V1,v2:WS.ETransactionVersion.V2,v3:WS.ETransactionVersion.V3}}var nO={headers:{"Content-Type":"application/json"},blockIdentifier:gI.PENDING,retries:200},oO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(LN).includes(a)?this.nodeUrl=Uz(a,t?.default):this.nodeUrl=a||Uz(void 0,t?.default),this.baseFetch=e??Rz,this.blockIdentifier=i??nO.blockIdentifier,this.chainId=n,this.headers={...nO.headers,...o},this.retries=s??nO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new AI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:nI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new uI(r,t,e);if(i instanceof hI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new Vz(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=RI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new Vz(r).identifier,a=[];return i&&a.push(QS.ESimulationFlag.SKIP_VALIDATE),n&&a.push(QS.ESimulationFlag.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=RI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[QS.ETransactionStatus.REJECTED],h=e?.successStates??[QS.ETransactionExecutionStatus.SUCCEEDED,QS.ETransactionStatus.ACCEPTED_ON_L2,QS.ETransactionStatus.ACCEPTED_ON_L1];let u;for(;!n;){await $z(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await $z(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=RI(t),n=BI(e),o=new Vz(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new Vz(e).identifier;let n={};return Gz("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[QS.ESimulationFlag.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return Hz(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:QS.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:QS.ETransactionVersion.V3,signature:_z(t.signature),nonce:RI(e.nonce),resource_bounds:e.resourceBounds,tip:RI(e.tip),paymaster_data:e.paymasterData.map((t=>RI(t))),account_deployment_data:e.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),type:QS.ETransactionType.INVOKE,max_fee:RI(e.maxFee||0),version:QS.ETransactionVersion.V1,signature:_z(t.signature),nonce:RI(e.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V1,type:QS.ETransactionType.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Cz(t)||Hz(n))if(Cz(t)&&!Hz(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:QS.ETransactionType.DECLARE,contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:QS.ETransactionVersion.V2,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V2,type:QS.ETransactionType.DECLARE});else{if(!Cz(t)||!Hz(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:QS.ETransactionType.DECLARE,sender_address:r,compiled_class_hash:i||"",version:QS.ETransactionVersion.V3,signature:_z(e),nonce:RI(n.nonce),contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),account_deployment_data:n.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:QS.ETransactionType.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:QS.ETransactionVersion.V1,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V1,type:QS.ETransactionType.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return Hz(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:QS.ETransactionType.DEPLOY_ACCOUNT,version:QS.ETransactionVersion.V3,signature:_z(i),nonce:RI(n.nonce),contract_address_salt:RI(r||0),constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),contract_address_salt:RI(r||0),type:QS.ETransactionType.DEPLOY_ACCOUNT,max_fee:RI(n.maxFee||0),version:QS.ETransactionVersion.V1,signature:_z(i),nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V1,type:QS.ETransactionType.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new Vz(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:eT(t.entrypoint),calldata:TC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Oz(r),to_address:RI(i),entry_point_selector:rT(n),payload:ZI(o)},s=new Vz(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=iO(e);let i;if(Hz(t)?i={signature:_z(t.signature),nonce:RI(t.nonce),resource_bounds:t.resourceBounds,tip:RI(t.tip),paymaster_data:t.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>RI(t)))}:(i={signature:_z(t.signature),nonce:RI(t.nonce),max_fee:RI(t.maxFee||0)},Dz.warn(XN.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===cI.INVOKE)return{type:QS.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:RI(t.version||r.v3),...i};if(t.type===cI.DECLARE)return Cz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:wz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:RI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:RI(t.version||r.v1),...i};if(t.type===cI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:TC.toHex(t.constructorCalldata||[]),class_hash:RI(t.classHash),contract_address_salt:RI(t.addressSalt||0),version:RI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}};KS({},{RpcChannel:()=>sO});var aO={headers:{"Content-Type":"application/json"},blockIdentifier:gI.PENDING,retries:200},sO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(LN).includes(a)?this.nodeUrl=Uz(a,t?.default):this.nodeUrl=a||Uz(void 0,t?.default),this.baseFetch=e??Rz,this.blockIdentifier=i??aO.blockIdentifier,this.chainId=n,this.headers={...aO.headers,...o},this.retries=s??aO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new AI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:nI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new uI(r,t,e);if(i instanceof hI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockWithReceipts(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithReceipts",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new Vz(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=RI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new Vz(r).identifier,a=[];return i&&a.push(Zp.SKIP_VALIDATE),n&&a.push(Zp.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=RI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[Kp.REJECTED],h=e?.successStates??[Wp.SUCCEEDED,Kp.ACCEPTED_ON_L2,Kp.ACCEPTED_ON_L1];let u;for(;!n;){await $z(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await $z(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=RI(t),n=BI(e),o=new Vz(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new Vz(e).identifier;let n={};return Gz("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[Zp.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return Hz(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:Gp.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:tg.V3,signature:_z(t.signature),nonce:RI(e.nonce),resource_bounds:e.resourceBounds,tip:RI(e.tip),paymaster_data:e.paymasterData.map((t=>RI(t))),account_deployment_data:e.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),type:Gp.INVOKE,max_fee:RI(e.maxFee||0),version:tg.V1,signature:_z(t.signature),nonce:RI(e.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V1,type:Gp.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Cz(t)||Hz(n))if(Cz(t)&&!Hz(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:Gp.DECLARE,contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:tg.V2,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V2,type:Gp.DECLARE});else{if(!Cz(t)||!Hz(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:Gp.DECLARE,sender_address:r,compiled_class_hash:i||"",version:tg.V3,signature:_z(e),nonce:RI(n.nonce),contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),account_deployment_data:n.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:Gp.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:tg.V1,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V1,type:Gp.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return Hz(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:Gp.DEPLOY_ACCOUNT,version:tg.V3,signature:_z(i),nonce:RI(n.nonce),contract_address_salt:RI(r||0),constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),contract_address_salt:RI(r||0),type:Gp.DEPLOY_ACCOUNT,max_fee:RI(n.maxFee||0),version:tg.V1,signature:_z(i),nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V1,type:Gp.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new Vz(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:eT(t.entrypoint),calldata:TC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Oz(r),to_address:RI(i),entry_point_selector:rT(n),payload:ZI(o)},s=new Vz(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=iO(e);let i;if(Hz(t)?i={signature:_z(t.signature),nonce:RI(t.nonce),resource_bounds:t.resourceBounds,tip:RI(t.tip),paymaster_data:t.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>RI(t)))}:(i={signature:_z(t.signature),nonce:RI(t.nonce),max_fee:RI(t.maxFee||0)},Dz.warn(XN.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===cI.INVOKE)return{type:Gp.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:RI(t.version||r.v3),...i};if(t.type===cI.DECLARE)return Cz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:wz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:RI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:RI(t.version||r.v1),...i};if(t.type===cI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:TC.toHex(t.constructorCalldata||[]),class_hash:RI(t.classHash),contract_address_salt:RI(t.addressSalt||0),version:RI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}},hO=class{margin;constructor(t){this.margin=t}estimatedFeeToMaxFee(t){return Ez(t,this.margin?.maxFee)}estimateFeeToBounds(t){return Az(t,this.margin?.l1BoundMaxAmount,this.margin?.l1BoundMaxPricePerUnit)}parseGetBlockResponse(t){return{status:"PENDING",...t}}parseTransactionReceipt(t){return"actual_fee"in t&&TI(t.actual_fee)?{...t,actual_fee:{amount:t.actual_fee,unit:"FRI"}}:t}parseFeeEstimateResponse(t){const e=t[0];return{overall_fee:OI(e.overall_fee),gas_consumed:OI(e.gas_consumed),gas_price:OI(e.gas_price),unit:e.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(e.overall_fee),resourceBounds:this.estimateFeeToBounds(e),data_gas_consumed:e.data_gas_consumed?OI(e.data_gas_consumed):0n,data_gas_price:e.data_gas_price?OI(e.data_gas_price):0n}}parseFeeEstimateBulkResponse(t){return t.map((t=>({overall_fee:OI(t.overall_fee),gas_consumed:OI(t.gas_consumed),gas_price:OI(t.gas_price),unit:t.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(t.overall_fee),resourceBounds:this.estimateFeeToBounds(t),data_gas_consumed:t.data_gas_consumed?OI(t.data_gas_consumed):0n,data_gas_price:t.data_gas_price?OI(t.data_gas_price):0n})))}parseSimulateTransactionResponse(t){return t.map((t=>({...t,suggestedMaxFee:this.estimatedFeeToMaxFee(t.fee_estimation.overall_fee),resourceBounds:this.estimateFeeToBounds(t.fee_estimation)})))}parseContractClassResponse(t){return{...t,abi:TI(t.abi)?JSON.parse(t.abi):t.abi}}parseL1GasPriceResponse(t){return t.l1_gas_price.price_in_wei}},uO=class t{statusReceipt;value;constructor(e){[this.statusReceipt,this.value]=t.isSuccess(e)?["success",e]:t.isReverted(e)?["reverted",e]:t.isRejected(e)?["rejected",e]:["error",new Error("Unknown response type")];for(const[t]of Object.entries(this))Object.defineProperty(this,t,{enumerable:!1});for(const[t,r]of Object.entries(e))Object.defineProperty(this,t,{enumerable:!0,writable:!1,value:r})}match(t){return this.statusReceipt in t?t[this.statusReceipt](this.value):t._()}isSuccess(){return"success"===this.statusReceipt}isReverted(){return"reverted"===this.statusReceipt}isRejected(){return"rejected"===this.statusReceipt}isError(){return"error"===this.statusReceipt}static isSuccess(t){return t.execution_status===mI.SUCCEEDED}static isReverted(t){return t.execution_status===mI.REVERTED}static isRejected(t){return t.status===mI.REJECTED}},lO={};KS(lO,{TypedDataRevision:()=>og,encodeData:()=>AO,encodeType:()=>MO,encodeValue:()=>EO,getDependencies:()=>kO,getMessageHash:()=>xO,getStructHash:()=>jO,getTypeHash:()=>_O,isMerkleTreeType:()=>bO,prepareSelector:()=>vO,validateTypedData:()=>wO,verifyMessage:()=>SO});KS({},{MerkleTree:()=>cO,proofMerklePath:()=>dO});var cO=class t{leaves;branches=[];root;hashMethod;constructor(t,e=ez){this.hashMethod=e,this.leaves=t,this.root=this.build(t)}build(e){if(1===e.length)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const r=[];for(let i=0;i<e.length;i+=2)i+1===e.length?r.push(t.hash(e[i],"0x0",this.hashMethod)):r.push(t.hash(e[i],e[i+1],this.hashMethod));return this.build(r)}static hash(t,e,r=ez){const[i,n]=[BigInt(t),BigInt(e)].sort(((t,e)=>t>=e?1:-1));return r(i,n)}getProof(e,r=this.leaves,i=[]){const n=r.indexOf(e);if(-1===n)throw new Error("leaf not found");if(1===r.length)return i;const o=n%2==0,a=(o?r[n+1]:r[n-1])??"0x0",s=[...i,a],h=this.leaves.length===r.length?-1:this.branches.findIndex((t=>t.length===r.length)),u=this.branches[h+1]??[this.root];return this.getProof(t.hash(o?e:a,o?a:e,this.hashMethod),u,s)}};function dO(t,e,r,i=ez){if(0===r.length)return t===e;const[n,...o]=r;return dO(t,cO.hash(e,n,i),o,i)}var fO={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},mO={[og.ACTIVE]:{domain:"StarknetDomain",hashMethod:oz,hashMerkleMethod:rz,escapeTypeString:t=>`"${t}"`,presetTypes:fO},[og.LEGACY]:{domain:"StarkNetDomain",hashMethod:nz,hashMerkleMethod:ez,escapeTypeString:t=>t,presetTypes:{}}};function pO(t,e,{min:r,max:i}){const n=BigInt(t);jI(n>=r&&n<=i,`${n} (${e}) is out of bounds [${r}, ${i}]`)}function gO({types:t,domain:e}){return mO[og.ACTIVE].domain in t&&e.revision===og.ACTIVE?og.ACTIVE:mO[og.LEGACY].domain in t&&(e.revision??og.LEGACY)===og.LEGACY?og.LEGACY:void 0}function yO(t){try{return RI(t)}catch(e){if(TI(t))return RI(dT(t));throw new Error(`Invalid BigNumberish: ${t}`)}}function wO(t){const e=t;return Boolean(e.message&&e.primaryType&&e.types&&gO(e))}function vO(t){return zI(t)?t:eT(t)}function bO(t){return"merkletree"===t.type}function kO(t,e,r=[],i="",n=og.LEGACY){let o=[e];return"*"===e[e.length-1]?o=[e.slice(0,-1)]:n===og.ACTIVE&&("enum"===e?o=[i]:e.match(/^\(.*\)$/)&&(o=e.slice(1,-1).split(",").map((t=>"*"===t[t.length-1]?t.slice(0,-1):t)))),o.filter((e=>!r.includes(e)&&t[e])).reduce(((e,r)=>[...e,...[r,...t[r].reduce(((e,r)=>[...e,...kO(t,r.type,e,r.contains,n).filter((t=>!e.includes(t)))]),[])].filter((t=>!e.includes(t)))]),[])}function MO(t,e,r=og.LEGACY){const i=r===og.ACTIVE?{...t,...mO[r].presetTypes}:t,[n,...o]=kO(i,e,void 0,void 0,r),a=n?[n,...o.sort()]:[],s=mO[r].escapeTypeString;return a.map((t=>{const e=i[t].map((t=>{const e="enum"===t.type&&r===og.ACTIVE?t.contains:t.type,i=e.match(/^\(.*\)$/)?`(${e.slice(1,-1).split(",").map((t=>t?s(t):t)).join(",")})`:s(e);return`${s(t.name)}:${i}`}));return`${s(t)}(${e})`})).join("")}function _O(t,e,r=og.LEGACY){return eT(MO(t,e,r))}function EO(t,e,r,i={},n=og.LEGACY){if(t[e])return[e,jO(t,e,r,n)];if(mO[n].presetTypes[e])return[e,jO(mO[n].presetTypes,e,r,n)];if(e.endsWith("*")){const i=r.map((r=>EO(t,e.slice(0,-1),r,void 0,n)[1]));return[e,mO[n].hashMethod(i)]}switch(e){case"enum":if(n===og.ACTIVE){const[o,a]=Object.entries(r)[0],s=t[i.parent].find((t=>t.name===i.key)),h=t[s.contains],u=h.find((t=>t.name===o)),l=h.indexOf(u),c=u.type.slice(1,-1).split(",").map(((e,r)=>{if(!e)return e;const i=a[r];return EO(t,e,i,void 0,n)[1]}));return[e,mO[n].hashMethod([l,...c])]}return[e,yO(r)];case"merkletree":{const e=function(t,e){if(e.parent&&e.key){const r=t[e.parent].find((t=>t.name===e.key));if(!bO(r))throw new Error(`${e.key} is not a merkle tree`);if(r.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return r.contains}return"raw"}(t,i),o=r.map((r=>EO(t,e,r,void 0,n)[1])),{root:a}=new cO(o,mO[n].hashMerkleMethod);return["felt",a]}case"selector":return["felt",vO(r)];case"string":if(n===og.ACTIVE){const t=pT(r),i=[t.data.length,...t.data,t.pending_word,t.pending_word_len];return[e,mO[n].hashMethod(i)]}return[e,yO(r)];case"i128":if(n===og.ACTIVE){const t=BigInt(r);return pO(t,e,BN),[e,yO(t<0n?CN+t:t)]}return[e,yO(r)];case"timestamp":case"u128":return n===og.ACTIVE&&pO(r,e,DN),[e,yO(r)];case"felt":case"shortstring":return n===og.ACTIVE&&pO(yO(r),e,PN),[e,yO(r)];case"ClassHash":case"ContractAddress":return n===og.ACTIVE&&pO(r,e,PN),[e,yO(r)];case"bool":return n===og.ACTIVE&&jI(NI(r),`Type mismatch for ${e} ${r}`),[e,yO(r)];default:if(n===og.ACTIVE)throw new Error(`Unsupported type: ${e}`);return[e,yO(r)]}}function AO(t,e,r,i=og.LEGACY){const n=t[e]??mO[i].presetTypes[e],[o,a]=n.reduce((([n,o],a)=>{if(void 0===r[a.name]||null===r[a.name]&&"enum"!==a.type)throw new Error(`Cannot encode data: missing data for '${a.name}'`);const s=r[a.name],h={parent:e,key:a.name},[u,l]=EO(t,a.type,s,h,i);return[[...n,u],[...o,l]]}),[["felt"],[_O(t,e,i)]]);return[o,a]}function jO(t,e,r,i=og.LEGACY){return mO[i].hashMethod(AO(t,e,r,i)[1])}function xO(t,e){if(!wO(t))throw new Error("Typed data does not match JSON schema");const r=gO(t),{domain:i,hashMethod:n}=mO[r];return n([dT("StarkNet Message"),jO(t.types,i,t.domain,r),e,jO(t.types,t.primaryType,t.message,r)])}function SO(t,e,r,i){const n=wO(t);if(!QI(t)&&!n)throw new Error("message has a wrong format.");if(n&&void 0===i)throw new Error("When providing a TypedData in message parameter, the accountAddress parameter has to be provided.");if(n&&!QI(i))throw new Error("accountAddress shall be a BigNumberish");const o=n?xO(t,i):RI(t);return _b(Array.isArray(e)?new jb(BigInt(e[0]),BigInt(e[1])):e,o,RI(r))}var NO=class{responseParser;channel;constructor(t){t&&"channel"in t?(this.channel=t.channel,this.responseParser="responseParser"in t?t.responseParser:new hO):(this.channel=new sO({...t,waitMode:!1}),this.responseParser=new hO(t?.feeMarginPercentage))}fetch(t,e,r=0){return this.channel.fetch(t,e,r)}async getChainId(){return this.channel.getChainId()}async getSpecVersion(){return this.channel.getSpecVersion()}async getNonceForAddress(t,e){return this.channel.getNonceForAddress(t,e)}async getBlock(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseGetBlockResponse)}async getBlockLatestAccepted(){return this.channel.getBlockLatestAccepted()}async getBlockNumber(){return this.channel.getBlockNumber()}async getBlockWithTxHashes(t){return this.channel.getBlockWithTxHashes(t)}async getBlockWithTxs(t){return this.channel.getBlockWithTxs(t)}async waitForBlock(t="pending",e=5e3){if(t===gI.LATEST)return;const r=await this.getBlockNumber(),i=t===gI.PENDING?r+1:Number(RI(t));if(i<=r)return;const{retries:n}=this.channel;let o=n,a=!1;for(;!a;){if(await this.getBlockNumber()===i?a=!0:await $z(e),o-=1,o<=0)throw new Error(`waitForBlock() timed-out after ${n} tries.`)}}async getL1GasPrice(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseL1GasPriceResponse)}async getL1MessageHash(t){const e=await this.channel.getTransactionByHash(t);jI("L1_HANDLER"===e.type,"This L2 transaction is not a L1 message.");const{calldata:r,contract_address:i,entry_point_selector:n,nonce:o}=e;return iT([r[0],i,o,n,r.length-1,...r.slice(1)])}async getBlockWithReceipts(t){if(this.channel instanceof tI.RpcChannel)throw new hI("Unsupported method for RPC version");return this.channel.getBlockWithReceipts(t)}getStateUpdate=this.getBlockStateUpdate;async getBlockStateUpdate(t){return this.channel.getBlockStateUpdate(t)}async getBlockTransactionsTraces(t){return this.channel.getBlockTransactionsTraces(t)}async getBlockTransactionCount(t){return this.channel.getBlockTransactionCount(t)}async getPendingTransactions(){const{transactions:t}=await this.getBlockWithTxHashes(gI.PENDING).then(this.responseParser.parseGetBlockResponse);return Promise.all(t.map((t=>this.getTransactionByHash(t))))}async getTransaction(t){return this.channel.getTransactionByHash(t)}async getTransactionByHash(t){return this.channel.getTransactionByHash(t)}async getTransactionByBlockIdAndIndex(t,e){return this.channel.getTransactionByBlockIdAndIndex(t,e)}async getTransactionReceipt(t){const e=await this.channel.getTransactionReceipt(t),r=this.responseParser.parseTransactionReceipt(e);return new uO(r)}async getTransactionTrace(t){return this.channel.getTransactionTrace(t)}async getTransactionStatus(t){return this.channel.getTransactionStatus(t)}async getSimulateTransaction(t,e){return this.channel.simulateTransaction(t,e).then((t=>this.responseParser.parseSimulateTransactionResponse(t)))}async waitForTransaction(t,e){const r=await this.channel.waitForTransaction(t,e);return new uO(r)}async getStorageAt(t,e,r){return this.channel.getStorageAt(t,e,r)}async getClassHashAt(t,e){return this.channel.getClassHashAt(t,e)}async getClassByHash(t){return this.getClass(t)}async getClass(t,e){return this.channel.getClass(t,e).then(this.responseParser.parseContractClassResponse)}async getClassAt(t,e){return this.channel.getClassAt(t,e).then(this.responseParser.parseContractClassResponse)}async getContractVersion(t,e,{blockIdentifier:r=this.channel.blockIdentifier,compiler:i=!0}={}){let n;if(t)n=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");n=await this.getClass(e,r)}if(Cz(n)){if(i){return{cairo:"1",compiler:XT(n.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async getEstimateFee(t,e,r,i){return this.getInvokeEstimateFee(t,e,r,i)}async getInvokeEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:cI.INVOKE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeclareEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:cI.DECLARE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeployAccountEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:cI.DEPLOY_ACCOUNT,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getEstimateFeeBulk(t,e){return this.channel.getEstimateFee(t,e).then((t=>this.responseParser.parseFeeEstimateBulkResponse(t)))}async invokeFunction(t,e){return this.channel.invoke(t,e)}async declareContract(t,e){return this.channel.declare(t,e)}async deployAccountContract(t,e){return this.channel.deployAccount(t,e)}async callContract(t,e){return this.channel.callContract(t,e)}async estimateMessageFee(t,e){return this.channel.estimateMessageFee(t,e)}async getSyncingStats(){return this.channel.getSyncingStats()}async getEvents(t){return this.channel.getEvents(t)}async verifyMessageInStarknet(t,e,r,i,n){const o=wO(t);if(!QI(t)&&!o)throw new Error("message has a wrong format.");if(!QI(r))throw new Error("accountAddress shall be a BigNumberish");const a=o?xO(t,r):RI(t),s=i?[i]:["isValidSignature","is_valid_signature"],h=n||{okResponse:[],nokResponse:["0x0","0x00"],error:["argent/invalid-signature","is invalid, with respect to the public key","INVALID_SIG"]};let u;for(const t of s)try{const i=await this.callContract({contractAddress:RI(r),entrypoint:t,calldata:TC.compile({hash:OI(a).toString(),signature:kz(e)})});if(h.nokResponse.includes(i[0].toString()))return!1;if(0===h.okResponse.length||h.okResponse.includes(i[0].toString()))return!0;throw Error("signatureVerificationResponse Error: response is not part of known responses")}catch(t){if(h.error.some((e=>t.message.includes(e))))return!1;u=t}throw Error(`Signature verification Error: ${u}`)}async isClassDeclared(t,e){let r;if(!t.classHash&&"contract"in t){r=function(t){const e={...t};if(Cz(t.contract)&&(!t.compiledClassHash&&t.casm&&(e.compiledClassHash=fz(t.casm)),!e.compiledClassHash))throw new Error("Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash");if(e.classHash=t.classHash??gz(t.contract),!e.classHash)throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");return e}(t).classHash}else{if(!t.classHash)throw Error("contractClassIdentifier type not satisfied");r=t.classHash}try{return await this.getClass(r,e)instanceof Object}catch(t){if(t instanceof hI)return!1;throw t}}async prepareInvocations(t){const e=[];for(const r of t)if(r.type===cI.DECLARE){await this.isClassDeclared("payload"in r?r.payload:r)||e.unshift(r)}else e.push(r);return e}};KS({},{StarknetIdContract:()=>$O,StarknetIdIdentityContract:()=>FO,StarknetIdMulticallContract:()=>qO,StarknetIdPfpContract:()=>ZO,StarknetIdPopContract:()=>JO,StarknetIdVerifierContract:()=>HO,dynamicCallData:()=>XO,dynamicFelt:()=>QO,execution:()=>YO,getStarknetIdContract:()=>LO,getStarknetIdIdentityContract:()=>UO,getStarknetIdMulticallContract:()=>VO,getStarknetIdPfpContract:()=>KO,getStarknetIdPopContract:()=>WO,getStarknetIdVerifierContract:()=>GO,isStarkDomain:()=>tR,useDecoded:()=>BO,useEncoded:()=>DO});var IO="abcdefghijklmnopqrstuvwxyz0123456789-",TO=BigInt(IO.length+1),CO="这来",zO=BigInt(IO.length),OO=BigInt(CO.length),RO=BigInt(CO.length+1);function PO(t){let e=0;for(;t.endsWith(CO[CO.length-1]);)t=t.substring(0,t.length-1),e+=1;return[t,e]}function BO(t){let e="";return t.forEach((t=>{for(;t!==SN;){const r=t%TO;if(t/=TO,r===BigInt(IO.length)){const r=t/RO;if(r===SN){const i=t%RO;t=r,e+=i===SN?IO[0]:CO[Number(i)-1]}else{e+=CO[Number(t%OO)],t/=OO}}else e+=IO[Number(r)]}const[r,i]=PO(e);i&&(e=r+(i%2==0?CO[CO.length-1].repeat(i/2-1)+CO[0]+IO[1]:CO[CO.length-1].repeat((i-1)/2+1))),e+="."})),e?e.concat("stark"):e}function DO(t){let e=BigInt(0),r=BigInt(1);if(t.endsWith(CO[0]+IO[1])){const[e,r]=PO(t.substring(0,t.length-2));t=e+CO[CO.length-1].repeat(2*(r+1))}else{const[e,r]=PO(t);r&&(t=e+CO[CO.length-1].repeat(1+2*(r-1)))}for(let i=0;i<t.length;i+=1){const n=t[i],o=IO.indexOf(n),a=BigInt(IO.indexOf(n));if(-1!==o)i===t.length-1&&t[i]===IO[0]?(e+=r*zO,r*=TO,r*=TO):(e+=r*a,r*=TO);else if(-1!==CO.indexOf(n)){e+=r*zO,r*=TO;const o=(i===t.length-1?1:0)+CO.indexOf(n);e+=r*BigInt(o),r*=OO}}return e}var $O={MAINNET:"0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",TESTNET_SEPOLIA:"0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474"};function LO(t){switch(t){case"0x534e5f4d41494e":return $O.MAINNET;case"0x534e5f5345504f4c4941":return $O.TESTNET_SEPOLIA;default:throw new Error("Starknet.id is not yet deployed on this network")}}var FO={MAINNET:"0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af",TESTNET_SEPOLIA:"0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda"};function UO(t){switch(t){case"0x534e5f4d41494e":return FO.MAINNET;case"0x534e5f5345504f4c4941":return FO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var qO="0x034ffb8f4452df7a613a0210824d6414dbadcddce6c6e19bf4ddc9e22ce5f970";function VO(t){switch(t){case"0x534e5f4d41494e":case"0x534e5f5345504f4c4941":return qO;default:throw new Error("Starknet.id multicall contract is not yet deployed on this network")}}var HO={MAINNET:"0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf",TESTNET_SEPOLIA:"0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566"};function GO(t){switch(t){case"0x534e5f4d41494e":return HO.MAINNET;case"0x534e5f5345504f4c4941":return HO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var ZO={MAINNET:"0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7",TESTNET_SEPOLIA:"0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02"};function KO(t){switch(t){case"0x534e5f4d41494e":return ZO.MAINNET;case"0x534e5f5345504f4c4941":return ZO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id profile picture verifier contract is not yet deployed on this network")}}var JO={MAINNET:"0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4",TESTNET_SEPOLIA:"0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a"};function WO(t){switch(t){case"0x534e5f4d41494e":return JO.MAINNET;case"0x534e5f5345504f4c4941":return JO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id proof of personhood verifier contract is not yet deployed on this network")}}function YO(t,e,r){return new nC({Static:t,IfEqual:e?rC(e[0],e[1],e[2]):void 0,IfNotEqual:r?rC(r[0],r[1],r[2]):void 0})}function QO(t,e){return new nC({Hardcoded:t,Reference:e?rC(e[0],e[1]):void 0})}function XO(t,e,r){return new nC({Hardcoded:t,Reference:e?rC(e[0],e[1]):void 0,ArrayReference:r?rC(r[0],r[1]):void 0})}function tR(t){return/^(?:[a-z0-9-]{1,48}(?:[a-z0-9-]{1,48}[a-z0-9-])?\.)*[a-z0-9-]{1,48}\.stark$/.test(t)}var eR=class extends(US(NO,class t{async getStarkName(e,r){return t.getStarkName(this,e,r)}async getAddressFromStarkName(e,r){return t.getAddressFromStarkName(this,e,r)}async getStarkProfile(e,r,i,n,o,a,s){return t.getStarkProfile(this,e,r,i,n,o,a,s)}static async getStarkName(t,e,r){const i=await t.getChainId(),n=r??LO(i);try{const r=await t.callContract({contractAddress:n,entrypoint:"address_to_domain",calldata:TC.compile({address:e,hint:[]})}),i=BO(r.map((t=>BigInt(t))).slice(1));if(!i)throw Error("Starkname not found");return i}catch(t){if(t instanceof Error&&"Starkname not found"===t.message)throw t;throw Error("Could not get stark name")}}static async getAddressFromStarkName(t,e,r){const i=e.endsWith(".stark")?e:`${e}.stark`;if(!tR(i))throw new Error("Invalid domain, must be a valid .stark domain");const n=await t.getChainId(),o=r??LO(n);try{const e=i.replace(".stark","").split(".").map((t=>DO(t).toString(10)));return(await t.callContract({contractAddress:o,entrypoint:"domain_to_address",calldata:TC.compile({domain:e,hint:[]})}))[0]}catch{throw Error("Could not get address from stark name")}}static async getStarkProfile(t,e,r,i,n,o,a,s){const h=await t.getChainId(),u=r??LO(h),l=i??UO(h),c=n??GO(h),d=o??KO(h),f=a??WO(h),m=s??VO(h);try{const r=[{execution:YO({}),to:XO(u),selector:XO(eT("address_to_domain")),calldata:[XO(e),XO("0")]},{execution:YO({}),to:QO(u),selector:QO(eT("domain_to_id")),calldata:[XO(void 0,void 0,[0,0])]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("twitter")),XO(c),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("github")),XO(c),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("discord")),XO(c),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("proof_of_personhood")),XO(f),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("nft_pp_contract")),XO(d),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_extended_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("nft_pp_id")),XO("2"),XO(d),XO("0")]},{execution:YO(void 0,void 0,[6,0,0]),to:QO(void 0,[6,0]),selector:QO(eT("tokenURI")),calldata:[XO(void 0,[7,1]),XO(void 0,[7,2])]}],i=await t.callContract({contractAddress:m,entrypoint:"aggregate",calldata:TC.compile({calls:r})});if(Array.isArray(i)){const t=parseInt(i[0],16),e=[];let r=1;for(let n=0;n<t&&r<i.length;n+=1){const t=parseInt(i[r],16);r+=1;const n=i.slice(r,r+t);e.push(n),r+=t}const n=BO(e[0].slice(1).map((t=>BigInt(t)))),o="0x0"!==e[2][0]?BigInt(e[2][0]).toString():void 0,a="0x0"!==e[3][0]?BigInt(e[3][0]).toString():void 0,s="0x0"!==e[4][0]?BigInt(e[4][0]).toString():void 0,h="0x1"===e[5][0],u="0x9"===i[0]?e[8].slice(1).map((t=>fT(t))).join(""):void 0;return{name:n,twitter:o,github:a,discord:s,proofOfPersonhood:h,profilePicture:u||`https://starknet.id/api/identicons/${BigInt(e[1][0]).toString()}`}}throw Error("Error while calling aggregate function")}catch(t){if(t instanceof Error)throw t;throw Error("Could not get user stark profile data from address")}}})){},rR=new NO({default:!0});function iR(t){return new AT(t).toBigInt()}function nR(t){return AT.is(t)}function oR(t){return new AT(t).toUint256HexString()}function aR(t){const e=function(t){const e=RI(bN(t.toString()));return bN(vN(e).padStart(64,"0"))}(t);if(!e.match(/^(0x)?[0-9a-fA-F]{64}$/))throw new Error("Invalid Address Format");return FI(e,SN,ON-1n,"Starknet Address"),e}KS({},{UINT_128_MAX:()=>wT,UINT_256_MAX:()=>vT,bnToUint256:()=>oR,isUint256:()=>nR,uint256ToBN:()=>iR});function sR(t){return"event"===t.type}function hR(t){const e=t.filter((t=>sR(t)&&"struct"===t.kind)),r=t.filter((t=>sR(t)&&"enum"===t.kind)),i=e.reduce(((t,e)=>{let i=[],{name:n}=e,o=!1;const a=t=>t.type===n;for(;;){const t=r.find((t=>t.variants.some(a)));if(xI(t))break;const e=t.variants.find(a);i.unshift(e.name),"flat"===e.kind&&(o=!0),n=t.name}if(0===i.length)throw new Error("inconsistency in ABI events definition.");o&&(i=[i[i.length-1]]);const s=i.pop();let h={[bN(Fb(mN(s)).toString(16))]:e};for(;i.length>0;)h={[bN(Fb(mN(i.pop())).toString(16))]:h};return h={...h},lR(t,h)}),{});return i}function uR(t){return YT(t)?hR(t):function(t){return t.filter((t=>"event"===t.type)).reduce(((t,e)=>{const r=e.name,i={...e};return i.name=r,{...t,[bN(Fb(mN(r)).toString(16))]:i}}),{})}(t)}function lR(t,e){const r={...t};return CI(t)&&CI(e)&&Object.keys(e).forEach((i=>{CI(e[i])?i in t?r[i]=lR(t[i],e[i]):Object.assign(r,{[i]:e[i]}):Object.assign(r,{[i]:e[i]})})),r}function cR(t,e,r,i){const n=t.flat().reduce(((t,n)=>{let o=e[n.keys.shift()??0];if(!o)return t;for(;!o.name;){const t=n.keys.shift();jI(!!t,'Not enough data in "keys" property of this event.'),o=o[t]}const a={};a[o.name]={};const s=n.keys[Symbol.iterator](),h=n.data[Symbol.iterator](),u=o.members?.filter((t=>"key"===t.kind))||o.keys,l=o.members?.filter((t=>"data"===t.kind))||o.data;return u.forEach((t=>{a[o.name][t.name]=MC(s,t,r,i,a[o.name])})),l.forEach((t=>{a[o.name][t.name]=MC(h,t,r,i,a[o.name])})),"block_hash"in n&&(a.block_hash=n.block_hash),"block_number"in n&&(a.block_number=n.block_number),"transaction_hash"in n&&(a.transaction_hash=n.transaction_hash),t.push(a),t}),[]);return n}function dR(t){if(!t.events?.length)throw new Error("UDC emitted event is empty");const e=t.events.find((t=>LI(t.from_address)===LI(VN.ADDRESS)))||{data:[]};return{transaction_hash:t.transaction_hash,contract_address:e.data[0],address:e.data[0],deployer:e.data[1],unique:e.data[2],classHash:e.data[3],calldata_len:e.data[4],calldata:e.data.slice(5,5+parseInt(e.data[4],16)),salt:e.data[e.data.length-1]}}KS({},{getAbiEvents:()=>uR,isAbiEvent:()=>sR,parseEvents:()=>cR,parseUDCEvent:()=>dR});function fR(t){const e=t.calldata??[],r=Array.isArray(e)?e:TC.compile(e);return{to:t.contractAddress,selector:eT(t.entrypoint),calldata:r}}function mR(t,e){const r=fR(t);return"1"===e?{...r,calldata_len:r.calldata.length,calldata:r.calldata}:{To:r.to,Selector:r.selector,Calldata:r.calldata}}function pR(t,e){return{name:"Account.execute_from_outside",version:e,chainId:t,..."2"===e?{revision:"1"}:{}}}function gR(t,e,r,i,n){return"1"===n?{types:MI,primaryType:"OutsideExecution",domain:pR(t,n),message:{...e,nonce:r,calls_len:i.length,calls:i.map((t=>mR(t,n)))}}:{types:_I,primaryType:"OutsideExecution",domain:pR(t,n),message:{Caller:e.caller,Nonce:r,"Execute After":e.execute_after,"Execute Before":e.execute_before,Calls:i.map((t=>mR(t,n)))}}}function yR(t){const e=t.outsideExecution,r=kz(t.signature);return TC.compile({outside_execution:e,signature:r})}function wR(t){return(Array.isArray(t)?t:[t]).map((t=>{let e;if("1"===t.version)e="execute_from_outside";else{if("2"!==t.version)throw new Error("Unsupported OutsideExecution version");e="execute_from_outside_v2"}return{contractAddress:RI(t.signerAddress),entrypoint:e,calldata:yR(t)}}))}KS({},{buildExecuteFromOutsideCall:()=>wR,buildExecuteFromOutsideCallData:()=>yR,getOutsideCall:()=>fR,getTypedData:()=>gR});async function vR(t,e,r){const i={contractAddress:RI(e),entrypoint:"supports_interface",calldata:[RI(r)]};try{const e=await t.callContract(i);return 0n!==BigInt(e[0])}catch{return!1}}KS({},{supportsInterface:()=>vR});function bR(t,e=!1){return t.request({type:"wallet_requestAccounts",params:{silent_mode:e}})}function kR(t){return t.request({type:"wallet_getPermissions"})}function MR(t,e){return t.request({type:"wallet_watchAsset",params:e})}function _R(t,e){return t.request({type:"wallet_addStarknetChain",params:e})}function ER(t,e){return t.request({type:"wallet_switchStarknetChain",params:{chainId:e}})}function AR(t){return t.request({type:"wallet_requestChainId"})}function jR(t){return t.request({type:"wallet_deploymentData"})}function xR(t,e){return t.request({type:"wallet_addInvokeTransaction",params:e})}function SR(t,e){return t.request({type:"wallet_addDeclareTransaction",params:e})}function NR(t,e){return t.request({type:"wallet_signTypedData",params:e})}function IR(t){return t.request({type:"wallet_supportedSpecs"})}function TR(t,e){t.on("accountsChanged",e)}function CR(t,e){t.on("networkChanged",e)}KS({},{addDeclareTransaction:()=>SR,addInvokeTransaction:()=>xR,addStarknetChain:()=>_R,deploymentData:()=>jR,getPermissions:()=>kR,onAccountChange:()=>TR,onNetworkChanged:()=>CR,requestAccounts:()=>bR,requestChainId:()=>AR,signMessage:()=>NR,supportedSpecs:()=>IR,switchStarknetChain:()=>ER,watchAsset:()=>MR});var zR=t=>{const e=t[t.length-1];return"object"==typeof e&&["blockIdentifier","parseRequest","parseResponse","formatResponse","maxFee","nonce","signature","addressSalt"].some((t=>t in e))?{args:t,options:t.pop()}:{args:t}};function OR(t,e){return async function(...r){const i=zR(r);return t.call(e.name,i.args,{parseRequest:!0,parseResponse:!0,...i.options})}}function RR(t,e){return"view"===e.stateMutability||"view"===e.state_mutability?OR(t,e):function(t,e){return async function(...r){const i=zR(r);return t.invoke(e.name,i.args,{parseRequest:!0,...i.options})}}(t,e)}function PR(t,e){return function(...r){return t.estimate(e.name,r)}}function BR(t,e){return Array.isArray(t)&&"__compiled__"in t?t:Array.isArray(t)&&Array.isArray(t[0])&&"__compiled__"in t[0]?t[0]:e()}var DR=class{abi;address;providerOrAccount;deployTransactionHash;structs;events;functions;callStatic;populateTransaction;estimateFee;callData;constructor(t,e,r=rR){this.address=e&&e.toLowerCase(),this.providerOrAccount=r,this.callData=new TC(t),this.structs=TC.getAbiStruct(t),this.events=uR(t);const i=dC(t);this.abi=i.getLegacyFormat();const n={enumerable:!0,value:{},writable:!1};Object.defineProperties(this,{functions:{enumerable:!0,value:{},writable:!1},callStatic:{enumerable:!0,value:{},writable:!1},populateTransaction:{enumerable:!0,value:{},writable:!1},estimateFee:{enumerable:!0,value:{},writable:!1}}),this.abi.forEach((t=>{if("function"!==t.type)return;const e=t.name;var r,i;this[e]||Object.defineProperty(this,e,{...n,value:RR(this,t)}),this.functions[e]||Object.defineProperty(this.functions,e,{...n,value:RR(this,t)}),this.callStatic[e]||Object.defineProperty(this.callStatic,e,{...n,value:OR(this,t)}),this.populateTransaction[e]||Object.defineProperty(this.populateTransaction,e,{...n,value:(r=this,i=t,function(...t){return r.populate(i.name,t)})}),this.estimateFee[e]||Object.defineProperty(this.estimateFee,e,{...n,value:PR(this,t)})}))}attach(t){this.address=t}connect(t){this.providerOrAccount=t}async deployed(){return this.deployTransactionHash&&(await this.providerOrAccount.waitForTransaction(this.deployTransactionHash),this.deployTransactionHash=void 0),this}async call(t,e=[],{parseRequest:r=!0,parseResponse:i=!0,formatResponse:n,blockIdentifier:o}={}){jI(null!==this.address,"contract is not connected to an address");const a=BR(e,(()=>r?(this.callData.validate(yI.CALL,t,e),this.callData.compile(t,e)):(Dz.warn("Call skipped parsing but provided rawArgs, possible malfunction request"),e)));return this.providerOrAccount.callContract({contractAddress:this.address,calldata:a,entrypoint:t},o).then((e=>i?n?this.callData.format(t,e,n):this.callData.parse(t,e):e))}invoke(t,e=[],{parseRequest:r=!0,maxFee:i,nonce:n,signature:o}={}){jI(null!==this.address,"contract is not connected to an address");const a=BR(e,(()=>r?(this.callData.validate(yI.INVOKE,t,e),this.callData.compile(t,e)):(Dz.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request"),e))),s={contractAddress:this.address,calldata:a,entrypoint:t};if("execute"in this.providerOrAccount)return this.providerOrAccount.execute(s,void 0,{maxFee:i,nonce:n});if(!n)throw new Error("Nonce is required when invoking a function without an account");return Dz.warn(`Invoking ${t} without an account. This will not work on a public node.`),this.providerOrAccount.invokeFunction({...s,signature:o},{nonce:n})}async estimate(t,e=[]){jI(null!==this.address,"contract is not connected to an address"),BR(e,(()=>!1))||this.callData.validate(yI.INVOKE,t,e);const r=this.populate(t,e);if("estimateInvokeFee"in this.providerOrAccount)return this.providerOrAccount.estimateInvokeFee(r);throw Error("Contract must be connected to the account contract to estimate")}populate(t,e=[]){const r=BR(e,(()=>this.callData.compile(t,e)));return{contractAddress:this.address,entrypoint:t,calldata:r}}parseEvents(t){let e;return t.match({success:t=>{const r=t.events?.map((e=>({block_hash:t.block_hash,block_number:t.block_number,transaction_hash:t.transaction_hash,...e}))).filter((t=>LI(t.from_address)===LI(this.address)),[])||[];e=cR(r,this.events,this.structs,TC.getAbiEnum(this.abi))},_:()=>{throw Error("This transaction was not successful.")}}),e}isCairo1(){return gT.isCairo1Abi(this.abi)}async getVersion(){return this.providerOrAccount.getContractVersion(this.address)}typedv2(t){return this}};const $R={SN_MAIN:"https://starknet-mainnet.public.blastapi.io",SN_SEPOLIA:"https://starknet-sepolia.public.blastapi.io"},LR=[{name:"argent::common::account::IAccount",type:"interface",items:[{name:"is_valid_signature",type:"function",inputs:[{name:"hash",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]}];function FR(t,e){var r;if(!$R[t])throw new Error("Invalid network");return new eR({nodeUrl:null!==(r=null==e?void 0:e.broviderUrl)&&void 0!==r?r:$R[t]})}function UR(t){return!!t.primaryType&&!!t.types.StarkNetDomain}function qR(t,e){const{domain:r,types:i,primaryType:n,message:o}=t;return lO.getMessageHash({types:i,primaryType:n,domain:r,message:o},e)}var VR=Object.freeze({__proto__:null,isStarknetMessage:UR,getHash:qR,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="SN_MAIN",n={}){try{const o=new DR(LR,t,FR(i,n));if(e.length<2)throw new Error("Invalid signature format");const a=yield o.is_valid_signature(qR(r,t),e.slice(-2));return eh.from(a).eq(eh.from("370462705988"))}catch(t){if(t.message.includes("Contract not found"))throw new Error("Contract not deployed");throw t}}))}});function HR(t){return mr(ui(t))}var GR=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Tt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var ZR=GR.BN;const KR=new Ut("bignumber/5.6.2"),JR={},WR=9007199254740991;let YR=!1;class QR{constructor(t,e){t!==JR&&KR.throwError("cannot call constructor directly; use BigNumber.from",Ut.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return tP(eP(this).fromTwos(t))}toTwos(t){return tP(eP(this).toTwos(t))}abs(){return"-"===this._hex[0]?QR.from(this._hex.substring(1)):this}add(t){return tP(eP(this).add(eP(t)))}sub(t){return tP(eP(this).sub(eP(t)))}div(t){return QR.from(t).isZero()&&rP("division-by-zero","div"),tP(eP(this).div(eP(t)))}mul(t){return tP(eP(this).mul(eP(t)))}mod(t){const e=eP(t);return e.isNeg()&&rP("division-by-zero","mod"),tP(eP(this).umod(e))}pow(t){const e=eP(t);return e.isNeg()&&rP("negative-power","pow"),tP(eP(this).pow(e))}and(t){const e=eP(t);return(this.isNegative()||e.isNeg())&&rP("unbound-bitwise-result","and"),tP(eP(this).and(e))}or(t){const e=eP(t);return(this.isNegative()||e.isNeg())&&rP("unbound-bitwise-result","or"),tP(eP(this).or(e))}xor(t){const e=eP(t);return(this.isNegative()||e.isNeg())&&rP("unbound-bitwise-result","xor"),tP(eP(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&rP("negative-width","mask"),tP(eP(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&rP("negative-width","shl"),tP(eP(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&rP("negative-width","shr"),tP(eP(this).shrn(t))}eq(t){return eP(this).eq(eP(t))}lt(t){return eP(this).lt(eP(t))}lte(t){return eP(this).lte(eP(t))}gt(t){return eP(this).gt(eP(t))}gte(t){return eP(this).gte(eP(t))}isNegative(){return"-"===this._hex[0]}isZero(){return eP(this).isZero()}toNumber(){try{return eP(this).toNumber()}catch(t){rP("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return KR.throwError("this platform does not support BigInt",Ut.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?YR||(YR=!0,KR.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?KR.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ut.errors.UNEXPECTED_ARGUMENT,{}):KR.throwError("BigNumber.toString does not accept parameters",Ut.errors.UNEXPECTED_ARGUMENT,{})),eP(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof QR)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new QR(JR,XR(t)):t.match(/^-?[0-9]+$/)?new QR(JR,XR(new ZR(t))):KR.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&rP("underflow","BigNumber.from",t),(t>=WR||t<=-WR)&&rP("overflow","BigNumber.from",t),QR.from(String(t));const e=t;if("bigint"==typeof e)return QR.from(e.toString());if(Kt(e))return QR.from(te(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return QR.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(Qt(t)||"-"===t[0]&&Qt(t.substring(1))))return QR.from(t)}return KR.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function XR(t){if("string"!=typeof t)return XR(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&KR.throwArgumentError("invalid hex","value",t),"0x00"===(t=XR(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function tP(t){return QR.from(XR(t))}function eP(t){const e=QR.from(t).toHexString();return"-"===e[0]?new ZR("-"+e.substring(3),16):new ZR(e.substring(2),16)}function rP(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),KR.throwError(t,Ut.errors.NUMERIC_FAULT,i)}var iP=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const nP=new Ut("hash/5.6.1"),oP=new Uint8Array(32);oP.fill(0);const aP=QR.from(-1),sP=QR.from(0),hP=QR.from(1),uP=QR.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const lP=oe(hP.toHexString(),32),cP=oe(sP.toHexString(),32),dP={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},fP=["name","version","chainId","verifyingContract","salt"];function mP(t){return function(e){return"string"!=typeof e&&nP.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const pP={name:mP("name"),version:mP("version"),chainId:function(t){try{return QR.from(t).toString()}catch(t){}return nP.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return xr(t).toLowerCase()}catch(t){}return nP.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=Jt(t);if(32!==e.length)throw new Error("bad length");return te(e)}catch(t){}return nP.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function gP(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],i=parseInt(e[2]||"256");(i%8!=0||i>256||e[2]&&e[2]!==String(i))&&nP.throwArgumentError("invalid numeric width","type",t);const n=uP.mask(r?i-1:i),o=r?n.add(hP).mul(aP):sP;return function(e){const r=QR.from(e);return(r.lt(o)||r.gt(n))&&nP.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),oe(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&nP.throwArgumentError("invalid bytes width","type",t),function(e){return Jt(e).length!==r&&nP.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=Jt(t),r=e.length%32;return r?ie([e,oP.slice(r)]):te(e)}(e)}}}switch(t){case"address":return function(t){return oe(xr(t),32)};case"bool":return function(t){return t?lP:cP};case"bytes":return function(t){return mr(t)};case"string":return function(t){return HR(t)}}return null}function yP(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class wP{constructor(t){ve(this,"types",Object.freeze(je(t))),ve(this,"_encoderCache",{}),ve(this,"_types",{});const e={},r={},i={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],i[t]={}}));for(const i in t){const n={};t[i].forEach((o=>{n[o.name]&&nP.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(i)}`,"types",t),n[o.name]=!0;const a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===i&&nP.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",t);gP(a)||(r[a]||nP.throwArgumentError(`unknown type ${JSON.stringify(a)}`,"types",t),r[a].push(i),e[i][a]=!0)}))}const n=Object.keys(r).filter((t=>0===r[t].length));0===n.length?nP.throwArgumentError("missing primary type","types",t):n.length>1&&nP.throwArgumentError(`ambiguous primary types or unused types: ${n.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),ve(this,"primaryType",n[0]),function n(o,a){a[o]&&nP.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),a[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(n(t,a),Object.keys(a).forEach((e=>{i[e][t]=!0})))})),delete a[o]}(this.primaryType,{});for(const e in i){const r=Object.keys(i[e]);r.sort(),this._types[e]=yP(e,t[e])+r.map((e=>yP(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=gP(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),i=parseInt(e[3]);return e=>{i>=0&&e.length!==i&&nP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let n=e.map(r);return this._types[t]&&(n=n.map(mr)),mr(ie(n))}}const r=this.types[t];if(r){const e=HR(this._types[t]);return t=>{const i=r.map((({name:e,type:r})=>{const i=this.getEncoder(r)(t[e]);return this._types[r]?mr(i):i}));return i.unshift(e),ie(i)}}return nP.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||nP.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return mr(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(gP(t))return r(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const t=i[1],n=parseInt(i[3]);return n>=0&&e.length!==n&&nP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const n=this.types[t];return n?n.reduce(((t,{name:i,type:n})=>(t[i]=this._visit(n,e[i],r),t)),{}):nP.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new wP(t)}static getPrimaryType(t){return wP.from(t).primaryType}static hashStruct(t,e,r){return wP.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const i=dP[r];i||nP.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort(((t,e)=>fP.indexOf(t.name)-fP.indexOf(e.name))),wP.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return ie(["0x1901",wP.hashDomain(t),wP.from(e).hash(r)])}static hash(t,e,r){return mr(wP.encode(t,e,r))}static resolveNames(t,e,r,i){return iP(this,void 0,void 0,(function*(){t=Me(t);const n={};t.verifyingContract&&!Qt(t.verifyingContract,20)&&(n[t.verifyingContract]="0x");const o=wP.from(e);o.visit(r,((t,e)=>("address"!==t||Qt(e,20)||(n[e]="0x"),e)));for(const t in n)n[t]=yield i(t);return t.verifyingContract&&n[t.verifyingContract]&&(t.verifyingContract=n[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&n[e]?n[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){wP.hashDomain(t);const i={},n=[];fP.forEach((e=>{const r=t[e];null!=r&&(i[e]=pP[e](r),n.push({name:e,type:dP[e]}))}));const o=wP.from(e),a=Me(e);return a.EIP712Domain?nP.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):a.EIP712Domain=n,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return te(Jt(e));if(t.match(/^u?int/))return QR.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&nP.throwArgumentError("invalid string","value",e),e}return nP.throwArgumentError("unsupported type","type",t)}))}}}window&&window.__awaiter;new Ut("wallet/5.6.2");function vP(t,e,r,i){return as(wP.hash(t,e,r),i)}const bP="6492649264926492649264926492649264926492649264926492649264926492";function kP(t,e){return t.toLowerCase()===e.toLowerCase()}function MP(t){const{domain:e,types:r,message:i}=t;return hl.hash(e,r,i)}function _P(t,e,i,n){return r(this,void 0,void 0,(function*(){let r;try{r=yield uB(n,["function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[Jt(i),e]])}catch(t){if(t.message.startsWith("missing revert data in call exception"))return!1;throw t}return kP(r,"0x1626ba7e")}))}function EP(t,e,i,n){return r(this,void 0,void 0,(function*(){return kP(yield uB(n,["function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[Jt(i),e]]),"0x20c13b0b")}))}var AP=Object.freeze({__proto__:null,getHash:MP,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){const{domain:o,types:a,message:s}=r;try{if(kP(t,vP(o,a,s,e)))return!0}catch(t){}const h=qp(i,n),u=MP(r);if(e.endsWith(bP))try{return"0x01"===(yield h.call({data:Wt(["0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",(new Ni).encode(["address","bytes32","bytes"],[t,Jt(u),e])])}))}catch(t){return!1}return!!(yield _P(t,e,u,h))||(yield EP(t,e,u,h))}))}});var jP=["ipfs.snapshot.box","snapshot.4everland.link","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],xP={1:{key:"1",name:"Ethereum",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolvers:["0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63","0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],ensNameWrapper:"0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",rpc:["https://rpc.ankr.com/eth",{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],light:["https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:{url:"https://etherscan.io",apiUrl:"https://api.etherscan.io"},start:7929876,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},8:{key:"8",name:"Ubiq",chainId:8,network:"Ubiq",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:{url:"https://ubiqscan.io"},start:1,logo:"ipfs://Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"OP Mainnet",chainId:10,network:"OP Mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:{url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io"},start:657806,logo:"ipfs://bafkreifu2remiqfpsb4hgisbwb3qxedrzpwsea7ik4el45znjcf56xf2ku"},19:{key:"19",name:"Songbird Canary-Network",shortName:"Songbird",chainId:19,network:"songbird",multicall:"0x17032Ea9c3a13Ed337665145364c0d2aD1108c91",rpc:["https://songbird-api.flare.network/ext/C/rpc"],explorer:{url:"https://songbird-explorer.flare.network"},start:21807126,logo:"ipfs://QmXyvnrZY8FUxSULfnKKA99sAEkjAHtvhRx5WeHixgaEdu"},24:{key:"24",name:"KardiaChain Mainnet",shortName:"KAI",chainId:24,network:"mainnet",multicall:"0xd9c92F2287B7802A37eC9BEce96Aa65fb5f31E1b",rpc:["https://kai-internal.kardiachain.io"],explorer:{url:"https://explorer.kardiachain.io"},start:8260245,logo:"ipfs://bafkreig73yfyqzbxydv6e3dbj5nks3f57px2iez7tywayey4rilfhhrr34"},25:{key:"25",name:"Cronos",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:{url:"https://cronos.crypto.org/explorer"},start:4067,logo:"ipfs://QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:{url:"https://explorer.rsk.co"},start:2516442,logo:"ipfs://QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},46:{key:"46",name:"Darwinia Network",shortName:"Darwinia",chainId:46,network:"mainnet",multicall:"0x67f9ae42EaA9a8aBf065D60ec6Ab3C1A11370607",rpc:["https://rpc.darwinia.network"],explorer:{url:"https://darwinia.subscan.io"},start:141853,logo:"ipfs://bafkreicf55maidhx46pyu3mwsshlr43xbewr6tkckkonh4nesbkp7krwkm"},56:{key:"56",name:"BNB Smart Chain",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://rpc.ankr.com/bsc","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org"],explorer:{url:"https://bscscan.com"},start:461230,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},61:{key:"61",name:"Ethereum Classic",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"0x51be3a92C56ae7E207C5b5Fd87F7798Ce82C1AC2",rpc:["https://www.ethercluster.com/etc"],explorer:{url:"https://blockscout.com/etc/mainnet"},start:13307544,logo:"ipfs://QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},66:{key:"66",name:"OKExChain",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:{url:"https://www.oklink.com/okexchain"},start:5076543,logo:"ipfs://Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},75:{key:"75",name:"Decimal",shortName:"mainnet",chainId:75,network:"mainnet",multicall:"0x949d1A0757803C51F2EfFFEb5472C861A898B8E8",rpc:[],explorer:{url:"https://explorer.decimalchain.com"},start:16031065,logo:"ipfs://bafkreihkdhbce5rkogl63xegaarlirjrvbfarxbtbf5mqme3s5grvbjyxm"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:{url:"https://blockscout.com/shibuya"},start:856303,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:{url:"https://scan.meter.io"},start:4992871,logo:"ipfs://QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"BNB Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://data-seed-prebsc-1-s1.binance.org:8545","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive"],explorer:{url:"https://testnet.bscscan.com"},start:3599656,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://gno.getblock.io/mainnet/6c1d1e6e-75d9-452f-a863-a694bff93d5c/","https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],light:["https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:{url:"https://gnosis.blockscout.com"},start:4108192,logo:"ipfs://QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},108:{key:"108",name:"Thundercore",chainId:108,network:"mainnet",multicall:"0x3017086deef56679e267f67f66c4415109b7a97f",rpc:["https://mainnet-rpc.thundercore.com/archived/SNAPSHOTEuR82a75fLYA"],explorer:{url:"https://viewblock.io/thundercore"},start:94425385,logo:"ipfs://bafkreifc5z5vtvqx2luzgateyvoocwpd2ifv2hwufxdnyl2a767wa6icli"},109:{key:"109",name:"Shibarium",shortName:"mainnet",chainId:109,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://shibariumscan.io"},start:3485946,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm"},122:{key:"122",name:"Fuse",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://explorer-node.fuse.io/","https://oefusefull1.liquify.info/"],explorer:{url:"https://explorer.fuse.io"},start:11923459,logo:"ipfs://QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},137:{key:"137",name:"Polygon PoS",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://rpc.ankr.com/polygon","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"],ws:["wss://ws-mainnet.matic.network"],explorer:{url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com"},start:9834491,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},144:{key:"144",name:"PHI Network",shortName:"PHI",chainId:144,network:"mainnet",multicall:"0xc2f41B404a6757863AAeF49ff93039421acCd630",rpc:["https://connect.phi.network"],explorer:{url:"https://phiscan.com"},start:360030,logo:"ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"},146:{key:"146",name:"Sonic",shortName:"mainnet",chainId:146,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.soniclabs.com"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44"},148:{key:"148",name:"ShimmerEVM",shortName:"ShimmerEVM",chainId:148,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.evm.shimmer.network"},start:1290,logo:"ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"},157:{key:"157",name:"Shibarium Puppynet Testnet",shortName:"testnet",chainId:157,network:"testnet",multicall:"0xA4029b74FBA366c926eDFA7Dd10B21C621170a4c",rpc:[],explorer:{url:"https://puppyscan.shib.io"},start:3035769,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm",testnet:!0},169:{key:"169",name:"Manta Pacific",shortName:"Manta",chainId:169,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.oklink.com/manta"},start:332890,logo:"ipfs://bafkreibbrwgwdcfh755dqh4ndta6tja77qbaa36bfv4pstub6prhhore7a"},204:{key:"204",name:"opBNB",shortName:"mainnet",chainId:204,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"http://opbnbscan.com"},start:512881,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:{url:"https://explorer.energyweb.org"},start:12086501,logo:"ipfs://Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ankr.com/fantom","https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:{url:"https://ftmscan.com"},start:2497732,logo:"ipfs://QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},252:{key:"252",name:"Fraxtal",shortName:"mainnet",chainId:252,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu"},269:{key:"269",name:"High Performance Blockchain",shortName:"HPB",chainId:269,network:"mainnet",multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:{url:"https://hscan.org"},start:13960096,logo:"ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},296:{key:"296",name:"Hedera Testnet",shortName:"testnet",chainId:296,network:"testnet",multicall:"0xADE3166b0afA89b2CDB64870D70ADeD330Eab015",rpc:[],explorer:{url:"https://hashscan.io/testnet"},start:17561901,logo:"ipfs://bafkreia5gpitwgo4sspvvtwqcxosq2krrqo5dbrnvylgibvmypzotfmbuu",testnet:!0},300:{key:"300",name:"zkSync Sepolia Testnet",shortName:"testnet",chainId:300,network:"testnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:[],explorer:{url:"https://sepolia.explorer.zksync.dev"},start:2292,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy",testnet:!0},314:{key:"314",name:"Filecoin",shortName:"mainnet",chainId:314,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://filfox.io"},start:3328594,logo:"ipfs://bafybeibyvjfmk6aqlfdrczvth55jkmnoadtrch7ht3rdmvqmy2bfxynecm"},321:{key:"321",name:"KCC",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:{url:"https://explorer.kcc.io"},start:1487453,logo:"ipfs://QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},324:{key:"324",name:"zkSync Era",shortName:"zkSync-era",chainId:324,network:"zkSync Era Mainnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:["https://mainnet.era.zksync.io"],explorer:{url:"https://explorer.zksync.io"},start:3908235,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:{url:"https://blockscout.com/shiden"},start:1170016,logo:"ipfs://QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},369:{key:"369",name:"Pulsechain",shortName:"Pulsechain",chainId:369,network:"mainnet",multicall:"0xdbdd0FD8B16F0092f306392b699D7fbddaA9011B",rpc:["https://rpc.pulsechain.com"],explorer:{url:"https://scan.pulsechain.com"},start:17657774,logo:"ipfs://QmWUsiEWdejtHZ9B9981TYXn7Ds8C7fkB1S4h5rP3kCCZR"},416:{key:"416",name:"SX Network",shortName:"SX",chainId:416,network:"mainnet",multicall:"0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",rpc:["https://rpc.sx.technology"],ws:["wss://rpc.sx.technology/ws"],explorer:{url:"https://explorer.sx.technology"},start:2680605,logo:"ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://astar.api.onfinality.io/public","https://rpc.astar.network:8545"],explorer:{url:"https://blockscout.com/astar"},start:366482,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},813:{key:"813",name:"Qitmeer",shortName:"MEER",chainId:813,network:"mainnet",multicall:"0x55034b2cF530ae3A8fC1e2e4523F58496796610F",rpc:["https://evm-dataseed1.meerscan.io","https://evm-dataseed.meerscan.com","https://evm-dataseed2.meerscan.io","https://evm-dataseed3.meerscan.io"],explorer:{url:"https://evm.meerscan.io"},start:43317,logo:"ipfs://QmXvum7SNVaAqAc2jNzR1NpNZN1GGvNaKWydg8a1GEDQ7y"},841:{key:"841",name:"Taraxa",shortName:"841",chainId:841,network:"mainnet",multicall:"0xFCe7a3121B42664AaD145712e1c2Bf2e38f60AA1",rpc:["https://rpc.mainnet.taraxa.io"],ws:["wss://ws.mainnet.taraxa.io"],explorer:{url:"https://mainnet.explorer.taraxa.io"},start:1515906,logo:"ipfs://Qmcc6ZCAGESMzZzoj5LsTVcCo2E35x3Ydk71uPJyov6Mwx"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:{url:"https://www.wanscan.org"},start:11302663,logo:"ipfs://QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},1001:{key:"1001",name:"Kaia Kairos Testnet",shortName:"kaia-kairos",chainId:1001,network:"testnet",testnet:!0,multicall:"0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",rpc:["https://archive-en-kairos.node.kaia.io"],ws:["wss://archive-en-kairos.node.kaia.io/ws"],explorer:{url:"https://kairos.kaiascan.com"},start:87232478,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},1072:{key:"1072",name:"Shimmer EVM Testnet",shortName:"ShimmerEVM",chainId:1072,network:"testnet",testnet:!0,multicall:"0x751d21047C116413895c259f3f305e38C10B7cF6",rpc:["https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"],explorer:{url:"https://explorer.evm.testnet.shimmer.network"},start:10614,logo:"ipfs://bafkreihtwfwrue7klzedwx4rqlk6agklz4lbbk7owsyw6xzn6c2m4t5tgy"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:{url:"https://andromeda-explorer.metis.io"},start:451,logo:"ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"},1101:{key:"1101",name:"Polygon zkEVM",shortName:"mainnet",chainId:1101,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://zkevm.polygonscan.com"},start:57746,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm"},1116:{key:"1116",name:"Core Chain",shortName:"Core",chainId:1116,network:"mainnet",multicall:"0x024f0041b76B598c2A0a75004F8447FaF67BD004",rpc:["https://rpcar.coredao.org/"],explorer:{url:"https://scan.coredao.org"},start:853908,logo:"ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:{url:"https://moonscan.io"},start:171135,logo:"ipfs://QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:{url:"https://blockscout.moonriver.moonbeam.network"},start:413539,logo:"ipfs://QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:{url:"https://moonbase-blockscout.testnet.moonbeam.network"},start:859041,logo:"ipfs://QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},1315:{key:"1315",name:"Story Aeneid Testnet",shortName:"testnet",chainId:1315,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://aeneid.storyscan.io"},start:1792,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne",testnet:!0},1328:{key:"1328",name:"Sei atlantic testnet",shortName:"testnet",chainId:1328,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://seitrace.com"},start:96978658,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},1329:{key:"1329",name:"Sei",shortName:"mainnet",chainId:1329,network:"mainnet",multicall:"0xe033Bed7cae4114Af84Be1e9F1CA7DEa07Dfe1Cf",rpc:[],explorer:{url:"https://seitrace.com"},start:79164574,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq"},1480:{key:"1480",name:"Vana",shortName:"mainnet",chainId:1480,network:"mainnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://islander.vanascan.io"},start:716763,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa"},1514:{key:"1514",name:"Story",shortName:"mainnet",chainId:1514,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.storyscan.io"},start:340998,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne"},1559:{key:"1559",name:"Tenet",shortName:"tenet",chainId:1559,network:"mainnet",multicall:"0xcCB3F00bE353950E4C08501ac8Af48765EAAa738",rpc:[],explorer:{url:"https://tenetscan.io"},start:944415,logo:"ipfs://Qmc1gqjWTzNo4pyFSGtQuCu7kRSZZBUVybtTjHn2nNEEPA"},1663:{key:"1663",name:"Horizen Gobi Testnet",shortName:"Gobi",chainId:1663,network:"testnet",testnet:!0,multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:["https://gobi-testnet.horizenlabs.io/ethv1"],explorer:{url:"https://gobi-explorer.horizen.io"},start:1,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},2e3:{key:"2000",name:"Doge Chain",shortName:"dogechain",chainId:2e3,network:"mainnet",multicall:"0x6f9D3f3932B417bd4957585D236Cbc32b32C0BDc",rpc:["https://rpc.dogechain.dog"],explorer:{url:"https://explorer.dogechain.dog"},start:877115,logo:"ipfs://bafkreigovfh3pinsdih777issfgaflwu2yjzroljs2642gbvwikcd3nm4i"},2109:{key:"2109",name:"Exosama Network",shortName:"EXN",chainId:2109,network:"mainnet",multicall:"0x2feFC828e2fEfdE0C9f7740919c6A9139F886067",rpc:["https://rpc.exosama.com"],explorer:{url:"https://explorer.exosama.com"},start:94085,logo:"ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"},2152:{key:"2152",name:"Findora",shortName:"Findora",chainId:2152,network:"mainnet",multicall:"0xCF7D1e21CBe9bdEF235aef06C5d8051B3d4DF0f5",rpc:["https://archive.prod.findora.org:8545/"],explorer:{url:"https://evm.findorascan.io"},start:4219343,logo:"ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"},2192:{key:"2192",name:"SnaxChain",shortName:"mainnet",chainId:2192,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.snaxchain.io"},start:1554893,logo:"ipfs://bafkreibzz757piho2llzkbiszpvalf5k5hpmxcwhvrmgp7vpz2vp4vj7ly"},2221:{key:"2221",name:"Kava Testnet",shortName:"testnet",chainId:2221,network:"testnet",multicall:"0xc7193EFE367DF0C9349a1149F4E95A2A35604262",rpc:[],explorer:{url:"https://testnet.kavascan.com"},start:6193104,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4",testnet:!0},2222:{key:"2222",name:"Kava",shortName:"mainnet",chainId:2222,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://kavascan.com"},start:3661165,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4"},2400:{key:"2400",name:"TCG Verse",shortName:"TCGV",chainId:2400,network:"mainnet",multicall:"0xceC65DEE0b5012F1b7321b2647681F997c7204FC",rpc:["https://rpc.tcgverse.xyz"],explorer:{url:"https://explorer.tcgverse.xyz"},start:57500,logo:"ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"},2522:{key:"2522",name:"Fraxtal Testnet",shortName:"testnet",chainId:2522,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://holesky.fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu",testnet:!0},3338:{key:"3338",name:"peaq",shortName:"mainnet",chainId:3338,network:"mainnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://peaq.subscan.io"},start:3525964,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm"},4162:{key:"4162",name:"SX Rollup",shortName:"mainnet",chainId:4162,network:"mainnet",multicall:"0x46997eb05F6A6A0bD5C140ABed09Cb02CA36b98c",rpc:[],explorer:{url:"https://explorerl2.sx.technology"},start:1847483,logo:"ipfs://bafkreibjkjx7evbw74e3sx65dtmcdr4g2rrbcorb2ivd6jz6yh6on6ozw4"},4200:{key:"4200",name:"Merlin",shortName:"merlin",chainId:4200,network:"mainnet",multicall:"0x830E7E548F4D80947a40A7Cf3a2a53166a0C3980",rpc:[],explorer:{url:"https://scan.merlinchain.io"},start:589494,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe"},4337:{key:"4337",name:"Beam",shortName:"Beam",chainId:4337,network:"mainnet",multicall:"0x4956F15eFdc3dC16645e90Cc356eAFA65fFC65Ec",rpc:[],explorer:{url:"https://subnets.avax.network/beam"},start:1,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF"},4689:{key:"4689",name:"IoTeX",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:{url:"https://iotexscan.io"},start:11533283,logo:"ipfs://QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5e3:{key:"5000",name:"Mantle",chainId:5e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.mantle.xyz"],explorer:{url:"https://mantlescan.xyz"},start:304717,logo:"ipfs://bafkreidkucwfn4mzo2gtydrt2wogk3je5xpugom67vhi4h4comaxxjzoz4"},5555:{key:"5555",name:"Chain Verse",shortName:"ChainVerse",chainId:5555,network:"ChainVerse",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.chainverse.info"],explorer:{url:"https://explorer.chainverse.info"},start:6334180,logo:"ipfs://QmQyJt28h4wN3QHPXUQJQYQqGiFUD77han3zibZPzHbitk"},5611:{key:"5611",name:"opBNB Testnet",shortName:"testnet",chainId:5611,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://opbnb-testnet.bscscan.com"},start:3705108,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64",testnet:!0},6102:{key:"6102",name:"Cascadia Testnet",shortName:"Cascadia",chainId:6102,network:"testnet",multicall:"0x728989819bAD588F193563008E0a03E8cD6a3e4a",rpc:["https://testnet.cascadia.foundation"],explorer:{url:"https://explorer.cascadia.foundation"},testnet:!0,start:370457,logo:"ipfs://QmWkhZYhReYyaa5pQXj32hEGxoRcBqarFMcfQScELmjYQj"},6900:{key:"6900",name:"Animechain Testnet",shortName:"testnet",chainId:6900,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-testnet-i8yja6a1a0.t.conduit.xyz"},start:1666749,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi",testnet:!0},7332:{key:"7332",name:"Horizen EON",shortName:"EON",chainId:7332,network:"mainnet",multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:[],explorer:{url:"https://eon-explorer.horizenlabs.io"},start:85108,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:{url:"https://bx.shyft.network"},start:3673983,logo:"ipfs://bafkreifwxnnfk6koabzmxgcxcwlrwt6b5gijdain2gyqee77q4ajfb7fu4"},7560:{key:"7560",name:"Cyber",shortName:"mainnet",chainId:7560,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://cyberscan.co"},start:1731707,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm"},8217:{key:"8217",name:"Kaia Mainnet",shortName:"kaia-mainnet",chainId:8217,network:"mainnet",multicall:"0x5f5f0d1b9ff8b3dcace308e39b13b203354906e9",rpc:["https://archive-en.node.kaia.io"],ws:["wss://archive-en.node.kaia.io/ws"],explorer:{url:"https://kaiascan.com"},start:91582357,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},8453:{key:"8453",name:"Base",shortName:"mainnet",chainId:8453,network:"mainnet",multicall:"0xca11bde05977b3631167028862be2a173976ca11",rpc:[],explorer:{url:"https://basescan.org"},start:5022,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"},9001:{key:"9001",name:"Evmos Network",shortName:"Evmos",chainId:9001,network:"mainnet",multicall:"0x37763d16f8dBf6F185368E0f256350cAb7E24b26",rpc:["https://eth.bd.evmos.org:8545"],ws:["wss://eth.bd.evmos.org:8546"],explorer:{url:"https://escan.live"},start:13959539,logo:"ipfs://bafkreif4obrdoiretpozdd56seziywc6clha7wwkbldng3ovry2bpzly34"},9990:{key:"9990",name:"Agung testnet",shortName:"testnet",chainId:9990,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://agung-testnet.subscan.io"},start:2031789,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm",testnet:!0},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:{url:"https://smartbch-explorer.web.app"},start:268248,logo:"ipfs://QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},10243:{key:"10243",name:"Arthera Testnet",shortName:"Arthera_",chainId:10243,network:"testnet",testnet:!0,multicall:"0x27c7FC597aD2E81C4c1cA1769972f79DaF042Da7",rpc:["https://rpc-test.arthera.net"],explorer:{url:"https://explorer-test.arthera.net"},start:10523,logo:"ipfs://QmYQp3e52KjkT4bYdAvB6ACEEpXs2D8DozsDitaADRY2Ak"},13337:{key:"13337",name:"Beam Testnet",shortName:"testnet",chainId:13337,network:"testnet",multicall:"0x9BF49b704EE2A095b95c1f2D4EB9010510c41C9E",rpc:[],explorer:{url:"https://subnets-test.avax.network/beam"},start:3,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",testnet:!0},13371:{key:"13371",name:"Immutable zkEVM",shortName:"mainnet",chainId:13371,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.immutable.com"},start:3680945,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"},13473:{key:"13473",name:"Immutable zkEVM Testnet",shortName:"testnet",chainId:13473,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.testnet.immutable.com"},start:5307209,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",testnet:!0},14800:{key:"14800",name:"Vana Moksha Testnet",shortName:"testnet",chainId:14800,network:"testnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://moksha.vanascan.io"},start:732283,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa",testnet:!0},16718:{key:"16718",name:"AirDAO",chainId:16718,network:"mainnet",multicall:"0x25e81aC81A8B03389D78CB45faB78353aB528574",rpc:["https://network-archive.ambrosus.io"],ws:["wss://network-archive.ambrosus.io/ws"],explorer:{url:"https://airdao.io/explorer"},start:22922566,logo:"ipfs://QmSxXjvWng3Diz4YwXDV2VqSPgMyzLYBNfkjJcr7rzkxom"},29548:{key:"29548",name:"MCH Verse",shortName:"mainnet",chainId:29548,network:"mainnet",multicall:"0x1d39652386488CE1fE4254E105F5A42a04d43dB2",rpc:[],explorer:{url:"https://explorer.oasys.mycryptoheroes.net"},start:27458402,logo:"ipfs://QmZZnwR1y6cU1sare2TQmwqkNDLXQxD4GdPrmHLmUoPtbU"},33111:{key:"33111",name:"Curtis",shortName:"apechain",chainId:33111,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://curtis.apescan.io"},start:6661339,logo:"ipfs://bafkreicljxttjq2xkgfwwpii5xegirgq2ctrnsjnzelxudjj33qzq65apu",testnet:!0},33139:{key:"33139",name:"ApeChain",shortName:"mainnet",chainId:33139,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://apescan.io"},start:20889,logo:"ipfs://bafkreielbgcox2jsw3g6pqulqb7pyjgx7czjt6ahnibihaij6lozoy53w4"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://rpc.ankr.com/arbitrum","https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet","https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:{url:"https://arbiscan.io"},start:256508,logo:"ipfs://QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42170:{key:"42170",name:"Arbitrum Nova",chainId:42170,network:"Arbitrum Nova",multicall:"0x4E74EBd9CABff51cE9a43EFe059bA8c5A28E4A14",rpc:["https://nova.arbitrum.io/rpc","https://arbitrum-nova.public.blastapi.io"],explorer:{url:"https://nova.arbiscan.io"},start:6006607,logo:"ipfs://bafkreie5xsqt3mrrwu7v32qpmmctibhzhgxf4emfzzddsdhdlfsa7fmplu"},42220:{key:"42220",name:"Celo",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:{url:"https://explorer.celo.org"},start:6599803,logo:"ipfs://QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},43113:{key:"43113",name:"Avalanche FUJI Testnet",chainId:43113,network:"testnet",testnet:!0,multicall:"0x984476ea55e32e785A9D8FF14329f99D74E3d2A2",rpc:["https://api.avax-test.network/ext/bc/C/rpc"],explorer:{url:"https://testnet.snowtrace.io"},start:10528153,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:{url:"https://snowtrace.io"},start:536483,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:{url:"https://scan.rei.network"},start:1715902,logo:"ipfs://QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},53935:{key:"53935",name:"DFK Chain",chainId:53935,network:"mainnet",multicall:"0x5b24224dC16508DAD755756639E420817DD4c99E",rpc:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"],explorer:{url:"https://subnets.avax.network/defi-kingdoms"},start:62,logo:"ipfs://QmZNkpVgPbuVbDcsi6arwH1om3456FGnwfDqYQJWUfHDEx"},57054:{key:"57054",name:"Sonic Blaze Testnet",shortName:"testnet",chainId:57054,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://testnet.sonicscan.org"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44",testnet:!0},57073:{key:"57073",name:"Ink",shortName:"mainnet",chainId:57073,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.inkonchain.com"},start:6659154,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju"},59141:{key:"59141",name:"Linea Sepolia",shortName:"testnet",chainId:59141,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.lineascan.build"},start:227427,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce",testnet:!0},59144:{key:"59144",name:"Linea",shortName:"linea",chainId:59144,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://lineascan.build"},start:42,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce"},69e3:{key:"69000",name:"Animechain",shortName:"mainnet",chainId:69e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-39xf6m45e3.t.conduit.xyz"},start:23482,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi"},80001:{key:"80001",name:"Polygon Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:{url:"https://mumbai.polygonscan.com",apiUrl:"https://api-mumbai.polygonscan.com"},start:12011090,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},80002:{key:"80002",name:"Polygon Amoy Testnet",shortName:"testnet",chainId:80002,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://amoy.polygonscan.com"},start:3127388,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm",testnet:!0},81457:{key:"81457",name:"Blast",shortName:"mainnet",chainId:81457,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://blastscan.io"},start:88189,logo:"ipfs://bafkreicqhrimt2zyp2kvhmbpvffxlmxovkg5vw6zkissyzibcfy45kbvrm"},84532:{key:"84532",name:"Base Sepolia",shortName:"testnet",chainId:84532,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://base-sepolia.blockscout.com"},start:1059647,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",testnet:!0},314159:{key:"314159",name:"Filecoin Calibration Testnet",shortName:"testnet",chainId:314159,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://calibration.filscan.io/en"},start:1446201,logo:"ipfs://bafkreiffbopdjior7li3nlemzko7rjua6wd2hfh2vhdbenqbv4tfsbnzwu",testnet:!0},686868:{key:"686868",name:"Merlin Testnet",shortName:"merlin",chainId:686868,network:"testnet",multicall:"0x758BC6321b7c68F4986d62a4D46E83A2DCb58c80",rpc:[],explorer:{url:"https://testnet-scan.merlinchain.io"},start:3562021,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe",testnet:!0},713715:{key:"713715",name:"Sei EVM Devnet",shortName:"devnet",chainId:713715,network:"testnet",multicall:"0xEe8d287B844959ADe40d718Dc23077ba920e2f07",rpc:[],explorer:{url:"https://seitrace.com"},start:1463669,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},763373:{key:"763373",name:"Ink Sepolia",shortName:"testnet",chainId:763373,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-sepolia.inkonchain.com"},start:9701940,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju",testnet:!0},810180:{key:"810180",name:"zkLink Nova",shortName:"zlink",chainId:810180,network:"mainnet",multicall:"0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5",rpc:[],explorer:{url:"https://explorer.zklink.io"},start:146055,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74"},810181:{key:"810181",name:"zkLink Nova Sepolia",shortName:"testnet",chainId:810181,network:"testnet",multicall:"0x97148F8fDdd9A1620f72EC1Bb2932916623d9da5",rpc:[],explorer:{url:"https://sepolia.explorer.zklink.io"},start:43723,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74",testnet:!0},11155111:{key:"11155111",name:"Sepolia testnet",shortName:"Sepolia",chainId:11155111,network:"sepolia",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://sepolia.infura.io/v3/d26b4fd748814fe994b05899fd89e667"],ensResolvers:["0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"],ensNameWrapper:"0x0635513f179D50A207757E05759CbD106d7dFcE8",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV",explorer:{url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io"},start:751532,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},11155420:{key:"11155420",name:"OP Sepolia",shortName:"testnet",chainId:11155420,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia-optimism.etherscan.io"},start:1620204,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb",testnet:!0},111557560:{key:"111557560",name:"Cyber Testnet",shortName:"testnet",chainId:111557560,network:"testnet",multicall:"0xffc391F0018269d4758AEA1a144772E8FB99545E",rpc:[],explorer:{url:"https://testnet.cyberscan.co"},start:304545,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm",testnet:!0},168587773:{key:"168587773",name:"Blast Sepolia",shortName:"testnet",chainId:168587773,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.blastexplorer.io"},start:756690,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce",testnet:!0},245022926:{key:"245022926",name:"Neon Devnet",shortName:"devnet",chainId:245022926,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://devnet.neonscan.org"},start:205206112,logo:"ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",testnet:!0},1313161554:{key:"1313161554",name:"Aurora",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:{url:"https://explorer.mainnet.aurora.dev"},start:57190533,logo:"ipfs://QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:{url:"https://explorer.harmony.one"},start:10911984,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:{url:"https://explorer.pops.one"},start:7521509,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"}};class SP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"number"==typeof t&&void 0!==(null==e?void 0:e[t-1])}getValidVotes(){return this.votes.filter((t=>SP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>{const r=this.getValidVotes().filter((t=>t.choice===e+1));return r.reduce(((t,e)=>t+e.balance),0)}))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>{const r=this.strategies.map(((t,r)=>{const i=this.getValidVotes().filter((t=>t.choice===e+1));return i.reduce(((t,e)=>t+e.scores[r]),0)}));return r}))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices[this.selected-1]}}class NP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size}getValidVotes(){return this.votes.filter((t=>NP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.balance),0)))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.scores[r]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected?this.proposal.choices.filter(((t,e)=>this.selected.includes(e+1))).join(", "):""}}function IP(t,e){const r=t/e.reduce(((t,e)=>t+e),0);return isNaN(r)?0:r}function TP(t,e){return Math.sqrt(t*e)}function CP(t){return t*t}function zP(t,e){return t.map((t=>e*t))}class OP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>OP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>{const i=t.map((t=>TP(IP(t.choice[r+1],Object.values(t.choice)),t.balance))).reduce(((t,e)=>t+e),0);return CP(i)}));return zP(r.map(((t,e)=>IP(r[e],r))),e)}getScoresByStrategy(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.map((t=>TP(IP(t.choice[r+1],Object.values(t.choice)),t.scores[i]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[CP(t)]))));return r.map(((t,i)=>zP(this.strategies.map(((t,e)=>IP(r[i][e][0],r.flat(2)))),e)))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1]){const r=IP(this.selected[e+1],Object.values(this.selected));return`${Math.round(1e3*r)/10}% for ${t}`}})).filter((t=>null!=t)).join(", ")}}function RP(t,e){const r=[...new Set(t.map((t=>t[0])).flat())],i=Object.entries(t.reduce(((t,[e],r,i)=>{const n=i[r][1];t[e[0]][0]+=n;const o=i[r][2];return o.length>1?t[e[0]][1]=o.map(((r,i)=>r+t[e[0]][1][i]||r)):t[e[0]][1]=[t[e[0]][1].concat(o).reduce(((t,e)=>t+e),0)],t}),Object.assign({},...r.map((t=>({[t]:[0,[]]})))))),n=i.map((t=>[t[0],t[1][0]])),[o,a]=n.reduce((([t,e],[r,i])=>i>e?[r,i]:[t,e]),["?",-1/0]),[s,h]=n.reduce((([t,e],[r,i])=>i<e?[r,i]:[t,e]),["?",1/0]),u=i.sort(((t,e)=>e[1][0]-t[1][0])),l=t.map((t=>t[1])).reduce(((t,e)=>t+e),0);return e.push({round:e.length+1,sortedByHighest:u}),a>l/2||u.length<3?e:RP(t.map((t=>[t[0].filter((t=>t!=s)),t[1],t[2]])).filter((t=>t[0].length>0)),e)}function PP(t){const e=RP(t.map((t=>[t.choice,t.balance,t.scores])),[]);return e[e.length-1].sortedByHighest}class BP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size&&t.length>0&&t.length===e.length}getValidVotes(){return this.votes.filter((t=>BP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return function(t,e){const r=PP(t);return e.choices.map(((t,e)=>r.filter((t=>Number(t[0])===e+1)).reduce(((t,e)=>t+e[1][0]),0)))}(this.getValidVotes(),this.proposal)}getScoresByStrategy(){const t=PP(this.getValidVotes());return this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.filter((t=>Number(t[0])===r+1)).reduce(((t,e)=>t+e[1][1][i]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>{if(this.proposal.choices[t-1])return this.proposal.choices[t-1]})).map(((t,e)=>`(${wB(e+1)}) ${t}`)).join(", ")}}class DP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return!(!Array.isArray(t)||0===t.length||t.length>e.length||new Set(t).size!==t.length)&&t.every((t=>Number.isInteger(t)&&t>=1&&t<=e.length))}getValidVotes(){return this.votes.filter((t=>DP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=Array.from({length:e},(()=>Array(e).fill(0))),i=this.getScoresTotal();for(const e of t)for(let t=0;t<e.choice.length;t++)for(let i=t+1;i<e.choice.length;i++){const n=e.choice[t]-1,o=e.choice[i]-1;r[n][o]+=e.balance,r[o][n]-=e.balance}const n=Array(e).fill(0);let o=0;for(let t=0;t<e;t++)for(let i=0;i<e;i++)if(t!==i){const e=r[t][i];e>0?n[t]++:e<0?n[i]++:(n[t]+=.5,n[i]+=.5)}return o=n.reduce(((t,e)=>t+e),0),o>0?n.map((t=>t/o*i)):n.map((()=>i/e))}getScoresByStrategy(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=this.strategies.length,i=Array.from({length:e},(()=>Array.from({length:e},(()=>Array(r).fill(0))))),n=Array(r).fill(0);for(const e of t)for(let t=0;t<r;t++)n[t]+=e.scores[t];for(const e of t)for(let t=0;t<e.choice.length;t++)for(let n=t+1;n<e.choice.length;n++){const o=e.choice[t]-1,a=e.choice[n]-1;for(let t=0;t<r;t++)i[o][a][t]+=e.scores[t],i[a][o][t]-=e.scores[t]}const o=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<e;t++)for(let n=0;n<e;n++)if(t!==n)for(let e=0;e<r;e++){const r=i[t][n][e];r>0?o[t][e]++:r<0?o[n][e]++:(o[t][e]+=.5,o[n][e]+=.5)}const a=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<r;t++){let r=0;for(let i=0;i<e;i++)r+=o[i][t];if(r>0)for(let i=0;i<e;i++)a[i][t]=o[i][t]/r*n[t];else if(n[t]>0)for(let r=0;r<e;r++)a[r][t]=n[t]/e}return a}getScoresTotal(){return this.getValidVotes().reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>this.proposal.choices[t-1])).join(", ")}}function $P(t,e,r){const i=r.reduce(((t,e)=>t+e),0),n=e[t]/i*100;return isNaN(n)?0:n}function LP(t,e,r){return $P(t+1,e,Object.values(e))/100*r}class FP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>FP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.proposal.choices.map(((t,e)=>this.getValidVotes().map((t=>LP(e,t.choice,t.balance))).reduce(((t,e)=>t+e),0))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((e,r)=>$P(r,t,t))).map((t=>e/100*t))}getScoresByStrategy(){const t=this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().map((t=>LP(e,t.choice,t.scores[r]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[t])))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((r,i)=>this.strategies.map(((e,r)=>$P(0,t[i][r],t.flat(2)))).map((t=>[e/100*t])).flat()))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1])return`${Math.round(10*$P(e+1,this.selected,Object.values(this.selected)))/10}% for ${t}`})).filter((t=>null!=t)).join(", ")}}var UP={"single-choice":SP,approval:NP,quadratic:OP,"ranked-choice":BP,copeland:DP,weighted:FP,basic:SP};const qP={1:"https://subgrapher.snapshot.org/delegation/1",10:"https://subgrapher.snapshot.org/delegation/10",56:"https://subgrapher.snapshot.org/delegation/56",100:"https://subgrapher.snapshot.org/delegation/100",137:"https://subgrapher.snapshot.org/delegation/137",146:"https://subgrapher.snapshot.org/delegation/146",250:"https://subgrapher.snapshot.org/delegation/250",5e3:"https://subgrapher.snapshot.org/delegation/5000",8453:"https://subgrapher.snapshot.org/delegation/8453",42161:"https://subgrapher.snapshot.org/delegation/42161",59144:"https://subgrapher.snapshot.org/delegation/59144",81457:"https://subgrapher.snapshot.org/delegation/81457",84532:"https://subgrapher.snapshot.org/delegation/84532",11155111:"https://subgrapher.snapshot.org/delegation/11155111"},VP=1e3;function HP(t){return t.length===VP&&t[0].timestamp===t[t.length-1].timestamp}function GP(t,e){const r=function(t){return`${t.delegator}-${t.delegate}-${t.space}`}(e);t.has(r)||t.set(r,e)}function ZP(t){const e=["",t];return t.includes(".eth")&&e.push(t.replace(".eth","")),e}function KP(t){return r(this,arguments,void 0,(function*({url:t,spaces:e,pivot:r,snapshot:i}){const n={delegations:{__args:{where:{timestamp_gte:r},first:VP,skip:0,orderBy:"timestamp",orderDirection:"asc"},delegator:!0,space:!0,delegate:!0,timestamp:!0}};return"latest"!==i&&(n.delegations.__args.block={number:i}),null!==e&&(n.delegations.__args.where.space_in=e),(yield cB(t,n)).delegations||[]}))}const JP=["response not found during CCIP fetch","UNSUPPORTED_OPERATION"],WP="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",YP=["function text(bytes32 node, string calldata key) external view returns (string memory)","function resolver(bytes32 node) view returns (address)"],QP="0x0000000000000000000000000000000000000000",XP={"0x534e5f4d41494e":{name:"Starknet",testnet:!1},"0x534e5f5345504f4c4941":{name:"Starknet Sepolia",testnet:!0}},tB={Accept:"application/json","Content-Type":"application/json"},eB="https://score.snapshot.org";function rB(t=eB,e={path:""}){const r=new URL(t);e.path&&(r.pathname=e.path);const i=r.searchParams.get("apiKey");let n=Object.assign({},tB);return i&&(r.searchParams.delete("apiKey"),n=Object.assign(Object.assign({},tB),{"X-API-KEY":i})),{url:r.toString(),headers:n}}function iB(t){return r(this,void 0,void 0,(function*(){let e=yield t.text();try{e=JSON.parse(e)}catch(r){return Promise.reject({code:t.status||500,message:"Failed to parse response from score API",data:e})}return e.error?Promise.reject(e.error):e}))}const nB=new Ud({allErrors:!0,allowUnionTypes:!0,$data:!0,passContext:!0});Gd(nB),Kd(nB),nB.addFormat("address",{validate:t=>{try{return t===xr(t)}catch(t){return!1}}}),nB.addFormat("evmAddress",{validate:t=>{try{return xr(t),!0}catch(t){return!1}}}),nB.addFormat("starknetAddress",{validate:t=>{try{return aR(t).toLowerCase()===t.toLowerCase()}catch(t){return!1}}}),nB.addFormat("long",{validate:()=>!0}),nB.addFormat("lowercase",{validate:t=>t===t.toLowerCase()}),nB.addFormat("color",{validate:t=>!!t&&!!t.match(/^#[0-9A-F]{6}$/)}),nB.addFormat("ethValue",{validate:t=>{if(!t.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))return!1;try{return function(t,e){if("string"!=typeof t&&Nh.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=Ih.indexOf(e);-1!==t&&(e=3*t)}mh(t,null!=e?e:18)}(t,18),!0}catch(t){return!1}}});const oB=Object.keys(xP),aB=Object.keys(xP).filter((t=>!xP[t].testnet));function sB(t){const e=t.endsWith(".eth"),r=t.split(".");if(1===r.length)return"tld";if(2!==r.length||e){if(r.length>2)return"subdomain";if(e)return"ens";throw new Error("Invalid domain")}return"other-tld"}function hB(t){return r(this,void 0,void 0,(function*(){var e;const r=yield h(`https://cloudflare-dns.com/dns-query?name=${t}&type=TXT`,{headers:{accept:"application/dns-json"}}),i=yield r.json();if(3===i.Status)return QP;if(0!==i.Status)throw new Error("Failed to fetch DNS Owner");const n=null===(e=i.Answer)||void 0===e?void 0:e.find((t=>t.data.includes("ENS1")));return n?xr(n.data.replace(new RegExp('"',"g"),"").split(" ").pop()):QP}))}function uB(t,e,i,n){return r(this,void 0,void 0,(function*(){const r=new Ss(i[0],e,t);try{const t=i[2]||[];return yield r[i[1]](...t,n||{})}catch(t){return Promise.reject(t)}}))}function lB(t,e,i,n,o){return r(this,void 0,void 0,(function*(){const r=(null==o?void 0:o.multicallAddress)||xP[t].multicall,a=new Ss(r,["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],e),s=new $i(i);try{const t=(null==o?void 0:o.limit)||500;(null==o?void 0:o.limit)&&delete o.limit;const e=Math.ceil(n.length/t),r=[];Array.from(Array(e)).forEach(((e,i)=>{const h=n.slice(t*i,t*(i+1));r.push(a.aggregate(h.map((t=>[t[0].toLowerCase(),s.encodeFunctionData(t[1],t[2])])),o||{}))}));let i=yield Promise.all(r);return i=i.reduce(((t,[,e])=>t.concat(e)),[]),i.map(((t,e)=>s.decodeFunctionResult(n[e][1],t)))}catch(t){return Promise.reject(t)}}))}function cB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i={query:ml.jsonToGraphQLQuery({query:e})};r.variables&&(i.variables=r.variables);const n=yield h(t,{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},null==r?void 0:r.headers),body:JSON.stringify(i)});let o=yield n.text();try{o=JSON.parse(o)}catch(e){throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${o.substring(0,400)}`)}if(o.errors)throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${JSON.stringify(o.errors).substring(0,400)}`);const{data:a}=o;return a||{}}))}function dB(t,e=jP[0]){const r=`https://${e}`;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return`${r}/ipfs/${t}`;const i=t.split("://")[0];return"ipfs"===i?t.replace("ipfs://",`${r}/ipfs/`):"ipns"===i?t.replace("ipns://",`${r}/ipns/`):t}function fB(t,i){return r(this,arguments,void 0,(function*(t,r,i="1",n={}){var o,a;const{ensResolvers:s=(null===(o=xP[i])||void 0===o?void 0:o.ensResolvers)||xP[1].ensResolvers,broviderUrl:h}=n,u=e(n,["ensResolvers","broviderUrl"]);let l;try{l=Ou(zu(t))}catch(t){return null}const c=qp(i,{broviderUrl:h}),d=[[WP,"resolver",[l]],...s.map((t=>[t,"text",[l,r]]))],[[f],...m]=yield lB(i,c,YP,d,u),p=s.indexOf(f);return-1!==p?null===(a=m[p])||void 0===a?void 0:a[0]:null}))}function mB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){try{return yield fB(t,"snapshot",e,r)}catch(t){return console.log(t),null}}))}function pB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){var i,n;if(!(null===(n=null===(i=xP[e])||void 0===i?void 0:i.ensResolvers)||void 0===n?void 0:n.length))throw new Error("Network not supported");const o=sB(t),a=qp(e,r),s=new Ss(WP,["function owner(bytes32) view returns (address)"],a);let h;try{h=Ou(zu(t))}catch(t){return QP}const u=r.ensNameWrapper||xP[e].ensNameWrapper;let l=yield s.owner(h);if(l===u){const t=new Ss(u,["function ownerOf(uint256) view returns (address)"],a);l=yield t.ownerOf(h)}if(l===QP&&"other-tld"===o){(yield a.resolveName(t))&&(l=yield hB(t))}if(l===QP&&"subdomain"===o)try{l=yield a.resolveName(t)}catch(t){if(JP.every((e=>!t.message.includes(e))))throw t;l=QP}return l||QP}))}function gB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i=yield mB(t,e,r);if(i){let t=Sr(i);if(t)return i;const e=i.split("/"),r=e.includes("testnet")?5:4,n=e[r];if(t=Sr(n),t)return n}return yield pB(t,e,r)}))}function yB(t,e){return r(this,void 0,void 0,(function*(){if(!t.endsWith(".shib"))return QP;const r=yield h("https://stamp.fyi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"get_owner",params:t,network:e})});return(yield r.json()).result}))}function wB(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}function vB(t){return!!xP[t]}function bB(t){return t!==QP&&(Sr(t)||MB(t))}function kB(t,e){return"latest"===t||"number"==typeof t&&t>=xP[e].start}function MB(t){if(!t)return!1;try{return aR(t),!0}catch(t){return!1}}function _B(t){return Sr(t)}function EB(t,e){const r=null!=e?e:_B(t)?"evm":"starknet";if("evm"===r&&_B(t))return xr(t);if("starknet"===r&&MB(t))return aR(t);throw new Error(`Invalid address: ${t}`)}function AB(t){return Promise.reject(new Error(t))}nB.addKeyword({keyword:"snapshotNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?aB.includes(e):oB.includes(e)},error:{message:"network not allowed"}}),nB.addKeyword({keyword:"starknetNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?Object.keys(XP).filter((t=>!XP[t].testnet)).includes(e):Object.keys(XP).includes(e)},error:{message:"network not allowed"}}),nB.addFormat("customUrl",{type:"string",validate:t=>!t.length||(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("snapshot://"))}),nB.addFormat("domain",{validate:t=>!!t&&!!t.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(\/)?$/)});var jB={call:uB,multicall:lB,subgraphRequest:cB,ipfsGet:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="ipfs"){return h(`https://${t}/${r}/${e}`).then((t=>t.json()))}))},getUrl:dB,getJSON:function(t){return r(this,arguments,void 0,(function*(t,e={}){const r=dB(t,e.gateways);return h(r).then((t=>t.json()))}))},sendTransaction:function(t,e,i,n,o){return r(this,arguments,void 0,(function*(t,e,r,i,n,o={}){const a=t.getSigner(),s=new Ss(e,r,t).connect(a);return yield s[i](...n,o)}))},getScores:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n="latest",o=eB,a={}){if(!Array.isArray(i))return AB("addresses should be an array of addresses");if(0===i.length)return AB("addresses can not be empty");const s=i.find((t=>!bB(t)));if(s)return AB(`Invalid address: ${s}`);if(!vB(r))return AB(`Invalid network: ${r}`);const u=e.find((t=>t.network&&!vB(t.network)));if(u)return AB(`Invalid network (${u.network}) in strategy ${u.name}`);if(!kB(n,r))return AB(`Snapshot (${n}) must be 'latest' or greater than network start block (${xP[r].start})`);new URL(o).pathname="/api/scores";const{url:l,headers:c}=rB(o,{path:"/api/scores"});try{const o={space:t,network:r,snapshot:n,strategies:e,addresses:i},s=yield h(l,{method:"POST",headers:c,body:JSON.stringify({params:o})}),u=yield iB(s);return"all"===a.returnValue?u.result:u.result[a.returnValue||"scores"]}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},getVp:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){const{url:r,headers:u}=rB(null==s?void 0:s.url);if(!bB(t))return AB(`Invalid voter address: ${t}`);if(!vB(e))return AB(`Invalid network: ${e}`);const l=i.find((t=>t.network&&!vB(t.network)));if(l)return AB(`Invalid network (${l.network}) in strategy ${l.name}`);if(!kB(n,e))return AB(`Snapshot (${n}) must be 'latest' or greater than network start block (${xP[e].start})`);const c={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"get_vp",params:{address:t,network:e,strategies:i,snapshot:n,space:o,delegation:a}})};try{const t=yield h(r,c);return(yield iB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},validateSchema:function(t,e,r={snapshotEnv:"default",spaceType:"default"}){const i=nB.compile(t),n=i.call(r,e);return n||i.errors},getEnsTextRecord:fB,getSpaceUri:mB,getEnsOwner:pB,getSpaceController:function(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){if(["1","11155111"].includes(e))return gB(t,e,r);if(["109","157"].includes(e))return yB(t,e);throw new Error(`Network not supported: ${e}`)}))},getDelegatesBySpace:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="latest",i={}){const n=i.subgraphUrl||qP[t];if(!n)return Promise.reject(`Delegation subgraph not available for network ${t}`);let o=0;const a=new Map,s=e?ZP(e):null;for(;;){const t=yield KP({url:n,spaces:s,pivot:o,snapshot:r});if(HP(t))throw new Error("Unable to paginate delegation");if(t.forEach((t=>{GP(a,t),o=t.timestamp})),t.length<VP)break}return[...a.values()]}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return r(this,void 0,void 0,(function*(){return new Promise((e=>{setTimeout(e,t)}))}))},getNumberWithOrdinal:wB,voting:UP,getProvider:qp,signMessage:function(t,e,i){return r(this,void 0,void 0,(function*(){return e=te(new G(e,"utf8")),yield t.send("personal_sign",[e,i])}))},getBlockNumber:function(t){return r(this,void 0,void 0,(function*(){try{const e=yield t.getBlockNumber();return parseInt(e)}catch(t){return Promise.reject()}}))},Multicaller:class{constructor(t,e,r,i){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=i||{}}call(t,e,r,i){return this.calls.push([e,r,i]),this.paths.push(t),this}execute(t){return r(this,void 0,void 0,(function*(){const e=t||{};return(yield lB(this.network,this.provider,this.abi,this.calls,this.options)).forEach(((t,r)=>Uf(e,this.paths[r],t.length>1?t:t[0]))),this.calls=[],this.paths=[],e}))}},getSnapshots:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n={}){const o={};if(i.forEach((t=>o[t]="latest")),"latest"===e)return o;const a=`${t}-${e}-${i.join("-")}`,s=qf[a],h=Date.now();if(s&&Vf>h)return s;Vf<h&&(qf={},Vf=h+36e5-h%36e5),o[t]=e;const u=Object.keys(o).filter((e=>t!==e));if(0===u.length)return o;const l={blocks:{__args:{where:{ts:(yield r.getBlock(e)).timestamp,network_in:u}},network:!0,number:!0}},c=n.blockFinderUrl||"https://blockfinder.snapshot.org";return(yield cB(c,l)).blocks.forEach((t=>o[t.network]=t.number)),qf[a]=o,o}))},getHash:function(t,e){return(UR(t)?VR:AP).getHash(t,e)},verify:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){if(!MB(t)&&!_B(t))throw new Error("Invalid address");const o=UR(r)?VR:AP;return yield o.default(t,e,r,i,n)}))},validate:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){if(!bB(e))return AB(`Invalid author: ${e}`);if(!vB(n))return AB(`Invalid network: ${n}`);if(!kB(o,n))return AB(`Snapshot (${o}) must be 'latest' or greater than network start block (${xP[n].start})`);s||(s={});const{url:r,headers:u}=rB(s.url),l={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"validate",params:{validation:t,author:e,space:i,network:n,snapshot:o,params:a}})};try{const t=yield h(r,l);return(yield iB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},isStarknetAddress:MB,isEvmAddress:_B,getFormattedAddress:EB,SNAPSHOT_SUBGRAPH_URL:qP};const xB={name:"snapshot",version:"0.1.4"};class SB{constructor(t=N.sequencer,e={}){t=(t=(t=t.replace(N.hub,N.sequencer)).replace(I.hub,I.sequencer)).replace(T.hub,T.sequencer),this.address=t,this.options=e}sign(t,e,i,n){return r(this,void 0,void 0,(function*(){var r;const o=(null==t?void 0:t.getSigner)?t.getSigner():t,a=EB(e,"evm");i.from=i.from?EB(i.from):a,i.timestamp||(i.timestamp=parseInt((Date.now()/1e3).toFixed()));const s=Object.assign({},xB);"undefined"!=typeof window&&(null===(r=window.ethereum)||void 0===r?void 0:r.isTrust)&&(s.chainId=(yield o.provider.getNetwork()).chainId);const h={domain:s,types:n,message:i},u=yield o._signTypedData(s,h.types,i);return yield this.send({address:a,sig:u,data:h})}))}send(t){return r(this,void 0,void 0,(function*(){let e=this.address;"0x"===t.sig&&this.options.relayerURL&&(e=this.options.relayerURL);const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)};return new Promise(((t,i)=>{h(e,r).then((e=>{var r;if(e.ok)return t(e.json());if(null===(r=e.headers.get("content-type"))||void 0===r?void 0:r.includes("application/json"))return e.json().then(i).catch(i);throw e})).catch(i)}))}))}space(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,u)}))}proposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.labels||(i.labels=[]),i.discussion||(i.discussion=""),i.app||(i.app=""),i.privacy||(i.privacy=""),yield this.sign(t,e,i,l)}))}updateProposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.privacy||(i.privacy=""),yield this.sign(t,e,i,c)}))}flagProposal(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,d)}))}cancelProposal(t,e,i){return r(this,void 0,void 0,(function*(){const r=i.proposal.startsWith("0x");return yield this.sign(t,e,i,r?m:f)}))}vote(t,e,i){return r(this,void 0,void 0,(function*(){const r="shutter"===(null==i?void 0:i.privacy);i.reason||(i.reason=""),i.app||(i.app=""),i.metadata||(i.metadata="{}");const n=i.proposal.startsWith("0x");let o=n?w:p;return["approval","ranked-choice"].includes(i.type)&&(o=n?v:g),!r&&["quadratic","weighted"].includes(i.type)&&(o=n?b:y,i.choice=JSON.stringify(i.choice)),r&&(o=n?b:y),delete i.privacy,delete i.type,yield this.sign(t,e,i,o)}))}follow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,k)}))}unfollow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,M)}))}subscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,_)}))}unsubscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,E)}))}profile(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,A)}))}statement(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,j)}))}alias(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,x)}))}deleteSpace(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,S)}))}}var NB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Proposal",definitions:{Proposal:{title:"Proposal",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{type:"string",enum:["single-choice","approval","ranked-choice","quadratic","copeland","weighted","custom","basic"]},snapshot:{type:"number",title:"snapshot"},start:{type:"number",title:"start",minimum:1e9,maximum:2e9},end:{type:"number",title:"end",minimum:1e9,maximum:2e9},metadata:{type:"object",title:"metadata"},app:{type:"string",title:"app",maxLength:24},privacy:{type:"string",enum:["","shutter"]}},required:["name","body","choices","snapshot","start","end"],additionalProperties:!1}}},IB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/UpdateProposal",definitions:{UpdateProposal:{title:"Update Proposal",type:"object",properties:{proposal:{type:"string",title:"proposal id"},name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{enum:["single-choice","approval","ranked-choice","quadratic","weighted","custom","basic"]},metadata:{type:"object",title:"metadata"},privacy:{type:"string",enum:["","shutter"]}},required:["proposal","name","body","discussion","choices","type","metadata"],additionalProperties:!1}}},TB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Vote",definitions:{Vote:{title:"Vote",type:"object",properties:{proposal:{type:"string",title:"proposal"},choice:{type:["number","array","object","boolean","string"],title:"choice"},metadata:{type:"object",title:"metadata"},reason:{type:"string",title:"reason",maxLength:5e3},app:{type:"string",title:"app",maxLength:24}},required:["proposal","choice"],additionalProperties:!1}}},CB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Profile",definitions:{Profile:{title:"Profile",type:"object",properties:{name:{type:"string",title:"name",maxLength:32},about:{type:"string",title:"about",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},lens:{type:"string",title:"lens",pattern:"^[A-Za-z0-9_]*$",maxLength:26},farcaster:{type:"string",title:"farcaster",pattern:"^[a-z0-9-]*$",maxLength:17}},required:[],additionalProperties:!1}}},zB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Statement",definitions:{Statement:{title:"Statement",type:"object",properties:{about:{type:"string",format:"long",title:"About",maxLength:140},statement:{type:"string",format:"long",title:"Statement",maxLength:1e4},discourse:{type:"string",title:"discourse",pattern:"^[A-Za-z0-9-_.]*$",maxLength:30},network:{type:"string",title:"network",pattern:"^[a-z0-9-]*$",maxLength:24},status:{enum:["ACTIVE","INACTIVE"],title:"status"}},required:[],additionalProperties:!1}}},OB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Zodiac",definitions:{Zodiac:{title:"Zodiac",type:"object",properties:{safes:{title:"Safe(s)",type:"array",maxItems:8,items:{type:"object",properties:{network:{title:"Network",type:"string",snapshotNetwork:!0},multisend:{title:"Multisend contract address",type:"string"},realityAddress:{title:"Reality module address",type:"string"},umaAddress:{title:"UMA module address",type:"string"}},additionalProperties:!1}},additionalProperties:!1}}}},RB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Alias",definitions:{Alias:{title:"Alias",type:"object",properties:{alias:{type:"string",format:"address"}},required:["alias"],additionalProperties:!1}}};return{Client:SB,Client712:SB,schemas:{space:{$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Space",definitions:{Space:{title:"Space",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:32},private:{type:"boolean"},about:{type:"string",title:"about",maxLength:160},guidelines:{type:"string",format:"customUrl",title:"guidelines",maxLength:256},template:{type:"string",title:"template",maxLength:1024},terms:{type:"string",title:"terms",format:"customUrl",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},location:{type:"string",title:"location",maxLength:24},website:{type:"string",title:"website",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},coingecko:{type:"string",title:"coingecko",pattern:"^[a-z0-9-]*$",maxLength:32},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},farcaster:{type:"string",title:"farcaster"},email:{type:"string",title:"email",maxLength:32},network:{type:"string",snapshotNetwork:!0,title:"network",minLength:1,maxLength:32},symbol:{type:"string",title:"symbol",maxLength:16},skin:{type:"string",title:"skin",maxLength:32},domain:{type:"string",title:"domain",maxLength:64,format:"domain"},discussions:{type:"string",format:"uri",title:"Discussions link",maxLength:256},discourseCategory:{type:"integer",minimum:1,title:"Discourse category"},strategies:{type:"array",minItems:1,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},network:{type:"string",maxLength:12,title:"network",snapshotNetwork:!0},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},title:"strategies"},members:{type:"array",maxItems:100,items:{type:"string",anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid address"},title:"members",uniqueItems:!0},admins:{type:"array",maxItems:100,items:{type:"string",anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid address"},title:"admins",uniqueItems:!0},moderators:{type:"array",maxItems:100,items:{type:"string",anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid address"},title:"moderators",uniqueItems:!0},filters:{type:"object",properties:{defaultTab:{type:"string"},minScore:{type:"number",minimum:0},onlyMembers:{type:"boolean"},invalids:{type:"array",items:{type:"string",maxLength:64},title:"invalids"}},additionalProperties:!1},validation:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},voteValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},followValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},delegationPortal:{type:"object",properties:{delegationType:{type:"string",title:"Delegation type",description:"Specify the type of delegation that you are using",anyOf:[{const:"compound-governor",title:"Compound governor"},{const:"split-delegation",title:"Split Delegation"},{const:"apechain-delegate-registry",title:"ApeChain Delegate Registry"}]},delegationContract:{type:"string",title:"Contract address",description:"The address of your delegation contract",examples:["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"],anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},delegationNetwork:{type:"string",title:"Delegation network",description:"The network of your delegation contract",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"},delegationApi:{type:"string",format:"uri",title:"Delegation API",description:"The URL of your delegation API (e.g a subgraph)",examples:["https://subgrapher.snapshot.org/subgraph/arbitrum/FTzC6VrZd8JhJgWfTJnwWgH1Z1dS3GxaosKkRbCqkZAZ"]}},required:["delegationType","delegationApi","delegationContract"],additionalProperties:!1},allowAlias:{type:"boolean"},plugins:{type:"object"},voting:{type:"object",properties:{delay:{type:"integer",minimum:0,maximum:2592e3,errorMessage:{maximum:"Delay must be less than 30 days"}},period:{type:"integer",minimum:0,maximum:31622400,errorMessage:{maximum:"Delay must be less than a year"}},type:{type:"string",title:"type"},quorum:{type:"number",minimum:0},quorumType:{type:"string",enum:["rejection"]},blind:{type:"boolean"},hideAbstain:{type:"boolean"},aliased:{type:"boolean"},privacy:{type:"string",enum:["","shutter","any"]}},additionalProperties:!1},categories:{type:"array",maxItems:2,items:{type:"string",enum:["protocol","social","investment","grant","service","media","creator","collector","ai-agent","gaming","wallet","music","layer-2","defai","defi","rwa","depin","meme"]}},treasuries:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",title:"Name",examples:["e.g. Balancer DAO 1"],minLength:1,maxLength:64},address:{type:"string",title:"Contract address",examples:["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},network:{type:"string",title:"Network",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"}},required:["name","address","network"],additionalProperties:!1}},labels:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{id:{type:"string",title:"Id",minLength:1,maxLength:8},name:{type:"string",title:"Name",minLength:1,maxLength:32},description:{type:"string",title:"Description",maxLength:100},color:{type:"string",title:"Color",format:"color"}},required:["id","name","color"],additionalProperties:!1}},parent:{type:"string",title:"parent"},children:{type:"array",maxItems:16,title:"children",items:{type:"string"},uniqueItems:!0},boost:{type:"object",properties:{enabled:{type:"boolean"},bribeEnabled:{type:"boolean"}},required:["enabled","bribeEnabled"],additionalProperties:!1},skinSettings:{type:"object",properties:{bg_color:{type:"string",format:"color"},link_color:{type:"string",format:"color"},text_color:{type:"string",format:"color"},content_color:{type:"string",format:"color"},border_color:{type:"string",format:"color"},heading_color:{type:"string",format:"color"},primary_color:{type:"string",format:"color"},header_color:{type:"string",format:"color"},theme:{type:"string",enum:["light","dark"]},logo:{type:"string",title:"logo",format:"customUrl",maxLength:256}},additionalProperties:!1}},required:["name","network","strategies"],additionalProperties:!1}}}.definitions.Space,proposal:NB.definitions.Proposal,updateProposal:IB.definitions.UpdateProposal,vote:TB.definitions.Vote,profile:CB.definitions.Profile,statement:zB.definitions.Statement,zodiac:OB.definitions.Zodiac,alias:RB.definitions.Alias},utils:jB}}));
232
+ const Jj=$A.Store,Wj=Dj.MemoryCookieStore,Yj=qA.pathMatch,{fromCallback:Qj}=LA,{getCustomInspectSymbol:Xj}=Nj,tx=/^[\x21\x23-\x2B\x2D-\x3A\x3C-\x5B\x5D-\x7E]+$/,ex=/[\x00-\x1F]/,rx=["\n","\r","\0"],ix=/[\x20-\x3A\x3C-\x7E]+/,nx=/[\x09\x20-\x2F\x3B-\x40\x5B-\x60\x7B-\x7E]/,ox={jan:0,feb:1,mar:2,apr:3,may:4,jun:5,jul:6,aug:7,sep:8,oct:9,nov:10,dec:11},ax=2147483647e3,sx='Invalid sameSiteContext option for getCookies(); expected one of "strict", "lax", or "none"';function hx(t){Gj.validate(Gj.isNonEmptyString(t),t);const e=String(t).toLowerCase();return"none"===e||"lax"===e||"strict"===e?e:null}const ux=Object.freeze({SILENT:"silent",STRICT:"strict",DISABLED:"unsafe-disabled"}),lx=/(?:^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$)|(?:^(?:(?:[a-f\d]{1,4}:){7}(?:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|:[a-f\d]{1,4}|:)|(?:[a-f\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,2}|:)|(?:[a-f\d]{1,4}:){4}(?:(?::[a-f\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,3}|:)|(?:[a-f\d]{1,4}:){3}(?:(?::[a-f\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,4}|:)|(?:[a-f\d]{1,4}:){2}(?:(?::[a-f\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,5}|:)|(?:[a-f\d]{1,4}:){1}(?:(?::[a-f\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,6}|:)|(?::(?:(?::[a-f\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}|(?::[a-f\d]{1,4}){1,7}|:)))$)/,cx="\n\\[?(?:\n(?:[a-fA-F\\d]{1,4}:){7}(?:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|:[a-fA-F\\d]{1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){5}(?::(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,2}|:)|\n(?:[a-fA-F\\d]{1,4}:){4}(?:(?::[a-fA-F\\d]{1,4}){0,1}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,3}|:)|\n(?:[a-fA-F\\d]{1,4}:){3}(?:(?::[a-fA-F\\d]{1,4}){0,2}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,4}|:)|\n(?:[a-fA-F\\d]{1,4}:){2}(?:(?::[a-fA-F\\d]{1,4}){0,3}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,5}|:)|\n(?:[a-fA-F\\d]{1,4}:){1}(?:(?::[a-fA-F\\d]{1,4}){0,4}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,6}|:)|\n(?::(?:(?::[a-fA-F\\d]{1,4}){0,5}:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}|(?::[a-fA-F\\d]{1,4}){1,7}|:))\n)(?:%[0-9a-zA-Z]{1,})?\\]?\n".replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),dx=new RegExp(`^${cx}$`);function fx(t,e,r,i){let n=0;for(;n<t.length;){const e=t.charCodeAt(n);if(e<=47||e>=58)break;n++}return n<e||n>r?null:i||n==t.length?parseInt(t.substr(0,n),10):null}function mx(t){const e=t.split(":"),r=[0,0,0];if(3!==e.length)return null;for(let t=0;t<3;t++){const i=2==t,n=fx(e[t],1,2,i);if(null===n)return null;r[t]=n}return r}function px(t){t=String(t).substr(0,3).toLowerCase();const e=ox[t];return e>=0?e:null}function gx(t){if(!t)return;const e=t.split(nx);if(!e)return;let r=null,i=null,n=null,o=null,a=null,s=null;for(let t=0;t<e.length;t++){const h=e[t].trim();if(!h.length)continue;let u;null===n&&(u=mx(h),u)?(r=u[0],i=u[1],n=u[2]):null!==o||(u=fx(h,1,2,!0),null===u)?null!==a||(u=px(h),null===u)?null===s&&(u=fx(h,2,4,!0),null!==u&&(s=u,s>=70&&s<=99?s+=1900:s>=0&&s<=69&&(s+=2e3))):a=u:o=u}return null===o||null===a||null===s||null===n||o<1||o>31||s<1601||r>23||i>59||n>59?void 0:new Date(Date.UTC(s,a,o,r,i,n))}function yx(t){return Gj.validate(Gj.isDate(t),t),t.toUTCString()}function wx(t){return null==t?null:(t=t.trim().replace(/^\./,""),dx.test(t)&&(t=t.replace("[","").replace("]","")),Kj&&/[^\u0001-\u007f]/.test(t)&&(t=Kj.toASCII(t)),t.toLowerCase())}function vx(t,e,r){if(null==t||null==e)return null;if(!1!==r&&(t=wx(t),e=wx(e)),t==e)return!0;const i=t.lastIndexOf(e);return!(i<=0)&&(t.length===e.length+i&&("."===t.substr(i-1,1)&&!lx.test(t)))}function bx(t){if(!t||"/"!==t.substr(0,1))return"/";if("/"===t)return t;const e=t.lastIndexOf("/");return 0===e?"/":t.slice(0,e)}function kx(t,e){t=function(t){if(Gj.isEmptyString(t))return t;for(let e=0;e<rx.length;e++){const r=t.indexOf(rx[e]);-1!==r&&(t=t.substr(0,r))}return t}(t),Gj.validate(Gj.isString(t),t);let r,i,n=t.indexOf("=");if(e)0===n&&(n=(t=t.substr(1)).indexOf("="));else if(n<=0)return;if(n<=0?(r="",i=t.trim()):(r=t.substr(0,n).trim(),i=t.substr(n+1).trim()),ex.test(r)||ex.test(i))return;const o=new Sx;return o.key=r,o.value=i,o}function Mx(t,e){if(e&&"object"==typeof e||(e={}),Gj.isEmptyString(t)||!Gj.isString(t))return null;const r=(t=t.trim()).indexOf(";"),i=kx(-1===r?t:t.substr(0,r),!!e.loose);if(!i)return;if(-1===r)return i;const n=t.slice(r+1).trim();if(0===n.length)return i;const o=n.split(";");for(;o.length;){const t=o.shift().trim();if(0===t.length)continue;const e=t.indexOf("=");let r,n;switch(-1===e?(r=t,n=null):(r=t.substr(0,e),n=t.substr(e+1)),r=r.trim().toLowerCase(),n&&(n=n.trim()),r){case"expires":if(n){const t=gx(n);t&&(i.expires=t)}break;case"max-age":if(n&&/^-?[0-9]+$/.test(n)){const t=parseInt(n,10);i.setMaxAge(t)}break;case"domain":if(n){const t=n.trim().replace(/^\./,"");t&&(i.domain=t.toLowerCase())}break;case"path":i.path=n&&"/"===n[0]?n:null;break;case"secure":i.secure=!0;break;case"httponly":i.httpOnly=!0;break;case"samesite":switch(n?n.toLowerCase():""){case"strict":i.sameSite="strict";break;case"lax":i.sameSite="lax";break;case"none":i.sameSite="none";break;default:i.sameSite=void 0}break;default:i.extensions=i.extensions||[],i.extensions.push(t)}}return i}function _x(t){let e;try{e=JSON.parse(t)}catch(t){return t}return e}function Ex(t){if(!t||Gj.isEmptyString(t))return null;let e;if("string"==typeof t){if(e=_x(t),e instanceof Error)return null}else e=t;const r=new Sx;for(let t=0;t<Sx.serializableProperties.length;t++){const i=Sx.serializableProperties[t];void 0!==e[i]&&e[i]!==xx[i]&&("expires"===i||"creation"===i||"lastAccessed"===i?null===e[i]?r[i]=null:r[i]="Infinity"==e[i]?"Infinity":new Date(e[i]):r[i]=e[i])}return r}function Ax(t,e){Gj.validate(Gj.isObject(t),t),Gj.validate(Gj.isObject(e),e);let r=0;const i=t.path?t.path.length:0;if(r=(e.path?e.path.length:0)-i,0!==r)return r;return r=(t.creation?t.creation.getTime():ax)-(e.creation?e.creation.getTime():ax),0!==r||(r=t.creationIndex-e.creationIndex),r}function jx(t){if(t instanceof Object)return t;try{t=decodeURI(t)}catch(t){}return zA(t)}const xx={key:"",value:"",expires:"Infinity",maxAge:null,domain:null,path:null,secure:!1,httpOnly:!1,extensions:null,hostOnly:null,pathIsDefault:null,creation:null,lastAccessed:null,sameSite:void 0};class Sx{constructor(t={}){const e=Xj();e&&(this[e]=this.inspect),Object.assign(this,xx,t),this.creation=this.creation||new Date,Object.defineProperty(this,"creationIndex",{configurable:!1,enumerable:!1,writable:!0,value:++Sx.cookiesCreated})}inspect(){const t=Date.now(),e=null!=this.hostOnly?this.hostOnly:"?",r=this.creation?t-this.creation.getTime()+"ms":"?",i=this.lastAccessed?t-this.lastAccessed.getTime()+"ms":"?";return`Cookie="${this.toString()}; hostOnly=${e}; aAge=${i}; cAge=${r}"`}toJSON(){const t={};for(const e of Sx.serializableProperties)this[e]!==xx[e]&&("expires"===e||"creation"===e||"lastAccessed"===e?null===this[e]?t[e]=null:t[e]="Infinity"==this[e]?"Infinity":this[e].toISOString():"maxAge"===e?null!==this[e]&&(t[e]=this[e]==1/0||this[e]==-1/0?this[e].toString():this[e]):this[e]!==xx[e]&&(t[e]=this[e]));return t}clone(){return Ex(this.toJSON())}validate(){if(!tx.test(this.value))return!1;if(!(this.expires==1/0||this.expires instanceof Date||gx(this.expires)))return!1;if(null!=this.maxAge&&this.maxAge<=0)return!1;if(null!=this.path&&!ix.test(this.path))return!1;const t=this.cdomain();if(t){if(t.match(/\.$/))return!1;if(null==DA.getPublicSuffix(t))return!1}return!0}setExpires(t){t instanceof Date?this.expires=t:this.expires=gx(t)||"Infinity"}setMaxAge(t){this.maxAge=t===1/0||t===-1/0?t.toString():t}cookieString(){let t=this.value;return null==t&&(t=""),""===this.key?t:`${this.key}=${t}`}toString(){let t=this.cookieString();if(this.expires!=1/0&&(this.expires instanceof Date?t+=`; Expires=${yx(this.expires)}`:t+=`; Expires=${this.expires}`),null!=this.maxAge&&this.maxAge!=1/0&&(t+=`; Max-Age=${this.maxAge}`),this.domain&&!this.hostOnly&&(t+=`; Domain=${this.domain}`),this.path&&(t+=`; Path=${this.path}`),this.secure&&(t+="; Secure"),this.httpOnly&&(t+="; HttpOnly"),this.sameSite&&"none"!==this.sameSite){const e=Sx.sameSiteCanonical[this.sameSite.toLowerCase()];t+=`; SameSite=${e||this.sameSite}`}return this.extensions&&this.extensions.forEach((e=>{t+=`; ${e}`})),t}TTL(t){if(null!=this.maxAge)return this.maxAge<=0?0:1e3*this.maxAge;let e=this.expires;return e!=1/0?(e instanceof Date||(e=gx(e)||1/0),e==1/0?1/0:e.getTime()-(t||Date.now())):1/0}expiryTime(t){if(null!=this.maxAge){const e=t||this.creation||new Date,r=this.maxAge<=0?-1/0:1e3*this.maxAge;return e.getTime()+r}return this.expires==1/0?1/0:this.expires.getTime()}expiryDate(t){const e=this.expiryTime(t);return e==1/0?new Date(ax):e==-1/0?new Date(0):new Date(e)}isPersistent(){return null!=this.maxAge||this.expires!=1/0}canonicalizedDomain(){return null==this.domain?null:wx(this.domain)}cdomain(){return this.canonicalizedDomain()}}function Nx(t){if(null!=t){const e=t.toLowerCase();switch(e){case ux.STRICT:case ux.SILENT:case ux.DISABLED:return e}}return ux.SILENT}Sx.cookiesCreated=0,Sx.parse=Mx,Sx.fromJSON=Ex,Sx.serializableProperties=Object.keys(xx),Sx.sameSiteLevel={strict:3,lax:2,none:1},Sx.sameSiteCanonical={strict:"Strict",lax:"Lax"};class Ix{constructor(t,e={rejectPublicSuffixes:!0}){"boolean"==typeof e&&(e={rejectPublicSuffixes:e}),Gj.validate(Gj.isObject(e),e),this.rejectPublicSuffixes=e.rejectPublicSuffixes,this.enableLooseMode=!!e.looseMode,this.allowSpecialUseDomain="boolean"!=typeof e.allowSpecialUseDomain||e.allowSpecialUseDomain,this.store=t||new Wj,this.prefixSecurity=Nx(e.prefixSecurity),this._cloneSync=Tx("clone"),this._importCookiesSync=Tx("_importCookies"),this.getCookiesSync=Tx("getCookies"),this.getCookieStringSync=Tx("getCookieString"),this.getSetCookieStringsSync=Tx("getSetCookieStrings"),this.removeAllCookiesSync=Tx("removeAllCookies"),this.setCookieSync=Tx("setCookie"),this.serializeSync=Tx("serialize")}setCookie(t,e,r,i){let n;if(Gj.validate(Gj.isUrlStringOrObject(e),i,r),Gj.isFunction(e))return(i=e)(new Error("No URL was specified"));const o=jx(e);if(Gj.isFunction(r)&&(i=r,r={}),Gj.validate(Gj.isFunction(i),i),!Gj.isNonEmptyString(t)&&!Gj.isObject(t)&&t instanceof String&&0==t.length)return i(null);const a=wx(o.hostname),s=r.loose||this.enableLooseMode;let h=null;if(r.sameSiteContext&&(h=hx(r.sameSiteContext),!h))return i(new Error(sx));if("string"==typeof t||t instanceof String){if(!(t=Sx.parse(t,{loose:s})))return n=new Error("Cookie failed to parse"),i(r.ignoreError?null:n)}else if(!(t instanceof Sx))return n=new Error("First argument to setCookie must be a Cookie object or string"),i(r.ignoreError?null:n);const u=r.now||new Date;if(this.rejectPublicSuffixes&&t.domain){if(null==DA.getPublicSuffix(t.cdomain(),{allowSpecialUseDomain:this.allowSpecialUseDomain,ignoreError:r.ignoreError})&&!dx.test(t.domain))return n=new Error("Cookie has domain set to a public suffix"),i(r.ignoreError?null:n)}if(t.domain){if(!vx(a,t.cdomain(),!1))return n=new Error(`Cookie not in this host's domain. Cookie:${t.cdomain()} Request:${a}`),i(r.ignoreError?null:n);null==t.hostOnly&&(t.hostOnly=!1)}else t.hostOnly=!0,t.domain=a;if(t.path&&"/"===t.path[0]||(t.path=bx(o.pathname),t.pathIsDefault=!0),!1===r.http&&t.httpOnly)return n=new Error("Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:n);if("none"!==t.sameSite&&void 0!==t.sameSite&&h&&"none"===h)return n=new Error("Cookie is SameSite but this is a cross-origin request"),i(r.ignoreError?null:n);const l=this.prefixSecurity===ux.SILENT;if(!(this.prefixSecurity===ux.DISABLED)){let e,n=!1;if(!function(t){return Gj.validate(Gj.isObject(t),t),!t.key.startsWith("__Secure-")||t.secure}(t)?(n=!0,e="Cookie has __Secure prefix but Secure attribute is not set"):function(t){return Gj.validate(Gj.isObject(t)),!t.key.startsWith("__Host-")||t.secure&&t.hostOnly&&null!=t.path&&"/"===t.path}(t)||(n=!0,e="Cookie has __Host prefix but either Secure or HostOnly attribute is not set or Path is not '/'"),n)return i(r.ignoreError||l?null:new Error(e))}const c=this.store;c.updateCookie||(c.updateCookie=function(t,e,r){this.putCookie(e,r)}),c.findCookie(t.domain,t.path,t.key,(function(e,n){if(e)return i(e);const o=function(e){if(e)return i(e);i(null,t)};if(n){if(!1===r.http&&n.httpOnly)return e=new Error("old Cookie is HttpOnly and this isn't an HTTP API"),i(r.ignoreError?null:e);t.creation=n.creation,t.creationIndex=n.creationIndex,t.lastAccessed=u,c.updateCookie(n,t,o)}else t.creation=t.lastAccessed=u,c.putCookie(t,o)}))}getCookies(t,e,r){Gj.validate(Gj.isUrlStringOrObject(t),r,t);const i=jx(t);Gj.isFunction(e)&&(r=e,e={}),Gj.validate(Gj.isObject(e),r,e),Gj.validate(Gj.isFunction(r),r);const n=wx(i.hostname),o=i.pathname||"/";let a=e.secure;null!=a||!i.protocol||"https:"!=i.protocol&&"wss:"!=i.protocol||(a=!0);let s=0;if(e.sameSiteContext){const t=hx(e.sameSiteContext);if(s=Sx.sameSiteLevel[t],!s)return r(new Error(sx))}let h=e.http;null==h&&(h=!0);const u=e.now||Date.now(),l=!1!==e.expire,c=!!e.allPaths,d=this.store;function f(t){if(t.hostOnly){if(t.domain!=n)return!1}else if(!vx(n,t.domain,!1))return!1;if(!c&&!Yj(o,t.path))return!1;if(t.secure&&!a)return!1;if(t.httpOnly&&!h)return!1;if(s){if(Sx.sameSiteLevel[t.sameSite||"none"]>s)return!1}return!(l&&t.expiryTime()<=u)||(d.removeCookie(t.domain,t.path,t.key,(()=>{})),!1)}d.findCookies(n,c?null:o,this.allowSpecialUseDomain,((t,i)=>{if(t)return r(t);i=i.filter(f),!1!==e.sort&&(i=i.sort(Ax));const n=new Date;for(const t of i)t.lastAccessed=n;r(null,i)}))}getCookieString(...t){const e=t.pop();Gj.validate(Gj.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.sort(Ax).map((t=>t.cookieString())).join("; "))})),this.getCookies.apply(this,t)}getSetCookieStrings(...t){const e=t.pop();Gj.validate(Gj.isFunction(e),e);t.push((function(t,r){t?e(t):e(null,r.map((t=>t.toString())))})),this.getCookies.apply(this,t)}serialize(t){Gj.validate(Gj.isFunction(t),t);let e=this.store.constructor.name;Gj.isObject(e)&&(e=null);const r={version:"tough-cookie@4.1.4",storeType:e,rejectPublicSuffixes:!!this.rejectPublicSuffixes,enableLooseMode:!!this.enableLooseMode,allowSpecialUseDomain:!!this.allowSpecialUseDomain,prefixSecurity:Nx(this.prefixSecurity),cookies:[]};if(!this.store.getAllCookies||"function"!=typeof this.store.getAllCookies)return t(new Error("store does not support getAllCookies and cannot be serialized"));this.store.getAllCookies(((e,i)=>e?t(e):(r.cookies=i.map((t=>(delete(t=t instanceof Sx?t.toJSON():t).creationIndex,t))),t(null,r))))}toJSON(){return this.serializeSync()}_importCookies(t,e){let r=t.cookies;if(!r||!Array.isArray(r))return e(new Error("serialized jar has no cookies array"));r=r.slice();const i=t=>{if(t)return e(t);if(!r.length)return e(t,this);let n;try{n=Ex(r.shift())}catch(t){return e(t)}if(null===n)return i(null);this.store.putCookie(n,i)};i()}clone(t,e){1===arguments.length&&(e=t,t=null),this.serialize(((r,i)=>{if(r)return e(r);Ix.deserialize(i,t,e)}))}cloneSync(t){if(0===arguments.length)return this._cloneSync();if(!t.synchronous)throw new Error("CookieJar clone destination store is not synchronous; use async API instead.");return this._cloneSync(t)}removeAllCookies(t){Gj.validate(Gj.isFunction(t),t);const e=this.store;if("function"==typeof e.removeAllCookies&&e.removeAllCookies!==Jj.prototype.removeAllCookies)return e.removeAllCookies(t);e.getAllCookies(((r,i)=>{if(r)return t(r);if(0===i.length)return t(null);let n=0;const o=[];function a(e){if(e&&o.push(e),n++,n===i.length)return t(o.length?o[0]:null)}i.forEach((t=>{e.removeCookie(t.domain,t.path,t.key,a)}))}))}static deserialize(t,e,r){let i;if(3!==arguments.length&&(r=e,e=null),Gj.validate(Gj.isFunction(r),r),"string"==typeof t){if(i=_x(t),i instanceof Error)return r(i)}else i=t;const n=new Ix(e,{rejectPublicSuffixes:i.rejectPublicSuffixes,looseMode:i.enableLooseMode,allowSpecialUseDomain:i.allowSpecialUseDomain,prefixSecurity:i.prefixSecurity});n._importCookies(i,(t=>{if(t)return r(t);r(null,n)}))}static deserializeSync(t,e){const r="string"==typeof t?JSON.parse(t):t,i=new Ix(e,{rejectPublicSuffixes:r.rejectPublicSuffixes,looseMode:r.enableLooseMode});if(!i.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");return i._importCookiesSync(r),i}}function Tx(t){return function(...e){if(!this.store.synchronous)throw new Error("CookieJar store is not synchronous; use async API instead.");let r,i;if(this[t](...e,((t,e)=>{r=t,i=e})),r)throw r;return i}}Ix.fromJSON=Ix.deserializeSync,["_importCookies","clone","getCookies","getCookieString","getSetCookieStrings","removeAllCookies","serialize","setCookie"].forEach((t=>{Ix.prototype[t]=Qj(Ix.prototype[t])})),Ix.deserialize=Qj(Ix.deserialize);var Cx=Zj,zx=Ix,Ox=Sx,Rx=Jj,Px=Wj,Bx=gx,Dx=yx,$x=Mx,Lx=Ex,Fx=vx,Ux=bx,qx=Yj,Vx=DA.getPublicSuffix,Hx=Ax,Gx=UA.permuteDomain,Zx=function(t){if(Gj.validate(Gj.isString(t)),"/"===t)return["/"];const e=[t];for(;t.length>1;){const r=t.lastIndexOf("/");if(0===r)break;t=t.substr(0,r),e.push(t)}return e.push("/"),e},Kx=wx,Jx=ux,Wx=Gj.ParameterError,Yx={version:Cx,CookieJar:zx,Cookie:Ox,Store:Rx,MemoryCookieStore:Px,parseDate:Bx,formatDate:Dx,parse:$x,fromJSON:Lx,domainMatch:Fx,defaultPath:Ux,pathMatch:qx,getPublicSuffix:Vx,cookieCompare:Hx,permuteDomain:Gx,permutePath:Zx,canonicalDomain:Kx,PrefixSecurityEnum:Jx,ParameterError:Wx},Qx=Object.freeze(Object.assign(Object.create(null),Yx,{default:Yx,version:Cx,CookieJar:zx,Cookie:Ox,Store:Rx,MemoryCookieStore:Px,parseDate:Bx,formatDate:Dx,parse:$x,fromJSON:Lx,domainMatch:Fx,defaultPath:Ux,pathMatch:qx,getPublicSuffix:Vx,cookieCompare:Hx,permuteDomain:Gx,permutePath:Zx,canonicalDomain:Kx,PrefixSecurityEnum:Jx,ParameterError:Wx}));var Xx=function(t){if(Array.isArray(t))return t;if("string"!=typeof t)return[];var e,r,i,n,o,a=[],s=0;function h(){for(;s<t.length&&/\s/.test(t.charAt(s));)s+=1;return s<t.length}for(;s<t.length;){for(e=s,o=!1;h();)if(","===(r=t.charAt(s))){for(i=s,s+=1,h(),n=s;s<t.length&&"="!==(r=t.charAt(s))&&";"!==r&&","!==r;)s+=1;s<t.length&&"="===t.charAt(s)?(o=!0,s=n,a.push(t.substring(e,i)),e=s):s=i+1}else s+=1;(!o||s>=t.length)&&a.push(t.substring(e,t.length))}return a};const tS=new Set(["","no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"]);function eS(t,e){}function rS(t,e){t.headers.delete(e)}function iS(t,e){const r=t.headers;for(const t of Object.keys(r))t.toLowerCase()===e&&delete r[t]}const nS=new Set([301,302,303,307,308]);async function oS(t,e,r){switch(e.redirect??"follow"){case"error":throw new TypeError(`URI requested responded with a redirect and redirect mode is set to error: ${r.url}`);case"manual":return r;case"follow":break;default:throw new TypeError(`Invalid redirect option: ${e.redirect}`)}const i=r.headers.get("location");if(null===i)return r;const n=r.url,o=new URL(i,n).toString(),a=e.redirectCount??0,s=e.maxRedirect??20;if(a>=s)throw new TypeError(`Reached maximum redirect of ${s} for URL: ${n}`);const h=function(t){return null==t.headers?eS:"function"==typeof t.headers.delete?rS:iS}(e={...e,redirectCount:a+1});if(!function(t,e){const r=new URL(e).hostname,i=new URL(t).hostname;return r===i||r.endsWith(`.${i}`)}(n,o))for(const t of["authorization","www-authenticate","cookie","cookie2"])h(e,t);const u=e.body,l=e.body;if(303!==r.status&&null!=e.body&&("function"==typeof u.pipe||"function"==typeof l.pipeTo))throw new TypeError("Cannot follow redirect with body being a readable stream");return 303!==r.status&&(301!==r.status&&302!==r.status||"POST"!==e.method)||(e.method="GET",e.body=void 0,h(e,"content-length")),r.headers.has("referrer-policy")&&(e.referrerPolicy=function(t){const e=t.split(/[,\s]+/);let r="";for(const t of e)""!==t&&tS.has(t)&&(r=t);return r}(r.headers.get("referrer-policy"))),await t(o,e)}function aS(t,e,r=!0){const i=t,n=e??new zx;async function o(t,e){const a=e??{};e={...e,redirect:"manual"};const s="string"==typeof t?t:t.url??t.href;e=function(t,e,r){if(""===r)return e;const i=t,n=e.headers;return i.headers&&"function"==typeof i.headers.append?i.headers.append("cookie",r):n&&"function"==typeof n.append?n.append("cookie",r):e={...e,headers:{...e.headers,cookie:r}},e}(t,e,await n.getCookieString(s));const h=await i(t,e),u=function(t){const e=t.headers;if("function"==typeof e.getAll)return e.getAll("set-cookie");if("function"==typeof e.raw){const t=e.raw();return Array.isArray(t["set-cookie"])?t["set-cookie"]:[]}const r=t.headers.get("set-cookie");return null!==r?Xx(r):[]}(h);return await Promise.all(u.map((async t=>await n.setCookie(t,h.url,{ignoreError:r})))),(e.redirectCount??0)>0&&Object.defineProperty(h,"redirected",{value:!0}),l=h.status,nS.has(l)?await oS(o,a,h):h;var l}return o.toughCookie=Qx,o}aS.toughCookie=Qx;var sS="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==t&&t||{},hS="URLSearchParams"in sS,uS="Symbol"in sS&&"iterator"in Symbol,lS="FileReader"in sS&&"Blob"in sS&&function(){try{return new Blob,!0}catch(t){return!1}}(),cS="FormData"in sS,dS="ArrayBuffer"in sS;if(dS)var fS=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],mS=ArrayBuffer.isView||function(t){return t&&fS.indexOf(Object.prototype.toString.call(t))>-1};function pS(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function gS(t){return"string"!=typeof t&&(t=String(t)),t}function yS(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return uS&&(e[Symbol.iterator]=function(){return e}),e}function wS(t){this.map={},t instanceof wS?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function vS(t){if(!t._noBody)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function bS(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function kS(t){var e=new FileReader,r=bS(e);return e.readAsArrayBuffer(t),r}function MS(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function _S(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:lS&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:cS&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:hS&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():dS&&lS&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=MS(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):dS&&(ArrayBuffer.prototype.isPrototypeOf(t)||mS(t))?this._bodyArrayBuffer=MS(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):hS&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},lS&&(this.blob=function(){var t=vS(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=vS(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(lS)return this.blob().then(kS);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,e,r,i,n,o=vS(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=bS(e),i=/charset=([A-Za-z0-9_-]+)/.exec(t.type),n=i?i[1]:"utf-8",e.readAsText(t,n),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),i=0;i<e.length;i++)r[i]=String.fromCharCode(e[i]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},cS&&(this.formData=function(){return this.text().then(jS)}),this.json=function(){return this.text().then(JSON.parse)},this}wS.prototype.append=function(t,e){t=pS(t),e=gS(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},wS.prototype.delete=function(t){delete this.map[pS(t)]},wS.prototype.get=function(t){return t=pS(t),this.has(t)?this.map[t]:null},wS.prototype.has=function(t){return this.map.hasOwnProperty(pS(t))},wS.prototype.set=function(t,e){this.map[pS(t)]=gS(e)},wS.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},wS.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),yS(t)},wS.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),yS(t)},wS.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),yS(t)},uS&&(wS.prototype[Symbol.iterator]=wS.prototype.entries);var ES=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function AS(t,e){if(!(this instanceof AS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r,i,n=(e=e||{}).body;if(t instanceof AS){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new wS(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new wS(e.headers)),this.method=(r=e.method||this.method||"GET",i=r.toUpperCase(),ES.indexOf(i)>-1?i:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in sS)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==e.cache&&"no-cache"!==e.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function jS(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(i),decodeURIComponent(n))}})),e}function xS(t,e){if(!(this instanceof xS))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new wS(e.headers),this.url=e.url||"",this._initBody(t)}AS.prototype.clone=function(){return new AS(this,{body:this._bodyInit})},_S.call(AS.prototype),_S.call(xS.prototype),xS.prototype.clone=function(){return new xS(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new wS(this.headers),url:this.url})},xS.error=function(){var t=new xS(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var SS=[301,302,303,307,308];xS.redirect=function(t,e){if(-1===SS.indexOf(e))throw new RangeError("Invalid status code");return new xS(null,{status:e,headers:{location:t}})};var NS=sS.DOMException;try{new NS}catch(PM){NS=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},NS.prototype=Object.create(Error.prototype),NS.prototype.constructor=NS}function IS(t,e){return new Promise((function(r,i){var n=new AS(t,e);if(n.signal&&n.signal.aborted)return i(new NS("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}if(o.onload=function(){var t,e,i={statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new wS,t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),i=r.shift().trim();if(i){var n=r.join(":").trim();try{e.append(i,n)}catch(t){console.warn("Response "+t.message)}}})),e)};0===n.url.indexOf("file://")&&(o.status<200||o.status>599)?i.status=200:i.status=o.status,i.url="responseURL"in o?o.responseURL:i.headers.get("X-Request-URL");var a="response"in o?o.response:o.responseText;setTimeout((function(){r(new xS(a,i))}),0)},o.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},o.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request timed out"))}),0)},o.onabort=function(){setTimeout((function(){i(new NS("Aborted","AbortError"))}),0)},o.open(n.method,function(t){try{return""===t&&sS.location.href?sS.location.href:t}catch(e){return t}}(n.url),!0),"include"===n.credentials?o.withCredentials=!0:"omit"===n.credentials&&(o.withCredentials=!1),"responseType"in o&&(lS?o.responseType="blob":dS&&(o.responseType="arraybuffer")),e&&"object"==typeof e.headers&&!(e.headers instanceof wS||sS.Headers&&e.headers instanceof sS.Headers)){var s=[];Object.getOwnPropertyNames(e.headers).forEach((function(t){s.push(pS(t)),o.setRequestHeader(t,gS(e.headers[t]))})),n.headers.forEach((function(t,e){-1===s.indexOf(e)&&o.setRequestHeader(e,t)}))}else n.headers.forEach((function(t,e){o.setRequestHeader(e,t)}));n.signal&&(n.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&n.signal.removeEventListener("abort",a)}),o.send(void 0===n._bodyInit?null:n._bodyInit)}))}IS.polyfill=!0,sS.fetch||(sS.fetch=IS,sS.Headers=wS,sS.Request=AS,sS.Response=xS);var TS=self.fetch.bind(self);const CS=(t,e,r=[])=>{const i=Object.getOwnPropertyDescriptors(e);for(let t of r)delete i[t];Object.defineProperties(t,i)},zS=(t,e=[t])=>{const r=Object.getPrototypeOf(t);return null===r?e:zS(r,[...e,r])},OS=(t,e,r=[])=>{var i;const n=null!==(i=((...t)=>{if(0===t.length)return;let e;const r=t.map((t=>zS(t)));for(;r.every((t=>t.length>0));){const t=r.map((t=>t.pop())),i=t[0];if(!t.every((t=>t===i)))break;e=i}return e})(...t))&&void 0!==i?i:Object.prototype,o=Object.create(n),a=zS(n);for(let e of t){let t=zS(e);for(let e=t.length-1;e>=0;e--){let i=t[e];-1===a.indexOf(i)&&(CS(o,i,["constructor",...r]),a.push(i))}}return o.constructor=e,o},RS=t=>t.filter(((e,r)=>t.indexOf(e)==r)),PS=new WeakMap,BS=t=>PS.get(t),DS=(t,e)=>{var r,i;const n=RS([...Object.getOwnPropertyNames(t),...Object.getOwnPropertyNames(e)]),o={};for(let a of n)o[a]=RS([...null!==(r=null==t?void 0:t[a])&&void 0!==r?r:[],...null!==(i=null==e?void 0:e[a])&&void 0!==i?i:[]]);return o},$S=(t,e)=>{var r,i,n,o;return{property:DS(null!==(r=null==t?void 0:t.property)&&void 0!==r?r:{},null!==(i=null==e?void 0:e.property)&&void 0!==i?i:{}),method:DS(null!==(n=null==t?void 0:t.method)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.method)&&void 0!==o?o:{})}},LS=new Map,FS=(...t)=>{const e=((...t)=>{var e;const r=new Set,i=new Set([...t]);for(;i.size>0;)for(let t of i){const n=[...zS(t.prototype).map((t=>t.constructor)),...null!==(e=BS(t))&&void 0!==e?e:[]].filter((t=>!r.has(t)));for(let t of n)i.add(t);r.add(t),i.delete(t)}return[...r]})(...t).map((t=>LS.get(t))).filter((t=>!!t));return 0==e.length?{}:1==e.length?e[0]:e.reduce(((t,e)=>((t,e)=>{var r,i,n,o,a,s;return{class:RS([...null!==(r=null==t?void 0:t.class)&&void 0!==r?r:[],...null!==(i=null==e?void 0:e.class)&&void 0!==i?i:[]]),static:$S(null!==(n=null==t?void 0:t.static)&&void 0!==n?n:{},null!==(o=null==e?void 0:e.static)&&void 0!==o?o:{}),instance:$S(null!==(a=null==t?void 0:t.instance)&&void 0!==a?a:{},null!==(s=null==e?void 0:e.instance)&&void 0!==s?s:{})}})(t,e)))};function US(...t){var e,r,i;const n=t.map((t=>t.prototype));function o(...e){for(const r of t)CS(this,new r(...e))}o.prototype=OS(n,o),Object.setPrototypeOf(o,OS(t,null,["prototype"]));let a=o;{const n=FS(...t);for(let t of null!==(e=null==n?void 0:n.class)&&void 0!==e?e:[]){const e=t(a);e&&(a=e)}qS(null!==(r=null==n?void 0:n.static)&&void 0!==r?r:{},a),qS(null!==(i=null==n?void 0:n.instance)&&void 0!==i?i:{},a.prototype)}var s,h;return s=a,h=t,PS.set(s,h),a}const qS=(t,e)=>{const r=t.property,i=t.method;if(r)for(let t in r)for(let i of r[t])i(e,t);if(i)for(let t in i)for(let r of i[t])r(e,t,Object.getOwnPropertyDescriptor(e,t))};var VS=Object.defineProperty,HS=Object.getOwnPropertyDescriptor,GS=Object.getOwnPropertyNames,ZS=Object.prototype.hasOwnProperty,KS=(t,e)=>{for(var r in e)VS(t,r,{get:e[r],enumerable:!0})},JS=(t,e,r,i)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let n of GS(e))ZS.call(t,n)||n===r||VS(t,n,{get:()=>e[n],enumerable:!(i=HS(e,n))||i.enumerable});return t};KS({},{ADDR_BOUND:()=>ON,API_VERSION:()=>TN,BaseUrl:()=>$N,DEFAULT_GLOBAL_CONFIG:()=>QN,FeeMarginPercentage:()=>qN,HARDENING_4BYTES:()=>YN,HARDENING_BYTE:()=>WN,IS_BROWSER:()=>dN,MASK_250:()=>NN,MASK_31:()=>IN,MAX_STORAGE_ITEM_SIZE:()=>zN,NetworkName:()=>LN,OutsideExecutionCallerAny:()=>ZN,PRIME:()=>CN,RANGE_FELT:()=>PN,RANGE_I128:()=>BN,RANGE_U128:()=>DN,RPC_DEFAULT_VERSION:()=>HN,RPC_NODES:()=>GN,SNIP9_V1_INTERFACE_ID:()=>KN,SNIP9_V2_INTERFACE_ID:()=>JN,SYSTEM_MESSAGES:()=>XN,StarknetChainId:()=>FN,TEXT_TO_FELT_MAX_LEN:()=>xN,TRANSACTION_VERSION:()=>WS.ETransactionVersion,TransactionHashPrefix:()=>UN,UDC:()=>VN,ZERO:()=>SN});var WS={};KS(WS,{JRPC:()=>YS,RPCSPEC06:()=>QS,RPCSPEC07:()=>sg});var YS={},QS={};KS(QS,{EBlockTag:()=>aN,EDAMode:()=>hN,EDataAvailabilityMode:()=>sN,ESimulationFlag:()=>rN,ETransactionExecutionStatus:()=>oN,ETransactionFinalityStatus:()=>nN,ETransactionStatus:()=>iN,ETransactionType:()=>eN,ETransactionVersion:()=>uN,ETransactionVersion2:()=>lN,ETransactionVersion3:()=>cN,Errors:()=>XS,SPEC:()=>tN});var XS={},tN={},eN={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE",L1_HANDLER:"L1_HANDLER"},rN={SKIP_VALIDATE:"SKIP_VALIDATE",SKIP_FEE_CHARGE:"SKIP_FEE_CHARGE"},iN={RECEIVED:"RECEIVED",REJECTED:"REJECTED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},nN={ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},oN={SUCCEEDED:"SUCCEEDED",REVERTED:"REVERTED"},aN={PENDING:"pending",LATEST:"latest"},sN={L1:"L1",L2:"L2"},hN={L1:0,L2:1},uN={V0:"0x0",V1:"0x1",V2:"0x2",V3:"0x3",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002",F3:"0x100000000000000000000000000000003"},lN={V0:"0x0",V1:"0x1",V2:"0x2",F0:"0x100000000000000000000000000000000",F1:"0x100000000000000000000000000000001",F2:"0x100000000000000000000000000000002"},cN={V3:"0x3",F3:"0x100000000000000000000000000000003"};((t,e,r)=>{JS(t,e,"default"),r&&JS(r,e,"default")})(WS,sg);KS({},{IS_BROWSER:()=>dN,addHexPrefix:()=>bN,arrayBufferToString:()=>fN,atobUniversal:()=>gN,btoaUniversal:()=>yN,buf2hex:()=>wN,calcByteLength:()=>MN,concatenateArrayBuffer:()=>jN,padLeft:()=>kN,pascalToSnake:()=>AN,removeHexPrefix:()=>vN,sanitizeBytes:()=>_N,sanitizeHex:()=>EN,stringToArrayBuffer:()=>pN,utf8ToArray:()=>mN});var dN="undefined"!=typeof window;function fN(t){return new Uint8Array(t).reduce(((t,e)=>t+String.fromCharCode(e)),"")}function mN(t){return(new TextEncoder).encode(t)}function pN(t){return mN(t)}function gN(t){return Sg.decode(t)}function yN(t){return Sg.encode(new Uint8Array(t))}function wN(t){return t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),"")}function vN(t){return t.replace(/^0x/i,"")}function bN(t){return`0x${vN(t)}`}function kN(t,e,r="0"){return function(t,e,r,i="0"){const n=e-t.length;let o=t;if(n>0){const e=i.repeat(n);o=r?e+t:t+e}return o}(t,e,!0,r)}function MN(t,e=8){const{length:r}=t,i=r%e;return i?(r-i)/e*e+e:r}function _N(t,e=8,r="0"){return kN(t,MN(t,e),r)}function EN(t){const e=_N(vN(t),2);return e?bN(e):e}var AN=t=>/[a-z]/.test(t)?t.split(/(?=[A-Z])/).join("_").toUpperCase():t;function jN(t){const e=t.reduce(((t,e)=>t+e.byteLength),0),r=new Uint8Array(e);let i=0;return t.forEach((t=>{r.set(t,i),i+=t.byteLength})),r}var xN=31,SN=0n,NN=2n**250n-1n,IN=2n**31n-1n,TN=SN,CN=2n**251n+17n*2n**192n+1n,zN=256n,ON=2n**251n-zN,RN=(t,e)=>({min:t,max:e}),PN=RN(SN,CN-1n),BN=RN(-(2n**127n),2n**127n-1n),DN=RN(SN,2n**128n-1n),$N=(t=>(t.SN_MAIN="https://alpha-mainnet.starknet.io",t.SN_SEPOLIA="https://alpha-sepolia.starknet.io",t))($N||{}),LN=(t=>(t.SN_MAIN="SN_MAIN",t.SN_SEPOLIA="SN_SEPOLIA",t))(LN||{}),FN=(t=>(t.SN_MAIN="0x534e5f4d41494e",t.SN_SEPOLIA="0x534e5f5345504f4c4941",t))(FN||{}),UN=(t=>(t.DECLARE="0x6465636c617265",t.DEPLOY="0x6465706c6f79",t.DEPLOY_ACCOUNT="0x6465706c6f795f6163636f756e74",t.INVOKE="0x696e766f6b65",t.L1_HANDLER="0x6c315f68616e646c6572",t))(UN||{}),qN=(t=>(t[t.L1_BOUND_MAX_AMOUNT=50]="L1_BOUND_MAX_AMOUNT",t[t.L1_BOUND_MAX_PRICE_PER_UNIT=50]="L1_BOUND_MAX_PRICE_PER_UNIT",t[t.MAX_FEE=50]="MAX_FEE",t))(qN||{}),VN={ADDRESS:"0x041a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf",ENTRYPOINT:"deployContract"},HN="v0_7",GN={SN_MAIN:[`https://starknet-mainnet.public.blastapi.io/rpc/${HN}`,`https://free-rpc.nethermind.io/mainnet-juno/${HN}`],SN_SEPOLIA:[`https://starknet-sepolia.public.blastapi.io/rpc/${HN}`,`https://free-rpc.nethermind.io/sepolia-juno/${HN}`]},ZN="0x414e595f43414c4c4552",KN="0x68cfd18b92d1907b8ba3cc324900277f5a3622099431ea85dd8089255e4181",JN="0x1d1144bb2138366ff28d8e9ab57456b1d332ac42196230c3a602003c89872",WN=128,YN=2147483648n,QN={legacyMode:!1,logLevel:"INFO",accountTxVersion:WS.ETransactionVersion.V2},XN={legacyTxWarningMessage:"You are using a deprecated transaction version (V0,V1,V2)!\nUpdate to the latest V3 transactions!"},tI={};KS(tI,{RpcChannel:()=>oO});KS({},{parse:()=>rI,parseAlwaysAsBig:()=>iI,stringify:()=>nI,stringifyAlwaysAsBig:()=>oI});var eI=t=>{if(!Rg(t))return parseFloat(t);const e=parseInt(t,10);return Number.isSafeInteger(e)?e:BigInt(t)},rI=t=>Yg(String(t),void 0,eI),iI=t=>Yg(String(t),void 0,Kg),nI=(t,e,r,i)=>Iy(t,e,r,i),oI=nI,aI={FAILED_TO_RECEIVE_TXN:1,NO_TRACE_AVAILABLE:10,CONTRACT_NOT_FOUND:20,BLOCK_NOT_FOUND:24,INVALID_TXN_INDEX:27,CLASS_HASH_NOT_FOUND:28,TXN_HASH_NOT_FOUND:29,PAGE_SIZE_TOO_BIG:31,NO_BLOCKS:32,INVALID_CONTINUATION_TOKEN:33,TOO_MANY_KEYS_IN_FILTER:34,CONTRACT_ERROR:40,TRANSACTION_EXECUTION_ERROR:41,CLASS_ALREADY_DECLARED:51,INVALID_TRANSACTION_NONCE:52,INSUFFICIENT_MAX_FEE:53,INSUFFICIENT_ACCOUNT_BALANCE:54,VALIDATION_FAILURE:55,COMPILATION_FAILED:56,CONTRACT_CLASS_SIZE_IS_TOO_LARGE:57,NON_ACCOUNT:58,DUPLICATE_TX:59,COMPILED_CLASS_HASH_MISMATCH:60,UNSUPPORTED_TX_VERSION:61,UNSUPPORTED_CONTRACT_CLASS_VERSION:62,UNEXPECTED_ERROR:63};var sI=class extends Error{name;constructor(t){super(t),Object.defineProperty(this,"name",{value:new.target.name,enumerable:!1,configurable:!0}),function(t,e){const{setPrototypeOf:r}=Object;r?r(t,e):t.__proto__=e}(this,new.target.prototype),function(t,e=t.constructor){const{captureStackTrace:r}=Error;r&&r(t,e)}(this)}},hI=class extends sI{},uI=class extends hI{constructor(t,e,r){super(`RPC: ${e} with params ${nI(r,null,2)}\n\n ${t.code}: ${t.message}: ${nI(t.data)}`),this.baseError=t,this.request={method:e,params:r}}request;get code(){return this.baseError.code}isType(t){return aI[t]===this.code}};KS({},{BlockStatus:()=>pI,BlockTag:()=>gI,ETH_ADDRESS:()=>bI,EntryPointType:()=>lI,Literal:()=>vI,NON_ZERO_PREFIX:()=>kI,OutsideExecutionTypesV1:()=>MI,OutsideExecutionTypesV2:()=>_I,OutsideExecutionVersion:()=>EI,RPC:()=>WS,TransactionExecutionStatus:()=>mI,TransactionFinalityStatus:()=>fI,TransactionStatus:()=>dI,TransactionType:()=>cI,TypedDataRevision:()=>og,Uint:()=>wI,ValidateType:()=>yI});var lI={EXTERNAL:"EXTERNAL",L1_HANDLER:"L1_HANDLER",CONSTRUCTOR:"CONSTRUCTOR"},cI={DECLARE:"DECLARE",DEPLOY:"DEPLOY",DEPLOY_ACCOUNT:"DEPLOY_ACCOUNT",INVOKE:"INVOKE_FUNCTION"},dI={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",REJECTED:"REJECTED",REVERTED:"REVERTED"},fI={NOT_RECEIVED:"NOT_RECEIVED",RECEIVED:"RECEIVED",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",ACCEPTED_ON_L1:"ACCEPTED_ON_L1"},mI={REJECTED:"REJECTED",REVERTED:"REVERTED",SUCCEEDED:"SUCCEEDED"},pI={PENDING:"PENDING",ACCEPTED_ON_L1:"ACCEPTED_ON_L1",ACCEPTED_ON_L2:"ACCEPTED_ON_L2",REJECTED:"REJECTED"},gI={PENDING:"pending",LATEST:"latest"},yI={DEPLOY:"DEPLOY",CALL:"CALL",INVOKE:"INVOKE"},wI={u8:"core::integer::u8",u16:"core::integer::u16",u32:"core::integer::u32",u64:"core::integer::u64",u128:"core::integer::u128",u256:"core::integer::u256",u512:"core::integer::u512"},vI={ClassHash:"core::starknet::class_hash::ClassHash",ContractAddress:"core::starknet::contract_address::ContractAddress",Secp256k1Point:"core::starknet::secp256k1::Secp256k1Point",U96:"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"},bI="core::starknet::eth_address::EthAddress",kI="core::zeroable::NonZero::",MI={StarkNetDomain:[{name:"name",type:"felt"},{name:"version",type:"felt"},{name:"chainId",type:"felt"}],OutsideExecution:[{name:"caller",type:"felt"},{name:"nonce",type:"felt"},{name:"execute_after",type:"felt"},{name:"execute_before",type:"felt"},{name:"calls_len",type:"felt"},{name:"calls",type:"OutsideCall*"}],OutsideCall:[{name:"to",type:"felt"},{name:"selector",type:"felt"},{name:"calldata_len",type:"felt"},{name:"calldata",type:"felt*"}]},_I={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],OutsideExecution:[{name:"Caller",type:"ContractAddress"},{name:"Nonce",type:"felt"},{name:"Execute After",type:"u128"},{name:"Execute Before",type:"u128"},{name:"Calls",type:"Call*"}],Call:[{name:"To",type:"ContractAddress"},{name:"Selector",type:"selector"},{name:"Calldata",type:"felt*"}]},EI=(t=>(t.UNSUPPORTED="0",t.V1="1",t.V2="2",t))(EI||{}),AI=class{nodeUrl;headers;interval;requestId=0;pendingRequests={};batchPromises={};delayTimer;delayPromise;delayPromiseResolve;baseFetch;constructor(t){this.nodeUrl=t.nodeUrl,this.headers=t.headers,this.interval=t.interval,this.baseFetch=t.baseFetch}async wait(){return this.delayPromise&&this.delayPromiseResolve||(this.delayPromise=new Promise((t=>{this.delayPromiseResolve=t}))),this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=void 0),this.delayTimer=setTimeout((()=>{this.delayPromiseResolve&&(this.delayPromiseResolve(),this.delayPromise=void 0,this.delayPromiseResolve=void 0)}),this.interval),this.delayPromise}addPendingRequest(t,e,r){const i={id:r??`batched_${this.requestId+=1}`,jsonrpc:"2.0",method:t,params:e??void 0};return this.pendingRequests[i.id]=i,i.id}async sendBatch(t){return(await this.baseFetch(this.nodeUrl,{method:"POST",body:nI(t),headers:this.headers})).json()}async fetch(t,e,r){const i=this.addPendingRequest(t,e,r);await this.wait();const n=this.pendingRequests;if(this.pendingRequests={},!this.batchPromises[i]){const t=this.sendBatch(Object.values(n));Object.keys(n).forEach((e=>{this.batchPromises[e]=t}))}const o=await this.batchPromises[i];delete this.batchPromises[i];const a=o.find((t=>t.id===i));if(!a)throw new Error(`Couldn't find the result for the request. Method: ${t}`);return a}};function jI(t,e){if(!t)throw new Error(e||"Assertion failure")}KS({},{addPercent:()=>WI,assertInRange:()=>FI,bigNumberishArrayToDecimalStringArray:()=>UI,bigNumberishArrayToHexadecimalStringArray:()=>qI,cleanHex:()=>LI,getDecimalString:()=>HI,getHexString:()=>GI,getHexStringArray:()=>ZI,hexToBytes:()=>JI,hexToDecimalString:()=>$I,isBigNumberish:()=>QI,isHex:()=>zI,isStringWholeNumber:()=>VI,stringToSha256ToArrayBuff4:()=>YI,toBigInt:()=>OI,toCairoBool:()=>KI,toHex:()=>RI,toHex64:()=>DI,toHexString:()=>PI,toStorageKey:()=>BI});var xI=t=>void 0===t||void 0===t;function SI(t){return"number"==typeof t}function NI(t){return"boolean"==typeof t}function II(t){return"bigint"==typeof t}function TI(t){return"string"==typeof t}function CI(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function zI(t){return/^0x[0-9a-f]*$/i.test(t)}function OI(t){return BigInt(t)}function RI(t){return bN(OI(t).toString(16))}var PI=RI;function BI(t){return bN(OI(t).toString(16).padStart(64,"0"))}function DI(t){const e=bN(OI(t).toString(16).padStart(64,"0"));if(66!==e.length)throw TypeError("number is too big for hex 0x(64) representation");return e}function $I(t){return BigInt(bN(t)).toString(10)}function LI(t){return t.toLowerCase().replace(/^(0x)0+/,"$1")}function FI(t,e,r,i=""){const n=""===i?"invalid length":`invalid ${i} length`,o=BigInt(t),a=BigInt(e),s=BigInt(r);jI(o>=a&&o<=s,`Message not signable, ${n}.`)}function UI(t){return t.map((t=>OI(t).toString(10)))}function qI(t){return t.map((t=>RI(t)))}function VI(t){return/^\d+$/.test(t)}function HI(t){if(zI(t))return $I(t);if(VI(t))return t;throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function GI(t){if(zI(t))return t;if(VI(t))return PI(t);throw new Error(`${t} needs to be a hex-string or whole-number-string`)}function ZI(t){return t.map(GI)}function KI(t){return(+t).toString()}function JI(t){if(!zI(t))throw new Error(`${t} needs to be a hex-string`);let e=vN(t);return e.length%2!=0&&(e=`0${e}`),Ky(e)}function WI(t,e){const r=BigInt(t);return r+r*BigInt(e)/100n}function YI(t){var e;return JI(RI((e=BigInt(bN(wN(zw(t)))),Number(e&IN))))}function QI(t){return SI(t)||II(t)||TI(t)&&(zI(t)||VI(t))}function XI(t){const e=vN(RI(BigInt(t))),r=e.length%2==0?e:`0${e}`;return bN(Fb(JI(bN(r))).toString(16))}function tT(t){const e=BigInt(function(t){return bN(Fb(mN(t)).toString(16))}(t));return e&NN}function eT(t){return RI(tT(t))}function rT(t){return SI(t)||II(t)?RI(t):zI(t)?t:VI(t)?RI(t):eT(t)}function iT(t){const e=bN(t.reduce(((t,e)=>t+vN(RI(e)).padStart(64,"0")),""));return bN(Dy(pk(JI(e))))}function nT(t,e,r,i,n){return iT([t,e,n,r,i.length,...i])}KS({},{getL2MessageHash:()=>nT,getSelector:()=>rT,getSelectorFromName:()=>eT,keccakBn:()=>XI,solidityUint256PackedKeccak256:()=>iT,starknetKeccak:()=>tT});function oT(t){return/^[\x00-\x7F]*$/.test(t)}function aT(t){return t.length<=xN}function sT(t){return/^[0-9]*$/i.test(t)}function hT(t){return TI(t)&&!zI(t)&&!VI(t)}KS({},{decodeShortString:()=>fT,encodeShortString:()=>dT,isASCII:()=>oT,isDecimalString:()=>sT,isLongText:()=>lT,isShortString:()=>aT,isShortText:()=>uT,isText:()=>hT,splitLongString:()=>cT});var uT=t=>hT(t)&&aT(t),lT=t=>hT(t)&&!aT(t);function cT(t){const e=RegExp(`[^]{1,${xN}}`,"g");return t.match(e)||[]}function dT(t){if(!oT(t))throw new Error(`${t} is not an ASCII string`);if(!aT(t))throw new Error(`${t} is too long`);return bN(t.replace(/./g,(t=>t.charCodeAt(0).toString(16))))}function fT(t){if(!oT(t))throw new Error(`${t} is not an ASCII string`);if(zI(t))return vN(t).replace(/.{2}/g,(t=>String.fromCharCode(parseInt(t,16))));if(sT(t))return fT("0X".concat(BigInt(t).toString(16)));throw new Error(`${t} is not Hex or decimal`)}function mT(t){const e=0n===BigInt(t.pending_word)?"":fT(RI(t.pending_word));return t.data.reduce(((t,e)=>t+(0n===BigInt(e)?"":fT(RI(e)))),"")+e}function pT(t){const e=cT(t),r=e[e.length-1],i=e.map(dT),[n,o]=void 0===r||31===r.length?["0x00",0]:[i.pop(),r.length];return{data:0===i.length?[]:i,pending_word:n,pending_word_len:o}}KS({},{byteArrayFromString:()=>pT,stringFromByteArray:()=>mT});var gT={};function yT(t){if(II(t)||Number.isInteger(t))return t.toString();if(TI(t)){if(zI(t))return BigInt(t).toString();if(hT(t)){if(!aT(t))throw new Error(`${t} is a long string > 31 chars. Please split it into an array of short strings.`);return BigInt(dT(t)).toString()}if(VI(t))return t}if(NI(t))return""+ +t;throw new Error(`${t} can't be computed by felt()`)}KS(gT,{felt:()=>iC,getAbiContractVersion:()=>XT,getArrayType:()=>WT,isCairo1Abi:()=>YT,isCairo1Type:()=>JT,isLen:()=>IT,isTypeArray:()=>CT,isTypeBool:()=>UT,isTypeByteArray:()=>GT,isTypeBytes31:()=>HT,isTypeContractAddress:()=>qT,isTypeEnum:()=>PT,isTypeEthAddress:()=>VT,isTypeFelt:()=>TT,isTypeLiteral:()=>FT,isTypeNamedTuple:()=>OT,isTypeNonZero:()=>QT,isTypeOption:()=>BT,isTypeResult:()=>DT,isTypeSecp256k1Point:()=>KT,isTypeStruct:()=>RT,isTypeTuple:()=>zT,isTypeU96:()=>ZT,isTypeUint:()=>$T,isTypeUint256:()=>LT,tuple:()=>rC,uint256:()=>tC,uint512:()=>eC});var wT=(1n<<128n)-1n,vT=(1n<<256n)-1n,bT=0n,kT=340282366920938463463374607431768211455n,MT=340282366920938463463374607431768211455n,_T=0n,ET=0n,AT=class t{low;high;static abiSelector="core::integer::u256";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"low"in e[0]&&"high"in e[0]){const r=t.validateProps(e[0].low,e[0].high);this.low=r.low,this.high=r.high}else if(1===e.length){const r=t.validate(e[0]);this.low=r&wT,this.high=r>>128n}else{if(2!==e.length)throw Error("Incorrect constructor parameters");{const r=t.validateProps(e[0],e[1]);this.low=r.low,this.high=r.high}}}static validate(t){const e=BigInt(t);if(e<bT)throw Error("bigNumberish is smaller than UINT_256_MIN");if(e>vT)throw new Error("bigNumberish is bigger than UINT_256_MAX");return e}static validateProps(t,e){const r=BigInt(t),i=BigInt(e);if(r<_T||r>kT)throw new Error("low is out of range UINT_256_LOW_MIN - UINT_256_LOW_MAX");if(i<ET||i>MT)throw new Error("high is out of range UINT_256_HIGH_MIN - UINT_256_HIGH_MAX");return{low:r,high:i}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.high<<128n)+this.low}toUint256HexString(){return{low:bN(this.low.toString(16)),high:bN(this.high.toString(16))}}toUint256DecimalString(){return{low:this.low.toString(10),high:this.high.toString(10)}}toApiRequest(){return[yT(this.low),yT(this.high)]}},jT=(1n<<512n)-1n,xT=0n,ST=0n,NT=class t{limb0;limb1;limb2;limb3;static abiSelector="core::integer::u512";constructor(...e){if("object"==typeof e[0]&&1===e.length&&"limb0"in e[0]&&"limb1"in e[0]&&"limb2"in e[0]&&"limb3"in e[0]){const r=t.validateProps(e[0].limb0,e[0].limb1,e[0].limb2,e[0].limb3);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}else if(1===e.length){const r=t.validate(e[0]);this.limb0=r&wT,this.limb1=(r&wT<<128n)>>128n,this.limb2=(r&wT<<256n)>>256n,this.limb3=r>>384n}else{if(4!==e.length)throw Error("Incorrect Uint512 constructor parameters");{const r=t.validateProps(e[0],e[1],e[2],e[3]);this.limb0=r.limb0,this.limb1=r.limb1,this.limb2=r.limb2,this.limb3=r.limb3}}}static validate(t){const e=BigInt(t);if(e<xT)throw Error("bigNumberish is smaller than UINT_512_MIN.");if(e>jT)throw Error("bigNumberish is bigger than UINT_512_MAX.");return e}static validateProps(t,e,r,i){const n=BigInt(t),o=BigInt(e),a=BigInt(r),s=BigInt(i);return[n,o,a,s].forEach(((t,e)=>{if(t<ST||t>wT)throw Error(`limb${e} is not in the range of a u128 number`)})),{limb0:n,limb1:o,limb2:a,limb3:s}}static is(e){try{t.validate(e)}catch(t){return!1}return!0}static isAbiType(e){return e===t.abiSelector}toBigInt(){return(this.limb3<<384n)+(this.limb2<<256n)+(this.limb1<<128n)+this.limb0}toUint512HexString(){return{limb0:bN(this.limb0.toString(16)),limb1:bN(this.limb1.toString(16)),limb2:bN(this.limb2.toString(16)),limb3:bN(this.limb3.toString(16))}}toUint512DecimalString(){return{limb0:this.limb0.toString(10),limb1:this.limb1.toString(10),limb2:this.limb2.toString(10),limb3:this.limb3.toString(10)}}toApiRequest(){return[yT(this.limb0),yT(this.limb1),yT(this.limb2),yT(this.limb3)]}},IT=t=>/_len$/.test(t),TT=t=>"felt"===t||"core::felt252"===t,CT=t=>/\*/.test(t)||t.startsWith("core::array::Array::")||t.startsWith("core::array::Span::"),zT=t=>/^\(.*\)$/i.test(t),OT=t=>/\(.*\)/i.test(t)&&t.includes(":"),RT=(t,e)=>t in e,PT=(t,e)=>t in e,BT=t=>t.startsWith("core::option::Option::"),DT=t=>t.startsWith("core::result::Result::"),$T=t=>Object.values(wI).includes(t),LT=t=>AT.isAbiType(t),FT=t=>Object.values(vI).includes(t),UT=t=>"core::bool"===t,qT=t=>t===vI.ContractAddress,VT=t=>t===bI,HT=t=>"core::bytes_31::bytes31"===t,GT=t=>"core::byte_array::ByteArray"===t,ZT=t=>"core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>"===t,KT=t=>t===vI.Secp256k1Point,JT=t=>t.includes("::"),WT=t=>JT(t)?t.substring(t.indexOf("<")+1,t.lastIndexOf(">")):t.replace("*","");function YT(t){const{cairo:e}=XT(t);if(void 0===e)throw Error("Unable to determine Cairo version");return"1"===e}function QT(t){return t.startsWith(kI)}function XT(t){if(t.find((t=>"interface"===t.type)))return{cairo:"1",compiler:"2"};const e=t.find((t=>("function"===t.type||"constructor"===t.type)&&(t.inputs.length||t.outputs.length)));if(!e)return{cairo:void 0,compiler:void 0};const r=e.inputs.length?e.inputs:e.outputs;return JT(r[0].type)?{cairo:"1",compiler:"1"}:{cairo:"0",compiler:"0"}}var tC=t=>new AT(t).toUint256DecimalString(),eC=t=>new NT(t).toUint512DecimalString(),rC=(...t)=>({...t});function iC(t){return yT(t)}var nC=class{variant;constructor(t){const e=Object.values(t);if(0===e.length)throw new Error("This Enum must have at least 1 variant");if(1!==e.filter((t=>!xI(t))).length)throw new Error("This Enum must have exactly one active variant");this.variant=t}unwrap(){return Object.values(this.variant).find((t=>!xI(t)))}activeVariant(){const t=Object.entries(this.variant).find((t=>!xI(t[1])));return xI(t)?"":t[0]}},oC={Some:0,None:1},aC=class{Some;None;constructor(t,e){if(!(t in Object.values(oC)))throw new Error("Wrong variant! It should be CairoOptionVariant.Some or .None.");if(t===oC.Some){if(xI(e))throw new Error('The creation of a Cairo Option with "Some" variant needs a content as input.');this.Some=e,this.None=void 0}else this.Some=void 0,this.None=!0}unwrap(){return this.None?void 0:this.Some}isSome(){return!xI(this.Some)}isNone(){return!0===this.None}},sC={Ok:0,Err:1},hC=class{Ok;Err;constructor(t,e){if(!(t in Object.values(sC)))throw new Error("Wrong variant! It should be CairoResultVariant.Ok or .Err.");t===sC.Ok?(this.Ok=e,this.Err=void 0):(this.Ok=void 0,this.Err=e)}unwrap(){if(!xI(this.Ok))return this.Ok;if(!xI(this.Err))return this.Err;throw new Error("Both Result.Ok and .Err are undefined. Not authorized.")}isOk(){return!xI(this.Ok)}isErr(){return!xI(this.Err)}},uC=(t,e,r)=>{if(!II(t[r]))throw new Error(`Data and formatter mismatch on ${r}:${e[r]}, expected response data ${r}:${t[r]} to be BN instead it is ${typeof t[r]}`)},lC=(t,e,r)=>{throw new Error(`Unhandled formatter type on ${r}:${e[r]} for data ${r}:${t[r]}`)};function cC(t,e,r){return Object.entries(t).reduce(((i,[n,o])=>{const a=r??e[n];if(!(n in e)&&!r)return i[n]=o,i;if("string"===a){if(Array.isArray(t[n])){const e=cC(t[n],t[n].map((t=>a)));return i[n]=Object.values(e).join(""),i}return uC(t,e,n),i[n]=fT(o),i}if("number"===a)return uC(t,e,n),i[n]=Number(o),i;if("function"==typeof a)return i[n]=a(o),i;if(Array.isArray(a)){const e=cC(t[n],a,a[0]);return i[n]=Object.values(e),i}return CI(a)?(i[n]=cC(t[n],a),i):(lC(t,e,n),i)}),{})}function dC(t){const e=function(t){return t.find((t=>"interface"===t.type))?2:YT(t)?1:0}(t);if(0===e||1===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.reduce(((t,e)=>IT(e.name)?t:t+1),0)}getMethod(t){return this.abi.find((e=>e.name===t))}getLegacyFormat(){return this.abi}}(t);if(2===e)return new class{abi;constructor(t){this.abi=t}methodInputsLength(t){return t.inputs.length}getMethod(t){return this.abi.find((t=>"interface"===t.type))?.items?.find((e=>e.name===t))}getLegacyFormat(){return this.abi.flatMap((t=>"interface"===t.type?t.items:t))}}(t);throw Error(`Unsupported ABI version ${e}`)}function fC(t,e,r){return"constructor"===t&&!r&&!e.length}function mC(t,e,r){for(let i=0,n=0;i<t.length;i++)if(t[i]===e)n++;else if(t[i]===r&&0==--n)return i;return Number.POSITIVE_INFINITY}function pC(t){return JT(t)?function(t){const e=t.slice(1,-1),r=[];let i,n=0;for(;n<e.length;){switch(!0){case"("===e[n]:i=n+mC(e.slice(n),"(",")")+1;break;case e.startsWith("core::result::Result::<",n)||e.startsWith("core::array::Array::<",n)||e.startsWith("core::option::Option::<",n):i=n+mC(e.slice(n),"<",">")+1;break;default:{const t=e.indexOf(",",n);i=-1!==t?t:Number.POSITIVE_INFINITY}}r.push(e.slice(n,i)),n=i+2}return r}(t):function(t){const e=t.replace(/\s/g,"").slice(1,-1),{subTuple:r,result:i}=function(t){if(!t.includes("("))return{subTuple:[],result:t};const e=[];let r="",i=0;for(;i<t.length;){if("("===t[i]){let n=1;const o=i;for(i++;n;)")"===t[i]&&n--,"("===t[i]&&n++,i++;e.push(t.substring(o,i)),r+=" ",i--}else r+=t[i];i++}return{subTuple:e,result:r}}(e);let n=i.split(",").map((t=>r.length?t.replace(" ",r.shift()):t));return OT(t)&&(n=n.reduce(((t,e)=>t.concat(function(t){const e=t.substring(0,t.indexOf(":"));return{name:e,type:t.substring(e.length+":".length)}}(e))),[])),n}(t)}var gC=class t{content;arrayType;constructor(e,r){jI(t.isTypeFixedArray(r),`The type ${r} is not a Cairo fixed array. Needs [type; length].`);try{t.getFixedArrayType(r)}catch{throw new Error(`The type ${r} do not includes any content type. Needs [type; length].`)}try{t.getFixedArraySize(r)}catch{throw new Error(`The type ${r} type do not includes any length. Needs [type; length].`)}jI(t.getFixedArraySize(r)===e.length,`The ABI type ${r} is expecting ${t.getFixedArraySize(r)} items. ${e.length} items provided.`),this.content=e,this.arrayType=r}static getFixedArraySize(t){const e=t.match(/(?<=; )\d+(?=\])/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid number after ';' character.`);return Number(e[0])}getFixedArraySize(){return t.getFixedArraySize(this.arrayType)}static getFixedArrayType=t=>{const e=t.match(/(?<=\[).+(?=;)/);if(null===e)throw new Error(`ABI type ${t} do not includes a valid type of data.`);return e[0]};getFixedArrayType(){return t.getFixedArrayType(this.arrayType)}static compile(t){return t.reduce(((t,e,r)=>(t[r]=e,t)),{})}compile(){return t.compile(this.content)}static isTypeFixedArray(t){return/^\[.*;\s.*\]$/.test(t)&&/(?<=\[).+(?=;)/.test(t)&&/(?<=; )\d+(?=\])/.test(t)}};function yC(t,e,r,i){const n=(t,e)=>{if(gC.isTypeFixedArray(e))return function(t,e){const r=gC.getFixedArrayType(e),i=gC.getFixedArraySize(e);if(Array.isArray(t)){if(i!==t.length)throw new Error(`ABI type ${e}: array provided do not includes ${i} items. ${t.length} items provided.`);return t.map((t=>n(t,r)))}if(i!==Object.keys(t).length)throw new Error(`ABI type ${e}: object provided do not includes ${i} properties. ${Object.keys(t).length} items provided.`);return n(t,r)}(t,e);if(CT(e))return function(t,e){const r=WT(e);if(TI(t))return t;return t.map((t=>n(t,r)))}(t,e);if(PT(e,i)){const r=i[e];return a(t,r)}if(zT(e))return function(t,e){const r=pC(e).reduce(((e,r,i)=>{const o=Object.keys(t),a=r=>Object.defineProperty(e,i.toString(),{enumerable:!0,value:r??t[o[i]]}),s=r?.type?r.type:r;return a(n(t[o[i]],s)),e}),{});return r}(t,e);if(VT(e))return t;if(QT(e))return t;if(GT(e))return t;if(ZT(e))return t;if(KT(e))return t;if(AT.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!("low"in r)||!("high"in r))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint256 object without the 'low' and 'high' keys.`)}(e);return{low:r.low,high:r.high}}if(NT.isAbiType(e)){const r=t;if("object"!=typeof r)return r;if(!["limb0","limb1","limb2","limb3"].every((t=>t in r)))throw function(t){return Error(`Your object includes the property : ${t}, containing an Uint512 object without the 'limb0' to 'limb3' keys.`)}(e);return{limb0:r.limb0,limb1:r.limb1,limb2:r.limb2,limb3:r.limb3}}if(RT(e,r)){const i=r[e].members;return o(t,i)}return t},o=(t,e)=>e.reduce(((e,r)=>{if("undefined"===t[r.name]&&(JT(r.type)||!IT(r.name)))throw Error(`Your object needs a property with key : ${r.name} .`);var i;return i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i??t[r.name]}),e}),{});const a=(t,e)=>{if(DT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(",")),o=e.name.substring(e.name.indexOf(",")+1,e.name.lastIndexOf(">"));return r.isOk()?new hC(sC.Ok,n(t.unwrap(),i)):new hC(sC.Err,n(t.unwrap(),o))}if(BT(e.name)){const r=t,i=e.name.substring(e.name.indexOf("<")+1,e.name.lastIndexOf(">"));return r.isSome()?new aC(oC.Some,n(r.unwrap(),i)):new aC(oC.None,{})}const r=t,i=Object.entries(r.variant).map((t=>{if(xI(t[1]))return t;const i=e.type.substring(e.type.lastIndexOf("<")+1,e.type.lastIndexOf(">"));return"()"===i?t:[t[0],n(r.unwrap(),i)]}));return new nC(Object.fromEntries(i))};return e.reduce(((e,r)=>{return IT(r.name)&&!JT(r.type)||(i=n(t[r.name],r.type),Object.defineProperty(e,r.name,{enumerable:!0,value:i})),e;var i}),{})}function wC(t,e){switch(!0){case AT.isAbiType(t):return new AT(e).toApiRequest();case NT.isAbiType(t):return new NT(e).toApiRequest();case HT(t):return dT(e.toString());case KT(t):{const t=vN(RI(e)).padStart(128,"0"),r=tC(bN(t.slice(-64))),i=tC(bN(t.slice(0,-64)));return[iC(i.low),iC(i.high),iC(r.low),iC(r.high)]}default:return iC(e)}}function vC(t,e,r,i){if(void 0===t)throw Error(`Missing parameter for type ${e}`);if(gC.isTypeFixedArray(e)){const n=gC.getFixedArrayType(e);let o=[];if(Array.isArray(t)){o=new gC(t,e).content}else{if("object"!=typeof t)throw new Error(`ABI type ${e}: not an Array representing a cairo.fixedArray() provided.`);o=Object.values(t),jI(o.length===gC.getFixedArraySize(e),`ABI type ${e}: object provided do not includes ${gC.getFixedArraySize(e)} items. ${o.length} items provided.`)}return o.reduce(((t,e)=>t.concat(vC(e,n,r,i))),[])}if(Array.isArray(t)){const n=[];n.push(iC(t.length));const o=WT(e);return t.reduce(((t,e)=>t.concat(vC(e,o,r,i))),n)}if(r[e]&&r[e].members.length){if(AT.isAbiType(e))return new AT(t).toApiRequest();if(NT.isAbiType(e))return new NT(t).toApiRequest();if(VT(e))return wC(e,t);if(GT(e))return function(t){const e=pT(t);return[e.data.length.toString(),...e.data.map((t=>t.toString())),e.pending_word.toString(),e.pending_word_len.toString()]}(t);const{members:n}=r[e],o=t;return n.reduce(((t,e)=>t.concat(vC(o[e.name],e.type,r,i))),[])}if(zT(e)){const n=function(t,e){const r=pC(e),i=Object.values(t);if(i.length!==r.length)throw Error(`ParseTuple: provided and expected abi tuple size do not match.\n provided: ${i}\n expected: ${r}`);return r.map(((t,e)=>({element:i[e],type:t.type??t})))}(t,e);return n.reduce(((t,e)=>{const n=vC(e.element,e.type,r,i);return t.concat(n)}),[])}if(AT.isAbiType(e))return new AT(t).toApiRequest();if(NT.isAbiType(e))return new NT(t).toApiRequest();if(PT(e,i)){const{variants:n}=i[e];if(BT(e)){const e=t;if(e.isSome()){const t=n.find((t=>"Some"===t.name));if(xI(t))throw Error("Error in abi : Option has no 'Some' variant.");const o=t.type;if("()"===o)return oC.Some.toString();const a=vC(e.unwrap(),o,r,i);return Array.isArray(a)?[oC.Some.toString(),...a]:[oC.Some.toString(),a]}return oC.None.toString()}if(DT(e)){const e=t;if(e.isOk()){const t=n.find((t=>"Ok"===t.name));if(xI(t))throw Error("Error in abi : Result has no 'Ok' variant.");const o=t.type;if("()"===o)return sC.Ok.toString();const a=vC(e.unwrap(),o,r,i);return Array.isArray(a)?[sC.Ok.toString(),...a]:[sC.Ok.toString(),a]}const o=n.find((t=>"Err"===t.name));if(xI(o))throw Error("Error in abi : Result has no 'Err' variant.");const a=o.type;if("()"===a)return sC.Err.toString();const s=vC(e.unwrap(),a,r,i);return Array.isArray(s)?[sC.Err.toString(),...s]:[sC.Err.toString(),s]}const o=t,a=o.activeVariant(),s=n.find((t=>t.name===a));if(xI(s))throw Error(`Not find in abi : Enum has no '${a}' variant.`);const h=s.type,u=n.findIndex((t=>t.name===a));if("()"===h)return u.toString();const l=vC(o.unwrap(),h,r,i);return Array.isArray(l)?[u.toString(),...l]:[u.toString(),l]}if(QT(e))return wC(WT(e),t);if("object"==typeof t)throw Error(`Parameter ${t} do not align with abi parameter ${e}`);return wC(e,t)}function bC(t,e){let r;switch(!0){case UT(t):return r=e.next().value,Boolean(BigInt(r));case AT.isAbiType(t):const i=e.next().value,n=e.next().value;return new AT(i,n).toBigInt();case NT.isAbiType(t):const o=e.next().value,a=e.next().value,s=e.next().value,h=e.next().value;return new NT(o,a,s,h).toBigInt();case VT(t):return r=e.next().value,BigInt(r);case HT(t):return r=e.next().value,fT(r);case KT(t):const u=vN(e.next().value).padStart(32,"0"),l=vN(e.next().value).padStart(32,"0"),c=vN(e.next().value).padStart(32,"0"),d=vN(e.next().value).padStart(32,"0");return BigInt(bN(l+u+d+c));default:return r=e.next().value,BigInt(r)}}function kC(t,e,r,i){if("()"===e.type)return{};if(AT.isAbiType(e.type)){const e=t.next().value,r=t.next().value;return new AT(e,r).toBigInt()}if(NT.isAbiType(e.type)){const e=t.next().value,r=t.next().value,i=t.next().value,n=t.next().value;return new NT(e,r,i,n).toBigInt()}if(GT(e.type)){const e=[],r=BigInt(t.next().value);for(;e.length<r;)e.push(RI(t.next().value));return mT({data:e,pending_word:RI(t.next().value),pending_word_len:BigInt(t.next().value)})}if(gC.isTypeFixedArray(e.type)){const n=[],o={name:"",type:gC.getFixedArrayType(e.type)},a=gC.getFixedArraySize(e.type);for(;n.length<a;)n.push(kC(t,o,r,i));return n}if(CT(e.type)){const n=[],o={name:"",type:WT(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(kC(t,o,r,i));return n}if(QT(e.type)){const n={name:"",type:WT(e.type)};return kC(t,n,r,i)}if(r&&e.type in r&&r[e.type])return VT(e.type)?bC(e.type,t):r[e.type].members.reduce(((e,n)=>(e[n.name]=kC(t,n,r,i),e)),{});if(i&&e.type in i&&i[e.type]){const n=Number(t.next().value),o=i[e.type].variants.reduce(((e,o,a)=>a===n?(e[o.name]=kC(t,{name:"",type:o.type},r,i),e):(e[o.name]=void 0,e)),{});if(e.type.startsWith("core::option::Option")){const t=n===oC.Some?o.Some:void 0;return new aC(n,t)}if(e.type.startsWith("core::result::Result")){let t;return t=n===sC.Ok?o.Ok:o.Err,new hC(n,t)}return new nC(o)}if(zT(e.type)){return pC(e.type).reduce(((e,n,o)=>{const a=n?.name?n.name:o,s={name:a,type:n?.type?n.type:n};return e[a]=kC(t,s,r,i),e}),{})}if(CT(e.type)){const n=[],o={name:"",type:WT(e.type)},a=BigInt(t.next().value);for(;n.length<a;)n.push(kC(t,o,r,i));return n}return bC(e.type,t)}function MC(t,e,r,i,n){const{name:o,type:a}=e;let s;switch(!0){case IT(o):return s=t.next().value,BigInt(s);case r&&a in r||zT(a):case i&&PT(a,i):case gC.isTypeFixedArray(a):return kC(t,e,r,i);case CT(a):if(JT(a))return kC(t,e,r,i);const h=[];if(n&&n[`${o}_len`]){const a=n[`${o}_len`];for(;h.length<a;)h.push(kC(t,{name:o,type:e.type.replace("*","")},r,i))}return h;case QT(a):return kC(t,e,r,i);default:return bC(a,t)}}var _C=(t,e)=>{if(jI(TI(t)||SI(t)||II(t),`Validate: arg ${e.name} should be a felt typed as (String, Number or BigInt)`),TI(t)&&!zI(t))return;const r=BigInt(t.toString(10));jI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`)},EC=(t,e)=>{let r;switch(SI(t)&&jI(t<=Number.MAX_SAFE_INTEGER,"Validation: Parameter is too large to be typed as Number use (BigInt or String)"),jI(TI(t)||SI(t)||II(t)||CI(t)&&"low"in t&&"high"in t||CI(t)&&["limb0","limb1","limb2","limb3"].every((e=>e in t)),`Validate: arg ${e.name} of cairo type ${e.type} should be type (String, Number or BigInt), but is ${typeof t} ${t}.`),e.type){case wI.u256:r=new AT(t).toBigInt();break;case wI.u512:r=new NT(t).toBigInt();break;default:r=OI(t)}switch(e.type){case wI.u8:jI(r>=0n&&r<=255n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0 - 255]`);break;case wI.u16:jI(r>=0n&&r<=65535n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 65535]`);break;case wI.u32:jI(r>=0n&&r<=4294967295n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 4294967295]`);break;case wI.u64:jI(r>=0n&&r<=2n**64n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^64-1]`);break;case wI.u128:jI(r>=0n&&r<=2n**128n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^128-1]`);break;case wI.u256:jI(r>=0n&&r<=2n**256n-1n,`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^256-1`);break;case wI.u512:jI(NT.is(r),`Validate: arg ${e.name} is ${e.type} should be in range 0 - 2^512-1`);break;case vI.ClassHash:case vI.ContractAddress:jI(r>=0n&&r<=2n**252n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^252-1]`);break;case vI.Secp256k1Point:jI(r>=0n&&r<=2n**512n-1n,`Validate: arg ${e.name} must be ${e.type} : a 512 bits number.`);break;case vI.U96:jI(r>=0n&&r<=2n**96n-1n,`Validate: arg ${e.name} must be ${e.type} : a 96 bits number.`)}},AC=(t,e)=>{jI(NI(t),`Validate: arg ${e.name} of cairo type ${e.type} should be type (Boolean)`)},jC=(t,e,r)=>{if(e.type!==wI.u256&&e.type!==wI.u512)if(VT(e.type)){jI(!CI(t),`EthAddress type is waiting a BigNumberish. Got "${t}"`);const r=BigInt(t.toString(10));jI(r>=0n&&r<=2n**160n-1n,`Validate: arg ${e.name} cairo typed ${e.type} should be in range [0, 2^160-1]`)}else jI(CI(t),`Validate: arg ${e.name} is cairo type struct (${e.type}), and should be defined as a js object (not array)`),r[e.type].members.forEach((({name:r})=>{jI(Object.keys(t).includes(r),`Validate: arg ${e.name} should have a property ${r}`)}));else EC(t,e)},xC=(t,e)=>{jI(CI(t),`Validate: arg ${e.name} is cairo type Enum (${e.type}), and should be defined as a js object (not array)`);const r=Object.getOwnPropertyNames(Object.getPrototypeOf(t)),i=[...Object.getOwnPropertyNames(t),...r];if(!(BT(e.type)&&i.includes("isSome")&&i.includes("isNone")||DT(e.type)&&i.includes("isOk")&&i.includes("isErr")||i.includes("variant")&&i.includes("activeVariant")))throw new Error(`Validate Enum: argument ${e.name}, type ${e.type}, value received "${t}", is not an Enum.`)},SC=(t,e)=>{jI(CI(t),`Validate: arg ${e.name} should be a tuple (defined as object)`)},NC=(t,e,r,i)=>{const n=CT(e.type),o=n?WT(e.type):gC.getFixedArrayType(e.type);if(n&&TT(o)&&lT(t))return;let a=[];if(n)jI(Array.isArray(t),`Validate: arg ${e.name} should be an Array`),a=t;else switch(!0){case Array.isArray(t):a=t;break;case"object"==typeof t:a=Object.values(t);break;default:throw new Error(`Validate: arg ${e.name} should be an Array or an object.`)}switch(!0){case TT(o):a.forEach((t=>_C(t,e)));break;case zT(o):a.forEach((t=>SC(t,{name:e.name,type:o})));break;case CT(o):a.forEach((t=>NC(t,{name:"",type:o},r,i)));break;case RT(o,r):a.forEach((t=>jC(t,{name:e.name,type:o},r)));break;case PT(o,i):a.forEach((t=>xC(t,{name:e.name,type:o})));break;case $T(o)||FT(o):a.forEach((t=>EC(t,{name:"",type:o})));break;case UT(o):a.forEach((t=>AC(t,e)));break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value ${a}`)}};function IC(t,e,r,i){t.inputs.reduce(((t,n)=>{const o=e[t];switch(!0){case IT(n.name):return t;case TT(n.type):_C(o,n);break;case HT(n.type):((t,e)=>{jI(TI(t),`Validate: arg ${e.name} should be a string.`),jI(t.length<32,`Validate: arg ${e.name} cairo typed ${e.type} should be a string of less than 32 characters.`)})(o,n);break;case $T(n.type)||FT(n.type):EC(o,n);break;case UT(n.type):AC(o,n);break;case GT(n.type):((t,e)=>{jI(TI(t),`Validate: arg ${e.name} should be a string.`)})(o,n);break;case CT(n.type)||gC.isTypeFixedArray(n.type):NC(o,n,r,i);break;case RT(n.type,r):jC(o,n,r);break;case PT(n.type,i):xC(o,n);break;case zT(n.type):SC(o,n);break;case QT(n.type):((t,e)=>{const r=WT(e.type);switch(jI($T(r)&&r!==NT.abiSelector||TT(r),`Validate: ${e.name} type is not authorized for NonZero type.`),!0){case TT(r):_C(t,e),jI(BigInt(t.toString(10))>0,"Validate: value 0 is not authorized in NonZero felt252 type.");break;case $T(r):EC(t,{name:"",type:r}),r===wI.u256?jI(new AT(t).toBigInt()>0,"Validate: value 0 is not authorized in NonZero uint256 type."):jI(OI(t)>0,"Validate: value 0 is not authorized in NonZero uint type.");break;default:throw new Error(`Validate Unhandled: argument ${e.name}, type ${e.type}, value "${t}"`)}})(o,n);break;default:throw new Error(`Validate Unhandled: argument ${n.name}, type ${n.type}, value ${o}`)}return t+1}),0)}var TC=class t{abi;parser;structs;enums;constructor(e){this.structs=t.getAbiStruct(e),this.enums=t.getAbiEnum(e),this.parser=dC(e),this.abi=this.parser.getLegacyFormat()}validate(t,e,r=[]){if(t!==yI.DEPLOY){jI(this.abi.filter((e=>{if("function"!==e.type)return!1;const r="view"===e.stateMutability||"view"===e.state_mutability;return t===yI.INVOKE?!r:r})).map((t=>t.name)).includes(e),(t===yI.INVOKE?"invocable":"viewable")+" method not found in abi")}const i=this.abi.find((r=>t===yI.DEPLOY?r.name===e&&"constructor"===r.type:r.name===e&&"function"===r.type));if(fC(e,r,i))return;const n=this.parser.methodInputsLength(i);if(r.length!==n)throw Error(`Invalid number of arguments, expected ${n} arguments, but got ${r.length}`);IC(i,r,this.structs,this.enums)}compile(t,e){const r=this.abi.find((e=>e.name===t));if(fC(t,e,r))return[];let i;if(Array.isArray(e))i=e;else{const t=yC(e,r.inputs,this.structs,this.enums);i=Object.values(t),IC(r,i,this.structs,this.enums)}const n=i[Symbol.iterator](),o=r.inputs.reduce(((t,e)=>IT(e.name)&&!JT(e.type)?t:t.concat(function(t,e,r,i){const{name:n,type:o}=e;let{value:a}=t.next();switch(!0){case gC.isTypeFixedArray(o):if(!Array.isArray(a)&&"object"!=typeof a)throw Error(`ABI expected parameter ${n} to be an array or an object, got ${a}`);return vC(a,e.type,r,i);case CT(o):if(!Array.isArray(a)&&!hT(a))throw Error(`ABI expected parameter ${n} to be array or long string, got ${a}`);return TI(a)&&(a=cT(a)),vC(a,e.type,r,i);case QT(o):return wC(WT(o),a);case VT(o):return wC(o,a);case RT(o,r)||zT(o)||AT.isAbiType(o):case PT(o,i):return vC(a,o,r,i);default:return wC(o,a)}}(n,e,this.structs,this.enums))),[]);return Object.defineProperty(o,"__compiled__",{enumerable:!1,writable:!1,value:!0}),o}static compile(t){const e=t=>{const e=(t,r=".")=>{const i=Array.isArray(t)?[t.length.toString(),...t]:t;return Object.entries(i).flatMap((([t,n])=>{let o=n;"entrypoint"===t?o=eT(o):lT(o)&&(o=pT(o));const a=Array.isArray(i)&&"0"===t?"$$len":t;if(II(o))return[[`${r}${a}`,iC(o)]];if(Object(o)===o){const t=Object.getOwnPropertyNames(Object.getPrototypeOf(o)),i=[...Object.getOwnPropertyNames(o),...t];if(i.includes("isSome")&&i.includes("isNone")){const t=o,i=t.isSome()?oC.Some:oC.None;return t.isSome()?e({0:i,1:t.unwrap()},`${r}${a}.`):[[`${r}${a}`,iC(i)]]}if(i.includes("isOk")&&i.includes("isErr")){const t=o,i=t.isOk()?sC.Ok:sC.Err;return e({0:i,1:t.unwrap()},`${r}${a}.`)}if(i.includes("variant")&&i.includes("activeVariant")){const t=o,i=t.activeVariant(),n=Object.keys(t.variant).findIndex((t=>t===i));return"object"==typeof t.unwrap()&&0===Object.keys(t.unwrap()).length?[[`${r}${a}`,iC(n)]]:e({0:n,1:t.unwrap()},`${r}${a}.`)}return e(o,`${r}${a}.`)}return[[`${r}${a}`,iC(o)]]}))};return Object.fromEntries(e(t))};let r;if(Array.isArray(t)){const i=e({...t});r=Object.values(i)}else{const i=e(t);r=Object.values(i)}return Object.defineProperty(r,"__compiled__",{enumerable:!1,writable:!1,value:!0}),r}parse(t,e){const{outputs:r}=this.abi.find((e=>e.name===t)),i=e.flat()[Symbol.iterator](),n=r.flat().reduce(((t,e,r)=>{const n=e.name??r;return t[n]=MC(i,e,this.structs,this.enums,t),t[n]&&t[`${n}_len`]&&delete t[`${n}_len`],t}),{});return 1===Object.keys(n).length&&0 in n?n[0]:n}format(t,e,r){return cC(this.parse(t,e),r)}static getAbiStruct(t){return t.filter((t=>"struct"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{})}static getAbiEnum(t){const e=t.filter((t=>"enum"===t.type)).reduce(((t,e)=>({...t,[e.name]:e})),{});return delete e["core::bool"],e}static toCalldata(e=[]){return t.compile(e)}static toHex(e=[]){return t.compile(e).map((t=>RI(t)))}decodeParameters(t,e){const r=Array.isArray(t)?t:[t],i=e.flat()[Symbol.iterator](),n=r.map((t=>MC(i,{name:"",type:t},this.structs,this.enums)));return 1===n.length?n[0]:n}};KS({},{calculateContractAddressFromHash:()=>az,calculateDeclareTransactionHash:()=>XC,calculateDeployAccountTransactionHash:()=>tz,calculateInvokeTransactionHash:()=>QC,calculateL2MessageTxHash:()=>BC,computeCompiledClassHash:()=>fz,computeContractClassHash:()=>gz,computeHashOnElements:()=>iz,computeHintedClassHash:()=>uz,computeLegacyContractClassHash:()=>lz,computePedersenHash:()=>ez,computePedersenHashOnElements:()=>nz,computePoseidonHash:()=>rz,computePoseidonHashOnElements:()=>oz,computeSierraContractClassHash:()=>pz,formatSpaces:()=>hz,getL2MessageHash:()=>nT,getSelector:()=>rT,getSelectorFromName:()=>eT,hashByteCodeSegments:()=>dz,keccakBn:()=>XI,poseidon:()=>$v,solidityUint256PackedKeccak256:()=>iT,starknetKeccak:()=>tT});KS({},{calculateDeclareTransactionHash:()=>OC,calculateDeployAccountTransactionHash:()=>RC,calculateL2MessageTxHash:()=>BC,calculateTransactionHash:()=>PC,calculateTransactionHashCommon:()=>zC,computeHashOnElements:()=>CC});function CC(t){return[...t,t.length].reduce(((t,e)=>$b(OI(t),OI(e))),0).toString()}function zC(t,e,r,i,n,o,a,s=[]){const h=CC(n);return CC([t,e,r,i,h,o,a,...s])}function OC(t,e,r,i,n,o,a){return zC("0x6465636c617265",r,e,0,[t],i,n,[o,...a?[a]:[]])}function RC(t,e,r,i,n,o,a,s){return zC("0x6465706c6f795f6163636f756e74",n,t,0,[e,i,...r],o,a,[s])}function PC(t,e,r,i,n,o){return zC("0x696e766f6b65",e,t,0,r,i,n,[o])}function BC(t,e,r,i,n,o){const a=[t,...i];return zC("0x6c315f68616e646c6572",0,e,rT(r),a,0,n,[o])}KS({},{starkCurve:()=>Wb,weierstrass:()=>hb});KS({},{calculateDeclareTransactionHash:()=>WC,calculateDeployAccountTransactionHash:()=>JC,calculateInvokeTransactionHash:()=>YC,calculateTransactionHashCommon:()=>KC,encodeResourceBoundsL1:()=>HC,encodeResourceBoundsL2:()=>GC,hashDAMode:()=>VC,hashFeeField:()=>ZC});var DC=t=>t.map((t=>BigInt(t))),$C=32n,LC=128n,FC=64n+LC,UC=BigInt(dT("L1_GAS")),qC=BigInt(dT("L2_GAS"));function VC(t,e){return(BigInt(t)<<$C)+BigInt(e)}function HC(t){return(UC<<FC)+(BigInt(t.l1_gas.max_amount)<<LC)+BigInt(t.l1_gas.max_price_per_unit)}function GC(t){return(qC<<FC)+(BigInt(t.l2_gas.max_amount)<<LC)+BigInt(t.l2_gas.max_price_per_unit)}function ZC(t,e){const r=HC(e),i=GC(e);return Jb([BigInt(t),r,i])}function KC(t,e,r,i,n,o,a,s,h,u,l=[]){const c=ZC(o,u),d=VC(s,h),f=DC([t,e,r,c,Jb(DC(a)),i,n,d,...DC(l)]);return RI(Jb(f))}function JC(t,e,r,i,n,o,a,s,h,u,l,c){return KC("0x6465706c6f795f6163636f756e74",n,t,o,a,l,c,s,h,u,[Jb(DC(r)),e,i])}function WC(t,e,r,i,n,o,a,s,h,u,l,c){return KC("0x6465636c617265",i,r,n,o,l,DC(c),s,h,u,[Jb(DC(a)),t,e])}function YC(t,e,r,i,n,o,a,s,h,u,l){return KC("0x696e766f6b65",e,t,i,n,u,l,a,s,h,[Jb(DC(o)),Jb(DC(r))])}function QC(t){return function(t){return[WS.ETransactionVersion.V3,WS.ETransactionVersion.F3].includes(t.version)}(t)?YC(t.senderAddress,t.version,t.compiledCalldata,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):PC(t.senderAddress,t.version,t.compiledCalldata,t.maxFee,t.chainId,t.nonce)}function XC(t){return function(t){return[WS.ETransactionVersion.V3,WS.ETransactionVersion.F3].includes(t.version)}(t)?WC(t.classHash,t.compiledClassHash,t.senderAddress,t.version,t.chainId,t.nonce,t.accountDeploymentData,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):OC(t.classHash,t.senderAddress,t.version,t.maxFee,t.chainId,t.nonce,t.compiledClassHash)}function tz(t){return function(t){return[WS.ETransactionVersion.V3,WS.ETransactionVersion.F3].includes(t.version)}(t)?JC(t.contractAddress,t.classHash,t.compiledConstructorCalldata,t.salt,t.version,t.chainId,t.nonce,t.nonceDataAvailabilityMode,t.feeDataAvailabilityMode,t.resourceBounds,t.tip,t.paymasterData):RC(t.contractAddress,t.classHash,t.constructorCalldata,t.salt,t.version,t.maxFee,t.chainId,t.nonce)}function ez(t,e){return $b(BigInt(t),BigInt(e))}function rz(t,e){return RI(Kb(BigInt(t),BigInt(e)))}function iz(t){return[...t,t.length].reduce(((t,e)=>$b(BigInt(t),BigInt(e))),0).toString()}var nz=iz;function oz(t){return RI(Jb(t.map((t=>BigInt(t)))))}function az(t,e,r,i){const n=iz(TC.compile(r)),o=iz([iC("0x535441524b4e45545f434f4e54524143545f41444452455353"),i,t,e,n]);return RI(BigInt(o)%ON)}function sz(t,e){return"attributes"===t||"accessible_scopes"===t?Array.isArray(e)&&0===e.length?void 0:e:"debug_info"===t?null:null===e?void 0:e}function hz(t){let e=!1;const r=[];for(const i of t)'"'===i&&!1==(r.length>0&&"\\"===r.slice(-1)[0])&&(e=!e),e?r.push(i):r.push(":"===i?": ":","===i?", ":i);return r.join("")}function uz(t){const{abi:e,program:r}=t,i=hz(nI({abi:e,program:r},sz));return bN(Fb(mN(i)).toString(16))}function lz(t){const e=TI(t)?rI(t):t,r=RI(TN),i=iz(e.entry_points_by_type.EXTERNAL.flatMap((t=>[t.selector,t.offset]))),n=iz(e.entry_points_by_type.L1_HANDLER.flatMap((t=>[t.selector,t.offset]))),o=iz(e.entry_points_by_type.CONSTRUCTOR.flatMap((t=>[t.selector,t.offset]))),a=iz(e.program.builtins.map((t=>dT(t)))),s=uz(e),h=iz(e.program.data);return iz([r,i,n,o,a,s,h])}function cz(t){const e=t.flatMap((t=>{return[BigInt(t.selector),BigInt(t.offset),(e=t.builtins,Jb(e.flatMap((t=>BigInt(dT(t))))))];var e}));return Jb(e)}function dz(t){const e=t.bytecode.map((t=>BigInt(t))),r=t.bytecode_segment_lengths??[];let i=0;const n=r.flatMap((t=>{const r=e.slice(i,i+=t);return[BigInt(t),Jb(r)]}));return 1n+Jb(n)}function fz(t){const e=BigInt(dT("COMPILED_CLASS_V1")),r=cz(t.entry_points_by_type.EXTERNAL),i=cz(t.entry_points_by_type.L1_HANDLER),n=cz(t.entry_points_by_type.CONSTRUCTOR),o=t.bytecode_segment_lengths?dz(t):Jb(t.bytecode.map((t=>BigInt(t))));return RI(Jb([e,r,i,n,o]))}function mz(t){return Jb(t.flatMap((t=>[BigInt(t.selector),BigInt(t.function_idx)])))}function pz(t){const e=BigInt(dT("CONTRACT_CLASS_V0.1.0")),r=mz(t.entry_points_by_type.EXTERNAL),i=mz(t.entry_points_by_type.L1_HANDLER),n=mz(t.entry_points_by_type.CONSTRUCTOR),o=function(t){const e=hz(nI(t.abi,null));return BigInt(bN(Fb(mN(e)).toString(16)))}(t),a=Jb(t.sierra_program.map((t=>BigInt(t))));return RI(Jb([e,r,i,n,o,a]))}function gz(t){const e=TI(t)?rI(t):t;return"sierra_program"in e?pz(e):lz(e)}function yz(t){const e=TI(t)?t:nI(t);return yN(DE(e))}function wz(t){if(Array.isArray(t))return t;const e=fN($E(gN(t)));return rI(e)}function vz(){return Tb(xb.randomPrivateKey())}function bz(t){return bN(t).toLowerCase()}function kz(t){if(!t)throw Error("formatSignature: provided signature is undefined");if(Array.isArray(t))return t.map((t=>RI(t)));try{const{r:e,s:r}=t;return[RI(e),RI(r)]}catch(t){throw new Error("Signature need to be weierstrass.SignatureType or an array for custom")}}function Mz(t){return UI(kz(t))}function _z(t){return qI(kz(t))}function Ez(t,e=50){return WI(t,e)}function Az(t,e=50,r=50){if(II(t))return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}};if(xI(t.gas_consumed)||xI(t.gas_price))throw Error("estimateFeeToBounds: estimate is undefined");return{l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"},l1_gas:{max_amount:void 0!==t.data_gas_consumed&&void 0!==t.data_gas_price?RI(WI(BigInt(t.overall_fee)/BigInt(t.gas_price),e)):RI(WI(t.gas_consumed,e)),max_price_per_unit:RI(WI(t.gas_price,r))}}}function jz(t){if(t===WS.EDataAvailabilityMode.L1)return WS.EDAMode.L1;if(t===WS.EDataAvailabilityMode.L2)return WS.EDAMode.L2;throw Error("EDAM conversion")}function xz(t,e){const r=e?RI(e):void 0,i=RI(t);if(e&&!Object.values(WS.ETransactionVersion).includes(r))throw Error(`providedVersion ${e} is not ETransactionVersion`);if(!Object.values(WS.ETransactionVersion).includes(i))throw Error(`defaultVersion ${t} is not ETransactionVersion`);return e?r:i}function Sz(t){if(!t)return;const e=RI(t);if(e===WS.ETransactionVersion.V0)return WS.ETransactionVersion.F0;if(e===WS.ETransactionVersion.V1)return WS.ETransactionVersion.F1;if(e===WS.ETransactionVersion.V2)return WS.ETransactionVersion.F2;if(e===WS.ETransactionVersion.V3)return WS.ETransactionVersion.F3;throw Error(`toFeeVersion: ${e} is not supported`)}function Nz(t){return{tip:t.tip||0,paymasterData:t.paymasterData||[],accountDeploymentData:t.accountDeploymentData||[],nonceDataAvailabilityMode:t.nonceDataAvailabilityMode||WS.EDataAvailabilityMode.L1,feeDataAvailabilityMode:t.feeDataAvailabilityMode||WS.EDataAvailabilityMode.L1,resourceBounds:t.resourceBounds??Az(SN)}}function Iz(t){return t===WS.ETransactionVersion.F2?WS.ETransactionVersion.F1:t===WS.ETransactionVersion.V2?WS.ETransactionVersion.V1:t}function Tz(t){return bN(wN(bb(RI(t),!1)))}function Cz(t){return"sierra_program"in(TI(t)?rI(t):t)}KS({},{compressProgram:()=>yz,decompressProgram:()=>wz,estimateFeeToBounds:()=>Az,estimatedFeeToMaxFee:()=>Ez,formatSignature:()=>kz,getFullPublicKey:()=>Tz,intDAM:()=>jz,makeAddress:()=>bz,randomAddress:()=>vz,reduceV2:()=>Iz,signatureToDecimalArray:()=>Mz,signatureToHexArray:()=>_z,toFeeVersion:()=>Sz,toTransactionVersion:()=>xz,v3Details:()=>Nz});function zz(){return EN(wN(GE.utils.randomPrivateKey()))}function Oz(t){FI(t,SN,2n**160n-1n,"Ethereum Address ");const e=bN(vN(RI(t)).padStart(40,"0"));return jI(Boolean(e.match(/^(0x)?[0-9a-f]{40}$/)),"Invalid Ethereum Address Format"),e}KS({},{ethRandomPrivateKey:()=>zz,validateAndParseEthAddress:()=>Oz});var Rz=dN&&window.fetch.bind(window)||!xI(t)&&aS(t.fetch)||TS;KS({},{Block:()=>Vz,createSierraContractClass:()=>Lz,getDefaultNodeUrl:()=>Uz,isPendingBlock:()=>Zz,isPendingStateUpdate:()=>Jz,isPendingTransaction:()=>Kz,isV3Tx:()=>Hz,isVersion:()=>Gz,parseContract:()=>Fz,validBlockTags:()=>qz,wait:()=>$z});var Pz=class t{static instance;config;constructor(){this.initialize()}initialize(){this.config={...QN}}static getInstance(){return t.instance||(t.instance=new t),t.instance}get(t,e){return this.config[t]??e}set(t,e){this.config[t]=e}update(t){this.config={...this.config,...t}}getAll(){return{...this.config}}reset(){this.initialize()}delete(t){delete this.config[t]}hasKey(t){return t in this.config}}.getInstance(),Bz={DEBUG:5,INFO:4,WARN:3,ERROR:2,FATAL:1,OFF:0},Dz=class t{static instance;config;constructor(){this.config=Pz}static getInstance(){return t.instance||(t.instance=new t),t.instance}getTimestamp(){return(new Date).toISOString()}shouldLog(t){const e=this.config.get("logLevel","INFO");return t<=Bz[e]}formatMessage(t){const{level:e,message:r,timestamp:i,data:n}=t;let o=`[${i}] ${e}: ${r}`;if(n)try{o+=`\n${JSON.stringify(n,null,2)}`}catch(t){o+=`\n[JSON.stringify Error/Circular]: ${t}`}return o}log(t,e,r){if(!this.shouldLog(Bz[t]))return;const i={level:t,message:e,timestamp:this.getTimestamp(),data:r},n=this.formatMessage(i);switch(t){case"DEBUG":console.debug(n);break;case"INFO":console.info(n);break;case"WARN":console.warn(n);break;case"ERROR":case"FATAL":console.error(n);break;case"OFF":break;default:console.log(n)}}debug(t,e){this.log("DEBUG",t,e)}info(t,e){this.log("INFO",t,e)}warn(t,e){this.log("WARN",t,e)}error(t,e){this.log("ERROR",t,e)}fatal(t,e){this.log("FATAL",t,e)}setLogLevel(t){this.config.set("logLevel",t)}getLogLevel(){return this.config.get("logLevel","INFO")}getEnabledLogLevels(){return Object.keys(Bz).filter((t=>this.shouldLog(Bz[t])&&"OFF"!==t))}}.getInstance();function $z(t){return new Promise((e=>{setTimeout(e,t)}))}function Lz(t){const e={...t};return delete e.sierra_program_debug_info,e.abi=hz(nI(t.abi)),e.sierra_program=hz(nI(t.sierra_program)),e.sierra_program=yz(e.sierra_program),e}function Fz(t){const e=TI(t)?rI(t):t;return Cz(t)?Lz(e):{...e,..."program"in e&&{program:yz(e.program)}}}var Uz=(t,e=!1)=>{e||Dz.info("Using default public node url, please provide nodeUrl in provider options!");const r=GN[t??"SN_SEPOLIA"];return r[Math.floor(Math.random()*r.length)]},qz=Object.values(gI),Vz=class{hash=null;number=null;tag=null;setIdentifier(t){if(TI(t))if(sT(t))this.number=parseInt(t,10);else if(zI(t))this.hash=t;else{if(!qz.includes(t))throw TypeError(`Block identifier unmanaged: ${t}`);this.tag=t}else II(t)?this.hash=RI(t):SI(t)?this.number=t:this.tag=gI.PENDING;if(SI(this.number)&&this.number<0)throw TypeError(`Block number (${this.number}) can't be negative`)}constructor(t){this.setIdentifier(t)}get queryIdentifier(){return null!==this.number?`blockNumber=${this.number}`:null!==this.hash?`blockHash=${this.hash}`:`blockNumber=${this.tag}`}get identifier(){return null!==this.number?{block_number:this.number}:null!==this.hash?{block_hash:this.hash}:this.tag}set identifier(t){this.setIdentifier(t)}valueOf=()=>this.number;toString=()=>this.hash};function Hz(t){const e=t.version?RI(t.version):WS.ETransactionVersion.V3;return e===WS.ETransactionVersion.V3||e===WS.ETransactionVersion.F3}function Gz(t,e){const[r,i]=t.split("."),[n,o]=e.split(".");return r===n&&i===o}function Zz(t){return"PENDING"===t.status}function Kz(t){return!("block_hash"in t)}function Jz(t){return!("block_hash"in t)}KS({},{buildUDCCall:()=>rO,fromCallsToExecuteCalldata:()=>Yz,fromCallsToExecuteCalldataWithNonce:()=>Qz,fromCallsToExecuteCalldata_cairo1:()=>tO,getExecuteCalldata:()=>eO,getVersionsByType:()=>iO,transformCallsToMulticallArrays:()=>Wz,transformCallsToMulticallArrays_cairo1:()=>Xz});var Wz=t=>{const e=[],r=[];return t.forEach((t=>{const i=TC.compile(t.calldata||[]);e.push({to:OI(t.contractAddress).toString(10),selector:OI(eT(t.entrypoint)).toString(10),data_offset:r.length.toString(),data_len:i.length.toString()}),r.push(...i)})),{callArray:e,calldata:TC.compile({calldata:r})}},Yz=t=>{const{callArray:e,calldata:r}=Wz(t);return[...TC.compile({callArray:e}),...r]},Qz=(t,e)=>[...Yz(t),OI(e).toString()],Xz=t=>{const e=t.map((t=>({to:OI(t.contractAddress).toString(10),selector:OI(eT(t.entrypoint)).toString(10),calldata:TC.compile(t.calldata||[])})));return e},tO=t=>{const e=t.map((t=>({contractAddress:t.contractAddress,entrypoint:t.entrypoint,calldata:Array.isArray(t.calldata)&&"__compiled__"in t.calldata?t.calldata:TC.compile(t.calldata)})));return TC.compile({orderCalls:e})},eO=(t,e="0")=>"1"===e?tO(t):Yz(t);function rO(t,e){const r=[].concat(t).map((t=>{const{classHash:r,salt:i,unique:n=!0,constructorCalldata:o=[]}=t,a=TC.compile(o),s=i??vz();return{call:{contractAddress:VN.ADDRESS,entrypoint:VN.ENTRYPOINT,calldata:[r,s,KI(n),a.length,...a]},address:az(n?$b(e,s):s,r,a,n?VN.ADDRESS:0)}}));return{calls:r.map((t=>t.call)),addresses:r.map((t=>t.address))}}function iO(t){return"fee"===t?{v1:WS.ETransactionVersion.F1,v2:WS.ETransactionVersion.F2,v3:WS.ETransactionVersion.F3}:{v1:WS.ETransactionVersion.V1,v2:WS.ETransactionVersion.V2,v3:WS.ETransactionVersion.V3}}var nO={headers:{"Content-Type":"application/json"},blockIdentifier:gI.PENDING,retries:200},oO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(LN).includes(a)?this.nodeUrl=Uz(a,t?.default):this.nodeUrl=a||Uz(void 0,t?.default),this.baseFetch=e??Rz,this.blockIdentifier=i??nO.blockIdentifier,this.chainId=n,this.headers={...nO.headers,...o},this.retries=s??nO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new AI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:nI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new uI(r,t,e);if(i instanceof hI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new Vz(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=RI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new Vz(r).identifier,a=[];return i&&a.push(QS.ESimulationFlag.SKIP_VALIDATE),n&&a.push(QS.ESimulationFlag.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=RI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[QS.ETransactionStatus.REJECTED],h=e?.successStates??[QS.ETransactionExecutionStatus.SUCCEEDED,QS.ETransactionStatus.ACCEPTED_ON_L2,QS.ETransactionStatus.ACCEPTED_ON_L1];let u;for(;!n;){await $z(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await $z(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=RI(t),n=BI(e),o=new Vz(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new Vz(e).identifier;let n={};return Gz("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[QS.ESimulationFlag.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return Hz(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:QS.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:QS.ETransactionVersion.V3,signature:_z(t.signature),nonce:RI(e.nonce),resource_bounds:e.resourceBounds,tip:RI(e.tip),paymaster_data:e.paymasterData.map((t=>RI(t))),account_deployment_data:e.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),type:QS.ETransactionType.INVOKE,max_fee:RI(e.maxFee||0),version:QS.ETransactionVersion.V1,signature:_z(t.signature),nonce:RI(e.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V1,type:QS.ETransactionType.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Cz(t)||Hz(n))if(Cz(t)&&!Hz(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:QS.ETransactionType.DECLARE,contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:QS.ETransactionVersion.V2,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V2,type:QS.ETransactionType.DECLARE});else{if(!Cz(t)||!Hz(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:QS.ETransactionType.DECLARE,sender_address:r,compiled_class_hash:i||"",version:QS.ETransactionVersion.V3,signature:_z(e),nonce:RI(n.nonce),contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),account_deployment_data:n.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:QS.ETransactionType.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:QS.ETransactionVersion.V1,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V1,type:QS.ETransactionType.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return Hz(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:QS.ETransactionType.DEPLOY_ACCOUNT,version:QS.ETransactionVersion.V3,signature:_z(i),nonce:RI(n.nonce),contract_address_salt:RI(r||0),constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),contract_address_salt:RI(r||0),type:QS.ETransactionType.DEPLOY_ACCOUNT,max_fee:RI(n.maxFee||0),version:QS.ETransactionVersion.V1,signature:_z(i),nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:QS.ETransactionVersion.V1,type:QS.ETransactionType.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new Vz(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:eT(t.entrypoint),calldata:TC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Oz(r),to_address:RI(i),entry_point_selector:rT(n),payload:ZI(o)},s=new Vz(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=iO(e);let i;if(Hz(t)?i={signature:_z(t.signature),nonce:RI(t.nonce),resource_bounds:t.resourceBounds,tip:RI(t.tip),paymaster_data:t.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>RI(t)))}:(i={signature:_z(t.signature),nonce:RI(t.nonce),max_fee:RI(t.maxFee||0)},Dz.warn(XN.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===cI.INVOKE)return{type:QS.ETransactionType.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:RI(t.version||r.v3),...i};if(t.type===cI.DECLARE)return Cz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:wz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:RI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:RI(t.version||r.v1),...i};if(t.type===cI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:TC.toHex(t.constructorCalldata||[]),class_hash:RI(t.classHash),contract_address_salt:RI(t.addressSalt||0),version:RI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}};KS({},{RpcChannel:()=>sO});var aO={headers:{"Content-Type":"application/json"},blockIdentifier:gI.PENDING,retries:200},sO=class{nodeUrl;headers;requestId;blockIdentifier;retries;waitMode;chainId;specVersion;transactionRetryIntervalFallback;batchClient;baseFetch;constructor(t){const{baseFetch:e,batch:r,blockIdentifier:i,chainId:n,headers:o,nodeUrl:a,retries:s,specVersion:h,transactionRetryIntervalFallback:u,waitMode:l}=t||{};Object.values(LN).includes(a)?this.nodeUrl=Uz(a,t?.default):this.nodeUrl=a||Uz(void 0,t?.default),this.baseFetch=e??Rz,this.blockIdentifier=i??aO.blockIdentifier,this.chainId=n,this.headers={...aO.headers,...o},this.retries=s??aO.retries,this.specVersion=h,this.transactionRetryIntervalFallback=u,this.waitMode=l??!1,this.requestId=0,"number"==typeof r&&(this.batchClient=new AI({nodeUrl:this.nodeUrl,headers:this.headers,interval:r,baseFetch:this.baseFetch}))}get transactionRetryIntervalDefault(){return this.transactionRetryIntervalFallback??5e3}setChainId(t){this.chainId=t}fetch(t,e,r=0){const i={id:r,jsonrpc:"2.0",method:t,...e&&{params:e}};return this.baseFetch(this.nodeUrl,{method:"POST",body:nI(i),headers:this.headers})}errorHandler(t,e,r,i){if(r)throw new uI(r,t,e);if(i instanceof hI)throw i;if(i)throw Error(i.message)}async fetchEndpoint(t,e){try{if(this.batchClient){const{error:r,result:i}=await this.batchClient.fetch(t,e,this.requestId+=1);return this.errorHandler(t,e,r),i}const r=await this.fetch(t,e,this.requestId+=1),{error:i,result:n}=await r.json();return this.errorHandler(t,e,i),n}catch(r){throw this.errorHandler(t,e,r?.response?.data,r),r}}async getChainId(){return this.chainId??=await this.fetchEndpoint("starknet_chainId"),this.chainId}async getSpecVersion(){return this.specVersion??=await this.fetchEndpoint("starknet_specVersion"),this.specVersion}getNonceForAddress(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getNonce",{contract_address:r,block_id:i})}getBlockLatestAccepted(){return this.fetchEndpoint("starknet_blockHashAndNumber")}getBlockNumber(){return this.fetchEndpoint("starknet_blockNumber")}getBlockWithTxHashes(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxHashes",{block_id:e})}getBlockWithTxs(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithTxs",{block_id:e})}getBlockWithReceipts(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockWithReceipts",{block_id:e})}getBlockStateUpdate(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getStateUpdate",{block_id:e})}getBlockTransactionsTraces(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_traceBlockTransactions",{block_id:e})}getBlockTransactionCount(t=this.blockIdentifier){const e=new Vz(t).identifier;return this.fetchEndpoint("starknet_getBlockTransactionCount",{block_id:e})}getTransactionByHash(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionByHash",{transaction_hash:e})}getTransactionByBlockIdAndIndex(t,e){const r=new Vz(t).identifier;return this.fetchEndpoint("starknet_getTransactionByBlockIdAndIndex",{block_id:r,index:e})}getTransactionReceipt(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionReceipt",{transaction_hash:e})}getTransactionTrace(t){const e=RI(t);return this.fetchEndpoint("starknet_traceTransaction",{transaction_hash:e})}getTransactionStatus(t){const e=RI(t);return this.fetchEndpoint("starknet_getTransactionStatus",{transaction_hash:e})}simulateTransaction(t,e={}){const{blockIdentifier:r=this.blockIdentifier,skipValidate:i=!0,skipFeeCharge:n=!0}=e,o=new Vz(r).identifier,a=[];return i&&a.push(Zp.SKIP_VALIDATE),n&&a.push(Zp.SKIP_FEE_CHARGE),this.fetchEndpoint("starknet_simulateTransactions",{block_id:o,transactions:t.map((t=>this.buildTransaction(t))),simulation_flags:a})}async waitForTransaction(t,e){const r=RI(t);let{retries:i}=this,n=!1,o=!1;const a=e?.retryInterval??this.transactionRetryIntervalDefault,s=e?.errorStates??[Kp.REJECTED],h=e?.successStates??[Wp.SUCCEEDED,Kp.ACCEPTED_ON_L2,Kp.ACCEPTED_ON_L1];let u;for(;!n;){await $z(a);try{u=await this.getTransactionStatus(r);const t=u.execution_status,e=u.finality_status;if(!e){throw new Error("waiting for transaction status")}if(s.includes(t)||s.includes(e)){const r=`${t}: ${e}`,i=new Error(r);throw i.response=u,o=!0,i}(h.includes(t)||h.includes(e))&&(n=!0)}catch(t){if(t instanceof Error&&o)throw t;if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1}let l=null;for(;null===l;){try{l=await this.getTransactionReceipt(r)}catch(t){if(i<=0)throw new Error(`waitForTransaction timed-out with retries ${this.retries}`)}i-=1,await $z(a)}return l}getStorageAt(t,e,r=this.blockIdentifier){const i=RI(t),n=BI(e),o=new Vz(r).identifier;return this.fetchEndpoint("starknet_getStorageAt",{contract_address:i,key:n,block_id:o})}getClassHashAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassHashAt",{block_id:i,contract_address:r})}getClass(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClass",{class_hash:r,block_id:i})}getClassAt(t,e=this.blockIdentifier){const r=RI(t),i=new Vz(e).identifier;return this.fetchEndpoint("starknet_getClassAt",{block_id:i,contract_address:r})}async getEstimateFee(t,{blockIdentifier:e=this.blockIdentifier,skipValidate:r=!0}){const i=new Vz(e).identifier;let n={};return Gz("0.5",await this.getSpecVersion())||(n={simulation_flags:r?[Zp.SKIP_VALIDATE]:[]}),this.fetchEndpoint("starknet_estimateFee",{request:t.map((t=>this.buildTransaction(t,"fee"))),block_id:i,...n})}async invoke(t,e){let r;return Hz(e)?r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{type:Gp.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:tg.V3,signature:_z(t.signature),nonce:RI(e.nonce),resource_bounds:e.resourceBounds,tip:RI(e.tip),paymaster_data:e.paymasterData.map((t=>RI(t))),account_deployment_data:e.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:e.nonceDataAvailabilityMode,fee_data_availability_mode:e.feeDataAvailabilityMode}}):(r=this.fetchEndpoint("starknet_addInvokeTransaction",{invoke_transaction:{sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),type:Gp.INVOKE,max_fee:RI(e.maxFee||0),version:tg.V1,signature:_z(t.signature),nonce:RI(e.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V1,type:Gp.INVOKE})),this.waitMode?this.waitForTransaction((await r).transaction_hash):r}async declare({contract:t,signature:e,senderAddress:r,compiledClassHash:i},n){let o;if(Cz(t)||Hz(n))if(Cz(t)&&!Hz(n))o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:Gp.DECLARE,contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},compiled_class_hash:i||"",version:tg.V2,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V2,type:Gp.DECLARE});else{if(!Cz(t)||!Hz(n))throw Error("declare unspotted parameters");o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:Gp.DECLARE,sender_address:r,compiled_class_hash:i||"",version:tg.V3,signature:_z(e),nonce:RI(n.nonce),contract_class:{sierra_program:wz(t.sierra_program),contract_class_version:t.contract_class_version,entry_points_by_type:t.entry_points_by_type,abi:t.abi},resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),account_deployment_data:n.accountDeploymentData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}})}else o=this.fetchEndpoint("starknet_addDeclareTransaction",{declare_transaction:{type:Gp.DECLARE,contract_class:{program:t.program,entry_points_by_type:t.entry_points_by_type,abi:t.abi},version:tg.V1,max_fee:RI(n.maxFee||0),signature:_z(e),sender_address:r,nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V1,type:Gp.DECLARE});return this.waitMode?this.waitForTransaction((await o).transaction_hash):o}async deployAccount({classHash:t,constructorCalldata:e,addressSalt:r,signature:i},n){let o;return Hz(n)?o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{type:Gp.DEPLOY_ACCOUNT,version:tg.V3,signature:_z(i),nonce:RI(n.nonce),contract_address_salt:RI(r||0),constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),resource_bounds:n.resourceBounds,tip:RI(n.tip),paymaster_data:n.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:n.nonceDataAvailabilityMode,fee_data_availability_mode:n.feeDataAvailabilityMode}}):(o=this.fetchEndpoint("starknet_addDeployAccountTransaction",{deploy_account_transaction:{constructor_calldata:TC.toHex(e||[]),class_hash:RI(t),contract_address_salt:RI(r||0),type:Gp.DEPLOY_ACCOUNT,max_fee:RI(n.maxFee||0),version:tg.V1,signature:_z(i),nonce:RI(n.nonce)}}),Dz.warn(XN.legacyTxWarningMessage,{version:tg.V1,type:Gp.DEPLOY_ACCOUNT})),this.waitMode?this.waitForTransaction((await o).transaction_hash):o}callContract(t,e=this.blockIdentifier){const r=new Vz(e).identifier;return this.fetchEndpoint("starknet_call",{request:{contract_address:t.contractAddress,entry_point_selector:eT(t.entrypoint),calldata:TC.toHex(t.calldata)},block_id:r})}estimateMessageFee(t,e=this.blockIdentifier){const{from_address:r,to_address:i,entry_point_selector:n,payload:o}=t,a={from_address:Oz(r),to_address:RI(i),entry_point_selector:rT(n),payload:ZI(o)},s=new Vz(e).identifier;return this.fetchEndpoint("starknet_estimateMessageFee",{message:a,block_id:s})}getSyncingStats(){return this.fetchEndpoint("starknet_syncing")}getEvents(t){return this.fetchEndpoint("starknet_getEvents",{filter:t})}buildTransaction(t,e){const r=iO(e);let i;if(Hz(t)?i={signature:_z(t.signature),nonce:RI(t.nonce),resource_bounds:t.resourceBounds,tip:RI(t.tip),paymaster_data:t.paymasterData.map((t=>RI(t))),nonce_data_availability_mode:t.nonceDataAvailabilityMode,fee_data_availability_mode:t.feeDataAvailabilityMode,account_deployment_data:t.accountDeploymentData.map((t=>RI(t)))}:(i={signature:_z(t.signature),nonce:RI(t.nonce),max_fee:RI(t.maxFee||0)},Dz.warn(XN.legacyTxWarningMessage,{version:t.version,type:t.type})),t.type===cI.INVOKE)return{type:Gp.INVOKE,sender_address:t.contractAddress,calldata:TC.toHex(t.calldata),version:RI(t.version||r.v3),...i};if(t.type===cI.DECLARE)return Cz(t.contract)?{type:t.type,contract_class:{...t.contract,sierra_program:wz(t.contract.sierra_program)},compiled_class_hash:t.compiledClassHash||"",sender_address:t.senderAddress,version:RI(t.version||r.v3),...i}:{type:t.type,contract_class:t.contract,sender_address:t.senderAddress,version:RI(t.version||r.v1),...i};if(t.type===cI.DEPLOY_ACCOUNT){const{account_deployment_data:e,...n}=i;return{type:t.type,constructor_calldata:TC.toHex(t.constructorCalldata||[]),class_hash:RI(t.classHash),contract_address_salt:RI(t.addressSalt||0),version:RI(t.version||r.v3),...n}}throw Error("RPC buildTransaction received unknown TransactionType")}},hO=class{margin;constructor(t){this.margin=t}estimatedFeeToMaxFee(t){return Ez(t,this.margin?.maxFee)}estimateFeeToBounds(t){return Az(t,this.margin?.l1BoundMaxAmount,this.margin?.l1BoundMaxPricePerUnit)}parseGetBlockResponse(t){return{status:"PENDING",...t}}parseTransactionReceipt(t){return"actual_fee"in t&&TI(t.actual_fee)?{...t,actual_fee:{amount:t.actual_fee,unit:"FRI"}}:t}parseFeeEstimateResponse(t){const e=t[0];return{overall_fee:OI(e.overall_fee),gas_consumed:OI(e.gas_consumed),gas_price:OI(e.gas_price),unit:e.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(e.overall_fee),resourceBounds:this.estimateFeeToBounds(e),data_gas_consumed:e.data_gas_consumed?OI(e.data_gas_consumed):0n,data_gas_price:e.data_gas_price?OI(e.data_gas_price):0n}}parseFeeEstimateBulkResponse(t){return t.map((t=>({overall_fee:OI(t.overall_fee),gas_consumed:OI(t.gas_consumed),gas_price:OI(t.gas_price),unit:t.unit,suggestedMaxFee:this.estimatedFeeToMaxFee(t.overall_fee),resourceBounds:this.estimateFeeToBounds(t),data_gas_consumed:t.data_gas_consumed?OI(t.data_gas_consumed):0n,data_gas_price:t.data_gas_price?OI(t.data_gas_price):0n})))}parseSimulateTransactionResponse(t){return t.map((t=>({...t,suggestedMaxFee:this.estimatedFeeToMaxFee(t.fee_estimation.overall_fee),resourceBounds:this.estimateFeeToBounds(t.fee_estimation)})))}parseContractClassResponse(t){return{...t,abi:TI(t.abi)?JSON.parse(t.abi):t.abi}}parseL1GasPriceResponse(t){return t.l1_gas_price.price_in_wei}},uO=class t{statusReceipt;value;constructor(e){[this.statusReceipt,this.value]=t.isSuccess(e)?["success",e]:t.isReverted(e)?["reverted",e]:t.isRejected(e)?["rejected",e]:["error",new Error("Unknown response type")];for(const[t]of Object.entries(this))Object.defineProperty(this,t,{enumerable:!1});for(const[t,r]of Object.entries(e))Object.defineProperty(this,t,{enumerable:!0,writable:!1,value:r})}match(t){return this.statusReceipt in t?t[this.statusReceipt](this.value):t._()}isSuccess(){return"success"===this.statusReceipt}isReverted(){return"reverted"===this.statusReceipt}isRejected(){return"rejected"===this.statusReceipt}isError(){return"error"===this.statusReceipt}static isSuccess(t){return t.execution_status===mI.SUCCEEDED}static isReverted(t){return t.execution_status===mI.REVERTED}static isRejected(t){return t.status===mI.REJECTED}},lO={};KS(lO,{TypedDataRevision:()=>og,encodeData:()=>AO,encodeType:()=>MO,encodeValue:()=>EO,getDependencies:()=>kO,getMessageHash:()=>xO,getStructHash:()=>jO,getTypeHash:()=>_O,isMerkleTreeType:()=>bO,prepareSelector:()=>vO,validateTypedData:()=>wO,verifyMessage:()=>SO});KS({},{MerkleTree:()=>cO,proofMerklePath:()=>dO});var cO=class t{leaves;branches=[];root;hashMethod;constructor(t,e=ez){this.hashMethod=e,this.leaves=t,this.root=this.build(t)}build(e){if(1===e.length)return e[0];e.length!==this.leaves.length&&this.branches.push(e);const r=[];for(let i=0;i<e.length;i+=2)i+1===e.length?r.push(t.hash(e[i],"0x0",this.hashMethod)):r.push(t.hash(e[i],e[i+1],this.hashMethod));return this.build(r)}static hash(t,e,r=ez){const[i,n]=[BigInt(t),BigInt(e)].sort(((t,e)=>t>=e?1:-1));return r(i,n)}getProof(e,r=this.leaves,i=[]){const n=r.indexOf(e);if(-1===n)throw new Error("leaf not found");if(1===r.length)return i;const o=n%2==0,a=(o?r[n+1]:r[n-1])??"0x0",s=[...i,a],h=this.leaves.length===r.length?-1:this.branches.findIndex((t=>t.length===r.length)),u=this.branches[h+1]??[this.root];return this.getProof(t.hash(o?e:a,o?a:e,this.hashMethod),u,s)}};function dO(t,e,r,i=ez){if(0===r.length)return t===e;const[n,...o]=r;return dO(t,cO.hash(e,n,i),o,i)}var fO={u256:JSON.parse('[{ "name": "low", "type": "u128" }, { "name": "high", "type": "u128" }]'),TokenAmount:JSON.parse('[{ "name": "token_address", "type": "ContractAddress" }, { "name": "amount", "type": "u256" }]'),NftId:JSON.parse('[{ "name": "collection_address", "type": "ContractAddress" }, { "name": "token_id", "type": "u256" }]')},mO={[og.ACTIVE]:{domain:"StarknetDomain",hashMethod:oz,hashMerkleMethod:rz,escapeTypeString:t=>`"${t}"`,presetTypes:fO},[og.LEGACY]:{domain:"StarkNetDomain",hashMethod:nz,hashMerkleMethod:ez,escapeTypeString:t=>t,presetTypes:{}}};function pO(t,e,{min:r,max:i}){const n=BigInt(t);jI(n>=r&&n<=i,`${n} (${e}) is out of bounds [${r}, ${i}]`)}function gO({types:t,domain:e}){return mO[og.ACTIVE].domain in t&&e.revision===og.ACTIVE?og.ACTIVE:mO[og.LEGACY].domain in t&&(e.revision??og.LEGACY)===og.LEGACY?og.LEGACY:void 0}function yO(t){try{return RI(t)}catch(e){if(TI(t))return RI(dT(t));throw new Error(`Invalid BigNumberish: ${t}`)}}function wO(t){const e=t;return Boolean(e.message&&e.primaryType&&e.types&&gO(e))}function vO(t){return zI(t)?t:eT(t)}function bO(t){return"merkletree"===t.type}function kO(t,e,r=[],i="",n=og.LEGACY){let o=[e];return"*"===e[e.length-1]?o=[e.slice(0,-1)]:n===og.ACTIVE&&("enum"===e?o=[i]:e.match(/^\(.*\)$/)&&(o=e.slice(1,-1).split(",").map((t=>"*"===t[t.length-1]?t.slice(0,-1):t)))),o.filter((e=>!r.includes(e)&&t[e])).reduce(((e,r)=>[...e,...[r,...t[r].reduce(((e,r)=>[...e,...kO(t,r.type,e,r.contains,n).filter((t=>!e.includes(t)))]),[])].filter((t=>!e.includes(t)))]),[])}function MO(t,e,r=og.LEGACY){const i=r===og.ACTIVE?{...t,...mO[r].presetTypes}:t,[n,...o]=kO(i,e,void 0,void 0,r),a=n?[n,...o.sort()]:[],s=mO[r].escapeTypeString;return a.map((t=>{const e=i[t].map((t=>{const e="enum"===t.type&&r===og.ACTIVE?t.contains:t.type,i=e.match(/^\(.*\)$/)?`(${e.slice(1,-1).split(",").map((t=>t?s(t):t)).join(",")})`:s(e);return`${s(t.name)}:${i}`}));return`${s(t)}(${e})`})).join("")}function _O(t,e,r=og.LEGACY){return eT(MO(t,e,r))}function EO(t,e,r,i={},n=og.LEGACY){if(t[e])return[e,jO(t,e,r,n)];if(mO[n].presetTypes[e])return[e,jO(mO[n].presetTypes,e,r,n)];if(e.endsWith("*")){const i=r.map((r=>EO(t,e.slice(0,-1),r,void 0,n)[1]));return[e,mO[n].hashMethod(i)]}switch(e){case"enum":if(n===og.ACTIVE){const[o,a]=Object.entries(r)[0],s=t[i.parent].find((t=>t.name===i.key)),h=t[s.contains],u=h.find((t=>t.name===o)),l=h.indexOf(u),c=u.type.slice(1,-1).split(",").map(((e,r)=>{if(!e)return e;const i=a[r];return EO(t,e,i,void 0,n)[1]}));return[e,mO[n].hashMethod([l,...c])]}return[e,yO(r)];case"merkletree":{const e=function(t,e){if(e.parent&&e.key){const r=t[e.parent].find((t=>t.name===e.key));if(!bO(r))throw new Error(`${e.key} is not a merkle tree`);if(r.contains.endsWith("*"))throw new Error(`Merkle tree contain property must not be an array but was given ${e.key}`);return r.contains}return"raw"}(t,i),o=r.map((r=>EO(t,e,r,void 0,n)[1])),{root:a}=new cO(o,mO[n].hashMerkleMethod);return["felt",a]}case"selector":return["felt",vO(r)];case"string":if(n===og.ACTIVE){const t=pT(r),i=[t.data.length,...t.data,t.pending_word,t.pending_word_len];return[e,mO[n].hashMethod(i)]}return[e,yO(r)];case"i128":if(n===og.ACTIVE){const t=BigInt(r);return pO(t,e,BN),[e,yO(t<0n?CN+t:t)]}return[e,yO(r)];case"timestamp":case"u128":return n===og.ACTIVE&&pO(r,e,DN),[e,yO(r)];case"felt":case"shortstring":return n===og.ACTIVE&&pO(yO(r),e,PN),[e,yO(r)];case"ClassHash":case"ContractAddress":return n===og.ACTIVE&&pO(r,e,PN),[e,yO(r)];case"bool":return n===og.ACTIVE&&jI(NI(r),`Type mismatch for ${e} ${r}`),[e,yO(r)];default:if(n===og.ACTIVE)throw new Error(`Unsupported type: ${e}`);return[e,yO(r)]}}function AO(t,e,r,i=og.LEGACY){const n=t[e]??mO[i].presetTypes[e],[o,a]=n.reduce((([n,o],a)=>{if(void 0===r[a.name]||null===r[a.name]&&"enum"!==a.type)throw new Error(`Cannot encode data: missing data for '${a.name}'`);const s=r[a.name],h={parent:e,key:a.name},[u,l]=EO(t,a.type,s,h,i);return[[...n,u],[...o,l]]}),[["felt"],[_O(t,e,i)]]);return[o,a]}function jO(t,e,r,i=og.LEGACY){return mO[i].hashMethod(AO(t,e,r,i)[1])}function xO(t,e){if(!wO(t))throw new Error("Typed data does not match JSON schema");const r=gO(t),{domain:i,hashMethod:n}=mO[r];return n([dT("StarkNet Message"),jO(t.types,i,t.domain,r),e,jO(t.types,t.primaryType,t.message,r)])}function SO(t,e,r,i){const n=wO(t);if(!QI(t)&&!n)throw new Error("message has a wrong format.");if(n&&void 0===i)throw new Error("When providing a TypedData in message parameter, the accountAddress parameter has to be provided.");if(n&&!QI(i))throw new Error("accountAddress shall be a BigNumberish");const o=n?xO(t,i):RI(t);return _b(Array.isArray(e)?new jb(BigInt(e[0]),BigInt(e[1])):e,o,RI(r))}var NO=class{responseParser;channel;constructor(t){t&&"channel"in t?(this.channel=t.channel,this.responseParser="responseParser"in t?t.responseParser:new hO):(this.channel=new sO({...t,waitMode:!1}),this.responseParser=new hO(t?.feeMarginPercentage))}fetch(t,e,r=0){return this.channel.fetch(t,e,r)}async getChainId(){return this.channel.getChainId()}async getSpecVersion(){return this.channel.getSpecVersion()}async getNonceForAddress(t,e){return this.channel.getNonceForAddress(t,e)}async getBlock(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseGetBlockResponse)}async getBlockLatestAccepted(){return this.channel.getBlockLatestAccepted()}async getBlockNumber(){return this.channel.getBlockNumber()}async getBlockWithTxHashes(t){return this.channel.getBlockWithTxHashes(t)}async getBlockWithTxs(t){return this.channel.getBlockWithTxs(t)}async waitForBlock(t="pending",e=5e3){if(t===gI.LATEST)return;const r=await this.getBlockNumber(),i=t===gI.PENDING?r+1:Number(RI(t));if(i<=r)return;const{retries:n}=this.channel;let o=n,a=!1;for(;!a;){if(await this.getBlockNumber()===i?a=!0:await $z(e),o-=1,o<=0)throw new Error(`waitForBlock() timed-out after ${n} tries.`)}}async getL1GasPrice(t){return this.channel.getBlockWithTxHashes(t).then(this.responseParser.parseL1GasPriceResponse)}async getL1MessageHash(t){const e=await this.channel.getTransactionByHash(t);jI("L1_HANDLER"===e.type,"This L2 transaction is not a L1 message.");const{calldata:r,contract_address:i,entry_point_selector:n,nonce:o}=e;return iT([r[0],i,o,n,r.length-1,...r.slice(1)])}async getBlockWithReceipts(t){if(this.channel instanceof tI.RpcChannel)throw new hI("Unsupported method for RPC version");return this.channel.getBlockWithReceipts(t)}getStateUpdate=this.getBlockStateUpdate;async getBlockStateUpdate(t){return this.channel.getBlockStateUpdate(t)}async getBlockTransactionsTraces(t){return this.channel.getBlockTransactionsTraces(t)}async getBlockTransactionCount(t){return this.channel.getBlockTransactionCount(t)}async getPendingTransactions(){const{transactions:t}=await this.getBlockWithTxHashes(gI.PENDING).then(this.responseParser.parseGetBlockResponse);return Promise.all(t.map((t=>this.getTransactionByHash(t))))}async getTransaction(t){return this.channel.getTransactionByHash(t)}async getTransactionByHash(t){return this.channel.getTransactionByHash(t)}async getTransactionByBlockIdAndIndex(t,e){return this.channel.getTransactionByBlockIdAndIndex(t,e)}async getTransactionReceipt(t){const e=await this.channel.getTransactionReceipt(t),r=this.responseParser.parseTransactionReceipt(e);return new uO(r)}async getTransactionTrace(t){return this.channel.getTransactionTrace(t)}async getTransactionStatus(t){return this.channel.getTransactionStatus(t)}async getSimulateTransaction(t,e){return this.channel.simulateTransaction(t,e).then((t=>this.responseParser.parseSimulateTransactionResponse(t)))}async waitForTransaction(t,e){const r=await this.channel.waitForTransaction(t,e);return new uO(r)}async getStorageAt(t,e,r){return this.channel.getStorageAt(t,e,r)}async getClassHashAt(t,e){return this.channel.getClassHashAt(t,e)}async getClassByHash(t){return this.getClass(t)}async getClass(t,e){return this.channel.getClass(t,e).then(this.responseParser.parseContractClassResponse)}async getClassAt(t,e){return this.channel.getClassAt(t,e).then(this.responseParser.parseContractClassResponse)}async getContractVersion(t,e,{blockIdentifier:r=this.channel.blockIdentifier,compiler:i=!0}={}){let n;if(t)n=await this.getClassAt(t,r);else{if(!e)throw Error("getContractVersion require contractAddress or classHash");n=await this.getClass(e,r)}if(Cz(n)){if(i){return{cairo:"1",compiler:XT(n.abi).compiler}}return{cairo:"1",compiler:void 0}}return{cairo:"0",compiler:"0"}}async getEstimateFee(t,e,r,i){return this.getInvokeEstimateFee(t,e,r,i)}async getInvokeEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:cI.INVOKE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeclareEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:cI.DECLARE,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getDeployAccountEstimateFee(t,e,r,i){return this.channel.getEstimateFee([{type:cI.DEPLOY_ACCOUNT,...t,...e}],{blockIdentifier:r,skipValidate:i}).then((t=>this.responseParser.parseFeeEstimateResponse(t)))}async getEstimateFeeBulk(t,e){return this.channel.getEstimateFee(t,e).then((t=>this.responseParser.parseFeeEstimateBulkResponse(t)))}async invokeFunction(t,e){return this.channel.invoke(t,e)}async declareContract(t,e){return this.channel.declare(t,e)}async deployAccountContract(t,e){return this.channel.deployAccount(t,e)}async callContract(t,e){return this.channel.callContract(t,e)}async estimateMessageFee(t,e){return this.channel.estimateMessageFee(t,e)}async getSyncingStats(){return this.channel.getSyncingStats()}async getEvents(t){return this.channel.getEvents(t)}async verifyMessageInStarknet(t,e,r,i,n){const o=wO(t);if(!QI(t)&&!o)throw new Error("message has a wrong format.");if(!QI(r))throw new Error("accountAddress shall be a BigNumberish");const a=o?xO(t,r):RI(t),s=i?[i]:["isValidSignature","is_valid_signature"],h=n||{okResponse:[],nokResponse:["0x0","0x00"],error:["argent/invalid-signature","is invalid, with respect to the public key","INVALID_SIG"]};let u;for(const t of s)try{const i=await this.callContract({contractAddress:RI(r),entrypoint:t,calldata:TC.compile({hash:OI(a).toString(),signature:kz(e)})});if(h.nokResponse.includes(i[0].toString()))return!1;if(0===h.okResponse.length||h.okResponse.includes(i[0].toString()))return!0;throw Error("signatureVerificationResponse Error: response is not part of known responses")}catch(t){if(h.error.some((e=>t.message.includes(e))))return!1;u=t}throw Error(`Signature verification Error: ${u}`)}async isClassDeclared(t,e){let r;if(!t.classHash&&"contract"in t){r=function(t){const e={...t};if(Cz(t.contract)&&(!t.compiledClassHash&&t.casm&&(e.compiledClassHash=fz(t.casm)),!e.compiledClassHash))throw new Error("Extract compiledClassHash failed, provide (CairoAssembly).casm file or compiledClassHash");if(e.classHash=t.classHash??gz(t.contract),!e.classHash)throw new Error("Extract classHash failed, provide (CompiledContract).json file or classHash");return e}(t).classHash}else{if(!t.classHash)throw Error("contractClassIdentifier type not satisfied");r=t.classHash}try{return await this.getClass(r,e)instanceof Object}catch(t){if(t instanceof hI)return!1;throw t}}async prepareInvocations(t){const e=[];for(const r of t)if(r.type===cI.DECLARE){await this.isClassDeclared("payload"in r?r.payload:r)||e.unshift(r)}else e.push(r);return e}};KS({},{StarknetIdContract:()=>$O,StarknetIdIdentityContract:()=>FO,StarknetIdMulticallContract:()=>qO,StarknetIdPfpContract:()=>ZO,StarknetIdPopContract:()=>JO,StarknetIdVerifierContract:()=>HO,dynamicCallData:()=>XO,dynamicFelt:()=>QO,execution:()=>YO,getStarknetIdContract:()=>LO,getStarknetIdIdentityContract:()=>UO,getStarknetIdMulticallContract:()=>VO,getStarknetIdPfpContract:()=>KO,getStarknetIdPopContract:()=>WO,getStarknetIdVerifierContract:()=>GO,isStarkDomain:()=>tR,useDecoded:()=>BO,useEncoded:()=>DO});var IO="abcdefghijklmnopqrstuvwxyz0123456789-",TO=BigInt(IO.length+1),CO="这来",zO=BigInt(IO.length),OO=BigInt(CO.length),RO=BigInt(CO.length+1);function PO(t){let e=0;for(;t.endsWith(CO[CO.length-1]);)t=t.substring(0,t.length-1),e+=1;return[t,e]}function BO(t){let e="";return t.forEach((t=>{for(;t!==SN;){const r=t%TO;if(t/=TO,r===BigInt(IO.length)){const r=t/RO;if(r===SN){const i=t%RO;t=r,e+=i===SN?IO[0]:CO[Number(i)-1]}else{e+=CO[Number(t%OO)],t/=OO}}else e+=IO[Number(r)]}const[r,i]=PO(e);i&&(e=r+(i%2==0?CO[CO.length-1].repeat(i/2-1)+CO[0]+IO[1]:CO[CO.length-1].repeat((i-1)/2+1))),e+="."})),e?e.concat("stark"):e}function DO(t){let e=BigInt(0),r=BigInt(1);if(t.endsWith(CO[0]+IO[1])){const[e,r]=PO(t.substring(0,t.length-2));t=e+CO[CO.length-1].repeat(2*(r+1))}else{const[e,r]=PO(t);r&&(t=e+CO[CO.length-1].repeat(1+2*(r-1)))}for(let i=0;i<t.length;i+=1){const n=t[i],o=IO.indexOf(n),a=BigInt(IO.indexOf(n));if(-1!==o)i===t.length-1&&t[i]===IO[0]?(e+=r*zO,r*=TO,r*=TO):(e+=r*a,r*=TO);else if(-1!==CO.indexOf(n)){e+=r*zO,r*=TO;const o=(i===t.length-1?1:0)+CO.indexOf(n);e+=r*BigInt(o),r*=OO}}return e}var $O={MAINNET:"0x6ac597f8116f886fa1c97a23fa4e08299975ecaf6b598873ca6792b9bbfb678",TESTNET_SEPOLIA:"0x154bc2e1af9260b9e66af0e9c46fc757ff893b3ff6a85718a810baf1474"};function LO(t){switch(t){case"0x534e5f4d41494e":return $O.MAINNET;case"0x534e5f5345504f4c4941":return $O.TESTNET_SEPOLIA;default:throw new Error("Starknet.id is not yet deployed on this network")}}var FO={MAINNET:"0x05dbdedc203e92749e2e746e2d40a768d966bd243df04a6b712e222bc040a9af",TESTNET_SEPOLIA:"0x3697660a0981d734780731949ecb2b4a38d6a58fc41629ed611e8defda"};function UO(t){switch(t){case"0x534e5f4d41494e":return FO.MAINNET;case"0x534e5f5345504f4c4941":return FO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var qO="0x034ffb8f4452df7a613a0210824d6414dbadcddce6c6e19bf4ddc9e22ce5f970";function VO(t){switch(t){case"0x534e5f4d41494e":case"0x534e5f5345504f4c4941":return qO;default:throw new Error("Starknet.id multicall contract is not yet deployed on this network")}}var HO={MAINNET:"0x07d14dfd8ee95b41fce179170d88ba1f0d5a512e13aeb232f19cfeec0a88f8bf",TESTNET_SEPOLIA:"0x60B94fEDe525f815AE5E8377A463e121C787cCCf3a36358Aa9B18c12c4D566"};function GO(t){switch(t){case"0x534e5f4d41494e":return HO.MAINNET;case"0x534e5f5345504f4c4941":return HO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id verifier contract is not yet deployed on this network")}}var ZO={MAINNET:"0x070aaa20ec4a46da57c932d9fd89ca5e6bb9ca3188d3df361a32306aff7d59c7",TESTNET_SEPOLIA:"0x9e7bdb8dabd02ea8cfc23b1d1c5278e46490f193f87516ed5ff2dfec02"};function KO(t){switch(t){case"0x534e5f4d41494e":return ZO.MAINNET;case"0x534e5f5345504f4c4941":return ZO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id profile picture verifier contract is not yet deployed on this network")}}var JO={MAINNET:"0x0293eb2ba9862f762bd3036586d5755a782bd22e6f5028320f1d0405fd47bff4",TESTNET_SEPOLIA:"0x15ae88ae054caa74090b89025c1595683f12edf7a4ed2ad0274de3e1d4a"};function WO(t){switch(t){case"0x534e5f4d41494e":return JO.MAINNET;case"0x534e5f5345504f4c4941":return JO.TESTNET_SEPOLIA;default:throw new Error("Starknet.id proof of personhood verifier contract is not yet deployed on this network")}}function YO(t,e,r){return new nC({Static:t,IfEqual:e?rC(e[0],e[1],e[2]):void 0,IfNotEqual:r?rC(r[0],r[1],r[2]):void 0})}function QO(t,e){return new nC({Hardcoded:t,Reference:e?rC(e[0],e[1]):void 0})}function XO(t,e,r){return new nC({Hardcoded:t,Reference:e?rC(e[0],e[1]):void 0,ArrayReference:r?rC(r[0],r[1]):void 0})}function tR(t){return/^(?:[a-z0-9-]{1,48}(?:[a-z0-9-]{1,48}[a-z0-9-])?\.)*[a-z0-9-]{1,48}\.stark$/.test(t)}var eR=class extends(US(NO,class t{async getStarkName(e,r){return t.getStarkName(this,e,r)}async getAddressFromStarkName(e,r){return t.getAddressFromStarkName(this,e,r)}async getStarkProfile(e,r,i,n,o,a,s){return t.getStarkProfile(this,e,r,i,n,o,a,s)}static async getStarkName(t,e,r){const i=await t.getChainId(),n=r??LO(i);try{const r=await t.callContract({contractAddress:n,entrypoint:"address_to_domain",calldata:TC.compile({address:e,hint:[]})}),i=BO(r.map((t=>BigInt(t))).slice(1));if(!i)throw Error("Starkname not found");return i}catch(t){if(t instanceof Error&&"Starkname not found"===t.message)throw t;throw Error("Could not get stark name")}}static async getAddressFromStarkName(t,e,r){const i=e.endsWith(".stark")?e:`${e}.stark`;if(!tR(i))throw new Error("Invalid domain, must be a valid .stark domain");const n=await t.getChainId(),o=r??LO(n);try{const e=i.replace(".stark","").split(".").map((t=>DO(t).toString(10)));return(await t.callContract({contractAddress:o,entrypoint:"domain_to_address",calldata:TC.compile({domain:e,hint:[]})}))[0]}catch{throw Error("Could not get address from stark name")}}static async getStarkProfile(t,e,r,i,n,o,a,s){const h=await t.getChainId(),u=r??LO(h),l=i??UO(h),c=n??GO(h),d=o??KO(h),f=a??WO(h),m=s??VO(h);try{const r=[{execution:YO({}),to:XO(u),selector:XO(eT("address_to_domain")),calldata:[XO(e),XO("0")]},{execution:YO({}),to:QO(u),selector:QO(eT("domain_to_id")),calldata:[XO(void 0,void 0,[0,0])]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("twitter")),XO(c),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("github")),XO(c),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("discord")),XO(c),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("proof_of_personhood")),XO(f),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("nft_pp_contract")),XO(d),XO("0")]},{execution:YO({}),to:QO(l),selector:QO(eT("get_extended_verifier_data")),calldata:[XO(void 0,[1,0]),XO(dT("nft_pp_id")),XO("2"),XO(d),XO("0")]},{execution:YO(void 0,void 0,[6,0,0]),to:QO(void 0,[6,0]),selector:QO(eT("tokenURI")),calldata:[XO(void 0,[7,1]),XO(void 0,[7,2])]}],i=await t.callContract({contractAddress:m,entrypoint:"aggregate",calldata:TC.compile({calls:r})});if(Array.isArray(i)){const t=parseInt(i[0],16),e=[];let r=1;for(let n=0;n<t&&r<i.length;n+=1){const t=parseInt(i[r],16);r+=1;const n=i.slice(r,r+t);e.push(n),r+=t}const n=BO(e[0].slice(1).map((t=>BigInt(t)))),o="0x0"!==e[2][0]?BigInt(e[2][0]).toString():void 0,a="0x0"!==e[3][0]?BigInt(e[3][0]).toString():void 0,s="0x0"!==e[4][0]?BigInt(e[4][0]).toString():void 0,h="0x1"===e[5][0],u="0x9"===i[0]?e[8].slice(1).map((t=>fT(t))).join(""):void 0;return{name:n,twitter:o,github:a,discord:s,proofOfPersonhood:h,profilePicture:u||`https://starknet.id/api/identicons/${BigInt(e[1][0]).toString()}`}}throw Error("Error while calling aggregate function")}catch(t){if(t instanceof Error)throw t;throw Error("Could not get user stark profile data from address")}}})){},rR=new NO({default:!0});function iR(t){return new AT(t).toBigInt()}function nR(t){return AT.is(t)}function oR(t){return new AT(t).toUint256HexString()}function aR(t){const e=function(t){const e=RI(bN(t.toString()));return bN(vN(e).padStart(64,"0"))}(t);if(!e.match(/^(0x)?[0-9a-fA-F]{64}$/))throw new Error("Invalid Address Format");return FI(e,SN,ON-1n,"Starknet Address"),e}KS({},{UINT_128_MAX:()=>wT,UINT_256_MAX:()=>vT,bnToUint256:()=>oR,isUint256:()=>nR,uint256ToBN:()=>iR});function sR(t){return"event"===t.type}function hR(t){const e=t.filter((t=>sR(t)&&"struct"===t.kind)),r=t.filter((t=>sR(t)&&"enum"===t.kind)),i=e.reduce(((t,e)=>{let i=[],{name:n}=e,o=!1;const a=t=>t.type===n;for(;;){const t=r.find((t=>t.variants.some(a)));if(xI(t))break;const e=t.variants.find(a);i.unshift(e.name),"flat"===e.kind&&(o=!0),n=t.name}if(0===i.length)throw new Error("inconsistency in ABI events definition.");o&&(i=[i[i.length-1]]);const s=i.pop();let h={[bN(Fb(mN(s)).toString(16))]:e};for(;i.length>0;)h={[bN(Fb(mN(i.pop())).toString(16))]:h};return h={...h},lR(t,h)}),{});return i}function uR(t){return YT(t)?hR(t):function(t){return t.filter((t=>"event"===t.type)).reduce(((t,e)=>{const r=e.name,i={...e};return i.name=r,{...t,[bN(Fb(mN(r)).toString(16))]:i}}),{})}(t)}function lR(t,e){const r={...t};return CI(t)&&CI(e)&&Object.keys(e).forEach((i=>{CI(e[i])?i in t?r[i]=lR(t[i],e[i]):Object.assign(r,{[i]:e[i]}):Object.assign(r,{[i]:e[i]})})),r}function cR(t,e,r,i){const n=t.flat().reduce(((t,n)=>{let o=e[n.keys.shift()??0];if(!o)return t;for(;!o.name;){const t=n.keys.shift();jI(!!t,'Not enough data in "keys" property of this event.'),o=o[t]}const a={};a[o.name]={};const s=n.keys[Symbol.iterator](),h=n.data[Symbol.iterator](),u=o.members?.filter((t=>"key"===t.kind))||o.keys,l=o.members?.filter((t=>"data"===t.kind))||o.data;return u.forEach((t=>{a[o.name][t.name]=MC(s,t,r,i,a[o.name])})),l.forEach((t=>{a[o.name][t.name]=MC(h,t,r,i,a[o.name])})),"block_hash"in n&&(a.block_hash=n.block_hash),"block_number"in n&&(a.block_number=n.block_number),"transaction_hash"in n&&(a.transaction_hash=n.transaction_hash),t.push(a),t}),[]);return n}function dR(t){if(!t.events?.length)throw new Error("UDC emitted event is empty");const e=t.events.find((t=>LI(t.from_address)===LI(VN.ADDRESS)))||{data:[]};return{transaction_hash:t.transaction_hash,contract_address:e.data[0],address:e.data[0],deployer:e.data[1],unique:e.data[2],classHash:e.data[3],calldata_len:e.data[4],calldata:e.data.slice(5,5+parseInt(e.data[4],16)),salt:e.data[e.data.length-1]}}KS({},{getAbiEvents:()=>uR,isAbiEvent:()=>sR,parseEvents:()=>cR,parseUDCEvent:()=>dR});function fR(t){const e=t.calldata??[],r=Array.isArray(e)?e:TC.compile(e);return{to:t.contractAddress,selector:eT(t.entrypoint),calldata:r}}function mR(t,e){const r=fR(t);return"1"===e?{...r,calldata_len:r.calldata.length,calldata:r.calldata}:{To:r.to,Selector:r.selector,Calldata:r.calldata}}function pR(t,e){return{name:"Account.execute_from_outside",version:e,chainId:t,..."2"===e?{revision:"1"}:{}}}function gR(t,e,r,i,n){return"1"===n?{types:MI,primaryType:"OutsideExecution",domain:pR(t,n),message:{...e,nonce:r,calls_len:i.length,calls:i.map((t=>mR(t,n)))}}:{types:_I,primaryType:"OutsideExecution",domain:pR(t,n),message:{Caller:e.caller,Nonce:r,"Execute After":e.execute_after,"Execute Before":e.execute_before,Calls:i.map((t=>mR(t,n)))}}}function yR(t){const e=t.outsideExecution,r=kz(t.signature);return TC.compile({outside_execution:e,signature:r})}function wR(t){return(Array.isArray(t)?t:[t]).map((t=>{let e;if("1"===t.version)e="execute_from_outside";else{if("2"!==t.version)throw new Error("Unsupported OutsideExecution version");e="execute_from_outside_v2"}return{contractAddress:RI(t.signerAddress),entrypoint:e,calldata:yR(t)}}))}KS({},{buildExecuteFromOutsideCall:()=>wR,buildExecuteFromOutsideCallData:()=>yR,getOutsideCall:()=>fR,getTypedData:()=>gR});async function vR(t,e,r){const i={contractAddress:RI(e),entrypoint:"supports_interface",calldata:[RI(r)]};try{const e=await t.callContract(i);return 0n!==BigInt(e[0])}catch{return!1}}KS({},{supportsInterface:()=>vR});function bR(t,e=!1){return t.request({type:"wallet_requestAccounts",params:{silent_mode:e}})}function kR(t){return t.request({type:"wallet_getPermissions"})}function MR(t,e){return t.request({type:"wallet_watchAsset",params:e})}function _R(t,e){return t.request({type:"wallet_addStarknetChain",params:e})}function ER(t,e){return t.request({type:"wallet_switchStarknetChain",params:{chainId:e}})}function AR(t){return t.request({type:"wallet_requestChainId"})}function jR(t){return t.request({type:"wallet_deploymentData"})}function xR(t,e){return t.request({type:"wallet_addInvokeTransaction",params:e})}function SR(t,e){return t.request({type:"wallet_addDeclareTransaction",params:e})}function NR(t,e){return t.request({type:"wallet_signTypedData",params:e})}function IR(t){return t.request({type:"wallet_supportedSpecs"})}function TR(t,e){t.on("accountsChanged",e)}function CR(t,e){t.on("networkChanged",e)}KS({},{addDeclareTransaction:()=>SR,addInvokeTransaction:()=>xR,addStarknetChain:()=>_R,deploymentData:()=>jR,getPermissions:()=>kR,onAccountChange:()=>TR,onNetworkChanged:()=>CR,requestAccounts:()=>bR,requestChainId:()=>AR,signMessage:()=>NR,supportedSpecs:()=>IR,switchStarknetChain:()=>ER,watchAsset:()=>MR});var zR=t=>{const e=t[t.length-1];return"object"==typeof e&&["blockIdentifier","parseRequest","parseResponse","formatResponse","maxFee","nonce","signature","addressSalt"].some((t=>t in e))?{args:t,options:t.pop()}:{args:t}};function OR(t,e){return async function(...r){const i=zR(r);return t.call(e.name,i.args,{parseRequest:!0,parseResponse:!0,...i.options})}}function RR(t,e){return"view"===e.stateMutability||"view"===e.state_mutability?OR(t,e):function(t,e){return async function(...r){const i=zR(r);return t.invoke(e.name,i.args,{parseRequest:!0,...i.options})}}(t,e)}function PR(t,e){return function(...r){return t.estimate(e.name,r)}}function BR(t,e){return Array.isArray(t)&&"__compiled__"in t?t:Array.isArray(t)&&Array.isArray(t[0])&&"__compiled__"in t[0]?t[0]:e()}var DR=class{abi;address;providerOrAccount;deployTransactionHash;structs;events;functions;callStatic;populateTransaction;estimateFee;callData;constructor(t,e,r=rR){this.address=e&&e.toLowerCase(),this.providerOrAccount=r,this.callData=new TC(t),this.structs=TC.getAbiStruct(t),this.events=uR(t);const i=dC(t);this.abi=i.getLegacyFormat();const n={enumerable:!0,value:{},writable:!1};Object.defineProperties(this,{functions:{enumerable:!0,value:{},writable:!1},callStatic:{enumerable:!0,value:{},writable:!1},populateTransaction:{enumerable:!0,value:{},writable:!1},estimateFee:{enumerable:!0,value:{},writable:!1}}),this.abi.forEach((t=>{if("function"!==t.type)return;const e=t.name;var r,i;this[e]||Object.defineProperty(this,e,{...n,value:RR(this,t)}),this.functions[e]||Object.defineProperty(this.functions,e,{...n,value:RR(this,t)}),this.callStatic[e]||Object.defineProperty(this.callStatic,e,{...n,value:OR(this,t)}),this.populateTransaction[e]||Object.defineProperty(this.populateTransaction,e,{...n,value:(r=this,i=t,function(...t){return r.populate(i.name,t)})}),this.estimateFee[e]||Object.defineProperty(this.estimateFee,e,{...n,value:PR(this,t)})}))}attach(t){this.address=t}connect(t){this.providerOrAccount=t}async deployed(){return this.deployTransactionHash&&(await this.providerOrAccount.waitForTransaction(this.deployTransactionHash),this.deployTransactionHash=void 0),this}async call(t,e=[],{parseRequest:r=!0,parseResponse:i=!0,formatResponse:n,blockIdentifier:o}={}){jI(null!==this.address,"contract is not connected to an address");const a=BR(e,(()=>r?(this.callData.validate(yI.CALL,t,e),this.callData.compile(t,e)):(Dz.warn("Call skipped parsing but provided rawArgs, possible malfunction request"),e)));return this.providerOrAccount.callContract({contractAddress:this.address,calldata:a,entrypoint:t},o).then((e=>i?n?this.callData.format(t,e,n):this.callData.parse(t,e):e))}invoke(t,e=[],{parseRequest:r=!0,maxFee:i,nonce:n,signature:o}={}){jI(null!==this.address,"contract is not connected to an address");const a=BR(e,(()=>r?(this.callData.validate(yI.INVOKE,t,e),this.callData.compile(t,e)):(Dz.warn("Invoke skipped parsing but provided rawArgs, possible malfunction request"),e))),s={contractAddress:this.address,calldata:a,entrypoint:t};if("execute"in this.providerOrAccount)return this.providerOrAccount.execute(s,void 0,{maxFee:i,nonce:n});if(!n)throw new Error("Nonce is required when invoking a function without an account");return Dz.warn(`Invoking ${t} without an account. This will not work on a public node.`),this.providerOrAccount.invokeFunction({...s,signature:o},{nonce:n})}async estimate(t,e=[]){jI(null!==this.address,"contract is not connected to an address"),BR(e,(()=>!1))||this.callData.validate(yI.INVOKE,t,e);const r=this.populate(t,e);if("estimateInvokeFee"in this.providerOrAccount)return this.providerOrAccount.estimateInvokeFee(r);throw Error("Contract must be connected to the account contract to estimate")}populate(t,e=[]){const r=BR(e,(()=>this.callData.compile(t,e)));return{contractAddress:this.address,entrypoint:t,calldata:r}}parseEvents(t){let e;return t.match({success:t=>{const r=t.events?.map((e=>({block_hash:t.block_hash,block_number:t.block_number,transaction_hash:t.transaction_hash,...e}))).filter((t=>LI(t.from_address)===LI(this.address)),[])||[];e=cR(r,this.events,this.structs,TC.getAbiEnum(this.abi))},_:()=>{throw Error("This transaction was not successful.")}}),e}isCairo1(){return gT.isCairo1Abi(this.abi)}async getVersion(){return this.providerOrAccount.getContractVersion(this.address)}typedv2(t){return this}};const $R={SN_MAIN:"https://starknet-mainnet.public.blastapi.io",SN_SEPOLIA:"https://starknet-sepolia.public.blastapi.io"},LR=[{name:"argent::common::account::IAccount",type:"interface",items:[{name:"is_valid_signature",type:"function",inputs:[{name:"hash",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]}];function FR(t,e){var r;if(!$R[t])throw new Error("Invalid network");return new eR({nodeUrl:null!==(r=null==e?void 0:e.broviderUrl)&&void 0!==r?r:$R[t]})}function UR(t){return!!t.primaryType&&!!t.types.StarkNetDomain}function qR(t,e){const{domain:r,types:i,primaryType:n,message:o}=t;return lO.getMessageHash({types:i,primaryType:n,domain:r,message:o},e)}var VR=Object.freeze({__proto__:null,isStarknetMessage:UR,getHash:qR,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="SN_MAIN",n={}){try{const o=new DR(LR,t,FR(i,n));if(e.length<2)throw new Error("Invalid signature format");const a=yield o.is_valid_signature(qR(r,t),e.slice(-2));return eh.from(a).eq(eh.from("370462705988"))}catch(t){if(t.message.includes("Contract not found"))throw new Error("Contract not deployed");throw t}}))}});function HR(t){return mr(ui(t))}var GR=a((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function n(t,e,r){if(n.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=n:e.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Tt.Buffer}catch(t){}function a(t,e){var i=t.charCodeAt(e);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void r(!1,"Invalid character in "+t)}function s(t,e,r){var i=a(t,r);return r-1>=e&&(i|=a(t,r-1)<<4),i}function h(t,e,i,n){for(var o=0,a=0,s=Math.min(t.length,i),h=e;h<s;h++){var u=t.charCodeAt(h)-48;o*=n,a=u>=49?u-49+10:u>=17?u-17+10:u,r(u>=0&&a<n,"Invalid character"),o+=a}return o}function u(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(n.isBN=function(t){return t instanceof n||null!==t&&"object"==typeof t&&t.constructor.wordSize===n.wordSize&&Array.isArray(t.words)},n.max=function(t,e){return t.cmp(e)>0?t:e},n.min=function(t,e){return t.cmp(e)<0?t:e},n.prototype._init=function(t,e,i){if("number"==typeof t)return this._initNumber(t,e,i);if("object"==typeof t)return this._initArray(t,e,i);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===e?this._parseHex(t,n,i):(this._parseBase(t,e,n),"le"===i&&this._initArray(this.toArray(),e,i)))},n.prototype._initNumber=function(t,e,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),e,i)},n.prototype._initArray=function(t,e,i){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,a,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)a=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)a=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=a<<s&67108863,this.words[o+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},n.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var n,o=0,a=0;if("be"===r)for(i=t.length-1;i>=e;i-=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)n=s(t,e,i)<<o,this.words[a]|=67108863&n,o>=18?(o-=18,a+=1,this.words[a]|=n>>>26):o+=8;this._strip()},n.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var i=0,n=1;n<=67108863;n*=e)i++;i--,n=n/e|0;for(var o=t.length-r,a=o%i,s=Math.min(o,o-a)+r,u=0,l=r;l<s;l+=i)u=h(t,l,l+i,e),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==a){var c=1;for(u=h(t,l,t.length,e),l=0;l<a;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},n.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},n.prototype._move=function(t){u(t,this)},n.prototype.clone=function(){var t=new n(null);return this.copy(t),t},n.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},n.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){n.prototype.inspect=l}else n.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(t,e){var i;if(e=0|e||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,a=0;a<this.length;a++){var s=this.words[a],h=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,a--),i=0!==o||a!==this.length-1?c[6-h.length]+h+i:h+i}for(0!==o&&(i=o.toString(16)+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var u=d[t],l=f[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?p+i:c[u-p.length]+p+i}for(this.isZero()&&(i="0"+i);i.length%e!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}r(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},n.prototype.toJSON=function(){return this.toString(16,2)},o&&(n.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),n.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,r){r.negative=e.negative^t.negative;var i=t.length+e.length|0;r.length=i,i=i-1|0;var n=0|t.words[0],o=0|e.words[0],a=n*o,s=67108863&a,h=a/67108864|0;r.words[0]=s;for(var u=1;u<i;u++){for(var l=h>>>26,c=67108863&h,d=Math.min(u,e.length-1),f=Math.max(0,u-t.length+1);f<=d;f++){var m=u-f|0;l+=(a=(n=0|t.words[m])*(o=0|e.words[f])+c)/67108864|0,c=67108863&a}r.words[u]=0|c,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r._strip()}n.prototype.toArrayLike=function(t,e,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);r(n<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0");var a=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](a,n),a},n.prototype._toArrayLikeLE=function(t,e){for(var r=0,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r++]=255&a,r<t.length&&(t[r++]=a>>8&255),r<t.length&&(t[r++]=a>>16&255),6===o?(r<t.length&&(t[r++]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r<t.length)for(t[r++]=i;r<t.length;)t[r++]=0},n.prototype._toArrayLikeBE=function(t,e){for(var r=t.length-1,i=0,n=0,o=0;n<this.length;n++){var a=this.words[n]<<o|i;t[r--]=255&a,r>=0&&(t[r--]=a>>8&255),r>=0&&(t[r--]=a>>16&255),6===o?(r>=0&&(t[r--]=a>>24&255),i=0,o=0):(i=a>>>24,o+=2)}if(r>=0)for(t[r--]=i;r>=0;)t[r--]=0},Math.clz32?n.prototype._countBits=function(t){return 32-Math.clz32(t)}:n.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},n.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},n.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},n.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},n.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},n.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},n.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},n.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this._strip()},n.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},n.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},n.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},n.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var i=0;i<r.length;i++)this.words[i]=e.words[i]^r.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},n.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},n.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},n.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},n.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),i=t%26;this._expand(e),i>0&&e--;for(var n=0;n<e;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},n.prototype.notn=function(t){return this.clone().inotn(t)},n.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=e?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},n.prototype.iadd=function(t){var e,r,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,i=t):(r=t,i=this);for(var n=0,o=0;o<i.length;o++)e=(0|r.words[o])+(0|i.words[o])+n,this.words[o]=67108863&e,n=e>>>26;for(;0!==n&&o<r.length;o++)e=(0|r.words[o])+n,this.words[o]=67108863&e,n=e>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},n.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},n.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,i,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,i=t):(r=t,i=this);for(var o=0,a=0;a<i.length;a++)o=(e=(0|r.words[a])-(0|i.words[a])+o)>>26,this.words[a]=67108863&e;for(;0!==o&&a<r.length;a++)o=(e=(0|r.words[a])+o)>>26,this.words[a]=67108863&e;if(0===o&&a<r.length&&r!==this)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=Math.max(this.length,a),r!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(t){return this.clone().isub(t)};var p=function(t,e,r){var i,n,o,a=t.words,s=e.words,h=r.words,u=0,l=0|a[0],c=8191&l,d=l>>>13,f=0|a[1],m=8191&f,p=f>>>13,g=0|a[2],y=8191&g,w=g>>>13,v=0|a[3],b=8191&v,k=v>>>13,M=0|a[4],_=8191&M,E=M>>>13,A=0|a[5],j=8191&A,x=A>>>13,S=0|a[6],N=8191&S,I=S>>>13,T=0|a[7],C=8191&T,z=T>>>13,O=0|a[8],R=8191&O,P=O>>>13,B=0|a[9],D=8191&B,$=B>>>13,L=0|s[0],F=8191&L,U=L>>>13,q=0|s[1],V=8191&q,H=q>>>13,G=0|s[2],Z=8191&G,K=G>>>13,J=0|s[3],W=8191&J,Y=J>>>13,Q=0|s[4],X=8191&Q,tt=Q>>>13,et=0|s[5],rt=8191&et,it=et>>>13,nt=0|s[6],ot=8191&nt,at=nt>>>13,st=0|s[7],ht=8191&st,ut=st>>>13,lt=0|s[8],ct=8191&lt,dt=lt>>>13,ft=0|s[9],mt=8191&ft,pt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(i=Math.imul(c,F))|0)+((8191&(n=(n=Math.imul(c,U))+Math.imul(d,F)|0))<<13)|0;u=((o=Math.imul(d,U))+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(m,F),n=(n=Math.imul(m,U))+Math.imul(p,F)|0,o=Math.imul(p,U);var yt=(u+(i=i+Math.imul(c,V)|0)|0)+((8191&(n=(n=n+Math.imul(c,H)|0)+Math.imul(d,V)|0))<<13)|0;u=((o=o+Math.imul(d,H)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(y,F),n=(n=Math.imul(y,U))+Math.imul(w,F)|0,o=Math.imul(w,U),i=i+Math.imul(m,V)|0,n=(n=n+Math.imul(m,H)|0)+Math.imul(p,V)|0,o=o+Math.imul(p,H)|0;var wt=(u+(i=i+Math.imul(c,Z)|0)|0)+((8191&(n=(n=n+Math.imul(c,K)|0)+Math.imul(d,Z)|0))<<13)|0;u=((o=o+Math.imul(d,K)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(b,F),n=(n=Math.imul(b,U))+Math.imul(k,F)|0,o=Math.imul(k,U),i=i+Math.imul(y,V)|0,n=(n=n+Math.imul(y,H)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,H)|0,i=i+Math.imul(m,Z)|0,n=(n=n+Math.imul(m,K)|0)+Math.imul(p,Z)|0,o=o+Math.imul(p,K)|0;var vt=(u+(i=i+Math.imul(c,W)|0)|0)+((8191&(n=(n=n+Math.imul(c,Y)|0)+Math.imul(d,W)|0))<<13)|0;u=((o=o+Math.imul(d,Y)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(_,F),n=(n=Math.imul(_,U))+Math.imul(E,F)|0,o=Math.imul(E,U),i=i+Math.imul(b,V)|0,n=(n=n+Math.imul(b,H)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,H)|0,i=i+Math.imul(y,Z)|0,n=(n=n+Math.imul(y,K)|0)+Math.imul(w,Z)|0,o=o+Math.imul(w,K)|0,i=i+Math.imul(m,W)|0,n=(n=n+Math.imul(m,Y)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,Y)|0;var bt=(u+(i=i+Math.imul(c,X)|0)|0)+((8191&(n=(n=n+Math.imul(c,tt)|0)+Math.imul(d,X)|0))<<13)|0;u=((o=o+Math.imul(d,tt)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(j,F),n=(n=Math.imul(j,U))+Math.imul(x,F)|0,o=Math.imul(x,U),i=i+Math.imul(_,V)|0,n=(n=n+Math.imul(_,H)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,H)|0,i=i+Math.imul(b,Z)|0,n=(n=n+Math.imul(b,K)|0)+Math.imul(k,Z)|0,o=o+Math.imul(k,K)|0,i=i+Math.imul(y,W)|0,n=(n=n+Math.imul(y,Y)|0)+Math.imul(w,W)|0,o=o+Math.imul(w,Y)|0,i=i+Math.imul(m,X)|0,n=(n=n+Math.imul(m,tt)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,tt)|0;var kt=(u+(i=i+Math.imul(c,rt)|0)|0)+((8191&(n=(n=n+Math.imul(c,it)|0)+Math.imul(d,rt)|0))<<13)|0;u=((o=o+Math.imul(d,it)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(N,F),n=(n=Math.imul(N,U))+Math.imul(I,F)|0,o=Math.imul(I,U),i=i+Math.imul(j,V)|0,n=(n=n+Math.imul(j,H)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,H)|0,i=i+Math.imul(_,Z)|0,n=(n=n+Math.imul(_,K)|0)+Math.imul(E,Z)|0,o=o+Math.imul(E,K)|0,i=i+Math.imul(b,W)|0,n=(n=n+Math.imul(b,Y)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,Y)|0,i=i+Math.imul(y,X)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,i=i+Math.imul(m,rt)|0,n=(n=n+Math.imul(m,it)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,it)|0;var Mt=(u+(i=i+Math.imul(c,ot)|0)|0)+((8191&(n=(n=n+Math.imul(c,at)|0)+Math.imul(d,ot)|0))<<13)|0;u=((o=o+Math.imul(d,at)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(C,F),n=(n=Math.imul(C,U))+Math.imul(z,F)|0,o=Math.imul(z,U),i=i+Math.imul(N,V)|0,n=(n=n+Math.imul(N,H)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,H)|0,i=i+Math.imul(j,Z)|0,n=(n=n+Math.imul(j,K)|0)+Math.imul(x,Z)|0,o=o+Math.imul(x,K)|0,i=i+Math.imul(_,W)|0,n=(n=n+Math.imul(_,Y)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,Y)|0,i=i+Math.imul(b,X)|0,n=(n=n+Math.imul(b,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,tt)|0,i=i+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,it)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,it)|0,i=i+Math.imul(m,ot)|0,n=(n=n+Math.imul(m,at)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,at)|0;var _t=(u+(i=i+Math.imul(c,ht)|0)|0)+((8191&(n=(n=n+Math.imul(c,ut)|0)+Math.imul(d,ht)|0))<<13)|0;u=((o=o+Math.imul(d,ut)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(R,F),n=(n=Math.imul(R,U))+Math.imul(P,F)|0,o=Math.imul(P,U),i=i+Math.imul(C,V)|0,n=(n=n+Math.imul(C,H)|0)+Math.imul(z,V)|0,o=o+Math.imul(z,H)|0,i=i+Math.imul(N,Z)|0,n=(n=n+Math.imul(N,K)|0)+Math.imul(I,Z)|0,o=o+Math.imul(I,K)|0,i=i+Math.imul(j,W)|0,n=(n=n+Math.imul(j,Y)|0)+Math.imul(x,W)|0,o=o+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=(n=n+Math.imul(_,tt)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,tt)|0,i=i+Math.imul(b,rt)|0,n=(n=n+Math.imul(b,it)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,it)|0,i=i+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,at)|0,i=i+Math.imul(m,ht)|0,n=(n=n+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var Et=(u+(i=i+Math.imul(c,ct)|0)|0)+((8191&(n=(n=n+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;u=((o=o+Math.imul(d,dt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(D,F),n=(n=Math.imul(D,U))+Math.imul($,F)|0,o=Math.imul($,U),i=i+Math.imul(R,V)|0,n=(n=n+Math.imul(R,H)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,H)|0,i=i+Math.imul(C,Z)|0,n=(n=n+Math.imul(C,K)|0)+Math.imul(z,Z)|0,o=o+Math.imul(z,K)|0,i=i+Math.imul(N,W)|0,n=(n=n+Math.imul(N,Y)|0)+Math.imul(I,W)|0,o=o+Math.imul(I,Y)|0,i=i+Math.imul(j,X)|0,n=(n=n+Math.imul(j,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,i=i+Math.imul(_,rt)|0,n=(n=n+Math.imul(_,it)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,it)|0,i=i+Math.imul(b,ot)|0,n=(n=n+Math.imul(b,at)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,at)|0,i=i+Math.imul(y,ht)|0,n=(n=n+Math.imul(y,ut)|0)+Math.imul(w,ht)|0,o=o+Math.imul(w,ut)|0,i=i+Math.imul(m,ct)|0,n=(n=n+Math.imul(m,dt)|0)+Math.imul(p,ct)|0,o=o+Math.imul(p,dt)|0;var At=(u+(i=i+Math.imul(c,mt)|0)|0)+((8191&(n=(n=n+Math.imul(c,pt)|0)+Math.imul(d,mt)|0))<<13)|0;u=((o=o+Math.imul(d,pt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(D,V),n=(n=Math.imul(D,H))+Math.imul($,V)|0,o=Math.imul($,H),i=i+Math.imul(R,Z)|0,n=(n=n+Math.imul(R,K)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,K)|0,i=i+Math.imul(C,W)|0,n=(n=n+Math.imul(C,Y)|0)+Math.imul(z,W)|0,o=o+Math.imul(z,Y)|0,i=i+Math.imul(N,X)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,tt)|0,i=i+Math.imul(j,rt)|0,n=(n=n+Math.imul(j,it)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,it)|0,i=i+Math.imul(_,ot)|0,n=(n=n+Math.imul(_,at)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,at)|0,i=i+Math.imul(b,ht)|0,n=(n=n+Math.imul(b,ut)|0)+Math.imul(k,ht)|0,o=o+Math.imul(k,ut)|0,i=i+Math.imul(y,ct)|0,n=(n=n+Math.imul(y,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var jt=(u+(i=i+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(n>>>13)|0)+(jt>>>26)|0,jt&=67108863,i=Math.imul(D,Z),n=(n=Math.imul(D,K))+Math.imul($,Z)|0,o=Math.imul($,K),i=i+Math.imul(R,W)|0,n=(n=n+Math.imul(R,Y)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,Y)|0,i=i+Math.imul(C,X)|0,n=(n=n+Math.imul(C,tt)|0)+Math.imul(z,X)|0,o=o+Math.imul(z,tt)|0,i=i+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,it)|0)+Math.imul(I,rt)|0,o=o+Math.imul(I,it)|0,i=i+Math.imul(j,ot)|0,n=(n=n+Math.imul(j,at)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,at)|0,i=i+Math.imul(_,ht)|0,n=(n=n+Math.imul(_,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,i=i+Math.imul(b,ct)|0,n=(n=n+Math.imul(b,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var xt=(u+(i=i+Math.imul(y,mt)|0)|0)+((8191&(n=(n=n+Math.imul(y,pt)|0)+Math.imul(w,mt)|0))<<13)|0;u=((o=o+Math.imul(w,pt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,i=Math.imul(D,W),n=(n=Math.imul(D,Y))+Math.imul($,W)|0,o=Math.imul($,Y),i=i+Math.imul(R,X)|0,n=(n=n+Math.imul(R,tt)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,tt)|0,i=i+Math.imul(C,rt)|0,n=(n=n+Math.imul(C,it)|0)+Math.imul(z,rt)|0,o=o+Math.imul(z,it)|0,i=i+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,at)|0,i=i+Math.imul(j,ht)|0,n=(n=n+Math.imul(j,ut)|0)+Math.imul(x,ht)|0,o=o+Math.imul(x,ut)|0,i=i+Math.imul(_,ct)|0,n=(n=n+Math.imul(_,dt)|0)+Math.imul(E,ct)|0,o=o+Math.imul(E,dt)|0;var St=(u+(i=i+Math.imul(b,mt)|0)|0)+((8191&(n=(n=n+Math.imul(b,pt)|0)+Math.imul(k,mt)|0))<<13)|0;u=((o=o+Math.imul(k,pt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(D,X),n=(n=Math.imul(D,tt))+Math.imul($,X)|0,o=Math.imul($,tt),i=i+Math.imul(R,rt)|0,n=(n=n+Math.imul(R,it)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,it)|0,i=i+Math.imul(C,ot)|0,n=(n=n+Math.imul(C,at)|0)+Math.imul(z,ot)|0,o=o+Math.imul(z,at)|0,i=i+Math.imul(N,ht)|0,n=(n=n+Math.imul(N,ut)|0)+Math.imul(I,ht)|0,o=o+Math.imul(I,ut)|0,i=i+Math.imul(j,ct)|0,n=(n=n+Math.imul(j,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var Nt=(u+(i=i+Math.imul(_,mt)|0)|0)+((8191&(n=(n=n+Math.imul(_,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,i=Math.imul(D,rt),n=(n=Math.imul(D,it))+Math.imul($,rt)|0,o=Math.imul($,it),i=i+Math.imul(R,ot)|0,n=(n=n+Math.imul(R,at)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,at)|0,i=i+Math.imul(C,ht)|0,n=(n=n+Math.imul(C,ut)|0)+Math.imul(z,ht)|0,o=o+Math.imul(z,ut)|0,i=i+Math.imul(N,ct)|0,n=(n=n+Math.imul(N,dt)|0)+Math.imul(I,ct)|0,o=o+Math.imul(I,dt)|0;var It=(u+(i=i+Math.imul(j,mt)|0)|0)+((8191&(n=(n=n+Math.imul(j,pt)|0)+Math.imul(x,mt)|0))<<13)|0;u=((o=o+Math.imul(x,pt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(D,ot),n=(n=Math.imul(D,at))+Math.imul($,ot)|0,o=Math.imul($,at),i=i+Math.imul(R,ht)|0,n=(n=n+Math.imul(R,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,i=i+Math.imul(C,ct)|0,n=(n=n+Math.imul(C,dt)|0)+Math.imul(z,ct)|0,o=o+Math.imul(z,dt)|0;var Tt=(u+(i=i+Math.imul(N,mt)|0)|0)+((8191&(n=(n=n+Math.imul(N,pt)|0)+Math.imul(I,mt)|0))<<13)|0;u=((o=o+Math.imul(I,pt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(D,ht),n=(n=Math.imul(D,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),i=i+Math.imul(R,ct)|0,n=(n=n+Math.imul(R,dt)|0)+Math.imul(P,ct)|0,o=o+Math.imul(P,dt)|0;var Ct=(u+(i=i+Math.imul(C,mt)|0)|0)+((8191&(n=(n=n+Math.imul(C,pt)|0)+Math.imul(z,mt)|0))<<13)|0;u=((o=o+Math.imul(z,pt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(D,ct),n=(n=Math.imul(D,dt))+Math.imul($,ct)|0,o=Math.imul($,dt);var zt=(u+(i=i+Math.imul(R,mt)|0)|0)+((8191&(n=(n=n+Math.imul(R,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(n>>>13)|0)+(zt>>>26)|0,zt&=67108863;var Ot=(u+(i=Math.imul(D,mt))|0)+((8191&(n=(n=Math.imul(D,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=wt,h[3]=vt,h[4]=bt,h[5]=kt,h[6]=Mt,h[7]=_t,h[8]=Et,h[9]=At,h[10]=jt,h[11]=xt,h[12]=St,h[13]=Nt,h[14]=It,h[15]=Tt,h[16]=Ct,h[17]=zt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function g(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var i=0,n=0,o=0;o<r.length-1;o++){var a=n;n=0;for(var s=67108863&i,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,c=(0|t.words[l])*(0|e.words[u]),d=67108863&c;s=67108863&(d=d+s|0),n+=(a=(a=a+(c/67108864|0)|0)+(d>>>26)|0)>>>26,a&=67108863}r.words[o]=s,i=a,a=n}return 0!==i?r.words[o]=i:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(p=m),n.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?p(this,t,e):r<63?m(this,t,e):r<1024?g(this,t,e):y(this,t,e)},n.prototype.mul=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},n.prototype.mulf=function(t){var e=new n(null);return e.words=new Array(this.length+t.length),y(this,t,e)},n.prototype.imul=function(t){return this.clone().mulTo(t,this)},n.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,a=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=a>>>26,this.words[n]=67108863&a}return 0!==i&&(this.words[n]=i,this.length++),e?this.ineg():this},n.prototype.muln=function(t){return this.clone().imuln(t)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var i=r/26|0,n=r%26;e[r]=t.words[i]>>>n&1}return e}(t);if(0===e.length)return new n(1);for(var r=this,i=0;i<e.length&&0===e[i];i++,r=r.sqr());if(++i<e.length)for(var o=r.sqr();i<e.length;i++,o=o.sqr())0!==e[i]&&(r=r.mul(o));return r},n.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var a=0;for(e=0;e<this.length;e++){var s=this.words[e]&o,h=(0|this.words[e])-s<<i;this.words[e]=h|a,a=s>>>26-i}a&&(this.words[e]=a,this.length++)}if(0!==n){for(e=this.length-1;e>=0;e--)this.words[e+n]=this.words[e];for(e=0;e<n;e++)this.words[e]=0;this.length+=n}return this._strip()},n.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},n.prototype.iushrn=function(t,e,i){var n;r("number"==typeof t&&t>=0),n=e?(e-e%26)/26:0;var o=t%26,a=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,h=i;if(n-=a,n=Math.max(0,n),h){for(var u=0;u<a;u++)h.words[u]=this.words[u];h.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=n);u--){var c=0|this.words[u];this.words[u]=l<<26-o|c>>>o,l=c&s}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(t,e,i){return r(0===this.negative),this.iushrn(t,e,i)},n.prototype.shln=function(t){return this.clone().ishln(t)},n.prototype.ushln=function(t){return this.clone().iushln(t)},n.prototype.shrn=function(t){return this.clone().ishrn(t)},n.prototype.ushrn=function(t){return this.clone().iushrn(t)},n.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26,n=1<<e;return!(this.length<=i)&&!!(this.words[i]&n)},n.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,i=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==e&&i++,this.length=Math.min(i,this.length),0!==e){var n=67108863^67108863>>>e<<e;this.words[this.length-1]&=n}return this._strip()},n.prototype.maskn=function(t){return this.clone().imaskn(t)},n.prototype.iaddn=function(t){return r("number"==typeof t),r(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},n.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},n.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},n.prototype.addn=function(t){return this.clone().iaddn(t)},n.prototype.subn=function(t){return this.clone().isubn(t)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(t,e,i){var n,o,a=t.length+i;this._expand(a);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var h=(0|t.words[n])*e;s=((o-=67108863&h)>>26)-(h/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(r(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},n.prototype._wordDiv=function(t,e){var r=(this.length,t.length),i=this.clone(),o=t,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),i.iushln(r),a=0|o.words[o.length-1]);var s,h=i.length-o.length;if("mod"!==e){(s=new n(null)).length=h+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=i.clone()._ishlnsubmul(o,1,h);0===l.negative&&(i=l,s&&(s.words[h]=1));for(var c=h-1;c>=0;c--){var d=67108864*(0|i.words[o.length+c])+(0|i.words[o.length+c-1]);for(d=Math.min(d/a|0,67108863),i._ishlnsubmul(o,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(o,1,c),i.isZero()||(i.negative^=1);s&&(s.words[c]=d)}return s&&s._strip(),i._strip(),"div"!==e&&0!==r&&i.iushrn(r),{div:s||null,mod:i}},n.prototype.divmod=function(t,e,i){return r(!t.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,e),"mod"!==e&&(o=s.div.neg()),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.iadd(t)),{div:o,mod:a}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),e),"mod"!==e&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),e),"div"!==e&&(a=s.mod.neg(),i&&0!==a.negative&&a.isub(t)),{div:s.div,mod:a}):t.length>this.length||this.cmp(t)<0?{div:new n(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new n(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new n(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,a,s},n.prototype.div=function(t){return this.divmod(t,"div",!1).div},n.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},n.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},n.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),n=t.andln(1),o=r.cmp(i);return o<0||1===n&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},n.prototype.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return e?-n:n},n.prototype.modn=function(t){return this.modrn(t)},n.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),e?this.ineg():this},n.prototype.divn=function(t){return this.clone().idivn(t)},n.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new n(1),a=new n(0),s=new n(0),h=new n(1),u=0;e.isEven()&&i.isEven();)e.iushrn(1),i.iushrn(1),++u;for(var l=i.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(c)),o.iushrn(1),a.iushrn(1);for(var m=0,p=1;0==(i.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(i.iushrn(m);m-- >0;)(s.isOdd()||h.isOdd())&&(s.iadd(l),h.isub(c)),s.iushrn(1),h.iushrn(1);e.cmp(i)>=0?(e.isub(i),o.isub(s),a.isub(h)):(i.isub(e),s.isub(o),h.isub(a))}return{a:s,b:h,gcd:i.iushln(u)}},n.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,i=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,a=new n(1),s=new n(0),h=i.clone();e.cmpn(1)>0&&i.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);for(var c=0,d=1;0==(i.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(i.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);e.cmp(i)>=0?(e.isub(i),a.isub(s)):(i.isub(e),s.isub(a))}return(o=0===e.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(t),o},n.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var i=0;e.isEven()&&r.isEven();i++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=e.cmp(r);if(n<0){var o=e;e=r,r=o}else if(0===n||0===r.cmpn(1))break;e.isub(r)}return r.iushln(i)},n.prototype.invm=function(t){return this.egcd(t).a.umod(t)},n.prototype.isEven=function(){return 0==(1&this.words[0])},n.prototype.isOdd=function(){return 1==(1&this.words[0])},n.prototype.andln=function(t){return this.words[0]&t},n.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,i=(t-e)/26,n=1<<e;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,a=i;0!==o&&a<this.length;a++){var s=0|this.words[a];o=(s+=o)>>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(t){var e,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)e=1;else{i&&(t=-t),r(t<=67108863,"Number is too big");var n=0|this.words[0];e=n===t?0:n<t?-1:1}return 0!==this.negative?0|-e:e},n.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},n.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var i=0|this.words[r],n=0|t.words[r];if(i!==n){i<n?e=-1:i>n&&(e=1);break}}return e},n.prototype.gtn=function(t){return 1===this.cmpn(t)},n.prototype.gt=function(t){return 1===this.cmp(t)},n.prototype.gten=function(t){return this.cmpn(t)>=0},n.prototype.gte=function(t){return this.cmp(t)>=0},n.prototype.ltn=function(t){return-1===this.cmpn(t)},n.prototype.lt=function(t){return-1===this.cmp(t)},n.prototype.lten=function(t){return this.cmpn(t)<=0},n.prototype.lte=function(t){return this.cmp(t)<=0},n.prototype.eqn=function(t){return 0===this.cmpn(t)},n.prototype.eq=function(t){return 0===this.cmp(t)},n.red=function(t){return new E(t)},n.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},n.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(t){return this.red=t,this},n.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},n.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},n.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},n.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},n.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},n.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},n.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},n.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},n.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new n(e,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function k(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function M(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=n._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new n(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:r.ucmp(this.p);return 0===i?(r.words[0]=0,r.length=1):i>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},i(b,v),b.prototype.split=function(t,e){for(var r=4194303,i=Math.min(t.length,9),n=0;n<i;n++)e.words[n]=t.words[n];if(e.length=i,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,n=10;n<t.length;n++){var a=0|t.words[n];t.words[n-10]=(a&r)<<4|o>>>22,o=a}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var i=0|t.words[r];e+=977*i,t.words[r]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},i(k,v),i(M,v),i(_,v),_.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var i=19*(0|t.words[r])+e,n=67108863&i;i>>>=26,t.words[r]=n,e=i}return 0!==e&&(t.words[t.length++]=e),t},n._prime=function(t){if(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new k;else if("p192"===t)e=new M;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return w[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(u(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var i=this.m.add(new n(1)).iushrn(2);return this.pow(t,i)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new n(1).toRed(this),h=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new n(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var c=this.pow(l,o),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),m=a;0!==f.cmp(s);){for(var p=f,g=0;0!==p.cmp(s);g++)p=p.redSqr();r(g<m);var y=this.pow(c,new n(1).iushln(m-g-1));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),m=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new n(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new n(1).toRed(this),r[1]=t;for(var i=2;i<r.length;i++)r[i]=this.mul(r[i-1],t);var o=r[0],a=0,s=0,h=e.bitLength()%26;for(0===h&&(h=26),i=e.length-1;i>=0;i--){for(var u=e.words[i],l=h-1;l>=0;l--){var c=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==a?(a<<=1,a|=c,(4===++s||0===i&&0===l)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}h=26}return o},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},n.mont=function(t){return new A(t)},i(A,E),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new n(0)._forceRed(this);var r=t.mul(e),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(i).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,i)}));var ZR=GR.BN;const KR=new Ut("bignumber/5.6.2"),JR={},WR=9007199254740991;let YR=!1;class QR{constructor(t,e){t!==JR&&KR.throwError("cannot call constructor directly; use BigNumber.from",Ut.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return tP(eP(this).fromTwos(t))}toTwos(t){return tP(eP(this).toTwos(t))}abs(){return"-"===this._hex[0]?QR.from(this._hex.substring(1)):this}add(t){return tP(eP(this).add(eP(t)))}sub(t){return tP(eP(this).sub(eP(t)))}div(t){return QR.from(t).isZero()&&rP("division-by-zero","div"),tP(eP(this).div(eP(t)))}mul(t){return tP(eP(this).mul(eP(t)))}mod(t){const e=eP(t);return e.isNeg()&&rP("division-by-zero","mod"),tP(eP(this).umod(e))}pow(t){const e=eP(t);return e.isNeg()&&rP("negative-power","pow"),tP(eP(this).pow(e))}and(t){const e=eP(t);return(this.isNegative()||e.isNeg())&&rP("unbound-bitwise-result","and"),tP(eP(this).and(e))}or(t){const e=eP(t);return(this.isNegative()||e.isNeg())&&rP("unbound-bitwise-result","or"),tP(eP(this).or(e))}xor(t){const e=eP(t);return(this.isNegative()||e.isNeg())&&rP("unbound-bitwise-result","xor"),tP(eP(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&rP("negative-width","mask"),tP(eP(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&rP("negative-width","shl"),tP(eP(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&rP("negative-width","shr"),tP(eP(this).shrn(t))}eq(t){return eP(this).eq(eP(t))}lt(t){return eP(this).lt(eP(t))}lte(t){return eP(this).lte(eP(t))}gt(t){return eP(this).gt(eP(t))}gte(t){return eP(this).gte(eP(t))}isNegative(){return"-"===this._hex[0]}isZero(){return eP(this).isZero()}toNumber(){try{return eP(this).toNumber()}catch(t){rP("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return KR.throwError("this platform does not support BigInt",Ut.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?YR||(YR=!0,KR.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?KR.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ut.errors.UNEXPECTED_ARGUMENT,{}):KR.throwError("BigNumber.toString does not accept parameters",Ut.errors.UNEXPECTED_ARGUMENT,{})),eP(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof QR)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new QR(JR,XR(t)):t.match(/^-?[0-9]+$/)?new QR(JR,XR(new ZR(t))):KR.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&rP("underflow","BigNumber.from",t),(t>=WR||t<=-WR)&&rP("overflow","BigNumber.from",t),QR.from(String(t));const e=t;if("bigint"==typeof e)return QR.from(e.toString());if(Kt(e))return QR.from(te(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return QR.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(Qt(t)||"-"===t[0]&&Qt(t.substring(1))))return QR.from(t)}return KR.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function XR(t){if("string"!=typeof t)return XR(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&KR.throwArgumentError("invalid hex","value",t),"0x00"===(t=XR(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function tP(t){return QR.from(XR(t))}function eP(t){const e=QR.from(t).toHexString();return"-"===e[0]?new ZR("-"+e.substring(3),16):new ZR(e.substring(2),16)}function rP(t,e,r){const i={fault:t,operation:e};return null!=r&&(i.value=r),KR.throwError(t,Ut.errors.NUMERIC_FAULT,i)}var iP=window&&window.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(n,o){function a(t){try{h(i.next(t))}catch(t){o(t)}}function s(t){try{h(i.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}h((i=i.apply(t,e||[])).next())}))};const nP=new Ut("hash/5.6.1"),oP=new Uint8Array(32);oP.fill(0);const aP=QR.from(-1),sP=QR.from(0),hP=QR.from(1),uP=QR.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const lP=oe(hP.toHexString(),32),cP=oe(sP.toHexString(),32),dP={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},fP=["name","version","chainId","verifyingContract","salt"];function mP(t){return function(e){return"string"!=typeof e&&nP.throwArgumentError(`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const pP={name:mP("name"),version:mP("version"),chainId:function(t){try{return QR.from(t).toString()}catch(t){}return nP.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return xr(t).toLowerCase()}catch(t){}return nP.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=Jt(t);if(32!==e.length)throw new Error("bad length");return te(e)}catch(t){}return nP.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function gP(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],i=parseInt(e[2]||"256");(i%8!=0||i>256||e[2]&&e[2]!==String(i))&&nP.throwArgumentError("invalid numeric width","type",t);const n=uP.mask(r?i-1:i),o=r?n.add(hP).mul(aP):sP;return function(e){const r=QR.from(e);return(r.lt(o)||r.gt(n))&&nP.throwArgumentError(`value out-of-bounds for ${t}`,"value",e),oe(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&nP.throwArgumentError("invalid bytes width","type",t),function(e){return Jt(e).length!==r&&nP.throwArgumentError(`invalid length for ${t}`,"value",e),function(t){const e=Jt(t),r=e.length%32;return r?ie([e,oP.slice(r)]):te(e)}(e)}}}switch(t){case"address":return function(t){return oe(xr(t),32)};case"bool":return function(t){return t?lP:cP};case"bytes":return function(t){return mr(t)};case"string":return function(t){return HR(t)}}return null}function yP(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}class wP{constructor(t){ve(this,"types",Object.freeze(je(t))),ve(this,"_encoderCache",{}),ve(this,"_types",{});const e={},r={},i={};Object.keys(t).forEach((t=>{e[t]={},r[t]=[],i[t]={}}));for(const i in t){const n={};t[i].forEach((o=>{n[o.name]&&nP.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(i)}`,"types",t),n[o.name]=!0;const a=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];a===i&&nP.throwArgumentError(`circular type reference to ${JSON.stringify(a)}`,"types",t);gP(a)||(r[a]||nP.throwArgumentError(`unknown type ${JSON.stringify(a)}`,"types",t),r[a].push(i),e[i][a]=!0)}))}const n=Object.keys(r).filter((t=>0===r[t].length));0===n.length?nP.throwArgumentError("missing primary type","types",t):n.length>1&&nP.throwArgumentError(`ambiguous primary types or unused types: ${n.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),ve(this,"primaryType",n[0]),function n(o,a){a[o]&&nP.throwArgumentError(`circular type reference to ${JSON.stringify(o)}`,"types",t),a[o]=!0,Object.keys(e[o]).forEach((t=>{r[t]&&(n(t,a),Object.keys(a).forEach((e=>{i[e][t]=!0})))})),delete a[o]}(this.primaryType,{});for(const e in i){const r=Object.keys(i[e]);r.sort(),this._types[e]=yP(e,t[e])+r.map((e=>yP(e,t[e]))).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=gP(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),i=parseInt(e[3]);return e=>{i>=0&&e.length!==i&&nP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let n=e.map(r);return this._types[t]&&(n=n.map(mr)),mr(ie(n))}}const r=this.types[t];if(r){const e=HR(this._types[t]);return t=>{const i=r.map((({name:e,type:r})=>{const i=this.getEncoder(r)(t[e]);return this._types[r]?mr(i):i}));return i.unshift(e),ie(i)}}return nP.throwArgumentError(`unknown type: ${t}`,"type",t)}encodeType(t){const e=this._types[t];return e||nP.throwArgumentError(`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return mr(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(gP(t))return r(t,e);const i=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(i){const t=i[1],n=parseInt(i[3]);return n>=0&&e.length!==n&&nP.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map((e=>this._visit(t,e,r)))}const n=this.types[t];return n?n.reduce(((t,{name:i,type:n})=>(t[i]=this._visit(n,e[i],r),t)),{}):nP.throwArgumentError(`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new wP(t)}static getPrimaryType(t){return wP.from(t).primaryType}static hashStruct(t,e,r){return wP.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const i=dP[r];i||nP.throwArgumentError(`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:i})}return e.sort(((t,e)=>fP.indexOf(t.name)-fP.indexOf(e.name))),wP.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return ie(["0x1901",wP.hashDomain(t),wP.from(e).hash(r)])}static hash(t,e,r){return mr(wP.encode(t,e,r))}static resolveNames(t,e,r,i){return iP(this,void 0,void 0,(function*(){t=Me(t);const n={};t.verifyingContract&&!Qt(t.verifyingContract,20)&&(n[t.verifyingContract]="0x");const o=wP.from(e);o.visit(r,((t,e)=>("address"!==t||Qt(e,20)||(n[e]="0x"),e)));for(const t in n)n[t]=yield i(t);return t.verifyingContract&&n[t.verifyingContract]&&(t.verifyingContract=n[t.verifyingContract]),r=o.visit(r,((t,e)=>"address"===t&&n[e]?n[e]:e)),{domain:t,value:r}}))}static getPayload(t,e,r){wP.hashDomain(t);const i={},n=[];fP.forEach((e=>{const r=t[e];null!=r&&(i[e]=pP[e](r),n.push({name:e,type:dP[e]}))}));const o=wP.from(e),a=Me(e);return a.EIP712Domain?nP.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):a.EIP712Domain=n,o.encode(r),{types:a,domain:i,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return te(Jt(e));if(t.match(/^u?int/))return QR.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&nP.throwArgumentError("invalid string","value",e),e}return nP.throwArgumentError("unsupported type","type",t)}))}}}window&&window.__awaiter;new Ut("wallet/5.6.2");function vP(t,e,r,i){return as(wP.hash(t,e,r),i)}const bP="6492649264926492649264926492649264926492649264926492649264926492";function kP(t,e){return t.toLowerCase()===e.toLowerCase()}function MP(t){const{domain:e,types:r,message:i}=t;return hl.hash(e,r,i)}function _P(t,e,i,n){return r(this,void 0,void 0,(function*(){let r;try{r=yield uB(n,["function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[Jt(i),e]])}catch(t){if(t.message.startsWith("missing revert data in call exception"))return!1;throw t}return kP(r,"0x1626ba7e")}))}function EP(t,e,i,n){return r(this,void 0,void 0,(function*(){return kP(yield uB(n,["function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)"],[t,"isValidSignature",[Jt(i),e]]),"0x20c13b0b")}))}var AP=Object.freeze({__proto__:null,getHash:MP,default:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){const{domain:o,types:a,message:s}=r;try{if(kP(t,vP(o,a,s,e)))return!0}catch(t){}const h=qp(i,n),u=MP(r);if(e.endsWith(bP))try{return"0x01"===(yield h.call({data:Wt(["0x60806040523480156200001157600080fd5b50604051620007003803806200070083398101604081905262000034916200056f565b6000620000438484846200004f565b9050806000526001601ff35b600080846001600160a01b0316803b806020016040519081016040528181526000908060200190933c90507f6492649264926492649264926492649264926492649264926492649264926492620000a68462000451565b036200021f57600060608085806020019051810190620000c79190620005ce565b8651929550909350915060000362000192576000836001600160a01b031683604051620000f5919062000643565b6000604051808303816000865af19150503d806000811462000134576040519150601f19603f3d011682016040523d82523d6000602084013e62000139565b606091505b5050905080620001905760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b505b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90620001c4908b90869060040162000661565b602060405180830381865afa158015620001e2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200020891906200069d565b6001600160e01b031916149450505050506200044a565b805115620002b157604051630b135d3f60e11b808252906001600160a01b03871690631626ba7e9062000259908890889060040162000661565b602060405180830381865afa15801562000277573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200029d91906200069d565b6001600160e01b031916149150506200044a565b8251604114620003195760405162461bcd60e51b815260206004820152603a6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e677468000000000000606482015260840162000187565b620003236200046b565b506020830151604080850151855186939260009185919081106200034b576200034b620006c9565b016020015160f81c9050601b81148015906200036b57508060ff16601c14155b15620003cf5760405162461bcd60e51b815260206004820152603b6024820152600080516020620006e083398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c75650000000000606482015260840162000187565b6040805160008152602081018083528a905260ff83169181019190915260608101849052608081018390526001600160a01b038a169060019060a0016020604051602081039080840390855afa1580156200042e573d6000803e3d6000fd5b505050602060405103516001600160a01b031614955050505050505b9392505050565b60006020825110156200046357600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b03811681146200049f57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620004d5578181015183820152602001620004bb565b50506000910152565b600082601f830112620004f057600080fd5b81516001600160401b03808211156200050d576200050d620004a2565b604051601f8301601f19908116603f01168101908282118183101715620005385762000538620004a2565b816040528381528660208588010111156200055257600080fd5b62000565846020830160208901620004b8565b9695505050505050565b6000806000606084860312156200058557600080fd5b8351620005928162000489565b6020850151604086015191945092506001600160401b03811115620005b657600080fd5b620005c486828701620004de565b9150509250925092565b600080600060608486031215620005e457600080fd5b8351620005f18162000489565b60208501519093506001600160401b03808211156200060f57600080fd5b6200061d87838801620004de565b935060408601519150808211156200063457600080fd5b50620005c486828701620004de565b6000825162000657818460208701620004b8565b9190910192915050565b828152604060208201526000825180604084015262000688816060850160208701620004b8565b601f01601f1916919091016060019392505050565b600060208284031215620006b057600080fd5b81516001600160e01b0319811681146200044a57600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",(new Ni).encode(["address","bytes32","bytes"],[t,Jt(u),e])])}))}catch(t){return!1}return!!(yield _P(t,e,u,h))||(yield EP(t,e,u,h))}))}});var jP=["ipfs.snapshot.box","snapshot.4everland.link","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],xP={1:{key:"1",name:"Ethereum",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolvers:["0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63","0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],ensNameWrapper:"0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/5XqPmWe6gjyrJtFn9cLy237i4cWw2j9HcUJEXsP5qGtH",rpc:["https://rpc.ankr.com/eth",{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],light:["https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:{url:"https://etherscan.io",apiUrl:"https://api.etherscan.io"},start:7929876,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},8:{key:"8",name:"Ubiq",chainId:8,network:"Ubiq",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:{url:"https://ubiqscan.io"},start:1,logo:"ipfs://Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"OP Mainnet",chainId:10,network:"OP Mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:{url:"https://optimistic.etherscan.io",apiUrl:"https://api-optimistic.etherscan.io"},start:657806,logo:"ipfs://bafkreifu2remiqfpsb4hgisbwb3qxedrzpwsea7ik4el45znjcf56xf2ku"},19:{key:"19",name:"Songbird Canary-Network",shortName:"Songbird",chainId:19,network:"songbird",multicall:"0x17032Ea9c3a13Ed337665145364c0d2aD1108c91",rpc:["https://songbird-api.flare.network/ext/C/rpc"],explorer:{url:"https://songbird-explorer.flare.network"},start:21807126,logo:"ipfs://QmXyvnrZY8FUxSULfnKKA99sAEkjAHtvhRx5WeHixgaEdu"},24:{key:"24",name:"KardiaChain Mainnet",shortName:"KAI",chainId:24,network:"mainnet",multicall:"0xd9c92F2287B7802A37eC9BEce96Aa65fb5f31E1b",rpc:["https://kai-internal.kardiachain.io"],explorer:{url:"https://explorer.kardiachain.io"},start:8260245,logo:"ipfs://bafkreig73yfyqzbxydv6e3dbj5nks3f57px2iez7tywayey4rilfhhrr34"},25:{key:"25",name:"Cronos",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:{url:"https://cronos.crypto.org/explorer"},start:4067,logo:"ipfs://QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:{url:"https://explorer.rsk.co"},start:2516442,logo:"ipfs://QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},46:{key:"46",name:"Darwinia Network",shortName:"Darwinia",chainId:46,network:"mainnet",multicall:"0x67f9ae42EaA9a8aBf065D60ec6Ab3C1A11370607",rpc:["https://rpc.darwinia.network"],explorer:{url:"https://darwinia.subscan.io"},start:141853,logo:"ipfs://bafkreicf55maidhx46pyu3mwsshlr43xbewr6tkckkonh4nesbkp7krwkm"},56:{key:"56",name:"BNB Smart Chain",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://rpc.ankr.com/bsc","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org"],explorer:{url:"https://bscscan.com"},start:461230,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},61:{key:"61",name:"Ethereum Classic",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"0x51be3a92C56ae7E207C5b5Fd87F7798Ce82C1AC2",rpc:["https://www.ethercluster.com/etc"],explorer:{url:"https://blockscout.com/etc/mainnet"},start:13307544,logo:"ipfs://QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},66:{key:"66",name:"OKExChain",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:{url:"https://www.oklink.com/okexchain"},start:5076543,logo:"ipfs://Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},75:{key:"75",name:"Decimal",shortName:"mainnet",chainId:75,network:"mainnet",multicall:"0x949d1A0757803C51F2EfFFEb5472C861A898B8E8",rpc:[],explorer:{url:"https://explorer.decimalchain.com"},start:16031065,logo:"ipfs://bafkreihkdhbce5rkogl63xegaarlirjrvbfarxbtbf5mqme3s5grvbjyxm"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:{url:"https://blockscout.com/shibuya"},start:856303,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:{url:"https://scan.meter.io"},start:4992871,logo:"ipfs://QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"BNB Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://data-seed-prebsc-1-s1.binance.org:8545","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive"],explorer:{url:"https://testnet.bscscan.com"},start:3599656,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://gno.getblock.io/mainnet/6c1d1e6e-75d9-452f-a863-a694bff93d5c/","https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],light:["https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:{url:"https://gnosis.blockscout.com"},start:4108192,logo:"ipfs://QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},108:{key:"108",name:"Thundercore",chainId:108,network:"mainnet",multicall:"0x3017086deef56679e267f67f66c4415109b7a97f",rpc:["https://mainnet-rpc.thundercore.com/archived/SNAPSHOTEuR82a75fLYA"],explorer:{url:"https://viewblock.io/thundercore"},start:94425385,logo:"ipfs://bafkreifc5z5vtvqx2luzgateyvoocwpd2ifv2hwufxdnyl2a767wa6icli"},109:{key:"109",name:"Shibarium",shortName:"mainnet",chainId:109,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://shibariumscan.io"},start:3485946,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm"},122:{key:"122",name:"Fuse",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://explorer-node.fuse.io/","https://oefusefull1.liquify.info/"],explorer:{url:"https://explorer.fuse.io"},start:11923459,logo:"ipfs://QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},137:{key:"137",name:"Polygon PoS",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://rpc.ankr.com/polygon","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive","https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e"],ws:["wss://ws-mainnet.matic.network"],explorer:{url:"https://polygonscan.com",apiUrl:"https://api.polygonscan.com"},start:9834491,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},144:{key:"144",name:"PHI Network",shortName:"PHI",chainId:144,network:"mainnet",multicall:"0xc2f41B404a6757863AAeF49ff93039421acCd630",rpc:["https://connect.phi.network"],explorer:{url:"https://phiscan.com"},start:360030,logo:"ipfs://bafkreid6pm3mic7izp3a6zlfwhhe7etd276bjfsq2xash6a4s2vmcdf65a"},146:{key:"146",name:"Sonic",shortName:"mainnet",chainId:146,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.soniclabs.com"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44"},148:{key:"148",name:"ShimmerEVM",shortName:"ShimmerEVM",chainId:148,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.evm.shimmer.network"},start:1290,logo:"ipfs://bafkreib4xhbgbhrwkmizp4d4nz3wzbpyhdm6wpz2v2pbkk7jxsgg3hdt74"},157:{key:"157",name:"Shibarium Puppynet Testnet",shortName:"testnet",chainId:157,network:"testnet",multicall:"0xA4029b74FBA366c926eDFA7Dd10B21C621170a4c",rpc:[],explorer:{url:"https://puppyscan.shib.io"},start:3035769,logo:"ipfs://bafkreig57igai5phg4icywc5yoockd52jo3hlvbkyi6wiufrmu4p2lmenm",testnet:!0},169:{key:"169",name:"Manta Pacific",shortName:"Manta",chainId:169,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.oklink.com/manta"},start:332890,logo:"ipfs://bafkreibbrwgwdcfh755dqh4ndta6tja77qbaa36bfv4pstub6prhhore7a"},204:{key:"204",name:"opBNB",shortName:"mainnet",chainId:204,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"http://opbnbscan.com"},start:512881,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:{url:"https://explorer.energyweb.org"},start:12086501,logo:"ipfs://Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ankr.com/fantom","https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:{url:"https://ftmscan.com"},start:2497732,logo:"ipfs://QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},252:{key:"252",name:"Fraxtal",shortName:"mainnet",chainId:252,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu"},269:{key:"269",name:"High Performance Blockchain",shortName:"HPB",chainId:269,network:"mainnet",multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:{url:"https://hscan.org"},start:13960096,logo:"ipfs://QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},296:{key:"296",name:"Hedera Testnet",shortName:"testnet",chainId:296,network:"testnet",multicall:"0xADE3166b0afA89b2CDB64870D70ADeD330Eab015",rpc:[],explorer:{url:"https://hashscan.io/testnet"},start:17561901,logo:"ipfs://bafkreia5gpitwgo4sspvvtwqcxosq2krrqo5dbrnvylgibvmypzotfmbuu",testnet:!0},300:{key:"300",name:"zkSync Sepolia Testnet",shortName:"testnet",chainId:300,network:"testnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:[],explorer:{url:"https://sepolia.explorer.zksync.dev"},start:2292,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy",testnet:!0},314:{key:"314",name:"Filecoin",shortName:"mainnet",chainId:314,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://filfox.io"},start:3328594,logo:"ipfs://bafybeibyvjfmk6aqlfdrczvth55jkmnoadtrch7ht3rdmvqmy2bfxynecm"},321:{key:"321",name:"KCC",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:{url:"https://explorer.kcc.io"},start:1487453,logo:"ipfs://QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},324:{key:"324",name:"zkSync Era",shortName:"zkSync-era",chainId:324,network:"zkSync Era Mainnet",multicall:"0xF9cda624FBC7e059355ce98a31693d299FACd963",rpc:["https://mainnet.era.zksync.io"],explorer:{url:"https://explorer.zksync.io"},start:3908235,logo:"ipfs://bafkreih6y7ri7h667cwxe5miisxghfheiidtbw2747y75stoxt3gp3a2yy"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:{url:"https://blockscout.com/shiden"},start:1170016,logo:"ipfs://QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},369:{key:"369",name:"Pulsechain",shortName:"Pulsechain",chainId:369,network:"mainnet",multicall:"0xdbdd0FD8B16F0092f306392b699D7fbddaA9011B",rpc:["https://rpc.pulsechain.com"],explorer:{url:"https://scan.pulsechain.com"},start:17657774,logo:"ipfs://QmWUsiEWdejtHZ9B9981TYXn7Ds8C7fkB1S4h5rP3kCCZR"},416:{key:"416",name:"SX Network",shortName:"SX",chainId:416,network:"mainnet",multicall:"0x834a005DDCF990Ba1a79f259e840e58F2D14F49a",rpc:["https://rpc.sx.technology"],ws:["wss://rpc.sx.technology/ws"],explorer:{url:"https://explorer.sx.technology"},start:2680605,logo:"ipfs://QmSXLXqyr2H6Ja5XrmznXbWTEvF2gFaL8RXNXgyLmDHjAF"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://astar.api.onfinality.io/public","https://rpc.astar.network:8545"],explorer:{url:"https://blockscout.com/astar"},start:366482,logo:"ipfs://QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},813:{key:"813",name:"Qitmeer",shortName:"MEER",chainId:813,network:"mainnet",multicall:"0x55034b2cF530ae3A8fC1e2e4523F58496796610F",rpc:["https://evm-dataseed1.meerscan.io","https://evm-dataseed.meerscan.com","https://evm-dataseed2.meerscan.io","https://evm-dataseed3.meerscan.io"],explorer:{url:"https://evm.meerscan.io"},start:43317,logo:"ipfs://QmXvum7SNVaAqAc2jNzR1NpNZN1GGvNaKWydg8a1GEDQ7y"},841:{key:"841",name:"Taraxa",shortName:"841",chainId:841,network:"mainnet",multicall:"0xFCe7a3121B42664AaD145712e1c2Bf2e38f60AA1",rpc:["https://rpc.mainnet.taraxa.io"],ws:["wss://ws.mainnet.taraxa.io"],explorer:{url:"https://mainnet.explorer.taraxa.io"},start:1515906,logo:"ipfs://Qmcc6ZCAGESMzZzoj5LsTVcCo2E35x3Ydk71uPJyov6Mwx"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:{url:"https://www.wanscan.org"},start:11302663,logo:"ipfs://QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},1001:{key:"1001",name:"Kaia Kairos Testnet",shortName:"kaia-kairos",chainId:1001,network:"testnet",testnet:!0,multicall:"0x40643B8Aeaaca0b87Ea1A1E596e64a0e14B1d244",rpc:["https://archive-en-kairos.node.kaia.io"],ws:["wss://archive-en-kairos.node.kaia.io/ws"],explorer:{url:"https://kairos.kaiascan.com"},start:87232478,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},1072:{key:"1072",name:"Shimmer EVM Testnet",shortName:"ShimmerEVM",chainId:1072,network:"testnet",testnet:!0,multicall:"0x751d21047C116413895c259f3f305e38C10B7cF6",rpc:["https://archive.evm.testnet.shimmer.network/v1/chains/rms1pr75wa5xuepg2hew44vnr28wz5h6n6x99zptk2g68sp2wuu2karywgrztx3/evm"],explorer:{url:"https://explorer.evm.testnet.shimmer.network"},start:10614,logo:"ipfs://bafkreihtwfwrue7klzedwx4rqlk6agklz4lbbk7owsyw6xzn6c2m4t5tgy"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:{url:"https://andromeda-explorer.metis.io"},start:451,logo:"ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"},1101:{key:"1101",name:"Polygon zkEVM",shortName:"mainnet",chainId:1101,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://zkevm.polygonscan.com"},start:57746,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm"},1116:{key:"1116",name:"Core Chain",shortName:"Core",chainId:1116,network:"mainnet",multicall:"0x024f0041b76B598c2A0a75004F8447FaF67BD004",rpc:["https://rpcar.coredao.org/"],explorer:{url:"https://scan.coredao.org"},start:853908,logo:"ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:{url:"https://moonscan.io"},start:171135,logo:"ipfs://QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:{url:"https://blockscout.moonriver.moonbeam.network"},start:413539,logo:"ipfs://QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:{url:"https://moonbase-blockscout.testnet.moonbeam.network"},start:859041,logo:"ipfs://QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},1315:{key:"1315",name:"Story Aeneid Testnet",shortName:"testnet",chainId:1315,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://aeneid.storyscan.io"},start:1792,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne",testnet:!0},1328:{key:"1328",name:"Sei atlantic testnet",shortName:"testnet",chainId:1328,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://seitrace.com"},start:96978658,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},1329:{key:"1329",name:"Sei",shortName:"mainnet",chainId:1329,network:"mainnet",multicall:"0xe033Bed7cae4114Af84Be1e9F1CA7DEa07Dfe1Cf",rpc:[],explorer:{url:"https://seitrace.com"},start:79164574,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq"},1480:{key:"1480",name:"Vana",shortName:"mainnet",chainId:1480,network:"mainnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://islander.vanascan.io"},start:716763,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa"},1514:{key:"1514",name:"Story",shortName:"mainnet",chainId:1514,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://www.storyscan.io"},start:340998,logo:"ipfs://bafkreiaicdywqkmej6htv4e4lnq5fzajb3qfoxslkrbf5byvqc2aalxcne"},1559:{key:"1559",name:"Tenet",shortName:"tenet",chainId:1559,network:"mainnet",multicall:"0xcCB3F00bE353950E4C08501ac8Af48765EAAa738",rpc:[],explorer:{url:"https://tenetscan.io"},start:944415,logo:"ipfs://Qmc1gqjWTzNo4pyFSGtQuCu7kRSZZBUVybtTjHn2nNEEPA"},1663:{key:"1663",name:"Horizen Gobi Testnet",shortName:"Gobi",chainId:1663,network:"testnet",testnet:!0,multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:["https://gobi-testnet.horizenlabs.io/ethv1"],explorer:{url:"https://gobi-explorer.horizen.io"},start:1,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},2e3:{key:"2000",name:"Doge Chain",shortName:"dogechain",chainId:2e3,network:"mainnet",multicall:"0x6f9D3f3932B417bd4957585D236Cbc32b32C0BDc",rpc:["https://rpc.dogechain.dog"],explorer:{url:"https://explorer.dogechain.dog"},start:877115,logo:"ipfs://bafkreigovfh3pinsdih777issfgaflwu2yjzroljs2642gbvwikcd3nm4i"},2109:{key:"2109",name:"Exosama Network",shortName:"EXN",chainId:2109,network:"mainnet",multicall:"0x2feFC828e2fEfdE0C9f7740919c6A9139F886067",rpc:["https://rpc.exosama.com"],explorer:{url:"https://explorer.exosama.com"},start:94085,logo:"ipfs://QmaQxfwpXYTomUd24PMx5tKjosupXcm99z1jL1XLq9LWBS"},2152:{key:"2152",name:"Findora",shortName:"Findora",chainId:2152,network:"mainnet",multicall:"0xCF7D1e21CBe9bdEF235aef06C5d8051B3d4DF0f5",rpc:["https://archive.prod.findora.org:8545/"],explorer:{url:"https://evm.findorascan.io"},start:4219343,logo:"ipfs://QmXkneyRB6HbHTHRLCZpZqSsawiyJY7b2kZ2V8ydvKYAgv"},2192:{key:"2192",name:"SnaxChain",shortName:"mainnet",chainId:2192,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.snaxchain.io"},start:1554893,logo:"ipfs://bafkreibzz757piho2llzkbiszpvalf5k5hpmxcwhvrmgp7vpz2vp4vj7ly"},2221:{key:"2221",name:"Kava Testnet",shortName:"testnet",chainId:2221,network:"testnet",multicall:"0xc7193EFE367DF0C9349a1149F4E95A2A35604262",rpc:[],explorer:{url:"https://testnet.kavascan.com"},start:6193104,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4",testnet:!0},2222:{key:"2222",name:"Kava",shortName:"mainnet",chainId:2222,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://kavascan.com"},start:3661165,logo:"ipfs://bafkreibpfubharx32fjqkqbfdhygwdjb2khxdg6meaasrcxsgvowos26f4"},2400:{key:"2400",name:"TCG Verse",shortName:"TCGV",chainId:2400,network:"mainnet",multicall:"0xceC65DEE0b5012F1b7321b2647681F997c7204FC",rpc:["https://rpc.tcgverse.xyz"],explorer:{url:"https://explorer.tcgverse.xyz"},start:57500,logo:"ipfs://bafkreidg4wpewve5mdxrofneqblydkrjl3oevtgpdf3fk3z3vjqam6ocoe"},2522:{key:"2522",name:"Fraxtal Testnet",shortName:"testnet",chainId:2522,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://holesky.fraxscan.com"},start:1,logo:"ipfs://bafkreieflj4wq6tx7k5kq47z3xnsrdrn2xgm4bxa3uovrnndcb2vqqwlyu",testnet:!0},3338:{key:"3338",name:"peaq",shortName:"mainnet",chainId:3338,network:"mainnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://peaq.subscan.io"},start:3525964,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm"},4162:{key:"4162",name:"SX Rollup",shortName:"mainnet",chainId:4162,network:"mainnet",multicall:"0x46997eb05F6A6A0bD5C140ABed09Cb02CA36b98c",rpc:[],explorer:{url:"https://explorerl2.sx.technology"},start:1847483,logo:"ipfs://bafkreibjkjx7evbw74e3sx65dtmcdr4g2rrbcorb2ivd6jz6yh6on6ozw4"},4200:{key:"4200",name:"Merlin",shortName:"merlin",chainId:4200,network:"mainnet",multicall:"0x830E7E548F4D80947a40A7Cf3a2a53166a0C3980",rpc:[],explorer:{url:"https://scan.merlinchain.io"},start:589494,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe"},4337:{key:"4337",name:"Beam",shortName:"Beam",chainId:4337,network:"mainnet",multicall:"0x4956F15eFdc3dC16645e90Cc356eAFA65fFC65Ec",rpc:[],explorer:{url:"https://subnets.avax.network/beam"},start:1,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF"},4689:{key:"4689",name:"IoTeX",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:{url:"https://iotexscan.io"},start:11533283,logo:"ipfs://QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5e3:{key:"5000",name:"Mantle",chainId:5e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.mantle.xyz"],explorer:{url:"https://mantlescan.xyz"},start:304717,logo:"ipfs://bafkreidkucwfn4mzo2gtydrt2wogk3je5xpugom67vhi4h4comaxxjzoz4"},5555:{key:"5555",name:"Chain Verse",shortName:"ChainVerse",chainId:5555,network:"ChainVerse",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://rpc.chainverse.info"],explorer:{url:"https://explorer.chainverse.info"},start:6334180,logo:"ipfs://QmQyJt28h4wN3QHPXUQJQYQqGiFUD77han3zibZPzHbitk"},5611:{key:"5611",name:"opBNB Testnet",shortName:"testnet",chainId:5611,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://opbnb-testnet.bscscan.com"},start:3705108,logo:"ipfs://bafkreibll4la7wqerzs7zwxjne2j7ayynbg2wlenemssoahxxj5rbt6c64",testnet:!0},6102:{key:"6102",name:"Cascadia Testnet",shortName:"Cascadia",chainId:6102,network:"testnet",multicall:"0x728989819bAD588F193563008E0a03E8cD6a3e4a",rpc:["https://testnet.cascadia.foundation"],explorer:{url:"https://explorer.cascadia.foundation"},testnet:!0,start:370457,logo:"ipfs://QmWkhZYhReYyaa5pQXj32hEGxoRcBqarFMcfQScELmjYQj"},6900:{key:"6900",name:"Animechain Testnet",shortName:"testnet",chainId:6900,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-testnet-i8yja6a1a0.t.conduit.xyz"},start:1666749,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi",testnet:!0},7332:{key:"7332",name:"Horizen EON",shortName:"EON",chainId:7332,network:"mainnet",multicall:"0xC743e4910Bdd4e5aBacCA38F74cdA270281C5eef",rpc:[],explorer:{url:"https://eon-explorer.horizenlabs.io"},start:85108,logo:"ipfs://QmUYQdsnkUoiDiQ3WaWrtH7fsc5yQDC7kZJCHmC2qWPTPt"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:{url:"https://bx.shyft.network"},start:3673983,logo:"ipfs://bafkreifwxnnfk6koabzmxgcxcwlrwt6b5gijdain2gyqee77q4ajfb7fu4"},7560:{key:"7560",name:"Cyber",shortName:"mainnet",chainId:7560,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://cyberscan.co"},start:1731707,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm"},8217:{key:"8217",name:"Kaia Mainnet",shortName:"kaia-mainnet",chainId:8217,network:"mainnet",multicall:"0x5f5f0d1b9ff8b3dcace308e39b13b203354906e9",rpc:["https://archive-en.node.kaia.io"],ws:["wss://archive-en.node.kaia.io/ws"],explorer:{url:"https://kaiascan.com"},start:91582357,logo:"ipfs://bafkreifm6l67f4blcv7qwuszalwoxzptt5ad2f3t472lytr3d2hmi626ju"},8453:{key:"8453",name:"Base",shortName:"mainnet",chainId:8453,network:"mainnet",multicall:"0xca11bde05977b3631167028862be2a173976ca11",rpc:[],explorer:{url:"https://basescan.org"},start:5022,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv"},9001:{key:"9001",name:"Evmos Network",shortName:"Evmos",chainId:9001,network:"mainnet",multicall:"0x37763d16f8dBf6F185368E0f256350cAb7E24b26",rpc:["https://eth.bd.evmos.org:8545"],ws:["wss://eth.bd.evmos.org:8546"],explorer:{url:"https://escan.live"},start:13959539,logo:"ipfs://bafkreif4obrdoiretpozdd56seziywc6clha7wwkbldng3ovry2bpzly34"},9990:{key:"9990",name:"Agung testnet",shortName:"testnet",chainId:9990,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://agung-testnet.subscan.io"},start:2031789,logo:"ipfs://bafkreidqkleori7pmilesz4t52iebebaqf3oflzmoz646qfuaznanb3sgm",testnet:!0},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:{url:"https://smartbch-explorer.web.app"},start:268248,logo:"ipfs://QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},10243:{key:"10243",name:"Arthera Testnet",shortName:"Arthera_",chainId:10243,network:"testnet",testnet:!0,multicall:"0x27c7FC597aD2E81C4c1cA1769972f79DaF042Da7",rpc:["https://rpc-test.arthera.net"],explorer:{url:"https://explorer-test.arthera.net"},start:10523,logo:"ipfs://QmYQp3e52KjkT4bYdAvB6ACEEpXs2D8DozsDitaADRY2Ak"},13337:{key:"13337",name:"Beam Testnet",shortName:"testnet",chainId:13337,network:"testnet",multicall:"0x9BF49b704EE2A095b95c1f2D4EB9010510c41C9E",rpc:[],explorer:{url:"https://subnets-test.avax.network/beam"},start:3,logo:"ipfs://QmaKRLxXPdeTsLx7MFLS3CJbhpSbResgoeL4fCgHB1mTsF",testnet:!0},13371:{key:"13371",name:"Immutable zkEVM",shortName:"mainnet",chainId:13371,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.immutable.com"},start:3680945,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi"},13473:{key:"13473",name:"Immutable zkEVM Testnet",shortName:"testnet",chainId:13473,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.testnet.immutable.com"},start:5307209,logo:"ipfs://bafkreiepnhfv3hgexddjpyaeemxo3byhtxxit6t4zsponyczee6ddjqxwi",testnet:!0},14800:{key:"14800",name:"Vana Moksha Testnet",shortName:"testnet",chainId:14800,network:"testnet",multicall:"0xD8d2dFca27E8797fd779F8547166A2d3B29d360E",rpc:[],explorer:{url:"https://moksha.vanascan.io"},start:732283,logo:"ipfs://bafkreibotel3dmc5og5rf3tpt7l74awkene7x6q3oxtwhptt4y4rpa7vsa",testnet:!0},16718:{key:"16718",name:"AirDAO",chainId:16718,network:"mainnet",multicall:"0x25e81aC81A8B03389D78CB45faB78353aB528574",rpc:["https://network-archive.ambrosus.io"],ws:["wss://network-archive.ambrosus.io/ws"],explorer:{url:"https://airdao.io/explorer"},start:22922566,logo:"ipfs://QmSxXjvWng3Diz4YwXDV2VqSPgMyzLYBNfkjJcr7rzkxom"},29548:{key:"29548",name:"MCH Verse",shortName:"mainnet",chainId:29548,network:"mainnet",multicall:"0x1d39652386488CE1fE4254E105F5A42a04d43dB2",rpc:[],explorer:{url:"https://explorer.oasys.mycryptoheroes.net"},start:27458402,logo:"ipfs://QmZZnwR1y6cU1sare2TQmwqkNDLXQxD4GdPrmHLmUoPtbU"},33111:{key:"33111",name:"Curtis",shortName:"apechain",chainId:33111,network:"testnet",multicall:"0xc454132B017b55b427f45078E335549A7124f5f7",rpc:[],explorer:{url:"https://curtis.apescan.io"},start:6661339,logo:"ipfs://bafkreicljxttjq2xkgfwwpii5xegirgq2ctrnsjnzelxudjj33qzq65apu",testnet:!0},33139:{key:"33139",name:"ApeChain",shortName:"mainnet",chainId:33139,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://apescan.io"},start:20889,logo:"ipfs://bafkreielbgcox2jsw3g6pqulqb7pyjgx7czjt6ahnibihaij6lozoy53w4"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://rpc.ankr.com/arbitrum","https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/arbitrum/mainnet","https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:{url:"https://arbiscan.io"},start:256508,logo:"ipfs://QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42170:{key:"42170",name:"Arbitrum Nova",chainId:42170,network:"Arbitrum Nova",multicall:"0x4E74EBd9CABff51cE9a43EFe059bA8c5A28E4A14",rpc:["https://nova.arbitrum.io/rpc","https://arbitrum-nova.public.blastapi.io"],explorer:{url:"https://nova.arbiscan.io"},start:6006607,logo:"ipfs://bafkreie5xsqt3mrrwu7v32qpmmctibhzhgxf4emfzzddsdhdlfsa7fmplu"},42220:{key:"42220",name:"Celo",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:{url:"https://explorer.celo.org"},start:6599803,logo:"ipfs://QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},43113:{key:"43113",name:"Avalanche FUJI Testnet",chainId:43113,network:"testnet",testnet:!0,multicall:"0x984476ea55e32e785A9D8FF14329f99D74E3d2A2",rpc:["https://api.avax-test.network/ext/bc/C/rpc"],explorer:{url:"https://testnet.snowtrace.io"},start:10528153,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:{url:"https://snowtrace.io"},start:536483,logo:"ipfs://QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:{url:"https://scan.rei.network"},start:1715902,logo:"ipfs://QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},53935:{key:"53935",name:"DFK Chain",chainId:53935,network:"mainnet",multicall:"0x5b24224dC16508DAD755756639E420817DD4c99E",rpc:["https://subnets.avax.network/defi-kingdoms/dfk-chain/rpc"],explorer:{url:"https://subnets.avax.network/defi-kingdoms"},start:62,logo:"ipfs://QmZNkpVgPbuVbDcsi6arwH1om3456FGnwfDqYQJWUfHDEx"},57054:{key:"57054",name:"Sonic Blaze Testnet",shortName:"testnet",chainId:57054,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://testnet.sonicscan.org"},start:60,logo:"ipfs://bafkreic5fffatwy2gzf6y5iymje6ijii43tz4wlxl35da36guurhibjx44",testnet:!0},57073:{key:"57073",name:"Ink",shortName:"mainnet",chainId:57073,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer.inkonchain.com"},start:6659154,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju"},59141:{key:"59141",name:"Linea Sepolia",shortName:"testnet",chainId:59141,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.lineascan.build"},start:227427,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce",testnet:!0},59144:{key:"59144",name:"Linea",shortName:"linea",chainId:59144,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://lineascan.build"},start:42,logo:"ipfs://bafkreihtyzolub3sejuwc32hpdpjnt7ksowaguni2yuho3kyihhcqrtqce"},69e3:{key:"69000",name:"Animechain",shortName:"mainnet",chainId:69e3,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-animechain-39xf6m45e3.t.conduit.xyz"},start:23482,logo:"ipfs://bafkreihm7dy6jzkd3nh6mokq4vshuzwkoeyjmbb3qkskn77rt5iufn7egi"},80001:{key:"80001",name:"Polygon Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://speedy-nodes-nyc.moralis.io/9e03baabdc27be2a35bdec4a/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:{url:"https://mumbai.polygonscan.com",apiUrl:"https://api-mumbai.polygonscan.com"},start:12011090,logo:"ipfs://bafkreihgr7zy7vi5kqddybfaezwuhvssg57qluwmyan4qq7l57nr7w7wey"},80002:{key:"80002",name:"Polygon Amoy Testnet",shortName:"testnet",chainId:80002,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://amoy.polygonscan.com"},start:3127388,logo:"ipfs://bafkreibfiyvhqnme2vbxxfcku7qkxgjpkg6ywdkplxh4oxlkqsbznyorfm",testnet:!0},81457:{key:"81457",name:"Blast",shortName:"mainnet",chainId:81457,network:"mainnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://blastscan.io"},start:88189,logo:"ipfs://bafkreicqhrimt2zyp2kvhmbpvffxlmxovkg5vw6zkissyzibcfy45kbvrm"},84532:{key:"84532",name:"Base Sepolia",shortName:"testnet",chainId:84532,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://base-sepolia.blockscout.com"},start:1059647,logo:"ipfs://QmaxRoHpxZd8PqccAynherrMznMufG6sdmHZLihkECXmZv",testnet:!0},314159:{key:"314159",name:"Filecoin Calibration Testnet",shortName:"testnet",chainId:314159,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://calibration.filscan.io/en"},start:1446201,logo:"ipfs://bafkreiffbopdjior7li3nlemzko7rjua6wd2hfh2vhdbenqbv4tfsbnzwu",testnet:!0},686868:{key:"686868",name:"Merlin Testnet",shortName:"merlin",chainId:686868,network:"testnet",multicall:"0x758BC6321b7c68F4986d62a4D46E83A2DCb58c80",rpc:[],explorer:{url:"https://testnet-scan.merlinchain.io"},start:3562021,logo:"ipfs://bafkreicew2qv3m756m7xs2nrjezinghps7rlessrqjqetvox74w4hov2xe",testnet:!0},713715:{key:"713715",name:"Sei EVM Devnet",shortName:"devnet",chainId:713715,network:"testnet",multicall:"0xEe8d287B844959ADe40d718Dc23077ba920e2f07",rpc:[],explorer:{url:"https://seitrace.com"},start:1463669,logo:"ipfs://bafkreiammyt7uztbztqbcqv4bydnczsh2fqmnjf6jxj4xnskzzl6sjrigq",testnet:!0},763373:{key:"763373",name:"Ink Sepolia",shortName:"testnet",chainId:763373,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://explorer-sepolia.inkonchain.com"},start:9701940,logo:"ipfs://bafkreics2duafru4mw36wftcmklgrsgq6fz4lgcjctzmov34bxjzuuypju",testnet:!0},810180:{key:"810180",name:"zkLink Nova",shortName:"zlink",chainId:810180,network:"mainnet",multicall:"0x825267E0fA5CAe92F98540828a54198dcB3Eaeb5",rpc:[],explorer:{url:"https://explorer.zklink.io"},start:146055,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74"},810181:{key:"810181",name:"zkLink Nova Sepolia",shortName:"testnet",chainId:810181,network:"testnet",multicall:"0x97148F8fDdd9A1620f72EC1Bb2932916623d9da5",rpc:[],explorer:{url:"https://sepolia.explorer.zklink.io"},start:43723,logo:"ipfs://bafkreic6c3iems5235qapyhyrygha7akqrsfact2nok3y2uhljpzxrdu74",testnet:!0},11155111:{key:"11155111",name:"Sepolia testnet",shortName:"Sepolia",chainId:11155111,network:"sepolia",testnet:!0,multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:["https://sepolia.infura.io/v3/d26b4fd748814fe994b05899fd89e667"],ensResolvers:["0x8FADE66B79cC9f707aB26799354482EB93a5B7dD"],ensNameWrapper:"0x0635513f179D50A207757E05759CbD106d7dFcE8",ensSubgraph:"https://subgrapher.snapshot.org/subgraph/arbitrum/DmMXLtMZnGbQXASJ7p1jfzLUbBYnYUD9zNBTxpkjHYXV",explorer:{url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io"},start:751532,logo:"ipfs://bafkreid7ndxh6y2ljw2jhbisodiyrhcy2udvnwqgon5wgells3kh4si5z4"},11155420:{key:"11155420",name:"OP Sepolia",shortName:"testnet",chainId:11155420,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia-optimism.etherscan.io"},start:1620204,logo:"ipfs://QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb",testnet:!0},111557560:{key:"111557560",name:"Cyber Testnet",shortName:"testnet",chainId:111557560,network:"testnet",multicall:"0xffc391F0018269d4758AEA1a144772E8FB99545E",rpc:[],explorer:{url:"https://testnet.cyberscan.co"},start:304545,logo:"ipfs://bafkreifm2bbehoqpz4454o7gixnxfi6cgvqlxigqr3f6ipj7l2omtgfgnm",testnet:!0},168587773:{key:"168587773",name:"Blast Sepolia",shortName:"testnet",chainId:168587773,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://sepolia.blastexplorer.io"},start:756690,logo:"ipfs://bafkreibfmkjg22cozxppzcoxswj45clvh2rqhxzax57cmmgudbtkf4dkce",testnet:!0},245022926:{key:"245022926",name:"Neon Devnet",shortName:"devnet",chainId:245022926,network:"testnet",multicall:"0xcA11bde05977b3631167028862bE2a173976CA11",rpc:[],explorer:{url:"https://devnet.neonscan.org"},start:205206112,logo:"ipfs://QmecRPQGa4bU7tybg1sUQY48Md9rWnmhrT6WW5ueqvhg6P",testnet:!0},1313161554:{key:"1313161554",name:"Aurora",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:{url:"https://explorer.mainnet.aurora.dev"},start:57190533,logo:"ipfs://QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:{url:"https://explorer.harmony.one"},start:10911984,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:{url:"https://explorer.pops.one"},start:7521509,logo:"ipfs://QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"}};class SP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"number"==typeof t&&void 0!==(null==e?void 0:e[t-1])}getValidVotes(){return this.votes.filter((t=>SP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>{const r=this.getValidVotes().filter((t=>t.choice===e+1));return r.reduce(((t,e)=>t+e.balance),0)}))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>{const r=this.strategies.map(((t,r)=>{const i=this.getValidVotes().filter((t=>t.choice===e+1));return i.reduce(((t,e)=>t+e.scores[r]),0)}));return r}))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices[this.selected-1]}}class NP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size}getValidVotes(){return this.votes.filter((t=>NP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return this.proposal.choices.map(((t,e)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.balance),0)))}getScoresByStrategy(){return this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().filter((t=>t.choice.includes(e+1))).reduce(((t,e)=>t+e.scores[r]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected?this.proposal.choices.filter(((t,e)=>this.selected.includes(e+1))).join(", "):""}}function IP(t,e){const r=t/e.reduce(((t,e)=>t+e),0);return isNaN(r)?0:r}function TP(t,e){return Math.sqrt(t*e)}function CP(t){return t*t}function zP(t,e){return t.map((t=>e*t))}class OP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>OP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>{const i=t.map((t=>TP(IP(t.choice[r+1],Object.values(t.choice)),t.balance))).reduce(((t,e)=>t+e),0);return CP(i)}));return zP(r.map(((t,e)=>IP(r[e],r))),e)}getScoresByStrategy(){const t=this.getValidVotes(),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0),r=this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.map((t=>TP(IP(t.choice[r+1],Object.values(t.choice)),t.scores[i]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[CP(t)]))));return r.map(((t,i)=>zP(this.strategies.map(((t,e)=>IP(r[i][e][0],r.flat(2)))),e)))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1]){const r=IP(this.selected[e+1],Object.values(this.selected));return`${Math.round(1e3*r)/10}% for ${t}`}})).filter((t=>null!=t)).join(", ")}}function RP(t,e){const r=[...new Set(t.map((t=>t[0])).flat())],i=Object.entries(t.reduce(((t,[e],r,i)=>{const n=i[r][1];t[e[0]][0]+=n;const o=i[r][2];return o.length>1?t[e[0]][1]=o.map(((r,i)=>r+t[e[0]][1][i]||r)):t[e[0]][1]=[t[e[0]][1].concat(o).reduce(((t,e)=>t+e),0)],t}),Object.assign({},...r.map((t=>({[t]:[0,[]]})))))),n=i.map((t=>[t[0],t[1][0]])),[o,a]=n.reduce((([t,e],[r,i])=>i>e?[r,i]:[t,e]),["?",-1/0]),[s,h]=n.reduce((([t,e],[r,i])=>i<e?[r,i]:[t,e]),["?",1/0]),u=i.sort(((t,e)=>e[1][0]-t[1][0])),l=t.map((t=>t[1])).reduce(((t,e)=>t+e),0);return e.push({round:e.length+1,sortedByHighest:u}),a>l/2||u.length<3?e:RP(t.map((t=>[t[0].filter((t=>t!=s)),t[1],t[2]])).filter((t=>t[0].length>0)),e)}function PP(t){const e=RP(t.map((t=>[t.choice,t.balance,t.scores])),[]);return e[e.length-1].sortedByHighest}class BP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return Array.isArray(t)&&t.every((t=>void 0!==(null==e?void 0:e[t-1])))&&t.length===new Set(t).size&&t.length>0&&t.length===e.length}getValidVotes(){return this.votes.filter((t=>BP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){return function(t,e){const r=PP(t);return e.choices.map(((t,e)=>r.filter((t=>Number(t[0])===e+1)).reduce(((t,e)=>t+e[1][0]),0)))}(this.getValidVotes(),this.proposal)}getScoresByStrategy(){const t=PP(this.getValidVotes());return this.proposal.choices.map(((e,r)=>this.strategies.map(((e,i)=>t.filter((t=>Number(t[0])===r+1)).reduce(((t,e)=>t+e[1][1][i]),0)))))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>{if(this.proposal.choices[t-1])return this.proposal.choices[t-1]})).map(((t,e)=>`(${wB(e+1)}) ${t}`)).join(", ")}}class DP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return!(!Array.isArray(t)||0===t.length||t.length>e.length||new Set(t).size!==t.length)&&t.every((t=>Number.isInteger(t)&&t>=1&&t<=e.length))}getValidVotes(){return this.votes.filter((t=>DP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=Array.from({length:e},(()=>Array(e).fill(0))),i=this.getScoresTotal();for(const e of t)for(let t=0;t<e.choice.length;t++)for(let i=t+1;i<e.choice.length;i++){const n=e.choice[t]-1,o=e.choice[i]-1;r[n][o]+=e.balance,r[o][n]-=e.balance}const n=Array(e).fill(0);let o=0;for(let t=0;t<e;t++)for(let i=0;i<e;i++)if(t!==i){const e=r[t][i];e>0?n[t]++:e<0?n[i]++:(n[t]+=.5,n[i]+=.5)}return o=n.reduce(((t,e)=>t+e),0),o>0?n.map((t=>t/o*i)):n.map((()=>i/e))}getScoresByStrategy(){const t=this.getValidVotes(),e=this.proposal.choices.length,r=this.strategies.length,i=Array.from({length:e},(()=>Array.from({length:e},(()=>Array(r).fill(0))))),n=Array(r).fill(0);for(const e of t)for(let t=0;t<r;t++)n[t]+=e.scores[t];for(const e of t)for(let t=0;t<e.choice.length;t++)for(let n=t+1;n<e.choice.length;n++){const o=e.choice[t]-1,a=e.choice[n]-1;for(let t=0;t<r;t++)i[o][a][t]+=e.scores[t],i[a][o][t]-=e.scores[t]}const o=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<e;t++)for(let n=0;n<e;n++)if(t!==n)for(let e=0;e<r;e++){const r=i[t][n][e];r>0?o[t][e]++:r<0?o[n][e]++:(o[t][e]+=.5,o[n][e]+=.5)}const a=Array.from({length:e},(()=>Array(r).fill(0)));for(let t=0;t<r;t++){let r=0;for(let i=0;i<e;i++)r+=o[i][t];if(r>0)for(let i=0;i<e;i++)a[i][t]=o[i][t]/r*n[t];else if(n[t]>0)for(let r=0;r<e;r++)a[r][t]=n[t]/e}return a}getScoresTotal(){return this.getValidVotes().reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.selected.map((t=>this.proposal.choices[t-1])).join(", ")}}function $P(t,e,r){const i=r.reduce(((t,e)=>t+e),0),n=e[t]/i*100;return isNaN(n)?0:n}function LP(t,e,r){return $P(t+1,e,Object.values(e))/100*r}class FP{constructor(t,e,r,i){this.proposal=t,this.votes=e,this.strategies=r,this.selected=i}static isValidChoice(t,e){return"object"==typeof t&&!Array.isArray(t)&&null!==t&&Object.keys(t).every((t=>void 0!==(null==e?void 0:e[Number(t)-1])))&&Object.keys(t).length>0&&Object.values(t).every((t=>"number"==typeof t&&t>=0))&&Object.values(t).some((t=>"number"==typeof t&&t>0))}getValidVotes(){return this.votes.filter((t=>FP.isValidChoice(t.choice,this.proposal.choices)))}getScores(){const t=this.proposal.choices.map(((t,e)=>this.getValidVotes().map((t=>LP(e,t.choice,t.balance))).reduce(((t,e)=>t+e),0))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((e,r)=>$P(r,t,t))).map((t=>e/100*t))}getScoresByStrategy(){const t=this.proposal.choices.map(((t,e)=>this.strategies.map(((t,r)=>this.getValidVotes().map((t=>LP(e,t.choice,t.scores[r]))).reduce(((t,e)=>t+e),0))))).map((t=>t.map((t=>[t])))),e=this.getValidVotes().reduce(((t,e)=>t+e.balance),0);return t.map(((r,i)=>this.strategies.map(((e,r)=>$P(0,t[i][r],t.flat(2)))).map((t=>[e/100*t])).flat()))}getScoresTotal(){return this.votes.reduce(((t,e)=>t+e.balance),0)}getChoiceString(){return this.proposal.choices.map(((t,e)=>{if(this.selected[e+1])return`${Math.round(10*$P(e+1,this.selected,Object.values(this.selected)))/10}% for ${t}`})).filter((t=>null!=t)).join(", ")}}var UP={"single-choice":SP,approval:NP,quadratic:OP,"ranked-choice":BP,copeland:DP,weighted:FP,basic:SP};const qP={1:"https://subgrapher.snapshot.org/delegation/1",10:"https://subgrapher.snapshot.org/delegation/10",56:"https://subgrapher.snapshot.org/delegation/56",100:"https://subgrapher.snapshot.org/delegation/100",137:"https://subgrapher.snapshot.org/delegation/137",146:"https://subgrapher.snapshot.org/delegation/146",250:"https://subgrapher.snapshot.org/delegation/250",5e3:"https://subgrapher.snapshot.org/delegation/5000",8453:"https://subgrapher.snapshot.org/delegation/8453",42161:"https://subgrapher.snapshot.org/delegation/42161",59144:"https://subgrapher.snapshot.org/delegation/59144",81457:"https://subgrapher.snapshot.org/delegation/81457",84532:"https://subgrapher.snapshot.org/delegation/84532",11155111:"https://subgrapher.snapshot.org/delegation/11155111"},VP=1e3;function HP(t){return t.length===VP&&t[0].timestamp===t[t.length-1].timestamp}function GP(t,e){const r=function(t){return`${t.delegator}-${t.delegate}-${t.space}`}(e);t.has(r)||t.set(r,e)}function ZP(t){const e=["",t];return t.includes(".eth")&&e.push(t.replace(".eth","")),e}function KP(t){return r(this,arguments,void 0,(function*({url:t,spaces:e,pivot:r,snapshot:i}){const n={delegations:{__args:{where:{timestamp_gte:r},first:VP,skip:0,orderBy:"timestamp",orderDirection:"asc"},delegator:!0,space:!0,delegate:!0,timestamp:!0}};return"latest"!==i&&(n.delegations.__args.block={number:i}),null!==e&&(n.delegations.__args.where.space_in=e),(yield cB(t,n)).delegations||[]}))}const JP=["response not found during CCIP fetch","UNSUPPORTED_OPERATION"],WP="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",YP=["function text(bytes32 node, string calldata key) external view returns (string memory)","function resolver(bytes32 node) view returns (address)"],QP="0x0000000000000000000000000000000000000000",XP={"0x534e5f4d41494e":{name:"Starknet",testnet:!1},"0x534e5f5345504f4c4941":{name:"Starknet Sepolia",testnet:!0}},tB={Accept:"application/json","Content-Type":"application/json"},eB="https://score.snapshot.org";function rB(t=eB,e={path:""}){const r=new URL(t);e.path&&(r.pathname=e.path);const i=r.searchParams.get("apiKey");let n=Object.assign({},tB);return i&&(r.searchParams.delete("apiKey"),n=Object.assign(Object.assign({},tB),{"X-API-KEY":i})),{url:r.toString(),headers:n}}function iB(t){return r(this,void 0,void 0,(function*(){let e=yield t.text();try{e=JSON.parse(e)}catch(r){return Promise.reject({code:t.status||500,message:"Failed to parse response from score API",data:e})}return e.error?Promise.reject(e.error):e}))}const nB=new Ud({allErrors:!0,allowUnionTypes:!0,$data:!0,passContext:!0});Gd(nB),Kd(nB),nB.addFormat("address",{validate:t=>{try{return t===xr(t)}catch(t){return!1}}}),nB.addFormat("evmAddress",{validate:t=>{try{return xr(t),!0}catch(t){return!1}}}),nB.addFormat("starknetAddress",{validate:t=>{try{return aR(t).toLowerCase()===t.toLowerCase()}catch(t){return!1}}}),nB.addFormat("long",{validate:()=>!0}),nB.addFormat("lowercase",{validate:t=>t===t.toLowerCase()}),nB.addFormat("color",{validate:t=>!!t&&!!t.match(/^#[0-9A-F]{6}$/)}),nB.addFormat("ethValue",{validate:t=>{if(!t.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))return!1;try{return function(t,e){if("string"!=typeof t&&Nh.throwArgumentError("value must be a string","value",t),"string"==typeof e){const t=Ih.indexOf(e);-1!==t&&(e=3*t)}mh(t,null!=e?e:18)}(t,18),!0}catch(t){return!1}}});const oB=Object.keys(xP),aB=Object.keys(xP).filter((t=>!xP[t].testnet));function sB(t){const e=t.endsWith(".eth"),r=t.split(".");if(1===r.length)return"tld";if(2!==r.length||e){if(r.length>2)return"subdomain";if(e)return"ens";throw new Error("Invalid domain")}return"other-tld"}function hB(t){return r(this,void 0,void 0,(function*(){var e;const r=yield h(`https://cloudflare-dns.com/dns-query?name=${t}&type=TXT`,{headers:{accept:"application/dns-json"}}),i=yield r.json();if(3===i.Status)return QP;if(0!==i.Status)throw new Error("Failed to fetch DNS Owner");const n=null===(e=i.Answer)||void 0===e?void 0:e.find((t=>t.data.includes("ENS1")));return n?xr(n.data.replace(new RegExp('"',"g"),"").split(" ").pop()):QP}))}function uB(t,e,i,n){return r(this,void 0,void 0,(function*(){const r=new Ss(i[0],e,t);try{const t=i[2]||[];return yield r[i[1]](...t,n||{})}catch(t){return Promise.reject(t)}}))}function lB(t,e,i,n,o){return r(this,void 0,void 0,(function*(){const r=(null==o?void 0:o.multicallAddress)||xP[t].multicall,a=new Ss(r,["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],e),s=new $i(i);try{const t=(null==o?void 0:o.limit)||500;(null==o?void 0:o.limit)&&delete o.limit;const e=Math.ceil(n.length/t),r=[];Array.from(Array(e)).forEach(((e,i)=>{const h=n.slice(t*i,t*(i+1));r.push(a.aggregate(h.map((t=>[t[0].toLowerCase(),s.encodeFunctionData(t[1],t[2])])),o||{}))}));let i=yield Promise.all(r);return i=i.reduce(((t,[,e])=>t.concat(e)),[]),i.map(((t,e)=>s.decodeFunctionResult(n[e][1],t)))}catch(t){return Promise.reject(t)}}))}function cB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i={query:ml.jsonToGraphQLQuery({query:e})};r.variables&&(i.variables=r.variables);const n=yield h(t,{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},null==r?void 0:r.headers),body:JSON.stringify(i)});let o=yield n.text();try{o=JSON.parse(o)}catch(e){throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${o.substring(0,400)}`)}if(o.errors)throw new Error(`Errors found in subgraphRequest: URL: ${t}, Status: ${n.status}, Response: ${JSON.stringify(o.errors).substring(0,400)}`);const{data:a}=o;return a||{}}))}function dB(t,e=jP[0]){const r=`https://${e}`;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return`${r}/ipfs/${t}`;const i=t.split("://")[0];return"ipfs"===i?t.replace("ipfs://",`${r}/ipfs/`):"ipns"===i?t.replace("ipns://",`${r}/ipns/`):t}function fB(t,i){return r(this,arguments,void 0,(function*(t,r,i="1",n={}){var o,a;const{ensResolvers:s=(null===(o=xP[i])||void 0===o?void 0:o.ensResolvers)||xP[1].ensResolvers,broviderUrl:h}=n,u=e(n,["ensResolvers","broviderUrl"]);let l;try{l=Ou(zu(t))}catch(t){return null}const c=qp(i,{broviderUrl:h}),d=[[WP,"resolver",[l]],...s.map((t=>[t,"text",[l,r]]))],[[f],...m]=yield lB(i,c,YP,d,u),p=s.indexOf(f);return-1!==p?null===(a=m[p])||void 0===a?void 0:a[0]:null}))}function mB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){try{return yield fB(t,"snapshot",e,r)}catch(t){return console.log(t),null}}))}function pB(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){var i,n;if(!(null===(n=null===(i=xP[e])||void 0===i?void 0:i.ensResolvers)||void 0===n?void 0:n.length))throw new Error("Network not supported");const o=sB(t),a=qp(e,r),s=new Ss(WP,["function owner(bytes32) view returns (address)"],a);let h;try{h=Ou(zu(t))}catch(t){return QP}const u=r.ensNameWrapper||xP[e].ensNameWrapper;let l=yield s.owner(h);if(l===u){const t=new Ss(u,["function ownerOf(uint256) view returns (address)"],a);l=yield t.ownerOf(h)}if(l===QP&&"other-tld"===o){(yield a.resolveName(t))&&(l=yield hB(t))}if(l===QP&&"subdomain"===o)try{l=yield a.resolveName(t)}catch(t){if(JP.every((e=>!t.message.includes(e))))throw t;l=QP}return l||QP}))}function gB(t,e){return r(this,arguments,void 0,(function*(t,e,r={}){const i=yield mB(t,e,r);if(i){let t=Sr(i);if(t)return i;const e=i.split("/"),r=e.includes("testnet")?5:4,n=e[r];if(t=Sr(n),t)return n}return yield pB(t,e,r)}))}function yB(t,e){return r(this,void 0,void 0,(function*(){if(!t.endsWith(".shib"))return QP;const r=yield h("https://stamp.fyi",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"get_owner",params:t,network:e})});return(yield r.json()).result}))}function wB(t){const e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}function vB(t){return!!xP[t]}function bB(t){return t!==QP&&(Sr(t)||MB(t))}function kB(t,e){return"latest"===t||"number"==typeof t&&t>=xP[e].start}function MB(t){if(!t)return!1;try{return aR(t),!0}catch(t){return!1}}function _B(t){return Sr(t)}function EB(t,e){if("string"!=typeof t||!/^0[xX]/.test(t))throw new Error(`Invalid address: ${t}`);const r=null!=e?e:42===t.length?"evm":"starknet";if("evm"===r&&_B(t))return xr(t);if("starknet"===r&&MB(t))return aR(t);throw new Error(`Invalid ${r} address: ${t}`)}function AB(t){return Promise.reject(new Error(t))}nB.addKeyword({keyword:"snapshotNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?aB.includes(e):oB.includes(e)},error:{message:"network not allowed"}}),nB.addKeyword({keyword:"starknetNetwork",validate:function(t,e){return"mainnet"===(this.snapshotEnv||"default")?Object.keys(XP).filter((t=>!XP[t].testnet)).includes(e):Object.keys(XP).includes(e)},error:{message:"network not allowed"}}),nB.addFormat("customUrl",{type:"string",validate:t=>!t.length||(t.startsWith("http://")||t.startsWith("https://")||t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("snapshot://"))}),nB.addFormat("domain",{validate:t=>!!t&&!!t.match(/^(https:\/\/)?([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}(\/)?$/)});var jB={call:uB,multicall:lB,subgraphRequest:cB,ipfsGet:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="ipfs"){return h(`https://${t}/${r}/${e}`).then((t=>t.json()))}))},getUrl:dB,getJSON:function(t){return r(this,arguments,void 0,(function*(t,e={}){const r=dB(t,e.gateways);return h(r).then((t=>t.json()))}))},sendTransaction:function(t,e,i,n,o){return r(this,arguments,void 0,(function*(t,e,r,i,n,o={}){const a=t.getSigner(),s=new Ss(e,r,t).connect(a);return yield s[i](...n,o)}))},getScores:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n="latest",o=eB,a={}){if(!Array.isArray(i))return AB("addresses should be an array of addresses");if(0===i.length)return AB("addresses can not be empty");const s=i.find((t=>!bB(t)));if(s)return AB(`Invalid address: ${s}`);if(!vB(r))return AB(`Invalid network: ${r}`);const u=e.find((t=>t.network&&!vB(t.network)));if(u)return AB(`Invalid network (${u.network}) in strategy ${u.name}`);if(!kB(n,r))return AB(`Snapshot (${n}) must be 'latest' or greater than network start block (${xP[r].start})`);new URL(o).pathname="/api/scores";const{url:l,headers:c}=rB(o,{path:"/api/scores"});try{const o={space:t,network:r,snapshot:n,strategies:e,addresses:i},s=yield h(l,{method:"POST",headers:c,body:JSON.stringify({params:o})}),u=yield iB(s);return"all"===a.returnValue?u.result:u.result[a.returnValue||"scores"]}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},getVp:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){const{url:r,headers:u}=rB(null==s?void 0:s.url);if(!bB(t))return AB(`Invalid voter address: ${t}`);if(!vB(e))return AB(`Invalid network: ${e}`);const l=i.find((t=>t.network&&!vB(t.network)));if(l)return AB(`Invalid network (${l.network}) in strategy ${l.name}`);if(!kB(n,e))return AB(`Snapshot (${n}) must be 'latest' or greater than network start block (${xP[e].start})`);const c={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"get_vp",params:{address:t,network:e,strategies:i,snapshot:n,space:o,delegation:a}})};try{const t=yield h(r,c);return(yield iB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},validateSchema:function(t,e,r={snapshotEnv:"default",spaceType:"default"}){const i=nB.compile(t),n=i.call(r,e);return n||i.errors},getEnsTextRecord:fB,getSpaceUri:mB,getEnsOwner:pB,getSpaceController:function(t){return r(this,arguments,void 0,(function*(t,e="1",r={}){if(["1","11155111"].includes(e))return gB(t,e,r);if(["109","157"].includes(e))return yB(t,e);throw new Error(`Network not supported: ${e}`)}))},getDelegatesBySpace:function(t,e){return r(this,arguments,void 0,(function*(t,e,r="latest",i={}){const n=i.subgraphUrl||qP[t];if(!n)return Promise.reject(`Delegation subgraph not available for network ${t}`);let o=0;const a=new Map,s=e?ZP(e):null;for(;;){const t=yield KP({url:n,spaces:s,pivot:o,snapshot:r});if(HP(t))throw new Error("Unable to paginate delegation");if(t.forEach((t=>{GP(a,t),o=t.timestamp})),t.length<VP)break}return[...a.values()]}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return r(this,void 0,void 0,(function*(){return new Promise((e=>{setTimeout(e,t)}))}))},getNumberWithOrdinal:wB,voting:UP,getProvider:qp,signMessage:function(t,e,i){return r(this,void 0,void 0,(function*(){return e=te(new G(e,"utf8")),yield t.send("personal_sign",[e,i])}))},getBlockNumber:function(t){return r(this,void 0,void 0,(function*(){try{const e=yield t.getBlockNumber();return parseInt(e)}catch(t){return Promise.reject()}}))},Multicaller:class{constructor(t,e,r,i){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=i||{}}call(t,e,r,i){return this.calls.push([e,r,i]),this.paths.push(t),this}execute(t){return r(this,void 0,void 0,(function*(){const e=t||{};return(yield lB(this.network,this.provider,this.abi,this.calls,this.options)).forEach(((t,r)=>Uf(e,this.paths[r],t.length>1?t:t[0]))),this.calls=[],this.paths=[],e}))}},getSnapshots:function(t,e,i,n){return r(this,arguments,void 0,(function*(t,e,r,i,n={}){const o={};if(i.forEach((t=>o[t]="latest")),"latest"===e)return o;const a=`${t}-${e}-${i.join("-")}`,s=qf[a],h=Date.now();if(s&&Vf>h)return s;Vf<h&&(qf={},Vf=h+36e5-h%36e5),o[t]=e;const u=Object.keys(o).filter((e=>t!==e));if(0===u.length)return o;const l={blocks:{__args:{where:{ts:(yield r.getBlock(e)).timestamp,network_in:u}},network:!0,number:!0}},c=n.blockFinderUrl||"https://blockfinder.snapshot.org";return(yield cB(c,l)).blocks.forEach((t=>o[t.network]=t.number)),qf[a]=o,o}))},getHash:function(t,e){return(UR(t)?VR:AP).getHash(t,e)},verify:function(t,e,i){return r(this,arguments,void 0,(function*(t,e,r,i="1",n={}){if(!MB(t)&&!_B(t))throw new Error("Invalid address");const o=UR(r)?VR:AP;return yield o.default(t,e,r,i,n)}))},validate:function(t,e,i,n,o,a,s){return r(this,void 0,void 0,(function*(){if(!bB(e))return AB(`Invalid author: ${e}`);if(!vB(n))return AB(`Invalid network: ${n}`);if(!kB(o,n))return AB(`Snapshot (${o}) must be 'latest' or greater than network start block (${xP[n].start})`);s||(s={});const{url:r,headers:u}=rB(s.url),l={method:"POST",headers:u,body:JSON.stringify({jsonrpc:"2.0",method:"validate",params:{validation:t,author:e,space:i,network:n,snapshot:o,params:a}})};try{const t=yield h(r,l);return(yield iB(t)).result}catch(t){return t.errno?Promise.reject({code:t.errno,message:t.toString(),data:""}):Promise.reject(t)}}))},isStarknetAddress:MB,isEvmAddress:_B,getFormattedAddress:EB,SNAPSHOT_SUBGRAPH_URL:qP};const xB={name:"snapshot",version:"0.1.4"};class SB{constructor(t=N.sequencer,e={}){t=(t=(t=t.replace(N.hub,N.sequencer)).replace(I.hub,I.sequencer)).replace(T.hub,T.sequencer),this.address=t,this.options=e}sign(t,e,i,n){return r(this,void 0,void 0,(function*(){var r;const o=(null==t?void 0:t.getSigner)?t.getSigner():t,a=EB(e,"evm");i.from=i.from?EB(i.from):a,i.timestamp||(i.timestamp=parseInt((Date.now()/1e3).toFixed()));const s=Object.assign({},xB);"undefined"!=typeof window&&(null===(r=window.ethereum)||void 0===r?void 0:r.isTrust)&&(s.chainId=(yield o.provider.getNetwork()).chainId);const h={domain:s,types:n,message:i},u=yield o._signTypedData(s,h.types,i);return yield this.send({address:a,sig:u,data:h})}))}send(t){return r(this,void 0,void 0,(function*(){let e=this.address;"0x"===t.sig&&this.options.relayerURL&&(e=this.options.relayerURL);const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)};return new Promise(((t,i)=>{h(e,r).then((e=>{var r;if(e.ok)return t(e.json());if(null===(r=e.headers.get("content-type"))||void 0===r?void 0:r.includes("application/json"))return e.json().then(i).catch(i);throw e})).catch(i)}))}))}space(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,u)}))}proposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.labels||(i.labels=[]),i.discussion||(i.discussion=""),i.app||(i.app=""),i.privacy||(i.privacy=""),yield this.sign(t,e,i,l)}))}updateProposal(t,e,i){return r(this,void 0,void 0,(function*(){return i.privacy||(i.privacy=""),yield this.sign(t,e,i,c)}))}flagProposal(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,d)}))}cancelProposal(t,e,i){return r(this,void 0,void 0,(function*(){const r=i.proposal.startsWith("0x");return yield this.sign(t,e,i,r?m:f)}))}vote(t,e,i){return r(this,void 0,void 0,(function*(){const r="shutter"===(null==i?void 0:i.privacy);i.reason||(i.reason=""),i.app||(i.app=""),i.metadata||(i.metadata="{}");const n=i.proposal.startsWith("0x");let o=n?w:p;return["approval","ranked-choice"].includes(i.type)&&(o=n?v:g),!r&&["quadratic","weighted"].includes(i.type)&&(o=n?b:y,i.choice=JSON.stringify(i.choice)),r&&(o=n?b:y),delete i.privacy,delete i.type,yield this.sign(t,e,i,o)}))}follow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,k)}))}unfollow(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,M)}))}subscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,_)}))}unsubscribe(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,E)}))}profile(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,A)}))}statement(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,j)}))}alias(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,x)}))}deleteSpace(t,e,i){return r(this,void 0,void 0,(function*(){return yield this.sign(t,e,i,S)}))}}var NB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Proposal",definitions:{Proposal:{title:"Proposal",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{type:"string",enum:["single-choice","approval","ranked-choice","quadratic","copeland","weighted","custom","basic"]},snapshot:{type:"number",title:"snapshot"},start:{type:"number",title:"start",minimum:1e9,maximum:2e9},end:{type:"number",title:"end",minimum:1e9,maximum:2e9},metadata:{type:"object",title:"metadata"},app:{type:"string",title:"app",maxLength:24},privacy:{type:"string",enum:["","shutter"]}},required:["name","body","choices","snapshot","start","end"],additionalProperties:!1}}},IB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/UpdateProposal",definitions:{UpdateProposal:{title:"Update Proposal",type:"object",properties:{proposal:{type:"string",title:"proposal id"},name:{type:"string",title:"name",minLength:1,maxLength:256},body:{type:"string",title:"body",minLength:0},discussion:{type:"string",format:"customUrl",title:"discussion",maxLength:256},choices:{type:"array",title:"choices",minItems:1},labels:{type:"array",title:"labels",maxItems:10,uniqueItems:!0,items:{type:"string",minLength:1,maxLength:8,pattern:"^[a-zA-Z0-9]+$"}},type:{enum:["single-choice","approval","ranked-choice","quadratic","weighted","custom","basic"]},metadata:{type:"object",title:"metadata"},privacy:{type:"string",enum:["","shutter"]}},required:["proposal","name","body","discussion","choices","type","metadata"],additionalProperties:!1}}},TB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Vote",definitions:{Vote:{title:"Vote",type:"object",properties:{proposal:{type:"string",title:"proposal"},choice:{type:["number","array","object","boolean","string"],title:"choice"},metadata:{type:"object",title:"metadata"},reason:{type:"string",title:"reason",maxLength:5e3},app:{type:"string",title:"app",maxLength:24}},required:["proposal","choice"],additionalProperties:!1}}},CB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Profile",definitions:{Profile:{title:"Profile",type:"object",properties:{name:{type:"string",title:"name",maxLength:32},about:{type:"string",title:"about",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},lens:{type:"string",title:"lens",pattern:"^[A-Za-z0-9_]*$",maxLength:26},farcaster:{type:"string",title:"farcaster",pattern:"^[a-z0-9-]*$",maxLength:17}},required:[],additionalProperties:!1}}},zB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Statement",definitions:{Statement:{title:"Statement",type:"object",properties:{about:{type:"string",format:"long",title:"About",maxLength:140},statement:{type:"string",format:"long",title:"Statement",maxLength:1e4},discourse:{type:"string",title:"discourse",pattern:"^[A-Za-z0-9-_.]*$",maxLength:30},network:{type:"string",title:"network",pattern:"^[a-z0-9-]*$",maxLength:24},status:{enum:["ACTIVE","INACTIVE"],title:"status"}},required:[],additionalProperties:!1}}},OB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Zodiac",definitions:{Zodiac:{title:"Zodiac",type:"object",properties:{safes:{title:"Safe(s)",type:"array",maxItems:8,items:{type:"object",properties:{network:{title:"Network",type:"string",snapshotNetwork:!0},multisend:{title:"Multisend contract address",type:"string"},realityAddress:{title:"Reality module address",type:"string"},umaAddress:{title:"UMA module address",type:"string"}},additionalProperties:!1}},additionalProperties:!1}}}},RB={$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Alias",definitions:{Alias:{title:"Alias",type:"object",properties:{alias:{type:"string",format:"address"}},required:["alias"],additionalProperties:!1}}};return{Client:SB,Client712:SB,schemas:{space:{$schema:"http://json-schema.org/draft-07/schema#",$ref:"#/definitions/Space",definitions:{Space:{title:"Space",type:"object",properties:{name:{type:"string",title:"name",minLength:1,maxLength:32},private:{type:"boolean"},about:{type:"string",title:"about",maxLength:160},guidelines:{type:"string",format:"customUrl",title:"guidelines",maxLength:256},template:{type:"string",title:"template",maxLength:1024},terms:{type:"string",title:"terms",format:"customUrl",maxLength:256},avatar:{type:"string",title:"avatar",format:"customUrl",maxLength:256},cover:{type:"string",title:"avatar",format:"customUrl",maxLength:256},location:{type:"string",title:"location",maxLength:24},website:{type:"string",title:"website",format:"customUrl",maxLength:256},twitter:{type:"string",title:"twitter",pattern:"^[A-Za-z0-9_]*$",maxLength:15},coingecko:{type:"string",title:"coingecko",pattern:"^[a-z0-9-]*$",maxLength:32},github:{type:"string",title:"github",pattern:"^[A-Za-z0-9_-]*$",maxLength:39},farcaster:{type:"string",title:"farcaster"},email:{type:"string",title:"email",maxLength:32},network:{type:"string",snapshotNetwork:!0,title:"network",minLength:1,maxLength:32},symbol:{type:"string",title:"symbol",maxLength:16},skin:{type:"string",title:"skin",maxLength:32},domain:{type:"string",title:"domain",maxLength:64,format:"domain"},discussions:{type:"string",format:"uri",title:"Discussions link",maxLength:256},discourseCategory:{type:"integer",minimum:1,title:"Discourse category"},strategies:{type:"array",minItems:1,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},network:{type:"string",maxLength:12,title:"network",snapshotNetwork:!0},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},title:"strategies"},members:{type:"array",maxItems:100,items:{type:"string",anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid address"},title:"members",uniqueItems:!0},admins:{type:"array",maxItems:100,items:{type:"string",anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid address"},title:"admins",uniqueItems:!0},moderators:{type:"array",maxItems:100,items:{type:"string",anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid address"},title:"moderators",uniqueItems:!0},filters:{type:"object",properties:{defaultTab:{type:"string"},minScore:{type:"number",minimum:0},onlyMembers:{type:"boolean"},invalids:{type:"array",items:{type:"string",maxLength:64},title:"invalids"}},additionalProperties:!1},validation:{type:"object",properties:{name:{type:"string",maxLength:64,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},voteValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},followValidation:{type:"object",properties:{name:{type:"string",maxLength:32,title:"name"},params:{type:"object",title:"params"}},required:["name"],additionalProperties:!1},delegationPortal:{type:"object",properties:{delegationType:{type:"string",title:"Delegation type",description:"Specify the type of delegation that you are using",anyOf:[{const:"compound-governor",title:"Compound governor"},{const:"split-delegation",title:"Split Delegation"},{const:"apechain-delegate-registry",title:"ApeChain Delegate Registry"}]},delegationContract:{type:"string",title:"Contract address",description:"The address of your delegation contract",examples:["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"],anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},delegationNetwork:{type:"string",title:"Delegation network",description:"The network of your delegation contract",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"},delegationApi:{type:"string",format:"uri",title:"Delegation API",description:"The URL of your delegation API (e.g a subgraph)",examples:["https://subgrapher.snapshot.org/subgraph/arbitrum/FTzC6VrZd8JhJgWfTJnwWgH1Z1dS3GxaosKkRbCqkZAZ"]}},required:["delegationType","delegationApi","delegationContract"],additionalProperties:!1},allowAlias:{type:"boolean"},plugins:{type:"object"},voting:{type:"object",properties:{delay:{type:"integer",minimum:0,maximum:2592e3,errorMessage:{maximum:"Delay must be less than 30 days"}},period:{type:"integer",minimum:0,maximum:31622400,errorMessage:{maximum:"Delay must be less than a year"}},type:{type:"string",title:"type"},quorum:{type:"number",minimum:0},quorumType:{type:"string",enum:["rejection"]},blind:{type:"boolean"},hideAbstain:{type:"boolean"},aliased:{type:"boolean"},privacy:{type:"string",enum:["","shutter","any"]}},additionalProperties:!1},categories:{type:"array",maxItems:2,items:{type:"string",enum:["protocol","social","investment","grant","service","media","creator","collector","ai-agent","gaming","wallet","music","layer-2","defai","defi","rwa","depin","meme"]}},treasuries:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{name:{type:"string",title:"Name",examples:["e.g. Balancer DAO 1"],minLength:1,maxLength:64},address:{type:"string",title:"Contract address",examples:["e.g. 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984"],anyOf:[{type:"string",format:"evmAddress"},{type:"string",format:"starknetAddress"}],errorMessage:"Must be a valid EVM of Starknet address"},network:{type:"string",title:"Network",anyOf:[{snapshotNetwork:!0},{starknetNetwork:!0}],errorMessage:"Must be a valid network"}},required:["name","address","network"],additionalProperties:!1}},labels:{type:"array",maxItems:10,uniqueItems:!0,items:{type:"object",properties:{id:{type:"string",title:"Id",minLength:1,maxLength:8},name:{type:"string",title:"Name",minLength:1,maxLength:32},description:{type:"string",title:"Description",maxLength:100},color:{type:"string",title:"Color",format:"color"}},required:["id","name","color"],additionalProperties:!1}},parent:{type:"string",title:"parent"},children:{type:"array",maxItems:16,title:"children",items:{type:"string"},uniqueItems:!0},boost:{type:"object",properties:{enabled:{type:"boolean"},bribeEnabled:{type:"boolean"}},required:["enabled","bribeEnabled"],additionalProperties:!1},skinSettings:{type:"object",properties:{bg_color:{type:"string",format:"color"},link_color:{type:"string",format:"color"},text_color:{type:"string",format:"color"},content_color:{type:"string",format:"color"},border_color:{type:"string",format:"color"},heading_color:{type:"string",format:"color"},primary_color:{type:"string",format:"color"},header_color:{type:"string",format:"color"},theme:{type:"string",enum:["light","dark"]},logo:{type:"string",title:"logo",format:"customUrl",maxLength:256}},additionalProperties:!1}},required:["name","network","strategies"],additionalProperties:!1}}}.definitions.Space,proposal:NB.definitions.Proposal,updateProposal:IB.definitions.UpdateProposal,vote:TB.definitions.Vote,profile:CB.definitions.Profile,statement:zB.definitions.Statement,zodiac:OB.definitions.Zodiac,alias:RB.definitions.Alias},utils:jB}}));