@chainrails/react 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +1,42 @@
1
- (function(Rt,Be){typeof exports=="object"&&typeof module<"u"?Be(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],Be):(Rt=typeof globalThis<"u"?globalThis:Rt||self,Be(Rt.Chainrails={},Rt.React,Rt.jsxRuntime))})(this,(function(Rt,Be,Wn){"use strict";var Eu=document.createElement("style");Eu.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
- /*$vite$:1*/`,document.head.appendChild(Eu);class Eo extends Error{response;request;options;constructor(e,n,r){const s=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${s} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=r}}class vu extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class vo extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new vu(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Ru=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(s){if(s instanceof Error&&s.message==="unsupported BodyInit type")return!1;throw s}return t&&!e})(),M0=typeof globalThis.AbortController=="function",Au=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",B0=typeof globalThis.ReadableStream=="function",k0=typeof globalThis.FormData=="function",xu=["get","post","put","patch","head","delete"],L0={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Ro=2147483647,P0=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Su=Symbol("stop");class Tu{options;constructor(e){this.options=e}}const U0=t=>new Tu(t),D0={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},F0={next:!0},$0={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},z0=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,r]of t)e+=P0,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Ou=(t,e,n)=>{let r,s=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),r){s+=r.byteLength;let a=e===0?0:s/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,s),transferredBytes:s},r)}r=i},flush(){r&&(s+=r.byteLength,n?.({percent:1,totalBytes:Math.max(e,s),transferredBytes:s},r))}}))},j0=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Ou(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},V0=(t,e,n)=>{if(!t.body)return t;const r=z0(n??t.body);return new Request(t,{duplex:"half",body:Ou(t.body,r,e)})},Zn=t=>t!==null&&typeof t=="object",Xs=(...t)=>{for(const e of t)if((!Zn(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Ao({},...t)},Iu=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(const[i,o]of s.entries())r&&o==="undefined"||o===void 0?n.delete(i):n.set(i,o);return n};function Qs(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:Ao(t[n]??[],e[n]??[])}const Nu=(t={},e={})=>({beforeRequest:Qs(t,e,"beforeRequest"),beforeRetry:Qs(t,e,"beforeRetry"),afterResponse:Qs(t,e,"afterResponse"),beforeError:Qs(t,e,"beforeError")}),G0=(t,e)=>{const n=new URLSearchParams;for(const r of[t,e])if(r!==void 0)if(r instanceof URLSearchParams)for(const[s,i]of r.entries())n.append(s,i);else if(Array.isArray(r))for(const s of r){if(!Array.isArray(s)||s.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(s[0]),String(s[1]))}else if(Zn(r))for(const[s,i]of Object.entries(r))i!==void 0&&n.append(s,String(i));else{const s=new URLSearchParams(r);for(const[i,o]of s.entries())n.append(i,o)}return n},Ao=(...t)=>{let e={},n={},r={},s;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(Zn(o)){for(let[a,d]of Object.entries(o)){if(a==="signal"&&d instanceof globalThis.AbortSignal){i.push(d);continue}if(a==="context"){if(d!=null&&(!Zn(d)||Array.isArray(d)))throw new TypeError("The `context` option must be an object");e={...e,context:d==null?{}:{...e.context,...d}};continue}if(a==="searchParams"){d==null?s=void 0:s=s===void 0?d:G0(s,d);continue}Zn(d)&&a in e&&(d=Ao(e[a],d)),e={...e,[a]:d}}Zn(o.hooks)&&(r=Nu(r,o.hooks),e.hooks=r),Zn(o.headers)&&(n=Iu(n,o.headers),e.headers=n)}return s!==void 0&&(e.searchParams=s),i.length>0&&(i.length===1?e.signal=i[0]:Au?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},H0=t=>xu.includes(t)?t.toUpperCase():t,Cu={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},q0=(t={})=>{if(typeof t=="number")return{...Cu,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Cu,...t}};class xo extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function K0(t,e,n,r){return new Promise((s,i)=>{const o=setTimeout(()=>{n&&n.abort(),i(new xo(t))},r.timeout);r.fetch(t,e).then(s).catch(i).then(()=>{clearTimeout(o)})})}async function W0(t,{signal:e}){return new Promise((n,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",s,{once:!0}));function s(){clearTimeout(i),r(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",s),n()},t)})}const Z0=(t,e)=>{const n={};for(const r in e)Object.hasOwn(e,r)&&!(r in $0)&&!(r in D0)&&(!(r in t)||r in F0)&&(n[r]=e[r]);return n},Y0=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function J0(t){return t instanceof Eo||t?.name===Eo.name}function X0(t){return t instanceof xo||t?.name===xo.name}class Yr{static create(e,n){const r=new Yr(e,n),s=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>Ro)throw new RangeError(`The \`timeout\` option cannot be greater than ${Ro}`);await Promise.resolve();let o=await r.#m();for(const a of r.#e.hooks.afterResponse){const d=r.#d(o.clone()),m=await a(r.request,r.#a(),d,{retryCount:r.#n});if(m instanceof globalThis.Response&&(o=m),m instanceof Tu)throw await Promise.all([d.body?.cancel(),o.body?.cancel()]),new vo(m.options)}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new Eo(o,r.request,r.#a());for(const d of r.#e.hooks.beforeError)a=await d(a,{retryCount:r.#n});throw a}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!B0)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return j0(o.clone(),r.#e.onDownloadProgress)}return o},i=r.#l(s).finally(async()=>{const o=r.#i,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),r.request.bodyUsed||a.push(r.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(L0))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||a);const d=await i;if(o==="json"){if(d.status===204)return"";const m=await d.text();return m===""?"":n.parseJson?n.parseJson(m):JSON.parse(m)}return d[o]()});return i}static#h(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#r;#n=0;#t;#e;#i;#s;#o;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Iu(this.#t.headers,n.headers),hooks:Nu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:H0(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:q0(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}M0&&Au&&(this.#s=this.#e.signal??this.#t.signal,this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal),Ru&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const r=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(k0&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),Y0(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Yr.#h(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Ru)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#f(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#n);let n=e;return this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e)),Math.min(this.#e.retry.backoffLimit,n)}async#p(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new vu(e);if(n instanceof vo)return n.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const r=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(r===!1)throw e;if(r===!0)return this.#c()}if(X0(e)&&!this.#e.retry.retryOnTimeout)throw e;if(J0(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let s=Number(r)*1e3;Number.isNaN(s)?s=Date.parse(r)-Date.now():s>=Date.parse("2024-01-01")&&(s-=Date.now());const i=this.#e.retry.maxRetryAfter??s;return s<i?s:i}if(e.response.status===413)throw e}return this.#c()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#l(e){try{return await e()}catch(n){const r=Math.min(await this.#p(n),Ro);if(this.#n<1)throw n;if(await W0(r,this.#s?{signal:this.#s}:{}),n instanceof vo&&n.customRequest){const s=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#u(s)}for(const s of this.#e.hooks.beforeRetry){const i=await s({request:this.request,options:this.#a(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Su)return}return this.#l(e)}}async#m(){this.#r?.signal.aborted&&(this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const r=await n(this.request,this.#a(),{retryCount:this.#n});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#u(r);break}}const e=Z0(this.request,this.#e);return this.#i=this.request,this.request=this.#i.clone(),this.#e.timeout===!1?this.#e.fetch(this.#i,e):K0(this.#i,e,this.#r,this.#e)}#a(){if(!this.#o){const{hooks:e,...n}=this.#e;this.#o=Object.freeze(n)}return this.#o}#u(e){this.#o=void 0,this.request=this.#f(e)}#f(e,n){return!this.#e.onUploadProgress||!e.body?e:V0(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const So=t=>{const e=(n,r)=>Yr.create(n,Xs(t,r));for(const n of xu)e[n]=(r,s)=>Yr.create(r,Xs(t,s,{method:n}));return e.create=n=>So(Xs(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),So(Xs(t,n))),e.stop=Su,e.retry=U0,e},Q0=So(),Xe={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"},Mu={ARBITRUM:"ARBITRUM",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC",ETHEREUM:"ETHEREUM",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM",LISK:"LISK",MONAD:"MONAD",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON",STARKNET:"STARKNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function To(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Bu(t){return To(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ku="2.43.4";let Oo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${ku}`},Jr=class yu extends Error{constructor(e,n={}){const r=n.cause instanceof yu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof yu&&n.cause.docsPath||n.docsPath,i=Oo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Oo.version?[`Version: ${Oo.version}`]:[]].join(`
3
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=ku}walk(e){return Lu(this,e)}};function Lu(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Lu(t.cause,e):e?null:t}let Pu=class extends Jr{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};function ei(t,{dir:e,size:n=32}={}){return typeof t=="string"?ep(t,{dir:e,size:n}):tp(t,{dir:e,size:n})}function ep(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Pu({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function tp(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Pu({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class np extends Jr{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class rp extends Jr{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Io(t,{size:e}){if(Bu(t)>e)throw new rp({givenSize:Bu(t),maxSize:e})}function sp(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new np({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ei(a,{size:r}):a}const ip=new TextEncoder;function op(t,e={}){return typeof t=="number"||typeof t=="bigint"?cp(t,e):typeof t=="boolean"?ap(t,e):To(t)?Du(t,e):Fu(t,e)}function ap(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Io(n,{size:e.size}),ei(n,{size:e.size})):n}const mn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Uu(t){if(t>=mn.zero&&t<=mn.nine)return t-mn.zero;if(t>=mn.A&&t<=mn.F)return t-(mn.A-10);if(t>=mn.a&&t<=mn.f)return t-(mn.a-10)}function Du(t,e={}){let n=t;e.size&&(Io(n,{size:e.size}),n=ei(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=Uu(r.charCodeAt(a++)),m=Uu(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Jr(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function cp(t,e){const n=sp(t,e);return Du(n)}function Fu(t,e={}){const n=ip.encode(t);return typeof e.size=="number"?(Io(n,{size:e.size}),ei(n,{dir:"right",size:e.size})):n}const ti=BigInt(2**32-1),$u=BigInt(32);function up(t,e=!1){return e?{h:Number(t&ti),l:Number(t>>$u&ti)}:{h:Number(t>>$u&ti)|0,l:Number(t&ti)|0}}function dp(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=up(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const lp=(t,e,n)=>t<<n|e>>>32-n,fp=(t,e,n)=>e<<n|t>>>32-n,hp=(t,e,n)=>e<<n-32|t>>>64-n,pp=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function zu(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ni(t,...e){if(!mp(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function ju(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function gp(t,e){ni(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function yp(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Vu(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const bp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _p(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function wp(t){for(let e=0;e<t.length;e++)t[e]=_p(t[e]);return t}const Gu=bp?t=>t:wp;function Ep(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Hu(t){return typeof t=="string"&&(t=Ep(t)),ni(t),t}let vp=class{};function Rp(t){const e=r=>t().update(Hu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const Ap=BigInt(0),Xr=BigInt(1),xp=BigInt(2),Sp=BigInt(7),Tp=BigInt(256),Op=BigInt(113),qu=[],Ku=[],Wu=[];for(let t=0,e=Xr,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],qu.push(2*(5*r+n)),Ku.push((t+1)*(t+2)/2%64);let s=Ap;for(let i=0;i<7;i++)e=(e<<Xr^(e>>Sp)*Op)%Tp,e&xp&&(s^=Xr<<(Xr<<BigInt(i))-Xr);Wu.push(s)}const Zu=dp(Wu,!0),Ip=Zu[0],Np=Zu[1],Yu=(t,e,n)=>n>32?hp(t,e,n):lp(t,e,n),Ju=(t,e,n)=>n>32?pp(t,e,n):fp(t,e,n);function Cp(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=Yu(m,g,1)^n[a],O=Ju(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Ku[o],d=Yu(s,i,a),m=Ju(s,i,a),g=qu[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Ip[r],t[1]^=Np[r]}Vu(n)}let Mp=class I0 extends vp{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,zu(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=yp(this.state)}clone(){return this._cloneInto()}keccak(){Gu(this.state32),Cp(this.state32,this.rounds),Gu(this.state32),this.posOut=0,this.pos=0}update(e){ju(this),e=Hu(e),ni(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){ju(this,!1),ni(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return zu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gp(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Vu(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new I0(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const Bp=(t,e,n)=>Rp(()=>new Mp(e,t,n)),kp=Bp(1,136,256/8);function Lp(t,e){return kp(To(t,{strict:!1})?op(t):t)}let Pp=class extends Jr{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}};class Xu extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const No=new Xu(8192);function Qu(t,e){if(No.has(`${t}.${e}`))return No.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=Lp(Fu(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return No.set(`${t}.${e}`,i),i}function At(t,e){if(!Dp(t,{strict:!1}))throw new Pp({address:t});return Qu(t,e)}const Up=/^0x[a-fA-F0-9]{40}$/,Co=new Xu(8192);function Dp(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Co.has(r))return Co.get(r);const s=Up.test(t)?t.toLowerCase()===t?!0:n?Qu(t)===t:!0:!1;return Co.set(r,s),s}const X={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};X.USDC;const ed={[Xe.ARBITRUM]:{[X.DAI]:{address:At("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:At("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:At("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:At("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ARBITRUM_TESTNET]:{[X.USDC]:{address:At("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.AVALANCHE]:{[X.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:At("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.AVALANCHE_TESTNET]:{[X.USDC]:{address:At("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.BASE]:{[X.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.USDC]:{address:At("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.WETH]:{address:At("0x4200000000000000000000000000000000000006"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.BASE_TESTNET]:{[X.USDC]:{address:At("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.BSC]:{[X.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:X.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[X.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.USDC]:{address:At("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:X.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:X.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Xe.ETHEREUM]:{[X.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:At("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:At("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:At("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:At("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ETHEREUM_TESTNET]:{[X.USDC]:{address:At("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:X.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.HYPEREVM]:{[X.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.LISK]:{[X.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.MONAD]:{[X.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.MONAD_TESTNET]:{[X.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.OPTIMISM]:{[X.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.OPTIMISM_TESTNET]:{[X.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.POLYGON]:{[X.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.STARKNET]:{[X.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:X.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[X.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Xe.STARKNET_TESTNET]:{[X.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},Fp=new Set(Object.values(Xe));function Lt(t){if($p(t))return t;const e=Xe[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function $p(t){return Fp.has(t)}function zp(t,e){const n=e.toLowerCase().trim(),r=ed[t];if(!r)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let s;for(const i in r){const o=r[i];if(o&&o.address.toLowerCase()===n.toLowerCase()){s=o;break}}if(!s)throw new Error(`Token address mismatch: address ${e} does not exist on chain ${t}. The token address must be a valid token address on the specified chain.`);return s}function Mo(t,e,n){const r=zp(t,e);if(r.symbol!==n)throw new Error(`Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${r.symbol}", but expected "${n}". The token address must correspond to a token with the expected symbol on the specified chain.`);return r}function jp(t,e){return ed[t]?.[e]}function td(t,e){return jp(t,e)?.address}var Bo=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(Bo||{});class Ce{constructor({api_key:e,env:n,seesion_token:r,props:s}){this.api_key=e||"",this.sessionToken=r||"",this.env=n??Bo.PRODUCTION,this.props=s}static async config(e){if(!Ce.app){if(!e)throw new Error("Please provide an api_key");Ce.app=new Ce(e)}return e&&(e.api_key!==void 0&&(Ce.app.api_key=e.api_key),e.seesion_token!==void 0&&(Ce.app.sessionToken=e.seesion_token),e.env!==void 0&&(Ce.app.env=e.env),e.props!==void 0&&(Ce.app.props=e.props)),Ce.app}static getApiKey(){if(!Ce.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ce.app.api_key}static getSessionToken(){if(!Ce.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ce.app.sessionToken}static getProps(){if(!Ce.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ce.app.props}static getEnv(){if(!Ce.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ce.app.env==="internal"?"staging":Ce.app.env}static getBaseUrl(){if(!Ce.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(Ce.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e){if(!Ce.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=Ce.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",r=Number(e),s=e&&!isNaN(Number(e))&&r>0?"/pay/":"/deposit/",i=`${e&&!isNaN(Number(e))&&r>0?r*100:""}`;return n+s+i}}let ko=null;function Vp(){ko=Q0.create({prefixUrl:Ce.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=Ce.getSessionToken()||Ce.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,n)=>n]},retry:{limit:2}})}function ze(){return ko||Vp(),ko}let Gp=class{async getById(e){return await ze().get("intents/"+e).json()}async getForSender(e){return await ze().get("intents/user/"+e).json()}async getForAddress(e){return await ze().get("intents/address/"+e).json()}async getForSession(e){return await ze().get("modal/sessions/intents/"+e).json()}async getAll(e){return await ze().get("intents",{searchParams:e}).json()}async create(e){const n=Lt(e.source_chain),r=Lt(e.destination_chain);return await ze().post("intents",{json:{...e,source_chain:n,destination_chain:r}}).json()}async createForSession(e){const n=Lt(e.sourceChain);return await ze().post("modal/sessions/intents",{json:{...e,sourceChain:n}}).json()}async update(e,n){return await ze().post("intents",{json:n}).json()}async triggerProcessing(e){return await ze().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await ze().post(`modal/sessions/intents/${e}/process`).json()}},Hp=class{async getFromSpecificBridge(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/single",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getFromAllBridges(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/multiple",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getBestAcrossBridges(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/best",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAll(e){const n=Lt(e.destinationChain);return await ze().get("quotes/multi-source",{searchParams:{...e,destinationChain:n}}).json()}async getAllForSession(e){return await ze().get("modal/sessions/quotes",{searchParams:e}).json()}},qp=class{async getOptimalRoutes(e){const n=Lt(e.sourceChain),r=Lt(e.destinationChain);return await ze().get("router/optimal-route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAllSupportedBridges(){return await ze().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const n=Lt(e.sourceChain),r=Lt(e.destinationChain);return await ze().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getSupportedRoutes(e){return await ze().get("router/supported-routes/bridge/"+e).json()}},Kp=class{async getSupported(e){return await ze().get("chains",{searchParams:e}).json()}async getBalance(e){return await ze().get(`chains/balances/${e.address}`,{searchParams:e}).json()}},Wp=class{async getClientInfo(){return await ze().get("client/auth/client-info").json()}async getClientInfoForSession(){return await ze().get("modal/sessions/client").json()}},Zp=class{async getSessionToken(e){const n=Lt(e.destinationChain);let r=td(n,e.token);r||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),r=td(n,"USDC"));const s={recipient:e.recipient,tokenOut:r,destinationChain:n,amount:e.amount};return ze().post("modal/sessions",{json:s}).json().then(i=>({...i,amount:s.amount}))}};const Yp={router:new qp,quotes:new Hp,intents:new Gp,chains:new Kp,client:new Wp,auth:new Zp};function nd(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=nd(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Jp(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=nd(t))&&(r&&(r+=" "),r+=e);return r}const an={CLOSED:"closed",COMPLETED:"completed",AUTH:"session",REQUEST_FARCASTER_CONNECT:"cr:request-farcaster-connect",REQUEST_FARCASTER_DISCONNECT:"cr:request-farcaster-disconnect",REQUEST_FARCASTER_SEND_TRANSACTION:"cr:request-farcaster-send-transaction",FARCASTER_SEND_TRANSACTION_RESULT:"cr:farcaster-send-transaction-result",FARCASTER_CONNECTED:"cr:farcaster-connected",FARCASTER_DISCONNECTED:"cr:farcaster-disconnected",IN_FARCASTER_MINI_APP:"cr:in-farcaster-mini-app"},Lo="https://app.chainrails.io",Po="https://chainrails-frontend-git-staging-horus-labs.vercel.app",Xp=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];function mr(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new cm(t.type);return`${t.name}(${Uo(t.inputs,{includeName:e})})`}function Uo(t,{includeName:e=!1}={}){return t?t.map(n=>Qp(n,{includeName:e})).join(e?", ":","):""}function Qp(t,{includeName:e}){return t.type.startsWith("tuple")?`(${Uo(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function Nn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function bt(t){return Nn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const rd="2.43.4";let Do={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${rd}`},ue=class bu extends Error{constructor(e,n={}){const r=n.cause instanceof bu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof bu&&n.cause.docsPath||n.docsPath,i=Do.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Do.version?[`Version: ${Do.version}`]:[]].join(`
4
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=rd}walk(e){return sd(this,e)}};function sd(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?sd(t.cause,e):e?null:t}class em extends ue{constructor({data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
5
- `),{metaMessages:[`Params: (${Uo(n,{includeName:!0})})`,`Data: ${e} (${r} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=n,this.size=r}}class Fo extends ue{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class tm extends ue{constructor({expectedLength:e,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${e}`,`Given length: ${n}`].join(`
1
+ (function(Rt,Ie){typeof exports=="object"&&typeof module<"u"?Ie(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],Ie):(Rt=typeof globalThis<"u"?globalThis:Rt||self,Ie(Rt.Chainrails={},Rt.React,Rt.jsxRuntime))})(this,(function(Rt,Ie,Jt){"use strict";var vu=document.createElement("style");vu.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);background-color:#0008;transition:all .2s ease-out}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader-logo{animation:cr-pulse 1.5s ease-in-out infinite;transform:scale(0);filter:blur(4px);transition:all .3s cubic-bezier(.25,1,.5,1),filter .2s 1.75s ease-out,transform .2s 1.75s ease-out}@keyframes cr-pulse{0%,to{opacity:1}50%{opacity:.5}}@media (prefers-color-scheme: dark){.payment-modal-container{background:#141414!important;border-color:#202020!important}}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;bottom:0;left:0;right:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.payment-modal-loader-container{position:absolute;bottom:0;left:50%;transform:translate(-50%) scale(.8);width:100%;max-width:28.375rem;border-top-left-radius:1.5rem;border-top-right-radius:1.5rem;pointer-events:none;transform-origin:50% 100%;transition:all .3s cubic-bezier(.25,1,.5,1),opacity .2s 1s ease-out,transform .2s 1s ease-out;opacity:0}.payment-modal-loader.light-mode .payment-modal-loader-container .payment-modal-loader-logo{color:#171717}.payment-modal-loader.dark-mode .payment-modal-loader-container .payment-modal-loader-logo{color:#f0f0f0}.payment-modal-loader-container.light-mode{background:#f8f8f8}.payment-modal-loader-container.dark-mode{background:#141414}.payment-modal-loader-container.no-amount{height:361px}.payment-modal-loader-container.has-amount{height:453.84px}@media (min-width: 48rem){.payment-modal-loader-container{bottom:3rem;border-bottom-left-radius:1.5rem;border-bottom-right-radius:1.5rem}.payment-modal-loader-container.no-amount{height:348.98px}.payment-modal-loader-container.has-amount{height:441.82px}}.payment-modal-wrapper.dark-mode .payment-modal-loader-container.dark-mode{background:#141414}.payment-modal-wrapper.light-mode .payment-modal-loader-container.light-mode{background:#f8f8f8}.payment-modal-loader-container.dark-mode .payment-modal-loader{color:#94a3b8}
2
+ /*$vite$:1*/`,document.head.appendChild(vu);class Eo extends Error{response;request;options;constructor(e,n,r){const s=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${s} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${n.method} ${n.url}`),this.name="HTTPError",this.response=e,this.request=n,this.options=r}}class Ru extends Error{name="NonError";value;constructor(e){let n="Non-error value was thrown";try{typeof e=="string"?n=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(n=e.message)}catch{}super(n),this.value=e}}class vo extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Ru(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",n?{cause:n}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Au=(()=>{let t=!1,e=!1;const n=typeof globalThis.ReadableStream=="function",r=typeof globalThis.Request=="function";if(n&&r)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(s){if(s instanceof Error&&s.message==="unsupported BodyInit type")return!1;throw s}return t&&!e})(),B0=typeof globalThis.AbortController=="function",xu=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",k0=typeof globalThis.ReadableStream=="function",L0=typeof globalThis.FormData=="function",Su=["get","post","put","patch","head","delete"],P0={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},Ro=2147483647,U0=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Tu=Symbol("stop");class Ou{options;constructor(e){this.options=e}}const D0=t=>new Ou(t),F0={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},$0={next:!0},z0={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},j0=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,r]of t)e+=U0,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,e+=typeof r=="string"?new TextEncoder().encode(r).length:r.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Iu=(t,e,n)=>{let r,s=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),r){s+=r.byteLength;let a=e===0?0:s/e;a>=1&&(a=1-Number.EPSILON),n?.({percent:a,totalBytes:Math.max(e,s),transferredBytes:s},r)}r=i},flush(){r&&(s+=r.byteLength,n?.({percent:1,totalBytes:Math.max(e,s),transferredBytes:s},r))}}))},V0=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const n=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Iu(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},G0=(t,e,n)=>{if(!t.body)return t;const r=j0(n??t.body);return new Request(t,{duplex:"half",body:Iu(t.body,r,e)})},Zn=t=>t!==null&&typeof t=="object",Xs=(...t)=>{for(const e of t)if((!Zn(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return Ao({},...t)},Nu=(t={},e={})=>{const n=new globalThis.Headers(t),r=e instanceof globalThis.Headers,s=new globalThis.Headers(e);for(const[i,o]of s.entries())r&&o==="undefined"||o===void 0?n.delete(i):n.set(i,o);return n};function Qs(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:Ao(t[n]??[],e[n]??[])}const Cu=(t={},e={})=>({beforeRequest:Qs(t,e,"beforeRequest"),beforeRetry:Qs(t,e,"beforeRetry"),afterResponse:Qs(t,e,"afterResponse"),beforeError:Qs(t,e,"beforeError")}),H0=(t,e)=>{const n=new URLSearchParams;for(const r of[t,e])if(r!==void 0)if(r instanceof URLSearchParams)for(const[s,i]of r.entries())n.append(s,i);else if(Array.isArray(r))for(const s of r){if(!Array.isArray(s)||s.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");n.append(String(s[0]),String(s[1]))}else if(Zn(r))for(const[s,i]of Object.entries(r))i!==void 0&&n.append(s,String(i));else{const s=new URLSearchParams(r);for(const[i,o]of s.entries())n.append(i,o)}return n},Ao=(...t)=>{let e={},n={},r={},s;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(Zn(o)){for(let[a,d]of Object.entries(o)){if(a==="signal"&&d instanceof globalThis.AbortSignal){i.push(d);continue}if(a==="context"){if(d!=null&&(!Zn(d)||Array.isArray(d)))throw new TypeError("The `context` option must be an object");e={...e,context:d==null?{}:{...e.context,...d}};continue}if(a==="searchParams"){d==null?s=void 0:s=s===void 0?d:H0(s,d);continue}Zn(d)&&a in e&&(d=Ao(e[a],d)),e={...e,[a]:d}}Zn(o.hooks)&&(r=Cu(r,o.hooks),e.hooks=r),Zn(o.headers)&&(n=Nu(n,o.headers),e.headers=n)}return s!==void 0&&(e.searchParams=s),i.length>0&&(i.length===1?e.signal=i[0]:xu?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},q0=t=>Su.includes(t)?t.toUpperCase():t,Mu={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},K0=(t={})=>{if(typeof t=="number")return{...Mu,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Mu,...t}};class xo extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function W0(t,e,n,r){return new Promise((s,i)=>{const o=setTimeout(()=>{n&&n.abort(),i(new xo(t))},r.timeout);r.fetch(t,e).then(s).catch(i).then(()=>{clearTimeout(o)})})}async function Z0(t,{signal:e}){return new Promise((n,r)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",s,{once:!0}));function s(){clearTimeout(i),r(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",s),n()},t)})}const Y0=(t,e)=>{const n={};for(const r in e)Object.hasOwn(e,r)&&!(r in z0)&&!(r in F0)&&(!(r in t)||r in $0)&&(n[r]=e[r]);return n},J0=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function X0(t){return t instanceof Eo||t?.name===Eo.name}function Q0(t){return t instanceof xo||t?.name===xo.name}class Yr{static create(e,n){const r=new Yr(e,n),s=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>Ro)throw new RangeError(`The \`timeout\` option cannot be greater than ${Ro}`);await Promise.resolve();let o=await r.#m();for(const a of r.#e.hooks.afterResponse){const d=r.#d(o.clone()),m=await a(r.request,r.#a(),d,{retryCount:r.#n});if(m instanceof globalThis.Response&&(o=m),m instanceof Ou)throw await Promise.all([d.body?.cancel(),o.body?.cancel()]),new vo(m.options)}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new Eo(o,r.request,r.#a());for(const d of r.#e.hooks.beforeError)a=await d(a,{retryCount:r.#n});throw a}if(r.#e.onDownloadProgress){if(typeof r.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!k0)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return V0(o.clone(),r.#e.onDownloadProgress)}return o},i=r.#l(s).finally(async()=>{const o=r.#i,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),r.request.bodyUsed||a.push(r.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(P0))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||a);const d=await i;if(o==="json"){if(d.status===204)return"";const m=await d.text();return m===""?"":n.parseJson?n.parseJson(m):JSON.parse(m)}return d[o]()});return i}static#h(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0)):e}request;#r;#n=0;#t;#e;#i;#s;#o;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Nu(this.#t.headers,n.headers),hooks:Cu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:q0(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:K0(n.retry),throwHttpErrors:n.throwHttpErrors??!0,timeout:n.timeout??1e4,fetch:n.fetch??globalThis.fetch.bind(globalThis),context:n.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}B0&&xu&&(this.#s=this.#e.signal??this.#t.signal,this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal),Au&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const r=n.headers&&new globalThis.Headers(n.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(L0&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!r&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),J0(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Yr.#h(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Au)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#f(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#n);let n=e;return this.#e.retry.jitter===!0?n=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(n=this.#e.retry.jitter(e),(!Number.isFinite(n)||n<0)&&(n=e)),Math.min(this.#e.retry.backoffLimit,n)}async#p(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new Ru(e);if(n instanceof vo)return n.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const r=await this.#e.retry.shouldRetry({error:n,retryCount:this.#n});if(r===!1)throw e;if(r===!0)return this.#c()}if(Q0(e)&&!this.#e.retry.retryOnTimeout)throw e;if(X0(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const r=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(r&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let s=Number(r)*1e3;Number.isNaN(s)?s=Date.parse(r)-Date.now():s>=Date.parse("2024-01-01")&&(s-=Date.now());const i=this.#e.retry.maxRetryAfter??s;return s<i?s:i}if(e.response.status===413)throw e}return this.#c()}#d(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#l(e){try{return await e()}catch(n){const r=Math.min(await this.#p(n),Ro);if(this.#n<1)throw n;if(await Z0(r,this.#s?{signal:this.#s}:{}),n instanceof vo&&n.customRequest){const s=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#u(s)}for(const s of this.#e.hooks.beforeRetry){const i=await s({request:this.request,options:this.#a(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Tu)return}return this.#l(e)}}async#m(){this.#r?.signal.aborted&&(this.#r=new globalThis.AbortController,this.#e.signal=this.#s?AbortSignal.any([this.#s,this.#r.signal]):this.#r.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const n of this.#e.hooks.beforeRequest){const r=await n(this.request,this.#a(),{retryCount:this.#n});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#u(r);break}}const e=Y0(this.request,this.#e);return this.#i=this.request,this.request=this.#i.clone(),this.#e.timeout===!1?this.#e.fetch(this.#i,e):W0(this.#i,e,this.#r,this.#e)}#a(){if(!this.#o){const{hooks:e,...n}=this.#e;this.#o=Object.freeze(n)}return this.#o}#u(e){this.#o=void 0,this.request=this.#f(e)}#f(e,n){return!this.#e.onUploadProgress||!e.body?e:G0(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const So=t=>{const e=(n,r)=>Yr.create(n,Xs(t,r));for(const n of Su)e[n]=(r,s)=>Yr.create(r,Xs(t,s,{method:n}));return e.create=n=>So(Xs(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),So(Xs(t,n))),e.stop=Tu,e.retry=D0,e},ep=So(),Xe={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"},Bu={ARBITRUM:"ARBITRUM",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC",ETHEREUM:"ETHEREUM",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM",LISK:"LISK",MONAD:"MONAD",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON",STARKNET:"STARKNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function To(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ku(t){return To(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Lu="2.43.4";let Oo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Lu}`},Jr=class bu extends Error{constructor(e,n={}){const r=n.cause instanceof bu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof bu&&n.cause.docsPath||n.docsPath,i=Oo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Oo.version?[`Version: ${Oo.version}`]:[]].join(`
3
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Lu}walk(e){return Pu(this,e)}};function Pu(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Pu(t.cause,e):e?null:t}let Uu=class extends Jr{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}};function ei(t,{dir:e,size:n=32}={}){return typeof t=="string"?tp(t,{dir:e,size:n}):np(t,{dir:e,size:n})}function tp(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Uu({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function np(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Uu({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class rp extends Jr{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class sp extends Jr{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Io(t,{size:e}){if(ku(t)>e)throw new sp({givenSize:ku(t),maxSize:e})}function ip(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new rp({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ei(a,{size:r}):a}const op=new TextEncoder;function ap(t,e={}){return typeof t=="number"||typeof t=="bigint"?up(t,e):typeof t=="boolean"?cp(t,e):To(t)?Fu(t,e):$u(t,e)}function cp(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Io(n,{size:e.size}),ei(n,{size:e.size})):n}const gn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Du(t){if(t>=gn.zero&&t<=gn.nine)return t-gn.zero;if(t>=gn.A&&t<=gn.F)return t-(gn.A-10);if(t>=gn.a&&t<=gn.f)return t-(gn.a-10)}function Fu(t,e={}){let n=t;e.size&&(Io(n,{size:e.size}),n=ei(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=Du(r.charCodeAt(a++)),m=Du(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Jr(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function up(t,e){const n=ip(t,e);return Fu(n)}function $u(t,e={}){const n=op.encode(t);return typeof e.size=="number"?(Io(n,{size:e.size}),ei(n,{dir:"right",size:e.size})):n}const ti=BigInt(2**32-1),zu=BigInt(32);function dp(t,e=!1){return e?{h:Number(t&ti),l:Number(t>>zu&ti)}:{h:Number(t>>zu&ti)|0,l:Number(t&ti)|0}}function lp(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=dp(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const fp=(t,e,n)=>t<<n|e>>>32-n,hp=(t,e,n)=>e<<n|t>>>32-n,pp=(t,e,n)=>e<<n-32|t>>>64-n,mp=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function gp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ju(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ni(t,...e){if(!gp(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Vu(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function yp(t,e){ni(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function bp(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Gu(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const _p=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function wp(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Ep(t){for(let e=0;e<t.length;e++)t[e]=wp(t[e]);return t}const Hu=_p?t=>t:Ep;function vp(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function qu(t){return typeof t=="string"&&(t=vp(t)),ni(t),t}let Rp=class{};function Ap(t){const e=r=>t().update(qu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const xp=BigInt(0),Xr=BigInt(1),Sp=BigInt(2),Tp=BigInt(7),Op=BigInt(256),Ip=BigInt(113),Ku=[],Wu=[],Zu=[];for(let t=0,e=Xr,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Ku.push(2*(5*r+n)),Wu.push((t+1)*(t+2)/2%64);let s=xp;for(let i=0;i<7;i++)e=(e<<Xr^(e>>Tp)*Ip)%Op,e&Sp&&(s^=Xr<<(Xr<<BigInt(i))-Xr);Zu.push(s)}const Yu=lp(Zu,!0),Np=Yu[0],Cp=Yu[1],Ju=(t,e,n)=>n>32?pp(t,e,n):fp(t,e,n),Xu=(t,e,n)=>n>32?mp(t,e,n):hp(t,e,n);function Mp(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=Ju(m,g,1)^n[a],O=Xu(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Wu[o],d=Ju(s,i,a),m=Xu(s,i,a),g=Ku[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Np[r],t[1]^=Cp[r]}Gu(n)}let Bp=class N0 extends Rp{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,ju(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=bp(this.state)}clone(){return this._cloneInto()}keccak(){Hu(this.state32),Mp(this.state32,this.rounds),Hu(this.state32),this.posOut=0,this.pos=0}update(e){Vu(this),e=qu(e),ni(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Vu(this,!1),ni(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ju(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(yp(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Gu(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new N0(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}};const kp=(t,e,n)=>Ap(()=>new Bp(e,t,n)),Lp=kp(1,136,256/8);function Pp(t,e){return Lp(To(t,{strict:!1})?ap(t):t)}let Up=class extends Jr{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}};class Qu extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const No=new Qu(8192);function ed(t,e){if(No.has(`${t}.${e}`))return No.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=Pp($u(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return No.set(`${t}.${e}`,i),i}function At(t,e){if(!Fp(t,{strict:!1}))throw new Up({address:t});return ed(t,e)}const Dp=/^0x[a-fA-F0-9]{40}$/,Co=new Qu(8192);function Fp(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Co.has(r))return Co.get(r);const s=Dp.test(t)?t.toLowerCase()===t?!0:n?ed(t)===t:!0:!1;return Co.set(r,s),s}const X={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};X.USDC;const td={[Xe.ARBITRUM]:{[X.DAI]:{address:At("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:At("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:At("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:At("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ARBITRUM_TESTNET]:{[X.USDC]:{address:At("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.AVALANCHE]:{[X.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:At("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.AVALANCHE_TESTNET]:{[X.USDC]:{address:At("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.BASE]:{[X.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.USDC]:{address:At("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.WETH]:{address:At("0x4200000000000000000000000000000000000006"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.BASE_TESTNET]:{[X.USDC]:{address:At("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:X.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.BSC]:{[X.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:X.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[X.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.USDC]:{address:At("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:X.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:X.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Xe.ETHEREUM]:{[X.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:At("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:X.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[X.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:At("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:At("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:At("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ETHEREUM_TESTNET]:{[X.USDC]:{address:At("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:X.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Xe.HYPEREVM]:{[X.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.LISK]:{[X.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.MONAD]:{[X.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.MONAD_TESTNET]:{[X.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.OPTIMISM]:{[X.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[X.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.OPTIMISM_TESTNET]:{[X.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Xe.POLYGON]:{[X.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.STARKNET]:{[X.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:X.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[X.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:X.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[X.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:X.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[X.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[X.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Xe.STARKNET_TESTNET]:{[X.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},$p=new Set(Object.values(Xe));function Lt(t){if(zp(t))return t;const e=Xe[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function zp(t){return $p.has(t)}function jp(t,e){const n=e.toLowerCase().trim(),r=td[t];if(!r)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let s;for(const i in r){const o=r[i];if(o&&o.address.toLowerCase()===n.toLowerCase()){s=o;break}}if(!s)throw new Error(`Token address mismatch: address ${e} does not exist on chain ${t}. The token address must be a valid token address on the specified chain.`);return s}function Mo(t,e,n){const r=jp(t,e);if(r.symbol!==n)throw new Error(`Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${r.symbol}", but expected "${n}". The token address must correspond to a token with the expected symbol on the specified chain.`);return r}function Vp(t,e){return td[t]?.[e]}function nd(t,e){return Vp(t,e)?.address}var Bo=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(Bo||{});class Me{constructor({api_key:e,env:n,seesion_token:r,props:s}){this.api_key=e||"",this.sessionToken=r||"",this.env=n??Bo.PRODUCTION,this.props=s}static async config(e){if(!Me.app){if(!e)throw new Error("Please provide an api_key");Me.app=new Me(e)}return e&&(e.api_key!==void 0&&(Me.app.api_key=e.api_key),e.seesion_token!==void 0&&(Me.app.sessionToken=e.seesion_token),e.env!==void 0&&(Me.app.env=e.env),e.props!==void 0&&(Me.app.props=e.props)),Me.app}static getApiKey(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.api_key}static getSessionToken(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.sessionToken}static getProps(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.props}static getEnv(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Me.app.env==="internal"?"staging":Me.app.env}static getBaseUrl(){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(Me.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e){if(!Me.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=Me.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",r=Number(e),s=e&&!isNaN(Number(e))&&r>0?"/pay/":"/deposit/",i=`${e&&!isNaN(Number(e))&&r>0?r*100:""}`;return n+s+i}}let ko=null;function Gp(){ko=ep.create({prefixUrl:Me.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=Me.getSessionToken()||Me.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,n)=>n]},retry:{limit:2}})}function ze(){return ko||Gp(),ko}let Hp=class{async getById(e){return await ze().get("intents/"+e).json()}async getForSender(e){return await ze().get("intents/user/"+e).json()}async getForAddress(e){return await ze().get("intents/address/"+e).json()}async getForSession(e){return await ze().get("modal/sessions/intents/"+e).json()}async getAll(e){return await ze().get("intents",{searchParams:e}).json()}async create(e){const n=Lt(e.source_chain),r=Lt(e.destination_chain);return await ze().post("intents",{json:{...e,source_chain:n,destination_chain:r}}).json()}async createForSession(e){const n=Lt(e.sourceChain);return await ze().post("modal/sessions/intents",{json:{...e,sourceChain:n}}).json()}async update(e,n){return await ze().post("intents",{json:n}).json()}async triggerProcessing(e){return await ze().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await ze().post(`modal/sessions/intents/${e}/process`).json()}},qp=class{async getFromSpecificBridge(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/single",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getFromAllBridges(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/multiple",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getBestAcrossBridges(e){const n=Lt(e.sourceChain);Mo(n,e.tokenIn,e.amountSymbol);const r=Lt(e.destinationChain);return await ze().get("quotes/best",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAll(e){const n=Lt(e.destinationChain);return await ze().get("quotes/multi-source",{searchParams:{...e,destinationChain:n}}).json()}async getAllForSession(e){return await ze().get("modal/sessions/quotes",{searchParams:e}).json()}},Kp=class{async getOptimalRoutes(e){const n=Lt(e.sourceChain),r=Lt(e.destinationChain);return await ze().get("router/optimal-route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAllSupportedBridges(){return await ze().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const n=Lt(e.sourceChain),r=Lt(e.destinationChain);return await ze().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getSupportedRoutes(e){return await ze().get("router/supported-routes/bridge/"+e).json()}},Wp=class{async getSupported(e){return await ze().get("chains",{searchParams:e}).json()}async getBalance(e){return await ze().get(`chains/balances/${e.address}`,{searchParams:e}).json()}},Zp=class{async getClientInfo(){return await ze().get("client/auth/client-info").json()}async getClientInfoForSession(){return await ze().get("modal/sessions/client").json()}},Yp=class{async getSessionToken(e){const n=Lt(e.destinationChain);let r=nd(n,e.token);r||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),r=nd(n,"USDC"));const s={recipient:e.recipient,tokenOut:r,destinationChain:n,amount:e.amount};return ze().post("modal/sessions",{json:s}).json().then(i=>({...i,amount:s.amount}))}};const Jp={router:new Kp,quotes:new qp,intents:new Hp,chains:new Wp,client:new Zp,auth:new Yp};function rd(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var s=t.length;for(e=0;e<s;e++)t[e]&&(n=rd(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Lo(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=rd(t))&&(r&&(r+=" "),r+=e);return r}const cn={CLOSED:"closed",COMPLETED:"completed",AUTH:"session",REQUEST_FARCASTER_CONNECT:"cr:request-farcaster-connect",REQUEST_FARCASTER_DISCONNECT:"cr:request-farcaster-disconnect",REQUEST_FARCASTER_SEND_TRANSACTION:"cr:request-farcaster-send-transaction",FARCASTER_SEND_TRANSACTION_RESULT:"cr:farcaster-send-transaction-result",FARCASTER_CONNECTED:"cr:farcaster-connected",FARCASTER_DISCONNECTED:"cr:farcaster-disconnected",IN_FARCASTER_MINI_APP:"cr:in-farcaster-mini-app"},Po="https://app.chainrails.io",Uo="https://chainrails-frontend-git-staging-horus-labs.vercel.app",Xp=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];function mr(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new cm(t.type);return`${t.name}(${Do(t.inputs,{includeName:e})})`}function Do(t,{includeName:e=!1}={}){return t?t.map(n=>Qp(n,{includeName:e})).join(e?", ":","):""}function Qp(t,{includeName:e}){return t.type.startsWith("tuple")?`(${Do(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function Cn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function bt(t){return Cn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const sd="2.43.4";let Fo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${sd}`},ue=class _u extends Error{constructor(e,n={}){const r=n.cause instanceof _u?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof _u&&n.cause.docsPath||n.docsPath,i=Fo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Fo.version?[`Version: ${Fo.version}`]:[]].join(`
4
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=sd}walk(e){return id(this,e)}};function id(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?id(t.cause,e):e?null:t}class em extends ue{constructor({data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
5
+ `),{metaMessages:[`Params: (${Do(n,{includeName:!0})})`,`Data: ${e} (${r} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e,this.params=n,this.size=r}}class $o extends ue{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class tm extends ue{constructor({expectedLength:e,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${e}`,`Given length: ${n}`].join(`
6
6
  `),{name:"AbiEncodingArrayLengthMismatchError"})}}class nm extends ue{constructor({expectedSize:e,value:n}){super(`Size of bytes "${n}" (bytes${bt(n)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class rm extends ue{constructor({expectedLength:e,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${n}`].join(`
7
- `),{name:"AbiEncodingLengthMismatchError"})}}class id extends ue{constructor(e,{docsPath:n}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(`
8
- `),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class od extends ue{constructor(e,{docsPath:n}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
7
+ `),{name:"AbiEncodingLengthMismatchError"})}}class od extends ue{constructor(e,{docsPath:n}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(`
8
+ `),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class ad extends ue{constructor(e,{docsPath:n}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(`
9
9
  `),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class sm extends ue{constructor(e,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${mr(e.abiItem)}\`, and`,`\`${n.type}\` in \`${mr(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class im extends ue{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
10
10
  `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class om extends ue{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
11
11
  `),{docsPath:n,name:"InvalidAbiDecodingType"})}}class am extends ue{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
12
12
  `),{name:"InvalidArrayError"})}}class cm extends ue{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
13
- `),{name:"InvalidDefinitionTypeError"})}}class Qr extends ue{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class ad extends ue{constructor({offset:e,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class cd extends ue{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}class ud extends ue{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${e} ${r} long.`,{name:"InvalidBytesLengthError"})}}function gr(t,{dir:e,size:n=32}={}){return typeof t=="string"?Cn(t,{dir:e,size:n}):um(t,{dir:e,size:n})}function Cn(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new cd({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function um(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new cd({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class dd extends ue{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class dm extends ue{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class lm extends ue{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class fm extends ue{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Yn(t,{dir:e="left"}={}){let n=typeof t=="string"?t.replace("0x",""):t,r=0;for(let s=0;s<n.length-1&&n[e==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=e==="left"?n.slice(r):n.slice(0,n.length-r),typeof t=="string"?(n.length===1&&e==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function Jt(t,{size:e}){if(bt(t)>e)throw new fm({givenSize:bt(t),maxSize:e})}function hm(t,e){const n={to:e},r=n.to;return r==="number"?Jn(t,n):r==="bigint"?yr(t,n):r==="string"?mm(t,n):r==="boolean"?pm(t,n):Qt(t,n)}function yr(t,e={}){const{signed:n}=e;e.size&&Jt(t,{size:e.size});const r=BigInt(t);if(!n)return r;const s=(t.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function pm(t,e={}){let n=t;if(e.size&&(Jt(n,{size:e.size}),n=Yn(n)),Yn(n)==="0x00")return!1;if(Yn(n)==="0x01")return!0;throw new lm(n)}function Jn(t,e={}){return Number(yr(t,e))}function mm(t,e={}){let n=Qt(t);return e.size&&(Jt(n,{size:e.size}),n=Yn(n,{dir:"right"})),new TextDecoder().decode(n)}const gm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function $o(t,e={}){return typeof t=="number"||typeof t=="bigint"?ke(t,e):typeof t=="string"?zo(t,e):typeof t=="boolean"?ld(t,e):zt(t,e)}function ld(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(Jt(n,{size:e.size}),gr(n,{size:e.size})):n}function zt(t,e={}){let n="";for(let s=0;s<t.length;s++)n+=gm[t[s]];const r=`0x${n}`;return typeof e.size=="number"?(Jt(r,{size:e.size}),gr(r,{dir:"right",size:e.size})):r}function ke(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new dd({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?gr(a,{size:r}):a}const ym=new TextEncoder;function zo(t,e={}){const n=ym.encode(t);return zt(n,e)}const bm=new TextEncoder;function jo(t,e={}){return typeof t=="number"||typeof t=="bigint"?wm(t,e):typeof t=="boolean"?_m(t,e):Nn(t)?Qt(t,e):hd(t,e)}function _m(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Jt(n,{size:e.size}),gr(n,{size:e.size})):n}const gn={zero:48,nine:57,A:65,F:70,a:97,f:102};function fd(t){if(t>=gn.zero&&t<=gn.nine)return t-gn.zero;if(t>=gn.A&&t<=gn.F)return t-(gn.A-10);if(t>=gn.a&&t<=gn.f)return t-(gn.a-10)}function Qt(t,e={}){let n=t;e.size&&(Jt(n,{size:e.size}),n=gr(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=fd(r.charCodeAt(a++)),m=fd(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new ue(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function wm(t,e){const n=ke(t,e);return Qt(n)}function hd(t,e={}){const n=bm.encode(t);return typeof e.size=="number"?(Jt(n,{size:e.size}),gr(n,{dir:"right",size:e.size})):n}const ri=BigInt(2**32-1),pd=BigInt(32);function Em(t,e=!1){return e?{h:Number(t&ri),l:Number(t>>pd&ri)}:{h:Number(t>>pd&ri)|0,l:Number(t&ri)|0}}function md(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=Em(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const gd=(t,e,n)=>t>>>n,yd=(t,e,n)=>t<<32-n|e>>>n,br=(t,e,n)=>t>>>n|e<<32-n,_r=(t,e,n)=>t<<32-n|e>>>n,si=(t,e,n)=>t<<64-n|e>>>n-32,ii=(t,e,n)=>t>>>n-32|e<<64-n,vm=(t,e,n)=>t<<n|e>>>32-n,Rm=(t,e,n)=>e<<n|t>>>32-n,Am=(t,e,n)=>e<<n-32|t>>>64-n,xm=(t,e,n)=>t<<n-32|e>>>64-n;function yn(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Sm=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Tm=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Om=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Im=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Nm=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Cm=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,wr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function es(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Xn(t,...e){if(!Mm(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Bm(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");es(t.outputLen),es(t.blockLen)}function Er(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function bd(t,e){Xn(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function km(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Mn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Vo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function cn(t,e){return t<<32-e|t>>>e}const Lm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Pm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Um(t){for(let e=0;e<t.length;e++)t[e]=Pm(t[e]);return t}const _d=Lm?t=>t:Um;function Dm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function oi(t){return typeof t=="string"&&(t=Dm(t)),Xn(t),t}function Fm(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];Xn(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}class Go{}function Ho(t){const e=r=>t().update(oi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function wd(t=32){if(wr&&typeof wr.getRandomValues=="function")return wr.getRandomValues(new Uint8Array(t));if(wr&&typeof wr.randomBytes=="function")return Uint8Array.from(wr.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const $m=BigInt(0),ts=BigInt(1),zm=BigInt(2),jm=BigInt(7),Vm=BigInt(256),Gm=BigInt(113),Ed=[],vd=[],Rd=[];for(let t=0,e=ts,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Ed.push(2*(5*r+n)),vd.push((t+1)*(t+2)/2%64);let s=$m;for(let i=0;i<7;i++)e=(e<<ts^(e>>jm)*Gm)%Vm,e&zm&&(s^=ts<<(ts<<BigInt(i))-ts);Rd.push(s)}const Ad=md(Rd,!0),Hm=Ad[0],qm=Ad[1],xd=(t,e,n)=>n>32?Am(t,e,n):vm(t,e,n),Sd=(t,e,n)=>n>32?xm(t,e,n):Rm(t,e,n);function Km(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=xd(m,g,1)^n[a],O=Sd(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=vd[o],d=xd(s,i,a),m=Sd(s,i,a),g=Ed[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Hm[r],t[1]^=qm[r]}Mn(n)}class qo extends Go{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,es(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=km(this.state)}clone(){return this._cloneInto()}keccak(){_d(this.state32),Km(this.state32,this.rounds),_d(this.state32),this.posOut=0,this.pos=0}update(e){Er(this),e=oi(e),Xn(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Er(this,!1),Xn(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return es(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(bd(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Mn(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new qo(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Wm=(t,e,n)=>Ho(()=>new qo(e,t,n)),Zm=Wm(1,136,256/8);function ai(t,e){const n=e||"hex",r=Zm(Nn(t,{strict:!1})?jo(t):t);return n==="bytes"?r:$o(r)}class ns extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Ym=/^0x[a-fA-F0-9]{40}$/,Ko=new ns(8192);function Bn(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Ko.has(r))return Ko.get(r);const s=Ym.test(t)?t.toLowerCase()===t?!0:n?ci(t)===t:!0:!1;return Ko.set(r,s),s}const Wo=new ns(8192);function ci(t,e){if(Wo.has(`${t}.${e}`))return Wo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=ai(hd(n),"bytes"),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return Wo.set(`${t}.${e}`,i),i}function ui(t,e){if(!Bn(t,{strict:!1}))throw new Qr({address:t});return ci(t,e)}class Td extends ue{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Jm extends ue{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class Xm extends ue{constructor({count:e,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const Qm={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Xm({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new Jm({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Td({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new Td({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function Zo(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(Qm);return n.bytes=t,n.dataView=new DataView(t.buffer??t,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}function di(t,e,n,{strict:r}={}){return Nn(t,{strict:!1})?eg(t,e,n,{strict:r}):Nd(t,e,n,{strict:r})}function Od(t,e){if(typeof e=="number"&&e>0&&e>bt(t)-1)throw new ad({offset:e,position:"start",size:bt(t)})}function Id(t,e,n){if(typeof e=="number"&&typeof n=="number"&&bt(t)!==n-e)throw new ad({offset:n,position:"end",size:bt(t)})}function Nd(t,e,n,{strict:r}={}){Od(t,e);const s=t.slice(e,n);return r&&Id(s,e,n),s}function eg(t,e,n,{strict:r}={}){Od(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(n??t.length)*2)}`;return r&&Id(s,e,n),s}function tg(t,e={}){typeof e.size<"u"&&Jt(t,{size:e.size});const n=zt(t,e);return yr(n,e)}function ng(t,e={}){let n=t;if(typeof e.size<"u"&&(Jt(n,{size:e.size}),n=Yn(n)),n.length>1||n[0]>1)throw new dm(n);return!!n[0]}function bn(t,e={}){typeof e.size<"u"&&Jt(t,{size:e.size});const n=zt(t,e);return Jn(n,e)}function rg(t,e={}){let n=t;return typeof e.size<"u"&&(Jt(n,{size:e.size}),n=Yn(n,{dir:"right"})),new TextDecoder().decode(n)}function vr(t){return typeof t[0]=="string"?Yo(t):sg(t)}function sg(t){let e=0;for(const s of t)e+=s.length;const n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Yo(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}const ig=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function og(t,e){if(t.length!==e.length)throw new rm({expectedLength:t.length,givenLength:e.length});const n=ag({params:t,values:e}),r=Xo(n);return r.length===0?"0x":r}function ag({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(Jo({param:t[r],value:e[r]}));return n}function Jo({param:t,value:e}){const n=Qo(t.type);if(n){const[r,s]=n;return ug(e,{length:r,param:{...t,type:s}})}if(t.type==="tuple")return pg(e,{param:t});if(t.type==="address")return cg(e);if(t.type==="bool")return lg(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const r=t.type.startsWith("int"),[,,s="256"]=ig.exec(t.type)??[];return fg(e,{signed:r,size:Number(s)})}if(t.type.startsWith("bytes"))return dg(e,{param:t});if(t.type==="string")return hg(e);throw new im(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Xo(t){let e=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?e+=32:e+=bt(a)}const n=[],r=[];let s=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?(n.push(ke(e+s,{size:32})),r.push(a),s+=bt(a)):n.push(a)}return vr([...n,...r])}function cg(t){if(!Bn(t))throw new Qr({address:t});return{dynamic:!1,encoded:Cn(t.toLowerCase())}}function ug(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new am(t);if(!r&&t.length!==e)throw new tm({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let s=!1;const i=[];for(let o=0;o<t.length;o++){const a=Jo({param:n,value:t[o]});a.dynamic&&(s=!0),i.push(a)}if(r||s){const o=Xo(i);if(r){const a=ke(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?vr([a,o]):a}}if(s)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:vr(i.map(({encoded:o})=>o))}}function dg(t,{param:e}){const[,n]=e.type.split("bytes"),r=bt(t);if(!n){let s=t;return r%32!==0&&(s=Cn(s,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:vr([Cn(ke(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new nm({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:Cn(t,{dir:"right"})}}function lg(t){if(typeof t!="boolean")throw new ue(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Cn(ld(t))}}function fg(t,{signed:e,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(e?1n:0n))-1n,s=e?-r-1n:0n;if(t>r||t<s)throw new dd({max:r.toString(),min:s.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:ke(t,{size:32,signed:e})}}function hg(t){const e=zo(t),n=Math.ceil(bt(e)/32),r=[];for(let s=0;s<n;s++)r.push(Cn(di(e,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:vr([Cn(ke(bt(e),{size:32})),...r])}}function pg(t,{param:e}){let n=!1;const r=[];for(let s=0;s<e.components.length;s++){const i=e.components[s],o=Array.isArray(t)?s:i.name,a=Jo({param:i,value:t[o]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Xo(r):vr(r.map(({encoded:s})=>s))}}function Qo(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function mg(t,e){const n=typeof e=="string"?Qt(e):e,r=Zo(n);if(bt(n)===0&&t.length>0)throw new Fo;if(bt(e)&&bt(e)<32)throw new em({data:typeof e=="string"?e:zt(e),params:t,size:bt(e)});let s=0;const i=[];for(let o=0;o<t.length;++o){const a=t[o];r.setPosition(s);const[d,m]=Rr(r,a,{staticPosition:0});s+=m,i.push(d)}return i}function Rr(t,e,{staticPosition:n}){const r=Qo(e.type);if(r){const[s,i]=r;return yg(t,{...e,type:i},{length:s,staticPosition:n})}if(e.type==="tuple")return Eg(t,e,{staticPosition:n});if(e.type==="address")return gg(t);if(e.type==="bool")return bg(t);if(e.type.startsWith("bytes"))return _g(t,e,{staticPosition:n});if(e.type.startsWith("uint")||e.type.startsWith("int"))return wg(t,e);if(e.type==="string")return vg(t,{staticPosition:n});throw new om(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Cd=32,ea=32;function gg(t){const e=t.readBytes(32);return[ci(zt(Nd(e,-20))),32]}function yg(t,e,{length:n,staticPosition:r}){if(!n){const o=bn(t.readBytes(ea)),a=r+o,d=a+Cd;t.setPosition(a);const m=bn(t.readBytes(Cd)),g=rs(e);let x=0;const O=[];for(let N=0;N<m;++N){t.setPosition(d+(g?N*32:x));const[F,M]=Rr(t,e,{staticPosition:d});x+=M,O.push(F)}return t.setPosition(r+32),[O,32]}if(rs(e)){const o=bn(t.readBytes(ea)),a=r+o,d=[];for(let m=0;m<n;++m){t.setPosition(a+m*32);const[g]=Rr(t,e,{staticPosition:a});d.push(g)}return t.setPosition(r+32),[d,32]}let s=0;const i=[];for(let o=0;o<n;++o){const[a,d]=Rr(t,e,{staticPosition:r+s});s+=d,i.push(a)}return[i,s]}function bg(t){return[ng(t.readBytes(32),{size:32}),32]}function _g(t,e,{staticPosition:n}){const[r,s]=e.type.split("bytes");if(!s){const o=bn(t.readBytes(32));t.setPosition(n+o);const a=bn(t.readBytes(32));if(a===0)return t.setPosition(n+32),["0x",32];const d=t.readBytes(a);return t.setPosition(n+32),[zt(d),32]}return[zt(t.readBytes(Number.parseInt(s,10),32)),32]}function wg(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),s=t.readBytes(32);return[r>48?tg(s,{signed:n}):bn(s,{signed:n}),32]}function Eg(t,e,{staticPosition:n}){const r=e.components.length===0||e.components.some(({name:o})=>!o),s=r?[]:{};let i=0;if(rs(e)){const o=bn(t.readBytes(ea)),a=n+o;for(let d=0;d<e.components.length;++d){const m=e.components[d];t.setPosition(a+i);const[g,x]=Rr(t,m,{staticPosition:a});i+=x,s[r?d:m?.name]=g}return t.setPosition(n+32),[s,32]}for(let o=0;o<e.components.length;++o){const a=e.components[o],[d,m]=Rr(t,a,{staticPosition:n});s[r?o:a?.name]=d,i+=m}return[s,i]}function vg(t,{staticPosition:e}){const n=bn(t.readBytes(32)),r=e+n;t.setPosition(r);const s=bn(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const i=t.readBytes(s,32),o=rg(Yn(i));return t.setPosition(e+32),[o,32]}function rs(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(rs);const n=Qo(t.type);return!!(n&&rs({...t,type:n[1]}))}const Rg=t=>ai(jo(t));function Ag(t){return Rg(t)}function xg(t,e){return t.exec(e)?.groups}const Md=/^tuple(?<array>(\[(\d*)\])*)$/;function ta(t){let e=t.type;if(Md.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let s=0;s<n;s++){const i=t.components[s];e+=ta(i),s<n-1&&(e+=", ")}const r=xg(Md,t.type);return e+=`)${r?.array||""}`,ta({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function ss(t){let e="";const n=t.length;for(let r=0;r<n;r++){const s=t[r];e+=ta(s),r!==n-1&&(e+=", ")}return e}function Sg(t){return t.type==="function"?`function ${t.name}(${ss(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${ss(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${ss(t.inputs)})`:t.type==="error"?`error ${t.name}(${ss(t.inputs)})`:t.type==="constructor"?`constructor(${ss(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}function Tg(t){let e=!0,n="",r=0,s="",i=!1;for(let o=0;o<t.length;o++){const a=t[o];if(["(",")",","].includes(a)&&(e=!0),a==="("&&r++,a===")"&&r--,!!e){if(r===0){if(a===" "&&["event","function",""].includes(s))s="";else if(s+=a,a===")"){i=!0;break}continue}if(a===" "){t[o-1]!==","&&n!==","&&n!==",("&&(n="",e=!1);continue}s+=a,n+=a}}if(!i)throw new ue("Unable to normalize signature.");return s}const Og=t=>{const e=typeof t=="string"?t:Sg(t);return Tg(e)};function Bd(t){return Ag(Og(t))}const Ig=Bd,na=t=>di(Bd(t),0,4);function kd(t){const{abi:e,args:n=[],name:r}=t,s=Nn(r,{strict:!1}),i=e.filter(a=>s?a.type==="function"?na(a)===r:a.type==="event"?Ig(a)===r:!1:"name"in a&&a.name===r);if(i.length===0)return;if(i.length===1)return i[0];let o;for(const a of i){if(!("inputs"in a))continue;if(!n||n.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==n.length)continue;if(n.every((m,g)=>{const x="inputs"in a&&a.inputs[g];return x?ra(m,x):!1})){if(o&&"inputs"in o&&o.inputs){const m=Ld(a.inputs,o.inputs,n);if(m)throw new sm({abiItem:a,type:m[0]},{abiItem:o,type:m[1]})}o=a}}return o||i[0]}function ra(t,e){const n=typeof t,r=e.type;switch(r){case"address":return Bn(t,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in e?Object.values(e.components).every((s,i)=>n==="object"&&ra(Object.values(t)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(t)&&t.every(s=>ra(s,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Ld(t,e,n){for(const r in t){const s=t[r],i=e[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Ld(s.components,i.components,n[r]);const o=[s.type,i.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?Bn(n[r],{strict:!1}):o.includes("address")&&o.includes("bytes")?Bn(n[r],{strict:!1}):!1)return o}}const Pd="/docs/contract/encodeFunctionData";function Ng(t){const{abi:e,args:n,functionName:r}=t;let s=e[0];if(r){const i=kd({abi:e,args:n,name:r});if(!i)throw new od(r,{docsPath:Pd});s=i}if(s.type!=="function")throw new od(void 0,{docsPath:Pd});return{abi:[s],functionName:na(mr(s))}}function Cg(t){const{args:e}=t,{abi:n,functionName:r}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:Ng(t),s=n[0],i=r,o="inputs"in s&&s.inputs?og(s.inputs,e??[]):void 0;return Yo([i,o??"0x"])}class Mg extends ue{constructor({chain:e,currentChainId:n}){super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class Bg extends ue{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
14
- `),{name:"ChainNotFoundError"})}}function _n(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const kg={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},Lg={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},Pg={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function Ug(t){const{abi:e,data:n}=t,r=di(n,0,4);if(r==="0x")throw new Fo;const i=[...e||[],Lg,Pg].find(o=>o.type==="error"&&r===na(mr(o)));if(!i)throw new id(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?mg(i.inputs,di(n,4)):void 0,errorName:i.name}}const li=(t,e,n)=>JSON.stringify(t,(r,s)=>typeof s=="bigint"?s.toString():s,n);function Ud({abiItem:t,args:e,includeFunctionName:n=!0,includeName:r=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${n?t.name:""}(${t.inputs.map((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof e[i]=="object"?li(e[i]):e[i]}`).join(", ")})`}const Dg={gwei:9,wei:18},Fg={ether:-9,wei:9};function Dd(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[s,i]=[n.slice(0,n.length-e),n.slice(n.length-e)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function Fd(t,e="wei"){return Dd(t,Dg[e])}function en(t,e="wei"){return Dd(t,Fg[e])}class $g extends ue{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class zg extends ue{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function fi(t){const e=Object.entries(t).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=e.reduce((r,[s])=>Math.max(r,s.length),0);return e.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
15
- `)}class jg extends ue{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",fi(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Vg extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:x,value:O}){const N=fi({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:x,value:typeof O<"u"&&`${Fd(O)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${en(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${en(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${en(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",N].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const Gg=t=>t,$d=t=>t;class Hg extends ue{constructor(e,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:o,sender:a}){const d=kd({abi:n,args:r,name:o}),m=d?Ud({abiItem:d,args:r,includeFunctionName:!1,includeName:!1}):void 0,g=d?mr(d,{includeName:!0}):void 0,x=fi({address:s&&Gg(s),function:g,args:m&&m!=="()"&&`${[...Array(o?.length??0).keys()].map(()=>" ").join("")}${m}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:e,docsPath:i,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],x&&"Contract Call:",x].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=n,this.args=r,this.cause=e,this.contractAddress=s,this.functionName=o,this.sender=a}}class qg extends ue{constructor({abi:e,data:n,functionName:r,message:s}){let i,o,a,d;if(n&&n!=="0x")try{o=Ug({abi:e,data:n});const{abiItem:g,errorName:x,args:O}=o;if(x==="Error")d=O[0];else if(x==="Panic"){const[N]=O;d=kg[N]}else{const N=g?mr(g,{includeName:!0}):void 0,F=g&&O?Ud({abiItem:g,args:O,includeFunctionName:!1,includeName:!1}):void 0;a=[N?`Error: ${N}`:"",F&&F!=="()"?` ${[...Array(x?.length??0).keys()].map(()=>" ").join("")}${F}`:""]}}catch(g){i=g}else s&&(d=s);let m;i instanceof id&&(m=i.signature,a=[`Unable to decode signature "${m}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${m}.`]),super(d&&d!=="execution reverted"||m?[`The contract function "${r}" reverted with the following ${m?"signature":"reason"}:`,d||m].join(`
16
- `):`The contract function "${r}" reverted.`,{cause:i,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=n,this.reason=d,this.signature=m}}class Kg extends ue{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Wg extends ue{constructor({data:e,message:n}){super(n||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}function xt(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}class zd extends ue{constructor({body:e,cause:n,details:r,headers:s,status:i,url:o}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${$d(o)}`,e&&`Request body: ${li(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=s,this.status=i,this.url=o}}class jd extends ue{constructor({body:e,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${$d(r)}`,`Request body: ${li(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const Zg=-1;class jt extends ue{constructor(e,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:o}){super(o,{cause:e,docsPath:r,metaMessages:s||e?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||e.name,this.code=e instanceof jd?e.code:n??Zg}}let Ht=class extends jt{constructor(e,n){super(e,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}};class is extends jt{constructor(e){super(e,{code:is.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(is,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class os extends jt{constructor(e){super(e,{code:os.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(os,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class as extends jt{constructor(e,{method:n}={}){super(e,{code:as.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(as,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class cs extends jt{constructor(e){super(e,{code:cs.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
13
+ `),{name:"InvalidDefinitionTypeError"})}}class Qr extends ue{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class cd extends ue{constructor({offset:e,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class ud extends ue{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}class dd extends ue{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} is expected to be ${n} ${r} long, but is ${e} ${r} long.`,{name:"InvalidBytesLengthError"})}}function gr(t,{dir:e,size:n=32}={}){return typeof t=="string"?Mn(t,{dir:e,size:n}):um(t,{dir:e,size:n})}function Mn(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new ud({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function um(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new ud({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class ld extends ue{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class dm extends ue{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class lm extends ue{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}class fm extends ue{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Yn(t,{dir:e="left"}={}){let n=typeof t=="string"?t.replace("0x",""):t,r=0;for(let s=0;s<n.length-1&&n[e==="left"?s:n.length-s-1].toString()==="0";s++)r++;return n=e==="left"?n.slice(r):n.slice(0,n.length-r),typeof t=="string"?(n.length===1&&e==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function Xt(t,{size:e}){if(bt(t)>e)throw new fm({givenSize:bt(t),maxSize:e})}function hm(t,e){const n={to:e},r=n.to;return r==="number"?Jn(t,n):r==="bigint"?yr(t,n):r==="string"?mm(t,n):r==="boolean"?pm(t,n):en(t,n)}function yr(t,e={}){const{signed:n}=e;e.size&&Xt(t,{size:e.size});const r=BigInt(t);if(!n)return r;const s=(t.length-2)/2,i=(1n<<BigInt(s)*8n-1n)-1n;return r<=i?r:r-BigInt(`0x${"f".padStart(s*2,"f")}`)-1n}function pm(t,e={}){let n=t;if(e.size&&(Xt(n,{size:e.size}),n=Yn(n)),Yn(n)==="0x00")return!1;if(Yn(n)==="0x01")return!0;throw new lm(n)}function Jn(t,e={}){return Number(yr(t,e))}function mm(t,e={}){let n=en(t);return e.size&&(Xt(n,{size:e.size}),n=Yn(n,{dir:"right"})),new TextDecoder().decode(n)}const gm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function zo(t,e={}){return typeof t=="number"||typeof t=="bigint"?ke(t,e):typeof t=="string"?jo(t,e):typeof t=="boolean"?fd(t,e):zt(t,e)}function fd(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(Xt(n,{size:e.size}),gr(n,{size:e.size})):n}function zt(t,e={}){let n="";for(let s=0;s<t.length;s++)n+=gm[t[s]];const r=`0x${n}`;return typeof e.size=="number"?(Xt(r,{size:e.size}),gr(r,{dir:"right",size:e.size})):r}function ke(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new ld({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?gr(a,{size:r}):a}const ym=new TextEncoder;function jo(t,e={}){const n=ym.encode(t);return zt(n,e)}const bm=new TextEncoder;function Vo(t,e={}){return typeof t=="number"||typeof t=="bigint"?wm(t,e):typeof t=="boolean"?_m(t,e):Cn(t)?en(t,e):pd(t,e)}function _m(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Xt(n,{size:e.size}),gr(n,{size:e.size})):n}const yn={zero:48,nine:57,A:65,F:70,a:97,f:102};function hd(t){if(t>=yn.zero&&t<=yn.nine)return t-yn.zero;if(t>=yn.A&&t<=yn.F)return t-(yn.A-10);if(t>=yn.a&&t<=yn.f)return t-(yn.a-10)}function en(t,e={}){let n=t;e.size&&(Xt(n,{size:e.size}),n=gr(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=hd(r.charCodeAt(a++)),m=hd(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new ue(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function wm(t,e){const n=ke(t,e);return en(n)}function pd(t,e={}){const n=bm.encode(t);return typeof e.size=="number"?(Xt(n,{size:e.size}),gr(n,{dir:"right",size:e.size})):n}const ri=BigInt(2**32-1),md=BigInt(32);function Em(t,e=!1){return e?{h:Number(t&ri),l:Number(t>>md&ri)}:{h:Number(t>>md&ri)|0,l:Number(t&ri)|0}}function gd(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=Em(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const yd=(t,e,n)=>t>>>n,bd=(t,e,n)=>t<<32-n|e>>>n,br=(t,e,n)=>t>>>n|e<<32-n,_r=(t,e,n)=>t<<32-n|e>>>n,si=(t,e,n)=>t<<64-n|e>>>n-32,ii=(t,e,n)=>t>>>n-32|e<<64-n,vm=(t,e,n)=>t<<n|e>>>32-n,Rm=(t,e,n)=>e<<n|t>>>32-n,Am=(t,e,n)=>e<<n-32|t>>>64-n,xm=(t,e,n)=>t<<n-32|e>>>64-n;function bn(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Sm=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Tm=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Om=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Im=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Nm=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Cm=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,wr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Mm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function es(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Xn(t,...e){if(!Mm(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Bm(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");es(t.outputLen),es(t.blockLen)}function Er(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function _d(t,e){Xn(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function km(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Bn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Go(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function un(t,e){return t<<32-e|t>>>e}const Lm=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Pm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Um(t){for(let e=0;e<t.length;e++)t[e]=Pm(t[e]);return t}const wd=Lm?t=>t:Um;function Dm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function oi(t){return typeof t=="string"&&(t=Dm(t)),Xn(t),t}function Fm(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];Xn(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}class Ho{}function qo(t){const e=r=>t().update(oi(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ed(t=32){if(wr&&typeof wr.getRandomValues=="function")return wr.getRandomValues(new Uint8Array(t));if(wr&&typeof wr.randomBytes=="function")return Uint8Array.from(wr.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const $m=BigInt(0),ts=BigInt(1),zm=BigInt(2),jm=BigInt(7),Vm=BigInt(256),Gm=BigInt(113),vd=[],Rd=[],Ad=[];for(let t=0,e=ts,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],vd.push(2*(5*r+n)),Rd.push((t+1)*(t+2)/2%64);let s=$m;for(let i=0;i<7;i++)e=(e<<ts^(e>>jm)*Gm)%Vm,e&zm&&(s^=ts<<(ts<<BigInt(i))-ts);Ad.push(s)}const xd=gd(Ad,!0),Hm=xd[0],qm=xd[1],Sd=(t,e,n)=>n>32?Am(t,e,n):vm(t,e,n),Td=(t,e,n)=>n>32?xm(t,e,n):Rm(t,e,n);function Km(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=Sd(m,g,1)^n[a],O=Td(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Rd[o],d=Sd(s,i,a),m=Td(s,i,a),g=vd[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=Hm[r],t[1]^=qm[r]}Bn(n)}class Ko extends Ho{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,es(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=km(this.state)}clone(){return this._cloneInto()}keccak(){wd(this.state32),Km(this.state32,this.rounds),wd(this.state32),this.posOut=0,this.pos=0}update(e){Er(this),e=oi(e),Xn(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Er(this,!1),Xn(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return es(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(_d(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Bn(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Ko(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Wm=(t,e,n)=>qo(()=>new Ko(e,t,n)),Zm=Wm(1,136,256/8);function ai(t,e){const n=e||"hex",r=Zm(Cn(t,{strict:!1})?Vo(t):t);return n==="bytes"?r:zo(r)}class ns extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const Ym=/^0x[a-fA-F0-9]{40}$/,Wo=new ns(8192);function kn(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Wo.has(r))return Wo.get(r);const s=Ym.test(t)?t.toLowerCase()===t?!0:n?ci(t)===t:!0:!1;return Wo.set(r,s),s}const Zo=new ns(8192);function ci(t,e){if(Zo.has(`${t}.${e}`))return Zo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=ai(pd(n),"bytes"),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return Zo.set(`${t}.${e}`,i),i}function ui(t,e){if(!kn(t,{strict:!1}))throw new Qr({address:t});return ci(t,e)}class Od extends ue{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class Jm extends ue{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class Xm extends ue{constructor({count:e,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const Qm={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Xm({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new Jm({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Od({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new Od({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function Yo(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(Qm);return n.bytes=t,n.dataView=new DataView(t.buffer??t,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}function di(t,e,n,{strict:r}={}){return Cn(t,{strict:!1})?eg(t,e,n,{strict:r}):Cd(t,e,n,{strict:r})}function Id(t,e){if(typeof e=="number"&&e>0&&e>bt(t)-1)throw new cd({offset:e,position:"start",size:bt(t)})}function Nd(t,e,n){if(typeof e=="number"&&typeof n=="number"&&bt(t)!==n-e)throw new cd({offset:n,position:"end",size:bt(t)})}function Cd(t,e,n,{strict:r}={}){Id(t,e);const s=t.slice(e,n);return r&&Nd(s,e,n),s}function eg(t,e,n,{strict:r}={}){Id(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(n??t.length)*2)}`;return r&&Nd(s,e,n),s}function tg(t,e={}){typeof e.size<"u"&&Xt(t,{size:e.size});const n=zt(t,e);return yr(n,e)}function ng(t,e={}){let n=t;if(typeof e.size<"u"&&(Xt(n,{size:e.size}),n=Yn(n)),n.length>1||n[0]>1)throw new dm(n);return!!n[0]}function _n(t,e={}){typeof e.size<"u"&&Xt(t,{size:e.size});const n=zt(t,e);return Jn(n,e)}function rg(t,e={}){let n=t;return typeof e.size<"u"&&(Xt(n,{size:e.size}),n=Yn(n,{dir:"right"})),new TextDecoder().decode(n)}function vr(t){return typeof t[0]=="string"?Jo(t):sg(t)}function sg(t){let e=0;for(const s of t)e+=s.length;const n=new Uint8Array(e);let r=0;for(const s of t)n.set(s,r),r+=s.length;return n}function Jo(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}const ig=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function og(t,e){if(t.length!==e.length)throw new rm({expectedLength:t.length,givenLength:e.length});const n=ag({params:t,values:e}),r=Qo(n);return r.length===0?"0x":r}function ag({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(Xo({param:t[r],value:e[r]}));return n}function Xo({param:t,value:e}){const n=ea(t.type);if(n){const[r,s]=n;return ug(e,{length:r,param:{...t,type:s}})}if(t.type==="tuple")return pg(e,{param:t});if(t.type==="address")return cg(e);if(t.type==="bool")return lg(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const r=t.type.startsWith("int"),[,,s="256"]=ig.exec(t.type)??[];return fg(e,{signed:r,size:Number(s)})}if(t.type.startsWith("bytes"))return dg(e,{param:t});if(t.type==="string")return hg(e);throw new im(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Qo(t){let e=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?e+=32:e+=bt(a)}const n=[],r=[];let s=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?(n.push(ke(e+s,{size:32})),r.push(a),s+=bt(a)):n.push(a)}return vr([...n,...r])}function cg(t){if(!kn(t))throw new Qr({address:t});return{dynamic:!1,encoded:Mn(t.toLowerCase())}}function ug(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new am(t);if(!r&&t.length!==e)throw new tm({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let s=!1;const i=[];for(let o=0;o<t.length;o++){const a=Xo({param:n,value:t[o]});a.dynamic&&(s=!0),i.push(a)}if(r||s){const o=Qo(i);if(r){const a=ke(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?vr([a,o]):a}}if(s)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:vr(i.map(({encoded:o})=>o))}}function dg(t,{param:e}){const[,n]=e.type.split("bytes"),r=bt(t);if(!n){let s=t;return r%32!==0&&(s=Mn(s,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:vr([Mn(ke(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new nm({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:Mn(t,{dir:"right"})}}function lg(t){if(typeof t!="boolean")throw new ue(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Mn(fd(t))}}function fg(t,{signed:e,size:n=256}){if(typeof n=="number"){const r=2n**(BigInt(n)-(e?1n:0n))-1n,s=e?-r-1n:0n;if(t>r||t<s)throw new ld({max:r.toString(),min:s.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:ke(t,{size:32,signed:e})}}function hg(t){const e=jo(t),n=Math.ceil(bt(e)/32),r=[];for(let s=0;s<n;s++)r.push(Mn(di(e,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:vr([Mn(ke(bt(e),{size:32})),...r])}}function pg(t,{param:e}){let n=!1;const r=[];for(let s=0;s<e.components.length;s++){const i=e.components[s],o=Array.isArray(t)?s:i.name,a=Xo({param:i,value:t[o]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Qo(r):vr(r.map(({encoded:s})=>s))}}function ea(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function mg(t,e){const n=typeof e=="string"?en(e):e,r=Yo(n);if(bt(n)===0&&t.length>0)throw new $o;if(bt(e)&&bt(e)<32)throw new em({data:typeof e=="string"?e:zt(e),params:t,size:bt(e)});let s=0;const i=[];for(let o=0;o<t.length;++o){const a=t[o];r.setPosition(s);const[d,m]=Rr(r,a,{staticPosition:0});s+=m,i.push(d)}return i}function Rr(t,e,{staticPosition:n}){const r=ea(e.type);if(r){const[s,i]=r;return yg(t,{...e,type:i},{length:s,staticPosition:n})}if(e.type==="tuple")return Eg(t,e,{staticPosition:n});if(e.type==="address")return gg(t);if(e.type==="bool")return bg(t);if(e.type.startsWith("bytes"))return _g(t,e,{staticPosition:n});if(e.type.startsWith("uint")||e.type.startsWith("int"))return wg(t,e);if(e.type==="string")return vg(t,{staticPosition:n});throw new om(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Md=32,ta=32;function gg(t){const e=t.readBytes(32);return[ci(zt(Cd(e,-20))),32]}function yg(t,e,{length:n,staticPosition:r}){if(!n){const o=_n(t.readBytes(ta)),a=r+o,d=a+Md;t.setPosition(a);const m=_n(t.readBytes(Md)),g=rs(e);let x=0;const O=[];for(let N=0;N<m;++N){t.setPosition(d+(g?N*32:x));const[F,C]=Rr(t,e,{staticPosition:d});x+=C,O.push(F)}return t.setPosition(r+32),[O,32]}if(rs(e)){const o=_n(t.readBytes(ta)),a=r+o,d=[];for(let m=0;m<n;++m){t.setPosition(a+m*32);const[g]=Rr(t,e,{staticPosition:a});d.push(g)}return t.setPosition(r+32),[d,32]}let s=0;const i=[];for(let o=0;o<n;++o){const[a,d]=Rr(t,e,{staticPosition:r+s});s+=d,i.push(a)}return[i,s]}function bg(t){return[ng(t.readBytes(32),{size:32}),32]}function _g(t,e,{staticPosition:n}){const[r,s]=e.type.split("bytes");if(!s){const o=_n(t.readBytes(32));t.setPosition(n+o);const a=_n(t.readBytes(32));if(a===0)return t.setPosition(n+32),["0x",32];const d=t.readBytes(a);return t.setPosition(n+32),[zt(d),32]}return[zt(t.readBytes(Number.parseInt(s,10),32)),32]}function wg(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),s=t.readBytes(32);return[r>48?tg(s,{signed:n}):_n(s,{signed:n}),32]}function Eg(t,e,{staticPosition:n}){const r=e.components.length===0||e.components.some(({name:o})=>!o),s=r?[]:{};let i=0;if(rs(e)){const o=_n(t.readBytes(ta)),a=n+o;for(let d=0;d<e.components.length;++d){const m=e.components[d];t.setPosition(a+i);const[g,x]=Rr(t,m,{staticPosition:a});i+=x,s[r?d:m?.name]=g}return t.setPosition(n+32),[s,32]}for(let o=0;o<e.components.length;++o){const a=e.components[o],[d,m]=Rr(t,a,{staticPosition:n});s[r?o:a?.name]=d,i+=m}return[s,i]}function vg(t,{staticPosition:e}){const n=_n(t.readBytes(32)),r=e+n;t.setPosition(r);const s=_n(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const i=t.readBytes(s,32),o=rg(Yn(i));return t.setPosition(e+32),[o,32]}function rs(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(rs);const n=ea(t.type);return!!(n&&rs({...t,type:n[1]}))}const Rg=t=>ai(Vo(t));function Ag(t){return Rg(t)}function xg(t,e){return t.exec(e)?.groups}const Bd=/^tuple(?<array>(\[(\d*)\])*)$/;function na(t){let e=t.type;if(Bd.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let s=0;s<n;s++){const i=t.components[s];e+=na(i),s<n-1&&(e+=", ")}const r=xg(Bd,t.type);return e+=`)${r?.array||""}`,na({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function ss(t){let e="";const n=t.length;for(let r=0;r<n;r++){const s=t[r];e+=na(s),r!==n-1&&(e+=", ")}return e}function Sg(t){return t.type==="function"?`function ${t.name}(${ss(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${ss(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${ss(t.inputs)})`:t.type==="error"?`error ${t.name}(${ss(t.inputs)})`:t.type==="constructor"?`constructor(${ss(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}function Tg(t){let e=!0,n="",r=0,s="",i=!1;for(let o=0;o<t.length;o++){const a=t[o];if(["(",")",","].includes(a)&&(e=!0),a==="("&&r++,a===")"&&r--,!!e){if(r===0){if(a===" "&&["event","function",""].includes(s))s="";else if(s+=a,a===")"){i=!0;break}continue}if(a===" "){t[o-1]!==","&&n!==","&&n!==",("&&(n="",e=!1);continue}s+=a,n+=a}}if(!i)throw new ue("Unable to normalize signature.");return s}const Og=t=>{const e=typeof t=="string"?t:Sg(t);return Tg(e)};function kd(t){return Ag(Og(t))}const Ig=kd,ra=t=>di(kd(t),0,4);function Ld(t){const{abi:e,args:n=[],name:r}=t,s=Cn(r,{strict:!1}),i=e.filter(a=>s?a.type==="function"?ra(a)===r:a.type==="event"?Ig(a)===r:!1:"name"in a&&a.name===r);if(i.length===0)return;if(i.length===1)return i[0];let o;for(const a of i){if(!("inputs"in a))continue;if(!n||n.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==n.length)continue;if(n.every((m,g)=>{const x="inputs"in a&&a.inputs[g];return x?sa(m,x):!1})){if(o&&"inputs"in o&&o.inputs){const m=Pd(a.inputs,o.inputs,n);if(m)throw new sm({abiItem:a,type:m[0]},{abiItem:o,type:m[1]})}o=a}}return o||i[0]}function sa(t,e){const n=typeof t,r=e.type;switch(r){case"address":return kn(t,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return r==="tuple"&&"components"in e?Object.values(e.components).every((s,i)=>n==="object"&&sa(Object.values(t)[i],s)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(r)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?n==="string"||t instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)?Array.isArray(t)&&t.every(s=>sa(s,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Pd(t,e,n){for(const r in t){const s=t[r],i=e[r];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Pd(s.components,i.components,n[r]);const o=[s.type,i.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?kn(n[r],{strict:!1}):o.includes("address")&&o.includes("bytes")?kn(n[r],{strict:!1}):!1)return o}}const Ud="/docs/contract/encodeFunctionData";function Ng(t){const{abi:e,args:n,functionName:r}=t;let s=e[0];if(r){const i=Ld({abi:e,args:n,name:r});if(!i)throw new ad(r,{docsPath:Ud});s=i}if(s.type!=="function")throw new ad(void 0,{docsPath:Ud});return{abi:[s],functionName:ra(mr(s))}}function Cg(t){const{args:e}=t,{abi:n,functionName:r}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:Ng(t),s=n[0],i=r,o="inputs"in s&&s.inputs?og(s.inputs,e??[]):void 0;return Jo([i,o??"0x"])}class Mg extends ue{constructor({chain:e,currentChainId:n}){super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class Bg extends ue{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
14
+ `),{name:"ChainNotFoundError"})}}function wn(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const kg={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},Lg={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},Pg={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function Ug(t){const{abi:e,data:n}=t,r=di(n,0,4);if(r==="0x")throw new $o;const i=[...e||[],Lg,Pg].find(o=>o.type==="error"&&r===ra(mr(o)));if(!i)throw new od(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?mg(i.inputs,di(n,4)):void 0,errorName:i.name}}const li=(t,e,n)=>JSON.stringify(t,(r,s)=>typeof s=="bigint"?s.toString():s,n);function Dd({abiItem:t,args:e,includeFunctionName:n=!0,includeName:r=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${n?t.name:""}(${t.inputs.map((s,i)=>`${r&&s.name?`${s.name}: `:""}${typeof e[i]=="object"?li(e[i]):e[i]}`).join(", ")})`}const Dg={gwei:9,wei:18},Fg={ether:-9,wei:9};function Fd(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[s,i]=[n.slice(0,n.length-e),n.slice(n.length-e)];return i=i.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${i?`.${i}`:""}`}function $d(t,e="wei"){return Fd(t,Dg[e])}function tn(t,e="wei"){return Fd(t,Fg[e])}class $g extends ue{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class zg extends ue{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function fi(t){const e=Object.entries(t).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=e.reduce((r,[s])=>Math.max(r,s.length),0);return e.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
15
+ `)}class jg extends ue{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",fi(e),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class Vg extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:x,value:O}){const N=fi({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:x,value:typeof O<"u"&&`${$d(O)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${tn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${tn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${tn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",N].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const Gg=t=>t,zd=t=>t;class Hg extends ue{constructor(e,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:o,sender:a}){const d=Ld({abi:n,args:r,name:o}),m=d?Dd({abiItem:d,args:r,includeFunctionName:!1,includeName:!1}):void 0,g=d?mr(d,{includeName:!0}):void 0,x=fi({address:s&&Gg(s),function:g,args:m&&m!=="()"&&`${[...Array(o?.length??0).keys()].map(()=>" ").join("")}${m}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${o}".`,{cause:e,docsPath:i,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],x&&"Contract Call:",x].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=n,this.args=r,this.cause=e,this.contractAddress=s,this.functionName=o,this.sender=a}}class qg extends ue{constructor({abi:e,data:n,functionName:r,message:s}){let i,o,a,d;if(n&&n!=="0x")try{o=Ug({abi:e,data:n});const{abiItem:g,errorName:x,args:O}=o;if(x==="Error")d=O[0];else if(x==="Panic"){const[N]=O;d=kg[N]}else{const N=g?mr(g,{includeName:!0}):void 0,F=g&&O?Dd({abiItem:g,args:O,includeFunctionName:!1,includeName:!1}):void 0;a=[N?`Error: ${N}`:"",F&&F!=="()"?` ${[...Array(x?.length??0).keys()].map(()=>" ").join("")}${F}`:""]}}catch(g){i=g}else s&&(d=s);let m;i instanceof od&&(m=i.signature,a=[`Unable to decode signature "${m}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${m}.`]),super(d&&d!=="execution reverted"||m?[`The contract function "${r}" reverted with the following ${m?"signature":"reason"}:`,d||m].join(`
16
+ `):`The contract function "${r}" reverted.`,{cause:i,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=n,this.reason=d,this.signature=m}}class Kg extends ue{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Wg extends ue{constructor({data:e,message:n}){super(n||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e}}function xt(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}class jd extends ue{constructor({body:e,cause:n,details:r,headers:s,status:i,url:o}){super("HTTP request failed.",{cause:n,details:r,metaMessages:[i&&`Status: ${i}`,`URL: ${zd(o)}`,e&&`Request body: ${li(e)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=e,this.headers=s,this.status=i,this.url=o}}class Vd extends ue{constructor({body:e,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${zd(r)}`,`Request body: ${li(e)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n.code,this.data=n.data,this.url=r}}const Zg=-1;class jt extends ue{constructor(e,{code:n,docsPath:r,metaMessages:s,name:i,shortMessage:o}){super(o,{cause:e,docsPath:r,metaMessages:s||e?.metaMessages,name:i||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=i||e.name,this.code=e instanceof Vd?e.code:n??Zg}}let Ht=class extends jt{constructor(e,n){super(e,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}};class is extends jt{constructor(e){super(e,{code:is.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(is,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class os extends jt{constructor(e){super(e,{code:os.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(os,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class as extends jt{constructor(e,{method:n}={}){super(e,{code:as.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(as,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class cs extends jt{constructor(e){super(e,{code:cs.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
17
17
  `)})}}Object.defineProperty(cs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Qn extends jt{constructor(e){super(e,{code:Qn.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(Qn,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ar extends jt{constructor(e){super(e,{code:Ar.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
18
- `)})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class us extends jt{constructor(e){super(e,{code:us.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ds extends jt{constructor(e){super(e,{code:ds.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ls extends jt{constructor(e){super(e,{code:ls.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class er extends jt{constructor(e,{method:n}={}){super(e,{code:er.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(er,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class xr extends jt{constructor(e){super(e,{code:xr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class fs extends jt{constructor(e){super(e,{code:fs.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});let hi=class N0 extends Ht{constructor(e){super(e,{code:N0.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}};Object.defineProperty(hi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class hs extends Ht{constructor(e){super(e,{code:hs.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ps extends Ht{constructor(e,{method:n}={}){super(e,{code:ps.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class ms extends Ht{constructor(e){super(e,{code:ms.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});let sa=class C0 extends Ht{constructor(e){super(e,{code:C0.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}};Object.defineProperty(sa,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Sr extends Ht{constructor(e){super(e,{code:Sr.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class gs extends Ht{constructor(e){super(e,{code:gs.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class ys extends Ht{constructor(e){super(e,{code:ys.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class bs extends Ht{constructor(e){super(e,{code:bs.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class _s extends Ht{constructor(e){super(e,{code:_s.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class ws extends Ht{constructor(e){super(e,{code:ws.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Es extends Ht{constructor(e){super(e,{code:Es.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class vs extends Ht{constructor(e){super(e,{code:vs.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Yg extends jt{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Jg=3;function Xg(t,{abi:e,address:n,args:r,docsPath:s,functionName:i,sender:o}){const a=t instanceof Wg?t:t instanceof ue?t.walk(F=>"data"in F)||t.walk():{},{code:d,data:m,details:g,message:x,shortMessage:O}=a,N=t instanceof Fo?new Kg({functionName:i}):[Jg,Qn.code].includes(d)&&(m||g||x||O)||d===Ar.code&&g==="execution reverted"&&m?new qg({abi:e,data:typeof m=="object"?m.data:m,functionName:i,message:a instanceof jd?g:O??x}):t;return new Hg(N,{abi:e,args:r,contractAddress:n,docsPath:s,functionName:i,sender:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ia=BigInt(0),oa=BigInt(1);function Rs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function aa(t){if(!Rs(t))throw new Error("Uint8Array expected")}function kn(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function pi(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Vd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ia:BigInt("0x"+t)}const Gd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Qg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Tr(t){if(aa(t),Gd)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Qg[t[n]];return e}const wn={_0:48,_9:57,A:65,F:70,a:97,f:102};function Hd(t){if(t>=wn._0&&t<=wn._9)return t-wn._0;if(t>=wn.A&&t<=wn.F)return t-(wn.A-10);if(t>=wn.a&&t<=wn.f)return t-(wn.a-10)}function mi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Gd)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,i=0;s<n;s++,i+=2){const o=Hd(t.charCodeAt(i)),a=Hd(t.charCodeAt(i+1));if(o===void 0||a===void 0){const d=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+i)}r[s]=o*16+a}return r}function tr(t){return Vd(Tr(t))}function As(t){return aa(t),Vd(Tr(Uint8Array.from(t).reverse()))}function xs(t,e){return mi(t.toString(16).padStart(e*2,"0"))}function gi(t,e){return xs(t,e).reverse()}function Je(t,e,n){let r;if(typeof e=="string")try{r=mi(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Rs(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Or(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];aa(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}const ca=t=>typeof t=="bigint"&&ia<=t;function ua(t,e,n){return ca(t)&&ca(e)&&ca(n)&&e<=t&&t<n}function tn(t,e,n,r){if(!ua(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function ey(t){let e;for(e=0;t>ia;t>>=oa,e+=1);return e}const yi=t=>(oa<<BigInt(t))-oa,da=t=>new Uint8Array(t),qd=t=>Uint8Array.from(t);function ty(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=da(t),s=da(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...x)=>n(s,r,...x),d=(x=da(0))=>{s=a(qd([0]),x),r=a(),x.length!==0&&(s=a(qd([1]),x),r=a())},m=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let x=0;const O=[];for(;x<e;){r=a();const N=r.slice();O.push(N),x+=r.length}return Or(...O)};return(x,O)=>{o(),d(x);let N;for(;!(N=O(m()));)d();return o(),N}}const ny={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Rs(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ss(t,e,n={}){const r=(s,i,o)=>{const a=ny[i];if(typeof a!="function")throw new Error("invalid validator function");const d=t[s];if(!(o&&d===void 0)&&!a(d,t))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+d)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(n))r(s,i,!0);return t}function bi(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const i=t(n,...r);return e.set(n,i),i}}class Ir extends ue{constructor({cause:e,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Ir,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class _i extends ue{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${en(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(_i,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class la extends ue{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${en(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(la,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class fa extends ue{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(fa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class ha extends ue{constructor({cause:e,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
19
- `),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(ha,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class pa extends ue{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(pa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ma extends ue{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
20
- `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(ma,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ga extends ue{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ga,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ya extends ue{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class ba extends ue{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(ba,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class wi extends ue{constructor({cause:e,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${en(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${en(r)} gwei`:""}).`].join(`
21
- `),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(wi,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class _a extends ue{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Kd(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof ue?t.walk(s=>s?.code===Ir.code):t;return r instanceof ue?new Ir({cause:t,message:r.details}):Ir.nodeMessage.test(n)?new Ir({cause:t,message:t.details}):_i.nodeMessage.test(n)?new _i({cause:t,maxFeePerGas:e?.maxFeePerGas}):la.nodeMessage.test(n)?new la({cause:t,maxFeePerGas:e?.maxFeePerGas}):fa.nodeMessage.test(n)?new fa({cause:t,nonce:e?.nonce}):ha.nodeMessage.test(n)?new ha({cause:t,nonce:e?.nonce}):pa.nodeMessage.test(n)?new pa({cause:t,nonce:e?.nonce}):ma.nodeMessage.test(n)?new ma({cause:t}):ga.nodeMessage.test(n)?new ga({cause:t,gas:e?.gas}):ya.nodeMessage.test(n)?new ya({cause:t,gas:e?.gas}):ba.nodeMessage.test(n)?new ba({cause:t}):wi.nodeMessage.test(n)?new wi({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new _a({cause:t})}function wa(t,{format:e}){if(!e)return{};const n={};function r(i){const o=Object.keys(i);for(const a of o)a in t&&(n[a]=t[a]),i[a]&&typeof i[a]=="object"&&!Array.isArray(i[a])&&r(i[a])}const s=e(t||{});return r(s),n}const ry={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Ea(t,e){const n={};return typeof t.authorizationList<"u"&&(n.authorizationList=sy(t.authorizationList)),typeof t.accessList<"u"&&(n.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(n.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?n.blobs=t.blobs.map(r=>zt(r)):n.blobs=t.blobs),typeof t.data<"u"&&(n.data=t.data),t.account&&(n.from=t.account.address),typeof t.from<"u"&&(n.from=t.from),typeof t.gas<"u"&&(n.gas=ke(t.gas)),typeof t.gasPrice<"u"&&(n.gasPrice=ke(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=ke(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(n.maxFeePerGas=ke(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=ke(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(n.nonce=ke(t.nonce)),typeof t.to<"u"&&(n.to=t.to),typeof t.type<"u"&&(n.type=ry[t.type]),typeof t.value<"u"&&(n.value=ke(t.value)),n}function sy(t){return t.map(e=>({address:e.address,r:e.r?ke(BigInt(e.r)):e.r,s:e.s?ke(BigInt(e.s)):e.s,chainId:ke(e.chainId),nonce:ke(e.nonce),...typeof e.yParity<"u"?{yParity:ke(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:ke(e.v)}:{}}))}function Wd(t){if(!(!t||t.length===0))return t.reduce((e,{slot:n,value:r})=>{if(n.length!==66)throw new ud({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new ud({size:r.length,targetSize:66,type:"hex"});return e[n]=r,e},{})}function iy(t){const{balance:e,nonce:n,state:r,stateDiff:s,code:i}=t,o={};if(i!==void 0&&(o.code=i),e!==void 0&&(o.balance=ke(e)),n!==void 0&&(o.nonce=ke(n)),r!==void 0&&(o.state=Wd(r)),s!==void 0){if(o.state)throw new zg;o.stateDiff=Wd(s)}return o}function oy(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!Bn(n,{strict:!1}))throw new Qr({address:n});if(e[n])throw new $g({address:n});e[n]=iy(r)}return e}const ay=2n**256n-1n;function Ei(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=t,i=e?_n(e):void 0;if(i&&!Bn(i.address))throw new Qr({address:i.address});if(s&&!Bn(s))throw new Qr({address:s});if(n&&n>ay)throw new _i({maxFeePerGas:n});if(r&&n&&r>n)throw new wi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function cy(t){const e=ai(`0x${t.substring(4)}`).substring(26);return ci(`0x${e}`)}async function uy({hash:t,signature:e}){const n=Nn(t)?t:$o(t),{secp256k1:r}=await Promise.resolve().then(()=>y1);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:m,s:g,v:x,yParity:O}=e,N=Number(O??x),F=Zd(N);return new r.Signature(yr(m),yr(g)).addRecoveryBit(F)}const o=Nn(e)?e:$o(e);if(bt(o)!==65)throw new Error("invalid signature length");const a=Jn(`0x${o.slice(130)}`),d=Zd(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(d)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Zd(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function dy({hash:t,signature:e}){return cy(await uy({hash:t,signature:e}))}function ly(t,e="hex"){const n=Yd(t),r=Zo(new Uint8Array(n.length));return n.encode(r),e==="hex"?zt(r.bytes):r.bytes}function Yd(t){return Array.isArray(t)?fy(t.map(e=>Yd(e))):hy(t)}function fy(t){const e=t.reduce((s,i)=>s+i.length,0),n=Jd(e);return{length:e<=55?1+e:1+n+e,encode(s){e<=55?s.pushByte(192+e):(s.pushByte(247+n),n===1?s.pushUint8(e):n===2?s.pushUint16(e):n===3?s.pushUint24(e):s.pushUint32(e));for(const{encode:i}of t)i(s)}}}function hy(t){const e=typeof t=="string"?Qt(t):t,n=Jd(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length,encode(s){e.length===1&&e[0]<128?s.pushBytes(e):e.length<=55?(s.pushByte(128+e.length),s.pushBytes(e)):(s.pushByte(183+n),n===1?s.pushUint8(e.length):n===2?s.pushUint16(e.length):n===3?s.pushUint24(e.length):s.pushUint32(e.length),s.pushBytes(e))}}}function Jd(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new ue("Length is too large.")}function py(t){const{chainId:e,nonce:n,to:r}=t,s=t.contractAddress??t.address,i=ai(Yo(["0x05",ly([e?ke(e):"0x",s,n?ke(n):"0x"])]));return r==="bytes"?Qt(i):i}async function Xd(t){const{authorization:e,signature:n}=t;return dy({hash:py(e),signature:n??e})}class my extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:x,value:O}){const N=fi({from:n?.address,to:x,value:typeof O<"u"&&`${Fd(O)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${en(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${en(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${en(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",N].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function gy(t,{docsPath:e,...n}){const r=(()=>{const s=Kd(t,n);return s instanceof _a?t:s})();return new my(r,{docsPath:e,...n})}class Qd extends ue{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class va extends ue{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class yy extends ue{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${en(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class by extends ue{constructor({blockHash:e,blockNumber:n}){let r="Block";e&&(r=`Block at hash "${e}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const _y={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function el(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?Jn(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?Jn(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?_y[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(n.authorizationList=wy(t.authorizationList)),n.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}function wy(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function Ey(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:el(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:n,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function Ts(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:s}={}){const i=s??!1,o=n!==void 0?ke(n):void 0;let a=null;if(e?a=await t.request({method:"eth_getBlockByHash",params:[e,i]},{dedupe:!0}):a=await t.request({method:"eth_getBlockByNumber",params:[o||r,i]},{dedupe:!!o}),!a)throw new by({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||Ey)(a,"getBlock")}async function tl(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function vy(t,e){const{block:n,chain:r=t.chain,request:s}=e||{};try{const i=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if(typeof i=="function"){const a=n||await xt(t,Ts,"getBlock")({}),d=await i({block:a,client:t,request:s});if(d===null)throw new Error;return d}if(typeof i<"u")return i;const o=await t.request({method:"eth_maxPriorityFeePerGas"});return yr(o)}catch{const[i,o]=await Promise.all([n?Promise.resolve(n):xt(t,Ts,"getBlock")({}),xt(t,tl,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new va;const a=o-i.baseFeePerGas;return a<0n?0n:a}}async function nl(t,e){const{block:n,chain:r=t.chain,request:s,type:i="eip1559"}=e||{},o=await(async()=>typeof r?.fees?.baseFeeMultiplier=="function"?r.fees.baseFeeMultiplier({block:n,client:t,request:s}):r?.fees?.baseFeeMultiplier??1.2)();if(o<1)throw new Qd;const d=10**(o.toString().split(".")[1]?.length??0),m=O=>O*BigInt(Math.ceil(o*d))/BigInt(d),g=n||await xt(t,Ts,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const O=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:m,request:s,type:i});if(O!==null)return O}if(i==="eip1559"){if(typeof g.baseFeePerGas!="bigint")throw new va;const O=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await vy(t,{block:g,chain:r,request:s}),N=m(g.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??N+O,maxPriorityFeePerGas:O}}return{gasPrice:s?.gasPrice??m(await xt(t,tl,"getGasPrice")({}))}}async function Ry(t,{address:e,blockTag:n="latest",blockNumber:r}){const s=await t.request({method:"eth_getTransactionCount",params:[e,typeof r=="bigint"?ke(r):n]},{dedupe:!!r});return Jn(s)}function rl(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(i=>Qt(i)):t.blobs,s=[];for(const i of r)s.push(Uint8Array.from(e.blobToKzgCommitment(i)));return n==="bytes"?s:s.map(i=>zt(i))}function sl(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(o=>Qt(o)):t.blobs,s=typeof t.commitments[0]=="string"?t.commitments.map(o=>Qt(o)):t.commitments,i=[];for(let o=0;o<r.length;o++){const a=r[o],d=s[o];i.push(Uint8Array.from(e.computeBlobKzgProof(a,d)))}return n==="bytes"?i:i.map(o=>zt(o))}function Ay(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),d=r?4:0,m=r?0:4;t.setUint32(e+d,o,r),t.setUint32(e+m,a,r)}function xy(t,e,n){return t&e^~t&n}function Sy(t,e,n){return t&e^t&n^e&n}class il extends Go{constructor(e,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(e),this.view=Vo(this.buffer)}update(e){Er(this),e=oi(e),Xn(e);const{view:n,buffer:r,blockLen:s}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const d=Vo(e);for(;s<=i-o;o+=s)this.process(d,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Er(this),bd(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;n[o++]=128,Mn(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(r,0),o=0);for(let x=o;x<s;x++)n[x]=0;Ay(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Vo(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const m=d/4,g=this.get();if(m>g.length)throw new Error("_sha2: outputLen bigger than state");for(let x=0;x<m;x++)a.setUint32(4*x,g[x],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=s,e.pos=a,s%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Ln=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),St=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ty=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Pn=new Uint32Array(64);class Oy extends il{constructor(e=32){super(64,e,8,!1),this.A=Ln[0]|0,this.B=Ln[1]|0,this.C=Ln[2]|0,this.D=Ln[3]|0,this.E=Ln[4]|0,this.F=Ln[5]|0,this.G=Ln[6]|0,this.H=Ln[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:d}=this;return[e,n,r,s,i,o,a,d]}set(e,n,r,s,i,o,a,d){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=d|0}process(e,n){for(let x=0;x<16;x++,n+=4)Pn[x]=e.getUint32(n,!1);for(let x=16;x<64;x++){const O=Pn[x-15],N=Pn[x-2],F=cn(O,7)^cn(O,18)^O>>>3,M=cn(N,17)^cn(N,19)^N>>>10;Pn[x]=M+Pn[x-7]+F+Pn[x-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:d,G:m,H:g}=this;for(let x=0;x<64;x++){const O=cn(a,6)^cn(a,11)^cn(a,25),N=g+O+xy(a,d,m)+Ty[x]+Pn[x]|0,M=(cn(r,2)^cn(r,13)^cn(r,22))+Sy(r,s,i)|0;g=m,m=d,d=a,a=o+N|0,o=i,i=s,s=r,r=N+M|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,d=d+this.F|0,m=m+this.G|0,g=g+this.H|0,this.set(r,s,i,o,a,d,m,g)}roundClean(){Mn(Pn)}destroy(){this.set(0,0,0,0,0,0,0,0),Mn(this.buffer)}}const ol=md(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Iy=ol[0],Ny=ol[1],Un=new Uint32Array(80),Dn=new Uint32Array(80);class Cy extends il{constructor(e=64){super(128,e,16,!1),this.Ah=St[0]|0,this.Al=St[1]|0,this.Bh=St[2]|0,this.Bl=St[3]|0,this.Ch=St[4]|0,this.Cl=St[5]|0,this.Dh=St[6]|0,this.Dl=St[7]|0,this.Eh=St[8]|0,this.El=St[9]|0,this.Fh=St[10]|0,this.Fl=St[11]|0,this.Gh=St[12]|0,this.Gl=St[13]|0,this.Hh=St[14]|0,this.Hl=St[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:d,Eh:m,El:g,Fh:x,Fl:O,Gh:N,Gl:F,Hh:M,Hl:k}=this;return[e,n,r,s,i,o,a,d,m,g,x,O,N,F,M,k]}set(e,n,r,s,i,o,a,d,m,g,x,O,N,F,M,k){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=d|0,this.Eh=m|0,this.El=g|0,this.Fh=x|0,this.Fl=O|0,this.Gh=N|0,this.Gl=F|0,this.Hh=M|0,this.Hl=k|0}process(e,n){for(let z=0;z<16;z++,n+=4)Un[z]=e.getUint32(n),Dn[z]=e.getUint32(n+=4);for(let z=16;z<80;z++){const L=Un[z-15]|0,j=Dn[z-15]|0,J=br(L,j,1)^br(L,j,8)^gd(L,j,7),te=_r(L,j,1)^_r(L,j,8)^yd(L,j,7),ee=Un[z-2]|0,V=Dn[z-2]|0,C=br(ee,V,19)^si(ee,V,61)^gd(ee,V,6),P=_r(ee,V,19)^ii(ee,V,61)^yd(ee,V,6),q=Om(te,P,Dn[z-7],Dn[z-16]),E=Im(q,J,C,Un[z-7],Un[z-16]);Un[z]=E|0,Dn[z]=q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:d,Dh:m,Dl:g,Eh:x,El:O,Fh:N,Fl:F,Gh:M,Gl:k,Hh:K,Hl:Y}=this;for(let z=0;z<80;z++){const L=br(x,O,14)^br(x,O,18)^si(x,O,41),j=_r(x,O,14)^_r(x,O,18)^ii(x,O,41),J=x&N^~x&M,te=O&F^~O&k,ee=Nm(Y,j,te,Ny[z],Dn[z]),V=Cm(ee,K,L,J,Iy[z],Un[z]),C=ee|0,P=br(r,s,28)^si(r,s,34)^si(r,s,39),q=_r(r,s,28)^ii(r,s,34)^ii(r,s,39),E=r&i^r&a^i&a,c=s&o^s&d^o&d;K=M|0,Y=k|0,M=N|0,k=F|0,N=x|0,F=O|0,{h:x,l:O}=yn(m|0,g|0,V|0,C|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const p=Sm(C,q,c);r=Tm(p,V,P,E),s=p|0}({h:r,l:s}=yn(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=yn(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:d}=yn(this.Ch|0,this.Cl|0,a|0,d|0),{h:m,l:g}=yn(this.Dh|0,this.Dl|0,m|0,g|0),{h:x,l:O}=yn(this.Eh|0,this.El|0,x|0,O|0),{h:N,l:F}=yn(this.Fh|0,this.Fl|0,N|0,F|0),{h:M,l:k}=yn(this.Gh|0,this.Gl|0,M|0,k|0),{h:K,l:Y}=yn(this.Hh|0,this.Hl|0,K|0,Y|0),this.set(r,s,i,o,a,d,m,g,x,O,N,F,M,k,K,Y)}roundClean(){Mn(Un,Dn)}destroy(){Mn(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const al=Ho(()=>new Oy),My=Ho(()=>new Cy),Ra=al;function By(t,e){return Ra(Nn(t,{strict:!1})?jo(t):t)}function ky(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),s=By(e);return s.set([n],0),r==="bytes"?s:zt(s)}function Ly(t){const{commitments:e,version:n}=t,r=t.to,s=[];for(const i of e)s.push(ky({commitment:i,to:r,version:n}));return s}const cl=6,ul=32,Aa=4096,dl=ul*Aa,ll=dl*cl-1-1*Aa*cl;class Py extends ue{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class Uy extends ue{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Dy(t){const e=typeof t.data=="string"?Qt(t.data):t.data,n=bt(e);if(!n)throw new Uy;if(n>ll)throw new Py({maxSize:ll,size:n});const r=[];let s=!0,i=0;for(;s;){const o=Zo(new Uint8Array(dl));let a=0;for(;a<Aa;){const d=e.slice(i,i+(ul-1));if(o.pushByte(0),o.pushBytes(d),d.length<31){o.pushByte(128),s=!1;break}a++,i+=31}r.push(o)}return r.map(o=>zt(o.bytes))}function Fy(t){const{data:e,kzg:n,to:r}=t,s=t.blobs??Dy({data:e}),i=t.commitments??rl({blobs:s,kzg:n,to:r}),o=t.proofs??sl({blobs:s,commitments:i,kzg:n,to:r}),a=[];for(let d=0;d<s.length;d++)a.push({blob:s[d],commitment:i[d],proof:o[d]});return a}function $y(t){if(t.type)return t.type;if(typeof t.authorizationList<"u")return"eip7702";if(typeof t.blobs<"u"||typeof t.blobVersionedHashes<"u"||typeof t.maxFeePerBlobGas<"u"||typeof t.sidecars<"u")return"eip4844";if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")return"eip1559";if(typeof t.gasPrice<"u")return typeof t.accessList<"u"?"eip2930":"legacy";throw new jg({transaction:t})}function fl(t,{docsPath:e,...n}){const r=(()=>{const s=Kd(t,n);return s instanceof _a?t:s})();return new Vg(r,{docsPath:e,...n})}async function xa(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return Jn(e)}async function zy(t,e){const{account:n=t.account,accessList:r,authorizationList:s,chain:i=t.chain,blobVersionedHashes:o,blobs:a,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:x,maxFeePerGas:O,maxPriorityFeePerGas:N,nonce:F,nonceManager:M,to:k,type:K,value:Y,...z}=e,L=await(async()=>{if(!n||!M||typeof F<"u")return F;const ee=_n(n),V=i?i.id:await xt(t,xa,"getChainId")({});return await M.consume({address:ee.address,chainId:V,client:t})})();Ei(e);const j=i?.formatters?.transactionRequest?.format,te=(j||Ea)({...wa(z,{format:j}),account:n?_n(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:o,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:x,maxFeePerGas:O,maxPriorityFeePerGas:N,nonce:L,to:k,type:K,value:Y},"fillTransaction");try{const ee=await t.request({method:"eth_fillTransaction",params:[te]}),C=(i?.formatters?.transaction?.format||el)(ee.tx);delete C.blockHash,delete C.blockNumber,delete C.r,delete C.s,delete C.transactionIndex,delete C.v,delete C.yParity,C.data=C.input,C.gas&&(C.gas=e.gas??C.gas),C.gasPrice&&(C.gasPrice=e.gasPrice??C.gasPrice),C.maxFeePerBlobGas&&(C.maxFeePerBlobGas=e.maxFeePerBlobGas??C.maxFeePerBlobGas),C.maxFeePerGas&&(C.maxFeePerGas=e.maxFeePerGas??C.maxFeePerGas),C.maxPriorityFeePerGas&&(C.maxPriorityFeePerGas=e.maxPriorityFeePerGas??C.maxPriorityFeePerGas),C.nonce&&(C.nonce=e.nonce??C.nonce);const P=await(async()=>{if(typeof i?.fees?.baseFeeMultiplier=="function"){const p=await xt(t,Ts,"getBlock")({});return i.fees.baseFeeMultiplier({block:p,client:t,request:e})}return i?.fees?.baseFeeMultiplier??1.2})();if(P<1)throw new Qd;const E=10**(P.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(P*E))/BigInt(E);return C.maxFeePerGas&&!e.maxFeePerGas&&(C.maxFeePerGas=c(C.maxFeePerGas)),C.gasPrice&&!e.gasPrice&&(C.gasPrice=c(C.gasPrice)),{raw:ee.raw,transaction:{from:te.from,...C}}}catch(ee){throw fl(ee,{...e,chain:t.chain})}}const hl=["blobVersionedHashes","chainId","fees","gas","nonce","type"],pl=new Map,Sa=new ns(128);async function ml(t,e){let n=e;n.account??=t.account,n.parameters??=hl;const{account:r,chain:s=t.chain,nonceManager:i,parameters:o}=n,a=(()=>{if(typeof s?.prepareTransactionRequest=="function")return{fn:s.prepareTransactionRequest,runAt:["beforeFillTransaction"]};if(Array.isArray(s?.prepareTransactionRequest))return{fn:s.prepareTransactionRequest[0],runAt:s.prepareTransactionRequest[1].runAt}})();let d;async function m(){return d||(typeof n.chainId<"u"?n.chainId:s?s.id:(d=await xt(t,xa,"getChainId")({}),d))}const g=r&&_n(r);let x=n.nonce;if(o.includes("nonce")&&typeof x>"u"&&g&&i){const L=await m();x=await i.consume({address:g.address,chainId:L,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillTransaction"}),x??=n.nonce);const N=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Sa.get(t.uid)===!1||!["fees","gas"].some(j=>o.includes(j))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof x!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await xt(t,zy,"fillTransaction")({...n,nonce:x}).then(L=>{const{chainId:j,from:J,gas:te,gasPrice:ee,nonce:V,maxFeePerBlobGas:C,maxFeePerGas:P,maxPriorityFeePerGas:q,type:E,...c}=L.transaction;return Sa.set(t.uid,!0),{...n,...J?{from:J}:{},...E?{type:E}:{},...typeof j<"u"?{chainId:j}:{},...typeof te<"u"?{gas:te}:{},...typeof ee<"u"?{gasPrice:ee}:{},...typeof V<"u"?{nonce:V}:{},...typeof C<"u"?{maxFeePerBlobGas:C}:{},...typeof P<"u"?{maxFeePerGas:P}:{},...typeof q<"u"?{maxPriorityFeePerGas:q}:{},..."nonceKey"in c&&typeof c.nonceKey<"u"?{nonceKey:c.nonceKey}:{}}}).catch(L=>{const j=L;return j.name!=="TransactionExecutionError"||j.walk?.(te=>{const ee=te;return ee.name==="MethodNotFoundRpcError"||ee.name==="MethodNotSupportedRpcError"})&&Sa.set(t.uid,!1),n}):n;x??=N.nonce,n={...N,...g?{from:g?.address}:{},...x?{nonce:x}:{}};const{blobs:F,gas:M,kzg:k,type:K}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillParameters"}));let Y;async function z(){return Y||(Y=await xt(t,Ts,"getBlock")({blockTag:"latest"}),Y)}if(o.includes("nonce")&&typeof x>"u"&&g&&!i&&(n.nonce=await xt(t,Ry,"getTransactionCount")({address:g.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&F&&k){const L=rl({blobs:F,kzg:k});if(o.includes("blobVersionedHashes")){const j=Ly({commitments:L,to:"hex"});n.blobVersionedHashes=j}if(o.includes("sidecars")){const j=sl({blobs:F,commitments:L,kzg:k}),J=Fy({blobs:F,commitments:L,proofs:j,to:"hex"});n.sidecars=J}}if(o.includes("chainId")&&(n.chainId=await m()),(o.includes("fees")||o.includes("type"))&&typeof K>"u")try{n.type=$y(n)}catch{let L=pl.get(t.uid);typeof L>"u"&&(L=typeof(await z())?.baseFeePerGas=="bigint",pl.set(t.uid,L)),n.type=L?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const L=await z(),{maxFeePerGas:j,maxPriorityFeePerGas:J}=await nl(t,{block:L,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<J)throw new yy({maxPriorityFeePerGas:J});n.maxPriorityFeePerGas=J,n.maxFeePerGas=j}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new va;if(typeof n.gasPrice>"u"){const L=await z(),{gasPrice:j}=await nl(t,{block:L,chain:s,request:n,type:"legacy"});n.gasPrice=j}}return o.includes("gas")&&typeof M>"u"&&(n.gas=await xt(t,jy,"estimateGas")({...n,account:g,prepare:g?.type==="local"?[]:["blobVersionedHashes"]})),a?.fn&&a.runAt?.includes("afterFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"afterFillParameters"})),Ei(n),delete n.parameters,n}async function jy(t,e){const{account:n=t.account,prepare:r=!0}=e,s=n?_n(n):void 0,i=(()=>{if(Array.isArray(r))return r;if(s?.type!=="local")return["blobVersionedHashes"]})();try{const o=await(async()=>{if(e.to)return e.to;if(e.authorizationList&&e.authorizationList.length>0)return await Xd({authorization:e.authorizationList[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,blockNumber:x,blockTag:O,data:N,gas:F,gasPrice:M,maxFeePerBlobGas:k,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:z,value:L,stateOverride:j,...J}=r?await ml(t,{...e,parameters:i,to:o}):e;if(F&&e.gas!==F)return F;const ee=(typeof x=="bigint"?ke(x):void 0)||O,V=oy(j);Ei(e);const C=t.chain?.formatters?.transactionRequest?.format,q=(C||Ea)({...wa(J,{format:C}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:N,gasPrice:M,maxFeePerBlobGas:k,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:z,to:o,value:L},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:V?[q,ee??t.experimental_blockTag??"latest",V]:ee?[q,ee]:[q]}))}catch(o){throw gy(o,{...e,account:s,chain:t.chain})}}const vi=new ns(8192);function Vy(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(vi.get(n))return vi.get(n);const r=t().finally(()=>vi.delete(n));return vi.set(n,r),r}async function Gy(t){return new Promise(e=>setTimeout(e,t))}function Hy(t,{delay:e=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((s,i)=>{const o=async({count:a=0}={})=>{const d=async({error:m})=>{const g=typeof e=="function"?e({count:a,error:m}):e;g&&await Gy(g),o({count:a+1})};try{const m=await t();s(m)}catch(m){if(a<n&&await r({count:a,error:m}))return d({error:m});i(m)}};o()})}function qy(t,e={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:d}={...e,...r},{method:m}=n;if(i?.exclude?.includes(m))throw new er(new Error("method not supported"),{method:m});if(i?.include&&!i.include.includes(m))throw new er(new Error("method not supported"),{method:m});const g=s?zo(`${d}.${li(n)}`):void 0;return Vy(()=>Hy(async()=>{try{return await t(n)}catch(x){const O=x;switch(O.code){case is.code:throw new is(O);case os.code:throw new os(O);case as.code:throw new as(O,{method:n.method});case cs.code:throw new cs(O);case Qn.code:throw new Qn(O);case Ar.code:throw new Ar(O);case us.code:throw new us(O);case ds.code:throw new ds(O);case ls.code:throw new ls(O);case er.code:throw new er(O,{method:n.method});case xr.code:throw new xr(O);case fs.code:throw new fs(O);case hi.code:throw new hi(O);case hs.code:throw new hs(O);case ps.code:throw new ps(O);case ms.code:throw new ms(O);case sa.code:throw new sa(O);case Sr.code:throw new Sr(O);case gs.code:throw new gs(O);case ys.code:throw new ys(O);case bs.code:throw new bs(O);case _s.code:throw new _s(O);case ws.code:throw new ws(O);case Es.code:throw new Es(O);case vs.code:throw new vs(O);case 5e3:throw new hi(O);default:throw x instanceof ue?x:new Yg(O)}}},{delay:({count:x,error:O})=>{if(O&&O instanceof zd){const N=O?.headers?.get("Retry-After");if(N?.match(/\d/))return Number.parseInt(N,10)*1e3}return~~(1<<x)*o},retryCount:a,shouldRetry:({error:x})=>Ky(x)}),{enabled:s,id:g})}}function Ky(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===xr.code||t.code===Qn.code:t instanceof zd&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function Wy({chain:t,currentChainId:e}){if(!t)throw new Bg;if(e!==t.id)throw new Mg({chain:t,currentChainId:e})}class gl extends Go{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Bm(e);const r=oi(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Mn(i)}update(e){return Er(this),this.iHash.update(e),this}digestInto(e){Er(this),Xn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const yl=(t,e,n)=>new gl(t,e).update(n).digest();yl.create=(t,e)=>new gl(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vt=BigInt(0),wt=BigInt(1),nr=BigInt(2),Zy=BigInt(3),bl=BigInt(4),_l=BigInt(5),wl=BigInt(8);function je(t,e){const n=t%e;return n>=Vt?n:e+n}function qe(t,e,n){let r=t;for(;e-- >Vt;)r*=r,r%=n;return r}function Ta(t,e){if(t===Vt)throw new Error("invert: expected non-zero number");if(e<=Vt)throw new Error("invert: expected positive modulus, got "+e);let n=je(t,e),r=e,s=Vt,i=wt;for(;n!==Vt;){const a=r/n,d=r%n,m=s-i*a;r=n,n=d,s=i,i=m}if(r!==wt)throw new Error("invert: does not exist");return je(s,e)}function El(t,e){const n=(t.ORDER+wt)/bl,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function Yy(t,e){const n=(t.ORDER-_l)/wl,r=t.mul(e,nr),s=t.pow(r,n),i=t.mul(e,s),o=t.mul(t.mul(i,nr),s),a=t.mul(i,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function Jy(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-wt,n=0;for(;e%nr===Vt;)e/=nr,n++;let r=nr;const s=Os(t);for(;vl(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return El;let i=s.pow(r,e);const o=(e+wt)/nr;return function(d,m){if(d.is0(m))return m;if(vl(d,m)!==1)throw new Error("Cannot find square root");let g=n,x=d.mul(d.ONE,i),O=d.pow(m,e),N=d.pow(m,o);for(;!d.eql(O,d.ONE);){if(d.is0(O))return d.ZERO;let F=1,M=d.sqr(O);for(;!d.eql(M,d.ONE);)if(F++,M=d.sqr(M),F===g)throw new Error("Cannot find square root");const k=wt<<BigInt(g-F-1),K=d.pow(x,k);g=F,x=d.sqr(K),O=d.mul(O,x),N=d.mul(N,K)}return N}}function Xy(t){return t%bl===Zy?El:t%wl===_l?Yy:Jy(t)}const Qy=(t,e)=>(je(t,e)&wt)===wt,e1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function t1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=e1.reduce((r,s)=>(r[s]="function",r),e);return Ss(t,n)}function n1(t,e,n){if(n<Vt)throw new Error("invalid exponent, negatives unsupported");if(n===Vt)return t.ONE;if(n===wt)return e;let r=t.ONE,s=e;for(;n>Vt;)n&wt&&(r=t.mul(r,s)),s=t.sqr(s),n>>=wt;return r}function Oa(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((o,a,d)=>t.is0(a)?o:(r[d]=o,t.mul(o,a)),t.ONE),i=t.inv(s);return e.reduceRight((o,a,d)=>t.is0(a)?o:(r[d]=t.mul(o,r[d]),t.mul(o,a)),i),r}function vl(t,e){const n=(t.ORDER-wt)/nr,r=t.pow(e,n),s=t.eql(r,t.ONE),i=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Rl(t,e){e!==void 0&&es(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Os(t,e,n=!1,r={}){if(t<=Vt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:i}=Rl(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:n,BITS:s,BYTES:i,MASK:yi(s),ZERO:Vt,ONE:wt,create:d=>je(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Vt<=d&&d<t},is0:d=>d===Vt,isOdd:d=>(d&wt)===wt,neg:d=>je(-d,t),eql:(d,m)=>d===m,sqr:d=>je(d*d,t),add:(d,m)=>je(d+m,t),sub:(d,m)=>je(d-m,t),mul:(d,m)=>je(d*m,t),pow:(d,m)=>n1(a,d,m),div:(d,m)=>je(d*Ta(m,t),t),sqrN:d=>d*d,addN:(d,m)=>d+m,subN:(d,m)=>d-m,mulN:(d,m)=>d*m,inv:d=>Ta(d,t),sqrt:r.sqrt||(d=>(o||(o=Xy(t)),o(a,d))),toBytes:d=>n?gi(d,i):xs(d,i),fromBytes:d=>{if(d.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+d.length);return n?As(d):tr(d)},invertBatch:d=>Oa(a,d),cmov:(d,m,g)=>g?m:d});return Object.freeze(a)}function Al(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function xl(t){const e=Al(t);return e+Math.ceil(e/2)}function r1(t,e,n=!1){const r=t.length,s=Al(e),i=xl(e);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=n?As(t):tr(t),a=je(o,e-wt)+wt;return n?gi(a,s):xs(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Sl=BigInt(0),Ia=BigInt(1);function Na(t,e){const n=e.negate();return t?n:e}function Tl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ca(t,e){Tl(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=yi(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function Ol(t,e,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:o}=n;let a=Number(t&s),d=t>>o;a>r&&(a-=i,d+=Ia);const m=e*r,g=m+Math.abs(a)-1,x=a===0,O=a<0,N=e%2!==0;return{nextN:d,offset:g,isZero:x,isNeg:O,isNegF:N,offsetF:m}}function s1(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function i1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ma=new WeakMap,Il=new WeakMap;function Ba(t){return Il.get(t)||1}function Nl(t,e){return{constTimeNegate:Na,hasPrecomputes(n){return Ba(n)!==1},unsafeLadder(n,r,s=t.ZERO){let i=n;for(;r>Sl;)r&Ia&&(s=s.add(i)),i=i.double(),r>>=Ia;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ca(r,e),o=[];let a=n,d=a;for(let m=0;m<s;m++){d=a,o.push(d);for(let g=1;g<i;g++)d=d.add(a),o.push(d);a=d.double()}return o},wNAF(n,r,s){let i=t.ZERO,o=t.BASE;const a=Ca(n,e);for(let d=0;d<a.windows;d++){const{nextN:m,offset:g,isZero:x,isNeg:O,isNegF:N,offsetF:F}=Ol(s,d,a);s=m,x?o=o.add(Na(N,r[F])):i=i.add(Na(O,r[g]))}return{p:i,f:o}},wNAFUnsafe(n,r,s,i=t.ZERO){const o=Ca(n,e);for(let a=0;a<o.windows&&s!==Sl;a++){const{nextN:d,offset:m,isZero:g,isNeg:x}=Ol(s,a,o);if(s=d,!g){const O=r[m];i=i.add(x?O.negate():O)}}return i},getPrecomputes(n,r,s){let i=Ma.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&Ma.set(r,s(i))),i},wNAFCached(n,r,s){const i=Ba(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const o=Ba(n);return o===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,n,s),r,i)},setWindowSize(n,r){Tl(r,e),Il.set(n,r),Ma.delete(n)}}}function Cl(t,e,n,r){s1(n,t),i1(r,e);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=ey(BigInt(s));let d=1;a>12?d=a-3:a>4?d=a-2:a>0&&(d=2);const m=yi(d),g=new Array(Number(m)+1).fill(o),x=Math.floor((e.BITS-1)/d)*d;let O=o;for(let N=x;N>=0;N-=d){g.fill(o);for(let M=0;M<i;M++){const k=r[M],K=Number(k>>BigInt(N)&m);g[K]=g[K].add(n[M])}let F=o;for(let M=g.length-1,k=o;M>0;M--)k=k.add(g[M]),F=F.add(k);if(O=O.add(F),N!==0)for(let M=0;M<d;M++)O=O.double()}return O}function ka(t){return t1(t.Fp),Ss(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Rl(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ml(t){t.lowS!==void 0&&kn("lowS",t.lowS),t.prehash!==void 0&&kn("prehash",t.prehash)}function o1(t){const e=ka(t);Ss(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class a1 extends Error{constructor(e=""){super(e)}}const En={Err:a1,_tlv:{encode:(t,e)=>{const{Err:n}=En;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=pi(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?pi(s.length/2|128):"";return pi(t)+i+s+e},decode(t,e){const{Err:n}=En;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],i=!!(s&128);let o=0;if(!i)o=s;else{const d=s&127;if(!d)throw new n("tlv.decode(long): indefinite length not supported");if(d>4)throw new n("tlv.decode(long): byte length is too big");const m=e.subarray(r,r+d);if(m.length!==d)throw new n("tlv.decode: length bytes not complete");if(m[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const g of m)o=o<<8|g;if(r+=d,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=En;if(t<vn)throw new e("integer: negative integers are not allowed");let n=pi(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=En;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tr(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=En,s=Je("signature",t),{v:i,l:o}=r.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:d}=r.decode(2,i),{v:m,l:g}=r.decode(2,d);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(m)}},hexFromSig(t){const{_tlv:e,_int:n}=En,r=e.encode(2,n.encode(t.r)),s=e.encode(2,n.encode(t.s)),i=r+s;return e.encode(48,i)}};function La(t,e){return Tr(xs(t,e))}const vn=BigInt(0),_t=BigInt(1);BigInt(2);const Pa=BigInt(3),c1=BigInt(4);function u1(t){const e=o1(t),{Fp:n}=e,r=Os(e.n,e.nBitLength),s=e.toBytes||((z,L,j)=>{const J=L.toAffine();return Or(Uint8Array.from([4]),n.toBytes(J.x),n.toBytes(J.y))}),i=e.fromBytes||(z=>{const L=z.subarray(1),j=n.fromBytes(L.subarray(0,n.BYTES)),J=n.fromBytes(L.subarray(n.BYTES,2*n.BYTES));return{x:j,y:J}});function o(z){const{a:L,b:j}=e,J=n.sqr(z),te=n.mul(J,z);return n.add(n.add(te,n.mul(z,L)),j)}function a(z,L){const j=n.sqr(L),J=o(z);return n.eql(j,J)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const d=n.mul(n.pow(e.a,Pa),c1),m=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(d,m)))throw new Error("bad curve params: a or b");function g(z){return ua(z,_t,e.n)}function x(z){const{allowedPrivateKeyLengths:L,nByteLength:j,wrapPrivateKey:J,n:te}=e;if(L&&typeof z!="bigint"){if(Rs(z)&&(z=Tr(z)),typeof z!="string"||!L.includes(z.length))throw new Error("invalid private key");z=z.padStart(j*2,"0")}let ee;try{ee=typeof z=="bigint"?z:tr(Je("private key",z,j))}catch{throw new Error("invalid private key, expected hex or "+j+" bytes, got "+typeof z)}return J&&(ee=je(ee,te)),tn("private key",ee,_t,te),ee}function O(z){if(!(z instanceof M))throw new Error("ProjectivePoint expected")}const N=bi((z,L)=>{const{px:j,py:J,pz:te}=z;if(n.eql(te,n.ONE))return{x:j,y:J};const ee=z.is0();L==null&&(L=ee?n.ONE:n.inv(te));const V=n.mul(j,L),C=n.mul(J,L),P=n.mul(te,L);if(ee)return{x:n.ZERO,y:n.ZERO};if(!n.eql(P,n.ONE))throw new Error("invZ was invalid");return{x:V,y:C}}),F=bi(z=>{if(z.is0()){if(e.allowInfinityPoint&&!n.is0(z.py))return;throw new Error("bad point: ZERO")}const{x:L,y:j}=z.toAffine();if(!n.isValid(L)||!n.isValid(j))throw new Error("bad point: x or y not FE");if(!a(L,j))throw new Error("bad point: equation left != right");if(!z.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class M{constructor(L,j,J){if(L==null||!n.isValid(L))throw new Error("x required");if(j==null||!n.isValid(j)||n.is0(j))throw new Error("y required");if(J==null||!n.isValid(J))throw new Error("z required");this.px=L,this.py=j,this.pz=J,Object.freeze(this)}static fromAffine(L){const{x:j,y:J}=L||{};if(!L||!n.isValid(j)||!n.isValid(J))throw new Error("invalid affine point");if(L instanceof M)throw new Error("projective point not allowed");const te=ee=>n.eql(ee,n.ZERO);return te(j)&&te(J)?M.ZERO:new M(j,J,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(L){const j=Oa(n,L.map(J=>J.pz));return L.map((J,te)=>J.toAffine(j[te])).map(M.fromAffine)}static fromHex(L){const j=M.fromAffine(i(Je("pointHex",L)));return j.assertValidity(),j}static fromPrivateKey(L){return M.BASE.multiply(x(L))}static msm(L,j){return Cl(M,r,L,j)}_setWindowSize(L){Y.setWindowSize(this,L)}assertValidity(){F(this)}hasEvenY(){const{y:L}=this.toAffine();if(n.isOdd)return!n.isOdd(L);throw new Error("Field doesn't support isOdd")}equals(L){O(L);const{px:j,py:J,pz:te}=this,{px:ee,py:V,pz:C}=L,P=n.eql(n.mul(j,C),n.mul(ee,te)),q=n.eql(n.mul(J,C),n.mul(V,te));return P&&q}negate(){return new M(this.px,n.neg(this.py),this.pz)}double(){const{a:L,b:j}=e,J=n.mul(j,Pa),{px:te,py:ee,pz:V}=this;let C=n.ZERO,P=n.ZERO,q=n.ZERO,E=n.mul(te,te),c=n.mul(ee,ee),p=n.mul(V,V),y=n.mul(te,ee);return y=n.add(y,y),q=n.mul(te,V),q=n.add(q,q),C=n.mul(L,q),P=n.mul(J,p),P=n.add(C,P),C=n.sub(c,P),P=n.add(c,P),P=n.mul(C,P),C=n.mul(y,C),q=n.mul(J,q),p=n.mul(L,p),y=n.sub(E,p),y=n.mul(L,y),y=n.add(y,q),q=n.add(E,E),E=n.add(q,E),E=n.add(E,p),E=n.mul(E,y),P=n.add(P,E),p=n.mul(ee,V),p=n.add(p,p),E=n.mul(p,y),C=n.sub(C,E),q=n.mul(p,c),q=n.add(q,q),q=n.add(q,q),new M(C,P,q)}add(L){O(L);const{px:j,py:J,pz:te}=this,{px:ee,py:V,pz:C}=L;let P=n.ZERO,q=n.ZERO,E=n.ZERO;const c=e.a,p=n.mul(e.b,Pa);let y=n.mul(j,ee),A=n.mul(J,V),v=n.mul(te,C),R=n.add(j,J),I=n.add(ee,V);R=n.mul(R,I),I=n.add(y,A),R=n.sub(R,I),I=n.add(j,te);let _=n.add(ee,C);return I=n.mul(I,_),_=n.add(y,v),I=n.sub(I,_),_=n.add(J,te),P=n.add(V,C),_=n.mul(_,P),P=n.add(A,v),_=n.sub(_,P),E=n.mul(c,I),P=n.mul(p,v),E=n.add(P,E),P=n.sub(A,E),E=n.add(A,E),q=n.mul(P,E),A=n.add(y,y),A=n.add(A,y),v=n.mul(c,v),I=n.mul(p,I),A=n.add(A,v),v=n.sub(y,v),v=n.mul(c,v),I=n.add(I,v),y=n.mul(A,I),q=n.add(q,y),y=n.mul(_,I),P=n.mul(R,P),P=n.sub(P,y),y=n.mul(R,A),E=n.mul(_,E),E=n.add(E,y),new M(P,q,E)}subtract(L){return this.add(L.negate())}is0(){return this.equals(M.ZERO)}wNAF(L){return Y.wNAFCached(this,L,M.normalizeZ)}multiplyUnsafe(L){const{endo:j,n:J}=e;tn("scalar",L,vn,J);const te=M.ZERO;if(L===vn)return te;if(this.is0()||L===_t)return this;if(!j||Y.hasPrecomputes(this))return Y.wNAFCachedUnsafe(this,L,M.normalizeZ);let{k1neg:ee,k1:V,k2neg:C,k2:P}=j.splitScalar(L),q=te,E=te,c=this;for(;V>vn||P>vn;)V&_t&&(q=q.add(c)),P&_t&&(E=E.add(c)),c=c.double(),V>>=_t,P>>=_t;return ee&&(q=q.negate()),C&&(E=E.negate()),E=new M(n.mul(E.px,j.beta),E.py,E.pz),q.add(E)}multiply(L){const{endo:j,n:J}=e;tn("scalar",L,_t,J);let te,ee;if(j){const{k1neg:V,k1:C,k2neg:P,k2:q}=j.splitScalar(L);let{p:E,f:c}=this.wNAF(C),{p,f:y}=this.wNAF(q);E=Y.constTimeNegate(V,E),p=Y.constTimeNegate(P,p),p=new M(n.mul(p.px,j.beta),p.py,p.pz),te=E.add(p),ee=c.add(y)}else{const{p:V,f:C}=this.wNAF(L);te=V,ee=C}return M.normalizeZ([te,ee])[0]}multiplyAndAddUnsafe(L,j,J){const te=M.BASE,ee=(C,P)=>P===vn||P===_t||!C.equals(te)?C.multiplyUnsafe(P):C.multiply(P),V=ee(this,j).add(ee(L,J));return V.is0()?void 0:V}toAffine(L){return N(this,L)}isTorsionFree(){const{h:L,isTorsionFree:j}=e;if(L===_t)return!0;if(j)return j(M,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:L,clearCofactor:j}=e;return L===_t?this:j?j(M,this):this.multiplyUnsafe(e.h)}toRawBytes(L=!0){return kn("isCompressed",L),this.assertValidity(),s(M,this,L)}toHex(L=!0){return kn("isCompressed",L),Tr(this.toRawBytes(L))}}M.BASE=new M(e.Gx,e.Gy,n.ONE),M.ZERO=new M(n.ZERO,n.ONE,n.ZERO);const{endo:k,nBitLength:K}=e,Y=Nl(M,k?Math.ceil(K/2):K);return{CURVE:e,ProjectivePoint:M,normPrivateKeyToScalar:x,weierstrassEquation:o,isWithinCurveOrder:g}}function d1(t){const e=ka(t);return Ss(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function l1(t){const e=d1(t),{Fp:n,n:r,nByteLength:s,nBitLength:i}=e,o=n.BYTES+1,a=2*n.BYTES+1;function d(p){return je(p,r)}function m(p){return Ta(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:x,weierstrassEquation:O,isWithinCurveOrder:N}=u1({...e,toBytes(p,y,A){const v=y.toAffine(),R=n.toBytes(v.x),I=Or;return kn("isCompressed",A),A?I(Uint8Array.from([y.hasEvenY()?2:3]),R):I(Uint8Array.from([4]),R,n.toBytes(v.y))},fromBytes(p){const y=p.length,A=p[0],v=p.subarray(1);if(y===o&&(A===2||A===3)){const R=tr(v);if(!ua(R,_t,n.ORDER))throw new Error("Point is not on curve");const I=O(R);let _;try{_=n.sqrt(I)}catch(w){const T=w instanceof Error?": "+w.message:"";throw new Error("Point is not on curve"+T)}const u=(_&_t)===_t;return(A&1)===1!==u&&(_=n.neg(_)),{x:R,y:_}}else if(y===a&&A===4){const R=n.fromBytes(v.subarray(0,n.BYTES)),I=n.fromBytes(v.subarray(n.BYTES,2*n.BYTES));return{x:R,y:I}}else{const R=o,I=a;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+I+", got "+y)}}});function F(p){const y=r>>_t;return p>y}function M(p){return F(p)?d(-p):p}const k=(p,y,A)=>tr(p.slice(y,A));class K{constructor(y,A,v){tn("r",y,_t,r),tn("s",A,_t,r),this.r=y,this.s=A,v!=null&&(this.recovery=v),Object.freeze(this)}static fromCompact(y){const A=s;return y=Je("compactSignature",y,A*2),new K(k(y,0,A),k(y,A,2*A))}static fromDER(y){const{r:A,s:v}=En.toSig(Je("DER",y));return new K(A,v)}assertValidity(){}addRecoveryBit(y){return new K(this.r,this.s,y)}recoverPublicKey(y){const{r:A,s:v,recovery:R}=this,I=te(Je("msgHash",y));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");const _=R===2||R===3?A+e.n:A;if(_>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(R&1)===0?"02":"03",l=g.fromHex(u+La(_,n.BYTES)),w=m(_),T=d(-I*w),D=d(v*w),W=g.BASE.multiplyAndAddUnsafe(l,T,D);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return F(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return mi(this.toDERHex())}toDERHex(){return En.hexFromSig(this)}toCompactRawBytes(){return mi(this.toCompactHex())}toCompactHex(){const y=s;return La(this.r,y)+La(this.s,y)}}const Y={isValidPrivateKey(p){try{return x(p),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const p=xl(e.n);return r1(e.randomBytes(p),e.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function z(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function L(p){if(typeof p=="bigint")return!1;if(p instanceof g)return!0;const A=Je("key",p).length,v=n.BYTES,R=v+1,I=2*v+1;if(!(e.allowedPrivateKeyLengths||s===R))return A===R||A===I}function j(p,y,A=!0){if(L(p)===!0)throw new Error("first arg must be private key");if(L(y)===!1)throw new Error("second arg must be public key");return g.fromHex(y).multiply(x(p)).toRawBytes(A)}const J=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const y=tr(p),A=p.length*8-i;return A>0?y>>BigInt(A):y},te=e.bits2int_modN||function(p){return d(J(p))},ee=yi(i);function V(p){return tn("num < 2^"+i,p,vn,ee),xs(p,s)}function C(p,y,A=P){if(["recovered","canonical"].some(oe=>oe in A))throw new Error("sign() legacy options not supported");const{hash:v,randomBytes:R}=e;let{lowS:I,prehash:_,extraEntropy:u}=A;I==null&&(I=!0),p=Je("msgHash",p),Ml(A),_&&(p=Je("prehashed msgHash",v(p)));const l=te(p),w=x(y),T=[V(w),V(l)];if(u!=null&&u!==!1){const oe=u===!0?R(n.BYTES):u;T.push(Je("extraEntropy",oe))}const D=Or(...T),W=l;function re(oe){const Ne=J(oe);if(!N(Ne))return;const Ee=m(Ne),we=g.BASE.multiply(Ne).toAffine(),De=d(we.x);if(De===vn)return;const ve=d(Ee*d(W+De*w));if(ve===vn)return;let Oe=(we.x===De?0:2)|Number(we.y&_t),pn=ve;return I&&F(ve)&&(pn=M(ve),Oe^=1),new K(De,pn,Oe)}return{seed:D,k2sig:re}}const P={lowS:e.lowS,prehash:!1},q={lowS:e.lowS,prehash:!1};function E(p,y,A=P){const{seed:v,k2sig:R}=C(p,y,A),I=e;return ty(I.hash.outputLen,I.nByteLength,I.hmac)(v,R)}g.BASE._setWindowSize(8);function c(p,y,A,v=q){const R=p;y=Je("msgHash",y),A=Je("publicKey",A);const{lowS:I,prehash:_,format:u}=v;if(Ml(v),"strict"in v)throw new Error("options.strict was renamed to lowS");if(u!==void 0&&u!=="compact"&&u!=="der")throw new Error("format must be compact or der");const l=typeof R=="string"||Rs(R),w=!l&&!u&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!l&&!w)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let T,D;try{if(w&&(T=new K(R.r,R.s)),l){try{u!=="compact"&&(T=K.fromDER(R))}catch(Oe){if(!(Oe instanceof En.Err))throw Oe}!T&&u!=="der"&&(T=K.fromCompact(R))}D=g.fromHex(A)}catch{return!1}if(!T||I&&T.hasHighS())return!1;_&&(y=e.hash(y));const{r:W,s:re}=T,oe=te(y),Ne=m(re),Ee=d(oe*Ne),we=d(W*Ne),De=g.BASE.multiplyAndAddUnsafe(D,Ee,we)?.toAffine();return De?d(De.x)===W:!1}return{CURVE:e,getPublicKey:z,getSharedSecret:j,sign:E,verify:c,ProjectivePoint:g,Signature:K,utils:Y}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function f1(t){return{hash:t,hmac:(e,...n)=>yl(t,e,Fm(...n)),randomBytes:wd}}function h1(t,e){const n=r=>l1({...t,...f1(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Bl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),kl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),p1=BigInt(0),m1=BigInt(1),Ua=BigInt(2),Ll=(t,e)=>(t+e/Ua)/e;function g1(t){const e=Bl,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),d=BigInt(88),m=t*t*t%e,g=m*m*t%e,x=qe(g,n,e)*g%e,O=qe(x,n,e)*g%e,N=qe(O,Ua,e)*m%e,F=qe(N,s,e)*N%e,M=qe(F,i,e)*F%e,k=qe(M,a,e)*M%e,K=qe(k,d,e)*k%e,Y=qe(K,a,e)*M%e,z=qe(Y,n,e)*g%e,L=qe(z,o,e)*F%e,j=qe(L,r,e)*m%e,J=qe(j,Ua,e);if(!Da.eql(Da.sqr(J),t))throw new Error("Cannot find square root");return J}const Da=Os(Bl,void 0,void 0,{sqrt:g1}),Fa=h1({a:p1,b:BigInt(7),Fp:Da,n:kl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=kl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-m1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=Ll(i*t,e),d=Ll(-r*t,e);let m=je(t-a*n-d*s,e),g=je(-a*r-d*i,e);const x=m>o,O=g>o;if(x&&(m=e-m),O&&(g=e-g),m>o||g>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:x,k1:m,k2neg:O,k2:g}}}},al),y1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:Fa},Symbol.toStringTag,{value:"Module"}));class Pl extends ue{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
22
- `),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class $a extends ue{constructor({docsPath:e,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:e,metaMessages:n,name:"AccountTypeNotSupportedError"})}}async function b1(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const za=new ns(128);async function Ul(t,e){const{account:n=t.account,chain:r=t.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,type:F,value:M,...k}=e;if(typeof n>"u")throw new Pl({docsPath:"/docs/actions/wallet/sendTransaction"});const K=n?_n(n):null;try{Ei(e);const Y=await(async()=>{if(e.to)return e.to;if(e.to!==null&&i&&i.length>0)return await Xd({authorization:i[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`.")})})();if(K?.type==="json-rpc"||K===null){let z;r!==null&&(z=await xt(t,xa,"getChainId")({}),Wy({currentChainId:z,chain:r}));const L=t.chain?.formatters?.transactionRequest?.format,J=(L||Ea)({...wa(k,{format:L}),accessList:s,account:K,authorizationList:i,blobs:o,chainId:z,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,to:Y,type:F,value:M},"sendTransaction"),te=za.get(t.uid),ee=te?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:ee,params:[J]},{retryCount:0})}catch(V){if(te===!1)throw V;const C=V;if(C.name==="InvalidInputRpcError"||C.name==="InvalidParamsRpcError"||C.name==="MethodNotFoundRpcError"||C.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[J]},{retryCount:0}).then(P=>(za.set(t.uid,!0),P)).catch(P=>{const q=P;throw q.name==="MethodNotFoundRpcError"||q.name==="MethodNotSupportedRpcError"?(za.set(t.uid,!1),C):q});throw C}}if(K?.type==="local"){const z=await xt(t,ml,"prepareTransactionRequest")({account:K,accessList:s,authorizationList:i,blobs:o,chain:r,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,nonceManager:K.nonceManager,parameters:[...hl,"sidecars"],type:F,value:M,...k,to:Y}),L=r?.serializers?.transaction,j=await K.signTransaction(z,{serializer:L});return await xt(t,b1,"sendRawTransaction")({serializedTransaction:j})}throw K?.type==="smart"?new $a({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new $a({docsPath:"/docs/actions/wallet/sendTransaction",type:K?.type})}catch(Y){throw Y instanceof $a?Y:fl(Y,{...e,account:K,chain:e.chain||void 0})}}async function Ri(t,e){return Ri.internal(t,Ul,"sendTransaction",e)}(function(t){async function e(n,r,s,i){const{abi:o,account:a=n.account,address:d,args:m,dataSuffix:g,functionName:x,...O}=i;if(typeof a>"u")throw new Pl({docsPath:"/docs/contract/writeContract"});const N=a?_n(a):null,F=Cg({abi:o,args:m,functionName:x});try{return await xt(n,r,s)({data:`${F}${g?g.replace("0x",""):""}`,to:d,account:N,...O})}catch(M){throw Xg(M,{abi:o,address:d,args:m,docsPath:"/docs/contract/writeContract",functionName:x,sender:N?.address})}}t.internal=e})(Ri||(Ri={}));function Dl(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}const _1="3.4.0",w1=()=>`@wagmi/core@${_1}`;var Fl=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Ai,$l;let rr=class _u extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return w1()}constructor(e,n={}){super(),Ai.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const r=n.cause instanceof _u?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof _u&&n.cause.docsPath||n.docsPath;this.message=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${this.docsBaseUrl}${s}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join(`
23
- `),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=e}walk(e){return Fl(this,Ai,"m",$l).call(this,this,e)}};Ai=new WeakSet,$l=function t(e,n){return n?.(e)?e:e.cause?Fl(this,Ai,"m",t).call(this,e.cause,n):e};class zl extends rr{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class E1 extends rr{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class v1 extends rr{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class R1 extends rr{constructor({address:e,connector:n}){super(`Account "${e}" not found for connector "${n.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class A1 extends rr{constructor({connectionChainId:e,connectorChainId:n}){super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class x1 extends rr{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function S1(t,e){let n;if(typeof e.connector=="function"?n=t._internal.connectors.setup(e.connector):n=e.connector,n.uid===t.state.current)throw new E1;try{t.setState(o=>({...o,status:"connecting"})),n.emitter.emit("message",{type:"connecting"});const{connector:r,...s}=e,i=await n.connect(s);return n.emitter.off("connect",t._internal.events.connect),n.emitter.on("change",t._internal.events.change),n.emitter.on("disconnect",t._internal.events.disconnect),await t.storage?.setItem("recentConnectorId",n.id),t.setState(o=>({...o,connections:new Map(o.connections).set(n.uid,{accounts:s.withCapabilities?i.accounts.map(a=>typeof a=="object"?a.address:a):i.accounts,chainId:i.chainId,connector:n}),current:n.uid,status:"connected"})),{accounts:s.withCapabilities?i.accounts.map(o=>typeof o=="object"?o:{address:o,capabilities:{}}):i.accounts,chainId:i.chainId}}catch(r){throw t.setState(s=>({...s,status:s.current?"connected":"disconnected"})),r}}const ja=256;let xi=ja,Si;function jl(t=11){if(!Si||xi+t>ja*2){Si="",xi=0;for(let e=0;e<ja;e++)Si+=(256+Math.random()*256|0).toString(16).substring(1)}return Si.substring(xi,xi+++t)}function T1(t){const{batch:e,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:o="base"}=t,a=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),d=n?.blockTime??12e3,m=Math.min(Math.max(Math.floor(d/2),500),4e3),g=t.pollingInterval??m,x=t.cacheTime??g,O=t.account?_n(t.account):void 0,{config:N,request:F,value:M}=t.transport({account:O,chain:n,pollingInterval:g}),k={...N,...M},K={account:O,batch:e,cacheTime:x,ccipRead:r,chain:n,key:s,name:i,pollingInterval:g,request:F,transport:k,type:o,uid:jl(),...a?{experimental_blockTag:a}:{}};function Y(z){return L=>{const j=L(z);for(const te in K)delete j[te];const J={...z,...j};return Object.assign(J,{extend:Y(J)})}}return Object.assign(K,{extend:Y(K)})}function O1({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},d){const m=jl();return{config:{key:t,methods:e,name:n,request:r,retryCount:s,retryDelay:i,timeout:o,type:a},request:qy(r,{methods:e,retryCount:s,retryDelay:i,uid:m}),value:d}}function I1(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:i}=e;return({retryCount:o})=>O1({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:i,type:"custom"})}async function Vl(t,e={}){const{assertChainId:n=!0}=e;let r;if(e.connector){const{connector:g}=e;if(t.state.status==="reconnecting"&&!g.getAccounts&&!g.getChainId)throw new x1({connector:g});const[x,O]=await Promise.all([g.getAccounts().catch(N=>{if(e.account===null)return[];throw N}),g.getChainId()]);r={accounts:x,chainId:O,connector:g}}else r=t.state.connections.get(t.state.current);if(!r)throw new v1;const s=e.chainId??r.chainId,i=await r.connector.getChainId();if(n&&i!==s)throw new A1({connectionChainId:s,connectorChainId:i});const o=r.connector;if(o.getClient)return o.getClient({chainId:s});const a=_n(e.account??r.accounts[0]);if(a&&(a.address=ui(a.address)),e.account&&!r.accounts.some(g=>g.toLowerCase()===a.address.toLowerCase()))throw new R1({address:a.address,connector:o});const d=t.chains.find(g=>g.id===s),m=await r.connector.getProvider({chainId:s});return T1({account:a,chain:d,name:"Connector Client",transport:g=>I1(m)({...g,retryCount:0})})}async function N1(t,e={}){let n;if(e.connector)n=e.connector;else{const{connections:s,current:i}=t.state;n=s.get(i)?.connector}const r=t.state.connections;n&&(await n.disconnect(),n.emitter.off("change",t._internal.events.change),n.emitter.off("disconnect",t._internal.events.disconnect),n.emitter.on("connect",t._internal.events.connect),r.delete(n.uid)),t.setState(s=>{if(r.size===0)return{...s,connections:new Map,current:null,status:"disconnected"};const i=r.values().next().value;return{...s,connections:new Map(r),current:i.connector.uid}});{const s=t.state.current;if(!s)return;const i=t.state.connections.get(s)?.connector;if(!i)return;await t.storage?.setItem("recentConnectorId",i.id)}}async function C1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Vl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Dl(o,Ul,"sendTransaction")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a,gas:i.gas??void 0})}class M1 extends rr{constructor({connector:e}){super(`"${e.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function B1(t,e){const{addEthereumChainParameter:n,chainId:r}=e,s=t.state.connections.get(e.connector?.uid??t.state.current);if(s){const o=s.connector;if(!o.switchChain)throw new M1({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const i=t.chains.find(o=>o.id===r);if(!i)throw new zl;return t.setState(o=>({...o,chainId:r})),i}async function k1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Vl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Dl(o,Ri,"writeContract")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a})}function AT(t){return t}function Va(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ga(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var Ha={exports:{}},Gl;function L1(){return Gl||(Gl=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function s(d,m,g){this.fn=d,this.context=m,this.once=g||!1}function i(d,m,g,x,O){if(typeof g!="function")throw new TypeError("The listener must be a function");var N=new s(g,x||d,O),F=n?n+m:m;return d._events[F]?d._events[F].fn?d._events[F]=[d._events[F],N]:d._events[F].push(N):(d._events[F]=N,d._eventsCount++),d}function o(d,m){--d._eventsCount===0?d._events=new r:delete d._events[m]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var m=[],g,x;if(this._eventsCount===0)return m;for(x in g=this._events)e.call(g,x)&&m.push(n?x.slice(1):x);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,x=this._events[g];if(!x)return[];if(x.fn)return[x.fn];for(var O=0,N=x.length,F=new Array(N);O<N;O++)F[O]=x[O].fn;return F},a.prototype.listenerCount=function(m){var g=n?n+m:m,x=this._events[g];return x?x.fn?1:x.length:0},a.prototype.emit=function(m,g,x,O,N,F){var M=n?n+m:m;if(!this._events[M])return!1;var k=this._events[M],K=arguments.length,Y,z;if(k.fn){switch(k.once&&this.removeListener(m,k.fn,void 0,!0),K){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,g),!0;case 3:return k.fn.call(k.context,g,x),!0;case 4:return k.fn.call(k.context,g,x,O),!0;case 5:return k.fn.call(k.context,g,x,O,N),!0;case 6:return k.fn.call(k.context,g,x,O,N,F),!0}for(z=1,Y=new Array(K-1);z<K;z++)Y[z-1]=arguments[z];k.fn.apply(k.context,Y)}else{var L=k.length,j;for(z=0;z<L;z++)switch(k[z].once&&this.removeListener(m,k[z].fn,void 0,!0),K){case 1:k[z].fn.call(k[z].context);break;case 2:k[z].fn.call(k[z].context,g);break;case 3:k[z].fn.call(k[z].context,g,x);break;case 4:k[z].fn.call(k[z].context,g,x,O);break;default:if(!Y)for(j=1,Y=new Array(K-1);j<K;j++)Y[j-1]=arguments[j];k[z].fn.apply(k[z].context,Y)}}return!0},a.prototype.on=function(m,g,x){return i(this,m,g,x,!1)},a.prototype.once=function(m,g,x){return i(this,m,g,x,!0)},a.prototype.removeListener=function(m,g,x,O){var N=n?n+m:m;if(!this._events[N])return this;if(!g)return o(this,N),this;var F=this._events[N];if(F.fn)F.fn===g&&(!O||F.once)&&(!x||F.context===x)&&o(this,N);else{for(var M=0,k=[],K=F.length;M<K;M++)(F[M].fn!==g||O&&!F[M].once||x&&F[M].context!==x)&&k.push(F[M]);k.length?this._events[N]=k.length===1?k[0]:k:o(this,N)}return this},a.prototype.removeAllListeners=function(m){var g;return m?(g=n?n+m:m,this._events[g]&&o(this,g)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(Ha)),Ha.exports}var P1=L1();const Hl=Va(P1);let Nr=class extends Error{name="BaseError";cause;constructor(e,n={}){super(e,n.cause?{cause:n.cause}:void 0),this.cause=n.cause}};class U1 extends Nr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}}let D1=class extends Nr{name="AddMiniApp.RejectedByUser";constructor(){super("Add miniapp rejected by user")}},ql=class extends Nr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};class F1 extends Nr{name="SignManifest.RejectedByUser";constructor(){super("Sign manifest rejected by user")}}class $1 extends Nr{name="SignManifest.InvalidDomain";constructor(){super("Invalid domain provided")}}class z1 extends Nr{name="SignManifest.GenericError";constructor(e="Manifest signing failed"){super(e)}}var Ie;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ie||(Ie={}));var Kl;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Kl||(Kl={}));const de=Ie.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Fn=t=>{switch(typeof t){case"undefined":return de.undefined;case"string":return de.string;case"number":return Number.isNaN(t)?de.nan:de.number;case"boolean":return de.boolean;case"function":return de.function;case"bigint":return de.bigint;case"symbol":return de.symbol;case"object":return Array.isArray(t)?de.array:t===null?de.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?de.promise:typeof Map<"u"&&t instanceof Map?de.map:typeof Set<"u"&&t instanceof Set?de.set:typeof Date<"u"&&t instanceof Date?de.date:de.object;default:return de.unknown}},ne=Ie.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Rn extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,d=0;for(;d<o.path.length;){const m=o.path[d];d===o.path.length-1?(a[m]=a[m]||{_errors:[]},a[m]._errors.push(n(o))):a[m]=a[m]||{_errors:[]},a=a[m],d++}}};return s(this),r}static assert(e){if(!(e instanceof Rn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ie.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Rn.create=t=>new Rn(t);const qa=(t,e)=>{let n;switch(t.code){case ne.invalid_type:t.received===de.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case ne.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ie.jsonStringifyReplacer)}`;break;case ne.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ie.joinValues(t.keys,", ")}`;break;case ne.invalid_union:n="Invalid input";break;case ne.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ie.joinValues(t.options)}`;break;case ne.invalid_enum_value:n=`Invalid enum value. Expected ${Ie.joinValues(t.options)}, received '${t.received}'`;break;case ne.invalid_arguments:n="Invalid function arguments";break;case ne.invalid_return_type:n="Invalid function return type";break;case ne.invalid_date:n="Invalid date";break;case ne.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ie.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case ne.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case ne.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case ne.custom:n="Invalid input";break;case ne.invalid_intersection_types:n="Intersection results could not be merged";break;case ne.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case ne.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ie.assertNever(t)}return{message:n}};let j1=qa;function V1(){return j1}const G1=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const d=r.filter(m=>!!m).slice().reverse();for(const m of d)a=m(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function ie(t,e){const n=V1(),r=G1({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===qa?void 0:qa].filter(s=>!!s)});t.common.issues.push(r)}class qt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return qt.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const pe=Object.freeze({status:"aborted"}),Is=t=>({status:"dirty",value:t}),Xt=t=>({status:"valid",value:t}),Wl=t=>t.status==="aborted",Zl=t=>t.status==="dirty",Cr=t=>t.status==="valid",Ti=t=>typeof Promise<"u"&&t instanceof Promise;var le;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(le||(le={}));class $n{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Yl=(t,e)=>{if(Cr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Rn(t.common.issues);return this._error=n,this._error}}};function Ae(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:d}=t;return o.code==="invalid_enum_value"?{message:d??a.defaultError}:typeof a.data>"u"?{message:d??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:d??n??a.defaultError}},description:s}}class Te{get description(){return this._def.description}_getType(e){return Fn(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Fn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qt,ctx:{common:e.parent.common,data:e.data,parsedType:Fn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Ti(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fn(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Yl(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fn(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Cr(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Cr(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Fn(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ti(s)?s:Promise.resolve(s));return Yl(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:ne.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new or({schema:this,typeName:me.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return xn.create(this,this._def)}nullable(){return ar.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return un.create(this)}promise(){return Mi.create(this,this._def)}or(e){return Ii.create([this,e],this._def)}and(e){return Ni.create(this,e,this._def)}transform(e){return new or({...Ae(this._def),schema:this,typeName:me.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Bi({...Ae(this._def),innerType:this,defaultValue:n,typeName:me.ZodDefault})}brand(){return new af({typeName:me.ZodBranded,type:this,...Ae(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ki({...Ae(this._def),innerType:this,catchValue:n,typeName:me.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tc.create(this,e)}readonly(){return Li.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const H1=/^c[^\s-]{8,}$/i,q1=/^[0-9a-z]+$/,K1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,W1=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z1=/^[a-z0-9_-]{21}$/i,Y1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,J1=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,X1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ka;const eb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,nb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ib=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ob=new RegExp(`^${Jl}$`);function Xl(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function ab(t){return new RegExp(`^${Xl(t)}$`)}function cb(t){let e=`${Jl}T${Xl(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ub(t,e){return!!((e==="v4"||!e)&&eb.test(t)||(e==="v6"||!e)&&nb.test(t))}function db(t,e){if(!Y1.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function lb(t,e){return!!((e==="v4"||!e)&&tb.test(t)||(e==="v6"||!e)&&rb.test(t))}class zn extends Te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==de.string){const i=this._getOrReturnCtx(e);return ie(i,{code:ne.invalid_type,expected:de.string,received:i.parsedType}),pe}const r=new qt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?ie(s,{code:ne.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ie(s,{code:ne.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")X1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"email",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Ka||(Ka=new RegExp(Q1,"u")),Ka.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"emoji",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")W1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"uuid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Z1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"nanoid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")H1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cuid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")q1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cuid2",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")K1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"ulid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),ie(s,{validation:"url",code:ne.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"regex",code:ne.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?cb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?ob.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?ab(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?J1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"duration",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?ub(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"ip",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?db(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"jwt",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?lb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cidr",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?sb.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ib.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64url",code:ne.invalid_string,message:i.message}),r.dirty()):Ie.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:ne.invalid_string,...le.errToObj(r)})}_addCheck(e){return new zn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...le.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...le.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...le.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...le.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...le.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...le.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...le.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...le.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...le.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...le.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...le.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...le.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...le.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...le.errToObj(n)})}nonempty(e){return this.min(1,le.errToObj(e))}trim(){return new zn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new zn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new zn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}zn.create=t=>new zn({checks:[],typeName:me.ZodString,coerce:t?.coerce??!1,...Ae(t)});function fb(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Mr extends Te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==de.number){const i=this._getOrReturnCtx(e);return ie(i,{code:ne.invalid_type,expected:de.number,received:i.parsedType}),pe}let r;const s=new qt;for(const i of this._def.checks)i.kind==="int"?Ie.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?fb(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.not_finite,message:i.message}),s.dirty()):Ie.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,le.toString(n))}gt(e,n){return this.setLimit("min",e,!1,le.toString(n))}lte(e,n){return this.setLimit("max",e,!0,le.toString(n))}lt(e,n){return this.setLimit("max",e,!1,le.toString(n))}setLimit(e,n,r,s){return new Mr({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Mr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:le.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:le.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ie.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Mr.create=t=>new Mr({checks:[],typeName:me.ZodNumber,coerce:t?.coerce||!1,...Ae(t)});class Ns extends Te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==de.bigint)return this._getInvalidInput(e);let r;const s=new qt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ne.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ie.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ne.invalid_type,expected:de.bigint,received:n.parsedType}),pe}gte(e,n){return this.setLimit("min",e,!0,le.toString(n))}gt(e,n){return this.setLimit("min",e,!1,le.toString(n))}lte(e,n){return this.setLimit("max",e,!0,le.toString(n))}lt(e,n){return this.setLimit("max",e,!1,le.toString(n))}setLimit(e,n,r,s){return new Ns({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Ns({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:le.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Ns.create=t=>new Ns({checks:[],typeName:me.ZodBigInt,coerce:t?.coerce??!1,...Ae(t)});class Wa extends Te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==de.boolean){const r=this._getOrReturnCtx(e);return ie(r,{code:ne.invalid_type,expected:de.boolean,received:r.parsedType}),pe}return Xt(e.data)}}Wa.create=t=>new Wa({typeName:me.ZodBoolean,coerce:t?.coerce||!1,...Ae(t)});class Oi extends Te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==de.date){const i=this._getOrReturnCtx(e);return ie(i,{code:ne.invalid_type,expected:de.date,received:i.parsedType}),pe}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ie(i,{code:ne.invalid_date}),pe}const r=new qt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ie.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oi({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:le.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:le.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Oi.create=t=>new Oi({checks:[],coerce:t?.coerce||!1,typeName:me.ZodDate,...Ae(t)});class Ql extends Te{_parse(e){if(this._getType(e)!==de.symbol){const r=this._getOrReturnCtx(e);return ie(r,{code:ne.invalid_type,expected:de.symbol,received:r.parsedType}),pe}return Xt(e.data)}}Ql.create=t=>new Ql({typeName:me.ZodSymbol,...Ae(t)});class Za extends Te{_parse(e){if(this._getType(e)!==de.undefined){const r=this._getOrReturnCtx(e);return ie(r,{code:ne.invalid_type,expected:de.undefined,received:r.parsedType}),pe}return Xt(e.data)}}Za.create=t=>new Za({typeName:me.ZodUndefined,...Ae(t)});class Ya extends Te{_parse(e){if(this._getType(e)!==de.null){const r=this._getOrReturnCtx(e);return ie(r,{code:ne.invalid_type,expected:de.null,received:r.parsedType}),pe}return Xt(e.data)}}Ya.create=t=>new Ya({typeName:me.ZodNull,...Ae(t)});class ef extends Te{constructor(){super(...arguments),this._any=!0}_parse(e){return Xt(e.data)}}ef.create=t=>new ef({typeName:me.ZodAny,...Ae(t)});class tf extends Te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Xt(e.data)}}tf.create=t=>new tf({typeName:me.ZodUnknown,...Ae(t)});class jn extends Te{_parse(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ne.invalid_type,expected:de.never,received:n.parsedType}),pe}}jn.create=t=>new jn({typeName:me.ZodNever,...Ae(t)});class nf extends Te{_parse(e){if(this._getType(e)!==de.undefined){const r=this._getOrReturnCtx(e);return ie(r,{code:ne.invalid_type,expected:de.void,received:r.parsedType}),pe}return Xt(e.data)}}nf.create=t=>new nf({typeName:me.ZodVoid,...Ae(t)});class un extends Te{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==de.array)return ie(n,{code:ne.invalid_type,expected:de.array,received:n.parsedType}),pe;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(ie(n,{code:o?ne.too_big:ne.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(ie(n,{code:ne.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(ie(n,{code:ne.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new $n(n,o,n.path,a)))).then(o=>qt.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new $n(n,o,n.path,a)));return qt.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new un({...this._def,minLength:{value:e,message:le.toString(n)}})}max(e,n){return new un({...this._def,maxLength:{value:e,message:le.toString(n)}})}length(e,n){return new un({...this._def,exactLength:{value:e,message:le.toString(n)}})}nonempty(e){return this.min(1,e)}}un.create=(t,e)=>new un({type:t,minLength:null,maxLength:null,exactLength:null,typeName:me.ZodArray,...Ae(e)});function Br(t){if(t instanceof Qe){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=xn.create(Br(r))}return new Qe({...t._def,shape:()=>e})}else return t instanceof un?new un({...t._def,type:Br(t.element)}):t instanceof xn?xn.create(Br(t.unwrap())):t instanceof ar?ar.create(Br(t.unwrap())):t instanceof sr?sr.create(t.items.map(e=>Br(e))):t}class Qe extends Te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Ie.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==de.object){const m=this._getOrReturnCtx(e);return ie(m,{code:ne.invalid_type,expected:de.object,received:m.parsedType}),pe}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof jn&&this._def.unknownKeys==="strip"))for(const m in s.data)o.includes(m)||a.push(m);const d=[];for(const m of o){const g=i[m],x=s.data[m];d.push({key:{status:"valid",value:m},value:g._parse(new $n(s,x,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof jn){const m=this._def.unknownKeys;if(m==="passthrough")for(const g of a)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(m==="strict")a.length>0&&(ie(s,{code:ne.unrecognized_keys,keys:a}),r.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const g of a){const x=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new $n(s,x,s.path,g)),alwaysSet:g in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of d){const x=await g.key,O=await g.value;m.push({key:x,value:O,alwaysSet:g.alwaysSet})}return m}).then(m=>qt.mergeObjectSync(r,m)):qt.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return le.errToObj,new Qe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:le.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Qe({...this._def,unknownKeys:"strip"})}passthrough(){return new Qe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Qe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Qe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:me.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Qe({...this._def,catchall:e})}pick(e){const n={};for(const r of Ie.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Qe({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ie.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new Qe({...this._def,shape:()=>n})}deepPartial(){return Br(this)}partial(e){const n={};for(const r of Ie.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new Qe({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ie.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof xn;)i=i._def.innerType;n[r]=i}return new Qe({...this._def,shape:()=>n})}keyof(){return sf(Ie.objectKeys(this.shape))}}Qe.create=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strip",catchall:jn.create(),typeName:me.ZodObject,...Ae(e)}),Qe.strictCreate=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strict",catchall:jn.create(),typeName:me.ZodObject,...Ae(e)}),Qe.lazycreate=(t,e)=>new Qe({shape:t,unknownKeys:"strip",catchall:jn.create(),typeName:me.ZodObject,...Ae(e)});class Ii extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new Rn(a.ctx.common.issues));return ie(n,{code:ne.invalid_union,unionErrors:o}),pe}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const d of r){const m={...n,common:{...n.common,issues:[]},parent:null},g=d._parseSync({data:n.data,path:n.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(d=>new Rn(d));return ie(n,{code:ne.invalid_union,unionErrors:a}),pe}}get options(){return this._def.options}}Ii.create=(t,e)=>new Ii({options:t,typeName:me.ZodUnion,...Ae(e)});const An=t=>t instanceof Qa?An(t.schema):t instanceof or?An(t.innerType()):t instanceof Ci?[t.value]:t instanceof ir?t.options:t instanceof ec?Ie.objectValues(t.enum):t instanceof Bi?An(t._def.innerType):t instanceof Za?[void 0]:t instanceof Ya?[null]:t instanceof xn?[void 0,...An(t.unwrap())]:t instanceof ar?[null,...An(t.unwrap())]:t instanceof af||t instanceof Li?An(t.unwrap()):t instanceof ki?An(t._def.innerType):[];class Ja extends Te{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==de.object)return ie(n,{code:ne.invalid_type,expected:de.object,received:n.parsedType}),pe;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:ne.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const i of n){const o=An(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new Ja({typeName:me.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Ae(r)})}}function Xa(t,e){const n=Fn(t),r=Fn(e);if(t===e)return{valid:!0,data:t};if(n===de.object&&r===de.object){const s=Ie.objectKeys(e),i=Ie.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const d=Xa(t[a],e[a]);if(!d.valid)return{valid:!1};o[a]=d.data}return{valid:!0,data:o}}else if(n===de.array&&r===de.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],d=Xa(o,a);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return n===de.date&&r===de.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ni extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Wl(i)||Wl(o))return pe;const a=Xa(i.value,o.value);return a.valid?((Zl(i)||Zl(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:ne.invalid_intersection_types}),pe)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ni.create=(t,e,n)=>new Ni({left:t,right:e,typeName:me.ZodIntersection,...Ae(n)});class sr extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.array)return ie(r,{code:ne.invalid_type,expected:de.array,received:r.parsedType}),pe;if(r.data.length<this._def.items.length)return ie(r,{code:ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const d=this._def.items[a]||this._def.rest;return d?d._parse(new $n(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>qt.mergeArray(n,o)):qt.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new sr({...this._def,rest:e})}}sr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new sr({items:t,typeName:me.ZodTuple,rest:null,...Ae(e)})};class rf extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.map)return ie(r,{code:ne.invalid_type,expected:de.map,received:r.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,d],m)=>({key:s._parse(new $n(r,a,r.path,[m,"key"])),value:i._parse(new $n(r,d,r.path,[m,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const d of o){const m=await d.key,g=await d.value;if(m.status==="aborted"||g.status==="aborted")return pe;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const d of o){const m=d.key,g=d.value;if(m.status==="aborted"||g.status==="aborted")return pe;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}}}}rf.create=(t,e,n)=>new rf({valueType:e,keyType:t,typeName:me.ZodMap,...Ae(n)});class Cs extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.set)return ie(r,{code:ne.invalid_type,expected:de.set,received:r.parsedType}),pe;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(ie(r,{code:ne.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(ie(r,{code:ne.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(d){const m=new Set;for(const g of d){if(g.status==="aborted")return pe;g.status==="dirty"&&n.dirty(),m.add(g.value)}return{status:n.value,value:m}}const a=[...r.data.values()].map((d,m)=>i._parse(new $n(r,d,r.path,m)));return r.common.async?Promise.all(a).then(d=>o(d)):o(a)}min(e,n){return new Cs({...this._def,minSize:{value:e,message:le.toString(n)}})}max(e,n){return new Cs({...this._def,maxSize:{value:e,message:le.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Cs.create=(t,e)=>new Cs({valueType:t,minSize:null,maxSize:null,typeName:me.ZodSet,...Ae(e)});class Qa extends Te{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Qa.create=(t,e)=>new Qa({getter:t,typeName:me.ZodLazy,...Ae(e)});class Ci extends Te{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return ie(n,{received:n.data,code:ne.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ci.create=(t,e)=>new Ci({value:t,typeName:me.ZodLiteral,...Ae(e)});function sf(t,e){return new ir({values:t,typeName:me.ZodEnum,...Ae(e)})}class ir extends Te{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return ie(n,{expected:Ie.joinValues(r),received:n.parsedType,code:ne.invalid_type}),pe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return ie(n,{received:n.data,code:ne.invalid_enum_value,options:r}),pe}return Xt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ir.create(e,{...this._def,...n})}exclude(e,n=this._def){return ir.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}ir.create=sf;class ec extends Te{_parse(e){const n=Ie.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==de.string&&r.parsedType!==de.number){const s=Ie.objectValues(n);return ie(r,{expected:Ie.joinValues(s),received:r.parsedType,code:ne.invalid_type}),pe}if(this._cache||(this._cache=new Set(Ie.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ie.objectValues(n);return ie(r,{received:r.data,code:ne.invalid_enum_value,options:s}),pe}return Xt(e.data)}get enum(){return this._def.values}}ec.create=(t,e)=>new ec({values:t,typeName:me.ZodNativeEnum,...Ae(e)});class Mi extends Te{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==de.promise&&n.common.async===!1)return ie(n,{code:ne.invalid_type,expected:de.promise,received:n.parsedType}),pe;const r=n.parsedType===de.promise?n.data:Promise.resolve(n.data);return Xt(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Mi.create=(t,e)=>new Mi({type:t,typeName:me.ZodPromise,...Ae(e)});class or extends Te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===me.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return pe;const d=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return d.status==="aborted"?pe:d.status==="dirty"||n.value==="dirty"?Is(d.value):d});{if(n.value==="aborted")return pe;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?pe:a.status==="dirty"||n.value==="dirty"?Is(a.value):a}}if(s.type==="refinement"){const o=a=>{const d=s.refinement(a,i);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?pe:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?pe:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Cr(o))return pe;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Cr(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):pe);Ie.assertNever(s)}}or.create=(t,e,n)=>new or({schema:t,typeName:me.ZodEffects,effect:e,...Ae(n)}),or.createWithPreprocess=(t,e,n)=>new or({schema:e,effect:{type:"preprocess",transform:t},typeName:me.ZodEffects,...Ae(n)});class xn extends Te{_parse(e){return this._getType(e)===de.undefined?Xt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xn.create=(t,e)=>new xn({innerType:t,typeName:me.ZodOptional,...Ae(e)});class ar extends Te{_parse(e){return this._getType(e)===de.null?Xt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ar.create=(t,e)=>new ar({innerType:t,typeName:me.ZodNullable,...Ae(e)});class Bi extends Te{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===de.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Bi.create=(t,e)=>new Bi({innerType:t,typeName:me.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ae(e)});class ki extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ti(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Rn(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ki.create=(t,e)=>new ki({innerType:t,typeName:me.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ae(e)});class of extends Te{_parse(e){if(this._getType(e)!==de.nan){const r=this._getOrReturnCtx(e);return ie(r,{code:ne.invalid_type,expected:de.nan,received:r.parsedType}),pe}return{status:"valid",value:e.data}}}of.create=t=>new of({typeName:me.ZodNaN,...Ae(t)});class af extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class tc extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?pe:i.status==="dirty"?(n.dirty(),Is(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?pe:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new tc({in:e,out:n,typeName:me.ZodPipeline})}}class Li extends Te{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Cr(s)&&(s.value=Object.freeze(s.value)),s);return Ti(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Li.create=(t,e)=>new Li({innerType:t,typeName:me.ZodReadonly,...Ae(e)});var me;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(me||(me={}));const Ke=zn.create,cf=Mr.create,hb=Wa.create;jn.create;const cr=un.create,Et=Qe.create,Pi=Ii.create,uf=Ja.create;Ni.create,sr.create;const Tt=Ci.create,nc=ir.create;Mi.create,xn.create,ar.create;const pb=/[@#$%^&*+=/\\|~«»]/,mb=/(!{2,}|\?{2,}|-{2,})/,gb=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,kr=({max:t,noSpaces:e}={})=>(e?Ke().max(t??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):Ke().max(t??Number.POSITIVE_INFINITY)).refine(r=>!gb.test(r),{message:"Emojis and symbols are not allowed"}).refine(r=>!pb.test(r),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed"}).refine(r=>!mb.test(r),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Pt=Ke().url().startsWith("https://",{message:"Must be an https url"}).max(1024).refine(t=>!t.includes(" "),{message:"URL must not contain spaces"}).refine(t=>{try{const e=new URL(t).hostname;return!(e==="localhost"||e.endsWith(".localhost")||/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||e.startsWith("[")&&e.endsWith("]"))}catch{return!1}},{message:"URL must not use IP addresses or localhost"}),rc=Ke().max(32),df=Ke().max(32),yb=/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/,bb=Ke().regex(yb,{message:"Invalid CAIP-19 asset ID"}),sc=Ke().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),_b=/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,wb=Ke().max(1024).regex(_b,{message:"Must be a valid domain name (e.g., example.com, sub.example.com)"}).refine(t=>!t.includes("://"),{message:"Domain must not include protocol (http://, https://, etc.)"}).refine(t=>!t.includes("/"),{message:"Domain must not include path separators"}).refine(t=>!t.includes("@"),{message:"Domain must not include @ symbol"}).refine(t=>!t.includes(":"),{message:"Domain must not include port numbers"}),Eb=Pi([Tt("1:1"),Tt("3:2")]),vb=Et({header:Ke(),payload:Ke(),signature:Ke()});Et({fid:cf(),type:Tt("app_key"),key:Ke().startsWith("0x")});const Rb=Et({type:Tt("launch_frame"),name:rc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:sc.optional()}),Ab=Et({type:Tt("launch_miniapp"),name:rc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:sc.optional()}),xb=Et({type:Tt("view_token"),token:bb}),Sb=uf("type",[Ab,xb,Rb]),Tb=Et({title:df,action:Sb});Et({version:Pi([Ke(),cf()]).transform(t=>String(t)).pipe(Pi([Tt("next"),Tt("1")])),imageUrl:Pt,aspectRatio:Eb.optional(),button:Tb});const lf=Et({url:Ke(),token:Ke()});Et({notificationId:Ke().max(128),title:Ke().max(32),body:Ke().max(128),targetUrl:Pt,tokens:Ke().array().max(100)}),Et({result:Et({successfulTokens:cr(Ke()),invalidTokens:cr(Ke()),rateLimitedTokens:cr(Ke())})});const Ob=Et({event:Tt("miniapp_added"),notificationDetails:lf.optional()}),Ib=Et({event:Tt("miniapp_removed")}),Nb=Et({event:Tt("notifications_enabled"),notificationDetails:lf.required()}),Cb=Et({event:Tt("notifications_disabled")});uf("event",[Ob,Ib,Nb,Cb]);const Mb=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewCast","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken","actions.openMiniApp","actions.requestCameraAndMicrophoneAccess","experimental.signManifest","haptics.impactOccurred","haptics.notificationOccurred","haptics.selectionChanged","back"],Bb=nc(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),kb=Pi([Tt("0.0.0"),Tt("0.0.1"),Tt("1"),Tt("next")]),Lb=kr({max:30}),Pb=kr({max:170}),Ub=cr(Pt).max(3),Db=cr(kr({max:20,noSpaces:!0})).max(5),Fb=kr({max:30}),$b=kr({max:30}),zb=kr({max:100}),jb=hb(),Vb=["eip155:1","eip155:8453","eip155:42161","eip155:421614","eip155:84532","eip155:666666666","eip155:100","eip155:10","eip155:11155420","eip155:137","eip155:11155111","eip155:7777777","eip155:130","eip155:10143","eip155:42220","eip155:999","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"];function ff(t){const e=new Set(t);return Array.from(e)}const Gb=cr(nc(Vb)).transform(ff),Hb=cr(nc(Mb)).transform(ff),hf=Et({version:kb,name:rc,iconUrl:Pt,homeUrl:Pt,imageUrl:Pt.optional(),buttonTitle:df.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:sc.optional(),webhookUrl:Pt.optional(),subtitle:Lb.optional(),description:Pb.optional(),screenshotUrls:Ub.optional(),primaryCategory:Bb.optional(),tags:Db.optional(),heroImageUrl:Pt.optional(),tagline:Fb.optional(),ogTitle:$b.optional(),ogDescription:zb.optional(),ogImageUrl:Pt.optional(),noindex:jb.optional(),requiredChains:Gb.optional(),requiredCapabilities:Hb.optional(),castShareUrl:Pt.optional(),canonicalDomain:wb.optional()}).refine(t=>{if(t.castShareUrl===void 0)return!0;try{const e=new URL(t.homeUrl).hostname,n=new URL(t.castShareUrl).hostname;return e===n}catch{return!1}},{message:"castShareUrl must have the same domain as homeUrl",path:["castShareUrl"]});Et({accountAssociation:vb,miniapp:hf.optional(),frame:hf.optional()}).refine(t=>t.frame&&t.miniapp?JSON.stringify(t.frame)===JSON.stringify(t.miniapp):!0,{message:'If both "frame" and "miniapp" are provided, they must be identical',path:["frame","miniapp"]}).transform(t=>({...t,frame:t.frame??t.miniapp}));var ic={},Ms={},pf;function qb(){if(pf)return Ms;pf=1,Ms.byteLength=a,Ms.toByteArray=m,Ms.fromByteArray=O;for(var t=[],e=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)t[s]=r[s],e[r.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(N){var F=N.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var M=N.indexOf("=");M===-1&&(M=F);var k=M===F?0:4-M%4;return[M,k]}function a(N){var F=o(N),M=F[0],k=F[1];return(M+k)*3/4-k}function d(N,F,M){return(F+M)*3/4-M}function m(N){var F,M=o(N),k=M[0],K=M[1],Y=new n(d(N,k,K)),z=0,L=K>0?k-4:k,j;for(j=0;j<L;j+=4)F=e[N.charCodeAt(j)]<<18|e[N.charCodeAt(j+1)]<<12|e[N.charCodeAt(j+2)]<<6|e[N.charCodeAt(j+3)],Y[z++]=F>>16&255,Y[z++]=F>>8&255,Y[z++]=F&255;return K===2&&(F=e[N.charCodeAt(j)]<<2|e[N.charCodeAt(j+1)]>>4,Y[z++]=F&255),K===1&&(F=e[N.charCodeAt(j)]<<10|e[N.charCodeAt(j+1)]<<4|e[N.charCodeAt(j+2)]>>2,Y[z++]=F>>8&255,Y[z++]=F&255),Y}function g(N){return t[N>>18&63]+t[N>>12&63]+t[N>>6&63]+t[N&63]}function x(N,F,M){for(var k,K=[],Y=F;Y<M;Y+=3)k=(N[Y]<<16&16711680)+(N[Y+1]<<8&65280)+(N[Y+2]&255),K.push(g(k));return K.join("")}function O(N){for(var F,M=N.length,k=M%3,K=[],Y=16383,z=0,L=M-k;z<L;z+=Y)K.push(x(N,z,z+Y>L?L:z+Y));return k===1?(F=N[M-1],K.push(t[F>>2]+t[F<<4&63]+"==")):k===2&&(F=(N[M-2]<<8)+N[M-1],K.push(t[F>>10]+t[F>>4&63]+t[F<<2&63]+"=")),K.join("")}return Ms}var Ui={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var mf;function Kb(){return mf||(mf=1,Ui.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,d=(1<<a)-1,m=d>>1,g=-7,x=n?s-1:0,O=n?-1:1,N=t[e+x];for(x+=O,i=N&(1<<-g)-1,N>>=-g,g+=a;g>0;i=i*256+t[e+x],x+=O,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=r;g>0;o=o*256+t[e+x],x+=O,g-=8);if(i===0)i=1-m;else{if(i===d)return o?NaN:(N?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-m}return(N?-1:1)*o*Math.pow(2,i-r)},Ui.write=function(t,e,n,r,s,i){var o,a,d,m=i*8-s-1,g=(1<<m)-1,x=g>>1,O=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=r?0:i-1,F=r?1:-1,M=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=g):(o=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-o))<1&&(o--,d*=2),o+x>=1?e+=O/d:e+=O*Math.pow(2,1-x),e*d>=2&&(o++,d/=2),o+x>=g?(a=0,o=g):o+x>=1?(a=(e*d-1)*Math.pow(2,s),o=o+x):(a=e*Math.pow(2,x-1)*Math.pow(2,s),o=0));s>=8;t[n+N]=a&255,N+=F,a/=256,s-=8);for(o=o<<s|a,m+=s;m>0;t[n+N]=o&255,N+=F,o/=256,m-=8);t[n+N-F]|=M*128}),Ui}/*!
18
+ `)})}}Object.defineProperty(Ar,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class us extends jt{constructor(e){super(e,{code:us.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ds extends jt{constructor(e){super(e,{code:ds.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ls extends jt{constructor(e){super(e,{code:ls.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class er extends jt{constructor(e,{method:n}={}){super(e,{code:er.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(er,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class xr extends jt{constructor(e){super(e,{code:xr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class fs extends jt{constructor(e){super(e,{code:fs.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});let hi=class C0 extends Ht{constructor(e){super(e,{code:C0.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}};Object.defineProperty(hi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class hs extends Ht{constructor(e){super(e,{code:hs.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ps extends Ht{constructor(e,{method:n}={}){super(e,{code:ps.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class ms extends Ht{constructor(e){super(e,{code:ms.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});let ia=class M0 extends Ht{constructor(e){super(e,{code:M0.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}};Object.defineProperty(ia,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Sr extends Ht{constructor(e){super(e,{code:Sr.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class gs extends Ht{constructor(e){super(e,{code:gs.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class ys extends Ht{constructor(e){super(e,{code:ys.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class bs extends Ht{constructor(e){super(e,{code:bs.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class _s extends Ht{constructor(e){super(e,{code:_s.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class ws extends Ht{constructor(e){super(e,{code:ws.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Es extends Ht{constructor(e){super(e,{code:Es.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class vs extends Ht{constructor(e){super(e,{code:vs.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Yg extends jt{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Jg=3;function Xg(t,{abi:e,address:n,args:r,docsPath:s,functionName:i,sender:o}){const a=t instanceof Wg?t:t instanceof ue?t.walk(F=>"data"in F)||t.walk():{},{code:d,data:m,details:g,message:x,shortMessage:O}=a,N=t instanceof $o?new Kg({functionName:i}):[Jg,Qn.code].includes(d)&&(m||g||x||O)||d===Ar.code&&g==="execution reverted"&&m?new qg({abi:e,data:typeof m=="object"?m.data:m,functionName:i,message:a instanceof Vd?g:O??x}):t;return new Hg(N,{abi:e,args:r,contractAddress:n,docsPath:s,functionName:i,sender:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const oa=BigInt(0),aa=BigInt(1);function Rs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ca(t){if(!Rs(t))throw new Error("Uint8Array expected")}function Ln(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function pi(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Gd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?oa:BigInt("0x"+t)}const Hd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Qg=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Tr(t){if(ca(t),Hd)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Qg[t[n]];return e}const En={_0:48,_9:57,A:65,F:70,a:97,f:102};function qd(t){if(t>=En._0&&t<=En._9)return t-En._0;if(t>=En.A&&t<=En.F)return t-(En.A-10);if(t>=En.a&&t<=En.f)return t-(En.a-10)}function mi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Hd)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let s=0,i=0;s<n;s++,i+=2){const o=qd(t.charCodeAt(i)),a=qd(t.charCodeAt(i+1));if(o===void 0||a===void 0){const d=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+d+'" at index '+i)}r[s]=o*16+a}return r}function tr(t){return Gd(Tr(t))}function As(t){return ca(t),Gd(Tr(Uint8Array.from(t).reverse()))}function xs(t,e){return mi(t.toString(16).padStart(e*2,"0"))}function gi(t,e){return xs(t,e).reverse()}function Je(t,e,n){let r;if(typeof e=="string")try{r=mi(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Rs(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const s=r.length;if(typeof n=="number"&&s!==n)throw new Error(t+" of length "+n+" expected, got "+s);return r}function Or(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];ca(s),e+=s.length}const n=new Uint8Array(e);for(let r=0,s=0;r<t.length;r++){const i=t[r];n.set(i,s),s+=i.length}return n}const ua=t=>typeof t=="bigint"&&oa<=t;function da(t,e,n){return ua(t)&&ua(e)&&ua(n)&&e<=t&&t<n}function nn(t,e,n,r){if(!da(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function ey(t){let e;for(e=0;t>oa;t>>=aa,e+=1);return e}const yi=t=>(aa<<BigInt(t))-aa,la=t=>new Uint8Array(t),Kd=t=>Uint8Array.from(t);function ty(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");let r=la(t),s=la(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...x)=>n(s,r,...x),d=(x=la(0))=>{s=a(Kd([0]),x),r=a(),x.length!==0&&(s=a(Kd([1]),x),r=a())},m=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let x=0;const O=[];for(;x<e;){r=a();const N=r.slice();O.push(N),x+=r.length}return Or(...O)};return(x,O)=>{o(),d(x);let N;for(;!(N=O(m()));)d();return o(),N}}const ny={bigint:t=>typeof t=="bigint",function:t=>typeof t=="function",boolean:t=>typeof t=="boolean",string:t=>typeof t=="string",stringOrUint8Array:t=>typeof t=="string"||Rs(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>typeof t=="function"&&Number.isSafeInteger(t.outputLen)};function Ss(t,e,n={}){const r=(s,i,o)=>{const a=ny[i];if(typeof a!="function")throw new Error("invalid validator function");const d=t[s];if(!(o&&d===void 0)&&!a(d,t))throw new Error("param "+String(s)+" is invalid. Expected "+i+", got "+d)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(n))r(s,i,!0);return t}function bi(t){const e=new WeakMap;return(n,...r)=>{const s=e.get(n);if(s!==void 0)return s;const i=t(n,...r);return e.set(n,i),i}}class Ir extends ue{constructor({cause:e,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Ir,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class _i extends ue{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${tn(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(_i,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class fa extends ue{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${tn(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(fa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class ha extends ue{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(ha,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class pa extends ue{constructor({cause:e,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
19
+ `),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(pa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class ma extends ue{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(ma,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ga extends ue{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join(`
20
+ `),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(ga,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ya extends ue{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class ba extends ue{constructor({cause:e,gas:n}={}){super(`The amount of gas ${n?`(${n}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(ba,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class _a extends ue{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(_a,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class wi extends ue{constructor({cause:e,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${tn(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${tn(r)} gwei`:""}).`].join(`
21
+ `),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(wi,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class wa extends ue{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Wd(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof ue?t.walk(s=>s?.code===Ir.code):t;return r instanceof ue?new Ir({cause:t,message:r.details}):Ir.nodeMessage.test(n)?new Ir({cause:t,message:t.details}):_i.nodeMessage.test(n)?new _i({cause:t,maxFeePerGas:e?.maxFeePerGas}):fa.nodeMessage.test(n)?new fa({cause:t,maxFeePerGas:e?.maxFeePerGas}):ha.nodeMessage.test(n)?new ha({cause:t,nonce:e?.nonce}):pa.nodeMessage.test(n)?new pa({cause:t,nonce:e?.nonce}):ma.nodeMessage.test(n)?new ma({cause:t,nonce:e?.nonce}):ga.nodeMessage.test(n)?new ga({cause:t}):ya.nodeMessage.test(n)?new ya({cause:t,gas:e?.gas}):ba.nodeMessage.test(n)?new ba({cause:t,gas:e?.gas}):_a.nodeMessage.test(n)?new _a({cause:t}):wi.nodeMessage.test(n)?new wi({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new wa({cause:t})}function Ea(t,{format:e}){if(!e)return{};const n={};function r(i){const o=Object.keys(i);for(const a of o)a in t&&(n[a]=t[a]),i[a]&&typeof i[a]=="object"&&!Array.isArray(i[a])&&r(i[a])}const s=e(t||{});return r(s),n}const ry={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function va(t,e){const n={};return typeof t.authorizationList<"u"&&(n.authorizationList=sy(t.authorizationList)),typeof t.accessList<"u"&&(n.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(n.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?n.blobs=t.blobs.map(r=>zt(r)):n.blobs=t.blobs),typeof t.data<"u"&&(n.data=t.data),t.account&&(n.from=t.account.address),typeof t.from<"u"&&(n.from=t.from),typeof t.gas<"u"&&(n.gas=ke(t.gas)),typeof t.gasPrice<"u"&&(n.gasPrice=ke(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=ke(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(n.maxFeePerGas=ke(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=ke(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(n.nonce=ke(t.nonce)),typeof t.to<"u"&&(n.to=t.to),typeof t.type<"u"&&(n.type=ry[t.type]),typeof t.value<"u"&&(n.value=ke(t.value)),n}function sy(t){return t.map(e=>({address:e.address,r:e.r?ke(BigInt(e.r)):e.r,s:e.s?ke(BigInt(e.s)):e.s,chainId:ke(e.chainId),nonce:ke(e.nonce),...typeof e.yParity<"u"?{yParity:ke(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:ke(e.v)}:{}}))}function Zd(t){if(!(!t||t.length===0))return t.reduce((e,{slot:n,value:r})=>{if(n.length!==66)throw new dd({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new dd({size:r.length,targetSize:66,type:"hex"});return e[n]=r,e},{})}function iy(t){const{balance:e,nonce:n,state:r,stateDiff:s,code:i}=t,o={};if(i!==void 0&&(o.code=i),e!==void 0&&(o.balance=ke(e)),n!==void 0&&(o.nonce=ke(n)),r!==void 0&&(o.state=Zd(r)),s!==void 0){if(o.state)throw new zg;o.stateDiff=Zd(s)}return o}function oy(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!kn(n,{strict:!1}))throw new Qr({address:n});if(e[n])throw new $g({address:n});e[n]=iy(r)}return e}const ay=2n**256n-1n;function Ei(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=t,i=e?wn(e):void 0;if(i&&!kn(i.address))throw new Qr({address:i.address});if(s&&!kn(s))throw new Qr({address:s});if(n&&n>ay)throw new _i({maxFeePerGas:n});if(r&&n&&r>n)throw new wi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function cy(t){const e=ai(`0x${t.substring(4)}`).substring(26);return ci(`0x${e}`)}async function uy({hash:t,signature:e}){const n=Cn(t)?t:zo(t),{secp256k1:r}=await Promise.resolve().then(()=>y1);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:m,s:g,v:x,yParity:O}=e,N=Number(O??x),F=Yd(N);return new r.Signature(yr(m),yr(g)).addRecoveryBit(F)}const o=Cn(e)?e:zo(e);if(bt(o)!==65)throw new Error("invalid signature length");const a=Jn(`0x${o.slice(130)}`),d=Yd(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(d)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Yd(t){if(t===0||t===1)return t;if(t===27)return 0;if(t===28)return 1;throw new Error("Invalid yParityOrV value")}async function dy({hash:t,signature:e}){return cy(await uy({hash:t,signature:e}))}function ly(t,e="hex"){const n=Jd(t),r=Yo(new Uint8Array(n.length));return n.encode(r),e==="hex"?zt(r.bytes):r.bytes}function Jd(t){return Array.isArray(t)?fy(t.map(e=>Jd(e))):hy(t)}function fy(t){const e=t.reduce((s,i)=>s+i.length,0),n=Xd(e);return{length:e<=55?1+e:1+n+e,encode(s){e<=55?s.pushByte(192+e):(s.pushByte(247+n),n===1?s.pushUint8(e):n===2?s.pushUint16(e):n===3?s.pushUint24(e):s.pushUint32(e));for(const{encode:i}of t)i(s)}}}function hy(t){const e=typeof t=="string"?en(t):t,n=Xd(e.length);return{length:e.length===1&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length,encode(s){e.length===1&&e[0]<128?s.pushBytes(e):e.length<=55?(s.pushByte(128+e.length),s.pushBytes(e)):(s.pushByte(183+n),n===1?s.pushUint8(e.length):n===2?s.pushUint16(e.length):n===3?s.pushUint24(e.length):s.pushUint32(e.length),s.pushBytes(e))}}}function Xd(t){if(t<2**8)return 1;if(t<2**16)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new ue("Length is too large.")}function py(t){const{chainId:e,nonce:n,to:r}=t,s=t.contractAddress??t.address,i=ai(Jo(["0x05",ly([e?ke(e):"0x",s,n?ke(n):"0x"])]));return r==="bytes"?en(i):i}async function Qd(t){const{authorization:e,signature:n}=t;return dy({hash:py(e),signature:n??e})}class my extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:x,value:O}){const N=fi({from:n?.address,to:x,value:typeof O<"u"&&`${$d(O)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${tn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${tn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${tn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",N].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function gy(t,{docsPath:e,...n}){const r=(()=>{const s=Wd(t,n);return s instanceof wa?t:s})();return new my(r,{docsPath:e,...n})}class el extends ue{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Ra extends ue{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class yy extends ue{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${tn(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class by extends ue{constructor({blockHash:e,blockNumber:n}){let r="Block";e&&(r=`Block at hash "${e}"`),n&&(r=`Block at number "${n}"`),super(`${r} could not be found.`,{name:"BlockNotFoundError"})}}const _y={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function tl(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?Jn(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?Jn(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?_y[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(n.authorizationList=wy(t.authorizationList)),n.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}function wy(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function Ey(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:tl(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:n,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}async function Ts(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:s}={}){const i=s??!1,o=n!==void 0?ke(n):void 0;let a=null;if(e?a=await t.request({method:"eth_getBlockByHash",params:[e,i]},{dedupe:!0}):a=await t.request({method:"eth_getBlockByNumber",params:[o||r,i]},{dedupe:!!o}),!a)throw new by({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||Ey)(a,"getBlock")}async function nl(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function vy(t,e){const{block:n,chain:r=t.chain,request:s}=e||{};try{const i=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if(typeof i=="function"){const a=n||await xt(t,Ts,"getBlock")({}),d=await i({block:a,client:t,request:s});if(d===null)throw new Error;return d}if(typeof i<"u")return i;const o=await t.request({method:"eth_maxPriorityFeePerGas"});return yr(o)}catch{const[i,o]=await Promise.all([n?Promise.resolve(n):xt(t,Ts,"getBlock")({}),xt(t,nl,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new Ra;const a=o-i.baseFeePerGas;return a<0n?0n:a}}async function rl(t,e){const{block:n,chain:r=t.chain,request:s,type:i="eip1559"}=e||{},o=await(async()=>typeof r?.fees?.baseFeeMultiplier=="function"?r.fees.baseFeeMultiplier({block:n,client:t,request:s}):r?.fees?.baseFeeMultiplier??1.2)();if(o<1)throw new el;const d=10**(o.toString().split(".")[1]?.length??0),m=O=>O*BigInt(Math.ceil(o*d))/BigInt(d),g=n||await xt(t,Ts,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const O=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:m,request:s,type:i});if(O!==null)return O}if(i==="eip1559"){if(typeof g.baseFeePerGas!="bigint")throw new Ra;const O=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await vy(t,{block:g,chain:r,request:s}),N=m(g.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??N+O,maxPriorityFeePerGas:O}}return{gasPrice:s?.gasPrice??m(await xt(t,nl,"getGasPrice")({}))}}async function Ry(t,{address:e,blockTag:n="latest",blockNumber:r}){const s=await t.request({method:"eth_getTransactionCount",params:[e,typeof r=="bigint"?ke(r):n]},{dedupe:!!r});return Jn(s)}function sl(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(i=>en(i)):t.blobs,s=[];for(const i of r)s.push(Uint8Array.from(e.blobToKzgCommitment(i)));return n==="bytes"?s:s.map(i=>zt(i))}function il(t){const{kzg:e}=t,n=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),r=typeof t.blobs[0]=="string"?t.blobs.map(o=>en(o)):t.blobs,s=typeof t.commitments[0]=="string"?t.commitments.map(o=>en(o)):t.commitments,i=[];for(let o=0;o<r.length;o++){const a=r[o],d=s[o];i.push(Uint8Array.from(e.computeBlobKzgProof(a,d)))}return n==="bytes"?i:i.map(o=>zt(o))}function Ay(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(n>>s&i),a=Number(n&i),d=r?4:0,m=r?0:4;t.setUint32(e+d,o,r),t.setUint32(e+m,a,r)}function xy(t,e,n){return t&e^~t&n}function Sy(t,e,n){return t&e^t&n^e&n}class ol extends Ho{constructor(e,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(e),this.view=Go(this.buffer)}update(e){Er(this),e=oi(e),Xn(e);const{view:n,buffer:r,blockLen:s}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const d=Go(e);for(;s<=i-o;o+=s)this.process(d,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Er(this),_d(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;n[o++]=128,Bn(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(r,0),o=0);for(let x=o;x<s;x++)n[x]=0;Ay(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Go(e),d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const m=d/4,g=this.get();if(m>g.length)throw new Error("_sha2: outputLen bigger than state");for(let x=0;x<m;x++)a.setUint32(4*x,g[x],i)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=s,e.pos=a,s%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Pn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),St=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Ty=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Un=new Uint32Array(64);class Oy extends ol{constructor(e=32){super(64,e,8,!1),this.A=Pn[0]|0,this.B=Pn[1]|0,this.C=Pn[2]|0,this.D=Pn[3]|0,this.E=Pn[4]|0,this.F=Pn[5]|0,this.G=Pn[6]|0,this.H=Pn[7]|0}get(){const{A:e,B:n,C:r,D:s,E:i,F:o,G:a,H:d}=this;return[e,n,r,s,i,o,a,d]}set(e,n,r,s,i,o,a,d){this.A=e|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=d|0}process(e,n){for(let x=0;x<16;x++,n+=4)Un[x]=e.getUint32(n,!1);for(let x=16;x<64;x++){const O=Un[x-15],N=Un[x-2],F=un(O,7)^un(O,18)^O>>>3,C=un(N,17)^un(N,19)^N>>>10;Un[x]=C+Un[x-7]+F+Un[x-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:d,G:m,H:g}=this;for(let x=0;x<64;x++){const O=un(a,6)^un(a,11)^un(a,25),N=g+O+xy(a,d,m)+Ty[x]+Un[x]|0,C=(un(r,2)^un(r,13)^un(r,22))+Sy(r,s,i)|0;g=m,m=d,d=a,a=o+N|0,o=i,i=s,s=r,r=N+C|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,d=d+this.F|0,m=m+this.G|0,g=g+this.H|0,this.set(r,s,i,o,a,d,m,g)}roundClean(){Bn(Un)}destroy(){this.set(0,0,0,0,0,0,0,0),Bn(this.buffer)}}const al=gd(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Iy=al[0],Ny=al[1],Dn=new Uint32Array(80),Fn=new Uint32Array(80);class Cy extends ol{constructor(e=64){super(128,e,16,!1),this.Ah=St[0]|0,this.Al=St[1]|0,this.Bh=St[2]|0,this.Bl=St[3]|0,this.Ch=St[4]|0,this.Cl=St[5]|0,this.Dh=St[6]|0,this.Dl=St[7]|0,this.Eh=St[8]|0,this.El=St[9]|0,this.Fh=St[10]|0,this.Fl=St[11]|0,this.Gh=St[12]|0,this.Gl=St[13]|0,this.Hh=St[14]|0,this.Hl=St[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:d,Eh:m,El:g,Fh:x,Fl:O,Gh:N,Gl:F,Hh:C,Hl:k}=this;return[e,n,r,s,i,o,a,d,m,g,x,O,N,F,C,k]}set(e,n,r,s,i,o,a,d,m,g,x,O,N,F,C,k){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=d|0,this.Eh=m|0,this.El=g|0,this.Fh=x|0,this.Fl=O|0,this.Gh=N|0,this.Gl=F|0,this.Hh=C|0,this.Hl=k|0}process(e,n){for(let V=0;V<16;V++,n+=4)Dn[V]=e.getUint32(n),Fn[V]=e.getUint32(n+=4);for(let V=16;V<80;V++){const L=Dn[V-15]|0,z=Fn[V-15]|0,J=br(L,z,1)^br(L,z,8)^yd(L,z,7),te=_r(L,z,1)^_r(L,z,8)^bd(L,z,7),ne=Dn[V-2]|0,q=Fn[V-2]|0,B=br(ne,q,19)^si(ne,q,61)^yd(ne,q,6),P=_r(ne,q,19)^ii(ne,q,61)^bd(ne,q,6),j=Om(te,P,Fn[V-7],Fn[V-16]),E=Im(j,J,B,Dn[V-7],Dn[V-16]);Dn[V]=E|0,Fn[V]=j|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:d,Dh:m,Dl:g,Eh:x,El:O,Fh:N,Fl:F,Gh:C,Gl:k,Hh:K,Hl:Y}=this;for(let V=0;V<80;V++){const L=br(x,O,14)^br(x,O,18)^si(x,O,41),z=_r(x,O,14)^_r(x,O,18)^ii(x,O,41),J=x&N^~x&C,te=O&F^~O&k,ne=Nm(Y,z,te,Ny[V],Fn[V]),q=Cm(ne,K,L,J,Iy[V],Dn[V]),B=ne|0,P=br(r,s,28)^si(r,s,34)^si(r,s,39),j=_r(r,s,28)^ii(r,s,34)^ii(r,s,39),E=r&i^r&a^i&a,c=s&o^s&d^o&d;K=C|0,Y=k|0,C=N|0,k=F|0,N=x|0,F=O|0,{h:x,l:O}=bn(m|0,g|0,q|0,B|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const p=Sm(B,j,c);r=Tm(p,q,P,E),s=p|0}({h:r,l:s}=bn(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=bn(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:d}=bn(this.Ch|0,this.Cl|0,a|0,d|0),{h:m,l:g}=bn(this.Dh|0,this.Dl|0,m|0,g|0),{h:x,l:O}=bn(this.Eh|0,this.El|0,x|0,O|0),{h:N,l:F}=bn(this.Fh|0,this.Fl|0,N|0,F|0),{h:C,l:k}=bn(this.Gh|0,this.Gl|0,C|0,k|0),{h:K,l:Y}=bn(this.Hh|0,this.Hl|0,K|0,Y|0),this.set(r,s,i,o,a,d,m,g,x,O,N,F,C,k,K,Y)}roundClean(){Bn(Dn,Fn)}destroy(){Bn(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const cl=qo(()=>new Oy),My=qo(()=>new Cy),Aa=cl;function By(t,e){return Aa(Cn(t,{strict:!1})?Vo(t):t)}function ky(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),s=By(e);return s.set([n],0),r==="bytes"?s:zt(s)}function Ly(t){const{commitments:e,version:n}=t,r=t.to,s=[];for(const i of e)s.push(ky({commitment:i,to:r,version:n}));return s}const ul=6,dl=32,xa=4096,ll=dl*xa,fl=ll*ul-1-1*xa*ul;class Py extends ue{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class Uy extends ue{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Dy(t){const e=typeof t.data=="string"?en(t.data):t.data,n=bt(e);if(!n)throw new Uy;if(n>fl)throw new Py({maxSize:fl,size:n});const r=[];let s=!0,i=0;for(;s;){const o=Yo(new Uint8Array(ll));let a=0;for(;a<xa;){const d=e.slice(i,i+(dl-1));if(o.pushByte(0),o.pushBytes(d),d.length<31){o.pushByte(128),s=!1;break}a++,i+=31}r.push(o)}return r.map(o=>zt(o.bytes))}function Fy(t){const{data:e,kzg:n,to:r}=t,s=t.blobs??Dy({data:e}),i=t.commitments??sl({blobs:s,kzg:n,to:r}),o=t.proofs??il({blobs:s,commitments:i,kzg:n,to:r}),a=[];for(let d=0;d<s.length;d++)a.push({blob:s[d],commitment:i[d],proof:o[d]});return a}function $y(t){if(t.type)return t.type;if(typeof t.authorizationList<"u")return"eip7702";if(typeof t.blobs<"u"||typeof t.blobVersionedHashes<"u"||typeof t.maxFeePerBlobGas<"u"||typeof t.sidecars<"u")return"eip4844";if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")return"eip1559";if(typeof t.gasPrice<"u")return typeof t.accessList<"u"?"eip2930":"legacy";throw new jg({transaction:t})}function hl(t,{docsPath:e,...n}){const r=(()=>{const s=Wd(t,n);return s instanceof wa?t:s})();return new Vg(r,{docsPath:e,...n})}async function Sa(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return Jn(e)}async function zy(t,e){const{account:n=t.account,accessList:r,authorizationList:s,chain:i=t.chain,blobVersionedHashes:o,blobs:a,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:x,maxFeePerGas:O,maxPriorityFeePerGas:N,nonce:F,nonceManager:C,to:k,type:K,value:Y,...V}=e,L=await(async()=>{if(!n||!C||typeof F<"u")return F;const ne=wn(n),q=i?i.id:await xt(t,Sa,"getChainId")({});return await C.consume({address:ne.address,chainId:q,client:t})})();Ei(e);const z=i?.formatters?.transactionRequest?.format,te=(z||va)({...Ea(V,{format:z}),account:n?wn(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:o,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:x,maxFeePerGas:O,maxPriorityFeePerGas:N,nonce:L,to:k,type:K,value:Y},"fillTransaction");try{const ne=await t.request({method:"eth_fillTransaction",params:[te]}),B=(i?.formatters?.transaction?.format||tl)(ne.tx);delete B.blockHash,delete B.blockNumber,delete B.r,delete B.s,delete B.transactionIndex,delete B.v,delete B.yParity,B.data=B.input,B.gas&&(B.gas=e.gas??B.gas),B.gasPrice&&(B.gasPrice=e.gasPrice??B.gasPrice),B.maxFeePerBlobGas&&(B.maxFeePerBlobGas=e.maxFeePerBlobGas??B.maxFeePerBlobGas),B.maxFeePerGas&&(B.maxFeePerGas=e.maxFeePerGas??B.maxFeePerGas),B.maxPriorityFeePerGas&&(B.maxPriorityFeePerGas=e.maxPriorityFeePerGas??B.maxPriorityFeePerGas),B.nonce&&(B.nonce=e.nonce??B.nonce);const P=await(async()=>{if(typeof i?.fees?.baseFeeMultiplier=="function"){const p=await xt(t,Ts,"getBlock")({});return i.fees.baseFeeMultiplier({block:p,client:t,request:e})}return i?.fees?.baseFeeMultiplier??1.2})();if(P<1)throw new el;const E=10**(P.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(P*E))/BigInt(E);return B.maxFeePerGas&&!e.maxFeePerGas&&(B.maxFeePerGas=c(B.maxFeePerGas)),B.gasPrice&&!e.gasPrice&&(B.gasPrice=c(B.gasPrice)),{raw:ne.raw,transaction:{from:te.from,...B}}}catch(ne){throw hl(ne,{...e,chain:t.chain})}}const pl=["blobVersionedHashes","chainId","fees","gas","nonce","type"],ml=new Map,Ta=new ns(128);async function gl(t,e){let n=e;n.account??=t.account,n.parameters??=pl;const{account:r,chain:s=t.chain,nonceManager:i,parameters:o}=n,a=(()=>{if(typeof s?.prepareTransactionRequest=="function")return{fn:s.prepareTransactionRequest,runAt:["beforeFillTransaction"]};if(Array.isArray(s?.prepareTransactionRequest))return{fn:s.prepareTransactionRequest[0],runAt:s.prepareTransactionRequest[1].runAt}})();let d;async function m(){return d||(typeof n.chainId<"u"?n.chainId:s?s.id:(d=await xt(t,Sa,"getChainId")({}),d))}const g=r&&wn(r);let x=n.nonce;if(o.includes("nonce")&&typeof x>"u"&&g&&i){const L=await m();x=await i.consume({address:g.address,chainId:L,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillTransaction"}),x??=n.nonce);const N=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Ta.get(t.uid)===!1||!["fees","gas"].some(z=>o.includes(z))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof x!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await xt(t,zy,"fillTransaction")({...n,nonce:x}).then(L=>{const{chainId:z,from:J,gas:te,gasPrice:ne,nonce:q,maxFeePerBlobGas:B,maxFeePerGas:P,maxPriorityFeePerGas:j,type:E,...c}=L.transaction;return Ta.set(t.uid,!0),{...n,...J?{from:J}:{},...E?{type:E}:{},...typeof z<"u"?{chainId:z}:{},...typeof te<"u"?{gas:te}:{},...typeof ne<"u"?{gasPrice:ne}:{},...typeof q<"u"?{nonce:q}:{},...typeof B<"u"?{maxFeePerBlobGas:B}:{},...typeof P<"u"?{maxFeePerGas:P}:{},...typeof j<"u"?{maxPriorityFeePerGas:j}:{},..."nonceKey"in c&&typeof c.nonceKey<"u"?{nonceKey:c.nonceKey}:{}}}).catch(L=>{const z=L;return z.name!=="TransactionExecutionError"||z.walk?.(te=>{const ne=te;return ne.name==="MethodNotFoundRpcError"||ne.name==="MethodNotSupportedRpcError"})&&Ta.set(t.uid,!1),n}):n;x??=N.nonce,n={...N,...g?{from:g?.address}:{},...x?{nonce:x}:{}};const{blobs:F,gas:C,kzg:k,type:K}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillParameters"}));let Y;async function V(){return Y||(Y=await xt(t,Ts,"getBlock")({blockTag:"latest"}),Y)}if(o.includes("nonce")&&typeof x>"u"&&g&&!i&&(n.nonce=await xt(t,Ry,"getTransactionCount")({address:g.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&F&&k){const L=sl({blobs:F,kzg:k});if(o.includes("blobVersionedHashes")){const z=Ly({commitments:L,to:"hex"});n.blobVersionedHashes=z}if(o.includes("sidecars")){const z=il({blobs:F,commitments:L,kzg:k}),J=Fy({blobs:F,commitments:L,proofs:z,to:"hex"});n.sidecars=J}}if(o.includes("chainId")&&(n.chainId=await m()),(o.includes("fees")||o.includes("type"))&&typeof K>"u")try{n.type=$y(n)}catch{let L=ml.get(t.uid);typeof L>"u"&&(L=typeof(await V())?.baseFeePerGas=="bigint",ml.set(t.uid,L)),n.type=L?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const L=await V(),{maxFeePerGas:z,maxPriorityFeePerGas:J}=await rl(t,{block:L,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<J)throw new yy({maxPriorityFeePerGas:J});n.maxPriorityFeePerGas=J,n.maxFeePerGas=z}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new Ra;if(typeof n.gasPrice>"u"){const L=await V(),{gasPrice:z}=await rl(t,{block:L,chain:s,request:n,type:"legacy"});n.gasPrice=z}}return o.includes("gas")&&typeof C>"u"&&(n.gas=await xt(t,jy,"estimateGas")({...n,account:g,prepare:g?.type==="local"?[]:["blobVersionedHashes"]})),a?.fn&&a.runAt?.includes("afterFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"afterFillParameters"})),Ei(n),delete n.parameters,n}async function jy(t,e){const{account:n=t.account,prepare:r=!0}=e,s=n?wn(n):void 0,i=(()=>{if(Array.isArray(r))return r;if(s?.type!=="local")return["blobVersionedHashes"]})();try{const o=await(async()=>{if(e.to)return e.to;if(e.authorizationList&&e.authorizationList.length>0)return await Qd({authorization:e.authorizationList[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,blockNumber:x,blockTag:O,data:N,gas:F,gasPrice:C,maxFeePerBlobGas:k,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:V,value:L,stateOverride:z,...J}=r?await gl(t,{...e,parameters:i,to:o}):e;if(F&&e.gas!==F)return F;const ne=(typeof x=="bigint"?ke(x):void 0)||O,q=oy(z);Ei(e);const B=t.chain?.formatters?.transactionRequest?.format,j=(B||va)({...Ea(J,{format:B}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:N,gasPrice:C,maxFeePerBlobGas:k,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:V,to:o,value:L},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:q?[j,ne??t.experimental_blockTag??"latest",q]:ne?[j,ne]:[j]}))}catch(o){throw gy(o,{...e,account:s,chain:t.chain})}}const vi=new ns(8192);function Vy(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(vi.get(n))return vi.get(n);const r=t().finally(()=>vi.delete(n));return vi.set(n,r),r}async function Gy(t){return new Promise(e=>setTimeout(e,t))}function Hy(t,{delay:e=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((s,i)=>{const o=async({count:a=0}={})=>{const d=async({error:m})=>{const g=typeof e=="function"?e({count:a,error:m}):e;g&&await Gy(g),o({count:a+1})};try{const m=await t();s(m)}catch(m){if(a<n&&await r({count:a,error:m}))return d({error:m});i(m)}};o()})}function qy(t,e={}){return async(n,r={})=>{const{dedupe:s=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:d}={...e,...r},{method:m}=n;if(i?.exclude?.includes(m))throw new er(new Error("method not supported"),{method:m});if(i?.include&&!i.include.includes(m))throw new er(new Error("method not supported"),{method:m});const g=s?jo(`${d}.${li(n)}`):void 0;return Vy(()=>Hy(async()=>{try{return await t(n)}catch(x){const O=x;switch(O.code){case is.code:throw new is(O);case os.code:throw new os(O);case as.code:throw new as(O,{method:n.method});case cs.code:throw new cs(O);case Qn.code:throw new Qn(O);case Ar.code:throw new Ar(O);case us.code:throw new us(O);case ds.code:throw new ds(O);case ls.code:throw new ls(O);case er.code:throw new er(O,{method:n.method});case xr.code:throw new xr(O);case fs.code:throw new fs(O);case hi.code:throw new hi(O);case hs.code:throw new hs(O);case ps.code:throw new ps(O);case ms.code:throw new ms(O);case ia.code:throw new ia(O);case Sr.code:throw new Sr(O);case gs.code:throw new gs(O);case ys.code:throw new ys(O);case bs.code:throw new bs(O);case _s.code:throw new _s(O);case ws.code:throw new ws(O);case Es.code:throw new Es(O);case vs.code:throw new vs(O);case 5e3:throw new hi(O);default:throw x instanceof ue?x:new Yg(O)}}},{delay:({count:x,error:O})=>{if(O&&O instanceof jd){const N=O?.headers?.get("Retry-After");if(N?.match(/\d/))return Number.parseInt(N,10)*1e3}return~~(1<<x)*o},retryCount:a,shouldRetry:({error:x})=>Ky(x)}),{enabled:s,id:g})}}function Ky(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===xr.code||t.code===Qn.code:t instanceof jd&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function Wy({chain:t,currentChainId:e}){if(!t)throw new Bg;if(e!==t.id)throw new Mg({chain:t,currentChainId:e})}class yl extends Ho{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Bm(e);const r=oi(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Bn(i)}update(e){return Er(this),this.iHash.update(e),this}digestInto(e){Er(this),Xn(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bl=(t,e,n)=>new yl(t,e).update(n).digest();bl.create=(t,e)=>new yl(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vt=BigInt(0),wt=BigInt(1),nr=BigInt(2),Zy=BigInt(3),_l=BigInt(4),wl=BigInt(5),El=BigInt(8);function je(t,e){const n=t%e;return n>=Vt?n:e+n}function qe(t,e,n){let r=t;for(;e-- >Vt;)r*=r,r%=n;return r}function Oa(t,e){if(t===Vt)throw new Error("invert: expected non-zero number");if(e<=Vt)throw new Error("invert: expected positive modulus, got "+e);let n=je(t,e),r=e,s=Vt,i=wt;for(;n!==Vt;){const a=r/n,d=r%n,m=s-i*a;r=n,n=d,s=i,i=m}if(r!==wt)throw new Error("invert: does not exist");return je(s,e)}function vl(t,e){const n=(t.ORDER+wt)/_l,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function Yy(t,e){const n=(t.ORDER-wl)/El,r=t.mul(e,nr),s=t.pow(r,n),i=t.mul(e,s),o=t.mul(t.mul(i,nr),s),a=t.mul(i,t.sub(o,t.ONE));if(!t.eql(t.sqr(a),e))throw new Error("Cannot find square root");return a}function Jy(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-wt,n=0;for(;e%nr===Vt;)e/=nr,n++;let r=nr;const s=Os(t);for(;Rl(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return vl;let i=s.pow(r,e);const o=(e+wt)/nr;return function(d,m){if(d.is0(m))return m;if(Rl(d,m)!==1)throw new Error("Cannot find square root");let g=n,x=d.mul(d.ONE,i),O=d.pow(m,e),N=d.pow(m,o);for(;!d.eql(O,d.ONE);){if(d.is0(O))return d.ZERO;let F=1,C=d.sqr(O);for(;!d.eql(C,d.ONE);)if(F++,C=d.sqr(C),F===g)throw new Error("Cannot find square root");const k=wt<<BigInt(g-F-1),K=d.pow(x,k);g=F,x=d.sqr(K),O=d.mul(O,x),N=d.mul(N,K)}return N}}function Xy(t){return t%_l===Zy?vl:t%El===wl?Yy:Jy(t)}const Qy=(t,e)=>(je(t,e)&wt)===wt,e1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function t1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=e1.reduce((r,s)=>(r[s]="function",r),e);return Ss(t,n)}function n1(t,e,n){if(n<Vt)throw new Error("invalid exponent, negatives unsupported");if(n===Vt)return t.ONE;if(n===wt)return e;let r=t.ONE,s=e;for(;n>Vt;)n&wt&&(r=t.mul(r,s)),s=t.sqr(s),n>>=wt;return r}function Ia(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),s=e.reduce((o,a,d)=>t.is0(a)?o:(r[d]=o,t.mul(o,a)),t.ONE),i=t.inv(s);return e.reduceRight((o,a,d)=>t.is0(a)?o:(r[d]=t.mul(o,r[d]),t.mul(o,a)),i),r}function Rl(t,e){const n=(t.ORDER-wt)/nr,r=t.pow(e,n),s=t.eql(r,t.ONE),i=t.eql(r,t.ZERO),o=t.eql(r,t.neg(t.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Al(t,e){e!==void 0&&es(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Os(t,e,n=!1,r={}){if(t<=Vt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:i}=Al(t,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:t,isLE:n,BITS:s,BYTES:i,MASK:yi(s),ZERO:Vt,ONE:wt,create:d=>je(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Vt<=d&&d<t},is0:d=>d===Vt,isOdd:d=>(d&wt)===wt,neg:d=>je(-d,t),eql:(d,m)=>d===m,sqr:d=>je(d*d,t),add:(d,m)=>je(d+m,t),sub:(d,m)=>je(d-m,t),mul:(d,m)=>je(d*m,t),pow:(d,m)=>n1(a,d,m),div:(d,m)=>je(d*Oa(m,t),t),sqrN:d=>d*d,addN:(d,m)=>d+m,subN:(d,m)=>d-m,mulN:(d,m)=>d*m,inv:d=>Oa(d,t),sqrt:r.sqrt||(d=>(o||(o=Xy(t)),o(a,d))),toBytes:d=>n?gi(d,i):xs(d,i),fromBytes:d=>{if(d.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+d.length);return n?As(d):tr(d)},invertBatch:d=>Ia(a,d),cmov:(d,m,g)=>g?m:d});return Object.freeze(a)}function xl(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Sl(t){const e=xl(t);return e+Math.ceil(e/2)}function r1(t,e,n=!1){const r=t.length,s=xl(e),i=Sl(e);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=n?As(t):tr(t),a=je(o,e-wt)+wt;return n?gi(a,s):xs(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Tl=BigInt(0),Na=BigInt(1);function Ca(t,e){const n=e.negate();return t?n:e}function Ol(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ma(t,e){Ol(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=yi(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function Il(t,e,n){const{windowSize:r,mask:s,maxNumber:i,shiftBy:o}=n;let a=Number(t&s),d=t>>o;a>r&&(a-=i,d+=Na);const m=e*r,g=m+Math.abs(a)-1,x=a===0,O=a<0,N=e%2!==0;return{nextN:d,offset:g,isZero:x,isNeg:O,isNegF:N,offsetF:m}}function s1(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function i1(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Ba=new WeakMap,Nl=new WeakMap;function ka(t){return Nl.get(t)||1}function Cl(t,e){return{constTimeNegate:Ca,hasPrecomputes(n){return ka(n)!==1},unsafeLadder(n,r,s=t.ZERO){let i=n;for(;r>Tl;)r&Na&&(s=s.add(i)),i=i.double(),r>>=Na;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ma(r,e),o=[];let a=n,d=a;for(let m=0;m<s;m++){d=a,o.push(d);for(let g=1;g<i;g++)d=d.add(a),o.push(d);a=d.double()}return o},wNAF(n,r,s){let i=t.ZERO,o=t.BASE;const a=Ma(n,e);for(let d=0;d<a.windows;d++){const{nextN:m,offset:g,isZero:x,isNeg:O,isNegF:N,offsetF:F}=Il(s,d,a);s=m,x?o=o.add(Ca(N,r[F])):i=i.add(Ca(O,r[g]))}return{p:i,f:o}},wNAFUnsafe(n,r,s,i=t.ZERO){const o=Ma(n,e);for(let a=0;a<o.windows&&s!==Tl;a++){const{nextN:d,offset:m,isZero:g,isNeg:x}=Il(s,a,o);if(s=d,!g){const O=r[m];i=i.add(x?O.negate():O)}}return i},getPrecomputes(n,r,s){let i=Ba.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&Ba.set(r,s(i))),i},wNAFCached(n,r,s){const i=ka(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const o=ka(n);return o===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,n,s),r,i)},setWindowSize(n,r){Ol(r,e),Nl.set(n,r),Ba.delete(n)}}}function Ml(t,e,n,r){s1(n,t),i1(r,e);const s=n.length,i=r.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=ey(BigInt(s));let d=1;a>12?d=a-3:a>4?d=a-2:a>0&&(d=2);const m=yi(d),g=new Array(Number(m)+1).fill(o),x=Math.floor((e.BITS-1)/d)*d;let O=o;for(let N=x;N>=0;N-=d){g.fill(o);for(let C=0;C<i;C++){const k=r[C],K=Number(k>>BigInt(N)&m);g[K]=g[K].add(n[C])}let F=o;for(let C=g.length-1,k=o;C>0;C--)k=k.add(g[C]),F=F.add(k);if(O=O.add(F),N!==0)for(let C=0;C<d;C++)O=O.double()}return O}function La(t){return t1(t.Fp),Ss(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Al(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Bl(t){t.lowS!==void 0&&Ln("lowS",t.lowS),t.prehash!==void 0&&Ln("prehash",t.prehash)}function o1(t){const e=La(t);Ss(e,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:n,Fp:r,a:s}=e;if(n){if(!r.eql(s,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof n!="object"||typeof n.beta!="bigint"||typeof n.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...e})}class a1 extends Error{constructor(e=""){super(e)}}const vn={Err:a1,_tlv:{encode:(t,e)=>{const{Err:n}=vn;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length&1)throw new n("tlv.encode: unpadded data");const r=e.length/2,s=pi(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?pi(s.length/2|128):"";return pi(t)+i+s+e},decode(t,e){const{Err:n}=vn;let r=0;if(t<0||t>256)throw new n("tlv.encode: wrong tag");if(e.length<2||e[r++]!==t)throw new n("tlv.decode: wrong tlv");const s=e[r++],i=!!(s&128);let o=0;if(!i)o=s;else{const d=s&127;if(!d)throw new n("tlv.decode(long): indefinite length not supported");if(d>4)throw new n("tlv.decode(long): byte length is too big");const m=e.subarray(r,r+d);if(m.length!==d)throw new n("tlv.decode: length bytes not complete");if(m[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const g of m)o=o<<8|g;if(r+=d,o<128)throw new n("tlv.decode(long): not minimal encoding")}const a=e.subarray(r,r+o);if(a.length!==o)throw new n("tlv.decode: wrong value length");return{v:a,l:e.subarray(r+o)}}},_int:{encode(t){const{Err:e}=vn;if(t<Rn)throw new e("integer: negative integers are not allowed");let n=pi(t);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return n},decode(t){const{Err:e}=vn;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return tr(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=vn,s=Je("signature",t),{v:i,l:o}=r.decode(48,s);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:d}=r.decode(2,i),{v:m,l:g}=r.decode(2,d);if(g.length)throw new e("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(m)}},hexFromSig(t){const{_tlv:e,_int:n}=vn,r=e.encode(2,n.encode(t.r)),s=e.encode(2,n.encode(t.s)),i=r+s;return e.encode(48,i)}};function Pa(t,e){return Tr(xs(t,e))}const Rn=BigInt(0),_t=BigInt(1);BigInt(2);const Ua=BigInt(3),c1=BigInt(4);function u1(t){const e=o1(t),{Fp:n}=e,r=Os(e.n,e.nBitLength),s=e.toBytes||((V,L,z)=>{const J=L.toAffine();return Or(Uint8Array.from([4]),n.toBytes(J.x),n.toBytes(J.y))}),i=e.fromBytes||(V=>{const L=V.subarray(1),z=n.fromBytes(L.subarray(0,n.BYTES)),J=n.fromBytes(L.subarray(n.BYTES,2*n.BYTES));return{x:z,y:J}});function o(V){const{a:L,b:z}=e,J=n.sqr(V),te=n.mul(J,V);return n.add(n.add(te,n.mul(V,L)),z)}function a(V,L){const z=n.sqr(L),J=o(V);return n.eql(z,J)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const d=n.mul(n.pow(e.a,Ua),c1),m=n.mul(n.sqr(e.b),BigInt(27));if(n.is0(n.add(d,m)))throw new Error("bad curve params: a or b");function g(V){return da(V,_t,e.n)}function x(V){const{allowedPrivateKeyLengths:L,nByteLength:z,wrapPrivateKey:J,n:te}=e;if(L&&typeof V!="bigint"){if(Rs(V)&&(V=Tr(V)),typeof V!="string"||!L.includes(V.length))throw new Error("invalid private key");V=V.padStart(z*2,"0")}let ne;try{ne=typeof V=="bigint"?V:tr(Je("private key",V,z))}catch{throw new Error("invalid private key, expected hex or "+z+" bytes, got "+typeof V)}return J&&(ne=je(ne,te)),nn("private key",ne,_t,te),ne}function O(V){if(!(V instanceof C))throw new Error("ProjectivePoint expected")}const N=bi((V,L)=>{const{px:z,py:J,pz:te}=V;if(n.eql(te,n.ONE))return{x:z,y:J};const ne=V.is0();L==null&&(L=ne?n.ONE:n.inv(te));const q=n.mul(z,L),B=n.mul(J,L),P=n.mul(te,L);if(ne)return{x:n.ZERO,y:n.ZERO};if(!n.eql(P,n.ONE))throw new Error("invZ was invalid");return{x:q,y:B}}),F=bi(V=>{if(V.is0()){if(e.allowInfinityPoint&&!n.is0(V.py))return;throw new Error("bad point: ZERO")}const{x:L,y:z}=V.toAffine();if(!n.isValid(L)||!n.isValid(z))throw new Error("bad point: x or y not FE");if(!a(L,z))throw new Error("bad point: equation left != right");if(!V.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class C{constructor(L,z,J){if(L==null||!n.isValid(L))throw new Error("x required");if(z==null||!n.isValid(z)||n.is0(z))throw new Error("y required");if(J==null||!n.isValid(J))throw new Error("z required");this.px=L,this.py=z,this.pz=J,Object.freeze(this)}static fromAffine(L){const{x:z,y:J}=L||{};if(!L||!n.isValid(z)||!n.isValid(J))throw new Error("invalid affine point");if(L instanceof C)throw new Error("projective point not allowed");const te=ne=>n.eql(ne,n.ZERO);return te(z)&&te(J)?C.ZERO:new C(z,J,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(L){const z=Ia(n,L.map(J=>J.pz));return L.map((J,te)=>J.toAffine(z[te])).map(C.fromAffine)}static fromHex(L){const z=C.fromAffine(i(Je("pointHex",L)));return z.assertValidity(),z}static fromPrivateKey(L){return C.BASE.multiply(x(L))}static msm(L,z){return Ml(C,r,L,z)}_setWindowSize(L){Y.setWindowSize(this,L)}assertValidity(){F(this)}hasEvenY(){const{y:L}=this.toAffine();if(n.isOdd)return!n.isOdd(L);throw new Error("Field doesn't support isOdd")}equals(L){O(L);const{px:z,py:J,pz:te}=this,{px:ne,py:q,pz:B}=L,P=n.eql(n.mul(z,B),n.mul(ne,te)),j=n.eql(n.mul(J,B),n.mul(q,te));return P&&j}negate(){return new C(this.px,n.neg(this.py),this.pz)}double(){const{a:L,b:z}=e,J=n.mul(z,Ua),{px:te,py:ne,pz:q}=this;let B=n.ZERO,P=n.ZERO,j=n.ZERO,E=n.mul(te,te),c=n.mul(ne,ne),p=n.mul(q,q),y=n.mul(te,ne);return y=n.add(y,y),j=n.mul(te,q),j=n.add(j,j),B=n.mul(L,j),P=n.mul(J,p),P=n.add(B,P),B=n.sub(c,P),P=n.add(c,P),P=n.mul(B,P),B=n.mul(y,B),j=n.mul(J,j),p=n.mul(L,p),y=n.sub(E,p),y=n.mul(L,y),y=n.add(y,j),j=n.add(E,E),E=n.add(j,E),E=n.add(E,p),E=n.mul(E,y),P=n.add(P,E),p=n.mul(ne,q),p=n.add(p,p),E=n.mul(p,y),B=n.sub(B,E),j=n.mul(p,c),j=n.add(j,j),j=n.add(j,j),new C(B,P,j)}add(L){O(L);const{px:z,py:J,pz:te}=this,{px:ne,py:q,pz:B}=L;let P=n.ZERO,j=n.ZERO,E=n.ZERO;const c=e.a,p=n.mul(e.b,Ua);let y=n.mul(z,ne),A=n.mul(J,q),v=n.mul(te,B),R=n.add(z,J),I=n.add(ne,q);R=n.mul(R,I),I=n.add(y,A),R=n.sub(R,I),I=n.add(z,te);let _=n.add(ne,B);return I=n.mul(I,_),_=n.add(y,v),I=n.sub(I,_),_=n.add(J,te),P=n.add(q,B),_=n.mul(_,P),P=n.add(A,v),_=n.sub(_,P),E=n.mul(c,I),P=n.mul(p,v),E=n.add(P,E),P=n.sub(A,E),E=n.add(A,E),j=n.mul(P,E),A=n.add(y,y),A=n.add(A,y),v=n.mul(c,v),I=n.mul(p,I),A=n.add(A,v),v=n.sub(y,v),v=n.mul(c,v),I=n.add(I,v),y=n.mul(A,I),j=n.add(j,y),y=n.mul(_,I),P=n.mul(R,P),P=n.sub(P,y),y=n.mul(R,A),E=n.mul(_,E),E=n.add(E,y),new C(P,j,E)}subtract(L){return this.add(L.negate())}is0(){return this.equals(C.ZERO)}wNAF(L){return Y.wNAFCached(this,L,C.normalizeZ)}multiplyUnsafe(L){const{endo:z,n:J}=e;nn("scalar",L,Rn,J);const te=C.ZERO;if(L===Rn)return te;if(this.is0()||L===_t)return this;if(!z||Y.hasPrecomputes(this))return Y.wNAFCachedUnsafe(this,L,C.normalizeZ);let{k1neg:ne,k1:q,k2neg:B,k2:P}=z.splitScalar(L),j=te,E=te,c=this;for(;q>Rn||P>Rn;)q&_t&&(j=j.add(c)),P&_t&&(E=E.add(c)),c=c.double(),q>>=_t,P>>=_t;return ne&&(j=j.negate()),B&&(E=E.negate()),E=new C(n.mul(E.px,z.beta),E.py,E.pz),j.add(E)}multiply(L){const{endo:z,n:J}=e;nn("scalar",L,_t,J);let te,ne;if(z){const{k1neg:q,k1:B,k2neg:P,k2:j}=z.splitScalar(L);let{p:E,f:c}=this.wNAF(B),{p,f:y}=this.wNAF(j);E=Y.constTimeNegate(q,E),p=Y.constTimeNegate(P,p),p=new C(n.mul(p.px,z.beta),p.py,p.pz),te=E.add(p),ne=c.add(y)}else{const{p:q,f:B}=this.wNAF(L);te=q,ne=B}return C.normalizeZ([te,ne])[0]}multiplyAndAddUnsafe(L,z,J){const te=C.BASE,ne=(B,P)=>P===Rn||P===_t||!B.equals(te)?B.multiplyUnsafe(P):B.multiply(P),q=ne(this,z).add(ne(L,J));return q.is0()?void 0:q}toAffine(L){return N(this,L)}isTorsionFree(){const{h:L,isTorsionFree:z}=e;if(L===_t)return!0;if(z)return z(C,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:L,clearCofactor:z}=e;return L===_t?this:z?z(C,this):this.multiplyUnsafe(e.h)}toRawBytes(L=!0){return Ln("isCompressed",L),this.assertValidity(),s(C,this,L)}toHex(L=!0){return Ln("isCompressed",L),Tr(this.toRawBytes(L))}}C.BASE=new C(e.Gx,e.Gy,n.ONE),C.ZERO=new C(n.ZERO,n.ONE,n.ZERO);const{endo:k,nBitLength:K}=e,Y=Cl(C,k?Math.ceil(K/2):K);return{CURVE:e,ProjectivePoint:C,normPrivateKeyToScalar:x,weierstrassEquation:o,isWithinCurveOrder:g}}function d1(t){const e=La(t);return Ss(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function l1(t){const e=d1(t),{Fp:n,n:r,nByteLength:s,nBitLength:i}=e,o=n.BYTES+1,a=2*n.BYTES+1;function d(p){return je(p,r)}function m(p){return Oa(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:x,weierstrassEquation:O,isWithinCurveOrder:N}=u1({...e,toBytes(p,y,A){const v=y.toAffine(),R=n.toBytes(v.x),I=Or;return Ln("isCompressed",A),A?I(Uint8Array.from([y.hasEvenY()?2:3]),R):I(Uint8Array.from([4]),R,n.toBytes(v.y))},fromBytes(p){const y=p.length,A=p[0],v=p.subarray(1);if(y===o&&(A===2||A===3)){const R=tr(v);if(!da(R,_t,n.ORDER))throw new Error("Point is not on curve");const I=O(R);let _;try{_=n.sqrt(I)}catch(w){const T=w instanceof Error?": "+w.message:"";throw new Error("Point is not on curve"+T)}const u=(_&_t)===_t;return(A&1)===1!==u&&(_=n.neg(_)),{x:R,y:_}}else if(y===a&&A===4){const R=n.fromBytes(v.subarray(0,n.BYTES)),I=n.fromBytes(v.subarray(n.BYTES,2*n.BYTES));return{x:R,y:I}}else{const R=o,I=a;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+I+", got "+y)}}});function F(p){const y=r>>_t;return p>y}function C(p){return F(p)?d(-p):p}const k=(p,y,A)=>tr(p.slice(y,A));class K{constructor(y,A,v){nn("r",y,_t,r),nn("s",A,_t,r),this.r=y,this.s=A,v!=null&&(this.recovery=v),Object.freeze(this)}static fromCompact(y){const A=s;return y=Je("compactSignature",y,A*2),new K(k(y,0,A),k(y,A,2*A))}static fromDER(y){const{r:A,s:v}=vn.toSig(Je("DER",y));return new K(A,v)}assertValidity(){}addRecoveryBit(y){return new K(this.r,this.s,y)}recoverPublicKey(y){const{r:A,s:v,recovery:R}=this,I=te(Je("msgHash",y));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");const _=R===2||R===3?A+e.n:A;if(_>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(R&1)===0?"02":"03",l=g.fromHex(u+Pa(_,n.BYTES)),w=m(_),T=d(-I*w),D=d(v*w),W=g.BASE.multiplyAndAddUnsafe(l,T,D);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return F(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return mi(this.toDERHex())}toDERHex(){return vn.hexFromSig(this)}toCompactRawBytes(){return mi(this.toCompactHex())}toCompactHex(){const y=s;return Pa(this.r,y)+Pa(this.s,y)}}const Y={isValidPrivateKey(p){try{return x(p),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const p=Sl(e.n);return r1(e.randomBytes(p),e.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function V(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function L(p){if(typeof p=="bigint")return!1;if(p instanceof g)return!0;const A=Je("key",p).length,v=n.BYTES,R=v+1,I=2*v+1;if(!(e.allowedPrivateKeyLengths||s===R))return A===R||A===I}function z(p,y,A=!0){if(L(p)===!0)throw new Error("first arg must be private key");if(L(y)===!1)throw new Error("second arg must be public key");return g.fromHex(y).multiply(x(p)).toRawBytes(A)}const J=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const y=tr(p),A=p.length*8-i;return A>0?y>>BigInt(A):y},te=e.bits2int_modN||function(p){return d(J(p))},ne=yi(i);function q(p){return nn("num < 2^"+i,p,Rn,ne),xs(p,s)}function B(p,y,A=P){if(["recovered","canonical"].some(oe=>oe in A))throw new Error("sign() legacy options not supported");const{hash:v,randomBytes:R}=e;let{lowS:I,prehash:_,extraEntropy:u}=A;I==null&&(I=!0),p=Je("msgHash",p),Bl(A),_&&(p=Je("prehashed msgHash",v(p)));const l=te(p),w=x(y),T=[q(w),q(l)];if(u!=null&&u!==!1){const oe=u===!0?R(n.BYTES):u;T.push(Je("extraEntropy",oe))}const D=Or(...T),W=l;function re(oe){const Ce=J(oe);if(!N(Ce))return;const Ee=m(Ce),we=g.BASE.multiply(Ce).toAffine(),De=d(we.x);if(De===Rn)return;const ve=d(Ee*d(W+De*w));if(ve===Rn)return;let Oe=(we.x===De?0:2)|Number(we.y&_t),mn=ve;return I&&F(ve)&&(mn=C(ve),Oe^=1),new K(De,mn,Oe)}return{seed:D,k2sig:re}}const P={lowS:e.lowS,prehash:!1},j={lowS:e.lowS,prehash:!1};function E(p,y,A=P){const{seed:v,k2sig:R}=B(p,y,A),I=e;return ty(I.hash.outputLen,I.nByteLength,I.hmac)(v,R)}g.BASE._setWindowSize(8);function c(p,y,A,v=j){const R=p;y=Je("msgHash",y),A=Je("publicKey",A);const{lowS:I,prehash:_,format:u}=v;if(Bl(v),"strict"in v)throw new Error("options.strict was renamed to lowS");if(u!==void 0&&u!=="compact"&&u!=="der")throw new Error("format must be compact or der");const l=typeof R=="string"||Rs(R),w=!l&&!u&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!l&&!w)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let T,D;try{if(w&&(T=new K(R.r,R.s)),l){try{u!=="compact"&&(T=K.fromDER(R))}catch(Oe){if(!(Oe instanceof vn.Err))throw Oe}!T&&u!=="der"&&(T=K.fromCompact(R))}D=g.fromHex(A)}catch{return!1}if(!T||I&&T.hasHighS())return!1;_&&(y=e.hash(y));const{r:W,s:re}=T,oe=te(y),Ce=m(re),Ee=d(oe*Ce),we=d(W*Ce),De=g.BASE.multiplyAndAddUnsafe(D,Ee,we)?.toAffine();return De?d(De.x)===W:!1}return{CURVE:e,getPublicKey:V,getSharedSecret:z,sign:E,verify:c,ProjectivePoint:g,Signature:K,utils:Y}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function f1(t){return{hash:t,hmac:(e,...n)=>bl(t,e,Fm(...n)),randomBytes:Ed}}function h1(t,e){const n=r=>l1({...t,...f1(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const kl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ll=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),p1=BigInt(0),m1=BigInt(1),Da=BigInt(2),Pl=(t,e)=>(t+e/Da)/e;function g1(t){const e=kl,n=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),d=BigInt(88),m=t*t*t%e,g=m*m*t%e,x=qe(g,n,e)*g%e,O=qe(x,n,e)*g%e,N=qe(O,Da,e)*m%e,F=qe(N,s,e)*N%e,C=qe(F,i,e)*F%e,k=qe(C,a,e)*C%e,K=qe(k,d,e)*k%e,Y=qe(K,a,e)*C%e,V=qe(Y,n,e)*g%e,L=qe(V,o,e)*F%e,z=qe(L,r,e)*m%e,J=qe(z,Da,e);if(!Fa.eql(Fa.sqr(J),t))throw new Error("Cannot find square root");return J}const Fa=Os(kl,void 0,void 0,{sqrt:g1}),$a=h1({a:p1,b:BigInt(7),Fp:Fa,n:Ll,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ll,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-m1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=Pl(i*t,e),d=Pl(-r*t,e);let m=je(t-a*n-d*s,e),g=je(-a*r-d*i,e);const x=m>o,O=g>o;if(x&&(m=e-m),O&&(g=e-g),m>o||g>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:x,k1:m,k2neg:O,k2:g}}}},cl),y1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:$a},Symbol.toStringTag,{value:"Module"}));class Ul extends ue{constructor({docsPath:e}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
22
+ `),{docsPath:e,docsSlug:"account",name:"AccountNotFoundError"})}}class za extends ue{constructor({docsPath:e,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:e,metaMessages:n,name:"AccountTypeNotSupportedError"})}}async function b1(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const ja=new ns(128);async function Dl(t,e){const{account:n=t.account,chain:r=t.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,type:F,value:C,...k}=e;if(typeof n>"u")throw new Ul({docsPath:"/docs/actions/wallet/sendTransaction"});const K=n?wn(n):null;try{Ei(e);const Y=await(async()=>{if(e.to)return e.to;if(e.to!==null&&i&&i.length>0)return await Qd({authorization:i[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`.")})})();if(K?.type==="json-rpc"||K===null){let V;r!==null&&(V=await xt(t,Sa,"getChainId")({}),Wy({currentChainId:V,chain:r}));const L=t.chain?.formatters?.transactionRequest?.format,J=(L||va)({...Ea(k,{format:L}),accessList:s,account:K,authorizationList:i,blobs:o,chainId:V,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,to:Y,type:F,value:C},"sendTransaction"),te=ja.get(t.uid),ne=te?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:ne,params:[J]},{retryCount:0})}catch(q){if(te===!1)throw q;const B=q;if(B.name==="InvalidInputRpcError"||B.name==="InvalidParamsRpcError"||B.name==="MethodNotFoundRpcError"||B.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[J]},{retryCount:0}).then(P=>(ja.set(t.uid,!0),P)).catch(P=>{const j=P;throw j.name==="MethodNotFoundRpcError"||j.name==="MethodNotSupportedRpcError"?(ja.set(t.uid,!1),B):j});throw B}}if(K?.type==="local"){const V=await xt(t,gl,"prepareTransactionRequest")({account:K,accessList:s,authorizationList:i,blobs:o,chain:r,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:x,maxPriorityFeePerGas:O,nonce:N,nonceManager:K.nonceManager,parameters:[...pl,"sidecars"],type:F,value:C,...k,to:Y}),L=r?.serializers?.transaction,z=await K.signTransaction(V,{serializer:L});return await xt(t,b1,"sendRawTransaction")({serializedTransaction:z})}throw K?.type==="smart"?new za({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new za({docsPath:"/docs/actions/wallet/sendTransaction",type:K?.type})}catch(Y){throw Y instanceof za?Y:hl(Y,{...e,account:K,chain:e.chain||void 0})}}async function Ri(t,e){return Ri.internal(t,Dl,"sendTransaction",e)}(function(t){async function e(n,r,s,i){const{abi:o,account:a=n.account,address:d,args:m,dataSuffix:g,functionName:x,...O}=i;if(typeof a>"u")throw new Ul({docsPath:"/docs/contract/writeContract"});const N=a?wn(a):null,F=Cg({abi:o,args:m,functionName:x});try{return await xt(n,r,s)({data:`${F}${g?g.replace("0x",""):""}`,to:d,account:N,...O})}catch(C){throw Xg(C,{abi:o,address:d,args:m,docsPath:"/docs/contract/writeContract",functionName:x,sender:N?.address})}}t.internal=e})(Ri||(Ri={}));function Fl(t,e,n){const r=t[e.name];if(typeof r=="function")return r;const s=t[n];return typeof s=="function"?s:i=>e(t,i)}const _1="3.4.0",w1=()=>`@wagmi/core@${_1}`;var $l=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Ai,zl;let rr=class wu extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return w1()}constructor(e,n={}){super(),Ai.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const r=n.cause instanceof wu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof wu&&n.cause.docsPath||n.docsPath;this.message=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${this.docsBaseUrl}${s}.html${n.docsSlug?`#${n.docsSlug}`:""}`]:[],...r?[`Details: ${r}`]:[],`Version: ${this.version}`].join(`
23
+ `),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.shortMessage=e}walk(e){return $l(this,Ai,"m",zl).call(this,this,e)}};Ai=new WeakSet,zl=function t(e,n){return n?.(e)?e:e.cause?$l(this,Ai,"m",t).call(this,e.cause,n):e};class jl extends rr{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class E1 extends rr{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class v1 extends rr{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class R1 extends rr{constructor({address:e,connector:n}){super(`Account "${e}" not found for connector "${n.name}".`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAccountNotFoundError"})}}class A1 extends rr{constructor({connectionChainId:e,connectorChainId:n}){super(`The current chain of the connector (id: ${n}) does not match the connection's chain (id: ${e}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorChainMismatchError"})}}class x1 extends rr{constructor({connector:e}){super(`Connector "${e.name}" unavailable while reconnecting.`,{details:["During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.","All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.","This error commonly occurs for connectors that asynchronously inject after reconnection has already started."].join(" ")}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorUnavailableReconnectingError"})}}async function S1(t,e){let n;if(typeof e.connector=="function"?n=t._internal.connectors.setup(e.connector):n=e.connector,n.uid===t.state.current)throw new E1;try{t.setState(o=>({...o,status:"connecting"})),n.emitter.emit("message",{type:"connecting"});const{connector:r,...s}=e,i=await n.connect(s);return n.emitter.off("connect",t._internal.events.connect),n.emitter.on("change",t._internal.events.change),n.emitter.on("disconnect",t._internal.events.disconnect),await t.storage?.setItem("recentConnectorId",n.id),t.setState(o=>({...o,connections:new Map(o.connections).set(n.uid,{accounts:s.withCapabilities?i.accounts.map(a=>typeof a=="object"?a.address:a):i.accounts,chainId:i.chainId,connector:n}),current:n.uid,status:"connected"})),{accounts:s.withCapabilities?i.accounts.map(o=>typeof o=="object"?o:{address:o,capabilities:{}}):i.accounts,chainId:i.chainId}}catch(r){throw t.setState(s=>({...s,status:s.current?"connected":"disconnected"})),r}}const Va=256;let xi=Va,Si;function Vl(t=11){if(!Si||xi+t>Va*2){Si="",xi=0;for(let e=0;e<Va;e++)Si+=(256+Math.random()*256|0).toString(16).substring(1)}return Si.substring(xi,xi+++t)}function T1(t){const{batch:e,chain:n,ccipRead:r,key:s="base",name:i="Base Client",type:o="base"}=t,a=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),d=n?.blockTime??12e3,m=Math.min(Math.max(Math.floor(d/2),500),4e3),g=t.pollingInterval??m,x=t.cacheTime??g,O=t.account?wn(t.account):void 0,{config:N,request:F,value:C}=t.transport({account:O,chain:n,pollingInterval:g}),k={...N,...C},K={account:O,batch:e,cacheTime:x,ccipRead:r,chain:n,key:s,name:i,pollingInterval:g,request:F,transport:k,type:o,uid:Vl(),...a?{experimental_blockTag:a}:{}};function Y(V){return L=>{const z=L(V);for(const te in K)delete z[te];const J={...V,...z};return Object.assign(J,{extend:Y(J)})}}return Object.assign(K,{extend:Y(K)})}function O1({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},d){const m=Vl();return{config:{key:t,methods:e,name:n,request:r,retryCount:s,retryDelay:i,timeout:o,type:a},request:qy(r,{methods:e,retryCount:s,retryDelay:i,uid:m}),value:d}}function I1(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:i}=e;return({retryCount:o})=>O1({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:i,type:"custom"})}async function Gl(t,e={}){const{assertChainId:n=!0}=e;let r;if(e.connector){const{connector:g}=e;if(t.state.status==="reconnecting"&&!g.getAccounts&&!g.getChainId)throw new x1({connector:g});const[x,O]=await Promise.all([g.getAccounts().catch(N=>{if(e.account===null)return[];throw N}),g.getChainId()]);r={accounts:x,chainId:O,connector:g}}else r=t.state.connections.get(t.state.current);if(!r)throw new v1;const s=e.chainId??r.chainId,i=await r.connector.getChainId();if(n&&i!==s)throw new A1({connectionChainId:s,connectorChainId:i});const o=r.connector;if(o.getClient)return o.getClient({chainId:s});const a=wn(e.account??r.accounts[0]);if(a&&(a.address=ui(a.address)),e.account&&!r.accounts.some(g=>g.toLowerCase()===a.address.toLowerCase()))throw new R1({address:a.address,connector:o});const d=t.chains.find(g=>g.id===s),m=await r.connector.getProvider({chainId:s});return T1({account:a,chain:d,name:"Connector Client",transport:g=>I1(m)({...g,retryCount:0})})}async function N1(t,e={}){let n;if(e.connector)n=e.connector;else{const{connections:s,current:i}=t.state;n=s.get(i)?.connector}const r=t.state.connections;n&&(await n.disconnect(),n.emitter.off("change",t._internal.events.change),n.emitter.off("disconnect",t._internal.events.disconnect),n.emitter.on("connect",t._internal.events.connect),r.delete(n.uid)),t.setState(s=>{if(r.size===0)return{...s,connections:new Map,current:null,status:"disconnected"};const i=r.values().next().value;return{...s,connections:new Map(r),current:i.connector.uid}});{const s=t.state.current;if(!s)return;const i=t.state.connections.get(s)?.connector;if(!i)return;await t.storage?.setItem("recentConnectorId",i.id)}}async function C1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Gl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Fl(o,Dl,"sendTransaction")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a,gas:i.gas??void 0})}class M1 extends rr{constructor({connector:e}){super(`"${e.name}" does not support programmatic chain switching.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SwitchChainNotSupportedError"})}}async function B1(t,e){const{addEthereumChainParameter:n,chainId:r}=e,s=t.state.connections.get(e.connector?.uid??t.state.current);if(s){const o=s.connector;if(!o.switchChain)throw new M1({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const i=t.chains.find(o=>o.id===r);if(!i)throw new jl;return t.setState(o=>({...o,chainId:r})),i}async function k1(t,e){const{account:n,chainId:r,connector:s,...i}=e;let o;typeof n=="object"&&n?.type==="local"?o=t.getClient({chainId:r}):o=await Gl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await Fl(o,Ri,"writeContract")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a})}function AT(t){return t}function Ga(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Ha(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var n=function r(){var s=!1;try{s=this instanceof r}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(r){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,s.get?s:{enumerable:!0,get:function(){return t[r]}})}),n}var qa={exports:{}},Hl;function L1(){return Hl||(Hl=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function s(d,m,g){this.fn=d,this.context=m,this.once=g||!1}function i(d,m,g,x,O){if(typeof g!="function")throw new TypeError("The listener must be a function");var N=new s(g,x||d,O),F=n?n+m:m;return d._events[F]?d._events[F].fn?d._events[F]=[d._events[F],N]:d._events[F].push(N):(d._events[F]=N,d._eventsCount++),d}function o(d,m){--d._eventsCount===0?d._events=new r:delete d._events[m]}function a(){this._events=new r,this._eventsCount=0}a.prototype.eventNames=function(){var m=[],g,x;if(this._eventsCount===0)return m;for(x in g=this._events)e.call(g,x)&&m.push(n?x.slice(1):x);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,x=this._events[g];if(!x)return[];if(x.fn)return[x.fn];for(var O=0,N=x.length,F=new Array(N);O<N;O++)F[O]=x[O].fn;return F},a.prototype.listenerCount=function(m){var g=n?n+m:m,x=this._events[g];return x?x.fn?1:x.length:0},a.prototype.emit=function(m,g,x,O,N,F){var C=n?n+m:m;if(!this._events[C])return!1;var k=this._events[C],K=arguments.length,Y,V;if(k.fn){switch(k.once&&this.removeListener(m,k.fn,void 0,!0),K){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,g),!0;case 3:return k.fn.call(k.context,g,x),!0;case 4:return k.fn.call(k.context,g,x,O),!0;case 5:return k.fn.call(k.context,g,x,O,N),!0;case 6:return k.fn.call(k.context,g,x,O,N,F),!0}for(V=1,Y=new Array(K-1);V<K;V++)Y[V-1]=arguments[V];k.fn.apply(k.context,Y)}else{var L=k.length,z;for(V=0;V<L;V++)switch(k[V].once&&this.removeListener(m,k[V].fn,void 0,!0),K){case 1:k[V].fn.call(k[V].context);break;case 2:k[V].fn.call(k[V].context,g);break;case 3:k[V].fn.call(k[V].context,g,x);break;case 4:k[V].fn.call(k[V].context,g,x,O);break;default:if(!Y)for(z=1,Y=new Array(K-1);z<K;z++)Y[z-1]=arguments[z];k[V].fn.apply(k[V].context,Y)}}return!0},a.prototype.on=function(m,g,x){return i(this,m,g,x,!1)},a.prototype.once=function(m,g,x){return i(this,m,g,x,!0)},a.prototype.removeListener=function(m,g,x,O){var N=n?n+m:m;if(!this._events[N])return this;if(!g)return o(this,N),this;var F=this._events[N];if(F.fn)F.fn===g&&(!O||F.once)&&(!x||F.context===x)&&o(this,N);else{for(var C=0,k=[],K=F.length;C<K;C++)(F[C].fn!==g||O&&!F[C].once||x&&F[C].context!==x)&&k.push(F[C]);k.length?this._events[N]=k.length===1?k[0]:k:o(this,N)}return this},a.prototype.removeAllListeners=function(m){var g;return m?(g=n?n+m:m,this._events[g]&&o(this,g)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,t.exports=a})(qa)),qa.exports}var P1=L1();const ql=Ga(P1);let Nr=class extends Error{name="BaseError";cause;constructor(e,n={}){super(e,n.cause?{cause:n.cause}:void 0),this.cause=n.cause}};class U1 extends Nr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}}let D1=class extends Nr{name="AddMiniApp.RejectedByUser";constructor(){super("Add miniapp rejected by user")}},Kl=class extends Nr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};class F1 extends Nr{name="SignManifest.RejectedByUser";constructor(){super("Sign manifest rejected by user")}}class $1 extends Nr{name="SignManifest.InvalidDomain";constructor(){super("Invalid domain provided")}}class z1 extends Nr{name="SignManifest.GenericError";constructor(e="Manifest signing failed"){super(e)}}var Ne;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ne||(Ne={}));var Wl;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Wl||(Wl={}));const de=Ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$n=t=>{switch(typeof t){case"undefined":return de.undefined;case"string":return de.string;case"number":return Number.isNaN(t)?de.nan:de.number;case"boolean":return de.boolean;case"function":return de.function;case"bigint":return de.bigint;case"symbol":return de.symbol;case"object":return Array.isArray(t)?de.array:t===null?de.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?de.promise:typeof Map<"u"&&t instanceof Map?de.map:typeof Set<"u"&&t instanceof Set?de.set:typeof Date<"u"&&t instanceof Date?de.date:de.object;default:return de.unknown}},ee=Ne.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class An extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,d=0;for(;d<o.path.length;){const m=o.path[d];d===o.path.length-1?(a[m]=a[m]||{_errors:[]},a[m]._errors.push(n(o))):a[m]=a[m]||{_errors:[]},a=a[m],d++}}};return s(this),r}static assert(e){if(!(e instanceof An))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}An.create=t=>new An(t);const Ka=(t,e)=>{let n;switch(t.code){case ee.invalid_type:t.received===de.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case ee.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ne.jsonStringifyReplacer)}`;break;case ee.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ne.joinValues(t.keys,", ")}`;break;case ee.invalid_union:n="Invalid input";break;case ee.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ne.joinValues(t.options)}`;break;case ee.invalid_enum_value:n=`Invalid enum value. Expected ${Ne.joinValues(t.options)}, received '${t.received}'`;break;case ee.invalid_arguments:n="Invalid function arguments";break;case ee.invalid_return_type:n="Invalid function return type";break;case ee.invalid_date:n="Invalid date";break;case ee.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ne.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case ee.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case ee.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case ee.custom:n="Invalid input";break;case ee.invalid_intersection_types:n="Intersection results could not be merged";break;case ee.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case ee.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ne.assertNever(t)}return{message:n}};let j1=Ka;function V1(){return j1}const G1=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const d=r.filter(m=>!!m).slice().reverse();for(const m of d)a=m(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function ie(t,e){const n=V1(),r=G1({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Ka?void 0:Ka].filter(s=>!!s)});t.common.issues.push(r)}class qt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return pe;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return qt.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return pe;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const pe=Object.freeze({status:"aborted"}),Is=t=>({status:"dirty",value:t}),Qt=t=>({status:"valid",value:t}),Zl=t=>t.status==="aborted",Yl=t=>t.status==="dirty",Cr=t=>t.status==="valid",Ti=t=>typeof Promise<"u"&&t instanceof Promise;var le;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(le||(le={}));class zn{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Jl=(t,e)=>{if(Cr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new An(t.common.issues);return this._error=n,this._error}}};function Ae(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:d}=t;return o.code==="invalid_enum_value"?{message:d??a.defaultError}:typeof a.data>"u"?{message:d??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:d??n??a.defaultError}},description:s}}class Te{get description(){return this._def.description}_getType(e){return $n(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:$n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new qt,ctx:{common:e.parent.common,data:e.data,parsedType:$n(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Ti(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$n(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Jl(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$n(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Cr(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Cr(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$n(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ti(s)?s:Promise.resolve(s));return Jl(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:ee.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new or({schema:this,typeName:me.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Sn.create(this,this._def)}nullable(){return ar.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this)}promise(){return Mi.create(this,this._def)}or(e){return Ii.create([this,e],this._def)}and(e){return Ni.create(this,e,this._def)}transform(e){return new or({...Ae(this._def),schema:this,typeName:me.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Bi({...Ae(this._def),innerType:this,defaultValue:n,typeName:me.ZodDefault})}brand(){return new cf({typeName:me.ZodBranded,type:this,...Ae(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ki({...Ae(this._def),innerType:this,catchValue:n,typeName:me.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return nc.create(this,e)}readonly(){return Li.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const H1=/^c[^\s-]{8,}$/i,q1=/^[0-9a-z]+$/,K1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,W1=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z1=/^[a-z0-9_-]{21}$/i,Y1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,J1=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,X1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Wa;const eb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tb=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,nb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,rb=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,sb=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ib=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Xl="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ob=new RegExp(`^${Xl}$`);function Ql(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function ab(t){return new RegExp(`^${Ql(t)}$`)}function cb(t){let e=`${Xl}T${Ql(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ub(t,e){return!!((e==="v4"||!e)&&eb.test(t)||(e==="v6"||!e)&&nb.test(t))}function db(t,e){if(!Y1.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function lb(t,e){return!!((e==="v4"||!e)&&tb.test(t)||(e==="v6"||!e)&&rb.test(t))}class jn extends Te{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==de.string){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:de.string,received:i.parsedType}),pe}const r=new qt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?ie(s,{code:ee.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ie(s,{code:ee.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")X1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"email",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Wa||(Wa=new RegExp(Q1,"u")),Wa.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"emoji",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")W1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"uuid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")Z1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"nanoid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")H1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cuid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")q1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cuid2",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")K1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"ulid",code:ee.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),ie(s,{validation:"url",code:ee.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"regex",code:ee.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?cb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?ob.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?ab(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?J1.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"duration",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?ub(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"ip",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?db(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"jwt",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?lb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"cidr",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?sb.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64",code:ee.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?ib.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64url",code:ee.invalid_string,message:i.message}),r.dirty()):Ne.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:ee.invalid_string,...le.errToObj(r)})}_addCheck(e){return new jn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...le.errToObj(e)})}url(e){return this._addCheck({kind:"url",...le.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...le.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...le.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...le.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...le.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...le.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...le.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...le.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...le.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...le.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...le.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...le.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...le.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...le.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...le.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...le.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...le.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...le.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...le.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...le.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...le.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...le.errToObj(n)})}nonempty(e){return this.min(1,le.errToObj(e))}trim(){return new jn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}jn.create=t=>new jn({checks:[],typeName:me.ZodString,coerce:t?.coerce??!1,...Ae(t)});function fb(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class Mr extends Te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==de.number){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:de.number,received:i.parsedType}),pe}let r;const s=new qt;for(const i of this._def.checks)i.kind==="int"?Ne.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?fb(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.not_finite,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,le.toString(n))}gt(e,n){return this.setLimit("min",e,!1,le.toString(n))}lte(e,n){return this.setLimit("max",e,!0,le.toString(n))}lt(e,n){return this.setLimit("max",e,!1,le.toString(n))}setLimit(e,n,r,s){return new Mr({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Mr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:le.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:le.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:le.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:le.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:le.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ne.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Mr.create=t=>new Mr({checks:[],typeName:me.ZodNumber,coerce:t?.coerce||!1,...Ae(t)});class Ns extends Te{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==de.bigint)return this._getInvalidInput(e);let r;const s=new qt;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),ie(r,{code:ee.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ne.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ee.invalid_type,expected:de.bigint,received:n.parsedType}),pe}gte(e,n){return this.setLimit("min",e,!0,le.toString(n))}gt(e,n){return this.setLimit("min",e,!1,le.toString(n))}lte(e,n){return this.setLimit("max",e,!0,le.toString(n))}lt(e,n){return this.setLimit("max",e,!1,le.toString(n))}setLimit(e,n,r,s){return new Ns({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Ns({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:le.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:le.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:le.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:le.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:le.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Ns.create=t=>new Ns({checks:[],typeName:me.ZodBigInt,coerce:t?.coerce??!1,...Ae(t)});class Za extends Te{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==de.boolean){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.boolean,received:r.parsedType}),pe}return Qt(e.data)}}Za.create=t=>new Za({typeName:me.ZodBoolean,coerce:t?.coerce||!1,...Ae(t)});class Oi extends Te{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==de.date){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_type,expected:de.date,received:i.parsedType}),pe}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ie(i,{code:ee.invalid_date}),pe}const r=new qt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),ie(s,{code:ee.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ne.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oi({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:le.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:le.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Oi.create=t=>new Oi({checks:[],coerce:t?.coerce||!1,typeName:me.ZodDate,...Ae(t)});class ef extends Te{_parse(e){if(this._getType(e)!==de.symbol){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.symbol,received:r.parsedType}),pe}return Qt(e.data)}}ef.create=t=>new ef({typeName:me.ZodSymbol,...Ae(t)});class Ya extends Te{_parse(e){if(this._getType(e)!==de.undefined){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.undefined,received:r.parsedType}),pe}return Qt(e.data)}}Ya.create=t=>new Ya({typeName:me.ZodUndefined,...Ae(t)});class Ja extends Te{_parse(e){if(this._getType(e)!==de.null){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.null,received:r.parsedType}),pe}return Qt(e.data)}}Ja.create=t=>new Ja({typeName:me.ZodNull,...Ae(t)});class tf extends Te{constructor(){super(...arguments),this._any=!0}_parse(e){return Qt(e.data)}}tf.create=t=>new tf({typeName:me.ZodAny,...Ae(t)});class nf extends Te{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Qt(e.data)}}nf.create=t=>new nf({typeName:me.ZodUnknown,...Ae(t)});class Vn extends Te{_parse(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ee.invalid_type,expected:de.never,received:n.parsedType}),pe}}Vn.create=t=>new Vn({typeName:me.ZodNever,...Ae(t)});class rf extends Te{_parse(e){if(this._getType(e)!==de.undefined){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.void,received:r.parsedType}),pe}return Qt(e.data)}}rf.create=t=>new rf({typeName:me.ZodVoid,...Ae(t)});class dn extends Te{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==de.array)return ie(n,{code:ee.invalid_type,expected:de.array,received:n.parsedType}),pe;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(ie(n,{code:o?ee.too_big:ee.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(ie(n,{code:ee.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(ie(n,{code:ee.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new zn(n,o,n.path,a)))).then(o=>qt.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new zn(n,o,n.path,a)));return qt.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new dn({...this._def,minLength:{value:e,message:le.toString(n)}})}max(e,n){return new dn({...this._def,maxLength:{value:e,message:le.toString(n)}})}length(e,n){return new dn({...this._def,exactLength:{value:e,message:le.toString(n)}})}nonempty(e){return this.min(1,e)}}dn.create=(t,e)=>new dn({type:t,minLength:null,maxLength:null,exactLength:null,typeName:me.ZodArray,...Ae(e)});function Br(t){if(t instanceof Qe){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Sn.create(Br(r))}return new Qe({...t._def,shape:()=>e})}else return t instanceof dn?new dn({...t._def,type:Br(t.element)}):t instanceof Sn?Sn.create(Br(t.unwrap())):t instanceof ar?ar.create(Br(t.unwrap())):t instanceof sr?sr.create(t.items.map(e=>Br(e))):t}class Qe extends Te{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Ne.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==de.object){const m=this._getOrReturnCtx(e);return ie(m,{code:ee.invalid_type,expected:de.object,received:m.parsedType}),pe}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Vn&&this._def.unknownKeys==="strip"))for(const m in s.data)o.includes(m)||a.push(m);const d=[];for(const m of o){const g=i[m],x=s.data[m];d.push({key:{status:"valid",value:m},value:g._parse(new zn(s,x,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof Vn){const m=this._def.unknownKeys;if(m==="passthrough")for(const g of a)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(m==="strict")a.length>0&&(ie(s,{code:ee.unrecognized_keys,keys:a}),r.dirty());else if(m!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const m=this._def.catchall;for(const g of a){const x=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new zn(s,x,s.path,g)),alwaysSet:g in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of d){const x=await g.key,O=await g.value;m.push({key:x,value:O,alwaysSet:g.alwaysSet})}return m}).then(m=>qt.mergeObjectSync(r,m)):qt.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return le.errToObj,new Qe({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const s=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:le.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Qe({...this._def,unknownKeys:"strip"})}passthrough(){return new Qe({...this._def,unknownKeys:"passthrough"})}extend(e){return new Qe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Qe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:me.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Qe({...this._def,catchall:e})}pick(e){const n={};for(const r of Ne.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Qe({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ne.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new Qe({...this._def,shape:()=>n})}deepPartial(){return Br(this)}partial(e){const n={};for(const r of Ne.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new Qe({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ne.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Sn;)i=i._def.innerType;n[r]=i}return new Qe({...this._def,shape:()=>n})}keyof(){return of(Ne.objectKeys(this.shape))}}Qe.create=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strip",catchall:Vn.create(),typeName:me.ZodObject,...Ae(e)}),Qe.strictCreate=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strict",catchall:Vn.create(),typeName:me.ZodObject,...Ae(e)}),Qe.lazycreate=(t,e)=>new Qe({shape:t,unknownKeys:"strip",catchall:Vn.create(),typeName:me.ZodObject,...Ae(e)});class Ii extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new An(a.ctx.common.issues));return ie(n,{code:ee.invalid_union,unionErrors:o}),pe}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const d of r){const m={...n,common:{...n.common,issues:[]},parent:null},g=d._parseSync({data:n.data,path:n.path,parent:m});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:m}),m.common.issues.length&&o.push(m.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(d=>new An(d));return ie(n,{code:ee.invalid_union,unionErrors:a}),pe}}get options(){return this._def.options}}Ii.create=(t,e)=>new Ii({options:t,typeName:me.ZodUnion,...Ae(e)});const xn=t=>t instanceof ec?xn(t.schema):t instanceof or?xn(t.innerType()):t instanceof Ci?[t.value]:t instanceof ir?t.options:t instanceof tc?Ne.objectValues(t.enum):t instanceof Bi?xn(t._def.innerType):t instanceof Ya?[void 0]:t instanceof Ja?[null]:t instanceof Sn?[void 0,...xn(t.unwrap())]:t instanceof ar?[null,...xn(t.unwrap())]:t instanceof cf||t instanceof Li?xn(t.unwrap()):t instanceof ki?xn(t._def.innerType):[];class Xa extends Te{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==de.object)return ie(n,{code:ee.invalid_type,expected:de.object,received:n.parsedType}),pe;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(ie(n,{code:ee.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),pe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const i of n){const o=xn(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new Xa({typeName:me.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Ae(r)})}}function Qa(t,e){const n=$n(t),r=$n(e);if(t===e)return{valid:!0,data:t};if(n===de.object&&r===de.object){const s=Ne.objectKeys(e),i=Ne.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const d=Qa(t[a],e[a]);if(!d.valid)return{valid:!1};o[a]=d.data}return{valid:!0,data:o}}else if(n===de.array&&r===de.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],d=Qa(o,a);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return n===de.date&&r===de.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ni extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Zl(i)||Zl(o))return pe;const a=Qa(i.value,o.value);return a.valid?((Yl(i)||Yl(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:ee.invalid_intersection_types}),pe)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ni.create=(t,e,n)=>new Ni({left:t,right:e,typeName:me.ZodIntersection,...Ae(n)});class sr extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.array)return ie(r,{code:ee.invalid_type,expected:de.array,received:r.parsedType}),pe;if(r.data.length<this._def.items.length)return ie(r,{code:ee.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),pe;!this._def.rest&&r.data.length>this._def.items.length&&(ie(r,{code:ee.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const d=this._def.items[a]||this._def.rest;return d?d._parse(new zn(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>qt.mergeArray(n,o)):qt.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new sr({...this._def,rest:e})}}sr.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new sr({items:t,typeName:me.ZodTuple,rest:null,...Ae(e)})};class sf extends Te{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.map)return ie(r,{code:ee.invalid_type,expected:de.map,received:r.parsedType}),pe;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,d],m)=>({key:s._parse(new zn(r,a,r.path,[m,"key"])),value:i._parse(new zn(r,d,r.path,[m,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const d of o){const m=await d.key,g=await d.value;if(m.status==="aborted"||g.status==="aborted")return pe;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const d of o){const m=d.key,g=d.value;if(m.status==="aborted"||g.status==="aborted")return pe;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}}}}sf.create=(t,e,n)=>new sf({valueType:e,keyType:t,typeName:me.ZodMap,...Ae(n)});class Cs extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==de.set)return ie(r,{code:ee.invalid_type,expected:de.set,received:r.parsedType}),pe;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(ie(r,{code:ee.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(ie(r,{code:ee.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(d){const m=new Set;for(const g of d){if(g.status==="aborted")return pe;g.status==="dirty"&&n.dirty(),m.add(g.value)}return{status:n.value,value:m}}const a=[...r.data.values()].map((d,m)=>i._parse(new zn(r,d,r.path,m)));return r.common.async?Promise.all(a).then(d=>o(d)):o(a)}min(e,n){return new Cs({...this._def,minSize:{value:e,message:le.toString(n)}})}max(e,n){return new Cs({...this._def,maxSize:{value:e,message:le.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Cs.create=(t,e)=>new Cs({valueType:t,minSize:null,maxSize:null,typeName:me.ZodSet,...Ae(e)});class ec extends Te{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ec.create=(t,e)=>new ec({getter:t,typeName:me.ZodLazy,...Ae(e)});class Ci extends Te{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return ie(n,{received:n.data,code:ee.invalid_literal,expected:this._def.value}),pe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ci.create=(t,e)=>new Ci({value:t,typeName:me.ZodLiteral,...Ae(e)});function of(t,e){return new ir({values:t,typeName:me.ZodEnum,...Ae(e)})}class ir extends Te{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return ie(n,{expected:Ne.joinValues(r),received:n.parsedType,code:ee.invalid_type}),pe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return ie(n,{received:n.data,code:ee.invalid_enum_value,options:r}),pe}return Qt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ir.create(e,{...this._def,...n})}exclude(e,n=this._def){return ir.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}ir.create=of;class tc extends Te{_parse(e){const n=Ne.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==de.string&&r.parsedType!==de.number){const s=Ne.objectValues(n);return ie(r,{expected:Ne.joinValues(s),received:r.parsedType,code:ee.invalid_type}),pe}if(this._cache||(this._cache=new Set(Ne.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ne.objectValues(n);return ie(r,{received:r.data,code:ee.invalid_enum_value,options:s}),pe}return Qt(e.data)}get enum(){return this._def.values}}tc.create=(t,e)=>new tc({values:t,typeName:me.ZodNativeEnum,...Ae(e)});class Mi extends Te{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==de.promise&&n.common.async===!1)return ie(n,{code:ee.invalid_type,expected:de.promise,received:n.parsedType}),pe;const r=n.parsedType===de.promise?n.data:Promise.resolve(n.data);return Qt(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Mi.create=(t,e)=>new Mi({type:t,typeName:me.ZodPromise,...Ae(e)});class or extends Te{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===me.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{ie(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return pe;const d=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return d.status==="aborted"?pe:d.status==="dirty"||n.value==="dirty"?Is(d.value):d});{if(n.value==="aborted")return pe;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?pe:a.status==="dirty"||n.value==="dirty"?Is(a.value):a}}if(s.type==="refinement"){const o=a=>{const d=s.refinement(a,i);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?pe:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?pe:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Cr(o))return pe;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Cr(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):pe);Ne.assertNever(s)}}or.create=(t,e,n)=>new or({schema:t,typeName:me.ZodEffects,effect:e,...Ae(n)}),or.createWithPreprocess=(t,e,n)=>new or({schema:e,effect:{type:"preprocess",transform:t},typeName:me.ZodEffects,...Ae(n)});class Sn extends Te{_parse(e){return this._getType(e)===de.undefined?Qt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sn.create=(t,e)=>new Sn({innerType:t,typeName:me.ZodOptional,...Ae(e)});class ar extends Te{_parse(e){return this._getType(e)===de.null?Qt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ar.create=(t,e)=>new ar({innerType:t,typeName:me.ZodNullable,...Ae(e)});class Bi extends Te{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===de.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Bi.create=(t,e)=>new Bi({innerType:t,typeName:me.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ae(e)});class ki extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ti(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new An(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new An(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ki.create=(t,e)=>new ki({innerType:t,typeName:me.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ae(e)});class af extends Te{_parse(e){if(this._getType(e)!==de.nan){const r=this._getOrReturnCtx(e);return ie(r,{code:ee.invalid_type,expected:de.nan,received:r.parsedType}),pe}return{status:"valid",value:e.data}}}af.create=t=>new af({typeName:me.ZodNaN,...Ae(t)});class cf extends Te{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class nc extends Te{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?pe:i.status==="dirty"?(n.dirty(),Is(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?pe:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new nc({in:e,out:n,typeName:me.ZodPipeline})}}class Li extends Te{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Cr(s)&&(s.value=Object.freeze(s.value)),s);return Ti(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Li.create=(t,e)=>new Li({innerType:t,typeName:me.ZodReadonly,...Ae(e)});var me;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(me||(me={}));const Ke=jn.create,uf=Mr.create,hb=Za.create;Vn.create;const cr=dn.create,Et=Qe.create,Pi=Ii.create,df=Xa.create;Ni.create,sr.create;const Tt=Ci.create,rc=ir.create;Mi.create,Sn.create,ar.create;const pb=/[@#$%^&*+=/\\|~«»]/,mb=/(!{2,}|\?{2,}|-{2,})/,gb=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,kr=({max:t,noSpaces:e}={})=>(e?Ke().max(t??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):Ke().max(t??Number.POSITIVE_INFINITY)).refine(r=>!gb.test(r),{message:"Emojis and symbols are not allowed"}).refine(r=>!pb.test(r),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed"}).refine(r=>!mb.test(r),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Pt=Ke().url().startsWith("https://",{message:"Must be an https url"}).max(1024).refine(t=>!t.includes(" "),{message:"URL must not contain spaces"}).refine(t=>{try{const e=new URL(t).hostname;return!(e==="localhost"||e.endsWith(".localhost")||/^(\d{1,3}\.){3}\d{1,3}$/.test(e)||e.startsWith("[")&&e.endsWith("]"))}catch{return!1}},{message:"URL must not use IP addresses or localhost"}),sc=Ke().max(32),lf=Ke().max(32),yb=/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/,bb=Ke().regex(yb,{message:"Invalid CAIP-19 asset ID"}),ic=Ke().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),_b=/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,wb=Ke().max(1024).regex(_b,{message:"Must be a valid domain name (e.g., example.com, sub.example.com)"}).refine(t=>!t.includes("://"),{message:"Domain must not include protocol (http://, https://, etc.)"}).refine(t=>!t.includes("/"),{message:"Domain must not include path separators"}).refine(t=>!t.includes("@"),{message:"Domain must not include @ symbol"}).refine(t=>!t.includes(":"),{message:"Domain must not include port numbers"}),Eb=Pi([Tt("1:1"),Tt("3:2")]),vb=Et({header:Ke(),payload:Ke(),signature:Ke()});Et({fid:uf(),type:Tt("app_key"),key:Ke().startsWith("0x")});const Rb=Et({type:Tt("launch_frame"),name:sc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:ic.optional()}),Ab=Et({type:Tt("launch_miniapp"),name:sc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:ic.optional()}),xb=Et({type:Tt("view_token"),token:bb}),Sb=df("type",[Ab,xb,Rb]),Tb=Et({title:lf,action:Sb});Et({version:Pi([Ke(),uf()]).transform(t=>String(t)).pipe(Pi([Tt("next"),Tt("1")])),imageUrl:Pt,aspectRatio:Eb.optional(),button:Tb});const ff=Et({url:Ke(),token:Ke()});Et({notificationId:Ke().max(128),title:Ke().max(32),body:Ke().max(128),targetUrl:Pt,tokens:Ke().array().max(100)}),Et({result:Et({successfulTokens:cr(Ke()),invalidTokens:cr(Ke()),rateLimitedTokens:cr(Ke())})});const Ob=Et({event:Tt("miniapp_added"),notificationDetails:ff.optional()}),Ib=Et({event:Tt("miniapp_removed")}),Nb=Et({event:Tt("notifications_enabled"),notificationDetails:ff.required()}),Cb=Et({event:Tt("notifications_disabled")});df("event",[Ob,Ib,Nb,Cb]);const Mb=["wallet.getEthereumProvider","wallet.getSolanaProvider","actions.ready","actions.openUrl","actions.close","actions.setPrimaryButton","actions.addMiniApp","actions.signIn","actions.viewCast","actions.viewProfile","actions.composeCast","actions.viewToken","actions.sendToken","actions.swapToken","actions.openMiniApp","actions.requestCameraAndMicrophoneAccess","experimental.signManifest","haptics.impactOccurred","haptics.notificationOccurred","haptics.selectionChanged","back"],Bb=rc(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),kb=Pi([Tt("0.0.0"),Tt("0.0.1"),Tt("1"),Tt("next")]),Lb=kr({max:30}),Pb=kr({max:170}),Ub=cr(Pt).max(3),Db=cr(kr({max:20,noSpaces:!0})).max(5),Fb=kr({max:30}),$b=kr({max:30}),zb=kr({max:100}),jb=hb(),Vb=["eip155:1","eip155:8453","eip155:42161","eip155:421614","eip155:84532","eip155:666666666","eip155:100","eip155:10","eip155:11155420","eip155:137","eip155:11155111","eip155:7777777","eip155:130","eip155:10143","eip155:42220","eip155:999","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"];function hf(t){const e=new Set(t);return Array.from(e)}const Gb=cr(rc(Vb)).transform(hf),Hb=cr(rc(Mb)).transform(hf),pf=Et({version:kb,name:sc,iconUrl:Pt,homeUrl:Pt,imageUrl:Pt.optional(),buttonTitle:lf.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:ic.optional(),webhookUrl:Pt.optional(),subtitle:Lb.optional(),description:Pb.optional(),screenshotUrls:Ub.optional(),primaryCategory:Bb.optional(),tags:Db.optional(),heroImageUrl:Pt.optional(),tagline:Fb.optional(),ogTitle:$b.optional(),ogDescription:zb.optional(),ogImageUrl:Pt.optional(),noindex:jb.optional(),requiredChains:Gb.optional(),requiredCapabilities:Hb.optional(),castShareUrl:Pt.optional(),canonicalDomain:wb.optional()}).refine(t=>{if(t.castShareUrl===void 0)return!0;try{const e=new URL(t.homeUrl).hostname,n=new URL(t.castShareUrl).hostname;return e===n}catch{return!1}},{message:"castShareUrl must have the same domain as homeUrl",path:["castShareUrl"]});Et({accountAssociation:vb,miniapp:pf.optional(),frame:pf.optional()}).refine(t=>t.frame&&t.miniapp?JSON.stringify(t.frame)===JSON.stringify(t.miniapp):!0,{message:'If both "frame" and "miniapp" are provided, they must be identical',path:["frame","miniapp"]}).transform(t=>({...t,frame:t.frame??t.miniapp}));var oc={},Ms={},mf;function qb(){if(mf)return Ms;mf=1,Ms.byteLength=a,Ms.toByteArray=m,Ms.fromByteArray=O;for(var t=[],e=[],n=typeof Uint8Array<"u"?Uint8Array:Array,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,i=r.length;s<i;++s)t[s]=r[s],e[r.charCodeAt(s)]=s;e[45]=62,e[95]=63;function o(N){var F=N.length;if(F%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var C=N.indexOf("=");C===-1&&(C=F);var k=C===F?0:4-C%4;return[C,k]}function a(N){var F=o(N),C=F[0],k=F[1];return(C+k)*3/4-k}function d(N,F,C){return(F+C)*3/4-C}function m(N){var F,C=o(N),k=C[0],K=C[1],Y=new n(d(N,k,K)),V=0,L=K>0?k-4:k,z;for(z=0;z<L;z+=4)F=e[N.charCodeAt(z)]<<18|e[N.charCodeAt(z+1)]<<12|e[N.charCodeAt(z+2)]<<6|e[N.charCodeAt(z+3)],Y[V++]=F>>16&255,Y[V++]=F>>8&255,Y[V++]=F&255;return K===2&&(F=e[N.charCodeAt(z)]<<2|e[N.charCodeAt(z+1)]>>4,Y[V++]=F&255),K===1&&(F=e[N.charCodeAt(z)]<<10|e[N.charCodeAt(z+1)]<<4|e[N.charCodeAt(z+2)]>>2,Y[V++]=F>>8&255,Y[V++]=F&255),Y}function g(N){return t[N>>18&63]+t[N>>12&63]+t[N>>6&63]+t[N&63]}function x(N,F,C){for(var k,K=[],Y=F;Y<C;Y+=3)k=(N[Y]<<16&16711680)+(N[Y+1]<<8&65280)+(N[Y+2]&255),K.push(g(k));return K.join("")}function O(N){for(var F,C=N.length,k=C%3,K=[],Y=16383,V=0,L=C-k;V<L;V+=Y)K.push(x(N,V,V+Y>L?L:V+Y));return k===1?(F=N[C-1],K.push(t[F>>2]+t[F<<4&63]+"==")):k===2&&(F=(N[C-2]<<8)+N[C-1],K.push(t[F>>10]+t[F>>4&63]+t[F<<2&63]+"=")),K.join("")}return Ms}var Ui={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var gf;function Kb(){return gf||(gf=1,Ui.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,d=(1<<a)-1,m=d>>1,g=-7,x=n?s-1:0,O=n?-1:1,N=t[e+x];for(x+=O,i=N&(1<<-g)-1,N>>=-g,g+=a;g>0;i=i*256+t[e+x],x+=O,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=r;g>0;o=o*256+t[e+x],x+=O,g-=8);if(i===0)i=1-m;else{if(i===d)return o?NaN:(N?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-m}return(N?-1:1)*o*Math.pow(2,i-r)},Ui.write=function(t,e,n,r,s,i){var o,a,d,m=i*8-s-1,g=(1<<m)-1,x=g>>1,O=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=r?0:i-1,F=r?1:-1,C=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=g):(o=Math.floor(Math.log(e)/Math.LN2),e*(d=Math.pow(2,-o))<1&&(o--,d*=2),o+x>=1?e+=O/d:e+=O*Math.pow(2,1-x),e*d>=2&&(o++,d/=2),o+x>=g?(a=0,o=g):o+x>=1?(a=(e*d-1)*Math.pow(2,s),o=o+x):(a=e*Math.pow(2,x-1)*Math.pow(2,s),o=0));s>=8;t[n+N]=a&255,N+=F,a/=256,s-=8);for(o=o<<s|a,m+=s;m>0;t[n+N]=o&255,N+=F,o/=256,m-=8);t[n+N-F]|=C*128}),Ui}/*!
24
24
  * The buffer module from node.js, for the browser.
25
25
  *
26
26
  * @author Feross Aboukhadijeh <https://feross.org>
27
27
  * @license MIT
28
- */var gf;function oc(){return gf||(gf=1,(function(t){const e=qb(),n=Kb(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=Y,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const b=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(b,f),b.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(b){if(b>s)throw new RangeError('The value "'+b+'" is invalid for option "size"');const f=new Uint8Array(b);return Object.setPrototypeOf(f,a.prototype),f}function a(b,f,h){if(typeof b=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(b)}return d(b,f,h)}a.poolSize=8192;function d(b,f,h){if(typeof b=="string")return O(b,f);if(ArrayBuffer.isView(b))return F(b);if(b==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(Yt(b,ArrayBuffer)||b&&Yt(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Yt(b,SharedArrayBuffer)||b&&Yt(b.buffer,SharedArrayBuffer)))return M(b,f,h);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const S=b.valueOf&&b.valueOf();if(S!=null&&S!==b)return a.from(S,f,h);const U=k(b);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return a.from(b[Symbol.toPrimitive]("string"),f,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}a.from=function(b,f,h){return d(b,f,h)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function m(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function g(b,f,h){return m(b),b<=0?o(b):f!==void 0?typeof h=="string"?o(b).fill(f,h):o(b).fill(f):o(b)}a.alloc=function(b,f,h){return g(b,f,h)};function x(b){return m(b),o(b<0?0:K(b)|0)}a.allocUnsafe=function(b){return x(b)},a.allocUnsafeSlow=function(b){return x(b)};function O(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=z(b,f)|0;let S=o(h);const U=S.write(b,f);return U!==h&&(S=S.slice(0,U)),S}function N(b){const f=b.length<0?0:K(b.length)|0,h=o(f);for(let S=0;S<f;S+=1)h[S]=b[S]&255;return h}function F(b){if(Yt(b,Uint8Array)){const f=new Uint8Array(b);return M(f.buffer,f.byteOffset,f.byteLength)}return N(b)}function M(b,f,h){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(h||0))throw new RangeError('"length" is outside of buffer bounds');let S;return f===void 0&&h===void 0?S=new Uint8Array(b):h===void 0?S=new Uint8Array(b,f):S=new Uint8Array(b,f,h),Object.setPrototypeOf(S,a.prototype),S}function k(b){if(a.isBuffer(b)){const f=K(b.length)|0,h=o(f);return h.length===0||b.copy(h,0,0,f),h}if(b.length!==void 0)return typeof b.length!="number"||Ge(b.length)?o(0):N(b);if(b.type==="Buffer"&&Array.isArray(b.data))return N(b.data)}function K(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function Y(b){return+b!=b&&(b=0),a.alloc(+b)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,h){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Yt(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(f)||!a.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===h)return 0;let S=f.length,U=h.length;for(let $=0,Z=Math.min(S,U);$<Z;++$)if(f[$]!==h[$]){S=f[$],U=h[$];break}return S<U?-1:U<S?1:0},a.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(f,h){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let S;if(h===void 0)for(h=0,S=0;S<f.length;++S)h+=f[S].length;const U=a.allocUnsafe(h);let $=0;for(S=0;S<f.length;++S){let Z=f[S];if(Yt(Z,Uint8Array))$+Z.length>U.length?(a.isBuffer(Z)||(Z=a.from(Z)),Z.copy(U,$)):Uint8Array.prototype.set.call(U,Z,$);else if(a.isBuffer(Z))Z.copy(U,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Z.length}return U};function z(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||Yt(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);const h=b.length,S=arguments.length>2&&arguments[2]===!0;if(!S&&h===0)return 0;let U=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Le(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Fe(b).length;default:if(U)return S?-1:Le(b).length;f=(""+f).toLowerCase(),U=!0}}a.byteLength=z;function L(b,f,h){let S=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,f>>>=0,h<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return R(this,f,h);case"utf8":case"utf-8":return c(this,f,h);case"ascii":return A(this,f,h);case"latin1":case"binary":return v(this,f,h);case"base64":return E(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,f,h);default:if(S)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),S=!0}}a.prototype._isBuffer=!0;function j(b,f,h){const S=b[f];b[f]=b[h],b[h]=S}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<f;h+=2)j(this,h,h+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<f;h+=4)j(this,h,h+3),j(this,h+1,h+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<f;h+=8)j(this,h,h+7),j(this,h+1,h+6),j(this,h+2,h+5),j(this,h+3,h+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?c(this,0,f):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const h=t.INSPECT_MAX_BYTES;return f=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,h,S,U,$){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(h===void 0&&(h=0),S===void 0&&(S=f?f.length:0),U===void 0&&(U=0),$===void 0&&($=this.length),h<0||S>f.length||U<0||$>this.length)throw new RangeError("out of range index");if(U>=$&&h>=S)return 0;if(U>=$)return-1;if(h>=S)return 1;if(h>>>=0,S>>>=0,U>>>=0,$>>>=0,this===f)return 0;let Z=$-U,Re=S-h;const _e=Math.min(Z,Re),ge=this.slice(U,$),$e=f.slice(h,S);for(let he=0;he<_e;++he)if(ge[he]!==$e[he]){Z=ge[he],Re=$e[he];break}return Z<Re?-1:Re<Z?1:0};function J(b,f,h,S,U){if(b.length===0)return-1;if(typeof h=="string"?(S=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ge(h)&&(h=U?0:b.length-1),h<0&&(h=b.length+h),h>=b.length){if(U)return-1;h=b.length-1}else if(h<0)if(U)h=0;else return-1;if(typeof f=="string"&&(f=a.from(f,S)),a.isBuffer(f))return f.length===0?-1:te(b,f,h,S,U);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(b,f,h):Uint8Array.prototype.lastIndexOf.call(b,f,h):te(b,[f],h,S,U);throw new TypeError("val must be string, number or Buffer")}function te(b,f,h,S,U){let $=1,Z=b.length,Re=f.length;if(S!==void 0&&(S=String(S).toLowerCase(),S==="ucs2"||S==="ucs-2"||S==="utf16le"||S==="utf-16le")){if(b.length<2||f.length<2)return-1;$=2,Z/=2,Re/=2,h/=2}function _e($e,he){return $===1?$e[he]:$e.readUInt16BE(he*$)}let ge;if(U){let $e=-1;for(ge=h;ge<Z;ge++)if(_e(b,ge)===_e(f,$e===-1?0:ge-$e)){if($e===-1&&($e=ge),ge-$e+1===Re)return $e*$}else $e!==-1&&(ge-=ge-$e),$e=-1}else for(h+Re>Z&&(h=Z-Re),ge=h;ge>=0;ge--){let $e=!0;for(let he=0;he<Re;he++)if(_e(b,ge+he)!==_e(f,he)){$e=!1;break}if($e)return ge}return-1}a.prototype.includes=function(f,h,S){return this.indexOf(f,h,S)!==-1},a.prototype.indexOf=function(f,h,S){return J(this,f,h,S,!0)},a.prototype.lastIndexOf=function(f,h,S){return J(this,f,h,S,!1)};function ee(b,f,h,S){h=Number(h)||0;const U=b.length-h;S?(S=Number(S),S>U&&(S=U)):S=U;const $=f.length;S>$/2&&(S=$/2);let Z;for(Z=0;Z<S;++Z){const Re=parseInt(f.substr(Z*2,2),16);if(Ge(Re))return Z;b[h+Z]=Re}return Z}function V(b,f,h,S){return Pe(Le(f,b.length-h),b,h,S)}function C(b,f,h,S){return Pe(Ve(f),b,h,S)}function P(b,f,h,S){return Pe(Fe(f),b,h,S)}function q(b,f,h,S){return Pe(Zr(f,b.length-h),b,h,S)}a.prototype.write=function(f,h,S,U){if(h===void 0)U="utf8",S=this.length,h=0;else if(S===void 0&&typeof h=="string")U=h,S=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(S)?(S=S>>>0,U===void 0&&(U="utf8")):(U=S,S=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-h;if((S===void 0||S>$)&&(S=$),f.length>0&&(S<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Z=!1;for(;;)switch(U){case"hex":return ee(this,f,h,S);case"utf8":case"utf-8":return V(this,f,h,S);case"ascii":case"latin1":case"binary":return C(this,f,h,S);case"base64":return P(this,f,h,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,f,h,S);default:if(Z)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(b,f,h){return f===0&&h===b.length?e.fromByteArray(b):e.fromByteArray(b.slice(f,h))}function c(b,f,h){h=Math.min(b.length,h);const S=[];let U=f;for(;U<h;){const $=b[U];let Z=null,Re=$>239?4:$>223?3:$>191?2:1;if(U+Re<=h){let _e,ge,$e,he;switch(Re){case 1:$<128&&(Z=$);break;case 2:_e=b[U+1],(_e&192)===128&&(he=($&31)<<6|_e&63,he>127&&(Z=he));break;case 3:_e=b[U+1],ge=b[U+2],(_e&192)===128&&(ge&192)===128&&(he=($&15)<<12|(_e&63)<<6|ge&63,he>2047&&(he<55296||he>57343)&&(Z=he));break;case 4:_e=b[U+1],ge=b[U+2],$e=b[U+3],(_e&192)===128&&(ge&192)===128&&($e&192)===128&&(he=($&15)<<18|(_e&63)<<12|(ge&63)<<6|$e&63,he>65535&&he<1114112&&(Z=he))}}Z===null?(Z=65533,Re=1):Z>65535&&(Z-=65536,S.push(Z>>>10&1023|55296),Z=56320|Z&1023),S.push(Z),U+=Re}return y(S)}const p=4096;function y(b){const f=b.length;if(f<=p)return String.fromCharCode.apply(String,b);let h="",S=0;for(;S<f;)h+=String.fromCharCode.apply(String,b.slice(S,S+=p));return h}function A(b,f,h){let S="";h=Math.min(b.length,h);for(let U=f;U<h;++U)S+=String.fromCharCode(b[U]&127);return S}function v(b,f,h){let S="";h=Math.min(b.length,h);for(let U=f;U<h;++U)S+=String.fromCharCode(b[U]);return S}function R(b,f,h){const S=b.length;(!f||f<0)&&(f=0),(!h||h<0||h>S)&&(h=S);let U="";for(let $=f;$<h;++$)U+=Ze[b[$]];return U}function I(b,f,h){const S=b.slice(f,h);let U="";for(let $=0;$<S.length-1;$+=2)U+=String.fromCharCode(S[$]+S[$+1]*256);return U}a.prototype.slice=function(f,h){const S=this.length;f=~~f,h=h===void 0?S:~~h,f<0?(f+=S,f<0&&(f=0)):f>S&&(f=S),h<0?(h+=S,h<0&&(h=0)):h>S&&(h=S),h<f&&(h=f);const U=this.subarray(f,h);return Object.setPrototypeOf(U,a.prototype),U};function _(b,f,h){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+f>h)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)U+=this[f+Z]*$;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f+--h],$=1;for(;h>0&&($*=256);)U+=this[f+--h]*$;return U},a.prototype.readUint8=a.prototype.readUInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=on(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+S*2**24;return BigInt(U)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=on(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S;return(BigInt(U)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)U+=this[f+Z]*$;return $*=128,U>=$&&(U-=Math.pow(2,8*h)),U},a.prototype.readIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=h,$=1,Z=this[f+--U];for(;U>0&&($*=256);)Z+=this[f+--U]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*h)),Z},a.prototype.readInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,h){f=f>>>0,h||_(f,2,this.length);const S=this[f]|this[f+1]<<8;return S&32768?S|4294901760:S},a.prototype.readInt16BE=function(f,h){f=f>>>0,h||_(f,2,this.length);const S=this[f+1]|this[f]<<8;return S&32768?S|4294901760:S},a.prototype.readInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=on(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(S<<24);return(BigInt(U)<<BigInt(32))+BigInt(h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=on(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(U)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S)}),a.prototype.readFloatLE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!1,52,8)};function u(b,f,h,S,U,$){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>U||f<$)throw new RangeError('"value" argument is out of bounds');if(h+S>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,h,S,U){if(f=+f,h=h>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,h,S,Re,0)}let $=1,Z=0;for(this[h]=f&255;++Z<S&&($*=256);)this[h+Z]=f/$&255;return h+S},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,h,S,U){if(f=+f,h=h>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,h,S,Re,0)}let $=S-1,Z=1;for(this[h+$]=f&255;--$>=0&&(Z*=256);)this[h+$]=f/Z&255;return h+S},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,1,255,0),this[h]=f&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,65535,0),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,65535,0),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,4294967295,0),this[h+3]=f>>>24,this[h+2]=f>>>16,this[h+1]=f>>>8,this[h]=f&255,h+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,4294967295,0),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4};function l(b,f,h,S,U){we(f,S,U,b,h,7);let $=Number(f&BigInt(4294967295));b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,h}function w(b,f,h,S,U){we(f,S,U,b,h,7);let $=Number(f&BigInt(4294967295));b[h+7]=$,$=$>>8,b[h+6]=$,$=$>>8,b[h+5]=$,$=$>>8,b[h+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h+3]=Z,Z=Z>>8,b[h+2]=Z,Z=Z>>8,b[h+1]=Z,Z=Z>>8,b[h]=Z,h+8}a.prototype.writeBigUInt64LE=on(function(f,h=0){return l(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=on(function(f,h=0){return w(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,h,S,U){if(f=+f,h=h>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let $=0,Z=1,Re=0;for(this[h]=f&255;++$<S&&(Z*=256);)f<0&&Re===0&&this[h+$-1]!==0&&(Re=1),this[h+$]=(f/Z>>0)-Re&255;return h+S},a.prototype.writeIntBE=function(f,h,S,U){if(f=+f,h=h>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let $=S-1,Z=1,Re=0;for(this[h+$]=f&255;--$>=0&&(Z*=256);)f<0&&Re===0&&this[h+$+1]!==0&&(Re=1),this[h+$]=(f/Z>>0)-Re&255;return h+S},a.prototype.writeInt8=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,1,127,-128),f<0&&(f=255+f+1),this[h]=f&255,h+1},a.prototype.writeInt16LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,32767,-32768),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeInt16BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,32767,-32768),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeInt32LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,2147483647,-2147483648),this[h]=f&255,this[h+1]=f>>>8,this[h+2]=f>>>16,this[h+3]=f>>>24,h+4},a.prototype.writeInt32BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4},a.prototype.writeBigInt64LE=on(function(f,h=0){return l(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=on(function(f,h=0){return w(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function T(b,f,h,S,U,$){if(h+S>b.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function D(b,f,h,S,U){return f=+f,h=h>>>0,U||T(b,f,h,4),n.write(b,f,h,S,23,4),h+4}a.prototype.writeFloatLE=function(f,h,S){return D(this,f,h,!0,S)},a.prototype.writeFloatBE=function(f,h,S){return D(this,f,h,!1,S)};function W(b,f,h,S,U){return f=+f,h=h>>>0,U||T(b,f,h,8),n.write(b,f,h,S,52,8),h+8}a.prototype.writeDoubleLE=function(f,h,S){return W(this,f,h,!0,S)},a.prototype.writeDoubleBE=function(f,h,S){return W(this,f,h,!1,S)},a.prototype.copy=function(f,h,S,U){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(S||(S=0),!U&&U!==0&&(U=this.length),h>=f.length&&(h=f.length),h||(h=0),U>0&&U<S&&(U=S),U===S||f.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(S<0||S>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),f.length-h<U-S&&(U=f.length-h+S);const $=U-S;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,S,U):Uint8Array.prototype.set.call(f,this.subarray(S,U),h),$},a.prototype.fill=function(f,h,S,U){if(typeof f=="string"){if(typeof h=="string"?(U=h,h=0,S=this.length):typeof S=="string"&&(U=S,S=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(f.length===1){const Z=f.charCodeAt(0);(U==="utf8"&&Z<128||U==="latin1")&&(f=Z)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(h<0||this.length<h||this.length<S)throw new RangeError("Out of range index");if(S<=h)return this;h=h>>>0,S=S===void 0?this.length:S>>>0,f||(f=0);let $;if(typeof f=="number")for($=h;$<S;++$)this[$]=f;else{const Z=a.isBuffer(f)?f:a.from(f,U),Re=Z.length;if(Re===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<S-h;++$)this[$+h]=Z[$%Re]}return this};const re={};function oe(b,f,h){re[b]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${b}]`,this.stack,delete this.name}get code(){return b}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}oe("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),oe("ERR_INVALID_ARG_TYPE",function(b,f){return`The "${b}" argument must be of type number. Received type ${typeof f}`},TypeError),oe("ERR_OUT_OF_RANGE",function(b,f,h){let S=`The value of "${b}" is out of range.`,U=h;return Number.isInteger(h)&&Math.abs(h)>2**32?U=Ne(String(h)):typeof h=="bigint"&&(U=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(U=Ne(U)),U+="n"),S+=` It must be ${f}. Received ${U}`,S},RangeError);function Ne(b){let f="",h=b.length;const S=b[0]==="-"?1:0;for(;h>=S+4;h-=3)f=`_${b.slice(h-3,h)}${f}`;return`${b.slice(0,h)}${f}`}function Ee(b,f,h){De(f,"offset"),(b[f]===void 0||b[f+h]===void 0)&&ve(f,b.length-(h+1))}function we(b,f,h,S,U,$){if(b>h||b<f){const Z=typeof f=="bigint"?"n":"";let Re;throw f===0||f===BigInt(0)?Re=`>= 0${Z} and < 2${Z} ** ${($+1)*8}${Z}`:Re=`>= -(2${Z} ** ${($+1)*8-1}${Z}) and < 2 ** ${($+1)*8-1}${Z}`,new re.ERR_OUT_OF_RANGE("value",Re,b)}Ee(S,U,$)}function De(b,f){if(typeof b!="number")throw new re.ERR_INVALID_ARG_TYPE(f,"number",b)}function ve(b,f,h){throw Math.floor(b)!==b?(De(b,h),new re.ERR_OUT_OF_RANGE("offset","an integer",b)):f<0?new re.ERR_BUFFER_OUT_OF_BOUNDS:new re.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,b)}const Oe=/[^+/0-9A-Za-z-_]/g;function pn(b){if(b=b.split("=")[0],b=b.trim().replace(Oe,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function Le(b,f){f=f||1/0;let h;const S=b.length;let U=null;const $=[];for(let Z=0;Z<S;++Z){if(h=b.charCodeAt(Z),h>55295&&h<57344){if(!U){if(h>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===S){(f-=3)>-1&&$.push(239,191,189);continue}U=h;continue}if(h<56320){(f-=3)>-1&&$.push(239,191,189),U=h;continue}h=(U-55296<<10|h-56320)+65536}else U&&(f-=3)>-1&&$.push(239,191,189);if(U=null,h<128){if((f-=1)<0)break;$.push(h)}else if(h<2048){if((f-=2)<0)break;$.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;$.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;$.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return $}function Ve(b){const f=[];for(let h=0;h<b.length;++h)f.push(b.charCodeAt(h)&255);return f}function Zr(b,f){let h,S,U;const $=[];for(let Z=0;Z<b.length&&!((f-=2)<0);++Z)h=b.charCodeAt(Z),S=h>>8,U=h%256,$.push(U),$.push(S);return $}function Fe(b){return e.toByteArray(pn(b))}function Pe(b,f,h,S){let U;for(U=0;U<S&&!(U+h>=f.length||U>=b.length);++U)f[U+h]=b[U];return U}function Yt(b,f){return b instanceof f||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===f.name}function Ge(b){return b!==b}const Ze=(function(){const b="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const S=h*16;for(let U=0;U<16;++U)f[S+U]=b[h]+b[U]}return f})();function on(b){return typeof BigInt>"u"?Ye:b}function Ye(){throw new Error("BigInt not supported")}})(ic)),ic}var xe=oc();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const dn=BigInt(0),Ut=BigInt(1),yf=BigInt(2),Wb=BigInt(8),Zb={zip215:!0};function Yb(t){const e=ka(t);return Ss(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Jb(t){const e=Yb(t),{Fp:n,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:d}=e,m=yf<<BigInt(a*8)-Ut,g=n.create,x=Os(e.n,e.nBitLength);function O(v,R){const I=n.sqr(v),_=n.sqr(R),u=n.add(n.mul(e.a,I),_),l=n.add(n.ONE,n.mul(e.d,n.mul(I,_)));return n.eql(u,l)}if(!O(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const N=e.uvRatio||((v,R)=>{try{return{isValid:!0,value:n.sqrt(v*n.inv(R))}}catch{return{isValid:!1,value:dn}}}),F=e.adjustScalarBytes||(v=>v),M=e.domain||((v,R,I)=>{if(kn("phflag",I),R.length||I)throw new Error("Contexts/pre-hash are not supported");return v});function k(v,R,I=!1){const _=I?Ut:dn;tn("coordinate "+v,R,_,m)}function K(v){if(!(v instanceof L))throw new Error("ExtendedPoint expected")}const Y=bi((v,R)=>{const{ex:I,ey:_,ez:u}=v,l=v.is0();R==null&&(R=l?Wb:n.inv(u));const w=g(I*R),T=g(_*R),D=g(u*R);if(l)return{x:dn,y:Ut};if(D!==Ut)throw new Error("invZ was invalid");return{x:w,y:T}}),z=bi(v=>{const{a:R,d:I}=e;if(v.is0())throw new Error("bad point: ZERO");const{ex:_,ey:u,ez:l,et:w}=v,T=g(_*_),D=g(u*u),W=g(l*l),re=g(W*W),oe=g(T*R),Ne=g(W*g(oe+D)),Ee=g(re+g(I*g(T*D)));if(Ne!==Ee)throw new Error("bad point: equation left != right (1)");const we=g(_*u),De=g(l*w);if(we!==De)throw new Error("bad point: equation left != right (2)");return!0});class L{constructor(R,I,_,u){k("x",R),k("y",I),k("z",_,!0),k("t",u),this.ex=R,this.ey=I,this.ez=_,this.et=u,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof L)throw new Error("extended point not allowed");const{x:I,y:_}=R||{};return k("x",I),k("y",_),new L(I,_,Ut,g(I*_))}static normalizeZ(R){const I=Oa(n,R.map(_=>_.ez));return R.map((_,u)=>_.toAffine(I[u])).map(L.fromAffine)}static msm(R,I){return Cl(L,x,R,I)}_setWindowSize(R){te.setWindowSize(this,R)}assertValidity(){z(this)}equals(R){K(R);const{ex:I,ey:_,ez:u}=this,{ex:l,ey:w,ez:T}=R,D=g(I*T),W=g(l*u),re=g(_*T),oe=g(w*u);return D===W&&re===oe}is0(){return this.equals(L.ZERO)}negate(){return new L(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:R}=e,{ex:I,ey:_,ez:u}=this,l=g(I*I),w=g(_*_),T=g(yf*g(u*u)),D=g(R*l),W=I+_,re=g(g(W*W)-l-w),oe=D+w,Ne=oe-T,Ee=D-w,we=g(re*Ne),De=g(oe*Ee),ve=g(re*Ee),Oe=g(Ne*oe);return new L(we,De,Oe,ve)}add(R){K(R);const{a:I,d:_}=e,{ex:u,ey:l,ez:w,et:T}=this,{ex:D,ey:W,ez:re,et:oe}=R,Ne=g(u*D),Ee=g(l*W),we=g(T*_*oe),De=g(w*re),ve=g((u+l)*(D+W)-Ne-Ee),Oe=De-we,pn=De+we,Le=g(Ee-I*Ne),Ve=g(ve*Oe),Zr=g(pn*Le),Fe=g(ve*Le),Pe=g(Oe*pn);return new L(Ve,Zr,Pe,Fe)}subtract(R){return this.add(R.negate())}wNAF(R){return te.wNAFCached(this,R,L.normalizeZ)}multiply(R){const I=R;tn("scalar",I,Ut,r);const{p:_,f:u}=this.wNAF(I);return L.normalizeZ([_,u])[0]}multiplyUnsafe(R,I=L.ZERO){const _=R;return tn("scalar",_,dn,r),_===dn?J:this.is0()||_===Ut?this:te.wNAFCachedUnsafe(this,_,L.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return te.unsafeLadder(this,r).is0()}toAffine(R){return Y(this,R)}clearCofactor(){const{h:R}=e;return R===Ut?this:this.multiplyUnsafe(R)}static fromHex(R,I=!1){const{d:_,a:u}=e,l=n.BYTES;R=Je("pointHex",R,l),kn("zip215",I);const w=R.slice(),T=R[l-1];w[l-1]=T&-129;const D=As(w),W=I?m:n.ORDER;tn("pointHex.y",D,dn,W);const re=g(D*D),oe=g(re-Ut),Ne=g(_*re-u);let{isValid:Ee,value:we}=N(oe,Ne);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");const De=(we&Ut)===Ut,ve=(T&128)!==0;if(!I&&we===dn&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==De&&(we=g(-we)),L.fromAffine({x:we,y:D})}static fromPrivateKey(R){const{scalar:I}=C(R);return j.multiply(I)}toRawBytes(){const{x:R,y:I}=this.toAffine(),_=gi(I,n.BYTES);return _[_.length-1]|=R&Ut?128:0,_}toHex(){return Tr(this.toRawBytes())}}L.BASE=new L(e.Gx,e.Gy,Ut,g(e.Gx*e.Gy)),L.ZERO=new L(dn,Ut,Ut,dn);const{BASE:j,ZERO:J}=L,te=Nl(L,a*8);function ee(v){return je(v,r)}function V(v){return ee(As(v))}function C(v){const R=n.BYTES;v=Je("private key",v,R);const I=Je("hashed private key",i(v),2*R),_=F(I.slice(0,R)),u=I.slice(R,2*R),l=V(_);return{head:_,prefix:u,scalar:l}}function P(v){const{head:R,prefix:I,scalar:_}=C(v),u=j.multiply(_),l=u.toRawBytes();return{head:R,prefix:I,scalar:_,point:u,pointBytes:l}}function q(v){return P(v).pointBytes}function E(v=Uint8Array.of(),...R){const I=Or(...R);return V(i(M(I,Je("context",v),!!s)))}function c(v,R,I={}){v=Je("message",v),s&&(v=s(v));const{prefix:_,scalar:u,pointBytes:l}=P(R),w=E(I.context,_,v),T=j.multiply(w).toRawBytes(),D=E(I.context,T,l,v),W=ee(w+D*u);tn("signature.s",W,dn,r);const re=Or(T,gi(W,n.BYTES));return Je("result",re,n.BYTES*2)}const p=Zb;function y(v,R,I,_=p){const{context:u,zip215:l}=_,w=n.BYTES;v=Je("signature",v,2*w),R=Je("message",R),I=Je("publicKey",I,w),l!==void 0&&kn("zip215",l),s&&(R=s(R));const T=As(v.slice(w,2*w));let D,W,re;try{D=L.fromHex(I,l),W=L.fromHex(v.slice(0,w),l),re=j.multiplyUnsafe(T)}catch{return!1}if(!l&&D.isSmallOrder())return!1;const oe=E(u,W.toRawBytes(),D.toRawBytes(),R);return W.add(D.multiplyUnsafe(oe)).subtract(re).clearCofactor().equals(L.ZERO)}return j._setWindowSize(8),{CURVE:e,getPublicKey:q,sign:c,verify:y,ExtendedPoint:L,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(n.BYTES),precompute(v=8,R=L.BASE){return R._setWindowSize(v),R.multiply(BigInt(3)),R}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ac=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),bf=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Xb=BigInt(1),_f=BigInt(2);BigInt(3);const Qb=BigInt(5),e_=BigInt(8);function t_(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),i=ac,a=t*t%i*t%i,d=qe(a,_f,i)*a%i,m=qe(d,Xb,i)*t%i,g=qe(m,Qb,i)*m%i,x=qe(g,e,i)*g%i,O=qe(x,n,i)*x%i,N=qe(O,r,i)*O%i,F=qe(N,s,i)*N%i,M=qe(F,s,i)*N%i,k=qe(M,e,i)*g%i;return{pow_p_5_8:qe(k,_f,i)*t%i,b2:a}}function n_(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function r_(t,e){const n=ac,r=je(e*e*e,n),s=je(r*r*e,n),i=t_(t*s).pow_p_5_8;let o=je(t*r*i,n);const a=je(e*o*o,n),d=o,m=je(o*bf,n),g=a===t,x=a===je(-t,n),O=a===je(-t*bf,n);return g&&(o=d),(x||O)&&(o=m),Qy(o,n)&&(o=je(-o,n)),{isValid:g||x,value:o}}const wf=Os(ac,void 0,!0),s_={a:wf.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:wf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:e_,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:My,randomBytes:wd,adjustScalarBytes:n_,uvRatio:r_},cc=Jb(s_);var Di={exports:{}};const i_=Ga(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var o_=Di.exports,Ef;function vf(){return Ef||(Ef=1,(function(t){(function(e,n){function r(E,c){if(!E)throw new Error(c||"Assertion failed")}function s(E,c){E.super_=c;var p=function(){};p.prototype=c.prototype,E.prototype=new p,E.prototype.constructor=E}function i(E,c,p){if(i.isBN(E))return E;this.negative=0,this.words=null,this.length=0,this.red=null,E!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(E||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:n.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=i_.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,y){if(typeof c=="number")return this._initNumber(c,p,y);if(typeof c=="object")return this._initArray(c,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(p===16?this._parseHex(c,A,y):(this._parseBase(c,p,A),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(c,p,y){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(c,p,y){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v,R,I=0;if(y==="be")for(A=c.length-1,v=0;A>=0;A-=3)R=c[A]|c[A-1]<<8|c[A-2]<<16,this.words[v]|=R<<I&67108863,this.words[v+1]=R>>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);else if(y==="le")for(A=0,v=0;A<c.length;A+=3)R=c[A]|c[A+1]<<8|c[A+2]<<16,this.words[v]|=R<<I&67108863,this.words[v+1]=R>>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);return this._strip()};function a(E,c){var p=E.charCodeAt(c);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+E)}function d(E,c,p){var y=a(E,p);return p-1>=c&&(y|=a(E,p-1)<<4),y}i.prototype._parseHex=function(c,p,y){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v=0,R=0,I;if(y==="be")for(A=c.length-1;A>=p;A-=2)I=d(c,p,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8;else{var _=c.length-p;for(A=_%2===0?p+1:p;A<c.length;A+=2)I=d(c,p,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8}this._strip()};function m(E,c,p,y){for(var A=0,v=0,R=Math.min(E.length,p),I=c;I<R;I++){var _=E.charCodeAt(I)-48;A*=y,_>=49?v=_-49+10:_>=17?v=_-17+10:v=_,r(_>=0&&v<y,"Invalid character"),A+=v}return A}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var A=0,v=1;v<=67108863;v*=p)A++;A--,v=v/p|0;for(var R=c.length-y,I=R%A,_=Math.min(R,R-I)+y,u=0,l=y;l<_;l+=A)u=m(c,l,l+A,p),this.imuln(v),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(I!==0){var w=1;for(u=m(c,l,c.length,p),l=0;l<I;l++)w*=p;this.imuln(w),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function g(E,c){E.words=c.words,E.length=c.length,E.negative=c.negative,E.red=c.red}if(i.prototype._move=function(c){g(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=x}catch{i.prototype.inspect=x}else i.prototype.inspect=x;function x(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var O=["","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"],N=[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];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var y;if(c===16||c==="hex"){y="";for(var A=0,v=0,R=0;R<this.length;R++){var I=this.words[R],_=((I<<A|v)&16777215).toString(16);v=I>>>24-A&16777215,A+=2,A>=26&&(A-=26,R--),v!==0||R!==this.length-1?y=O[6-_.length]+_+y:y=_+y}for(v!==0&&(y=v.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(c===(c|0)&&c>=2&&c<=36){var u=N[c],l=F[c];y="";var w=this.clone();for(w.negative=0;!w.isZero();){var T=w.modrn(l).toString(c);w=w.idivn(l),w.isZero()?y=T+y:y=O[u-T.length]+T+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var M=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,y){this._strip();var A=this.byteLength(),v=y||Math.max(1,A);r(A<=v,"byte array longer than desired length"),r(v>0,"Requested array length <= 0");var R=M(c,v),I=p==="le"?"LE":"BE";return this["_toArrayLike"+I](R,A),R},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,A=0,v=0,R=0;v<this.length;v++){var I=this.words[v]<<R|A;c[y++]=I&255,y<c.length&&(c[y++]=I>>8&255),y<c.length&&(c[y++]=I>>16&255),R===6?(y<c.length&&(c[y++]=I>>24&255),A=0,R=0):(A=I>>>24,R+=2)}if(y<c.length)for(c[y++]=A;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,A=0,v=0,R=0;v<this.length;v++){var I=this.words[v]<<R|A;c[y--]=I&255,y>=0&&(c[y--]=I>>8&255),y>=0&&(c[y--]=I>>16&255),R===6?(y>=0&&(c[y--]=I>>24&255),A=0,R=0):(A=I>>>24,R+=2)}if(y>=0)for(c[y--]=A;y>=0;)c[y--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function k(E){for(var c=new Array(E.bitLength()),p=0;p<c.length;p++){var y=p/26|0,A=p%26;c[p]=E.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(c+=y,y!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,y;this.length>c.length?(p=this,y=c):(p=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=p.words[A]^y.words[A];if(this!==p)for(;A<p.length;A++)this.words[A]=p.words[A];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,y=c%26;this._expand(p),y>0&&p--;for(var A=0;A<p;A++)this.words[A]=~this.words[A]&67108863;return y>0&&(this.words[A]=~this.words[A]&67108863>>26-y),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var y,A;this.length>c.length?(y=this,A=c):(y=c,A=this);for(var v=0,R=0;R<A.length;R++)p=(y.words[R]|0)+(A.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;for(;v!==0&&R<y.length;R++)p=(y.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;if(this.length=y.length,v!==0)this.words[this.length]=v,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var y=this.cmp(c);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,v;y>0?(A=this,v=c):(A=c,v=this);for(var R=0,I=0;I<v.length;I++)p=(A.words[I]|0)-(v.words[I]|0)+R,R=p>>26,this.words[I]=p&67108863;for(;R!==0&&I<A.length;I++)p=(A.words[I]|0)+R,R=p>>26,this.words[I]=p&67108863;if(R===0&&I<A.length&&A!==this)for(;I<A.length;I++)this.words[I]=A.words[I];return this.length=Math.max(this.length,I),A!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function K(E,c,p){p.negative=c.negative^E.negative;var y=E.length+c.length|0;p.length=y,y=y-1|0;var A=E.words[0]|0,v=c.words[0]|0,R=A*v,I=R&67108863,_=R/67108864|0;p.words[0]=I;for(var u=1;u<y;u++){for(var l=_>>>26,w=_&67108863,T=Math.min(u,c.length-1),D=Math.max(0,u-E.length+1);D<=T;D++){var W=u-D|0;A=E.words[W]|0,v=c.words[D]|0,R=A*v+w,l+=R/67108864|0,w=R&67108863}p.words[u]=w|0,_=l|0}return _!==0?p.words[u]=_|0:p.length--,p._strip()}var Y=function(c,p,y){var A=c.words,v=p.words,R=y.words,I=0,_,u,l,w=A[0]|0,T=w&8191,D=w>>>13,W=A[1]|0,re=W&8191,oe=W>>>13,Ne=A[2]|0,Ee=Ne&8191,we=Ne>>>13,De=A[3]|0,ve=De&8191,Oe=De>>>13,pn=A[4]|0,Le=pn&8191,Ve=pn>>>13,Zr=A[5]|0,Fe=Zr&8191,Pe=Zr>>>13,Yt=A[6]|0,Ge=Yt&8191,Ze=Yt>>>13,on=A[7]|0,Ye=on&8191,b=on>>>13,f=A[8]|0,h=f&8191,S=f>>>13,U=A[9]|0,$=U&8191,Z=U>>>13,Re=v[0]|0,_e=Re&8191,ge=Re>>>13,$e=v[1]|0,he=$e&8191,et=$e>>>13,E0=v[2]|0,tt=E0&8191,nt=E0>>>13,v0=v[3]|0,rt=v0&8191,st=v0>>>13,R0=v[4]|0,it=R0&8191,ot=R0>>>13,A0=v[5]|0,at=A0&8191,ct=A0>>>13,x0=v[6]|0,ut=x0&8191,dt=x0>>>13,S0=v[7]|0,lt=S0&8191,ft=S0>>>13,T0=v[8]|0,ht=T0&8191,pt=T0>>>13,O0=v[9]|0,mt=O0&8191,gt=O0>>>13;y.negative=c.negative^p.negative,y.length=19,_=Math.imul(T,_e),u=Math.imul(T,ge),u=u+Math.imul(D,_e)|0,l=Math.imul(D,ge);var Xc=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(Xc>>>26)|0,Xc&=67108863,_=Math.imul(re,_e),u=Math.imul(re,ge),u=u+Math.imul(oe,_e)|0,l=Math.imul(oe,ge),_=_+Math.imul(T,he)|0,u=u+Math.imul(T,et)|0,u=u+Math.imul(D,he)|0,l=l+Math.imul(D,et)|0;var Qc=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(Ee,_e),u=Math.imul(Ee,ge),u=u+Math.imul(we,_e)|0,l=Math.imul(we,ge),_=_+Math.imul(re,he)|0,u=u+Math.imul(re,et)|0,u=u+Math.imul(oe,he)|0,l=l+Math.imul(oe,et)|0,_=_+Math.imul(T,tt)|0,u=u+Math.imul(T,nt)|0,u=u+Math.imul(D,tt)|0,l=l+Math.imul(D,nt)|0;var eu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(eu>>>26)|0,eu&=67108863,_=Math.imul(ve,_e),u=Math.imul(ve,ge),u=u+Math.imul(Oe,_e)|0,l=Math.imul(Oe,ge),_=_+Math.imul(Ee,he)|0,u=u+Math.imul(Ee,et)|0,u=u+Math.imul(we,he)|0,l=l+Math.imul(we,et)|0,_=_+Math.imul(re,tt)|0,u=u+Math.imul(re,nt)|0,u=u+Math.imul(oe,tt)|0,l=l+Math.imul(oe,nt)|0,_=_+Math.imul(T,rt)|0,u=u+Math.imul(T,st)|0,u=u+Math.imul(D,rt)|0,l=l+Math.imul(D,st)|0;var tu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(tu>>>26)|0,tu&=67108863,_=Math.imul(Le,_e),u=Math.imul(Le,ge),u=u+Math.imul(Ve,_e)|0,l=Math.imul(Ve,ge),_=_+Math.imul(ve,he)|0,u=u+Math.imul(ve,et)|0,u=u+Math.imul(Oe,he)|0,l=l+Math.imul(Oe,et)|0,_=_+Math.imul(Ee,tt)|0,u=u+Math.imul(Ee,nt)|0,u=u+Math.imul(we,tt)|0,l=l+Math.imul(we,nt)|0,_=_+Math.imul(re,rt)|0,u=u+Math.imul(re,st)|0,u=u+Math.imul(oe,rt)|0,l=l+Math.imul(oe,st)|0,_=_+Math.imul(T,it)|0,u=u+Math.imul(T,ot)|0,u=u+Math.imul(D,it)|0,l=l+Math.imul(D,ot)|0;var nu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(nu>>>26)|0,nu&=67108863,_=Math.imul(Fe,_e),u=Math.imul(Fe,ge),u=u+Math.imul(Pe,_e)|0,l=Math.imul(Pe,ge),_=_+Math.imul(Le,he)|0,u=u+Math.imul(Le,et)|0,u=u+Math.imul(Ve,he)|0,l=l+Math.imul(Ve,et)|0,_=_+Math.imul(ve,tt)|0,u=u+Math.imul(ve,nt)|0,u=u+Math.imul(Oe,tt)|0,l=l+Math.imul(Oe,nt)|0,_=_+Math.imul(Ee,rt)|0,u=u+Math.imul(Ee,st)|0,u=u+Math.imul(we,rt)|0,l=l+Math.imul(we,st)|0,_=_+Math.imul(re,it)|0,u=u+Math.imul(re,ot)|0,u=u+Math.imul(oe,it)|0,l=l+Math.imul(oe,ot)|0,_=_+Math.imul(T,at)|0,u=u+Math.imul(T,ct)|0,u=u+Math.imul(D,at)|0,l=l+Math.imul(D,ct)|0;var ru=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(ru>>>26)|0,ru&=67108863,_=Math.imul(Ge,_e),u=Math.imul(Ge,ge),u=u+Math.imul(Ze,_e)|0,l=Math.imul(Ze,ge),_=_+Math.imul(Fe,he)|0,u=u+Math.imul(Fe,et)|0,u=u+Math.imul(Pe,he)|0,l=l+Math.imul(Pe,et)|0,_=_+Math.imul(Le,tt)|0,u=u+Math.imul(Le,nt)|0,u=u+Math.imul(Ve,tt)|0,l=l+Math.imul(Ve,nt)|0,_=_+Math.imul(ve,rt)|0,u=u+Math.imul(ve,st)|0,u=u+Math.imul(Oe,rt)|0,l=l+Math.imul(Oe,st)|0,_=_+Math.imul(Ee,it)|0,u=u+Math.imul(Ee,ot)|0,u=u+Math.imul(we,it)|0,l=l+Math.imul(we,ot)|0,_=_+Math.imul(re,at)|0,u=u+Math.imul(re,ct)|0,u=u+Math.imul(oe,at)|0,l=l+Math.imul(oe,ct)|0,_=_+Math.imul(T,ut)|0,u=u+Math.imul(T,dt)|0,u=u+Math.imul(D,ut)|0,l=l+Math.imul(D,dt)|0;var su=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(su>>>26)|0,su&=67108863,_=Math.imul(Ye,_e),u=Math.imul(Ye,ge),u=u+Math.imul(b,_e)|0,l=Math.imul(b,ge),_=_+Math.imul(Ge,he)|0,u=u+Math.imul(Ge,et)|0,u=u+Math.imul(Ze,he)|0,l=l+Math.imul(Ze,et)|0,_=_+Math.imul(Fe,tt)|0,u=u+Math.imul(Fe,nt)|0,u=u+Math.imul(Pe,tt)|0,l=l+Math.imul(Pe,nt)|0,_=_+Math.imul(Le,rt)|0,u=u+Math.imul(Le,st)|0,u=u+Math.imul(Ve,rt)|0,l=l+Math.imul(Ve,st)|0,_=_+Math.imul(ve,it)|0,u=u+Math.imul(ve,ot)|0,u=u+Math.imul(Oe,it)|0,l=l+Math.imul(Oe,ot)|0,_=_+Math.imul(Ee,at)|0,u=u+Math.imul(Ee,ct)|0,u=u+Math.imul(we,at)|0,l=l+Math.imul(we,ct)|0,_=_+Math.imul(re,ut)|0,u=u+Math.imul(re,dt)|0,u=u+Math.imul(oe,ut)|0,l=l+Math.imul(oe,dt)|0,_=_+Math.imul(T,lt)|0,u=u+Math.imul(T,ft)|0,u=u+Math.imul(D,lt)|0,l=l+Math.imul(D,ft)|0;var iu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(iu>>>26)|0,iu&=67108863,_=Math.imul(h,_e),u=Math.imul(h,ge),u=u+Math.imul(S,_e)|0,l=Math.imul(S,ge),_=_+Math.imul(Ye,he)|0,u=u+Math.imul(Ye,et)|0,u=u+Math.imul(b,he)|0,l=l+Math.imul(b,et)|0,_=_+Math.imul(Ge,tt)|0,u=u+Math.imul(Ge,nt)|0,u=u+Math.imul(Ze,tt)|0,l=l+Math.imul(Ze,nt)|0,_=_+Math.imul(Fe,rt)|0,u=u+Math.imul(Fe,st)|0,u=u+Math.imul(Pe,rt)|0,l=l+Math.imul(Pe,st)|0,_=_+Math.imul(Le,it)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(Ve,it)|0,l=l+Math.imul(Ve,ot)|0,_=_+Math.imul(ve,at)|0,u=u+Math.imul(ve,ct)|0,u=u+Math.imul(Oe,at)|0,l=l+Math.imul(Oe,ct)|0,_=_+Math.imul(Ee,ut)|0,u=u+Math.imul(Ee,dt)|0,u=u+Math.imul(we,ut)|0,l=l+Math.imul(we,dt)|0,_=_+Math.imul(re,lt)|0,u=u+Math.imul(re,ft)|0,u=u+Math.imul(oe,lt)|0,l=l+Math.imul(oe,ft)|0,_=_+Math.imul(T,ht)|0,u=u+Math.imul(T,pt)|0,u=u+Math.imul(D,ht)|0,l=l+Math.imul(D,pt)|0;var ou=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(ou>>>26)|0,ou&=67108863,_=Math.imul($,_e),u=Math.imul($,ge),u=u+Math.imul(Z,_e)|0,l=Math.imul(Z,ge),_=_+Math.imul(h,he)|0,u=u+Math.imul(h,et)|0,u=u+Math.imul(S,he)|0,l=l+Math.imul(S,et)|0,_=_+Math.imul(Ye,tt)|0,u=u+Math.imul(Ye,nt)|0,u=u+Math.imul(b,tt)|0,l=l+Math.imul(b,nt)|0,_=_+Math.imul(Ge,rt)|0,u=u+Math.imul(Ge,st)|0,u=u+Math.imul(Ze,rt)|0,l=l+Math.imul(Ze,st)|0,_=_+Math.imul(Fe,it)|0,u=u+Math.imul(Fe,ot)|0,u=u+Math.imul(Pe,it)|0,l=l+Math.imul(Pe,ot)|0,_=_+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(Ve,at)|0,l=l+Math.imul(Ve,ct)|0,_=_+Math.imul(ve,ut)|0,u=u+Math.imul(ve,dt)|0,u=u+Math.imul(Oe,ut)|0,l=l+Math.imul(Oe,dt)|0,_=_+Math.imul(Ee,lt)|0,u=u+Math.imul(Ee,ft)|0,u=u+Math.imul(we,lt)|0,l=l+Math.imul(we,ft)|0,_=_+Math.imul(re,ht)|0,u=u+Math.imul(re,pt)|0,u=u+Math.imul(oe,ht)|0,l=l+Math.imul(oe,pt)|0,_=_+Math.imul(T,mt)|0,u=u+Math.imul(T,gt)|0,u=u+Math.imul(D,mt)|0,l=l+Math.imul(D,gt)|0;var au=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(au>>>26)|0,au&=67108863,_=Math.imul($,he),u=Math.imul($,et),u=u+Math.imul(Z,he)|0,l=Math.imul(Z,et),_=_+Math.imul(h,tt)|0,u=u+Math.imul(h,nt)|0,u=u+Math.imul(S,tt)|0,l=l+Math.imul(S,nt)|0,_=_+Math.imul(Ye,rt)|0,u=u+Math.imul(Ye,st)|0,u=u+Math.imul(b,rt)|0,l=l+Math.imul(b,st)|0,_=_+Math.imul(Ge,it)|0,u=u+Math.imul(Ge,ot)|0,u=u+Math.imul(Ze,it)|0,l=l+Math.imul(Ze,ot)|0,_=_+Math.imul(Fe,at)|0,u=u+Math.imul(Fe,ct)|0,u=u+Math.imul(Pe,at)|0,l=l+Math.imul(Pe,ct)|0,_=_+Math.imul(Le,ut)|0,u=u+Math.imul(Le,dt)|0,u=u+Math.imul(Ve,ut)|0,l=l+Math.imul(Ve,dt)|0,_=_+Math.imul(ve,lt)|0,u=u+Math.imul(ve,ft)|0,u=u+Math.imul(Oe,lt)|0,l=l+Math.imul(Oe,ft)|0,_=_+Math.imul(Ee,ht)|0,u=u+Math.imul(Ee,pt)|0,u=u+Math.imul(we,ht)|0,l=l+Math.imul(we,pt)|0,_=_+Math.imul(re,mt)|0,u=u+Math.imul(re,gt)|0,u=u+Math.imul(oe,mt)|0,l=l+Math.imul(oe,gt)|0;var cu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(cu>>>26)|0,cu&=67108863,_=Math.imul($,tt),u=Math.imul($,nt),u=u+Math.imul(Z,tt)|0,l=Math.imul(Z,nt),_=_+Math.imul(h,rt)|0,u=u+Math.imul(h,st)|0,u=u+Math.imul(S,rt)|0,l=l+Math.imul(S,st)|0,_=_+Math.imul(Ye,it)|0,u=u+Math.imul(Ye,ot)|0,u=u+Math.imul(b,it)|0,l=l+Math.imul(b,ot)|0,_=_+Math.imul(Ge,at)|0,u=u+Math.imul(Ge,ct)|0,u=u+Math.imul(Ze,at)|0,l=l+Math.imul(Ze,ct)|0,_=_+Math.imul(Fe,ut)|0,u=u+Math.imul(Fe,dt)|0,u=u+Math.imul(Pe,ut)|0,l=l+Math.imul(Pe,dt)|0,_=_+Math.imul(Le,lt)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(Ve,lt)|0,l=l+Math.imul(Ve,ft)|0,_=_+Math.imul(ve,ht)|0,u=u+Math.imul(ve,pt)|0,u=u+Math.imul(Oe,ht)|0,l=l+Math.imul(Oe,pt)|0,_=_+Math.imul(Ee,mt)|0,u=u+Math.imul(Ee,gt)|0,u=u+Math.imul(we,mt)|0,l=l+Math.imul(we,gt)|0;var uu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(uu>>>26)|0,uu&=67108863,_=Math.imul($,rt),u=Math.imul($,st),u=u+Math.imul(Z,rt)|0,l=Math.imul(Z,st),_=_+Math.imul(h,it)|0,u=u+Math.imul(h,ot)|0,u=u+Math.imul(S,it)|0,l=l+Math.imul(S,ot)|0,_=_+Math.imul(Ye,at)|0,u=u+Math.imul(Ye,ct)|0,u=u+Math.imul(b,at)|0,l=l+Math.imul(b,ct)|0,_=_+Math.imul(Ge,ut)|0,u=u+Math.imul(Ge,dt)|0,u=u+Math.imul(Ze,ut)|0,l=l+Math.imul(Ze,dt)|0,_=_+Math.imul(Fe,lt)|0,u=u+Math.imul(Fe,ft)|0,u=u+Math.imul(Pe,lt)|0,l=l+Math.imul(Pe,ft)|0,_=_+Math.imul(Le,ht)|0,u=u+Math.imul(Le,pt)|0,u=u+Math.imul(Ve,ht)|0,l=l+Math.imul(Ve,pt)|0,_=_+Math.imul(ve,mt)|0,u=u+Math.imul(ve,gt)|0,u=u+Math.imul(Oe,mt)|0,l=l+Math.imul(Oe,gt)|0;var du=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(du>>>26)|0,du&=67108863,_=Math.imul($,it),u=Math.imul($,ot),u=u+Math.imul(Z,it)|0,l=Math.imul(Z,ot),_=_+Math.imul(h,at)|0,u=u+Math.imul(h,ct)|0,u=u+Math.imul(S,at)|0,l=l+Math.imul(S,ct)|0,_=_+Math.imul(Ye,ut)|0,u=u+Math.imul(Ye,dt)|0,u=u+Math.imul(b,ut)|0,l=l+Math.imul(b,dt)|0,_=_+Math.imul(Ge,lt)|0,u=u+Math.imul(Ge,ft)|0,u=u+Math.imul(Ze,lt)|0,l=l+Math.imul(Ze,ft)|0,_=_+Math.imul(Fe,ht)|0,u=u+Math.imul(Fe,pt)|0,u=u+Math.imul(Pe,ht)|0,l=l+Math.imul(Pe,pt)|0,_=_+Math.imul(Le,mt)|0,u=u+Math.imul(Le,gt)|0,u=u+Math.imul(Ve,mt)|0,l=l+Math.imul(Ve,gt)|0;var lu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(lu>>>26)|0,lu&=67108863,_=Math.imul($,at),u=Math.imul($,ct),u=u+Math.imul(Z,at)|0,l=Math.imul(Z,ct),_=_+Math.imul(h,ut)|0,u=u+Math.imul(h,dt)|0,u=u+Math.imul(S,ut)|0,l=l+Math.imul(S,dt)|0,_=_+Math.imul(Ye,lt)|0,u=u+Math.imul(Ye,ft)|0,u=u+Math.imul(b,lt)|0,l=l+Math.imul(b,ft)|0,_=_+Math.imul(Ge,ht)|0,u=u+Math.imul(Ge,pt)|0,u=u+Math.imul(Ze,ht)|0,l=l+Math.imul(Ze,pt)|0,_=_+Math.imul(Fe,mt)|0,u=u+Math.imul(Fe,gt)|0,u=u+Math.imul(Pe,mt)|0,l=l+Math.imul(Pe,gt)|0;var fu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(fu>>>26)|0,fu&=67108863,_=Math.imul($,ut),u=Math.imul($,dt),u=u+Math.imul(Z,ut)|0,l=Math.imul(Z,dt),_=_+Math.imul(h,lt)|0,u=u+Math.imul(h,ft)|0,u=u+Math.imul(S,lt)|0,l=l+Math.imul(S,ft)|0,_=_+Math.imul(Ye,ht)|0,u=u+Math.imul(Ye,pt)|0,u=u+Math.imul(b,ht)|0,l=l+Math.imul(b,pt)|0,_=_+Math.imul(Ge,mt)|0,u=u+Math.imul(Ge,gt)|0,u=u+Math.imul(Ze,mt)|0,l=l+Math.imul(Ze,gt)|0;var hu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(hu>>>26)|0,hu&=67108863,_=Math.imul($,lt),u=Math.imul($,ft),u=u+Math.imul(Z,lt)|0,l=Math.imul(Z,ft),_=_+Math.imul(h,ht)|0,u=u+Math.imul(h,pt)|0,u=u+Math.imul(S,ht)|0,l=l+Math.imul(S,pt)|0,_=_+Math.imul(Ye,mt)|0,u=u+Math.imul(Ye,gt)|0,u=u+Math.imul(b,mt)|0,l=l+Math.imul(b,gt)|0;var pu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(pu>>>26)|0,pu&=67108863,_=Math.imul($,ht),u=Math.imul($,pt),u=u+Math.imul(Z,ht)|0,l=Math.imul(Z,pt),_=_+Math.imul(h,mt)|0,u=u+Math.imul(h,gt)|0,u=u+Math.imul(S,mt)|0,l=l+Math.imul(S,gt)|0;var mu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(mu>>>26)|0,mu&=67108863,_=Math.imul($,mt),u=Math.imul($,gt),u=u+Math.imul(Z,mt)|0,l=Math.imul(Z,gt);var gu=(I+_|0)+((u&8191)<<13)|0;return I=(l+(u>>>13)|0)+(gu>>>26)|0,gu&=67108863,R[0]=Xc,R[1]=Qc,R[2]=eu,R[3]=tu,R[4]=nu,R[5]=ru,R[6]=su,R[7]=iu,R[8]=ou,R[9]=au,R[10]=cu,R[11]=uu,R[12]=du,R[13]=lu,R[14]=fu,R[15]=hu,R[16]=pu,R[17]=mu,R[18]=gu,I!==0&&(R[19]=I,y.length++),y};Math.imul||(Y=K);function z(E,c,p){p.negative=c.negative^E.negative,p.length=E.length+c.length;for(var y=0,A=0,v=0;v<p.length-1;v++){var R=A;A=0;for(var I=y&67108863,_=Math.min(v,c.length-1),u=Math.max(0,v-E.length+1);u<=_;u++){var l=v-u,w=E.words[l]|0,T=c.words[u]|0,D=w*T,W=D&67108863;R=R+(D/67108864|0)|0,W=W+I|0,I=W&67108863,R=R+(W>>>26)|0,A+=R>>>26,R&=67108863}p.words[v]=I,y=R,R=A}return y!==0?p.words[v]=y:p.length--,p._strip()}function L(E,c,p){return z(E,c,p)}i.prototype.mulTo=function(c,p){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=Y(this,c,p):A<63?y=K(this,c,p):A<1024?y=z(this,c,p):y=L(this,c,p),y},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),L(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var y=0,A=0;A<this.length;A++){var v=(this.words[A]|0)*c,R=(v&67108863)+(y&67108863);y>>=26,y+=v/67108864|0,y+=R>>>26,this.words[A]=R&67108863}return y!==0&&(this.words[A]=y,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=k(c);if(p.length===0)return new i(1);for(var y=this,A=0;A<p.length&&p[A]===0;A++,y=y.sqr());if(++A<p.length)for(var v=y.sqr();A<p.length;A++,v=v.sqr())p[A]!==0&&(y=y.mul(v));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=67108863>>>26-p<<26-p,v;if(p!==0){var R=0;for(v=0;v<this.length;v++){var I=this.words[v]&A,_=(this.words[v]|0)-I<<p;this.words[v]=_|R,R=I>>>26-p}R&&(this.words[v]=R,this.length++)}if(y!==0){for(v=this.length-1;v>=0;v--)this.words[v+y]=this.words[v];for(v=0;v<y;v++)this.words[v]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,y){r(typeof c=="number"&&c>=0);var A;p?A=(p-p%26)/26:A=0;var v=c%26,R=Math.min((c-v)/26,this.length),I=67108863^67108863>>>v<<v,_=y;if(A-=R,A=Math.max(0,A),_){for(var u=0;u<R;u++)_.words[u]=this.words[u];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,u=0;u<this.length;u++)this.words[u]=this.words[u+R];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=A);u--){var w=this.words[u]|0;this.words[u]=l<<26-v|w>>>v,l=w&I}return _&&l!==0&&(_.words[_.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,y){return r(this.negative===0),this.iushrn(c,p,y)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return!1;var v=this.words[y];return!!(v&A)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var A=67108863^67108863>>>p<<p;this.words[this.length-1]&=A}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,y){var A=c.length+y,v;this._expand(A);var R,I=0;for(v=0;v<c.length;v++){R=(this.words[v+y]|0)+I;var _=(c.words[v]|0)*p;R-=_&67108863,I=(R>>26)-(_/67108864|0),this.words[v+y]=R&67108863}for(;v<this.length-y;v++)R=(this.words[v+y]|0)+I,I=R>>26,this.words[v+y]=R&67108863;if(I===0)return this._strip();for(r(I===-1),I=0,v=0;v<this.length;v++)R=-(this.words[v]|0)+I,I=R>>26,this.words[v]=R&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,A=this.clone(),v=c,R=v.words[v.length-1]|0,I=this._countBits(R);y=26-I,y!==0&&(v=v.ushln(y),A.iushln(y),R=v.words[v.length-1]|0);var _=A.length-v.length,u;if(p!=="mod"){u=new i(null),u.length=_+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var w=A.clone()._ishlnsubmul(v,1,_);w.negative===0&&(A=w,u&&(u.words[_]=1));for(var T=_-1;T>=0;T--){var D=(A.words[v.length+T]|0)*67108864+(A.words[v.length+T-1]|0);for(D=Math.min(D/R|0,67108863),A._ishlnsubmul(v,D,T);A.negative!==0;)D--,A.negative=0,A._ishlnsubmul(v,1,T),A.isZero()||(A.negative^=1);u&&(u.words[T]=D)}return u&&u._strip(),A._strip(),p!=="div"&&y!==0&&A.iushrn(y),{div:u||null,mod:A}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var A,v,R;return this.negative!==0&&c.negative===0?(R=this.neg().divmod(c,p),p!=="mod"&&(A=R.div.neg()),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.iadd(c)),{div:A,mod:v}):this.negative===0&&c.negative!==0?(R=this.divmod(c.neg(),p),p!=="mod"&&(A=R.div.neg()),{div:A,mod:R.mod}):(this.negative&c.negative)!==0?(R=this.neg().divmod(c.neg(),p),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.isub(c)),{div:R.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(c):p.mod,A=c.ushrn(1),v=c.andln(1),R=y.cmp(A);return R<0||v===1&&R===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=(1<<26)%c,A=0,v=this.length-1;v>=0;v--)A=(y*A+(this.words[v]|0))%c;return p?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=0,A=this.length-1;A>=0;A--){var v=(this.words[A]|0)+y*67108864;this.words[A]=v/c|0,y=v%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=new i(0),I=new i(1),_=0;p.isEven()&&y.isEven();)p.iushrn(1),y.iushrn(1),++_;for(var u=y.clone(),l=p.clone();!p.isZero();){for(var w=0,T=1;(p.words[0]&T)===0&&w<26;++w,T<<=1);if(w>0)for(p.iushrn(w);w-- >0;)(A.isOdd()||v.isOdd())&&(A.iadd(u),v.isub(l)),A.iushrn(1),v.iushrn(1);for(var D=0,W=1;(y.words[0]&W)===0&&D<26;++D,W<<=1);if(D>0)for(y.iushrn(D);D-- >0;)(R.isOdd()||I.isOdd())&&(R.iadd(u),I.isub(l)),R.iushrn(1),I.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(R),v.isub(I)):(y.isub(p),R.isub(A),I.isub(v))}return{a:R,b:I,gcd:y.iushln(_)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var I=0,_=1;(p.words[0]&_)===0&&I<26;++I,_<<=1);if(I>0)for(p.iushrn(I);I-- >0;)A.isOdd()&&A.iadd(R),A.iushrn(1);for(var u=0,l=1;(y.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(y.iushrn(u);u-- >0;)v.isOdd()&&v.iadd(R),v.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(v)):(y.isub(p),v.isub(A))}var w;return p.cmpn(1)===0?w=A:w=v,w.cmpn(0)<0&&w.iadd(c),w},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),y=c.clone();p.negative=0,y.negative=0;for(var A=0;p.isEven()&&y.isEven();A++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var v=p.cmp(y);if(v<0){var R=p;p=y,y=R}else if(v===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(A)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=A,this;for(var v=A,R=y;v!==0&&R<this.length;R++){var I=this.words[R]|0;I+=v,v=I>>>26,I&=67108863,this.words[R]=I}return v!==0&&(this.words[R]=v,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var A=this.words[0]|0;y=A===c?0:A<c?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,v=c.words[y]|0;if(A!==v){A<v?p=-1:A>v&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new P(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var j={k256:null,p224:null,p192:null,p25519:null};function J(E,c){this.name=E,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},J.prototype.ireduce=function(c){var p=c,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var A=y<this.n?-1:p.ucmp(this.p);return A===0?(p.words[0]=0,p.length=1):A>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},J.prototype.split=function(c,p){c.iushrn(this.n,0,p)},J.prototype.imulK=function(c){return c.imul(this.k)};function te(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(te,J),te.prototype.split=function(c,p){for(var y=4194303,A=Math.min(c.length,9),v=0;v<A;v++)p.words[v]=c.words[v];if(p.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var R=c.words[9];for(p.words[p.length++]=R&y,v=10;v<c.length;v++){var I=c.words[v]|0;c.words[v-10]=(I&y)<<4|R>>>22,R=I}R>>>=22,c.words[v-10]=R,R===0&&c.length>10?c.length-=10:c.length-=9},te.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,y=0;y<c.length;y++){var A=c.words[y]|0;p+=A*977,c.words[y]=p&67108863,p=A*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function ee(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ee,J);function V(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(V,J);function C(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(C,J),C.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+p,v=A&67108863;A>>>=26,c.words[y]=v,p=A}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(j[c])return j[c];var p;if(c==="k256")p=new te;else if(c==="p224")p=new ee;else if(c==="p192")p=new V;else if(c==="p25519")p=new C;else throw new Error("Unknown prime "+c);return j[c]=p,p};function P(E){if(typeof E=="string"){var c=i._prime(E);this.m=c.p,this.prime=c}else r(E.gtn(1),"modulus must be greater than 1"),this.m=E,this.prime=null}P.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},P.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},P.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(g(c,c.umod(this.m)._forceRed(this)),c)},P.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},P.prototype.add=function(c,p){this._verify2(c,p);var y=c.add(p);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},P.prototype.iadd=function(c,p){this._verify2(c,p);var y=c.iadd(p);return y.cmp(this.m)>=0&&y.isub(this.m),y},P.prototype.sub=function(c,p){this._verify2(c,p);var y=c.sub(p);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},P.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},P.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},P.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},P.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},P.prototype.isqr=function(c){return this.imul(c,c.clone())},P.prototype.sqr=function(c){return this.mul(c,c)},P.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(c,y)}for(var A=this.m.subn(1),v=0;!A.isZero()&&A.andln(1)===0;)v++,A.iushrn(1);r(!A.isZero());var R=new i(1).toRed(this),I=R.redNeg(),_=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,_).cmp(I)!==0;)u.redIAdd(I);for(var l=this.pow(u,A),w=this.pow(c,A.addn(1).iushrn(1)),T=this.pow(c,A),D=v;T.cmp(R)!==0;){for(var W=T,re=0;W.cmp(R)!==0;re++)W=W.redSqr();r(re<D);var oe=this.pow(l,new i(1).iushln(D-re-1));w=w.redMul(oe),l=oe.redSqr(),T=T.redMul(l),D=re}return w},P.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},P.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var y=4,A=new Array(1<<y);A[0]=new i(1).toRed(this),A[1]=c;for(var v=2;v<A.length;v++)A[v]=this.mul(A[v-1],c);var R=A[0],I=0,_=0,u=p.bitLength()%26;for(u===0&&(u=26),v=p.length-1;v>=0;v--){for(var l=p.words[v],w=u-1;w>=0;w--){var T=l>>w&1;if(R!==A[0]&&(R=this.sqr(R)),T===0&&I===0){_=0;continue}I<<=1,I|=T,_++,!(_!==y&&(v!==0||w!==0))&&(R=this.mul(R,A[I]),_=0,I=0)}u=26}return R},P.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},P.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new q(c)};function q(E){P.call(this,E),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(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)}s(q,P),q.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},q.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},q.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},q.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},q.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,o_)})(Di)),Di.exports}var a_=vf();const Rf=Va(a_);var Fi={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var Af;function c_(){return Af||(Af=1,(function(t,e){var n=oc(),r=n.Buffer;function s(o,a){for(var d in o)a[d]=o[d]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=i);function i(o,a,d){return r(o,a,d)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,d){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,d)},i.alloc=function(o,a,d){if(typeof o!="number")throw new TypeError("Argument must be a number");var m=r(o);return a!==void 0?typeof d=="string"?m.fill(a,d):m.fill(a):m.fill(0),m},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(o)}})(Fi,Fi.exports)),Fi.exports}var uc,xf;function u_(){if(xf)return uc;xf=1;var t=c_().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var d=n.length,m=n.charAt(0),g=Math.log(d)/Math.log(256),x=Math.log(256)/Math.log(d);function O(M){if((Array.isArray(M)||M instanceof Uint8Array)&&(M=t.from(M)),!t.isBuffer(M))throw new TypeError("Expected Buffer");if(M.length===0)return"";for(var k=0,K=0,Y=0,z=M.length;Y!==z&&M[Y]===0;)Y++,k++;for(var L=(z-Y)*x+1>>>0,j=new Uint8Array(L);Y!==z;){for(var J=M[Y],te=0,ee=L-1;(J!==0||te<K)&&ee!==-1;ee--,te++)J+=256*j[ee]>>>0,j[ee]=J%d>>>0,J=J/d>>>0;if(J!==0)throw new Error("Non-zero carry");K=te,Y++}for(var V=L-K;V!==L&&j[V]===0;)V++;for(var C=m.repeat(k);V<L;++V)C+=n.charAt(j[V]);return C}function N(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return t.alloc(0);for(var k=0,K=0,Y=0;M[k]===m;)K++,k++;for(var z=(M.length-k)*g+1>>>0,L=new Uint8Array(z);k<M.length;){var j=M.charCodeAt(k);if(j>255)return;var J=r[j];if(J===255)return;for(var te=0,ee=z-1;(J!==0||te<Y)&&ee!==-1;ee--,te++)J+=d*L[ee]>>>0,L[ee]=J%256>>>0,J=J/256>>>0;if(J!==0)throw new Error("Non-zero carry");Y=te,k++}for(var V=z-Y;V!==z&&L[V]===0;)V++;var C=t.allocUnsafe(K+(z-V));C.fill(0,0,K);for(var P=K;V!==z;)C[P++]=L[V++];return C}function F(M){var k=N(M);if(k)return k;throw new Error("Non-base"+d+" character")}return{encode:O,decodeUnsafe:N,decode:F}}return uc=e,uc}var dc,Sf;function Tf(){if(Sf)return dc;Sf=1;var t=u_(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return dc=t(e),dc}var d_=Tf();const Dt=Va(d_);var Me={};function Sn(t,e,n){return e<=t&&t<=n}function $i(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function l_(t){for(var e=String(t),n=e.length,r=0,s=[];r<n;){var i=e.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===n-1)s.push(65533);else{var o=t.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,d=o&1023;s.push(65536+(a<<10)+d),r+=1}else s.push(65533)}r+=1}return s}function f_(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var zi=-1;function lc(t){this.tokens=[].slice.call(t)}lc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():zi},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var Lr=-1;function fc(t,e){if(t)throw TypeError("Decoder error");return e||65533}var ji="utf-8";function Vi(t,e){if(!(this instanceof Vi))return new Vi(t,e);if(t=t!==void 0?String(t).toLowerCase():ji,t!==ji)throw new Error("Encoding not supported. Only utf-8 is supported");e=$i(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Vi.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=$i(n),this._streaming||(this._decoder=new h_({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var s=new lc(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Lr);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===Lr)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),f_(i)}};function Gi(t,e){if(!(this instanceof Gi))return new Gi(t,e);if(t=t!==void 0?String(t).toLowerCase():ji,t!==ji)throw new Error("Encoding not supported. Only utf-8 is supported");e=$i(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Gi.prototype={encode:function(e,n){e=e?String(e):"",n=$i(n),this._streaming||(this._encoder=new p_(this._options)),this._streaming=!!n.stream;for(var r=[],s=new lc(l_(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Lr);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Lr;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function h_(t){var e=t.fatal,n=0,r=0,s=0,i=128,o=191;this.handler=function(a,d){if(d===zi&&s!==0)return s=0,fc(e);if(d===zi)return Lr;if(s===0){if(Sn(d,0,127))return d;if(Sn(d,194,223))s=1,n=d-192;else if(Sn(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,n=d-224;else if(Sn(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,n=d-240;else return fc(e);return n=n<<6*s,null}if(!Sn(d,i,o))return n=s=r=0,i=128,o=191,a.prepend(d),fc(e);if(i=128,o=191,r+=1,n+=d-128<<6*(s-r),r!==s)return null;var m=n;return n=s=r=0,m}}function p_(t){t.fatal,this.handler=function(e,n){if(n===zi)return Lr;if(Sn(n,0,127))return n;var r,s;Sn(n,128,2047)?(r=1,s=192):Sn(n,2048,65535)?(r=2,s=224):Sn(n,65536,1114111)&&(r=3,s=240);for(var i=[(n>>6*r)+s];r>0;){var o=n>>6*(r-1);i.push(128|o&63),r-=1}return i}}const m_=Ga(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Vi,TextEncoder:Gi},Symbol.toStringTag,{value:"Module"})));var Of;function g_(){if(Of)return Me;Of=1;var t=Me&&Me.__createBinding||(Object.create?(function(V,C,P,q){q===void 0&&(q=P),Object.defineProperty(V,q,{enumerable:!0,get:function(){return C[P]}})}):(function(V,C,P,q){q===void 0&&(q=P),V[q]=C[P]})),e=Me&&Me.__setModuleDefault||(Object.create?(function(V,C){Object.defineProperty(V,"default",{enumerable:!0,value:C})}):function(V,C){V.default=C}),n=Me&&Me.__decorate||function(V,C,P,q){var E=arguments.length,c=E<3?C:q===null?q=Object.getOwnPropertyDescriptor(C,P):q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(V,C,P,q);else for(var y=V.length-1;y>=0;y--)(p=V[y])&&(c=(E<3?p(c):E>3?p(C,P,c):p(C,P))||c);return E>3&&c&&Object.defineProperty(C,P,c),c},r=Me&&Me.__importStar||function(V){if(V&&V.__esModule)return V;var C={};if(V!=null)for(var P in V)P!=="default"&&Object.hasOwnProperty.call(V,P)&&t(C,V,P);return e(C,V),C},s=Me&&Me.__importDefault||function(V){return V&&V.__esModule?V:{default:V}};Object.defineProperty(Me,"__esModule",{value:!0}),Me.deserializeUnchecked=Me.deserialize=Me.serialize=Me.BinaryReader=Me.BinaryWriter=Me.BorshError=Me.baseDecode=Me.baseEncode=void 0;const i=s(vf()),o=s(Tf()),a=r(m_),d=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,m=new d("utf-8",{fatal:!0});function g(V){return typeof V=="string"&&(V=Buffer.from(V,"utf8")),o.default.encode(Buffer.from(V))}Me.baseEncode=g;function x(V){return Buffer.from(o.default.decode(V))}Me.baseDecode=x;const O=1024;class N extends Error{constructor(C){super(C),this.fieldPath=[],this.originalMessage=C}addToFieldPath(C){this.fieldPath.splice(0,0,C),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Me.BorshError=N;class F{constructor(){this.buf=Buffer.alloc(O),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(O)]))}writeU8(C){this.maybeResize(),this.buf.writeUInt8(C,this.length),this.length+=1}writeU16(C){this.maybeResize(),this.buf.writeUInt16LE(C,this.length),this.length+=2}writeU32(C){this.maybeResize(),this.buf.writeUInt32LE(C,this.length),this.length+=4}writeU64(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",8)))}writeU128(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",16)))}writeU256(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",32)))}writeU512(C){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(C).toArray("le",64)))}writeBuffer(C){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),C,Buffer.alloc(O)]),this.length+=C.length}writeString(C){this.maybeResize();const P=Buffer.from(C,"utf8");this.writeU32(P.length),this.writeBuffer(P)}writeFixedArray(C){this.writeBuffer(Buffer.from(C))}writeArray(C,P){this.maybeResize(),this.writeU32(C.length);for(const q of C)this.maybeResize(),P(q)}toArray(){return this.buf.subarray(0,this.length)}}Me.BinaryWriter=F;function M(V,C,P){const q=P.value;P.value=function(...E){try{return q.apply(this,E)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new N("Reached the end of buffer when deserializing")}throw c}}}class k{constructor(C){this.buf=C,this.offset=0}readU8(){const C=this.buf.readUInt8(this.offset);return this.offset+=1,C}readU16(){const C=this.buf.readUInt16LE(this.offset);return this.offset+=2,C}readU32(){const C=this.buf.readUInt32LE(this.offset);return this.offset+=4,C}readU64(){const C=this.readBuffer(8);return new i.default(C,"le")}readU128(){const C=this.readBuffer(16);return new i.default(C,"le")}readU256(){const C=this.readBuffer(32);return new i.default(C,"le")}readU512(){const C=this.readBuffer(64);return new i.default(C,"le")}readBuffer(C){if(this.offset+C>this.buf.length)throw new N(`Expected buffer length ${C} isn't within bounds`);const P=this.buf.slice(this.offset,this.offset+C);return this.offset+=C,P}readString(){const C=this.readU32(),P=this.readBuffer(C);try{return m.decode(P)}catch(q){throw new N(`Error decoding UTF-8 string: ${q}`)}}readFixedArray(C){return new Uint8Array(this.readBuffer(C))}readArray(C){const P=this.readU32(),q=Array();for(let E=0;E<P;++E)q.push(C());return q}}n([M],k.prototype,"readU8",null),n([M],k.prototype,"readU16",null),n([M],k.prototype,"readU32",null),n([M],k.prototype,"readU64",null),n([M],k.prototype,"readU128",null),n([M],k.prototype,"readU256",null),n([M],k.prototype,"readU512",null),n([M],k.prototype,"readString",null),n([M],k.prototype,"readFixedArray",null),n([M],k.prototype,"readArray",null),Me.BinaryReader=k;function K(V){return V.charAt(0).toUpperCase()+V.slice(1)}function Y(V,C,P,q,E){try{if(typeof q=="string")E[`write${K(q)}`](P);else if(q instanceof Array)if(typeof q[0]=="number"){if(P.length!==q[0])throw new N(`Expecting byte array of length ${q[0]}, but got ${P.length} bytes`);E.writeFixedArray(P)}else if(q.length===2&&typeof q[1]=="number"){if(P.length!==q[1])throw new N(`Expecting byte array of length ${q[1]}, but got ${P.length} bytes`);for(let c=0;c<q[1];c++)Y(V,null,P[c],q[0],E)}else E.writeArray(P,c=>{Y(V,C,c,q[0],E)});else if(q.kind!==void 0)switch(q.kind){case"option":{P==null?E.writeU8(0):(E.writeU8(1),Y(V,C,P,q.type,E));break}case"map":{E.writeU32(P.size),P.forEach((c,p)=>{Y(V,C,p,q.key,E),Y(V,C,c,q.value,E)});break}default:throw new N(`FieldType ${q} unrecognized`)}else z(V,P,E)}catch(c){throw c instanceof N&&c.addToFieldPath(C),c}}function z(V,C,P){if(typeof C.borshSerialize=="function"){C.borshSerialize(P);return}const q=V.get(C.constructor);if(!q)throw new N(`Class ${C.constructor.name} is missing in schema`);if(q.kind==="struct")q.fields.map(([E,c])=>{Y(V,E,C[E],c,P)});else if(q.kind==="enum"){const E=C[q.field];for(let c=0;c<q.values.length;++c){const[p,y]=q.values[c];if(p===E){P.writeU8(c),Y(V,p,C[p],y,P);break}}}else throw new N(`Unexpected schema kind: ${q.kind} for ${C.constructor.name}`)}function L(V,C,P=F){const q=new P;return z(V,C,q),q.toArray()}Me.serialize=L;function j(V,C,P,q){try{if(typeof P=="string")return q[`read${K(P)}`]();if(P instanceof Array){if(typeof P[0]=="number")return q.readFixedArray(P[0]);if(typeof P[1]=="number"){const E=[];for(let c=0;c<P[1];c++)E.push(j(V,null,P[0],q));return E}else return q.readArray(()=>j(V,C,P[0],q))}if(P.kind==="option")return q.readU8()?j(V,C,P.type,q):void 0;if(P.kind==="map"){let E=new Map;const c=q.readU32();for(let p=0;p<c;p++){const y=j(V,C,P.key,q),A=j(V,C,P.value,q);E.set(y,A)}return E}return J(V,P,q)}catch(E){throw E instanceof N&&E.addToFieldPath(C),E}}function J(V,C,P){if(typeof C.borshDeserialize=="function")return C.borshDeserialize(P);const q=V.get(C);if(!q)throw new N(`Class ${C.name} is missing in schema`);if(q.kind==="struct"){const E={};for(const[c,p]of V.get(C).fields)E[c]=j(V,c,p,P);return new C(E)}if(q.kind==="enum"){const E=P.readU8();if(E>=q.values.length)throw new N(`Enum index: ${E} is out of range`);const[c,p]=q.values[E],y=j(V,c,p,P);return new C({[c]:y})}throw new N(`Unexpected schema kind: ${q.kind} for ${C.constructor.name}`)}function te(V,C,P,q=k){const E=new q(P),c=J(V,C,E);if(E.offset<P.length)throw new N(`Unexpected ${P.length-E.offset} bytes after deserialized data`);return c}Me.deserialize=te;function ee(V,C,P,q=k){const E=new q(P);return J(V,C,E)}return Me.deserializeUnchecked=ee,Me}var hc=g_(),H={},If;function y_(){if(If)return H;If=1,Object.defineProperty(H,"__esModule",{value:!0}),H.s16=H.s8=H.nu64be=H.u48be=H.u40be=H.u32be=H.u24be=H.u16be=H.nu64=H.u48=H.u40=H.u32=H.u24=H.u16=H.u8=H.offset=H.greedy=H.Constant=H.UTF8=H.CString=H.Blob=H.Boolean=H.BitField=H.BitStructure=H.VariantLayout=H.Union=H.UnionLayoutDiscriminator=H.UnionDiscriminator=H.Structure=H.Sequence=H.DoubleBE=H.Double=H.FloatBE=H.Float=H.NearInt64BE=H.NearInt64=H.NearUInt64BE=H.NearUInt64=H.IntBE=H.Int=H.UIntBE=H.UInt=H.OffsetLayout=H.GreedyCount=H.ExternalLayout=H.bindConstructorLayout=H.nameWithProperty=H.Layout=H.uint8ArrayToBuffer=H.checkUint8Array=void 0,H.constant=H.utf8=H.cstr=H.blob=H.unionLayoutDiscriminator=H.union=H.seq=H.bits=H.struct=H.f64be=H.f64=H.f32be=H.f32=H.ns64be=H.s48be=H.s40be=H.s32be=H.s24be=H.s16be=H.ns64=H.s48=H.s40=H.s32=H.s24=void 0;const t=oc();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=e;function n(u){return e(u),t.Buffer.from(u.buffer,u.byteOffset,u.length)}H.uint8ArrayToBuffer=n;let r=class{constructor(l,w){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=w}makeDestinationObject(){return{}}getSpan(l,w){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const w=Object.create(this.constructor.prototype);return Object.assign(w,this),w.property=l,w}fromArray(l){}};H.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}H.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=(()=>new u),Object.defineProperty(u.prototype,"encode",{value(w,T){return l.encode(this,w,T)},writable:!0}),Object.defineProperty(u,"decode",{value(w,T){return l.decode(w,T)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class a extends o{constructor(l=1,w){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,w),this.elementSpan=l}isCount(){return!0}decode(l,w=0){e(l);const T=l.length-w;return Math.floor(T/this.elementSpan)}encode(l,w,T){return 0}}H.GreedyCount=a;class d extends o{constructor(l,w=0,T){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(w))throw new TypeError("offset must be integer or undefined");super(l.span,T||l.property),this.layout=l,this.offset=w}isCount(){return this.layout instanceof m||this.layout instanceof g}decode(l,w=0){return this.layout.decode(l,w+this.offset)}encode(l,w,T=0){return this.layout.encode(l,w,T+this.offset)}}H.OffsetLayout=d;class m extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readUIntLE(w,this.span)}encode(l,w,T=0){return n(w).writeUIntLE(l,T,this.span),this.span}}H.UInt=m;class g extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readUIntBE(w,this.span)}encode(l,w,T=0){return n(w).writeUIntBE(l,T,this.span),this.span}}H.UIntBE=g;class x extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readIntLE(w,this.span)}encode(l,w,T=0){return n(w).writeIntLE(l,T,this.span),this.span}}H.Int=x;class O extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readIntBE(w,this.span)}encode(l,w,T=0){return n(w).writeIntBE(l,T,this.span),this.span}}H.IntBE=O;const N=Math.pow(2,32);function F(u){const l=Math.floor(u/N),w=u-l*N;return{hi32:l,lo32:w}}function M(u,l){return u*N+l}class k extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32LE(w),W=T.readUInt32LE(w+4);return M(W,D)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32LE(D.lo32,T),W.writeUInt32LE(D.hi32,T+4),8}}H.NearUInt64=k;class K extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32BE(w),W=T.readUInt32BE(w+4);return M(D,W)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}H.NearUInt64BE=K;class Y extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32LE(w),W=T.readInt32LE(w+4);return M(W,D)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32LE(D.lo32,T),W.writeInt32LE(D.hi32,T+4),8}}H.NearInt64=Y;class z extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readInt32BE(w),W=T.readUInt32BE(w+4);return M(D,W)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}H.NearInt64BE=z;class L extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatLE(w)}encode(l,w,T=0){return n(w).writeFloatLE(l,T),4}}H.Float=L;class j extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatBE(w)}encode(l,w,T=0){return n(w).writeFloatBE(l,T),4}}H.FloatBE=j;class J extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleLE(w)}encode(l,w,T=0){return n(w).writeDoubleLE(l,T),8}}H.Double=J;class te extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleBE(w)}encode(l,w,T=0){return n(w).writeDoubleBE(l,T),8}}H.DoubleBE=te;class ee extends r{constructor(l,w,T){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(w instanceof o&&w.isCount()||Number.isInteger(w)&&0<=w))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let D=-1;!(w instanceof o)&&0<l.span&&(D=w*l.span),super(D,T),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0,D=this.count;if(D instanceof o&&(D=D.decode(l,w)),0<this.elementLayout.span)T=D*this.elementLayout.span;else{let W=0;for(;W<D;)T+=this.elementLayout.getSpan(l,w+T),++W}return T}decode(l,w=0){const T=[];let D=0,W=this.count;for(W instanceof o&&(W=W.decode(l,w));D<W;)T.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),D+=1;return T}encode(l,w,T=0){const D=this.elementLayout,W=l.reduce((re,oe)=>re+D.encode(oe,w,T+re),0);return this.count instanceof o&&this.count.encode(l.length,w,T),W}}H.Sequence=ee;class V extends r{constructor(l,w,T){if(!(Array.isArray(l)&&l.reduce((W,re)=>W&&re instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof w=="boolean"&&T===void 0&&(T=w,w=void 0);for(const W of l)if(0>W.span&&W.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let D=-1;try{D=l.reduce((W,re)=>W+re.getSpan(),0)}catch{}super(D,w),this.fields=l,this.decodePrefixes=!!T}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0;try{T=this.fields.reduce((D,W)=>{const re=W.getSpan(l,w);return w+=re,D+re},0)}catch{throw new RangeError("indeterminate span")}return T}decode(l,w=0){e(l);const T=this.makeDestinationObject();for(const D of this.fields)if(D.property!==void 0&&(T[D.property]=D.decode(l,w)),w+=D.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return T}encode(l,w,T=0){const D=T;let W=0,re=0;for(const oe of this.fields){let Ne=oe.span;if(re=0<Ne?Ne:0,oe.property!==void 0){const Ee=l[oe.property];Ee!==void 0&&(re=oe.encode(Ee,w,T),0>Ne&&(Ne=oe.getSpan(w,T)))}W=T,T+=Ne}return W+re-D}fromArray(l){const w=this.makeDestinationObject();for(const T of this.fields)T.property!==void 0&&0<l.length&&(w[T.property]=l.shift());return w}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let w=0;for(const T of this.fields){if(T.property===l)return w;0>T.span?w=-1:0<=w&&(w+=T.span)}}}H.Structure=V;class C{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,T){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=C;class P extends C{constructor(l,w){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(w||l.property||"variant"),this.layout=l}decode(l,w){return this.layout.decode(l,w)}encode(l,w,T){return this.layout.encode(l,w,T)}}H.UnionLayoutDiscriminator=P;class q extends r{constructor(l,w,T){let D;if(l instanceof m||l instanceof g)D=new P(new d(l));else if(l instanceof o&&l.isCount())D=new P(l);else if(l instanceof C)D=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(w===void 0&&(w=null),!(w===null||w instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(w!==null){if(0>w.span)throw new Error("defaultLayout must have constant span");w.property===void 0&&(w=w.replicate("content"))}let W=-1;w&&(W=w.span,0<=W&&(l instanceof m||l instanceof g)&&(W+=D.layout.span)),super(W,T),this.discriminator=D,this.usesPrefixDiscriminator=l instanceof m||l instanceof g,this.defaultLayout=w,this.registry={};let re=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(oe){return re(oe)},this.configGetSourceVariant=function(oe){re=oe.bind(this)}}getSpan(l,w=0){if(0<=this.span)return this.span;const T=this.getVariant(l,w);if(!T)throw new Error("unable to determine span for unrecognized variant");return T.getSpan(l,w)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const w=this.registry[l[this.discriminator.property]];if(w&&(!w.layout||w.property&&Object.prototype.hasOwnProperty.call(l,w.property)))return w}else for(const w in this.registry){const T=this.registry[w];if(T.property&&Object.prototype.hasOwnProperty.call(l,T.property))return T}throw new Error("unable to infer src variant")}decode(l,w=0){let T;const D=this.discriminator,W=D.decode(l,w),re=this.registry[W];if(re===void 0){const oe=this.defaultLayout;let Ne=0;this.usesPrefixDiscriminator&&(Ne=D.layout.span),T=this.makeDestinationObject(),T[D.property]=W,T[oe.property]=oe.decode(l,w+Ne)}else T=re.decode(l,w);return T}encode(l,w,T=0){const D=this.getSourceVariant(l);if(D===void 0){const W=this.discriminator,re=this.defaultLayout;let oe=0;return this.usesPrefixDiscriminator&&(oe=W.layout.span),W.encode(l[W.property],w,T),oe+re.encode(l[re.property],w,T+oe)}return D.encode(l,w,T)}addVariant(l,w,T){const D=new E(this,l,w,T);return this.registry[l]=D,D}getVariant(l,w=0){let T;return l instanceof Uint8Array?T=this.discriminator.decode(l,w):T=l,this.registry[T]}}H.Union=q;class E extends r{constructor(l,w,T,D){if(!(l instanceof q))throw new TypeError("union must be a Union");if(!Number.isInteger(w)||0>w)throw new TypeError("variant must be a (non-negative) integer");if(typeof T=="string"&&D===void 0&&(D=T,T=null),T){if(!(T instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=T.span&&T.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof D!="string")throw new TypeError("variant must have a String property")}let W=l.span;0>l.span&&(W=T?T.span:0,0<=W&&l.usesPrefixDiscriminator&&(W+=l.discriminator.layout.span)),super(W,D),this.union=l,this.variant=w,this.layout=T||null}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0;this.union.usesPrefixDiscriminator&&(T=this.union.discriminator.layout.span);let D=0;return this.layout&&(D=this.layout.getSpan(l,w+T)),T+D}decode(l,w=0){const T=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let D=0;return this.union.usesPrefixDiscriminator&&(D=this.union.discriminator.layout.span),this.layout?T[this.property]=this.layout.decode(l,w+D):this.property?T[this.property]=!0:this.union.usesPrefixDiscriminator&&(T[this.union.discriminator.property]=this.variant),T}encode(l,w,T=0){let D=0;if(this.union.usesPrefixDiscriminator&&(D=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,w,T);let W=D;if(this.layout&&(this.layout.encode(l[this.property],w,T+D),W+=this.layout.getSpan(w,T+D),0<=this.union.span&&W>this.union.span))throw new Error("encoded variant overruns containing union");return W}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}H.VariantLayout=E;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,w,T){if(!(l instanceof m||l instanceof g))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&T===void 0&&(T=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,T),this.word=l,this.msb=!!w,this.fields=[];let D=0;this._packedSetValue=function(W){return D=c(W),this},this._packedGetValue=function(){return D}}decode(l,w=0){const T=this.makeDestinationObject(),D=this.word.decode(l,w);this._packedSetValue(D);for(const W of this.fields)W.property!==void 0&&(T[W.property]=W.decode(l));return T}encode(l,w,T=0){const D=this.word.decode(w,T);this._packedSetValue(D);for(const W of this.fields)if(W.property!==void 0){const re=l[W.property];re!==void 0&&W.encode(re)}return this.word.encode(this._packedGetValue(),w,T)}addField(l,w){const T=new y(this,l,w);return this.fields.push(T),T}addBoolean(l){const w=new A(this,l);return this.fields.push(w),w}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}}H.BitStructure=p;class y{constructor(l,w,T){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(w)||0>=w)throw new TypeError("bits must be positive integer");const D=8*l.span,W=l.fields.reduce((re,oe)=>re+oe.bits,0);if(w+W>D)throw new Error("bits too long for span remainder ("+(D-W)+" of "+D+" remain)");this.container=l,this.bits=w,this.valueMask=(1<<w)-1,w===32&&(this.valueMask=4294967295),this.start=W,this.container.msb&&(this.start=D-W-w),this.wordMask=c(this.valueMask<<this.start),this.property=T}decode(l,w){const T=this.container._packedGetValue();return c(T&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const w=this.container._packedGetValue(),T=c(l<<this.start);this.container._packedSetValue(c(w&~this.wordMask)|T)}}H.BitField=y;class A extends y{constructor(l,w){super(l,1,w)}decode(l,w){return!!super.decode(l,w)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=A;class v extends r{constructor(l,w){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let T=-1;l instanceof o||(T=l),super(T,w),this.length=l}getSpan(l,w){let T=this.span;return 0>T&&(T=this.length.decode(l,w)),T}decode(l,w=0){let T=this.span;return 0>T&&(T=this.length.decode(l,w)),n(l).slice(w,w+T)}encode(l,w,T){let D=this.length;if(this.length instanceof o&&(D=l.length),!(l instanceof Uint8Array&&D===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+D+") Uint8Array as src");if(T+D>w.length)throw new RangeError("encoding overruns Uint8Array");const W=n(l);return n(w).write(W.toString("hex"),T,D,"hex"),this.length instanceof o&&this.length.encode(D,w,T),D}}H.Blob=v;class R extends r{constructor(l){super(-1,l)}getSpan(l,w=0){e(l);let T=w;for(;T<l.length&&l[T]!==0;)T+=1;return 1+T-w}decode(l,w=0){const T=this.getSpan(l,w);return n(l).slice(w,w+T-1).toString("utf-8")}encode(l,w,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(T+W>w.length)throw new RangeError("encoding overruns Buffer");const re=n(w);return D.copy(re,T),re[T+W]=0,W+1}}H.CString=R;class I extends r{constructor(l,w){if(typeof l=="string"&&w===void 0&&(w=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,w),this.maxSpan=l}getSpan(l,w=0){return e(l),l.length-w}decode(l,w=0){const T=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<T)throw new RangeError("text length exceeds maxSpan");return n(l).slice(w,w+T).toString("utf-8")}encode(l,w,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(0<=this.maxSpan&&this.maxSpan<W)throw new RangeError("text length exceeds maxSpan");if(T+W>w.length)throw new RangeError("encoding overruns Buffer");return D.copy(n(w),T),W}}H.UTF8=I;class _ extends r{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,T){return 0}}return H.Constant=_,H.greedy=((u,l)=>new a(u,l)),H.offset=((u,l,w)=>new d(u,l,w)),H.u8=(u=>new m(1,u)),H.u16=(u=>new m(2,u)),H.u24=(u=>new m(3,u)),H.u32=(u=>new m(4,u)),H.u40=(u=>new m(5,u)),H.u48=(u=>new m(6,u)),H.nu64=(u=>new k(u)),H.u16be=(u=>new g(2,u)),H.u24be=(u=>new g(3,u)),H.u32be=(u=>new g(4,u)),H.u40be=(u=>new g(5,u)),H.u48be=(u=>new g(6,u)),H.nu64be=(u=>new K(u)),H.s8=(u=>new x(1,u)),H.s16=(u=>new x(2,u)),H.s24=(u=>new x(3,u)),H.s32=(u=>new x(4,u)),H.s40=(u=>new x(5,u)),H.s48=(u=>new x(6,u)),H.ns64=(u=>new Y(u)),H.s16be=(u=>new O(2,u)),H.s24be=(u=>new O(3,u)),H.s32be=(u=>new O(4,u)),H.s40be=(u=>new O(5,u)),H.s48be=(u=>new O(6,u)),H.ns64be=(u=>new z(u)),H.f32=(u=>new L(u)),H.f32be=(u=>new j(u)),H.f64=(u=>new J(u)),H.f64be=(u=>new te(u)),H.struct=((u,l,w)=>new V(u,l,w)),H.bits=((u,l,w)=>new p(u,l,w)),H.seq=((u,l,w)=>new ee(u,l,w)),H.union=((u,l,w)=>new q(u,l,w)),H.unionLayoutDiscriminator=((u,l)=>new P(u,l)),H.blob=((u,l)=>new v(u,l)),H.cstr=(u=>new R(u)),H.utf8=((u,l)=>new I(u,l)),H.constant=((u,l)=>new _(u,l)),H}var B=y_(),b_=1,__=2,w_=3,E_=4,v_=5,R_=6,A_=7,x_=8,S_=9,T_=10,O_=-32700,I_=-32603,N_=-32602,C_=-32601,M_=-32600,B_=-32016,k_=-32015,L_=-32014,P_=-32013,U_=-32012,D_=-32011,F_=-32010,$_=-32009,z_=-32008,j_=-32007,V_=-32006,G_=-32005,H_=-32004,q_=-32003,K_=-32002,W_=-32001,Z_=28e5,Y_=2800001,J_=2800002,X_=2800003,Q_=2800004,ew=2800005,tw=2800006,nw=2800007,rw=2800008,sw=2800009,iw=2800010,ow=2800011,aw=323e4,cw=32300001,uw=3230002,dw=3230003,lw=3230004,fw=361e4,hw=3610001,pw=3610002,mw=3610003,gw=3610004,yw=3610005,bw=3610006,_w=3610007,ww=3611e3,Ew=3704e3,vw=3704001,Rw=3704002,Aw=3704003,xw=3704004,Sw=4128e3,Tw=4128001,Ow=4128002,Iw=4615e3,Nw=4615001,Cw=4615002,Mw=4615003,Bw=4615004,kw=4615005,Lw=4615006,Pw=4615007,Uw=4615008,Dw=4615009,Fw=4615010,$w=4615011,zw=4615012,jw=4615013,Vw=4615014,Gw=4615015,Hw=4615016,qw=4615017,Kw=4615018,Ww=4615019,Zw=4615020,Yw=4615021,Jw=4615022,Xw=4615023,Qw=4615024,eE=4615025,tE=4615026,nE=4615027,rE=4615028,sE=4615029,iE=4615030,oE=4615031,aE=4615032,cE=4615033,uE=4615034,dE=4615035,lE=4615036,fE=4615037,hE=4615038,pE=4615039,mE=4615040,gE=4615041,yE=4615042,bE=4615043,_E=4615044,wE=4615045,EE=4615046,vE=4615047,RE=4615048,AE=4615049,xE=4615050,SE=4615051,TE=4615052,OE=4615053,IE=4615054,NE=5508e3,CE=5508001,ME=5508002,BE=5508003,kE=5508004,LE=5508005,PE=5508006,UE=5508007,DE=5508008,FE=5508009,$E=5508010,zE=5508011,jE=5663e3,VE=5663001,GE=5663002,HE=5663003,qE=5663004,KE=5663005,WE=5663006,ZE=5663007,YE=5663008,JE=5663009,XE=5663010,QE=5663011,ev=5663012,tv=5663013,nv=5663014,rv=5663015,sv=5663016,iv=5663017,ov=5663018,av=5663019,cv=5663020,uv=705e4,dv=7050001,lv=7050002,fv=7050003,hv=7050004,pv=7050005,mv=7050006,gv=7050007,yv=7050008,bv=7050009,_v=7050010,wv=7050011,Ev=7050012,vv=7050013,Rv=7050014,Av=7050015,xv=7050016,Sv=7050017,Tv=7050018,Ov=7050019,Iv=7050020,Nv=7050021,Cv=7050022,Mv=7050023,Bv=7050024,kv=7050025,Lv=7050026,Pv=7050027,Uv=7050028,Dv=7050029,Fv=7050030,$v=7050031,zv=7050032,jv=7050033,Vv=7050034,Gv=7050035,Hv=7050036,Nf=8078e3,Cf=8078001,qv=8078002,Kv=8078003,Mf=8078004,Bf=8078005,kf=8078006,Wv=8078007,Zv=8078008,Yv=8078009,Jv=8078010,Lf=8078011,Xv=8078012,Qv=8078013,eR=8078014,tR=8078015,nR=8078016,rR=8078017,sR=8078018,iR=8078019,oR=8078020,aR=8078021,cR=8078022,uR=81e5,dR=8100001,lR=8100002,fR=8100003,hR=819e4,pR=8190001,mR=8190002,gR=8190003,yR=8190004,bR=99e5,_R=9900001,wR=9900002,ER=9900003,vR=9900004;function Pf(t){return Array.isArray(t)?"%5B"+t.map(Pf).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function RR([t,e]){return`${t}=${Pf(e)}`}function AR(t){const e=Object.entries(t).map(RR).join("&");return btoa(e)}var xR={[aw]:"Account not found at address: $address",[lw]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[dw]:"Expected decoded account at address: $address",[uw]:"Failed to decode account data at address: $address",[cw]:"Accounts not found at addresses: $addresses",[sw]:"Unable to find a viable program address bump seed.",[J_]:"$putativeAddress is not a base58-encoded address.",[Z_]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[X_]:"The `CryptoKey` must be an `Ed25519` public key.",[ow]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[rw]:"Invalid seeds; point must fall off the Ed25519 curve.",[Q_]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[tw]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[nw]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[ew]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[iw]:"Program address cannot end with PDA marker.",[Y_]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[E_]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[b_]:"The network has progressed past the last block for which this transaction could have been committed.",[Nf]:"Codec [$codecDescription] cannot decode empty byte arrays.",[cR]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[oR]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Bf]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[kf]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Mf]:"Encoder and decoder must either both be fixed-size or variable-size.",[Zv]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[qv]:"Expected a fixed-size codec, got a variable-size one.",[Qv]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Kv]:"Expected a variable-size codec, got a fixed-size one.",[iR]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Cf]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[sR]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Yv]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Jv]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[tR]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Wv]:"Expected [$codecDescription] to have $expected items, got $actual.",[Xv]:"Invalid value $value for base $base with alphabet $alphabet.",[nR]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Lf]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[eR]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[aR]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[rR]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[ww]:"No random values implementation could be found.",[Dw]:"instruction requires an uninitialized account",[Xw]:"instruction tries to borrow reference for an account which is already borrowed",[Qw]:"instruction left account with an outstanding borrowed reference",[Yw]:"program other than the account's owner changed the size of the account data",[kw]:"account data too small for instruction",[Jw]:"instruction expected an executable account",[EE]:"An account does not have enough lamports to be rent-exempt",[RE]:"Program arithmetic overflowed",[wE]:"Failed to serialize or deserialize account data: $encodedData",[IE]:"Builtin programs must consume compute units",[aE]:"Cross-program invocation call depth too deep",[hE]:"Computational budget exceeded",[tE]:"custom program error: #$code",[qw]:"instruction contains duplicate accounts",[eE]:"instruction modifications of multiply-passed account differ",[iE]:"executable accounts must be rent exempt",[rE]:"instruction changed executable accounts data",[sE]:"instruction changed the balance of an executable account",[Kw]:"instruction changed executable bit of an account",[Vw]:"instruction modified data of an account it does not own",[jw]:"instruction spent from the balance of an account it does not own",[Nw]:"generic instruction error",[xE]:"Provided owner is not allowed",[bE]:"Account is immutable",[_E]:"Incorrect authority provided",[Pw]:"incorrect program id for instruction",[Lw]:"insufficient funds for instruction",[Bw]:"invalid account data for instruction",[vE]:"Invalid account owner",[Cw]:"invalid program argument",[nE]:"program returned invalid error code",[Mw]:"invalid instruction data",[fE]:"Failed to reallocate account data",[lE]:"Provided seeds do not result in a valid address",[SE]:"Accounts data allocations exceeded the maximum allowed per transaction",[TE]:"Max accounts exceeded",[OE]:"Max instruction trace length exceeded",[dE]:"Length of the seed is too long for address generation",[cE]:"An account required by the instruction is missing",[Uw]:"missing required signature for instruction",[zw]:"instruction illegally modified the program id of an account",[Zw]:"insufficient account keys for instruction",[pE]:"Cross-program invocation with unauthorized signer or writable account",[mE]:"Failed to create program execution environment",[yE]:"Program failed to compile",[gE]:"Program failed to complete",[Hw]:"instruction modified data of a read-only account",[Gw]:"instruction changed the balance of a read-only account",[uE]:"Cross-program invocation reentrancy not allowed for this instruction",[Ww]:"instruction modified rent epoch of an account",[$w]:"sum of account balances before and after instruction do not match",[Fw]:"instruction requires an initialized account",[Iw]:"",[oE]:"Unsupported program id",[AE]:"Unsupported sysvar",[Sw]:"The instruction does not have any accounts.",[Tw]:"The instruction does not have any data.",[Ow]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[v_]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[__]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[wR]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[vR]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[_R]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[bR]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ER]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[I_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[N_]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[M_]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[C_]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[O_]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[U_]:"$__serverMessage",[W_]:"$__serverMessage",[H_]:"$__serverMessage",[L_]:"$__serverMessage",[F_]:"$__serverMessage",[$_]:"$__serverMessage",[B_]:"Minimum context slot has not been reached",[G_]:"Node is unhealthy; behind by $numSlotsBehind slots",[z_]:"No snapshot",[K_]:"Transaction simulation failed",[j_]:"$__serverMessage",[D_]:"Transaction history is not available from this node",[V_]:"$__serverMessage",[P_]:"Transaction signature length mismatch",[q_]:"Transaction signature verification failure",[k_]:"$__serverMessage",[Ew]:"Key pair bytes must be of length 64, got $byteLength.",[vw]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Rw]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[xw]:"The provided private key does not match the provided public key.",[Aw]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[R_]:"Lamports value must be in the range [0, 2e64-1]",[A_]:"`$value` cannot be parsed as a `BigInt`",[T_]:"$message",[x_]:"`$value` cannot be parsed as a `Number`",[w_]:"No nonce account could be found at address `$nonceAccountAddress`",[hR]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[mR]:"WebSocket was closed before payload could be added to the send buffer",[gR]:"WebSocket connection closed",[yR]:"WebSocket failed to connect",[pR]:"Failed to obtain a subscription id from the server",[fR]:"Could not find an API plan for RPC method: `$method`",[uR]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[lR]:"HTTP error ($statusCode): $message",[dR]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[NE]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[CE]:"The provided value does not implement the `KeyPairSigner` interface",[BE]:"The provided value does not implement the `MessageModifyingSigner` interface",[kE]:"The provided value does not implement the `MessagePartialSigner` interface",[ME]:"The provided value does not implement any of the `MessageSigner` interfaces",[PE]:"The provided value does not implement the `TransactionModifyingSigner` interface",[UE]:"The provided value does not implement the `TransactionPartialSigner` interface",[DE]:"The provided value does not implement the `TransactionSendingSigner` interface",[LE]:"The provided value does not implement any of the `TransactionSigner` interfaces",[FE]:"More than one `TransactionSendingSigner` was identified.",[$E]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[zE]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[_w]:"Cannot export a non-extractable key.",[hw]:"No digest implementation could be found.",[fw]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[pw]:`This runtime does not support the generation of Ed25519 key pairs.
28
+ */var yf;function ac(){return yf||(yf=1,(function(t){const e=qb(),n=Kb(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=Y,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const b=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(b,f),b.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(b){if(b>s)throw new RangeError('The value "'+b+'" is invalid for option "size"');const f=new Uint8Array(b);return Object.setPrototypeOf(f,a.prototype),f}function a(b,f,h){if(typeof b=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(b)}return d(b,f,h)}a.poolSize=8192;function d(b,f,h){if(typeof b=="string")return O(b,f);if(ArrayBuffer.isView(b))return F(b);if(b==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b);if(Yt(b,ArrayBuffer)||b&&Yt(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Yt(b,SharedArrayBuffer)||b&&Yt(b.buffer,SharedArrayBuffer)))return C(b,f,h);if(typeof b=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const S=b.valueOf&&b.valueOf();if(S!=null&&S!==b)return a.from(S,f,h);const U=k(b);if(U)return U;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof b[Symbol.toPrimitive]=="function")return a.from(b[Symbol.toPrimitive]("string"),f,h);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof b)}a.from=function(b,f,h){return d(b,f,h)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function m(b){if(typeof b!="number")throw new TypeError('"size" argument must be of type number');if(b<0)throw new RangeError('The value "'+b+'" is invalid for option "size"')}function g(b,f,h){return m(b),b<=0?o(b):f!==void 0?typeof h=="string"?o(b).fill(f,h):o(b).fill(f):o(b)}a.alloc=function(b,f,h){return g(b,f,h)};function x(b){return m(b),o(b<0?0:K(b)|0)}a.allocUnsafe=function(b){return x(b)},a.allocUnsafeSlow=function(b){return x(b)};function O(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=V(b,f)|0;let S=o(h);const U=S.write(b,f);return U!==h&&(S=S.slice(0,U)),S}function N(b){const f=b.length<0?0:K(b.length)|0,h=o(f);for(let S=0;S<f;S+=1)h[S]=b[S]&255;return h}function F(b){if(Yt(b,Uint8Array)){const f=new Uint8Array(b);return C(f.buffer,f.byteOffset,f.byteLength)}return N(b)}function C(b,f,h){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(h||0))throw new RangeError('"length" is outside of buffer bounds');let S;return f===void 0&&h===void 0?S=new Uint8Array(b):h===void 0?S=new Uint8Array(b,f):S=new Uint8Array(b,f,h),Object.setPrototypeOf(S,a.prototype),S}function k(b){if(a.isBuffer(b)){const f=K(b.length)|0,h=o(f);return h.length===0||b.copy(h,0,0,f),h}if(b.length!==void 0)return typeof b.length!="number"||Ge(b.length)?o(0):N(b);if(b.type==="Buffer"&&Array.isArray(b.data))return N(b.data)}function K(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function Y(b){return+b!=b&&(b=0),a.alloc(+b)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,h){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Yt(h,Uint8Array)&&(h=a.from(h,h.offset,h.byteLength)),!a.isBuffer(f)||!a.isBuffer(h))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===h)return 0;let S=f.length,U=h.length;for(let $=0,Z=Math.min(S,U);$<Z;++$)if(f[$]!==h[$]){S=f[$],U=h[$];break}return S<U?-1:U<S?1:0},a.isEncoding=function(f){switch(String(f).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(f,h){if(!Array.isArray(f))throw new TypeError('"list" argument must be an Array of Buffers');if(f.length===0)return a.alloc(0);let S;if(h===void 0)for(h=0,S=0;S<f.length;++S)h+=f[S].length;const U=a.allocUnsafe(h);let $=0;for(S=0;S<f.length;++S){let Z=f[S];if(Yt(Z,Uint8Array))$+Z.length>U.length?(a.isBuffer(Z)||(Z=a.from(Z)),Z.copy(U,$)):Uint8Array.prototype.set.call(U,Z,$);else if(a.isBuffer(Z))Z.copy(U,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Z.length}return U};function V(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||Yt(b,ArrayBuffer))return b.byteLength;if(typeof b!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof b);const h=b.length,S=arguments.length>2&&arguments[2]===!0;if(!S&&h===0)return 0;let U=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return h;case"utf8":case"utf-8":return Le(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h*2;case"hex":return h>>>1;case"base64":return Fe(b).length;default:if(U)return S?-1:Le(b).length;f=(""+f).toLowerCase(),U=!0}}a.byteLength=V;function L(b,f,h){let S=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,f>>>=0,h<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return R(this,f,h);case"utf8":case"utf-8":return c(this,f,h);case"ascii":return A(this,f,h);case"latin1":case"binary":return v(this,f,h);case"base64":return E(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,f,h);default:if(S)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),S=!0}}a.prototype._isBuffer=!0;function z(b,f,h){const S=b[f];b[f]=b[h],b[h]=S}a.prototype.swap16=function(){const f=this.length;if(f%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let h=0;h<f;h+=2)z(this,h,h+1);return this},a.prototype.swap32=function(){const f=this.length;if(f%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let h=0;h<f;h+=4)z(this,h,h+3),z(this,h+1,h+2);return this},a.prototype.swap64=function(){const f=this.length;if(f%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let h=0;h<f;h+=8)z(this,h,h+7),z(this,h+1,h+6),z(this,h+2,h+5),z(this,h+3,h+4);return this},a.prototype.toString=function(){const f=this.length;return f===0?"":arguments.length===0?c(this,0,f):L.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(f){if(!a.isBuffer(f))throw new TypeError("Argument must be a Buffer");return this===f?!0:a.compare(this,f)===0},a.prototype.inspect=function(){let f="";const h=t.INSPECT_MAX_BYTES;return f=this.toString("hex",0,h).replace(/(.{2})/g,"$1 ").trim(),this.length>h&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,h,S,U,$){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),!a.isBuffer(f))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof f);if(h===void 0&&(h=0),S===void 0&&(S=f?f.length:0),U===void 0&&(U=0),$===void 0&&($=this.length),h<0||S>f.length||U<0||$>this.length)throw new RangeError("out of range index");if(U>=$&&h>=S)return 0;if(U>=$)return-1;if(h>=S)return 1;if(h>>>=0,S>>>=0,U>>>=0,$>>>=0,this===f)return 0;let Z=$-U,Re=S-h;const _e=Math.min(Z,Re),ge=this.slice(U,$),$e=f.slice(h,S);for(let he=0;he<_e;++he)if(ge[he]!==$e[he]){Z=ge[he],Re=$e[he];break}return Z<Re?-1:Re<Z?1:0};function J(b,f,h,S,U){if(b.length===0)return-1;if(typeof h=="string"?(S=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ge(h)&&(h=U?0:b.length-1),h<0&&(h=b.length+h),h>=b.length){if(U)return-1;h=b.length-1}else if(h<0)if(U)h=0;else return-1;if(typeof f=="string"&&(f=a.from(f,S)),a.isBuffer(f))return f.length===0?-1:te(b,f,h,S,U);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(b,f,h):Uint8Array.prototype.lastIndexOf.call(b,f,h):te(b,[f],h,S,U);throw new TypeError("val must be string, number or Buffer")}function te(b,f,h,S,U){let $=1,Z=b.length,Re=f.length;if(S!==void 0&&(S=String(S).toLowerCase(),S==="ucs2"||S==="ucs-2"||S==="utf16le"||S==="utf-16le")){if(b.length<2||f.length<2)return-1;$=2,Z/=2,Re/=2,h/=2}function _e($e,he){return $===1?$e[he]:$e.readUInt16BE(he*$)}let ge;if(U){let $e=-1;for(ge=h;ge<Z;ge++)if(_e(b,ge)===_e(f,$e===-1?0:ge-$e)){if($e===-1&&($e=ge),ge-$e+1===Re)return $e*$}else $e!==-1&&(ge-=ge-$e),$e=-1}else for(h+Re>Z&&(h=Z-Re),ge=h;ge>=0;ge--){let $e=!0;for(let he=0;he<Re;he++)if(_e(b,ge+he)!==_e(f,he)){$e=!1;break}if($e)return ge}return-1}a.prototype.includes=function(f,h,S){return this.indexOf(f,h,S)!==-1},a.prototype.indexOf=function(f,h,S){return J(this,f,h,S,!0)},a.prototype.lastIndexOf=function(f,h,S){return J(this,f,h,S,!1)};function ne(b,f,h,S){h=Number(h)||0;const U=b.length-h;S?(S=Number(S),S>U&&(S=U)):S=U;const $=f.length;S>$/2&&(S=$/2);let Z;for(Z=0;Z<S;++Z){const Re=parseInt(f.substr(Z*2,2),16);if(Ge(Re))return Z;b[h+Z]=Re}return Z}function q(b,f,h,S){return Pe(Le(f,b.length-h),b,h,S)}function B(b,f,h,S){return Pe(Ve(f),b,h,S)}function P(b,f,h,S){return Pe(Fe(f),b,h,S)}function j(b,f,h,S){return Pe(Zr(f,b.length-h),b,h,S)}a.prototype.write=function(f,h,S,U){if(h===void 0)U="utf8",S=this.length,h=0;else if(S===void 0&&typeof h=="string")U=h,S=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(S)?(S=S>>>0,U===void 0&&(U="utf8")):(U=S,S=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-h;if((S===void 0||S>$)&&(S=$),f.length>0&&(S<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");U||(U="utf8");let Z=!1;for(;;)switch(U){case"hex":return ne(this,f,h,S);case"utf8":case"utf-8":return q(this,f,h,S);case"ascii":case"latin1":case"binary":return B(this,f,h,S);case"base64":return P(this,f,h,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,f,h,S);default:if(Z)throw new TypeError("Unknown encoding: "+U);U=(""+U).toLowerCase(),Z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function E(b,f,h){return f===0&&h===b.length?e.fromByteArray(b):e.fromByteArray(b.slice(f,h))}function c(b,f,h){h=Math.min(b.length,h);const S=[];let U=f;for(;U<h;){const $=b[U];let Z=null,Re=$>239?4:$>223?3:$>191?2:1;if(U+Re<=h){let _e,ge,$e,he;switch(Re){case 1:$<128&&(Z=$);break;case 2:_e=b[U+1],(_e&192)===128&&(he=($&31)<<6|_e&63,he>127&&(Z=he));break;case 3:_e=b[U+1],ge=b[U+2],(_e&192)===128&&(ge&192)===128&&(he=($&15)<<12|(_e&63)<<6|ge&63,he>2047&&(he<55296||he>57343)&&(Z=he));break;case 4:_e=b[U+1],ge=b[U+2],$e=b[U+3],(_e&192)===128&&(ge&192)===128&&($e&192)===128&&(he=($&15)<<18|(_e&63)<<12|(ge&63)<<6|$e&63,he>65535&&he<1114112&&(Z=he))}}Z===null?(Z=65533,Re=1):Z>65535&&(Z-=65536,S.push(Z>>>10&1023|55296),Z=56320|Z&1023),S.push(Z),U+=Re}return y(S)}const p=4096;function y(b){const f=b.length;if(f<=p)return String.fromCharCode.apply(String,b);let h="",S=0;for(;S<f;)h+=String.fromCharCode.apply(String,b.slice(S,S+=p));return h}function A(b,f,h){let S="";h=Math.min(b.length,h);for(let U=f;U<h;++U)S+=String.fromCharCode(b[U]&127);return S}function v(b,f,h){let S="";h=Math.min(b.length,h);for(let U=f;U<h;++U)S+=String.fromCharCode(b[U]);return S}function R(b,f,h){const S=b.length;(!f||f<0)&&(f=0),(!h||h<0||h>S)&&(h=S);let U="";for(let $=f;$<h;++$)U+=Ze[b[$]];return U}function I(b,f,h){const S=b.slice(f,h);let U="";for(let $=0;$<S.length-1;$+=2)U+=String.fromCharCode(S[$]+S[$+1]*256);return U}a.prototype.slice=function(f,h){const S=this.length;f=~~f,h=h===void 0?S:~~h,f<0?(f+=S,f<0&&(f=0)):f>S&&(f=S),h<0?(h+=S,h<0&&(h=0)):h>S&&(h=S),h<f&&(h=f);const U=this.subarray(f,h);return Object.setPrototypeOf(U,a.prototype),U};function _(b,f,h){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+f>h)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)U+=this[f+Z]*$;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f+--h],$=1;for(;h>0&&($*=256);)U+=this[f+--h]*$;return U},a.prototype.readUint8=a.prototype.readUInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,h){return f=f>>>0,h||_(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),(this[f]|this[f+1]<<8|this[f+2]<<16)+this[f+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]*16777216+(this[f+1]<<16|this[f+2]<<8|this[f+3])},a.prototype.readBigUInt64LE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+S*2**24;return BigInt(U)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S;return(BigInt(U)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)U+=this[f+Z]*$;return $*=128,U>=$&&(U-=Math.pow(2,8*h)),U},a.prototype.readIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let U=h,$=1,Z=this[f+--U];for(;U>0&&($*=256);)Z+=this[f+--U]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*h)),Z},a.prototype.readInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,h){f=f>>>0,h||_(f,2,this.length);const S=this[f]|this[f+1]<<8;return S&32768?S|4294901760:S},a.prototype.readInt16BE=function(f,h){f=f>>>0,h||_(f,2,this.length);const S=this[f+1]|this[f]<<8;return S&32768?S|4294901760:S},a.prototype.readInt32LE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,h){return f=f>>>0,h||_(f,4,this.length),this[f]<<24|this[f+1]<<16|this[f+2]<<8|this[f+3]},a.prototype.readBigInt64LE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(S<<24);return(BigInt(U)<<BigInt(32))+BigInt(h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=an(function(f){f=f>>>0,De(f,"offset");const h=this[f],S=this[f+7];(h===void 0||S===void 0)&&ve(f,this.length-8);const U=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(U)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S)}),a.prototype.readFloatLE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,h){return f=f>>>0,h||_(f,4,this.length),n.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,h){return f=f>>>0,h||_(f,8,this.length),n.read(this,f,!1,52,8)};function u(b,f,h,S,U,$){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>U||f<$)throw new RangeError('"value" argument is out of bounds');if(h+S>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,h,S,U){if(f=+f,h=h>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,h,S,Re,0)}let $=1,Z=0;for(this[h]=f&255;++Z<S&&($*=256);)this[h+Z]=f/$&255;return h+S},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,h,S,U){if(f=+f,h=h>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,h,S,Re,0)}let $=S-1,Z=1;for(this[h+$]=f&255;--$>=0&&(Z*=256);)this[h+$]=f/Z&255;return h+S},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,1,255,0),this[h]=f&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,65535,0),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,65535,0),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,4294967295,0),this[h+3]=f>>>24,this[h+2]=f>>>16,this[h+1]=f>>>8,this[h]=f&255,h+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,4294967295,0),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4};function l(b,f,h,S,U){we(f,S,U,b,h,7);let $=Number(f&BigInt(4294967295));b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,h}function w(b,f,h,S,U){we(f,S,U,b,h,7);let $=Number(f&BigInt(4294967295));b[h+7]=$,$=$>>8,b[h+6]=$,$=$>>8,b[h+5]=$,$=$>>8,b[h+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h+3]=Z,Z=Z>>8,b[h+2]=Z,Z=Z>>8,b[h+1]=Z,Z=Z>>8,b[h]=Z,h+8}a.prototype.writeBigUInt64LE=an(function(f,h=0){return l(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=an(function(f,h=0){return w(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,h,S,U){if(f=+f,h=h>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let $=0,Z=1,Re=0;for(this[h]=f&255;++$<S&&(Z*=256);)f<0&&Re===0&&this[h+$-1]!==0&&(Re=1),this[h+$]=(f/Z>>0)-Re&255;return h+S},a.prototype.writeIntBE=function(f,h,S,U){if(f=+f,h=h>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let $=S-1,Z=1,Re=0;for(this[h+$]=f&255;--$>=0&&(Z*=256);)f<0&&Re===0&&this[h+$+1]!==0&&(Re=1),this[h+$]=(f/Z>>0)-Re&255;return h+S},a.prototype.writeInt8=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,1,127,-128),f<0&&(f=255+f+1),this[h]=f&255,h+1},a.prototype.writeInt16LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,32767,-32768),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeInt16BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,2,32767,-32768),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeInt32LE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,2147483647,-2147483648),this[h]=f&255,this[h+1]=f>>>8,this[h+2]=f>>>16,this[h+3]=f>>>24,h+4},a.prototype.writeInt32BE=function(f,h,S){return f=+f,h=h>>>0,S||u(this,f,h,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[h]=f>>>24,this[h+1]=f>>>16,this[h+2]=f>>>8,this[h+3]=f&255,h+4},a.prototype.writeBigInt64LE=an(function(f,h=0){return l(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=an(function(f,h=0){return w(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function T(b,f,h,S,U,$){if(h+S>b.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function D(b,f,h,S,U){return f=+f,h=h>>>0,U||T(b,f,h,4),n.write(b,f,h,S,23,4),h+4}a.prototype.writeFloatLE=function(f,h,S){return D(this,f,h,!0,S)},a.prototype.writeFloatBE=function(f,h,S){return D(this,f,h,!1,S)};function W(b,f,h,S,U){return f=+f,h=h>>>0,U||T(b,f,h,8),n.write(b,f,h,S,52,8),h+8}a.prototype.writeDoubleLE=function(f,h,S){return W(this,f,h,!0,S)},a.prototype.writeDoubleBE=function(f,h,S){return W(this,f,h,!1,S)},a.prototype.copy=function(f,h,S,U){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(S||(S=0),!U&&U!==0&&(U=this.length),h>=f.length&&(h=f.length),h||(h=0),U>0&&U<S&&(U=S),U===S||f.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(S<0||S>=this.length)throw new RangeError("Index out of range");if(U<0)throw new RangeError("sourceEnd out of bounds");U>this.length&&(U=this.length),f.length-h<U-S&&(U=f.length-h+S);const $=U-S;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,S,U):Uint8Array.prototype.set.call(f,this.subarray(S,U),h),$},a.prototype.fill=function(f,h,S,U){if(typeof f=="string"){if(typeof h=="string"?(U=h,h=0,S=this.length):typeof S=="string"&&(U=S,S=this.length),U!==void 0&&typeof U!="string")throw new TypeError("encoding must be a string");if(typeof U=="string"&&!a.isEncoding(U))throw new TypeError("Unknown encoding: "+U);if(f.length===1){const Z=f.charCodeAt(0);(U==="utf8"&&Z<128||U==="latin1")&&(f=Z)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(h<0||this.length<h||this.length<S)throw new RangeError("Out of range index");if(S<=h)return this;h=h>>>0,S=S===void 0?this.length:S>>>0,f||(f=0);let $;if(typeof f=="number")for($=h;$<S;++$)this[$]=f;else{const Z=a.isBuffer(f)?f:a.from(f,U),Re=Z.length;if(Re===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<S-h;++$)this[$+h]=Z[$%Re]}return this};const re={};function oe(b,f,h){re[b]=class extends h{constructor(){super(),Object.defineProperty(this,"message",{value:f.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${b}]`,this.stack,delete this.name}get code(){return b}set code(U){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:U,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}oe("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),oe("ERR_INVALID_ARG_TYPE",function(b,f){return`The "${b}" argument must be of type number. Received type ${typeof f}`},TypeError),oe("ERR_OUT_OF_RANGE",function(b,f,h){let S=`The value of "${b}" is out of range.`,U=h;return Number.isInteger(h)&&Math.abs(h)>2**32?U=Ce(String(h)):typeof h=="bigint"&&(U=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(U=Ce(U)),U+="n"),S+=` It must be ${f}. Received ${U}`,S},RangeError);function Ce(b){let f="",h=b.length;const S=b[0]==="-"?1:0;for(;h>=S+4;h-=3)f=`_${b.slice(h-3,h)}${f}`;return`${b.slice(0,h)}${f}`}function Ee(b,f,h){De(f,"offset"),(b[f]===void 0||b[f+h]===void 0)&&ve(f,b.length-(h+1))}function we(b,f,h,S,U,$){if(b>h||b<f){const Z=typeof f=="bigint"?"n":"";let Re;throw f===0||f===BigInt(0)?Re=`>= 0${Z} and < 2${Z} ** ${($+1)*8}${Z}`:Re=`>= -(2${Z} ** ${($+1)*8-1}${Z}) and < 2 ** ${($+1)*8-1}${Z}`,new re.ERR_OUT_OF_RANGE("value",Re,b)}Ee(S,U,$)}function De(b,f){if(typeof b!="number")throw new re.ERR_INVALID_ARG_TYPE(f,"number",b)}function ve(b,f,h){throw Math.floor(b)!==b?(De(b,h),new re.ERR_OUT_OF_RANGE("offset","an integer",b)):f<0?new re.ERR_BUFFER_OUT_OF_BOUNDS:new re.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,b)}const Oe=/[^+/0-9A-Za-z-_]/g;function mn(b){if(b=b.split("=")[0],b=b.trim().replace(Oe,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function Le(b,f){f=f||1/0;let h;const S=b.length;let U=null;const $=[];for(let Z=0;Z<S;++Z){if(h=b.charCodeAt(Z),h>55295&&h<57344){if(!U){if(h>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===S){(f-=3)>-1&&$.push(239,191,189);continue}U=h;continue}if(h<56320){(f-=3)>-1&&$.push(239,191,189),U=h;continue}h=(U-55296<<10|h-56320)+65536}else U&&(f-=3)>-1&&$.push(239,191,189);if(U=null,h<128){if((f-=1)<0)break;$.push(h)}else if(h<2048){if((f-=2)<0)break;$.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;$.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;$.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return $}function Ve(b){const f=[];for(let h=0;h<b.length;++h)f.push(b.charCodeAt(h)&255);return f}function Zr(b,f){let h,S,U;const $=[];for(let Z=0;Z<b.length&&!((f-=2)<0);++Z)h=b.charCodeAt(Z),S=h>>8,U=h%256,$.push(U),$.push(S);return $}function Fe(b){return e.toByteArray(mn(b))}function Pe(b,f,h,S){let U;for(U=0;U<S&&!(U+h>=f.length||U>=b.length);++U)f[U+h]=b[U];return U}function Yt(b,f){return b instanceof f||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===f.name}function Ge(b){return b!==b}const Ze=(function(){const b="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const S=h*16;for(let U=0;U<16;++U)f[S+U]=b[h]+b[U]}return f})();function an(b){return typeof BigInt>"u"?Ye:b}function Ye(){throw new Error("BigInt not supported")}})(oc)),oc}var xe=ac();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ln=BigInt(0),Ut=BigInt(1),bf=BigInt(2),Wb=BigInt(8),Zb={zip215:!0};function Yb(t){const e=La(t);return Ss(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Jb(t){const e=Yb(t),{Fp:n,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:d}=e,m=bf<<BigInt(a*8)-Ut,g=n.create,x=Os(e.n,e.nBitLength);function O(v,R){const I=n.sqr(v),_=n.sqr(R),u=n.add(n.mul(e.a,I),_),l=n.add(n.ONE,n.mul(e.d,n.mul(I,_)));return n.eql(u,l)}if(!O(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const N=e.uvRatio||((v,R)=>{try{return{isValid:!0,value:n.sqrt(v*n.inv(R))}}catch{return{isValid:!1,value:ln}}}),F=e.adjustScalarBytes||(v=>v),C=e.domain||((v,R,I)=>{if(Ln("phflag",I),R.length||I)throw new Error("Contexts/pre-hash are not supported");return v});function k(v,R,I=!1){const _=I?Ut:ln;nn("coordinate "+v,R,_,m)}function K(v){if(!(v instanceof L))throw new Error("ExtendedPoint expected")}const Y=bi((v,R)=>{const{ex:I,ey:_,ez:u}=v,l=v.is0();R==null&&(R=l?Wb:n.inv(u));const w=g(I*R),T=g(_*R),D=g(u*R);if(l)return{x:ln,y:Ut};if(D!==Ut)throw new Error("invZ was invalid");return{x:w,y:T}}),V=bi(v=>{const{a:R,d:I}=e;if(v.is0())throw new Error("bad point: ZERO");const{ex:_,ey:u,ez:l,et:w}=v,T=g(_*_),D=g(u*u),W=g(l*l),re=g(W*W),oe=g(T*R),Ce=g(W*g(oe+D)),Ee=g(re+g(I*g(T*D)));if(Ce!==Ee)throw new Error("bad point: equation left != right (1)");const we=g(_*u),De=g(l*w);if(we!==De)throw new Error("bad point: equation left != right (2)");return!0});class L{constructor(R,I,_,u){k("x",R),k("y",I),k("z",_,!0),k("t",u),this.ex=R,this.ey=I,this.ez=_,this.et=u,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(R){if(R instanceof L)throw new Error("extended point not allowed");const{x:I,y:_}=R||{};return k("x",I),k("y",_),new L(I,_,Ut,g(I*_))}static normalizeZ(R){const I=Ia(n,R.map(_=>_.ez));return R.map((_,u)=>_.toAffine(I[u])).map(L.fromAffine)}static msm(R,I){return Ml(L,x,R,I)}_setWindowSize(R){te.setWindowSize(this,R)}assertValidity(){V(this)}equals(R){K(R);const{ex:I,ey:_,ez:u}=this,{ex:l,ey:w,ez:T}=R,D=g(I*T),W=g(l*u),re=g(_*T),oe=g(w*u);return D===W&&re===oe}is0(){return this.equals(L.ZERO)}negate(){return new L(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:R}=e,{ex:I,ey:_,ez:u}=this,l=g(I*I),w=g(_*_),T=g(bf*g(u*u)),D=g(R*l),W=I+_,re=g(g(W*W)-l-w),oe=D+w,Ce=oe-T,Ee=D-w,we=g(re*Ce),De=g(oe*Ee),ve=g(re*Ee),Oe=g(Ce*oe);return new L(we,De,Oe,ve)}add(R){K(R);const{a:I,d:_}=e,{ex:u,ey:l,ez:w,et:T}=this,{ex:D,ey:W,ez:re,et:oe}=R,Ce=g(u*D),Ee=g(l*W),we=g(T*_*oe),De=g(w*re),ve=g((u+l)*(D+W)-Ce-Ee),Oe=De-we,mn=De+we,Le=g(Ee-I*Ce),Ve=g(ve*Oe),Zr=g(mn*Le),Fe=g(ve*Le),Pe=g(Oe*mn);return new L(Ve,Zr,Pe,Fe)}subtract(R){return this.add(R.negate())}wNAF(R){return te.wNAFCached(this,R,L.normalizeZ)}multiply(R){const I=R;nn("scalar",I,Ut,r);const{p:_,f:u}=this.wNAF(I);return L.normalizeZ([_,u])[0]}multiplyUnsafe(R,I=L.ZERO){const _=R;return nn("scalar",_,ln,r),_===ln?J:this.is0()||_===Ut?this:te.wNAFCachedUnsafe(this,_,L.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return te.unsafeLadder(this,r).is0()}toAffine(R){return Y(this,R)}clearCofactor(){const{h:R}=e;return R===Ut?this:this.multiplyUnsafe(R)}static fromHex(R,I=!1){const{d:_,a:u}=e,l=n.BYTES;R=Je("pointHex",R,l),Ln("zip215",I);const w=R.slice(),T=R[l-1];w[l-1]=T&-129;const D=As(w),W=I?m:n.ORDER;nn("pointHex.y",D,ln,W);const re=g(D*D),oe=g(re-Ut),Ce=g(_*re-u);let{isValid:Ee,value:we}=N(oe,Ce);if(!Ee)throw new Error("Point.fromHex: invalid y coordinate");const De=(we&Ut)===Ut,ve=(T&128)!==0;if(!I&&we===ln&&ve)throw new Error("Point.fromHex: x=0 and x_0=1");return ve!==De&&(we=g(-we)),L.fromAffine({x:we,y:D})}static fromPrivateKey(R){const{scalar:I}=B(R);return z.multiply(I)}toRawBytes(){const{x:R,y:I}=this.toAffine(),_=gi(I,n.BYTES);return _[_.length-1]|=R&Ut?128:0,_}toHex(){return Tr(this.toRawBytes())}}L.BASE=new L(e.Gx,e.Gy,Ut,g(e.Gx*e.Gy)),L.ZERO=new L(ln,Ut,Ut,ln);const{BASE:z,ZERO:J}=L,te=Cl(L,a*8);function ne(v){return je(v,r)}function q(v){return ne(As(v))}function B(v){const R=n.BYTES;v=Je("private key",v,R);const I=Je("hashed private key",i(v),2*R),_=F(I.slice(0,R)),u=I.slice(R,2*R),l=q(_);return{head:_,prefix:u,scalar:l}}function P(v){const{head:R,prefix:I,scalar:_}=B(v),u=z.multiply(_),l=u.toRawBytes();return{head:R,prefix:I,scalar:_,point:u,pointBytes:l}}function j(v){return P(v).pointBytes}function E(v=Uint8Array.of(),...R){const I=Or(...R);return q(i(C(I,Je("context",v),!!s)))}function c(v,R,I={}){v=Je("message",v),s&&(v=s(v));const{prefix:_,scalar:u,pointBytes:l}=P(R),w=E(I.context,_,v),T=z.multiply(w).toRawBytes(),D=E(I.context,T,l,v),W=ne(w+D*u);nn("signature.s",W,ln,r);const re=Or(T,gi(W,n.BYTES));return Je("result",re,n.BYTES*2)}const p=Zb;function y(v,R,I,_=p){const{context:u,zip215:l}=_,w=n.BYTES;v=Je("signature",v,2*w),R=Je("message",R),I=Je("publicKey",I,w),l!==void 0&&Ln("zip215",l),s&&(R=s(R));const T=As(v.slice(w,2*w));let D,W,re;try{D=L.fromHex(I,l),W=L.fromHex(v.slice(0,w),l),re=z.multiplyUnsafe(T)}catch{return!1}if(!l&&D.isSmallOrder())return!1;const oe=E(u,W.toRawBytes(),D.toRawBytes(),R);return W.add(D.multiplyUnsafe(oe)).subtract(re).clearCofactor().equals(L.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:j,sign:c,verify:y,ExtendedPoint:L,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(n.BYTES),precompute(v=8,R=L.BASE){return R._setWindowSize(v),R.multiply(BigInt(3)),R}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const cc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),_f=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Xb=BigInt(1),wf=BigInt(2);BigInt(3);const Qb=BigInt(5),e_=BigInt(8);function t_(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),i=cc,a=t*t%i*t%i,d=qe(a,wf,i)*a%i,m=qe(d,Xb,i)*t%i,g=qe(m,Qb,i)*m%i,x=qe(g,e,i)*g%i,O=qe(x,n,i)*x%i,N=qe(O,r,i)*O%i,F=qe(N,s,i)*N%i,C=qe(F,s,i)*N%i,k=qe(C,e,i)*g%i;return{pow_p_5_8:qe(k,wf,i)*t%i,b2:a}}function n_(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function r_(t,e){const n=cc,r=je(e*e*e,n),s=je(r*r*e,n),i=t_(t*s).pow_p_5_8;let o=je(t*r*i,n);const a=je(e*o*o,n),d=o,m=je(o*_f,n),g=a===t,x=a===je(-t,n),O=a===je(-t*_f,n);return g&&(o=d),(x||O)&&(o=m),Qy(o,n)&&(o=je(-o,n)),{isValid:g||x,value:o}}const Ef=Os(cc,void 0,!0),s_={a:Ef.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ef,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:e_,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:My,randomBytes:Ed,adjustScalarBytes:n_,uvRatio:r_},uc=Jb(s_);var Di={exports:{}};const i_=Ha(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var o_=Di.exports,vf;function Rf(){return vf||(vf=1,(function(t){(function(e,n){function r(E,c){if(!E)throw new Error(c||"Assertion failed")}function s(E,c){E.super_=c;var p=function(){};p.prototype=c.prototype,E.prototype=new p,E.prototype.constructor=E}function i(E,c,p){if(i.isBN(E))return E;this.negative=0,this.words=null,this.length=0,this.red=null,E!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(E||0,c||10,p||"be"))}typeof e=="object"?e.exports=i:n.BN=i,i.BN=i,i.wordSize=26;var o;try{typeof window<"u"&&typeof window.Buffer<"u"?o=window.Buffer:o=i_.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,y){if(typeof c=="number")return this._initNumber(c,p,y);if(typeof c=="object")return this._initArray(c,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(p===16?this._parseHex(c,A,y):(this._parseBase(c,p,A),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(c,p,y){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(c,p,y){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v,R,I=0;if(y==="be")for(A=c.length-1,v=0;A>=0;A-=3)R=c[A]|c[A-1]<<8|c[A-2]<<16,this.words[v]|=R<<I&67108863,this.words[v+1]=R>>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);else if(y==="le")for(A=0,v=0;A<c.length;A+=3)R=c[A]|c[A+1]<<8|c[A+2]<<16,this.words[v]|=R<<I&67108863,this.words[v+1]=R>>>26-I&67108863,I+=24,I>=26&&(I-=26,v++);return this._strip()};function a(E,c){var p=E.charCodeAt(c);if(p>=48&&p<=57)return p-48;if(p>=65&&p<=70)return p-55;if(p>=97&&p<=102)return p-87;r(!1,"Invalid character in "+E)}function d(E,c,p){var y=a(E,p);return p-1>=c&&(y|=a(E,p-1)<<4),y}i.prototype._parseHex=function(c,p,y){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v=0,R=0,I;if(y==="be")for(A=c.length-1;A>=p;A-=2)I=d(c,p,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8;else{var _=c.length-p;for(A=_%2===0?p+1:p;A<c.length;A+=2)I=d(c,p,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8}this._strip()};function m(E,c,p,y){for(var A=0,v=0,R=Math.min(E.length,p),I=c;I<R;I++){var _=E.charCodeAt(I)-48;A*=y,_>=49?v=_-49+10:_>=17?v=_-17+10:v=_,r(_>=0&&v<y,"Invalid character"),A+=v}return A}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var A=0,v=1;v<=67108863;v*=p)A++;A--,v=v/p|0;for(var R=c.length-y,I=R%A,_=Math.min(R,R-I)+y,u=0,l=y;l<_;l+=A)u=m(c,l,l+A,p),this.imuln(v),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(I!==0){var w=1;for(u=m(c,l,c.length,p),l=0;l<I;l++)w*=p;this.imuln(w),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},i.prototype.copy=function(c){c.words=new Array(this.length);for(var p=0;p<this.length;p++)c.words[p]=this.words[p];c.length=this.length,c.negative=this.negative,c.red=this.red};function g(E,c){E.words=c.words,E.length=c.length,E.negative=c.negative,E.red=c.red}if(i.prototype._move=function(c){g(c,this)},i.prototype.clone=function(){var c=new i(null);return this.copy(c),c},i.prototype._expand=function(c){for(;this.length<c;)this.words[this.length++]=0;return this},i.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},i.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=x}catch{i.prototype.inspect=x}else i.prototype.inspect=x;function x(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var O=["","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"],N=[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];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var y;if(c===16||c==="hex"){y="";for(var A=0,v=0,R=0;R<this.length;R++){var I=this.words[R],_=((I<<A|v)&16777215).toString(16);v=I>>>24-A&16777215,A+=2,A>=26&&(A-=26,R--),v!==0||R!==this.length-1?y=O[6-_.length]+_+y:y=_+y}for(v!==0&&(y=v.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(c===(c|0)&&c>=2&&c<=36){var u=N[c],l=F[c];y="";var w=this.clone();for(w.negative=0;!w.isZero();){var T=w.modrn(l).toString(c);w=w.idivn(l),w.isZero()?y=T+y:y=O[u-T.length]+T+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var C=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,y){this._strip();var A=this.byteLength(),v=y||Math.max(1,A);r(A<=v,"byte array longer than desired length"),r(v>0,"Requested array length <= 0");var R=C(c,v),I=p==="le"?"LE":"BE";return this["_toArrayLike"+I](R,A),R},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,A=0,v=0,R=0;v<this.length;v++){var I=this.words[v]<<R|A;c[y++]=I&255,y<c.length&&(c[y++]=I>>8&255),y<c.length&&(c[y++]=I>>16&255),R===6?(y<c.length&&(c[y++]=I>>24&255),A=0,R=0):(A=I>>>24,R+=2)}if(y<c.length)for(c[y++]=A;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,A=0,v=0,R=0;v<this.length;v++){var I=this.words[v]<<R|A;c[y--]=I&255,y>=0&&(c[y--]=I>>8&255),y>=0&&(c[y--]=I>>16&255),R===6?(y>=0&&(c[y--]=I>>24&255),A=0,R=0):(A=I>>>24,R+=2)}if(y>=0)for(c[y--]=A;y>=0;)c[y--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function k(E){for(var c=new Array(E.bitLength()),p=0;p<c.length;p++){var y=p/26|0,A=p%26;c[p]=E.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(c+=y,y!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,y;this.length>c.length?(p=this,y=c):(p=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=p.words[A]^y.words[A];if(this!==p)for(;A<p.length;A++)this.words[A]=p.words[A];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,y=c%26;this._expand(p),y>0&&p--;for(var A=0;A<p;A++)this.words[A]=~this.words[A]&67108863;return y>0&&(this.words[A]=~this.words[A]&67108863>>26-y),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var y,A;this.length>c.length?(y=this,A=c):(y=c,A=this);for(var v=0,R=0;R<A.length;R++)p=(y.words[R]|0)+(A.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;for(;v!==0&&R<y.length;R++)p=(y.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;if(this.length=y.length,v!==0)this.words[this.length]=v,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var y=this.cmp(c);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,v;y>0?(A=this,v=c):(A=c,v=this);for(var R=0,I=0;I<v.length;I++)p=(A.words[I]|0)-(v.words[I]|0)+R,R=p>>26,this.words[I]=p&67108863;for(;R!==0&&I<A.length;I++)p=(A.words[I]|0)+R,R=p>>26,this.words[I]=p&67108863;if(R===0&&I<A.length&&A!==this)for(;I<A.length;I++)this.words[I]=A.words[I];return this.length=Math.max(this.length,I),A!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function K(E,c,p){p.negative=c.negative^E.negative;var y=E.length+c.length|0;p.length=y,y=y-1|0;var A=E.words[0]|0,v=c.words[0]|0,R=A*v,I=R&67108863,_=R/67108864|0;p.words[0]=I;for(var u=1;u<y;u++){for(var l=_>>>26,w=_&67108863,T=Math.min(u,c.length-1),D=Math.max(0,u-E.length+1);D<=T;D++){var W=u-D|0;A=E.words[W]|0,v=c.words[D]|0,R=A*v+w,l+=R/67108864|0,w=R&67108863}p.words[u]=w|0,_=l|0}return _!==0?p.words[u]=_|0:p.length--,p._strip()}var Y=function(c,p,y){var A=c.words,v=p.words,R=y.words,I=0,_,u,l,w=A[0]|0,T=w&8191,D=w>>>13,W=A[1]|0,re=W&8191,oe=W>>>13,Ce=A[2]|0,Ee=Ce&8191,we=Ce>>>13,De=A[3]|0,ve=De&8191,Oe=De>>>13,mn=A[4]|0,Le=mn&8191,Ve=mn>>>13,Zr=A[5]|0,Fe=Zr&8191,Pe=Zr>>>13,Yt=A[6]|0,Ge=Yt&8191,Ze=Yt>>>13,an=A[7]|0,Ye=an&8191,b=an>>>13,f=A[8]|0,h=f&8191,S=f>>>13,U=A[9]|0,$=U&8191,Z=U>>>13,Re=v[0]|0,_e=Re&8191,ge=Re>>>13,$e=v[1]|0,he=$e&8191,et=$e>>>13,v0=v[2]|0,tt=v0&8191,nt=v0>>>13,R0=v[3]|0,rt=R0&8191,st=R0>>>13,A0=v[4]|0,it=A0&8191,ot=A0>>>13,x0=v[5]|0,at=x0&8191,ct=x0>>>13,S0=v[6]|0,ut=S0&8191,dt=S0>>>13,T0=v[7]|0,lt=T0&8191,ft=T0>>>13,O0=v[8]|0,ht=O0&8191,pt=O0>>>13,I0=v[9]|0,mt=I0&8191,gt=I0>>>13;y.negative=c.negative^p.negative,y.length=19,_=Math.imul(T,_e),u=Math.imul(T,ge),u=u+Math.imul(D,_e)|0,l=Math.imul(D,ge);var Qc=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(Qc>>>26)|0,Qc&=67108863,_=Math.imul(re,_e),u=Math.imul(re,ge),u=u+Math.imul(oe,_e)|0,l=Math.imul(oe,ge),_=_+Math.imul(T,he)|0,u=u+Math.imul(T,et)|0,u=u+Math.imul(D,he)|0,l=l+Math.imul(D,et)|0;var eu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(eu>>>26)|0,eu&=67108863,_=Math.imul(Ee,_e),u=Math.imul(Ee,ge),u=u+Math.imul(we,_e)|0,l=Math.imul(we,ge),_=_+Math.imul(re,he)|0,u=u+Math.imul(re,et)|0,u=u+Math.imul(oe,he)|0,l=l+Math.imul(oe,et)|0,_=_+Math.imul(T,tt)|0,u=u+Math.imul(T,nt)|0,u=u+Math.imul(D,tt)|0,l=l+Math.imul(D,nt)|0;var tu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(tu>>>26)|0,tu&=67108863,_=Math.imul(ve,_e),u=Math.imul(ve,ge),u=u+Math.imul(Oe,_e)|0,l=Math.imul(Oe,ge),_=_+Math.imul(Ee,he)|0,u=u+Math.imul(Ee,et)|0,u=u+Math.imul(we,he)|0,l=l+Math.imul(we,et)|0,_=_+Math.imul(re,tt)|0,u=u+Math.imul(re,nt)|0,u=u+Math.imul(oe,tt)|0,l=l+Math.imul(oe,nt)|0,_=_+Math.imul(T,rt)|0,u=u+Math.imul(T,st)|0,u=u+Math.imul(D,rt)|0,l=l+Math.imul(D,st)|0;var nu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(nu>>>26)|0,nu&=67108863,_=Math.imul(Le,_e),u=Math.imul(Le,ge),u=u+Math.imul(Ve,_e)|0,l=Math.imul(Ve,ge),_=_+Math.imul(ve,he)|0,u=u+Math.imul(ve,et)|0,u=u+Math.imul(Oe,he)|0,l=l+Math.imul(Oe,et)|0,_=_+Math.imul(Ee,tt)|0,u=u+Math.imul(Ee,nt)|0,u=u+Math.imul(we,tt)|0,l=l+Math.imul(we,nt)|0,_=_+Math.imul(re,rt)|0,u=u+Math.imul(re,st)|0,u=u+Math.imul(oe,rt)|0,l=l+Math.imul(oe,st)|0,_=_+Math.imul(T,it)|0,u=u+Math.imul(T,ot)|0,u=u+Math.imul(D,it)|0,l=l+Math.imul(D,ot)|0;var ru=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(ru>>>26)|0,ru&=67108863,_=Math.imul(Fe,_e),u=Math.imul(Fe,ge),u=u+Math.imul(Pe,_e)|0,l=Math.imul(Pe,ge),_=_+Math.imul(Le,he)|0,u=u+Math.imul(Le,et)|0,u=u+Math.imul(Ve,he)|0,l=l+Math.imul(Ve,et)|0,_=_+Math.imul(ve,tt)|0,u=u+Math.imul(ve,nt)|0,u=u+Math.imul(Oe,tt)|0,l=l+Math.imul(Oe,nt)|0,_=_+Math.imul(Ee,rt)|0,u=u+Math.imul(Ee,st)|0,u=u+Math.imul(we,rt)|0,l=l+Math.imul(we,st)|0,_=_+Math.imul(re,it)|0,u=u+Math.imul(re,ot)|0,u=u+Math.imul(oe,it)|0,l=l+Math.imul(oe,ot)|0,_=_+Math.imul(T,at)|0,u=u+Math.imul(T,ct)|0,u=u+Math.imul(D,at)|0,l=l+Math.imul(D,ct)|0;var su=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(su>>>26)|0,su&=67108863,_=Math.imul(Ge,_e),u=Math.imul(Ge,ge),u=u+Math.imul(Ze,_e)|0,l=Math.imul(Ze,ge),_=_+Math.imul(Fe,he)|0,u=u+Math.imul(Fe,et)|0,u=u+Math.imul(Pe,he)|0,l=l+Math.imul(Pe,et)|0,_=_+Math.imul(Le,tt)|0,u=u+Math.imul(Le,nt)|0,u=u+Math.imul(Ve,tt)|0,l=l+Math.imul(Ve,nt)|0,_=_+Math.imul(ve,rt)|0,u=u+Math.imul(ve,st)|0,u=u+Math.imul(Oe,rt)|0,l=l+Math.imul(Oe,st)|0,_=_+Math.imul(Ee,it)|0,u=u+Math.imul(Ee,ot)|0,u=u+Math.imul(we,it)|0,l=l+Math.imul(we,ot)|0,_=_+Math.imul(re,at)|0,u=u+Math.imul(re,ct)|0,u=u+Math.imul(oe,at)|0,l=l+Math.imul(oe,ct)|0,_=_+Math.imul(T,ut)|0,u=u+Math.imul(T,dt)|0,u=u+Math.imul(D,ut)|0,l=l+Math.imul(D,dt)|0;var iu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(iu>>>26)|0,iu&=67108863,_=Math.imul(Ye,_e),u=Math.imul(Ye,ge),u=u+Math.imul(b,_e)|0,l=Math.imul(b,ge),_=_+Math.imul(Ge,he)|0,u=u+Math.imul(Ge,et)|0,u=u+Math.imul(Ze,he)|0,l=l+Math.imul(Ze,et)|0,_=_+Math.imul(Fe,tt)|0,u=u+Math.imul(Fe,nt)|0,u=u+Math.imul(Pe,tt)|0,l=l+Math.imul(Pe,nt)|0,_=_+Math.imul(Le,rt)|0,u=u+Math.imul(Le,st)|0,u=u+Math.imul(Ve,rt)|0,l=l+Math.imul(Ve,st)|0,_=_+Math.imul(ve,it)|0,u=u+Math.imul(ve,ot)|0,u=u+Math.imul(Oe,it)|0,l=l+Math.imul(Oe,ot)|0,_=_+Math.imul(Ee,at)|0,u=u+Math.imul(Ee,ct)|0,u=u+Math.imul(we,at)|0,l=l+Math.imul(we,ct)|0,_=_+Math.imul(re,ut)|0,u=u+Math.imul(re,dt)|0,u=u+Math.imul(oe,ut)|0,l=l+Math.imul(oe,dt)|0,_=_+Math.imul(T,lt)|0,u=u+Math.imul(T,ft)|0,u=u+Math.imul(D,lt)|0,l=l+Math.imul(D,ft)|0;var ou=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(ou>>>26)|0,ou&=67108863,_=Math.imul(h,_e),u=Math.imul(h,ge),u=u+Math.imul(S,_e)|0,l=Math.imul(S,ge),_=_+Math.imul(Ye,he)|0,u=u+Math.imul(Ye,et)|0,u=u+Math.imul(b,he)|0,l=l+Math.imul(b,et)|0,_=_+Math.imul(Ge,tt)|0,u=u+Math.imul(Ge,nt)|0,u=u+Math.imul(Ze,tt)|0,l=l+Math.imul(Ze,nt)|0,_=_+Math.imul(Fe,rt)|0,u=u+Math.imul(Fe,st)|0,u=u+Math.imul(Pe,rt)|0,l=l+Math.imul(Pe,st)|0,_=_+Math.imul(Le,it)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(Ve,it)|0,l=l+Math.imul(Ve,ot)|0,_=_+Math.imul(ve,at)|0,u=u+Math.imul(ve,ct)|0,u=u+Math.imul(Oe,at)|0,l=l+Math.imul(Oe,ct)|0,_=_+Math.imul(Ee,ut)|0,u=u+Math.imul(Ee,dt)|0,u=u+Math.imul(we,ut)|0,l=l+Math.imul(we,dt)|0,_=_+Math.imul(re,lt)|0,u=u+Math.imul(re,ft)|0,u=u+Math.imul(oe,lt)|0,l=l+Math.imul(oe,ft)|0,_=_+Math.imul(T,ht)|0,u=u+Math.imul(T,pt)|0,u=u+Math.imul(D,ht)|0,l=l+Math.imul(D,pt)|0;var au=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(au>>>26)|0,au&=67108863,_=Math.imul($,_e),u=Math.imul($,ge),u=u+Math.imul(Z,_e)|0,l=Math.imul(Z,ge),_=_+Math.imul(h,he)|0,u=u+Math.imul(h,et)|0,u=u+Math.imul(S,he)|0,l=l+Math.imul(S,et)|0,_=_+Math.imul(Ye,tt)|0,u=u+Math.imul(Ye,nt)|0,u=u+Math.imul(b,tt)|0,l=l+Math.imul(b,nt)|0,_=_+Math.imul(Ge,rt)|0,u=u+Math.imul(Ge,st)|0,u=u+Math.imul(Ze,rt)|0,l=l+Math.imul(Ze,st)|0,_=_+Math.imul(Fe,it)|0,u=u+Math.imul(Fe,ot)|0,u=u+Math.imul(Pe,it)|0,l=l+Math.imul(Pe,ot)|0,_=_+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(Ve,at)|0,l=l+Math.imul(Ve,ct)|0,_=_+Math.imul(ve,ut)|0,u=u+Math.imul(ve,dt)|0,u=u+Math.imul(Oe,ut)|0,l=l+Math.imul(Oe,dt)|0,_=_+Math.imul(Ee,lt)|0,u=u+Math.imul(Ee,ft)|0,u=u+Math.imul(we,lt)|0,l=l+Math.imul(we,ft)|0,_=_+Math.imul(re,ht)|0,u=u+Math.imul(re,pt)|0,u=u+Math.imul(oe,ht)|0,l=l+Math.imul(oe,pt)|0,_=_+Math.imul(T,mt)|0,u=u+Math.imul(T,gt)|0,u=u+Math.imul(D,mt)|0,l=l+Math.imul(D,gt)|0;var cu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(cu>>>26)|0,cu&=67108863,_=Math.imul($,he),u=Math.imul($,et),u=u+Math.imul(Z,he)|0,l=Math.imul(Z,et),_=_+Math.imul(h,tt)|0,u=u+Math.imul(h,nt)|0,u=u+Math.imul(S,tt)|0,l=l+Math.imul(S,nt)|0,_=_+Math.imul(Ye,rt)|0,u=u+Math.imul(Ye,st)|0,u=u+Math.imul(b,rt)|0,l=l+Math.imul(b,st)|0,_=_+Math.imul(Ge,it)|0,u=u+Math.imul(Ge,ot)|0,u=u+Math.imul(Ze,it)|0,l=l+Math.imul(Ze,ot)|0,_=_+Math.imul(Fe,at)|0,u=u+Math.imul(Fe,ct)|0,u=u+Math.imul(Pe,at)|0,l=l+Math.imul(Pe,ct)|0,_=_+Math.imul(Le,ut)|0,u=u+Math.imul(Le,dt)|0,u=u+Math.imul(Ve,ut)|0,l=l+Math.imul(Ve,dt)|0,_=_+Math.imul(ve,lt)|0,u=u+Math.imul(ve,ft)|0,u=u+Math.imul(Oe,lt)|0,l=l+Math.imul(Oe,ft)|0,_=_+Math.imul(Ee,ht)|0,u=u+Math.imul(Ee,pt)|0,u=u+Math.imul(we,ht)|0,l=l+Math.imul(we,pt)|0,_=_+Math.imul(re,mt)|0,u=u+Math.imul(re,gt)|0,u=u+Math.imul(oe,mt)|0,l=l+Math.imul(oe,gt)|0;var uu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(uu>>>26)|0,uu&=67108863,_=Math.imul($,tt),u=Math.imul($,nt),u=u+Math.imul(Z,tt)|0,l=Math.imul(Z,nt),_=_+Math.imul(h,rt)|0,u=u+Math.imul(h,st)|0,u=u+Math.imul(S,rt)|0,l=l+Math.imul(S,st)|0,_=_+Math.imul(Ye,it)|0,u=u+Math.imul(Ye,ot)|0,u=u+Math.imul(b,it)|0,l=l+Math.imul(b,ot)|0,_=_+Math.imul(Ge,at)|0,u=u+Math.imul(Ge,ct)|0,u=u+Math.imul(Ze,at)|0,l=l+Math.imul(Ze,ct)|0,_=_+Math.imul(Fe,ut)|0,u=u+Math.imul(Fe,dt)|0,u=u+Math.imul(Pe,ut)|0,l=l+Math.imul(Pe,dt)|0,_=_+Math.imul(Le,lt)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(Ve,lt)|0,l=l+Math.imul(Ve,ft)|0,_=_+Math.imul(ve,ht)|0,u=u+Math.imul(ve,pt)|0,u=u+Math.imul(Oe,ht)|0,l=l+Math.imul(Oe,pt)|0,_=_+Math.imul(Ee,mt)|0,u=u+Math.imul(Ee,gt)|0,u=u+Math.imul(we,mt)|0,l=l+Math.imul(we,gt)|0;var du=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(du>>>26)|0,du&=67108863,_=Math.imul($,rt),u=Math.imul($,st),u=u+Math.imul(Z,rt)|0,l=Math.imul(Z,st),_=_+Math.imul(h,it)|0,u=u+Math.imul(h,ot)|0,u=u+Math.imul(S,it)|0,l=l+Math.imul(S,ot)|0,_=_+Math.imul(Ye,at)|0,u=u+Math.imul(Ye,ct)|0,u=u+Math.imul(b,at)|0,l=l+Math.imul(b,ct)|0,_=_+Math.imul(Ge,ut)|0,u=u+Math.imul(Ge,dt)|0,u=u+Math.imul(Ze,ut)|0,l=l+Math.imul(Ze,dt)|0,_=_+Math.imul(Fe,lt)|0,u=u+Math.imul(Fe,ft)|0,u=u+Math.imul(Pe,lt)|0,l=l+Math.imul(Pe,ft)|0,_=_+Math.imul(Le,ht)|0,u=u+Math.imul(Le,pt)|0,u=u+Math.imul(Ve,ht)|0,l=l+Math.imul(Ve,pt)|0,_=_+Math.imul(ve,mt)|0,u=u+Math.imul(ve,gt)|0,u=u+Math.imul(Oe,mt)|0,l=l+Math.imul(Oe,gt)|0;var lu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(lu>>>26)|0,lu&=67108863,_=Math.imul($,it),u=Math.imul($,ot),u=u+Math.imul(Z,it)|0,l=Math.imul(Z,ot),_=_+Math.imul(h,at)|0,u=u+Math.imul(h,ct)|0,u=u+Math.imul(S,at)|0,l=l+Math.imul(S,ct)|0,_=_+Math.imul(Ye,ut)|0,u=u+Math.imul(Ye,dt)|0,u=u+Math.imul(b,ut)|0,l=l+Math.imul(b,dt)|0,_=_+Math.imul(Ge,lt)|0,u=u+Math.imul(Ge,ft)|0,u=u+Math.imul(Ze,lt)|0,l=l+Math.imul(Ze,ft)|0,_=_+Math.imul(Fe,ht)|0,u=u+Math.imul(Fe,pt)|0,u=u+Math.imul(Pe,ht)|0,l=l+Math.imul(Pe,pt)|0,_=_+Math.imul(Le,mt)|0,u=u+Math.imul(Le,gt)|0,u=u+Math.imul(Ve,mt)|0,l=l+Math.imul(Ve,gt)|0;var fu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(fu>>>26)|0,fu&=67108863,_=Math.imul($,at),u=Math.imul($,ct),u=u+Math.imul(Z,at)|0,l=Math.imul(Z,ct),_=_+Math.imul(h,ut)|0,u=u+Math.imul(h,dt)|0,u=u+Math.imul(S,ut)|0,l=l+Math.imul(S,dt)|0,_=_+Math.imul(Ye,lt)|0,u=u+Math.imul(Ye,ft)|0,u=u+Math.imul(b,lt)|0,l=l+Math.imul(b,ft)|0,_=_+Math.imul(Ge,ht)|0,u=u+Math.imul(Ge,pt)|0,u=u+Math.imul(Ze,ht)|0,l=l+Math.imul(Ze,pt)|0,_=_+Math.imul(Fe,mt)|0,u=u+Math.imul(Fe,gt)|0,u=u+Math.imul(Pe,mt)|0,l=l+Math.imul(Pe,gt)|0;var hu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(hu>>>26)|0,hu&=67108863,_=Math.imul($,ut),u=Math.imul($,dt),u=u+Math.imul(Z,ut)|0,l=Math.imul(Z,dt),_=_+Math.imul(h,lt)|0,u=u+Math.imul(h,ft)|0,u=u+Math.imul(S,lt)|0,l=l+Math.imul(S,ft)|0,_=_+Math.imul(Ye,ht)|0,u=u+Math.imul(Ye,pt)|0,u=u+Math.imul(b,ht)|0,l=l+Math.imul(b,pt)|0,_=_+Math.imul(Ge,mt)|0,u=u+Math.imul(Ge,gt)|0,u=u+Math.imul(Ze,mt)|0,l=l+Math.imul(Ze,gt)|0;var pu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(pu>>>26)|0,pu&=67108863,_=Math.imul($,lt),u=Math.imul($,ft),u=u+Math.imul(Z,lt)|0,l=Math.imul(Z,ft),_=_+Math.imul(h,ht)|0,u=u+Math.imul(h,pt)|0,u=u+Math.imul(S,ht)|0,l=l+Math.imul(S,pt)|0,_=_+Math.imul(Ye,mt)|0,u=u+Math.imul(Ye,gt)|0,u=u+Math.imul(b,mt)|0,l=l+Math.imul(b,gt)|0;var mu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(mu>>>26)|0,mu&=67108863,_=Math.imul($,ht),u=Math.imul($,pt),u=u+Math.imul(Z,ht)|0,l=Math.imul(Z,pt),_=_+Math.imul(h,mt)|0,u=u+Math.imul(h,gt)|0,u=u+Math.imul(S,mt)|0,l=l+Math.imul(S,gt)|0;var gu=(I+_|0)+((u&8191)<<13)|0;I=(l+(u>>>13)|0)+(gu>>>26)|0,gu&=67108863,_=Math.imul($,mt),u=Math.imul($,gt),u=u+Math.imul(Z,mt)|0,l=Math.imul(Z,gt);var yu=(I+_|0)+((u&8191)<<13)|0;return I=(l+(u>>>13)|0)+(yu>>>26)|0,yu&=67108863,R[0]=Qc,R[1]=eu,R[2]=tu,R[3]=nu,R[4]=ru,R[5]=su,R[6]=iu,R[7]=ou,R[8]=au,R[9]=cu,R[10]=uu,R[11]=du,R[12]=lu,R[13]=fu,R[14]=hu,R[15]=pu,R[16]=mu,R[17]=gu,R[18]=yu,I!==0&&(R[19]=I,y.length++),y};Math.imul||(Y=K);function V(E,c,p){p.negative=c.negative^E.negative,p.length=E.length+c.length;for(var y=0,A=0,v=0;v<p.length-1;v++){var R=A;A=0;for(var I=y&67108863,_=Math.min(v,c.length-1),u=Math.max(0,v-E.length+1);u<=_;u++){var l=v-u,w=E.words[l]|0,T=c.words[u]|0,D=w*T,W=D&67108863;R=R+(D/67108864|0)|0,W=W+I|0,I=W&67108863,R=R+(W>>>26)|0,A+=R>>>26,R&=67108863}p.words[v]=I,y=R,R=A}return y!==0?p.words[v]=y:p.length--,p._strip()}function L(E,c,p){return V(E,c,p)}i.prototype.mulTo=function(c,p){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=Y(this,c,p):A<63?y=K(this,c,p):A<1024?y=V(this,c,p):y=L(this,c,p),y},i.prototype.mul=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),this.mulTo(c,p)},i.prototype.mulf=function(c){var p=new i(null);return p.words=new Array(this.length+c.length),L(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var y=0,A=0;A<this.length;A++){var v=(this.words[A]|0)*c,R=(v&67108863)+(y&67108863);y>>=26,y+=v/67108864|0,y+=R>>>26,this.words[A]=R&67108863}return y!==0&&(this.words[A]=y,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=k(c);if(p.length===0)return new i(1);for(var y=this,A=0;A<p.length&&p[A]===0;A++,y=y.sqr());if(++A<p.length)for(var v=y.sqr();A<p.length;A++,v=v.sqr())p[A]!==0&&(y=y.mul(v));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=67108863>>>26-p<<26-p,v;if(p!==0){var R=0;for(v=0;v<this.length;v++){var I=this.words[v]&A,_=(this.words[v]|0)-I<<p;this.words[v]=_|R,R=I>>>26-p}R&&(this.words[v]=R,this.length++)}if(y!==0){for(v=this.length-1;v>=0;v--)this.words[v+y]=this.words[v];for(v=0;v<y;v++)this.words[v]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,y){r(typeof c=="number"&&c>=0);var A;p?A=(p-p%26)/26:A=0;var v=c%26,R=Math.min((c-v)/26,this.length),I=67108863^67108863>>>v<<v,_=y;if(A-=R,A=Math.max(0,A),_){for(var u=0;u<R;u++)_.words[u]=this.words[u];_.length=R}if(R!==0)if(this.length>R)for(this.length-=R,u=0;u<this.length;u++)this.words[u]=this.words[u+R];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=A);u--){var w=this.words[u]|0;this.words[u]=l<<26-v|w>>>v,l=w&I}return _&&l!==0&&(_.words[_.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,y){return r(this.negative===0),this.iushrn(c,p,y)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return!1;var v=this.words[y];return!!(v&A)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var A=67108863^67108863>>>p<<p;this.words[this.length-1]&=A}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,y){var A=c.length+y,v;this._expand(A);var R,I=0;for(v=0;v<c.length;v++){R=(this.words[v+y]|0)+I;var _=(c.words[v]|0)*p;R-=_&67108863,I=(R>>26)-(_/67108864|0),this.words[v+y]=R&67108863}for(;v<this.length-y;v++)R=(this.words[v+y]|0)+I,I=R>>26,this.words[v+y]=R&67108863;if(I===0)return this._strip();for(r(I===-1),I=0,v=0;v<this.length;v++)R=-(this.words[v]|0)+I,I=R>>26,this.words[v]=R&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,A=this.clone(),v=c,R=v.words[v.length-1]|0,I=this._countBits(R);y=26-I,y!==0&&(v=v.ushln(y),A.iushln(y),R=v.words[v.length-1]|0);var _=A.length-v.length,u;if(p!=="mod"){u=new i(null),u.length=_+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var w=A.clone()._ishlnsubmul(v,1,_);w.negative===0&&(A=w,u&&(u.words[_]=1));for(var T=_-1;T>=0;T--){var D=(A.words[v.length+T]|0)*67108864+(A.words[v.length+T-1]|0);for(D=Math.min(D/R|0,67108863),A._ishlnsubmul(v,D,T);A.negative!==0;)D--,A.negative=0,A._ishlnsubmul(v,1,T),A.isZero()||(A.negative^=1);u&&(u.words[T]=D)}return u&&u._strip(),A._strip(),p!=="div"&&y!==0&&A.iushrn(y),{div:u||null,mod:A}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var A,v,R;return this.negative!==0&&c.negative===0?(R=this.neg().divmod(c,p),p!=="mod"&&(A=R.div.neg()),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.iadd(c)),{div:A,mod:v}):this.negative===0&&c.negative!==0?(R=this.divmod(c.neg(),p),p!=="mod"&&(A=R.div.neg()),{div:A,mod:R.mod}):(this.negative&c.negative)!==0?(R=this.neg().divmod(c.neg(),p),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.isub(c)),{div:R.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(c):p.mod,A=c.ushrn(1),v=c.andln(1),R=y.cmp(A);return R<0||v===1&&R===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=(1<<26)%c,A=0,v=this.length-1;v>=0;v--)A=(y*A+(this.words[v]|0))%c;return p?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=0,A=this.length-1;A>=0;A--){var v=(this.words[A]|0)+y*67108864;this.words[A]=v/c|0,y=v%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=new i(0),I=new i(1),_=0;p.isEven()&&y.isEven();)p.iushrn(1),y.iushrn(1),++_;for(var u=y.clone(),l=p.clone();!p.isZero();){for(var w=0,T=1;(p.words[0]&T)===0&&w<26;++w,T<<=1);if(w>0)for(p.iushrn(w);w-- >0;)(A.isOdd()||v.isOdd())&&(A.iadd(u),v.isub(l)),A.iushrn(1),v.iushrn(1);for(var D=0,W=1;(y.words[0]&W)===0&&D<26;++D,W<<=1);if(D>0)for(y.iushrn(D);D-- >0;)(R.isOdd()||I.isOdd())&&(R.iadd(u),I.isub(l)),R.iushrn(1),I.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(R),v.isub(I)):(y.isub(p),R.isub(A),I.isub(v))}return{a:R,b:I,gcd:y.iushln(_)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var I=0,_=1;(p.words[0]&_)===0&&I<26;++I,_<<=1);if(I>0)for(p.iushrn(I);I-- >0;)A.isOdd()&&A.iadd(R),A.iushrn(1);for(var u=0,l=1;(y.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(y.iushrn(u);u-- >0;)v.isOdd()&&v.iadd(R),v.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(v)):(y.isub(p),v.isub(A))}var w;return p.cmpn(1)===0?w=A:w=v,w.cmpn(0)<0&&w.iadd(c),w},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),y=c.clone();p.negative=0,y.negative=0;for(var A=0;p.isEven()&&y.isEven();A++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var v=p.cmp(y);if(v<0){var R=p;p=y,y=R}else if(v===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(A)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=A,this;for(var v=A,R=y;v!==0&&R<this.length;R++){var I=this.words[R]|0;I+=v,v=I>>>26,I&=67108863,this.words[R]=I}return v!==0&&(this.words[R]=v,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var A=this.words[0]|0;y=A===c?0:A<c?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,v=c.words[y]|0;if(A!==v){A<v?p=-1:A>v&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new P(c)},i.prototype.toRed=function(c){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(c){return this.red=c,this},i.prototype.forceRed=function(c){return r(!this.red,"Already a number in reduction context"),this._forceRed(c)},i.prototype.redAdd=function(c){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},i.prototype.redIAdd=function(c){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},i.prototype.redSub=function(c){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},i.prototype.redISub=function(c){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},i.prototype.redShl=function(c){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},i.prototype.redMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},i.prototype.redIMul=function(c){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(c){return r(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var z={k256:null,p224:null,p192:null,p25519:null};function J(E,c){this.name=E,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},J.prototype.ireduce=function(c){var p=c,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var A=y<this.n?-1:p.ucmp(this.p);return A===0?(p.words[0]=0,p.length=1):A>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},J.prototype.split=function(c,p){c.iushrn(this.n,0,p)},J.prototype.imulK=function(c){return c.imul(this.k)};function te(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(te,J),te.prototype.split=function(c,p){for(var y=4194303,A=Math.min(c.length,9),v=0;v<A;v++)p.words[v]=c.words[v];if(p.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var R=c.words[9];for(p.words[p.length++]=R&y,v=10;v<c.length;v++){var I=c.words[v]|0;c.words[v-10]=(I&y)<<4|R>>>22,R=I}R>>>=22,c.words[v-10]=R,R===0&&c.length>10?c.length-=10:c.length-=9},te.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,y=0;y<c.length;y++){var A=c.words[y]|0;p+=A*977,c.words[y]=p&67108863,p=A*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function ne(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(ne,J);function q(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(q,J);function B(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(B,J),B.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+p,v=A&67108863;A>>>=26,c.words[y]=v,p=A}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(z[c])return z[c];var p;if(c==="k256")p=new te;else if(c==="p224")p=new ne;else if(c==="p192")p=new q;else if(c==="p25519")p=new B;else throw new Error("Unknown prime "+c);return z[c]=p,p};function P(E){if(typeof E=="string"){var c=i._prime(E);this.m=c.p,this.prime=c}else r(E.gtn(1),"modulus must be greater than 1"),this.m=E,this.prime=null}P.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},P.prototype._verify2=function(c,p){r((c.negative|p.negative)===0,"red works only with positives"),r(c.red&&c.red===p.red,"red works only with red numbers")},P.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(g(c,c.umod(this.m)._forceRed(this)),c)},P.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},P.prototype.add=function(c,p){this._verify2(c,p);var y=c.add(p);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},P.prototype.iadd=function(c,p){this._verify2(c,p);var y=c.iadd(p);return y.cmp(this.m)>=0&&y.isub(this.m),y},P.prototype.sub=function(c,p){this._verify2(c,p);var y=c.sub(p);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},P.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},P.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},P.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},P.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},P.prototype.isqr=function(c){return this.imul(c,c.clone())},P.prototype.sqr=function(c){return this.mul(c,c)},P.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(c,y)}for(var A=this.m.subn(1),v=0;!A.isZero()&&A.andln(1)===0;)v++,A.iushrn(1);r(!A.isZero());var R=new i(1).toRed(this),I=R.redNeg(),_=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,_).cmp(I)!==0;)u.redIAdd(I);for(var l=this.pow(u,A),w=this.pow(c,A.addn(1).iushrn(1)),T=this.pow(c,A),D=v;T.cmp(R)!==0;){for(var W=T,re=0;W.cmp(R)!==0;re++)W=W.redSqr();r(re<D);var oe=this.pow(l,new i(1).iushln(D-re-1));w=w.redMul(oe),l=oe.redSqr(),T=T.redMul(l),D=re}return w},P.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},P.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var y=4,A=new Array(1<<y);A[0]=new i(1).toRed(this),A[1]=c;for(var v=2;v<A.length;v++)A[v]=this.mul(A[v-1],c);var R=A[0],I=0,_=0,u=p.bitLength()%26;for(u===0&&(u=26),v=p.length-1;v>=0;v--){for(var l=p.words[v],w=u-1;w>=0;w--){var T=l>>w&1;if(R!==A[0]&&(R=this.sqr(R)),T===0&&I===0){_=0;continue}I<<=1,I|=T,_++,!(_!==y&&(v!==0||w!==0))&&(R=this.mul(R,A[I]),_=0,I=0)}u=26}return R},P.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},P.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new j(c)};function j(E){P.call(this,E),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(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)}s(j,P),j.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},j.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},j.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},j.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},j.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,o_)})(Di)),Di.exports}var a_=Rf();const Af=Ga(a_);var Fi={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var xf;function c_(){return xf||(xf=1,(function(t,e){var n=ac(),r=n.Buffer;function s(o,a){for(var d in o)a[d]=o[d]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(s(n,e),e.Buffer=i);function i(o,a,d){return r(o,a,d)}i.prototype=Object.create(r.prototype),s(r,i),i.from=function(o,a,d){if(typeof o=="number")throw new TypeError("Argument must not be a number");return r(o,a,d)},i.alloc=function(o,a,d){if(typeof o!="number")throw new TypeError("Argument must be a number");var m=r(o);return a!==void 0?typeof d=="string"?m.fill(a,d):m.fill(a):m.fill(0),m},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(o)}})(Fi,Fi.exports)),Fi.exports}var dc,Sf;function u_(){if(Sf)return dc;Sf=1;var t=c_().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<n.length;i++){var o=n.charAt(i),a=o.charCodeAt(0);if(r[a]!==255)throw new TypeError(o+" is ambiguous");r[a]=i}var d=n.length,m=n.charAt(0),g=Math.log(d)/Math.log(256),x=Math.log(256)/Math.log(d);function O(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=t.from(C)),!t.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var k=0,K=0,Y=0,V=C.length;Y!==V&&C[Y]===0;)Y++,k++;for(var L=(V-Y)*x+1>>>0,z=new Uint8Array(L);Y!==V;){for(var J=C[Y],te=0,ne=L-1;(J!==0||te<K)&&ne!==-1;ne--,te++)J+=256*z[ne]>>>0,z[ne]=J%d>>>0,J=J/d>>>0;if(J!==0)throw new Error("Non-zero carry");K=te,Y++}for(var q=L-K;q!==L&&z[q]===0;)q++;for(var B=m.repeat(k);q<L;++q)B+=n.charAt(z[q]);return B}function N(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return t.alloc(0);for(var k=0,K=0,Y=0;C[k]===m;)K++,k++;for(var V=(C.length-k)*g+1>>>0,L=new Uint8Array(V);k<C.length;){var z=C.charCodeAt(k);if(z>255)return;var J=r[z];if(J===255)return;for(var te=0,ne=V-1;(J!==0||te<Y)&&ne!==-1;ne--,te++)J+=d*L[ne]>>>0,L[ne]=J%256>>>0,J=J/256>>>0;if(J!==0)throw new Error("Non-zero carry");Y=te,k++}for(var q=V-Y;q!==V&&L[q]===0;)q++;var B=t.allocUnsafe(K+(V-q));B.fill(0,0,K);for(var P=K;q!==V;)B[P++]=L[q++];return B}function F(C){var k=N(C);if(k)return k;throw new Error("Non-base"+d+" character")}return{encode:O,decodeUnsafe:N,decode:F}}return dc=e,dc}var lc,Tf;function Of(){if(Tf)return lc;Tf=1;var t=u_(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return lc=t(e),lc}var d_=Of();const Dt=Ga(d_);var Be={};function Tn(t,e,n){return e<=t&&t<=n}function $i(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function l_(t){for(var e=String(t),n=e.length,r=0,s=[];r<n;){var i=e.charCodeAt(r);if(i<55296||i>57343)s.push(i);else if(56320<=i&&i<=57343)s.push(65533);else if(55296<=i&&i<=56319)if(r===n-1)s.push(65533);else{var o=t.charCodeAt(r+1);if(56320<=o&&o<=57343){var a=i&1023,d=o&1023;s.push(65536+(a<<10)+d),r+=1}else s.push(65533)}r+=1}return s}function f_(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var zi=-1;function fc(t){this.tokens=[].slice.call(t)}fc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():zi},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var Lr=-1;function hc(t,e){if(t)throw TypeError("Decoder error");return e||65533}var ji="utf-8";function Vi(t,e){if(!(this instanceof Vi))return new Vi(t,e);if(t=t!==void 0?String(t).toLowerCase():ji,t!==ji)throw new Error("Encoding not supported. Only utf-8 is supported");e=$i(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Vi.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=$i(n),this._streaming||(this._decoder=new h_({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var s=new fc(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Lr);)o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o));if(!this._streaming){do{if(o=this._decoder.handler(s,s.read()),o===Lr)break;o!==null&&(Array.isArray(o)?i.push.apply(i,o):i.push(o))}while(!s.endOfStream());this._decoder=null}return i.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(i[0]===65279?(this._BOMseen=!0,i.shift()):this._BOMseen=!0),f_(i)}};function Gi(t,e){if(!(this instanceof Gi))return new Gi(t,e);if(t=t!==void 0?String(t).toLowerCase():ji,t!==ji)throw new Error("Encoding not supported. Only utf-8 is supported");e=$i(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Gi.prototype={encode:function(e,n){e=e?String(e):"",n=$i(n),this._streaming||(this._encoder=new p_(this._options)),this._streaming=!!n.stream;for(var r=[],s=new fc(l_(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Lr);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Lr;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function h_(t){var e=t.fatal,n=0,r=0,s=0,i=128,o=191;this.handler=function(a,d){if(d===zi&&s!==0)return s=0,hc(e);if(d===zi)return Lr;if(s===0){if(Tn(d,0,127))return d;if(Tn(d,194,223))s=1,n=d-192;else if(Tn(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,n=d-224;else if(Tn(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,n=d-240;else return hc(e);return n=n<<6*s,null}if(!Tn(d,i,o))return n=s=r=0,i=128,o=191,a.prepend(d),hc(e);if(i=128,o=191,r+=1,n+=d-128<<6*(s-r),r!==s)return null;var m=n;return n=s=r=0,m}}function p_(t){t.fatal,this.handler=function(e,n){if(n===zi)return Lr;if(Tn(n,0,127))return n;var r,s;Tn(n,128,2047)?(r=1,s=192):Tn(n,2048,65535)?(r=2,s=224):Tn(n,65536,1114111)&&(r=3,s=240);for(var i=[(n>>6*r)+s];r>0;){var o=n>>6*(r-1);i.push(128|o&63),r-=1}return i}}const m_=Ha(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Vi,TextEncoder:Gi},Symbol.toStringTag,{value:"Module"})));var If;function g_(){if(If)return Be;If=1;var t=Be&&Be.__createBinding||(Object.create?(function(q,B,P,j){j===void 0&&(j=P),Object.defineProperty(q,j,{enumerable:!0,get:function(){return B[P]}})}):(function(q,B,P,j){j===void 0&&(j=P),q[j]=B[P]})),e=Be&&Be.__setModuleDefault||(Object.create?(function(q,B){Object.defineProperty(q,"default",{enumerable:!0,value:B})}):function(q,B){q.default=B}),n=Be&&Be.__decorate||function(q,B,P,j){var E=arguments.length,c=E<3?B:j===null?j=Object.getOwnPropertyDescriptor(B,P):j,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(q,B,P,j);else for(var y=q.length-1;y>=0;y--)(p=q[y])&&(c=(E<3?p(c):E>3?p(B,P,c):p(B,P))||c);return E>3&&c&&Object.defineProperty(B,P,c),c},r=Be&&Be.__importStar||function(q){if(q&&q.__esModule)return q;var B={};if(q!=null)for(var P in q)P!=="default"&&Object.hasOwnProperty.call(q,P)&&t(B,q,P);return e(B,q),B},s=Be&&Be.__importDefault||function(q){return q&&q.__esModule?q:{default:q}};Object.defineProperty(Be,"__esModule",{value:!0}),Be.deserializeUnchecked=Be.deserialize=Be.serialize=Be.BinaryReader=Be.BinaryWriter=Be.BorshError=Be.baseDecode=Be.baseEncode=void 0;const i=s(Rf()),o=s(Of()),a=r(m_),d=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,m=new d("utf-8",{fatal:!0});function g(q){return typeof q=="string"&&(q=Buffer.from(q,"utf8")),o.default.encode(Buffer.from(q))}Be.baseEncode=g;function x(q){return Buffer.from(o.default.decode(q))}Be.baseDecode=x;const O=1024;class N extends Error{constructor(B){super(B),this.fieldPath=[],this.originalMessage=B}addToFieldPath(B){this.fieldPath.splice(0,0,B),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Be.BorshError=N;class F{constructor(){this.buf=Buffer.alloc(O),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(O)]))}writeU8(B){this.maybeResize(),this.buf.writeUInt8(B,this.length),this.length+=1}writeU16(B){this.maybeResize(),this.buf.writeUInt16LE(B,this.length),this.length+=2}writeU32(B){this.maybeResize(),this.buf.writeUInt32LE(B,this.length),this.length+=4}writeU64(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",8)))}writeU128(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",16)))}writeU256(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",32)))}writeU512(B){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(B).toArray("le",64)))}writeBuffer(B){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),B,Buffer.alloc(O)]),this.length+=B.length}writeString(B){this.maybeResize();const P=Buffer.from(B,"utf8");this.writeU32(P.length),this.writeBuffer(P)}writeFixedArray(B){this.writeBuffer(Buffer.from(B))}writeArray(B,P){this.maybeResize(),this.writeU32(B.length);for(const j of B)this.maybeResize(),P(j)}toArray(){return this.buf.subarray(0,this.length)}}Be.BinaryWriter=F;function C(q,B,P){const j=P.value;P.value=function(...E){try{return j.apply(this,E)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new N("Reached the end of buffer when deserializing")}throw c}}}class k{constructor(B){this.buf=B,this.offset=0}readU8(){const B=this.buf.readUInt8(this.offset);return this.offset+=1,B}readU16(){const B=this.buf.readUInt16LE(this.offset);return this.offset+=2,B}readU32(){const B=this.buf.readUInt32LE(this.offset);return this.offset+=4,B}readU64(){const B=this.readBuffer(8);return new i.default(B,"le")}readU128(){const B=this.readBuffer(16);return new i.default(B,"le")}readU256(){const B=this.readBuffer(32);return new i.default(B,"le")}readU512(){const B=this.readBuffer(64);return new i.default(B,"le")}readBuffer(B){if(this.offset+B>this.buf.length)throw new N(`Expected buffer length ${B} isn't within bounds`);const P=this.buf.slice(this.offset,this.offset+B);return this.offset+=B,P}readString(){const B=this.readU32(),P=this.readBuffer(B);try{return m.decode(P)}catch(j){throw new N(`Error decoding UTF-8 string: ${j}`)}}readFixedArray(B){return new Uint8Array(this.readBuffer(B))}readArray(B){const P=this.readU32(),j=Array();for(let E=0;E<P;++E)j.push(B());return j}}n([C],k.prototype,"readU8",null),n([C],k.prototype,"readU16",null),n([C],k.prototype,"readU32",null),n([C],k.prototype,"readU64",null),n([C],k.prototype,"readU128",null),n([C],k.prototype,"readU256",null),n([C],k.prototype,"readU512",null),n([C],k.prototype,"readString",null),n([C],k.prototype,"readFixedArray",null),n([C],k.prototype,"readArray",null),Be.BinaryReader=k;function K(q){return q.charAt(0).toUpperCase()+q.slice(1)}function Y(q,B,P,j,E){try{if(typeof j=="string")E[`write${K(j)}`](P);else if(j instanceof Array)if(typeof j[0]=="number"){if(P.length!==j[0])throw new N(`Expecting byte array of length ${j[0]}, but got ${P.length} bytes`);E.writeFixedArray(P)}else if(j.length===2&&typeof j[1]=="number"){if(P.length!==j[1])throw new N(`Expecting byte array of length ${j[1]}, but got ${P.length} bytes`);for(let c=0;c<j[1];c++)Y(q,null,P[c],j[0],E)}else E.writeArray(P,c=>{Y(q,B,c,j[0],E)});else if(j.kind!==void 0)switch(j.kind){case"option":{P==null?E.writeU8(0):(E.writeU8(1),Y(q,B,P,j.type,E));break}case"map":{E.writeU32(P.size),P.forEach((c,p)=>{Y(q,B,p,j.key,E),Y(q,B,c,j.value,E)});break}default:throw new N(`FieldType ${j} unrecognized`)}else V(q,P,E)}catch(c){throw c instanceof N&&c.addToFieldPath(B),c}}function V(q,B,P){if(typeof B.borshSerialize=="function"){B.borshSerialize(P);return}const j=q.get(B.constructor);if(!j)throw new N(`Class ${B.constructor.name} is missing in schema`);if(j.kind==="struct")j.fields.map(([E,c])=>{Y(q,E,B[E],c,P)});else if(j.kind==="enum"){const E=B[j.field];for(let c=0;c<j.values.length;++c){const[p,y]=j.values[c];if(p===E){P.writeU8(c),Y(q,p,B[p],y,P);break}}}else throw new N(`Unexpected schema kind: ${j.kind} for ${B.constructor.name}`)}function L(q,B,P=F){const j=new P;return V(q,B,j),j.toArray()}Be.serialize=L;function z(q,B,P,j){try{if(typeof P=="string")return j[`read${K(P)}`]();if(P instanceof Array){if(typeof P[0]=="number")return j.readFixedArray(P[0]);if(typeof P[1]=="number"){const E=[];for(let c=0;c<P[1];c++)E.push(z(q,null,P[0],j));return E}else return j.readArray(()=>z(q,B,P[0],j))}if(P.kind==="option")return j.readU8()?z(q,B,P.type,j):void 0;if(P.kind==="map"){let E=new Map;const c=j.readU32();for(let p=0;p<c;p++){const y=z(q,B,P.key,j),A=z(q,B,P.value,j);E.set(y,A)}return E}return J(q,P,j)}catch(E){throw E instanceof N&&E.addToFieldPath(B),E}}function J(q,B,P){if(typeof B.borshDeserialize=="function")return B.borshDeserialize(P);const j=q.get(B);if(!j)throw new N(`Class ${B.name} is missing in schema`);if(j.kind==="struct"){const E={};for(const[c,p]of q.get(B).fields)E[c]=z(q,c,p,P);return new B(E)}if(j.kind==="enum"){const E=P.readU8();if(E>=j.values.length)throw new N(`Enum index: ${E} is out of range`);const[c,p]=j.values[E],y=z(q,c,p,P);return new B({[c]:y})}throw new N(`Unexpected schema kind: ${j.kind} for ${B.constructor.name}`)}function te(q,B,P,j=k){const E=new j(P),c=J(q,B,E);if(E.offset<P.length)throw new N(`Unexpected ${P.length-E.offset} bytes after deserialized data`);return c}Be.deserialize=te;function ne(q,B,P,j=k){const E=new j(P);return J(q,B,E)}return Be.deserializeUnchecked=ne,Be}var pc=g_(),H={},Nf;function y_(){if(Nf)return H;Nf=1,Object.defineProperty(H,"__esModule",{value:!0}),H.s16=H.s8=H.nu64be=H.u48be=H.u40be=H.u32be=H.u24be=H.u16be=H.nu64=H.u48=H.u40=H.u32=H.u24=H.u16=H.u8=H.offset=H.greedy=H.Constant=H.UTF8=H.CString=H.Blob=H.Boolean=H.BitField=H.BitStructure=H.VariantLayout=H.Union=H.UnionLayoutDiscriminator=H.UnionDiscriminator=H.Structure=H.Sequence=H.DoubleBE=H.Double=H.FloatBE=H.Float=H.NearInt64BE=H.NearInt64=H.NearUInt64BE=H.NearUInt64=H.IntBE=H.Int=H.UIntBE=H.UInt=H.OffsetLayout=H.GreedyCount=H.ExternalLayout=H.bindConstructorLayout=H.nameWithProperty=H.Layout=H.uint8ArrayToBuffer=H.checkUint8Array=void 0,H.constant=H.utf8=H.cstr=H.blob=H.unionLayoutDiscriminator=H.union=H.seq=H.bits=H.struct=H.f64be=H.f64=H.f32be=H.f32=H.ns64be=H.s48be=H.s40be=H.s32be=H.s24be=H.s16be=H.ns64=H.s48=H.s40=H.s32=H.s24=void 0;const t=ac();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}H.checkUint8Array=e;function n(u){return e(u),t.Buffer.from(u.buffer,u.byteOffset,u.length)}H.uint8ArrayToBuffer=n;let r=class{constructor(l,w){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=w}makeDestinationObject(){return{}}getSpan(l,w){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const w=Object.create(this.constructor.prototype);return Object.assign(w,this),w.property=l,w}fromArray(l){}};H.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}H.nameWithProperty=s;function i(u,l){if(typeof u!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(u,"layout_"))throw new Error("Class is already bound to a layout");if(!(l&&l instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(l,"boundConstructor_"))throw new Error("layout is already bound to a constructor");u.layout_=l,l.boundConstructor_=u,l.makeDestinationObject=(()=>new u),Object.defineProperty(u.prototype,"encode",{value(w,T){return l.encode(this,w,T)},writable:!0}),Object.defineProperty(u,"decode",{value(w,T){return l.decode(w,T)},writable:!0})}H.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}H.ExternalLayout=o;class a extends o{constructor(l=1,w){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,w),this.elementSpan=l}isCount(){return!0}decode(l,w=0){e(l);const T=l.length-w;return Math.floor(T/this.elementSpan)}encode(l,w,T){return 0}}H.GreedyCount=a;class d extends o{constructor(l,w=0,T){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(w))throw new TypeError("offset must be integer or undefined");super(l.span,T||l.property),this.layout=l,this.offset=w}isCount(){return this.layout instanceof m||this.layout instanceof g}decode(l,w=0){return this.layout.decode(l,w+this.offset)}encode(l,w,T=0){return this.layout.encode(l,w,T+this.offset)}}H.OffsetLayout=d;class m extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readUIntLE(w,this.span)}encode(l,w,T=0){return n(w).writeUIntLE(l,T,this.span),this.span}}H.UInt=m;class g extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readUIntBE(w,this.span)}encode(l,w,T=0){return n(w).writeUIntBE(l,T,this.span),this.span}}H.UIntBE=g;class x extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readIntLE(w,this.span)}encode(l,w,T=0){return n(w).writeIntLE(l,T,this.span),this.span}}H.Int=x;class O extends r{constructor(l,w){if(super(l,w),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,w=0){return n(l).readIntBE(w,this.span)}encode(l,w,T=0){return n(w).writeIntBE(l,T,this.span),this.span}}H.IntBE=O;const N=Math.pow(2,32);function F(u){const l=Math.floor(u/N),w=u-l*N;return{hi32:l,lo32:w}}function C(u,l){return u*N+l}class k extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32LE(w),W=T.readUInt32LE(w+4);return C(W,D)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32LE(D.lo32,T),W.writeUInt32LE(D.hi32,T+4),8}}H.NearUInt64=k;class K extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32BE(w),W=T.readUInt32BE(w+4);return C(D,W)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}H.NearUInt64BE=K;class Y extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readUInt32LE(w),W=T.readInt32LE(w+4);return C(W,D)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeUInt32LE(D.lo32,T),W.writeInt32LE(D.hi32,T+4),8}}H.NearInt64=Y;class V extends r{constructor(l){super(8,l)}decode(l,w=0){const T=n(l),D=T.readInt32BE(w),W=T.readUInt32BE(w+4);return C(D,W)}encode(l,w,T=0){const D=F(l),W=n(w);return W.writeInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}H.NearInt64BE=V;class L extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatLE(w)}encode(l,w,T=0){return n(w).writeFloatLE(l,T),4}}H.Float=L;class z extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatBE(w)}encode(l,w,T=0){return n(w).writeFloatBE(l,T),4}}H.FloatBE=z;class J extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleLE(w)}encode(l,w,T=0){return n(w).writeDoubleLE(l,T),8}}H.Double=J;class te extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleBE(w)}encode(l,w,T=0){return n(w).writeDoubleBE(l,T),8}}H.DoubleBE=te;class ne extends r{constructor(l,w,T){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(w instanceof o&&w.isCount()||Number.isInteger(w)&&0<=w))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let D=-1;!(w instanceof o)&&0<l.span&&(D=w*l.span),super(D,T),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0,D=this.count;if(D instanceof o&&(D=D.decode(l,w)),0<this.elementLayout.span)T=D*this.elementLayout.span;else{let W=0;for(;W<D;)T+=this.elementLayout.getSpan(l,w+T),++W}return T}decode(l,w=0){const T=[];let D=0,W=this.count;for(W instanceof o&&(W=W.decode(l,w));D<W;)T.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),D+=1;return T}encode(l,w,T=0){const D=this.elementLayout,W=l.reduce((re,oe)=>re+D.encode(oe,w,T+re),0);return this.count instanceof o&&this.count.encode(l.length,w,T),W}}H.Sequence=ne;class q extends r{constructor(l,w,T){if(!(Array.isArray(l)&&l.reduce((W,re)=>W&&re instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof w=="boolean"&&T===void 0&&(T=w,w=void 0);for(const W of l)if(0>W.span&&W.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let D=-1;try{D=l.reduce((W,re)=>W+re.getSpan(),0)}catch{}super(D,w),this.fields=l,this.decodePrefixes=!!T}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0;try{T=this.fields.reduce((D,W)=>{const re=W.getSpan(l,w);return w+=re,D+re},0)}catch{throw new RangeError("indeterminate span")}return T}decode(l,w=0){e(l);const T=this.makeDestinationObject();for(const D of this.fields)if(D.property!==void 0&&(T[D.property]=D.decode(l,w)),w+=D.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return T}encode(l,w,T=0){const D=T;let W=0,re=0;for(const oe of this.fields){let Ce=oe.span;if(re=0<Ce?Ce:0,oe.property!==void 0){const Ee=l[oe.property];Ee!==void 0&&(re=oe.encode(Ee,w,T),0>Ce&&(Ce=oe.getSpan(w,T)))}W=T,T+=Ce}return W+re-D}fromArray(l){const w=this.makeDestinationObject();for(const T of this.fields)T.property!==void 0&&0<l.length&&(w[T.property]=l.shift());return w}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let w=0;for(const T of this.fields){if(T.property===l)return w;0>T.span?w=-1:0<=w&&(w+=T.span)}}}H.Structure=q;class B{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,T){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=B;class P extends B{constructor(l,w){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(w||l.property||"variant"),this.layout=l}decode(l,w){return this.layout.decode(l,w)}encode(l,w,T){return this.layout.encode(l,w,T)}}H.UnionLayoutDiscriminator=P;class j extends r{constructor(l,w,T){let D;if(l instanceof m||l instanceof g)D=new P(new d(l));else if(l instanceof o&&l.isCount())D=new P(l);else if(l instanceof B)D=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(w===void 0&&(w=null),!(w===null||w instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(w!==null){if(0>w.span)throw new Error("defaultLayout must have constant span");w.property===void 0&&(w=w.replicate("content"))}let W=-1;w&&(W=w.span,0<=W&&(l instanceof m||l instanceof g)&&(W+=D.layout.span)),super(W,T),this.discriminator=D,this.usesPrefixDiscriminator=l instanceof m||l instanceof g,this.defaultLayout=w,this.registry={};let re=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(oe){return re(oe)},this.configGetSourceVariant=function(oe){re=oe.bind(this)}}getSpan(l,w=0){if(0<=this.span)return this.span;const T=this.getVariant(l,w);if(!T)throw new Error("unable to determine span for unrecognized variant");return T.getSpan(l,w)}defaultGetSourceVariant(l){if(Object.prototype.hasOwnProperty.call(l,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(l,this.defaultLayout.property))return;const w=this.registry[l[this.discriminator.property]];if(w&&(!w.layout||w.property&&Object.prototype.hasOwnProperty.call(l,w.property)))return w}else for(const w in this.registry){const T=this.registry[w];if(T.property&&Object.prototype.hasOwnProperty.call(l,T.property))return T}throw new Error("unable to infer src variant")}decode(l,w=0){let T;const D=this.discriminator,W=D.decode(l,w),re=this.registry[W];if(re===void 0){const oe=this.defaultLayout;let Ce=0;this.usesPrefixDiscriminator&&(Ce=D.layout.span),T=this.makeDestinationObject(),T[D.property]=W,T[oe.property]=oe.decode(l,w+Ce)}else T=re.decode(l,w);return T}encode(l,w,T=0){const D=this.getSourceVariant(l);if(D===void 0){const W=this.discriminator,re=this.defaultLayout;let oe=0;return this.usesPrefixDiscriminator&&(oe=W.layout.span),W.encode(l[W.property],w,T),oe+re.encode(l[re.property],w,T+oe)}return D.encode(l,w,T)}addVariant(l,w,T){const D=new E(this,l,w,T);return this.registry[l]=D,D}getVariant(l,w=0){let T;return l instanceof Uint8Array?T=this.discriminator.decode(l,w):T=l,this.registry[T]}}H.Union=j;class E extends r{constructor(l,w,T,D){if(!(l instanceof j))throw new TypeError("union must be a Union");if(!Number.isInteger(w)||0>w)throw new TypeError("variant must be a (non-negative) integer");if(typeof T=="string"&&D===void 0&&(D=T,T=null),T){if(!(T instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=T.span&&T.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof D!="string")throw new TypeError("variant must have a String property")}let W=l.span;0>l.span&&(W=T?T.span:0,0<=W&&l.usesPrefixDiscriminator&&(W+=l.discriminator.layout.span)),super(W,D),this.union=l,this.variant=w,this.layout=T||null}getSpan(l,w=0){if(0<=this.span)return this.span;let T=0;this.union.usesPrefixDiscriminator&&(T=this.union.discriminator.layout.span);let D=0;return this.layout&&(D=this.layout.getSpan(l,w+T)),T+D}decode(l,w=0){const T=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let D=0;return this.union.usesPrefixDiscriminator&&(D=this.union.discriminator.layout.span),this.layout?T[this.property]=this.layout.decode(l,w+D):this.property?T[this.property]=!0:this.union.usesPrefixDiscriminator&&(T[this.union.discriminator.property]=this.variant),T}encode(l,w,T=0){let D=0;if(this.union.usesPrefixDiscriminator&&(D=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(l,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,w,T);let W=D;if(this.layout&&(this.layout.encode(l[this.property],w,T+D),W+=this.layout.getSpan(w,T+D),0<=this.union.span&&W>this.union.span))throw new Error("encoded variant overruns containing union");return W}fromArray(l){if(this.layout)return this.layout.fromArray(l)}}H.VariantLayout=E;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,w,T){if(!(l instanceof m||l instanceof g))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&T===void 0&&(T=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,T),this.word=l,this.msb=!!w,this.fields=[];let D=0;this._packedSetValue=function(W){return D=c(W),this},this._packedGetValue=function(){return D}}decode(l,w=0){const T=this.makeDestinationObject(),D=this.word.decode(l,w);this._packedSetValue(D);for(const W of this.fields)W.property!==void 0&&(T[W.property]=W.decode(l));return T}encode(l,w,T=0){const D=this.word.decode(w,T);this._packedSetValue(D);for(const W of this.fields)if(W.property!==void 0){const re=l[W.property];re!==void 0&&W.encode(re)}return this.word.encode(this._packedGetValue(),w,T)}addField(l,w){const T=new y(this,l,w);return this.fields.push(T),T}addBoolean(l){const w=new A(this,l);return this.fields.push(w),w}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const w of this.fields)if(w.property===l)return w}}H.BitStructure=p;class y{constructor(l,w,T){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(w)||0>=w)throw new TypeError("bits must be positive integer");const D=8*l.span,W=l.fields.reduce((re,oe)=>re+oe.bits,0);if(w+W>D)throw new Error("bits too long for span remainder ("+(D-W)+" of "+D+" remain)");this.container=l,this.bits=w,this.valueMask=(1<<w)-1,w===32&&(this.valueMask=4294967295),this.start=W,this.container.msb&&(this.start=D-W-w),this.wordMask=c(this.valueMask<<this.start),this.property=T}decode(l,w){const T=this.container._packedGetValue();return c(T&this.wordMask)>>>this.start}encode(l){if(typeof l!="number"||!Number.isInteger(l)||l!==c(l&this.valueMask))throw new TypeError(s("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const w=this.container._packedGetValue(),T=c(l<<this.start);this.container._packedSetValue(c(w&~this.wordMask)|T)}}H.BitField=y;class A extends y{constructor(l,w){super(l,1,w)}decode(l,w){return!!super.decode(l,w)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}H.Boolean=A;class v extends r{constructor(l,w){if(!(l instanceof o&&l.isCount()||Number.isInteger(l)&&0<=l))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let T=-1;l instanceof o||(T=l),super(T,w),this.length=l}getSpan(l,w){let T=this.span;return 0>T&&(T=this.length.decode(l,w)),T}decode(l,w=0){let T=this.span;return 0>T&&(T=this.length.decode(l,w)),n(l).slice(w,w+T)}encode(l,w,T){let D=this.length;if(this.length instanceof o&&(D=l.length),!(l instanceof Uint8Array&&D===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+D+") Uint8Array as src");if(T+D>w.length)throw new RangeError("encoding overruns Uint8Array");const W=n(l);return n(w).write(W.toString("hex"),T,D,"hex"),this.length instanceof o&&this.length.encode(D,w,T),D}}H.Blob=v;class R extends r{constructor(l){super(-1,l)}getSpan(l,w=0){e(l);let T=w;for(;T<l.length&&l[T]!==0;)T+=1;return 1+T-w}decode(l,w=0){const T=this.getSpan(l,w);return n(l).slice(w,w+T-1).toString("utf-8")}encode(l,w,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(T+W>w.length)throw new RangeError("encoding overruns Buffer");const re=n(w);return D.copy(re,T),re[T+W]=0,W+1}}H.CString=R;class I extends r{constructor(l,w){if(typeof l=="string"&&w===void 0&&(w=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,w),this.maxSpan=l}getSpan(l,w=0){return e(l),l.length-w}decode(l,w=0){const T=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<T)throw new RangeError("text length exceeds maxSpan");return n(l).slice(w,w+T).toString("utf-8")}encode(l,w,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(0<=this.maxSpan&&this.maxSpan<W)throw new RangeError("text length exceeds maxSpan");if(T+W>w.length)throw new RangeError("encoding overruns Buffer");return D.copy(n(w),T),W}}H.UTF8=I;class _ extends r{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,T){return 0}}return H.Constant=_,H.greedy=((u,l)=>new a(u,l)),H.offset=((u,l,w)=>new d(u,l,w)),H.u8=(u=>new m(1,u)),H.u16=(u=>new m(2,u)),H.u24=(u=>new m(3,u)),H.u32=(u=>new m(4,u)),H.u40=(u=>new m(5,u)),H.u48=(u=>new m(6,u)),H.nu64=(u=>new k(u)),H.u16be=(u=>new g(2,u)),H.u24be=(u=>new g(3,u)),H.u32be=(u=>new g(4,u)),H.u40be=(u=>new g(5,u)),H.u48be=(u=>new g(6,u)),H.nu64be=(u=>new K(u)),H.s8=(u=>new x(1,u)),H.s16=(u=>new x(2,u)),H.s24=(u=>new x(3,u)),H.s32=(u=>new x(4,u)),H.s40=(u=>new x(5,u)),H.s48=(u=>new x(6,u)),H.ns64=(u=>new Y(u)),H.s16be=(u=>new O(2,u)),H.s24be=(u=>new O(3,u)),H.s32be=(u=>new O(4,u)),H.s40be=(u=>new O(5,u)),H.s48be=(u=>new O(6,u)),H.ns64be=(u=>new V(u)),H.f32=(u=>new L(u)),H.f32be=(u=>new z(u)),H.f64=(u=>new J(u)),H.f64be=(u=>new te(u)),H.struct=((u,l,w)=>new q(u,l,w)),H.bits=((u,l,w)=>new p(u,l,w)),H.seq=((u,l,w)=>new ne(u,l,w)),H.union=((u,l,w)=>new j(u,l,w)),H.unionLayoutDiscriminator=((u,l)=>new P(u,l)),H.blob=((u,l)=>new v(u,l)),H.cstr=(u=>new R(u)),H.utf8=((u,l)=>new I(u,l)),H.constant=((u,l)=>new _(u,l)),H}var M=y_(),b_=1,__=2,w_=3,E_=4,v_=5,R_=6,A_=7,x_=8,S_=9,T_=10,O_=-32700,I_=-32603,N_=-32602,C_=-32601,M_=-32600,B_=-32016,k_=-32015,L_=-32014,P_=-32013,U_=-32012,D_=-32011,F_=-32010,$_=-32009,z_=-32008,j_=-32007,V_=-32006,G_=-32005,H_=-32004,q_=-32003,K_=-32002,W_=-32001,Z_=28e5,Y_=2800001,J_=2800002,X_=2800003,Q_=2800004,ew=2800005,tw=2800006,nw=2800007,rw=2800008,sw=2800009,iw=2800010,ow=2800011,aw=323e4,cw=32300001,uw=3230002,dw=3230003,lw=3230004,fw=361e4,hw=3610001,pw=3610002,mw=3610003,gw=3610004,yw=3610005,bw=3610006,_w=3610007,ww=3611e3,Ew=3704e3,vw=3704001,Rw=3704002,Aw=3704003,xw=3704004,Sw=4128e3,Tw=4128001,Ow=4128002,Iw=4615e3,Nw=4615001,Cw=4615002,Mw=4615003,Bw=4615004,kw=4615005,Lw=4615006,Pw=4615007,Uw=4615008,Dw=4615009,Fw=4615010,$w=4615011,zw=4615012,jw=4615013,Vw=4615014,Gw=4615015,Hw=4615016,qw=4615017,Kw=4615018,Ww=4615019,Zw=4615020,Yw=4615021,Jw=4615022,Xw=4615023,Qw=4615024,eE=4615025,tE=4615026,nE=4615027,rE=4615028,sE=4615029,iE=4615030,oE=4615031,aE=4615032,cE=4615033,uE=4615034,dE=4615035,lE=4615036,fE=4615037,hE=4615038,pE=4615039,mE=4615040,gE=4615041,yE=4615042,bE=4615043,_E=4615044,wE=4615045,EE=4615046,vE=4615047,RE=4615048,AE=4615049,xE=4615050,SE=4615051,TE=4615052,OE=4615053,IE=4615054,NE=5508e3,CE=5508001,ME=5508002,BE=5508003,kE=5508004,LE=5508005,PE=5508006,UE=5508007,DE=5508008,FE=5508009,$E=5508010,zE=5508011,jE=5663e3,VE=5663001,GE=5663002,HE=5663003,qE=5663004,KE=5663005,WE=5663006,ZE=5663007,YE=5663008,JE=5663009,XE=5663010,QE=5663011,ev=5663012,tv=5663013,nv=5663014,rv=5663015,sv=5663016,iv=5663017,ov=5663018,av=5663019,cv=5663020,uv=705e4,dv=7050001,lv=7050002,fv=7050003,hv=7050004,pv=7050005,mv=7050006,gv=7050007,yv=7050008,bv=7050009,_v=7050010,wv=7050011,Ev=7050012,vv=7050013,Rv=7050014,Av=7050015,xv=7050016,Sv=7050017,Tv=7050018,Ov=7050019,Iv=7050020,Nv=7050021,Cv=7050022,Mv=7050023,Bv=7050024,kv=7050025,Lv=7050026,Pv=7050027,Uv=7050028,Dv=7050029,Fv=7050030,$v=7050031,zv=7050032,jv=7050033,Vv=7050034,Gv=7050035,Hv=7050036,Cf=8078e3,Mf=8078001,qv=8078002,Kv=8078003,Bf=8078004,kf=8078005,Lf=8078006,Wv=8078007,Zv=8078008,Yv=8078009,Jv=8078010,Pf=8078011,Xv=8078012,Qv=8078013,eR=8078014,tR=8078015,nR=8078016,rR=8078017,sR=8078018,iR=8078019,oR=8078020,aR=8078021,cR=8078022,uR=81e5,dR=8100001,lR=8100002,fR=8100003,hR=819e4,pR=8190001,mR=8190002,gR=8190003,yR=8190004,bR=99e5,_R=9900001,wR=9900002,ER=9900003,vR=9900004;function Uf(t){return Array.isArray(t)?"%5B"+t.map(Uf).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function RR([t,e]){return`${t}=${Uf(e)}`}function AR(t){const e=Object.entries(t).map(RR).join("&");return btoa(e)}var xR={[aw]:"Account not found at address: $address",[lw]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[dw]:"Expected decoded account at address: $address",[uw]:"Failed to decode account data at address: $address",[cw]:"Accounts not found at addresses: $addresses",[sw]:"Unable to find a viable program address bump seed.",[J_]:"$putativeAddress is not a base58-encoded address.",[Z_]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[X_]:"The `CryptoKey` must be an `Ed25519` public key.",[ow]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[rw]:"Invalid seeds; point must fall off the Ed25519 curve.",[Q_]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[tw]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[nw]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[ew]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[iw]:"Program address cannot end with PDA marker.",[Y_]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[E_]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[b_]:"The network has progressed past the last block for which this transaction could have been committed.",[Cf]:"Codec [$codecDescription] cannot decode empty byte arrays.",[cR]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[oR]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[kf]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Lf]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Bf]:"Encoder and decoder must either both be fixed-size or variable-size.",[Zv]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[qv]:"Expected a fixed-size codec, got a variable-size one.",[Qv]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Kv]:"Expected a variable-size codec, got a fixed-size one.",[iR]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Mf]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[sR]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Yv]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Jv]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[tR]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Wv]:"Expected [$codecDescription] to have $expected items, got $actual.",[Xv]:"Invalid value $value for base $base with alphabet $alphabet.",[nR]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Pf]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[eR]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[aR]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[rR]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[ww]:"No random values implementation could be found.",[Dw]:"instruction requires an uninitialized account",[Xw]:"instruction tries to borrow reference for an account which is already borrowed",[Qw]:"instruction left account with an outstanding borrowed reference",[Yw]:"program other than the account's owner changed the size of the account data",[kw]:"account data too small for instruction",[Jw]:"instruction expected an executable account",[EE]:"An account does not have enough lamports to be rent-exempt",[RE]:"Program arithmetic overflowed",[wE]:"Failed to serialize or deserialize account data: $encodedData",[IE]:"Builtin programs must consume compute units",[aE]:"Cross-program invocation call depth too deep",[hE]:"Computational budget exceeded",[tE]:"custom program error: #$code",[qw]:"instruction contains duplicate accounts",[eE]:"instruction modifications of multiply-passed account differ",[iE]:"executable accounts must be rent exempt",[rE]:"instruction changed executable accounts data",[sE]:"instruction changed the balance of an executable account",[Kw]:"instruction changed executable bit of an account",[Vw]:"instruction modified data of an account it does not own",[jw]:"instruction spent from the balance of an account it does not own",[Nw]:"generic instruction error",[xE]:"Provided owner is not allowed",[bE]:"Account is immutable",[_E]:"Incorrect authority provided",[Pw]:"incorrect program id for instruction",[Lw]:"insufficient funds for instruction",[Bw]:"invalid account data for instruction",[vE]:"Invalid account owner",[Cw]:"invalid program argument",[nE]:"program returned invalid error code",[Mw]:"invalid instruction data",[fE]:"Failed to reallocate account data",[lE]:"Provided seeds do not result in a valid address",[SE]:"Accounts data allocations exceeded the maximum allowed per transaction",[TE]:"Max accounts exceeded",[OE]:"Max instruction trace length exceeded",[dE]:"Length of the seed is too long for address generation",[cE]:"An account required by the instruction is missing",[Uw]:"missing required signature for instruction",[zw]:"instruction illegally modified the program id of an account",[Zw]:"insufficient account keys for instruction",[pE]:"Cross-program invocation with unauthorized signer or writable account",[mE]:"Failed to create program execution environment",[yE]:"Program failed to compile",[gE]:"Program failed to complete",[Hw]:"instruction modified data of a read-only account",[Gw]:"instruction changed the balance of a read-only account",[uE]:"Cross-program invocation reentrancy not allowed for this instruction",[Ww]:"instruction modified rent epoch of an account",[$w]:"sum of account balances before and after instruction do not match",[Fw]:"instruction requires an initialized account",[Iw]:"",[oE]:"Unsupported program id",[AE]:"Unsupported sysvar",[Sw]:"The instruction does not have any accounts.",[Tw]:"The instruction does not have any data.",[Ow]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[v_]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[__]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[wR]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[vR]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[_R]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[bR]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ER]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[I_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[N_]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[M_]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[C_]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[O_]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[U_]:"$__serverMessage",[W_]:"$__serverMessage",[H_]:"$__serverMessage",[L_]:"$__serverMessage",[F_]:"$__serverMessage",[$_]:"$__serverMessage",[B_]:"Minimum context slot has not been reached",[G_]:"Node is unhealthy; behind by $numSlotsBehind slots",[z_]:"No snapshot",[K_]:"Transaction simulation failed",[j_]:"$__serverMessage",[D_]:"Transaction history is not available from this node",[V_]:"$__serverMessage",[P_]:"Transaction signature length mismatch",[q_]:"Transaction signature verification failure",[k_]:"$__serverMessage",[Ew]:"Key pair bytes must be of length 64, got $byteLength.",[vw]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Rw]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[xw]:"The provided private key does not match the provided public key.",[Aw]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[R_]:"Lamports value must be in the range [0, 2e64-1]",[A_]:"`$value` cannot be parsed as a `BigInt`",[T_]:"$message",[x_]:"`$value` cannot be parsed as a `Number`",[w_]:"No nonce account could be found at address `$nonceAccountAddress`",[hR]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[mR]:"WebSocket was closed before payload could be added to the send buffer",[gR]:"WebSocket connection closed",[yR]:"WebSocket failed to connect",[pR]:"Failed to obtain a subscription id from the server",[fR]:"Could not find an API plan for RPC method: `$method`",[uR]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[lR]:"HTTP error ($statusCode): $message",[dR]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[NE]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[CE]:"The provided value does not implement the `KeyPairSigner` interface",[BE]:"The provided value does not implement the `MessageModifyingSigner` interface",[kE]:"The provided value does not implement the `MessagePartialSigner` interface",[ME]:"The provided value does not implement any of the `MessageSigner` interfaces",[PE]:"The provided value does not implement the `TransactionModifyingSigner` interface",[UE]:"The provided value does not implement the `TransactionPartialSigner` interface",[DE]:"The provided value does not implement the `TransactionSendingSigner` interface",[LE]:"The provided value does not implement any of the `TransactionSigner` interfaces",[FE]:"More than one `TransactionSendingSigner` was identified.",[$E]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[zE]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[_w]:"Cannot export a non-extractable key.",[hw]:"No digest implementation could be found.",[fw]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[pw]:`This runtime does not support the generation of Ed25519 key pairs.
29
29
 
30
30
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
31
31
 
32
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[mw]:"No signature verification implementation could be found.",[gw]:"No key generation implementation could be found.",[yw]:"No signing implementation could be found.",[bw]:"No key export implementation could be found.",[S_]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[xv]:"Transaction processing left an account with an outstanding borrowed reference",[dv]:"Account in use",[lv]:"Account loaded twice",[fv]:"Attempt to debit an account but found no record of a prior credit.",[Mv]:"Transaction loads an address table account that doesn't exist",[gv]:"This transaction has already been processed",[yv]:"Blockhash not found",[bv]:"Loader call chain is too deep",[Av]:"Transactions are currently disabled due to cluster maintenance",[Fv]:"Transaction contains a duplicate instruction ($index) that is not allowed",[pv]:"Insufficient funds for fee",[$v]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[mv]:"This account may not be used to pay transaction fees",[wv]:"Transaction contains an invalid account reference",[kv]:"Transaction loads an address table account with invalid data",[Lv]:"Transaction address table lookup uses an invalid index",[Bv]:"Transaction loads an address table account with an invalid owner",[jv]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[vv]:"This program may not be used for executing instructions",[Pv]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ov]:"Transaction loads a writable account that cannot be written",[zv]:"Transaction exceeded max loaded accounts data size cap",[_v]:"Transaction requires a fee but has no signature present",[hv]:"Attempt to load a program that does not exist",[Gv]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Vv]:"ResanitizationNeeded",[Rv]:"Transaction failed to sanitize accounts offsets correctly",[Ev]:"Transaction did not pass signature verification",[Cv]:"Transaction locked too many accounts",[Hv]:"Sum of account balances before and after transaction do not match",[uv]:"The transaction failed with the error `$errorName`",[Tv]:"Transaction version is unsupported",[Nv]:"Transaction would exceed account data limit within the block",[Dv]:"Transaction would exceed total account data limit",[Iv]:"Transaction would exceed max account limit within the block",[Sv]:"Transaction would exceed max Block Cost Limit",[Uv]:"Transaction would exceed max Vote Cost Limit",[rv]:"Attempted to sign a transaction with an address that is not a signer for it",[XE]:"Transaction is missing an address at index: $index.",[sv]:"Transaction has no expected signers therefore it cannot be encoded",[cv]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[GE]:"Transaction does not have a blockhash lifetime",[HE]:"Transaction is not a durable nonce transaction",[KE]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[WE]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[YE]:"No fee payer set in CompiledTransaction",[ZE]:"Could not find program address at index $index",[ov]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[av]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[QE]:"Transaction is missing a fee payer.",[ev]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[nv]:"Transaction first instruction is not advance nonce account instruction.",[tv]:"Transaction with no instructions cannot be durable nonce transaction.",[jE]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[VE]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[iv]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[JE]:"Transaction is missing signatures for addresses: $addresses.",[qE]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},Tn="i",ln="t";function SR(t,e={}){const n=xR[t];if(n.length===0)return"";let r;function s(o){if(r[ln]===2){const a=n.slice(r[Tn]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[ln]===1&&i.push(n.slice(r[Tn],o))}const i=[];return n.split("").forEach((o,a)=>{if(a===0){r={[Tn]:0,[ln]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let d;switch(r[ln]){case 0:d={[Tn]:a,[ln]:1};break;case 1:o==="\\"?d={[Tn]:a,[ln]:0}:o==="$"&&(d={[Tn]:a,[ln]:2});break;case 2:o==="\\"?d={[Tn]:a,[ln]:0}:o==="$"?d={[Tn]:a,[ln]:2}:o.match(/\w/)||(d={[Tn]:a,[ln]:1});break}d&&(r!==d&&s(a),r=d)}),s(),i.join("")}function TR(t,e={}){if(process.env.NODE_ENV!=="production")return SR(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${AR(e)}'`),`${n}\``}}var Pr=class extends Error{cause=this.cause;context;constructor(...[t,e]){let n,r;if(e){const{cause:i,...o}=e;i&&(r={cause:i}),Object.keys(o).length>0&&(n=o)}const s=TR(t,n);super(s,r),this.context={__code:t,...n},this.name="SolanaError"}};function OR(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function IR(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(OR(e,t));return t.write(e,n,0),n}})}function NR(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function Ur(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function CR(t,e){if(Ur(t)!==Ur(e))throw new Pr(Mf);if(Ur(t)&&Ur(e)&&t.fixedSize!==e.fixedSize)throw new Pr(Bf,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!Ur(t)&&!Ur(e)&&t.maxSize!==e.maxSize)throw new Pr(kf,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function MR(t,e,n=0){if(e.length-n<=0)throw new Pr(Nf,{codecDescription:t})}function BR(t,e,n,r=0){const s=n.length-r;if(s<e)throw new Pr(Cf,{bytesLength:s,codecDescription:t,expected:e})}function kR(t,e,n,r){if(r<e||r>n)throw new Pr(Lf,{codecDescription:t,max:n,min:e,value:r})}function Uf(t){return t?.endian!==1}function LR(t){return IR({fixedSize:t.size,write(e,n,r){t.range&&kR(t.name,t.range[0],t.range[1],e);const s=new ArrayBuffer(t.size);return t.set(new DataView(s),e,Uf(t.config)),n.set(new Uint8Array(s),r),r+t.size}})}function PR(t){return NR({fixedSize:t.size,read(e,n=0){MR(t.name,e,n),BR(t.name,t.size,e,n);const r=new DataView(UR(e,n,t.size));return[t.get(r,Uf(t.config)),n+t.size]}})}function UR(t,e,n){const r=t.byteOffset+(e??0),s=n??t.byteLength;return t.buffer.slice(r,r+s)}var DR=(t={})=>LR({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),FR=(t={})=>PR({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),$R=(t={})=>CR(DR(t),FR(t));class zR extends TypeError{constructor(e,n){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,d=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??d),i!=null&&(this.cause=d),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function jR(t){return Bs(t)&&typeof t[Symbol.iterator]=="function"}function Bs(t){return typeof t=="object"&&t!=null}function Hi(t){return Bs(t)&&!Array.isArray(t)}function nn(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function VR(t){const{done:e,value:n}=t.next();return e?void 0:n}function GR(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:o}=n,{refinement:a,message:d=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${nn(r)}\``}=t;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...t,message:d}}function*Df(t,e,n,r){jR(t)||(t=[t]);for(const s of t){const i=GR(s,e,n,r);i&&(yield i)}}function*pc(t,e,n={}){const{path:r=[],branch:s=[t],coerce:i=!1,mask:o=!1}=n,a={path:r,branch:s,mask:o};i&&(t=e.coercer(t,a));let d="valid";for(const m of e.validator(t,a))m.explanation=n.message,d="not_valid",yield[m,void 0];for(let[m,g,x]of e.entries(t,a)){const O=pc(g,x,{path:m===void 0?r:[...r,m],branch:m===void 0?s:[...s,g],coerce:i,mask:o,message:n.message});for(const N of O)N[0]?(d=N[0].refinement!=null?"not_refined":"not_valid",yield[N[0],void 0]):i&&(g=N[1],m===void 0?t=g:t instanceof Map?t.set(m,g):t instanceof Set?t.add(g):Bs(t)&&(g!==void 0||m in t)&&(t[m]=g))}if(d!=="not_valid")for(const m of e.refiner(t,a))m.explanation=n.message,d="not_refined",yield[m,void 0];d==="valid"&&(yield[void 0,t])}let fn=class{constructor(e){const{type:n,schema:r,validator:s,refiner:i,coercer:o=d=>d,entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(d,m)=>{const g=s(d,m);return Df(g,m,this,d)}:this.validator=()=>[],i?this.refiner=(d,m)=>{const g=i(d,m);return Df(g,m,this,d)}:this.refiner=()=>[]}assert(e,n){return HR(e,this,n)}create(e,n){return ks(e,this,n)}is(e){return Ff(e,this)}mask(e,n){return qR(e,this,n)}validate(e,n={}){return Ls(e,this,n)}};function HR(t,e,n){const r=Ls(t,e,{message:n});if(r[0])throw r[0]}function ks(t,e,n){const r=Ls(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function qR(t,e,n){const r=Ls(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Ff(t,e){return!Ls(t,e)[0]}function Ls(t,e,n={}){const r=pc(t,e,n),s=VR(r);return s[0]?[new zR(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function ur(t,e){return new fn({type:t,schema:null,validator:e})}function KR(){return ur("any",()=>!0)}function ae(t){return new fn({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${nn(e)}`}})}function hn(){return ur("boolean",t=>typeof t=="boolean")}function mc(t){return ur("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${nn(e)}`)}function He(t){const e=nn(t),n=typeof t;return new fn({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${nn(r)}`}})}function WR(){return ur("never",()=>!1)}function ce(t){return new fn({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function G(){return ur("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${nn(t)}`)}function fe(t){return new fn({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function $f(t,e){return new fn({type:"record",schema:null,*entries(n){if(Bs(n))for(const r in n){const s=n[r];yield[r,r,t],yield[r,s,e]}},validator(n){return Hi(n)||`Expected an object, but received: ${nn(n)}`},coercer(n){return Hi(n)?{...n}:n}})}function se(){return ur("string",t=>typeof t=="string"||`Expected a string, but received: ${nn(t)}`)}function gc(t){const e=WR();return new fn({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let s=0;s<r;s++)yield[s,n[s],t[s]||e]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${nn(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function Q(t){const e=Object.keys(t);return new fn({type:"type",schema:t,*entries(n){if(Bs(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Hi(n)||`Expected an object, but received: ${nn(n)}`},coercer(n){return Hi(n)?{...n}:n}})}function Ft(t){const e=t.map(n=>n.type).join(" | ");return new fn({type:"union",schema:null,coercer(n,r){for(const s of t){const[i,o]=s.validate(n,{coerce:!0,mask:r.mask});if(!i)return o}return n},validator(n,r){const s=[];for(const i of t){const[...o]=pc(n,i,r),[a]=o;if(a[0])for(const[d]of o)d&&s.push(d);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${nn(n)}`,...s]}})}function Dr(){return ur("unknown",()=>!0)}function Ps(t,e,n){return new fn({...t,coercer:(r,s)=>Ff(r,e)?t.coercer(n(r,s),s):t.coercer(r,s)})}var qi,ZR=new Uint8Array(16);function zf(){if(!qi&&(qi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!qi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qi(ZR)}const YR=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ki(t){return typeof t=="string"&&YR.test(t)}for(var vt=[],yc=0;yc<256;++yc)vt.push((yc+256).toString(16).substr(1));function Wi(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(vt[t[e+0]]+vt[t[e+1]]+vt[t[e+2]]+vt[t[e+3]]+"-"+vt[t[e+4]]+vt[t[e+5]]+"-"+vt[t[e+6]]+vt[t[e+7]]+"-"+vt[t[e+8]]+vt[t[e+9]]+"-"+vt[t[e+10]]+vt[t[e+11]]+vt[t[e+12]]+vt[t[e+13]]+vt[t[e+14]]+vt[t[e+15]]).toLowerCase();if(!Ki(n))throw TypeError("Stringified UUID is invalid");return n}var jf,bc,_c=0,wc=0;function JR(t,e,n){var r=e&&n||0,s=e||new Array(16);t=t||{};var i=t.node||jf,o=t.clockseq!==void 0?t.clockseq:bc;if(i==null||o==null){var a=t.random||(t.rng||zf)();i==null&&(i=jf=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=bc=(a[6]<<8|a[7])&16383)}var d=t.msecs!==void 0?t.msecs:Date.now(),m=t.nsecs!==void 0?t.nsecs:wc+1,g=d-_c+(m-wc)/1e4;if(g<0&&t.clockseq===void 0&&(o=o+1&16383),(g<0||d>_c)&&t.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_c=d,wc=m,bc=o,d+=122192928e5;var x=((d&268435455)*1e4+m)%4294967296;s[r++]=x>>>24&255,s[r++]=x>>>16&255,s[r++]=x>>>8&255,s[r++]=x&255;var O=d/4294967296*1e4&268435455;s[r++]=O>>>8&255,s[r++]=O&255,s[r++]=O>>>24&15|16,s[r++]=O>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var N=0;N<6;++N)s[r+N]=i[N];return e||Wi(s)}function Vf(t){if(!Ki(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function XR(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var QR="6ba7b810-9dad-11d1-80b4-00c04fd430c8",eA="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Gf(t,e,n){function r(s,i,o,a){if(typeof s=="string"&&(s=XR(s)),typeof i=="string"&&(i=Vf(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+s.length);if(d.set(i),d.set(s,i.length),d=n(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,o){a=a||0;for(var m=0;m<16;++m)o[a+m]=d[m];return o}return Wi(d)}try{r.name=t}catch{}return r.DNS=QR,r.URL=eA,r}function tA(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return nA(rA(sA(t),t.length*8))}function nA(t){for(var e=[],n=t.length*32,r="0123456789abcdef",s=0;s<n;s+=8){var i=t[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function Hf(t){return(t+64>>>9<<4)+14+1}function rA(t,e){t[e>>5]|=128<<e%32,t[Hf(e)-1]=e;for(var n=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<t.length;o+=16){var a=n,d=r,m=s,g=i;n=Ot(n,r,s,i,t[o],7,-680876936),i=Ot(i,n,r,s,t[o+1],12,-389564586),s=Ot(s,i,n,r,t[o+2],17,606105819),r=Ot(r,s,i,n,t[o+3],22,-1044525330),n=Ot(n,r,s,i,t[o+4],7,-176418897),i=Ot(i,n,r,s,t[o+5],12,1200080426),s=Ot(s,i,n,r,t[o+6],17,-1473231341),r=Ot(r,s,i,n,t[o+7],22,-45705983),n=Ot(n,r,s,i,t[o+8],7,1770035416),i=Ot(i,n,r,s,t[o+9],12,-1958414417),s=Ot(s,i,n,r,t[o+10],17,-42063),r=Ot(r,s,i,n,t[o+11],22,-1990404162),n=Ot(n,r,s,i,t[o+12],7,1804603682),i=Ot(i,n,r,s,t[o+13],12,-40341101),s=Ot(s,i,n,r,t[o+14],17,-1502002290),r=Ot(r,s,i,n,t[o+15],22,1236535329),n=It(n,r,s,i,t[o+1],5,-165796510),i=It(i,n,r,s,t[o+6],9,-1069501632),s=It(s,i,n,r,t[o+11],14,643717713),r=It(r,s,i,n,t[o],20,-373897302),n=It(n,r,s,i,t[o+5],5,-701558691),i=It(i,n,r,s,t[o+10],9,38016083),s=It(s,i,n,r,t[o+15],14,-660478335),r=It(r,s,i,n,t[o+4],20,-405537848),n=It(n,r,s,i,t[o+9],5,568446438),i=It(i,n,r,s,t[o+14],9,-1019803690),s=It(s,i,n,r,t[o+3],14,-187363961),r=It(r,s,i,n,t[o+8],20,1163531501),n=It(n,r,s,i,t[o+13],5,-1444681467),i=It(i,n,r,s,t[o+2],9,-51403784),s=It(s,i,n,r,t[o+7],14,1735328473),r=It(r,s,i,n,t[o+12],20,-1926607734),n=Nt(n,r,s,i,t[o+5],4,-378558),i=Nt(i,n,r,s,t[o+8],11,-2022574463),s=Nt(s,i,n,r,t[o+11],16,1839030562),r=Nt(r,s,i,n,t[o+14],23,-35309556),n=Nt(n,r,s,i,t[o+1],4,-1530992060),i=Nt(i,n,r,s,t[o+4],11,1272893353),s=Nt(s,i,n,r,t[o+7],16,-155497632),r=Nt(r,s,i,n,t[o+10],23,-1094730640),n=Nt(n,r,s,i,t[o+13],4,681279174),i=Nt(i,n,r,s,t[o],11,-358537222),s=Nt(s,i,n,r,t[o+3],16,-722521979),r=Nt(r,s,i,n,t[o+6],23,76029189),n=Nt(n,r,s,i,t[o+9],4,-640364487),i=Nt(i,n,r,s,t[o+12],11,-421815835),s=Nt(s,i,n,r,t[o+15],16,530742520),r=Nt(r,s,i,n,t[o+2],23,-995338651),n=Ct(n,r,s,i,t[o],6,-198630844),i=Ct(i,n,r,s,t[o+7],10,1126891415),s=Ct(s,i,n,r,t[o+14],15,-1416354905),r=Ct(r,s,i,n,t[o+5],21,-57434055),n=Ct(n,r,s,i,t[o+12],6,1700485571),i=Ct(i,n,r,s,t[o+3],10,-1894986606),s=Ct(s,i,n,r,t[o+10],15,-1051523),r=Ct(r,s,i,n,t[o+1],21,-2054922799),n=Ct(n,r,s,i,t[o+8],6,1873313359),i=Ct(i,n,r,s,t[o+15],10,-30611744),s=Ct(s,i,n,r,t[o+6],15,-1560198380),r=Ct(r,s,i,n,t[o+13],21,1309151649),n=Ct(n,r,s,i,t[o+4],6,-145523070),i=Ct(i,n,r,s,t[o+11],10,-1120210379),s=Ct(s,i,n,r,t[o+2],15,718787259),r=Ct(r,s,i,n,t[o+9],21,-343485551),n=Vn(n,a),r=Vn(r,d),s=Vn(s,m),i=Vn(i,g)}return[n,r,s,i]}function sA(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(Hf(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function Vn(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function iA(t,e){return t<<e|t>>>32-e}function Zi(t,e,n,r,s,i){return Vn(iA(Vn(Vn(e,t),Vn(r,i)),s),n)}function Ot(t,e,n,r,s,i,o){return Zi(e&n|~e&r,t,e,s,i,o)}function It(t,e,n,r,s,i,o){return Zi(e&r|n&~r,t,e,s,i,o)}function Nt(t,e,n,r,s,i,o){return Zi(e^n^r,t,e,s,i,o)}function Ct(t,e,n,r,s,i,o){return Zi(n^(e|~r),t,e,s,i,o)}var oA=Gf("v3",48,tA);function aA(t,e,n){t=t||{};var r=t.random||(t.rng||zf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var s=0;s<16;++s)e[n+s]=r[s];return e}return Wi(r)}function cA(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function Ec(t,e){return t<<e|t>>>32-e}function uA(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var s=0;s<r.length;++s)t.push(r.charCodeAt(s))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var i=t.length/4+2,o=Math.ceil(i/16),a=new Array(o),d=0;d<o;++d){for(var m=new Uint32Array(16),g=0;g<16;++g)m[g]=t[d*64+g*4]<<24|t[d*64+g*4+1]<<16|t[d*64+g*4+2]<<8|t[d*64+g*4+3];a[d]=m}a[o-1][14]=(t.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(t.length-1)*8&4294967295;for(var x=0;x<o;++x){for(var O=new Uint32Array(80),N=0;N<16;++N)O[N]=a[x][N];for(var F=16;F<80;++F)O[F]=Ec(O[F-3]^O[F-8]^O[F-14]^O[F-16],1);for(var M=n[0],k=n[1],K=n[2],Y=n[3],z=n[4],L=0;L<80;++L){var j=Math.floor(L/20),J=Ec(M,5)+cA(j,k,K,Y)+z+e[j]+O[L]>>>0;z=Y,Y=K,K=Ec(k,30)>>>0,k=M,M=J}n[0]=n[0]+M>>>0,n[1]=n[1]+k>>>0,n[2]=n[2]+K>>>0,n[3]=n[3]+Y>>>0,n[4]=n[4]+z>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var dA=Gf("v5",80,uA);const lA="00000000-0000-0000-0000-000000000000";function fA(t){if(!Ki(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const qf=Ga(Object.freeze(Object.defineProperty({__proto__:null,NIL:lA,parse:Vf,stringify:Wi,v1:JR,v3:oA,v4:aA,v5:dA,validate:Ki,version:fA},Symbol.toStringTag,{value:"Module"})));var vc,Kf;function hA(){if(Kf)return vc;Kf=1;const t=qf.v4;return vc=function(n,r,s,i){if(typeof n!="string")throw new TypeError(n+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:n};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const d=typeof i.generator=="function"?i.generator:function(){return t()};a.id=d(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},vc}var Rc,Wf;function pA(){if(Wf)return Rc;Wf=1;const t=qf.v4,e=hA(),n=function(r,s){if(!(this instanceof n))return new n(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return t()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return Rc=n,n.prototype.request=function(r,s,i,o){const a=this;let d=null;const m=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&m)throw new TypeError("JSON-RPC 1.0 does not support batching");if(m||!m&&r&&typeof r=="object"&&typeof s=="function")o=s,d=r;else{typeof i=="function"&&(o=i,i=void 0);const O=typeof o=="function";try{d=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(N){if(O){o(N);return}throw N}if(!O)return d}let x;try{x=JSON.stringify(d,this.options.replacer)}catch(O){o(O);return}return this.callServer(x,function(O,N){a._parseResponse(O,N,o)}),d},n.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s){i();return}let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){i(a);return}if(i.length===3)if(Array.isArray(o)){const a=function(m){return typeof m.error<"u"},d=function(m){return!a(m)};i(null,o.filter(a),o.filter(d));return}else{i(null,o.error,o.result);return}i(null,o)},Rc}pA();function Zf(t){try{return cc.ExtendedPoint.fromHex(t),!0}catch{return!1}}const Yf=(t,e)=>cc.sign(t,e.slice(0,32)),mA=cc.verify,Ac=t=>xe.Buffer.isBuffer(t)?t:t instanceof Uint8Array?xe.Buffer.from(t.buffer,t.byteOffset,t.byteLength):xe.Buffer.from(t);class gA{constructor(e){Object.assign(this,e)}encode(){return xe.Buffer.from(hc.serialize(Yi,this))}static decode(e){return hc.deserialize(Yi,this,e)}static decodeUnchecked(e){return hc.deserializeUnchecked(Yi,this,e)}}const Yi=new Map;var Jf;const yA=32,Gn=32;function bA(t){return t._bn!==void 0}let Xf=1;class ye extends gA{constructor(e){if(super({}),this._bn=void 0,bA(e))this._bn=e._bn;else{if(typeof e=="string"){const n=Dt.decode(e);if(n.length!=Gn)throw new Error("Invalid public key input");this._bn=new Rf(n)}else this._bn=new Rf(e);if(this._bn.byteLength()>Gn)throw new Error("Invalid public key input")}}static unique(){const e=new ye(Xf);return Xf+=1,new ye(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Dt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(xe.Buffer);if(e.length===Gn)return e;const n=xe.Buffer.alloc(32);return e.copy(n,32-e.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,n,r){const s=xe.Buffer.concat([e.toBuffer(),xe.Buffer.from(n),r.toBuffer()]),i=Ra(s);return new ye(i)}static createProgramAddressSync(e,n){let r=xe.Buffer.alloc(0);e.forEach(function(i){if(i.length>yA)throw new TypeError("Max seed length exceeded");r=xe.Buffer.concat([r,Ac(i)])}),r=xe.Buffer.concat([r,n.toBuffer(),xe.Buffer.from("ProgramDerivedAddress")]);const s=Ra(r);if(Zf(s))throw new Error("Invalid seeds, address must fall off the curve");return new ye(s)}static async createProgramAddress(e,n){return this.createProgramAddressSync(e,n)}static findProgramAddressSync(e,n){let r=255,s;for(;r!=0;){try{const i=e.concat(xe.Buffer.from([r]));s=this.createProgramAddressSync(i,n)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,n){return this.findProgramAddressSync(e,n)}static isOnCurve(e){const n=new ye(e);return Zf(n.toBytes())}}Jf=ye,ye.default=new Jf("11111111111111111111111111111111"),Yi.set(ye,{kind:"struct",fields:[["_bn","u256"]]}),new ye("BPFLoader1111111111111111111111111111111111");const Fr=1232,xc=127,Ji=64;class Xi{constructor(e,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const n of this.keySegments()){if(e<n.length)return n[e];e-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Se=(t="publicKey")=>B.blob(32,t),_A=(t="signature")=>B.blob(64,t),$r=(t="string")=>{const e=B.struct([B.u32("length"),B.u32("lengthPadding"),B.blob(B.offset(B.u32(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>n(i,o).chars.toString(),s.encode=(i,o,a)=>{const d={chars:xe.Buffer.from(i,"utf8")};return r(d,o,a)},s.alloc=i=>B.u32().span+B.u32().span+xe.Buffer.from(i,"utf8").length,s},wA=(t="authorized")=>B.struct([Se("staker"),Se("withdrawer")],t),EA=(t="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Se("custodian")],t),vA=(t="voteInit")=>B.struct([Se("nodePubkey"),Se("authorizedVoter"),Se("authorizedWithdrawer"),B.u8("commission")],t),RA=(t="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Se("currentAuthorityDerivedKeyOwnerPubkey"),$r("currentAuthorityDerivedKeySeed"),Se("newAuthorized")],t);function Kt(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(r&127)<<n*7,n+=1,(r&128)===0)break}return e}function Wt(t,e){let n=e;for(;;){let r=n&127;if(n>>=7,n==0){t.push(r);break}else r|=128,t.push(r)}}function yt(t,e){if(!t)throw new Error(e||"Assertion failed")}class Qi{constructor(e,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}static compile(e,n){const r=new Map,s=o=>{const a=o.toBase58();let d=r.get(a);return d===void 0&&(d={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,d)),d},i=s(n);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const d=s(a.pubkey);d.isSigner||=a.isSigner,d.isWritable||=a.isWritable}}return new Qi(n,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];yt(e.length<=256,"Max static account keys length exceeded");const n=e.filter(([,d])=>d.isSigner&&d.isWritable),r=e.filter(([,d])=>d.isSigner&&!d.isWritable),s=e.filter(([,d])=>!d.isSigner&&d.isWritable),i=e.filter(([,d])=>!d.isSigner&&!d.isWritable),o={numRequiredSignatures:n.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{yt(n.length>0,"Expected at least one writable signer key");const[d]=n[0];yt(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([d])=>new ye(d)),...r.map(([d])=>new ye(d)),...s.map(([d])=>new ye(d)),...i.map(([d])=>new ye(d))];return[o,a]}extractTableLookup(e){const[n,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(n.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:n,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,n){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(n(o)){const a=new ye(i),d=e.findIndex(m=>m.equals(a));d>=0&&(yt(d<256,"Max lookup table index exceeded"),r.push(d),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const Qf="Reached end of buffer unexpectedly";function On(t){if(t.length===0)throw new Error(Qf);return t.shift()}function Zt(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(Qf);return t.splice(...e)}class zr{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(n=>new ye(n)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Dt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xi(this.staticAccountKeys)}static compile(e){const n=Qi.compile(e.instructions,e.payerKey),[r,s]=n.getMessageComponents(),o=new Xi(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Dt.encode(a.data)}));return new zr({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-n,i=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=n-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,n)=>!this.isProgramId(n))}serialize(){const e=this.accountKeys.length;let n=[];Wt(n,e);const r=this.instructions.map(x=>{const{accounts:O,programIdIndex:N}=x,F=Array.from(Dt.decode(x.data));let M=[];Wt(M,O.length);let k=[];return Wt(k,F.length),{programIdIndex:N,keyIndicesCount:xe.Buffer.from(M),keyIndices:O,dataLength:xe.Buffer.from(k),data:F}});let s=[];Wt(s,r.length);let i=xe.Buffer.alloc(Fr);xe.Buffer.from(s).copy(i);let o=s.length;r.forEach(x=>{const N=B.struct([B.u8("programIdIndex"),B.blob(x.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),x.keyIndices.length,"keyIndices"),B.blob(x.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),x.data.length,"data")]).encode(x,i,o);o+=N}),i=i.slice(0,o);const a=B.struct([B.blob(1,"numRequiredSignatures"),B.blob(1,"numReadonlySignedAccounts"),B.blob(1,"numReadonlyUnsignedAccounts"),B.blob(n.length,"keyCount"),B.seq(Se("key"),e,"keys"),Se("recentBlockhash")]),d={numRequiredSignatures:xe.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:xe.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:xe.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:xe.Buffer.from(n),keys:this.accountKeys.map(x=>Ac(x.toBytes())),recentBlockhash:Dt.decode(this.recentBlockhash)};let m=xe.Buffer.alloc(2048);const g=a.encode(d,m);return i.copy(m,g),m.slice(0,g+i.length)}static from(e){let n=[...e];const r=On(n);if(r!==(r&xc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=On(n),i=On(n),o=Kt(n);let a=[];for(let O=0;O<o;O++){const N=Zt(n,0,Gn);a.push(new ye(xe.Buffer.from(N)))}const d=Zt(n,0,Gn),m=Kt(n);let g=[];for(let O=0;O<m;O++){const N=On(n),F=Kt(n),M=Zt(n,0,F),k=Kt(n),K=Zt(n,0,k),Y=Dt.encode(xe.Buffer.from(K));g.push({programIdIndex:N,accounts:M,data:Y})}const x={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:Dt.encode(xe.Buffer.from(d)),accountKeys:a,instructions:g};return new zr(x)}}class eo{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const n of this.addressTableLookups)e+=n.readonlyIndexes.length+n.writableIndexes.length;return e}getAccountKeys(e){let n;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)n=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Xi(this.staticAccountKeys,n)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-n,o=r-n-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=n-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const n={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)n.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)n.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return n}static compile(e){const n=Qi.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const g of i){const x=n.extractTableLookup(g);if(x!==void 0){const[O,{writable:N,readonly:F}]=x;r.push(O),s.writable.push(...N),s.readonly.push(...F)}}const[o,a]=n.getMessageComponents(),m=new Xi(a,s).compileInstructions(e.instructions);return new eo({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:m,addressTableLookups:r})}serialize(){const e=Array();Wt(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Wt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Wt(i,this.addressTableLookups.length);const o=B.struct([B.u8("prefix"),B.struct([B.u8("numRequiredSignatures"),B.u8("numReadonlySignedAccounts"),B.u8("numReadonlyUnsignedAccounts")],"header"),B.blob(e.length,"staticAccountKeysLength"),B.seq(Se(),this.staticAccountKeys.length,"staticAccountKeys"),Se("recentBlockhash"),B.blob(r.length,"instructionsLength"),B.blob(n.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(Fr),m=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:Dt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,m)}serializeInstructions(){let e=0;const n=new Uint8Array(Fr);for(const r of this.compiledInstructions){const s=Array();Wt(s,r.accountKeyIndexes.length);const i=Array();Wt(i,r.data.length);const o=B.struct([B.u8("programIdIndex"),B.blob(s.length,"encodedAccountKeyIndexesLength"),B.seq(B.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),B.blob(i.length,"encodedDataLength"),B.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},n,e)}return n.slice(0,e)}serializeAddressTableLookups(){let e=0;const n=new Uint8Array(Fr);for(const r of this.addressTableLookups){const s=Array();Wt(s,r.writableIndexes.length);const i=Array();Wt(i,r.readonlyIndexes.length);const o=B.struct([Se("accountKey"),B.blob(s.length,"encodedWritableIndexesLength"),B.seq(B.u8(),r.writableIndexes.length,"writableIndexes"),B.blob(i.length,"encodedReadonlyIndexesLength"),B.seq(B.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},n,e)}return n.slice(0,e)}static deserialize(e){let n=[...e];const r=On(n),s=r&xc;yt(r!==s,"Expected versioned message but received legacy message");const i=s;yt(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:On(n),numReadonlySignedAccounts:On(n),numReadonlyUnsignedAccounts:On(n)},a=[],d=Kt(n);for(let F=0;F<d;F++)a.push(new ye(Zt(n,0,Gn)));const m=Dt.encode(Zt(n,0,Gn)),g=Kt(n),x=[];for(let F=0;F<g;F++){const M=On(n),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),z=new Uint8Array(Zt(n,0,Y));x.push({programIdIndex:M,accountKeyIndexes:K,data:z})}const O=Kt(n),N=[];for(let F=0;F<O;F++){const M=new ye(Zt(n,0,Gn)),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),z=Zt(n,0,Y);N.push({accountKey:M,writableIndexes:K,readonlyIndexes:z})}return new eo({header:o,staticAccountKeys:a,recentBlockhash:m,compiledInstructions:x,addressTableLookups:N})}}const Sc={deserializeMessageVersion(t){const e=t[0],n=e&xc;return n===e?"legacy":n},deserialize:t=>{const e=Sc.deserializeMessageVersion(t);if(e==="legacy")return zr.from(t);if(e===0)return eo.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},AA=xe.Buffer.alloc(Ji).fill(0);class eh{constructor(e){this.keys=void 0,this.programId=void 0,this.data=xe.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:n,isWritable:r})=>({pubkey:e.toJSON(),isSigner:n,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class to{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:n,nonceInfo:r}=e;this.minNonceContextSlot=n,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:r}=e;this.recentBlockhash=n,this.lastValidBlockHeight=r}else{const{recentBlockhash:n,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new eh(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(e=this.recentBlockhash,n=this.instructions),!e)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let M=0;M<n.length;M++)if(n[M].programId===void 0)throw new Error(`Transaction instruction index ${M} has undefined program id`);const s=[],i=[];n.forEach(M=>{M.keys.forEach(K=>{i.push({...K})});const k=M.programId.toString();s.includes(k)||s.push(k)}),s.forEach(M=>{i.push({pubkey:new ye(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const k=M.pubkey.toString(),K=o.findIndex(Y=>Y.pubkey.toString()===k);K>-1?(o[K].isWritable=o[K].isWritable||M.isWritable,o[K].isSigner=o[K].isSigner||M.isSigner):o.push(M)}),o.sort(function(M,k){if(M.isSigner!==k.isSigner)return M.isSigner?-1:1;if(M.isWritable!==k.isWritable)return M.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(k.pubkey.toBase58(),"en",K)});const a=o.findIndex(M=>M.pubkey.equals(r));if(a>-1){const[M]=o.splice(a,1);M.isSigner=!0,M.isWritable=!0,o.unshift(M)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const M of this.signatures){const k=o.findIndex(K=>K.pubkey.equals(M.publicKey));if(k>-1)o[k].isSigner||(o[k].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${M.publicKey.toString()}`)}let d=0,m=0,g=0;const x=[],O=[];o.forEach(({pubkey:M,isSigner:k,isWritable:K})=>{k?(x.push(M.toString()),d+=1,K||(m+=1)):(O.push(M.toString()),K||(g+=1))});const N=x.concat(O),F=n.map(M=>{const{data:k,programId:K}=M;return{programIdIndex:N.indexOf(K.toString()),accounts:M.keys.map(Y=>N.indexOf(Y.pubkey.toString())),data:Dt.encode(k)}});return F.forEach(M=>{yt(M.programIdIndex>=0),M.accounts.forEach(k=>yt(k>=0))}),new zr({header:{numRequiredSignatures:d,numReadonlySignedAccounts:m,numReadonlyUnsignedAccounts:g},accountKeys:N,recentBlockhash:e,instructions:F})}_compile(){const e=this.compileMessage(),n=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((s,i)=>n[i].equals(s.publicKey))||(this.signatures=n.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const n=new Set;this.signatures=e.filter(r=>{const s=r.toString();return n.has(s)?!1:(n.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...n){const r=e.serialize();n.forEach(s=>{const i=Yf(r,s.secretKey);this._addSignature(s.publicKey,Ac(i))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){yt(n.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=xe.Buffer.from(n)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,n){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?n&&(r.missing||=[]).push(i):mA(s,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:n,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,n);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
32
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[mw]:"No signature verification implementation could be found.",[gw]:"No key generation implementation could be found.",[yw]:"No signing implementation could be found.",[bw]:"No key export implementation could be found.",[S_]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[xv]:"Transaction processing left an account with an outstanding borrowed reference",[dv]:"Account in use",[lv]:"Account loaded twice",[fv]:"Attempt to debit an account but found no record of a prior credit.",[Mv]:"Transaction loads an address table account that doesn't exist",[gv]:"This transaction has already been processed",[yv]:"Blockhash not found",[bv]:"Loader call chain is too deep",[Av]:"Transactions are currently disabled due to cluster maintenance",[Fv]:"Transaction contains a duplicate instruction ($index) that is not allowed",[pv]:"Insufficient funds for fee",[$v]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[mv]:"This account may not be used to pay transaction fees",[wv]:"Transaction contains an invalid account reference",[kv]:"Transaction loads an address table account with invalid data",[Lv]:"Transaction address table lookup uses an invalid index",[Bv]:"Transaction loads an address table account with an invalid owner",[jv]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[vv]:"This program may not be used for executing instructions",[Pv]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ov]:"Transaction loads a writable account that cannot be written",[zv]:"Transaction exceeded max loaded accounts data size cap",[_v]:"Transaction requires a fee but has no signature present",[hv]:"Attempt to load a program that does not exist",[Gv]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Vv]:"ResanitizationNeeded",[Rv]:"Transaction failed to sanitize accounts offsets correctly",[Ev]:"Transaction did not pass signature verification",[Cv]:"Transaction locked too many accounts",[Hv]:"Sum of account balances before and after transaction do not match",[uv]:"The transaction failed with the error `$errorName`",[Tv]:"Transaction version is unsupported",[Nv]:"Transaction would exceed account data limit within the block",[Dv]:"Transaction would exceed total account data limit",[Iv]:"Transaction would exceed max account limit within the block",[Sv]:"Transaction would exceed max Block Cost Limit",[Uv]:"Transaction would exceed max Vote Cost Limit",[rv]:"Attempted to sign a transaction with an address that is not a signer for it",[XE]:"Transaction is missing an address at index: $index.",[sv]:"Transaction has no expected signers therefore it cannot be encoded",[cv]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[GE]:"Transaction does not have a blockhash lifetime",[HE]:"Transaction is not a durable nonce transaction",[KE]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[WE]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[YE]:"No fee payer set in CompiledTransaction",[ZE]:"Could not find program address at index $index",[ov]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[av]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[QE]:"Transaction is missing a fee payer.",[ev]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[nv]:"Transaction first instruction is not advance nonce account instruction.",[tv]:"Transaction with no instructions cannot be durable nonce transaction.",[jE]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[VE]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[iv]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[JE]:"Transaction is missing signatures for addresses: $addresses.",[qE]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},On="i",fn="t";function SR(t,e={}){const n=xR[t];if(n.length===0)return"";let r;function s(o){if(r[fn]===2){const a=n.slice(r[On]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[fn]===1&&i.push(n.slice(r[On],o))}const i=[];return n.split("").forEach((o,a)=>{if(a===0){r={[On]:0,[fn]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let d;switch(r[fn]){case 0:d={[On]:a,[fn]:1};break;case 1:o==="\\"?d={[On]:a,[fn]:0}:o==="$"&&(d={[On]:a,[fn]:2});break;case 2:o==="\\"?d={[On]:a,[fn]:0}:o==="$"?d={[On]:a,[fn]:2}:o.match(/\w/)||(d={[On]:a,[fn]:1});break}d&&(r!==d&&s(a),r=d)}),s(),i.join("")}function TR(t,e={}){if(process.env.NODE_ENV!=="production")return SR(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${AR(e)}'`),`${n}\``}}var Pr=class extends Error{cause=this.cause;context;constructor(...[t,e]){let n,r;if(e){const{cause:i,...o}=e;i&&(r={cause:i}),Object.keys(o).length>0&&(n=o)}const s=TR(t,n);super(s,r),this.context={__code:t,...n},this.name="SolanaError"}};function OR(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function IR(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(OR(e,t));return t.write(e,n,0),n}})}function NR(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function Ur(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function CR(t,e){if(Ur(t)!==Ur(e))throw new Pr(Bf);if(Ur(t)&&Ur(e)&&t.fixedSize!==e.fixedSize)throw new Pr(kf,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!Ur(t)&&!Ur(e)&&t.maxSize!==e.maxSize)throw new Pr(Lf,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function MR(t,e,n=0){if(e.length-n<=0)throw new Pr(Cf,{codecDescription:t})}function BR(t,e,n,r=0){const s=n.length-r;if(s<e)throw new Pr(Mf,{bytesLength:s,codecDescription:t,expected:e})}function kR(t,e,n,r){if(r<e||r>n)throw new Pr(Pf,{codecDescription:t,max:n,min:e,value:r})}function Df(t){return t?.endian!==1}function LR(t){return IR({fixedSize:t.size,write(e,n,r){t.range&&kR(t.name,t.range[0],t.range[1],e);const s=new ArrayBuffer(t.size);return t.set(new DataView(s),e,Df(t.config)),n.set(new Uint8Array(s),r),r+t.size}})}function PR(t){return NR({fixedSize:t.size,read(e,n=0){MR(t.name,e,n),BR(t.name,t.size,e,n);const r=new DataView(UR(e,n,t.size));return[t.get(r,Df(t.config)),n+t.size]}})}function UR(t,e,n){const r=t.byteOffset+(e??0),s=n??t.byteLength;return t.buffer.slice(r,r+s)}var DR=(t={})=>LR({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),FR=(t={})=>PR({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),$R=(t={})=>CR(DR(t),FR(t));class zR extends TypeError{constructor(e,n){let r;const{message:s,explanation:i,...o}=e,{path:a}=e,d=a.length===0?s:`At path: ${a.join(".")} -- ${s}`;super(i??d),i!=null&&(this.cause=d),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>r??(r=[e,...n()])}}function jR(t){return Bs(t)&&typeof t[Symbol.iterator]=="function"}function Bs(t){return typeof t=="object"&&t!=null}function Hi(t){return Bs(t)&&!Array.isArray(t)}function rn(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function VR(t){const{done:e,value:n}=t.next();return e?void 0:n}function GR(t,e,n,r){if(t===!0)return;t===!1?t={}:typeof t=="string"&&(t={message:t});const{path:s,branch:i}=e,{type:o}=n,{refinement:a,message:d=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${rn(r)}\``}=t;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...t,message:d}}function*Ff(t,e,n,r){jR(t)||(t=[t]);for(const s of t){const i=GR(s,e,n,r);i&&(yield i)}}function*mc(t,e,n={}){const{path:r=[],branch:s=[t],coerce:i=!1,mask:o=!1}=n,a={path:r,branch:s,mask:o};i&&(t=e.coercer(t,a));let d="valid";for(const m of e.validator(t,a))m.explanation=n.message,d="not_valid",yield[m,void 0];for(let[m,g,x]of e.entries(t,a)){const O=mc(g,x,{path:m===void 0?r:[...r,m],branch:m===void 0?s:[...s,g],coerce:i,mask:o,message:n.message});for(const N of O)N[0]?(d=N[0].refinement!=null?"not_refined":"not_valid",yield[N[0],void 0]):i&&(g=N[1],m===void 0?t=g:t instanceof Map?t.set(m,g):t instanceof Set?t.add(g):Bs(t)&&(g!==void 0||m in t)&&(t[m]=g))}if(d!=="not_valid")for(const m of e.refiner(t,a))m.explanation=n.message,d="not_refined",yield[m,void 0];d==="valid"&&(yield[void 0,t])}let hn=class{constructor(e){const{type:n,schema:r,validator:s,refiner:i,coercer:o=d=>d,entries:a=function*(){}}=e;this.type=n,this.schema=r,this.entries=a,this.coercer=o,s?this.validator=(d,m)=>{const g=s(d,m);return Ff(g,m,this,d)}:this.validator=()=>[],i?this.refiner=(d,m)=>{const g=i(d,m);return Ff(g,m,this,d)}:this.refiner=()=>[]}assert(e,n){return HR(e,this,n)}create(e,n){return ks(e,this,n)}is(e){return $f(e,this)}mask(e,n){return qR(e,this,n)}validate(e,n={}){return Ls(e,this,n)}};function HR(t,e,n){const r=Ls(t,e,{message:n});if(r[0])throw r[0]}function ks(t,e,n){const r=Ls(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function qR(t,e,n){const r=Ls(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function $f(t,e){return!Ls(t,e)[0]}function Ls(t,e,n={}){const r=mc(t,e,n),s=VR(r);return s[0]?[new zR(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function ur(t,e){return new hn({type:t,schema:null,validator:e})}function KR(){return ur("any",()=>!0)}function ae(t){return new hn({type:"array",schema:t,*entries(e){if(t&&Array.isArray(e))for(const[n,r]of e.entries())yield[n,r,t]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${rn(e)}`}})}function pn(){return ur("boolean",t=>typeof t=="boolean")}function gc(t){return ur("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${rn(e)}`)}function He(t){const e=rn(t),n=typeof t;return new hn({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${rn(r)}`}})}function WR(){return ur("never",()=>!1)}function ce(t){return new hn({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function G(){return ur("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${rn(t)}`)}function fe(t){return new hn({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function zf(t,e){return new hn({type:"record",schema:null,*entries(n){if(Bs(n))for(const r in n){const s=n[r];yield[r,r,t],yield[r,s,e]}},validator(n){return Hi(n)||`Expected an object, but received: ${rn(n)}`},coercer(n){return Hi(n)?{...n}:n}})}function se(){return ur("string",t=>typeof t=="string"||`Expected a string, but received: ${rn(t)}`)}function yc(t){const e=WR();return new hn({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(t.length,n.length);for(let s=0;s<r;s++)yield[s,n[s],t[s]||e]}},validator(n){return Array.isArray(n)||`Expected an array, but received: ${rn(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function Q(t){const e=Object.keys(t);return new hn({type:"type",schema:t,*entries(n){if(Bs(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Hi(n)||`Expected an object, but received: ${rn(n)}`},coercer(n){return Hi(n)?{...n}:n}})}function Ft(t){const e=t.map(n=>n.type).join(" | ");return new hn({type:"union",schema:null,coercer(n,r){for(const s of t){const[i,o]=s.validate(n,{coerce:!0,mask:r.mask});if(!i)return o}return n},validator(n,r){const s=[];for(const i of t){const[...o]=mc(n,i,r),[a]=o;if(a[0])for(const[d]of o)d&&s.push(d);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${rn(n)}`,...s]}})}function Dr(){return ur("unknown",()=>!0)}function Ps(t,e,n){return new hn({...t,coercer:(r,s)=>$f(r,e)?t.coercer(n(r,s),s):t.coercer(r,s)})}var qi,ZR=new Uint8Array(16);function jf(){if(!qi&&(qi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!qi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qi(ZR)}const YR=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Ki(t){return typeof t=="string"&&YR.test(t)}for(var vt=[],bc=0;bc<256;++bc)vt.push((bc+256).toString(16).substr(1));function Wi(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(vt[t[e+0]]+vt[t[e+1]]+vt[t[e+2]]+vt[t[e+3]]+"-"+vt[t[e+4]]+vt[t[e+5]]+"-"+vt[t[e+6]]+vt[t[e+7]]+"-"+vt[t[e+8]]+vt[t[e+9]]+"-"+vt[t[e+10]]+vt[t[e+11]]+vt[t[e+12]]+vt[t[e+13]]+vt[t[e+14]]+vt[t[e+15]]).toLowerCase();if(!Ki(n))throw TypeError("Stringified UUID is invalid");return n}var Vf,_c,wc=0,Ec=0;function JR(t,e,n){var r=e&&n||0,s=e||new Array(16);t=t||{};var i=t.node||Vf,o=t.clockseq!==void 0?t.clockseq:_c;if(i==null||o==null){var a=t.random||(t.rng||jf)();i==null&&(i=Vf=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=_c=(a[6]<<8|a[7])&16383)}var d=t.msecs!==void 0?t.msecs:Date.now(),m=t.nsecs!==void 0?t.nsecs:Ec+1,g=d-wc+(m-Ec)/1e4;if(g<0&&t.clockseq===void 0&&(o=o+1&16383),(g<0||d>wc)&&t.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");wc=d,Ec=m,_c=o,d+=122192928e5;var x=((d&268435455)*1e4+m)%4294967296;s[r++]=x>>>24&255,s[r++]=x>>>16&255,s[r++]=x>>>8&255,s[r++]=x&255;var O=d/4294967296*1e4&268435455;s[r++]=O>>>8&255,s[r++]=O&255,s[r++]=O>>>24&15|16,s[r++]=O>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var N=0;N<6;++N)s[r+N]=i[N];return e||Wi(s)}function Gf(t){if(!Ki(t))throw TypeError("Invalid UUID");var e,n=new Uint8Array(16);return n[0]=(e=parseInt(t.slice(0,8),16))>>>24,n[1]=e>>>16&255,n[2]=e>>>8&255,n[3]=e&255,n[4]=(e=parseInt(t.slice(9,13),16))>>>8,n[5]=e&255,n[6]=(e=parseInt(t.slice(14,18),16))>>>8,n[7]=e&255,n[8]=(e=parseInt(t.slice(19,23),16))>>>8,n[9]=e&255,n[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,n[11]=e/4294967296&255,n[12]=e>>>24&255,n[13]=e>>>16&255,n[14]=e>>>8&255,n[15]=e&255,n}function XR(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var QR="6ba7b810-9dad-11d1-80b4-00c04fd430c8",eA="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Hf(t,e,n){function r(s,i,o,a){if(typeof s=="string"&&(s=XR(s)),typeof i=="string"&&(i=Gf(i)),i.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var d=new Uint8Array(16+s.length);if(d.set(i),d.set(s,i.length),d=n(d),d[6]=d[6]&15|e,d[8]=d[8]&63|128,o){a=a||0;for(var m=0;m<16;++m)o[a+m]=d[m];return o}return Wi(d)}try{r.name=t}catch{}return r.DNS=QR,r.URL=eA,r}function tA(t){if(typeof t=="string"){var e=unescape(encodeURIComponent(t));t=new Uint8Array(e.length);for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)}return nA(rA(sA(t),t.length*8))}function nA(t){for(var e=[],n=t.length*32,r="0123456789abcdef",s=0;s<n;s+=8){var i=t[s>>5]>>>s%32&255,o=parseInt(r.charAt(i>>>4&15)+r.charAt(i&15),16);e.push(o)}return e}function qf(t){return(t+64>>>9<<4)+14+1}function rA(t,e){t[e>>5]|=128<<e%32,t[qf(e)-1]=e;for(var n=1732584193,r=-271733879,s=-1732584194,i=271733878,o=0;o<t.length;o+=16){var a=n,d=r,m=s,g=i;n=Ot(n,r,s,i,t[o],7,-680876936),i=Ot(i,n,r,s,t[o+1],12,-389564586),s=Ot(s,i,n,r,t[o+2],17,606105819),r=Ot(r,s,i,n,t[o+3],22,-1044525330),n=Ot(n,r,s,i,t[o+4],7,-176418897),i=Ot(i,n,r,s,t[o+5],12,1200080426),s=Ot(s,i,n,r,t[o+6],17,-1473231341),r=Ot(r,s,i,n,t[o+7],22,-45705983),n=Ot(n,r,s,i,t[o+8],7,1770035416),i=Ot(i,n,r,s,t[o+9],12,-1958414417),s=Ot(s,i,n,r,t[o+10],17,-42063),r=Ot(r,s,i,n,t[o+11],22,-1990404162),n=Ot(n,r,s,i,t[o+12],7,1804603682),i=Ot(i,n,r,s,t[o+13],12,-40341101),s=Ot(s,i,n,r,t[o+14],17,-1502002290),r=Ot(r,s,i,n,t[o+15],22,1236535329),n=It(n,r,s,i,t[o+1],5,-165796510),i=It(i,n,r,s,t[o+6],9,-1069501632),s=It(s,i,n,r,t[o+11],14,643717713),r=It(r,s,i,n,t[o],20,-373897302),n=It(n,r,s,i,t[o+5],5,-701558691),i=It(i,n,r,s,t[o+10],9,38016083),s=It(s,i,n,r,t[o+15],14,-660478335),r=It(r,s,i,n,t[o+4],20,-405537848),n=It(n,r,s,i,t[o+9],5,568446438),i=It(i,n,r,s,t[o+14],9,-1019803690),s=It(s,i,n,r,t[o+3],14,-187363961),r=It(r,s,i,n,t[o+8],20,1163531501),n=It(n,r,s,i,t[o+13],5,-1444681467),i=It(i,n,r,s,t[o+2],9,-51403784),s=It(s,i,n,r,t[o+7],14,1735328473),r=It(r,s,i,n,t[o+12],20,-1926607734),n=Nt(n,r,s,i,t[o+5],4,-378558),i=Nt(i,n,r,s,t[o+8],11,-2022574463),s=Nt(s,i,n,r,t[o+11],16,1839030562),r=Nt(r,s,i,n,t[o+14],23,-35309556),n=Nt(n,r,s,i,t[o+1],4,-1530992060),i=Nt(i,n,r,s,t[o+4],11,1272893353),s=Nt(s,i,n,r,t[o+7],16,-155497632),r=Nt(r,s,i,n,t[o+10],23,-1094730640),n=Nt(n,r,s,i,t[o+13],4,681279174),i=Nt(i,n,r,s,t[o],11,-358537222),s=Nt(s,i,n,r,t[o+3],16,-722521979),r=Nt(r,s,i,n,t[o+6],23,76029189),n=Nt(n,r,s,i,t[o+9],4,-640364487),i=Nt(i,n,r,s,t[o+12],11,-421815835),s=Nt(s,i,n,r,t[o+15],16,530742520),r=Nt(r,s,i,n,t[o+2],23,-995338651),n=Ct(n,r,s,i,t[o],6,-198630844),i=Ct(i,n,r,s,t[o+7],10,1126891415),s=Ct(s,i,n,r,t[o+14],15,-1416354905),r=Ct(r,s,i,n,t[o+5],21,-57434055),n=Ct(n,r,s,i,t[o+12],6,1700485571),i=Ct(i,n,r,s,t[o+3],10,-1894986606),s=Ct(s,i,n,r,t[o+10],15,-1051523),r=Ct(r,s,i,n,t[o+1],21,-2054922799),n=Ct(n,r,s,i,t[o+8],6,1873313359),i=Ct(i,n,r,s,t[o+15],10,-30611744),s=Ct(s,i,n,r,t[o+6],15,-1560198380),r=Ct(r,s,i,n,t[o+13],21,1309151649),n=Ct(n,r,s,i,t[o+4],6,-145523070),i=Ct(i,n,r,s,t[o+11],10,-1120210379),s=Ct(s,i,n,r,t[o+2],15,718787259),r=Ct(r,s,i,n,t[o+9],21,-343485551),n=Gn(n,a),r=Gn(r,d),s=Gn(s,m),i=Gn(i,g)}return[n,r,s,i]}function sA(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(qf(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function Gn(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function iA(t,e){return t<<e|t>>>32-e}function Zi(t,e,n,r,s,i){return Gn(iA(Gn(Gn(e,t),Gn(r,i)),s),n)}function Ot(t,e,n,r,s,i,o){return Zi(e&n|~e&r,t,e,s,i,o)}function It(t,e,n,r,s,i,o){return Zi(e&r|n&~r,t,e,s,i,o)}function Nt(t,e,n,r,s,i,o){return Zi(e^n^r,t,e,s,i,o)}function Ct(t,e,n,r,s,i,o){return Zi(n^(e|~r),t,e,s,i,o)}var oA=Hf("v3",48,tA);function aA(t,e,n){t=t||{};var r=t.random||(t.rng||jf)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(var s=0;s<16;++s)e[n+s]=r[s];return e}return Wi(r)}function cA(t,e,n,r){switch(t){case 0:return e&n^~e&r;case 1:return e^n^r;case 2:return e&n^e&r^n&r;case 3:return e^n^r}}function vc(t,e){return t<<e|t>>>32-e}function uA(t){var e=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){var r=unescape(encodeURIComponent(t));t=[];for(var s=0;s<r.length;++s)t.push(r.charCodeAt(s))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);for(var i=t.length/4+2,o=Math.ceil(i/16),a=new Array(o),d=0;d<o;++d){for(var m=new Uint32Array(16),g=0;g<16;++g)m[g]=t[d*64+g*4]<<24|t[d*64+g*4+1]<<16|t[d*64+g*4+2]<<8|t[d*64+g*4+3];a[d]=m}a[o-1][14]=(t.length-1)*8/Math.pow(2,32),a[o-1][14]=Math.floor(a[o-1][14]),a[o-1][15]=(t.length-1)*8&4294967295;for(var x=0;x<o;++x){for(var O=new Uint32Array(80),N=0;N<16;++N)O[N]=a[x][N];for(var F=16;F<80;++F)O[F]=vc(O[F-3]^O[F-8]^O[F-14]^O[F-16],1);for(var C=n[0],k=n[1],K=n[2],Y=n[3],V=n[4],L=0;L<80;++L){var z=Math.floor(L/20),J=vc(C,5)+cA(z,k,K,Y)+V+e[z]+O[L]>>>0;V=Y,Y=K,K=vc(k,30)>>>0,k=C,C=J}n[0]=n[0]+C>>>0,n[1]=n[1]+k>>>0,n[2]=n[2]+K>>>0,n[3]=n[3]+Y>>>0,n[4]=n[4]+V>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var dA=Hf("v5",80,uA);const lA="00000000-0000-0000-0000-000000000000";function fA(t){if(!Ki(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const Kf=Ha(Object.freeze(Object.defineProperty({__proto__:null,NIL:lA,parse:Gf,stringify:Wi,v1:JR,v3:oA,v4:aA,v5:dA,validate:Ki,version:fA},Symbol.toStringTag,{value:"Module"})));var Rc,Wf;function hA(){if(Wf)return Rc;Wf=1;const t=Kf.v4;return Rc=function(n,r,s,i){if(typeof n!="string")throw new TypeError(n+" must be a string");i=i||{};const o=typeof i.version=="number"?i.version:2;if(o!==1&&o!==2)throw new TypeError(o+" must be 1 or 2");const a={method:n};if(o===2&&(a.jsonrpc="2.0"),r){if(typeof r!="object"&&!Array.isArray(r))throw new TypeError(r+" must be an object, array or omitted");a.params=r}if(typeof s>"u"){const d=typeof i.generator=="function"?i.generator:function(){return t()};a.id=d(a,i)}else o===2&&s===null?i.notificationIdNull&&(a.id=null):a.id=s;return a},Rc}var Ac,Zf;function pA(){if(Zf)return Ac;Zf=1;const t=Kf.v4,e=hA(),n=function(r,s){if(!(this instanceof n))return new n(r,s);s||(s={}),this.options={reviver:typeof s.reviver<"u"?s.reviver:null,replacer:typeof s.replacer<"u"?s.replacer:null,generator:typeof s.generator<"u"?s.generator:function(){return t()},version:typeof s.version<"u"?s.version:2,notificationIdNull:typeof s.notificationIdNull=="boolean"?s.notificationIdNull:!1},this.callServer=r};return Ac=n,n.prototype.request=function(r,s,i,o){const a=this;let d=null;const m=Array.isArray(r)&&typeof s=="function";if(this.options.version===1&&m)throw new TypeError("JSON-RPC 1.0 does not support batching");if(m||!m&&r&&typeof r=="object"&&typeof s=="function")o=s,d=r;else{typeof i=="function"&&(o=i,i=void 0);const O=typeof o=="function";try{d=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(N){if(O){o(N);return}throw N}if(!O)return d}let x;try{x=JSON.stringify(d,this.options.replacer)}catch(O){o(O);return}return this.callServer(x,function(O,N){a._parseResponse(O,N,o)}),d},n.prototype._parseResponse=function(r,s,i){if(r){i(r);return}if(!s){i();return}let o;try{o=JSON.parse(s,this.options.reviver)}catch(a){i(a);return}if(i.length===3)if(Array.isArray(o)){const a=function(m){return typeof m.error<"u"},d=function(m){return!a(m)};i(null,o.filter(a),o.filter(d));return}else{i(null,o.error,o.result);return}i(null,o)},Ac}pA();function Yf(t){try{return uc.ExtendedPoint.fromHex(t),!0}catch{return!1}}const Jf=(t,e)=>uc.sign(t,e.slice(0,32)),mA=uc.verify,xc=t=>xe.Buffer.isBuffer(t)?t:t instanceof Uint8Array?xe.Buffer.from(t.buffer,t.byteOffset,t.byteLength):xe.Buffer.from(t);class gA{constructor(e){Object.assign(this,e)}encode(){return xe.Buffer.from(pc.serialize(Yi,this))}static decode(e){return pc.deserialize(Yi,this,e)}static decodeUnchecked(e){return pc.deserializeUnchecked(Yi,this,e)}}const Yi=new Map;var Xf;const yA=32,Hn=32;function bA(t){return t._bn!==void 0}let Qf=1;class ye extends gA{constructor(e){if(super({}),this._bn=void 0,bA(e))this._bn=e._bn;else{if(typeof e=="string"){const n=Dt.decode(e);if(n.length!=Hn)throw new Error("Invalid public key input");this._bn=new Af(n)}else this._bn=new Af(e);if(this._bn.byteLength()>Hn)throw new Error("Invalid public key input")}}static unique(){const e=new ye(Qf);return Qf+=1,new ye(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Dt.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(xe.Buffer);if(e.length===Hn)return e;const n=xe.Buffer.alloc(32);return e.copy(n,32-e.length),n}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,n,r){const s=xe.Buffer.concat([e.toBuffer(),xe.Buffer.from(n),r.toBuffer()]),i=Aa(s);return new ye(i)}static createProgramAddressSync(e,n){let r=xe.Buffer.alloc(0);e.forEach(function(i){if(i.length>yA)throw new TypeError("Max seed length exceeded");r=xe.Buffer.concat([r,xc(i)])}),r=xe.Buffer.concat([r,n.toBuffer(),xe.Buffer.from("ProgramDerivedAddress")]);const s=Aa(r);if(Yf(s))throw new Error("Invalid seeds, address must fall off the curve");return new ye(s)}static async createProgramAddress(e,n){return this.createProgramAddressSync(e,n)}static findProgramAddressSync(e,n){let r=255,s;for(;r!=0;){try{const i=e.concat(xe.Buffer.from([r]));s=this.createProgramAddressSync(i,n)}catch(i){if(i instanceof TypeError)throw i;r--;continue}return[s,r]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,n){return this.findProgramAddressSync(e,n)}static isOnCurve(e){const n=new ye(e);return Yf(n.toBytes())}}Xf=ye,ye.default=new Xf("11111111111111111111111111111111"),Yi.set(ye,{kind:"struct",fields:[["_bn","u256"]]}),new ye("BPFLoader1111111111111111111111111111111111");const Fr=1232,Sc=127,Ji=64;class Xi{constructor(e,n){this.staticAccountKeys=void 0,this.accountKeysFromLookups=void 0,this.staticAccountKeys=e,this.accountKeysFromLookups=n}keySegments(){const e=[this.staticAccountKeys];return this.accountKeysFromLookups&&(e.push(this.accountKeysFromLookups.writable),e.push(this.accountKeysFromLookups.readonly)),e}get(e){for(const n of this.keySegments()){if(e<n.length)return n[e];e-=n.length}}get length(){return this.keySegments().flat().length}compileInstructions(e){if(this.length>256)throw new Error("Account index overflow encountered during compilation");const r=new Map;this.keySegments().flat().forEach((i,o)=>{r.set(i.toBase58(),o)});const s=i=>{const o=r.get(i.toBase58());if(o===void 0)throw new Error("Encountered an unknown instruction account key during compilation");return o};return e.map(i=>({programIdIndex:s(i.programId),accountKeyIndexes:i.keys.map(o=>s(o.pubkey)),data:i.data}))}}const Se=(t="publicKey")=>M.blob(32,t),_A=(t="signature")=>M.blob(64,t),$r=(t="string")=>{const e=M.struct([M.u32("length"),M.u32("lengthPadding"),M.blob(M.offset(M.u32(),-8),"chars")],t),n=e.decode.bind(e),r=e.encode.bind(e),s=e;return s.decode=(i,o)=>n(i,o).chars.toString(),s.encode=(i,o,a)=>{const d={chars:xe.Buffer.from(i,"utf8")};return r(d,o,a)},s.alloc=i=>M.u32().span+M.u32().span+xe.Buffer.from(i,"utf8").length,s},wA=(t="authorized")=>M.struct([Se("staker"),Se("withdrawer")],t),EA=(t="lockup")=>M.struct([M.ns64("unixTimestamp"),M.ns64("epoch"),Se("custodian")],t),vA=(t="voteInit")=>M.struct([Se("nodePubkey"),Se("authorizedVoter"),Se("authorizedWithdrawer"),M.u8("commission")],t),RA=(t="voteAuthorizeWithSeedArgs")=>M.struct([M.u32("voteAuthorizationType"),Se("currentAuthorityDerivedKeyOwnerPubkey"),$r("currentAuthorityDerivedKeySeed"),Se("newAuthorized")],t);function Kt(t){let e=0,n=0;for(;;){let r=t.shift();if(e|=(r&127)<<n*7,n+=1,(r&128)===0)break}return e}function Wt(t,e){let n=e;for(;;){let r=n&127;if(n>>=7,n==0){t.push(r);break}else r|=128,t.push(r)}}function yt(t,e){if(!t)throw new Error(e||"Assertion failed")}class Qi{constructor(e,n){this.payer=void 0,this.keyMetaMap=void 0,this.payer=e,this.keyMetaMap=n}static compile(e,n){const r=new Map,s=o=>{const a=o.toBase58();let d=r.get(a);return d===void 0&&(d={isSigner:!1,isWritable:!1,isInvoked:!1},r.set(a,d)),d},i=s(n);i.isSigner=!0,i.isWritable=!0;for(const o of e){s(o.programId).isInvoked=!0;for(const a of o.keys){const d=s(a.pubkey);d.isSigner||=a.isSigner,d.isWritable||=a.isWritable}}return new Qi(n,r)}getMessageComponents(){const e=[...this.keyMetaMap.entries()];yt(e.length<=256,"Max static account keys length exceeded");const n=e.filter(([,d])=>d.isSigner&&d.isWritable),r=e.filter(([,d])=>d.isSigner&&!d.isWritable),s=e.filter(([,d])=>!d.isSigner&&d.isWritable),i=e.filter(([,d])=>!d.isSigner&&!d.isWritable),o={numRequiredSignatures:n.length+r.length,numReadonlySignedAccounts:r.length,numReadonlyUnsignedAccounts:i.length};{yt(n.length>0,"Expected at least one writable signer key");const[d]=n[0];yt(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([d])=>new ye(d)),...r.map(([d])=>new ye(d)),...s.map(([d])=>new ye(d)),...i.map(([d])=>new ye(d))];return[o,a]}extractTableLookup(e){const[n,r]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&o.isWritable),[s,i]=this.drainKeysFoundInLookupTable(e.state.addresses,o=>!o.isSigner&&!o.isInvoked&&!o.isWritable);if(!(n.length===0&&s.length===0))return[{accountKey:e.key,writableIndexes:n,readonlyIndexes:s},{writable:r,readonly:i}]}drainKeysFoundInLookupTable(e,n){const r=new Array,s=new Array;for(const[i,o]of this.keyMetaMap.entries())if(n(o)){const a=new ye(i),d=e.findIndex(m=>m.equals(a));d>=0&&(yt(d<256,"Max lookup table index exceeded"),r.push(d),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const eh="Reached end of buffer unexpectedly";function In(t){if(t.length===0)throw new Error(eh);return t.shift()}function Zt(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(eh);return t.splice(...e)}class zr{constructor(e){this.header=void 0,this.accountKeys=void 0,this.recentBlockhash=void 0,this.instructions=void 0,this.indexToProgramIds=new Map,this.header=e.header,this.accountKeys=e.accountKeys.map(n=>new ye(n)),this.recentBlockhash=e.recentBlockhash,this.instructions=e.instructions,this.instructions.forEach(n=>this.indexToProgramIds.set(n.programIdIndex,this.accountKeys[n.programIdIndex]))}get version(){return"legacy"}get staticAccountKeys(){return this.accountKeys}get compiledInstructions(){return this.instructions.map(e=>({programIdIndex:e.programIdIndex,accountKeyIndexes:e.accounts,data:Dt.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new Xi(this.staticAccountKeys)}static compile(e){const n=Qi.compile(e.instructions,e.payerKey),[r,s]=n.getMessageComponents(),o=new Xi(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Dt.encode(a.data)}));return new zr({header:r,accountKeys:s,recentBlockhash:e.recentBlockhash,instructions:o})}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures;if(e>=this.header.numRequiredSignatures){const r=e-n,i=this.accountKeys.length-n-this.header.numReadonlyUnsignedAccounts;return r<i}else{const r=n-this.header.numReadonlySignedAccounts;return e<r}}isProgramId(e){return this.indexToProgramIds.has(e)}programIds(){return[...this.indexToProgramIds.values()]}nonProgramIds(){return this.accountKeys.filter((e,n)=>!this.isProgramId(n))}serialize(){const e=this.accountKeys.length;let n=[];Wt(n,e);const r=this.instructions.map(x=>{const{accounts:O,programIdIndex:N}=x,F=Array.from(Dt.decode(x.data));let C=[];Wt(C,O.length);let k=[];return Wt(k,F.length),{programIdIndex:N,keyIndicesCount:xe.Buffer.from(C),keyIndices:O,dataLength:xe.Buffer.from(k),data:F}});let s=[];Wt(s,r.length);let i=xe.Buffer.alloc(Fr);xe.Buffer.from(s).copy(i);let o=s.length;r.forEach(x=>{const N=M.struct([M.u8("programIdIndex"),M.blob(x.keyIndicesCount.length,"keyIndicesCount"),M.seq(M.u8("keyIndex"),x.keyIndices.length,"keyIndices"),M.blob(x.dataLength.length,"dataLength"),M.seq(M.u8("userdatum"),x.data.length,"data")]).encode(x,i,o);o+=N}),i=i.slice(0,o);const a=M.struct([M.blob(1,"numRequiredSignatures"),M.blob(1,"numReadonlySignedAccounts"),M.blob(1,"numReadonlyUnsignedAccounts"),M.blob(n.length,"keyCount"),M.seq(Se("key"),e,"keys"),Se("recentBlockhash")]),d={numRequiredSignatures:xe.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:xe.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:xe.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:xe.Buffer.from(n),keys:this.accountKeys.map(x=>xc(x.toBytes())),recentBlockhash:Dt.decode(this.recentBlockhash)};let m=xe.Buffer.alloc(2048);const g=a.encode(d,m);return i.copy(m,g),m.slice(0,g+i.length)}static from(e){let n=[...e];const r=In(n);if(r!==(r&Sc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=In(n),i=In(n),o=Kt(n);let a=[];for(let O=0;O<o;O++){const N=Zt(n,0,Hn);a.push(new ye(xe.Buffer.from(N)))}const d=Zt(n,0,Hn),m=Kt(n);let g=[];for(let O=0;O<m;O++){const N=In(n),F=Kt(n),C=Zt(n,0,F),k=Kt(n),K=Zt(n,0,k),Y=Dt.encode(xe.Buffer.from(K));g.push({programIdIndex:N,accounts:C,data:Y})}const x={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:Dt.encode(xe.Buffer.from(d)),accountKeys:a,instructions:g};return new zr(x)}}class eo{constructor(e){this.header=void 0,this.staticAccountKeys=void 0,this.recentBlockhash=void 0,this.compiledInstructions=void 0,this.addressTableLookups=void 0,this.header=e.header,this.staticAccountKeys=e.staticAccountKeys,this.recentBlockhash=e.recentBlockhash,this.compiledInstructions=e.compiledInstructions,this.addressTableLookups=e.addressTableLookups}get version(){return 0}get numAccountKeysFromLookups(){let e=0;for(const n of this.addressTableLookups)e+=n.readonlyIndexes.length+n.writableIndexes.length;return e}getAccountKeys(e){let n;if(e&&"accountKeysFromLookups"in e&&e.accountKeysFromLookups){if(this.numAccountKeysFromLookups!=e.accountKeysFromLookups.writable.length+e.accountKeysFromLookups.readonly.length)throw new Error("Failed to get account keys because of a mismatch in the number of account keys from lookups");n=e.accountKeysFromLookups}else if(e&&"addressLookupTableAccounts"in e&&e.addressLookupTableAccounts)n=this.resolveAddressTableLookups(e.addressLookupTableAccounts);else if(this.addressTableLookups.length>0)throw new Error("Failed to get account keys because address table lookups were not resolved");return new Xi(this.staticAccountKeys,n)}isAccountSigner(e){return e<this.header.numRequiredSignatures}isAccountWritable(e){const n=this.header.numRequiredSignatures,r=this.staticAccountKeys.length;if(e>=r){const s=e-r,i=this.addressTableLookups.reduce((o,a)=>o+a.writableIndexes.length,0);return s<i}else if(e>=this.header.numRequiredSignatures){const s=e-n,o=r-n-this.header.numReadonlyUnsignedAccounts;return s<o}else{const s=n-this.header.numReadonlySignedAccounts;return e<s}}resolveAddressTableLookups(e){const n={writable:[],readonly:[]};for(const r of this.addressTableLookups){const s=e.find(i=>i.key.equals(r.accountKey));if(!s)throw new Error(`Failed to find address lookup table account for table key ${r.accountKey.toBase58()}`);for(const i of r.writableIndexes)if(i<s.state.addresses.length)n.writable.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`);for(const i of r.readonlyIndexes)if(i<s.state.addresses.length)n.readonly.push(s.state.addresses[i]);else throw new Error(`Failed to find address for index ${i} in address lookup table ${r.accountKey.toBase58()}`)}return n}static compile(e){const n=Qi.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const g of i){const x=n.extractTableLookup(g);if(x!==void 0){const[O,{writable:N,readonly:F}]=x;r.push(O),s.writable.push(...N),s.readonly.push(...F)}}const[o,a]=n.getMessageComponents(),m=new Xi(a,s).compileInstructions(e.instructions);return new eo({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:m,addressTableLookups:r})}serialize(){const e=Array();Wt(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Wt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Wt(i,this.addressTableLookups.length);const o=M.struct([M.u8("prefix"),M.struct([M.u8("numRequiredSignatures"),M.u8("numReadonlySignedAccounts"),M.u8("numReadonlyUnsignedAccounts")],"header"),M.blob(e.length,"staticAccountKeysLength"),M.seq(Se(),this.staticAccountKeys.length,"staticAccountKeys"),Se("recentBlockhash"),M.blob(r.length,"instructionsLength"),M.blob(n.length,"serializedInstructions"),M.blob(i.length,"addressTableLookupsLength"),M.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(Fr),m=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:Dt.decode(this.recentBlockhash),instructionsLength:new Uint8Array(r),serializedInstructions:n,addressTableLookupsLength:new Uint8Array(i),serializedAddressTableLookups:s},a);return a.slice(0,m)}serializeInstructions(){let e=0;const n=new Uint8Array(Fr);for(const r of this.compiledInstructions){const s=Array();Wt(s,r.accountKeyIndexes.length);const i=Array();Wt(i,r.data.length);const o=M.struct([M.u8("programIdIndex"),M.blob(s.length,"encodedAccountKeyIndexesLength"),M.seq(M.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),M.blob(i.length,"encodedDataLength"),M.blob(r.data.length,"data")]);e+=o.encode({programIdIndex:r.programIdIndex,encodedAccountKeyIndexesLength:new Uint8Array(s),accountKeyIndexes:r.accountKeyIndexes,encodedDataLength:new Uint8Array(i),data:r.data},n,e)}return n.slice(0,e)}serializeAddressTableLookups(){let e=0;const n=new Uint8Array(Fr);for(const r of this.addressTableLookups){const s=Array();Wt(s,r.writableIndexes.length);const i=Array();Wt(i,r.readonlyIndexes.length);const o=M.struct([Se("accountKey"),M.blob(s.length,"encodedWritableIndexesLength"),M.seq(M.u8(),r.writableIndexes.length,"writableIndexes"),M.blob(i.length,"encodedReadonlyIndexesLength"),M.seq(M.u8(),r.readonlyIndexes.length,"readonlyIndexes")]);e+=o.encode({accountKey:r.accountKey.toBytes(),encodedWritableIndexesLength:new Uint8Array(s),writableIndexes:r.writableIndexes,encodedReadonlyIndexesLength:new Uint8Array(i),readonlyIndexes:r.readonlyIndexes},n,e)}return n.slice(0,e)}static deserialize(e){let n=[...e];const r=In(n),s=r&Sc;yt(r!==s,"Expected versioned message but received legacy message");const i=s;yt(i===0,`Expected versioned message with version 0 but found version ${i}`);const o={numRequiredSignatures:In(n),numReadonlySignedAccounts:In(n),numReadonlyUnsignedAccounts:In(n)},a=[],d=Kt(n);for(let F=0;F<d;F++)a.push(new ye(Zt(n,0,Hn)));const m=Dt.encode(Zt(n,0,Hn)),g=Kt(n),x=[];for(let F=0;F<g;F++){const C=In(n),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),V=new Uint8Array(Zt(n,0,Y));x.push({programIdIndex:C,accountKeyIndexes:K,data:V})}const O=Kt(n),N=[];for(let F=0;F<O;F++){const C=new ye(Zt(n,0,Hn)),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),V=Zt(n,0,Y);N.push({accountKey:C,writableIndexes:K,readonlyIndexes:V})}return new eo({header:o,staticAccountKeys:a,recentBlockhash:m,compiledInstructions:x,addressTableLookups:N})}}const Tc={deserializeMessageVersion(t){const e=t[0],n=e&Sc;return n===e?"legacy":n},deserialize:t=>{const e=Tc.deserializeMessageVersion(t);if(e==="legacy")return zr.from(t);if(e===0)return eo.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},AA=xe.Buffer.alloc(Ji).fill(0);class th{constructor(e){this.keys=void 0,this.programId=void 0,this.data=xe.Buffer.alloc(0),this.programId=e.programId,this.keys=e.keys,e.data&&(this.data=e.data)}toJSON(){return{keys:this.keys.map(({pubkey:e,isSigner:n,isWritable:r})=>({pubkey:e.toJSON(),isSigner:n,isWritable:r})),programId:this.programId.toJSON(),data:[...this.data]}}}class to{get signature(){return this.signatures.length>0?this.signatures[0].signature:null}constructor(e){if(this.signatures=[],this.feePayer=void 0,this.instructions=[],this.recentBlockhash=void 0,this.lastValidBlockHeight=void 0,this.nonceInfo=void 0,this.minNonceContextSlot=void 0,this._message=void 0,this._json=void 0,!!e)if(e.feePayer&&(this.feePayer=e.feePayer),e.signatures&&(this.signatures=e.signatures),Object.prototype.hasOwnProperty.call(e,"nonceInfo")){const{minContextSlot:n,nonceInfo:r}=e;this.minNonceContextSlot=n,this.nonceInfo=r}else if(Object.prototype.hasOwnProperty.call(e,"lastValidBlockHeight")){const{blockhash:n,lastValidBlockHeight:r}=e;this.recentBlockhash=n,this.lastValidBlockHeight=r}else{const{recentBlockhash:n,nonceInfo:r}=e;r&&(this.nonceInfo=r),this.recentBlockhash=n}}toJSON(){return{recentBlockhash:this.recentBlockhash||null,feePayer:this.feePayer?this.feePayer.toJSON():null,nonceInfo:this.nonceInfo?{nonce:this.nonceInfo.nonce,nonceInstruction:this.nonceInfo.nonceInstruction.toJSON()}:null,instructions:this.instructions.map(e=>e.toJSON()),signers:this.signatures.map(({publicKey:e})=>e.toJSON())}}add(...e){if(e.length===0)throw new Error("No instructions");return e.forEach(n=>{"instructions"in n?this.instructions=this.instructions.concat(n.instructions):"data"in n&&"programId"in n&&"keys"in n?this.instructions.push(n):this.instructions.push(new th(n))}),this}compileMessage(){if(this._message&&JSON.stringify(this.toJSON())===JSON.stringify(this._json))return this._message;let e,n;if(this.nonceInfo?(e=this.nonceInfo.nonce,this.instructions[0]!=this.nonceInfo.nonceInstruction?n=[this.nonceInfo.nonceInstruction,...this.instructions]:n=this.instructions):(e=this.recentBlockhash,n=this.instructions),!e)throw new Error("Transaction recentBlockhash required");n.length<1&&console.warn("No instructions provided");let r;if(this.feePayer)r=this.feePayer;else if(this.signatures.length>0&&this.signatures[0].publicKey)r=this.signatures[0].publicKey;else throw new Error("Transaction fee payer required");for(let C=0;C<n.length;C++)if(n[C].programId===void 0)throw new Error(`Transaction instruction index ${C} has undefined program id`);const s=[],i=[];n.forEach(C=>{C.keys.forEach(K=>{i.push({...K})});const k=C.programId.toString();s.includes(k)||s.push(k)}),s.forEach(C=>{i.push({pubkey:new ye(C),isSigner:!1,isWritable:!1})});const o=[];i.forEach(C=>{const k=C.pubkey.toString(),K=o.findIndex(Y=>Y.pubkey.toString()===k);K>-1?(o[K].isWritable=o[K].isWritable||C.isWritable,o[K].isSigner=o[K].isSigner||C.isSigner):o.push(C)}),o.sort(function(C,k){if(C.isSigner!==k.isSigner)return C.isSigner?-1:1;if(C.isWritable!==k.isWritable)return C.isWritable?-1:1;const K={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return C.pubkey.toBase58().localeCompare(k.pubkey.toBase58(),"en",K)});const a=o.findIndex(C=>C.pubkey.equals(r));if(a>-1){const[C]=o.splice(a,1);C.isSigner=!0,C.isWritable=!0,o.unshift(C)}else o.unshift({pubkey:r,isSigner:!0,isWritable:!0});for(const C of this.signatures){const k=o.findIndex(K=>K.pubkey.equals(C.publicKey));if(k>-1)o[k].isSigner||(o[k].isSigner=!0,console.warn("Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release."));else throw new Error(`unknown signer: ${C.publicKey.toString()}`)}let d=0,m=0,g=0;const x=[],O=[];o.forEach(({pubkey:C,isSigner:k,isWritable:K})=>{k?(x.push(C.toString()),d+=1,K||(m+=1)):(O.push(C.toString()),K||(g+=1))});const N=x.concat(O),F=n.map(C=>{const{data:k,programId:K}=C;return{programIdIndex:N.indexOf(K.toString()),accounts:C.keys.map(Y=>N.indexOf(Y.pubkey.toString())),data:Dt.encode(k)}});return F.forEach(C=>{yt(C.programIdIndex>=0),C.accounts.forEach(k=>yt(k>=0))}),new zr({header:{numRequiredSignatures:d,numReadonlySignedAccounts:m,numReadonlyUnsignedAccounts:g},accountKeys:N,recentBlockhash:e,instructions:F})}_compile(){const e=this.compileMessage(),n=e.accountKeys.slice(0,e.header.numRequiredSignatures);return this.signatures.length===n.length&&this.signatures.every((s,i)=>n[i].equals(s.publicKey))||(this.signatures=n.map(r=>({signature:null,publicKey:r}))),e}serializeMessage(){return this._compile().serialize()}async getEstimatedFee(e){return(await e.getFeeForMessage(this.compileMessage())).value}setSigners(...e){if(e.length===0)throw new Error("No signers");const n=new Set;this.signatures=e.filter(r=>{const s=r.toString();return n.has(s)?!1:(n.add(s),!0)}).map(r=>({signature:null,publicKey:r}))}sign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}this.signatures=r.map(i=>({signature:null,publicKey:i.publicKey}));const s=this._compile();this._partialSign(s,...r)}partialSign(...e){if(e.length===0)throw new Error("No signers");const n=new Set,r=[];for(const i of e){const o=i.publicKey.toString();n.has(o)||(n.add(o),r.push(i))}const s=this._compile();this._partialSign(s,...r)}_partialSign(e,...n){const r=e.serialize();n.forEach(s=>{const i=Jf(r,s.secretKey);this._addSignature(s.publicKey,xc(i))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){yt(n.length===64);const r=this.signatures.findIndex(s=>e.equals(s.publicKey));if(r<0)throw new Error(`unknown signer: ${e.toString()}`);this.signatures[r].signature=xe.Buffer.from(n)}verifySignatures(e=!0){return!this._getMessageSignednessErrors(this.serializeMessage(),e)}_getMessageSignednessErrors(e,n){const r={};for(const{signature:s,publicKey:i}of this.signatures)s===null?n&&(r.missing||=[]).push(i):mA(s,e,i.toBytes())||(r.invalid||=[]).push(i);return r.invalid||r.missing?r:void 0}serialize(e){const{requireAllSignatures:n,verifySignatures:r}=Object.assign({requireAllSignatures:!0,verifySignatures:!0},e),s=this.serializeMessage();if(r){const i=this._getMessageSignednessErrors(s,n);if(i){let o="Signature verification failed.";throw i.invalid&&(o+=`
33
33
  Invalid signature for public key${i.invalid.length===1?"":"(s)"} [\`${i.invalid.map(a=>a.toBase58()).join("`, `")}\`].`),i.missing&&(o+=`
34
- Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:n}=this,r=[];Wt(r,n.length);const s=r.length+n.length*64+e.length,i=xe.Buffer.alloc(s);return yt(n.length<256),xe.Buffer.from(r).copy(i,0),n.forEach(({signature:o},a)=>{o!==null&&(yt(o.length===64,"signature has invalid length"),xe.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+n.length*64),yt(i.length<=Fr,`Transaction too large: ${i.length} > ${Fr}`),i}get keys(){return yt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return yt(this.instructions.length===1),this.instructions[0].programId}get data(){return yt(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=Kt(n);let s=[];for(let i=0;i<r;i++){const o=Zt(n,0,Ji);s.push(Dt.encode(xe.Buffer.from(o)))}return to.populate(zr.from(n),s)}static populate(e,n=[]){const r=new to;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((s,i)=>{const o={signature:s==Dt.encode(AA)?null:Dt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(d=>d.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new eh({keys:i,programId:e.accountKeys[s.programIdIndex],data:Dt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Tc{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)yt(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(Ji));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();Wt(n,this.signatures.length);const r=B.struct([B.blob(n.length,"encodedSignaturesLength"),B.seq(_A(),this.signatures.length,"signatures"),B.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let n=[...e];const r=[],s=Kt(n);for(let o=0;o<s;o++)r.push(new Uint8Array(Zt(n,0,Ji)));const i=Sc.deserialize(new Uint8Array(n));return new Tc(i,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));yt(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Yf(n,s.secretKey)}}addSignature(e,n){yt(n.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));yt(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=n}}new ye("SysvarC1ock11111111111111111111111111111111"),new ye("SysvarEpochSchedu1e111111111111111111111111"),new ye("Sysvar1nstructions1111111111111111111111111"),new ye("SysvarRecentB1ockHashes11111111111111111111"),new ye("SysvarRent111111111111111111111111111111111"),new ye("SysvarRewards111111111111111111111111111111"),new ye("SysvarS1otHashes111111111111111111111111111"),new ye("SysvarS1otHistory11111111111111111111111111"),new ye("SysvarStakeHistory1111111111111111111111111");const xA=B.nu64("lamportsPerSignature");B.struct([B.u32("version"),B.u32("state"),Se("authorizedPubkey"),Se("nonce"),B.struct([xA],"feeCalculator")]).span;function jr(t){const e=B.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),s=e,i=$R();return s.decode=(o,a)=>{const d=n(o,a);return i.decode(d)},s.encode=(o,a,d)=>{const m=i.encode(o);return r(m,a,d)},s}Object.freeze({Create:{index:0,layout:B.struct([B.u32("instruction"),B.ns64("lamports"),B.ns64("space"),Se("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Se("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),jr("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Se("base"),$r("seed"),B.ns64("lamports"),B.ns64("space"),Se("programId")])},AdvanceNonceAccount:{index:4,layout:B.struct([B.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:B.struct([B.u32("instruction"),Se("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Se("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Se("base"),$r("seed"),B.ns64("space"),Se("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Se("base"),$r("seed"),Se("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),jr("lamports"),$r("seed"),Se("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}}),new ye("11111111111111111111111111111111"),new ye("BPFLoader2111111111111111111111111111111111"),B.struct([B.u32("typeIndex"),jr("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Se(),B.offset(B.u8(),-1),"authority")]);const We=Ps(mc(ye),se(),t=>new ye(t)),th=gc([se(),He("base64")]),Oc=Ps(mc(xe.Buffer),th,t=>xe.Buffer.from(t[0],"base64"));function nh(t){return Ft([Q({jsonrpc:He("2.0"),id:se(),result:t}),Q({jsonrpc:He("2.0"),id:se(),error:Q({code:Dr(),message:se(),data:fe(KR())})})])}const SA=nh(Dr());function Ue(t){return Ps(nh(t),SA,e=>"error"in e?e:{...e,result:ks(e.result,t)})}function rn(t){return Ue(Q({context:Q({slot:G()}),value:t}))}function no(t){return Q({context:Q({slot:G()}),value:t})}const TA=Q({foundation:G(),foundationTerm:G(),initial:G(),taper:G(),terminal:G()});Ue(ae(ce(Q({epoch:G(),effectiveSlot:G(),amount:G(),postBalance:G(),commission:fe(ce(G()))}))));const OA=ae(Q({slot:G(),prioritizationFee:G()})),IA=Q({total:G(),validator:G(),foundation:G(),epoch:G()}),NA=Q({epoch:G(),slotIndex:G(),slotsInEpoch:G(),absoluteSlot:G(),blockHeight:fe(G()),transactionCount:fe(G())}),CA=Q({slotsPerEpoch:G(),leaderScheduleSlotOffset:G(),warmup:hn(),firstNormalEpoch:G(),firstNormalSlot:G()}),MA=$f(se(),ae(G())),dr=ce(Ft([Q({}),se()])),BA=Q({err:dr}),kA=He("receivedSignature");Q({"solana-core":se(),"feature-set":fe(G())});const LA=Q({program:se(),programId:We,parsed:Dr()}),PA=Q({programId:We,accounts:ae(We),data:se()});rn(Q({err:ce(Ft([Q({}),se()])),logs:ce(ae(se())),accounts:fe(ce(ae(ce(Q({executable:hn(),owner:se(),lamports:G(),data:ae(se()),rentEpoch:fe(G())}))))),unitsConsumed:fe(G()),returnData:fe(ce(Q({programId:se(),data:gc([se(),He("base64")])}))),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(Ft([LA,PA]))}))))})),rn(Q({byIdentity:$f(se(),ae(G())),range:Q({firstSlot:G(),lastSlot:G()})})),Ue(TA),Ue(IA),Ue(OA),Ue(NA),Ue(CA),Ue(MA),Ue(G()),rn(Q({total:G(),circulating:G(),nonCirculating:G(),nonCirculatingAccounts:ae(We)}));const UA=Q({amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())});rn(ae(Q({address:We,amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())}))),rn(ae(Q({pubkey:We,account:Q({executable:hn(),owner:We,lamports:G(),data:Oc,rentEpoch:G()})})));const Ic=Q({program:se(),parsed:Dr(),space:G()});rn(ae(Q({pubkey:We,account:Q({executable:hn(),owner:We,lamports:G(),data:Ic,rentEpoch:G()})}))),rn(ae(Q({lamports:G(),address:We})));const Nc=Q({executable:hn(),owner:We,lamports:G(),data:Oc,rentEpoch:G()});Q({pubkey:We,account:Nc});const DA=Ps(Ft([mc(xe.Buffer),Ic]),Ft([th,Ic]),t=>Array.isArray(t)?ks(t,Oc):t),FA=Q({executable:hn(),owner:We,lamports:G(),data:DA,rentEpoch:G()});Q({pubkey:We,account:FA}),Q({state:Ft([He("active"),He("inactive"),He("activating"),He("deactivating")]),active:G(),inactive:G()}),Ue(ae(Q({signature:se(),slot:G(),err:dr,memo:ce(se()),blockTime:fe(ce(G()))}))),Ue(ae(Q({signature:se(),slot:G(),err:dr,memo:ce(se()),blockTime:fe(ce(G()))}))),Q({subscription:G(),result:no(Nc)});const $A=Q({pubkey:We,account:Nc});Q({subscription:G(),result:no($A)});const zA=Q({parent:G(),slot:G(),root:G()});Q({subscription:G(),result:zA});const jA=Ft([Q({type:Ft([He("firstShredReceived"),He("completed"),He("optimisticConfirmation"),He("root")]),slot:G(),timestamp:G()}),Q({type:He("createdBank"),parent:G(),slot:G(),timestamp:G()}),Q({type:He("frozen"),slot:G(),timestamp:G(),stats:Q({numTransactionEntries:G(),numSuccessfulTransactions:G(),numFailedTransactions:G(),maxTransactionsPerEntry:G()})}),Q({type:He("dead"),slot:G(),timestamp:G(),err:se()})]);Q({subscription:G(),result:jA}),Q({subscription:G(),result:no(Ft([BA,kA]))}),Q({subscription:G(),result:G()}),Q({pubkey:se(),gossip:ce(se()),tpu:ce(se()),rpc:ce(se()),version:ce(se())});const rh=Q({votePubkey:se(),nodePubkey:se(),activatedStake:G(),epochVoteAccount:hn(),epochCredits:ae(gc([G(),G(),G()])),commission:G(),lastVote:G(),rootSlot:ce(G())});Ue(Q({current:ae(rh),delinquent:ae(rh)}));const VA=Ft([He("processed"),He("confirmed"),He("finalized")]),GA=Q({slot:G(),confirmations:ce(G()),err:dr,confirmationStatus:fe(VA)});rn(ae(ce(GA))),Ue(G());const sh=Q({accountKey:We,writableIndexes:ae(G()),readonlyIndexes:ae(G())}),Cc=Q({signatures:ae(se()),message:Q({accountKeys:ae(se()),header:Q({numRequiredSignatures:G(),numReadonlySignedAccounts:G(),numReadonlyUnsignedAccounts:G()}),instructions:ae(Q({accounts:ae(G()),data:se(),programIdIndex:G()})),recentBlockhash:se(),addressTableLookups:fe(ae(sh))})}),ih=Q({pubkey:We,signer:hn(),writable:hn(),source:fe(Ft([He("transaction"),He("lookupTable")]))}),oh=Q({accountKeys:ae(ih),signatures:ae(se())}),ah=Q({parsed:Dr(),program:se(),programId:We}),ch=Q({accounts:ae(We),data:se(),programId:We}),HA=Ft([ch,ah]),qA=Ft([Q({parsed:Dr(),program:se(),programId:se()}),Q({accounts:ae(se()),data:se(),programId:se()})]),uh=Ps(HA,qA,t=>"accounts"in t?ks(t,ch):ks(t,ah)),dh=Q({signatures:ae(se()),message:Q({accountKeys:ae(ih),instructions:ae(uh),recentBlockhash:se(),addressTableLookups:fe(ce(ae(sh)))})}),ro=Q({accountIndex:G(),mint:se(),owner:fe(se()),programId:fe(se()),uiTokenAmount:UA}),lh=Q({writable:ae(We),readonly:ae(We)}),so=Q({err:dr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(Q({accounts:ae(G()),data:se(),programIdIndex:G()}))})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(ro))),postTokenBalances:fe(ce(ae(ro))),loadedAddresses:fe(lh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Mc=Q({err:dr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(uh)})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(ro))),postTokenBalances:fe(ce(ae(ro))),loadedAddresses:fe(lh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Vr=Ft([He(0),He("legacy")]),lr=Q({pubkey:se(),lamports:G(),postBalance:ce(G()),rewardType:ce(se()),commission:fe(ce(G()))});Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Cc,meta:ce(so),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:oh,meta:ce(so),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:dh,meta:ce(Mc),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:oh,meta:ce(Mc),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Cc,meta:ce(so)})),rewards:fe(ae(lr)),blockTime:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),signatures:ae(se()),blockTime:ce(G())}))),Ue(ce(Q({slot:G(),meta:ce(so),blockTime:fe(ce(G())),transaction:Cc,version:fe(Vr)}))),Ue(ce(Q({slot:G(),transaction:dh,meta:ce(Mc),blockTime:fe(ce(G())),version:fe(Vr)}))),rn(Q({blockhash:se(),lastValidBlockHeight:G()})),rn(hn());const KA=Q({slot:G(),numTransactions:G(),numSlots:G(),samplePeriodSecs:G()});Ue(ae(KA)),rn(ce(Q({feeCalculator:Q({lamportsPerSignature:G()})}))),Ue(se()),Ue(se());const WA=Q({err:dr,logs:ae(se()),signature:se()});Q({result:no(WA),subscription:G()}),Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),jr("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),jr(),B.seq(Se(),B.offset(B.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:B.struct([B.u32("instruction")])},CloseLookupTable:{index:4,layout:B.struct([B.u32("instruction")])}}),new ye("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:B.struct([B.u8("instruction"),B.u32("units"),B.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:B.struct([B.u8("instruction"),B.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:B.struct([B.u8("instruction"),B.u32("units")])},SetComputeUnitPrice:{index:3,layout:B.struct([B.u8("instruction"),jr("microLamports")])}}),new ye("ComputeBudget111111111111111111111111111111"),B.struct([B.u8("numSignatures"),B.u8("padding"),B.u16("signatureOffset"),B.u16("signatureInstructionIndex"),B.u16("publicKeyOffset"),B.u16("publicKeyInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u16("messageInstructionIndex")]),new ye("Ed25519SigVerify111111111111111111111111111"),Fa.utils.isValidPrivateKey,Fa.getPublicKey,B.struct([B.u8("numSignatures"),B.u16("signatureOffset"),B.u8("signatureInstructionIndex"),B.u16("ethAddressOffset"),B.u8("ethAddressInstructionIndex"),B.u16("messageDataOffset"),B.u16("messageDataSize"),B.u8("messageInstructionIndex"),B.blob(20,"ethAddress"),B.blob(64,"signature"),B.u8("recoveryId")]),new ye("KeccakSecp256k11111111111111111111111111111");var fh;new ye("StakeConfig11111111111111111111111111111111");class hh{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}fh=hh,hh.default=new fh(0,0,ye.default),Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),wA(),EA()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:B.struct([B.u32("instruction")])},Split:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Withdraw:{index:4,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},Deactivate:{index:5,layout:B.struct([B.u32("instruction")])},Merge:{index:7,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("stakeAuthorizationType"),$r("authoritySeed"),Se("authorityOwner")])}}),new ye("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),vA()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Se("newAuthorized"),B.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:B.struct([B.u32("instruction"),B.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:B.struct([B.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:B.struct([B.u32("instruction"),RA()])}}),new ye("Vote111111111111111111111111111111111111111"),new ye("Va1idator1nfo111111111111111111111111111111"),Q({name:se(),website:fe(se()),details:fe(se()),iconUrl:fe(se()),keybaseUsername:fe(se())}),new ye("Vote111111111111111111111111111111111111111"),B.struct([Se("nodePubkey"),Se("authorizedWithdrawer"),B.u8("commission"),B.nu64(),B.seq(B.struct([B.nu64("slot"),B.u32("confirmationCount")]),B.offset(B.u32(),-8),"votes"),B.u8("rootSlotValid"),B.nu64("rootSlot"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),Se("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Se("authorizedPubkey"),B.nu64("epochOfLastAuthorizedSwitch"),B.nu64("targetEpoch")]),32,"buf"),B.nu64("idx"),B.u8("isEmpty")],"priorVoters"),B.nu64(),B.seq(B.struct([B.nu64("epoch"),B.nu64("credits"),B.nu64("prevCredits")]),B.offset(B.u32(),-8),"epochCredits"),B.struct([B.nu64("slot"),B.nu64("timestamp")],"lastTimestamp")]);const ZA=t=>({request:t,signMessage:e=>t({method:"signMessage",params:{message:e}}),signTransaction:e=>t({method:"signTransaction",params:{transaction:e}}),signAndSendTransaction:e=>t({method:"signAndSendTransaction",params:e})});function ph(t){return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64")}function YA(t){const e=Buffer.from(t,"base64");return Sc.deserializeMessageVersion(e)==="legacy"?Tc.deserialize(e):to.from(e)}function JA(t){return async n=>{if(n.method==="connect")return await t(n);if(n.method==="signMessage")return await t(n);if(n.method==="signAndSendTransaction"){const{transaction:r}=n.params,s={transaction:ph(r)};return await t({method:"signAndSendTransaction",params:s})}if(n.method==="signTransaction"){const{transaction:r}=n.params,s={transaction:ph(r)},{signedTransaction:i}=await t({method:"signTransaction",params:s});return{signedTransaction:YA(i)}}}}const XA=({miniAppHost:t,emitter:e})=>{let n,r=null;return{visible:!1,get onback(){return r},set onback(s){r&&e.removeListener("backNavigationTriggered",r),r=s,s&&e.addListener("backNavigationTriggered",s)},async show(){await t.updateBackState({visible:!0}),this.visible=!0},async hide(){await t.updateBackState({visible:!1}),this.visible=!1},async enableWebNavigation(){n=QA({back:this,emitter:e})},async disableWebNavigation(){n?.(),n=void 0}}};function QA({emitter:t,back:e}){const n=ex();if(n)return tx({emitter:t,back:e,navigation:n});if(typeof window<"u")return nx({emitter:t,back:e,window})}function ex(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function tx({emitter:t,back:e,navigation:n}){function r(){n.canGoBack?e.show():e.hide()}function s(){e.visible&&n.canGoBack&&n.back()}return n.addEventListener("navigatesuccess",r),t.addListener("backNavigationTriggered",s),()=>{n.removeEventListener("navigatesuccess",r),t.removeListener("backNavigationTriggered",s)}}function nx({emitter:t,back:e,window:n}){e.show();function r(){e.visible&&n.history.back()}return t.addListener("backNavigationTriggered",r),()=>{t.removeListener("backNavigationTriggered",r)}}const rx="0.1.1";function sx(){return rx}let ix=class wu extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof wu){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof wu&&n.cause.docsPath||n.docsPath,o=`https://oxlib.sh${s??""}`,a=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s?["",r?`Details: ${r}`:void 0,s?`See: ${o}`:void 0]:[]].filter(d=>typeof d=="string").join(`
35
- `);super(a,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${sx()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return mh(this,e)}};function mh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?mh(t.cause,e):e?null:t}function gh(t,e={}){const{raw:n=!1}=e,r=t;if(n)return t;if(r.error){const{code:s}=r.error,i=s===Gr.code?Gr:s===Us.code?Us:s===qs.code?qs:s===Gs.code?Gs:s===js.code?js:s===Hs.code?Hs:s===zs.code?zs:s===Ks.code?Ks:s===Ds.code?Ds:s===Fs.code?Fs:s===$s.code?$s:s===Vs.code?Vs:Gt;throw new i(r.error)}return r.result}let Gt=class extends Error{constructor(e){const{code:n,message:r,data:s}=e;super(r),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n,this.data=s}};class Us extends Gt{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:Us.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty(Us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class Ds extends Gt{constructor(e={}){super({message:"Requested resource not found.",...e,code:Ds.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(Ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class Fs extends Gt{constructor(e={}){super({message:"Requested resource not available.",...e,code:Fs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(Fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class $s extends Gt{constructor(e={}){super({message:"Transaction creation failed.",...e,code:$s.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class zs extends Gt{constructor(e={}){super({message:"Method is not implemented.",...e,code:zs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class js extends Gt{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:js.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(js,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Vs extends Gt{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:Vs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Gs extends Gt{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:Gs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(Gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Hs extends Gt{constructor(e={}){super({message:"Method does not exist.",...e,code:Hs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(Hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class qs extends Gt{constructor(e={}){super({message:"Invalid method parameters.",...e,code:qs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(qs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Gr extends Gt{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:Gr.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalErrorError"})}}Object.defineProperty(Gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ks extends Gt{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:Ks.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(Ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class fr extends Error{constructor(e,n){super(n),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=n}}class yh extends fr{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(yh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class bh extends fr{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(bh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class _h extends fr{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(_h,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class wh extends fr{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty(wh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Eh extends fr{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(Eh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function ox(){const t=new Hl;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}function ax(t,e={}){const{includeEvents:n=!0}=e;if(!t)throw new cx;return{...n?{on:t.on?.bind(t),removeListener:t.removeListener?.bind(t)}:{},async request(r){const s=await t.request(r);return s&&typeof s=="object"&&"jsonrpc"in s?gh(s):s}}}class cx extends ix{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}function ux(t={}){let e=t.id??0;return{prepare(n){return dx({id:e++,...n})},get id(){return e}}}function dx(t){return{...t,jsonrpc:"2.0"}}/**
34
+ Missing signature for public key${i.missing.length===1?"":"(s)"} [\`${i.missing.map(a=>a.toBase58()).join("`, `")}\`].`),new Error(o)}}return this._serialize(s)}_serialize(e){const{signatures:n}=this,r=[];Wt(r,n.length);const s=r.length+n.length*64+e.length,i=xe.Buffer.alloc(s);return yt(n.length<256),xe.Buffer.from(r).copy(i,0),n.forEach(({signature:o},a)=>{o!==null&&(yt(o.length===64,"signature has invalid length"),xe.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+n.length*64),yt(i.length<=Fr,`Transaction too large: ${i.length} > ${Fr}`),i}get keys(){return yt(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return yt(this.instructions.length===1),this.instructions[0].programId}get data(){return yt(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=Kt(n);let s=[];for(let i=0;i<r;i++){const o=Zt(n,0,Ji);s.push(Dt.encode(xe.Buffer.from(o)))}return to.populate(zr.from(n),s)}static populate(e,n=[]){const r=new to;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((s,i)=>{const o={signature:s==Dt.encode(AA)?null:Dt.decode(s),publicKey:e.accountKeys[i]};r.signatures.push(o)}),e.instructions.forEach(s=>{const i=s.accounts.map(o=>{const a=e.accountKeys[o];return{pubkey:a,isSigner:r.signatures.some(d=>d.publicKey.toString()===a.toString())||e.isAccountSigner(o),isWritable:e.isAccountWritable(o)}});r.instructions.push(new th({keys:i,programId:e.accountKeys[s.programIdIndex],data:Dt.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Oc{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)yt(n.length===e.header.numRequiredSignatures,"Expected signatures length to be equal to the number of required signatures"),this.signatures=n;else{const r=[];for(let s=0;s<e.header.numRequiredSignatures;s++)r.push(new Uint8Array(Ji));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();Wt(n,this.signatures.length);const r=M.struct([M.blob(n.length,"encodedSignaturesLength"),M.seq(_A(),this.signatures.length,"signatures"),M.blob(e.length,"serializedMessage")]),s=new Uint8Array(2048),i=r.encode({encodedSignaturesLength:new Uint8Array(n),signatures:this.signatures,serializedMessage:e},s);return s.slice(0,i)}static deserialize(e){let n=[...e];const r=[],s=Kt(n);for(let o=0;o<s;o++)r.push(new Uint8Array(Zt(n,0,Ji)));const i=Tc.deserialize(new Uint8Array(n));return new Oc(i,r)}sign(e){const n=this.message.serialize(),r=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures);for(const s of e){const i=r.findIndex(o=>o.equals(s.publicKey));yt(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=Jf(n,s.secretKey)}}addSignature(e,n){yt(n.byteLength===64,"Signature must be 64 bytes long");const s=this.message.staticAccountKeys.slice(0,this.message.header.numRequiredSignatures).findIndex(i=>i.equals(e));yt(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=n}}new ye("SysvarC1ock11111111111111111111111111111111"),new ye("SysvarEpochSchedu1e111111111111111111111111"),new ye("Sysvar1nstructions1111111111111111111111111"),new ye("SysvarRecentB1ockHashes11111111111111111111"),new ye("SysvarRent111111111111111111111111111111111"),new ye("SysvarRewards111111111111111111111111111111"),new ye("SysvarS1otHashes111111111111111111111111111"),new ye("SysvarS1otHistory11111111111111111111111111"),new ye("SysvarStakeHistory1111111111111111111111111");const xA=M.nu64("lamportsPerSignature");M.struct([M.u32("version"),M.u32("state"),Se("authorizedPubkey"),Se("nonce"),M.struct([xA],"feeCalculator")]).span;function jr(t){const e=M.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),s=e,i=$R();return s.decode=(o,a)=>{const d=n(o,a);return i.decode(d)},s.encode=(o,a,d)=>{const m=i.encode(o);return r(m,a,d)},s}Object.freeze({Create:{index:0,layout:M.struct([M.u32("instruction"),M.ns64("lamports"),M.ns64("space"),Se("programId")])},Assign:{index:1,layout:M.struct([M.u32("instruction"),Se("programId")])},Transfer:{index:2,layout:M.struct([M.u32("instruction"),jr("lamports")])},CreateWithSeed:{index:3,layout:M.struct([M.u32("instruction"),Se("base"),$r("seed"),M.ns64("lamports"),M.ns64("space"),Se("programId")])},AdvanceNonceAccount:{index:4,layout:M.struct([M.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:M.struct([M.u32("instruction"),Se("authorized")])},AuthorizeNonceAccount:{index:7,layout:M.struct([M.u32("instruction"),Se("authorized")])},Allocate:{index:8,layout:M.struct([M.u32("instruction"),M.ns64("space")])},AllocateWithSeed:{index:9,layout:M.struct([M.u32("instruction"),Se("base"),$r("seed"),M.ns64("space"),Se("programId")])},AssignWithSeed:{index:10,layout:M.struct([M.u32("instruction"),Se("base"),$r("seed"),Se("programId")])},TransferWithSeed:{index:11,layout:M.struct([M.u32("instruction"),jr("lamports"),$r("seed"),Se("programId")])},UpgradeNonceAccount:{index:12,layout:M.struct([M.u32("instruction")])}}),new ye("11111111111111111111111111111111"),new ye("BPFLoader2111111111111111111111111111111111"),M.struct([M.u32("typeIndex"),jr("deactivationSlot"),M.nu64("lastExtendedSlot"),M.u8("lastExtendedStartIndex"),M.u8(),M.seq(Se(),M.offset(M.u8(),-1),"authority")]);const We=Ps(gc(ye),se(),t=>new ye(t)),nh=yc([se(),He("base64")]),Ic=Ps(gc(xe.Buffer),nh,t=>xe.Buffer.from(t[0],"base64"));function rh(t){return Ft([Q({jsonrpc:He("2.0"),id:se(),result:t}),Q({jsonrpc:He("2.0"),id:se(),error:Q({code:Dr(),message:se(),data:fe(KR())})})])}const SA=rh(Dr());function Ue(t){return Ps(rh(t),SA,e=>"error"in e?e:{...e,result:ks(e.result,t)})}function sn(t){return Ue(Q({context:Q({slot:G()}),value:t}))}function no(t){return Q({context:Q({slot:G()}),value:t})}const TA=Q({foundation:G(),foundationTerm:G(),initial:G(),taper:G(),terminal:G()});Ue(ae(ce(Q({epoch:G(),effectiveSlot:G(),amount:G(),postBalance:G(),commission:fe(ce(G()))}))));const OA=ae(Q({slot:G(),prioritizationFee:G()})),IA=Q({total:G(),validator:G(),foundation:G(),epoch:G()}),NA=Q({epoch:G(),slotIndex:G(),slotsInEpoch:G(),absoluteSlot:G(),blockHeight:fe(G()),transactionCount:fe(G())}),CA=Q({slotsPerEpoch:G(),leaderScheduleSlotOffset:G(),warmup:pn(),firstNormalEpoch:G(),firstNormalSlot:G()}),MA=zf(se(),ae(G())),dr=ce(Ft([Q({}),se()])),BA=Q({err:dr}),kA=He("receivedSignature");Q({"solana-core":se(),"feature-set":fe(G())});const LA=Q({program:se(),programId:We,parsed:Dr()}),PA=Q({programId:We,accounts:ae(We),data:se()});sn(Q({err:ce(Ft([Q({}),se()])),logs:ce(ae(se())),accounts:fe(ce(ae(ce(Q({executable:pn(),owner:se(),lamports:G(),data:ae(se()),rentEpoch:fe(G())}))))),unitsConsumed:fe(G()),returnData:fe(ce(Q({programId:se(),data:yc([se(),He("base64")])}))),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(Ft([LA,PA]))}))))})),sn(Q({byIdentity:zf(se(),ae(G())),range:Q({firstSlot:G(),lastSlot:G()})})),Ue(TA),Ue(IA),Ue(OA),Ue(NA),Ue(CA),Ue(MA),Ue(G()),sn(Q({total:G(),circulating:G(),nonCirculating:G(),nonCirculatingAccounts:ae(We)}));const UA=Q({amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())});sn(ae(Q({address:We,amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())}))),sn(ae(Q({pubkey:We,account:Q({executable:pn(),owner:We,lamports:G(),data:Ic,rentEpoch:G()})})));const Nc=Q({program:se(),parsed:Dr(),space:G()});sn(ae(Q({pubkey:We,account:Q({executable:pn(),owner:We,lamports:G(),data:Nc,rentEpoch:G()})}))),sn(ae(Q({lamports:G(),address:We})));const Cc=Q({executable:pn(),owner:We,lamports:G(),data:Ic,rentEpoch:G()});Q({pubkey:We,account:Cc});const DA=Ps(Ft([gc(xe.Buffer),Nc]),Ft([nh,Nc]),t=>Array.isArray(t)?ks(t,Ic):t),FA=Q({executable:pn(),owner:We,lamports:G(),data:DA,rentEpoch:G()});Q({pubkey:We,account:FA}),Q({state:Ft([He("active"),He("inactive"),He("activating"),He("deactivating")]),active:G(),inactive:G()}),Ue(ae(Q({signature:se(),slot:G(),err:dr,memo:ce(se()),blockTime:fe(ce(G()))}))),Ue(ae(Q({signature:se(),slot:G(),err:dr,memo:ce(se()),blockTime:fe(ce(G()))}))),Q({subscription:G(),result:no(Cc)});const $A=Q({pubkey:We,account:Cc});Q({subscription:G(),result:no($A)});const zA=Q({parent:G(),slot:G(),root:G()});Q({subscription:G(),result:zA});const jA=Ft([Q({type:Ft([He("firstShredReceived"),He("completed"),He("optimisticConfirmation"),He("root")]),slot:G(),timestamp:G()}),Q({type:He("createdBank"),parent:G(),slot:G(),timestamp:G()}),Q({type:He("frozen"),slot:G(),timestamp:G(),stats:Q({numTransactionEntries:G(),numSuccessfulTransactions:G(),numFailedTransactions:G(),maxTransactionsPerEntry:G()})}),Q({type:He("dead"),slot:G(),timestamp:G(),err:se()})]);Q({subscription:G(),result:jA}),Q({subscription:G(),result:no(Ft([BA,kA]))}),Q({subscription:G(),result:G()}),Q({pubkey:se(),gossip:ce(se()),tpu:ce(se()),rpc:ce(se()),version:ce(se())});const sh=Q({votePubkey:se(),nodePubkey:se(),activatedStake:G(),epochVoteAccount:pn(),epochCredits:ae(yc([G(),G(),G()])),commission:G(),lastVote:G(),rootSlot:ce(G())});Ue(Q({current:ae(sh),delinquent:ae(sh)}));const VA=Ft([He("processed"),He("confirmed"),He("finalized")]),GA=Q({slot:G(),confirmations:ce(G()),err:dr,confirmationStatus:fe(VA)});sn(ae(ce(GA))),Ue(G());const ih=Q({accountKey:We,writableIndexes:ae(G()),readonlyIndexes:ae(G())}),Mc=Q({signatures:ae(se()),message:Q({accountKeys:ae(se()),header:Q({numRequiredSignatures:G(),numReadonlySignedAccounts:G(),numReadonlyUnsignedAccounts:G()}),instructions:ae(Q({accounts:ae(G()),data:se(),programIdIndex:G()})),recentBlockhash:se(),addressTableLookups:fe(ae(ih))})}),oh=Q({pubkey:We,signer:pn(),writable:pn(),source:fe(Ft([He("transaction"),He("lookupTable")]))}),ah=Q({accountKeys:ae(oh),signatures:ae(se())}),ch=Q({parsed:Dr(),program:se(),programId:We}),uh=Q({accounts:ae(We),data:se(),programId:We}),HA=Ft([uh,ch]),qA=Ft([Q({parsed:Dr(),program:se(),programId:se()}),Q({accounts:ae(se()),data:se(),programId:se()})]),dh=Ps(HA,qA,t=>"accounts"in t?ks(t,uh):ks(t,ch)),lh=Q({signatures:ae(se()),message:Q({accountKeys:ae(oh),instructions:ae(dh),recentBlockhash:se(),addressTableLookups:fe(ce(ae(ih)))})}),ro=Q({accountIndex:G(),mint:se(),owner:fe(se()),programId:fe(se()),uiTokenAmount:UA}),fh=Q({writable:ae(We),readonly:ae(We)}),so=Q({err:dr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(Q({accounts:ae(G()),data:se(),programIdIndex:G()}))})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(ro))),postTokenBalances:fe(ce(ae(ro))),loadedAddresses:fe(fh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Bc=Q({err:dr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(dh)})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(ro))),postTokenBalances:fe(ce(ae(ro))),loadedAddresses:fe(fh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Vr=Ft([He(0),He("legacy")]),lr=Q({pubkey:se(),lamports:G(),postBalance:ce(G()),rewardType:ce(se()),commission:fe(ce(G()))});Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Mc,meta:ce(so),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:ah,meta:ce(so),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:lh,meta:ce(Bc),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:ah,meta:ce(Bc),version:fe(Vr)})),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(lr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Mc,meta:ce(so)})),rewards:fe(ae(lr)),blockTime:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),signatures:ae(se()),blockTime:ce(G())}))),Ue(ce(Q({slot:G(),meta:ce(so),blockTime:fe(ce(G())),transaction:Mc,version:fe(Vr)}))),Ue(ce(Q({slot:G(),transaction:lh,meta:ce(Bc),blockTime:fe(ce(G())),version:fe(Vr)}))),sn(Q({blockhash:se(),lastValidBlockHeight:G()})),sn(pn());const KA=Q({slot:G(),numTransactions:G(),numSlots:G(),samplePeriodSecs:G()});Ue(ae(KA)),sn(ce(Q({feeCalculator:Q({lamportsPerSignature:G()})}))),Ue(se()),Ue(se());const WA=Q({err:dr,logs:ae(se()),signature:se()});Q({result:no(WA),subscription:G()}),Object.freeze({CreateLookupTable:{index:0,layout:M.struct([M.u32("instruction"),jr("recentSlot"),M.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:M.struct([M.u32("instruction")])},ExtendLookupTable:{index:2,layout:M.struct([M.u32("instruction"),jr(),M.seq(Se(),M.offset(M.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:M.struct([M.u32("instruction")])},CloseLookupTable:{index:4,layout:M.struct([M.u32("instruction")])}}),new ye("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:M.struct([M.u8("instruction"),M.u32("units"),M.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:M.struct([M.u8("instruction"),M.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:M.struct([M.u8("instruction"),M.u32("units")])},SetComputeUnitPrice:{index:3,layout:M.struct([M.u8("instruction"),jr("microLamports")])}}),new ye("ComputeBudget111111111111111111111111111111"),M.struct([M.u8("numSignatures"),M.u8("padding"),M.u16("signatureOffset"),M.u16("signatureInstructionIndex"),M.u16("publicKeyOffset"),M.u16("publicKeyInstructionIndex"),M.u16("messageDataOffset"),M.u16("messageDataSize"),M.u16("messageInstructionIndex")]),new ye("Ed25519SigVerify111111111111111111111111111"),$a.utils.isValidPrivateKey,$a.getPublicKey,M.struct([M.u8("numSignatures"),M.u16("signatureOffset"),M.u8("signatureInstructionIndex"),M.u16("ethAddressOffset"),M.u8("ethAddressInstructionIndex"),M.u16("messageDataOffset"),M.u16("messageDataSize"),M.u8("messageInstructionIndex"),M.blob(20,"ethAddress"),M.blob(64,"signature"),M.u8("recoveryId")]),new ye("KeccakSecp256k11111111111111111111111111111");var hh;new ye("StakeConfig11111111111111111111111111111111");class ph{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}hh=ph,ph.default=new hh(0,0,ye.default),Object.freeze({Initialize:{index:0,layout:M.struct([M.u32("instruction"),wA(),EA()])},Authorize:{index:1,layout:M.struct([M.u32("instruction"),Se("newAuthorized"),M.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:M.struct([M.u32("instruction")])},Split:{index:3,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},Withdraw:{index:4,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},Deactivate:{index:5,layout:M.struct([M.u32("instruction")])},Merge:{index:7,layout:M.struct([M.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:M.struct([M.u32("instruction"),Se("newAuthorized"),M.u32("stakeAuthorizationType"),$r("authoritySeed"),Se("authorityOwner")])}}),new ye("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:M.struct([M.u32("instruction"),vA()])},Authorize:{index:1,layout:M.struct([M.u32("instruction"),Se("newAuthorized"),M.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:M.struct([M.u32("instruction"),M.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:M.struct([M.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:M.struct([M.u32("instruction"),RA()])}}),new ye("Vote111111111111111111111111111111111111111"),new ye("Va1idator1nfo111111111111111111111111111111"),Q({name:se(),website:fe(se()),details:fe(se()),iconUrl:fe(se()),keybaseUsername:fe(se())}),new ye("Vote111111111111111111111111111111111111111"),M.struct([Se("nodePubkey"),Se("authorizedWithdrawer"),M.u8("commission"),M.nu64(),M.seq(M.struct([M.nu64("slot"),M.u32("confirmationCount")]),M.offset(M.u32(),-8),"votes"),M.u8("rootSlotValid"),M.nu64("rootSlot"),M.nu64(),M.seq(M.struct([M.nu64("epoch"),Se("authorizedVoter")]),M.offset(M.u32(),-8),"authorizedVoters"),M.struct([M.seq(M.struct([Se("authorizedPubkey"),M.nu64("epochOfLastAuthorizedSwitch"),M.nu64("targetEpoch")]),32,"buf"),M.nu64("idx"),M.u8("isEmpty")],"priorVoters"),M.nu64(),M.seq(M.struct([M.nu64("epoch"),M.nu64("credits"),M.nu64("prevCredits")]),M.offset(M.u32(),-8),"epochCredits"),M.struct([M.nu64("slot"),M.nu64("timestamp")],"lastTimestamp")]);const ZA=t=>({request:t,signMessage:e=>t({method:"signMessage",params:{message:e}}),signTransaction:e=>t({method:"signTransaction",params:{transaction:e}}),signAndSendTransaction:e=>t({method:"signAndSendTransaction",params:e})});function mh(t){return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64")}function YA(t){const e=Buffer.from(t,"base64");return Tc.deserializeMessageVersion(e)==="legacy"?Oc.deserialize(e):to.from(e)}function JA(t){return async n=>{if(n.method==="connect")return await t(n);if(n.method==="signMessage")return await t(n);if(n.method==="signAndSendTransaction"){const{transaction:r}=n.params,s={transaction:mh(r)};return await t({method:"signAndSendTransaction",params:s})}if(n.method==="signTransaction"){const{transaction:r}=n.params,s={transaction:mh(r)},{signedTransaction:i}=await t({method:"signTransaction",params:s});return{signedTransaction:YA(i)}}}}const XA=({miniAppHost:t,emitter:e})=>{let n,r=null;return{visible:!1,get onback(){return r},set onback(s){r&&e.removeListener("backNavigationTriggered",r),r=s,s&&e.addListener("backNavigationTriggered",s)},async show(){await t.updateBackState({visible:!0}),this.visible=!0},async hide(){await t.updateBackState({visible:!1}),this.visible=!1},async enableWebNavigation(){n=QA({back:this,emitter:e})},async disableWebNavigation(){n?.(),n=void 0}}};function QA({emitter:t,back:e}){const n=ex();if(n)return tx({emitter:t,back:e,navigation:n});if(typeof window<"u")return nx({emitter:t,back:e,window})}function ex(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function tx({emitter:t,back:e,navigation:n}){function r(){n.canGoBack?e.show():e.hide()}function s(){e.visible&&n.canGoBack&&n.back()}return n.addEventListener("navigatesuccess",r),t.addListener("backNavigationTriggered",s),()=>{n.removeEventListener("navigatesuccess",r),t.removeListener("backNavigationTriggered",s)}}function nx({emitter:t,back:e,window:n}){e.show();function r(){e.visible&&n.history.back()}return t.addListener("backNavigationTriggered",r),()=>{t.removeListener("backNavigationTriggered",r)}}const rx="0.1.1";function sx(){return rx}let ix=class Eu extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof Eu){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause?.message?n.cause.message:n.details})(),s=n.cause instanceof Eu&&n.cause.docsPath||n.docsPath,o=`https://oxlib.sh${s??""}`,a=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||s?["",r?`Details: ${r}`:void 0,s?`See: ${o}`:void 0]:[]].filter(d=>typeof d=="string").join(`
35
+ `);super(a,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${sx()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return gh(this,e)}};function gh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?gh(t.cause,e):e?null:t}function yh(t,e={}){const{raw:n=!1}=e,r=t;if(n)return t;if(r.error){const{code:s}=r.error,i=s===Gr.code?Gr:s===Us.code?Us:s===qs.code?qs:s===Gs.code?Gs:s===js.code?js:s===Hs.code?Hs:s===zs.code?zs:s===Ks.code?Ks:s===Ds.code?Ds:s===Fs.code?Fs:s===$s.code?$s:s===Vs.code?Vs:Gt;throw new i(r.error)}return r.result}let Gt=class extends Error{constructor(e){const{code:n,message:r,data:s}=e;super(r),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.BaseError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=n,this.data=s}};class Us extends Gt{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:Us.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidInputError"})}}Object.defineProperty(Us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class Ds extends Gt{constructor(e={}){super({message:"Requested resource not found.",...e,code:Ds.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceNotFoundError"})}}Object.defineProperty(Ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class Fs extends Gt{constructor(e={}){super({message:"Requested resource not available.",...e,code:Fs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ResourceUnavailableError"})}}Object.defineProperty(Fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class $s extends Gt{constructor(e={}){super({message:"Transaction creation failed.",...e,code:$s.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.TransactionRejectedError"})}}Object.defineProperty($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class zs extends Gt{constructor(e={}){super({message:"Method is not implemented.",...e,code:zs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotSupportedError"})}}Object.defineProperty(zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class js extends Gt{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:js.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.LimitExceededError"})}}Object.defineProperty(js,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Vs extends Gt{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:Vs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.VersionNotSupportedError"})}}Object.defineProperty(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Gs extends Gt{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:Gs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidRequestError"})}}Object.defineProperty(Gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Hs extends Gt{constructor(e={}){super({message:"Method does not exist.",...e,code:Hs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.MethodNotFoundError"})}}Object.defineProperty(Hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class qs extends Gt{constructor(e={}){super({message:"Invalid method parameters.",...e,code:qs.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InvalidParamsError"})}}Object.defineProperty(qs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Gr extends Gt{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:Gr.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.InternalErrorError"})}}Object.defineProperty(Gr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ks extends Gt{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:Ks.code}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RpcResponse.ParseError"})}}Object.defineProperty(Ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class fr extends Error{constructor(e,n){super(n),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderRpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e,this.details=n}}class bh extends fr{constructor({message:e="The user rejected the request."}={}){super(4001,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UserRejectedRequestError"})}}Object.defineProperty(bh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class _h extends fr{constructor({message:e="The requested method and/or account has not been authorized by the user."}={}){super(4100,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnauthorizedError"})}}Object.defineProperty(_h,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class wh extends fr{constructor({message:e="The provider does not support the requested method."}={}){super(4200,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.UnsupportedMethodError"})}}Object.defineProperty(wh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Eh extends fr{constructor({message:e="The provider is disconnected from all chains."}={}){super(4900,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.DisconnectedError"})}}Object.defineProperty(Eh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class vh extends fr{constructor({message:e="The provider is not connected to the requested chain."}={}){super(4901,e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.ChainDisconnectedError"})}}Object.defineProperty(vh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function ox(){const t=new ql;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}function ax(t,e={}){const{includeEvents:n=!0}=e;if(!t)throw new cx;return{...n?{on:t.on?.bind(t),removeListener:t.removeListener?.bind(t)}:{},async request(r){const s=await t.request(r);return s&&typeof s=="object"&&"jsonrpc"in s?yh(s):s}}}class cx extends ix{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}function ux(t={}){let e=t.id??0;return{prepare(n){return dx({id:e++,...n})},get id(){return e}}}function dx(t){return{...t,jsonrpc:"2.0"}}/**
36
36
  * @license
37
37
  * Copyright 2019 Google LLC
38
38
  * SPDX-License-Identifier: Apache-2.0
39
- */const vh=Symbol("Comlink.proxy"),lx=Symbol("Comlink.endpoint"),fx=Symbol("Comlink.releaseProxy"),Bc=Symbol("Comlink.finalizer"),io=Symbol("Comlink.thrown"),Rh=t=>typeof t=="object"&&t!==null||typeof t=="function",hx={canHandle:t=>Rh(t)&&t[vh],serialize(t){const{port1:e,port2:n}=new MessageChannel;return xh(t,e),[n,[n]]},deserialize(t){return t.start(),Th(t)}},px={canHandle:t=>Rh(t)&&io in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},Ah=new Map([["proxy",hx],["throw",px]]);function mx(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function xh(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!mx(n,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:i,type:o,path:a}=Object.assign({path:[]},s.data),d=(s.data.argumentList||[]).map(hr);let m;try{const g=a.slice(0,-1).reduce((O,N)=>O[N],t),x=a.reduce((O,N)=>O[N],t);switch(o){case"GET":m=x;break;case"SET":g[a.slice(-1)[0]]=hr(s.data.value),m=!0;break;case"APPLY":m=x.apply(g,d);break;case"CONSTRUCT":{const O=new x(...d);m=Ex(O)}break;case"ENDPOINT":{const{port1:O,port2:N}=new MessageChannel;xh(t,N),m=wx(O,[O])}break;case"RELEASE":m=void 0;break;default:return}}catch(g){m={value:g,[io]:0}}Promise.resolve(m).catch(g=>({value:g,[io]:0})).then(g=>{const[x,O]=uo(g);e.postMessage(Object.assign(Object.assign({},x),{id:i}),O),o==="RELEASE"&&(e.removeEventListener("message",r),Sh(e),Bc in t&&typeof t[Bc]=="function"&&t[Bc]())}).catch(g=>{const[x,O]=uo({value:new TypeError("Unserializable return value"),[io]:0});e.postMessage(Object.assign(Object.assign({},x),{id:i}),O)})}),e.start&&e.start()}function gx(t){return t.constructor.name==="MessagePort"}function Sh(t){gx(t)&&t.close()}function Th(t,e){const n=new Map;return t.addEventListener("message",function(s){const{data:i}=s;if(!i||!i.id)return;const o=n.get(i.id);if(o)try{o(i)}finally{n.delete(i.id)}}),kc(t,n,[],e)}function oo(t){if(t)throw new Error("Proxy has been released and is not useable")}function Oh(t){return Hr(t,new Map,{type:"RELEASE"}).then(()=>{Sh(t)})}const ao=new WeakMap,co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(ao.get(t)||0)-1;ao.set(t,e),e===0&&Oh(t)});function yx(t,e){const n=(ao.get(e)||0)+1;ao.set(e,n),co&&co.register(t,e,t)}function bx(t){co&&co.unregister(t)}function kc(t,e,n=[],r=function(){}){let s=!1;const i=new Proxy(r,{get(o,a){if(oo(s),a===fx)return()=>{bx(i),Oh(t),e.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>i};const d=Hr(t,e,{type:"GET",path:n.map(m=>m.toString())}).then(hr);return d.then.bind(d)}return kc(t,e,[...n,a])},set(o,a,d){oo(s);const[m,g]=uo(d);return Hr(t,e,{type:"SET",path:[...n,a].map(x=>x.toString()),value:m},g).then(hr)},apply(o,a,d){oo(s);const m=n[n.length-1];if(m===lx)return Hr(t,e,{type:"ENDPOINT"}).then(hr);if(m==="bind")return kc(t,e,n.slice(0,-1));const[g,x]=Ih(d);return Hr(t,e,{type:"APPLY",path:n.map(O=>O.toString()),argumentList:g},x).then(hr)},construct(o,a){oo(s);const[d,m]=Ih(a);return Hr(t,e,{type:"CONSTRUCT",path:n.map(g=>g.toString()),argumentList:d},m).then(hr)}});return yx(i,t),i}function _x(t){return Array.prototype.concat.apply([],t)}function Ih(t){const e=t.map(uo);return[e.map(n=>n[0]),_x(e.map(n=>n[1]))]}const Nh=new WeakMap;function wx(t,e){return Nh.set(t,e),t}function Ex(t){return Object.assign(t,{[vh]:!0})}function vx(t,e=globalThis,n="*"){return{postMessage:(r,s)=>t.postMessage(r,n,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function uo(t){for(const[e,n]of Ah)if(n.canHandle(t)){const[r,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:t},Nh.get(t)||[]]}function hr(t){switch(t.type){case"HANDLER":return Ah.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Hr(t,e,n,r){return new Promise(s=>{const i=Rx();e.set(i,s),t.start&&t.start(),t.postMessage(Object.assign({id:i},n),r)})}function Rx(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const Ax={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},xx={postMessage:t=>{window.ReactNativeWebView.postMessage(JSON.stringify(t))},addEventListener:(t,e,...n)=>{document.addEventListener("FarcasterFrameCallback",e,...n)},removeEventListener:(t,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},Sx=typeof window>"u"?Ax:window?.ReactNativeWebView?xx:vx(window?.parent??window),be=Th(Sx),Lc=ox(),Tx=ux();function Ox({code:t,details:e}){switch(t){case 4001:return new yh;case 4100:return new bh;case 4200:return new _h;case 4900:return new wh;case 4901:return new Eh;default:return new fr(t,e??"Unknown provider RPC error")}}const Ws=ax({...Lc,async request(t){const e=Tx.prepare(t);try{const n=await be.ethProviderRequestV2(e).then(r=>gh(r,{request:e,raw:!0}));if(n.error)throw Ox(n.error);return n.result}catch(n){if(n instanceof Error&&n.message.match(/cannot read property 'apply'/i))return await be.ethProviderRequest(e);throw n instanceof fr||n instanceof Gt?n:new Gr({message:n instanceof Error?n.message:void 0})}}});async function Ix(){try{const t=await be.getCapabilities();return!t.includes("wallet.getEthereumProvider")&&!t.includes("wallet.getEvmProvider")?void 0:Ws}catch{return Ws}}function Ch(t){const e=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(t)});window.dispatchEvent(e);const n=()=>window.dispatchEvent(e);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}typeof document<"u"&&(document.addEventListener("eip6963:requestProvider",()=>{be.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",t=>{if(t instanceof MessageEvent){const e=t.data;Lc.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="eip6963:announceProvider"&&Ch({info:e.info,provider:Ws})}})),typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{be.eip6963RequestProvider()}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEthProviderEvent"){const e=t.data;Lc.emit(e.event,...e.params)}}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="eip6963:announceProvider"&&Ch({info:e.info,provider:Ws})}})),new TextEncoder;const Mh=new TextDecoder,Nx=t=>{const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},Cx=t=>{let e=t;e instanceof Uint8Array&&(e=Mh.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Nx(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};function Mx(t){return typeof t=="object"&&t!==null}function Bx(t){if(!Mx(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}class $t extends Error{constructor(e,n){super(e,n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}$t.code="ERR_JOSE_GENERIC";class kx extends $t{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=s,this.payload=n}}kx.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Lx extends $t{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=s,this.payload=n}}Lx.code="ERR_JWT_EXPIRED";class Px extends $t{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Px.code="ERR_JOSE_ALG_NOT_ALLOWED";class Ux extends $t{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}Ux.code="ERR_JOSE_NOT_SUPPORTED";class Dx extends $t{constructor(e="decryption operation failed",n){super(e,n),this.code="ERR_JWE_DECRYPTION_FAILED"}}Dx.code="ERR_JWE_DECRYPTION_FAILED";class Fx extends $t{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Fx.code="ERR_JWE_INVALID";class $x extends $t{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}$x.code="ERR_JWS_INVALID";class Hn extends $t{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}Hn.code="ERR_JWT_INVALID";class zx extends $t{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}zx.code="ERR_JWK_INVALID";class jx extends $t{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}jx.code="ERR_JWKS_INVALID";class Vx extends $t{constructor(e="no applicable key found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Vx.code="ERR_JWKS_NO_MATCHING_KEY";class Gx extends $t{constructor(e="multiple matching keys found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Gx.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class Hx extends $t{constructor(e="request timed out",n){super(e,n),this.code="ERR_JWKS_TIMEOUT"}}Hx.code="ERR_JWKS_TIMEOUT";class qx extends $t{constructor(e="signature verification failed",n){super(e,n),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}qx.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Kx(t){if(typeof t!="string")throw new Hn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new Hn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new Hn("Invalid JWT");if(!e)throw new Hn("JWTs must contain a payload");let r;try{r=Cx(e)}catch{throw new Hn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(Mh.decode(r))}catch{throw new Hn("Failed to parse the decoded payload as JSON")}if(!Bx(s))throw new Hn("Invalid JWT Claims Set");return s}function Wx(t){return Kx(t)}class lo extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof lo){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r?["",r?`Details: ${r}`:void 0]:[]].filter(i=>typeof i=="string").join(`
40
- `);super(s,n.cause?{cause:n.cause}:void 0),this.name="BaseError",this.cause=n.cause,this.details=r,this.shortMessage=e}}class Bh extends lo{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}}class Zx extends lo{constructor(e){super(e),this.name="InvalidToken"}}async function Yx({origin:t}){const e=await fetch(`${t}/nonce`,{method:"POST"});if(!e.ok)throw new Bh({status:e.status});return await e.json()}async function Jx({origin:t},e){const n=await fetch(`${t}/verify-siwf`,{method:"POST",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(e)});if(!n.ok)throw new Bh({status:n.status});const r=await n.json();if(r.valid===!1)throw new Zx(r.message??"unknown");return{token:r.token}}function Xx(t={}){return{origin:t.origin??"https://auth.farcaster.xyz"}}function Qx(t={}){const e=Xx(t);return{generateNonce:()=>Yx(e),verifySiwf:n=>Jx(e,n)}}const eS=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,tS=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function nS(t){const{scheme:e,statement:n,...r}=t.match(eS)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:d,...m}=t.match(tS)?.groups??{},g=t.split("Resources:")[1]?.split(`
41
- - `).slice(1);return{...r,...m,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...o?{issuedAt:new Date(o)}:{},...a?{notBefore:new Date(a)}:{},...d?{requestId:d}:{},...g?{resources:g}:{},...e?{scheme:e}:{},...n?{statement:n}:{}}}const kh=(()=>{let t,e;async function n(r){const s=Qx({origin:r.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await be.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){const a=nS(o.result.message);if(!a.domain)throw new Error("Missing domain on SIWE message");const d=await s.verifySiwf({domain:a.domain,message:o.result.message,signature:o.result.signature});return t={token:d.token,payload:Wx(d.token)},d}throw o.error.type==="rejected_by_user"?new ql:new Error("Unreachable")}return{get token(){if(t&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3))return t.token},async getToken(r={}){const s=r.force??!1;return t&&!s&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3)?{token:t.token}:(e||(e=n(r)),e.finally(()=>{e=void 0}),e)},async fetch(r,s){const{token:i}=await this.getToken(),o=new Headers(s?.headers);return o.set("Authorization",`Bearer ${i}`),fetch(r,{...s,headers:o})}}})();function rS(){const t=new Hl;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}const Mt=rS(),{solanaProviderRequest:Lh}=be;let Ph;Lh&&(Ph=ZA(JA(Lh)));async function Uh(){let t;try{t=await be.getCapabilities()}catch{}if(t?.includes("wallet.getSolanaProvider"))return Ph}let Dh=null;async function sS(t=1e3){if(Dh===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;const e=await Promise.race([be.context.then(n=>!!n),new Promise(n=>{setTimeout(()=>n(!1),t)})]).catch(()=>!1);return e&&(Dh=!0),e}const Fh=async()=>{const t=await be.addFrame();if(t.result)return t.result;throw t.error.type==="invalid_domain_manifest"?new U1:t.error.type==="rejected_by_user"?new D1:new Error("Unreachable")},$h={...Mt,getCapabilities:be.getCapabilities,getChains:be.getChains,isInMiniApp:sS,context:be.context,back:XA({miniAppHost:be,emitter:Mt}),quickAuth:kh,actions:{setPrimaryButton:be.setPrimaryButton.bind(be),ready:async(t={})=>await be.ready(t),close:be.close.bind(be),viewCast:be.viewCast.bind(be),viewProfile:be.viewProfile.bind(be),openMiniApp:be.openMiniApp.bind(be),signIn:async t=>{const e=await be.signIn({...t,acceptAuthAddress:t.acceptAuthAddress??!0});if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new ql:new Error("Unreachable")},openUrl:t=>{const e=typeof t=="string"?t:t.url;return be.openUrl(e.trim())},addFrame:Fh,addMiniApp:Fh,composeCast(t={}){return be.composeCast(t)},viewToken:be.viewToken.bind(be),sendToken:be.sendToken.bind(be),swapToken:be.swapToken.bind(be),requestCameraAndMicrophoneAccess:be.requestCameraAndMicrophoneAccess.bind(be)},experimental:{getSolanaProvider:Uh,signManifest:async t=>{const e=await be.signManifest(t);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new F1:e.error.type==="invalid_domain"?new $1:e.error.type==="generic_error"?new z1(e.error.message):new Error("Unreachable")},quickAuth(t){return kh.getToken(t)}},wallet:{ethProvider:Ws,getEthereumProvider:Ix,getSolanaProvider:Uh},haptics:{impactOccurred:be.impactOccurred.bind(be),notificationOccurred:be.notificationOccurred.bind(be),selectionChanged:be.selectionChanged.bind(be)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="primary_button_clicked"?Mt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Mt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Mt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Mt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Mt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Mt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Mt.emit("backNavigationTriggered")}}),typeof window<"u"&&window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="primary_button_clicked"?Mt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Mt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Mt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Mt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Mt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Mt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Mt.emit("backNavigationTriggered")}}),fo.type="farcasterMiniApp";let qr,Kr,Wr;function fo(){return t=>({id:"farcaster",name:"Farcaster",rdns:"xyz.farcaster.MiniAppWallet",icon:"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/055c25d6-7fe7-4a49-abf9-49772021cf00/original",type:fo.type,async connect({chainId:e}={}){const n=await this.getProvider(),r=await n.request({method:"eth_requestAccounts"});let s=e;if(!s){const o=await t.storage?.getItem("state")??{};t.chains.some(d=>d.id===o.chainId)?s=o.chainId:s=t.chains[0]?.id}if(!s)throw new Error("No chains found on connector.");qr||(qr=this.onAccountsChanged.bind(this),n.on("accountsChanged",qr)),Kr||(Kr=this.onChainChanged.bind(this),n.on("chainChanged",Kr)),Wr||(Wr=this.onDisconnect.bind(this),n.on("disconnect",Wr));let i=await this.getChainId();return s&&i!==s&&(i=(await this.switchChain({chainId:s})).id),{accounts:r.map(o=>ui(o)),chainId:i}},async disconnect(){const e=await this.getProvider();qr&&(e.removeListener("accountsChanged",qr),qr=void 0),Kr&&(e.removeListener("chainChanged",Kr),Kr=void 0),Wr&&(e.removeListener("disconnect",Wr),Wr=void 0)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(r=>ui(r))},async getChainId(){const n=await(await this.getProvider()).request({method:"eth_chainId"});return hm(n,"number")},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({chainId:e}){const n=await this.getProvider(),r=t.chains.find(s=>s.id===e);if(!r)throw new Sr(new zl);return await n.request({method:"wallet_switchEthereumChain",params:[{chainId:ke(e)}]}),t.emitter.emit("change",{chainId:e}),r},onAccountsChanged(e){e.length===0?this.onDisconnect():t.emitter.emit("change",{accounts:e.map(n=>ui(n))})},onChainChanged(e){const n=Number(e);t.emitter.emit("change",{chainId:n})},async onDisconnect(){t.emitter.emit("disconnect")},async getProvider(){return $h.wallet.ethProvider}})}const iS=fo;iS.type="farcasterFrame";const sn={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function Pc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function zh(t){return Pc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const jh="2.43.4";let Uc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${jh}`};class qn extends Error{constructor(e,n={}){const r=n.cause instanceof qn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof qn&&n.cause.docsPath||n.docsPath,i=Uc.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Uc.version?[`Version: ${Uc.version}`]:[]].join(`
42
- `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=jh}walk(e){return Vh(this,e)}}function Vh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Vh(t.cause,e):e?null:t}class Gh extends qn{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function ho(t,{dir:e,size:n=32}={}){return typeof t=="string"?oS(t,{dir:e,size:n}):aS(t,{dir:e,size:n})}function oS(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Gh({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function aS(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Gh({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class cS extends qn{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class uS extends qn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Dc(t,{size:e}){if(zh(t)>e)throw new uS({givenSize:zh(t),maxSize:e})}function dS(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new cS({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ho(a,{size:r}):a}const lS=new TextEncoder;function fS(t,e={}){return typeof t=="number"||typeof t=="bigint"?pS(t,e):typeof t=="boolean"?hS(t,e):Pc(t)?qh(t,e):Kh(t,e)}function hS(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Dc(n,{size:e.size}),ho(n,{size:e.size})):n}const In={zero:48,nine:57,A:65,F:70,a:97,f:102};function Hh(t){if(t>=In.zero&&t<=In.nine)return t-In.zero;if(t>=In.A&&t<=In.F)return t-(In.A-10);if(t>=In.a&&t<=In.f)return t-(In.a-10)}function qh(t,e={}){let n=t;e.size&&(Dc(n,{size:e.size}),n=ho(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=Hh(r.charCodeAt(a++)),m=Hh(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new qn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function pS(t,e){const n=dS(t,e);return qh(n)}function Kh(t,e={}){const n=lS.encode(t);return typeof e.size=="number"?(Dc(n,{size:e.size}),ho(n,{dir:"right",size:e.size})):n}const po=BigInt(2**32-1),Wh=BigInt(32);function mS(t,e=!1){return e?{h:Number(t&po),l:Number(t>>Wh&po)}:{h:Number(t>>Wh&po)|0,l:Number(t&po)|0}}function gS(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=mS(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const yS=(t,e,n)=>t<<n|e>>>32-n,bS=(t,e,n)=>e<<n|t>>>32-n,_S=(t,e,n)=>e<<n-32|t>>>64-n,wS=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ES(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Zh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function mo(t,...e){if(!ES(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Yh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function vS(t,e){mo(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function RS(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Jh(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const AS=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xS(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function SS(t){for(let e=0;e<t.length;e++)t[e]=xS(t[e]);return t}const Xh=AS?t=>t:SS;function TS(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Qh(t){return typeof t=="string"&&(t=TS(t)),mo(t),t}class OS{}function IS(t){const e=r=>t().update(Qh(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const NS=BigInt(0),Zs=BigInt(1),CS=BigInt(2),MS=BigInt(7),BS=BigInt(256),kS=BigInt(113),e0=[],t0=[],n0=[];for(let t=0,e=Zs,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],e0.push(2*(5*r+n)),t0.push((t+1)*(t+2)/2%64);let s=NS;for(let i=0;i<7;i++)e=(e<<Zs^(e>>MS)*kS)%BS,e&CS&&(s^=Zs<<(Zs<<BigInt(i))-Zs);n0.push(s)}const r0=gS(n0,!0),LS=r0[0],PS=r0[1],s0=(t,e,n)=>n>32?_S(t,e,n):yS(t,e,n),i0=(t,e,n)=>n>32?wS(t,e,n):bS(t,e,n);function US(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=s0(m,g,1)^n[a],O=i0(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=t0[o],d=s0(s,i,a),m=i0(s,i,a),g=e0[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=LS[r],t[1]^=PS[r]}Jh(n)}class Fc extends OS{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,Zh(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=RS(this.state)}clone(){return this._cloneInto()}keccak(){Xh(this.state32),US(this.state32,this.rounds),Xh(this.state32),this.posOut=0,this.pos=0}update(e){Yh(this),e=Qh(e),mo(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Yh(this,!1),mo(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Zh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vS(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Jh(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Fc(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const DS=(t,e,n)=>IS(()=>new Fc(e,t,n)),FS=DS(1,136,256/8);function $S(t,e){return FS(Pc(t,{strict:!1})?fS(t):t)}class zS extends qn{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class o0 extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const $c=new o0(8192);function a0(t,e){if($c.has(`${t}.${e}`))return $c.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=$S(Kh(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return $c.set(`${t}.${e}`,i),i}function Bt(t,e){if(!VS(t,{strict:!1}))throw new zS({address:t});return a0(t,e)}const jS=/^0x[a-fA-F0-9]{40}$/,zc=new o0(8192);function VS(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(zc.has(r))return zc.get(r);const s=jS.test(t)?t.toLowerCase()===t?!0:n?a0(t)===t:!0:!1;return zc.set(r,s),s}const kt={USDC:"USDC",USDT:"USDT",DAI:"DAI",WETH:"WETH"};sn.ARBITRUM+"",kt.DAI+"",Bt("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),kt.USDC+"",Bt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),kt.USDT+"",Bt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),kt.WETH+"",Bt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),sn.ARBITRUM_TESTNET+"",kt.USDC+"",Bt("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),sn.AVALANCHE+"",kt.USDC+"",Bt("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),sn.AVALANCHE_TESTNET+"",kt.USDC+"",Bt("0x5425890298aed601595a70AB815c96711a31Bc65"),sn.BASE+"",kt.USDC+"",Bt("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),kt.WETH+"",Bt("0x4200000000000000000000000000000000000006"),sn.BASE_TESTNET+"",kt.USDC+"",Bt("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),sn.BSC+"",kt.USDC+"",Bt("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),sn.ETHEREUM+"",kt.DAI+"",Bt("0x6B175474E89094C44Da98b954EedeAC495271d0F"),kt.USDC+"",Bt("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),kt.USDT+"",Bt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),kt.WETH+"",Bt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),sn.ETHEREUM_TESTNET+"",kt.USDC+"",Bt("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238");const GS=new Set(Object.values(sn));function HS(t){if(qS(t))return t;const e=sn[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function qS(t){return GS.has(t)}async function KS(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");const r=await S1(e,{connector:fo()});if(r?.accounts?.length){const s={type:an.FARCASTER_CONNECTED,isConnected:!0,address:r.accounts[0],chainId:r.chainId};[Lo,Po].forEach(i=>{t.current?.contentWindow?.postMessage(s,i)})}}async function WS(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");await N1(e);const r={type:an.FARCASTER_DISCONNECTED,isConnected:!1,address:null,chainId:null};[Lo,Po].forEach(s=>{t.current?.contentWindow?.postMessage(r,s)})}async function ZS(t,e,n,r,s){if(!n||!e)throw new Error("Wagmi config not found");let i=null;try{return await B1(e,{chainId:t.chainId}),t.nativeToken?(i=await C1(e,{to:t.to,value:t.value,chainId:t.chainId}),i):(i=await k1(e,{abi:Xp,address:t.token,functionName:"transfer",args:[t.to,t.value]}),i)}catch{[Lo,Po].forEach(a=>{r?.contentWindow?.postMessage({type:an.FARCASTER_SEND_TRANSACTION_RESULT,requestId:s.params,error:"an error occurred"},a)})}return i}function YS(t){if(!t)throw new Error("Wagmi config not found");return t.chains.map(e=>e.id)}function JS(){return Wn.jsx("div",{role:"status",className:"payment-modal-loader",children:Wn.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Wn.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),Wn.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})})}const XS=["light","dark","system"],go="https://app.chainrails.io",yo="https://chainrails-frontend-git-staging-horus-labs.vercel.app";function QS(t){const{amount:e,styles:n,excludeChains:r,isOpen:s,isPending:i,open:o,close:a,onCancel:d,onSuccess:m,session_url:g,sessionToken:x,farcasterMiniApp:O,wagmiConfig:N}=t,[F,M]=Be.useState(0),[k,K]=Be.useState(""),[Y,z]=Be.useState(null),L=Be.useRef(null);Ce.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Be.useEffect(()=>{K(Ce.getPayModalUrl(e))},[e]),Be.useEffect(()=>{const J=n?.theme;if(!J||XS.includes(J)){z(null);return}let te=!1;return(async()=>{try{const V=Ce.getBaseUrl(),C=await fetch(`${V}/themes/${J}`);if(!C.ok)return;const P=await C.json();!te&&P.status==="approved"&&P.cssContent&&z(P.cssContent)}catch(V){console.error("Failed to fetch theme:",V)}})(),()=>{te=!0}},[n?.theme]),Be.useEffect(()=>{const J=document.body.style.overflow;s?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=J||"";const te=async ee=>{if(ee.data===an.CLOSED&&(a(),d?.()),ee?.data?.type===an.COMPLETED){window.setTimeout(a,2e3);const P=ee?.data?.transactionHash?{transactionHash:ee.data.transactionHash}:void 0;m?.(P)}if(ee.data===an.REQUEST_FARCASTER_CONNECT)try{await KS(L,N,O)}catch(P){console.error(P)}if(ee.data===an.REQUEST_FARCASTER_DISCONNECT)try{await WS(L,N,O)}catch(P){console.error(P)}const C=ee.data;if(C?.type===an.REQUEST_FARCASTER_SEND_TRANSACTION&&typeof C.requestId=="string"&&C.params)try{const P=await ZS(C.params,N,O,L.current,C.requestId);P?[go,yo].forEach(q=>{L.current?.contentWindow?.postMessage({type:an.FARCASTER_SEND_TRANSACTION_RESULT,requestId:C.requestId,hash:P},q)}):[go,yo].forEach(q=>{L.current?.contentWindow?.postMessage({type:an.FARCASTER_SEND_TRANSACTION_RESULT,requestId:C.requestId,error:"sendTransaction not configured or returned no hash"},q)})}catch(P){console.log(P)}};return window.addEventListener("message",te),()=>{document.body.style.overflow=J||"",window.removeEventListener("message",te)}},[s,d,m,a,O,N]),Be.useEffect(()=>{if(!x)return;const J=t.css||Y||void 0,te=async()=>{const V=await $h.isInMiniApp(),C=r?.map(HS)||[],P=N?YS(N):void 0;return{type:"session",session_token:x,environment:Ce.getEnv()||Bo.PRODUCTION,styles:n,props:{excludeChains:C.join(","),isFarcasterMiniApp:V,...P?.length?{supportedChains:P}:{}},...J?{css:J}:{}}};let ee=!1;return te().then(V=>{ee||([go,yo].forEach(C=>{L.current?.contentWindow?.postMessage(V,C)}),window.setTimeout(()=>{ee||[go,yo].forEach(C=>{L.current?.contentWindow?.postMessage(V,C)})},1e3))}),()=>{ee=!0}},[x,F,s,n,Y]);function j(){M(Math.random())}return Wn.jsxs("div",{className:Jp("payment-modal-wrapper",F===0||i?"loading":"not-loading",s?"open":"closed"),children:[(F===0||i)&&Wn.jsx(JS,{}),Wn.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:k||void 0,onLoad:j,className:`payment-modal ${F===0||i?"invisible":"visible"}`,"data-id":e,ref:L},e)]})}const eT=Symbol(),jc=Symbol(),Ys="a",c0="f",u0="p",d0="c",l0="t",Vc="h",Js="w",Gc="o",Hc="k";let tT=(t,e)=>new Proxy(t,e);const qc=Object.getPrototypeOf,Kc=new WeakMap,f0=t=>t&&(Kc.has(t)?Kc.get(t):qc(t)===Object.prototype||qc(t)===Array.prototype),bo=t=>typeof t=="object"&&t!==null,nT=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),rT=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(n=>{n.configurable=!0}),Object.create(qc(t),e)},sT=(t,e)=>{const n={[c0]:e};let r=!1;const s=(a,d)=>{if(!r){let m=n[Ys].get(t);if(m||(m={},n[Ys].set(t,m)),a===Js)m[Js]=!0;else{let g=m[a];g||(g=new Set,m[a]=g),g.add(d)}}},i=()=>{r=!0,n[Ys].delete(t)},o={get(a,d){return d===jc?t:(s(Hc,d),h0(Reflect.get(a,d),n[Ys],n[d0],n[l0]))},has(a,d){return d===eT?(i(),!0):(s(Vc,d),Reflect.has(a,d))},getOwnPropertyDescriptor(a,d){return s(Gc,d),Reflect.getOwnPropertyDescriptor(a,d)},ownKeys(a){return s(Js),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,n]},Wc=t=>t[jc]||t,h0=(t,e,n,r)=>{if(!f0(t))return t;let s=r&&r.get(t);if(!s){const d=Wc(t);nT(d)?s=[d,rT(d)]:s=[d],r?.set(t,s)}const[i,o]=s;let a=n&&n.get(i);return(!a||a[1][c0]!==!!o)&&(a=sT(i,!!o),a[1][u0]=tT(o||i,a[0]),n&&n.set(i,a)),a[1][Ys]=e,a[1][d0]=n,a[1][l0]=r,a[1][u0]},iT=(t,e)=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return n.length!==r.length||n.some((s,i)=>s!==r[i])},p0=(t,e,n,r,s=Object.is)=>{if(s(t,e))return!1;if(!bo(t)||!bo(e))return!0;const i=n.get(Wc(t));if(!i)return!0;if(r){if(r.get(t)===e)return!1;r.set(t,e)}let o=null;for(const a of i[Vc]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[Js]===!0){if(o=iT(t,e),o)return o}else for(const a of i[Gc]||[]){const d=!!Reflect.getOwnPropertyDescriptor(t,a),m=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=d!==m,o)return o}for(const a of i[Hc]||[])if(o=p0(t[a],e[a],n,r,s),o)return o;if(o===null)throw new Error("invalid used");return o},oT=t=>f0(t)&&t[jc]||null,m0=(t,e=!0)=>{Kc.set(t,e)},aT=(t,e,n)=>{const r=[],s=new WeakSet,i=(o,a)=>{var d,m,g;if(s.has(o))return;bo(o)&&s.add(o);const x=bo(o)&&e.get(Wc(o));if(x){if((d=x[Vc])===null||d===void 0||d.forEach(O=>{const N=`:has(${String(O)})`;r.push(a?[...a,N]:[N])}),x[Js]===!0){const O=":ownKeys";r.push(a?[...a,O]:[O])}else(m=x[Gc])===null||m===void 0||m.forEach(O=>{const N=`:hasOwn(${String(O)})`;r.push(a?[...a,N]:[N])});(g=x[Hc])===null||g===void 0||g.forEach(O=>{"value"in(Object.getOwnPropertyDescriptor(o,O)||{})&&i(o[O],a?[...a,O]:[O])})}else a&&r.push(a)};return i(t),r},_o={},Zc=t=>typeof t=="object"&&t!==null,cT=t=>Zc(t)&&!Yc.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),g0=(t,e)=>{const n=y0.get(t);if(n?.[0]===e)return n[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return m0(r,!0),y0.set(t,[e,r]),Reflect.ownKeys(t).forEach(s=>{if(Object.getOwnPropertyDescriptor(r,s))return;const i=Reflect.get(t,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,s),a={value:i,enumerable:o,configurable:!0};if(Yc.has(i))m0(i,!1);else if(pr.has(i)){const[d,m]=pr.get(i);a.value=g0(d,m())}Object.defineProperty(r,s,a)}),Object.preventExtensions(r)},uT=(t,e,n,r)=>({deleteProperty(s,i){const o=Reflect.get(s,i);n(i);const a=Reflect.deleteProperty(s,i);return a&&r(["delete",[i],o]),a},set(s,i,o,a){const d=!t()&&Reflect.has(s,i),m=Reflect.get(s,i,a);if(d&&(b0(m,o)||wo.has(o)&&b0(m,wo.get(o))))return!0;n(i),Zc(o)&&(o=oT(o)||o);const g=!pr.has(o)&&lT(o)?_0(o):o;return e(i,g),Reflect.set(s,i,g,a),r(["set",[i],o,m]),!0}}),pr=new WeakMap,Yc=new WeakSet,y0=new WeakMap,Jc=[1],wo=new WeakMap;let b0=Object.is,dT=(t,e)=>new Proxy(t,e),lT=cT,fT=g0,hT=uT;function _0(t={}){if(!Zc(t))throw new Error("object required");const e=wo.get(t);if(e)return e;let n=Jc[0];const r=new Set,s=(k,K=++Jc[0])=>{n!==K&&(i=n=K,r.forEach(Y=>Y(k,K)))};let i=n;const o=(k=Jc[0])=>(i!==k&&(i=k,d.forEach(([K])=>{const Y=K[1](k);Y>n&&(n=Y)})),n),a=k=>(K,Y)=>{const z=[...K];z[1]=[k,...z[1]],s(z,Y)},d=new Map,m=(k,K)=>{const Y=!Yc.has(K)&&pr.get(K);if(Y){if((_o?"production":void 0)!=="production"&&d.has(k))throw new Error("prop listener already exists");if(r.size){const z=Y[2](a(k));d.set(k,[Y,z])}else d.set(k,[Y])}},g=k=>{var K;const Y=d.get(k);Y&&(d.delete(k),(K=Y[1])==null||K.call(Y))},x=k=>(r.add(k),r.size===1&&d.forEach(([Y,z],L)=>{if((_o?"production":void 0)!=="production"&&z)throw new Error("remove already exists");const j=Y[2](a(L));d.set(L,[Y,j])}),()=>{r.delete(k),r.size===0&&d.forEach(([Y,z],L)=>{z&&(z(),d.set(L,[Y]))})});let O=!0;const N=hT(()=>O,m,g,s),F=dT(t,N);wo.set(t,F);const M=[t,o,x];return pr.set(F,M),Reflect.ownKeys(t).forEach(k=>{const K=Object.getOwnPropertyDescriptor(t,k);"value"in K&&K.writable&&(F[k]=t[k])}),O=!1,F}function pT(t,e,n){const r=pr.get(t);(_o?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let s;const i=[],o=r[2];let a=!1;const m=o(g=>{i.push(g),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,m()}}function w0(t){const e=pr.get(t);(_o?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[n,r]=e;return fT(n,r())}const mT={},gT=(t,e)=>{const n=Be.useRef(void 0);Be.useEffect(()=>{n.current=aT(t,e)}),Be.useDebugValue(n.current)},yT=new WeakMap;function bT(t,e){const r=Be.useMemo(()=>t&&new WeakMap,[t]),s=Be.useRef(void 0);let i=!0;const o=Be.useSyncExternalStore(Be.useCallback(d=>{const m=pT(t,d);return d(),m},[t,void 0]),()=>{const d=w0(t);try{if(!i&&s.current&&!p0(s.current,d,r,new WeakMap))return s.current}catch{}return d},()=>w0(t));i=!1,Be.useLayoutEffect(()=>{s.current=o}),(mT?"production":void 0)!=="production"&&gT(o,r);const a=Be.useMemo(()=>new WeakMap,[]);return h0(o,r,a,yT)}const Kn=_0({data:null,isPending:!1,error:null});function _T({session_url:t,onCancel:e,onSuccess:n,farcasterMiniApp:r,wagmiConfig:s}){const i=bT(Kn),[o,a]=Be.useState(!1),[d,m]=Be.useState(Date.now()),g=i?.data?.sessionToken,x=i?.data?.amount;function O(){g||window.setTimeout(()=>{g&&a(!0)},200),a(!0)}function N(){a(!1)}const F=()=>{const M=Date.now();Kn.isPending=!0,Kn.error=null,Kn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(k=>k.json()).then(k=>{M<d||(Kn.data=k,Kn.isPending=!1,m(M))}).catch(k=>{M<d||(Kn.error=k?.toString(),Kn.isPending=!1,m(M),setInterval(F,5e3))})};return Be.useEffect(()=>{F()},[t]),{sessionToken:g,amount:x,isOpen:o,session_url:t,open:O,close:N,isPending:i.isPending,error:i.error,refetch:F,onSuccess:n,onCancel:e,farcasterMiniApp:r,wagmiConfig:s}}function wT({sessionToken:t,amount:e,onCancel:n,onSuccess:r,farcasterMiniApp:s,wagmiConfig:i}){const[o,a]=Be.useState(!1),[d,m]=Be.useState(t),[g,x]=Be.useState(e);function O({sessionToken:M,amount:k}){m(M),x(k)}Be.useEffect(()=>{m(t)},[t]);function N(){d||window.setTimeout(()=>{d&&a(!0)},200),a(!0)}function F(){a(!1)}return{sessionToken:d,updateSession:O,amount:g,isOpen:o,open:N,close:F,onSuccess:r,onCancel:n,farcasterMiniApp:s,wagmiConfig:i}}Rt.AmountSymbols=X,Rt.Chainrails=Ce,Rt.Chains=Mu,Rt.PaymentModal=QS,Rt.chains=Mu,Rt.crapi=Yp,Rt.tokens=X,Rt.usePaymentModal=wT,Rt.usePaymentSession=_T,Object.defineProperty(Rt,Symbol.toStringTag,{value:"Module"})}));
39
+ */const Rh=Symbol("Comlink.proxy"),lx=Symbol("Comlink.endpoint"),fx=Symbol("Comlink.releaseProxy"),kc=Symbol("Comlink.finalizer"),io=Symbol("Comlink.thrown"),Ah=t=>typeof t=="object"&&t!==null||typeof t=="function",hx={canHandle:t=>Ah(t)&&t[Rh],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Sh(t,e),[n,[n]]},deserialize(t){return t.start(),Oh(t)}},px={canHandle:t=>Ah(t)&&io in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},xh=new Map([["proxy",hx],["throw",px]]);function mx(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function Sh(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!mx(n,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:i,type:o,path:a}=Object.assign({path:[]},s.data),d=(s.data.argumentList||[]).map(hr);let m;try{const g=a.slice(0,-1).reduce((O,N)=>O[N],t),x=a.reduce((O,N)=>O[N],t);switch(o){case"GET":m=x;break;case"SET":g[a.slice(-1)[0]]=hr(s.data.value),m=!0;break;case"APPLY":m=x.apply(g,d);break;case"CONSTRUCT":{const O=new x(...d);m=Ex(O)}break;case"ENDPOINT":{const{port1:O,port2:N}=new MessageChannel;Sh(t,N),m=wx(O,[O])}break;case"RELEASE":m=void 0;break;default:return}}catch(g){m={value:g,[io]:0}}Promise.resolve(m).catch(g=>({value:g,[io]:0})).then(g=>{const[x,O]=uo(g);e.postMessage(Object.assign(Object.assign({},x),{id:i}),O),o==="RELEASE"&&(e.removeEventListener("message",r),Th(e),kc in t&&typeof t[kc]=="function"&&t[kc]())}).catch(g=>{const[x,O]=uo({value:new TypeError("Unserializable return value"),[io]:0});e.postMessage(Object.assign(Object.assign({},x),{id:i}),O)})}),e.start&&e.start()}function gx(t){return t.constructor.name==="MessagePort"}function Th(t){gx(t)&&t.close()}function Oh(t,e){const n=new Map;return t.addEventListener("message",function(s){const{data:i}=s;if(!i||!i.id)return;const o=n.get(i.id);if(o)try{o(i)}finally{n.delete(i.id)}}),Lc(t,n,[],e)}function oo(t){if(t)throw new Error("Proxy has been released and is not useable")}function Ih(t){return Hr(t,new Map,{type:"RELEASE"}).then(()=>{Th(t)})}const ao=new WeakMap,co="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(ao.get(t)||0)-1;ao.set(t,e),e===0&&Ih(t)});function yx(t,e){const n=(ao.get(e)||0)+1;ao.set(e,n),co&&co.register(t,e,t)}function bx(t){co&&co.unregister(t)}function Lc(t,e,n=[],r=function(){}){let s=!1;const i=new Proxy(r,{get(o,a){if(oo(s),a===fx)return()=>{bx(i),Ih(t),e.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>i};const d=Hr(t,e,{type:"GET",path:n.map(m=>m.toString())}).then(hr);return d.then.bind(d)}return Lc(t,e,[...n,a])},set(o,a,d){oo(s);const[m,g]=uo(d);return Hr(t,e,{type:"SET",path:[...n,a].map(x=>x.toString()),value:m},g).then(hr)},apply(o,a,d){oo(s);const m=n[n.length-1];if(m===lx)return Hr(t,e,{type:"ENDPOINT"}).then(hr);if(m==="bind")return Lc(t,e,n.slice(0,-1));const[g,x]=Nh(d);return Hr(t,e,{type:"APPLY",path:n.map(O=>O.toString()),argumentList:g},x).then(hr)},construct(o,a){oo(s);const[d,m]=Nh(a);return Hr(t,e,{type:"CONSTRUCT",path:n.map(g=>g.toString()),argumentList:d},m).then(hr)}});return yx(i,t),i}function _x(t){return Array.prototype.concat.apply([],t)}function Nh(t){const e=t.map(uo);return[e.map(n=>n[0]),_x(e.map(n=>n[1]))]}const Ch=new WeakMap;function wx(t,e){return Ch.set(t,e),t}function Ex(t){return Object.assign(t,{[Rh]:!0})}function vx(t,e=globalThis,n="*"){return{postMessage:(r,s)=>t.postMessage(r,n,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function uo(t){for(const[e,n]of xh)if(n.canHandle(t)){const[r,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:t},Ch.get(t)||[]]}function hr(t){switch(t.type){case"HANDLER":return xh.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Hr(t,e,n,r){return new Promise(s=>{const i=Rx();e.set(i,s),t.start&&t.start(),t.postMessage(Object.assign({id:i},n),r)})}function Rx(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const Ax={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},xx={postMessage:t=>{window.ReactNativeWebView.postMessage(JSON.stringify(t))},addEventListener:(t,e,...n)=>{document.addEventListener("FarcasterFrameCallback",e,...n)},removeEventListener:(t,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},Sx=typeof window>"u"?Ax:window?.ReactNativeWebView?xx:vx(window?.parent??window),be=Oh(Sx),Pc=ox(),Tx=ux();function Ox({code:t,details:e}){switch(t){case 4001:return new bh;case 4100:return new _h;case 4200:return new wh;case 4900:return new Eh;case 4901:return new vh;default:return new fr(t,e??"Unknown provider RPC error")}}const Ws=ax({...Pc,async request(t){const e=Tx.prepare(t);try{const n=await be.ethProviderRequestV2(e).then(r=>yh(r,{request:e,raw:!0}));if(n.error)throw Ox(n.error);return n.result}catch(n){if(n instanceof Error&&n.message.match(/cannot read property 'apply'/i))return await be.ethProviderRequest(e);throw n instanceof fr||n instanceof Gt?n:new Gr({message:n instanceof Error?n.message:void 0})}}});async function Ix(){try{const t=await be.getCapabilities();return!t.includes("wallet.getEthereumProvider")&&!t.includes("wallet.getEvmProvider")?void 0:Ws}catch{return Ws}}function Mh(t){const e=new CustomEvent("eip6963:announceProvider",{detail:Object.freeze(t)});window.dispatchEvent(e);const n=()=>window.dispatchEvent(e);return window.addEventListener("eip6963:requestProvider",n),()=>window.removeEventListener("eip6963:requestProvider",n)}typeof document<"u"&&(document.addEventListener("eip6963:requestProvider",()=>{be.eip6963RequestProvider()}),document.addEventListener("FarcasterFrameEthProviderEvent",t=>{if(t instanceof MessageEvent){const e=t.data;Pc.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="eip6963:announceProvider"&&Mh({info:e.info,provider:Ws})}})),typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{be.eip6963RequestProvider()}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEthProviderEvent"){const e=t.data;Pc.emit(e.event,...e.params)}}),window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="eip6963:announceProvider"&&Mh({info:e.info,provider:Ws})}})),new TextEncoder;const Bh=new TextDecoder,Nx=t=>{const e=atob(t),n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},Cx=t=>{let e=t;e instanceof Uint8Array&&(e=Bh.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Nx(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};function Mx(t){return typeof t=="object"&&t!==null}function Bx(t){if(!Mx(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}class $t extends Error{constructor(e,n){super(e,n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}$t.code="ERR_JOSE_GENERIC";class kx extends $t{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=r,this.reason=s,this.payload=n}}kx.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Lx extends $t{constructor(e,n,r="unspecified",s="unspecified"){super(e,{cause:{claim:r,reason:s,payload:n}}),this.code="ERR_JWT_EXPIRED",this.claim=r,this.reason=s,this.payload=n}}Lx.code="ERR_JWT_EXPIRED";class Px extends $t{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Px.code="ERR_JOSE_ALG_NOT_ALLOWED";class Ux extends $t{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}Ux.code="ERR_JOSE_NOT_SUPPORTED";class Dx extends $t{constructor(e="decryption operation failed",n){super(e,n),this.code="ERR_JWE_DECRYPTION_FAILED"}}Dx.code="ERR_JWE_DECRYPTION_FAILED";class Fx extends $t{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Fx.code="ERR_JWE_INVALID";class $x extends $t{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}$x.code="ERR_JWS_INVALID";class qn extends $t{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}qn.code="ERR_JWT_INVALID";class zx extends $t{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}zx.code="ERR_JWK_INVALID";class jx extends $t{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}jx.code="ERR_JWKS_INVALID";class Vx extends $t{constructor(e="no applicable key found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Vx.code="ERR_JWKS_NO_MATCHING_KEY";class Gx extends $t{constructor(e="multiple matching keys found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Gx.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class Hx extends $t{constructor(e="request timed out",n){super(e,n),this.code="ERR_JWKS_TIMEOUT"}}Hx.code="ERR_JWKS_TIMEOUT";class qx extends $t{constructor(e="signature verification failed",n){super(e,n),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}qx.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function Kx(t){if(typeof t!="string")throw new qn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new qn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new qn("Invalid JWT");if(!e)throw new qn("JWTs must contain a payload");let r;try{r=Cx(e)}catch{throw new qn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(Bh.decode(r))}catch{throw new qn("Failed to parse the decoded payload as JSON")}if(!Bx(s))throw new qn("Invalid JWT Claims Set");return s}function Wx(t){return Kx(t)}class lo extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof lo){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&typeof n.cause.details=="string"?n.cause.details:n.cause?.message?n.cause.message:n.details})(),s=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r?["",r?`Details: ${r}`:void 0]:[]].filter(i=>typeof i=="string").join(`
40
+ `);super(s,n.cause?{cause:n.cause}:void 0),this.name="BaseError",this.cause=n.cause,this.details=r,this.shortMessage=e}}class kh extends lo{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}}class Zx extends lo{constructor(e){super(e),this.name="InvalidToken"}}async function Yx({origin:t}){const e=await fetch(`${t}/nonce`,{method:"POST"});if(!e.ok)throw new kh({status:e.status});return await e.json()}async function Jx({origin:t},e){const n=await fetch(`${t}/verify-siwf`,{method:"POST",headers:new Headers({"Content-Type":"application/json"}),body:JSON.stringify(e)});if(!n.ok)throw new kh({status:n.status});const r=await n.json();if(r.valid===!1)throw new Zx(r.message??"unknown");return{token:r.token}}function Xx(t={}){return{origin:t.origin??"https://auth.farcaster.xyz"}}function Qx(t={}){const e=Xx(t);return{generateNonce:()=>Yx(e),verifySiwf:n=>Jx(e,n)}}const eS=/^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\/\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\n)(?<address>0x[a-fA-F0-9]{40})\n\n(?:(?<statement>.*)\n\n)?/,tS=/(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.+))?/;function nS(t){const{scheme:e,statement:n,...r}=t.match(eS)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:d,...m}=t.match(tS)?.groups??{},g=t.split("Resources:")[1]?.split(`
41
+ - `).slice(1);return{...r,...m,...s?{chainId:Number(s)}:{},...i?{expirationTime:new Date(i)}:{},...o?{issuedAt:new Date(o)}:{},...a?{notBefore:new Date(a)}:{},...d?{requestId:d}:{},...g?{resources:g}:{},...e?{scheme:e}:{},...n?{statement:n}:{}}}const Lh=(()=>{let t,e;async function n(r){const s=Qx({origin:r.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await be.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){const a=nS(o.result.message);if(!a.domain)throw new Error("Missing domain on SIWE message");const d=await s.verifySiwf({domain:a.domain,message:o.result.message,signature:o.result.signature});return t={token:d.token,payload:Wx(d.token)},d}throw o.error.type==="rejected_by_user"?new Kl:new Error("Unreachable")}return{get token(){if(t&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3))return t.token},async getToken(r={}){const s=r.force??!1;return t&&!s&&new Date(t.payload.exp*1e3)>new Date(Date.now()+15e3)?{token:t.token}:(e||(e=n(r)),e.finally(()=>{e=void 0}),e)},async fetch(r,s){const{token:i}=await this.getToken(),o=new Headers(s?.headers);return o.set("Authorization",`Bearer ${i}`),fetch(r,{...s,headers:o})}}})();function rS(){const t=new ql;return{get eventNames(){return t.eventNames.bind(t)},get listenerCount(){return t.listenerCount.bind(t)},get listeners(){return t.listeners.bind(t)},addListener:t.addListener.bind(t),emit:t.emit.bind(t),off:t.off.bind(t),on:t.on.bind(t),once:t.once.bind(t),removeAllListeners:t.removeAllListeners.bind(t),removeListener:t.removeListener.bind(t)}}const Mt=rS(),{solanaProviderRequest:Ph}=be;let Uh;Ph&&(Uh=ZA(JA(Ph)));async function Dh(){let t;try{t=await be.getCapabilities()}catch{}if(t?.includes("wallet.getSolanaProvider"))return Uh}let Fh=null;async function sS(t=1e3){if(Fh===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;const e=await Promise.race([be.context.then(n=>!!n),new Promise(n=>{setTimeout(()=>n(!1),t)})]).catch(()=>!1);return e&&(Fh=!0),e}const $h=async()=>{const t=await be.addFrame();if(t.result)return t.result;throw t.error.type==="invalid_domain_manifest"?new U1:t.error.type==="rejected_by_user"?new D1:new Error("Unreachable")},zh={...Mt,getCapabilities:be.getCapabilities,getChains:be.getChains,isInMiniApp:sS,context:be.context,back:XA({miniAppHost:be,emitter:Mt}),quickAuth:Lh,actions:{setPrimaryButton:be.setPrimaryButton.bind(be),ready:async(t={})=>await be.ready(t),close:be.close.bind(be),viewCast:be.viewCast.bind(be),viewProfile:be.viewProfile.bind(be),openMiniApp:be.openMiniApp.bind(be),signIn:async t=>{const e=await be.signIn({...t,acceptAuthAddress:t.acceptAuthAddress??!0});if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new Kl:new Error("Unreachable")},openUrl:t=>{const e=typeof t=="string"?t:t.url;return be.openUrl(e.trim())},addFrame:$h,addMiniApp:$h,composeCast(t={}){return be.composeCast(t)},viewToken:be.viewToken.bind(be),sendToken:be.sendToken.bind(be),swapToken:be.swapToken.bind(be),requestCameraAndMicrophoneAccess:be.requestCameraAndMicrophoneAccess.bind(be)},experimental:{getSolanaProvider:Dh,signManifest:async t=>{const e=await be.signManifest(t);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new F1:e.error.type==="invalid_domain"?new $1:e.error.type==="generic_error"?new z1(e.error.message):new Error("Unreachable")},quickAuth(t){return Lh.getToken(t)}},wallet:{ethProvider:Ws,getEthereumProvider:Ix,getSolanaProvider:Dh},haptics:{impactOccurred:be.impactOccurred.bind(be),notificationOccurred:be.notificationOccurred.bind(be),selectionChanged:be.selectionChanged.bind(be)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="primary_button_clicked"?Mt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Mt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Mt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Mt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Mt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Mt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Mt.emit("backNavigationTriggered")}}),typeof window<"u"&&window.addEventListener("message",t=>{if(t instanceof MessageEvent&&t.data.type==="frameEvent"){const e=t.data.event;e.event==="primary_button_clicked"?Mt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Mt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Mt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Mt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Mt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Mt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Mt.emit("backNavigationTriggered")}}),fo.type="farcasterMiniApp";let qr,Kr,Wr;function fo(){return t=>({id:"farcaster",name:"Farcaster",rdns:"xyz.farcaster.MiniAppWallet",icon:"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/055c25d6-7fe7-4a49-abf9-49772021cf00/original",type:fo.type,async connect({chainId:e}={}){const n=await this.getProvider(),r=await n.request({method:"eth_requestAccounts"});let s=e;if(!s){const o=await t.storage?.getItem("state")??{};t.chains.some(d=>d.id===o.chainId)?s=o.chainId:s=t.chains[0]?.id}if(!s)throw new Error("No chains found on connector.");qr||(qr=this.onAccountsChanged.bind(this),n.on("accountsChanged",qr)),Kr||(Kr=this.onChainChanged.bind(this),n.on("chainChanged",Kr)),Wr||(Wr=this.onDisconnect.bind(this),n.on("disconnect",Wr));let i=await this.getChainId();return s&&i!==s&&(i=(await this.switchChain({chainId:s})).id),{accounts:r.map(o=>ui(o)),chainId:i}},async disconnect(){const e=await this.getProvider();qr&&(e.removeListener("accountsChanged",qr),qr=void 0),Kr&&(e.removeListener("chainChanged",Kr),Kr=void 0),Wr&&(e.removeListener("disconnect",Wr),Wr=void 0)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(r=>ui(r))},async getChainId(){const n=await(await this.getProvider()).request({method:"eth_chainId"});return hm(n,"number")},async isAuthorized(){try{return!!(await this.getAccounts()).length}catch{return!1}},async switchChain({chainId:e}){const n=await this.getProvider(),r=t.chains.find(s=>s.id===e);if(!r)throw new Sr(new jl);return await n.request({method:"wallet_switchEthereumChain",params:[{chainId:ke(e)}]}),t.emitter.emit("change",{chainId:e}),r},onAccountsChanged(e){e.length===0?this.onDisconnect():t.emitter.emit("change",{accounts:e.map(n=>ui(n))})},onChainChanged(e){const n=Number(e);t.emitter.emit("change",{chainId:n})},async onDisconnect(){t.emitter.emit("disconnect")},async getProvider(){return zh.wallet.ethProvider}})}const iS=fo;iS.type="farcasterFrame";const on={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function Uc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function jh(t){return Uc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Vh="2.43.4";let Dc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Vh}`};class Kn extends Error{constructor(e,n={}){const r=n.cause instanceof Kn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Kn&&n.cause.docsPath||n.docsPath,i=Dc.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Dc.version?[`Version: ${Dc.version}`]:[]].join(`
42
+ `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Vh}walk(e){return Gh(this,e)}}function Gh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Gh(t.cause,e):e?null:t}class Hh extends Kn{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function ho(t,{dir:e,size:n=32}={}){return typeof t=="string"?oS(t,{dir:e,size:n}):aS(t,{dir:e,size:n})}function oS(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Hh({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function aS(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Hh({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let s=0;s<n;s++){const i=e==="right";r[i?s:n-s-1]=t[i?s:t.length-s-1]}return r}class cS extends Kn{constructor({max:e,min:n,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${s*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class uS extends Kn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Fc(t,{size:e}){if(jh(t)>e)throw new uS({givenSize:jh(t),maxSize:e})}function dS(t,e={}){const{signed:n,size:r}=e,s=BigInt(t);let i;r?n?i=(1n<<BigInt(r)*8n-1n)-1n:i=2n**(BigInt(r)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&n?-i-1n:0;if(i&&s>i||s<o){const d=typeof t=="bigint"?"n":"";throw new cS({max:i?`${i}${d}`:void 0,min:`${o}${d}`,signed:n,size:r,value:`${t}${d}`})}const a=`0x${(n&&s<0?(1n<<BigInt(r*8))+BigInt(s):s).toString(16)}`;return r?ho(a,{size:r}):a}const lS=new TextEncoder;function fS(t,e={}){return typeof t=="number"||typeof t=="bigint"?pS(t,e):typeof t=="boolean"?hS(t,e):Uc(t)?Kh(t,e):Wh(t,e)}function hS(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Fc(n,{size:e.size}),ho(n,{size:e.size})):n}const Nn={zero:48,nine:57,A:65,F:70,a:97,f:102};function qh(t){if(t>=Nn.zero&&t<=Nn.nine)return t-Nn.zero;if(t>=Nn.A&&t<=Nn.F)return t-(Nn.A-10);if(t>=Nn.a&&t<=Nn.f)return t-(Nn.a-10)}function Kh(t,e={}){let n=t;e.size&&(Fc(n,{size:e.size}),n=ho(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const s=r.length/2,i=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const d=qh(r.charCodeAt(a++)),m=qh(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Kn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function pS(t,e){const n=dS(t,e);return Kh(n)}function Wh(t,e={}){const n=lS.encode(t);return typeof e.size=="number"?(Fc(n,{size:e.size}),ho(n,{dir:"right",size:e.size})):n}const po=BigInt(2**32-1),Zh=BigInt(32);function mS(t,e=!1){return e?{h:Number(t&po),l:Number(t>>Zh&po)}:{h:Number(t>>Zh&po)|0,l:Number(t&po)|0}}function gS(t,e=!1){const n=t.length;let r=new Uint32Array(n),s=new Uint32Array(n);for(let i=0;i<n;i++){const{h:o,l:a}=mS(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const yS=(t,e,n)=>t<<n|e>>>32-n,bS=(t,e,n)=>e<<n|t>>>32-n,_S=(t,e,n)=>e<<n-32|t>>>64-n,wS=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ES(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Yh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function mo(t,...e){if(!ES(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Jh(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function vS(t,e){mo(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function RS(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Xh(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const AS=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function xS(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function SS(t){for(let e=0;e<t.length;e++)t[e]=xS(t[e]);return t}const Qh=AS?t=>t:SS;function TS(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function e0(t){return typeof t=="string"&&(t=TS(t)),mo(t),t}class OS{}function IS(t){const e=r=>t().update(e0(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const NS=BigInt(0),Zs=BigInt(1),CS=BigInt(2),MS=BigInt(7),BS=BigInt(256),kS=BigInt(113),t0=[],n0=[],r0=[];for(let t=0,e=Zs,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],t0.push(2*(5*r+n)),n0.push((t+1)*(t+2)/2%64);let s=NS;for(let i=0;i<7;i++)e=(e<<Zs^(e>>MS)*kS)%BS,e&CS&&(s^=Zs<<(Zs<<BigInt(i))-Zs);r0.push(s)}const s0=gS(r0,!0),LS=s0[0],PS=s0[1],i0=(t,e,n)=>n>32?_S(t,e,n):yS(t,e,n),o0=(t,e,n)=>n>32?wS(t,e,n):bS(t,e,n);function US(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,d=(o+2)%10,m=n[d],g=n[d+1],x=i0(m,g,1)^n[a],O=o0(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=x,t[o+N+1]^=O}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=n0[o],d=i0(s,i,a),m=o0(s,i,a),g=t0[o];s=t[g],i=t[g+1],t[g]=d,t[g+1]=m}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=LS[r],t[1]^=PS[r]}Xh(n)}class $c extends OS{constructor(e,n,r,s=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,Yh(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=RS(this.state)}clone(){return this._cloneInto()}keccak(){Qh(this.state32),US(this.state32,this.rounds),Qh(this.state32),this.posOut=0,this.pos=0}update(e){Jh(this),e=e0(e),mo(e);const{blockLen:n,state:r}=this,s=e.length;for(let i=0;i<s;){const o=Math.min(n-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:s}=this;e[r]^=n,(n&128)!==0&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Jh(this,!1),mo(e),this.finish();const n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Yh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vS(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Xh(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new $c(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const DS=(t,e,n)=>IS(()=>new $c(e,t,n)),FS=DS(1,136,256/8);function $S(t,e){return FS(Uc(t,{strict:!1})?fS(t):t)}class zS extends Kn{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class a0 extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const zc=new a0(8192);function c0(t,e){if(zc.has(`${t}.${e}`))return zc.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=$S(Wh(n)),s=n.split("");for(let o=0;o<40;o+=2)r[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(r[o>>1]&15)>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const i=`0x${s.join("")}`;return zc.set(`${t}.${e}`,i),i}function Bt(t,e){if(!VS(t,{strict:!1}))throw new zS({address:t});return c0(t,e)}const jS=/^0x[a-fA-F0-9]{40}$/,jc=new a0(8192);function VS(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(jc.has(r))return jc.get(r);const s=jS.test(t)?t.toLowerCase()===t?!0:n?c0(t)===t:!0:!1;return jc.set(r,s),s}const kt={USDC:"USDC",USDT:"USDT",DAI:"DAI",WETH:"WETH"};on.ARBITRUM+"",kt.DAI+"",Bt("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),kt.USDC+"",Bt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),kt.USDT+"",Bt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),kt.WETH+"",Bt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),on.ARBITRUM_TESTNET+"",kt.USDC+"",Bt("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),on.AVALANCHE+"",kt.USDC+"",Bt("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),on.AVALANCHE_TESTNET+"",kt.USDC+"",Bt("0x5425890298aed601595a70AB815c96711a31Bc65"),on.BASE+"",kt.USDC+"",Bt("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),kt.WETH+"",Bt("0x4200000000000000000000000000000000000006"),on.BASE_TESTNET+"",kt.USDC+"",Bt("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),on.BSC+"",kt.USDC+"",Bt("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),on.ETHEREUM+"",kt.DAI+"",Bt("0x6B175474E89094C44Da98b954EedeAC495271d0F"),kt.USDC+"",Bt("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),kt.USDT+"",Bt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),kt.WETH+"",Bt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),on.ETHEREUM_TESTNET+"",kt.USDC+"",Bt("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238");const GS=new Set(Object.values(on));function HS(t){if(qS(t))return t;const e=on[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function qS(t){return GS.has(t)}async function KS(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");const r=await S1(e,{connector:fo()});if(r?.accounts?.length){const s={type:cn.FARCASTER_CONNECTED,isConnected:!0,address:r.accounts[0],chainId:r.chainId};[Po,Uo].forEach(i=>{t.current?.contentWindow?.postMessage(s,i)})}}async function WS(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");await N1(e);const r={type:cn.FARCASTER_DISCONNECTED,isConnected:!1,address:null,chainId:null};[Po,Uo].forEach(s=>{t.current?.contentWindow?.postMessage(r,s)})}async function ZS(t,e,n,r,s){if(!n||!e)throw new Error("Wagmi config not found");let i=null;try{return await B1(e,{chainId:t.chainId}),t.nativeToken?(i=await C1(e,{to:t.to,value:t.value,chainId:t.chainId}),i):(i=await k1(e,{abi:Xp,address:t.token,functionName:"transfer",args:[t.to,t.value]}),i)}catch{[Po,Uo].forEach(a=>{r?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:s.params,error:"an error occurred"},a)})}return i}function YS(t){if(!t)throw new Error("Wagmi config not found");return t.chains.map(e=>e.id)}function JS(){return Jt.jsx("div",{role:"status",className:"payment-modal-loader",children:Jt.jsxs("svg",{className:"payment-modal-loader-logo",xmlns:"http://www.w3.org/2000/svg",width:"51",height:"30",viewBox:"0 0 34 20",fill:"none",children:[Jt.jsxs("g",{clipPath:"url(#clip0_9521_19796)",children:[Jt.jsx("path",{d:"M4.50445 9.38014C4.50445 12.0779 6.69067 14.2641 9.38839 14.2641H19.1532V19.0243H9.51214C5.98943 19.0243 2.91222 17.1103 1.27048 14.2641C0.461994 12.8698 0 11.2446 0 9.51213C0 7.77966 0.486744 6.05543 1.34473 4.63644C3.00296 1.85623 6.03893 0 9.51214 0H16.2012V4.48795H10.5269C10.0731 4.50445 9.78438 4.4962 9.38839 4.4962C8.99239 4.4962 8.6129 4.5457 8.2499 4.63644C6.09668 5.14794 4.50445 7.07841 4.50445 9.38014Z",fill:"currentColor"}),Jt.jsx("path",{d:"M32.163 14.2745V18.911C29.325 18.9027 26.7758 17.6405 25.0516 15.644C24.6804 15.2233 24.3421 14.7613 24.0616 14.2745C23.5831 13.4743 23.2201 12.608 22.9974 11.684C22.8571 11.0901 22.8489 10.4796 22.8901 9.87732C22.8901 9.76182 22.8984 9.64632 22.8984 9.52257C22.8984 9.15133 22.8571 8.78008 22.7746 8.43358C22.7746 8.35934 22.7499 8.29334 22.7251 8.22734C22.1559 6.09061 20.2089 4.52313 17.8989 4.52313C17.8494 4.52313 17.7917 4.52313 17.7422 4.53138V-0.0390625H17.8989C19.6644 -0.0390625 21.3144 0.439432 22.7251 1.28092C23.6079 1.80067 24.3916 2.46066 25.0516 3.2279C26.4706 4.85313 27.3368 6.9651 27.3781 9.27507C27.3781 11.9645 29.4983 14.1673 32.163 14.2745Z",fill:"currentColor"})]}),Jt.jsx("defs",{children:Jt.jsx("clipPath",{id:"clip0_9521_19796",children:Jt.jsx("rect",{width:"33.6761",height:"19.0243",fill:"white"})})})]})})}const XS=["light","dark","system"],go="https://app.chainrails.io",yo="https://chainrails-frontend-git-staging-horus-labs.vercel.app";function QS(t){const{amount:e,styles:n,excludeChains:r,isOpen:s,isPending:i,open:o,close:a,onCancel:d,onSuccess:m,session_url:g,sessionToken:x,farcasterMiniApp:O,wagmiConfig:N}=t,[F,C]=Ie.useState(0),[k,K]=Ie.useState(""),[Y,V]=Ie.useState(null),[L,z]=Ie.useState(!1),J=Ie.useRef(null),te=Ie.useRef(!1);Ie.useEffect(()=>{const P=n?.theme;if(P==="dark"){z(!0);return}if(P==="light"){z(!1);return}const j=window.matchMedia("(prefers-color-scheme: dark)"),E=()=>z(j.matches);return E(),j.addEventListener("change",E),()=>j.removeEventListener("change",E)},[n?.theme]),Me.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Ie.useEffect(()=>{K(Me.getPayModalUrl(e))},[e]),Ie.useEffect(()=>{const P=n?.theme;if(!P||XS.includes(P)){V(null);return}let j=!1;return(async()=>{try{const c=Me.getBaseUrl(),p=await fetch(`${c}/themes/${P}`);if(!p.ok)return;const y=await p.json();!j&&y.status==="approved"&&y.cssContent&&V(y.cssContent)}catch(c){console.error("Failed to fetch theme:",c)}})(),()=>{j=!0}},[n?.theme]),Ie.useEffect(()=>{const P=document.body.style.overflow;s?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=P||"";const j=async E=>{if(E.data===cn.CLOSED&&(a(),d?.()),E?.data?.type===cn.COMPLETED){window.setTimeout(a,2e3);const y=E?.data?.transactionHash?{transactionHash:E.data.transactionHash}:void 0;m?.(y)}if(E.data===cn.REQUEST_FARCASTER_CONNECT)try{await KS(J,N,O)}catch(y){console.error(y)}if(E.data===cn.REQUEST_FARCASTER_DISCONNECT)try{await WS(J,N,O)}catch(y){console.error(y)}const p=E.data;if(p?.type===cn.REQUEST_FARCASTER_SEND_TRANSACTION&&typeof p.requestId=="string"&&p.params)try{const y=await ZS(p.params,N,O,J.current,p.requestId);y?[go,yo].forEach(A=>{J.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:p.requestId,hash:y},A)}):[go,yo].forEach(A=>{J.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:p.requestId,error:"sendTransaction not configured or returned no hash"},A)})}catch(y){console.log(y)}};return window.addEventListener("message",j),()=>{document.body.style.overflow=P||"",window.removeEventListener("message",j)}},[s,d,m,a,O,N]),Ie.useEffect(()=>{if(!x)return;const P=t.css||Y||void 0,j=async()=>{const c=await zh.isInMiniApp(),p=r?.map(HS)||[],y=N?YS(N):void 0;return{type:"session",session_token:x,environment:Me.getEnv()||Bo.PRODUCTION,styles:n,props:{excludeChains:p.join(","),isFarcasterMiniApp:c,...y?.length?{supportedChains:y}:{}},...P?{css:P}:{}}};let E=!1;return j().then(c=>{E||([go,yo].forEach(p=>{J.current?.contentWindow?.postMessage(c,p)}),window.setTimeout(()=>{E||[go,yo].forEach(p=>{J.current?.contentWindow?.postMessage(c,p)})},1e3))}),()=>{E=!0}},[x,F,s,n,Y]),Ie.useEffect(()=>{if(!s)return;const P=te.current;C(P?Math.random():0)},[s]);function ne(){te.current=!0,C(Math.random())}Ie.useEffect(()=>{const P=document.querySelector(".payment-modal-loader-container"),j=document.querySelector(".payment-modal-loader-logo");P.style.opacity="1",P.style.transform="translateX(-50%)",j.style.opacity="1",j.style.transform="scale(1)",j.style.filter="blur(0px)"},[]);const q=F===0||i,B=(Number(e)||0)>0;return Jt.jsxs("div",{className:Lo("payment-modal-wrapper",s?"open":"closed"),children:[Jt.jsx("div",{className:Lo("payment-modal-loader-container",L?"dark-mode":"light-mode",B?"has-amount":"no-amount"),children:Jt.jsx(JS,{})}),Jt.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:k||void 0,onLoad:ne,className:Lo(`payment-modal ${q?"invisible":"visible"}`),"data-id":e,ref:J},e)]})}const eT=Symbol(),Vc=Symbol(),Ys="a",u0="f",d0="p",l0="c",f0="t",Gc="h",Js="w",Hc="o",qc="k";let tT=(t,e)=>new Proxy(t,e);const Kc=Object.getPrototypeOf,Wc=new WeakMap,h0=t=>t&&(Wc.has(t)?Wc.get(t):Kc(t)===Object.prototype||Kc(t)===Array.prototype),bo=t=>typeof t=="object"&&t!==null,nT=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),rT=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(n=>{n.configurable=!0}),Object.create(Kc(t),e)},sT=(t,e)=>{const n={[u0]:e};let r=!1;const s=(a,d)=>{if(!r){let m=n[Ys].get(t);if(m||(m={},n[Ys].set(t,m)),a===Js)m[Js]=!0;else{let g=m[a];g||(g=new Set,m[a]=g),g.add(d)}}},i=()=>{r=!0,n[Ys].delete(t)},o={get(a,d){return d===Vc?t:(s(qc,d),p0(Reflect.get(a,d),n[Ys],n[l0],n[f0]))},has(a,d){return d===eT?(i(),!0):(s(Gc,d),Reflect.has(a,d))},getOwnPropertyDescriptor(a,d){return s(Hc,d),Reflect.getOwnPropertyDescriptor(a,d)},ownKeys(a){return s(Js),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,n]},Zc=t=>t[Vc]||t,p0=(t,e,n,r)=>{if(!h0(t))return t;let s=r&&r.get(t);if(!s){const d=Zc(t);nT(d)?s=[d,rT(d)]:s=[d],r?.set(t,s)}const[i,o]=s;let a=n&&n.get(i);return(!a||a[1][u0]!==!!o)&&(a=sT(i,!!o),a[1][d0]=tT(o||i,a[0]),n&&n.set(i,a)),a[1][Ys]=e,a[1][l0]=n,a[1][f0]=r,a[1][d0]},iT=(t,e)=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return n.length!==r.length||n.some((s,i)=>s!==r[i])},m0=(t,e,n,r,s=Object.is)=>{if(s(t,e))return!1;if(!bo(t)||!bo(e))return!0;const i=n.get(Zc(t));if(!i)return!0;if(r){if(r.get(t)===e)return!1;r.set(t,e)}let o=null;for(const a of i[Gc]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[Js]===!0){if(o=iT(t,e),o)return o}else for(const a of i[Hc]||[]){const d=!!Reflect.getOwnPropertyDescriptor(t,a),m=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=d!==m,o)return o}for(const a of i[qc]||[])if(o=m0(t[a],e[a],n,r,s),o)return o;if(o===null)throw new Error("invalid used");return o},oT=t=>h0(t)&&t[Vc]||null,g0=(t,e=!0)=>{Wc.set(t,e)},aT=(t,e,n)=>{const r=[],s=new WeakSet,i=(o,a)=>{var d,m,g;if(s.has(o))return;bo(o)&&s.add(o);const x=bo(o)&&e.get(Zc(o));if(x){if((d=x[Gc])===null||d===void 0||d.forEach(O=>{const N=`:has(${String(O)})`;r.push(a?[...a,N]:[N])}),x[Js]===!0){const O=":ownKeys";r.push(a?[...a,O]:[O])}else(m=x[Hc])===null||m===void 0||m.forEach(O=>{const N=`:hasOwn(${String(O)})`;r.push(a?[...a,N]:[N])});(g=x[qc])===null||g===void 0||g.forEach(O=>{"value"in(Object.getOwnPropertyDescriptor(o,O)||{})&&i(o[O],a?[...a,O]:[O])})}else a&&r.push(a)};return i(t),r},_o={},Yc=t=>typeof t=="object"&&t!==null,cT=t=>Yc(t)&&!Jc.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),y0=(t,e)=>{const n=b0.get(t);if(n?.[0]===e)return n[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return g0(r,!0),b0.set(t,[e,r]),Reflect.ownKeys(t).forEach(s=>{if(Object.getOwnPropertyDescriptor(r,s))return;const i=Reflect.get(t,s),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,s),a={value:i,enumerable:o,configurable:!0};if(Jc.has(i))g0(i,!1);else if(pr.has(i)){const[d,m]=pr.get(i);a.value=y0(d,m())}Object.defineProperty(r,s,a)}),Object.preventExtensions(r)},uT=(t,e,n,r)=>({deleteProperty(s,i){const o=Reflect.get(s,i);n(i);const a=Reflect.deleteProperty(s,i);return a&&r(["delete",[i],o]),a},set(s,i,o,a){const d=!t()&&Reflect.has(s,i),m=Reflect.get(s,i,a);if(d&&(_0(m,o)||wo.has(o)&&_0(m,wo.get(o))))return!0;n(i),Yc(o)&&(o=oT(o)||o);const g=!pr.has(o)&&lT(o)?w0(o):o;return e(i,g),Reflect.set(s,i,g,a),r(["set",[i],o,m]),!0}}),pr=new WeakMap,Jc=new WeakSet,b0=new WeakMap,Xc=[1],wo=new WeakMap;let _0=Object.is,dT=(t,e)=>new Proxy(t,e),lT=cT,fT=y0,hT=uT;function w0(t={}){if(!Yc(t))throw new Error("object required");const e=wo.get(t);if(e)return e;let n=Xc[0];const r=new Set,s=(k,K=++Xc[0])=>{n!==K&&(i=n=K,r.forEach(Y=>Y(k,K)))};let i=n;const o=(k=Xc[0])=>(i!==k&&(i=k,d.forEach(([K])=>{const Y=K[1](k);Y>n&&(n=Y)})),n),a=k=>(K,Y)=>{const V=[...K];V[1]=[k,...V[1]],s(V,Y)},d=new Map,m=(k,K)=>{const Y=!Jc.has(K)&&pr.get(K);if(Y){if((_o?"production":void 0)!=="production"&&d.has(k))throw new Error("prop listener already exists");if(r.size){const V=Y[2](a(k));d.set(k,[Y,V])}else d.set(k,[Y])}},g=k=>{var K;const Y=d.get(k);Y&&(d.delete(k),(K=Y[1])==null||K.call(Y))},x=k=>(r.add(k),r.size===1&&d.forEach(([Y,V],L)=>{if((_o?"production":void 0)!=="production"&&V)throw new Error("remove already exists");const z=Y[2](a(L));d.set(L,[Y,z])}),()=>{r.delete(k),r.size===0&&d.forEach(([Y,V],L)=>{V&&(V(),d.set(L,[Y]))})});let O=!0;const N=hT(()=>O,m,g,s),F=dT(t,N);wo.set(t,F);const C=[t,o,x];return pr.set(F,C),Reflect.ownKeys(t).forEach(k=>{const K=Object.getOwnPropertyDescriptor(t,k);"value"in K&&K.writable&&(F[k]=t[k])}),O=!1,F}function pT(t,e,n){const r=pr.get(t);(_o?"production":void 0)!=="production"&&!r&&console.warn("Please use proxy object");let s;const i=[],o=r[2];let a=!1;const m=o(g=>{i.push(g),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,m()}}function E0(t){const e=pr.get(t);(_o?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[n,r]=e;return fT(n,r())}const mT={},gT=(t,e)=>{const n=Ie.useRef(void 0);Ie.useEffect(()=>{n.current=aT(t,e)}),Ie.useDebugValue(n.current)},yT=new WeakMap;function bT(t,e){const r=Ie.useMemo(()=>t&&new WeakMap,[t]),s=Ie.useRef(void 0);let i=!0;const o=Ie.useSyncExternalStore(Ie.useCallback(d=>{const m=pT(t,d);return d(),m},[t,void 0]),()=>{const d=E0(t);try{if(!i&&s.current&&!m0(s.current,d,r,new WeakMap))return s.current}catch{}return d},()=>E0(t));i=!1,Ie.useLayoutEffect(()=>{s.current=o}),(mT?"production":void 0)!=="production"&&gT(o,r);const a=Ie.useMemo(()=>new WeakMap,[]);return p0(o,r,a,yT)}const Wn=w0({data:null,isPending:!1,error:null});function _T({session_url:t,onCancel:e,onSuccess:n,farcasterMiniApp:r,wagmiConfig:s}){const i=bT(Wn),[o,a]=Ie.useState(!1),[d,m]=Ie.useState(Date.now()),g=i?.data?.sessionToken,x=i?.data?.amount;function O(){g||window.setTimeout(()=>{g&&a(!0)},200),a(!0)}function N(){a(!1)}const F=()=>{const C=Date.now();Wn.isPending=!0,Wn.error=null,Wn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(k=>k.json()).then(k=>{C<d||(Wn.data=k,Wn.isPending=!1,m(C))}).catch(k=>{C<d||(Wn.error=k?.toString(),Wn.isPending=!1,m(C),setInterval(F,5e3))})};return Ie.useEffect(()=>{F()},[t]),{sessionToken:g,amount:x,isOpen:o,session_url:t,open:O,close:N,isPending:i.isPending,error:i.error,refetch:F,onSuccess:n,onCancel:e,farcasterMiniApp:r,wagmiConfig:s}}function wT({sessionToken:t,amount:e,onCancel:n,onSuccess:r,farcasterMiniApp:s,wagmiConfig:i}){const[o,a]=Ie.useState(!1),[d,m]=Ie.useState(t),[g,x]=Ie.useState(e);function O({sessionToken:C,amount:k}){m(C),x(k)}Ie.useEffect(()=>{m(t)},[t]);function N(){d||window.setTimeout(()=>{d&&a(!0)},200),a(!0)}function F(){a(!1)}return{sessionToken:d,updateSession:O,amount:g,isOpen:o,open:N,close:F,onSuccess:r,onCancel:n,farcasterMiniApp:s,wagmiConfig:i}}Rt.AmountSymbols=X,Rt.Chainrails=Me,Rt.Chains=Bu,Rt.PaymentModal=QS,Rt.chains=Bu,Rt.crapi=Jp,Rt.tokens=X,Rt.usePaymentModal=wT,Rt.usePaymentSession=_T,Object.defineProperty(Rt,Symbol.toStringTag,{value:"Module"})}));