@chainrails/react 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PaymentModal/index.d.ts.map +1 -1
- package/dist/chainrails-sdk.es.js +6145 -5898
- package/dist/chainrails-sdk.es.mjs +6145 -5898
- package/dist/chainrails-sdk.umd.js +29 -38
- package/dist/hooks/usePaymentModal.d.ts +10 -2
- package/dist/hooks/usePaymentModal.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/sw.js +176 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/serviceWorker.d.ts +36 -0
- package/dist/utils/serviceWorker.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,42 +1,33 @@
|
|
|
1
|
-
(function(
|
|
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=
|
|
5
|
-
`),{metaMessages:[`Params: (${
|
|
6
|
-
`),{name:"AbiEncodingArrayLengthMismatchError"})}}class
|
|
7
|
-
`),{name:"AbiEncodingLengthMismatchError"})}}class
|
|
8
|
-
`),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class
|
|
9
|
-
`),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class
|
|
10
|
-
`),{docsPath:n,name:"InvalidAbiEncodingType"})}}class
|
|
11
|
-
`),{docsPath:n,name:"InvalidAbiDecodingType"})}}class
|
|
12
|
-
`),{name:"InvalidArrayError"})}}class
|
|
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,M]=Rr(t,e,{staticPosition:d});x+=M,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
|
|
15
|
-
`)}class
|
|
16
|
-
`):`The contract function "${r}" reverted.`,{cause:i,metaMessages:
|
|
17
|
-
`)})}}Object.defineProperty(
|
|
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(
|
|
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(
|
|
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,M=un(N,17)^un(N,19)^N>>>10;Un[x]=M+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,M=(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+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(){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: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 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,C=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,C,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:M,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&M,te=O&F^~O&k,ne=Nm(Y,z,te,Ny[V],Fn[V]),q=Cm(ne,K,L,J,Iy[V],Dn[V]),C=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=M|0,Y=k|0,M=N|0,k=F|0,N=x|0,F=O|0,{h:x,l:O}=bn(m|0,g|0,q|0,C|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const h=Sm(C,j,c);r=Tm(h,q,P,E),s=h|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:M,l:k}=bn(this.Gh|0,this.Gl|0,M|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,M,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:M,to:k,type:K,value:Y,...V}=e,L=await(async()=>{if(!n||!M||typeof F<"u")return F;const ne=wn(n),q=i?i.id:await xt(t,Sa,"getChainId")({});return await M.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]}),C=(i?.formatters?.transaction?.format||tl)(ne.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 h=await xt(t,Ts,"getBlock")({});return i.fees.baseFeeMultiplier({block:h,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=h=>h*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:ne.raw,transaction:{from:te.from,...C}}}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:C,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 C<"u"?{maxFeePerBlobGas:C}:{},...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: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 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 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?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:M,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 C=t.chain?.formatters?.transactionRequest?.format,j=(C||va)({...Ea(J,{format:C}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:N,gasPrice:M,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,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%_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 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 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 M))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),C=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:C}}),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 M{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 M)throw new Error("projective point not allowed");const te=ne=>n.eql(ne,n.ZERO);return te(z)&&te(J)?M.ZERO:new M(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(M.fromAffine)}static fromHex(L){const z=M.fromAffine(i(Je("pointHex",L)));return z.assertValidity(),z}static fromPrivateKey(L){return M.BASE.multiply(x(L))}static msm(L,z){return Ml(M,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:C}=L,P=n.eql(n.mul(z,C),n.mul(ne,te)),j=n.eql(n.mul(J,C),n.mul(q,te));return P&&j}negate(){return new M(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 C=n.ZERO,P=n.ZERO,j=n.ZERO,E=n.mul(te,te),c=n.mul(ne,ne),h=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),C=n.mul(L,j),P=n.mul(J,h),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),j=n.mul(J,j),h=n.mul(L,h),y=n.sub(E,h),y=n.mul(L,y),y=n.add(y,j),j=n.add(E,E),E=n.add(j,E),E=n.add(E,h),E=n.mul(E,y),P=n.add(P,E),h=n.mul(ne,q),h=n.add(h,h),E=n.mul(h,y),C=n.sub(C,E),j=n.mul(h,c),j=n.add(j,j),j=n.add(j,j),new M(C,P,j)}add(L){O(L);const{px:z,py:J,pz:te}=this,{px:ne,py:q,pz:C}=L;let P=n.ZERO,j=n.ZERO,E=n.ZERO;const c=e.a,h=n.mul(e.b,Ua);let y=n.mul(z,ne),A=n.mul(J,q),v=n.mul(te,C),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,C);return I=n.mul(I,_),_=n.add(y,v),I=n.sub(I,_),_=n.add(J,te),P=n.add(q,C),_=n.mul(_,P),P=n.add(A,v),_=n.sub(_,P),E=n.mul(c,I),P=n.mul(h,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(h,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 M(P,j,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:z,n:J}=e;nn("scalar",L,Rn,J);const te=M.ZERO;if(L===Rn)return te;if(this.is0()||L===_t)return this;if(!z||Y.hasPrecomputes(this))return Y.wNAFCachedUnsafe(this,L,M.normalizeZ);let{k1neg:ne,k1:q,k2neg:C,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()),C&&(E=E.negate()),E=new M(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:C,k2neg:P,k2:j}=z.splitScalar(L);let{p:E,f:c}=this.wNAF(C),{p:h,f:y}=this.wNAF(j);E=Y.constTimeNegate(q,E),h=Y.constTimeNegate(P,h),h=new M(n.mul(h.px,z.beta),h.py,h.pz),te=E.add(h),ne=c.add(y)}else{const{p:q,f:C}=this.wNAF(L);te=q,ne=C}return M.normalizeZ([te,ne])[0]}multiplyAndAddUnsafe(L,z,J){const te=M.BASE,ne=(C,P)=>P===Rn||P===_t||!C.equals(te)?C.multiplyUnsafe(P):C.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(M,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(M,this):this.multiplyUnsafe(e.h)}toRawBytes(L=!0){return Ln("isCompressed",L),this.assertValidity(),s(M,this,L)}toHex(L=!0){return Ln("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=Cl(M,k?Math.ceil(K/2):K);return{CURVE:e,ProjectivePoint:M,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(h){return je(h,r)}function m(h){return Oa(h,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:x,weierstrassEquation:O,isWithinCurveOrder:N}=u1({...e,toBytes(h,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(h){const y=h.length,A=h[0],v=h.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(h){const y=r>>_t;return h>y}function M(h){return F(h)?d(-h):h}const k=(h,y,A)=>tr(h.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(h){try{return x(h),!0}catch{return!1}},normPrivateKeyToScalar:x,randomPrivateKey:()=>{const h=Sl(e.n);return r1(e.randomBytes(h),e.n)},precompute(h=8,y=g.BASE){return y._setWindowSize(h),y.multiply(BigInt(3)),y}};function V(h,y=!0){return g.fromPrivateKey(h).toRawBytes(y)}function L(h){if(typeof h=="bigint")return!1;if(h instanceof g)return!0;const A=Je("key",h).length,v=n.BYTES,R=v+1,I=2*v+1;if(!(e.allowedPrivateKeyLengths||s===R))return A===R||A===I}function z(h,y,A=!0){if(L(h)===!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(h)).toRawBytes(A)}const J=e.bits2int||function(h){if(h.length>8192)throw new Error("input is too large");const y=tr(h),A=h.length*8-i;return A>0?y>>BigInt(A):y},te=e.bits2int_modN||function(h){return d(J(h))},ne=yi(i);function q(h){return nn("num < 2^"+i,h,Rn,ne),xs(h,s)}function C(h,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),h=Je("msgHash",h),Bl(A),_&&(h=Je("prehashed msgHash",v(h)));const l=te(h),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=M(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(h,y,A=P){const{seed:v,k2sig:R}=C(h,y,A),I=e;return ty(I.hash.outputLen,I.nByteLength,I.hmac)(v,R)}g.BASE._setWindowSize(8);function c(h,y,A,v=j){const R=h;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,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,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
|
|
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: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: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 M=n?n+m:m;if(!this._events[M])return!1;var k=this._events[M],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 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})(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 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)),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,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,V=0,L=M-k;V<L;V+=Y)K.push(x(N,V,V+Y>L?L:V+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 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,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}/*!
|
|
24
|
-
* The buffer module from node.js, for the browser.
|
|
25
|
-
*
|
|
26
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
27
|
-
* @license MIT
|
|
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,p){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,p)}a.poolSize=8192;function d(b,f,p){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,p);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,p);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,p);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,p){return d(b,f,p)},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,p){return m(b),b<=0?o(b):f!==void 0?typeof p=="string"?o(b).fill(f,p):o(b).fill(f):o(b)}a.alloc=function(b,f,p){return g(b,f,p)};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 p=V(b,f)|0;let S=o(p);const U=S.write(b,f);return U!==p&&(S=S.slice(0,U)),S}function N(b){const f=b.length<0?0:K(b.length)|0,p=o(f);for(let S=0;S<f;S+=1)p[S]=b[S]&255;return p}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,p){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(p||0))throw new RangeError('"length" is outside of buffer bounds');let S;return f===void 0&&p===void 0?S=new Uint8Array(b):p===void 0?S=new Uint8Array(b,f):S=new Uint8Array(b,f,p),Object.setPrototypeOf(S,a.prototype),S}function k(b){if(a.isBuffer(b)){const f=K(b.length)|0,p=o(f);return p.length===0||b.copy(p,0,0,f),p}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,p){if(Yt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Yt(p,Uint8Array)&&(p=a.from(p,p.offset,p.byteLength)),!a.isBuffer(f)||!a.isBuffer(p))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(f===p)return 0;let S=f.length,U=p.length;for(let $=0,Z=Math.min(S,U);$<Z;++$)if(f[$]!==p[$]){S=f[$],U=p[$];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,p){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(p===void 0)for(p=0,S=0;S<f.length;++S)p+=f[S].length;const U=a.allocUnsafe(p);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 p=b.length,S=arguments.length>2&&arguments[2]===!0;if(!S&&p===0)return 0;let U=!1;for(;;)switch(f){case"ascii":case"latin1":case"binary":return p;case"utf8":case"utf-8":return Le(b).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p*2;case"hex":return p>>>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,p){let S=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((p===void 0||p>this.length)&&(p=this.length),p<=0)||(p>>>=0,f>>>=0,p<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return R(this,f,p);case"utf8":case"utf-8":return c(this,f,p);case"ascii":return A(this,f,p);case"latin1":case"binary":return v(this,f,p);case"base64":return E(this,f,p);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,f,p);default:if(S)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),S=!0}}a.prototype._isBuffer=!0;function z(b,f,p){const S=b[f];b[f]=b[p],b[p]=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 p=0;p<f;p+=2)z(this,p,p+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 p=0;p<f;p+=4)z(this,p,p+3),z(this,p+1,p+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 p=0;p<f;p+=8)z(this,p,p+7),z(this,p+1,p+6),z(this,p+2,p+5),z(this,p+3,p+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 p=t.INSPECT_MAX_BYTES;return f=this.toString("hex",0,p).replace(/(.{2})/g,"$1 ").trim(),this.length>p&&(f+=" ... "),"<Buffer "+f+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(f,p,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(p===void 0&&(p=0),S===void 0&&(S=f?f.length:0),U===void 0&&(U=0),$===void 0&&($=this.length),p<0||S>f.length||U<0||$>this.length)throw new RangeError("out of range index");if(U>=$&&p>=S)return 0;if(U>=$)return-1;if(p>=S)return 1;if(p>>>=0,S>>>=0,U>>>=0,$>>>=0,this===f)return 0;let Z=$-U,Re=S-p;const _e=Math.min(Z,Re),ge=this.slice(U,$),$e=f.slice(p,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,p,S,U){if(b.length===0)return-1;if(typeof p=="string"?(S=p,p=0):p>2147483647?p=2147483647:p<-2147483648&&(p=-2147483648),p=+p,Ge(p)&&(p=U?0:b.length-1),p<0&&(p=b.length+p),p>=b.length){if(U)return-1;p=b.length-1}else if(p<0)if(U)p=0;else return-1;if(typeof f=="string"&&(f=a.from(f,S)),a.isBuffer(f))return f.length===0?-1:te(b,f,p,S,U);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?U?Uint8Array.prototype.indexOf.call(b,f,p):Uint8Array.prototype.lastIndexOf.call(b,f,p):te(b,[f],p,S,U);throw new TypeError("val must be string, number or Buffer")}function te(b,f,p,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,p/=2}function _e($e,he){return $===1?$e[he]:$e.readUInt16BE(he*$)}let ge;if(U){let $e=-1;for(ge=p;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(p+Re>Z&&(p=Z-Re),ge=p;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,p,S){return this.indexOf(f,p,S)!==-1},a.prototype.indexOf=function(f,p,S){return J(this,f,p,S,!0)},a.prototype.lastIndexOf=function(f,p,S){return J(this,f,p,S,!1)};function ne(b,f,p,S){p=Number(p)||0;const U=b.length-p;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[p+Z]=Re}return Z}function q(b,f,p,S){return Pe(Le(f,b.length-p),b,p,S)}function C(b,f,p,S){return Pe(Ve(f),b,p,S)}function P(b,f,p,S){return Pe(Fe(f),b,p,S)}function j(b,f,p,S){return Pe(Zr(f,b.length-p),b,p,S)}a.prototype.write=function(f,p,S,U){if(p===void 0)U="utf8",S=this.length,p=0;else if(S===void 0&&typeof p=="string")U=p,S=this.length,p=0;else if(isFinite(p))p=p>>>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-p;if((S===void 0||S>$)&&(S=$),f.length>0&&(S<0||p<0)||p>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,p,S);case"utf8":case"utf-8":return q(this,f,p,S);case"ascii":case"latin1":case"binary":return C(this,f,p,S);case"base64":return P(this,f,p,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,f,p,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,p){return f===0&&p===b.length?e.fromByteArray(b):e.fromByteArray(b.slice(f,p))}function c(b,f,p){p=Math.min(b.length,p);const S=[];let U=f;for(;U<p;){const $=b[U];let Z=null,Re=$>239?4:$>223?3:$>191?2:1;if(U+Re<=p){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 h=4096;function y(b){const f=b.length;if(f<=h)return String.fromCharCode.apply(String,b);let p="",S=0;for(;S<f;)p+=String.fromCharCode.apply(String,b.slice(S,S+=h));return p}function A(b,f,p){let S="";p=Math.min(b.length,p);for(let U=f;U<p;++U)S+=String.fromCharCode(b[U]&127);return S}function v(b,f,p){let S="";p=Math.min(b.length,p);for(let U=f;U<p;++U)S+=String.fromCharCode(b[U]);return S}function R(b,f,p){const S=b.length;(!f||f<0)&&(f=0),(!p||p<0||p>S)&&(p=S);let U="";for(let $=f;$<p;++$)U+=Ze[b[$]];return U}function I(b,f,p){const S=b.slice(f,p);let U="";for(let $=0;$<S.length-1;$+=2)U+=String.fromCharCode(S[$]+S[$+1]*256);return U}a.prototype.slice=function(f,p){const S=this.length;f=~~f,p=p===void 0?S:~~p,f<0?(f+=S,f<0&&(f=0)):f>S&&(f=S),p<0?(p+=S,p<0&&(p=0)):p>S&&(p=S),p<f&&(p=f);const U=this.subarray(f,p);return Object.setPrototypeOf(U,a.prototype),U};function _(b,f,p){if(b%1!==0||b<0)throw new RangeError("offset is not uint");if(b+f>p)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(f,p,S){f=f>>>0,p=p>>>0,S||_(f,p,this.length);let U=this[f],$=1,Z=0;for(;++Z<p&&($*=256);)U+=this[f+Z]*$;return U},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,p,S){f=f>>>0,p=p>>>0,S||_(f,p,this.length);let U=this[f+--p],$=1;for(;p>0&&($*=256);)U+=this[f+--p]*$;return U},a.prototype.readUint8=a.prototype.readUInt8=function(f,p){return f=f>>>0,p||_(f,1,this.length),this[f]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(f,p){return f=f>>>0,p||_(f,2,this.length),this[f]|this[f+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(f,p){return f=f>>>0,p||_(f,2,this.length),this[f]<<8|this[f+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(f,p){return f=f>>>0,p||_(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,p){return f=f>>>0,p||_(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 p=this[f],S=this[f+7];(p===void 0||S===void 0)&&ve(f,this.length-8);const U=p+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 p=this[f],S=this[f+7];(p===void 0||S===void 0)&&ve(f,this.length-8);const U=p*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,p,S){f=f>>>0,p=p>>>0,S||_(f,p,this.length);let U=this[f],$=1,Z=0;for(;++Z<p&&($*=256);)U+=this[f+Z]*$;return $*=128,U>=$&&(U-=Math.pow(2,8*p)),U},a.prototype.readIntBE=function(f,p,S){f=f>>>0,p=p>>>0,S||_(f,p,this.length);let U=p,$=1,Z=this[f+--U];for(;U>0&&($*=256);)Z+=this[f+--U]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*p)),Z},a.prototype.readInt8=function(f,p){return f=f>>>0,p||_(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,p){f=f>>>0,p||_(f,2,this.length);const S=this[f]|this[f+1]<<8;return S&32768?S|4294901760:S},a.prototype.readInt16BE=function(f,p){f=f>>>0,p||_(f,2,this.length);const S=this[f+1]|this[f]<<8;return S&32768?S|4294901760:S},a.prototype.readInt32LE=function(f,p){return f=f>>>0,p||_(f,4,this.length),this[f]|this[f+1]<<8|this[f+2]<<16|this[f+3]<<24},a.prototype.readInt32BE=function(f,p){return f=f>>>0,p||_(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 p=this[f],S=this[f+7];(p===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(p+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 p=this[f],S=this[f+7];(p===void 0||S===void 0)&&ve(f,this.length-8);const U=(p<<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,p){return f=f>>>0,p||_(f,4,this.length),n.read(this,f,!0,23,4)},a.prototype.readFloatBE=function(f,p){return f=f>>>0,p||_(f,4,this.length),n.read(this,f,!1,23,4)},a.prototype.readDoubleLE=function(f,p){return f=f>>>0,p||_(f,8,this.length),n.read(this,f,!0,52,8)},a.prototype.readDoubleBE=function(f,p){return f=f>>>0,p||_(f,8,this.length),n.read(this,f,!1,52,8)};function u(b,f,p,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(p+S>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,p,S,U){if(f=+f,p=p>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,p,S,Re,0)}let $=1,Z=0;for(this[p]=f&255;++Z<S&&($*=256);)this[p+Z]=f/$&255;return p+S},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,p,S,U){if(f=+f,p=p>>>0,S=S>>>0,!U){const Re=Math.pow(2,8*S)-1;u(this,f,p,S,Re,0)}let $=S-1,Z=1;for(this[p+$]=f&255;--$>=0&&(Z*=256);)this[p+$]=f/Z&255;return p+S},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,1,255,0),this[p]=f&255,p+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,2,65535,0),this[p]=f&255,this[p+1]=f>>>8,p+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,2,65535,0),this[p]=f>>>8,this[p+1]=f&255,p+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,4,4294967295,0),this[p+3]=f>>>24,this[p+2]=f>>>16,this[p+1]=f>>>8,this[p]=f&255,p+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,4,4294967295,0),this[p]=f>>>24,this[p+1]=f>>>16,this[p+2]=f>>>8,this[p+3]=f&255,p+4};function l(b,f,p,S,U){we(f,S,U,b,p,7);let $=Number(f&BigInt(4294967295));b[p++]=$,$=$>>8,b[p++]=$,$=$>>8,b[p++]=$,$=$>>8,b[p++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[p++]=Z,Z=Z>>8,b[p++]=Z,Z=Z>>8,b[p++]=Z,Z=Z>>8,b[p++]=Z,p}function w(b,f,p,S,U){we(f,S,U,b,p,7);let $=Number(f&BigInt(4294967295));b[p+7]=$,$=$>>8,b[p+6]=$,$=$>>8,b[p+5]=$,$=$>>8,b[p+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[p+3]=Z,Z=Z>>8,b[p+2]=Z,Z=Z>>8,b[p+1]=Z,Z=Z>>8,b[p]=Z,p+8}a.prototype.writeBigUInt64LE=an(function(f,p=0){return l(this,f,p,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=an(function(f,p=0){return w(this,f,p,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,p,S,U){if(f=+f,p=p>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,p,S,_e-1,-_e)}let $=0,Z=1,Re=0;for(this[p]=f&255;++$<S&&(Z*=256);)f<0&&Re===0&&this[p+$-1]!==0&&(Re=1),this[p+$]=(f/Z>>0)-Re&255;return p+S},a.prototype.writeIntBE=function(f,p,S,U){if(f=+f,p=p>>>0,!U){const _e=Math.pow(2,8*S-1);u(this,f,p,S,_e-1,-_e)}let $=S-1,Z=1,Re=0;for(this[p+$]=f&255;--$>=0&&(Z*=256);)f<0&&Re===0&&this[p+$+1]!==0&&(Re=1),this[p+$]=(f/Z>>0)-Re&255;return p+S},a.prototype.writeInt8=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,1,127,-128),f<0&&(f=255+f+1),this[p]=f&255,p+1},a.prototype.writeInt16LE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,2,32767,-32768),this[p]=f&255,this[p+1]=f>>>8,p+2},a.prototype.writeInt16BE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,2,32767,-32768),this[p]=f>>>8,this[p+1]=f&255,p+2},a.prototype.writeInt32LE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,4,2147483647,-2147483648),this[p]=f&255,this[p+1]=f>>>8,this[p+2]=f>>>16,this[p+3]=f>>>24,p+4},a.prototype.writeInt32BE=function(f,p,S){return f=+f,p=p>>>0,S||u(this,f,p,4,2147483647,-2147483648),f<0&&(f=4294967295+f+1),this[p]=f>>>24,this[p+1]=f>>>16,this[p+2]=f>>>8,this[p+3]=f&255,p+4},a.prototype.writeBigInt64LE=an(function(f,p=0){return l(this,f,p,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=an(function(f,p=0){return w(this,f,p,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function T(b,f,p,S,U,$){if(p+S>b.length)throw new RangeError("Index out of range");if(p<0)throw new RangeError("Index out of range")}function D(b,f,p,S,U){return f=+f,p=p>>>0,U||T(b,f,p,4),n.write(b,f,p,S,23,4),p+4}a.prototype.writeFloatLE=function(f,p,S){return D(this,f,p,!0,S)},a.prototype.writeFloatBE=function(f,p,S){return D(this,f,p,!1,S)};function W(b,f,p,S,U){return f=+f,p=p>>>0,U||T(b,f,p,8),n.write(b,f,p,S,52,8),p+8}a.prototype.writeDoubleLE=function(f,p,S){return W(this,f,p,!0,S)},a.prototype.writeDoubleBE=function(f,p,S){return W(this,f,p,!1,S)},a.prototype.copy=function(f,p,S,U){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(S||(S=0),!U&&U!==0&&(U=this.length),p>=f.length&&(p=f.length),p||(p=0),U>0&&U<S&&(U=S),U===S||f.length===0||this.length===0)return 0;if(p<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-p<U-S&&(U=f.length-p+S);const $=U-S;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(p,S,U):Uint8Array.prototype.set.call(f,this.subarray(S,U),p),$},a.prototype.fill=function(f,p,S,U){if(typeof f=="string"){if(typeof p=="string"?(U=p,p=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(p<0||this.length<p||this.length<S)throw new RangeError("Out of range index");if(S<=p)return this;p=p>>>0,S=S===void 0?this.length:S>>>0,f||(f=0);let $;if(typeof f=="number")for($=p;$<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-p;++$)this[$+p]=Z[$%Re]}return this};const re={};function oe(b,f,p){re[b]=class extends p{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,p){let S=`The value of "${b}" is out of range.`,U=p;return Number.isInteger(p)&&Math.abs(p)>2**32?U=Ce(String(p)):typeof p=="bigint"&&(U=String(p),(p>BigInt(2)**BigInt(32)||p<-(BigInt(2)**BigInt(32)))&&(U=Ce(U)),U+="n"),S+=` It must be ${f}. Received ${U}`,S},RangeError);function Ce(b){let f="",p=b.length;const S=b[0]==="-"?1:0;for(;p>=S+4;p-=3)f=`_${b.slice(p-3,p)}${f}`;return`${b.slice(0,p)}${f}`}function Ee(b,f,p){De(f,"offset"),(b[f]===void 0||b[f+p]===void 0)&&ve(f,b.length-(p+1))}function we(b,f,p,S,U,$){if(b>p||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,p){throw Math.floor(b)!==b?(De(b,p),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 p;const S=b.length;let U=null;const $=[];for(let Z=0;Z<S;++Z){if(p=b.charCodeAt(Z),p>55295&&p<57344){if(!U){if(p>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===S){(f-=3)>-1&&$.push(239,191,189);continue}U=p;continue}if(p<56320){(f-=3)>-1&&$.push(239,191,189),U=p;continue}p=(U-55296<<10|p-56320)+65536}else U&&(f-=3)>-1&&$.push(239,191,189);if(U=null,p<128){if((f-=1)<0)break;$.push(p)}else if(p<2048){if((f-=2)<0)break;$.push(p>>6|192,p&63|128)}else if(p<65536){if((f-=3)<0)break;$.push(p>>12|224,p>>6&63|128,p&63|128)}else if(p<1114112){if((f-=4)<0)break;$.push(p>>18|240,p>>12&63|128,p>>6&63|128,p&63|128)}else throw new Error("Invalid code point")}return $}function Ve(b){const f=[];for(let p=0;p<b.length;++p)f.push(b.charCodeAt(p)&255);return f}function Zr(b,f){let p,S,U;const $=[];for(let Z=0;Z<b.length&&!((f-=2)<0);++Z)p=b.charCodeAt(Z),S=p>>8,U=p%256,$.push(U),$.push(S);return $}function Fe(b){return e.toByteArray(mn(b))}function Pe(b,f,p,S){let U;for(U=0;U<S&&!(U+p>=f.length||U>=b.length);++U)f[U+p]=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 p=0;p<16;++p){const S=p*16;for(let U=0;U<16;++U)f[S+U]=b[p]+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),M=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}=C(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 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=q(_);return{head:_,prefix:u,scalar:l}}function P(v){const{head:R,prefix:I,scalar:_}=C(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(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=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 h=Zb;function y(v,R,I,_=h){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,M=qe(F,s,i)*N%i,k=qe(M,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 h=function(){};h.prototype=c.prototype,E.prototype=new h,E.prototype.constructor=E}function i(E,c,h){if(i.isBN(E))return E;this.negative=0,this.words=null,this.length=0,this.red=null,E!==null&&((c==="le"||c==="be")&&(h=c,c=10),this._init(E||0,c||10,h||"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,h){return c.cmp(h)>0?c:h},i.min=function(c,h){return c.cmp(h)<0?c:h},i.prototype._init=function(c,h,y){if(typeof c=="number")return this._initNumber(c,h,y);if(typeof c=="object")return this._initArray(c,h,y);h==="hex"&&(h=16),r(h===(h|0)&&h>=2&&h<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(h===16?this._parseHex(c,A,y):(this._parseBase(c,h,A),y==="le"&&this._initArray(this.toArray(),h,y)))},i.prototype._initNumber=function(c,h,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(),h,y)},i.prototype._initArray=function(c,h,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 h=E.charCodeAt(c);if(h>=48&&h<=57)return h-48;if(h>=65&&h<=70)return h-55;if(h>=97&&h<=102)return h-87;r(!1,"Invalid character in "+E)}function d(E,c,h){var y=a(E,h);return h-1>=c&&(y|=a(E,h-1)<<4),y}i.prototype._parseHex=function(c,h,y){this.length=Math.ceil((c.length-h)/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>=h;A-=2)I=d(c,h,A)<<v,this.words[R]|=I&67108863,v>=18?(v-=18,R+=1,this.words[R]|=I>>>26):v+=8;else{var _=c.length-h;for(A=_%2===0?h+1:h;A<c.length;A+=2)I=d(c,h,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,h,y){for(var A=0,v=0,R=Math.min(E.length,h),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,h,y){this.words=[0],this.length=1;for(var A=0,v=1;v<=67108863;v*=h)A++;A--,v=v/h|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,h),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,h),l=0;l<I;l++)w*=h;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 h=0;h<this.length;h++)c.words[h]=this.words[h];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,h){c=c||10,h=h|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%h!==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%h!==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,h){return this.toArrayLike(o,c,h)}),i.prototype.toArray=function(c,h){return this.toArrayLike(Array,c,h)};var M=function(c,h){return c.allocUnsafe?c.allocUnsafe(h):new c(h)};i.prototype.toArrayLike=function(c,h,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=h==="le"?"LE":"BE";return this["_toArrayLike"+I](R,A),R},i.prototype._toArrayLikeLE=function(c,h){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,h){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 h=c,y=0;return h>=4096&&(y+=13,h>>>=13),h>=64&&(y+=7,h>>>=7),h>=8&&(y+=4,h>>>=4),h>=2&&(y+=2,h>>>=2),y+h},i.prototype._zeroBits=function(c){if(c===0)return 26;var h=c,y=0;return(h&8191)===0&&(y+=13,h>>>=13),(h&127)===0&&(y+=7,h>>>=7),(h&15)===0&&(y+=4,h>>>=4),(h&3)===0&&(y+=2,h>>>=2),(h&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],h=this._countBits(c);return(this.length-1)*26+h};function k(E){for(var c=new Array(E.bitLength()),h=0;h<c.length;h++){var y=h/26|0,A=h%26;c[h]=E.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,h=0;h<this.length;h++){var y=this._zeroBits(this.words[h]);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 h=0;h<c.length;h++)this.words[h]=this.words[h]|c.words[h];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 h;this.length>c.length?h=c:h=this;for(var y=0;y<h.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=h.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 h,y;this.length>c.length?(h=this,y=c):(h=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=h.words[A]^y.words[A];if(this!==h)for(;A<h.length;A++)this.words[A]=h.words[A];return this.length=h.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 h=Math.ceil(c/26)|0,y=c%26;this._expand(h),y>0&&h--;for(var A=0;A<h;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,h){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),h?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var h;if(this.negative!==0&&c.negative===0)return this.negative=0,h=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,h=this.isub(c),c.negative=1,h._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++)h=(y.words[R]|0)+(A.words[R]|0)+v,this.words[R]=h&67108863,v=h>>>26;for(;v!==0&&R<y.length;R++)h=(y.words[R]|0)+v,this.words[R]=h&67108863,v=h>>>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 h;return c.negative!==0&&this.negative===0?(c.negative=0,h=this.sub(c),c.negative^=1,h):c.negative===0&&this.negative!==0?(this.negative=0,h=c.sub(this),this.negative=1,h):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 h=this.iadd(c);return c.negative=1,h._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++)h=(A.words[I]|0)-(v.words[I]|0)+R,R=h>>26,this.words[I]=h&67108863;for(;R!==0&&I<A.length;I++)h=(A.words[I]|0)+R,R=h>>26,this.words[I]=h&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,h){h.negative=c.negative^E.negative;var y=E.length+c.length|0;h.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;h.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}h.words[u]=w|0,_=l|0}return _!==0?h.words[u]=_|0:h.length--,h._strip()}var Y=function(c,h,y){var A=c.words,v=h.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,p=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^h.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(p,_e),u=Math.imul(p,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(p,he)|0,u=u+Math.imul(p,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(p,tt)|0,u=u+Math.imul(p,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(p,rt)|0,u=u+Math.imul(p,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(p,it)|0,u=u+Math.imul(p,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(p,at)|0,u=u+Math.imul(p,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(p,ut)|0,u=u+Math.imul(p,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(p,lt)|0,u=u+Math.imul(p,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(p,ht)|0,u=u+Math.imul(p,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(p,mt)|0,u=u+Math.imul(p,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,h){h.negative=c.negative^E.negative,h.length=E.length+c.length;for(var y=0,A=0,v=0;v<h.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}h.words[v]=I,y=R,R=A}return y!==0?h.words[v]=y:h.length--,h._strip()}function L(E,c,h){return V(E,c,h)}i.prototype.mulTo=function(c,h){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=Y(this,c,h):A<63?y=K(this,c,h):A<1024?y=V(this,c,h):y=L(this,c,h),y},i.prototype.mul=function(c){var h=new i(null);return h.words=new Array(this.length+c.length),this.mulTo(c,h)},i.prototype.mulf=function(c){var h=new i(null);return h.words=new Array(this.length+c.length),L(this,c,h)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var h=c<0;h&&(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,h?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 h=k(c);if(h.length===0)return new i(1);for(var y=this,A=0;A<h.length&&h[A]===0;A++,y=y.sqr());if(++A<h.length)for(var v=y.sqr();A<h.length;A++,v=v.sqr())h[A]!==0&&(y=y.mul(v));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var h=c%26,y=(c-h)/26,A=67108863>>>26-h<<26-h,v;if(h!==0){var R=0;for(v=0;v<this.length;v++){var I=this.words[v]&A,_=(this.words[v]|0)-I<<h;this.words[v]=_|R,R=I>>>26-h}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,h,y){r(typeof c=="number"&&c>=0);var A;h?A=(h-h%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,h,y){return r(this.negative===0),this.iushrn(c,h,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 h=c%26,y=(c-h)/26,A=1<<h;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 h=c%26,y=(c-h)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(h!==0&&y++,this.length=Math.min(y,this.length),h!==0){var A=67108863^67108863>>>h<<h;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 h=0;h<this.length&&this.words[h]>=67108864;h++)this.words[h]-=67108864,h===this.length-1?this.words[h+1]=1:this.words[h+1]++;return this.length=Math.max(this.length,h+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 h=0;h<this.length&&this.words[h]<0;h++)this.words[h]+=67108864,this.words[h+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,h,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)*h;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,h){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(h!=="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(),h!=="div"&&y!==0&&A.iushrn(y),{div:u||null,mod:A}},i.prototype.divmod=function(c,h,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,h),h!=="mod"&&(A=R.div.neg()),h!=="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(),h),h!=="mod"&&(A=R.div.neg()),{div:A,mod:R.mod}):(this.negative&c.negative)!==0?(R=this.neg().divmod(c.neg(),h),h!=="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?h==="div"?{div:this.divn(c.words[0]),mod:null}:h==="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,h)},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 h=this.divmod(c);if(h.mod.isZero())return h.div;var y=h.div.negative!==0?h.mod.isub(c):h.mod,A=c.ushrn(1),v=c.andln(1),R=y.cmp(A);return R<0||v===1&&R===0?h.div:h.div.negative!==0?h.div.isubn(1):h.div.iaddn(1)},i.prototype.modrn=function(c){var h=c<0;h&&(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 h?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var h=c<0;h&&(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(),h?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 h=this,y=c.clone();h.negative!==0?h=h.umod(c):h=h.clone();for(var A=new i(1),v=new i(0),R=new i(0),I=new i(1),_=0;h.isEven()&&y.isEven();)h.iushrn(1),y.iushrn(1),++_;for(var u=y.clone(),l=h.clone();!h.isZero();){for(var w=0,T=1;(h.words[0]&T)===0&&w<26;++w,T<<=1);if(w>0)for(h.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);h.cmp(y)>=0?(h.isub(y),A.isub(R),v.isub(I)):(y.isub(h),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 h=this,y=c.clone();h.negative!==0?h=h.umod(c):h=h.clone();for(var A=new i(1),v=new i(0),R=y.clone();h.cmpn(1)>0&&y.cmpn(1)>0;){for(var I=0,_=1;(h.words[0]&_)===0&&I<26;++I,_<<=1);if(I>0)for(h.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);h.cmp(y)>=0?(h.isub(y),A.isub(v)):(y.isub(h),v.isub(A))}var w;return h.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 h=this.clone(),y=c.clone();h.negative=0,y.negative=0;for(var A=0;h.isEven()&&y.isEven();A++)h.iushrn(1),y.iushrn(1);do{for(;h.isEven();)h.iushrn(1);for(;y.isEven();)y.iushrn(1);var v=h.cmp(y);if(v<0){var R=h;h=y,y=R}else if(v===0||y.cmpn(1)===0)break;h.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 h=c%26,y=(c-h)/26,A=1<<h;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 h=c<0;if(this.negative!==0&&!h)return-1;if(this.negative===0&&h)return 1;this._strip();var y;if(this.length>1)y=1;else{h&&(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 h=this.ucmp(c);return this.negative!==0?-h|0:h},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var h=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,v=c.words[y]|0;if(A!==v){A<v?h=-1:A>v&&(h=1);break}}return h},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 h=c,y;do this.split(h,this.tmp),h=this.imulK(h),h=h.iadd(this.tmp),y=h.bitLength();while(y>this.n);var A=y<this.n?-1:h.ucmp(this.p);return A===0?(h.words[0]=0,h.length=1):A>0?h.isub(this.p):h.strip!==void 0?h.strip():h._strip(),h},J.prototype.split=function(c,h){c.iushrn(this.n,0,h)},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,h){for(var y=4194303,A=Math.min(c.length,9),v=0;v<A;v++)h.words[v]=c.words[v];if(h.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var R=c.words[9];for(h.words[h.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 h=0,y=0;y<c.length;y++){var A=c.words[y]|0;h+=A*977,c.words[y]=h&67108863,h=A*64+(h/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 C(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(C,J),C.prototype.imulK=function(c){for(var h=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+h,v=A&67108863;A>>>=26,c.words[y]=v,h=A}return h!==0&&(c.words[c.length++]=h),c},i._prime=function(c){if(z[c])return z[c];var h;if(c==="k256")h=new te;else if(c==="p224")h=new ne;else if(c==="p192")h=new q;else if(c==="p25519")h=new C;else throw new Error("Unknown prime "+c);return z[c]=h,h};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,h){r((c.negative|h.negative)===0,"red works only with positives"),r(c.red&&c.red===h.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,h){this._verify2(c,h);var y=c.add(h);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},P.prototype.iadd=function(c,h){this._verify2(c,h);var y=c.iadd(h);return y.cmp(this.m)>=0&&y.isub(this.m),y},P.prototype.sub=function(c,h){this._verify2(c,h);var y=c.sub(h);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},P.prototype.isub=function(c,h){this._verify2(c,h);var y=c.isub(h);return y.cmpn(0)<0&&y.iadd(this.m),y},P.prototype.shl=function(c,h){return this._verify1(c),this.imod(c.ushln(h))},P.prototype.imul=function(c,h){return this._verify2(c,h),this.imod(c.imul(h))},P.prototype.mul=function(c,h){return this._verify2(c,h),this.imod(c.mul(h))},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 h=this.m.andln(3);if(r(h%2===1),h===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 h=c._invmp(this.m);return h.negative!==0?(h.negative=0,this.imod(h).redNeg()):this.imod(h)},P.prototype.pow=function(c,h){if(h.isZero())return new i(1).toRed(this);if(h.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=h.bitLength()%26;for(u===0&&(u=26),v=h.length-1;v>=0;v--){for(var l=h.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 h=c.umod(this.m);return h===c?h.clone():h},P.prototype.convertFrom=function(c){var h=c.clone();return h.red=null,h},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 h=this.imod(c.mul(this.rinv));return h.red=null,h},j.prototype.imul=function(c,h){if(c.isZero()||h.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(h),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,h){if(c.isZero()||h.isZero())return new i(0)._forceRed(this);var y=c.mul(h),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 h=this.imod(c._invmp(this.m).mul(this.r2));return h._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(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,V=M.length;Y!==V&&M[Y]===0;)Y++,k++;for(var L=(V-Y)*x+1>>>0,z=new Uint8Array(L);Y!==V;){for(var J=M[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 C=m.repeat(k);q<L;++q)C+=n.charAt(z[q]);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 V=(M.length-k)*g+1>>>0,L=new Uint8Array(V);k<M.length;){var z=M.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 C=t.allocUnsafe(K+(V-q));C.fill(0,0,K);for(var P=K;q!==V;)C[P++]=L[q++];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 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,C,P,j){j===void 0&&(j=P),Object.defineProperty(q,j,{enumerable:!0,get:function(){return C[P]}})}):(function(q,C,P,j){j===void 0&&(j=P),q[j]=C[P]})),e=Be&&Be.__setModuleDefault||(Object.create?(function(q,C){Object.defineProperty(q,"default",{enumerable:!0,value:C})}):function(q,C){q.default=C}),n=Be&&Be.__decorate||function(q,C,P,j){var E=arguments.length,c=E<3?C:j===null?j=Object.getOwnPropertyDescriptor(C,P):j,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(q,C,P,j);else for(var y=q.length-1;y>=0;y--)(h=q[y])&&(c=(E<3?h(c):E>3?h(C,P,c):h(C,P))||c);return E>3&&c&&Object.defineProperty(C,P,c),c},r=Be&&Be.__importStar||function(q){if(q&&q.__esModule)return q;var C={};if(q!=null)for(var P in q)P!=="default"&&Object.hasOwnProperty.call(q,P)&&t(C,q,P);return e(C,q),C},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(C){super(C),this.fieldPath=[],this.originalMessage=C}addToFieldPath(C){this.fieldPath.splice(0,0,C),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(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 j of C)this.maybeResize(),P(j)}toArray(){return this.buf.subarray(0,this.length)}}Be.BinaryWriter=F;function M(q,C,P){const j=P.value;P.value=function(...E){try{return j.apply(this,E)}catch(c){if(c instanceof RangeError){const h=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(h)>=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(j){throw new N(`Error decoding UTF-8 string: ${j}`)}}readFixedArray(C){return new Uint8Array(this.readBuffer(C))}readArray(C){const P=this.readU32(),j=Array();for(let E=0;E<P;++E)j.push(C());return j}}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),Be.BinaryReader=k;function K(q){return q.charAt(0).toUpperCase()+q.slice(1)}function Y(q,C,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,C,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,C,P,j.type,E));break}case"map":{E.writeU32(P.size),P.forEach((c,h)=>{Y(q,C,h,j.key,E),Y(q,C,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(C),c}}function V(q,C,P){if(typeof C.borshSerialize=="function"){C.borshSerialize(P);return}const j=q.get(C.constructor);if(!j)throw new N(`Class ${C.constructor.name} is missing in schema`);if(j.kind==="struct")j.fields.map(([E,c])=>{Y(q,E,C[E],c,P)});else if(j.kind==="enum"){const E=C[j.field];for(let c=0;c<j.values.length;++c){const[h,y]=j.values[c];if(h===E){P.writeU8(c),Y(q,h,C[h],y,P);break}}}else throw new N(`Unexpected schema kind: ${j.kind} for ${C.constructor.name}`)}function L(q,C,P=F){const j=new P;return V(q,C,j),j.toArray()}Be.serialize=L;function z(q,C,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,C,P[0],j))}if(P.kind==="option")return j.readU8()?z(q,C,P.type,j):void 0;if(P.kind==="map"){let E=new Map;const c=j.readU32();for(let h=0;h<c;h++){const y=z(q,C,P.key,j),A=z(q,C,P.value,j);E.set(y,A)}return E}return J(q,P,j)}catch(E){throw E instanceof N&&E.addToFieldPath(C),E}}function J(q,C,P){if(typeof C.borshDeserialize=="function")return C.borshDeserialize(P);const j=q.get(C);if(!j)throw new N(`Class ${C.name} is missing in schema`);if(j.kind==="struct"){const E={};for(const[c,h]of q.get(C).fields)E[c]=z(q,c,h,P);return new C(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,h]=j.values[E],y=z(q,c,h,P);return new C({[c]:y})}throw new N(`Unexpected schema kind: ${j.kind} for ${C.constructor.name}`)}function te(q,C,P,j=k){const E=new j(P),c=J(q,C,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,C,P,j=k){const E=new j(P);return J(q,C,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 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 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 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=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 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 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 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 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 h 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=h;class y{constructor(l,w,T){if(!(l instanceof h))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 h(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 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,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.
|
|
1
|
+
(function(At,wt){typeof exports=="object"&&typeof module<"u"?wt(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],wt):(At=typeof globalThis<"u"?globalThis:At||self,wt(At.Chainrails={},At.jsxRuntime,At.React))})(this,(function(At,wt,Me){"use strict";var xu=document.createElement("style");xu.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(xu);class Ao 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 Su 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 xo extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Su(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 Tu=(()=>{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})(),L0=typeof globalThis.AbortController=="function",Ou=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",P0=typeof globalThis.ReadableStream=="function",U0=typeof globalThis.FormData=="function",Iu=["get","post","put","patch","head","delete"],D0={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},So=2147483647,F0=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Nu=Symbol("stop");class Cu{options;constructor(e){this.options=e}}const $0=t=>new Cu(t),z0={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},j0={next:!0},V0={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},G0=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[n,r]of t)e+=F0,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},Mu=(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))}}))},H0=(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(Mu(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},q0=(t,e,n)=>{if(!t.body)return t;const r=G0(n??t.body);return new Request(t,{duplex:"half",body:Mu(t.body,r,e)})},Xn=t=>t!==null&&typeof t=="object",ei=(...t)=>{for(const e of t)if((!Xn(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return To({},...t)},Bu=(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 ti(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:To(t[n]??[],e[n]??[])}const ku=(t={},e={})=>({beforeRequest:ti(t,e,"beforeRequest"),beforeRetry:ti(t,e,"beforeRetry"),afterResponse:ti(t,e,"afterResponse"),beforeError:ti(t,e,"beforeError")}),K0=(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(Xn(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},To=(...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(Xn(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&&(!Xn(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:K0(s,d);continue}Xn(d)&&a in e&&(d=To(e[a],d)),e={...e,[a]:d}}Xn(o.hooks)&&(r=ku(r,o.hooks),e.hooks=r),Xn(o.headers)&&(n=Bu(n,o.headers),e.headers=n)}return s!==void 0&&(e.searchParams=s),i.length>0&&(i.length===1?e.signal=i[0]:Ou?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e},W0=t=>Iu.includes(t)?t.toUpperCase():t,Lu={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},Z0=(t={})=>{if(typeof t=="number")return{...Lu,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.methods&&=t.methods.map(n=>n.toLowerCase()),t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");const e=Object.fromEntries(Object.entries(t).filter(([,n])=>n!==void 0));return{...Lu,...e}};class Oo extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function Y0(t,e,n,r){return new Promise((s,i)=>{const o=setTimeout(()=>{n&&n.abort(),i(new Oo(t))},r.timeout);r.fetch(t,e).then(s).catch(i).then(()=>{clearTimeout(o)})})}async function J0(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 X0=(t,e)=>{const n={};for(const r in e)Object.hasOwn(e,r)&&!(r in V0)&&!(r in z0)&&(!(r in t)||r in j0)&&(n[r]=e[r]);return n},Q0=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 ep(t){return t instanceof Ao||t?.name===Ao.name}function tp(t){return t instanceof Oo||t?.name===Oo.name}class Xr{static create(e,n){const r=new Xr(e,n),s=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>So)throw new RangeError(`The \`timeout\` option cannot be greater than ${So}`);await Promise.resolve();let o=await r.#y();for(const a of r.#e.hooks.afterResponse){const d=r.#f(o.clone());let m;try{m=await a(r.request,r.#c(),d,{retryCount:r.#n})}catch(v){throw r.#i(d),r.#i(o),v}if(m instanceof Cu)throw r.#i(d),r.#i(o),new xo(m.options);const g=m instanceof globalThis.Response?m:o;d!==g&&r.#i(d),o!==g&&r.#i(o),o=g}if(r.#f(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new Ao(o,r.request,r.#c());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(!P0)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");const a=o.clone();return r.#i(o),H0(a,r.#e.onDownloadProgress)}return o},i=r.#h(s).finally(()=>{const o=r.#o;r.#d(o?.body??void 0),r.#d(r.request.body??void 0)});for(const[o,a]of Object.entries(D0))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#m(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;#o;#s;#a;constructor(e,n={}){if(this.#t=e,this.#e={...n,headers:Bu(this.#t.headers,n.headers),hooks:ku({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:W0(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:Z0(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}L0&&Ou&&(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),Tu&&(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&&(U0&&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),Q0(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Xr.#m(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(!Tu)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#p(this.request,this.#e.body??void 0)}}#u(){const e=this.#e.retry.delay(this.#n);let n=e;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));const r=this.#e.retry.backoffLimit??Number.POSITIVE_INFINITY;return Math.min(r,n)}async#g(e){if(this.#n++,this.#n>this.#e.retry.limit)throw e;const n=e instanceof Error?e:new Su(e);if(n instanceof xo)return n.customDelay??this.#u();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.#u()}if(tp(e)&&!this.#e.retry.retryOnTimeout)throw e;if(ep(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.#u()}#f(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}#d(e){e&&e.cancel().catch(()=>{})}#i(e){this.#d(e.body??void 0)}async#h(e){try{return await e()}catch(n){const r=Math.min(await this.#g(n),So);if(this.#n<1)throw n;if(await J0(r,this.#s?{signal:this.#s}:{}),n instanceof xo&&n.customRequest){const s=this.#e.signal?new globalThis.Request(n.customRequest,{signal:this.#e.signal}):new globalThis.Request(n.customRequest);this.#l(s)}for(const s of this.#e.hooks.beforeRetry){const i=await s({request:this.request,options:this.#c(),error:n,retryCount:this.#n});if(i instanceof globalThis.Request){this.#l(i);break}if(i instanceof globalThis.Response)return i;if(i===Nu)return}return this.#h(e)}}async#y(){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.#c(),{retryCount:this.#n});if(r instanceof Response)return r;if(r instanceof globalThis.Request){this.#l(r);break}}const e=X0(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):Y0(this.#o,e,this.#r,this.#e)}#c(){if(!this.#a){const{hooks:e,...n}=this.#e;this.#a=Object.freeze(n)}return this.#a}#l(e){this.#a=void 0,this.request=this.#p(e)}#p(e,n){return!this.#e.onUploadProgress||!e.body?e:q0(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}const Io=t=>{const e=(n,r)=>Xr.create(n,ei(t,r));for(const n of Iu)e[n]=(r,s)=>Xr.create(r,ei(t,s,{method:n}));return e.create=n=>Io(ei(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),Io(ei(t,n))),e.stop=Nu,e.retry=$0,e},np=Io(),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"},Pu={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 No(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Uu(t){return No(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Du="2.43.4";let Co={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Du}`};class Mn extends Error{constructor(e,n={}){const r=n.cause instanceof Mn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Mn&&n.cause.docsPath||n.docsPath,i=Co.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...Co.version?[`Version: ${Co.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=Du}walk(e){return Fu(this,e)}}function Fu(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Fu(t.cause,e):e?null:t}let $u=class extends Mn{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 ni(t,{dir:e,size:n=32}={}){return typeof t=="string"?rp(t,{dir:e,size:n}):sp(t,{dir:e,size:n})}function rp(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new $u({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function sp(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new $u({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 ip extends Mn{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 op extends Mn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Mo(t,{size:e}){if(Uu(t)>e)throw new op({givenSize:Uu(t),maxSize:e})}function ap(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 ip({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?ni(a,{size:r}):a}const cp=new TextEncoder;function up(t,e={}){return typeof t=="number"||typeof t=="bigint"?lp(t,e):typeof t=="boolean"?dp(t,e):No(t)?ju(t,e):Vu(t,e)}function dp(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Mo(n,{size:e.size}),ni(n,{size:e.size})):n}const gn={zero:48,nine:57,A:65,F:70,a:97,f:102};function zu(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 ju(t,e={}){let n=t;e.size&&(Mo(n,{size:e.size}),n=ni(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=zu(r.charCodeAt(a++)),m=zu(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Mn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function lp(t,e){const n=ap(t,e);return ju(n)}function Vu(t,e={}){const n=cp.encode(t);return typeof e.size=="number"?(Mo(n,{size:e.size}),ni(n,{dir:"right",size:e.size})):n}const ri=BigInt(2**32-1),Gu=BigInt(32);function fp(t,e=!1){return e?{h:Number(t&ri),l:Number(t>>Gu&ri)}:{h:Number(t>>Gu&ri)|0,l:Number(t&ri)|0}}function hp(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}=fp(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const pp=(t,e,n)=>t<<n|e>>>32-n,mp=(t,e,n)=>e<<n|t>>>32-n,gp=(t,e,n)=>e<<n-32|t>>>64-n,yp=(t,e,n)=>t<<n-32|e>>>64-n;function bp(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Hu(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function si(t,...e){if(!bp(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 qu(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 _p(t,e){si(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function wp(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ku(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Ep=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vp(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Rp(t){for(let e=0;e<t.length;e++)t[e]=vp(t[e]);return t}const Wu=Ep?t=>t:Rp;function Ap(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Zu(t){return typeof t=="string"&&(t=Ap(t)),si(t),t}let xp=class{};function Sp(t){const e=r=>t().update(Zu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const Tp=BigInt(0),Qr=BigInt(1),Op=BigInt(2),Ip=BigInt(7),Np=BigInt(256),Cp=BigInt(113),Yu=[],Ju=[],Xu=[];for(let t=0,e=Qr,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Yu.push(2*(5*r+n)),Ju.push((t+1)*(t+2)/2%64);let s=Tp;for(let i=0;i<7;i++)e=(e<<Qr^(e>>Ip)*Cp)%Np,e&Op&&(s^=Qr<<(Qr<<BigInt(i))-Qr);Xu.push(s)}const Qu=hp(Xu,!0),Mp=Qu[0],Bp=Qu[1],ed=(t,e,n)=>n>32?gp(t,e,n):pp(t,e,n),td=(t,e,n)=>n>32?yp(t,e,n):mp(t,e,n);function kp(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],v=ed(m,g,1)^n[a],T=td(m,g,1)^n[a+1];for(let I=0;I<50;I+=10)t[o+I]^=v,t[o+I+1]^=T}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=Ju[o],d=ed(s,i,a),m=td(s,i,a),g=Yu[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]^=Mp[r],t[1]^=Bp[r]}Ku(n)}let Lp=class M0 extends xp{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,Hu(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=wp(this.state)}clone(){return this._cloneInto()}keccak(){Wu(this.state32),kp(this.state32,this.rounds),Wu(this.state32),this.posOut=0,this.pos=0}update(e){qu(this),e=Zu(e),si(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){qu(this,!1),si(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 Hu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(_p(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,Ku(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new M0(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 Pp=(t,e,n)=>Sp(()=>new Lp(e,t,n)),Up=Pp(1,136,256/8);function Dp(t,e){return Up(No(t,{strict:!1})?up(t):t)}let Fp=class extends Mn{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 nd 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 Bo=new nd(8192);function rd(t,e){if(Bo.has(`${t}.${e}`))return Bo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=Dp(Vu(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 Bo.set(`${t}.${e}`,i),i}function xt(t,e){if(!zp(t,{strict:!1}))throw new Fp({address:t});return rd(t,e)}const $p=/^0x[a-fA-F0-9]{40}$/,ko=new nd(8192);function zp(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(ko.has(r))return ko.get(r);const s=$p.test(t)?t.toLowerCase()===t?!0:n?rd(t)===t:!0:!1;return ko.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 sd={[Xe.ARBITRUM]:{[X.DAI]:{address:xt("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:xt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:xt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:xt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ARBITRUM_TESTNET]:{[X.USDC]:{address:xt("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:xt("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:xt("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:xt("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:xt("0x4200000000000000000000000000000000000006"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.BASE_TESTNET]:{[X.USDC]:{address:xt("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:xt("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:xt("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:xt("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:xt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:xt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Xe.ETHEREUM_TESTNET]:{[X.USDC]:{address:xt("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}}},jp=new Set(Object.values(Xe));function Pt(t){if(Vp(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 Vp(t){return jp.has(t)}function Gp(t,e){const n=e.toLowerCase().trim(),r=sd[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 Lo(t,e,n){const r=Gp(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 Hp(t,e){return sd[t]?.[e]}function id(t,e){return Hp(t,e)?.address}var Po=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(Po||{});let yn=class Ye{constructor({api_key:e,env:n,seesion_token:r,props:s}){this.api_key=e||"",this.sessionToken=r||"",this.env=n??Po.PRODUCTION,this.props=s}static async config(e){if(!Ye.app){if(!e)throw new Error("Please provide an api_key");Ye.app=new Ye(e)}return e&&(e.api_key!==void 0&&(Ye.app.api_key=e.api_key),e.seesion_token!==void 0&&(Ye.app.sessionToken=e.seesion_token),e.env!==void 0&&(Ye.app.env=e.env),e.props!==void 0&&(Ye.app.props=e.props)),Ye.app}static getApiKey(){if(!Ye.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ye.app.api_key}static getSessionToken(){if(!Ye.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ye.app.sessionToken}static getProps(){if(!Ye.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ye.app.props}static getEnv(){if(!Ye.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Ye.app.env==="internal"?"staging":Ye.app.env}static getBaseUrl(){if(!Ye.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(Ye.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(!Ye.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=Ye.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}},Uo=null;function qp(){Uo=np.create({prefixUrl:yn.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=yn.getSessionToken()||yn.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,n)=>n]},retry:{limit:2}})}function we(){return Uo||qp(),Uo}let Kp=class{async getById(e){return await we().get("intents/"+e).json()}async getForSender(e){return await we().get("intents/user/"+e).json()}async getForAddress(e){return await we().get("intents/address/"+e).json()}async getForSession(e){return await we().get("modal/sessions/intents/"+e).json()}async getAll(e){return await we().get("intents",{searchParams:e}).json()}async create(e){const n=Pt(e.source_chain),r=Pt(e.destination_chain);return await we().post("intents",{json:{...e,source_chain:n,destination_chain:r}}).json()}async createForSession(e){const n=Pt(e.sourceChain);return await we().post("modal/sessions/intents",{json:{...e,sourceChain:n}}).json()}async update(e,n){return await we().post("intents",{json:n}).json()}async triggerProcessing(e){return await we().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await we().post(`modal/sessions/intents/${e}/process`).json()}},Wp=class{async getFromSpecificBridge(e){const n=Pt(e.sourceChain);Lo(n,e.tokenIn,e.amountSymbol);const r=Pt(e.destinationChain);return await we().get("quotes/single",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getFromAllBridges(e){const n=Pt(e.sourceChain);Lo(n,e.tokenIn,e.amountSymbol);const r=Pt(e.destinationChain);return await we().get("quotes/multiple",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getBestAcrossBridges(e){const n=Pt(e.sourceChain);Lo(n,e.tokenIn,e.amountSymbol);const r=Pt(e.destinationChain);return await we().get("quotes/best",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAll(e){const n=Pt(e.destinationChain);return await we().get("quotes/multi-source",{searchParams:{...e,destinationChain:n}}).json()}async getAllForSession(e){return await we().get("modal/sessions/quotes",{searchParams:e}).json()}},Zp=class{async getOptimalRoutes(e){const n=Pt(e.sourceChain),r=Pt(e.destinationChain);return await we().get("router/optimal-route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAllSupportedBridges(){return await we().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const n=Pt(e.sourceChain),r=Pt(e.destinationChain);return await we().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getSupportedRoutes(e){return await we().get("router/supported-routes/bridge/"+e).json()}},Yp=class{async getSupported(e){return await we().get("chains",{searchParams:e}).json()}async getBalance(e){return await we().get(`chains/balances/${e.address}`,{searchParams:e}).json()}},Jp=class{async getClientInfo(){return await we().get("client/auth/client-info").json()}async getClientInfoForSession(){return await we().get("modal/sessions/client").json()}},Xp=class{async getSessionToken(e){const n=Pt(e.destinationChain);let r=id(n,e.token);r||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),r=id(n,"USDC"));const s={recipient:e.recipient,tokenOut:r,destinationChain:n,amount:e.amount};return we().post("modal/sessions",{json:s}).json().then(i=>({...i,amount:s.amount}))}async getHandOffToken(){return we().post("modal/sessions/handoff-token").json()}async resumeSession(e){return we().post(`modal/sessions/${e.sessionId}/resume`,{json:e}).json()}};const Qp="modal/sessions/history";class em{async getHistoryForSession(e){return we().post(Qp,{json:e}).json()}}class tm{async getQuotes(e){return await we().get("ramp/quotes",{searchParams:e}).json()}async getQuotesForSession(e){return await we().get("modal/sessions/ramp/quotes",{searchParams:e}).json()}async getCountries(e){return await we().get("ramp/countries",{searchParams:e}).json()}async getCountriesForSession(e){return await we().get("modal/sessions/ramp/countries",{searchParams:e}).json()}async getCurrencies(e){return await we().get("ramp/currencies",{searchParams:e}).json()}async getCurrenciesForSession(e){return await we().get("modal/sessions/ramp/currencies",{searchParams:e}).json()}async createOrder(e){return await we().post("ramp/orders",{json:e}).json()}async createOrderForSession(e){return await we().post("modal/sessions/ramp/orders",{json:e}).json()}async getOrder(e){return await we().get(`ramp/orders/${e}`).json()}async getOrderForSession(e){return await we().get(`modal/sessions/ramp/orders/${e}`).json()}async getOrderByIntent(e){return await we().get(`ramp/orders/by-intent/${e}`).json()}async listOrders(e){return await we().get("ramp/orders",{searchParams:e}).json()}async confirmOrder(e){return await we().post(`ramp/orders/${e}/confirm`).json()}async confirmOrderForSession(e){return await we().post(`modal/sessions/ramp/orders/${e}/confirm`).json()}async cancelOrder(e){return await we().post(`ramp/orders/${e}/cancel`).json()}}const nm={router:new Zp,quotes:new Wp,intents:new Kp,chains:new Yp,client:new Jp,auth:new Xp,history:new em,ramp:new tm};function od(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=od(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function Do(){for(var t,e,n=0,r="",s=arguments.length;n<s;n++)(t=arguments[n])&&(e=od(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"},Fo="https://app.chainrails.io",$o="https://chainrails-frontend-git-staging-horus-labs.vercel.app",rm=[{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 br(t,{includeName:e=!1}={}){if(t.type!=="function"&&t.type!=="event"&&t.type!=="error")throw new hm(t.type);return`${t.name}(${zo(t.inputs,{includeName:e})})`}function zo(t,{includeName:e=!1}={}){return t?t.map(n=>sm(n,{includeName:e})).join(e?", ":","):""}function sm(t,{includeName:e}){return t.type.startsWith("tuple")?`(${zo(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function Bn(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 Bn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ad="2.47.6";let jo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${ad}`},ue=class vu extends Error{constructor(e,n={}){const r=n.cause instanceof vu?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof vu&&n.cause.docsPath||n.docsPath,i=jo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...jo.version?[`Version: ${jo.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=ad}walk(e){return cd(this,e)}};function cd(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?cd(t.cause,e):e?null:t}class im 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: (${zo(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 Vo extends ue{constructor({cause:e}={}){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError",cause:e})}}class om 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
|
+
`),{name:"AbiEncodingArrayLengthMismatchError"})}}class am 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 cm 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 ud extends ue{constructor(e,{docsPath:n,cause:r}){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://4byte.sourcify.dev/?q=${e}.`].join(`
|
|
8
|
+
`),{docsPath:n,name:"AbiErrorSignatureNotFoundError",cause:r}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class dd 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
|
+
`),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class um extends ue{constructor(e,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${br(e.abiItem)}\`, and`,`\`${n.type}\` in \`${br(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class dm extends ue{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
|
|
10
|
+
`),{docsPath:n,name:"InvalidAbiEncodingType"})}}class lm extends ue{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(`
|
|
11
|
+
`),{docsPath:n,name:"InvalidAbiDecodingType"})}}class fm extends ue{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
|
|
12
|
+
`),{name:"InvalidArrayError"})}}class hm extends ue{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
|
|
13
|
+
`),{name:"InvalidDefinitionTypeError"})}}class es 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 ld 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 fd 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 hd 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 _r(t,{dir:e,size:n=32}={}){return typeof t=="string"?kn(t,{dir:e,size:n}):pm(t,{dir:e,size:n})}function kn(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new fd({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function pm(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new fd({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 Go 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 mm 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 gm 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 ym extends ue{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Qn(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 ym({givenSize:bt(t),maxSize:e})}function bm(t,e){const n={to:e},r=n.to;return r==="number"?er(t,n):r==="bigint"?wr(t,n):r==="string"?wm(t,n):r==="boolean"?_m(t,n):en(t,n)}function wr(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 _m(t,e={}){let n=t;if(e.size&&(Xt(n,{size:e.size}),n=Qn(n)),Qn(n)==="0x00")return!1;if(Qn(n)==="0x01")return!0;throw new gm(n)}function er(t,e={}){const n=wr(t,e),r=Number(n);if(!Number.isSafeInteger(r))throw new Go({max:`${Number.MAX_SAFE_INTEGER}`,min:`${Number.MIN_SAFE_INTEGER}`,signed:e.signed,size:e.size,value:`${n}n`});return r}function wm(t,e={}){let n=en(t);return e.size&&(Xt(n,{size:e.size}),n=Qn(n,{dir:"right"})),new TextDecoder().decode(n)}const Em=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ho(t,e={}){return typeof t=="number"||typeof t=="bigint"?ke(t,e):typeof t=="string"?qo(t,e):typeof t=="boolean"?pd(t,e):jt(t,e)}function pd(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(Xt(n,{size:e.size}),_r(n,{size:e.size})):n}function jt(t,e={}){let n="";for(let s=0;s<t.length;s++)n+=Em[t[s]];const r=`0x${n}`;return typeof e.size=="number"?(Xt(r,{size:e.size}),_r(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 Go({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?_r(a,{size:r}):a}const vm=new TextEncoder;function qo(t,e={}){const n=vm.encode(t);return jt(n,e)}const Rm=new TextEncoder;function Ko(t,e={}){return typeof t=="number"||typeof t=="bigint"?xm(t,e):typeof t=="boolean"?Am(t,e):Bn(t)?en(t,e):gd(t,e)}function Am(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Xt(n,{size:e.size}),_r(n,{size:e.size})):n}const bn={zero:48,nine:57,A:65,F:70,a:97,f:102};function md(t){if(t>=bn.zero&&t<=bn.nine)return t-bn.zero;if(t>=bn.A&&t<=bn.F)return t-(bn.A-10);if(t>=bn.a&&t<=bn.f)return t-(bn.a-10)}function en(t,e={}){let n=t;e.size&&(Xt(n,{size:e.size}),n=_r(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=md(r.charCodeAt(a++)),m=md(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 xm(t,e){const n=ke(t,e);return en(n)}function gd(t,e={}){const n=Rm.encode(t);return typeof e.size=="number"?(Xt(n,{size:e.size}),_r(n,{dir:"right",size:e.size})):n}const ii=BigInt(2**32-1),yd=BigInt(32);function Sm(t,e=!1){return e?{h:Number(t&ii),l:Number(t>>yd&ii)}:{h:Number(t>>yd&ii)|0,l:Number(t&ii)|0}}function bd(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}=Sm(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const _d=(t,e,n)=>t>>>n,wd=(t,e,n)=>t<<32-n|e>>>n,Er=(t,e,n)=>t>>>n|e<<32-n,vr=(t,e,n)=>t<<32-n|e>>>n,oi=(t,e,n)=>t<<64-n|e>>>n-32,ai=(t,e,n)=>t>>>n-32|e<<64-n,Tm=(t,e,n)=>t<<n|e>>>32-n,Om=(t,e,n)=>e<<n|t>>>32-n,Im=(t,e,n)=>e<<n-32|t>>>64-n,Nm=(t,e,n)=>t<<n-32|e>>>64-n;function _n(t,e,n,r){const s=(e>>>0)+(r>>>0);return{h:t+n+(s/2**32|0)|0,l:s|0}}const Cm=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Mm=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Bm=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),km=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Lm=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Pm=(t,e,n,r,s,i)=>e+n+r+s+i+(t/2**32|0)|0,Rr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Um(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ts(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function tr(t,...e){if(!Um(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 Dm(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ts(t.outputLen),ts(t.blockLen)}function Ar(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 Ed(t,e){tr(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Fm(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Ln(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Wo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function un(t,e){return t<<32-e|t>>>e}const $m=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function zm(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function jm(t){for(let e=0;e<t.length;e++)t[e]=zm(t[e]);return t}const vd=$m?t=>t:jm;function Vm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ci(t){return typeof t=="string"&&(t=Vm(t)),tr(t),t}function Gm(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];tr(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 Zo{}function Yo(t){const e=r=>t().update(ci(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Rd(t=32){if(Rr&&typeof Rr.getRandomValues=="function")return Rr.getRandomValues(new Uint8Array(t));if(Rr&&typeof Rr.randomBytes=="function")return Uint8Array.from(Rr.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const Hm=BigInt(0),ns=BigInt(1),qm=BigInt(2),Km=BigInt(7),Wm=BigInt(256),Zm=BigInt(113),Ad=[],xd=[],Sd=[];for(let t=0,e=ns,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Ad.push(2*(5*r+n)),xd.push((t+1)*(t+2)/2%64);let s=Hm;for(let i=0;i<7;i++)e=(e<<ns^(e>>Km)*Zm)%Wm,e&qm&&(s^=ns<<(ns<<BigInt(i))-ns);Sd.push(s)}const Td=bd(Sd,!0),Ym=Td[0],Jm=Td[1],Od=(t,e,n)=>n>32?Im(t,e,n):Tm(t,e,n),Id=(t,e,n)=>n>32?Nm(t,e,n):Om(t,e,n);function Xm(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],v=Od(m,g,1)^n[a],T=Id(m,g,1)^n[a+1];for(let I=0;I<50;I+=10)t[o+I]^=v,t[o+I+1]^=T}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=xd[o],d=Od(s,i,a),m=Id(s,i,a),g=Ad[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]^=Ym[r],t[1]^=Jm[r]}Ln(n)}class Jo extends Zo{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,ts(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Fm(this.state)}clone(){return this._cloneInto()}keccak(){vd(this.state32),Xm(this.state32,this.rounds),vd(this.state32),this.posOut=0,this.pos=0}update(e){Ar(this),e=ci(e),tr(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){Ar(this,!1),tr(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 ts(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ed(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,Ln(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Jo(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 Qm=(t,e,n)=>Yo(()=>new Jo(e,t,n)),eg=Qm(1,136,256/8);function ui(t,e){const n=e||"hex",r=eg(Bn(t,{strict:!1})?Ko(t):t);return n==="bytes"?r:Ho(r)}class rs 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)&&(super.delete(e),super.set(e,n)),n}set(e,n){if(super.has(e)&&super.delete(e),super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=super.keys().next().value;r!==void 0&&super.delete(r)}return this}}const tg=/^0x[a-fA-F0-9]{40}$/,Xo=new rs(8192);function Pn(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Xo.has(r))return Xo.get(r);const s=tg.test(t)?t.toLowerCase()===t?!0:n?di(t)===t:!0:!1;return Xo.set(r,s),s}const Qo=new rs(8192);function di(t,e){if(Qo.has(`${t}.${e}`))return Qo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=ui(gd(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 Qo.set(`${t}.${e}`,i),i}function li(t,e){if(!Pn(t,{strict:!1}))throw new es({address:t});return di(t,e)}class Nd extends ue{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class ng extends ue{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class rg extends ue{constructor({count:e,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}}const sg={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 rg({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new ng({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Nd({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 Nd({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 ea(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(sg);return n.bytes=t,n.dataView=new DataView(t.buffer??t,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}function fi(t,e,n,{strict:r}={}){return Bn(t,{strict:!1})?ig(t,e,n,{strict:r}):Bd(t,e,n,{strict:r})}function Cd(t,e){if(typeof e=="number"&&e>0&&e>bt(t)-1)throw new ld({offset:e,position:"start",size:bt(t)})}function Md(t,e,n){if(typeof e=="number"&&typeof n=="number"&&bt(t)!==n-e)throw new ld({offset:n,position:"end",size:bt(t)})}function Bd(t,e,n,{strict:r}={}){Cd(t,e);const s=t.slice(e,n);return r&&Md(s,e,n),s}function ig(t,e,n,{strict:r}={}){Cd(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(n??t.length)*2)}`;return r&&Md(s,e,n),s}function og(t,e={}){typeof e.size<"u"&&Xt(t,{size:e.size});const n=jt(t,e);return wr(n,e)}function ag(t,e={}){let n=t;if(typeof e.size<"u"&&(Xt(n,{size:e.size}),n=Qn(n)),n.length>1||n[0]>1)throw new mm(n);return!!n[0]}function wn(t,e={}){typeof e.size<"u"&&Xt(t,{size:e.size});const n=jt(t,e);return er(n,e)}function cg(t,e={}){let n=t;return typeof e.size<"u"&&(Xt(n,{size:e.size}),n=Qn(n,{dir:"right"})),new TextDecoder().decode(n)}function Un(t){return typeof t[0]=="string"?ta(t):ug(t)}function ug(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 ta(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}const dg=/^(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 lg(t,e){if(t.length!==e.length)throw new cm({expectedLength:t.length,givenLength:e.length});const n=fg({params:t,values:e}),r=ra(n);return r.length===0?"0x":r}function fg({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(na({param:t[r],value:e[r]}));return n}function na({param:t,value:e}){const n=sa(t.type);if(n){const[r,s]=n;return pg(e,{length:r,param:{...t,type:s}})}if(t.type==="tuple")return _g(e,{param:t});if(t.type==="address")return hg(e);if(t.type==="bool")return gg(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const r=t.type.startsWith("int"),[,,s="256"]=dg.exec(t.type)??[];return yg(e,{signed:r,size:Number(s)})}if(t.type.startsWith("bytes"))return mg(e,{param:t});if(t.type==="string")return bg(e);throw new dm(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function ra(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 Un([...n,...r])}function hg(t){if(!Pn(t))throw new es({address:t});return{dynamic:!1,encoded:kn(t.toLowerCase())}}function pg(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new fm(t);if(!r&&t.length!==e)throw new om({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let s=!1;const i=[];for(let o=0;o<t.length;o++){const a=na({param:n,value:t[o]});a.dynamic&&(s=!0),i.push(a)}if(r||s){const o=ra(i);if(r){const a=ke(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Un([a,o]):a}}if(s)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:Un(i.map(({encoded:o})=>o))}}function mg(t,{param:e}){const[,n]=e.type.split("bytes"),r=bt(t);if(!n){let s=t;return r%32!==0&&(s=kn(s,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:Un([kn(ke(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new am({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:kn(t,{dir:"right"})}}function gg(t){if(typeof t!="boolean")throw new ue(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:kn(pd(t))}}function yg(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 Go({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 bg(t){const e=qo(t),n=Math.ceil(bt(e)/32),r=[];for(let s=0;s<n;s++)r.push(kn(fi(e,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:Un([kn(ke(bt(e),{size:32})),...r])}}function _g(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=na({param:i,value:t[o]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?ra(r):Un(r.map(({encoded:s})=>s))}}function sa(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function wg(t,e){const n=typeof e=="string"?en(e):e,r=ea(n);if(bt(n)===0&&t.length>0)throw new Vo;if(bt(e)&&bt(e)<32)throw new im({data:typeof e=="string"?e:jt(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]=xr(r,a,{staticPosition:0});s+=m,i.push(d)}return i}function xr(t,e,{staticPosition:n}){const r=sa(e.type);if(r){const[s,i]=r;return vg(t,{...e,type:i},{length:s,staticPosition:n})}if(e.type==="tuple")return Sg(t,e,{staticPosition:n});if(e.type==="address")return Eg(t);if(e.type==="bool")return Rg(t);if(e.type.startsWith("bytes"))return Ag(t,e,{staticPosition:n});if(e.type.startsWith("uint")||e.type.startsWith("int"))return xg(t,e);if(e.type==="string")return Tg(t,{staticPosition:n});throw new lm(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const kd=32,ia=32;function Eg(t){const e=t.readBytes(32);return[di(jt(Bd(e,-20))),32]}function vg(t,e,{length:n,staticPosition:r}){if(!n){const o=wn(t.readBytes(ia)),a=r+o,d=a+kd;t.setPosition(a);const m=wn(t.readBytes(kd)),g=ss(e);let v=0;const T=[];for(let I=0;I<m;++I){t.setPosition(d+(g?I*32:v));const[L,M]=xr(t,e,{staticPosition:d});v+=M,T.push(L)}return t.setPosition(r+32),[T,32]}if(ss(e)){const o=wn(t.readBytes(ia)),a=r+o,d=[];for(let m=0;m<n;++m){t.setPosition(a+m*32);const[g]=xr(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]=xr(t,e,{staticPosition:r+s});s+=d,i.push(a)}return[i,s]}function Rg(t){return[ag(t.readBytes(32),{size:32}),32]}function Ag(t,e,{staticPosition:n}){const[r,s]=e.type.split("bytes");if(!s){const o=wn(t.readBytes(32));t.setPosition(n+o);const a=wn(t.readBytes(32));if(a===0)return t.setPosition(n+32),["0x",32];const d=t.readBytes(a);return t.setPosition(n+32),[jt(d),32]}return[jt(t.readBytes(Number.parseInt(s,10),32)),32]}function xg(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?og(s,{signed:n}):wn(s,{signed:n}),32]}function Sg(t,e,{staticPosition:n}){const r=e.components.length===0||e.components.some(({name:o})=>!o),s=r?[]:{};let i=0;if(ss(e)){const o=wn(t.readBytes(ia)),a=n+o;for(let d=0;d<e.components.length;++d){const m=e.components[d];t.setPosition(a+i);const[g,v]=xr(t,m,{staticPosition:a});i+=v,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]=xr(t,a,{staticPosition:n});s[r?o:a?.name]=d,i+=m}return[s,i]}function Tg(t,{staticPosition:e}){const n=wn(t.readBytes(32)),r=e+n;t.setPosition(r);const s=wn(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const i=t.readBytes(s,32),o=cg(Qn(i));return t.setPosition(e+32),[o,32]}function ss(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(ss);const n=sa(t.type);return!!(n&&ss({...t,type:n[1]}))}const Og=t=>ui(Ko(t));function Ig(t){return Og(t)}function Ng(t,e){return t.exec(e)?.groups}const Ld=/^tuple(?<array>(\[(\d*)\])*)$/;function oa(t){let e=t.type;if(Ld.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+=oa(i),s<n-1&&(e+=", ")}const r=Ng(Ld,t.type);return e+=`)${r?.array||""}`,oa({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function is(t){let e="";const n=t.length;for(let r=0;r<n;r++){const s=t[r];e+=oa(s),r!==n-1&&(e+=", ")}return e}function Cg(t){return t.type==="function"?`function ${t.name}(${is(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${is(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${is(t.inputs)})`:t.type==="error"?`error ${t.name}(${is(t.inputs)})`:t.type==="constructor"?`constructor(${is(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}function Mg(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 Bg=t=>{const e=typeof t=="string"?t:Cg(t);return Mg(e)};function Pd(t){return Ig(Bg(t))}const kg=Pd,aa=t=>fi(Pd(t),0,4);function Ud(t){const{abi:e,args:n=[],name:r}=t,s=Bn(r,{strict:!1}),i=e.filter(a=>s?a.type==="function"?aa(a)===r:a.type==="event"?kg(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 v="inputs"in a&&a.inputs[g];return v?ca(m,v):!1})){if(o&&"inputs"in o&&o.inputs){const m=Dd(a.inputs,o.inputs,n);if(m)throw new um({abiItem:a,type:m[0]},{abiItem:o,type:m[1]})}o=a}}return o||i[0]}function ca(t,e){const n=typeof t,r=e.type;switch(r){case"address":return Pn(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"&&ca(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=>ca(s,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Dd(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 Dd(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")?Pn(n[r],{strict:!1}):o.includes("address")&&o.includes("bytes")?Pn(n[r],{strict:!1}):!1)return o}}const Fd="/docs/contract/encodeFunctionData";function Lg(t){const{abi:e,args:n,functionName:r}=t;let s=e[0];if(r){const i=Ud({abi:e,args:n,name:r});if(!i)throw new dd(r,{docsPath:Fd});s=i}if(s.type!=="function")throw new dd(void 0,{docsPath:Fd});return{abi:[s],functionName:aa(br(s))}}function Pg(t){const{args:e}=t,{abi:n,functionName:r}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:Lg(t),s=n[0],i=r,o="inputs"in s&&s.inputs?lg(s.inputs,e??[]):void 0;return ta([i,o??"0x"])}class Ug 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 Dg 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 En(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const Fg={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."},$g={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},zg={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};function jg(t){const{abi:e,data:n,cause:r}=t,s=fi(n,0,4);if(s==="0x")throw new Vo({cause:r});const o=[...e||[],$g,zg].find(a=>a.type==="error"&&s===aa(br(a)));if(!o)throw new ud(s,{docsPath:"/docs/contract/decodeErrorResult",cause:r});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?wg(o.inputs,fi(n,4)):void 0,errorName:o.name}}const hi=(t,e,n)=>JSON.stringify(t,(r,s)=>typeof s=="bigint"?s.toString():s,n);function $d({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"?hi(e[i]):e[i]}`).join(", ")})`}const Vg={gwei:9,wei:18},Gg={ether:-9,wei:9};function zd(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 jd(t,e="wei"){return zd(t,Vg[e])}function tn(t,e="wei"){return zd(t,Gg[e])}class Hg extends ue{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class qg extends ue{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function pi(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 Kg extends ue{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",pi(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 Wg extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:v,value:T}){const I=pi({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:v,value:typeof T<"u"&&`${jd(T)} ${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:",I].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const Zg=t=>t,Vd=t=>t;class Yg extends ue{constructor(e,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:o,sender:a}){const d=Ud({abi:n,args:r,name:o}),m=d?$d({abiItem:d,args:r,includeFunctionName:!1,includeName:!1}):void 0,g=d?br(d,{includeName:!0}):void 0,v=pi({address:s&&Zg(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," "]:[],v&&"Contract Call:",v].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 Jg extends ue{constructor({abi:e,data:n,functionName:r,message:s,cause:i}){let o,a,d,m;if(n&&n!=="0x")try{a=jg({abi:e,data:n,cause:i});const{abiItem:v,errorName:T,args:I}=a;if(T==="Error")m=I[0];else if(T==="Panic"){const[L]=I;m=Fg[L]}else{const L=v?br(v,{includeName:!0}):void 0,M=v&&I?$d({abiItem:v,args:I,includeFunctionName:!1,includeName:!1}):void 0;d=[L?`Error: ${L}`:"",M&&M!=="()"?` ${[...Array(T?.length??0).keys()].map(()=>" ").join("")}${M}`:""]}}catch(v){o=v}else s&&(m=s);let g;o instanceof ud&&(g=o.signature,d=[`Unable to decode signature "${g}" 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://4byte.sourcify.dev/?q=${g}.`]),super(m&&m!=="execution reverted"||g?[`The contract function "${r}" reverted with the following ${g?"signature":"reason"}:`,m||g].join(`
|
|
16
|
+
`):`The contract function "${r}" reverted.`,{cause:o??i,metaMessages:d,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=a,this.raw=n,this.reason=m,this.signature=g}}class Xg extends ue{constructor({functionName:e,cause:n}){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",cause:n})}}class Qg 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 St(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 Gd 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: ${Vd(o)}`,e&&`Request body: ${hi(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 Hd extends ue{constructor({body:e,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${Vd(r)}`,`Request body: ${hi(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 ey=-1;class Vt 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 Hd?e.code:n??ey}}let Gt=class extends Vt{constructor(e,n){super(e,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}};class os extends Vt{constructor(e){super(e,{code:os.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(os,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class as extends Vt{constructor(e){super(e,{code:as.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(as,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class cs extends Vt{constructor(e,{method:n}={}){super(e,{code:cs.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(cs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class us extends Vt{constructor(e){super(e,{code:us.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
|
|
17
|
+
`)})}}Object.defineProperty(us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class nr extends Vt{constructor(e){super(e,{code:nr.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(nr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Sr extends Vt{constructor(e){super(e,{code:Sr.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
|
|
18
|
+
`)})}}Object.defineProperty(Sr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class ds extends Vt{constructor(e){super(e,{code:ds.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ls extends Vt{constructor(e){super(e,{code:ls.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class fs extends Vt{constructor(e){super(e,{code:fs.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class rr extends Vt{constructor(e,{method:n}={}){super(e,{code:rr.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${n?` "${n}"`:""} is not supported.`})}}Object.defineProperty(rr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Tr extends Vt{constructor(e){super(e,{code:Tr.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(Tr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class hs extends Vt{constructor(e){super(e,{code:hs.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});let mi=class B0 extends Gt{constructor(e){super(e,{code:B0.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}};Object.defineProperty(mi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class ps extends Gt{constructor(e){super(e,{code:ps.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ms extends Gt{constructor(e,{method:n}={}){super(e,{code:ms.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class gs extends Gt{constructor(e){super(e,{code:gs.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});let ua=class k0 extends Gt{constructor(e){super(e,{code:k0.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}};Object.defineProperty(ua,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Or extends Gt{constructor(e){super(e,{code:Or.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Or,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class ys extends Gt{constructor(e){super(e,{code:ys.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class bs extends Gt{constructor(e){super(e,{code:bs.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class _s extends Gt{constructor(e){super(e,{code:_s.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class ws extends Gt{constructor(e){super(e,{code:ws.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Es extends Gt{constructor(e){super(e,{code:Es.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class vs extends Gt{constructor(e){super(e,{code:vs.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Rs extends Gt{constructor(e){super(e,{code:Rs.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Rs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class As extends Gt{constructor(e){super(e,{code:As.code,name:"WalletConnectSessionSettlementError",shortMessage:"WalletConnect session settlement failed."})}}Object.defineProperty(As,"code",{enumerable:!0,configurable:!0,writable:!0,value:7e3});class ty extends Vt{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const ny=3;function ry(t,{abi:e,address:n,args:r,docsPath:s,functionName:i,sender:o}){const a=t instanceof Qg?t:t instanceof ue?t.walk(L=>"data"in L)||t.walk():{},{code:d,data:m,details:g,message:v,shortMessage:T}=a,I=t instanceof Vo?new Xg({functionName:i,cause:t}):[ny,nr.code].includes(d)&&(m||g||v||T)||d===Sr.code&&g==="execution reverted"&&m?new Jg({abi:e,data:typeof m=="object"?m.data:m,functionName:i,message:a instanceof Hd?g:T??v,cause:t}):t;return new Yg(I,{abi:e,args:r,contractAddress:n,docsPath:s,functionName:i,sender:o})}const da=BigInt(0),la=BigInt(1);function xs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function fa(t){if(!xs(t))throw new Error("Uint8Array expected")}function Dn(t,e){if(typeof e!="boolean")throw new Error(t+" boolean expected, got "+e)}function gi(t){const e=t.toString(16);return e.length&1?"0"+e:e}function qd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?da:BigInt("0x"+t)}const Kd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",sy=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ir(t){if(fa(t),Kd)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=sy[t[n]];return e}const vn={_0:48,_9:57,A:65,F:70,a:97,f:102};function Wd(t){if(t>=vn._0&&t<=vn._9)return t-vn._0;if(t>=vn.A&&t<=vn.F)return t-(vn.A-10);if(t>=vn.a&&t<=vn.f)return t-(vn.a-10)}function yi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Kd)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=Wd(t.charCodeAt(i)),a=Wd(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 sr(t){return qd(Ir(t))}function Ss(t){return fa(t),qd(Ir(Uint8Array.from(t).reverse()))}function Ts(t,e){return yi(t.toString(16).padStart(e*2,"0"))}function bi(t,e){return Ts(t,e).reverse()}function Je(t,e,n){let r;if(typeof e=="string")try{r=yi(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(xs(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 Nr(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];fa(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 ha=t=>typeof t=="bigint"&&da<=t;function pa(t,e,n){return ha(t)&&ha(e)&&ha(n)&&e<=t&&t<n}function nn(t,e,n,r){if(!pa(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function iy(t){let e;for(e=0;t>da;t>>=la,e+=1);return e}const _i=t=>(la<<BigInt(t))-la,ma=t=>new Uint8Array(t),Zd=t=>Uint8Array.from(t);function oy(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=ma(t),s=ma(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...v)=>n(s,r,...v),d=(v=ma(0))=>{s=a(Zd([0]),v),r=a(),v.length!==0&&(s=a(Zd([1]),v),r=a())},m=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let v=0;const T=[];for(;v<e;){r=a();const I=r.slice();T.push(I),v+=r.length}return Nr(...T)};return(v,T)=>{o(),d(v);let I;for(;!(I=T(m()));)d();return o(),I}}const ay={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"||xs(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 Os(t,e,n={}){const r=(s,i,o)=>{const a=ay[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 wi(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 Cr 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(Cr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Cr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class Ei 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(Ei,"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 ga 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(ga,"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 ya 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(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class ba 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(ba,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class _a 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(_a,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class wa 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(wa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Ea 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(Ea,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class va 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(va,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Ra extends ue{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Ra,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class vi 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(vi,"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 Aa extends ue{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Yd(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof ue?t.walk(s=>s?.code===Cr.code):t;return r instanceof ue?new Cr({cause:t,message:r.details}):Cr.nodeMessage.test(n)?new Cr({cause:t,message:t.details}):Ei.nodeMessage.test(n)?new Ei({cause:t,maxFeePerGas:e?.maxFeePerGas}):ga.nodeMessage.test(n)?new ga({cause:t,maxFeePerGas:e?.maxFeePerGas}):ya.nodeMessage.test(n)?new ya({cause:t,nonce:e?.nonce}):ba.nodeMessage.test(n)?new ba({cause:t,nonce:e?.nonce}):_a.nodeMessage.test(n)?new _a({cause:t,nonce:e?.nonce}):wa.nodeMessage.test(n)?new wa({cause:t}):Ea.nodeMessage.test(n)?new Ea({cause:t,gas:e?.gas}):va.nodeMessage.test(n)?new va({cause:t,gas:e?.gas}):Ra.nodeMessage.test(n)?new Ra({cause:t}):vi.nodeMessage.test(n)?new vi({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new Aa({cause:t})}function xa(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 cy={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Sa(t,e){const n={};return typeof t.authorizationList<"u"&&(n.authorizationList=uy(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=>jt(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=cy[t.type]),typeof t.value<"u"&&(n.value=ke(t.value)),n}function uy(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 Jd(t){if(!(!t||t.length===0))return t.reduce((e,{slot:n,value:r})=>{if(n.length!==66)throw new hd({size:n.length,targetSize:66,type:"hex"});if(r.length!==66)throw new hd({size:r.length,targetSize:66,type:"hex"});return e[n]=r,e},{})}function dy(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=Jd(r)),s!==void 0){if(o.state)throw new qg;o.stateDiff=Jd(s)}return o}function ly(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!Pn(n,{strict:!1}))throw new es({address:n});if(e[n])throw new Hg({address:n});e[n]=dy(r)}return e}const fy=2n**256n-1n;function Ri(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=t,i=e?En(e):void 0;if(i&&!Pn(i.address))throw new es({address:i.address});if(s&&!Pn(s))throw new es({address:s});if(n&&n>fy)throw new Ei({maxFeePerGas:n});if(r&&n&&r>n)throw new vi({maxFeePerGas:n,maxPriorityFeePerGas:r})}function hy(t){const e=ui(`0x${t.substring(4)}`).substring(26);return di(`0x${e}`)}async function py({hash:t,signature:e}){const n=Bn(t)?t:Ho(t),{secp256k1:r}=await Promise.resolve().then(()=>v1);return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:m,s:g,v,yParity:T}=e,I=Number(T??v),L=Xd(I);return new r.Signature(wr(m),wr(g)).addRecoveryBit(L)}const o=Bn(e)?e:Ho(e);if(bt(o)!==65)throw new Error("invalid signature length");const a=er(`0x${o.slice(130)}`),d=Xd(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(d)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Xd(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 my({hash:t,signature:e}){return hy(await py({hash:t,signature:e}))}function gy(t,e="hex"){const n=Qd(t),r=ea(new Uint8Array(n.length));return n.encode(r),e==="hex"?jt(r.bytes):r.bytes}function Qd(t){return Array.isArray(t)?yy(t.map(e=>Qd(e))):by(t)}function yy(t){const e=t.reduce((s,i)=>s+i.length,0),n=el(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 by(t){const e=typeof t=="string"?en(t):t,n=el(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 el(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 _y(t){const{chainId:e,nonce:n,to:r}=t,s=t.contractAddress??t.address,i=ui(ta(["0x05",gy([e?ke(e):"0x",s,n?ke(n):"0x"])]));return r==="bytes"?en(i):i}async function tl(t){const{authorization:e,signature:n}=t;return my({hash:_y(e),signature:n??e})}class wy extends ue{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:v,value:T}){const I=pi({from:n?.address,to:v,value:typeof T<"u"&&`${jd(T)} ${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:",I].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}function Ey(t,{docsPath:e,...n}){const r=(()=>{const s=Yd(t,n);return s instanceof Aa?t:s})();return new wy(r,{docsPath:e,...n})}class nl extends ue{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Ta extends ue{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class vy extends ue{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${tn(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class Ry 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 Ay={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function rl(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?er(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?er(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?Ay[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=xy(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 xy(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 Sy(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:rl(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 Is(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 Ry({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||Sy)(a,"getBlock")}async function sl(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function Ty(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 St(t,Is,"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 wr(o)}catch{const[i,o]=await Promise.all([n?Promise.resolve(n):St(t,Is,"getBlock")({}),St(t,sl,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new Ta;const a=o-i.baseFeePerGas;return a<0n?0n:a}}async function il(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 nl;const d=10**(o.toString().split(".")[1]?.length??0),m=T=>T*BigInt(Math.ceil(o*d))/BigInt(d),g=n||await St(t,Is,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const T=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:m,request:s,type:i});if(T!==null)return T}if(i==="eip1559"){if(typeof g.baseFeePerGas!="bigint")throw new Ta;const T=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await Ty(t,{block:g,chain:r,request:s}),I=m(g.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??I+T,maxPriorityFeePerGas:T}}return{gasPrice:s?.gasPrice??m(await St(t,sl,"getGasPrice")({}))}}async function Oy(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 er(s)}function ol(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=>jt(i))}function al(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=>jt(o))}function Iy(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 Ny(t,e,n){return t&e^~t&n}function Cy(t,e,n){return t&e^t&n^e&n}class cl extends Zo{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=Wo(this.buffer)}update(e){Ar(this),e=ci(e),tr(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=Wo(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){Ar(this),Ed(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;n[o++]=128,Ln(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(r,0),o=0);for(let v=o;v<s;v++)n[v]=0;Iy(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Wo(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 v=0;v<m;v++)a.setUint32(4*v,g[v],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 Fn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),My=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]),$n=new Uint32Array(64);class By extends cl{constructor(e=32){super(64,e,8,!1),this.A=Fn[0]|0,this.B=Fn[1]|0,this.C=Fn[2]|0,this.D=Fn[3]|0,this.E=Fn[4]|0,this.F=Fn[5]|0,this.G=Fn[6]|0,this.H=Fn[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 v=0;v<16;v++,n+=4)$n[v]=e.getUint32(n,!1);for(let v=16;v<64;v++){const T=$n[v-15],I=$n[v-2],L=un(T,7)^un(T,18)^T>>>3,M=un(I,17)^un(I,19)^I>>>10;$n[v]=M+$n[v-7]+L+$n[v-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:d,G:m,H:g}=this;for(let v=0;v<64;v++){const T=un(a,6)^un(a,11)^un(a,25),I=g+T+Ny(a,d,m)+My[v]+$n[v]|0,M=(un(r,2)^un(r,13)^un(r,22))+Cy(r,s,i)|0;g=m,m=d,d=a,a=o+I|0,o=i,i=s,s=r,r=I+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(){Ln($n)}destroy(){this.set(0,0,0,0,0,0,0,0),Ln(this.buffer)}}const ul=bd(["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))),ky=ul[0],Ly=ul[1],zn=new Uint32Array(80),jn=new Uint32Array(80);class Py extends cl{constructor(e=64){super(128,e,16,!1),this.Ah=Tt[0]|0,this.Al=Tt[1]|0,this.Bh=Tt[2]|0,this.Bl=Tt[3]|0,this.Ch=Tt[4]|0,this.Cl=Tt[5]|0,this.Dh=Tt[6]|0,this.Dl=Tt[7]|0,this.Eh=Tt[8]|0,this.El=Tt[9]|0,this.Fh=Tt[10]|0,this.Fl=Tt[11]|0,this.Gh=Tt[12]|0,this.Gl=Tt[13]|0,this.Hh=Tt[14]|0,this.Hl=Tt[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:v,Fl:T,Gh:I,Gl:L,Hh:M,Hl:C}=this;return[e,n,r,s,i,o,a,d,m,g,v,T,I,L,M,C]}set(e,n,r,s,i,o,a,d,m,g,v,T,I,L,M,C){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=v|0,this.Fl=T|0,this.Gh=I|0,this.Gl=L|0,this.Hh=M|0,this.Hl=C|0}process(e,n){for(let D=0;D<16;D++,n+=4)zn[D]=e.getUint32(n),jn[D]=e.getUint32(n+=4);for(let D=16;D<80;D++){const P=zn[D-15]|0,z=jn[D-15]|0,J=Er(P,z,1)^Er(P,z,8)^_d(P,z,7),ee=vr(P,z,1)^vr(P,z,8)^wd(P,z,7),te=zn[D-2]|0,K=jn[D-2]|0,k=Er(te,K,19)^oi(te,K,61)^_d(te,K,6),U=vr(te,K,19)^ai(te,K,61)^wd(te,K,6),j=Bm(ee,U,jn[D-7],jn[D-16]),E=km(j,J,k,zn[D-7],zn[D-16]);zn[D]=E|0,jn[D]=j|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:d,Dh:m,Dl:g,Eh:v,El:T,Fh:I,Fl:L,Gh:M,Gl:C,Hh:q,Hl:Z}=this;for(let D=0;D<80;D++){const P=Er(v,T,14)^Er(v,T,18)^oi(v,T,41),z=vr(v,T,14)^vr(v,T,18)^ai(v,T,41),J=v&I^~v&M,ee=T&L^~T&C,te=Lm(Z,z,ee,Ly[D],jn[D]),K=Pm(te,q,P,J,ky[D],zn[D]),k=te|0,U=Er(r,s,28)^oi(r,s,34)^oi(r,s,39),j=vr(r,s,28)^ai(r,s,34)^ai(r,s,39),E=r&i^r&a^i&a,c=s&o^s&d^o&d;q=M|0,Z=C|0,M=I|0,C=L|0,I=v|0,L=T|0,{h:v,l:T}=_n(m|0,g|0,K|0,k|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const p=Cm(k,j,c);r=Mm(p,K,U,E),s=p|0}({h:r,l:s}=_n(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=_n(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:d}=_n(this.Ch|0,this.Cl|0,a|0,d|0),{h:m,l:g}=_n(this.Dh|0,this.Dl|0,m|0,g|0),{h:v,l:T}=_n(this.Eh|0,this.El|0,v|0,T|0),{h:I,l:L}=_n(this.Fh|0,this.Fl|0,I|0,L|0),{h:M,l:C}=_n(this.Gh|0,this.Gl|0,M|0,C|0),{h:q,l:Z}=_n(this.Hh|0,this.Hl|0,q|0,Z|0),this.set(r,s,i,o,a,d,m,g,v,T,I,L,M,C,q,Z)}roundClean(){Ln(zn,jn)}destroy(){Ln(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const dl=Yo(()=>new By),Uy=Yo(()=>new Py),Oa=dl;function Dy(t,e){return Oa(Bn(t,{strict:!1})?Ko(t):t)}function Fy(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),s=Dy(e);return s.set([n],0),r==="bytes"?s:jt(s)}function $y(t){const{commitments:e,version:n}=t,r=t.to,s=[];for(const i of e)s.push(Fy({commitment:i,to:r,version:n}));return s}const ll=6,fl=32,Ia=4096,hl=fl*Ia,pl=hl*ll-1-1*Ia*ll;class zy extends ue{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class jy extends ue{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Vy(t){const e=typeof t.data=="string"?en(t.data):t.data,n=bt(e);if(!n)throw new jy;if(n>pl)throw new zy({maxSize:pl,size:n});const r=[];let s=!0,i=0;for(;s;){const o=ea(new Uint8Array(hl));let a=0;for(;a<Ia;){const d=e.slice(i,i+(fl-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=>jt(o.bytes))}function Gy(t){const{data:e,kzg:n,to:r}=t,s=t.blobs??Vy({data:e}),i=t.commitments??ol({blobs:s,kzg:n,to:r}),o=t.proofs??al({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 Hy(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 Kg({transaction:t})}function ml(t,{docsPath:e,...n}){const r=(()=>{const s=Yd(t,n);return s instanceof Aa?t:s})();return new Wg(r,{docsPath:e,...n})}async function Na(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return er(e)}async function qy(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:v,maxFeePerGas:T,maxPriorityFeePerGas:I,nonce:L,nonceManager:M,to:C,type:q,value:Z,...D}=e,P=await(async()=>{if(!n||!M||typeof L<"u")return L;const te=En(n),K=i?i.id:await St(t,Na,"getChainId")({});return await M.consume({address:te.address,chainId:K,client:t})})();Ri(e);const z=i?.formatters?.transactionRequest?.format,ee=(z||Sa)({...xa(D,{format:z}),account:n?En(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:o,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:v,maxFeePerGas:T,maxPriorityFeePerGas:I,nonce:P,to:C,type:q,value:Z},"fillTransaction");try{const te=await t.request({method:"eth_fillTransaction",params:[ee]}),k=(i?.formatters?.transaction?.format||rl)(te.tx);delete k.blockHash,delete k.blockNumber,delete k.r,delete k.s,delete k.transactionIndex,delete k.v,delete k.yParity,k.data=k.input,k.gas&&(k.gas=e.gas??k.gas),k.gasPrice&&(k.gasPrice=e.gasPrice??k.gasPrice),k.maxFeePerBlobGas&&(k.maxFeePerBlobGas=e.maxFeePerBlobGas??k.maxFeePerBlobGas),k.maxFeePerGas&&(k.maxFeePerGas=e.maxFeePerGas??k.maxFeePerGas),k.maxPriorityFeePerGas&&(k.maxPriorityFeePerGas=e.maxPriorityFeePerGas??k.maxPriorityFeePerGas),k.nonce&&(k.nonce=e.nonce??k.nonce);const U=await(async()=>{if(typeof i?.fees?.baseFeeMultiplier=="function"){const p=await St(t,Is,"getBlock")({});return i.fees.baseFeeMultiplier({block:p,client:t,request:e})}return i?.fees?.baseFeeMultiplier??1.2})();if(U<1)throw new nl;const E=10**(U.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(U*E))/BigInt(E);return k.maxFeePerGas&&!e.maxFeePerGas&&(k.maxFeePerGas=c(k.maxFeePerGas)),k.gasPrice&&!e.gasPrice&&(k.gasPrice=c(k.gasPrice)),{raw:te.raw,transaction:{from:ee.from,...k}}}catch(te){throw ml(te,{...e,chain:t.chain})}}const gl=["blobVersionedHashes","chainId","fees","gas","nonce","type"],yl=new Map,Ca=new rs(128);async function bl(t,e){let n=e;n.account??=t.account,n.parameters??=gl;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 St(t,Na,"getChainId")({}),d))}const g=r&&En(r);let v=n.nonce;if(o.includes("nonce")&&typeof v>"u"&&g&&i){const P=await m();v=await i.consume({address:g.address,chainId:P,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillTransaction"}),v??=n.nonce);const I=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Ca.get(t.uid)===!1||!["fees","gas"].some(z=>o.includes(z))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof v!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await St(t,qy,"fillTransaction")({...n,nonce:v}).then(P=>{const{chainId:z,from:J,gas:ee,gasPrice:te,nonce:K,maxFeePerBlobGas:k,maxFeePerGas:U,maxPriorityFeePerGas:j,type:E,...c}=P.transaction;return Ca.set(t.uid,!0),{...n,...J?{from:J}:{},...E&&!n.type?{type:E}:{},...typeof z<"u"?{chainId:z}:{},...typeof ee<"u"?{gas:ee}:{},...typeof te<"u"?{gasPrice:te}:{},...typeof K<"u"?{nonce:K}:{},...typeof k<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxFeePerBlobGas:k}:{},...typeof U<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxFeePerGas:U}:{},...typeof j<"u"&&n.type!=="legacy"&&n.type!=="eip2930"?{maxPriorityFeePerGas:j}:{},..."nonceKey"in c&&typeof c.nonceKey<"u"?{nonceKey:c.nonceKey}:{}}}).catch(P=>{const z=P;return z.name!=="TransactionExecutionError"||z.walk?.(ee=>{const te=ee;return te.name==="MethodNotFoundRpcError"||te.name==="MethodNotSupportedRpcError"||te.message?.includes("eth_fillTransaction is not available")})&&Ca.set(t.uid,!1),n}):n;v??=I.nonce,n={...I,...g?{from:g?.address}:{},...v?{nonce:v}:{}};const{blobs:L,gas:M,kzg:C,type:q}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillParameters"}));let Z;async function D(){return Z||(Z=await St(t,Is,"getBlock")({blockTag:"latest"}),Z)}if(o.includes("nonce")&&typeof v>"u"&&g&&!i&&(n.nonce=await St(t,Oy,"getTransactionCount")({address:g.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&L&&C){const P=ol({blobs:L,kzg:C});if(o.includes("blobVersionedHashes")){const z=$y({commitments:P,to:"hex"});n.blobVersionedHashes=z}if(o.includes("sidecars")){const z=al({blobs:L,commitments:P,kzg:C}),J=Gy({blobs:L,commitments:P,proofs:z,to:"hex"});n.sidecars=J}}if(o.includes("chainId")&&(n.chainId=await m()),(o.includes("fees")||o.includes("type"))&&typeof q>"u")try{n.type=Hy(n)}catch{let P=yl.get(t.uid);typeof P>"u"&&(P=typeof(await D())?.baseFeePerGas=="bigint",yl.set(t.uid,P)),n.type=P?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const P=await D(),{maxFeePerGas:z,maxPriorityFeePerGas:J}=await il(t,{block:P,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<J)throw new vy({maxPriorityFeePerGas:J});n.maxPriorityFeePerGas=J,n.maxFeePerGas=z}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new Ta;if(typeof n.gasPrice>"u"){const P=await D(),{gasPrice:z}=await il(t,{block:P,chain:s,request:n,type:"legacy"});n.gasPrice=z}}return o.includes("gas")&&typeof M>"u"&&(n.gas=await St(t,Ky,"estimateGas")({...n,account:g,prepare:g?.type==="local"?[]:["blobVersionedHashes"]})),a?.fn&&a.runAt?.includes("afterFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"afterFillParameters"})),Ri(n),delete n.parameters,n}async function Ky(t,e){const{account:n=t.account,prepare:r=!0}=e,s=n?En(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 tl({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:v,blockTag:T,data:I,gas:L,gasPrice:M,maxFeePerBlobGas:C,maxFeePerGas:q,maxPriorityFeePerGas:Z,nonce:D,value:P,stateOverride:z,...J}=r?await bl(t,{...e,parameters:i,to:o}):e;if(L&&e.gas!==L)return L;const te=(typeof v=="bigint"?ke(v):void 0)||T,K=ly(z);Ri(e);const k=t.chain?.formatters?.transactionRequest?.format,j=(k||Sa)({...xa(J,{format:k}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:I,gasPrice:M,maxFeePerBlobGas:C,maxFeePerGas:q,maxPriorityFeePerGas:Z,nonce:D,to:o,value:P},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:K?[j,te??t.experimental_blockTag??"latest",K]:te?[j,te]:[j]}))}catch(o){throw Ey(o,{...e,account:s,chain:t.chain})}}const Ai=new rs(8192);function Wy(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(Ai.get(n))return Ai.get(n);const r=t().finally(()=>Ai.delete(n));return Ai.set(n,r),r}async function Zy(t){return new Promise(e=>setTimeout(e,t))}function Yy(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 Zy(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 Jy(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 rr(new Error("method not supported"),{method:m});if(i?.include&&!i.include.includes(m))throw new rr(new Error("method not supported"),{method:m});const g=s?qo(`${d}.${hi(n)}`):void 0;return Wy(()=>Yy(async()=>{try{return await t(n)}catch(v){const T=v;switch(T.code){case os.code:throw new os(T);case as.code:throw new as(T);case cs.code:throw new cs(T,{method:n.method});case us.code:throw new us(T);case nr.code:throw new nr(T);case Sr.code:throw new Sr(T);case ds.code:throw new ds(T);case ls.code:throw new ls(T);case fs.code:throw new fs(T);case rr.code:throw new rr(T,{method:n.method});case Tr.code:throw new Tr(T);case hs.code:throw new hs(T);case mi.code:throw new mi(T);case ps.code:throw new ps(T);case ms.code:throw new ms(T);case gs.code:throw new gs(T);case ua.code:throw new ua(T);case Or.code:throw new Or(T);case ys.code:throw new ys(T);case bs.code:throw new bs(T);case _s.code:throw new _s(T);case ws.code:throw new ws(T);case Es.code:throw new Es(T);case vs.code:throw new vs(T);case Rs.code:throw new Rs(T);case 5e3:throw new mi(T);case As.code:throw new As(T);default:throw v instanceof ue?v:new ty(T)}}},{delay:({count:v,error:T})=>{if(T&&T instanceof Gd){const I=T?.headers?.get("Retry-After");if(I?.match(/\d/))return Number.parseInt(I,10)*1e3}return~~(1<<v)*o},retryCount:a,shouldRetry:({error:v})=>Xy(v)}),{enabled:s,id:g})}}function Xy(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Tr.code||t.code===nr.code:t instanceof Gd&&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 Qy({chain:t,currentChainId:e}){if(!t)throw new Dg;if(e!==t.id)throw new Ug({chain:t,currentChainId:e})}class _l extends Zo{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Dm(e);const r=ci(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),Ln(i)}update(e){return Ar(this),this.iHash.update(e),this}digestInto(e){Ar(this),tr(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 wl=(t,e,n)=>new _l(t,e).update(n).digest();wl.create=(t,e)=>new _l(t,e);const Ht=BigInt(0),Et=BigInt(1),ir=BigInt(2),e1=BigInt(3),El=BigInt(4),vl=BigInt(5),Rl=BigInt(8);function ze(t,e){const n=t%e;return n>=Ht?n:e+n}function He(t,e,n){let r=t;for(;e-- >Ht;)r*=r,r%=n;return r}function Ma(t,e){if(t===Ht)throw new Error("invert: expected non-zero number");if(e<=Ht)throw new Error("invert: expected positive modulus, got "+e);let n=ze(t,e),r=e,s=Ht,i=Et;for(;n!==Ht;){const a=r/n,d=r%n,m=s-i*a;r=n,n=d,s=i,i=m}if(r!==Et)throw new Error("invert: does not exist");return ze(s,e)}function Al(t,e){const n=(t.ORDER+Et)/El,r=t.pow(e,n);if(!t.eql(t.sqr(r),e))throw new Error("Cannot find square root");return r}function t1(t,e){const n=(t.ORDER-vl)/Rl,r=t.mul(e,ir),s=t.pow(r,n),i=t.mul(e,s),o=t.mul(t.mul(i,ir),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 n1(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let e=t-Et,n=0;for(;e%ir===Ht;)e/=ir,n++;let r=ir;const s=Ns(t);for(;xl(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Al;let i=s.pow(r,e);const o=(e+Et)/ir;return function(d,m){if(d.is0(m))return m;if(xl(d,m)!==1)throw new Error("Cannot find square root");let g=n,v=d.mul(d.ONE,i),T=d.pow(m,e),I=d.pow(m,o);for(;!d.eql(T,d.ONE);){if(d.is0(T))return d.ZERO;let L=1,M=d.sqr(T);for(;!d.eql(M,d.ONE);)if(L++,M=d.sqr(M),L===g)throw new Error("Cannot find square root");const C=Et<<BigInt(g-L-1),q=d.pow(v,C);g=L,v=d.sqr(q),T=d.mul(T,v),I=d.mul(I,q)}return I}}function r1(t){return t%El===e1?Al:t%Rl===vl?t1:n1(t)}const s1=(t,e)=>(ze(t,e)&Et)===Et,i1=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function o1(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},n=i1.reduce((r,s)=>(r[s]="function",r),e);return Os(t,n)}function a1(t,e,n){if(n<Ht)throw new Error("invalid exponent, negatives unsupported");if(n===Ht)return t.ONE;if(n===Et)return e;let r=t.ONE,s=e;for(;n>Ht;)n&Et&&(r=t.mul(r,s)),s=t.sqr(s),n>>=Et;return r}function Ba(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 xl(t,e){const n=(t.ORDER-Et)/ir,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 Sl(t,e){e!==void 0&&ts(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Ns(t,e,n=!1,r={}){if(t<=Ht)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:i}=Sl(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:_i(s),ZERO:Ht,ONE:Et,create:d=>ze(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return Ht<=d&&d<t},is0:d=>d===Ht,isOdd:d=>(d&Et)===Et,neg:d=>ze(-d,t),eql:(d,m)=>d===m,sqr:d=>ze(d*d,t),add:(d,m)=>ze(d+m,t),sub:(d,m)=>ze(d-m,t),mul:(d,m)=>ze(d*m,t),pow:(d,m)=>a1(a,d,m),div:(d,m)=>ze(d*Ma(m,t),t),sqrN:d=>d*d,addN:(d,m)=>d+m,subN:(d,m)=>d-m,mulN:(d,m)=>d*m,inv:d=>Ma(d,t),sqrt:r.sqrt||(d=>(o||(o=r1(t)),o(a,d))),toBytes:d=>n?bi(d,i):Ts(d,i),fromBytes:d=>{if(d.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+d.length);return n?Ss(d):sr(d)},invertBatch:d=>Ba(a,d),cmov:(d,m,g)=>g?m:d});return Object.freeze(a)}function Tl(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 Ol(t){const e=Tl(t);return e+Math.ceil(e/2)}function c1(t,e,n=!1){const r=t.length,s=Tl(e),i=Ol(e);if(r<16||r<i||r>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+r);const o=n?Ss(t):sr(t),a=ze(o,e-Et)+Et;return n?bi(a,s):Ts(a,s)}const Il=BigInt(0),ka=BigInt(1);function La(t,e){const n=e.negate();return t?n:e}function Nl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Pa(t,e){Nl(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=_i(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function Cl(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+=ka);const m=e*r,g=m+Math.abs(a)-1,v=a===0,T=a<0,I=e%2!==0;return{nextN:d,offset:g,isZero:v,isNeg:T,isNegF:I,offsetF:m}}function u1(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 d1(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 Ua=new WeakMap,Ml=new WeakMap;function Da(t){return Ml.get(t)||1}function Bl(t,e){return{constTimeNegate:La,hasPrecomputes(n){return Da(n)!==1},unsafeLadder(n,r,s=t.ZERO){let i=n;for(;r>Il;)r&ka&&(s=s.add(i)),i=i.double(),r>>=ka;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Pa(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=Pa(n,e);for(let d=0;d<a.windows;d++){const{nextN:m,offset:g,isZero:v,isNeg:T,isNegF:I,offsetF:L}=Cl(s,d,a);s=m,v?o=o.add(La(I,r[L])):i=i.add(La(T,r[g]))}return{p:i,f:o}},wNAFUnsafe(n,r,s,i=t.ZERO){const o=Pa(n,e);for(let a=0;a<o.windows&&s!==Il;a++){const{nextN:d,offset:m,isZero:g,isNeg:v}=Cl(s,a,o);if(s=d,!g){const T=r[m];i=i.add(v?T.negate():T)}}return i},getPrecomputes(n,r,s){let i=Ua.get(r);return i||(i=this.precomputeWindow(r,n),n!==1&&Ua.set(r,s(i))),i},wNAFCached(n,r,s){const i=Da(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const o=Da(n);return o===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,n,s),r,i)},setWindowSize(n,r){Nl(r,e),Ml.set(n,r),Ua.delete(n)}}}function kl(t,e,n,r){u1(n,t),d1(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=iy(BigInt(s));let d=1;a>12?d=a-3:a>4?d=a-2:a>0&&(d=2);const m=_i(d),g=new Array(Number(m)+1).fill(o),v=Math.floor((e.BITS-1)/d)*d;let T=o;for(let I=v;I>=0;I-=d){g.fill(o);for(let M=0;M<i;M++){const C=r[M],q=Number(C>>BigInt(I)&m);g[q]=g[q].add(n[M])}let L=o;for(let M=g.length-1,C=o;M>0;M--)C=C.add(g[M]),L=L.add(C);if(T=T.add(L),I!==0)for(let M=0;M<d;M++)T=T.double()}return T}function Fa(t){return o1(t.Fp),Os(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Sl(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}function Ll(t){t.lowS!==void 0&&Dn("lowS",t.lowS),t.prehash!==void 0&&Dn("prehash",t.prehash)}function l1(t){const e=Fa(t);Os(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 f1 extends Error{constructor(e=""){super(e)}}const Rn={Err:f1,_tlv:{encode:(t,e)=>{const{Err:n}=Rn;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=gi(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?gi(s.length/2|128):"";return gi(t)+i+s+e},decode(t,e){const{Err:n}=Rn;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}=Rn;if(t<An)throw new e("integer: negative integers are not allowed");let n=gi(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}=Rn;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 sr(t)}},toSig(t){const{Err:e,_int:n,_tlv:r}=Rn,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}=Rn,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 $a(t,e){return Ir(Ts(t,e))}const An=BigInt(0),_t=BigInt(1);BigInt(2);const za=BigInt(3),h1=BigInt(4);function p1(t){const e=l1(t),{Fp:n}=e,r=Ns(e.n,e.nBitLength),s=e.toBytes||((D,P,z)=>{const J=P.toAffine();return Nr(Uint8Array.from([4]),n.toBytes(J.x),n.toBytes(J.y))}),i=e.fromBytes||(D=>{const P=D.subarray(1),z=n.fromBytes(P.subarray(0,n.BYTES)),J=n.fromBytes(P.subarray(n.BYTES,2*n.BYTES));return{x:z,y:J}});function o(D){const{a:P,b:z}=e,J=n.sqr(D),ee=n.mul(J,D);return n.add(n.add(ee,n.mul(D,P)),z)}function a(D,P){const z=n.sqr(P),J=o(D);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,za),h1),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(D){return pa(D,_t,e.n)}function v(D){const{allowedPrivateKeyLengths:P,nByteLength:z,wrapPrivateKey:J,n:ee}=e;if(P&&typeof D!="bigint"){if(xs(D)&&(D=Ir(D)),typeof D!="string"||!P.includes(D.length))throw new Error("invalid private key");D=D.padStart(z*2,"0")}let te;try{te=typeof D=="bigint"?D:sr(Je("private key",D,z))}catch{throw new Error("invalid private key, expected hex or "+z+" bytes, got "+typeof D)}return J&&(te=ze(te,ee)),nn("private key",te,_t,ee),te}function T(D){if(!(D instanceof M))throw new Error("ProjectivePoint expected")}const I=wi((D,P)=>{const{px:z,py:J,pz:ee}=D;if(n.eql(ee,n.ONE))return{x:z,y:J};const te=D.is0();P==null&&(P=te?n.ONE:n.inv(ee));const K=n.mul(z,P),k=n.mul(J,P),U=n.mul(ee,P);if(te)return{x:n.ZERO,y:n.ZERO};if(!n.eql(U,n.ONE))throw new Error("invZ was invalid");return{x:K,y:k}}),L=wi(D=>{if(D.is0()){if(e.allowInfinityPoint&&!n.is0(D.py))return;throw new Error("bad point: ZERO")}const{x:P,y:z}=D.toAffine();if(!n.isValid(P)||!n.isValid(z))throw new Error("bad point: x or y not FE");if(!a(P,z))throw new Error("bad point: equation left != right");if(!D.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class M{constructor(P,z,J){if(P==null||!n.isValid(P))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=P,this.py=z,this.pz=J,Object.freeze(this)}static fromAffine(P){const{x:z,y:J}=P||{};if(!P||!n.isValid(z)||!n.isValid(J))throw new Error("invalid affine point");if(P instanceof M)throw new Error("projective point not allowed");const ee=te=>n.eql(te,n.ZERO);return ee(z)&&ee(J)?M.ZERO:new M(z,J,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(P){const z=Ba(n,P.map(J=>J.pz));return P.map((J,ee)=>J.toAffine(z[ee])).map(M.fromAffine)}static fromHex(P){const z=M.fromAffine(i(Je("pointHex",P)));return z.assertValidity(),z}static fromPrivateKey(P){return M.BASE.multiply(v(P))}static msm(P,z){return kl(M,r,P,z)}_setWindowSize(P){Z.setWindowSize(this,P)}assertValidity(){L(this)}hasEvenY(){const{y:P}=this.toAffine();if(n.isOdd)return!n.isOdd(P);throw new Error("Field doesn't support isOdd")}equals(P){T(P);const{px:z,py:J,pz:ee}=this,{px:te,py:K,pz:k}=P,U=n.eql(n.mul(z,k),n.mul(te,ee)),j=n.eql(n.mul(J,k),n.mul(K,ee));return U&&j}negate(){return new M(this.px,n.neg(this.py),this.pz)}double(){const{a:P,b:z}=e,J=n.mul(z,za),{px:ee,py:te,pz:K}=this;let k=n.ZERO,U=n.ZERO,j=n.ZERO,E=n.mul(ee,ee),c=n.mul(te,te),p=n.mul(K,K),y=n.mul(ee,te);return y=n.add(y,y),j=n.mul(ee,K),j=n.add(j,j),k=n.mul(P,j),U=n.mul(J,p),U=n.add(k,U),k=n.sub(c,U),U=n.add(c,U),U=n.mul(k,U),k=n.mul(y,k),j=n.mul(J,j),p=n.mul(P,p),y=n.sub(E,p),y=n.mul(P,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),U=n.add(U,E),p=n.mul(te,K),p=n.add(p,p),E=n.mul(p,y),k=n.sub(k,E),j=n.mul(p,c),j=n.add(j,j),j=n.add(j,j),new M(k,U,j)}add(P){T(P);const{px:z,py:J,pz:ee}=this,{px:te,py:K,pz:k}=P;let U=n.ZERO,j=n.ZERO,E=n.ZERO;const c=e.a,p=n.mul(e.b,za);let y=n.mul(z,te),x=n.mul(J,K),R=n.mul(ee,k),A=n.add(z,J),N=n.add(te,K);A=n.mul(A,N),N=n.add(y,x),A=n.sub(A,N),N=n.add(z,ee);let _=n.add(te,k);return N=n.mul(N,_),_=n.add(y,R),N=n.sub(N,_),_=n.add(J,ee),U=n.add(K,k),_=n.mul(_,U),U=n.add(x,R),_=n.sub(_,U),E=n.mul(c,N),U=n.mul(p,R),E=n.add(U,E),U=n.sub(x,E),E=n.add(x,E),j=n.mul(U,E),x=n.add(y,y),x=n.add(x,y),R=n.mul(c,R),N=n.mul(p,N),x=n.add(x,R),R=n.sub(y,R),R=n.mul(c,R),N=n.add(N,R),y=n.mul(x,N),j=n.add(j,y),y=n.mul(_,N),U=n.mul(A,U),U=n.sub(U,y),y=n.mul(A,x),E=n.mul(_,E),E=n.add(E,y),new M(U,j,E)}subtract(P){return this.add(P.negate())}is0(){return this.equals(M.ZERO)}wNAF(P){return Z.wNAFCached(this,P,M.normalizeZ)}multiplyUnsafe(P){const{endo:z,n:J}=e;nn("scalar",P,An,J);const ee=M.ZERO;if(P===An)return ee;if(this.is0()||P===_t)return this;if(!z||Z.hasPrecomputes(this))return Z.wNAFCachedUnsafe(this,P,M.normalizeZ);let{k1neg:te,k1:K,k2neg:k,k2:U}=z.splitScalar(P),j=ee,E=ee,c=this;for(;K>An||U>An;)K&_t&&(j=j.add(c)),U&_t&&(E=E.add(c)),c=c.double(),K>>=_t,U>>=_t;return te&&(j=j.negate()),k&&(E=E.negate()),E=new M(n.mul(E.px,z.beta),E.py,E.pz),j.add(E)}multiply(P){const{endo:z,n:J}=e;nn("scalar",P,_t,J);let ee,te;if(z){const{k1neg:K,k1:k,k2neg:U,k2:j}=z.splitScalar(P);let{p:E,f:c}=this.wNAF(k),{p,f:y}=this.wNAF(j);E=Z.constTimeNegate(K,E),p=Z.constTimeNegate(U,p),p=new M(n.mul(p.px,z.beta),p.py,p.pz),ee=E.add(p),te=c.add(y)}else{const{p:K,f:k}=this.wNAF(P);ee=K,te=k}return M.normalizeZ([ee,te])[0]}multiplyAndAddUnsafe(P,z,J){const ee=M.BASE,te=(k,U)=>U===An||U===_t||!k.equals(ee)?k.multiplyUnsafe(U):k.multiply(U),K=te(this,z).add(te(P,J));return K.is0()?void 0:K}toAffine(P){return I(this,P)}isTorsionFree(){const{h:P,isTorsionFree:z}=e;if(P===_t)return!0;if(z)return z(M,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:P,clearCofactor:z}=e;return P===_t?this:z?z(M,this):this.multiplyUnsafe(e.h)}toRawBytes(P=!0){return Dn("isCompressed",P),this.assertValidity(),s(M,this,P)}toHex(P=!0){return Dn("isCompressed",P),Ir(this.toRawBytes(P))}}M.BASE=new M(e.Gx,e.Gy,n.ONE),M.ZERO=new M(n.ZERO,n.ONE,n.ZERO);const{endo:C,nBitLength:q}=e,Z=Bl(M,C?Math.ceil(q/2):q);return{CURVE:e,ProjectivePoint:M,normPrivateKeyToScalar:v,weierstrassEquation:o,isWithinCurveOrder:g}}function m1(t){const e=Fa(t);return Os(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function g1(t){const e=m1(t),{Fp:n,n:r,nByteLength:s,nBitLength:i}=e,o=n.BYTES+1,a=2*n.BYTES+1;function d(p){return ze(p,r)}function m(p){return Ma(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:v,weierstrassEquation:T,isWithinCurveOrder:I}=p1({...e,toBytes(p,y,x){const R=y.toAffine(),A=n.toBytes(R.x),N=Nr;return Dn("isCompressed",x),x?N(Uint8Array.from([y.hasEvenY()?2:3]),A):N(Uint8Array.from([4]),A,n.toBytes(R.y))},fromBytes(p){const y=p.length,x=p[0],R=p.subarray(1);if(y===o&&(x===2||x===3)){const A=sr(R);if(!pa(A,_t,n.ORDER))throw new Error("Point is not on curve");const N=T(A);let _;try{_=n.sqrt(N)}catch(w){const O=w instanceof Error?": "+w.message:"";throw new Error("Point is not on curve"+O)}const u=(_&_t)===_t;return(x&1)===1!==u&&(_=n.neg(_)),{x:A,y:_}}else if(y===a&&x===4){const A=n.fromBytes(R.subarray(0,n.BYTES)),N=n.fromBytes(R.subarray(n.BYTES,2*n.BYTES));return{x:A,y:N}}else{const A=o,N=a;throw new Error("invalid Point, expected length of "+A+", or uncompressed "+N+", got "+y)}}});function L(p){const y=r>>_t;return p>y}function M(p){return L(p)?d(-p):p}const C=(p,y,x)=>sr(p.slice(y,x));class q{constructor(y,x,R){nn("r",y,_t,r),nn("s",x,_t,r),this.r=y,this.s=x,R!=null&&(this.recovery=R),Object.freeze(this)}static fromCompact(y){const x=s;return y=Je("compactSignature",y,x*2),new q(C(y,0,x),C(y,x,2*x))}static fromDER(y){const{r:x,s:R}=Rn.toSig(Je("DER",y));return new q(x,R)}assertValidity(){}addRecoveryBit(y){return new q(this.r,this.s,y)}recoverPublicKey(y){const{r:x,s:R,recovery:A}=this,N=ee(Je("msgHash",y));if(A==null||![0,1,2,3].includes(A))throw new Error("recovery id invalid");const _=A===2||A===3?x+e.n:x;if(_>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=(A&1)===0?"02":"03",l=g.fromHex(u+$a(_,n.BYTES)),w=m(_),O=d(-N*w),$=d(R*w),W=g.BASE.multiplyAndAddUnsafe(l,O,$);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return L(this.s)}normalizeS(){return this.hasHighS()?new q(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return yi(this.toDERHex())}toDERHex(){return Rn.hexFromSig(this)}toCompactRawBytes(){return yi(this.toCompactHex())}toCompactHex(){const y=s;return $a(this.r,y)+$a(this.s,y)}}const Z={isValidPrivateKey(p){try{return v(p),!0}catch{return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const p=Ol(e.n);return c1(e.randomBytes(p),e.n)},precompute(p=8,y=g.BASE){return y._setWindowSize(p),y.multiply(BigInt(3)),y}};function D(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function P(p){if(typeof p=="bigint")return!1;if(p instanceof g)return!0;const x=Je("key",p).length,R=n.BYTES,A=R+1,N=2*R+1;if(!(e.allowedPrivateKeyLengths||s===A))return x===A||x===N}function z(p,y,x=!0){if(P(p)===!0)throw new Error("first arg must be private key");if(P(y)===!1)throw new Error("second arg must be public key");return g.fromHex(y).multiply(v(p)).toRawBytes(x)}const J=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const y=sr(p),x=p.length*8-i;return x>0?y>>BigInt(x):y},ee=e.bits2int_modN||function(p){return d(J(p))},te=_i(i);function K(p){return nn("num < 2^"+i,p,An,te),Ts(p,s)}function k(p,y,x=U){if(["recovered","canonical"].some(oe=>oe in x))throw new Error("sign() legacy options not supported");const{hash:R,randomBytes:A}=e;let{lowS:N,prehash:_,extraEntropy:u}=x;N==null&&(N=!0),p=Je("msgHash",p),Ll(x),_&&(p=Je("prehashed msgHash",R(p)));const l=ee(p),w=v(y),O=[K(w),K(l)];if(u!=null&&u!==!1){const oe=u===!0?A(n.BYTES):u;O.push(Je("extraEntropy",oe))}const $=Nr(...O),W=l;function re(oe){const Ce=J(oe);if(!I(Ce))return;const ve=m(Ce),Ee=g.BASE.multiply(Ce).toAffine(),De=d(Ee.x);if(De===An)return;const Re=d(ve*d(W+De*w));if(Re===An)return;let Ie=(Ee.x===De?0:2)|Number(Ee.y&_t),mn=Re;return N&&L(Re)&&(mn=M(Re),Ie^=1),new q(De,mn,Ie)}return{seed:$,k2sig:re}}const U={lowS:e.lowS,prehash:!1},j={lowS:e.lowS,prehash:!1};function E(p,y,x=U){const{seed:R,k2sig:A}=k(p,y,x),N=e;return oy(N.hash.outputLen,N.nByteLength,N.hmac)(R,A)}g.BASE._setWindowSize(8);function c(p,y,x,R=j){const A=p;y=Je("msgHash",y),x=Je("publicKey",x);const{lowS:N,prehash:_,format:u}=R;if(Ll(R),"strict"in R)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 A=="string"||xs(A),w=!l&&!u&&typeof A=="object"&&A!==null&&typeof A.r=="bigint"&&typeof A.s=="bigint";if(!l&&!w)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let O,$;try{if(w&&(O=new q(A.r,A.s)),l){try{u!=="compact"&&(O=q.fromDER(A))}catch(Ie){if(!(Ie instanceof Rn.Err))throw Ie}!O&&u!=="der"&&(O=q.fromCompact(A))}$=g.fromHex(x)}catch{return!1}if(!O||N&&O.hasHighS())return!1;_&&(y=e.hash(y));const{r:W,s:re}=O,oe=ee(y),Ce=m(re),ve=d(oe*Ce),Ee=d(W*Ce),De=g.BASE.multiplyAndAddUnsafe($,ve,Ee)?.toAffine();return De?d(De.x)===W:!1}return{CURVE:e,getPublicKey:D,getSharedSecret:z,sign:E,verify:c,ProjectivePoint:g,Signature:q,utils:Z}}function y1(t){return{hash:t,hmac:(e,...n)=>wl(t,e,Gm(...n)),randomBytes:Rd}}function b1(t,e){const n=r=>g1({...t,...y1(r)});return{...n(e),create:n}}const Pl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ul=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1=BigInt(0),w1=BigInt(1),ja=BigInt(2),Dl=(t,e)=>(t+e/ja)/e;function E1(t){const e=Pl,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,v=He(g,n,e)*g%e,T=He(v,n,e)*g%e,I=He(T,ja,e)*m%e,L=He(I,s,e)*I%e,M=He(L,i,e)*L%e,C=He(M,a,e)*M%e,q=He(C,d,e)*C%e,Z=He(q,a,e)*M%e,D=He(Z,n,e)*g%e,P=He(D,o,e)*L%e,z=He(P,r,e)*m%e,J=He(z,ja,e);if(!Va.eql(Va.sqr(J),t))throw new Error("Cannot find square root");return J}const Va=Ns(Pl,void 0,void 0,{sqrt:E1}),Ga=b1({a:_1,b:BigInt(7),Fp:Va,n:Ul,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Ul,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-w1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=Dl(i*t,e),d=Dl(-r*t,e);let m=ze(t-a*n-d*s,e),g=ze(-a*r-d*i,e);const v=m>o,T=g>o;if(v&&(m=e-m),T&&(g=e-g),m>o||g>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:v,k1:m,k2neg:T,k2:g}}}},dl),v1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:Ga},Symbol.toStringTag,{value:"Module"}));class Fl 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 Ha extends ue{constructor({docsPath:e,metaMessages:n,type:r}){super(`Account type "${r}" is not supported.`,{docsPath:e,metaMessages:n,name:"AccountTypeNotSupportedError"})}}async function R1(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const qa=new rs(128);async function $l(t,e){const{account:n=t.account,assertChainId:r=!0,chain:s=t.chain,accessList:i,authorizationList:o,blobs:a,data:d,dataSuffix:m=typeof t.dataSuffix=="string"?t.dataSuffix:t.dataSuffix?.value,gas:g,gasPrice:v,maxFeePerBlobGas:T,maxFeePerGas:I,maxPriorityFeePerGas:L,nonce:M,type:C,value:q,...Z}=e;if(typeof n>"u")throw new Fl({docsPath:"/docs/actions/wallet/sendTransaction"});const D=n?En(n):null;try{Ri(e);const P=await(async()=>{if(e.to)return e.to;if(e.to!==null&&o&&o.length>0)return await tl({authorization:o[0]}).catch(()=>{throw new ue("`to` is required. Could not infer from `authorizationList`.")})})();if(D?.type==="json-rpc"||D===null){let z;s!==null&&(z=await St(t,Na,"getChainId")({}),r&&Qy({currentChainId:z,chain:s}));const J=t.chain?.formatters?.transactionRequest?.format,te=(J||Sa)({...xa(Z,{format:J}),accessList:i,account:D,authorizationList:o,blobs:a,chainId:z,data:m?Un([d??"0x",m]):d,gas:g,gasPrice:v,maxFeePerBlobGas:T,maxFeePerGas:I,maxPriorityFeePerGas:L,nonce:M,to:P,type:C,value:q},"sendTransaction"),K=qa.get(t.uid),k=K?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:k,params:[te]},{retryCount:0})}catch(U){if(K===!1)throw U;const j=U;if(j.name==="InvalidInputRpcError"||j.name==="InvalidParamsRpcError"||j.name==="MethodNotFoundRpcError"||j.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[te]},{retryCount:0}).then(E=>(qa.set(t.uid,!0),E)).catch(E=>{const c=E;throw c.name==="MethodNotFoundRpcError"||c.name==="MethodNotSupportedRpcError"?(qa.set(t.uid,!1),j):c});throw j}}if(D?.type==="local"){const z=await St(t,bl,"prepareTransactionRequest")({account:D,accessList:i,authorizationList:o,blobs:a,chain:s,data:m?Un([d??"0x",m]):d,gas:g,gasPrice:v,maxFeePerBlobGas:T,maxFeePerGas:I,maxPriorityFeePerGas:L,nonce:M,nonceManager:D.nonceManager,parameters:[...gl,"sidecars"],type:C,value:q,...Z,to:P}),J=s?.serializers?.transaction,ee=await D.signTransaction(z,{serializer:J});return await St(t,R1,"sendRawTransaction")({serializedTransaction:ee})}throw D?.type==="smart"?new Ha({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new Ha({docsPath:"/docs/actions/wallet/sendTransaction",type:D?.type})}catch(P){throw P instanceof Ha?P:ml(P,{...e,account:D,chain:e.chain||void 0})}}async function xi(t,e){return xi.internal(t,$l,"sendTransaction",e)}(function(t){async function e(n,r,s,i){const{abi:o,account:a=n.account,address:d,args:m,functionName:g,...v}=i;if(typeof a>"u")throw new Fl({docsPath:"/docs/contract/writeContract"});const T=a?En(a):null,I=Pg({abi:o,args:m,functionName:g});try{return await St(n,r,s)({data:I,to:d,account:T,...v})}catch(L){throw ry(L,{abi:o,address:d,args:m,docsPath:"/docs/contract/writeContract",functionName:g,sender:T?.address})}}t.internal=e})(xi||(xi={}));function zl(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 A1="3.4.1",x1=()=>`@wagmi/core@${A1}`;var jl=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)},Si,Vl;let or=class Ru extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return x1()}constructor(e,n={}){super(),Si.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 Ru?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Ru&&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 jl(this,Si,"m",Vl).call(this,this,e)}};Si=new WeakSet,Vl=function t(e,n){return n?.(e)?e:e.cause?jl(this,Si,"m",t).call(this,e.cause,n):e};class Gl extends or{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class S1 extends or{constructor(){super("Connector already connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorAlreadyConnectedError"})}}class T1 extends or{constructor(){super("Connector not connected."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ConnectorNotConnectedError"})}}class O1 extends or{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 I1 extends or{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 N1 extends or{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 C1(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 S1;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 Ka=256;let Ti=Ka,Oi;function Hl(t=11){if(!Oi||Ti+t>Ka*2){Oi="",Ti=0;for(let e=0;e<Ka;e++)Oi+=(256+Math.random()*256|0).toString(16).substring(1)}return Oi.substring(Ti,Ti+++t)}function M1(t){const{batch:e,chain:n,ccipRead:r,dataSuffix:s,key:i="base",name:o="Base Client",type:a="base"}=t,d=t.experimental_blockTag??(typeof n?.experimental_preconfirmationTime=="number"?"pending":void 0),m=n?.blockTime??12e3,g=Math.min(Math.max(Math.floor(m/2),500),4e3),v=t.pollingInterval??g,T=t.cacheTime??v,I=t.account?En(t.account):void 0,{config:L,request:M,value:C}=t.transport({account:I,chain:n,pollingInterval:v}),q={...L,...C},Z={account:I,batch:e,cacheTime:T,ccipRead:r,chain:n,dataSuffix:s,key:i,name:o,pollingInterval:v,request:M,transport:q,type:a,uid:Hl(),...d?{experimental_blockTag:d}:{}};function D(P){return z=>{const J=z(P);for(const te in Z)delete J[te];const ee={...P,...J};return Object.assign(ee,{extend:D(ee)})}}return Object.assign(Z,{extend:D(Z)})}function B1({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},d){const m=Hl();return{config:{key:t,methods:e,name:n,request:r,retryCount:s,retryDelay:i,timeout:o,type:a},request:Jy(r,{methods:e,retryCount:s,retryDelay:i,uid:m}),value:d}}function k1(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:i}=e;return({retryCount:o})=>B1({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:i,type:"custom"})}async function ql(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 N1({connector:g});const[v,T]=await Promise.all([g.getAccounts().catch(I=>{if(e.account===null)return[];throw I}),g.getChainId()]);r={accounts:v,chainId:T,connector:g}}else r=t.state.connections.get(t.state.current);if(!r)throw new T1;const s=e.chainId??r.chainId,i=await r.connector.getChainId();if(n&&i!==s)throw new I1({connectionChainId:s,connectorChainId:i});const o=r.connector;if(o.getClient)return o.getClient({chainId:s});const a=En(e.account??r.accounts[0]);if(a&&(a.address=li(a.address)),e.account&&!r.accounts.some(g=>g.toLowerCase()===a.address.toLowerCase()))throw new O1({address:a.address,connector:o});const d=t.chains.find(g=>g.id===s),m=await r.connector.getProvider({chainId:s});return M1({account:a,chain:d,name:"Connector Client",transport:g=>k1(m)({...g,retryCount:0})})}async function L1(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 P1(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 ql(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await zl(o,$l,"sendTransaction")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a,gas:i.gas??void 0})}class U1 extends or{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 D1(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 U1({connector:o});return await o.switchChain({addEthereumChainParameter:n,chainId:r})}const i=t.chains.find(o=>o.id===r);if(!i)throw new Gl;return t.setState(o=>({...o,chainId:r})),i}async function F1(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 ql(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await zl(o,xi,"writeContract")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a})}function BT(t){return t}function Ii(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Wa(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}let Mr=class extends Error{name="BaseError";cause;constructor(e,n={}){super(e,n.cause?{cause:n.cause}:void 0),this.cause=n.cause}};class $1 extends Mr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}}let z1=class extends Mr{name="AddMiniApp.RejectedByUser";constructor(){super("Add miniapp rejected by user")}},Kl=class extends Mr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};class j1 extends Mr{name="SignManifest.RejectedByUser";constructor(){super("Sign manifest rejected by user")}}class V1 extends Mr{name="SignManifest.InvalidDomain";constructor(){super("Invalid domain provided")}}class G1 extends Mr{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"]),Vn=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=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 xn 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 xn))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()}}xn.create=t=>new xn(t);const Za=(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,Ne.jsonStringifyReplacer)}`;break;case ne.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ne.joinValues(t.keys,", ")}`;break;case ne.invalid_union:n="Invalid input";break;case ne.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ne.joinValues(t.options)}`;break;case ne.invalid_enum_value:n=`Invalid enum value. Expected ${Ne.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}"`:Ne.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,Ne.assertNever(t)}return{message:n}};let H1=Za;function q1(){return H1}const K1=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=q1(),r=K1({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Za?void 0:Za].filter(s=>!!s)});t.common.issues.push(r)}class Kt{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 Kt.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"}),Cs=t=>({status:"dirty",value:t}),Qt=t=>({status:"valid",value:t}),Zl=t=>t.status==="aborted",Yl=t=>t.status==="dirty",Br=t=>t.status==="valid",Ni=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 Gn{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(Br(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 xn(t.common.issues);return this._error=n,this._error}}};function xe(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 Oe{get description(){return this._def.description}_getType(e){return Vn(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Vn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Kt,ctx:{common:e.parent.common,data:e.data,parsedType:Vn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Ni(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:Vn(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:Vn(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return Br(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=>Br(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:Vn(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ni(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: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 ur({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 Tn.create(this,this._def)}nullable(){return dr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this)}promise(){return Li.create(this,this._def)}or(e){return Mi.create([this,e],this._def)}and(e){return Bi.create(this,e,this._def)}transform(e){return new ur({...xe(this._def),schema:this,typeName:me.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Pi({...xe(this._def),innerType:this,defaultValue:n,typeName:me.ZodDefault})}brand(){return new cf({typeName:me.ZodBranded,type:this,...xe(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Ui({...xe(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 sc.create(this,e)}readonly(){return Di.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const W1=/^c[^\s-]{8,}$/i,Z1=/^[0-9a-z]+$/,Y1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,J1=/^[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,X1=/^[a-z0-9_-]{21}$/i,Q1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,eb=/^[-+]?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)?)??$/,tb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,nb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ya;const rb=/^(?:(?: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])$/,sb=/^(?:(?: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])$/,ib=/^(([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]))$/,ob=/^(([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])$/,ab=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,cb=/^([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])))",ub=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 db(t){return new RegExp(`^${Ql(t)}$`)}function lb(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 fb(t,e){return!!((e==="v4"||!e)&&rb.test(t)||(e==="v6"||!e)&&ib.test(t))}function hb(t,e){if(!Q1.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 pb(t,e){return!!((e==="v4"||!e)&&sb.test(t)||(e==="v6"||!e)&&ob.test(t))}class Hn extends Oe{_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 Kt;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")tb.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")Ya||(Ya=new RegExp(nb,"u")),Ya.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")J1.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")X1.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")W1.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")Z1.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")Y1.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"?lb(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"?ub.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{code:ne.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?db(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"?eb.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"duration",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?fb(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"?hb(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"?pb(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"?ab.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?cb.test(e.data)||(s=this._getOrReturnCtx(e,s),ie(s,{validation:"base64url",code:ne.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:ne.invalid_string,...le.errToObj(r)})}_addCheck(e){return new Hn({...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 Hn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Hn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Hn({...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}}Hn.create=t=>new Hn({checks:[],typeName:me.ZodString,coerce:t?.coerce??!1,...xe(t)});function mb(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 kr extends Oe{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 Kt;for(const i of this._def.checks)i.kind==="int"?Ne.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"?mb(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()):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 kr({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new kr({...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)}}kr.create=t=>new kr({checks:[],typeName:me.ZodNumber,coerce:t?.coerce||!1,...xe(t)});class Ms extends Oe{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 Kt;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()):Ne.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 Ms({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:le.toString(s)}]})}_addCheck(e){return new Ms({...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}}Ms.create=t=>new Ms({checks:[],typeName:me.ZodBigInt,coerce:t?.coerce??!1,...xe(t)});class Ja extends Oe{_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 Qt(e.data)}}Ja.create=t=>new Ja({typeName:me.ZodBoolean,coerce:t?.coerce||!1,...xe(t)});class Ci extends Oe{_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 Kt;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()):Ne.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ci({...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}}Ci.create=t=>new Ci({checks:[],coerce:t?.coerce||!1,typeName:me.ZodDate,...xe(t)});class ef extends Oe{_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 Qt(e.data)}}ef.create=t=>new ef({typeName:me.ZodSymbol,...xe(t)});class Xa extends Oe{_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 Qt(e.data)}}Xa.create=t=>new Xa({typeName:me.ZodUndefined,...xe(t)});class Qa extends Oe{_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 Qt(e.data)}}Qa.create=t=>new Qa({typeName:me.ZodNull,...xe(t)});class tf extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return Qt(e.data)}}tf.create=t=>new tf({typeName:me.ZodAny,...xe(t)});class nf extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Qt(e.data)}}nf.create=t=>new nf({typeName:me.ZodUnknown,...xe(t)});class qn extends Oe{_parse(e){const n=this._getOrReturnCtx(e);return ie(n,{code:ne.invalid_type,expected:de.never,received:n.parsedType}),pe}}qn.create=t=>new qn({typeName:me.ZodNever,...xe(t)});class rf extends Oe{_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 Qt(e.data)}}rf.create=t=>new rf({typeName:me.ZodVoid,...xe(t)});class dn extends Oe{_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 Gn(n,o,n.path,a)))).then(o=>Kt.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new Gn(n,o,n.path,a)));return Kt.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,...xe(e)});function Lr(t){if(t instanceof Qe){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Tn.create(Lr(r))}return new Qe({...t._def,shape:()=>e})}else return t instanceof dn?new dn({...t._def,type:Lr(t.element)}):t instanceof Tn?Tn.create(Lr(t.unwrap())):t instanceof dr?dr.create(Lr(t.unwrap())):t instanceof ar?ar.create(t.items.map(e=>Lr(e))):t}class Qe extends Oe{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: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 qn&&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],v=s.data[m];d.push({key:{status:"valid",value:m},value:g._parse(new Gn(s,v,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof qn){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 v=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new Gn(s,v,s.path,g)),alwaysSet:g in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of d){const v=await g.key,T=await g.value;m.push({key:v,value:T,alwaysSet:g.alwaysSet})}return m}).then(m=>Kt.mergeObjectSync(r,m)):Kt.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 Lr(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 Tn;)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:qn.create(),typeName:me.ZodObject,...xe(e)}),Qe.strictCreate=(t,e)=>new Qe({shape:()=>t,unknownKeys:"strict",catchall:qn.create(),typeName:me.ZodObject,...xe(e)}),Qe.lazycreate=(t,e)=>new Qe({shape:t,unknownKeys:"strip",catchall:qn.create(),typeName:me.ZodObject,...xe(e)});class Mi extends Oe{_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 xn(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 xn(d));return ie(n,{code:ne.invalid_union,unionErrors:a}),pe}}get options(){return this._def.options}}Mi.create=(t,e)=>new Mi({options:t,typeName:me.ZodUnion,...xe(e)});const Sn=t=>t instanceof nc?Sn(t.schema):t instanceof ur?Sn(t.innerType()):t instanceof ki?[t.value]:t instanceof cr?t.options:t instanceof rc?Ne.objectValues(t.enum):t instanceof Pi?Sn(t._def.innerType):t instanceof Xa?[void 0]:t instanceof Qa?[null]:t instanceof Tn?[void 0,...Sn(t.unwrap())]:t instanceof dr?[null,...Sn(t.unwrap())]:t instanceof cf||t instanceof Di?Sn(t.unwrap()):t instanceof Ui?Sn(t._def.innerType):[];class ec extends Oe{_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=Sn(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 ec({typeName:me.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...xe(r)})}}function tc(t,e){const n=Vn(t),r=Vn(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=tc(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=tc(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 Bi extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Zl(i)||Zl(o))return pe;const a=tc(i.value,o.value);return a.valid?((Yl(i)||Yl(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}))}}Bi.create=(t,e,n)=>new Bi({left:t,right:e,typeName:me.ZodIntersection,...xe(n)});class ar extends Oe{_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 Gn(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Kt.mergeArray(n,o)):Kt.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new ar({...this._def,rest:e})}}ar.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ar({items:t,typeName:me.ZodTuple,rest:null,...xe(e)})};class sf extends Oe{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 Gn(r,a,r.path,[m,"key"])),value:i._parse(new Gn(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,...xe(n)});class Bs extends Oe{_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 Gn(r,d,r.path,m)));return r.common.async?Promise.all(a).then(d=>o(d)):o(a)}min(e,n){return new Bs({...this._def,minSize:{value:e,message:le.toString(n)}})}max(e,n){return new Bs({...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)}}Bs.create=(t,e)=>new Bs({valueType:t,minSize:null,maxSize:null,typeName:me.ZodSet,...xe(e)});class nc extends Oe{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})}}nc.create=(t,e)=>new nc({getter:t,typeName:me.ZodLazy,...xe(e)});class ki extends Oe{_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}}ki.create=(t,e)=>new ki({value:t,typeName:me.ZodLiteral,...xe(e)});function of(t,e){return new cr({values:t,typeName:me.ZodEnum,...xe(e)})}class cr extends Oe{_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: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 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 cr.create(e,{...this._def,...n})}exclude(e,n=this._def){return cr.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}cr.create=of;class rc extends Oe{_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:ne.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:ne.invalid_enum_value,options:s}),pe}return Qt(e.data)}get enum(){return this._def.values}}rc.create=(t,e)=>new rc({values:t,typeName:me.ZodNativeEnum,...xe(e)});class Li extends Oe{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 Qt(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Li.create=(t,e)=>new Li({type:t,typeName:me.ZodPromise,...xe(e)});class ur extends Oe{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"?Cs(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"?Cs(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(!Br(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=>Br(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):pe);Ne.assertNever(s)}}ur.create=(t,e,n)=>new ur({schema:t,typeName:me.ZodEffects,effect:e,...xe(n)}),ur.createWithPreprocess=(t,e,n)=>new ur({schema:e,effect:{type:"preprocess",transform:t},typeName:me.ZodEffects,...xe(n)});class Tn extends Oe{_parse(e){return this._getType(e)===de.undefined?Qt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Tn.create=(t,e)=>new Tn({innerType:t,typeName:me.ZodOptional,...xe(e)});class dr extends Oe{_parse(e){return this._getType(e)===de.null?Qt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:me.ZodNullable,...xe(e)});class Pi extends Oe{_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}}Pi.create=(t,e)=>new Pi({innerType:t,typeName:me.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...xe(e)});class Ui extends Oe{_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 Ni(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new xn(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new xn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ui.create=(t,e)=>new Ui({innerType:t,typeName:me.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...xe(e)});class af extends Oe{_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}}}af.create=t=>new af({typeName:me.ZodNaN,...xe(t)});class cf extends Oe{_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 sc extends Oe{_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(),Cs(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 sc({in:e,out:n,typeName:me.ZodPipeline})}}class Di extends Oe{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Br(s)&&(s.value=Object.freeze(s.value)),s);return Ni(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}Di.create=(t,e)=>new Di({innerType:t,typeName:me.ZodReadonly,...xe(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 qe=Hn.create,uf=kr.create,gb=Ja.create;qn.create;const lr=dn.create,vt=Qe.create,Fi=Mi.create,df=ec.create;Bi.create,ar.create;const Ot=ki.create,ic=cr.create;Li.create,Tn.create,dr.create;const yb=/[@#$%^&*+=/\\|~«»]/,bb=/(!{2,}|\?{2,}|-{2,})/,_b=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,Pr=({max:t,noSpaces:e}={})=>(e?qe().max(t??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):qe().max(t??Number.POSITIVE_INFINITY)).refine(r=>!_b.test(r),{message:"Emojis and symbols are not allowed"}).refine(r=>!yb.test(r),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed"}).refine(r=>!bb.test(r),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Ut=qe().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"}),oc=qe().max(32),lf=qe().max(32),wb=/^[-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)$/,Eb=qe().regex(wb,{message:"Invalid CAIP-19 asset ID"}),ac=qe().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),vb=/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Rb=qe().max(1024).regex(vb,{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"}),Ab=Fi([Ot("1:1"),Ot("3:2")]),xb=vt({header:qe(),payload:qe(),signature:qe()});vt({fid:uf(),type:Ot("app_key"),key:qe().startsWith("0x")});const Sb=vt({type:Ot("launch_frame"),name:oc,url:Ut.optional(),splashImageUrl:Ut.optional(),splashBackgroundColor:ac.optional()}),Tb=vt({type:Ot("launch_miniapp"),name:oc,url:Ut.optional(),splashImageUrl:Ut.optional(),splashBackgroundColor:ac.optional()}),Ob=vt({type:Ot("view_token"),token:Eb}),Ib=df("type",[Tb,Ob,Sb]),Nb=vt({title:lf,action:Ib});vt({version:Fi([qe(),uf()]).transform(t=>String(t)).pipe(Fi([Ot("next"),Ot("1")])),imageUrl:Ut,aspectRatio:Ab.optional(),button:Nb});const ff=vt({url:qe(),token:qe()});vt({notificationId:qe().max(128),title:qe().max(32),body:qe().max(128),targetUrl:Ut,tokens:qe().array().max(100)}),vt({result:vt({successfulTokens:lr(qe()),invalidTokens:lr(qe()),rateLimitedTokens:lr(qe())})});const Cb=vt({event:Ot("miniapp_added"),notificationDetails:ff.optional()}),Mb=vt({event:Ot("miniapp_removed")}),Bb=vt({event:Ot("notifications_enabled"),notificationDetails:ff.required()}),kb=vt({event:Ot("notifications_disabled")});df("event",[Cb,Mb,Bb,kb]);const Lb=["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"],Pb=ic(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),Ub=Fi([Ot("0.0.0"),Ot("0.0.1"),Ot("1"),Ot("next")]),Db=Pr({max:30}),Fb=Pr({max:170}),$b=lr(Ut).max(3),zb=lr(Pr({max:20,noSpaces:!0})).max(5),jb=Pr({max:30}),Vb=Pr({max:30}),Gb=Pr({max:100}),Hb=gb(),qb=["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 Kb=lr(ic(qb)).transform(hf),Wb=lr(ic(Lb)).transform(hf),pf=vt({version:Ub,name:oc,iconUrl:Ut,homeUrl:Ut,imageUrl:Ut.optional(),buttonTitle:lf.optional(),splashImageUrl:Ut.optional(),splashBackgroundColor:ac.optional(),webhookUrl:Ut.optional(),subtitle:Db.optional(),description:Fb.optional(),screenshotUrls:$b.optional(),primaryCategory:Pb.optional(),tags:zb.optional(),heroImageUrl:Ut.optional(),tagline:jb.optional(),ogTitle:Vb.optional(),ogDescription:Gb.optional(),ogImageUrl:Ut.optional(),noindex:Hb.optional(),requiredChains:Kb.optional(),requiredCapabilities:Wb.optional(),castShareUrl:Ut.optional(),canonicalDomain:Rb.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"]});vt({accountAssociation:xb,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 cc={},ks={},mf;function Zb(){if(mf)return ks;mf=1,ks.byteLength=a,ks.toByteArray=m,ks.fromByteArray=T;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(I){var L=I.length;if(L%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var M=I.indexOf("=");M===-1&&(M=L);var C=M===L?0:4-M%4;return[M,C]}function a(I){var L=o(I),M=L[0],C=L[1];return(M+C)*3/4-C}function d(I,L,M){return(L+M)*3/4-M}function m(I){var L,M=o(I),C=M[0],q=M[1],Z=new n(d(I,C,q)),D=0,P=q>0?C-4:C,z;for(z=0;z<P;z+=4)L=e[I.charCodeAt(z)]<<18|e[I.charCodeAt(z+1)]<<12|e[I.charCodeAt(z+2)]<<6|e[I.charCodeAt(z+3)],Z[D++]=L>>16&255,Z[D++]=L>>8&255,Z[D++]=L&255;return q===2&&(L=e[I.charCodeAt(z)]<<2|e[I.charCodeAt(z+1)]>>4,Z[D++]=L&255),q===1&&(L=e[I.charCodeAt(z)]<<10|e[I.charCodeAt(z+1)]<<4|e[I.charCodeAt(z+2)]>>2,Z[D++]=L>>8&255,Z[D++]=L&255),Z}function g(I){return t[I>>18&63]+t[I>>12&63]+t[I>>6&63]+t[I&63]}function v(I,L,M){for(var C,q=[],Z=L;Z<M;Z+=3)C=(I[Z]<<16&16711680)+(I[Z+1]<<8&65280)+(I[Z+2]&255),q.push(g(C));return q.join("")}function T(I){for(var L,M=I.length,C=M%3,q=[],Z=16383,D=0,P=M-C;D<P;D+=Z)q.push(v(I,D,D+Z>P?P:D+Z));return C===1?(L=I[M-1],q.push(t[L>>2]+t[L<<4&63]+"==")):C===2&&(L=(I[M-2]<<8)+I[M-1],q.push(t[L>>10]+t[L>>4&63]+t[L<<2&63]+"=")),q.join("")}return ks}var $i={};var gf;function Yb(){return gf||(gf=1,$i.read=function(t,e,n,r,s){var i,o,a=s*8-r-1,d=(1<<a)-1,m=d>>1,g=-7,v=n?s-1:0,T=n?-1:1,I=t[e+v];for(v+=T,i=I&(1<<-g)-1,I>>=-g,g+=a;g>0;i=i*256+t[e+v],v+=T,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=r;g>0;o=o*256+t[e+v],v+=T,g-=8);if(i===0)i=1-m;else{if(i===d)return o?NaN:(I?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-m}return(I?-1:1)*o*Math.pow(2,i-r)},$i.write=function(t,e,n,r,s,i){var o,a,d,m=i*8-s-1,g=(1<<m)-1,v=g>>1,T=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=r?0:i-1,L=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+v>=1?e+=T/d:e+=T*Math.pow(2,1-v),e*d>=2&&(o++,d/=2),o+v>=g?(a=0,o=g):o+v>=1?(a=(e*d-1)*Math.pow(2,s),o=o+v):(a=e*Math.pow(2,v-1)*Math.pow(2,s),o=0));s>=8;t[n+I]=a&255,I+=L,a/=256,s-=8);for(o=o<<s|a,m+=s;m>0;t[n+I]=o&255,I+=L,o/=256,m-=8);t[n+I-L]|=M*128}),$i}var yf;function uc(){return yf||(yf=1,(function(t){const e=Zb(),n=Yb(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=Z,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 v(b)}return d(b,f,h)}a.poolSize=8192;function d(b,f,h){if(typeof b=="string")return T(b,f);if(ArrayBuffer.isView(b))return L(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(Jt(b,ArrayBuffer)||b&&Jt(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Jt(b,SharedArrayBuffer)||b&&Jt(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 F=C(b);if(F)return F;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 v(b){return m(b),o(b<0?0:q(b)|0)}a.allocUnsafe=function(b){return v(b)},a.allocUnsafeSlow=function(b){return v(b)};function T(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=D(b,f)|0;let S=o(h);const F=S.write(b,f);return F!==h&&(S=S.slice(0,F)),S}function I(b){const f=b.length<0?0:q(b.length)|0,h=o(f);for(let S=0;S<f;S+=1)h[S]=b[S]&255;return h}function L(b){if(Jt(b,Uint8Array)){const f=new Uint8Array(b);return M(f.buffer,f.byteOffset,f.byteLength)}return I(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 C(b){if(a.isBuffer(b)){const f=q(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"||Ve(b.length)?o(0):I(b);if(b.type==="Buffer"&&Array.isArray(b.data))return I(b.data)}function q(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function Z(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(Jt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Jt(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,F=h.length;for(let V=0,Y=Math.min(S,F);V<Y;++V)if(f[V]!==h[V]){S=f[V],F=h[V];break}return S<F?-1:F<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 F=a.allocUnsafe(h);let V=0;for(S=0;S<f.length;++S){let Y=f[S];if(Jt(Y,Uint8Array))V+Y.length>F.length?(a.isBuffer(Y)||(Y=a.from(Y)),Y.copy(F,V)):Uint8Array.prototype.set.call(F,Y,V);else if(a.isBuffer(Y))Y.copy(F,V);else throw new TypeError('"list" argument must be an Array of Buffers');V+=Y.length}return F};function D(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||Jt(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 F=!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(F)return S?-1:Le(b).length;f=(""+f).toLowerCase(),F=!0}}a.byteLength=D;function P(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 A(this,f,h);case"utf8":case"utf-8":return c(this,f,h);case"ascii":return x(this,f,h);case"latin1":case"binary":return R(this,f,h);case"base64":return E(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return N(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):P.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,F,V){if(Jt(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),F===void 0&&(F=0),V===void 0&&(V=this.length),h<0||S>f.length||F<0||V>this.length)throw new RangeError("out of range index");if(F>=V&&h>=S)return 0;if(F>=V)return-1;if(h>=S)return 1;if(h>>>=0,S>>>=0,F>>>=0,V>>>=0,this===f)return 0;let Y=V-F,Ae=S-h;const _e=Math.min(Y,Ae),ge=this.slice(F,V),$e=f.slice(h,S);for(let he=0;he<_e;++he)if(ge[he]!==$e[he]){Y=ge[he],Ae=$e[he];break}return Y<Ae?-1:Ae<Y?1:0};function J(b,f,h,S,F){if(b.length===0)return-1;if(typeof h=="string"?(S=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ve(h)&&(h=F?0:b.length-1),h<0&&(h=b.length+h),h>=b.length){if(F)return-1;h=b.length-1}else if(h<0)if(F)h=0;else return-1;if(typeof f=="string"&&(f=a.from(f,S)),a.isBuffer(f))return f.length===0?-1:ee(b,f,h,S,F);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(b,f,h):Uint8Array.prototype.lastIndexOf.call(b,f,h):ee(b,[f],h,S,F);throw new TypeError("val must be string, number or Buffer")}function ee(b,f,h,S,F){let V=1,Y=b.length,Ae=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;V=2,Y/=2,Ae/=2,h/=2}function _e($e,he){return V===1?$e[he]:$e.readUInt16BE(he*V)}let ge;if(F){let $e=-1;for(ge=h;ge<Y;ge++)if(_e(b,ge)===_e(f,$e===-1?0:ge-$e)){if($e===-1&&($e=ge),ge-$e+1===Ae)return $e*V}else $e!==-1&&(ge-=ge-$e),$e=-1}else for(h+Ae>Y&&(h=Y-Ae),ge=h;ge>=0;ge--){let $e=!0;for(let he=0;he<Ae;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 te(b,f,h,S){h=Number(h)||0;const F=b.length-h;S?(S=Number(S),S>F&&(S=F)):S=F;const V=f.length;S>V/2&&(S=V/2);let Y;for(Y=0;Y<S;++Y){const Ae=parseInt(f.substr(Y*2,2),16);if(Ve(Ae))return Y;b[h+Y]=Ae}return Y}function K(b,f,h,S){return Pe(Le(f,b.length-h),b,h,S)}function k(b,f,h,S){return Pe(je(f),b,h,S)}function U(b,f,h,S){return Pe(Fe(f),b,h,S)}function j(b,f,h,S){return Pe(Jr(f,b.length-h),b,h,S)}a.prototype.write=function(f,h,S,F){if(h===void 0)F="utf8",S=this.length,h=0;else if(S===void 0&&typeof h=="string")F=h,S=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(S)?(S=S>>>0,F===void 0&&(F="utf8")):(F=S,S=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const V=this.length-h;if((S===void 0||S>V)&&(S=V),f.length>0&&(S<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let Y=!1;for(;;)switch(F){case"hex":return te(this,f,h,S);case"utf8":case"utf-8":return K(this,f,h,S);case"ascii":case"latin1":case"binary":return k(this,f,h,S);case"base64":return U(this,f,h,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,f,h,S);default:if(Y)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),Y=!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 F=f;for(;F<h;){const V=b[F];let Y=null,Ae=V>239?4:V>223?3:V>191?2:1;if(F+Ae<=h){let _e,ge,$e,he;switch(Ae){case 1:V<128&&(Y=V);break;case 2:_e=b[F+1],(_e&192)===128&&(he=(V&31)<<6|_e&63,he>127&&(Y=he));break;case 3:_e=b[F+1],ge=b[F+2],(_e&192)===128&&(ge&192)===128&&(he=(V&15)<<12|(_e&63)<<6|ge&63,he>2047&&(he<55296||he>57343)&&(Y=he));break;case 4:_e=b[F+1],ge=b[F+2],$e=b[F+3],(_e&192)===128&&(ge&192)===128&&($e&192)===128&&(he=(V&15)<<18|(_e&63)<<12|(ge&63)<<6|$e&63,he>65535&&he<1114112&&(Y=he))}}Y===null?(Y=65533,Ae=1):Y>65535&&(Y-=65536,S.push(Y>>>10&1023|55296),Y=56320|Y&1023),S.push(Y),F+=Ae}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 x(b,f,h){let S="";h=Math.min(b.length,h);for(let F=f;F<h;++F)S+=String.fromCharCode(b[F]&127);return S}function R(b,f,h){let S="";h=Math.min(b.length,h);for(let F=f;F<h;++F)S+=String.fromCharCode(b[F]);return S}function A(b,f,h){const S=b.length;(!f||f<0)&&(f=0),(!h||h<0||h>S)&&(h=S);let F="";for(let V=f;V<h;++V)F+=We[b[V]];return F}function N(b,f,h){const S=b.slice(f,h);let F="";for(let V=0;V<S.length-1;V+=2)F+=String.fromCharCode(S[V]+S[V+1]*256);return F}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 F=this.subarray(f,h);return Object.setPrototypeOf(F,a.prototype),F};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 F=this[f],V=1,Y=0;for(;++Y<h&&(V*=256);)F+=this[f+Y]*V;return F},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let F=this[f+--h],V=1;for(;h>0&&(V*=256);)F+=this[f+--h]*V;return F},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)&&Re(f,this.length-8);const F=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,V=this[++f]+this[++f]*2**8+this[++f]*2**16+S*2**24;return BigInt(F)+(BigInt(V)<<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)&&Re(f,this.length-8);const F=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],V=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+S;return(BigInt(F)<<BigInt(32))+BigInt(V)}),a.prototype.readIntLE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let F=this[f],V=1,Y=0;for(;++Y<h&&(V*=256);)F+=this[f+Y]*V;return V*=128,F>=V&&(F-=Math.pow(2,8*h)),F},a.prototype.readIntBE=function(f,h,S){f=f>>>0,h=h>>>0,S||_(f,h,this.length);let F=h,V=1,Y=this[f+--F];for(;F>0&&(V*=256);)Y+=this[f+--F]*V;return V*=128,Y>=V&&(Y-=Math.pow(2,8*h)),Y},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)&&Re(f,this.length-8);const F=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(S<<24);return(BigInt(F)<<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)&&Re(f,this.length-8);const F=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(F)<<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,F,V){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>F||f<V)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,F){if(f=+f,h=h>>>0,S=S>>>0,!F){const Ae=Math.pow(2,8*S)-1;u(this,f,h,S,Ae,0)}let V=1,Y=0;for(this[h]=f&255;++Y<S&&(V*=256);)this[h+Y]=f/V&255;return h+S},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,h,S,F){if(f=+f,h=h>>>0,S=S>>>0,!F){const Ae=Math.pow(2,8*S)-1;u(this,f,h,S,Ae,0)}let V=S-1,Y=1;for(this[h+V]=f&255;--V>=0&&(Y*=256);)this[h+V]=f/Y&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,F){Ee(f,S,F,b,h,7);let V=Number(f&BigInt(4294967295));b[h++]=V,V=V>>8,b[h++]=V,V=V>>8,b[h++]=V,V=V>>8,b[h++]=V;let Y=Number(f>>BigInt(32)&BigInt(4294967295));return b[h++]=Y,Y=Y>>8,b[h++]=Y,Y=Y>>8,b[h++]=Y,Y=Y>>8,b[h++]=Y,h}function w(b,f,h,S,F){Ee(f,S,F,b,h,7);let V=Number(f&BigInt(4294967295));b[h+7]=V,V=V>>8,b[h+6]=V,V=V>>8,b[h+5]=V,V=V>>8,b[h+4]=V;let Y=Number(f>>BigInt(32)&BigInt(4294967295));return b[h+3]=Y,Y=Y>>8,b[h+2]=Y,Y=Y>>8,b[h+1]=Y,Y=Y>>8,b[h]=Y,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,F){if(f=+f,h=h>>>0,!F){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let V=0,Y=1,Ae=0;for(this[h]=f&255;++V<S&&(Y*=256);)f<0&&Ae===0&&this[h+V-1]!==0&&(Ae=1),this[h+V]=(f/Y>>0)-Ae&255;return h+S},a.prototype.writeIntBE=function(f,h,S,F){if(f=+f,h=h>>>0,!F){const _e=Math.pow(2,8*S-1);u(this,f,h,S,_e-1,-_e)}let V=S-1,Y=1,Ae=0;for(this[h+V]=f&255;--V>=0&&(Y*=256);)f<0&&Ae===0&&this[h+V+1]!==0&&(Ae=1),this[h+V]=(f/Y>>0)-Ae&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 O(b,f,h,S,F,V){if(h+S>b.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function $(b,f,h,S,F){return f=+f,h=h>>>0,F||O(b,f,h,4),n.write(b,f,h,S,23,4),h+4}a.prototype.writeFloatLE=function(f,h,S){return $(this,f,h,!0,S)},a.prototype.writeFloatBE=function(f,h,S){return $(this,f,h,!1,S)};function W(b,f,h,S,F){return f=+f,h=h>>>0,F||O(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,F){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(S||(S=0),!F&&F!==0&&(F=this.length),h>=f.length&&(h=f.length),h||(h=0),F>0&&F<S&&(F=S),F===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(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),f.length-h<F-S&&(F=f.length-h+S);const V=F-S;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,S,F):Uint8Array.prototype.set.call(f,this.subarray(S,F),h),V},a.prototype.fill=function(f,h,S,F){if(typeof f=="string"){if(typeof h=="string"?(F=h,h=0,S=this.length):typeof S=="string"&&(F=S,S=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!a.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(f.length===1){const Y=f.charCodeAt(0);(F==="utf8"&&Y<128||F==="latin1")&&(f=Y)}}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 V;if(typeof f=="number")for(V=h;V<S;++V)this[V]=f;else{const Y=a.isBuffer(f)?f:a.from(f,F),Ae=Y.length;if(Ae===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for(V=0;V<S-h;++V)this[V+h]=Y[V%Ae]}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(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,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.`,F=h;return Number.isInteger(h)&&Math.abs(h)>2**32?F=Ce(String(h)):typeof h=="bigint"&&(F=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(F=Ce(F)),F+="n"),S+=` It must be ${f}. Received ${F}`,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 ve(b,f,h){De(f,"offset"),(b[f]===void 0||b[f+h]===void 0)&&Re(f,b.length-(h+1))}function Ee(b,f,h,S,F,V){if(b>h||b<f){const Y=typeof f=="bigint"?"n":"";let Ae;throw f===0||f===BigInt(0)?Ae=`>= 0${Y} and < 2${Y} ** ${(V+1)*8}${Y}`:Ae=`>= -(2${Y} ** ${(V+1)*8-1}${Y}) and < 2 ** ${(V+1)*8-1}${Y}`,new re.ERR_OUT_OF_RANGE("value",Ae,b)}ve(S,F,V)}function De(b,f){if(typeof b!="number")throw new re.ERR_INVALID_ARG_TYPE(f,"number",b)}function Re(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 Ie=/[^+/0-9A-Za-z-_]/g;function mn(b){if(b=b.split("=")[0],b=b.trim().replace(Ie,""),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 F=null;const V=[];for(let Y=0;Y<S;++Y){if(h=b.charCodeAt(Y),h>55295&&h<57344){if(!F){if(h>56319){(f-=3)>-1&&V.push(239,191,189);continue}else if(Y+1===S){(f-=3)>-1&&V.push(239,191,189);continue}F=h;continue}if(h<56320){(f-=3)>-1&&V.push(239,191,189),F=h;continue}h=(F-55296<<10|h-56320)+65536}else F&&(f-=3)>-1&&V.push(239,191,189);if(F=null,h<128){if((f-=1)<0)break;V.push(h)}else if(h<2048){if((f-=2)<0)break;V.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;V.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;V.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return V}function je(b){const f=[];for(let h=0;h<b.length;++h)f.push(b.charCodeAt(h)&255);return f}function Jr(b,f){let h,S,F;const V=[];for(let Y=0;Y<b.length&&!((f-=2)<0);++Y)h=b.charCodeAt(Y),S=h>>8,F=h%256,V.push(F),V.push(S);return V}function Fe(b){return e.toByteArray(mn(b))}function Pe(b,f,h,S){let F;for(F=0;F<S&&!(F+h>=f.length||F>=b.length);++F)f[F+h]=b[F];return F}function Jt(b,f){return b instanceof f||b!=null&&b.constructor!=null&&b.constructor.name!=null&&b.constructor.name===f.name}function Ve(b){return b!==b}const We=(function(){const b="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const S=h*16;for(let F=0;F<16;++F)f[S+F]=b[h]+b[F]}return f})();function an(b){return typeof BigInt>"u"?Ze:b}function Ze(){throw new Error("BigInt not supported")}})(cc)),cc}var Se=uc();const ln=BigInt(0),Dt=BigInt(1),bf=BigInt(2),Jb=BigInt(8),Xb={zip215:!0};function Qb(t){const e=Fa(t);return Os(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function e_(t){const e=Qb(t),{Fp:n,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:d}=e,m=bf<<BigInt(a*8)-Dt,g=n.create,v=Ns(e.n,e.nBitLength);function T(R,A){const N=n.sqr(R),_=n.sqr(A),u=n.add(n.mul(e.a,N),_),l=n.add(n.ONE,n.mul(e.d,n.mul(N,_)));return n.eql(u,l)}if(!T(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const I=e.uvRatio||((R,A)=>{try{return{isValid:!0,value:n.sqrt(R*n.inv(A))}}catch{return{isValid:!1,value:ln}}}),L=e.adjustScalarBytes||(R=>R),M=e.domain||((R,A,N)=>{if(Dn("phflag",N),A.length||N)throw new Error("Contexts/pre-hash are not supported");return R});function C(R,A,N=!1){const _=N?Dt:ln;nn("coordinate "+R,A,_,m)}function q(R){if(!(R instanceof P))throw new Error("ExtendedPoint expected")}const Z=wi((R,A)=>{const{ex:N,ey:_,ez:u}=R,l=R.is0();A==null&&(A=l?Jb:n.inv(u));const w=g(N*A),O=g(_*A),$=g(u*A);if(l)return{x:ln,y:Dt};if($!==Dt)throw new Error("invZ was invalid");return{x:w,y:O}}),D=wi(R=>{const{a:A,d:N}=e;if(R.is0())throw new Error("bad point: ZERO");const{ex:_,ey:u,ez:l,et:w}=R,O=g(_*_),$=g(u*u),W=g(l*l),re=g(W*W),oe=g(O*A),Ce=g(W*g(oe+$)),ve=g(re+g(N*g(O*$)));if(Ce!==ve)throw new Error("bad point: equation left != right (1)");const Ee=g(_*u),De=g(l*w);if(Ee!==De)throw new Error("bad point: equation left != right (2)");return!0});class P{constructor(A,N,_,u){C("x",A),C("y",N),C("z",_,!0),C("t",u),this.ex=A,this.ey=N,this.ez=_,this.et=u,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof P)throw new Error("extended point not allowed");const{x:N,y:_}=A||{};return C("x",N),C("y",_),new P(N,_,Dt,g(N*_))}static normalizeZ(A){const N=Ba(n,A.map(_=>_.ez));return A.map((_,u)=>_.toAffine(N[u])).map(P.fromAffine)}static msm(A,N){return kl(P,v,A,N)}_setWindowSize(A){ee.setWindowSize(this,A)}assertValidity(){D(this)}equals(A){q(A);const{ex:N,ey:_,ez:u}=this,{ex:l,ey:w,ez:O}=A,$=g(N*O),W=g(l*u),re=g(_*O),oe=g(w*u);return $===W&&re===oe}is0(){return this.equals(P.ZERO)}negate(){return new P(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:A}=e,{ex:N,ey:_,ez:u}=this,l=g(N*N),w=g(_*_),O=g(bf*g(u*u)),$=g(A*l),W=N+_,re=g(g(W*W)-l-w),oe=$+w,Ce=oe-O,ve=$-w,Ee=g(re*Ce),De=g(oe*ve),Re=g(re*ve),Ie=g(Ce*oe);return new P(Ee,De,Ie,Re)}add(A){q(A);const{a:N,d:_}=e,{ex:u,ey:l,ez:w,et:O}=this,{ex:$,ey:W,ez:re,et:oe}=A,Ce=g(u*$),ve=g(l*W),Ee=g(O*_*oe),De=g(w*re),Re=g((u+l)*($+W)-Ce-ve),Ie=De-Ee,mn=De+Ee,Le=g(ve-N*Ce),je=g(Re*Ie),Jr=g(mn*Le),Fe=g(Re*Le),Pe=g(Ie*mn);return new P(je,Jr,Pe,Fe)}subtract(A){return this.add(A.negate())}wNAF(A){return ee.wNAFCached(this,A,P.normalizeZ)}multiply(A){const N=A;nn("scalar",N,Dt,r);const{p:_,f:u}=this.wNAF(N);return P.normalizeZ([_,u])[0]}multiplyUnsafe(A,N=P.ZERO){const _=A;return nn("scalar",_,ln,r),_===ln?J:this.is0()||_===Dt?this:ee.wNAFCachedUnsafe(this,_,P.normalizeZ,N)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return ee.unsafeLadder(this,r).is0()}toAffine(A){return Z(this,A)}clearCofactor(){const{h:A}=e;return A===Dt?this:this.multiplyUnsafe(A)}static fromHex(A,N=!1){const{d:_,a:u}=e,l=n.BYTES;A=Je("pointHex",A,l),Dn("zip215",N);const w=A.slice(),O=A[l-1];w[l-1]=O&-129;const $=Ss(w),W=N?m:n.ORDER;nn("pointHex.y",$,ln,W);const re=g($*$),oe=g(re-Dt),Ce=g(_*re-u);let{isValid:ve,value:Ee}=I(oe,Ce);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");const De=(Ee&Dt)===Dt,Re=(O&128)!==0;if(!N&&Ee===ln&&Re)throw new Error("Point.fromHex: x=0 and x_0=1");return Re!==De&&(Ee=g(-Ee)),P.fromAffine({x:Ee,y:$})}static fromPrivateKey(A){const{scalar:N}=k(A);return z.multiply(N)}toRawBytes(){const{x:A,y:N}=this.toAffine(),_=bi(N,n.BYTES);return _[_.length-1]|=A&Dt?128:0,_}toHex(){return Ir(this.toRawBytes())}}P.BASE=new P(e.Gx,e.Gy,Dt,g(e.Gx*e.Gy)),P.ZERO=new P(ln,Dt,Dt,ln);const{BASE:z,ZERO:J}=P,ee=Bl(P,a*8);function te(R){return ze(R,r)}function K(R){return te(Ss(R))}function k(R){const A=n.BYTES;R=Je("private key",R,A);const N=Je("hashed private key",i(R),2*A),_=L(N.slice(0,A)),u=N.slice(A,2*A),l=K(_);return{head:_,prefix:u,scalar:l}}function U(R){const{head:A,prefix:N,scalar:_}=k(R),u=z.multiply(_),l=u.toRawBytes();return{head:A,prefix:N,scalar:_,point:u,pointBytes:l}}function j(R){return U(R).pointBytes}function E(R=Uint8Array.of(),...A){const N=Nr(...A);return K(i(M(N,Je("context",R),!!s)))}function c(R,A,N={}){R=Je("message",R),s&&(R=s(R));const{prefix:_,scalar:u,pointBytes:l}=U(A),w=E(N.context,_,R),O=z.multiply(w).toRawBytes(),$=E(N.context,O,l,R),W=te(w+$*u);nn("signature.s",W,ln,r);const re=Nr(O,bi(W,n.BYTES));return Je("result",re,n.BYTES*2)}const p=Xb;function y(R,A,N,_=p){const{context:u,zip215:l}=_,w=n.BYTES;R=Je("signature",R,2*w),A=Je("message",A),N=Je("publicKey",N,w),l!==void 0&&Dn("zip215",l),s&&(A=s(A));const O=Ss(R.slice(w,2*w));let $,W,re;try{$=P.fromHex(N,l),W=P.fromHex(R.slice(0,w),l),re=z.multiplyUnsafe(O)}catch{return!1}if(!l&&$.isSmallOrder())return!1;const oe=E(u,W.toRawBytes(),$.toRawBytes(),A);return W.add($.multiplyUnsafe(oe)).subtract(re).clearCofactor().equals(P.ZERO)}return z._setWindowSize(8),{CURVE:e,getPublicKey:j,sign:c,verify:y,ExtendedPoint:P,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>o(n.BYTES),precompute(R=8,A=P.BASE){return A._setWindowSize(R),A.multiply(BigInt(3)),A}}}}const dc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),_f=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const t_=BigInt(1),wf=BigInt(2);BigInt(3);const n_=BigInt(5),r_=BigInt(8);function s_(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),i=dc,a=t*t%i*t%i,d=He(a,wf,i)*a%i,m=He(d,t_,i)*t%i,g=He(m,n_,i)*m%i,v=He(g,e,i)*g%i,T=He(v,n,i)*v%i,I=He(T,r,i)*T%i,L=He(I,s,i)*I%i,M=He(L,s,i)*I%i,C=He(M,e,i)*g%i;return{pow_p_5_8:He(C,wf,i)*t%i,b2:a}}function i_(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function o_(t,e){const n=dc,r=ze(e*e*e,n),s=ze(r*r*e,n),i=s_(t*s).pow_p_5_8;let o=ze(t*r*i,n);const a=ze(e*o*o,n),d=o,m=ze(o*_f,n),g=a===t,v=a===ze(-t,n),T=a===ze(-t*_f,n);return g&&(o=d),(v||T)&&(o=m),s1(o,n)&&(o=ze(-o,n)),{isValid:g||v,value:o}}const Ef=Ns(dc,void 0,!0),a_={a:Ef.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ef,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:r_,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Uy,randomBytes:Rd,adjustScalarBytes:i_,uvRatio:o_},lc=e_(a_);var zi={exports:{}};const c_=Wa(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var u_=zi.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=c_.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 x=0;c[0]==="-"&&(x++,this.negative=1),x<c.length&&(p===16?this._parseHex(c,x,y):(this._parseBase(c,p,x),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 x=0;x<this.length;x++)this.words[x]=0;var R,A,N=0;if(y==="be")for(x=c.length-1,R=0;x>=0;x-=3)A=c[x]|c[x-1]<<8|c[x-2]<<16,this.words[R]|=A<<N&67108863,this.words[R+1]=A>>>26-N&67108863,N+=24,N>=26&&(N-=26,R++);else if(y==="le")for(x=0,R=0;x<c.length;x+=3)A=c[x]|c[x+1]<<8|c[x+2]<<16,this.words[R]|=A<<N&67108863,this.words[R+1]=A>>>26-N&67108863,N+=24,N>=26&&(N-=26,R++);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 x=0;x<this.length;x++)this.words[x]=0;var R=0,A=0,N;if(y==="be")for(x=c.length-1;x>=p;x-=2)N=d(c,p,x)<<R,this.words[A]|=N&67108863,R>=18?(R-=18,A+=1,this.words[A]|=N>>>26):R+=8;else{var _=c.length-p;for(x=_%2===0?p+1:p;x<c.length;x+=2)N=d(c,p,x)<<R,this.words[A]|=N&67108863,R>=18?(R-=18,A+=1,this.words[A]|=N>>>26):R+=8}this._strip()};function m(E,c,p,y){for(var x=0,R=0,A=Math.min(E.length,p),N=c;N<A;N++){var _=E.charCodeAt(N)-48;x*=y,_>=49?R=_-49+10:_>=17?R=_-17+10:R=_,r(_>=0&&R<y,"Invalid character"),x+=R}return x}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var x=0,R=1;R<=67108863;R*=p)x++;x--,R=R/p|0;for(var A=c.length-y,N=A%x,_=Math.min(A,A-N)+y,u=0,l=y;l<_;l+=x)u=m(c,l,l+x,p),this.imuln(R),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(N!==0){var w=1;for(u=m(c,l,c.length,p),l=0;l<N;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")]=v}catch{i.prototype.inspect=v}else i.prototype.inspect=v;function v(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var T=["","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"],I=[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],L=[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 x=0,R=0,A=0;A<this.length;A++){var N=this.words[A],_=((N<<x|R)&16777215).toString(16);R=N>>>24-x&16777215,x+=2,x>=26&&(x-=26,A--),R!==0||A!==this.length-1?y=T[6-_.length]+_+y:y=_+y}for(R!==0&&(y=R.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=I[c],l=L[c];y="";var w=this.clone();for(w.negative=0;!w.isZero();){var O=w.modrn(l).toString(c);w=w.idivn(l),w.isZero()?y=O+y:y=T[u-O.length]+O+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 x=this.byteLength(),R=y||Math.max(1,x);r(x<=R,"byte array longer than desired length"),r(R>0,"Requested array length <= 0");var A=M(c,R),N=p==="le"?"LE":"BE";return this["_toArrayLike"+N](A,x),A},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,x=0,R=0,A=0;R<this.length;R++){var N=this.words[R]<<A|x;c[y++]=N&255,y<c.length&&(c[y++]=N>>8&255),y<c.length&&(c[y++]=N>>16&255),A===6?(y<c.length&&(c[y++]=N>>24&255),x=0,A=0):(x=N>>>24,A+=2)}if(y<c.length)for(c[y++]=x;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,x=0,R=0,A=0;R<this.length;R++){var N=this.words[R]<<A|x;c[y--]=N&255,y>=0&&(c[y--]=N>>8&255),y>=0&&(c[y--]=N>>16&255),A===6?(y>=0&&(c[y--]=N>>24&255),x=0,A=0):(x=N>>>24,A+=2)}if(y>=0)for(c[y--]=x;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 C(E){for(var c=new Array(E.bitLength()),p=0;p<c.length;p++){var y=p/26|0,x=p%26;c[p]=E.words[y]>>>x&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 x=0;x<y.length;x++)this.words[x]=p.words[x]^y.words[x];if(this!==p)for(;x<p.length;x++)this.words[x]=p.words[x];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 x=0;x<p;x++)this.words[x]=~this.words[x]&67108863;return y>0&&(this.words[x]=~this.words[x]&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,x=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<x:this.words[y]=this.words[y]&~(1<<x),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,x;this.length>c.length?(y=this,x=c):(y=c,x=this);for(var R=0,A=0;A<x.length;A++)p=(y.words[A]|0)+(x.words[A]|0)+R,this.words[A]=p&67108863,R=p>>>26;for(;R!==0&&A<y.length;A++)p=(y.words[A]|0)+R,this.words[A]=p&67108863,R=p>>>26;if(this.length=y.length,R!==0)this.words[this.length]=R,this.length++;else if(y!==this)for(;A<y.length;A++)this.words[A]=y.words[A];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 x,R;y>0?(x=this,R=c):(x=c,R=this);for(var A=0,N=0;N<R.length;N++)p=(x.words[N]|0)-(R.words[N]|0)+A,A=p>>26,this.words[N]=p&67108863;for(;A!==0&&N<x.length;N++)p=(x.words[N]|0)+A,A=p>>26,this.words[N]=p&67108863;if(A===0&&N<x.length&&x!==this)for(;N<x.length;N++)this.words[N]=x.words[N];return this.length=Math.max(this.length,N),x!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function q(E,c,p){p.negative=c.negative^E.negative;var y=E.length+c.length|0;p.length=y,y=y-1|0;var x=E.words[0]|0,R=c.words[0]|0,A=x*R,N=A&67108863,_=A/67108864|0;p.words[0]=N;for(var u=1;u<y;u++){for(var l=_>>>26,w=_&67108863,O=Math.min(u,c.length-1),$=Math.max(0,u-E.length+1);$<=O;$++){var W=u-$|0;x=E.words[W]|0,R=c.words[$]|0,A=x*R+w,l+=A/67108864|0,w=A&67108863}p.words[u]=w|0,_=l|0}return _!==0?p.words[u]=_|0:p.length--,p._strip()}var Z=function(c,p,y){var x=c.words,R=p.words,A=y.words,N=0,_,u,l,w=x[0]|0,O=w&8191,$=w>>>13,W=x[1]|0,re=W&8191,oe=W>>>13,Ce=x[2]|0,ve=Ce&8191,Ee=Ce>>>13,De=x[3]|0,Re=De&8191,Ie=De>>>13,mn=x[4]|0,Le=mn&8191,je=mn>>>13,Jr=x[5]|0,Fe=Jr&8191,Pe=Jr>>>13,Jt=x[6]|0,Ve=Jt&8191,We=Jt>>>13,an=x[7]|0,Ze=an&8191,b=an>>>13,f=x[8]|0,h=f&8191,S=f>>>13,F=x[9]|0,V=F&8191,Y=F>>>13,Ae=R[0]|0,_e=Ae&8191,ge=Ae>>>13,$e=R[1]|0,he=$e&8191,et=$e>>>13,A0=R[2]|0,tt=A0&8191,nt=A0>>>13,x0=R[3]|0,rt=x0&8191,st=x0>>>13,S0=R[4]|0,it=S0&8191,ot=S0>>>13,T0=R[5]|0,at=T0&8191,ct=T0>>>13,O0=R[6]|0,ut=O0&8191,dt=O0>>>13,I0=R[7]|0,lt=I0&8191,ft=I0>>>13,N0=R[8]|0,ht=N0&8191,pt=N0>>>13,C0=R[9]|0,mt=C0&8191,gt=C0>>>13;y.negative=c.negative^p.negative,y.length=19,_=Math.imul(O,_e),u=Math.imul(O,ge),u=u+Math.imul($,_e)|0,l=Math.imul($,ge);var ru=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(ru>>>26)|0,ru&=67108863,_=Math.imul(re,_e),u=Math.imul(re,ge),u=u+Math.imul(oe,_e)|0,l=Math.imul(oe,ge),_=_+Math.imul(O,he)|0,u=u+Math.imul(O,et)|0,u=u+Math.imul($,he)|0,l=l+Math.imul($,et)|0;var su=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(su>>>26)|0,su&=67108863,_=Math.imul(ve,_e),u=Math.imul(ve,ge),u=u+Math.imul(Ee,_e)|0,l=Math.imul(Ee,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(O,tt)|0,u=u+Math.imul(O,nt)|0,u=u+Math.imul($,tt)|0,l=l+Math.imul($,nt)|0;var iu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(iu>>>26)|0,iu&=67108863,_=Math.imul(Re,_e),u=Math.imul(Re,ge),u=u+Math.imul(Ie,_e)|0,l=Math.imul(Ie,ge),_=_+Math.imul(ve,he)|0,u=u+Math.imul(ve,et)|0,u=u+Math.imul(Ee,he)|0,l=l+Math.imul(Ee,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(O,rt)|0,u=u+Math.imul(O,st)|0,u=u+Math.imul($,rt)|0,l=l+Math.imul($,st)|0;var ou=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(ou>>>26)|0,ou&=67108863,_=Math.imul(Le,_e),u=Math.imul(Le,ge),u=u+Math.imul(je,_e)|0,l=Math.imul(je,ge),_=_+Math.imul(Re,he)|0,u=u+Math.imul(Re,et)|0,u=u+Math.imul(Ie,he)|0,l=l+Math.imul(Ie,et)|0,_=_+Math.imul(ve,tt)|0,u=u+Math.imul(ve,nt)|0,u=u+Math.imul(Ee,tt)|0,l=l+Math.imul(Ee,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(O,it)|0,u=u+Math.imul(O,ot)|0,u=u+Math.imul($,it)|0,l=l+Math.imul($,ot)|0;var au=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(au>>>26)|0,au&=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(je,he)|0,l=l+Math.imul(je,et)|0,_=_+Math.imul(Re,tt)|0,u=u+Math.imul(Re,nt)|0,u=u+Math.imul(Ie,tt)|0,l=l+Math.imul(Ie,nt)|0,_=_+Math.imul(ve,rt)|0,u=u+Math.imul(ve,st)|0,u=u+Math.imul(Ee,rt)|0,l=l+Math.imul(Ee,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(O,at)|0,u=u+Math.imul(O,ct)|0,u=u+Math.imul($,at)|0,l=l+Math.imul($,ct)|0;var cu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(cu>>>26)|0,cu&=67108863,_=Math.imul(Ve,_e),u=Math.imul(Ve,ge),u=u+Math.imul(We,_e)|0,l=Math.imul(We,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(je,tt)|0,l=l+Math.imul(je,nt)|0,_=_+Math.imul(Re,rt)|0,u=u+Math.imul(Re,st)|0,u=u+Math.imul(Ie,rt)|0,l=l+Math.imul(Ie,st)|0,_=_+Math.imul(ve,it)|0,u=u+Math.imul(ve,ot)|0,u=u+Math.imul(Ee,it)|0,l=l+Math.imul(Ee,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(O,ut)|0,u=u+Math.imul(O,dt)|0,u=u+Math.imul($,ut)|0,l=l+Math.imul($,dt)|0;var uu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(uu>>>26)|0,uu&=67108863,_=Math.imul(Ze,_e),u=Math.imul(Ze,ge),u=u+Math.imul(b,_e)|0,l=Math.imul(b,ge),_=_+Math.imul(Ve,he)|0,u=u+Math.imul(Ve,et)|0,u=u+Math.imul(We,he)|0,l=l+Math.imul(We,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(je,rt)|0,l=l+Math.imul(je,st)|0,_=_+Math.imul(Re,it)|0,u=u+Math.imul(Re,ot)|0,u=u+Math.imul(Ie,it)|0,l=l+Math.imul(Ie,ot)|0,_=_+Math.imul(ve,at)|0,u=u+Math.imul(ve,ct)|0,u=u+Math.imul(Ee,at)|0,l=l+Math.imul(Ee,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(O,lt)|0,u=u+Math.imul(O,ft)|0,u=u+Math.imul($,lt)|0,l=l+Math.imul($,ft)|0;var du=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(du>>>26)|0,du&=67108863,_=Math.imul(h,_e),u=Math.imul(h,ge),u=u+Math.imul(S,_e)|0,l=Math.imul(S,ge),_=_+Math.imul(Ze,he)|0,u=u+Math.imul(Ze,et)|0,u=u+Math.imul(b,he)|0,l=l+Math.imul(b,et)|0,_=_+Math.imul(Ve,tt)|0,u=u+Math.imul(Ve,nt)|0,u=u+Math.imul(We,tt)|0,l=l+Math.imul(We,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(je,it)|0,l=l+Math.imul(je,ot)|0,_=_+Math.imul(Re,at)|0,u=u+Math.imul(Re,ct)|0,u=u+Math.imul(Ie,at)|0,l=l+Math.imul(Ie,ct)|0,_=_+Math.imul(ve,ut)|0,u=u+Math.imul(ve,dt)|0,u=u+Math.imul(Ee,ut)|0,l=l+Math.imul(Ee,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(O,ht)|0,u=u+Math.imul(O,pt)|0,u=u+Math.imul($,ht)|0,l=l+Math.imul($,pt)|0;var lu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(lu>>>26)|0,lu&=67108863,_=Math.imul(V,_e),u=Math.imul(V,ge),u=u+Math.imul(Y,_e)|0,l=Math.imul(Y,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(Ze,tt)|0,u=u+Math.imul(Ze,nt)|0,u=u+Math.imul(b,tt)|0,l=l+Math.imul(b,nt)|0,_=_+Math.imul(Ve,rt)|0,u=u+Math.imul(Ve,st)|0,u=u+Math.imul(We,rt)|0,l=l+Math.imul(We,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(je,at)|0,l=l+Math.imul(je,ct)|0,_=_+Math.imul(Re,ut)|0,u=u+Math.imul(Re,dt)|0,u=u+Math.imul(Ie,ut)|0,l=l+Math.imul(Ie,dt)|0,_=_+Math.imul(ve,lt)|0,u=u+Math.imul(ve,ft)|0,u=u+Math.imul(Ee,lt)|0,l=l+Math.imul(Ee,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(O,mt)|0,u=u+Math.imul(O,gt)|0,u=u+Math.imul($,mt)|0,l=l+Math.imul($,gt)|0;var fu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(fu>>>26)|0,fu&=67108863,_=Math.imul(V,he),u=Math.imul(V,et),u=u+Math.imul(Y,he)|0,l=Math.imul(Y,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(Ze,rt)|0,u=u+Math.imul(Ze,st)|0,u=u+Math.imul(b,rt)|0,l=l+Math.imul(b,st)|0,_=_+Math.imul(Ve,it)|0,u=u+Math.imul(Ve,ot)|0,u=u+Math.imul(We,it)|0,l=l+Math.imul(We,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(je,ut)|0,l=l+Math.imul(je,dt)|0,_=_+Math.imul(Re,lt)|0,u=u+Math.imul(Re,ft)|0,u=u+Math.imul(Ie,lt)|0,l=l+Math.imul(Ie,ft)|0,_=_+Math.imul(ve,ht)|0,u=u+Math.imul(ve,pt)|0,u=u+Math.imul(Ee,ht)|0,l=l+Math.imul(Ee,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 hu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(hu>>>26)|0,hu&=67108863,_=Math.imul(V,tt),u=Math.imul(V,nt),u=u+Math.imul(Y,tt)|0,l=Math.imul(Y,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(Ze,it)|0,u=u+Math.imul(Ze,ot)|0,u=u+Math.imul(b,it)|0,l=l+Math.imul(b,ot)|0,_=_+Math.imul(Ve,at)|0,u=u+Math.imul(Ve,ct)|0,u=u+Math.imul(We,at)|0,l=l+Math.imul(We,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(je,lt)|0,l=l+Math.imul(je,ft)|0,_=_+Math.imul(Re,ht)|0,u=u+Math.imul(Re,pt)|0,u=u+Math.imul(Ie,ht)|0,l=l+Math.imul(Ie,pt)|0,_=_+Math.imul(ve,mt)|0,u=u+Math.imul(ve,gt)|0,u=u+Math.imul(Ee,mt)|0,l=l+Math.imul(Ee,gt)|0;var pu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(pu>>>26)|0,pu&=67108863,_=Math.imul(V,rt),u=Math.imul(V,st),u=u+Math.imul(Y,rt)|0,l=Math.imul(Y,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(Ze,at)|0,u=u+Math.imul(Ze,ct)|0,u=u+Math.imul(b,at)|0,l=l+Math.imul(b,ct)|0,_=_+Math.imul(Ve,ut)|0,u=u+Math.imul(Ve,dt)|0,u=u+Math.imul(We,ut)|0,l=l+Math.imul(We,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(je,ht)|0,l=l+Math.imul(je,pt)|0,_=_+Math.imul(Re,mt)|0,u=u+Math.imul(Re,gt)|0,u=u+Math.imul(Ie,mt)|0,l=l+Math.imul(Ie,gt)|0;var mu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(mu>>>26)|0,mu&=67108863,_=Math.imul(V,it),u=Math.imul(V,ot),u=u+Math.imul(Y,it)|0,l=Math.imul(Y,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(Ze,ut)|0,u=u+Math.imul(Ze,dt)|0,u=u+Math.imul(b,ut)|0,l=l+Math.imul(b,dt)|0,_=_+Math.imul(Ve,lt)|0,u=u+Math.imul(Ve,ft)|0,u=u+Math.imul(We,lt)|0,l=l+Math.imul(We,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(je,mt)|0,l=l+Math.imul(je,gt)|0;var gu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(gu>>>26)|0,gu&=67108863,_=Math.imul(V,at),u=Math.imul(V,ct),u=u+Math.imul(Y,at)|0,l=Math.imul(Y,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(Ze,lt)|0,u=u+Math.imul(Ze,ft)|0,u=u+Math.imul(b,lt)|0,l=l+Math.imul(b,ft)|0,_=_+Math.imul(Ve,ht)|0,u=u+Math.imul(Ve,pt)|0,u=u+Math.imul(We,ht)|0,l=l+Math.imul(We,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 yu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(yu>>>26)|0,yu&=67108863,_=Math.imul(V,ut),u=Math.imul(V,dt),u=u+Math.imul(Y,ut)|0,l=Math.imul(Y,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(Ze,ht)|0,u=u+Math.imul(Ze,pt)|0,u=u+Math.imul(b,ht)|0,l=l+Math.imul(b,pt)|0,_=_+Math.imul(Ve,mt)|0,u=u+Math.imul(Ve,gt)|0,u=u+Math.imul(We,mt)|0,l=l+Math.imul(We,gt)|0;var bu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(bu>>>26)|0,bu&=67108863,_=Math.imul(V,lt),u=Math.imul(V,ft),u=u+Math.imul(Y,lt)|0,l=Math.imul(Y,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(Ze,mt)|0,u=u+Math.imul(Ze,gt)|0,u=u+Math.imul(b,mt)|0,l=l+Math.imul(b,gt)|0;var _u=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(_u>>>26)|0,_u&=67108863,_=Math.imul(V,ht),u=Math.imul(V,pt),u=u+Math.imul(Y,ht)|0,l=Math.imul(Y,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 wu=(N+_|0)+((u&8191)<<13)|0;N=(l+(u>>>13)|0)+(wu>>>26)|0,wu&=67108863,_=Math.imul(V,mt),u=Math.imul(V,gt),u=u+Math.imul(Y,mt)|0,l=Math.imul(Y,gt);var Eu=(N+_|0)+((u&8191)<<13)|0;return N=(l+(u>>>13)|0)+(Eu>>>26)|0,Eu&=67108863,A[0]=ru,A[1]=su,A[2]=iu,A[3]=ou,A[4]=au,A[5]=cu,A[6]=uu,A[7]=du,A[8]=lu,A[9]=fu,A[10]=hu,A[11]=pu,A[12]=mu,A[13]=gu,A[14]=yu,A[15]=bu,A[16]=_u,A[17]=wu,A[18]=Eu,N!==0&&(A[19]=N,y.length++),y};Math.imul||(Z=q);function D(E,c,p){p.negative=c.negative^E.negative,p.length=E.length+c.length;for(var y=0,x=0,R=0;R<p.length-1;R++){var A=x;x=0;for(var N=y&67108863,_=Math.min(R,c.length-1),u=Math.max(0,R-E.length+1);u<=_;u++){var l=R-u,w=E.words[l]|0,O=c.words[u]|0,$=w*O,W=$&67108863;A=A+($/67108864|0)|0,W=W+N|0,N=W&67108863,A=A+(W>>>26)|0,x+=A>>>26,A&=67108863}p.words[R]=N,y=A,A=x}return y!==0?p.words[R]=y:p.length--,p._strip()}function P(E,c,p){return D(E,c,p)}i.prototype.mulTo=function(c,p){var y,x=this.length+c.length;return this.length===10&&c.length===10?y=Z(this,c,p):x<63?y=q(this,c,p):x<1024?y=D(this,c,p):y=P(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),P(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,x=0;x<this.length;x++){var R=(this.words[x]|0)*c,A=(R&67108863)+(y&67108863);y>>=26,y+=R/67108864|0,y+=A>>>26,this.words[x]=A&67108863}return y!==0&&(this.words[x]=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=C(c);if(p.length===0)return new i(1);for(var y=this,x=0;x<p.length&&p[x]===0;x++,y=y.sqr());if(++x<p.length)for(var R=y.sqr();x<p.length;x++,R=R.sqr())p[x]!==0&&(y=y.mul(R));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,x=67108863>>>26-p<<26-p,R;if(p!==0){var A=0;for(R=0;R<this.length;R++){var N=this.words[R]&x,_=(this.words[R]|0)-N<<p;this.words[R]=_|A,A=N>>>26-p}A&&(this.words[R]=A,this.length++)}if(y!==0){for(R=this.length-1;R>=0;R--)this.words[R+y]=this.words[R];for(R=0;R<y;R++)this.words[R]=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 x;p?x=(p-p%26)/26:x=0;var R=c%26,A=Math.min((c-R)/26,this.length),N=67108863^67108863>>>R<<R,_=y;if(x-=A,x=Math.max(0,x),_){for(var u=0;u<A;u++)_.words[u]=this.words[u];_.length=A}if(A!==0)if(this.length>A)for(this.length-=A,u=0;u<this.length;u++)this.words[u]=this.words[u+A];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(l!==0||u>=x);u--){var w=this.words[u]|0;this.words[u]=l<<26-R|w>>>R,l=w&N}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,x=1<<p;if(this.length<=y)return!1;var R=this.words[y];return!!(R&x)},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 x=67108863^67108863>>>p<<p;this.words[this.length-1]&=x}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 x=c.length+y,R;this._expand(x);var A,N=0;for(R=0;R<c.length;R++){A=(this.words[R+y]|0)+N;var _=(c.words[R]|0)*p;A-=_&67108863,N=(A>>26)-(_/67108864|0),this.words[R+y]=A&67108863}for(;R<this.length-y;R++)A=(this.words[R+y]|0)+N,N=A>>26,this.words[R+y]=A&67108863;if(N===0)return this._strip();for(r(N===-1),N=0,R=0;R<this.length;R++)A=-(this.words[R]|0)+N,N=A>>26,this.words[R]=A&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,x=this.clone(),R=c,A=R.words[R.length-1]|0,N=this._countBits(A);y=26-N,y!==0&&(R=R.ushln(y),x.iushln(y),A=R.words[R.length-1]|0);var _=x.length-R.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=x.clone()._ishlnsubmul(R,1,_);w.negative===0&&(x=w,u&&(u.words[_]=1));for(var O=_-1;O>=0;O--){var $=(x.words[R.length+O]|0)*67108864+(x.words[R.length+O-1]|0);for($=Math.min($/A|0,67108863),x._ishlnsubmul(R,$,O);x.negative!==0;)$--,x.negative=0,x._ishlnsubmul(R,1,O),x.isZero()||(x.negative^=1);u&&(u.words[O]=$)}return u&&u._strip(),x._strip(),p!=="div"&&y!==0&&x.iushrn(y),{div:u||null,mod:x}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var x,R,A;return this.negative!==0&&c.negative===0?(A=this.neg().divmod(c,p),p!=="mod"&&(x=A.div.neg()),p!=="div"&&(R=A.mod.neg(),y&&R.negative!==0&&R.iadd(c)),{div:x,mod:R}):this.negative===0&&c.negative!==0?(A=this.divmod(c.neg(),p),p!=="mod"&&(x=A.div.neg()),{div:x,mod:A.mod}):(this.negative&c.negative)!==0?(A=this.neg().divmod(c.neg(),p),p!=="div"&&(R=A.mod.neg(),y&&R.negative!==0&&R.isub(c)),{div:A.div,mod:R}):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,x=c.ushrn(1),R=c.andln(1),A=y.cmp(x);return A<0||R===1&&A===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,x=0,R=this.length-1;R>=0;R--)x=(y*x+(this.words[R]|0))%c;return p?-x:x},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,x=this.length-1;x>=0;x--){var R=(this.words[x]|0)+y*67108864;this.words[x]=R/c|0,y=R%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 x=new i(1),R=new i(0),A=new i(0),N=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,O=1;(p.words[0]&O)===0&&w<26;++w,O<<=1);if(w>0)for(p.iushrn(w);w-- >0;)(x.isOdd()||R.isOdd())&&(x.iadd(u),R.isub(l)),x.iushrn(1),R.iushrn(1);for(var $=0,W=1;(y.words[0]&W)===0&&$<26;++$,W<<=1);if($>0)for(y.iushrn($);$-- >0;)(A.isOdd()||N.isOdd())&&(A.iadd(u),N.isub(l)),A.iushrn(1),N.iushrn(1);p.cmp(y)>=0?(p.isub(y),x.isub(A),R.isub(N)):(y.isub(p),A.isub(x),N.isub(R))}return{a:A,b:N,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 x=new i(1),R=new i(0),A=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var N=0,_=1;(p.words[0]&_)===0&&N<26;++N,_<<=1);if(N>0)for(p.iushrn(N);N-- >0;)x.isOdd()&&x.iadd(A),x.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;)R.isOdd()&&R.iadd(A),R.iushrn(1);p.cmp(y)>=0?(p.isub(y),x.isub(R)):(y.isub(p),R.isub(x))}var w;return p.cmpn(1)===0?w=x:w=R,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 x=0;p.isEven()&&y.isEven();x++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var R=p.cmp(y);if(R<0){var A=p;p=y,y=A}else if(R===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(x)},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,x=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=x,this;for(var R=x,A=y;R!==0&&A<this.length;A++){var N=this.words[A]|0;N+=R,R=N>>>26,N&=67108863,this.words[A]=N}return R!==0&&(this.words[A]=R,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 x=this.words[0]|0;y=x===c?0:x<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 x=this.words[y]|0,R=c.words[y]|0;if(x!==R){x<R?p=-1:x>R&&(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 U(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 x=y<this.n?-1:p.ucmp(this.p);return x===0?(p.words[0]=0,p.length=1):x>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 ee(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(ee,J),ee.prototype.split=function(c,p){for(var y=4194303,x=Math.min(c.length,9),R=0;R<x;R++)p.words[R]=c.words[R];if(p.length=x,c.length<=9){c.words[0]=0,c.length=1;return}var A=c.words[9];for(p.words[p.length++]=A&y,R=10;R<c.length;R++){var N=c.words[R]|0;c.words[R-10]=(N&y)<<4|A>>>22,A=N}A>>>=22,c.words[R-10]=A,A===0&&c.length>10?c.length-=10:c.length-=9},ee.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 x=c.words[y]|0;p+=x*977,c.words[y]=p&67108863,p=x*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function te(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(te,J);function K(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(K,J);function k(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(k,J),k.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var x=(c.words[y]|0)*19+p,R=x&67108863;x>>>=26,c.words[y]=R,p=x}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 ee;else if(c==="p224")p=new te;else if(c==="p192")p=new K;else if(c==="p25519")p=new k;else throw new Error("Unknown prime "+c);return z[c]=p,p};function U(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}U.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},U.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")},U.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(g(c,c.umod(this.m)._forceRed(this)),c)},U.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},U.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)},U.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},U.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)},U.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},U.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},U.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},U.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},U.prototype.isqr=function(c){return this.imul(c,c.clone())},U.prototype.sqr=function(c){return this.mul(c,c)},U.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 x=this.m.subn(1),R=0;!x.isZero()&&x.andln(1)===0;)R++,x.iushrn(1);r(!x.isZero());var A=new i(1).toRed(this),N=A.redNeg(),_=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new i(2*u*u).toRed(this);this.pow(u,_).cmp(N)!==0;)u.redIAdd(N);for(var l=this.pow(u,x),w=this.pow(c,x.addn(1).iushrn(1)),O=this.pow(c,x),$=R;O.cmp(A)!==0;){for(var W=O,re=0;W.cmp(A)!==0;re++)W=W.redSqr();r(re<$);var oe=this.pow(l,new i(1).iushln($-re-1));w=w.redMul(oe),l=oe.redSqr(),O=O.redMul(l),$=re}return w},U.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},U.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,x=new Array(1<<y);x[0]=new i(1).toRed(this),x[1]=c;for(var R=2;R<x.length;R++)x[R]=this.mul(x[R-1],c);var A=x[0],N=0,_=0,u=p.bitLength()%26;for(u===0&&(u=26),R=p.length-1;R>=0;R--){for(var l=p.words[R],w=u-1;w>=0;w--){var O=l>>w&1;if(A!==x[0]&&(A=this.sqr(A)),O===0&&N===0){_=0;continue}N<<=1,N|=O,_++,!(_!==y&&(R!==0||w!==0))&&(A=this.mul(A,x[N]),_=0,N=0)}u=26}return A},U.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},U.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new j(c)};function j(E){U.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,U),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),x=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=y.isub(x).iushrn(this.shift),A=R;return R.cmp(this.m)>=0?A=R.isub(this.m):R.cmpn(0)<0&&(A=R.iadd(this.m)),A._forceRed(this)},j.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),x=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=y.isub(x).iushrn(this.shift),A=R;return R.cmp(this.m)>=0?A=R.isub(this.m):R.cmpn(0)<0&&(A=R.iadd(this.m)),A._forceRed(this)},j.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,u_)})(zi)),zi.exports}var d_=Rf();const Af=Ii(d_);var ji={exports:{}};var xf;function l_(){return xf||(xf=1,(function(t,e){var n=uc(),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)}})(ji,ji.exports)),ji.exports}var fc,Sf;function f_(){if(Sf)return fc;Sf=1;var t=l_().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),v=Math.log(256)/Math.log(d);function T(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 C=0,q=0,Z=0,D=M.length;Z!==D&&M[Z]===0;)Z++,C++;for(var P=(D-Z)*v+1>>>0,z=new Uint8Array(P);Z!==D;){for(var J=M[Z],ee=0,te=P-1;(J!==0||ee<q)&&te!==-1;te--,ee++)J+=256*z[te]>>>0,z[te]=J%d>>>0,J=J/d>>>0;if(J!==0)throw new Error("Non-zero carry");q=ee,Z++}for(var K=P-q;K!==P&&z[K]===0;)K++;for(var k=m.repeat(C);K<P;++K)k+=n.charAt(z[K]);return k}function I(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return t.alloc(0);for(var C=0,q=0,Z=0;M[C]===m;)q++,C++;for(var D=(M.length-C)*g+1>>>0,P=new Uint8Array(D);C<M.length;){var z=M.charCodeAt(C);if(z>255)return;var J=r[z];if(J===255)return;for(var ee=0,te=D-1;(J!==0||ee<Z)&&te!==-1;te--,ee++)J+=d*P[te]>>>0,P[te]=J%256>>>0,J=J/256>>>0;if(J!==0)throw new Error("Non-zero carry");Z=ee,C++}for(var K=D-Z;K!==D&&P[K]===0;)K++;var k=t.allocUnsafe(q+(D-K));k.fill(0,0,q);for(var U=q;K!==D;)k[U++]=P[K++];return k}function L(M){var C=I(M);if(C)return C;throw new Error("Non-base"+d+" character")}return{encode:T,decodeUnsafe:I,decode:L}}return fc=e,fc}var hc,Tf;function Of(){if(Tf)return hc;Tf=1;var t=f_(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return hc=t(e),hc}var h_=Of();const Ft=Ii(h_);var Be={};function On(t,e,n){return e<=t&&t<=n}function Vi(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function p_(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 m_(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 Gi=-1;function pc(t){this.tokens=[].slice.call(t)}pc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Gi},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 Ur=-1;function mc(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Hi="utf-8";function qi(t,e){if(!(this instanceof qi))return new qi(t,e);if(t=t!==void 0?String(t).toLowerCase():Hi,t!==Hi)throw new Error("Encoding not supported. Only utf-8 is supported");e=Vi(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})}qi.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=Vi(n),this._streaming||(this._decoder=new g_({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var s=new pc(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Ur);)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===Ur)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),m_(i)}};function Ki(t,e){if(!(this instanceof Ki))return new Ki(t,e);if(t=t!==void 0?String(t).toLowerCase():Hi,t!==Hi)throw new Error("Encoding not supported. Only utf-8 is supported");e=Vi(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Ki.prototype={encode:function(e,n){e=e?String(e):"",n=Vi(n),this._streaming||(this._encoder=new y_(this._options)),this._streaming=!!n.stream;for(var r=[],s=new pc(p_(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Ur);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Ur;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function g_(t){var e=t.fatal,n=0,r=0,s=0,i=128,o=191;this.handler=function(a,d){if(d===Gi&&s!==0)return s=0,mc(e);if(d===Gi)return Ur;if(s===0){if(On(d,0,127))return d;if(On(d,194,223))s=1,n=d-192;else if(On(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,n=d-224;else if(On(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,n=d-240;else return mc(e);return n=n<<6*s,null}if(!On(d,i,o))return n=s=r=0,i=128,o=191,a.prepend(d),mc(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 y_(t){t.fatal,this.handler=function(e,n){if(n===Gi)return Ur;if(On(n,0,127))return n;var r,s;On(n,128,2047)?(r=1,s=192):On(n,2048,65535)?(r=2,s=224):On(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 b_=Wa(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:qi,TextEncoder:Ki},Symbol.toStringTag,{value:"Module"})));var If;function __(){if(If)return Be;If=1;var t=Be&&Be.__createBinding||(Object.create?(function(K,k,U,j){j===void 0&&(j=U),Object.defineProperty(K,j,{enumerable:!0,get:function(){return k[U]}})}):(function(K,k,U,j){j===void 0&&(j=U),K[j]=k[U]})),e=Be&&Be.__setModuleDefault||(Object.create?(function(K,k){Object.defineProperty(K,"default",{enumerable:!0,value:k})}):function(K,k){K.default=k}),n=Be&&Be.__decorate||function(K,k,U,j){var E=arguments.length,c=E<3?k:j===null?j=Object.getOwnPropertyDescriptor(k,U):j,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(K,k,U,j);else for(var y=K.length-1;y>=0;y--)(p=K[y])&&(c=(E<3?p(c):E>3?p(k,U,c):p(k,U))||c);return E>3&&c&&Object.defineProperty(k,U,c),c},r=Be&&Be.__importStar||function(K){if(K&&K.__esModule)return K;var k={};if(K!=null)for(var U in K)U!=="default"&&Object.hasOwnProperty.call(K,U)&&t(k,K,U);return e(k,K),k},s=Be&&Be.__importDefault||function(K){return K&&K.__esModule?K:{default:K}};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(b_),d=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,m=new d("utf-8",{fatal:!0});function g(K){return typeof K=="string"&&(K=Buffer.from(K,"utf8")),o.default.encode(Buffer.from(K))}Be.baseEncode=g;function v(K){return Buffer.from(o.default.decode(K))}Be.baseDecode=v;const T=1024;class I extends Error{constructor(k){super(k),this.fieldPath=[],this.originalMessage=k}addToFieldPath(k){this.fieldPath.splice(0,0,k),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Be.BorshError=I;class L{constructor(){this.buf=Buffer.alloc(T),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(T)]))}writeU8(k){this.maybeResize(),this.buf.writeUInt8(k,this.length),this.length+=1}writeU16(k){this.maybeResize(),this.buf.writeUInt16LE(k,this.length),this.length+=2}writeU32(k){this.maybeResize(),this.buf.writeUInt32LE(k,this.length),this.length+=4}writeU64(k){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(k).toArray("le",8)))}writeU128(k){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(k).toArray("le",16)))}writeU256(k){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(k).toArray("le",32)))}writeU512(k){this.maybeResize(),this.writeBuffer(Buffer.from(new i.default(k).toArray("le",64)))}writeBuffer(k){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),k,Buffer.alloc(T)]),this.length+=k.length}writeString(k){this.maybeResize();const U=Buffer.from(k,"utf8");this.writeU32(U.length),this.writeBuffer(U)}writeFixedArray(k){this.writeBuffer(Buffer.from(k))}writeArray(k,U){this.maybeResize(),this.writeU32(k.length);for(const j of k)this.maybeResize(),U(j)}toArray(){return this.buf.subarray(0,this.length)}}Be.BinaryWriter=L;function M(K,k,U){const j=U.value;U.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 I("Reached the end of buffer when deserializing")}throw c}}}class C{constructor(k){this.buf=k,this.offset=0}readU8(){const k=this.buf.readUInt8(this.offset);return this.offset+=1,k}readU16(){const k=this.buf.readUInt16LE(this.offset);return this.offset+=2,k}readU32(){const k=this.buf.readUInt32LE(this.offset);return this.offset+=4,k}readU64(){const k=this.readBuffer(8);return new i.default(k,"le")}readU128(){const k=this.readBuffer(16);return new i.default(k,"le")}readU256(){const k=this.readBuffer(32);return new i.default(k,"le")}readU512(){const k=this.readBuffer(64);return new i.default(k,"le")}readBuffer(k){if(this.offset+k>this.buf.length)throw new I(`Expected buffer length ${k} isn't within bounds`);const U=this.buf.slice(this.offset,this.offset+k);return this.offset+=k,U}readString(){const k=this.readU32(),U=this.readBuffer(k);try{return m.decode(U)}catch(j){throw new I(`Error decoding UTF-8 string: ${j}`)}}readFixedArray(k){return new Uint8Array(this.readBuffer(k))}readArray(k){const U=this.readU32(),j=Array();for(let E=0;E<U;++E)j.push(k());return j}}n([M],C.prototype,"readU8",null),n([M],C.prototype,"readU16",null),n([M],C.prototype,"readU32",null),n([M],C.prototype,"readU64",null),n([M],C.prototype,"readU128",null),n([M],C.prototype,"readU256",null),n([M],C.prototype,"readU512",null),n([M],C.prototype,"readString",null),n([M],C.prototype,"readFixedArray",null),n([M],C.prototype,"readArray",null),Be.BinaryReader=C;function q(K){return K.charAt(0).toUpperCase()+K.slice(1)}function Z(K,k,U,j,E){try{if(typeof j=="string")E[`write${q(j)}`](U);else if(j instanceof Array)if(typeof j[0]=="number"){if(U.length!==j[0])throw new I(`Expecting byte array of length ${j[0]}, but got ${U.length} bytes`);E.writeFixedArray(U)}else if(j.length===2&&typeof j[1]=="number"){if(U.length!==j[1])throw new I(`Expecting byte array of length ${j[1]}, but got ${U.length} bytes`);for(let c=0;c<j[1];c++)Z(K,null,U[c],j[0],E)}else E.writeArray(U,c=>{Z(K,k,c,j[0],E)});else if(j.kind!==void 0)switch(j.kind){case"option":{U==null?E.writeU8(0):(E.writeU8(1),Z(K,k,U,j.type,E));break}case"map":{E.writeU32(U.size),U.forEach((c,p)=>{Z(K,k,p,j.key,E),Z(K,k,c,j.value,E)});break}default:throw new I(`FieldType ${j} unrecognized`)}else D(K,U,E)}catch(c){throw c instanceof I&&c.addToFieldPath(k),c}}function D(K,k,U){if(typeof k.borshSerialize=="function"){k.borshSerialize(U);return}const j=K.get(k.constructor);if(!j)throw new I(`Class ${k.constructor.name} is missing in schema`);if(j.kind==="struct")j.fields.map(([E,c])=>{Z(K,E,k[E],c,U)});else if(j.kind==="enum"){const E=k[j.field];for(let c=0;c<j.values.length;++c){const[p,y]=j.values[c];if(p===E){U.writeU8(c),Z(K,p,k[p],y,U);break}}}else throw new I(`Unexpected schema kind: ${j.kind} for ${k.constructor.name}`)}function P(K,k,U=L){const j=new U;return D(K,k,j),j.toArray()}Be.serialize=P;function z(K,k,U,j){try{if(typeof U=="string")return j[`read${q(U)}`]();if(U instanceof Array){if(typeof U[0]=="number")return j.readFixedArray(U[0]);if(typeof U[1]=="number"){const E=[];for(let c=0;c<U[1];c++)E.push(z(K,null,U[0],j));return E}else return j.readArray(()=>z(K,k,U[0],j))}if(U.kind==="option")return j.readU8()?z(K,k,U.type,j):void 0;if(U.kind==="map"){let E=new Map;const c=j.readU32();for(let p=0;p<c;p++){const y=z(K,k,U.key,j),x=z(K,k,U.value,j);E.set(y,x)}return E}return J(K,U,j)}catch(E){throw E instanceof I&&E.addToFieldPath(k),E}}function J(K,k,U){if(typeof k.borshDeserialize=="function")return k.borshDeserialize(U);const j=K.get(k);if(!j)throw new I(`Class ${k.name} is missing in schema`);if(j.kind==="struct"){const E={};for(const[c,p]of K.get(k).fields)E[c]=z(K,c,p,U);return new k(E)}if(j.kind==="enum"){const E=U.readU8();if(E>=j.values.length)throw new I(`Enum index: ${E} is out of range`);const[c,p]=j.values[E],y=z(K,c,p,U);return new k({[c]:y})}throw new I(`Unexpected schema kind: ${j.kind} for ${k.constructor.name}`)}function ee(K,k,U,j=C){const E=new j(U),c=J(K,k,E);if(E.offset<U.length)throw new I(`Unexpected ${U.length-E.offset} bytes after deserialized data`);return c}Be.deserialize=ee;function te(K,k,U,j=C){const E=new j(U);return J(K,k,E)}return Be.deserializeUnchecked=te,Be}var gc=__(),H={},Nf;function w_(){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=uc();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,O){return l.encode(this,w,O)},writable:!0}),Object.defineProperty(u,"decode",{value(w,O){return l.decode(w,O)},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 O=l.length-w;return Math.floor(O/this.elementSpan)}encode(l,w,O){return 0}}H.GreedyCount=a;class d extends o{constructor(l,w=0,O){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,O||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,O=0){return this.layout.encode(l,w,O+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,O=0){return n(w).writeUIntLE(l,O,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,O=0){return n(w).writeUIntBE(l,O,this.span),this.span}}H.UIntBE=g;class v 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,O=0){return n(w).writeIntLE(l,O,this.span),this.span}}H.Int=v;class T 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,O=0){return n(w).writeIntBE(l,O,this.span),this.span}}H.IntBE=T;const I=Math.pow(2,32);function L(u){const l=Math.floor(u/I),w=u-l*I;return{hi32:l,lo32:w}}function M(u,l){return u*I+l}class C extends r{constructor(l){super(8,l)}decode(l,w=0){const O=n(l),$=O.readUInt32LE(w),W=O.readUInt32LE(w+4);return M(W,$)}encode(l,w,O=0){const $=L(l),W=n(w);return W.writeUInt32LE($.lo32,O),W.writeUInt32LE($.hi32,O+4),8}}H.NearUInt64=C;class q extends r{constructor(l){super(8,l)}decode(l,w=0){const O=n(l),$=O.readUInt32BE(w),W=O.readUInt32BE(w+4);return M($,W)}encode(l,w,O=0){const $=L(l),W=n(w);return W.writeUInt32BE($.hi32,O),W.writeUInt32BE($.lo32,O+4),8}}H.NearUInt64BE=q;class Z extends r{constructor(l){super(8,l)}decode(l,w=0){const O=n(l),$=O.readUInt32LE(w),W=O.readInt32LE(w+4);return M(W,$)}encode(l,w,O=0){const $=L(l),W=n(w);return W.writeUInt32LE($.lo32,O),W.writeInt32LE($.hi32,O+4),8}}H.NearInt64=Z;class D extends r{constructor(l){super(8,l)}decode(l,w=0){const O=n(l),$=O.readInt32BE(w),W=O.readUInt32BE(w+4);return M($,W)}encode(l,w,O=0){const $=L(l),W=n(w);return W.writeInt32BE($.hi32,O),W.writeUInt32BE($.lo32,O+4),8}}H.NearInt64BE=D;class P extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatLE(w)}encode(l,w,O=0){return n(w).writeFloatLE(l,O),4}}H.Float=P;class z extends r{constructor(l){super(4,l)}decode(l,w=0){return n(l).readFloatBE(w)}encode(l,w,O=0){return n(w).writeFloatBE(l,O),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,O=0){return n(w).writeDoubleLE(l,O),8}}H.Double=J;class ee extends r{constructor(l){super(8,l)}decode(l,w=0){return n(l).readDoubleBE(w)}encode(l,w,O=0){return n(w).writeDoubleBE(l,O),8}}H.DoubleBE=ee;class te extends r{constructor(l,w,O){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 $=-1;!(w instanceof o)&&0<l.span&&($=w*l.span),super($,O),this.elementLayout=l,this.count=w}getSpan(l,w=0){if(0<=this.span)return this.span;let O=0,$=this.count;if($ instanceof o&&($=$.decode(l,w)),0<this.elementLayout.span)O=$*this.elementLayout.span;else{let W=0;for(;W<$;)O+=this.elementLayout.getSpan(l,w+O),++W}return O}decode(l,w=0){const O=[];let $=0,W=this.count;for(W instanceof o&&(W=W.decode(l,w));$<W;)O.push(this.elementLayout.decode(l,w)),w+=this.elementLayout.getSpan(l,w),$+=1;return O}encode(l,w,O=0){const $=this.elementLayout,W=l.reduce((re,oe)=>re+$.encode(oe,w,O+re),0);return this.count instanceof o&&this.count.encode(l.length,w,O),W}}H.Sequence=te;class K extends r{constructor(l,w,O){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"&&O===void 0&&(O=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 $=-1;try{$=l.reduce((W,re)=>W+re.getSpan(),0)}catch{}super($,w),this.fields=l,this.decodePrefixes=!!O}getSpan(l,w=0){if(0<=this.span)return this.span;let O=0;try{O=this.fields.reduce(($,W)=>{const re=W.getSpan(l,w);return w+=re,$+re},0)}catch{throw new RangeError("indeterminate span")}return O}decode(l,w=0){e(l);const O=this.makeDestinationObject();for(const $ of this.fields)if($.property!==void 0&&(O[$.property]=$.decode(l,w)),w+=$.getSpan(l,w),this.decodePrefixes&&l.length===w)break;return O}encode(l,w,O=0){const $=O;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 ve=l[oe.property];ve!==void 0&&(re=oe.encode(ve,w,O),0>Ce&&(Ce=oe.getSpan(w,O)))}W=O,O+=Ce}return W+re-$}fromArray(l){const w=this.makeDestinationObject();for(const O of this.fields)O.property!==void 0&&0<l.length&&(w[O.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 O of this.fields){if(O.property===l)return w;0>O.span?w=-1:0<=w&&(w+=O.span)}}}H.Structure=K;class k{constructor(l){this.property=l}decode(l,w){throw new Error("UnionDiscriminator is abstract")}encode(l,w,O){throw new Error("UnionDiscriminator is abstract")}}H.UnionDiscriminator=k;class U extends k{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,O){return this.layout.encode(l,w,O)}}H.UnionLayoutDiscriminator=U;class j extends r{constructor(l,w,O){let $;if(l instanceof m||l instanceof g)$=new U(new d(l));else if(l instanceof o&&l.isCount())$=new U(l);else if(l instanceof k)$=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+=$.layout.span)),super(W,O),this.discriminator=$,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 O=this.getVariant(l,w);if(!O)throw new Error("unable to determine span for unrecognized variant");return O.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 O=this.registry[w];if(O.property&&Object.prototype.hasOwnProperty.call(l,O.property))return O}throw new Error("unable to infer src variant")}decode(l,w=0){let O;const $=this.discriminator,W=$.decode(l,w),re=this.registry[W];if(re===void 0){const oe=this.defaultLayout;let Ce=0;this.usesPrefixDiscriminator&&(Ce=$.layout.span),O=this.makeDestinationObject(),O[$.property]=W,O[oe.property]=oe.decode(l,w+Ce)}else O=re.decode(l,w);return O}encode(l,w,O=0){const $=this.getSourceVariant(l);if($===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,O),oe+re.encode(l[re.property],w,O+oe)}return $.encode(l,w,O)}addVariant(l,w,O){const $=new E(this,l,w,O);return this.registry[l]=$,$}getVariant(l,w=0){let O;return l instanceof Uint8Array?O=this.discriminator.decode(l,w):O=l,this.registry[O]}}H.Union=j;class E extends r{constructor(l,w,O,$){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 O=="string"&&$===void 0&&($=O,O=null),O){if(!(O instanceof r))throw new TypeError("layout must be a Layout");if(l.defaultLayout!==null&&0<=O.span&&O.span>l.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof $!="string")throw new TypeError("variant must have a String property")}let W=l.span;0>l.span&&(W=O?O.span:0,0<=W&&l.usesPrefixDiscriminator&&(W+=l.discriminator.layout.span)),super(W,$),this.union=l,this.variant=w,this.layout=O||null}getSpan(l,w=0){if(0<=this.span)return this.span;let O=0;this.union.usesPrefixDiscriminator&&(O=this.union.discriminator.layout.span);let $=0;return this.layout&&($=this.layout.getSpan(l,w+O)),O+$}decode(l,w=0){const O=this.makeDestinationObject();if(this!==this.union.getVariant(l,w))throw new Error("variant mismatch");let $=0;return this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout?O[this.property]=this.layout.decode(l,w+$):this.property?O[this.property]=!0:this.union.usesPrefixDiscriminator&&(O[this.union.discriminator.property]=this.variant),O}encode(l,w,O=0){let $=0;if(this.union.usesPrefixDiscriminator&&($=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,O);let W=$;if(this.layout&&(this.layout.encode(l[this.property],w,O+$),W+=this.layout.getSpan(w,O+$),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,O){if(!(l instanceof m||l instanceof g))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof w=="string"&&O===void 0&&(O=w,w=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,O),this.word=l,this.msb=!!w,this.fields=[];let $=0;this._packedSetValue=function(W){return $=c(W),this},this._packedGetValue=function(){return $}}decode(l,w=0){const O=this.makeDestinationObject(),$=this.word.decode(l,w);this._packedSetValue($);for(const W of this.fields)W.property!==void 0&&(O[W.property]=W.decode(l));return O}encode(l,w,O=0){const $=this.word.decode(w,O);this._packedSetValue($);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,O)}addField(l,w){const O=new y(this,l,w);return this.fields.push(O),O}addBoolean(l){const w=new x(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,O){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 $=8*l.span,W=l.fields.reduce((re,oe)=>re+oe.bits,0);if(w+W>$)throw new Error("bits too long for span remainder ("+($-W)+" of "+$+" 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=$-W-w),this.wordMask=c(this.valueMask<<this.start),this.property=O}decode(l,w){const O=this.container._packedGetValue();return c(O&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(),O=c(l<<this.start);this.container._packedSetValue(c(w&~this.wordMask)|O)}}H.BitField=y;class x 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=x;class R 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 O=-1;l instanceof o||(O=l),super(O,w),this.length=l}getSpan(l,w){let O=this.span;return 0>O&&(O=this.length.decode(l,w)),O}decode(l,w=0){let O=this.span;return 0>O&&(O=this.length.decode(l,w)),n(l).slice(w,w+O)}encode(l,w,O){let $=this.length;if(this.length instanceof o&&($=l.length),!(l instanceof Uint8Array&&$===l.length))throw new TypeError(s("Blob.encode",this)+" requires (length "+$+") Uint8Array as src");if(O+$>w.length)throw new RangeError("encoding overruns Uint8Array");const W=n(l);return n(w).write(W.toString("hex"),O,$,"hex"),this.length instanceof o&&this.length.encode($,w,O),$}}H.Blob=R;class A extends r{constructor(l){super(-1,l)}getSpan(l,w=0){e(l);let O=w;for(;O<l.length&&l[O]!==0;)O+=1;return 1+O-w}decode(l,w=0){const O=this.getSpan(l,w);return n(l).slice(w,w+O-1).toString("utf-8")}encode(l,w,O=0){typeof l!="string"&&(l=String(l));const $=t.Buffer.from(l,"utf8"),W=$.length;if(O+W>w.length)throw new RangeError("encoding overruns Buffer");const re=n(w);return $.copy(re,O),re[O+W]=0,W+1}}H.CString=A;class N 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 O=this.getSpan(l,w);if(0<=this.maxSpan&&this.maxSpan<O)throw new RangeError("text length exceeds maxSpan");return n(l).slice(w,w+O).toString("utf-8")}encode(l,w,O=0){typeof l!="string"&&(l=String(l));const $=t.Buffer.from(l,"utf8"),W=$.length;if(0<=this.maxSpan&&this.maxSpan<W)throw new RangeError("text length exceeds maxSpan");if(O+W>w.length)throw new RangeError("encoding overruns Buffer");return $.copy(n(w),O),W}}H.UTF8=N;class _ extends r{constructor(l,w){super(0,w),this.value=l}decode(l,w){return this.value}encode(l,w,O){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 C(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 q(u)),H.s8=(u=>new v(1,u)),H.s16=(u=>new v(2,u)),H.s24=(u=>new v(3,u)),H.s32=(u=>new v(4,u)),H.s40=(u=>new v(5,u)),H.s48=(u=>new v(6,u)),H.ns64=(u=>new Z(u)),H.s16be=(u=>new T(2,u)),H.s24be=(u=>new T(3,u)),H.s32be=(u=>new T(4,u)),H.s40be=(u=>new T(5,u)),H.s48be=(u=>new T(6,u)),H.ns64be=(u=>new D(u)),H.f32=(u=>new P(u)),H.f32be=(u=>new z(u)),H.f64=(u=>new J(u)),H.f64be=(u=>new ee(u)),H.struct=((u,l,w)=>new K(u,l,w)),H.bits=((u,l,w)=>new p(u,l,w)),H.seq=((u,l,w)=>new te(u,l,w)),H.union=((u,l,w)=>new j(u,l,w)),H.unionLayoutDiscriminator=((u,l)=>new U(u,l)),H.blob=((u,l)=>new R(u,l)),H.cstr=(u=>new A(u)),H.utf8=((u,l)=>new N(u,l)),H.constant=((u,l)=>new _(u,l)),H}var B=w_(),E_=1,v_=2,R_=3,A_=4,x_=5,S_=6,T_=7,O_=8,I_=9,N_=10,C_=-32700,M_=-32603,B_=-32602,k_=-32601,L_=-32600,P_=-32016,U_=-32015,D_=-32014,F_=-32013,$_=-32012,z_=-32011,j_=-32010,V_=-32009,G_=-32008,H_=-32007,q_=-32006,K_=-32005,W_=-32004,Z_=-32003,Y_=-32002,J_=-32001,X_=28e5,Q_=2800001,ew=2800002,tw=2800003,nw=2800004,rw=2800005,sw=2800006,iw=2800007,ow=2800008,aw=2800009,cw=2800010,uw=2800011,dw=323e4,lw=32300001,fw=3230002,hw=3230003,pw=3230004,mw=361e4,gw=3610001,yw=3610002,bw=3610003,_w=3610004,ww=3610005,Ew=3610006,vw=3610007,Rw=3611e3,Aw=3704e3,xw=3704001,Sw=3704002,Tw=3704003,Ow=3704004,Iw=4128e3,Nw=4128001,Cw=4128002,Mw=4615e3,Bw=4615001,kw=4615002,Lw=4615003,Pw=4615004,Uw=4615005,Dw=4615006,Fw=4615007,$w=4615008,zw=4615009,jw=4615010,Vw=4615011,Gw=4615012,Hw=4615013,qw=4615014,Kw=4615015,Ww=4615016,Zw=4615017,Yw=4615018,Jw=4615019,Xw=4615020,Qw=4615021,eE=4615022,tE=4615023,nE=4615024,rE=4615025,sE=4615026,iE=4615027,oE=4615028,aE=4615029,cE=4615030,uE=4615031,dE=4615032,lE=4615033,fE=4615034,hE=4615035,pE=4615036,mE=4615037,gE=4615038,yE=4615039,bE=4615040,_E=4615041,wE=4615042,EE=4615043,vE=4615044,RE=4615045,AE=4615046,xE=4615047,SE=4615048,TE=4615049,OE=4615050,IE=4615051,NE=4615052,CE=4615053,ME=4615054,BE=5508e3,kE=5508001,LE=5508002,PE=5508003,UE=5508004,DE=5508005,FE=5508006,$E=5508007,zE=5508008,jE=5508009,VE=5508010,GE=5508011,HE=5663e3,qE=5663001,KE=5663002,WE=5663003,ZE=5663004,YE=5663005,JE=5663006,XE=5663007,QE=5663008,ev=5663009,tv=5663010,nv=5663011,rv=5663012,sv=5663013,iv=5663014,ov=5663015,av=5663016,cv=5663017,uv=5663018,dv=5663019,lv=5663020,fv=705e4,hv=7050001,pv=7050002,mv=7050003,gv=7050004,yv=7050005,bv=7050006,_v=7050007,wv=7050008,Ev=7050009,vv=7050010,Rv=7050011,Av=7050012,xv=7050013,Sv=7050014,Tv=7050015,Ov=7050016,Iv=7050017,Nv=7050018,Cv=7050019,Mv=7050020,Bv=7050021,kv=7050022,Lv=7050023,Pv=7050024,Uv=7050025,Dv=7050026,Fv=7050027,$v=7050028,zv=7050029,jv=7050030,Vv=7050031,Gv=7050032,Hv=7050033,qv=7050034,Kv=7050035,Wv=7050036,Cf=8078e3,Mf=8078001,Zv=8078002,Yv=8078003,Bf=8078004,kf=8078005,Lf=8078006,Jv=8078007,Xv=8078008,Qv=8078009,eR=8078010,Pf=8078011,tR=8078012,nR=8078013,rR=8078014,sR=8078015,iR=8078016,oR=8078017,aR=8078018,cR=8078019,uR=8078020,dR=8078021,lR=8078022,fR=81e5,hR=8100001,pR=8100002,mR=8100003,gR=819e4,yR=8190001,bR=8190002,_R=8190003,wR=8190004,ER=99e5,vR=9900001,RR=9900002,AR=9900003,xR=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 SR([t,e]){return`${t}=${Uf(e)}`}function TR(t){const e=Object.entries(t).map(SR).join("&");return btoa(e)}var OR={[dw]:"Account not found at address: $address",[pw]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[hw]:"Expected decoded account at address: $address",[fw]:"Failed to decode account data at address: $address",[lw]:"Accounts not found at addresses: $addresses",[aw]:"Unable to find a viable program address bump seed.",[ew]:"$putativeAddress is not a base58-encoded address.",[X_]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[tw]:"The `CryptoKey` must be an `Ed25519` public key.",[uw]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[ow]:"Invalid seeds; point must fall off the Ed25519 curve.",[nw]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[sw]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[iw]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[rw]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[cw]:"Program address cannot end with PDA marker.",[Q_]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[A_]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[E_]:"The network has progressed past the last block for which this transaction could have been committed.",[Cf]:"Codec [$codecDescription] cannot decode empty byte arrays.",[lR]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[uR]:"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.",[Xv]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Zv]:"Expected a fixed-size codec, got a variable-size one.",[nR]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Yv]:"Expected a variable-size codec, got a fixed-size one.",[cR]:"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.",[aR]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Qv]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[eR]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[sR]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Jv]:"Expected [$codecDescription] to have $expected items, got $actual.",[tR]:"Invalid value $value for base $base with alphabet $alphabet.",[iR]:"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.",[rR]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[dR]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[oR]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Rw]:"No random values implementation could be found.",[zw]:"instruction requires an uninitialized account",[tE]:"instruction tries to borrow reference for an account which is already borrowed",[nE]:"instruction left account with an outstanding borrowed reference",[Qw]:"program other than the account's owner changed the size of the account data",[Uw]:"account data too small for instruction",[eE]:"instruction expected an executable account",[AE]:"An account does not have enough lamports to be rent-exempt",[SE]:"Program arithmetic overflowed",[RE]:"Failed to serialize or deserialize account data: $encodedData",[ME]:"Builtin programs must consume compute units",[dE]:"Cross-program invocation call depth too deep",[gE]:"Computational budget exceeded",[sE]:"custom program error: #$code",[Zw]:"instruction contains duplicate accounts",[rE]:"instruction modifications of multiply-passed account differ",[cE]:"executable accounts must be rent exempt",[oE]:"instruction changed executable accounts data",[aE]:"instruction changed the balance of an executable account",[Yw]:"instruction changed executable bit of an account",[qw]:"instruction modified data of an account it does not own",[Hw]:"instruction spent from the balance of an account it does not own",[Bw]:"generic instruction error",[OE]:"Provided owner is not allowed",[EE]:"Account is immutable",[vE]:"Incorrect authority provided",[Fw]:"incorrect program id for instruction",[Dw]:"insufficient funds for instruction",[Pw]:"invalid account data for instruction",[xE]:"Invalid account owner",[kw]:"invalid program argument",[iE]:"program returned invalid error code",[Lw]:"invalid instruction data",[mE]:"Failed to reallocate account data",[pE]:"Provided seeds do not result in a valid address",[IE]:"Accounts data allocations exceeded the maximum allowed per transaction",[NE]:"Max accounts exceeded",[CE]:"Max instruction trace length exceeded",[hE]:"Length of the seed is too long for address generation",[lE]:"An account required by the instruction is missing",[$w]:"missing required signature for instruction",[Gw]:"instruction illegally modified the program id of an account",[Xw]:"insufficient account keys for instruction",[yE]:"Cross-program invocation with unauthorized signer or writable account",[bE]:"Failed to create program execution environment",[wE]:"Program failed to compile",[_E]:"Program failed to complete",[Ww]:"instruction modified data of a read-only account",[Kw]:"instruction changed the balance of a read-only account",[fE]:"Cross-program invocation reentrancy not allowed for this instruction",[Jw]:"instruction modified rent epoch of an account",[Vw]:"sum of account balances before and after instruction do not match",[jw]:"instruction requires an initialized account",[Mw]:"",[uE]:"Unsupported program id",[TE]:"Unsupported sysvar",[Iw]:"The instruction does not have any accounts.",[Nw]:"The instruction does not have any data.",[Cw]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[x_]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[v_]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[RR]:"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",[xR]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[vR]:"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",[ER]:"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",[AR]:"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",[M_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[B_]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[L_]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[k_]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[C_]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[$_]:"$__serverMessage",[J_]:"$__serverMessage",[W_]:"$__serverMessage",[D_]:"$__serverMessage",[j_]:"$__serverMessage",[V_]:"$__serverMessage",[P_]:"Minimum context slot has not been reached",[K_]:"Node is unhealthy; behind by $numSlotsBehind slots",[G_]:"No snapshot",[Y_]:"Transaction simulation failed",[H_]:"$__serverMessage",[z_]:"Transaction history is not available from this node",[q_]:"$__serverMessage",[F_]:"Transaction signature length mismatch",[Z_]:"Transaction signature verification failure",[U_]:"$__serverMessage",[Aw]:"Key pair bytes must be of length 64, got $byteLength.",[xw]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Sw]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Ow]:"The provided private key does not match the provided public key.",[Tw]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[S_]:"Lamports value must be in the range [0, 2e64-1]",[T_]:"`$value` cannot be parsed as a `BigInt`",[N_]:"$message",[O_]:"`$value` cannot be parsed as a `Number`",[R_]:"No nonce account could be found at address `$nonceAccountAddress`",[gR]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[bR]:"WebSocket was closed before payload could be added to the send buffer",[_R]:"WebSocket connection closed",[wR]:"WebSocket failed to connect",[yR]:"Failed to obtain a subscription id from the server",[mR]:"Could not find an API plan for RPC method: `$method`",[fR]:"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`.",[pR]:"HTTP error ($statusCode): $message",[hR]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[BE]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[kE]:"The provided value does not implement the `KeyPairSigner` interface",[PE]:"The provided value does not implement the `MessageModifyingSigner` interface",[UE]:"The provided value does not implement the `MessagePartialSigner` interface",[LE]:"The provided value does not implement any of the `MessageSigner` interfaces",[FE]:"The provided value does not implement the `TransactionModifyingSigner` interface",[$E]:"The provided value does not implement the `TransactionPartialSigner` interface",[zE]:"The provided value does not implement the `TransactionSendingSigner` interface",[DE]:"The provided value does not implement any of the `TransactionSigner` interfaces",[jE]:"More than one `TransactionSendingSigner` was identified.",[VE]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[GE]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[vw]:"Cannot export a non-extractable key.",[gw]:"No digest implementation could be found.",[mw]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[yw]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
29
24
|
|
|
30
25
|
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
31
26
|
|
|
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 M=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(M,5)+cA(z,k,K,Y)+V+e[z]+O[L]>>>0;V=Y,Y=K,K=vc(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]+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")=>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 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 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=>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),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=In(n),s=r⪼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 M=In(n),k=Kt(n),K=Zt(n,0,k),Y=Kt(n),V=new Uint8Array(Zt(n,0,Y));x.push({programIdIndex:M,accountKeyIndexes:K,data:V})}const O=Kt(n),N=[];for(let F=0;F<O;F++){const M=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:M,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⪼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 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=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+=`
|
|
27
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[bw]:"No signature verification implementation could be found.",[_w]:"No key generation implementation could be found.",[ww]:"No signing implementation could be found.",[Ew]:"No key export implementation could be found.",[I_]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ov]:"Transaction processing left an account with an outstanding borrowed reference",[hv]:"Account in use",[pv]:"Account loaded twice",[mv]:"Attempt to debit an account but found no record of a prior credit.",[Lv]:"Transaction loads an address table account that doesn't exist",[_v]:"This transaction has already been processed",[wv]:"Blockhash not found",[Ev]:"Loader call chain is too deep",[Tv]:"Transactions are currently disabled due to cluster maintenance",[jv]:"Transaction contains a duplicate instruction ($index) that is not allowed",[yv]:"Insufficient funds for fee",[Vv]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[bv]:"This account may not be used to pay transaction fees",[Rv]:"Transaction contains an invalid account reference",[Uv]:"Transaction loads an address table account with invalid data",[Dv]:"Transaction address table lookup uses an invalid index",[Pv]:"Transaction loads an address table account with an invalid owner",[Hv]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[xv]:"This program may not be used for executing instructions",[Fv]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Cv]:"Transaction loads a writable account that cannot be written",[Gv]:"Transaction exceeded max loaded accounts data size cap",[vv]:"Transaction requires a fee but has no signature present",[gv]:"Attempt to load a program that does not exist",[Kv]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[qv]:"ResanitizationNeeded",[Sv]:"Transaction failed to sanitize accounts offsets correctly",[Av]:"Transaction did not pass signature verification",[kv]:"Transaction locked too many accounts",[Wv]:"Sum of account balances before and after transaction do not match",[fv]:"The transaction failed with the error `$errorName`",[Nv]:"Transaction version is unsupported",[Bv]:"Transaction would exceed account data limit within the block",[zv]:"Transaction would exceed total account data limit",[Mv]:"Transaction would exceed max account limit within the block",[Iv]:"Transaction would exceed max Block Cost Limit",[$v]:"Transaction would exceed max Vote Cost Limit",[ov]:"Attempted to sign a transaction with an address that is not a signer for it",[tv]:"Transaction is missing an address at index: $index.",[av]:"Transaction has no expected signers therefore it cannot be encoded",[lv]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[KE]:"Transaction does not have a blockhash lifetime",[WE]:"Transaction is not a durable nonce transaction",[YE]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[JE]:"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",[QE]:"No fee payer set in CompiledTransaction",[XE]:"Could not find program address at index $index",[uv]:"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",[dv]:"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",[nv]:"Transaction is missing a fee payer.",[rv]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[iv]:"Transaction first instruction is not advance nonce account instruction.",[sv]:"Transaction with no instructions cannot be durable nonce transaction.",[HE]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[qE]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[cv]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[ev]:"Transaction is missing signatures for addresses: $addresses.",[ZE]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},In="i",fn="t";function IR(t,e={}){const n=OR[t];if(n.length===0)return"";let r;function s(o){if(r[fn]===2){const a=n.slice(r[In]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[fn]===1&&i.push(n.slice(r[In],o))}const i=[];return n.split("").forEach((o,a)=>{if(a===0){r={[In]:0,[fn]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let d;switch(r[fn]){case 0:d={[In]:a,[fn]:1};break;case 1:o==="\\"?d={[In]:a,[fn]:0}:o==="$"&&(d={[In]:a,[fn]:2});break;case 2:o==="\\"?d={[In]:a,[fn]:0}:o==="$"?d={[In]:a,[fn]:2}:o.match(/\w/)||(d={[In]:a,[fn]:1});break}d&&(r!==d&&s(a),r=d)}),s(),i.join("")}function NR(t,e={}){if(process.env.NODE_ENV!=="production")return IR(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${TR(e)}'`),`${n}\``}}var Dr=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=NR(t,n);super(s,r),this.context={__code:t,...n},this.name="SolanaError"}};function CR(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function MR(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(CR(e,t));return t.write(e,n,0),n}})}function BR(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function Fr(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function kR(t,e){if(Fr(t)!==Fr(e))throw new Dr(Bf);if(Fr(t)&&Fr(e)&&t.fixedSize!==e.fixedSize)throw new Dr(kf,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!Fr(t)&&!Fr(e)&&t.maxSize!==e.maxSize)throw new Dr(Lf,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function LR(t,e,n=0){if(e.length-n<=0)throw new Dr(Cf,{codecDescription:t})}function PR(t,e,n,r=0){const s=n.length-r;if(s<e)throw new Dr(Mf,{bytesLength:s,codecDescription:t,expected:e})}function UR(t,e,n,r){if(r<e||r>n)throw new Dr(Pf,{codecDescription:t,max:n,min:e,value:r})}function Df(t){return t?.endian!==1}function DR(t){return MR({fixedSize:t.size,write(e,n,r){t.range&&UR(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 FR(t){return BR({fixedSize:t.size,read(e,n=0){LR(t.name,e,n),PR(t.name,t.size,e,n);const r=new DataView($R(e,n,t.size));return[t.get(r,Df(t.config)),n+t.size]}})}function $R(t,e,n){const r=t.byteOffset+(e??0),s=n??t.byteLength;return t.buffer.slice(r,r+s)}var zR=(t={})=>DR({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),jR=(t={})=>FR({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),VR=(t={})=>kR(zR(t),jR(t));class GR 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 HR(t){return Ls(t)&&typeof t[Symbol.iterator]=="function"}function Ls(t){return typeof t=="object"&&t!=null}function Wi(t){return Ls(t)&&!Array.isArray(t)}function rn(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function qR(t){const{done:e,value:n}=t.next();return e?void 0:n}function KR(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){HR(t)||(t=[t]);for(const s of t){const i=KR(s,e,n,r);i&&(yield i)}}function*yc(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,v]of e.entries(t,a)){const T=yc(g,v,{path:m===void 0?r:[...r,m],branch:m===void 0?s:[...s,g],coerce:i,mask:o,message:n.message});for(const I of T)I[0]?(d=I[0].refinement!=null?"not_refined":"not_valid",yield[I[0],void 0]):i&&(g=I[1],m===void 0?t=g:t instanceof Map?t.set(m,g):t instanceof Set?t.add(g):Ls(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 WR(e,this,n)}create(e,n){return Ps(e,this,n)}is(e){return $f(e,this)}mask(e,n){return ZR(e,this,n)}validate(e,n={}){return Us(e,this,n)}};function WR(t,e,n){const r=Us(t,e,{message:n});if(r[0])throw r[0]}function Ps(t,e,n){const r=Us(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function ZR(t,e,n){const r=Us(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function $f(t,e){return!Us(t,e)[0]}function Us(t,e,n={}){const r=yc(t,e,n),s=qR(r);return s[0]?[new GR(s[0],function*(){for(const o of r)o[0]&&(yield o[0])}),void 0]:[void 0,s[1]]}function fr(t,e){return new hn({type:t,schema:null,validator:e})}function YR(){return fr("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 fr("boolean",t=>typeof t=="boolean")}function bc(t){return fr("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${rn(e)}`)}function Ge(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 JR(){return fr("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 fr("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(Ls(n))for(const r in n){const s=n[r];yield[r,r,t],yield[r,s,e]}},validator(n){return Wi(n)||`Expected an object, but received: ${rn(n)}`},coercer(n){return Wi(n)?{...n}:n}})}function se(){return fr("string",t=>typeof t=="string"||`Expected a string, but received: ${rn(t)}`)}function _c(t){const e=JR();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(Ls(n))for(const r of e)yield[r,n[r],t[r]]},validator(n){return Wi(n)||`Expected an object, but received: ${rn(n)}`},coercer(n){return Wi(n)?{...n}:n}})}function $t(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]=yc(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 $r(){return fr("unknown",()=>!0)}function Ds(t,e,n){return new hn({...t,coercer:(r,s)=>$f(r,e)?t.coercer(n(r,s),s):t.coercer(r,s)})}var Zi,XR=new Uint8Array(16);function jf(){if(!Zi&&(Zi=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!Zi))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Zi(XR)}const QR=/^(?:[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 Yi(t){return typeof t=="string"&&QR.test(t)}for(var Rt=[],wc=0;wc<256;++wc)Rt.push((wc+256).toString(16).substr(1));function Ji(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(Rt[t[e+0]]+Rt[t[e+1]]+Rt[t[e+2]]+Rt[t[e+3]]+"-"+Rt[t[e+4]]+Rt[t[e+5]]+"-"+Rt[t[e+6]]+Rt[t[e+7]]+"-"+Rt[t[e+8]]+Rt[t[e+9]]+"-"+Rt[t[e+10]]+Rt[t[e+11]]+Rt[t[e+12]]+Rt[t[e+13]]+Rt[t[e+14]]+Rt[t[e+15]]).toLowerCase();if(!Yi(n))throw TypeError("Stringified UUID is invalid");return n}var Vf,Ec,vc=0,Rc=0;function eA(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:Ec;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=Ec=(a[6]<<8|a[7])&16383)}var d=t.msecs!==void 0?t.msecs:Date.now(),m=t.nsecs!==void 0?t.nsecs:Rc+1,g=d-vc+(m-Rc)/1e4;if(g<0&&t.clockseq===void 0&&(o=o+1&16383),(g<0||d>vc)&&t.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");vc=d,Rc=m,Ec=o,d+=122192928e5;var v=((d&268435455)*1e4+m)%4294967296;s[r++]=v>>>24&255,s[r++]=v>>>16&255,s[r++]=v>>>8&255,s[r++]=v&255;var T=d/4294967296*1e4&268435455;s[r++]=T>>>8&255,s[r++]=T&255,s[r++]=T>>>24&15|16,s[r++]=T>>>16&255,s[r++]=o>>>8|128,s[r++]=o&255;for(var I=0;I<6;++I)s[r+I]=i[I];return e||Ji(s)}function Gf(t){if(!Yi(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 tA(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var nA="6ba7b810-9dad-11d1-80b4-00c04fd430c8",rA="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Hf(t,e,n){function r(s,i,o,a){if(typeof s=="string"&&(s=tA(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 Ji(d)}try{r.name=t}catch{}return r.DNS=nA,r.URL=rA,r}function sA(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 iA(oA(aA(t),t.length*8))}function iA(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 oA(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=It(n,r,s,i,t[o],7,-680876936),i=It(i,n,r,s,t[o+1],12,-389564586),s=It(s,i,n,r,t[o+2],17,606105819),r=It(r,s,i,n,t[o+3],22,-1044525330),n=It(n,r,s,i,t[o+4],7,-176418897),i=It(i,n,r,s,t[o+5],12,1200080426),s=It(s,i,n,r,t[o+6],17,-1473231341),r=It(r,s,i,n,t[o+7],22,-45705983),n=It(n,r,s,i,t[o+8],7,1770035416),i=It(i,n,r,s,t[o+9],12,-1958414417),s=It(s,i,n,r,t[o+10],17,-42063),r=It(r,s,i,n,t[o+11],22,-1990404162),n=It(n,r,s,i,t[o+12],7,1804603682),i=It(i,n,r,s,t[o+13],12,-40341101),s=It(s,i,n,r,t[o+14],17,-1502002290),r=It(r,s,i,n,t[o+15],22,1236535329),n=Nt(n,r,s,i,t[o+1],5,-165796510),i=Nt(i,n,r,s,t[o+6],9,-1069501632),s=Nt(s,i,n,r,t[o+11],14,643717713),r=Nt(r,s,i,n,t[o],20,-373897302),n=Nt(n,r,s,i,t[o+5],5,-701558691),i=Nt(i,n,r,s,t[o+10],9,38016083),s=Nt(s,i,n,r,t[o+15],14,-660478335),r=Nt(r,s,i,n,t[o+4],20,-405537848),n=Nt(n,r,s,i,t[o+9],5,568446438),i=Nt(i,n,r,s,t[o+14],9,-1019803690),s=Nt(s,i,n,r,t[o+3],14,-187363961),r=Nt(r,s,i,n,t[o+8],20,1163531501),n=Nt(n,r,s,i,t[o+13],5,-1444681467),i=Nt(i,n,r,s,t[o+2],9,-51403784),s=Nt(s,i,n,r,t[o+7],14,1735328473),r=Nt(r,s,i,n,t[o+12],20,-1926607734),n=Ct(n,r,s,i,t[o+5],4,-378558),i=Ct(i,n,r,s,t[o+8],11,-2022574463),s=Ct(s,i,n,r,t[o+11],16,1839030562),r=Ct(r,s,i,n,t[o+14],23,-35309556),n=Ct(n,r,s,i,t[o+1],4,-1530992060),i=Ct(i,n,r,s,t[o+4],11,1272893353),s=Ct(s,i,n,r,t[o+7],16,-155497632),r=Ct(r,s,i,n,t[o+10],23,-1094730640),n=Ct(n,r,s,i,t[o+13],4,681279174),i=Ct(i,n,r,s,t[o],11,-358537222),s=Ct(s,i,n,r,t[o+3],16,-722521979),r=Ct(r,s,i,n,t[o+6],23,76029189),n=Ct(n,r,s,i,t[o+9],4,-640364487),i=Ct(i,n,r,s,t[o+12],11,-421815835),s=Ct(s,i,n,r,t[o+15],16,530742520),r=Ct(r,s,i,n,t[o+2],23,-995338651),n=Mt(n,r,s,i,t[o],6,-198630844),i=Mt(i,n,r,s,t[o+7],10,1126891415),s=Mt(s,i,n,r,t[o+14],15,-1416354905),r=Mt(r,s,i,n,t[o+5],21,-57434055),n=Mt(n,r,s,i,t[o+12],6,1700485571),i=Mt(i,n,r,s,t[o+3],10,-1894986606),s=Mt(s,i,n,r,t[o+10],15,-1051523),r=Mt(r,s,i,n,t[o+1],21,-2054922799),n=Mt(n,r,s,i,t[o+8],6,1873313359),i=Mt(i,n,r,s,t[o+15],10,-30611744),s=Mt(s,i,n,r,t[o+6],15,-1560198380),r=Mt(r,s,i,n,t[o+13],21,1309151649),n=Mt(n,r,s,i,t[o+4],6,-145523070),i=Mt(i,n,r,s,t[o+11],10,-1120210379),s=Mt(s,i,n,r,t[o+2],15,718787259),r=Mt(r,s,i,n,t[o+9],21,-343485551),n=Kn(n,a),r=Kn(r,d),s=Kn(s,m),i=Kn(i,g)}return[n,r,s,i]}function aA(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 Kn(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function cA(t,e){return t<<e|t>>>32-e}function Xi(t,e,n,r,s,i){return Kn(cA(Kn(Kn(e,t),Kn(r,i)),s),n)}function It(t,e,n,r,s,i,o){return Xi(e&n|~e&r,t,e,s,i,o)}function Nt(t,e,n,r,s,i,o){return Xi(e&r|n&~r,t,e,s,i,o)}function Ct(t,e,n,r,s,i,o){return Xi(e^n^r,t,e,s,i,o)}function Mt(t,e,n,r,s,i,o){return Xi(n^(e|~r),t,e,s,i,o)}var uA=Hf("v3",48,sA);function dA(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 Ji(r)}function lA(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 Ac(t,e){return t<<e|t>>>32-e}function fA(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 v=0;v<o;++v){for(var T=new Uint32Array(80),I=0;I<16;++I)T[I]=a[v][I];for(var L=16;L<80;++L)T[L]=Ac(T[L-3]^T[L-8]^T[L-14]^T[L-16],1);for(var M=n[0],C=n[1],q=n[2],Z=n[3],D=n[4],P=0;P<80;++P){var z=Math.floor(P/20),J=Ac(M,5)+lA(z,C,q,Z)+D+e[z]+T[P]>>>0;D=Z,Z=q,q=Ac(C,30)>>>0,C=M,M=J}n[0]=n[0]+M>>>0,n[1]=n[1]+C>>>0,n[2]=n[2]+q>>>0,n[3]=n[3]+Z>>>0,n[4]=n[4]+D>>>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 hA=Hf("v5",80,fA);const pA="00000000-0000-0000-0000-000000000000";function mA(t){if(!Yi(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const Kf=Wa(Object.freeze(Object.defineProperty({__proto__:null,NIL:pA,parse:Gf,stringify:Ji,v1:eA,v3:uA,v4:dA,v5:hA,validate:Yi,version:mA},Symbol.toStringTag,{value:"Module"})));var xc,Wf;function gA(){if(Wf)return xc;Wf=1;const t=Kf.v4;return xc=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},xc}var Sc,Zf;function yA(){if(Zf)return Sc;Zf=1;const t=Kf.v4,e=gA(),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 Sc=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 T=typeof o=="function";try{d=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(I){if(T){o(I);return}throw I}if(!T)return d}let v;try{v=JSON.stringify(d,this.options.replacer)}catch(T){o(T);return}return this.callServer(v,function(T,I){a._parseResponse(T,I,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)},Sc}yA();var Tc={exports:{}},Yf;function bA(){return Yf||(Yf=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,v,T){if(typeof g!="function")throw new TypeError("The listener must be a function");var I=new s(g,v||d,T),L=n?n+m:m;return d._events[L]?d._events[L].fn?d._events[L]=[d._events[L],I]:d._events[L].push(I):(d._events[L]=I,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,v;if(this._eventsCount===0)return m;for(v in g=this._events)e.call(g,v)&&m.push(n?v.slice(1):v);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,v=this._events[g];if(!v)return[];if(v.fn)return[v.fn];for(var T=0,I=v.length,L=new Array(I);T<I;T++)L[T]=v[T].fn;return L},a.prototype.listenerCount=function(m){var g=n?n+m:m,v=this._events[g];return v?v.fn?1:v.length:0},a.prototype.emit=function(m,g,v,T,I,L){var M=n?n+m:m;if(!this._events[M])return!1;var C=this._events[M],q=arguments.length,Z,D;if(C.fn){switch(C.once&&this.removeListener(m,C.fn,void 0,!0),q){case 1:return C.fn.call(C.context),!0;case 2:return C.fn.call(C.context,g),!0;case 3:return C.fn.call(C.context,g,v),!0;case 4:return C.fn.call(C.context,g,v,T),!0;case 5:return C.fn.call(C.context,g,v,T,I),!0;case 6:return C.fn.call(C.context,g,v,T,I,L),!0}for(D=1,Z=new Array(q-1);D<q;D++)Z[D-1]=arguments[D];C.fn.apply(C.context,Z)}else{var P=C.length,z;for(D=0;D<P;D++)switch(C[D].once&&this.removeListener(m,C[D].fn,void 0,!0),q){case 1:C[D].fn.call(C[D].context);break;case 2:C[D].fn.call(C[D].context,g);break;case 3:C[D].fn.call(C[D].context,g,v);break;case 4:C[D].fn.call(C[D].context,g,v,T);break;default:if(!Z)for(z=1,Z=new Array(q-1);z<q;z++)Z[z-1]=arguments[z];C[D].fn.apply(C[D].context,Z)}}return!0},a.prototype.on=function(m,g,v){return i(this,m,g,v,!1)},a.prototype.once=function(m,g,v){return i(this,m,g,v,!0)},a.prototype.removeListener=function(m,g,v,T){var I=n?n+m:m;if(!this._events[I])return this;if(!g)return o(this,I),this;var L=this._events[I];if(L.fn)L.fn===g&&(!T||L.once)&&(!v||L.context===v)&&o(this,I);else{for(var M=0,C=[],q=L.length;M<q;M++)(L[M].fn!==g||T&&!L[M].once||v&&L[M].context!==v)&&C.push(L[M]);C.length?this._events[I]=C.length===1?C[0]:C:o(this,I)}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})(Tc)),Tc.exports}var _A=bA();const wA=Ii(_A);function Jf(t){try{return lc.ExtendedPoint.fromHex(t),!0}catch{return!1}}const Xf=(t,e)=>lc.sign(t,e.slice(0,32)),EA=lc.verify,Oc=t=>Se.Buffer.isBuffer(t)?t:t instanceof Uint8Array?Se.Buffer.from(t.buffer,t.byteOffset,t.byteLength):Se.Buffer.from(t);class vA{constructor(e){Object.assign(this,e)}encode(){return Se.Buffer.from(gc.serialize(Qi,this))}static decode(e){return gc.deserialize(Qi,this,e)}static decodeUnchecked(e){return gc.deserializeUnchecked(Qi,this,e)}}const Qi=new Map;var Qf;const RA=32,Wn=32;function AA(t){return t._bn!==void 0}let eh=1;class ye extends vA{constructor(e){if(super({}),this._bn=void 0,AA(e))this._bn=e._bn;else{if(typeof e=="string"){const n=Ft.decode(e);if(n.length!=Wn)throw new Error("Invalid public key input");this._bn=new Af(n)}else this._bn=new Af(e);if(this._bn.byteLength()>Wn)throw new Error("Invalid public key input")}}static unique(){const e=new ye(eh);return eh+=1,new ye(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return Ft.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(Se.Buffer);if(e.length===Wn)return e;const n=Se.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=Se.Buffer.concat([e.toBuffer(),Se.Buffer.from(n),r.toBuffer()]),i=Oa(s);return new ye(i)}static createProgramAddressSync(e,n){let r=Se.Buffer.alloc(0);e.forEach(function(i){if(i.length>RA)throw new TypeError("Max seed length exceeded");r=Se.Buffer.concat([r,Oc(i)])}),r=Se.Buffer.concat([r,n.toBuffer(),Se.Buffer.from("ProgramDerivedAddress")]);const s=Oa(r);if(Jf(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(Se.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 Jf(n.toBytes())}}Qf=ye,ye.default=new Qf("11111111111111111111111111111111"),Qi.set(ye,{kind:"struct",fields:[["_bn","u256"]]}),new ye("BPFLoader1111111111111111111111111111111111");const zr=1232,Ic=127,eo=64;class to{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 Te=(t="publicKey")=>B.blob(32,t),xA=(t="signature")=>B.blob(64,t),jr=(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:Se.Buffer.from(i,"utf8")};return r(d,o,a)},s.alloc=i=>B.u32().span+B.u32().span+Se.Buffer.from(i,"utf8").length,s},SA=(t="authorized")=>B.struct([Te("staker"),Te("withdrawer")],t),TA=(t="lockup")=>B.struct([B.ns64("unixTimestamp"),B.ns64("epoch"),Te("custodian")],t),OA=(t="voteInit")=>B.struct([Te("nodePubkey"),Te("authorizedVoter"),Te("authorizedWithdrawer"),B.u8("commission")],t),IA=(t="voteAuthorizeWithSeedArgs")=>B.struct([B.u32("voteAuthorizationType"),Te("currentAuthorityDerivedKeyOwnerPubkey"),jr("currentAuthorityDerivedKeySeed"),Te("newAuthorized")],t);function Wt(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 Zt(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 no{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 no(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 th="Reached end of buffer unexpectedly";function Nn(t){if(t.length===0)throw new Error(th);return t.shift()}function Yt(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(th);return t.splice(...e)}class Vr{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:Ft.decode(e.data)}))}get addressTableLookups(){return[]}getAccountKeys(){return new to(this.staticAccountKeys)}static compile(e){const n=no.compile(e.instructions,e.payerKey),[r,s]=n.getMessageComponents(),o=new to(s).compileInstructions(e.instructions).map(a=>({programIdIndex:a.programIdIndex,accounts:a.accountKeyIndexes,data:Ft.encode(a.data)}));return new Vr({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=[];Zt(n,e);const r=this.instructions.map(v=>{const{accounts:T,programIdIndex:I}=v,L=Array.from(Ft.decode(v.data));let M=[];Zt(M,T.length);let C=[];return Zt(C,L.length),{programIdIndex:I,keyIndicesCount:Se.Buffer.from(M),keyIndices:T,dataLength:Se.Buffer.from(C),data:L}});let s=[];Zt(s,r.length);let i=Se.Buffer.alloc(zr);Se.Buffer.from(s).copy(i);let o=s.length;r.forEach(v=>{const I=B.struct([B.u8("programIdIndex"),B.blob(v.keyIndicesCount.length,"keyIndicesCount"),B.seq(B.u8("keyIndex"),v.keyIndices.length,"keyIndices"),B.blob(v.dataLength.length,"dataLength"),B.seq(B.u8("userdatum"),v.data.length,"data")]).encode(v,i,o);o+=I}),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(Te("key"),e,"keys"),Te("recentBlockhash")]),d={numRequiredSignatures:Se.Buffer.from([this.header.numRequiredSignatures]),numReadonlySignedAccounts:Se.Buffer.from([this.header.numReadonlySignedAccounts]),numReadonlyUnsignedAccounts:Se.Buffer.from([this.header.numReadonlyUnsignedAccounts]),keyCount:Se.Buffer.from(n),keys:this.accountKeys.map(v=>Oc(v.toBytes())),recentBlockhash:Ft.decode(this.recentBlockhash)};let m=Se.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=Nn(n);if(r!==(r&Ic))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Nn(n),i=Nn(n),o=Wt(n);let a=[];for(let T=0;T<o;T++){const I=Yt(n,0,Wn);a.push(new ye(Se.Buffer.from(I)))}const d=Yt(n,0,Wn),m=Wt(n);let g=[];for(let T=0;T<m;T++){const I=Nn(n),L=Wt(n),M=Yt(n,0,L),C=Wt(n),q=Yt(n,0,C),Z=Ft.encode(Se.Buffer.from(q));g.push({programIdIndex:I,accounts:M,data:Z})}const v={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:Ft.encode(Se.Buffer.from(d)),accountKeys:a,instructions:g};return new Vr(v)}}class ro{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 to(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=no.compile(e.instructions,e.payerKey),r=new Array,s={writable:new Array,readonly:new Array},i=e.addressLookupTableAccounts||[];for(const g of i){const v=n.extractTableLookup(g);if(v!==void 0){const[T,{writable:I,readonly:L}]=v;r.push(T),s.writable.push(...I),s.readonly.push(...L)}}const[o,a]=n.getMessageComponents(),m=new to(a,s).compileInstructions(e.instructions);return new ro({header:o,staticAccountKeys:a,recentBlockhash:e.recentBlockhash,compiledInstructions:m,addressTableLookups:r})}serialize(){const e=Array();Zt(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Zt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Zt(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(Te(),this.staticAccountKeys.length,"staticAccountKeys"),Te("recentBlockhash"),B.blob(r.length,"instructionsLength"),B.blob(n.length,"serializedInstructions"),B.blob(i.length,"addressTableLookupsLength"),B.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(zr),m=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:Ft.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(zr);for(const r of this.compiledInstructions){const s=Array();Zt(s,r.accountKeyIndexes.length);const i=Array();Zt(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(zr);for(const r of this.addressTableLookups){const s=Array();Zt(s,r.writableIndexes.length);const i=Array();Zt(i,r.readonlyIndexes.length);const o=B.struct([Te("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=Nn(n),s=r&Ic;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:Nn(n),numReadonlySignedAccounts:Nn(n),numReadonlyUnsignedAccounts:Nn(n)},a=[],d=Wt(n);for(let L=0;L<d;L++)a.push(new ye(Yt(n,0,Wn)));const m=Ft.encode(Yt(n,0,Wn)),g=Wt(n),v=[];for(let L=0;L<g;L++){const M=Nn(n),C=Wt(n),q=Yt(n,0,C),Z=Wt(n),D=new Uint8Array(Yt(n,0,Z));v.push({programIdIndex:M,accountKeyIndexes:q,data:D})}const T=Wt(n),I=[];for(let L=0;L<T;L++){const M=new ye(Yt(n,0,Wn)),C=Wt(n),q=Yt(n,0,C),Z=Wt(n),D=Yt(n,0,Z);I.push({accountKey:M,writableIndexes:q,readonlyIndexes:D})}return new ro({header:o,staticAccountKeys:a,recentBlockhash:m,compiledInstructions:v,addressTableLookups:I})}}const Nc={deserializeMessageVersion(t){const e=t[0],n=e&Ic;return n===e?"legacy":n},deserialize:t=>{const e=Nc.deserializeMessageVersion(t);if(e==="legacy")return Vr.from(t);if(e===0)return ro.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},NA=Se.Buffer.alloc(eo).fill(0);class nh{constructor(e){this.keys=void 0,this.programId=void 0,this.data=Se.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 so{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 nh(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(q=>{i.push({...q})});const C=M.programId.toString();s.includes(C)||s.push(C)}),s.forEach(M=>{i.push({pubkey:new ye(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const C=M.pubkey.toString(),q=o.findIndex(Z=>Z.pubkey.toString()===C);q>-1?(o[q].isWritable=o[q].isWritable||M.isWritable,o[q].isSigner=o[q].isSigner||M.isSigner):o.push(M)}),o.sort(function(M,C){if(M.isSigner!==C.isSigner)return M.isSigner?-1:1;if(M.isWritable!==C.isWritable)return M.isWritable?-1:1;const q={localeMatcher:"best fit",usage:"sort",sensitivity:"variant",ignorePunctuation:!1,numeric:!1,caseFirst:"lower"};return M.pubkey.toBase58().localeCompare(C.pubkey.toBase58(),"en",q)});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 C=o.findIndex(q=>q.pubkey.equals(M.publicKey));if(C>-1)o[C].isSigner||(o[C].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 v=[],T=[];o.forEach(({pubkey:M,isSigner:C,isWritable:q})=>{C?(v.push(M.toString()),d+=1,q||(m+=1)):(T.push(M.toString()),q||(g+=1))});const I=v.concat(T),L=n.map(M=>{const{data:C,programId:q}=M;return{programIdIndex:I.indexOf(q.toString()),accounts:M.keys.map(Z=>I.indexOf(Z.pubkey.toString())),data:Ft.encode(C)}});return L.forEach(M=>{yt(M.programIdIndex>=0),M.accounts.forEach(C=>yt(C>=0))}),new Vr({header:{numRequiredSignatures:d,numReadonlySignedAccounts:m,numReadonlyUnsignedAccounts:g},accountKeys:I,recentBlockhash:e,instructions:L})}_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=Xf(r,s.secretKey);this._addSignature(s.publicKey,Oc(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=Se.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):EA(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
28
|
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 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=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=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=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(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: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"),$a.utils.isValidPrivateKey,$a.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 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: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 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
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
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,M]=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 C=n?.theme;if(C==="dark"){z(!0);return}if(C==="light"){z(!1);return}const P=window.matchMedia("(prefers-color-scheme: dark)"),j=()=>z(P.matches);return j(),P.addEventListener("change",j),()=>P.removeEventListener("change",j)},[n?.theme]),Me.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Ie.useEffect(()=>{K(Me.getPayModalUrl(e))},[e]),Ie.useEffect(()=>{const C=n?.theme;if(!C||XS.includes(C)){V(null);return}let P=!1;return(async()=>{try{const E=Me.getBaseUrl(),c=await fetch(`${E}/themes/${C}`);if(!c.ok)return;const h=await c.json();!P&&h.status==="approved"&&h.cssContent&&V(h.cssContent)}catch(E){console.error("Failed to fetch theme:",E)}})(),()=>{P=!0}},[n?.theme]),Ie.useEffect(()=>{const C=document.body.style.overflow;s?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=C||"";const P=async j=>{if(j.data===cn.CLOSED&&(a(),d?.()),j?.data?.type===cn.COMPLETED){window.setTimeout(a,2e3);const h=j?.data?.transactionHash?{transactionHash:j.data.transactionHash}:void 0;m?.(h)}if(j.data===cn.REQUEST_FARCASTER_CONNECT)try{await KS(J,N,O)}catch(h){console.error(h)}if(j.data===cn.REQUEST_FARCASTER_DISCONNECT)try{await WS(J,N,O)}catch(h){console.error(h)}const c=j.data;if(c?.type===cn.REQUEST_FARCASTER_SEND_TRANSACTION&&typeof c.requestId=="string"&&c.params)try{const h=await ZS(c.params,N,O,J.current,c.requestId);h?[go,yo].forEach(y=>{J.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:c.requestId,hash:h},y)}):[go,yo].forEach(y=>{J.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:c.requestId,error:"sendTransaction not configured or returned no hash"},y)})}catch(h){console.log(h)}};return window.addEventListener("message",P),()=>{document.body.style.overflow=C||"",window.removeEventListener("message",P)}},[s,d,m,a,O,N]),Ie.useEffect(()=>{if(!x)return;const C=t.css||Y||void 0,P=async()=>{const E=await zh.isInMiniApp(),c=r?.map(HS)||[],h=N?YS(N):void 0;return{type:"session",session_token:x,environment:Me.getEnv()||Bo.PRODUCTION,styles:n,props:{excludeChains:c.join(","),isFarcasterMiniApp:E,...h?.length?{supportedChains:h}:{}},...C?{css:C}:{}}};let j=!1;return P().then(E=>{j||([go,yo].forEach(c=>{J.current?.contentWindow?.postMessage(E,c)}),window.setTimeout(()=>{j||[go,yo].forEach(c=>{J.current?.contentWindow?.postMessage(E,c)})},1e3))}),()=>{j=!0}},[x,F,s,n,Y]),Ie.useEffect(()=>{if(!s)return;const C=te.current;M(C?Math.random():0)},[s]);function ne(){te.current=!0,M(Math.random())}Ie.useEffect(()=>{const C=document.querySelector(".payment-modal-loader-container"),P=document.querySelector(".payment-modal-loader-logo");C.style.opacity="1",C.style.transform="translateX(-50%)",P.style.opacity="1",P.style.transform="scale(1)",P.style.filter="blur(0px)"},[]);const q=F===0||i;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","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 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 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 M=Date.now();Wn.isPending=!0,Wn.error=null,Wn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(k=>k.json()).then(k=>{M<d||(Wn.data=k,Wn.isPending=!1,m(M))}).catch(k=>{M<d||(Wn.error=k?.toString(),Wn.isPending=!1,m(M),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:M,amount:k}){m(M),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"})}));
|
|
29
|
+
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=[];Zt(r,n.length);const s=r.length+n.length*64+e.length,i=Se.Buffer.alloc(s);return yt(n.length<256),Se.Buffer.from(r).copy(i,0),n.forEach(({signature:o},a)=>{o!==null&&(yt(o.length===64,"signature has invalid length"),Se.Buffer.from(o).copy(i,r.length+a*64))}),e.copy(i,r.length+n.length*64),yt(i.length<=zr,`Transaction too large: ${i.length} > ${zr}`),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=Wt(n);let s=[];for(let i=0;i<r;i++){const o=Yt(n,0,eo);s.push(Ft.encode(Se.Buffer.from(o)))}return so.populate(Vr.from(n),s)}static populate(e,n=[]){const r=new so;return r.recentBlockhash=e.recentBlockhash,e.header.numRequiredSignatures>0&&(r.feePayer=e.accountKeys[0]),n.forEach((s,i)=>{const o={signature:s==Ft.encode(NA)?null:Ft.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 nh({keys:i,programId:e.accountKeys[s.programIdIndex],data:Ft.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Cc{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(eo));this.signatures=r}this.message=e}serialize(){const e=this.message.serialize(),n=Array();Zt(n,this.signatures.length);const r=B.struct([B.blob(n.length,"encodedSignaturesLength"),B.seq(xA(),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=Wt(n);for(let o=0;o<s;o++)r.push(new Uint8Array(Yt(n,0,eo)));const i=Nc.deserialize(new Uint8Array(n));return new Cc(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]=Xf(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 CA=B.nu64("lamportsPerSignature");B.struct([B.u32("version"),B.u32("state"),Te("authorizedPubkey"),Te("nonce"),B.struct([CA],"feeCalculator")]).span;function Gr(t){const e=B.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),s=e,i=VR();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"),Te("programId")])},Assign:{index:1,layout:B.struct([B.u32("instruction"),Te("programId")])},Transfer:{index:2,layout:B.struct([B.u32("instruction"),Gr("lamports")])},CreateWithSeed:{index:3,layout:B.struct([B.u32("instruction"),Te("base"),jr("seed"),B.ns64("lamports"),B.ns64("space"),Te("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"),Te("authorized")])},AuthorizeNonceAccount:{index:7,layout:B.struct([B.u32("instruction"),Te("authorized")])},Allocate:{index:8,layout:B.struct([B.u32("instruction"),B.ns64("space")])},AllocateWithSeed:{index:9,layout:B.struct([B.u32("instruction"),Te("base"),jr("seed"),B.ns64("space"),Te("programId")])},AssignWithSeed:{index:10,layout:B.struct([B.u32("instruction"),Te("base"),jr("seed"),Te("programId")])},TransferWithSeed:{index:11,layout:B.struct([B.u32("instruction"),Gr("lamports"),jr("seed"),Te("programId")])},UpgradeNonceAccount:{index:12,layout:B.struct([B.u32("instruction")])}}),new ye("11111111111111111111111111111111"),new ye("BPFLoader2111111111111111111111111111111111"),B.struct([B.u32("typeIndex"),Gr("deactivationSlot"),B.nu64("lastExtendedSlot"),B.u8("lastExtendedStartIndex"),B.u8(),B.seq(Te(),B.offset(B.u8(),-1),"authority")]);const Ke=Ds(bc(ye),se(),t=>new ye(t)),rh=_c([se(),Ge("base64")]),Mc=Ds(bc(Se.Buffer),rh,t=>Se.Buffer.from(t[0],"base64"));function sh(t){return $t([Q({jsonrpc:Ge("2.0"),id:se(),result:t}),Q({jsonrpc:Ge("2.0"),id:se(),error:Q({code:$r(),message:se(),data:fe(YR())})})])}const MA=sh($r());function Ue(t){return Ds(sh(t),MA,e=>"error"in e?e:{...e,result:Ps(e.result,t)})}function sn(t){return Ue(Q({context:Q({slot:G()}),value:t}))}function io(t){return Q({context:Q({slot:G()}),value:t})}const BA=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 kA=ae(Q({slot:G(),prioritizationFee:G()})),LA=Q({total:G(),validator:G(),foundation:G(),epoch:G()}),PA=Q({epoch:G(),slotIndex:G(),slotsInEpoch:G(),absoluteSlot:G(),blockHeight:fe(G()),transactionCount:fe(G())}),UA=Q({slotsPerEpoch:G(),leaderScheduleSlotOffset:G(),warmup:pn(),firstNormalEpoch:G(),firstNormalSlot:G()}),DA=zf(se(),ae(G())),hr=ce($t([Q({}),se()])),FA=Q({err:hr}),$A=Ge("receivedSignature");Q({"solana-core":se(),"feature-set":fe(G())});const zA=Q({program:se(),programId:Ke,parsed:$r()}),jA=Q({programId:Ke,accounts:ae(Ke),data:se()});sn(Q({err:ce($t([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:_c([se(),Ge("base64")])}))),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae($t([zA,jA]))}))))})),sn(Q({byIdentity:zf(se(),ae(G())),range:Q({firstSlot:G(),lastSlot:G()})})),Ue(BA),Ue(LA),Ue(kA),Ue(PA),Ue(UA),Ue(DA),Ue(G()),sn(Q({total:G(),circulating:G(),nonCirculating:G(),nonCirculatingAccounts:ae(Ke)}));const VA=Q({amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())});sn(ae(Q({address:Ke,amount:se(),uiAmount:ce(G()),decimals:G(),uiAmountString:fe(se())}))),sn(ae(Q({pubkey:Ke,account:Q({executable:pn(),owner:Ke,lamports:G(),data:Mc,rentEpoch:G()})})));const Bc=Q({program:se(),parsed:$r(),space:G()});sn(ae(Q({pubkey:Ke,account:Q({executable:pn(),owner:Ke,lamports:G(),data:Bc,rentEpoch:G()})}))),sn(ae(Q({lamports:G(),address:Ke})));const kc=Q({executable:pn(),owner:Ke,lamports:G(),data:Mc,rentEpoch:G()});Q({pubkey:Ke,account:kc});const GA=Ds($t([bc(Se.Buffer),Bc]),$t([rh,Bc]),t=>Array.isArray(t)?Ps(t,Mc):t),HA=Q({executable:pn(),owner:Ke,lamports:G(),data:GA,rentEpoch:G()});Q({pubkey:Ke,account:HA}),Q({state:$t([Ge("active"),Ge("inactive"),Ge("activating"),Ge("deactivating")]),active:G(),inactive:G()}),Ue(ae(Q({signature:se(),slot:G(),err:hr,memo:ce(se()),blockTime:fe(ce(G()))}))),Ue(ae(Q({signature:se(),slot:G(),err:hr,memo:ce(se()),blockTime:fe(ce(G()))}))),Q({subscription:G(),result:io(kc)});const qA=Q({pubkey:Ke,account:kc});Q({subscription:G(),result:io(qA)});const KA=Q({parent:G(),slot:G(),root:G()});Q({subscription:G(),result:KA});const WA=$t([Q({type:$t([Ge("firstShredReceived"),Ge("completed"),Ge("optimisticConfirmation"),Ge("root")]),slot:G(),timestamp:G()}),Q({type:Ge("createdBank"),parent:G(),slot:G(),timestamp:G()}),Q({type:Ge("frozen"),slot:G(),timestamp:G(),stats:Q({numTransactionEntries:G(),numSuccessfulTransactions:G(),numFailedTransactions:G(),maxTransactionsPerEntry:G()})}),Q({type:Ge("dead"),slot:G(),timestamp:G(),err:se()})]);Q({subscription:G(),result:WA}),Q({subscription:G(),result:io($t([FA,$A]))}),Q({subscription:G(),result:G()}),Q({pubkey:se(),gossip:ce(se()),tpu:ce(se()),rpc:ce(se()),version:ce(se())});const ih=Q({votePubkey:se(),nodePubkey:se(),activatedStake:G(),epochVoteAccount:pn(),epochCredits:ae(_c([G(),G(),G()])),commission:G(),lastVote:G(),rootSlot:ce(G())});Ue(Q({current:ae(ih),delinquent:ae(ih)}));const ZA=$t([Ge("processed"),Ge("confirmed"),Ge("finalized")]),YA=Q({slot:G(),confirmations:ce(G()),err:hr,confirmationStatus:fe(ZA)});sn(ae(ce(YA))),Ue(G());const oh=Q({accountKey:Ke,writableIndexes:ae(G()),readonlyIndexes:ae(G())}),Lc=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(oh))})}),ah=Q({pubkey:Ke,signer:pn(),writable:pn(),source:fe($t([Ge("transaction"),Ge("lookupTable")]))}),ch=Q({accountKeys:ae(ah),signatures:ae(se())}),uh=Q({parsed:$r(),program:se(),programId:Ke}),dh=Q({accounts:ae(Ke),data:se(),programId:Ke}),JA=$t([dh,uh]),XA=$t([Q({parsed:$r(),program:se(),programId:se()}),Q({accounts:ae(se()),data:se(),programId:se()})]),lh=Ds(JA,XA,t=>"accounts"in t?Ps(t,dh):Ps(t,uh)),fh=Q({signatures:ae(se()),message:Q({accountKeys:ae(ah),instructions:ae(lh),recentBlockhash:se(),addressTableLookups:fe(ce(ae(oh)))})}),oo=Q({accountIndex:G(),mint:se(),owner:fe(se()),programId:fe(se()),uiTokenAmount:VA}),hh=Q({writable:ae(Ke),readonly:ae(Ke)}),ao=Q({err:hr,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(oo))),postTokenBalances:fe(ce(ae(oo))),loadedAddresses:fe(hh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Pc=Q({err:hr,fee:G(),innerInstructions:fe(ce(ae(Q({index:G(),instructions:ae(lh)})))),preBalances:ae(G()),postBalances:ae(G()),logMessages:fe(ce(ae(se()))),preTokenBalances:fe(ce(ae(oo))),postTokenBalances:fe(ce(ae(oo))),loadedAddresses:fe(hh),computeUnitsConsumed:fe(G()),costUnits:fe(G())}),Hr=$t([Ge(0),Ge("legacy")]),pr=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:Lc,meta:ce(ao),version:fe(Hr)})),rewards:fe(ae(pr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(pr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:ch,meta:ce(ao),version:fe(Hr)})),rewards:fe(ae(pr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:fh,meta:ce(Pc),version:fe(Hr)})),rewards:fe(ae(pr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:ch,meta:ce(Pc),version:fe(Hr)})),rewards:fe(ae(pr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),rewards:fe(ae(pr)),blockTime:ce(G()),blockHeight:ce(G())}))),Ue(ce(Q({blockhash:se(),previousBlockhash:se(),parentSlot:G(),transactions:ae(Q({transaction:Lc,meta:ce(ao)})),rewards:fe(ae(pr)),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(ao),blockTime:fe(ce(G())),transaction:Lc,version:fe(Hr)}))),Ue(ce(Q({slot:G(),transaction:fh,meta:ce(Pc),blockTime:fe(ce(G())),version:fe(Hr)}))),sn(Q({blockhash:se(),lastValidBlockHeight:G()})),sn(pn());const QA=Q({slot:G(),numTransactions:G(),numSlots:G(),samplePeriodSecs:G()});Ue(ae(QA)),sn(ce(Q({feeCalculator:Q({lamportsPerSignature:G()})}))),Ue(se()),Ue(se());const ex=Q({err:hr,logs:ae(se()),signature:se()});Q({result:io(ex),subscription:G()}),Object.freeze({CreateLookupTable:{index:0,layout:B.struct([B.u32("instruction"),Gr("recentSlot"),B.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:B.struct([B.u32("instruction")])},ExtendLookupTable:{index:2,layout:B.struct([B.u32("instruction"),Gr(),B.seq(Te(),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"),Gr("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"),Ga.utils.isValidPrivateKey,Ga.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 ph;new ye("StakeConfig11111111111111111111111111111111");class mh{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}}ph=mh,mh.default=new ph(0,0,ye.default),Object.freeze({Initialize:{index:0,layout:B.struct([B.u32("instruction"),SA(),TA()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Te("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"),Te("newAuthorized"),B.u32("stakeAuthorizationType"),jr("authoritySeed"),Te("authorityOwner")])}}),new ye("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:B.struct([B.u32("instruction"),OA()])},Authorize:{index:1,layout:B.struct([B.u32("instruction"),Te("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"),IA()])}}),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([Te("nodePubkey"),Te("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"),Te("authorizedVoter")]),B.offset(B.u32(),-8),"authorizedVoters"),B.struct([B.seq(B.struct([Te("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 tx=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 gh(t){return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64")}function nx(t){const e=Buffer.from(t,"base64");return Nc.deserializeMessageVersion(e)==="legacy"?Cc.deserialize(e):so.from(e)}function rx(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:gh(r)};return await t({method:"signAndSendTransaction",params:s})}if(n.method==="signTransaction"){const{transaction:r}=n.params,s={transaction:gh(r)},{signedTransaction:i}=await t({method:"signTransaction",params:s});return{signedTransaction:nx(i)}}}}const sx=({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=ix({back:this,emitter:e})},async disableWebNavigation(){n?.(),n=void 0}}};function ix({emitter:t,back:e}){const n=ox();if(n)return ax({emitter:t,back:e,navigation:n});if(typeof window<"u")return cx({emitter:t,back:e,window})}function ox(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function ax({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 cx({emitter:t,back:e,window:n}){e.show();function r(){e.visible&&n.history.back()}return t.addListener("backNavigationTriggered",r),()=>{t.removeListener("backNavigationTriggered",r)}}var Uc={exports:{}},yh;function ux(){return yh||(yh=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,v,T){if(typeof g!="function")throw new TypeError("The listener must be a function");var I=new s(g,v||d,T),L=n?n+m:m;return d._events[L]?d._events[L].fn?d._events[L]=[d._events[L],I]:d._events[L].push(I):(d._events[L]=I,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,v;if(this._eventsCount===0)return m;for(v in g=this._events)e.call(g,v)&&m.push(n?v.slice(1):v);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,v=this._events[g];if(!v)return[];if(v.fn)return[v.fn];for(var T=0,I=v.length,L=new Array(I);T<I;T++)L[T]=v[T].fn;return L},a.prototype.listenerCount=function(m){var g=n?n+m:m,v=this._events[g];return v?v.fn?1:v.length:0},a.prototype.emit=function(m,g,v,T,I,L){var M=n?n+m:m;if(!this._events[M])return!1;var C=this._events[M],q=arguments.length,Z,D;if(C.fn){switch(C.once&&this.removeListener(m,C.fn,void 0,!0),q){case 1:return C.fn.call(C.context),!0;case 2:return C.fn.call(C.context,g),!0;case 3:return C.fn.call(C.context,g,v),!0;case 4:return C.fn.call(C.context,g,v,T),!0;case 5:return C.fn.call(C.context,g,v,T,I),!0;case 6:return C.fn.call(C.context,g,v,T,I,L),!0}for(D=1,Z=new Array(q-1);D<q;D++)Z[D-1]=arguments[D];C.fn.apply(C.context,Z)}else{var P=C.length,z;for(D=0;D<P;D++)switch(C[D].once&&this.removeListener(m,C[D].fn,void 0,!0),q){case 1:C[D].fn.call(C[D].context);break;case 2:C[D].fn.call(C[D].context,g);break;case 3:C[D].fn.call(C[D].context,g,v);break;case 4:C[D].fn.call(C[D].context,g,v,T);break;default:if(!Z)for(z=1,Z=new Array(q-1);z<q;z++)Z[z-1]=arguments[z];C[D].fn.apply(C[D].context,Z)}}return!0},a.prototype.on=function(m,g,v){return i(this,m,g,v,!1)},a.prototype.once=function(m,g,v){return i(this,m,g,v,!0)},a.prototype.removeListener=function(m,g,v,T){var I=n?n+m:m;if(!this._events[I])return this;if(!g)return o(this,I),this;var L=this._events[I];if(L.fn)L.fn===g&&(!T||L.once)&&(!v||L.context===v)&&o(this,I);else{for(var M=0,C=[],q=L.length;M<q;M++)(L[M].fn!==g||T&&!L[M].once||v&&L[M].context!==v)&&C.push(L[M]);C.length?this._events[I]=C.length===1?C[0]:C:o(this,I)}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})(Uc)),Uc.exports}var dx=ux();const lx=Ii(dx),fx="0.1.1";function hx(){return fx}let px=class Au extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof Au){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 Au&&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(`
|
|
30
|
+
`);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@${hx()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return bh(this,e)}};function bh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?bh(t.cause,e):e?null:t}function _h(t,e={}){const{raw:n=!1}=e,r=t;if(n)return t;if(r.error){const{code:s}=r.error,i=s===qr.code?qr:s===Fs.code?Fs:s===Ws.code?Ws:s===qs.code?qs:s===Gs.code?Gs:s===Ks.code?Ks:s===Vs.code?Vs:s===Zs.code?Zs:s===$s.code?$s:s===zs.code?zs:s===js.code?js:s===Hs.code?Hs:qt;throw new i(r.error)}return r.result}let qt=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 Fs extends qt{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:Fs.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(Fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class $s extends qt{constructor(e={}){super({message:"Requested resource not found.",...e,code:$s.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($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class zs extends qt{constructor(e={}){super({message:"Requested resource not available.",...e,code:zs.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(zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class js extends qt{constructor(e={}){super({message:"Transaction creation failed.",...e,code:js.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(js,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Vs extends qt{constructor(e={}){super({message:"Method is not implemented.",...e,code:Vs.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(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Gs extends qt{constructor(e={}){super({message:"Rate limit exceeded.",...e,code:Gs.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(Gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Hs extends qt{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:Hs.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(Hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class qs extends qt{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:qs.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(qs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Ks extends qt{constructor(e={}){super({message:"Method does not exist.",...e,code:Ks.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(Ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Ws extends qt{constructor(e={}){super({message:"Invalid method parameters.",...e,code:Ws.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(Ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class qr extends qt{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:qr.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(qr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Zs extends qt{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:Zs.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(Zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class mr 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 wh extends mr{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(wh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Eh extends mr{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(Eh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class vh extends mr{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(vh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Rh extends mr{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(Rh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Ah extends mr{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(Ah,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function mx(){const t=new lx;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 gx(t,e={}){const{includeEvents:n=!0}=e;if(!t)throw new yx;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?_h(s):s}}}class yx extends px{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}function bx(t={}){let e=t.id??0;return{prepare(n){return _x({id:e++,...n})},get id(){return e}}}function _x(t){return{...t,jsonrpc:"2.0"}}const xh=Symbol("Comlink.proxy"),wx=Symbol("Comlink.endpoint"),Ex=Symbol("Comlink.releaseProxy"),Dc=Symbol("Comlink.finalizer"),co=Symbol("Comlink.thrown"),Sh=t=>typeof t=="object"&&t!==null||typeof t=="function",vx={canHandle:t=>Sh(t)&&t[xh],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Oh(t,e),[n,[n]]},deserialize(t){return t.start(),Nh(t)}},Rx={canHandle:t=>Sh(t)&&co 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}},Th=new Map([["proxy",vx],["throw",Rx]]);function Ax(t,e){for(const n of t)if(e===n||n==="*"||n instanceof RegExp&&n.test(e))return!0;return!1}function Oh(t,e=globalThis,n=["*"]){e.addEventListener("message",function r(s){if(!s||!s.data)return;if(!Ax(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(gr);let m;try{const g=a.slice(0,-1).reduce((T,I)=>T[I],t),v=a.reduce((T,I)=>T[I],t);switch(o){case"GET":m=v;break;case"SET":g[a.slice(-1)[0]]=gr(s.data.value),m=!0;break;case"APPLY":m=v.apply(g,d);break;case"CONSTRUCT":{const T=new v(...d);m=Nx(T)}break;case"ENDPOINT":{const{port1:T,port2:I}=new MessageChannel;Oh(t,I),m=Ix(T,[T])}break;case"RELEASE":m=void 0;break;default:return}}catch(g){m={value:g,[co]:0}}Promise.resolve(m).catch(g=>({value:g,[co]:0})).then(g=>{const[v,T]=ho(g);e.postMessage(Object.assign(Object.assign({},v),{id:i}),T),o==="RELEASE"&&(e.removeEventListener("message",r),Ih(e),Dc in t&&typeof t[Dc]=="function"&&t[Dc]())}).catch(g=>{const[v,T]=ho({value:new TypeError("Unserializable return value"),[co]:0});e.postMessage(Object.assign(Object.assign({},v),{id:i}),T)})}),e.start&&e.start()}function xx(t){return t.constructor.name==="MessagePort"}function Ih(t){xx(t)&&t.close()}function Nh(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)}}),Fc(t,n,[],e)}function uo(t){if(t)throw new Error("Proxy has been released and is not useable")}function Ch(t){return Kr(t,new Map,{type:"RELEASE"}).then(()=>{Ih(t)})}const lo=new WeakMap,fo="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(lo.get(t)||0)-1;lo.set(t,e),e===0&&Ch(t)});function Sx(t,e){const n=(lo.get(e)||0)+1;lo.set(e,n),fo&&fo.register(t,e,t)}function Tx(t){fo&&fo.unregister(t)}function Fc(t,e,n=[],r=function(){}){let s=!1;const i=new Proxy(r,{get(o,a){if(uo(s),a===Ex)return()=>{Tx(i),Ch(t),e.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>i};const d=Kr(t,e,{type:"GET",path:n.map(m=>m.toString())}).then(gr);return d.then.bind(d)}return Fc(t,e,[...n,a])},set(o,a,d){uo(s);const[m,g]=ho(d);return Kr(t,e,{type:"SET",path:[...n,a].map(v=>v.toString()),value:m},g).then(gr)},apply(o,a,d){uo(s);const m=n[n.length-1];if(m===wx)return Kr(t,e,{type:"ENDPOINT"}).then(gr);if(m==="bind")return Fc(t,e,n.slice(0,-1));const[g,v]=Mh(d);return Kr(t,e,{type:"APPLY",path:n.map(T=>T.toString()),argumentList:g},v).then(gr)},construct(o,a){uo(s);const[d,m]=Mh(a);return Kr(t,e,{type:"CONSTRUCT",path:n.map(g=>g.toString()),argumentList:d},m).then(gr)}});return Sx(i,t),i}function Ox(t){return Array.prototype.concat.apply([],t)}function Mh(t){const e=t.map(ho);return[e.map(n=>n[0]),Ox(e.map(n=>n[1]))]}const Bh=new WeakMap;function Ix(t,e){return Bh.set(t,e),t}function Nx(t){return Object.assign(t,{[xh]:!0})}function Cx(t,e=globalThis,n="*"){return{postMessage:(r,s)=>t.postMessage(r,n,s),addEventListener:e.addEventListener.bind(e),removeEventListener:e.removeEventListener.bind(e)}}function ho(t){for(const[e,n]of Th)if(n.canHandle(t)){const[r,s]=n.serialize(t);return[{type:"HANDLER",name:e,value:r},s]}return[{type:"RAW",value:t},Bh.get(t)||[]]}function gr(t){switch(t.type){case"HANDLER":return Th.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Kr(t,e,n,r){return new Promise(s=>{const i=Mx();e.set(i,s),t.start&&t.start(),t.postMessage(Object.assign({id:i},n),r)})}function Mx(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const Bx={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},kx={postMessage:t=>{window.ReactNativeWebView.postMessage(JSON.stringify(t))},addEventListener:(t,e,...n)=>{document.addEventListener("FarcasterFrameCallback",e,...n)},removeEventListener:(t,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},Lx=typeof window>"u"?Bx:window?.ReactNativeWebView?kx:Cx(window?.parent??window),be=Nh(Lx),$c=mx(),Px=bx();function Ux({code:t,details:e}){switch(t){case 4001:return new wh;case 4100:return new Eh;case 4200:return new vh;case 4900:return new Rh;case 4901:return new Ah;default:return new mr(t,e??"Unknown provider RPC error")}}const Ys=gx({...$c,async request(t){const e=Px.prepare(t);try{const n=await be.ethProviderRequestV2(e).then(r=>_h(r,{request:e,raw:!0}));if(n.error)throw Ux(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 mr||n instanceof qt?n:new qr({message:n instanceof Error?n.message:void 0})}}});async function Dx(){try{const t=await be.getCapabilities();return!t.includes("wallet.getEthereumProvider")&&!t.includes("wallet.getEvmProvider")?void 0:Ys}catch{return Ys}}function kh(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;$c.emit(e.event,...e.params)}}),document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="eip6963:announceProvider"&&kh({info:e.info,provider:Ys})}})),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;$c.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"&&kh({info:e.info,provider:Ys})}})),new TextEncoder;const Lh=new TextDecoder,Fx=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},$x=t=>{let e=t;e instanceof Uint8Array&&(e=Lh.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Fx(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};function zx(t){return typeof t=="object"&&t!==null}function jx(t){if(!zx(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 zt extends Error{constructor(e,n){super(e,n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}zt.code="ERR_JOSE_GENERIC";class Vx extends zt{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}}Vx.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Gx extends zt{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}}Gx.code="ERR_JWT_EXPIRED";class Hx extends zt{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Hx.code="ERR_JOSE_ALG_NOT_ALLOWED";class qx extends zt{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}qx.code="ERR_JOSE_NOT_SUPPORTED";class Kx extends zt{constructor(e="decryption operation failed",n){super(e,n),this.code="ERR_JWE_DECRYPTION_FAILED"}}Kx.code="ERR_JWE_DECRYPTION_FAILED";class Wx extends zt{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Wx.code="ERR_JWE_INVALID";class Zx extends zt{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}Zx.code="ERR_JWS_INVALID";class Zn extends zt{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}Zn.code="ERR_JWT_INVALID";class Yx extends zt{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}Yx.code="ERR_JWK_INVALID";class Jx extends zt{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}Jx.code="ERR_JWKS_INVALID";class Xx extends zt{constructor(e="no applicable key found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Xx.code="ERR_JWKS_NO_MATCHING_KEY";class Qx extends zt{constructor(e="multiple matching keys found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Qx.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class eS extends zt{constructor(e="request timed out",n){super(e,n),this.code="ERR_JWKS_TIMEOUT"}}eS.code="ERR_JWKS_TIMEOUT";class tS extends zt{constructor(e="signature verification failed",n){super(e,n),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}tS.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function nS(t){if(typeof t!="string")throw new Zn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new Zn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new Zn("Invalid JWT");if(!e)throw new Zn("JWTs must contain a payload");let r;try{r=$x(e)}catch{throw new Zn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(Lh.decode(r))}catch{throw new Zn("Failed to parse the decoded payload as JSON")}if(!jx(s))throw new Zn("Invalid JWT Claims Set");return s}function rS(t){return nS(t)}class po extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof po){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(`
|
|
31
|
+
`);super(s,n.cause?{cause:n.cause}:void 0),this.name="BaseError",this.cause=n.cause,this.details=r,this.shortMessage=e}}class Ph extends po{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}}class sS extends po{constructor(e){super(e),this.name="InvalidToken"}}async function iS({origin:t}){const e=await fetch(`${t}/nonce`,{method:"POST"});if(!e.ok)throw new Ph({status:e.status});return await e.json()}async function oS({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 Ph({status:n.status});const r=await n.json();if(r.valid===!1)throw new sS(r.message??"unknown");return{token:r.token}}function aS(t={}){return{origin:t.origin??"https://auth.farcaster.xyz"}}function cS(t={}){const e=aS(t);return{generateNonce:()=>iS(e),verifySiwf:n=>oS(e,n)}}const uS=/^(?:(?<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)?/,dS=/(?: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 lS(t){const{scheme:e,statement:n,...r}=t.match(uS)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:d,...m}=t.match(dS)?.groups??{},g=t.split("Resources:")[1]?.split(`
|
|
32
|
+
- `).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 Uh=(()=>{let t,e;async function n(r){const s=cS({origin:r.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await be.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){const a=lS(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:rS(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 fS(){const t=new wA;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 Bt=fS(),{solanaProviderRequest:Dh}=be;let Fh;Dh&&(Fh=tx(rx(Dh)));async function $h(){let t;try{t=await be.getCapabilities()}catch{}if(t?.includes("wallet.getSolanaProvider"))return Fh}let zh=null;async function hS(t=1e3){if(zh===!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&&(zh=!0),e}const jh=async()=>{const t=await be.addFrame();if(t.result)return t.result;throw t.error.type==="invalid_domain_manifest"?new $1:t.error.type==="rejected_by_user"?new z1:new Error("Unreachable")},Vh={...Bt,getCapabilities:be.getCapabilities,getChains:be.getChains,isInMiniApp:hS,context:be.context,back:sx({miniAppHost:be,emitter:Bt}),quickAuth:Uh,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:jh,addMiniApp:jh,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:$h,signManifest:async t=>{const e=await be.signManifest(t);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new j1:e.error.type==="invalid_domain"?new V1:e.error.type==="generic_error"?new G1(e.error.message):new Error("Unreachable")},quickAuth(t){return Uh.getToken(t)}},wallet:{ethProvider:Ys,getEthereumProvider:Dx,getSolanaProvider:$h},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"?Bt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Bt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Bt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Bt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Bt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Bt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Bt.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"?Bt.emit("primaryButtonClicked"):e.event==="miniapp_added"?Bt.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Bt.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Bt.emit("miniAppRemoved"):e.event==="notifications_enabled"?Bt.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Bt.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Bt.emit("backNavigationTriggered")}}),mo.type="farcasterMiniApp";let Wr,Zr,Yr;function mo(){return t=>({id:"farcaster",name:"Farcaster",rdns:"xyz.farcaster.MiniAppWallet",icon:"https://imagedelivery.net/BXluQx4ige9GuW0Ia56BHw/055c25d6-7fe7-4a49-abf9-49772021cf00/original",type:mo.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.");Wr||(Wr=this.onAccountsChanged.bind(this),n.on("accountsChanged",Wr)),Zr||(Zr=this.onChainChanged.bind(this),n.on("chainChanged",Zr)),Yr||(Yr=this.onDisconnect.bind(this),n.on("disconnect",Yr));let i=await this.getChainId();return s&&i!==s&&(i=(await this.switchChain({chainId:s})).id),{accounts:r.map(o=>li(o)),chainId:i}},async disconnect(){const e=await this.getProvider();Wr&&(e.removeListener("accountsChanged",Wr),Wr=void 0),Zr&&(e.removeListener("chainChanged",Zr),Zr=void 0),Yr&&(e.removeListener("disconnect",Yr),Yr=void 0)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(r=>li(r))},async getChainId(){const n=await(await this.getProvider()).request({method:"eth_chainId"});return bm(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 Or(new Gl);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=>li(n))})},onChainChanged(e){const n=Number(e);t.emitter.emit("change",{chainId:n})},async onDisconnect(){t.emitter.emit("disconnect")},async getProvider(){return Vh.wallet.ethProvider}})}const pS=mo;pS.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 zc(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Gh(t){return zc(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Hh="2.43.4";let jc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Hh}`};class Yn extends Error{constructor(e,n={}){const r=n.cause instanceof Yn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Yn&&n.cause.docsPath||n.docsPath,i=jc.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...jc.version?[`Version: ${jc.version}`]:[]].join(`
|
|
33
|
+
`);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=Hh}walk(e){return qh(this,e)}}function qh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?qh(t.cause,e):e?null:t}class Kh extends Yn{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 go(t,{dir:e,size:n=32}={}){return typeof t=="string"?mS(t,{dir:e,size:n}):gS(t,{dir:e,size:n})}function mS(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Kh({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function gS(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Kh({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 yS extends Yn{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 bS extends Yn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Vc(t,{size:e}){if(Gh(t)>e)throw new bS({givenSize:Gh(t),maxSize:e})}function _S(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 yS({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?go(a,{size:r}):a}const wS=new TextEncoder;function ES(t,e={}){return typeof t=="number"||typeof t=="bigint"?RS(t,e):typeof t=="boolean"?vS(t,e):zc(t)?Zh(t,e):Yh(t,e)}function vS(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Vc(n,{size:e.size}),go(n,{size:e.size})):n}const Cn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Wh(t){if(t>=Cn.zero&&t<=Cn.nine)return t-Cn.zero;if(t>=Cn.A&&t<=Cn.F)return t-(Cn.A-10);if(t>=Cn.a&&t<=Cn.f)return t-(Cn.a-10)}function Zh(t,e={}){let n=t;e.size&&(Vc(n,{size:e.size}),n=go(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=Wh(r.charCodeAt(a++)),m=Wh(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Yn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function RS(t,e){const n=_S(t,e);return Zh(n)}function Yh(t,e={}){const n=wS.encode(t);return typeof e.size=="number"?(Vc(n,{size:e.size}),go(n,{dir:"right",size:e.size})):n}const yo=BigInt(2**32-1),Jh=BigInt(32);function AS(t,e=!1){return e?{h:Number(t&yo),l:Number(t>>Jh&yo)}:{h:Number(t>>Jh&yo)|0,l:Number(t&yo)|0}}function xS(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}=AS(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const SS=(t,e,n)=>t<<n|e>>>32-n,TS=(t,e,n)=>e<<n|t>>>32-n,OS=(t,e,n)=>e<<n-32|t>>>64-n,IS=(t,e,n)=>t<<n-32|e>>>64-n;function NS(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Xh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bo(t,...e){if(!NS(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 Qh(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 CS(t,e){bo(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function MS(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function e0(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const BS=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function kS(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function LS(t){for(let e=0;e<t.length;e++)t[e]=kS(t[e]);return t}const t0=BS?t=>t:LS;function PS(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function n0(t){return typeof t=="string"&&(t=PS(t)),bo(t),t}class US{}function DS(t){const e=r=>t().update(n0(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const FS=BigInt(0),Js=BigInt(1),$S=BigInt(2),zS=BigInt(7),jS=BigInt(256),VS=BigInt(113),r0=[],s0=[],i0=[];for(let t=0,e=Js,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],r0.push(2*(5*r+n)),s0.push((t+1)*(t+2)/2%64);let s=FS;for(let i=0;i<7;i++)e=(e<<Js^(e>>zS)*VS)%jS,e&$S&&(s^=Js<<(Js<<BigInt(i))-Js);i0.push(s)}const o0=xS(i0,!0),GS=o0[0],HS=o0[1],a0=(t,e,n)=>n>32?OS(t,e,n):SS(t,e,n),c0=(t,e,n)=>n>32?IS(t,e,n):TS(t,e,n);function qS(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],v=a0(m,g,1)^n[a],T=c0(m,g,1)^n[a+1];for(let I=0;I<50;I+=10)t[o+I]^=v,t[o+I+1]^=T}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=s0[o],d=a0(s,i,a),m=c0(s,i,a),g=r0[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]^=GS[r],t[1]^=HS[r]}e0(n)}class Gc extends US{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,Xh(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=MS(this.state)}clone(){return this._cloneInto()}keccak(){t0(this.state32),qS(this.state32,this.rounds),t0(this.state32),this.posOut=0,this.pos=0}update(e){Qh(this),e=n0(e),bo(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){Qh(this,!1),bo(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 Xh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(CS(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,e0(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Gc(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 KS=(t,e,n)=>DS(()=>new Gc(e,t,n)),WS=KS(1,136,256/8);function ZS(t,e){return WS(zc(t,{strict:!1})?ES(t):t)}class YS extends Yn{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 u0 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 Hc=new u0(8192);function d0(t,e){if(Hc.has(`${t}.${e}`))return Hc.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=ZS(Yh(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 Hc.set(`${t}.${e}`,i),i}function kt(t,e){if(!XS(t,{strict:!1}))throw new YS({address:t});return d0(t,e)}const JS=/^0x[a-fA-F0-9]{40}$/,qc=new u0(8192);function XS(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(qc.has(r))return qc.get(r);const s=JS.test(t)?t.toLowerCase()===t?!0:n?d0(t)===t:!0:!1;return qc.set(r,s),s}const Lt={USDC:"USDC",USDT:"USDT",DAI:"DAI",WETH:"WETH"};on.ARBITRUM+"",Lt.DAI+"",kt("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),Lt.USDC+"",kt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),Lt.USDT+"",kt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),Lt.WETH+"",kt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),on.ARBITRUM_TESTNET+"",Lt.USDC+"",kt("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),on.AVALANCHE+"",Lt.USDC+"",kt("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),on.AVALANCHE_TESTNET+"",Lt.USDC+"",kt("0x5425890298aed601595a70AB815c96711a31Bc65"),on.BASE+"",Lt.USDC+"",kt("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),Lt.WETH+"",kt("0x4200000000000000000000000000000000000006"),on.BASE_TESTNET+"",Lt.USDC+"",kt("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),on.BSC+"",Lt.USDC+"",kt("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),on.ETHEREUM+"",Lt.DAI+"",kt("0x6B175474E89094C44Da98b954EedeAC495271d0F"),Lt.USDC+"",kt("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),Lt.USDT+"",kt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),Lt.WETH+"",kt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),on.ETHEREUM_TESTNET+"",Lt.USDC+"",kt("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238");const QS=new Set(Object.values(on));function eT(t){if(tT(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 tT(t){return QS.has(t)}async function nT(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");const r=await C1(e,{connector:mo()});if(r?.accounts?.length){const s={type:cn.FARCASTER_CONNECTED,isConnected:!0,address:r.accounts[0],chainId:r.chainId};[Fo,$o].forEach(i=>{t.current?.contentWindow?.postMessage(s,i)})}}async function rT(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");await L1(e);const r={type:cn.FARCASTER_DISCONNECTED,isConnected:!1,address:null,chainId:null};[Fo,$o].forEach(s=>{t.current?.contentWindow?.postMessage(r,s)})}async function sT(t,e,n,r,s){if(!n||!e)throw new Error("Wagmi config not found");let i=null;try{return await D1(e,{chainId:t.chainId}),t.nativeToken?(i=await P1(e,{to:t.to,value:t.value,chainId:t.chainId}),i):(i=await F1(e,{abi:rm,address:t.token,functionName:"transfer",args:[t.to,t.value]}),i)}catch{[Fo,$o].forEach(a=>{r?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:s.params,error:"an error occurred"},a)})}return i}function iT(t){if(!t)throw new Error("Wagmi config not found");return t.chains.map(e=>e.id)}function oT(){return wt.jsx("div",{role:"status",className:"payment-modal-loader",children:wt.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:[wt.jsxs("g",{clipPath:"url(#clip0_9521_19796)",children:[wt.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"}),wt.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"})]}),wt.jsx("defs",{children:wt.jsx("clipPath",{id:"clip0_9521_19796",children:wt.jsx("rect",{width:"33.6761",height:"19.0243",fill:"white"})})})]})})}const aT=["light","dark","system"],_o="https://app.chainrails.io",wo="https://chainrails-frontend-git-staging-horus-labs.vercel.app";function cT(t){const{amount:e,client:n,styles:r,excludeChains:s,isOpen:i,isPending:o,open:a,close:d,onCancel:m,onSuccess:g,session_url:v,sessionToken:T,farcasterMiniApp:I,wagmiConfig:L}=t,[M,C]=Me.useState(0),[q,Z]=Me.useState(""),[D,P]=Me.useState(null),[z,J]=Me.useState(!1),ee=Me.useRef(null),te=Me.useRef(!1);Me.useEffect(()=>{const U=r?.theme;if(U==="dark"){J(!0);return}if(U==="light"){J(!1);return}const j=window.matchMedia("(prefers-color-scheme: dark)"),E=()=>J(j.matches);return E(),j.addEventListener("change",E),()=>j.removeEventListener("change",E)},[r?.theme]),yn.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Me.useEffect(()=>{Z(yn.getPayModalUrl(e))},[e]),Me.useEffect(()=>{const U=r?.theme;if(!U||aT.includes(U)){P(null);return}let j=!1;return(async()=>{try{const c=yn.getBaseUrl(),p=await fetch(`${c}/themes/${U}`);if(!p.ok)return;const y=await p.json();!j&&y.status==="approved"&&y.cssContent&&P(y.cssContent)}catch(c){console.error("Failed to fetch theme:",c)}})(),()=>{j=!0}},[r?.theme]),Me.useEffect(()=>{const U=document.body.style.overflow;i?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=U||"";const j=async E=>{if(E.data===cn.CLOSED&&(d(),m?.()),E?.data?.type===cn.COMPLETED){window.setTimeout(d,2e3);const y=E?.data?.transactionHash?{transactionHash:E.data.transactionHash}:void 0;g?.(y)}if(E.data===cn.REQUEST_FARCASTER_CONNECT)try{await nT(ee,L,I)}catch(y){console.error(y)}if(E.data===cn.REQUEST_FARCASTER_DISCONNECT)try{await rT(ee,L,I)}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 sT(p.params,L,I,ee.current,p.requestId);y?[_o,wo].forEach(x=>{ee.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:p.requestId,hash:y},x)}):[_o,wo].forEach(x=>{ee.current?.contentWindow?.postMessage({type:cn.FARCASTER_SEND_TRANSACTION_RESULT,requestId:p.requestId,error:"sendTransaction not configured or returned no hash"},x)})}catch(y){console.log(y)}};return window.addEventListener("message",j),()=>{document.body.style.overflow=U||"",window.removeEventListener("message",j)}},[i,m,g,d,I,L]),Me.useEffect(()=>{if(!T)return;const U=t.css||D||void 0,j=async()=>{const c=await Vh.isInMiniApp(),p=s?.map(eT)||[],y=L?iT(L):void 0;return{type:"session",session_token:T,client:n,environment:yn.getEnv()||Po.PRODUCTION,styles:r,props:{excludeChains:p.join(","),isFarcasterMiniApp:c,...y?.length?{supportedChains:y}:{}},...U?{css:U}:{}}};let E=!1;return j().then(c=>{E||([_o,wo].forEach(p=>{ee.current?.contentWindow?.postMessage(c,p)}),window.setTimeout(()=>{E||[_o,wo].forEach(p=>{ee.current?.contentWindow?.postMessage(c,p)})},1e3))}),()=>{E=!0}},[T,M,i,r,D]),Me.useEffect(()=>{if(!i)return;const U=te.current;C(U?Math.random():0)},[i]);function K(){te.current=!0,C(Math.random())}Me.useEffect(()=>{const U=document.querySelector(".payment-modal-loader-container"),j=document.querySelector(".payment-modal-loader-logo");U.style.opacity="1",U.style.transform="translateX(-50%)",j.style.opacity="1",j.style.transform="scale(1)",j.style.filter="blur(0px)"},[]);const k=M===0||!T;return wt.jsxs("div",{className:Do("payment-modal-wrapper",i?"open":"closed"),children:[wt.jsx("div",{className:Do("payment-modal-loader-container",z?"dark-mode":"light-mode","no-amount"),children:wt.jsx(oT,{})}),wt.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:q||void 0,onLoad:K,className:Do(`payment-modal ${k?"invisible":"visible"}`),"data-id":e,ref:ee},e),wt.jsx("iframe",{src:yn.getPayModalUrl("100"),style:{position:"absolute",left:"-9999px",visibility:"hidden",width:0,height:0,border:0}})]})}const uT=Symbol(),Kc=Symbol(),Xs="a",l0="f",f0="p",h0="c",p0="t",Wc="h",Qs="w",Zc="o",Yc="k";let dT=(t,e)=>new Proxy(t,e);const Jc=Object.getPrototypeOf,Xc=new WeakMap,m0=t=>t&&(Xc.has(t)?Xc.get(t):Jc(t)===Object.prototype||Jc(t)===Array.prototype),Eo=t=>typeof t=="object"&&t!==null,lT=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),fT=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(Jc(t),e)},hT=(t,e)=>{const n={[l0]:e};let r=!1;const s=(a,d)=>{if(!r){let m=n[Xs].get(t);if(m||(m={},n[Xs].set(t,m)),a===Qs)m[Qs]=!0;else{let g=m[a];g||(g=new Set,m[a]=g),g.add(d)}}},i=()=>{r=!0,n[Xs].delete(t)},o={get(a,d){return d===Kc?t:(s(Yc,d),g0(Reflect.get(a,d),n[Xs],n[h0],n[p0]))},has(a,d){return d===uT?(i(),!0):(s(Wc,d),Reflect.has(a,d))},getOwnPropertyDescriptor(a,d){return s(Zc,d),Reflect.getOwnPropertyDescriptor(a,d)},ownKeys(a){return s(Qs),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,n]},Qc=t=>t[Kc]||t,g0=(t,e,n,r)=>{if(!m0(t))return t;let s=r&&r.get(t);if(!s){const d=Qc(t);lT(d)?s=[d,fT(d)]:s=[d],r?.set(t,s)}const[i,o]=s;let a=n&&n.get(i);return(!a||a[1][l0]!==!!o)&&(a=hT(i,!!o),a[1][f0]=dT(o||i,a[0]),n&&n.set(i,a)),a[1][Xs]=e,a[1][h0]=n,a[1][p0]=r,a[1][f0]},pT=(t,e)=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return n.length!==r.length||n.some((s,i)=>s!==r[i])},y0=(t,e,n,r,s=Object.is)=>{if(s(t,e))return!1;if(!Eo(t)||!Eo(e))return!0;const i=n.get(Qc(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[Wc]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[Qs]===!0){if(o=pT(t,e),o)return o}else for(const a of i[Zc]||[]){const d=!!Reflect.getOwnPropertyDescriptor(t,a),m=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=d!==m,o)return o}for(const a of i[Yc]||[])if(o=y0(t[a],e[a],n,r,s),o)return o;if(o===null)throw new Error("invalid used");return o},mT=t=>m0(t)&&t[Kc]||null,b0=(t,e=!0)=>{Xc.set(t,e)},gT=(t,e,n)=>{const r=[],s=new WeakSet,i=(o,a)=>{var d,m,g;if(s.has(o))return;Eo(o)&&s.add(o);const v=Eo(o)&&e.get(Qc(o));if(v){if((d=v[Wc])===null||d===void 0||d.forEach(T=>{const I=`:has(${String(T)})`;r.push(a?[...a,I]:[I])}),v[Qs]===!0){const T=":ownKeys";r.push(a?[...a,T]:[T])}else(m=v[Zc])===null||m===void 0||m.forEach(T=>{const I=`:hasOwn(${String(T)})`;r.push(a?[...a,I]:[I])});(g=v[Yc])===null||g===void 0||g.forEach(T=>{"value"in(Object.getOwnPropertyDescriptor(o,T)||{})&&i(o[T],a?[...a,T]:[T])})}else a&&r.push(a)};return i(t),r},vo={},eu=t=>typeof t=="object"&&t!==null,yT=t=>eu(t)&&!tu.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),_0=(t,e)=>{const n=w0.get(t);if(n?.[0]===e)return n[1];const r=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return b0(r,!0),w0.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(tu.has(i))b0(i,!1);else if(yr.has(i)){const[d,m]=yr.get(i);a.value=_0(d,m())}Object.defineProperty(r,s,a)}),Object.preventExtensions(r)},bT=(t,e,n,r)=>({deleteProperty(s,i){Reflect.get(s,i),n(i);const o=Reflect.deleteProperty(s,i);return o&&r(void 0),o},set(s,i,o,a){const d=!t()&&Reflect.has(s,i),m=Reflect.get(s,i,a);if(d&&(E0(m,o)||Ro.has(o)&&E0(m,Ro.get(o))))return!0;n(i),eu(o)&&(o=mT(o)||o);const g=!yr.has(o)&&wT(o)?v0(o):o;return e(i,g),Reflect.set(s,i,g,a),r(void 0),!0}}),yr=new WeakMap,tu=new WeakSet,w0=new WeakMap,nu=[1],Ro=new WeakMap;let E0=Object.is,_T=(t,e)=>new Proxy(t,e),wT=yT,ET=_0,vT=bT;function v0(t={}){if(!eu(t))throw new Error("object required");const e=Ro.get(t);if(e)return e;let n=nu[0];const r=new Set,s=(C,q=++nu[0])=>{n!==q&&(i=n=q,r.forEach(Z=>Z(C,q)))};let i=n;const o=(C=nu[0])=>(i!==C&&(i=C,d.forEach(([q])=>{const Z=q[1](C);Z>n&&(n=Z)})),n),a=C=>(q,Z)=>{let D;q&&(D=[...q],D[1]=[C,...D[1]]),s(D,Z)},d=new Map,m=(C,q)=>{const Z=!tu.has(q)&&yr.get(q);if(Z){if((vo?"production":void 0)!=="production"&&d.has(C))throw new Error("prop listener already exists");if(r.size){const D=Z[2](a(C));d.set(C,[Z,D])}else d.set(C,[Z])}},g=C=>{var q;const Z=d.get(C);Z&&(d.delete(C),(q=Z[1])==null||q.call(Z))},v=C=>(r.add(C),r.size===1&&d.forEach(([Z,D],P)=>{if((vo?"production":void 0)!=="production"&&D)throw new Error("remove already exists");const z=Z[2](a(P));d.set(P,[Z,z])}),()=>{r.delete(C),r.size===0&&d.forEach(([Z,D],P)=>{D&&(D(),d.set(P,[Z]))})});let T=!0;const I=vT(()=>T,m,g,s),L=_T(t,I);Ro.set(t,L);const M=[t,o,v];return yr.set(L,M),Reflect.ownKeys(t).forEach(C=>{const q=Object.getOwnPropertyDescriptor(t,C);"value"in q&&q.writable&&(L[C]=t[C])}),T=!1,L}function RT(t,e,n){const r=yr.get(t);(vo?"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=>{g&&i.push(g),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,m()}}function R0(t){const e=yr.get(t);(vo?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[n,r]=e;return ET(n,r())}const AT={},xT=(t,e)=>{const n=Me.useRef(void 0);Me.useEffect(()=>{n.current=gT(t,e)}),Me.useDebugValue(n.current)},ST=new WeakMap;function TT(t,e){const r=Me.useMemo(()=>t&&new WeakMap,[t]),s=Me.useRef(void 0);let i=!0;const o=Me.useSyncExternalStore(Me.useCallback(d=>{const m=RT(t,d);return d(),m},[t,void 0]),()=>{const d=R0(t);try{if(!i&&s.current&&!y0(s.current,d,r,new WeakMap))return s.current}catch{}return d},()=>R0(t));i=!1,Me.useLayoutEffect(()=>{s.current=o}),(AT?"production":void 0)!=="production"&&xT(o,r);const a=Me.useMemo(()=>new WeakMap,[]);return g0(o,r,a,ST)}const Jn=v0({data:null,isPending:!1,error:null});function OT({session_url:t,onCancel:e,onSuccess:n,farcasterMiniApp:r,wagmiConfig:s}){const i=TT(Jn),[o,a]=Me.useState(!1),[d,m]=Me.useState(Date.now()),g=i?.data?.sessionToken,v=i?.data?.amount;function T(){g||window.setTimeout(()=>{g&&a(!0)},200),a(!0)}function I(){a(!1)}const L=()=>{const M=Date.now();Jn.isPending=!0,Jn.error=null,Jn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(C=>C.json()).then(C=>{M<d||(Jn.data=C,Jn.isPending=!1,m(M))}).catch(C=>{M<d||(Jn.error=C?.toString(),Jn.isPending=!1,m(M),setInterval(L,5e3))})};return Me.useEffect(()=>{L()},[t]),{sessionToken:g,amount:v,isOpen:o,session_url:t,open:T,close:I,isPending:i.isPending,error:i.error,refetch:L,onSuccess:n,onCancel:e,farcasterMiniApp:r,wagmiConfig:s}}function IT({sessionToken:t,amount:e,client:n,onCancel:r,onSuccess:s,farcasterMiniApp:i,wagmiConfig:o}){const[a,d]=Me.useState(!1),[m,g]=Me.useState(t),[v,T]=Me.useState(e),[I,L]=Me.useState(n);function M({sessionToken:Z,amount:D,client:P}){g(Z),T(D),L(P)}Me.useEffect(()=>{g(t)},[t]);function C(){m||window.setTimeout(()=>{m&&d(!0)},200),d(!0)}function q(){d(!1)}return{sessionToken:m,updateSession:M,amount:v,client:I,isOpen:a,open:C,close:q,onSuccess:s,onCancel:r,farcasterMiniApp:i,wagmiConfig:o}}At.AmountSymbols=X,At.Chainrails=yn,At.Chains=Pu,At.PaymentModal=cT,At.chains=Pu,At.crapi=nm,At.tokens=X,At.usePaymentModal=IT,At.usePaymentSession=OT,Object.defineProperty(At,Symbol.toStringTag,{value:"Module"})}));
|