@chainrails/react 0.3.3 → 0.4.0
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 +2 -19
- package/dist/PaymentModal/index.d.ts.map +1 -1
- package/dist/chainrails-sdk.es.js +19948 -1229
- package/dist/chainrails-sdk.es.mjs +19948 -1229
- package/dist/chainrails-sdk.umd.js +42 -3
- package/dist/components/PaymentModalLoader.d.ts +2 -0
- package/dist/components/PaymentModalLoader.d.ts.map +1 -0
- package/dist/constants/constants.d.ts +22 -0
- package/dist/constants/constants.d.ts.map +1 -0
- package/dist/hooks/usePaymentModal.d.ts +7 -2
- package/dist/hooks/usePaymentModal.d.ts.map +1 -1
- package/dist/hooks/usePaymentSession.d.ts +6 -1
- package/dist/hooks/usePaymentSession.d.ts.map +1 -1
- package/dist/types/index.d.ts +45 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/farcaster.d.ts +11 -0
- package/dist/utils/farcaster.d.ts.map +1 -0
- package/package.json +8 -2
|
@@ -1,3 +1,42 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(we);class V extends Error{response;request;options;constructor(e,s,n){const o=e.status||e.status===0?e.status:"",i=e.statusText??"",r=`${o} ${i}`.trim(),a=r?`status code ${r}`:"an unknown error";super(`Request failed with ${a}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=e,this.request=s,this.options=n}}class Ce extends Error{name="NonError";value;constructor(e){let s="Non-error value was thrown";try{typeof e=="string"?s=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(s=e.message)}catch{}super(s),this.value=e}}class Y extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const s=e?.cause?e.cause instanceof Error?e.cause:new Ce(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",s?{cause:s}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Re=(()=>{let t=!1,e=!1;const s=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(s&&n)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(o){if(o instanceof Error&&o.message==="unsupported BodyInit type")return!1;throw o}return t&&!e})(),yt=typeof globalThis.AbortController=="function",Ae=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Tt=typeof globalThis.ReadableStream=="function",bt=typeof globalThis.FormData=="function",De=["get","post","put","patch","head","delete"],Et={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},G=2147483647,St=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ue=Symbol("stop");class ve{options;constructor(e){this.options=e}}const wt=t=>new ve(t),Ct={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},Rt={next:!0},At={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},Dt=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[s,n]of t)e+=St,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length,e+=typeof n=="string"?new TextEncoder().encode(n).length:n.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},ke=(t,e,s)=>{let n,o=0;return t.pipeThrough(new TransformStream({transform(i,r){if(r.enqueue(i),n){o+=n.byteLength;let a=e===0?0:o/e;a>=1&&(a=1-Number.EPSILON),s?.({percent:a,totalBytes:Math.max(e,o),transferredBytes:o},n)}n=i},flush(){n&&(o+=n.byteLength,s?.({percent:1,totalBytes:Math.max(e,o),transferredBytes:o},n))}}))},Ut=(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 s=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(ke(t.body,s,e),{status:t.status,statusText:t.statusText,headers:t.headers})},vt=(t,e,s)=>{if(!t.body)return t;const n=Dt(s??t.body);return new Request(t,{duplex:"half",body:ke(t.body,n,e)})},x=t=>t!==null&&typeof t=="object",F=(...t)=>{for(const e of t)if((!x(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return X({},...t)},Ie=(t={},e={})=>{const s=new globalThis.Headers(t),n=e instanceof globalThis.Headers,o=new globalThis.Headers(e);for(const[i,r]of o.entries())n&&r==="undefined"||r===void 0?s.delete(i):s.set(i,r);return s};function $(t,e,s){return Object.hasOwn(e,s)&&e[s]===void 0?[]:X(t[s]??[],e[s]??[])}const Pe=(t={},e={})=>({beforeRequest:$(t,e,"beforeRequest"),beforeRetry:$(t,e,"beforeRetry"),afterResponse:$(t,e,"afterResponse"),beforeError:$(t,e,"beforeError")}),kt=(t,e)=>{const s=new URLSearchParams;for(const n of[t,e])if(n!==void 0)if(n instanceof URLSearchParams)for(const[o,i]of n.entries())s.append(o,i);else if(Array.isArray(n))for(const o of n){if(!Array.isArray(o)||o.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(o[0]),String(o[1]))}else if(x(n))for(const[o,i]of Object.entries(n))i!==void 0&&s.append(o,String(i));else{const o=new URLSearchParams(n);for(const[i,r]of o.entries())s.append(i,r)}return s},X=(...t)=>{let e={},s={},n={},o;const i=[];for(const r of t)if(Array.isArray(r))Array.isArray(e)||(e=[]),e=[...e,...r];else if(x(r)){for(let[a,l]of Object.entries(r)){if(a==="signal"&&l instanceof globalThis.AbortSignal){i.push(l);continue}if(a==="context"){if(l!=null&&(!x(l)||Array.isArray(l)))throw new TypeError("The `context` option must be an object");e={...e,context:l==null?{}:{...e.context,...l}};continue}if(a==="searchParams"){l==null?o=void 0:o=o===void 0?l:kt(o,l);continue}x(l)&&a in e&&(l=X(e[a],l)),e={...e,[a]:l}}x(r.hooks)&&(n=Pe(n,r.hooks),e.hooks=n),x(r.headers)&&(s=Ie(s,r.headers),e.headers=s)}return o!==void 0&&(e.searchParams=o),i.length>0&&(i.length===1?e.signal=i[0]:Ae?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},It=t=>De.includes(t)?t.toUpperCase():t,xe={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},Pt=(t={})=>{if(typeof t=="number")return{...xe,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{...xe,...t}};class J extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function xt(t,e,s,n){return new Promise((o,i)=>{const r=setTimeout(()=>{s&&s.abort(),i(new J(t))},n.timeout);n.fetch(t,e).then(o).catch(i).then(()=>{clearTimeout(r)})})}async function Nt(t,{signal:e}){return new Promise((s,n)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",o,{once:!0}));function o(){clearTimeout(i),n(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",o),s()},t)})}const Ot=(t,e)=>{const s={};for(const n in e)Object.hasOwn(e,n)&&!(n in At)&&!(n in Ct)&&(!(n in t)||n in Rt)&&(s[n]=e[n]);return s},Bt=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 Mt(t){return t instanceof V||t?.name===V.name}function _t(t){return t instanceof J||t?.name===J.name}class B{static create(e,s){const n=new B(e,s),o=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>G)throw new RangeError(`The \`timeout\` option cannot be greater than ${G}`);await Promise.resolve();let r=await n.#g();for(const a of n.#e.hooks.afterResponse){const l=n.#u(r.clone()),u=await a(n.request,n.#a(),l,{retryCount:n.#s});if(u instanceof globalThis.Response&&(r=u),u instanceof ve)throw await Promise.all([l.body?.cancel(),r.body?.cancel()]),new Y(u.options)}if(n.#u(r),!r.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(r.status):n.#e.throwHttpErrors)){let a=new V(r,n.request,n.#a());for(const l of n.#e.hooks.beforeError)a=await l(a,{retryCount:n.#s});throw a}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Tt)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return Ut(r.clone(),n.#e.onDownloadProgress)}return r},i=n.#d(o).finally(async()=>{const r=n.#r,a=[];r&&!r.bodyUsed&&a.push(r.body?.cancel()),n.request.bodyUsed||a.push(n.request.body?.cancel()),await Promise.all(a)});for(const[r,a]of Object.entries(Et))r==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[r]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const l=await i;if(r==="json"){if(l.status===204)return"";const u=await l.text();return u===""?"":s.parseJson?s.parseJson(u):JSON.parse(u)}return l[r]()});return i}static#h(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)):e}request;#n;#s=0;#t;#e;#r;#o;#i;constructor(e,s={}){if(this.#t=e,this.#e={...s,headers:Ie(this.#t.headers,s.headers),hooks:Pe({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:It(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:Pt(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.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}yt&&Ae&&(this.#o=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#o?AbortSignal.any([this.#o,this.#n.signal]):this.#n.signal),Re&&(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 n=s.headers&&new globalThis.Headers(s.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(bt&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!n&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),Bt(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(B.#h(this.#e.searchParams)).toString()),r=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(r,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Re)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.#s);let s=e;return this.#e.retry.jitter===!0?s=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(s=this.#e.retry.jitter(e),(!Number.isFinite(s)||s<0)&&(s=e)),Math.min(this.#e.retry.backoffLimit,s)}async#m(e){if(this.#s++,this.#s>this.#e.retry.limit)throw e;const s=e instanceof Error?e:new Ce(e);if(s instanceof Y)return s.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const n=await this.#e.retry.shouldRetry({error:s,retryCount:this.#s});if(n===!1)throw e;if(n===!0)return this.#c()}if(_t(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Mt(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const n=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(n&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let o=Number(n)*1e3;Number.isNaN(o)?o=Date.parse(n)-Date.now():o>=Date.parse("2024-01-01")&&(o-=Date.now());const i=this.#e.retry.maxRetryAfter??o;return o<i?o:i}if(e.response.status===413)throw e}return this.#c()}#u(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#d(e){try{return await e()}catch(s){const n=Math.min(await this.#m(s),G);if(this.#s<1)throw s;if(await Nt(n,this.#o?{signal:this.#o}:{}),s instanceof Y&&s.customRequest){const o=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#l(o)}for(const o of this.#e.hooks.beforeRetry){const i=await o({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(i instanceof globalThis.Request){this.#l(i);break}if(i instanceof globalThis.Response)return i;if(i===Ue)return}return this.#d(e)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#o?AbortSignal.any([this.#o,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const s of this.#e.hooks.beforeRequest){const n=await s(this.request,this.#a(),{retryCount:this.#s});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#l(n);break}}const e=Ot(this.request,this.#e);return this.#r=this.request,this.request=this.#r.clone(),this.#e.timeout===!1?this.#e.fetch(this.#r,e):xt(this.#r,e,this.#n,this.#e)}#a(){if(!this.#i){const{hooks:e,...s}=this.#e;this.#i=Object.freeze(s)}return this.#i}#l(e){this.#i=void 0,this.request=this.#f(e)}#f(e,s){return!this.#e.onUploadProgress||!e.body?e:vt(e,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const Z=t=>{const e=(s,n)=>B.create(s,F(t,n));for(const s of De)e[s]=(n,o)=>B.create(n,F(t,o,{method:s}));return e.create=s=>Z(F(s)),e.extend=s=>(typeof s=="function"&&(s=s(t??{})),Z(F(t,s))),e.stop=Ue,e.retry=wt,e},Lt=Z(),b={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"},Ft={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 Q(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Ne(t){return Q(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Oe="2.43.4";let ee={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${Oe}`};class I extends Error{constructor(e,s={}){const n=s.cause instanceof I?s.cause.details:s.cause?.message?s.cause.message:s.details,o=s.cause instanceof I&&s.cause.docsPath||s.docsPath,i=ee.getDocsUrl?.({...s,docsPath:o}),r=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...ee.version?[`Version: ${ee.version}`]:[]].join(`
|
|
3
|
-
`);super(r,s.cause?{cause:s.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=n,this.docsPath=o,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=Oe}walk(e){return Be(this,e)}}function Be(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Be(t.cause,e):e?null:t}class Me extends I{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function H(t,{dir:e,size:s=32}={}){return typeof t=="string"?$t(t,{dir:e,size:s}):Ht(t,{dir:e,size:s})}function $t(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new Me({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ht(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new Me({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let o=0;o<s;o++){const i=e==="right";n[i?o:s-o-1]=t[i?o:t.length-o-1]}return n}class jt extends I{constructor({max:e,min:s,signed:n,size:o,value:i}){super(`Number "${i}" is not in safe ${o?`${o*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class zt extends I{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function te(t,{size:e}){if(Ne(t)>e)throw new zt({givenSize:Ne(t),maxSize:e})}function qt(t,e={}){const{signed:s,size:n}=e,o=BigInt(t);let i;n?s?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const r=typeof i=="bigint"&&s?-i-1n:0;if(i&&o>i||o<r){const l=typeof t=="bigint"?"n":"";throw new jt({max:i?`${i}${l}`:void 0,min:`${r}${l}`,signed:s,size:n,value:`${t}${l}`})}const a=`0x${(s&&o<0?(1n<<BigInt(n*8))+BigInt(o):o).toString(16)}`;return n?H(a,{size:n}):a}const Kt=new TextEncoder;function Wt(t,e={}){return typeof t=="number"||typeof t=="bigint"?Yt(t,e):typeof t=="boolean"?Vt(t,e):Q(t)?Le(t,e):Fe(t,e)}function Vt(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(te(s,{size:e.size}),H(s,{size:e.size})):s}const k={zero:48,nine:57,A:65,F:70,a:97,f:102};function _e(t){if(t>=k.zero&&t<=k.nine)return t-k.zero;if(t>=k.A&&t<=k.F)return t-(k.A-10);if(t>=k.a&&t<=k.f)return t-(k.a-10)}function Le(t,e={}){let s=t;e.size&&(te(s,{size:e.size}),s=H(s,{dir:"right",size:e.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const o=n.length/2,i=new Uint8Array(o);for(let r=0,a=0;r<o;r++){const l=_e(n.charCodeAt(a++)),u=_e(n.charCodeAt(a++));if(l===void 0||u===void 0)throw new I(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);i[r]=l*16+u}return i}function Yt(t,e){const s=qt(t,e);return Le(s)}function Fe(t,e={}){const s=Kt.encode(t);return typeof e.size=="number"?(te(s,{size:e.size}),H(s,{dir:"right",size:e.size})):s}const j=BigInt(2**32-1),$e=BigInt(32);function Gt(t,e=!1){return e?{h:Number(t&j),l:Number(t>>$e&j)}:{h:Number(t>>$e&j)|0,l:Number(t&j)|0}}function Xt(t,e=!1){const s=t.length;let n=new Uint32Array(s),o=new Uint32Array(s);for(let i=0;i<s;i++){const{h:r,l:a}=Gt(t[i],e);[n[i],o[i]]=[r,a]}return[n,o]}const Jt=(t,e,s)=>t<<s|e>>>32-s,Zt=(t,e,s)=>e<<s|t>>>32-s,Qt=(t,e,s)=>e<<s-32|t>>>64-s,es=(t,e,s)=>t<<s-32|e>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ts(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function He(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function z(t,...e){if(!ts(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 je(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 ss(t,e){z(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function ns(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function ze(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const os=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function rs(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function is(t){for(let e=0;e<t.length;e++)t[e]=rs(t[e]);return t}const qe=os?t=>t:is;function as(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Ke(t){return typeof t=="string"&&(t=as(t)),z(t),t}class cs{}function ls(t){const e=n=>t().update(Ke(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}const us=BigInt(0),M=BigInt(1),ds=BigInt(2),fs=BigInt(7),hs=BigInt(256),ms=BigInt(113),We=[],Ve=[],Ye=[];for(let t=0,e=M,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],We.push(2*(5*n+s)),Ve.push((t+1)*(t+2)/2%64);let o=us;for(let i=0;i<7;i++)e=(e<<M^(e>>fs)*ms)%hs,e&ds&&(o^=M<<(M<<BigInt(i))-M);Ye.push(o)}const Ge=Xt(Ye,!0),gs=Ge[0],ps=Ge[1],Xe=(t,e,s)=>s>32?Qt(t,e,s):Jt(t,e,s),Je=(t,e,s)=>s>32?es(t,e,s):Zt(t,e,s);function ys(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let r=0;r<10;r++)s[r]=t[r]^t[r+10]^t[r+20]^t[r+30]^t[r+40];for(let r=0;r<10;r+=2){const a=(r+8)%10,l=(r+2)%10,u=s[l],h=s[l+1],S=Xe(u,h,1)^s[a],m=Je(u,h,1)^s[a+1];for(let T=0;T<50;T+=10)t[r+T]^=S,t[r+T+1]^=m}let o=t[2],i=t[3];for(let r=0;r<24;r++){const a=Ve[r],l=Xe(o,i,a),u=Je(o,i,a),h=We[r];o=t[h],i=t[h+1],t[h]=l,t[h+1]=u}for(let r=0;r<50;r+=10){for(let a=0;a<10;a++)s[a]=t[r+a];for(let a=0;a<10;a++)t[r+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=gs[n],t[1]^=ps[n]}ze(s)}class se extends cs{constructor(e,s,n,o=!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=s,this.outputLen=n,this.enableXOF=o,this.rounds=i,He(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=ns(this.state)}clone(){return this._cloneInto()}keccak(){qe(this.state32),ys(this.state32,this.rounds),qe(this.state32),this.posOut=0,this.pos=0}update(e){je(this),e=Ke(e),z(e);const{blockLen:s,state:n}=this,o=e.length;for(let i=0;i<o;){const r=Math.min(s-this.pos,o-i);for(let a=0;a<r;a++)n[this.pos++]^=e[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:o}=this;e[n]^=s,(s&128)!==0&&n===o-1&&this.keccak(),e[o-1]^=128,this.keccak()}writeInto(e){je(this,!1),z(e),this.finish();const s=this.state,{blockLen:n}=this;for(let o=0,i=e.length;o<i;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,i-o);e.set(s.subarray(this.posOut,this.posOut+r),o),this.posOut+=r,o+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return He(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ss(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,ze(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:o,rounds:i,enableXOF:r}=this;return e||(e=new se(s,n,o,r,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=o,e.enableXOF=r,e.destroyed=this.destroyed,e}}const Ts=(t,e,s)=>ls(()=>new se(e,t,s)),bs=Ts(1,136,256/8);function Es(t,e){return bs(Q(t,{strict:!1})?Wt(t):t)}class Ss extends I{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 Ze extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const ne=new Ze(8192);function Qe(t,e){if(ne.has(`${t}.${e}`))return ne.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),n=Es(Fe(s)),o=s.split("");for(let r=0;r<40;r+=2)n[r>>1]>>4>=8&&o[r]&&(o[r]=o[r].toUpperCase()),(n[r>>1]&15)>=8&&o[r+1]&&(o[r+1]=o[r+1].toUpperCase());const i=`0x${o.join("")}`;return ne.set(`${t}.${e}`,i),i}function w(t,e){if(!Cs(t,{strict:!1}))throw new Ss({address:t});return Qe(t,e)}const ws=/^0x[a-fA-F0-9]{40}$/,oe=new Ze(8192);function Cs(t,e){const{strict:s=!0}=e??{},n=`${t}.${s}`;if(oe.has(n))return oe.get(n);const o=ws.test(t)?t.toLowerCase()===t?!0:s?Qe(t)===t:!0:!1;return oe.set(n,o),o}const c={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};c.USDC;const et={[b.ARBITRUM]:{[c.DAI]:{address:w("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[c.USDC]:{address:w("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[c.USDT]:{address:w("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[c.WETH]:{address:w("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[b.ARBITRUM_TESTNET]:{[c.USDC]:{address:w("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[b.AVALANCHE]:{[c.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.USDC]:{address:w("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[c.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[c.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[b.AVALANCHE_TESTNET]:{[c.USDC]:{address:w("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[b.BASE]:{[c.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[c.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:c.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[c.USDC]:{address:w("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[c.WETH]:{address:w("0x4200000000000000000000000000000000000006"),symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[b.BASE_TESTNET]:{[c.USDC]:{address:w("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[b.BSC]:{[c.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:c.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[c.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:c.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[c.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[c.USDC]:{address:w("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:c.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[c.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:c.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[b.ETHEREUM]:{[c.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:c.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[c.DAI]:{address:w("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[c.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:c.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[c.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:c.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[c.USDC]:{address:w("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[c.USDT]:{address:w("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[c.WETH]:{address:w("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[b.ETHEREUM_TESTNET]:{[c.USDC]:{address:w("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:c.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[b.HYPEREVM]:{[c.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[b.LISK]:{[c.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[b.MONAD]:{[c.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[b.MONAD_TESTNET]:{[c.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[b.OPTIMISM]:{[c.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[c.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[c.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[c.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[b.OPTIMISM_TESTNET]:{[c.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[b.POLYGON]:{[c.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[c.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[c.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[b.STARKNET]:{[c.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[c.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[c.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:c.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[c.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:c.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[c.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[c.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[b.STARKNET_TESTNET]:{[c.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},Rs=new Set(Object.values(b));function R(t){if(As(t))return t;const e=b[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 As(t){return Rs.has(t)}function Ds(t,e){const s=e.toLowerCase().trim(),n=et[t];if(!n)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let o;for(const i in n){const r=n[i];if(r&&r.address.toLowerCase()===s.toLowerCase()){o=r;break}}if(!o)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 o}function re(t,e,s){const n=Ds(t,e);if(n.symbol!==s)throw new Error(`Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${n.symbol}", but expected "${s}". The token address must correspond to a token with the expected symbol on the specified chain.`);return n}function Us(t,e){return et[t]?.[e]}function tt(t,e){return Us(t,e)?.address}var ie=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(ie||{});class d{constructor({api_key:e,env:s,seesion_token:n,props:o}){this.api_key=e||"",this.sessionToken=n||"",this.env=s??ie.PRODUCTION,this.props=o}static async config(e){if(!d.app){if(!e)throw new Error("Please provide an api_key");d.app=new d(e)}return e&&(e.api_key!==void 0&&(d.app.api_key=e.api_key),e.seesion_token!==void 0&&(d.app.sessionToken=e.seesion_token),e.env!==void 0&&(d.app.env=e.env),e.props!==void 0&&(d.app.props=e.props)),d.app}static getApiKey(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.api_key}static getSessionToken(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.sessionToken}static getProps(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.props}static getEnv(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.env==="internal"?"staging":d.app.env}static getBaseUrl(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(d.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(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=d.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(e),o=e&&!isNaN(Number(e))&&n>0?"/pay/":"/deposit/",i=`${e&&!isNaN(Number(e))&&n>0?n*100:""}`;return s+o+i}}let ae=null;function vs(){ae=Lt.create({prefixUrl:d.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=d.getSessionToken()||d.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function y(){return ae||vs(),ae}class ks{async getById(e){return await y().get("intents/"+e).json()}async getForSender(e){return await y().get("intents/user/"+e).json()}async getForAddress(e){return await y().get("intents/address/"+e).json()}async getForSession(e){return await y().get("modal/sessions/intents/"+e).json()}async getAll(e){return await y().get("intents",{searchParams:e}).json()}async create(e){const s=R(e.source_chain),n=R(e.destination_chain);return await y().post("intents",{json:{...e,source_chain:s,destination_chain:n}}).json()}async createForSession(e){const s=R(e.sourceChain);return await y().post("modal/sessions/intents",{json:{...e,sourceChain:s}}).json()}async update(e,s){return await y().post("intents",{json:s}).json()}async triggerProcessing(e){return await y().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await y().post(`modal/sessions/intents/${e}/process`).json()}}class Is{async getFromSpecificBridge(e){const s=R(e.sourceChain);re(s,e.tokenIn,e.amountSymbol);const n=R(e.destinationChain);return await y().get("quotes/single",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getFromAllBridges(e){const s=R(e.sourceChain);re(s,e.tokenIn,e.amountSymbol);const n=R(e.destinationChain);return await y().get("quotes/multiple",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getBestAcrossBridges(e){const s=R(e.sourceChain);re(s,e.tokenIn,e.amountSymbol);const n=R(e.destinationChain);return await y().get("quotes/best",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAll(e){const s=R(e.destinationChain);return await y().get("quotes/multi-source",{searchParams:{...e,destinationChain:s}}).json()}async getAllForSession(e){return await y().get("modal/sessions/quotes",{searchParams:e}).json()}}class Ps{async getOptimalRoutes(e){const s=R(e.sourceChain),n=R(e.destinationChain);return await y().get("router/optimal-route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAllSupportedBridges(){return await y().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const s=R(e.sourceChain),n=R(e.destinationChain);return await y().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getSupportedRoutes(e){return await y().get("router/supported-routes/bridge/"+e).json()}}class xs{async getSupported(e){return await y().get("chains",{searchParams:e}).json()}async getBalance(e){return await y().get(`chains/balances/${e.address}`,{searchParams:e}).json()}}class Ns{async getClientInfo(){return await y().get("client/auth/client-info").json()}async getClientInfoForSession(){return await y().get("modal/sessions/client").json()}}class Os{async getSessionToken(e){const s=R(e.destinationChain);let n=tt(s,e.token);n||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),n=tt(s,"USDC"));const o={recipient:e.recipient,tokenOut:n,destinationChain:s,amount:e.amount};return y().post("modal/sessions",{json:o}).json().then(i=>({...i,amount:o.amount}))}}const Bs={router:new Ps,quotes:new Is,intents:new ks,chains:new xs,client:new Ns,auth:new Os};function st(t){var e,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(s=st(t[e]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}function Ms(){for(var t,e,s=0,n="",o=arguments.length;s<o;s++)(t=arguments[s])&&(e=st(t))&&(n&&(n+=" "),n+=e);return n}const _s=["light","dark","system"];function Ls(t){const{amount:e,styles:s,excludeChains:n,isOpen:o,isPending:i,open:r,close:a,onCancel:l,onSuccess:u,session_url:h,sessionToken:S}=t,[m,T]=f.useState(0),[D,Te]=f.useState(""),[g,E]=f.useState(null),p=f.useRef(null);d.config({api_key:"",env:t.env==="internal"?"internal":"production"}),f.useEffect(()=>{Te(d.getPayModalUrl(e))},[e]),f.useEffect(()=>{const C=s?.theme;if(console.log({themeValue:C}),!C||_s.includes(C)){E(null);return}let v=!1;return(async()=>{try{const Ee=d.getBaseUrl(),pt=await fetch(`${Ee}/themes/${C}`);if(!pt.ok)return;const Se=await pt.json();!v&&Se.status==="approved"&&Se.css_content&&E(Se.css_content)}catch(Ee){console.error("Failed to fetch theme:",Ee)}finally{console.log({themeCss:g})}})(),()=>{v=!0}},[s?.theme]),f.useEffect(()=>{const C=document.body.style.overflow;o?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=C||"";const v=be=>{be.data==="closed"&&(a(),l?.()),be.data==="completed"&&(window.setTimeout(a,2e3),u?.())};return window.addEventListener("message",v),()=>{document.body.style.overflow=C||"",window.removeEventListener("message",v)}},[o,l,u]),f.useEffect(()=>{if(!S)return;const C=t.css||g||void 0;console.log({cssToSend:C});const v={type:"session",session_token:S,environment:d.getEnv()||ie.PRODUCTION,styles:s,props:{excludeChains:n?.join(",")},...C?{css:C}:{}};p.current?.contentWindow?.postMessage(v,"https://app.chainrails.io"),p.current?.contentWindow?.postMessage(v,"https://chainrails-frontend-git-staging-horus-labs.vercel.app"),window.setTimeout(()=>{p.current?.contentWindow?.postMessage(v,"https://app.chainrails.io"),p.current?.contentWindow?.postMessage(v,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")},1e3)},[S,m,o,s,g]);function U(){T(Math.random())}return O.jsxs("div",{className:Ms("payment-modal-wrapper",m===0||i?"loading":"not-loading",o?"open":"closed"),children:[(m===0||i)&&O.jsx("div",{role:"status",className:"payment-modal-loader",children:O.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[O.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),O.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),O.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:D||void 0,onLoad:U,className:`payment-modal ${m===0||i?"invisible":"visible"}`,"data-id":e,ref:p},e)]})}const Fs=Symbol(),ce=Symbol(),_="a",nt="f",ot="p",rt="c",it="t",le="h",L="w",ue="o",de="k";let $s=(t,e)=>new Proxy(t,e);const fe=Object.getPrototypeOf,he=new WeakMap,at=t=>t&&(he.has(t)?he.get(t):fe(t)===Object.prototype||fe(t)===Array.prototype),q=t=>typeof t=="object"&&t!==null,Hs=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),js=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(s=>{s.configurable=!0}),Object.create(fe(t),e)},zs=(t,e)=>{const s={[nt]:e};let n=!1;const o=(a,l)=>{if(!n){let u=s[_].get(t);if(u||(u={},s[_].set(t,u)),a===L)u[L]=!0;else{let h=u[a];h||(h=new Set,u[a]=h),h.add(l)}}},i=()=>{n=!0,s[_].delete(t)},r={get(a,l){return l===ce?t:(o(de,l),ct(Reflect.get(a,l),s[_],s[rt],s[it]))},has(a,l){return l===Fs?(i(),!0):(o(le,l),Reflect.has(a,l))},getOwnPropertyDescriptor(a,l){return o(ue,l),Reflect.getOwnPropertyDescriptor(a,l)},ownKeys(a){return o(L),Reflect.ownKeys(a)}};return e&&(r.set=r.deleteProperty=()=>!1),[r,s]},me=t=>t[ce]||t,ct=(t,e,s,n)=>{if(!at(t))return t;let o=n&&n.get(t);if(!o){const l=me(t);Hs(l)?o=[l,js(l)]:o=[l],n?.set(t,o)}const[i,r]=o;let a=s&&s.get(i);return(!a||a[1][nt]!==!!r)&&(a=zs(i,!!r),a[1][ot]=$s(r||i,a[0]),s&&s.set(i,a)),a[1][_]=e,a[1][rt]=s,a[1][it]=n,a[1][ot]},qs=(t,e)=>{const s=Reflect.ownKeys(t),n=Reflect.ownKeys(e);return s.length!==n.length||s.some((o,i)=>o!==n[i])},lt=(t,e,s,n,o=Object.is)=>{if(o(t,e))return!1;if(!q(t)||!q(e))return!0;const i=s.get(me(t));if(!i)return!0;if(n){if(n.get(t)===e)return!1;n.set(t,e)}let r=null;for(const a of i[le]||[])if(r=Reflect.has(t,a)!==Reflect.has(e,a),r)return r;if(i[L]===!0){if(r=qs(t,e),r)return r}else for(const a of i[ue]||[]){const l=!!Reflect.getOwnPropertyDescriptor(t,a),u=!!Reflect.getOwnPropertyDescriptor(e,a);if(r=l!==u,r)return r}for(const a of i[de]||[])if(r=lt(t[a],e[a],s,n,o),r)return r;if(r===null)throw new Error("invalid used");return r},Ks=t=>at(t)&&t[ce]||null,ut=(t,e=!0)=>{he.set(t,e)},Ws=(t,e,s)=>{const n=[],o=new WeakSet,i=(r,a)=>{var l,u,h;if(o.has(r))return;q(r)&&o.add(r);const S=q(r)&&e.get(me(r));if(S){if((l=S[le])===null||l===void 0||l.forEach(m=>{const T=`:has(${String(m)})`;n.push(a?[...a,T]:[T])}),S[L]===!0){const m=":ownKeys";n.push(a?[...a,m]:[m])}else(u=S[ue])===null||u===void 0||u.forEach(m=>{const T=`:hasOwn(${String(m)})`;n.push(a?[...a,T]:[T])});(h=S[de])===null||h===void 0||h.forEach(m=>{"value"in(Object.getOwnPropertyDescriptor(r,m)||{})&&i(r[m],a?[...a,m]:[m])})}else a&&n.push(a)};return i(t),n},K={},ge=t=>typeof t=="object"&&t!==null,Vs=t=>ge(t)&&!pe.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),dt=(t,e)=>{const s=ft.get(t);if(s?.[0]===e)return s[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return ut(n,!0),ft.set(t,[e,n]),Reflect.ownKeys(t).forEach(o=>{if(Object.getOwnPropertyDescriptor(n,o))return;const i=Reflect.get(t,o),{enumerable:r}=Reflect.getOwnPropertyDescriptor(t,o),a={value:i,enumerable:r,configurable:!0};if(pe.has(i))ut(i,!1);else if(N.has(i)){const[l,u]=N.get(i);a.value=dt(l,u())}Object.defineProperty(n,o,a)}),Object.preventExtensions(n)},Ys=(t,e,s,n)=>({deleteProperty(o,i){const r=Reflect.get(o,i);s(i);const a=Reflect.deleteProperty(o,i);return a&&n(["delete",[i],r]),a},set(o,i,r,a){const l=!t()&&Reflect.has(o,i),u=Reflect.get(o,i,a);if(l&&(ht(u,r)||W.has(r)&&ht(u,W.get(r))))return!0;s(i),ge(r)&&(r=Ks(r)||r);const h=!N.has(r)&&Xs(r)?mt(r):r;return e(i,h),Reflect.set(o,i,h,a),n(["set",[i],r,u]),!0}}),N=new WeakMap,pe=new WeakSet,ft=new WeakMap,ye=[1],W=new WeakMap;let ht=Object.is,Gs=(t,e)=>new Proxy(t,e),Xs=Vs,Js=dt,Zs=Ys;function mt(t={}){if(!ge(t))throw new Error("object required");const e=W.get(t);if(e)return e;let s=ye[0];const n=new Set,o=(g,E=++ye[0])=>{s!==E&&(i=s=E,n.forEach(p=>p(g,E)))};let i=s;const r=(g=ye[0])=>(i!==g&&(i=g,l.forEach(([E])=>{const p=E[1](g);p>s&&(s=p)})),s),a=g=>(E,p)=>{const U=[...E];U[1]=[g,...U[1]],o(U,p)},l=new Map,u=(g,E)=>{const p=!pe.has(E)&&N.get(E);if(p){if((K?"production":void 0)!=="production"&&l.has(g))throw new Error("prop listener already exists");if(n.size){const U=p[2](a(g));l.set(g,[p,U])}else l.set(g,[p])}},h=g=>{var E;const p=l.get(g);p&&(l.delete(g),(E=p[1])==null||E.call(p))},S=g=>(n.add(g),n.size===1&&l.forEach(([p,U],C)=>{if((K?"production":void 0)!=="production"&&U)throw new Error("remove already exists");const v=p[2](a(C));l.set(C,[p,v])}),()=>{n.delete(g),n.size===0&&l.forEach(([p,U],C)=>{U&&(U(),l.set(C,[p]))})});let m=!0;const T=Zs(()=>m,u,h,o),D=Gs(t,T);W.set(t,D);const Te=[t,r,S];return N.set(D,Te),Reflect.ownKeys(t).forEach(g=>{const E=Object.getOwnPropertyDescriptor(t,g);"value"in E&&E.writable&&(D[g]=t[g])}),m=!1,D}function Qs(t,e,s){const n=N.get(t);(K?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let o;const i=[],r=n[2];let a=!1;const u=r(h=>{i.push(h),o||(o=Promise.resolve().then(()=>{o=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,u()}}function gt(t){const e=N.get(t);(K?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[s,n]=e;return Js(s,n())}const en={},tn=(t,e)=>{const s=f.useRef(void 0);f.useEffect(()=>{s.current=Ws(t,e)}),f.useDebugValue(s.current)},sn=new WeakMap;function nn(t,e){const n=f.useMemo(()=>t&&new WeakMap,[t]),o=f.useRef(void 0);let i=!0;const r=f.useSyncExternalStore(f.useCallback(l=>{const u=Qs(t,l);return l(),u},[t,void 0]),()=>{const l=gt(t);try{if(!i&&o.current&&!lt(o.current,l,n,new WeakMap))return o.current}catch{}return l},()=>gt(t));i=!1,f.useLayoutEffect(()=>{o.current=r}),(en?"production":void 0)!=="production"&&tn(r,n);const a=f.useMemo(()=>new WeakMap,[]);return ct(r,n,a,sn)}const P=mt({data:null,isPending:!1,error:null});function on({session_url:t,onCancel:e,onSuccess:s}){const n=nn(P),[o,i]=f.useState(!1),[r,a]=f.useState(Date.now()),l=n?.data?.sessionToken,u=n?.data?.amount;function h(){l||window.setTimeout(()=>{l&&i(!0)},200),i(!0)}function S(){i(!1)}const m=()=>{const T=Date.now();P.isPending=!0,P.error=null,P.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(D=>D.json()).then(D=>{T<r||(P.data=D,P.isPending=!1,a(T))}).catch(D=>{T<r||(P.error=D?.toString(),P.isPending=!1,a(T),setInterval(m,5e3))})};return f.useEffect(()=>{m()},[t]),{sessionToken:l,amount:u,isOpen:o,session_url:t,open:h,close:S,isPending:n.isPending,error:n.error,refetch:m,onSuccess:s,onCancel:e}}function rn({sessionToken:t,amount:e,onCancel:s,onSuccess:n}){const[o,i]=f.useState(!1),[r,a]=f.useState(t),[l,u]=f.useState(e);function h({sessionToken:T,amount:D}){a(T),u(D)}f.useEffect(()=>{a(t)},[t]);function S(){r||window.setTimeout(()=>{r&&i(!0)},200),i(!0)}function m(){i(!1)}return{sessionToken:r,updateSession:h,amount:l,isOpen:o,open:S,close:m,onSuccess:n,onCancel:s}}A.AmountSymbols=c,A.Chainrails=d,A.Chains=Ft,A.PaymentModal=Ls,A.crapi=Bs,A.usePaymentModal=rn,A.usePaymentSession=on,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(Vt,Be){typeof exports=="object"&&typeof module<"u"?Be(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],Be):(Vt=typeof globalThis<"u"?globalThis:Vt||self,Be(Vt.Chainrails={},Vt.React,Vt.jsxRuntime))})(this,(function(Vt,Be,Jn){"use strict";var xu=document.createElement("style");xu.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(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 Tu 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 So extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const n=e?.cause?e.cause instanceof Error?e.cause:new Tu(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 Iu=(()=>{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",D0=typeof globalThis.ReadableStream=="function",P0=typeof globalThis.FormData=="function",Nu=["get","post","put","patch","head","delete"],F0={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},xo=2147483647,$0=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Cu=Symbol("stop");class Mu{options;constructor(e){this.options=e}}const z0=t=>new Mu(t),j0={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},V0={next:!0},H0={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+=$0,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},ku=(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))}}))},q0=(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(ku(t.body,n,e),{status:t.status,statusText:t.statusText,headers:t.headers})},K0=(t,e,n)=>{if(!t.body)return t;const r=G0(n??t.body);return new Request(t,{duplex:"half",body:ku(t.body,r,e)})},Xn=t=>t!==null&&typeof t=="object",ti=(...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 ni(t,e,n){return Object.hasOwn(e,n)&&e[n]===void 0?[]:To(t[n]??[],e[n]??[])}const Uu=(t={},e={})=>({beforeRequest:ni(t,e,"beforeRequest"),beforeRetry:ni(t,e,"beforeRetry"),afterResponse:ni(t,e,"afterResponse"),beforeError:ni(t,e,"beforeError")}),W0=(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:W0(s,d);continue}Xn(d)&&a in e&&(d=To(e[a],d)),e={...e,[a]:d}}Xn(o.hooks)&&(r=Uu(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.context===void 0&&(e.context={}),e},Z0=t=>Nu.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},Y0=(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.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Lu,...t}};class Io extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function J0(t,e,n,r){return new Promise((s,i)=>{const o=setTimeout(()=>{n&&n.abort(),i(new Io(t))},r.timeout);r.fetch(t,e).then(s).catch(i).then(()=>{clearTimeout(o)})})}async function X0(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 Q0=(t,e)=>{const n={};for(const r in e)Object.hasOwn(e,r)&&!(r in H0)&&!(r in j0)&&(!(r in t)||r in V0)&&(n[r]=e[r]);return n},ep=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 tp(t){return t instanceof Ao||t?.name===Ao.name}function np(t){return t instanceof Io||t?.name===Io.name}class Qr{static create(e,n){const r=new Qr(e,n),s=async()=>{if(typeof r.#e.timeout=="number"&&r.#e.timeout>xo)throw new RangeError(`The \`timeout\` option cannot be greater than ${xo}`);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 Mu)throw await Promise.all([d.body?.cancel(),o.body?.cancel()]),new So(m.options)}if(r.#d(o),!o.ok&&(typeof r.#e.throwHttpErrors=="function"?r.#e.throwHttpErrors(o.status):r.#e.throwHttpErrors)){let a=new Ao(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(!D0)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return q0(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(F0))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:Bu(this.#t.headers,n.headers),hooks:Uu({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},n.hooks),method:Z0(n.method??this.#t.method??"GET"),prefixUrl:String(n.prefixUrl||""),retry:Y0(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),Iu&&(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&&(P0&&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),ep(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(Qr.#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(!Iu)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 Tu(e);if(n instanceof So)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(np(e)&&!this.#e.retry.retryOnTimeout)throw e;if(tp(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),xo);if(this.#n<1)throw n;if(await X0(r,this.#s?{signal:this.#s}:{}),n instanceof So&&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===Cu)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=Q0(this.request,this.#e);return this.#i=this.request,this.request=this.#i.clone(),this.#e.timeout===!1?this.#e.fetch(this.#i,e):J0(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:K0(e,this.#e.onUploadProgress,n??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const Oo=t=>{const e=(n,r)=>Qr.create(n,ti(t,r));for(const n of Nu)e[n]=(r,s)=>Qr.create(r,ti(t,s,{method:n}));return e.create=n=>Oo(ti(n)),e.extend=n=>(typeof n=="function"&&(n=n(t??{})),Oo(ti(t,n))),e.stop=Cu,e.retry=z0,e},rp=Oo(),et={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"},sp={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 Du(t){return No(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Pu="2.43.4";let Co={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${Pu}`},es=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=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=Pu}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 es{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 ri(t,{dir:e,size:n=32}={}){return typeof t=="string"?ip(t,{dir:e,size:n}):op(t,{dir:e,size:n})}function ip(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 op(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}let ap=class extends es{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"})}},cp=class extends es{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Mo(t,{size:e}){if(Du(t)>e)throw new cp({givenSize:Du(t),maxSize:e})}function up(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 ap({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?ri(a,{size:r}):a}const dp=new TextEncoder;function lp(t,e={}){return typeof t=="number"||typeof t=="bigint"?hp(t,e):typeof t=="boolean"?fp(t,e):No(t)?ju(t,e):Vu(t,e)}function fp(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(Mo(n,{size:e.size}),ri(n,{size:e.size})):n}const yn={zero:48,nine:57,A:65,F:70,a:97,f:102};function zu(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 ju(t,e={}){let n=t;e.size&&(Mo(n,{size:e.size}),n=ri(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 es(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function hp(t,e){const n=up(t,e);return ju(n)}function Vu(t,e={}){const n=dp.encode(t);return typeof e.size=="number"?(Mo(n,{size:e.size}),ri(n,{dir:"right",size:e.size})):n}const si=BigInt(2**32-1),Hu=BigInt(32);function pp(t,e=!1){return e?{h:Number(t&si),l:Number(t>>Hu&si)}:{h:Number(t>>Hu&si)|0,l:Number(t&si)|0}}function mp(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}=pp(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const gp=(t,e,n)=>t<<n|e>>>32-n,yp=(t,e,n)=>e<<n|t>>>32-n,bp=(t,e,n)=>e<<n-32|t>>>64-n,_p=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ep(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Gu(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ii(t,...e){if(!Ep(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 wp(t,e){ii(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function vp(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 Rp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Ap(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Sp(t){for(let e=0;e<t.length;e++)t[e]=Ap(t[e]);return t}const Wu=Rp?t=>t:Sp;function xp(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=xp(t)),ii(t),t}let Tp=class{};function Ip(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 Op=BigInt(0),ts=BigInt(1),Np=BigInt(2),Cp=BigInt(7),Mp=BigInt(256),kp=BigInt(113),Yu=[],Ju=[],Xu=[];for(let t=0,e=ts,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=Op;for(let i=0;i<7;i++)e=(e<<ts^(e>>Cp)*kp)%Mp,e&Np&&(s^=ts<<(ts<<BigInt(i))-ts);Xu.push(s)}const Qu=mp(Xu,!0),Bp=Qu[0],Up=Qu[1],ed=(t,e,n)=>n>32?bp(t,e,n):gp(t,e,n),td=(t,e,n)=>n>32?_p(t,e,n):yp(t,e,n);function Lp(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],S=ed(m,g,1)^n[a],I=td(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=S,t[o+N+1]^=I}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]^=Bp[r],t[1]^=Up[r]}Ku(n)}let Dp=class k0 extends Tp{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,Gu(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=vp(this.state)}clone(){return this._cloneInto()}keccak(){Wu(this.state32),Lp(this.state32,this.rounds),Wu(this.state32),this.posOut=0,this.pos=0}update(e){qu(this),e=Zu(e),ii(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),ii(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 Gu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(wp(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 k0(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)=>Ip(()=>new Dp(e,t,n)),Fp=Pp(1,136,256/8);function $p(t,e){return Fp(No(t,{strict:!1})?lp(t):t)}let zp=class extends es{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 ko=new nd(8192);function rd(t,e){if(ko.has(`${t}.${e}`))return ko.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=$p(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 ko.set(`${t}.${e}`,i),i}function Tt(t,e){if(!Vp(t,{strict:!1}))throw new zp({address:t});return rd(t,e)}const jp=/^0x[a-fA-F0-9]{40}$/,Bo=new nd(8192);function Vp(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Bo.has(r))return Bo.get(r);const s=jp.test(t)?t.toLowerCase()===t?!0:n?rd(t)===t:!0:!1;return Bo.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={[et.ARBITRUM]:{[X.DAI]:{address:Tt("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:Tt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[X.USDT]:{address:Tt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:Tt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.ARBITRUM_TESTNET]:{[X.USDC]:{address:Tt("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}},[et.AVALANCHE]:{[X.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:X.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[X.USDC]:{address:Tt("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}},[et.AVALANCHE_TESTNET]:{[X.USDC]:{address:Tt("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}},[et.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:Tt("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:Tt("0x4200000000000000000000000000000000000006"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.BASE_TESTNET]:{[X.USDC]:{address:Tt("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}},[et.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:Tt("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}},[et.ETHEREUM]:{[X.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:X.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[X.DAI]:{address:Tt("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:Tt("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:Tt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:X.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[X.WETH]:{address:Tt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:X.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[et.ETHEREUM_TESTNET]:{[X.USDC]:{address:Tt("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}},[et.HYPEREVM]:{[X.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.LISK]:{[X.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.MONAD]:{[X.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.MONAD_TESTNET]:{[X.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.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}},[et.OPTIMISM_TESTNET]:{[X.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[et.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}},[et.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}},[et.STARKNET_TESTNET]:{[X.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:X.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},Hp=new Set(Object.values(et));function Dt(t){if(Gp(t))return t;const e=et[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 Gp(t){return Hp.has(t)}function qp(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 Uo(t,e,n){const r=qp(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 Kp(t,e){return sd[t]?.[e]}function id(t,e){return Kp(t,e)?.address}var Lo=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(Lo||{});let Mn=class Xe{constructor({api_key:e,env:n,seesion_token:r,props:s}){this.api_key=e||"",this.sessionToken=r||"",this.env=n??Lo.PRODUCTION,this.props=s}static async config(e){if(!Xe.app){if(!e)throw new Error("Please provide an api_key");Xe.app=new Xe(e)}return e&&(e.api_key!==void 0&&(Xe.app.api_key=e.api_key),e.seesion_token!==void 0&&(Xe.app.sessionToken=e.seesion_token),e.env!==void 0&&(Xe.app.env=e.env),e.props!==void 0&&(Xe.app.props=e.props)),Xe.app}static getApiKey(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.api_key}static getSessionToken(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.sessionToken}static getProps(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.props}static getEnv(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return Xe.app.env==="internal"?"staging":Xe.app.env}static getBaseUrl(){if(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(Xe.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(!Xe.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const n=Xe.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}},Do=null;function Wp(){Do=rp.create({prefixUrl:Mn.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=Mn.getSessionToken()||Mn.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,n)=>n]},retry:{limit:2}})}function je(){return Do||Wp(),Do}let Zp=class{async getById(e){return await je().get("intents/"+e).json()}async getForSender(e){return await je().get("intents/user/"+e).json()}async getForAddress(e){return await je().get("intents/address/"+e).json()}async getForSession(e){return await je().get("modal/sessions/intents/"+e).json()}async getAll(e){return await je().get("intents",{searchParams:e}).json()}async create(e){const n=Dt(e.source_chain),r=Dt(e.destination_chain);return await je().post("intents",{json:{...e,source_chain:n,destination_chain:r}}).json()}async createForSession(e){const n=Dt(e.sourceChain);return await je().post("modal/sessions/intents",{json:{...e,sourceChain:n}}).json()}async update(e,n){return await je().post("intents",{json:n}).json()}async triggerProcessing(e){return await je().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await je().post(`modal/sessions/intents/${e}/process`).json()}},Yp=class{async getFromSpecificBridge(e){const n=Dt(e.sourceChain);Uo(n,e.tokenIn,e.amountSymbol);const r=Dt(e.destinationChain);return await je().get("quotes/single",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getFromAllBridges(e){const n=Dt(e.sourceChain);Uo(n,e.tokenIn,e.amountSymbol);const r=Dt(e.destinationChain);return await je().get("quotes/multiple",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getBestAcrossBridges(e){const n=Dt(e.sourceChain);Uo(n,e.tokenIn,e.amountSymbol);const r=Dt(e.destinationChain);return await je().get("quotes/best",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAll(e){const n=Dt(e.destinationChain);return await je().get("quotes/multi-source",{searchParams:{...e,destinationChain:n}}).json()}async getAllForSession(e){return await je().get("modal/sessions/quotes",{searchParams:e}).json()}},Jp=class{async getOptimalRoutes(e){const n=Dt(e.sourceChain),r=Dt(e.destinationChain);return await je().get("router/optimal-route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getAllSupportedBridges(){return await je().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const n=Dt(e.sourceChain),r=Dt(e.destinationChain);return await je().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:n,destinationChain:r}}).json()}async getSupportedRoutes(e){return await je().get("router/supported-routes/bridge/"+e).json()}},Xp=class{async getSupported(e){return await je().get("chains",{searchParams:e}).json()}async getBalance(e){return await je().get(`chains/balances/${e.address}`,{searchParams:e}).json()}},Qp=class{async getClientInfo(){return await je().get("client/auth/client-info").json()}async getClientInfoForSession(){return await je().get("modal/sessions/client").json()}},em=class{async getSessionToken(e){const n=Dt(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 je().post("modal/sessions",{json:s}).json().then(i=>({...i,amount:s.amount}))}};const tm={router:new Jp,quotes:new Yp,intents:new Zp,chains:new Xp,client:new Qp,auth:new em};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 nm(){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 un={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",Fo="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}(${$o(t.inputs,{includeName:e})})`}function $o(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")?`(${$o(t.components,{includeName:e})})${t.type.slice(5)}`:t.type+(e&&t.name?` ${t.name}`:"")}function kn(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function Et(t){return kn(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ad="2.43.4";let zo={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${ad}`},de=class Ru extends Error{constructor(e,n={}){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,i=zo.getDocsUrl?.({...n,docsPath:s}),o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...zo.version?[`Version: ${zo.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 de{constructor({data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for given parameters.`].join(`
|
|
5
|
+
`),{metaMessages:[`Params: (${$o(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 jo extends de{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class om extends de{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 de{constructor({expectedSize:e,value:n}){super(`Size of bytes "${n}" (bytes${Et(n)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class cm extends de{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 de{constructor(e,{docsPath:n}){super([`Encoded error signature "${e}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${e}.`].join(`
|
|
8
|
+
`),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class dd extends de{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 de{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 de{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 de{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 de{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
|
|
12
|
+
`),{name:"InvalidArrayError"})}}class hm extends de{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(`
|
|
13
|
+
`),{name:"InvalidDefinitionTypeError"})}}class ns extends de{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 de{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 de{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 de{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"?Bn(t,{dir:e,size:n}):pm(t,{dir:e,size:n})}function Bn(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 pd extends de{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 de{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 de{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 de{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 en(t,{size:e}){if(Et(t)>e)throw new ym({givenSize:Et(t),maxSize:e})}function bm(t,e){const n={to:e},r=n.to;return r==="number"?er(t,n):r==="bigint"?Er(t,n):r==="string"?Em(t,n):r==="boolean"?_m(t,n):nn(t,n)}function Er(t,e={}){const{signed:n}=e;e.size&&en(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&&(en(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={}){return Number(Er(t,e))}function Em(t,e={}){let n=nn(t);return e.size&&(en(n,{size:e.size}),n=Qn(n,{dir:"right"})),new TextDecoder().decode(n)}const wm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Vo(t,e={}){return typeof t=="number"||typeof t=="bigint"?Ue(t,e):typeof t=="string"?Ho(t,e):typeof t=="boolean"?md(t,e):Ht(t,e)}function md(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(en(n,{size:e.size}),_r(n,{size:e.size})):n}function Ht(t,e={}){let n="";for(let s=0;s<t.length;s++)n+=wm[t[s]];const r=`0x${n}`;return typeof e.size=="number"?(en(r,{size:e.size}),_r(r,{dir:"right",size:e.size})):r}function Ue(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 pd({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 Ho(t,e={}){const n=vm.encode(t);return Ht(n,e)}const Rm=new TextEncoder;function Go(t,e={}){return typeof t=="number"||typeof t=="bigint"?Sm(t,e):typeof t=="boolean"?Am(t,e):kn(t)?nn(t,e):yd(t,e)}function Am(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(en(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 gd(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 nn(t,e={}){let n=t;e.size&&(en(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=gd(r.charCodeAt(a++)),m=gd(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new de(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function Sm(t,e){const n=Ue(t,e);return nn(n)}function yd(t,e={}){const n=Rm.encode(t);return typeof e.size=="number"?(en(n,{size:e.size}),_r(n,{dir:"right",size:e.size})):n}const oi=BigInt(2**32-1),bd=BigInt(32);function xm(t,e=!1){return e?{h:Number(t&oi),l:Number(t>>bd&oi)}:{h:Number(t>>bd&oi)|0,l:Number(t&oi)|0}}function _d(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}=xm(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const Ed=(t,e,n)=>t>>>n,wd=(t,e,n)=>t<<32-n|e>>>n,wr=(t,e,n)=>t>>>n|e<<32-n,vr=(t,e,n)=>t<<32-n|e>>>n,ai=(t,e,n)=>t<<64-n|e>>>n-32,ci=(t,e,n)=>t>>>n-32|e<<64-n,Tm=(t,e,n)=>t<<n|e>>>32-n,Im=(t,e,n)=>e<<n|t>>>32-n,Om=(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,km=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),Bm=(t,e,n,r,s)=>e+n+r+s+(t/2**32|0)|0,Um=(t,e,n,r,s)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(s>>>0),Lm=(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;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Dm(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function rs(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function tr(t,...e){if(!Dm(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 Pm(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");rs(t.outputLen),rs(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 vd(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 Un(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function qo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function dn(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 Rd=$m?t=>t:jm;function Vm(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ui(t){return typeof t=="string"&&(t=Vm(t)),tr(t),t}function Hm(...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 Ko{}function Wo(t){const e=r=>t().update(ui(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function Ad(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 Gm=BigInt(0),ss=BigInt(1),qm=BigInt(2),Km=BigInt(7),Wm=BigInt(256),Zm=BigInt(113),Sd=[],xd=[],Td=[];for(let t=0,e=ss,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],Sd.push(2*(5*r+n)),xd.push((t+1)*(t+2)/2%64);let s=Gm;for(let i=0;i<7;i++)e=(e<<ss^(e>>Km)*Zm)%Wm,e&qm&&(s^=ss<<(ss<<BigInt(i))-ss);Td.push(s)}const Id=_d(Td,!0),Ym=Id[0],Jm=Id[1],Od=(t,e,n)=>n>32?Om(t,e,n):Tm(t,e,n),Nd=(t,e,n)=>n>32?Nm(t,e,n):Im(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],S=Od(m,g,1)^n[a],I=Nd(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=S,t[o+N+1]^=I}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=xd[o],d=Od(s,i,a),m=Nd(s,i,a),g=Sd[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]}Un(n)}class Zo extends Ko{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,rs(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(){Rd(this.state32),Xm(this.state32,this.rounds),Rd(this.state32),this.posOut=0,this.pos=0}update(e){Ar(this),e=ui(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 rs(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(vd(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,Un(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Zo(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)=>Wo(()=>new Zo(e,t,n)),eg=Qm(1,136,256/8);function di(t,e){const n=e||"hex",r=eg(kn(t,{strict:!1})?Go(t):t);return n==="bytes"?r:Vo(r)}class is 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 tg=/^0x[a-fA-F0-9]{40}$/,Yo=new is(8192);function Ln(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Yo.has(r))return Yo.get(r);const s=tg.test(t)?t.toLowerCase()===t?!0:n?li(t)===t:!0:!1;return Yo.set(r,s),s}const Jo=new is(8192);function li(t,e){if(Jo.has(`${t}.${e}`))return Jo.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=di(yd(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 Jo.set(`${t}.${e}`,i),i}function fi(t,e){if(!Ln(t,{strict:!1}))throw new ns({address:t});return li(t,e)}class Cd extends de{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class ng extends de{constructor({length:e,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}}class rg extends de{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 Cd({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 Cd({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 Xo(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 hi(t,e,n,{strict:r}={}){return kn(t,{strict:!1})?ig(t,e,n,{strict:r}):Bd(t,e,n,{strict:r})}function Md(t,e){if(typeof e=="number"&&e>0&&e>Et(t)-1)throw new ld({offset:e,position:"start",size:Et(t)})}function kd(t,e,n){if(typeof e=="number"&&typeof n=="number"&&Et(t)!==n-e)throw new ld({offset:n,position:"end",size:Et(t)})}function Bd(t,e,n,{strict:r}={}){Md(t,e);const s=t.slice(e,n);return r&&kd(s,e,n),s}function ig(t,e,n,{strict:r}={}){Md(t,e);const s=`0x${t.replace("0x","").slice((e??0)*2,(n??t.length)*2)}`;return r&&kd(s,e,n),s}function og(t,e={}){typeof e.size<"u"&&en(t,{size:e.size});const n=Ht(t,e);return Er(n,e)}function ag(t,e={}){let n=t;if(typeof e.size<"u"&&(en(n,{size:e.size}),n=Qn(n)),n.length>1||n[0]>1)throw new mm(n);return!!n[0]}function En(t,e={}){typeof e.size<"u"&&en(t,{size:e.size});const n=Ht(t,e);return er(n,e)}function cg(t,e={}){let n=t;return typeof e.size<"u"&&(en(n,{size:e.size}),n=Qn(n,{dir:"right"})),new TextDecoder().decode(n)}function Sr(t){return typeof t[0]=="string"?Qo(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 Qo(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=ta(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(ea({param:t[r],value:e[r]}));return n}function ea({param:t,value:e}){const n=na(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 ta(t){let e=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?e+=32:e+=Et(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(Ue(e+s,{size:32})),r.push(a),s+=Et(a)):n.push(a)}return Sr([...n,...r])}function hg(t){if(!Ln(t))throw new ns({address:t});return{dynamic:!1,encoded:Bn(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=ea({param:n,value:t[o]});a.dynamic&&(s=!0),i.push(a)}if(r||s){const o=ta(i);if(r){const a=Ue(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Sr([a,o]):a}}if(s)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:Sr(i.map(({encoded:o})=>o))}}function mg(t,{param:e}){const[,n]=e.type.split("bytes"),r=Et(t);if(!n){let s=t;return r%32!==0&&(s=Bn(s,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:Sr([Bn(Ue(r,{size:32})),s])}}if(r!==Number.parseInt(n,10))throw new am({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:Bn(t,{dir:"right"})}}function gg(t){if(typeof t!="boolean")throw new de(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Bn(md(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 pd({max:r.toString(),min:s.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:Ue(t,{size:32,signed:e})}}function bg(t){const e=Ho(t),n=Math.ceil(Et(e)/32),r=[];for(let s=0;s<n;s++)r.push(Bn(hi(e,s*32,(s+1)*32),{dir:"right"}));return{dynamic:!0,encoded:Sr([Bn(Ue(Et(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=ea({param:i,value:t[o]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?ta(r):Sr(r.map(({encoded:s})=>s))}}function na(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function Eg(t,e){const n=typeof e=="string"?nn(e):e,r=Xo(n);if(Et(n)===0&&t.length>0)throw new jo;if(Et(e)&&Et(e)<32)throw new im({data:typeof e=="string"?e:Ht(e),params:t,size:Et(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=na(e.type);if(r){const[s,i]=r;return vg(t,{...e,type:i},{length:s,staticPosition:n})}if(e.type==="tuple")return xg(t,e,{staticPosition:n});if(e.type==="address")return wg(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 Sg(t,e);if(e.type==="string")return Tg(t,{staticPosition:n});throw new lm(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Ud=32,ra=32;function wg(t){const e=t.readBytes(32);return[li(Ht(Bd(e,-20))),32]}function vg(t,e,{length:n,staticPosition:r}){if(!n){const o=En(t.readBytes(ra)),a=r+o,d=a+Ud;t.setPosition(a);const m=En(t.readBytes(Ud)),g=os(e);let S=0;const I=[];for(let N=0;N<m;++N){t.setPosition(d+(g?N*32:S));const[P,M]=xr(t,e,{staticPosition:d});S+=M,I.push(P)}return t.setPosition(r+32),[I,32]}if(os(e)){const o=En(t.readBytes(ra)),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=En(t.readBytes(32));t.setPosition(n+o);const a=En(t.readBytes(32));if(a===0)return t.setPosition(n+32),["0x",32];const d=t.readBytes(a);return t.setPosition(n+32),[Ht(d),32]}return[Ht(t.readBytes(Number.parseInt(s,10),32)),32]}function Sg(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}):En(s,{signed:n}),32]}function xg(t,e,{staticPosition:n}){const r=e.components.length===0||e.components.some(({name:o})=>!o),s=r?[]:{};let i=0;if(os(e)){const o=En(t.readBytes(ra)),a=n+o;for(let d=0;d<e.components.length;++d){const m=e.components[d];t.setPosition(a+i);const[g,S]=xr(t,m,{staticPosition:a});i+=S,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=En(t.readBytes(32)),r=e+n;t.setPosition(r);const s=En(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 os(t){const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return t.components?.some(os);const n=na(t.type);return!!(n&&os({...t,type:n[1]}))}const Ig=t=>di(Go(t));function Og(t){return Ig(t)}function Ng(t,e){return t.exec(e)?.groups}const Ld=/^tuple(?<array>(\[(\d*)\])*)$/;function sa(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+=sa(i),s<n-1&&(e+=", ")}const r=Ng(Ld,t.type);return e+=`)${r?.array||""}`,sa({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function as(t){let e="";const n=t.length;for(let r=0;r<n;r++){const s=t[r];e+=sa(s),r!==n-1&&(e+=", ")}return e}function Cg(t){return t.type==="function"?`function ${t.name}(${as(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${as(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${as(t.inputs)})`:t.type==="error"?`error ${t.name}(${as(t.inputs)})`:t.type==="constructor"?`constructor(${as(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 de("Unable to normalize signature.");return s}const kg=t=>{const e=typeof t=="string"?t:Cg(t);return Mg(e)};function Dd(t){return Og(kg(t))}const Bg=Dd,ia=t=>hi(Dd(t),0,4);function Pd(t){const{abi:e,args:n=[],name:r}=t,s=kn(r,{strict:!1}),i=e.filter(a=>s?a.type==="function"?ia(a)===r:a.type==="event"?Bg(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 S="inputs"in a&&a.inputs[g];return S?oa(m,S):!1})){if(o&&"inputs"in o&&o.inputs){const m=Fd(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 oa(t,e){const n=typeof t,r=e.type;switch(r){case"address":return Ln(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"&&oa(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=>oa(s,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Fd(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 Fd(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")?Ln(n[r],{strict:!1}):o.includes("address")&&o.includes("bytes")?Ln(n[r],{strict:!1}):!1)return o}}const $d="/docs/contract/encodeFunctionData";function Ug(t){const{abi:e,args:n,functionName:r}=t;let s=e[0];if(r){const i=Pd({abi:e,args:n,name:r});if(!i)throw new dd(r,{docsPath:$d});s=i}if(s.type!=="function")throw new dd(void 0,{docsPath:$d});return{abi:[s],functionName:ia(br(s))}}function Lg(t){const{args:e}=t,{abi:n,functionName:r}=t.abi.length===1&&t.functionName?.startsWith("0x")?t:Ug(t),s=n[0],i=r,o="inputs"in s&&s.inputs?lg(s.inputs,e??[]):void 0;return Qo([i,o??"0x"])}class Dg extends de{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 Pg extends de{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
|
|
14
|
+
`),{name:"ChainNotFoundError"})}}function wn(t){return typeof t=="string"?{address:t,type:"json-rpc"}:t}const 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}=t,r=hi(n,0,4);if(r==="0x")throw new jo;const i=[...e||[],$g,zg].find(o=>o.type==="error"&&r===ia(br(o)));if(!i)throw new ud(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:i,args:"inputs"in i&&i.inputs&&i.inputs.length>0?Eg(i.inputs,hi(n,4)):void 0,errorName:i.name}}const pi=(t,e,n)=>JSON.stringify(t,(r,s)=>typeof s=="bigint"?s.toString():s,n);function zd({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"?pi(e[i]):e[i]}`).join(", ")})`}const Vg={gwei:9,wei:18},Hg={ether:-9,wei:9};function jd(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 Vd(t,e="wei"){return jd(t,Vg[e])}function rn(t,e="wei"){return jd(t,Hg[e])}class Gg extends de{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class qg extends de{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function mi(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 de{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",mi(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 de{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:S,value:I}){const N=mi({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:S,value:typeof I<"u"&&`${Vd(I)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${rn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${rn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${rn(m)} gwei`,nonce:g});super(e.shortMessage,{cause:e,docsPath:r,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Request Arguments:",N].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}const Zg=t=>t,Hd=t=>t;class Yg extends de{constructor(e,{abi:n,args:r,contractAddress:s,docsPath:i,functionName:o,sender:a}){const d=Pd({abi:n,args:r,name:o}),m=d?zd({abiItem:d,args:r,includeFunctionName:!1,includeName:!1}):void 0,g=d?br(d,{includeName:!0}):void 0,S=mi({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," "]:[],S&&"Contract Call:",S].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 de{constructor({abi:e,data:n,functionName:r,message:s}){let i,o,a,d;if(n&&n!=="0x")try{o=jg({abi:e,data:n});const{abiItem:g,errorName:S,args:I}=o;if(S==="Error")d=I[0];else if(S==="Panic"){const[N]=I;d=Fg[N]}else{const N=g?br(g,{includeName:!0}):void 0,P=g&&I?zd({abiItem:g,args:I,includeFunctionName:!1,includeName:!1}):void 0;a=[N?`Error: ${N}`:"",P&&P!=="()"?` ${[...Array(S?.length??0).keys()].map(()=>" ").join("")}${P}`:""]}}catch(g){i=g}else s&&(d=s);let m;i instanceof ud&&(m=i.signature,a=[`Unable to decode signature "${m}" as it was not found on the provided ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${m}.`]),super(d&&d!=="execution reverted"||m?[`The contract function "${r}" reverted with the following ${m?"signature":"reason"}:`,d||m].join(`
|
|
16
|
+
`):`The contract function "${r}" reverted.`,{cause:i,metaMessages:a,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=o,this.raw=n,this.reason=d,this.signature=m}}class Xg extends de{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Qg extends de{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 It(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 de{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: ${Hd(o)}`,e&&`Request body: ${pi(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 qd extends de{constructor({body:e,error:n,url:r}){super("RPC Request failed.",{cause:n,details:n.message,metaMessages:[`URL: ${Hd(r)}`,`Request body: ${pi(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 Gt extends de{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 qd?e.code:n??ey}}let Wt=class extends Gt{constructor(e,n){super(e,n),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=n.data}};class cs extends Gt{constructor(e){super(e,{code:cs.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(cs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class us extends Gt{constructor(e){super(e,{code:us.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(us,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class ds extends Gt{constructor(e,{method:n}={}){super(e,{code:ds.code,name:"MethodNotFoundRpcError",shortMessage:`The method${n?` "${n}"`:""} does not exist / is not available.`})}}Object.defineProperty(ds,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class ls extends Gt{constructor(e){super(e,{code:ls.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join(`
|
|
17
|
+
`)})}}Object.defineProperty(ls,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class nr extends Gt{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 Tr extends Gt{constructor(e){super(e,{code:Tr.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join(`
|
|
18
|
+
`)})}}Object.defineProperty(Tr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class fs extends Gt{constructor(e){super(e,{code:fs.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(fs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class hs extends Gt{constructor(e){super(e,{code:hs.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class ps extends Gt{constructor(e){super(e,{code:ps.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(ps,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class rr extends Gt{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 Ir extends Gt{constructor(e){super(e,{code:Ir.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(Ir,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class ms extends Gt{constructor(e){super(e,{code:ms.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(ms,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});let gi=class B0 extends Wt{constructor(e){super(e,{code:B0.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}};Object.defineProperty(gi,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class gs extends Wt{constructor(e){super(e,{code:gs.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(gs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class ys extends Wt{constructor(e,{method:n}={}){super(e,{code:ys.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${n?` " ${n}"`:""}.`})}}Object.defineProperty(ys,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class bs extends Wt{constructor(e){super(e,{code:bs.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(bs,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});let aa=class U0 extends Wt{constructor(e){super(e,{code:U0.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}};Object.defineProperty(aa,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Or extends Wt{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 _s extends Wt{constructor(e){super(e,{code:_s.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(_s,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Es extends Wt{constructor(e){super(e,{code:Es.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Es,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class ws extends Wt{constructor(e){super(e,{code:ws.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class vs extends Wt{constructor(e){super(e,{code:vs.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class Rs extends Wt{constructor(e){super(e,{code:Rs.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(Rs,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class As extends Wt{constructor(e){super(e,{code:As.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(As,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Ss extends Wt{constructor(e){super(e,{code:Ss.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Ss,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class ty extends Gt{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 de?t.walk(P=>"data"in P)||t.walk():{},{code:d,data:m,details:g,message:S,shortMessage:I}=a,N=t instanceof jo?new Xg({functionName:i}):[ny,nr.code].includes(d)&&(m||g||S||I)||d===Tr.code&&g==="execution reverted"&&m?new Jg({abi:e,data:typeof m=="object"?m.data:m,functionName:i,message:a instanceof qd?g:I??S}):t;return new Yg(N,{abi:e,args:r,contractAddress:n,docsPath:s,functionName:i,sender:o})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ca=BigInt(0),ua=BigInt(1);function xs(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function da(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 yi(t){const e=t.toString(16);return e.length&1?"0"+e:e}function Kd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?ca:BigInt("0x"+t)}const Wd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",sy=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Nr(t){if(da(t),Wd)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 Zd(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 bi(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Wd)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=Zd(t.charCodeAt(i)),a=Zd(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 Kd(Nr(t))}function Ts(t){return da(t),Kd(Nr(Uint8Array.from(t).reverse()))}function Is(t,e){return bi(t.toString(16).padStart(e*2,"0"))}function _i(t,e){return Is(t,e).reverse()}function Qe(t,e,n){let r;if(typeof e=="string")try{r=bi(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 Cr(...t){let e=0;for(let r=0;r<t.length;r++){const s=t[r];da(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 la=t=>typeof t=="bigint"&&ca<=t;function fa(t,e,n){return la(t)&&la(e)&&la(n)&&e<=t&&t<n}function sn(t,e,n,r){if(!fa(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function iy(t){let e;for(e=0;t>ca;t>>=ua,e+=1);return e}const Ei=t=>(ua<<BigInt(t))-ua,ha=t=>new Uint8Array(t),Yd=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=ha(t),s=ha(t),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...S)=>n(s,r,...S),d=(S=ha(0))=>{s=a(Yd([0]),S),r=a(),S.length!==0&&(s=a(Yd([1]),S),r=a())},m=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let S=0;const I=[];for(;S<e;){r=a();const N=r.slice();I.push(N),S+=r.length}return Cr(...I)};return(S,I)=>{o(),d(S);let N;for(;!(N=I(m()));)d();return o(),N}}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 Mr extends de{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(Mr,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted|gas required exceeds allowance/});class vi extends de{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${rn(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(vi,"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 pa extends de{constructor({cause:e,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${rn(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(pa,"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 ma extends de{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(ma,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class ga extends de{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(ga,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class ya extends de{constructor({cause:e,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class ba extends de{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(ba,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class _a extends de{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(_a,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Ea extends de{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(Ea,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class wa extends de{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(wa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Ri extends de{constructor({cause:e,maxPriorityFeePerGas:n,maxFeePerGas:r}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${n?` = ${rn(n)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${r?` = ${rn(r)} gwei`:""}).`].join(`
|
|
21
|
+
`),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Ri,"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 va extends de{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Jd(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof de?t.walk(s=>s?.code===Mr.code):t;return r instanceof de?new Mr({cause:t,message:r.details}):Mr.nodeMessage.test(n)?new Mr({cause:t,message:t.details}):vi.nodeMessage.test(n)?new vi({cause:t,maxFeePerGas:e?.maxFeePerGas}):pa.nodeMessage.test(n)?new pa({cause:t,maxFeePerGas:e?.maxFeePerGas}):ma.nodeMessage.test(n)?new ma({cause:t,nonce:e?.nonce}):ga.nodeMessage.test(n)?new ga({cause:t,nonce:e?.nonce}):ya.nodeMessage.test(n)?new ya({cause:t,nonce:e?.nonce}):ba.nodeMessage.test(n)?new ba({cause:t}):_a.nodeMessage.test(n)?new _a({cause:t,gas:e?.gas}):Ea.nodeMessage.test(n)?new Ea({cause:t,gas:e?.gas}):wa.nodeMessage.test(n)?new wa({cause:t}):Ri.nodeMessage.test(n)?new Ri({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new va({cause:t})}function Ra(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 Aa(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=>Ht(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=Ue(t.gas)),typeof t.gasPrice<"u"&&(n.gasPrice=Ue(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=Ue(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(n.maxFeePerGas=Ue(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=Ue(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(n.nonce=Ue(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=Ue(t.value)),n}function uy(t){return t.map(e=>({address:e.address,r:e.r?Ue(BigInt(e.r)):e.r,s:e.s?Ue(BigInt(e.s)):e.s,chainId:Ue(e.chainId),nonce:Ue(e.nonce),...typeof e.yParity<"u"?{yParity:Ue(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:Ue(e.v)}:{}}))}function Xd(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=Ue(e)),n!==void 0&&(o.nonce=Ue(n)),r!==void 0&&(o.state=Xd(r)),s!==void 0){if(o.state)throw new qg;o.stateDiff=Xd(s)}return o}function ly(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!Ln(n,{strict:!1}))throw new ns({address:n});if(e[n])throw new Gg({address:n});e[n]=dy(r)}return e}const fy=2n**256n-1n;function Ai(t){const{account:e,maxFeePerGas:n,maxPriorityFeePerGas:r,to:s}=t,i=e?wn(e):void 0;if(i&&!Ln(i.address))throw new ns({address:i.address});if(s&&!Ln(s))throw new ns({address:s});if(n&&n>fy)throw new vi({maxFeePerGas:n});if(r&&n&&r>n)throw new Ri({maxFeePerGas:n,maxPriorityFeePerGas:r})}function hy(t){const e=di(`0x${t.substring(4)}`).substring(26);return li(`0x${e}`)}async function py({hash:t,signature:e}){const n=kn(t)?t:Vo(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:S,yParity:I}=e,N=Number(I??S),P=Qd(N);return new r.Signature(Er(m),Er(g)).addRecoveryBit(P)}const o=kn(e)?e:Vo(e);if(Et(o)!==65)throw new Error("invalid signature length");const a=er(`0x${o.slice(130)}`),d=Qd(a);return r.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(d)})().recoverPublicKey(n.substring(2)).toHex(!1)}`}function Qd(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=el(t),r=Xo(new Uint8Array(n.length));return n.encode(r),e==="hex"?Ht(r.bytes):r.bytes}function el(t){return Array.isArray(t)?yy(t.map(e=>el(e))):by(t)}function yy(t){const e=t.reduce((s,i)=>s+i.length,0),n=tl(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"?nn(t):t,n=tl(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 tl(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 de("Length is too large.")}function _y(t){const{chainId:e,nonce:n,to:r}=t,s=t.contractAddress??t.address,i=di(Qo(["0x05",gy([e?Ue(e):"0x",s,n?Ue(n):"0x"])]));return r==="bytes"?nn(i):i}async function nl(t){const{authorization:e,signature:n}=t;return my({hash:_y(e),signature:n??e})}class Ey extends de{constructor(e,{account:n,docsPath:r,chain:s,data:i,gas:o,gasPrice:a,maxFeePerGas:d,maxPriorityFeePerGas:m,nonce:g,to:S,value:I}){const N=mi({from:n?.address,to:S,value:typeof I<"u"&&`${Vd(I)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:o,gasPrice:typeof a<"u"&&`${rn(a)} gwei`,maxFeePerGas:typeof d<"u"&&`${rn(d)} gwei`,maxPriorityFeePerGas:typeof m<"u"&&`${rn(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 wy(t,{docsPath:e,...n}){const r=(()=>{const s=Jd(t,n);return s instanceof va?t:s})();return new Ey(r,{docsPath:e,...n})}class rl extends de{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Sa extends de{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class vy extends de{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${rn(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class Ry extends de{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 sl(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=Sy(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 Sy(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 xy(t,e){const n=(t.transactions??[]).map(r=>typeof r=="string"?r:sl(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 Ns(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:s}={}){const i=s??!1,o=n!==void 0?Ue(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||xy)(a,"getBlock")}async function il(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 It(t,Ns,"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 Er(o)}catch{const[i,o]=await Promise.all([n?Promise.resolve(n):It(t,Ns,"getBlock")({}),It(t,il,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new Sa;const a=o-i.baseFeePerGas;return a<0n?0n:a}}async function ol(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 rl;const d=10**(o.toString().split(".")[1]?.length??0),m=I=>I*BigInt(Math.ceil(o*d))/BigInt(d),g=n||await It(t,Ns,"getBlock")({});if(typeof r?.fees?.estimateFeesPerGas=="function"){const I=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:m,request:s,type:i});if(I!==null)return I}if(i==="eip1559"){if(typeof g.baseFeePerGas!="bigint")throw new Sa;const I=typeof s?.maxPriorityFeePerGas=="bigint"?s.maxPriorityFeePerGas:await Ty(t,{block:g,chain:r,request:s}),N=m(g.baseFeePerGas);return{maxFeePerGas:s?.maxFeePerGas??N+I,maxPriorityFeePerGas:I}}return{gasPrice:s?.gasPrice??m(await It(t,il,"getGasPrice")({}))}}async function Iy(t,{address:e,blockTag:n="latest",blockNumber:r}){const s=await t.request({method:"eth_getTransactionCount",params:[e,typeof r=="bigint"?Ue(r):n]},{dedupe:!!r});return er(s)}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(i=>nn(i)):t.blobs,s=[];for(const i of r)s.push(Uint8Array.from(e.blobToKzgCommitment(i)));return n==="bytes"?s:s.map(i=>Ht(i))}function cl(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=>nn(o)):t.blobs,s=typeof t.commitments[0]=="string"?t.commitments.map(o=>nn(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=>Ht(o))}function Oy(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 ul extends Ko{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=qo(this.buffer)}update(e){Ar(this),e=ui(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=qo(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),vd(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;n[o++]=128,Un(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(r,0),o=0);for(let S=o;S<s;S++)n[S]=0;Oy(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=qo(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 S=0;S<m;S++)a.setUint32(4*S,g[S],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]),Ot=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]),Fn=new Uint32Array(64);class ky extends ul{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 S=0;S<16;S++,n+=4)Fn[S]=e.getUint32(n,!1);for(let S=16;S<64;S++){const I=Fn[S-15],N=Fn[S-2],P=dn(I,7)^dn(I,18)^I>>>3,M=dn(N,17)^dn(N,19)^N>>>10;Fn[S]=M+Fn[S-7]+P+Fn[S-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:d,G:m,H:g}=this;for(let S=0;S<64;S++){const I=dn(a,6)^dn(a,11)^dn(a,25),N=g+I+Ny(a,d,m)+My[S]+Fn[S]|0,M=(dn(r,2)^dn(r,13)^dn(r,22))+Cy(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(){Un(Fn)}destroy(){this.set(0,0,0,0,0,0,0,0),Un(this.buffer)}}const dl=_d(["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))),By=dl[0],Uy=dl[1],$n=new Uint32Array(80),zn=new Uint32Array(80);class Ly extends ul{constructor(e=64){super(128,e,16,!1),this.Ah=Ot[0]|0,this.Al=Ot[1]|0,this.Bh=Ot[2]|0,this.Bl=Ot[3]|0,this.Ch=Ot[4]|0,this.Cl=Ot[5]|0,this.Dh=Ot[6]|0,this.Dl=Ot[7]|0,this.Eh=Ot[8]|0,this.El=Ot[9]|0,this.Fh=Ot[10]|0,this.Fl=Ot[11]|0,this.Gh=Ot[12]|0,this.Gl=Ot[13]|0,this.Hh=Ot[14]|0,this.Hl=Ot[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:S,Fl:I,Gh:N,Gl:P,Hh:M,Hl:B}=this;return[e,n,r,s,i,o,a,d,m,g,S,I,N,P,M,B]}set(e,n,r,s,i,o,a,d,m,g,S,I,N,P,M,B){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=S|0,this.Fl=I|0,this.Gh=N|0,this.Gl=P|0,this.Hh=M|0,this.Hl=B|0}process(e,n){for(let j=0;j<16;j++,n+=4)$n[j]=e.getUint32(n),zn[j]=e.getUint32(n+=4);for(let j=16;j<80;j++){const U=$n[j-15]|0,V=zn[j-15]|0,J=wr(U,V,1)^wr(U,V,8)^Ed(U,V,7),ne=vr(U,V,1)^vr(U,V,8)^wd(U,V,7),te=$n[j-2]|0,z=zn[j-2]|0,C=wr(te,z,19)^ai(te,z,61)^Ed(te,z,6),F=vr(te,z,19)^ci(te,z,61)^wd(te,z,6),q=km(ne,F,zn[j-7],zn[j-16]),w=Bm(q,J,C,$n[j-7],$n[j-16]);$n[j]=w|0,zn[j]=q|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:d,Dh:m,Dl:g,Eh:S,El:I,Fh:N,Fl:P,Gh:M,Gl:B,Hh:K,Hl:Y}=this;for(let j=0;j<80;j++){const U=wr(S,I,14)^wr(S,I,18)^ai(S,I,41),V=vr(S,I,14)^vr(S,I,18)^ci(S,I,41),J=S&N^~S&M,ne=I&P^~I&B,te=Um(Y,V,ne,Uy[j],zn[j]),z=Lm(te,K,U,J,By[j],$n[j]),C=te|0,F=wr(r,s,28)^ai(r,s,34)^ai(r,s,39),q=vr(r,s,28)^ci(r,s,34)^ci(r,s,39),w=r&i^r&a^i&a,c=s&o^s&d^o&d;K=M|0,Y=B|0,M=N|0,B=P|0,N=S|0,P=I|0,{h:S,l:I}=_n(m|0,g|0,z|0,C|0),m=a|0,g=d|0,a=i|0,d=o|0,i=r|0,o=s|0;const p=Cm(C,q,c);r=Mm(p,z,F,w),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:S,l:I}=_n(this.Eh|0,this.El|0,S|0,I|0),{h:N,l:P}=_n(this.Fh|0,this.Fl|0,N|0,P|0),{h:M,l:B}=_n(this.Gh|0,this.Gl|0,M|0,B|0),{h:K,l:Y}=_n(this.Hh|0,this.Hl|0,K|0,Y|0),this.set(r,s,i,o,a,d,m,g,S,I,N,P,M,B,K,Y)}roundClean(){Un($n,zn)}destroy(){Un(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ll=Wo(()=>new ky),Dy=Wo(()=>new Ly),xa=ll;function Py(t,e){return xa(kn(t,{strict:!1})?Go(t):t)}function Fy(t){const{commitment:e,version:n=1}=t,r=t.to??(typeof e=="string"?"hex":"bytes"),s=Py(e);return s.set([n],0),r==="bytes"?s:Ht(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 fl=6,hl=32,Ta=4096,pl=hl*Ta,ml=pl*fl-1-1*Ta*fl;class zy extends de{constructor({maxSize:e,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class jy extends de{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Vy(t){const e=typeof t.data=="string"?nn(t.data):t.data,n=Et(e);if(!n)throw new jy;if(n>ml)throw new zy({maxSize:ml,size:n});const r=[];let s=!0,i=0;for(;s;){const o=Xo(new Uint8Array(pl));let a=0;for(;a<Ta;){const d=e.slice(i,i+(hl-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=>Ht(o.bytes))}function Hy(t){const{data:e,kzg:n,to:r}=t,s=t.blobs??Vy({data:e}),i=t.commitments??al({blobs:s,kzg:n,to:r}),o=t.proofs??cl({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 Gy(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 gl(t,{docsPath:e,...n}){const r=(()=>{const s=Jd(t,n);return s instanceof va?t:s})();return new Wg(r,{docsPath:e,...n})}async function Ia(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:S,maxFeePerGas:I,maxPriorityFeePerGas:N,nonce:P,nonceManager:M,to:B,type:K,value:Y,...j}=e,U=await(async()=>{if(!n||!M||typeof P<"u")return P;const te=wn(n),z=i?i.id:await It(t,Ia,"getChainId")({});return await M.consume({address:te.address,chainId:z,client:t})})();Ai(e);const V=i?.formatters?.transactionRequest?.format,ne=(V||Aa)({...Ra(j,{format:V}),account:n?wn(n):void 0,accessList:r,authorizationList:s,blobs:a,blobVersionedHashes:o,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:S,maxFeePerGas:I,maxPriorityFeePerGas:N,nonce:U,to:B,type:K,value:Y},"fillTransaction");try{const te=await t.request({method:"eth_fillTransaction",params:[ne]}),C=(i?.formatters?.transaction?.format||sl)(te.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 F=await(async()=>{if(typeof i?.fees?.baseFeeMultiplier=="function"){const p=await It(t,Ns,"getBlock")({});return i.fees.baseFeeMultiplier({block:p,client:t,request:e})}return i?.fees?.baseFeeMultiplier??1.2})();if(F<1)throw new rl;const w=10**(F.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(F*w))/BigInt(w);return C.maxFeePerGas&&!e.maxFeePerGas&&(C.maxFeePerGas=c(C.maxFeePerGas)),C.gasPrice&&!e.gasPrice&&(C.gasPrice=c(C.gasPrice)),{raw:te.raw,transaction:{from:ne.from,...C}}}catch(te){throw gl(te,{...e,chain:t.chain})}}const yl=["blobVersionedHashes","chainId","fees","gas","nonce","type"],bl=new Map,Oa=new is(128);async function _l(t,e){let n=e;n.account??=t.account,n.parameters??=yl;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 It(t,Ia,"getChainId")({}),d))}const g=r&&wn(r);let S=n.nonce;if(o.includes("nonce")&&typeof S>"u"&&g&&i){const U=await m();S=await i.consume({address:g.address,chainId:U,client:t})}a?.fn&&a.runAt?.includes("beforeFillTransaction")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillTransaction"}),S??=n.nonce);const N=((o.includes("blobVersionedHashes")||o.includes("sidecars"))&&n.kzg&&n.blobs||Oa.get(t.uid)===!1||!["fees","gas"].some(V=>o.includes(V))?!1:!!(o.includes("chainId")&&typeof n.chainId!="number"||o.includes("nonce")&&typeof S!="number"||o.includes("fees")&&typeof n.gasPrice!="bigint"&&(typeof n.maxFeePerGas!="bigint"||typeof n.maxPriorityFeePerGas!="bigint")||o.includes("gas")&&typeof n.gas!="bigint"))?await It(t,qy,"fillTransaction")({...n,nonce:S}).then(U=>{const{chainId:V,from:J,gas:ne,gasPrice:te,nonce:z,maxFeePerBlobGas:C,maxFeePerGas:F,maxPriorityFeePerGas:q,type:w,...c}=U.transaction;return Oa.set(t.uid,!0),{...n,...J?{from:J}:{},...w?{type:w}:{},...typeof V<"u"?{chainId:V}:{},...typeof ne<"u"?{gas:ne}:{},...typeof te<"u"?{gasPrice:te}:{},...typeof z<"u"?{nonce:z}:{},...typeof C<"u"?{maxFeePerBlobGas:C}:{},...typeof F<"u"?{maxFeePerGas:F}:{},...typeof q<"u"?{maxPriorityFeePerGas:q}:{},..."nonceKey"in c&&typeof c.nonceKey<"u"?{nonceKey:c.nonceKey}:{}}}).catch(U=>{const V=U;return V.name!=="TransactionExecutionError"||V.walk?.(ne=>{const te=ne;return te.name==="MethodNotFoundRpcError"||te.name==="MethodNotSupportedRpcError"})&&Oa.set(t.uid,!1),n}):n;S??=N.nonce,n={...N,...g?{from:g?.address}:{},...S?{nonce:S}:{}};const{blobs:P,gas:M,kzg:B,type:K}=n;a?.fn&&a.runAt?.includes("beforeFillParameters")&&(n=await a.fn({...n,chain:s},{phase:"beforeFillParameters"}));let Y;async function j(){return Y||(Y=await It(t,Ns,"getBlock")({blockTag:"latest"}),Y)}if(o.includes("nonce")&&typeof S>"u"&&g&&!i&&(n.nonce=await It(t,Iy,"getTransactionCount")({address:g.address,blockTag:"pending"})),(o.includes("blobVersionedHashes")||o.includes("sidecars"))&&P&&B){const U=al({blobs:P,kzg:B});if(o.includes("blobVersionedHashes")){const V=$y({commitments:U,to:"hex"});n.blobVersionedHashes=V}if(o.includes("sidecars")){const V=cl({blobs:P,commitments:U,kzg:B}),J=Hy({blobs:P,commitments:U,proofs:V,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=Gy(n)}catch{let U=bl.get(t.uid);typeof U>"u"&&(U=typeof(await j())?.baseFeePerGas=="bigint",bl.set(t.uid,U)),n.type=U?"eip1559":"legacy"}if(o.includes("fees"))if(n.type!=="legacy"&&n.type!=="eip2930"){if(typeof n.maxFeePerGas>"u"||typeof n.maxPriorityFeePerGas>"u"){const U=await j(),{maxFeePerGas:V,maxPriorityFeePerGas:J}=await ol(t,{block:U,chain:s,request:n});if(typeof n.maxPriorityFeePerGas>"u"&&n.maxFeePerGas&&n.maxFeePerGas<J)throw new vy({maxPriorityFeePerGas:J});n.maxPriorityFeePerGas=J,n.maxFeePerGas=V}}else{if(typeof n.maxFeePerGas<"u"||typeof n.maxPriorityFeePerGas<"u")throw new Sa;if(typeof n.gasPrice>"u"){const U=await j(),{gasPrice:V}=await ol(t,{block:U,chain:s,request:n,type:"legacy"});n.gasPrice=V}}return o.includes("gas")&&typeof M>"u"&&(n.gas=await It(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"})),Ai(n),delete n.parameters,n}async function Ky(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 nl({authorization:e.authorizationList[0]}).catch(()=>{throw new de("`to` is required. Could not infer from `authorizationList`")})})(),{accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,blockNumber:S,blockTag:I,data:N,gas:P,gasPrice:M,maxFeePerBlobGas:B,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:j,value:U,stateOverride:V,...J}=r?await _l(t,{...e,parameters:i,to:o}):e;if(P&&e.gas!==P)return P;const te=(typeof S=="bigint"?Ue(S):void 0)||I,z=ly(V);Ai(e);const C=t.chain?.formatters?.transactionRequest?.format,q=(C||Aa)({...Ra(J,{format:C}),account:s,accessList:a,authorizationList:d,blobs:m,blobVersionedHashes:g,data:N,gasPrice:M,maxFeePerBlobGas:B,maxFeePerGas:K,maxPriorityFeePerGas:Y,nonce:j,to:o,value:U},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:z?[q,te??t.experimental_blockTag??"latest",z]:te?[q,te]:[q]}))}catch(o){throw wy(o,{...e,account:s,chain:t.chain})}}const Si=new is(8192);function Wy(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(Si.get(n))return Si.get(n);const r=t().finally(()=>Si.delete(n));return Si.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?Ho(`${d}.${pi(n)}`):void 0;return Wy(()=>Yy(async()=>{try{return await t(n)}catch(S){const I=S;switch(I.code){case cs.code:throw new cs(I);case us.code:throw new us(I);case ds.code:throw new ds(I,{method:n.method});case ls.code:throw new ls(I);case nr.code:throw new nr(I);case Tr.code:throw new Tr(I);case fs.code:throw new fs(I);case hs.code:throw new hs(I);case ps.code:throw new ps(I);case rr.code:throw new rr(I,{method:n.method});case Ir.code:throw new Ir(I);case ms.code:throw new ms(I);case gi.code:throw new gi(I);case gs.code:throw new gs(I);case ys.code:throw new ys(I);case bs.code:throw new bs(I);case aa.code:throw new aa(I);case Or.code:throw new Or(I);case _s.code:throw new _s(I);case Es.code:throw new Es(I);case ws.code:throw new ws(I);case vs.code:throw new vs(I);case Rs.code:throw new Rs(I);case As.code:throw new As(I);case Ss.code:throw new Ss(I);case 5e3:throw new gi(I);default:throw S instanceof de?S:new ty(I)}}},{delay:({count:S,error:I})=>{if(I&&I instanceof Gd){const N=I?.headers?.get("Retry-After");if(N?.match(/\d/))return Number.parseInt(N,10)*1e3}return~~(1<<S)*o},retryCount:a,shouldRetry:({error:S})=>Xy(S)}),{enabled:s,id:g})}}function Xy(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Ir.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 Pg;if(e!==t.id)throw new Dg({chain:t,currentChainId:e})}class El extends Ko{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Pm(e);const r=ui(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),Un(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 El(t,e).update(n).digest();wl.create=(t,e)=>new El(t,e);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qt=BigInt(0),At=BigInt(1),ir=BigInt(2),e1=BigInt(3),vl=BigInt(4),Rl=BigInt(5),Al=BigInt(8);function Ve(t,e){const n=t%e;return n>=qt?n:e+n}function Ke(t,e,n){let r=t;for(;e-- >qt;)r*=r,r%=n;return r}function Na(t,e){if(t===qt)throw new Error("invert: expected non-zero number");if(e<=qt)throw new Error("invert: expected positive modulus, got "+e);let n=Ve(t,e),r=e,s=qt,i=At;for(;n!==qt;){const a=r/n,d=r%n,m=s-i*a;r=n,n=d,s=i,i=m}if(r!==At)throw new Error("invert: does not exist");return Ve(s,e)}function Sl(t,e){const n=(t.ORDER+At)/vl,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-Rl)/Al,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-At,n=0;for(;e%ir===qt;)e/=ir,n++;let r=ir;const s=Cs(t);for(;xl(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Sl;let i=s.pow(r,e);const o=(e+At)/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,S=d.mul(d.ONE,i),I=d.pow(m,e),N=d.pow(m,o);for(;!d.eql(I,d.ONE);){if(d.is0(I))return d.ZERO;let P=1,M=d.sqr(I);for(;!d.eql(M,d.ONE);)if(P++,M=d.sqr(M),P===g)throw new Error("Cannot find square root");const B=At<<BigInt(g-P-1),K=d.pow(S,B);g=P,S=d.sqr(K),I=d.mul(I,S),N=d.mul(N,K)}return N}}function r1(t){return t%vl===e1?Sl:t%Al===Rl?t1:n1(t)}const s1=(t,e)=>(Ve(t,e)&At)===At,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<qt)throw new Error("invalid exponent, negatives unsupported");if(n===qt)return t.ONE;if(n===At)return e;let r=t.ONE,s=e;for(;n>qt;)n&At&&(r=t.mul(r,s)),s=t.sqr(s),n>>=At;return r}function Ca(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-At)/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 Tl(t,e){e!==void 0&&rs(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Cs(t,e,n=!1,r={}){if(t<=qt)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:i}=Tl(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:Ei(s),ZERO:qt,ONE:At,create:d=>Ve(d,t),isValid:d=>{if(typeof d!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof d);return qt<=d&&d<t},is0:d=>d===qt,isOdd:d=>(d&At)===At,neg:d=>Ve(-d,t),eql:(d,m)=>d===m,sqr:d=>Ve(d*d,t),add:(d,m)=>Ve(d+m,t),sub:(d,m)=>Ve(d-m,t),mul:(d,m)=>Ve(d*m,t),pow:(d,m)=>a1(a,d,m),div:(d,m)=>Ve(d*Na(m,t),t),sqrN:d=>d*d,addN:(d,m)=>d+m,subN:(d,m)=>d-m,mulN:(d,m)=>d*m,inv:d=>Na(d,t),sqrt:r.sqrt||(d=>(o||(o=r1(t)),o(a,d))),toBytes:d=>n?_i(d,i):Is(d,i),fromBytes:d=>{if(d.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+d.length);return n?Ts(d):sr(d)},invertBatch:d=>Ca(a,d),cmov:(d,m,g)=>g?m:d});return Object.freeze(a)}function Il(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=Il(t);return e+Math.ceil(e/2)}function c1(t,e,n=!1){const r=t.length,s=Il(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?Ts(t):sr(t),a=Ve(o,e-At)+At;return n?_i(a,s):Is(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nl=BigInt(0),Ma=BigInt(1);function ka(t,e){const n=e.negate();return t?n:e}function Cl(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ba(t,e){Cl(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),s=2**t,i=Ei(t),o=BigInt(t);return{windows:n,windowSize:r,mask:i,maxNumber:s,shiftBy:o}}function Ml(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+=Ma);const m=e*r,g=m+Math.abs(a)-1,S=a===0,I=a<0,N=e%2!==0;return{nextN:d,offset:g,isZero:S,isNeg:I,isNegF:N,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,kl=new WeakMap;function La(t){return kl.get(t)||1}function Bl(t,e){return{constTimeNegate:ka,hasPrecomputes(n){return La(n)!==1},unsafeLadder(n,r,s=t.ZERO){let i=n;for(;r>Nl;)r&Ma&&(s=s.add(i)),i=i.double(),r>>=Ma;return s},precomputeWindow(n,r){const{windows:s,windowSize:i}=Ba(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=Ba(n,e);for(let d=0;d<a.windows;d++){const{nextN:m,offset:g,isZero:S,isNeg:I,isNegF:N,offsetF:P}=Ml(s,d,a);s=m,S?o=o.add(ka(N,r[P])):i=i.add(ka(I,r[g]))}return{p:i,f:o}},wNAFUnsafe(n,r,s,i=t.ZERO){const o=Ba(n,e);for(let a=0;a<o.windows&&s!==Nl;a++){const{nextN:d,offset:m,isZero:g,isNeg:S}=Ml(s,a,o);if(s=d,!g){const I=r[m];i=i.add(S?I.negate():I)}}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=La(n);return this.wNAF(i,this.getPrecomputes(i,n,s),r)},wNAFCachedUnsafe(n,r,s,i){const o=La(n);return o===1?this.unsafeLadder(n,r,i):this.wNAFUnsafe(o,this.getPrecomputes(o,n,s),r,i)},setWindowSize(n,r){Cl(r,e),kl.set(n,r),Ua.delete(n)}}}function Ul(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=Ei(d),g=new Array(Number(m)+1).fill(o),S=Math.floor((e.BITS-1)/d)*d;let I=o;for(let N=S;N>=0;N-=d){g.fill(o);for(let M=0;M<i;M++){const B=r[M],K=Number(B>>BigInt(N)&m);g[K]=g[K].add(n[M])}let P=o;for(let M=g.length-1,B=o;M>0;M--)B=B.add(g[M]),P=P.add(B);if(I=I.add(P),N!==0)for(let M=0;M<d;M++)I=I.double()}return I}function Da(t){return o1(t.Fp),Os(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Tl(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ll(t){t.lowS!==void 0&&Dn("lowS",t.lowS),t.prehash!==void 0&&Dn("prehash",t.prehash)}function l1(t){const e=Da(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=yi(r);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?yi(s.length/2|128):"";return yi(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=yi(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=Qe("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 Pa(t,e){return Nr(Is(t,e))}const An=BigInt(0),wt=BigInt(1);BigInt(2);const Fa=BigInt(3),h1=BigInt(4);function p1(t){const e=l1(t),{Fp:n}=e,r=Cs(e.n,e.nBitLength),s=e.toBytes||((j,U,V)=>{const J=U.toAffine();return Cr(Uint8Array.from([4]),n.toBytes(J.x),n.toBytes(J.y))}),i=e.fromBytes||(j=>{const U=j.subarray(1),V=n.fromBytes(U.subarray(0,n.BYTES)),J=n.fromBytes(U.subarray(n.BYTES,2*n.BYTES));return{x:V,y:J}});function o(j){const{a:U,b:V}=e,J=n.sqr(j),ne=n.mul(J,j);return n.add(n.add(ne,n.mul(j,U)),V)}function a(j,U){const V=n.sqr(U),J=o(j);return n.eql(V,J)}if(!a(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const d=n.mul(n.pow(e.a,Fa),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(j){return fa(j,wt,e.n)}function S(j){const{allowedPrivateKeyLengths:U,nByteLength:V,wrapPrivateKey:J,n:ne}=e;if(U&&typeof j!="bigint"){if(xs(j)&&(j=Nr(j)),typeof j!="string"||!U.includes(j.length))throw new Error("invalid private key");j=j.padStart(V*2,"0")}let te;try{te=typeof j=="bigint"?j:sr(Qe("private key",j,V))}catch{throw new Error("invalid private key, expected hex or "+V+" bytes, got "+typeof j)}return J&&(te=Ve(te,ne)),sn("private key",te,wt,ne),te}function I(j){if(!(j instanceof M))throw new Error("ProjectivePoint expected")}const N=wi((j,U)=>{const{px:V,py:J,pz:ne}=j;if(n.eql(ne,n.ONE))return{x:V,y:J};const te=j.is0();U==null&&(U=te?n.ONE:n.inv(ne));const z=n.mul(V,U),C=n.mul(J,U),F=n.mul(ne,U);if(te)return{x:n.ZERO,y:n.ZERO};if(!n.eql(F,n.ONE))throw new Error("invZ was invalid");return{x:z,y:C}}),P=wi(j=>{if(j.is0()){if(e.allowInfinityPoint&&!n.is0(j.py))return;throw new Error("bad point: ZERO")}const{x:U,y:V}=j.toAffine();if(!n.isValid(U)||!n.isValid(V))throw new Error("bad point: x or y not FE");if(!a(U,V))throw new Error("bad point: equation left != right");if(!j.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class M{constructor(U,V,J){if(U==null||!n.isValid(U))throw new Error("x required");if(V==null||!n.isValid(V)||n.is0(V))throw new Error("y required");if(J==null||!n.isValid(J))throw new Error("z required");this.px=U,this.py=V,this.pz=J,Object.freeze(this)}static fromAffine(U){const{x:V,y:J}=U||{};if(!U||!n.isValid(V)||!n.isValid(J))throw new Error("invalid affine point");if(U instanceof M)throw new Error("projective point not allowed");const ne=te=>n.eql(te,n.ZERO);return ne(V)&&ne(J)?M.ZERO:new M(V,J,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(U){const V=Ca(n,U.map(J=>J.pz));return U.map((J,ne)=>J.toAffine(V[ne])).map(M.fromAffine)}static fromHex(U){const V=M.fromAffine(i(Qe("pointHex",U)));return V.assertValidity(),V}static fromPrivateKey(U){return M.BASE.multiply(S(U))}static msm(U,V){return Ul(M,r,U,V)}_setWindowSize(U){Y.setWindowSize(this,U)}assertValidity(){P(this)}hasEvenY(){const{y:U}=this.toAffine();if(n.isOdd)return!n.isOdd(U);throw new Error("Field doesn't support isOdd")}equals(U){I(U);const{px:V,py:J,pz:ne}=this,{px:te,py:z,pz:C}=U,F=n.eql(n.mul(V,C),n.mul(te,ne)),q=n.eql(n.mul(J,C),n.mul(z,ne));return F&&q}negate(){return new M(this.px,n.neg(this.py),this.pz)}double(){const{a:U,b:V}=e,J=n.mul(V,Fa),{px:ne,py:te,pz:z}=this;let C=n.ZERO,F=n.ZERO,q=n.ZERO,w=n.mul(ne,ne),c=n.mul(te,te),p=n.mul(z,z),y=n.mul(ne,te);return y=n.add(y,y),q=n.mul(ne,z),q=n.add(q,q),C=n.mul(U,q),F=n.mul(J,p),F=n.add(C,F),C=n.sub(c,F),F=n.add(c,F),F=n.mul(C,F),C=n.mul(y,C),q=n.mul(J,q),p=n.mul(U,p),y=n.sub(w,p),y=n.mul(U,y),y=n.add(y,q),q=n.add(w,w),w=n.add(q,w),w=n.add(w,p),w=n.mul(w,y),F=n.add(F,w),p=n.mul(te,z),p=n.add(p,p),w=n.mul(p,y),C=n.sub(C,w),q=n.mul(p,c),q=n.add(q,q),q=n.add(q,q),new M(C,F,q)}add(U){I(U);const{px:V,py:J,pz:ne}=this,{px:te,py:z,pz:C}=U;let F=n.ZERO,q=n.ZERO,w=n.ZERO;const c=e.a,p=n.mul(e.b,Fa);let y=n.mul(V,te),A=n.mul(J,z),v=n.mul(ne,C),R=n.add(V,J),O=n.add(te,z);R=n.mul(R,O),O=n.add(y,A),R=n.sub(R,O),O=n.add(V,ne);let _=n.add(te,C);return O=n.mul(O,_),_=n.add(y,v),O=n.sub(O,_),_=n.add(J,ne),F=n.add(z,C),_=n.mul(_,F),F=n.add(A,v),_=n.sub(_,F),w=n.mul(c,O),F=n.mul(p,v),w=n.add(F,w),F=n.sub(A,w),w=n.add(A,w),q=n.mul(F,w),A=n.add(y,y),A=n.add(A,y),v=n.mul(c,v),O=n.mul(p,O),A=n.add(A,v),v=n.sub(y,v),v=n.mul(c,v),O=n.add(O,v),y=n.mul(A,O),q=n.add(q,y),y=n.mul(_,O),F=n.mul(R,F),F=n.sub(F,y),y=n.mul(R,A),w=n.mul(_,w),w=n.add(w,y),new M(F,q,w)}subtract(U){return this.add(U.negate())}is0(){return this.equals(M.ZERO)}wNAF(U){return Y.wNAFCached(this,U,M.normalizeZ)}multiplyUnsafe(U){const{endo:V,n:J}=e;sn("scalar",U,An,J);const ne=M.ZERO;if(U===An)return ne;if(this.is0()||U===wt)return this;if(!V||Y.hasPrecomputes(this))return Y.wNAFCachedUnsafe(this,U,M.normalizeZ);let{k1neg:te,k1:z,k2neg:C,k2:F}=V.splitScalar(U),q=ne,w=ne,c=this;for(;z>An||F>An;)z&wt&&(q=q.add(c)),F&wt&&(w=w.add(c)),c=c.double(),z>>=wt,F>>=wt;return te&&(q=q.negate()),C&&(w=w.negate()),w=new M(n.mul(w.px,V.beta),w.py,w.pz),q.add(w)}multiply(U){const{endo:V,n:J}=e;sn("scalar",U,wt,J);let ne,te;if(V){const{k1neg:z,k1:C,k2neg:F,k2:q}=V.splitScalar(U);let{p:w,f:c}=this.wNAF(C),{p,f:y}=this.wNAF(q);w=Y.constTimeNegate(z,w),p=Y.constTimeNegate(F,p),p=new M(n.mul(p.px,V.beta),p.py,p.pz),ne=w.add(p),te=c.add(y)}else{const{p:z,f:C}=this.wNAF(U);ne=z,te=C}return M.normalizeZ([ne,te])[0]}multiplyAndAddUnsafe(U,V,J){const ne=M.BASE,te=(C,F)=>F===An||F===wt||!C.equals(ne)?C.multiplyUnsafe(F):C.multiply(F),z=te(this,V).add(te(U,J));return z.is0()?void 0:z}toAffine(U){return N(this,U)}isTorsionFree(){const{h:U,isTorsionFree:V}=e;if(U===wt)return!0;if(V)return V(M,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:U,clearCofactor:V}=e;return U===wt?this:V?V(M,this):this.multiplyUnsafe(e.h)}toRawBytes(U=!0){return Dn("isCompressed",U),this.assertValidity(),s(M,this,U)}toHex(U=!0){return Dn("isCompressed",U),Nr(this.toRawBytes(U))}}M.BASE=new M(e.Gx,e.Gy,n.ONE),M.ZERO=new M(n.ZERO,n.ONE,n.ZERO);const{endo:B,nBitLength:K}=e,Y=Bl(M,B?Math.ceil(K/2):K);return{CURVE:e,ProjectivePoint:M,normPrivateKeyToScalar:S,weierstrassEquation:o,isWithinCurveOrder:g}}function m1(t){const e=Da(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 Ve(p,r)}function m(p){return Na(p,r)}const{ProjectivePoint:g,normPrivateKeyToScalar:S,weierstrassEquation:I,isWithinCurveOrder:N}=p1({...e,toBytes(p,y,A){const v=y.toAffine(),R=n.toBytes(v.x),O=Cr;return Dn("isCompressed",A),A?O(Uint8Array.from([y.hasEvenY()?2:3]),R):O(Uint8Array.from([4]),R,n.toBytes(v.y))},fromBytes(p){const y=p.length,A=p[0],v=p.subarray(1);if(y===o&&(A===2||A===3)){const R=sr(v);if(!fa(R,wt,n.ORDER))throw new Error("Point is not on curve");const O=I(R);let _;try{_=n.sqrt(O)}catch(E){const T=E instanceof Error?": "+E.message:"";throw new Error("Point is not on curve"+T)}const u=(_&wt)===wt;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)),O=n.fromBytes(v.subarray(n.BYTES,2*n.BYTES));return{x:R,y:O}}else{const R=o,O=a;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+O+", got "+y)}}});function P(p){const y=r>>wt;return p>y}function M(p){return P(p)?d(-p):p}const B=(p,y,A)=>sr(p.slice(y,A));class K{constructor(y,A,v){sn("r",y,wt,r),sn("s",A,wt,r),this.r=y,this.s=A,v!=null&&(this.recovery=v),Object.freeze(this)}static fromCompact(y){const A=s;return y=Qe("compactSignature",y,A*2),new K(B(y,0,A),B(y,A,2*A))}static fromDER(y){const{r:A,s:v}=Rn.toSig(Qe("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,O=ne(Qe("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)),E=m(_),T=d(-O*E),D=d(v*E),W=g.BASE.multiplyAndAddUnsafe(l,T,D);if(!W)throw new Error("point at infinify");return W.assertValidity(),W}hasHighS(){return P(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return bi(this.toDERHex())}toDERHex(){return Rn.hexFromSig(this)}toCompactRawBytes(){return bi(this.toCompactHex())}toCompactHex(){const y=s;return Pa(this.r,y)+Pa(this.s,y)}}const Y={isValidPrivateKey(p){try{return S(p),!0}catch{return!1}},normPrivateKeyToScalar:S,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 j(p,y=!0){return g.fromPrivateKey(p).toRawBytes(y)}function U(p){if(typeof p=="bigint")return!1;if(p instanceof g)return!0;const A=Qe("key",p).length,v=n.BYTES,R=v+1,O=2*v+1;if(!(e.allowedPrivateKeyLengths||s===R))return A===R||A===O}function V(p,y,A=!0){if(U(p)===!0)throw new Error("first arg must be private key");if(U(y)===!1)throw new Error("second arg must be public key");return g.fromHex(y).multiply(S(p)).toRawBytes(A)}const J=e.bits2int||function(p){if(p.length>8192)throw new Error("input is too large");const y=sr(p),A=p.length*8-i;return A>0?y>>BigInt(A):y},ne=e.bits2int_modN||function(p){return d(J(p))},te=Ei(i);function z(p){return sn("num < 2^"+i,p,An,te),Is(p,s)}function C(p,y,A=F){if(["recovered","canonical"].some(ae=>ae in A))throw new Error("sign() legacy options not supported");const{hash:v,randomBytes:R}=e;let{lowS:O,prehash:_,extraEntropy:u}=A;O==null&&(O=!0),p=Qe("msgHash",p),Ll(A),_&&(p=Qe("prehashed msgHash",v(p)));const l=ne(p),E=S(y),T=[z(E),z(l)];if(u!=null&&u!==!1){const ae=u===!0?R(n.BYTES):u;T.push(Qe("extraEntropy",ae))}const D=Cr(...T),W=l;function se(ae){const Me=J(ae);if(!N(Me))return;const ve=m(Me),we=g.BASE.multiply(Me).toAffine(),Fe=d(we.x);if(Fe===An)return;const Re=d(ve*d(W+Fe*E));if(Re===An)return;let Ne=(we.x===Fe?0:2)|Number(we.y&wt),gn=Re;return O&&P(Re)&&(gn=M(Re),Ne^=1),new K(Fe,gn,Ne)}return{seed:D,k2sig:se}}const F={lowS:e.lowS,prehash:!1},q={lowS:e.lowS,prehash:!1};function w(p,y,A=F){const{seed:v,k2sig:R}=C(p,y,A),O=e;return oy(O.hash.outputLen,O.nByteLength,O.hmac)(v,R)}g.BASE._setWindowSize(8);function c(p,y,A,v=q){const R=p;y=Qe("msgHash",y),A=Qe("publicKey",A);const{lowS:O,prehash:_,format:u}=v;if(Ll(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"||xs(R),E=!l&&!u&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!l&&!E)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let T,D;try{if(E&&(T=new K(R.r,R.s)),l){try{u!=="compact"&&(T=K.fromDER(R))}catch(Ne){if(!(Ne instanceof Rn.Err))throw Ne}!T&&u!=="der"&&(T=K.fromCompact(R))}D=g.fromHex(A)}catch{return!1}if(!T||O&&T.hasHighS())return!1;_&&(y=e.hash(y));const{r:W,s:se}=T,ae=ne(y),Me=m(se),ve=d(ae*Me),we=d(W*Me),Fe=g.BASE.multiplyAndAddUnsafe(D,ve,we)?.toAffine();return Fe?d(Fe.x)===W:!1}return{CURVE:e,getPublicKey:j,getSharedSecret:V,sign:w,verify:c,ProjectivePoint:g,Signature:K,utils:Y}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function y1(t){return{hash:t,hmac:(e,...n)=>wl(t,e,Hm(...n)),randomBytes:Ad}}function b1(t,e){const n=r=>g1({...t,...y1(r)});return{...n(e),create:n}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Dl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Pl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),_1=BigInt(0),E1=BigInt(1),$a=BigInt(2),Fl=(t,e)=>(t+e/$a)/e;function w1(t){const e=Dl,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,S=Ke(g,n,e)*g%e,I=Ke(S,n,e)*g%e,N=Ke(I,$a,e)*m%e,P=Ke(N,s,e)*N%e,M=Ke(P,i,e)*P%e,B=Ke(M,a,e)*M%e,K=Ke(B,d,e)*B%e,Y=Ke(K,a,e)*M%e,j=Ke(Y,n,e)*g%e,U=Ke(j,o,e)*P%e,V=Ke(U,r,e)*m%e,J=Ke(V,$a,e);if(!za.eql(za.sqr(J),t))throw new Error("Cannot find square root");return J}const za=Cs(Dl,void 0,void 0,{sqrt:w1}),ja=b1({a:_1,b:BigInt(7),Fp:za,n:Pl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Pl,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-E1*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),a=Fl(i*t,e),d=Fl(-r*t,e);let m=Ve(t-a*n-d*s,e),g=Ve(-a*r-d*i,e);const S=m>o,I=g>o;if(S&&(m=e-m),I&&(g=e-g),m>o||g>o)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:S,k1:m,k2neg:I,k2:g}}}},ll),v1=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:ja},Symbol.toStringTag,{value:"Module"}));class $l extends de{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 Va extends de{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 Ha=new is(128);async function zl(t,e){const{account:n=t.account,chain:r=t.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:S,maxPriorityFeePerGas:I,nonce:N,type:P,value:M,...B}=e;if(typeof n>"u")throw new $l({docsPath:"/docs/actions/wallet/sendTransaction"});const K=n?wn(n):null;try{Ai(e);const Y=await(async()=>{if(e.to)return e.to;if(e.to!==null&&i&&i.length>0)return await nl({authorization:i[0]}).catch(()=>{throw new de("`to` is required. Could not infer from `authorizationList`.")})})();if(K?.type==="json-rpc"||K===null){let j;r!==null&&(j=await It(t,Ia,"getChainId")({}),Qy({currentChainId:j,chain:r}));const U=t.chain?.formatters?.transactionRequest?.format,J=(U||Aa)({...Ra(B,{format:U}),accessList:s,account:K,authorizationList:i,blobs:o,chainId:j,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:S,maxPriorityFeePerGas:I,nonce:N,to:Y,type:P,value:M},"sendTransaction"),ne=Ha.get(t.uid),te=ne?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:te,params:[J]},{retryCount:0})}catch(z){if(ne===!1)throw z;const C=z;if(C.name==="InvalidInputRpcError"||C.name==="InvalidParamsRpcError"||C.name==="MethodNotFoundRpcError"||C.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[J]},{retryCount:0}).then(F=>(Ha.set(t.uid,!0),F)).catch(F=>{const q=F;throw q.name==="MethodNotFoundRpcError"||q.name==="MethodNotSupportedRpcError"?(Ha.set(t.uid,!1),C):q});throw C}}if(K?.type==="local"){const j=await It(t,_l,"prepareTransactionRequest")({account:K,accessList:s,authorizationList:i,blobs:o,chain:r,data:a,gas:d,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:S,maxPriorityFeePerGas:I,nonce:N,nonceManager:K.nonceManager,parameters:[...yl,"sidecars"],type:P,value:M,...B,to:Y}),U=r?.serializers?.transaction,V=await K.signTransaction(j,{serializer:U});return await It(t,R1,"sendRawTransaction")({serializedTransaction:V})}throw K?.type==="smart"?new Va({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new Va({docsPath:"/docs/actions/wallet/sendTransaction",type:K?.type})}catch(Y){throw Y instanceof Va?Y:gl(Y,{...e,account:K,chain:e.chain||void 0})}}async function xi(t,e){return xi.internal(t,zl,"sendTransaction",e)}(function(t){async function e(n,r,s,i){const{abi:o,account:a=n.account,address:d,args:m,dataSuffix:g,functionName:S,...I}=i;if(typeof a>"u")throw new $l({docsPath:"/docs/contract/writeContract"});const N=a?wn(a):null,P=Lg({abi:o,args:m,functionName:S});try{return await It(n,r,s)({data:`${P}${g?g.replace("0x",""):""}`,to:d,account:N,...I})}catch(M){throw ry(M,{abi:o,address:d,args:m,docsPath:"/docs/contract/writeContract",functionName:S,sender:N?.address})}}t.internal=e})(xi||(xi={}));function jl(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.0",S1=()=>`@wagmi/core@${A1}`;var Vl=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)},Ti,Hl;let or=class Au extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return S1()}constructor(e,n={}){super(),Ti.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 Au?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Au&&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 Vl(this,Ti,"m",Hl).call(this,this,e)}};Ti=new WeakSet,Hl=function t(e,n){return n?.(e)?e:e.cause?Vl(this,Ti,"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 x1 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 I1 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 O1 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 x1;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 Ga=256;let Ii=Ga,Oi;function ql(t=11){if(!Oi||Ii+t>Ga*2){Oi="",Ii=0;for(let e=0;e<Ga;e++)Oi+=(256+Math.random()*256|0).toString(16).substring(1)}return Oi.substring(Ii,Ii+++t)}function M1(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,S=t.cacheTime??g,I=t.account?wn(t.account):void 0,{config:N,request:P,value:M}=t.transport({account:I,chain:n,pollingInterval:g}),B={...N,...M},K={account:I,batch:e,cacheTime:S,ccipRead:r,chain:n,key:s,name:i,pollingInterval:g,request:P,transport:B,type:o,uid:ql(),...a?{experimental_blockTag:a}:{}};function Y(j){return U=>{const V=U(j);for(const ne in K)delete V[ne];const J={...j,...V};return Object.assign(J,{extend:Y(J)})}}return Object.assign(K,{extend:Y(K)})}function k1({key:t,methods:e,name:n,request:r,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},d){const m=ql();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 B1(t,e={}){const{key:n="custom",methods:r,name:s="Custom Provider",retryDelay:i}=e;return({retryCount:o})=>k1({key:n,methods:r,name:s,request:t.request.bind(t),retryCount:e.retryCount??o,retryDelay:i,type:"custom"})}async function Kl(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[S,I]=await Promise.all([g.getAccounts().catch(N=>{if(e.account===null)return[];throw N}),g.getChainId()]);r={accounts:S,chainId:I,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 O1({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=fi(a.address)),e.account&&!r.accounts.some(g=>g.toLowerCase()===a.address.toLowerCase()))throw new I1({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=>B1(m)({...g,retryCount:0})})}async function U1(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)}}function qa(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){if(t.constructor!==e.constructor)return!1;let n,r;if(Array.isArray(t)&&Array.isArray(e)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!qa(t[r],e[r]))return!1;return!0}if(typeof t.valueOf=="function"&&t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!Object.hasOwn(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(i&&!qa(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}let Ka=[];function L1(t){const e=t.chains;return qa(Ka,e)?Ka:(Ka=e,e)}async function D1(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 Kl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await jl(o,zl,"sendTransaction")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a,gas:i.gas??void 0})}class P1 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 F1(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 P1({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 $1(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 Kl(t,{account:n??void 0,assertChainId:!1,chainId:r,connector:s});const a=!r||o.chain?.id===r?o.chain:{id:r};return await jl(o,xi,"writeContract")({...i,...n?{account:n}:{},assertChainId:!!r,chain:a})}function qT(t){return t}function Wa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Za(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 Ya={exports:{}},Wl;function z1(){return Wl||(Wl=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,S,I){if(typeof g!="function")throw new TypeError("The listener must be a function");var N=new s(g,S||d,I),P=n?n+m:m;return d._events[P]?d._events[P].fn?d._events[P]=[d._events[P],N]:d._events[P].push(N):(d._events[P]=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,S;if(this._eventsCount===0)return m;for(S in g=this._events)e.call(g,S)&&m.push(n?S.slice(1):S);return Object.getOwnPropertySymbols?m.concat(Object.getOwnPropertySymbols(g)):m},a.prototype.listeners=function(m){var g=n?n+m:m,S=this._events[g];if(!S)return[];if(S.fn)return[S.fn];for(var I=0,N=S.length,P=new Array(N);I<N;I++)P[I]=S[I].fn;return P},a.prototype.listenerCount=function(m){var g=n?n+m:m,S=this._events[g];return S?S.fn?1:S.length:0},a.prototype.emit=function(m,g,S,I,N,P){var M=n?n+m:m;if(!this._events[M])return!1;var B=this._events[M],K=arguments.length,Y,j;if(B.fn){switch(B.once&&this.removeListener(m,B.fn,void 0,!0),K){case 1:return B.fn.call(B.context),!0;case 2:return B.fn.call(B.context,g),!0;case 3:return B.fn.call(B.context,g,S),!0;case 4:return B.fn.call(B.context,g,S,I),!0;case 5:return B.fn.call(B.context,g,S,I,N),!0;case 6:return B.fn.call(B.context,g,S,I,N,P),!0}for(j=1,Y=new Array(K-1);j<K;j++)Y[j-1]=arguments[j];B.fn.apply(B.context,Y)}else{var U=B.length,V;for(j=0;j<U;j++)switch(B[j].once&&this.removeListener(m,B[j].fn,void 0,!0),K){case 1:B[j].fn.call(B[j].context);break;case 2:B[j].fn.call(B[j].context,g);break;case 3:B[j].fn.call(B[j].context,g,S);break;case 4:B[j].fn.call(B[j].context,g,S,I);break;default:if(!Y)for(V=1,Y=new Array(K-1);V<K;V++)Y[V-1]=arguments[V];B[j].fn.apply(B[j].context,Y)}}return!0},a.prototype.on=function(m,g,S){return i(this,m,g,S,!1)},a.prototype.once=function(m,g,S){return i(this,m,g,S,!0)},a.prototype.removeListener=function(m,g,S,I){var N=n?n+m:m;if(!this._events[N])return this;if(!g)return o(this,N),this;var P=this._events[N];if(P.fn)P.fn===g&&(!I||P.once)&&(!S||P.context===S)&&o(this,N);else{for(var M=0,B=[],K=P.length;M<K;M++)(P[M].fn!==g||I&&!P[M].once||S&&P[M].context!==S)&&B.push(P[M]);B.length?this._events[N]=B.length===1?B[0]:B: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})(Ya)),Ya.exports}var j1=z1();const Zl=Wa(j1);let kr=class extends Error{name="BaseError";cause;constructor(e,n={}){super(e,n.cause?{cause:n.cause}:void 0),this.cause=n.cause}};class V1 extends kr{name="AddMiniApp.InvalidDomainManifest";constructor(){super("Invalid domain manifest")}}let H1=class extends kr{name="AddMiniApp.RejectedByUser";constructor(){super("Add miniapp rejected by user")}},Yl=class extends kr{name="SignIn.RejectedByUser";constructor(){super("Sign in rejected by user")}};class G1 extends kr{name="SignManifest.RejectedByUser";constructor(){super("Sign manifest rejected by user")}}class q1 extends kr{name="SignManifest.InvalidDomain";constructor(){super("Invalid domain provided")}}class K1 extends kr{name="SignManifest.GenericError";constructor(e="Manifest signing failed"){super(e)}}var Ce;(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})(Ce||(Ce={}));var Jl;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Jl||(Jl={}));const le=Ce.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jn=t=>{switch(typeof t){case"undefined":return le.undefined;case"string":return le.string;case"number":return Number.isNaN(t)?le.nan:le.number;case"boolean":return le.boolean;case"function":return le.function;case"bigint":return le.bigint;case"symbol":return le.symbol;case"object":return Array.isArray(t)?le.array:t===null?le.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?le.promise:typeof Map<"u"&&t instanceof Map?le.map:typeof Set<"u"&&t instanceof Set?le.set:typeof Date<"u"&&t instanceof Date?le.date:le.object;default:return le.unknown}},re=Ce.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 Sn 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 Sn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ce.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()}}Sn.create=t=>new Sn(t);const Ja=(t,e)=>{let n;switch(t.code){case re.invalid_type:t.received===le.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case re.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ce.jsonStringifyReplacer)}`;break;case re.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ce.joinValues(t.keys,", ")}`;break;case re.invalid_union:n="Invalid input";break;case re.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ce.joinValues(t.options)}`;break;case re.invalid_enum_value:n=`Invalid enum value. Expected ${Ce.joinValues(t.options)}, received '${t.received}'`;break;case re.invalid_arguments:n="Invalid function arguments";break;case re.invalid_return_type:n="Invalid function return type";break;case re.invalid_date:n="Invalid date";break;case re.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}"`:Ce.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case re.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 re.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 re.custom:n="Invalid input";break;case re.invalid_intersection_types:n="Intersection results could not be merged";break;case re.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case re.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ce.assertNever(t)}return{message:n}};let W1=Ja;function Z1(){return W1}const Y1=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 oe(t,e){const n=Z1(),r=Y1({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Ja?void 0:Ja].filter(s=>!!s)});t.common.issues.push(r)}class Zt{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 me;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 Zt.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 me;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 me=Object.freeze({status:"aborted"}),Ms=t=>({status:"dirty",value:t}),tn=t=>({status:"valid",value:t}),Xl=t=>t.status==="aborted",Ql=t=>t.status==="dirty",Br=t=>t.status==="valid",Ni=t=>typeof Promise<"u"&&t instanceof Promise;var fe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(fe||(fe={}));class Vn{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 ef=(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 Sn(t.common.issues);return this._error=n,this._error}}};function Se(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 jn(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Zt,ctx:{common:e.parent.common,data:e.data,parsedType:jn(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:jn(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ef(r,s)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(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:jn(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Ni(s)?s:Promise.resolve(s));return ef(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:re.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:ge.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 ln.create(this)}promise(){return Ui.create(this,this._def)}or(e){return Mi.create([this,e],this._def)}and(e){return ki.create(this,e,this._def)}transform(e){return new ur({...Se(this._def),schema:this,typeName:ge.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Li({...Se(this._def),innerType:this,defaultValue:n,typeName:ge.ZodDefault})}brand(){return new lf({typeName:ge.ZodBranded,type:this,...Se(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Di({...Se(this._def),innerType:this,catchValue:n,typeName:ge.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return oc.create(this,e)}readonly(){return Pi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const J1=/^c[^\s-]{8,}$/i,X1=/^[0-9a-z]+$/,Q1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,eb=/^[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,tb=/^[a-z0-9_-]{21}$/i,nb=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rb=/^[-+]?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)?)??$/,sb=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ib="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Xa;const ob=/^(?:(?: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])$/,ab=/^(?:(?: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])$/,cb=/^(([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]))$/,ub=/^(([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])$/,db=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lb=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tf="((\\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])))",fb=new RegExp(`^${tf}$`);function nf(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 hb(t){return new RegExp(`^${nf(t)}$`)}function pb(t){let e=`${tf}T${nf(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 mb(t,e){return!!((e==="v4"||!e)&&ob.test(t)||(e==="v6"||!e)&&cb.test(t))}function gb(t,e){if(!nb.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 yb(t,e){return!!((e==="v4"||!e)&&ab.test(t)||(e==="v6"||!e)&&ub.test(t))}class Hn extends Oe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==le.string){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:le.string,received:i.parsedType}),me}const r=new Zt;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.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),oe(s,{code:re.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?oe(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&oe(s,{code:re.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")sb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"email",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Xa||(Xa=new RegExp(ib,"u")),Xa.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"emoji",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")eb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"uuid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")tb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"nanoid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")J1.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"cuid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")X1.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"cuid2",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")Q1.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"ulid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),oe(s,{validation:"url",code:re.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),oe(s,{validation:"regex",code:re.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),oe(s,{code:re.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),oe(s,{code:re.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?pb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?fb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?hb(i).test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{code:re.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?rb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"duration",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?mb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"ip",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?gb(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"jwt",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?yb(e.data,i.version)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"cidr",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?db.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"base64",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?lb.test(e.data)||(s=this._getOrReturnCtx(e,s),oe(s,{validation:"base64url",code:re.invalid_string,message:i.message}),r.dirty()):Ce.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:re.invalid_string,...fe.errToObj(r)})}_addCheck(e){return new Hn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...fe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...fe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...fe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...fe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...fe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...fe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...fe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...fe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...fe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...fe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...fe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...fe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...fe.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,...fe.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,...fe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...fe.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...fe.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...fe.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...fe.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...fe.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...fe.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...fe.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...fe.errToObj(n)})}nonempty(e){return this.min(1,fe.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:ge.ZodString,coerce:t?.coerce??!1,...Se(t)});function bb(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 Ur 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)!==le.number){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:le.number,received:i.parsedType}),me}let r;const s=new Zt;for(const i of this._def.checks)i.kind==="int"?Ce.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),oe(r,{code:re.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),oe(r,{code:re.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),oe(r,{code:re.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?bb(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),oe(r,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),oe(r,{code:re.not_finite,message:i.message}),s.dirty()):Ce.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,fe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,fe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,fe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,fe.toString(n))}setLimit(e,n,r,s){return new Ur({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:fe.toString(s)}]})}_addCheck(e){return new Ur({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:fe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:fe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:fe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:fe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:fe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:fe.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:fe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:fe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:fe.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"&&Ce.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)}}Ur.create=t=>new Ur({checks:[],typeName:ge.ZodNumber,coerce:t?.coerce||!1,...Se(t)});class ks 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)!==le.bigint)return this._getInvalidInput(e);let r;const s=new Zt;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),oe(r,{code:re.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),oe(r,{code:re.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),oe(r,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ce.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return oe(n,{code:re.invalid_type,expected:le.bigint,received:n.parsedType}),me}gte(e,n){return this.setLimit("min",e,!0,fe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,fe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,fe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,fe.toString(n))}setLimit(e,n,r,s){return new ks({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:fe.toString(s)}]})}_addCheck(e){return new ks({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:fe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:fe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:fe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:fe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:fe.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}}ks.create=t=>new ks({checks:[],typeName:ge.ZodBigInt,coerce:t?.coerce??!1,...Se(t)});class Qa extends Oe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==le.boolean){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.boolean,received:r.parsedType}),me}return tn(e.data)}}Qa.create=t=>new Qa({typeName:ge.ZodBoolean,coerce:t?.coerce||!1,...Se(t)});class Ci extends Oe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==le.date){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_type,expected:le.date,received:i.parsedType}),me}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return oe(i,{code:re.invalid_date}),me}const r=new Zt;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),oe(s,{code:re.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),oe(s,{code:re.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ce.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:fe.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:fe.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:ge.ZodDate,...Se(t)});class rf extends Oe{_parse(e){if(this._getType(e)!==le.symbol){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.symbol,received:r.parsedType}),me}return tn(e.data)}}rf.create=t=>new rf({typeName:ge.ZodSymbol,...Se(t)});class ec extends Oe{_parse(e){if(this._getType(e)!==le.undefined){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.undefined,received:r.parsedType}),me}return tn(e.data)}}ec.create=t=>new ec({typeName:ge.ZodUndefined,...Se(t)});class tc extends Oe{_parse(e){if(this._getType(e)!==le.null){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.null,received:r.parsedType}),me}return tn(e.data)}}tc.create=t=>new tc({typeName:ge.ZodNull,...Se(t)});class sf extends Oe{constructor(){super(...arguments),this._any=!0}_parse(e){return tn(e.data)}}sf.create=t=>new sf({typeName:ge.ZodAny,...Se(t)});class of extends Oe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return tn(e.data)}}of.create=t=>new of({typeName:ge.ZodUnknown,...Se(t)});class Gn extends Oe{_parse(e){const n=this._getOrReturnCtx(e);return oe(n,{code:re.invalid_type,expected:le.never,received:n.parsedType}),me}}Gn.create=t=>new Gn({typeName:ge.ZodNever,...Se(t)});class af extends Oe{_parse(e){if(this._getType(e)!==le.undefined){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.void,received:r.parsedType}),me}return tn(e.data)}}af.create=t=>new af({typeName:ge.ZodVoid,...Se(t)});class ln extends Oe{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==le.array)return oe(n,{code:re.invalid_type,expected:le.array,received:n.parsedType}),me;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(oe(n,{code:o?re.too_big:re.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&&(oe(n,{code:re.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&&(oe(n,{code:re.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 Vn(n,o,n.path,a)))).then(o=>Zt.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new Vn(n,o,n.path,a)));return Zt.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new ln({...this._def,minLength:{value:e,message:fe.toString(n)}})}max(e,n){return new ln({...this._def,maxLength:{value:e,message:fe.toString(n)}})}length(e,n){return new ln({...this._def,exactLength:{value:e,message:fe.toString(n)}})}nonempty(e){return this.min(1,e)}}ln.create=(t,e)=>new ln({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ge.ZodArray,...Se(e)});function Lr(t){if(t instanceof tt){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Tn.create(Lr(r))}return new tt({...t._def,shape:()=>e})}else return t instanceof ln?new ln({...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 tt 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=Ce.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==le.object){const m=this._getOrReturnCtx(e);return oe(m,{code:re.invalid_type,expected:le.object,received:m.parsedType}),me}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Gn&&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],S=s.data[m];d.push({key:{status:"valid",value:m},value:g._parse(new Vn(s,S,s.path,m)),alwaysSet:m in s.data})}if(this._def.catchall instanceof Gn){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&&(oe(s,{code:re.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 S=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new Vn(s,S,s.path,g)),alwaysSet:g in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const m=[];for(const g of d){const S=await g.key,I=await g.value;m.push({key:S,value:I,alwaysSet:g.alwaysSet})}return m}).then(m=>Zt.mergeObjectSync(r,m)):Zt.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return fe.errToObj,new tt({...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:fe.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new tt({...this._def,unknownKeys:"strip"})}passthrough(){return new tt({...this._def,unknownKeys:"passthrough"})}extend(e){return new tt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new tt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ge.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new tt({...this._def,catchall:e})}pick(e){const n={};for(const r of Ce.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new tt({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ce.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new tt({...this._def,shape:()=>n})}deepPartial(){return Lr(this)}partial(e){const n={};for(const r of Ce.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new tt({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ce.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 tt({...this._def,shape:()=>n})}keyof(){return uf(Ce.objectKeys(this.shape))}}tt.create=(t,e)=>new tt({shape:()=>t,unknownKeys:"strip",catchall:Gn.create(),typeName:ge.ZodObject,...Se(e)}),tt.strictCreate=(t,e)=>new tt({shape:()=>t,unknownKeys:"strict",catchall:Gn.create(),typeName:ge.ZodObject,...Se(e)}),tt.lazycreate=(t,e)=>new tt({shape:t,unknownKeys:"strip",catchall:Gn.create(),typeName:ge.ZodObject,...Se(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 Sn(a.ctx.common.issues));return oe(n,{code:re.invalid_union,unionErrors:o}),me}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 Sn(d));return oe(n,{code:re.invalid_union,unionErrors:a}),me}}get options(){return this._def.options}}Mi.create=(t,e)=>new Mi({options:t,typeName:ge.ZodUnion,...Se(e)});const xn=t=>t instanceof sc?xn(t.schema):t instanceof ur?xn(t.innerType()):t instanceof Bi?[t.value]:t instanceof cr?t.options:t instanceof ic?Ce.objectValues(t.enum):t instanceof Li?xn(t._def.innerType):t instanceof ec?[void 0]:t instanceof tc?[null]:t instanceof Tn?[void 0,...xn(t.unwrap())]:t instanceof dr?[null,...xn(t.unwrap())]:t instanceof lf||t instanceof Pi?xn(t.unwrap()):t instanceof Di?xn(t._def.innerType):[];class nc extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==le.object)return oe(n,{code:re.invalid_type,expected:le.object,received:n.parsedType}),me;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}):(oe(n,{code:re.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),me)}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 nc({typeName:ge.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Se(r)})}}function rc(t,e){const n=jn(t),r=jn(e);if(t===e)return{valid:!0,data:t};if(n===le.object&&r===le.object){const s=Ce.objectKeys(e),i=Ce.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const d=rc(t[a],e[a]);if(!d.valid)return{valid:!1};o[a]=d.data}return{valid:!0,data:o}}else if(n===le.array&&r===le.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=rc(o,a);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return n===le.date&&r===le.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ki extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Xl(i)||Xl(o))return me;const a=rc(i.value,o.value);return a.valid?((Ql(i)||Ql(o))&&n.dirty(),{status:n.value,value:a.data}):(oe(r,{code:re.invalid_intersection_types}),me)};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}))}}ki.create=(t,e,n)=>new ki({left:t,right:e,typeName:ge.ZodIntersection,...Se(n)});class ar extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==le.array)return oe(r,{code:re.invalid_type,expected:le.array,received:r.parsedType}),me;if(r.data.length<this._def.items.length)return oe(r,{code:re.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),me;!this._def.rest&&r.data.length>this._def.items.length&&(oe(r,{code:re.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 Vn(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Zt.mergeArray(n,o)):Zt.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:ge.ZodTuple,rest:null,...Se(e)})};class cf 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!==le.map)return oe(r,{code:re.invalid_type,expected:le.map,received:r.parsedType}),me;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,d],m)=>({key:s._parse(new Vn(r,a,r.path,[m,"key"])),value:i._parse(new Vn(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 me;(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 me;(m.status==="dirty"||g.status==="dirty")&&n.dirty(),a.set(m.value,g.value)}return{status:n.value,value:a}}}}cf.create=(t,e,n)=>new cf({valueType:e,keyType:t,typeName:ge.ZodMap,...Se(n)});class Bs extends Oe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==le.set)return oe(r,{code:re.invalid_type,expected:le.set,received:r.parsedType}),me;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(oe(r,{code:re.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&&(oe(r,{code:re.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 me;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 Vn(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:fe.toString(n)}})}max(e,n){return new Bs({...this._def,maxSize:{value:e,message:fe.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:ge.ZodSet,...Se(e)});class sc 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})}}sc.create=(t,e)=>new sc({getter:t,typeName:ge.ZodLazy,...Se(e)});class Bi extends Oe{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return oe(n,{received:n.data,code:re.invalid_literal,expected:this._def.value}),me}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bi.create=(t,e)=>new Bi({value:t,typeName:ge.ZodLiteral,...Se(e)});function uf(t,e){return new cr({values:t,typeName:ge.ZodEnum,...Se(e)})}class cr extends Oe{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return oe(n,{expected:Ce.joinValues(r),received:n.parsedType,code:re.invalid_type}),me}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 oe(n,{received:n.data,code:re.invalid_enum_value,options:r}),me}return tn(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=uf;class ic extends Oe{_parse(e){const n=Ce.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==le.string&&r.parsedType!==le.number){const s=Ce.objectValues(n);return oe(r,{expected:Ce.joinValues(s),received:r.parsedType,code:re.invalid_type}),me}if(this._cache||(this._cache=new Set(Ce.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ce.objectValues(n);return oe(r,{received:r.data,code:re.invalid_enum_value,options:s}),me}return tn(e.data)}get enum(){return this._def.values}}ic.create=(t,e)=>new ic({values:t,typeName:ge.ZodNativeEnum,...Se(e)});class Ui extends Oe{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==le.promise&&n.common.async===!1)return oe(n,{code:re.invalid_type,expected:le.promise,received:n.parsedType}),me;const r=n.parsedType===le.promise?n.data:Promise.resolve(n.data);return tn(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Ui.create=(t,e)=>new Ui({type:t,typeName:ge.ZodPromise,...Se(e)});class ur extends Oe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ge.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=>{oe(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 me;const d=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return d.status==="aborted"?me:d.status==="dirty"||n.value==="dirty"?Ms(d.value):d});{if(n.value==="aborted")return me;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?me:a.status==="dirty"||n.value==="dirty"?Ms(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"?me:(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"?me:(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 me;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})):me);Ce.assertNever(s)}}ur.create=(t,e,n)=>new ur({schema:t,typeName:ge.ZodEffects,effect:e,...Se(n)}),ur.createWithPreprocess=(t,e,n)=>new ur({schema:e,effect:{type:"preprocess",transform:t},typeName:ge.ZodEffects,...Se(n)});class Tn extends Oe{_parse(e){return this._getType(e)===le.undefined?tn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Tn.create=(t,e)=>new Tn({innerType:t,typeName:ge.ZodOptional,...Se(e)});class dr extends Oe{_parse(e){return this._getType(e)===le.null?tn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}dr.create=(t,e)=>new dr({innerType:t,typeName:ge.ZodNullable,...Se(e)});class Li extends Oe{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===le.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Li.create=(t,e)=>new Li({innerType:t,typeName:ge.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Se(e)});class Di 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 Sn(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Sn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Di.create=(t,e)=>new Di({innerType:t,typeName:ge.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Se(e)});class df extends Oe{_parse(e){if(this._getType(e)!==le.nan){const r=this._getOrReturnCtx(e);return oe(r,{code:re.invalid_type,expected:le.nan,received:r.parsedType}),me}return{status:"valid",value:e.data}}}df.create=t=>new df({typeName:ge.ZodNaN,...Se(t)});class lf 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 oc 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"?me:i.status==="dirty"?(n.dirty(),Ms(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"?me: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 oc({in:e,out:n,typeName:ge.ZodPipeline})}}class Pi 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}}Pi.create=(t,e)=>new Pi({innerType:t,typeName:ge.ZodReadonly,...Se(e)});var ge;(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"})(ge||(ge={}));const We=Hn.create,ff=Ur.create,_b=Qa.create;Gn.create;const lr=ln.create,St=tt.create,Fi=Mi.create,hf=nc.create;ki.create,ar.create;const Nt=Bi.create,ac=cr.create;Ui.create,Tn.create,dr.create;const Eb=/[@#$%^&*+=/\\|~«»]/,wb=/(!{2,}|\?{2,}|-{2,})/,vb=/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u,Dr=({max:t,noSpaces:e}={})=>(e?We().max(t??Number.POSITIVE_INFINITY).regex(/^\S*$/,"Spaces are not allowed"):We().max(t??Number.POSITIVE_INFINITY)).refine(r=>!vb.test(r),{message:"Emojis and symbols are not allowed"}).refine(r=>!Eb.test(r),{message:"Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed"}).refine(r=>!wb.test(r),{message:"Repeated punctuations (!!, ??, --) are not allowed"}),Pt=We().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"}),cc=We().max(32),pf=We().max(32),Rb=/^[-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)$/,Ab=We().regex(Rb,{message:"Invalid CAIP-19 asset ID"}),uc=We().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i,{message:"Invalid hex color code. It should be in the format #RRGGBB or #RGB."}),Sb=/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,xb=We().max(1024).regex(Sb,{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"}),Tb=Fi([Nt("1:1"),Nt("3:2")]),Ib=St({header:We(),payload:We(),signature:We()});St({fid:ff(),type:Nt("app_key"),key:We().startsWith("0x")});const Ob=St({type:Nt("launch_frame"),name:cc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:uc.optional()}),Nb=St({type:Nt("launch_miniapp"),name:cc,url:Pt.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:uc.optional()}),Cb=St({type:Nt("view_token"),token:Ab}),Mb=hf("type",[Nb,Cb,Ob]),kb=St({title:pf,action:Mb});St({version:Fi([We(),ff()]).transform(t=>String(t)).pipe(Fi([Nt("next"),Nt("1")])),imageUrl:Pt,aspectRatio:Tb.optional(),button:kb});const mf=St({url:We(),token:We()});St({notificationId:We().max(128),title:We().max(32),body:We().max(128),targetUrl:Pt,tokens:We().array().max(100)}),St({result:St({successfulTokens:lr(We()),invalidTokens:lr(We()),rateLimitedTokens:lr(We())})});const Bb=St({event:Nt("miniapp_added"),notificationDetails:mf.optional()}),Ub=St({event:Nt("miniapp_removed")}),Lb=St({event:Nt("notifications_enabled"),notificationDetails:mf.required()}),Db=St({event:Nt("notifications_disabled")});hf("event",[Bb,Ub,Lb,Db]);const Pb=["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"],Fb=ac(["games","social","finance","utility","productivity","health-fitness","news-media","music","shopping","education","developer-tools","entertainment","art-creativity"]),$b=Fi([Nt("0.0.0"),Nt("0.0.1"),Nt("1"),Nt("next")]),zb=Dr({max:30}),jb=Dr({max:170}),Vb=lr(Pt).max(3),Hb=lr(Dr({max:20,noSpaces:!0})).max(5),Gb=Dr({max:30}),qb=Dr({max:30}),Kb=Dr({max:100}),Wb=_b(),Zb=["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 gf(t){const e=new Set(t);return Array.from(e)}const Yb=lr(ac(Zb)).transform(gf),Jb=lr(ac(Pb)).transform(gf),yf=St({version:$b,name:cc,iconUrl:Pt,homeUrl:Pt,imageUrl:Pt.optional(),buttonTitle:pf.optional(),splashImageUrl:Pt.optional(),splashBackgroundColor:uc.optional(),webhookUrl:Pt.optional(),subtitle:zb.optional(),description:jb.optional(),screenshotUrls:Vb.optional(),primaryCategory:Fb.optional(),tags:Hb.optional(),heroImageUrl:Pt.optional(),tagline:Gb.optional(),ogTitle:qb.optional(),ogDescription:Kb.optional(),ogImageUrl:Pt.optional(),noindex:Wb.optional(),requiredChains:Yb.optional(),requiredCapabilities:Jb.optional(),castShareUrl:Pt.optional(),canonicalDomain:xb.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"]});St({accountAssociation:Ib,miniapp:yf.optional(),frame:yf.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 dc={},Us={},bf;function Xb(){if(bf)return Us;bf=1,Us.byteLength=a,Us.toByteArray=m,Us.fromByteArray=I;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 P=N.length;if(P%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var M=N.indexOf("=");M===-1&&(M=P);var B=M===P?0:4-M%4;return[M,B]}function a(N){var P=o(N),M=P[0],B=P[1];return(M+B)*3/4-B}function d(N,P,M){return(P+M)*3/4-M}function m(N){var P,M=o(N),B=M[0],K=M[1],Y=new n(d(N,B,K)),j=0,U=K>0?B-4:B,V;for(V=0;V<U;V+=4)P=e[N.charCodeAt(V)]<<18|e[N.charCodeAt(V+1)]<<12|e[N.charCodeAt(V+2)]<<6|e[N.charCodeAt(V+3)],Y[j++]=P>>16&255,Y[j++]=P>>8&255,Y[j++]=P&255;return K===2&&(P=e[N.charCodeAt(V)]<<2|e[N.charCodeAt(V+1)]>>4,Y[j++]=P&255),K===1&&(P=e[N.charCodeAt(V)]<<10|e[N.charCodeAt(V+1)]<<4|e[N.charCodeAt(V+2)]>>2,Y[j++]=P>>8&255,Y[j++]=P&255),Y}function g(N){return t[N>>18&63]+t[N>>12&63]+t[N>>6&63]+t[N&63]}function S(N,P,M){for(var B,K=[],Y=P;Y<M;Y+=3)B=(N[Y]<<16&16711680)+(N[Y+1]<<8&65280)+(N[Y+2]&255),K.push(g(B));return K.join("")}function I(N){for(var P,M=N.length,B=M%3,K=[],Y=16383,j=0,U=M-B;j<U;j+=Y)K.push(S(N,j,j+Y>U?U:j+Y));return B===1?(P=N[M-1],K.push(t[P>>2]+t[P<<4&63]+"==")):B===2&&(P=(N[M-2]<<8)+N[M-1],K.push(t[P>>10]+t[P>>4&63]+t[P<<2&63]+"=")),K.join("")}return Us}var $i={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var _f;function Qb(){return _f||(_f=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,S=n?s-1:0,I=n?-1:1,N=t[e+S];for(S+=I,i=N&(1<<-g)-1,N>>=-g,g+=a;g>0;i=i*256+t[e+S],S+=I,g-=8);for(o=i&(1<<-g)-1,i>>=-g,g+=r;g>0;o=o*256+t[e+S],S+=I,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)},$i.write=function(t,e,n,r,s,i){var o,a,d,m=i*8-s-1,g=(1<<m)-1,S=g>>1,I=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,N=r?0:i-1,P=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+S>=1?e+=I/d:e+=I*Math.pow(2,1-S),e*d>=2&&(o++,d/=2),o+S>=g?(a=0,o=g):o+S>=1?(a=(e*d-1)*Math.pow(2,s),o=o+S):(a=e*Math.pow(2,S-1)*Math.pow(2,s),o=0));s>=8;t[n+N]=a&255,N+=P,a/=256,s-=8);for(o=o<<s|a,m+=s;m>0;t[n+N]=o&255,N+=P,o/=256,m-=8);t[n+N-P]|=M*128}),$i}/*!
|
|
24
|
+
* The buffer module from node.js, for the browser.
|
|
25
|
+
*
|
|
26
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
27
|
+
* @license MIT
|
|
28
|
+
*/var Ef;function lc(){return Ef||(Ef=1,(function(t){const e=Xb(),n=Qb(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=Y,t.INSPECT_MAX_BYTES=50;const s=2147483647;t.kMaxLength=s,a.TYPED_ARRAY_SUPPORT=i(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function i(){try{const b=new Uint8Array(1),f={foo:function(){return 42}};return Object.setPrototypeOf(f,Uint8Array.prototype),Object.setPrototypeOf(b,f),b.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function o(b){if(b>s)throw new RangeError('The value "'+b+'" is invalid for option "size"');const f=new Uint8Array(b);return Object.setPrototypeOf(f,a.prototype),f}function a(b,f,h){if(typeof b=="number"){if(typeof f=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return S(b)}return d(b,f,h)}a.poolSize=8192;function d(b,f,h){if(typeof b=="string")return I(b,f);if(ArrayBuffer.isView(b))return P(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(Qt(b,ArrayBuffer)||b&&Qt(b.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Qt(b,SharedArrayBuffer)||b&&Qt(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 x=b.valueOf&&b.valueOf();if(x!=null&&x!==b)return a.from(x,f,h);const L=B(b);if(L)return L;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 S(b){return m(b),o(b<0?0:K(b)|0)}a.allocUnsafe=function(b){return S(b)},a.allocUnsafeSlow=function(b){return S(b)};function I(b,f){if((typeof f!="string"||f==="")&&(f="utf8"),!a.isEncoding(f))throw new TypeError("Unknown encoding: "+f);const h=j(b,f)|0;let x=o(h);const L=x.write(b,f);return L!==h&&(x=x.slice(0,L)),x}function N(b){const f=b.length<0?0:K(b.length)|0,h=o(f);for(let x=0;x<f;x+=1)h[x]=b[x]&255;return h}function P(b){if(Qt(b,Uint8Array)){const f=new Uint8Array(b);return M(f.buffer,f.byteOffset,f.byteLength)}return N(b)}function M(b,f,h){if(f<0||b.byteLength<f)throw new RangeError('"offset" is outside of buffer bounds');if(b.byteLength<f+(h||0))throw new RangeError('"length" is outside of buffer bounds');let x;return f===void 0&&h===void 0?x=new Uint8Array(b):h===void 0?x=new Uint8Array(b,f):x=new Uint8Array(b,f,h),Object.setPrototypeOf(x,a.prototype),x}function B(b){if(a.isBuffer(b)){const f=K(b.length)|0,h=o(f);return h.length===0||b.copy(h,0,0,f),h}if(b.length!==void 0)return typeof b.length!="number"||Ge(b.length)?o(0):N(b);if(b.type==="Buffer"&&Array.isArray(b.data))return N(b.data)}function K(b){if(b>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return b|0}function Y(b){return+b!=b&&(b=0),a.alloc(+b)}a.isBuffer=function(f){return f!=null&&f._isBuffer===!0&&f!==a.prototype},a.compare=function(f,h){if(Qt(f,Uint8Array)&&(f=a.from(f,f.offset,f.byteLength)),Qt(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 x=f.length,L=h.length;for(let $=0,Z=Math.min(x,L);$<Z;++$)if(f[$]!==h[$]){x=f[$],L=h[$];break}return x<L?-1:L<x?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 x;if(h===void 0)for(h=0,x=0;x<f.length;++x)h+=f[x].length;const L=a.allocUnsafe(h);let $=0;for(x=0;x<f.length;++x){let Z=f[x];if(Qt(Z,Uint8Array))$+Z.length>L.length?(a.isBuffer(Z)||(Z=a.from(Z)),Z.copy(L,$)):Uint8Array.prototype.set.call(L,Z,$);else if(a.isBuffer(Z))Z.copy(L,$);else throw new TypeError('"list" argument must be an Array of Buffers');$+=Z.length}return L};function j(b,f){if(a.isBuffer(b))return b.length;if(ArrayBuffer.isView(b)||Qt(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,x=arguments.length>2&&arguments[2]===!0;if(!x&&h===0)return 0;let L=!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 $e(b).length;default:if(L)return x?-1:Le(b).length;f=(""+f).toLowerCase(),L=!0}}a.byteLength=j;function U(b,f,h){let x=!1;if((f===void 0||f<0)&&(f=0),f>this.length||((h===void 0||h>this.length)&&(h=this.length),h<=0)||(h>>>=0,f>>>=0,h<=f))return"";for(b||(b="utf8");;)switch(b){case"hex":return R(this,f,h);case"utf8":case"utf-8":return c(this,f,h);case"ascii":return A(this,f,h);case"latin1":case"binary":return v(this,f,h);case"base64":return w(this,f,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return O(this,f,h);default:if(x)throw new TypeError("Unknown encoding: "+b);b=(b+"").toLowerCase(),x=!0}}a.prototype._isBuffer=!0;function V(b,f,h){const x=b[f];b[f]=b[h],b[h]=x}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)V(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)V(this,h,h+3),V(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)V(this,h,h+7),V(this,h+1,h+6),V(this,h+2,h+5),V(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):U.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,x,L,$){if(Qt(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),x===void 0&&(x=f?f.length:0),L===void 0&&(L=0),$===void 0&&($=this.length),h<0||x>f.length||L<0||$>this.length)throw new RangeError("out of range index");if(L>=$&&h>=x)return 0;if(L>=$)return-1;if(h>=x)return 1;if(h>>>=0,x>>>=0,L>>>=0,$>>>=0,this===f)return 0;let Z=$-L,Ae=x-h;const Ee=Math.min(Z,Ae),ye=this.slice(L,$),ze=f.slice(h,x);for(let pe=0;pe<Ee;++pe)if(ye[pe]!==ze[pe]){Z=ye[pe],Ae=ze[pe];break}return Z<Ae?-1:Ae<Z?1:0};function J(b,f,h,x,L){if(b.length===0)return-1;if(typeof h=="string"?(x=h,h=0):h>2147483647?h=2147483647:h<-2147483648&&(h=-2147483648),h=+h,Ge(h)&&(h=L?0:b.length-1),h<0&&(h=b.length+h),h>=b.length){if(L)return-1;h=b.length-1}else if(h<0)if(L)h=0;else return-1;if(typeof f=="string"&&(f=a.from(f,x)),a.isBuffer(f))return f.length===0?-1:ne(b,f,h,x,L);if(typeof f=="number")return f=f&255,typeof Uint8Array.prototype.indexOf=="function"?L?Uint8Array.prototype.indexOf.call(b,f,h):Uint8Array.prototype.lastIndexOf.call(b,f,h):ne(b,[f],h,x,L);throw new TypeError("val must be string, number or Buffer")}function ne(b,f,h,x,L){let $=1,Z=b.length,Ae=f.length;if(x!==void 0&&(x=String(x).toLowerCase(),x==="ucs2"||x==="ucs-2"||x==="utf16le"||x==="utf-16le")){if(b.length<2||f.length<2)return-1;$=2,Z/=2,Ae/=2,h/=2}function Ee(ze,pe){return $===1?ze[pe]:ze.readUInt16BE(pe*$)}let ye;if(L){let ze=-1;for(ye=h;ye<Z;ye++)if(Ee(b,ye)===Ee(f,ze===-1?0:ye-ze)){if(ze===-1&&(ze=ye),ye-ze+1===Ae)return ze*$}else ze!==-1&&(ye-=ye-ze),ze=-1}else for(h+Ae>Z&&(h=Z-Ae),ye=h;ye>=0;ye--){let ze=!0;for(let pe=0;pe<Ae;pe++)if(Ee(b,ye+pe)!==Ee(f,pe)){ze=!1;break}if(ze)return ye}return-1}a.prototype.includes=function(f,h,x){return this.indexOf(f,h,x)!==-1},a.prototype.indexOf=function(f,h,x){return J(this,f,h,x,!0)},a.prototype.lastIndexOf=function(f,h,x){return J(this,f,h,x,!1)};function te(b,f,h,x){h=Number(h)||0;const L=b.length-h;x?(x=Number(x),x>L&&(x=L)):x=L;const $=f.length;x>$/2&&(x=$/2);let Z;for(Z=0;Z<x;++Z){const Ae=parseInt(f.substr(Z*2,2),16);if(Ge(Ae))return Z;b[h+Z]=Ae}return Z}function z(b,f,h,x){return De(Le(f,b.length-h),b,h,x)}function C(b,f,h,x){return De(He(f),b,h,x)}function F(b,f,h,x){return De($e(f),b,h,x)}function q(b,f,h,x){return De(Xr(f,b.length-h),b,h,x)}a.prototype.write=function(f,h,x,L){if(h===void 0)L="utf8",x=this.length,h=0;else if(x===void 0&&typeof h=="string")L=h,x=this.length,h=0;else if(isFinite(h))h=h>>>0,isFinite(x)?(x=x>>>0,L===void 0&&(L="utf8")):(L=x,x=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const $=this.length-h;if((x===void 0||x>$)&&(x=$),f.length>0&&(x<0||h<0)||h>this.length)throw new RangeError("Attempt to write outside buffer bounds");L||(L="utf8");let Z=!1;for(;;)switch(L){case"hex":return te(this,f,h,x);case"utf8":case"utf-8":return z(this,f,h,x);case"ascii":case"latin1":case"binary":return C(this,f,h,x);case"base64":return F(this,f,h,x);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,f,h,x);default:if(Z)throw new TypeError("Unknown encoding: "+L);L=(""+L).toLowerCase(),Z=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function w(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 x=[];let L=f;for(;L<h;){const $=b[L];let Z=null,Ae=$>239?4:$>223?3:$>191?2:1;if(L+Ae<=h){let Ee,ye,ze,pe;switch(Ae){case 1:$<128&&(Z=$);break;case 2:Ee=b[L+1],(Ee&192)===128&&(pe=($&31)<<6|Ee&63,pe>127&&(Z=pe));break;case 3:Ee=b[L+1],ye=b[L+2],(Ee&192)===128&&(ye&192)===128&&(pe=($&15)<<12|(Ee&63)<<6|ye&63,pe>2047&&(pe<55296||pe>57343)&&(Z=pe));break;case 4:Ee=b[L+1],ye=b[L+2],ze=b[L+3],(Ee&192)===128&&(ye&192)===128&&(ze&192)===128&&(pe=($&15)<<18|(Ee&63)<<12|(ye&63)<<6|ze&63,pe>65535&&pe<1114112&&(Z=pe))}}Z===null?(Z=65533,Ae=1):Z>65535&&(Z-=65536,x.push(Z>>>10&1023|55296),Z=56320|Z&1023),x.push(Z),L+=Ae}return y(x)}const p=4096;function y(b){const f=b.length;if(f<=p)return String.fromCharCode.apply(String,b);let h="",x=0;for(;x<f;)h+=String.fromCharCode.apply(String,b.slice(x,x+=p));return h}function A(b,f,h){let x="";h=Math.min(b.length,h);for(let L=f;L<h;++L)x+=String.fromCharCode(b[L]&127);return x}function v(b,f,h){let x="";h=Math.min(b.length,h);for(let L=f;L<h;++L)x+=String.fromCharCode(b[L]);return x}function R(b,f,h){const x=b.length;(!f||f<0)&&(f=0),(!h||h<0||h>x)&&(h=x);let L="";for(let $=f;$<h;++$)L+=Ye[b[$]];return L}function O(b,f,h){const x=b.slice(f,h);let L="";for(let $=0;$<x.length-1;$+=2)L+=String.fromCharCode(x[$]+x[$+1]*256);return L}a.prototype.slice=function(f,h){const x=this.length;f=~~f,h=h===void 0?x:~~h,f<0?(f+=x,f<0&&(f=0)):f>x&&(f=x),h<0?(h+=x,h<0&&(h=0)):h>x&&(h=x),h<f&&(h=f);const L=this.subarray(f,h);return Object.setPrototypeOf(L,a.prototype),L};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,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let L=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)L+=this[f+Z]*$;return L},a.prototype.readUintBE=a.prototype.readUIntBE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let L=this[f+--h],$=1;for(;h>0&&($*=256);)L+=this[f+--h]*$;return L},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=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const L=h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24,$=this[++f]+this[++f]*2**8+this[++f]*2**16+x*2**24;return BigInt(L)+(BigInt($)<<BigInt(32))}),a.prototype.readBigUInt64BE=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const L=h*2**24+this[++f]*2**16+this[++f]*2**8+this[++f],$=this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+x;return(BigInt(L)<<BigInt(32))+BigInt($)}),a.prototype.readIntLE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let L=this[f],$=1,Z=0;for(;++Z<h&&($*=256);)L+=this[f+Z]*$;return $*=128,L>=$&&(L-=Math.pow(2,8*h)),L},a.prototype.readIntBE=function(f,h,x){f=f>>>0,h=h>>>0,x||_(f,h,this.length);let L=h,$=1,Z=this[f+--L];for(;L>0&&($*=256);)Z+=this[f+--L]*$;return $*=128,Z>=$&&(Z-=Math.pow(2,8*h)),Z},a.prototype.readInt8=function(f,h){return f=f>>>0,h||_(f,1,this.length),this[f]&128?(255-this[f]+1)*-1:this[f]},a.prototype.readInt16LE=function(f,h){f=f>>>0,h||_(f,2,this.length);const x=this[f]|this[f+1]<<8;return x&32768?x|4294901760:x},a.prototype.readInt16BE=function(f,h){f=f>>>0,h||_(f,2,this.length);const x=this[f+1]|this[f]<<8;return x&32768?x|4294901760:x},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=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const L=this[f+4]+this[f+5]*2**8+this[f+6]*2**16+(x<<24);return(BigInt(L)<<BigInt(32))+BigInt(h+this[++f]*2**8+this[++f]*2**16+this[++f]*2**24)}),a.prototype.readBigInt64BE=cn(function(f){f=f>>>0,Fe(f,"offset");const h=this[f],x=this[f+7];(h===void 0||x===void 0)&&Re(f,this.length-8);const L=(h<<24)+this[++f]*2**16+this[++f]*2**8+this[++f];return(BigInt(L)<<BigInt(32))+BigInt(this[++f]*2**24+this[++f]*2**16+this[++f]*2**8+x)}),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,x,L,$){if(!a.isBuffer(b))throw new TypeError('"buffer" argument must be a Buffer instance');if(f>L||f<$)throw new RangeError('"value" argument is out of bounds');if(h+x>b.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(f,h,x,L){if(f=+f,h=h>>>0,x=x>>>0,!L){const Ae=Math.pow(2,8*x)-1;u(this,f,h,x,Ae,0)}let $=1,Z=0;for(this[h]=f&255;++Z<x&&($*=256);)this[h+Z]=f/$&255;return h+x},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(f,h,x,L){if(f=+f,h=h>>>0,x=x>>>0,!L){const Ae=Math.pow(2,8*x)-1;u(this,f,h,x,Ae,0)}let $=x-1,Z=1;for(this[h+$]=f&255;--$>=0&&(Z*=256);)this[h+$]=f/Z&255;return h+x},a.prototype.writeUint8=a.prototype.writeUInt8=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,1,255,0),this[h]=f&255,h+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(f,h,x){return f=+f,h=h>>>0,x||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,x){return f=+f,h=h>>>0,x||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,x){return f=+f,h=h>>>0,x||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,x){return f=+f,h=h>>>0,x||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,x,L){we(f,x,L,b,h,7);let $=Number(f&BigInt(4294967295));b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$,$=$>>8,b[h++]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,Z=Z>>8,b[h++]=Z,h}function E(b,f,h,x,L){we(f,x,L,b,h,7);let $=Number(f&BigInt(4294967295));b[h+7]=$,$=$>>8,b[h+6]=$,$=$>>8,b[h+5]=$,$=$>>8,b[h+4]=$;let Z=Number(f>>BigInt(32)&BigInt(4294967295));return b[h+3]=Z,Z=Z>>8,b[h+2]=Z,Z=Z>>8,b[h+1]=Z,Z=Z>>8,b[h]=Z,h+8}a.prototype.writeBigUInt64LE=cn(function(f,h=0){return l(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=cn(function(f,h=0){return E(this,f,h,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(f,h,x,L){if(f=+f,h=h>>>0,!L){const Ee=Math.pow(2,8*x-1);u(this,f,h,x,Ee-1,-Ee)}let $=0,Z=1,Ae=0;for(this[h]=f&255;++$<x&&(Z*=256);)f<0&&Ae===0&&this[h+$-1]!==0&&(Ae=1),this[h+$]=(f/Z>>0)-Ae&255;return h+x},a.prototype.writeIntBE=function(f,h,x,L){if(f=+f,h=h>>>0,!L){const Ee=Math.pow(2,8*x-1);u(this,f,h,x,Ee-1,-Ee)}let $=x-1,Z=1,Ae=0;for(this[h+$]=f&255;--$>=0&&(Z*=256);)f<0&&Ae===0&&this[h+$+1]!==0&&(Ae=1),this[h+$]=(f/Z>>0)-Ae&255;return h+x},a.prototype.writeInt8=function(f,h,x){return f=+f,h=h>>>0,x||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,x){return f=+f,h=h>>>0,x||u(this,f,h,2,32767,-32768),this[h]=f&255,this[h+1]=f>>>8,h+2},a.prototype.writeInt16BE=function(f,h,x){return f=+f,h=h>>>0,x||u(this,f,h,2,32767,-32768),this[h]=f>>>8,this[h+1]=f&255,h+2},a.prototype.writeInt32LE=function(f,h,x){return f=+f,h=h>>>0,x||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,x){return f=+f,h=h>>>0,x||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=cn(function(f,h=0){return l(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=cn(function(f,h=0){return E(this,f,h,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function T(b,f,h,x,L,$){if(h+x>b.length)throw new RangeError("Index out of range");if(h<0)throw new RangeError("Index out of range")}function D(b,f,h,x,L){return f=+f,h=h>>>0,L||T(b,f,h,4),n.write(b,f,h,x,23,4),h+4}a.prototype.writeFloatLE=function(f,h,x){return D(this,f,h,!0,x)},a.prototype.writeFloatBE=function(f,h,x){return D(this,f,h,!1,x)};function W(b,f,h,x,L){return f=+f,h=h>>>0,L||T(b,f,h,8),n.write(b,f,h,x,52,8),h+8}a.prototype.writeDoubleLE=function(f,h,x){return W(this,f,h,!0,x)},a.prototype.writeDoubleBE=function(f,h,x){return W(this,f,h,!1,x)},a.prototype.copy=function(f,h,x,L){if(!a.isBuffer(f))throw new TypeError("argument should be a Buffer");if(x||(x=0),!L&&L!==0&&(L=this.length),h>=f.length&&(h=f.length),h||(h=0),L>0&&L<x&&(L=x),L===x||f.length===0||this.length===0)return 0;if(h<0)throw new RangeError("targetStart out of bounds");if(x<0||x>=this.length)throw new RangeError("Index out of range");if(L<0)throw new RangeError("sourceEnd out of bounds");L>this.length&&(L=this.length),f.length-h<L-x&&(L=f.length-h+x);const $=L-x;return this===f&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(h,x,L):Uint8Array.prototype.set.call(f,this.subarray(x,L),h),$},a.prototype.fill=function(f,h,x,L){if(typeof f=="string"){if(typeof h=="string"?(L=h,h=0,x=this.length):typeof x=="string"&&(L=x,x=this.length),L!==void 0&&typeof L!="string")throw new TypeError("encoding must be a string");if(typeof L=="string"&&!a.isEncoding(L))throw new TypeError("Unknown encoding: "+L);if(f.length===1){const Z=f.charCodeAt(0);(L==="utf8"&&Z<128||L==="latin1")&&(f=Z)}}else typeof f=="number"?f=f&255:typeof f=="boolean"&&(f=Number(f));if(h<0||this.length<h||this.length<x)throw new RangeError("Out of range index");if(x<=h)return this;h=h>>>0,x=x===void 0?this.length:x>>>0,f||(f=0);let $;if(typeof f=="number")for($=h;$<x;++$)this[$]=f;else{const Z=a.isBuffer(f)?f:a.from(f,L),Ae=Z.length;if(Ae===0)throw new TypeError('The value "'+f+'" is invalid for argument "value"');for($=0;$<x-h;++$)this[$+h]=Z[$%Ae]}return this};const se={};function ae(b,f,h){se[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(L){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:L,writable:!0})}toString(){return`${this.name} [${b}]: ${this.message}`}}}ae("ERR_BUFFER_OUT_OF_BOUNDS",function(b){return b?`${b} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),ae("ERR_INVALID_ARG_TYPE",function(b,f){return`The "${b}" argument must be of type number. Received type ${typeof f}`},TypeError),ae("ERR_OUT_OF_RANGE",function(b,f,h){let x=`The value of "${b}" is out of range.`,L=h;return Number.isInteger(h)&&Math.abs(h)>2**32?L=Me(String(h)):typeof h=="bigint"&&(L=String(h),(h>BigInt(2)**BigInt(32)||h<-(BigInt(2)**BigInt(32)))&&(L=Me(L)),L+="n"),x+=` It must be ${f}. Received ${L}`,x},RangeError);function Me(b){let f="",h=b.length;const x=b[0]==="-"?1:0;for(;h>=x+4;h-=3)f=`_${b.slice(h-3,h)}${f}`;return`${b.slice(0,h)}${f}`}function ve(b,f,h){Fe(f,"offset"),(b[f]===void 0||b[f+h]===void 0)&&Re(f,b.length-(h+1))}function we(b,f,h,x,L,$){if(b>h||b<f){const Z=typeof f=="bigint"?"n":"";let Ae;throw f===0||f===BigInt(0)?Ae=`>= 0${Z} and < 2${Z} ** ${($+1)*8}${Z}`:Ae=`>= -(2${Z} ** ${($+1)*8-1}${Z}) and < 2 ** ${($+1)*8-1}${Z}`,new se.ERR_OUT_OF_RANGE("value",Ae,b)}ve(x,L,$)}function Fe(b,f){if(typeof b!="number")throw new se.ERR_INVALID_ARG_TYPE(f,"number",b)}function Re(b,f,h){throw Math.floor(b)!==b?(Fe(b,h),new se.ERR_OUT_OF_RANGE("offset","an integer",b)):f<0?new se.ERR_BUFFER_OUT_OF_BOUNDS:new se.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${f}`,b)}const Ne=/[^+/0-9A-Za-z-_]/g;function gn(b){if(b=b.split("=")[0],b=b.trim().replace(Ne,""),b.length<2)return"";for(;b.length%4!==0;)b=b+"=";return b}function Le(b,f){f=f||1/0;let h;const x=b.length;let L=null;const $=[];for(let Z=0;Z<x;++Z){if(h=b.charCodeAt(Z),h>55295&&h<57344){if(!L){if(h>56319){(f-=3)>-1&&$.push(239,191,189);continue}else if(Z+1===x){(f-=3)>-1&&$.push(239,191,189);continue}L=h;continue}if(h<56320){(f-=3)>-1&&$.push(239,191,189),L=h;continue}h=(L-55296<<10|h-56320)+65536}else L&&(f-=3)>-1&&$.push(239,191,189);if(L=null,h<128){if((f-=1)<0)break;$.push(h)}else if(h<2048){if((f-=2)<0)break;$.push(h>>6|192,h&63|128)}else if(h<65536){if((f-=3)<0)break;$.push(h>>12|224,h>>6&63|128,h&63|128)}else if(h<1114112){if((f-=4)<0)break;$.push(h>>18|240,h>>12&63|128,h>>6&63|128,h&63|128)}else throw new Error("Invalid code point")}return $}function He(b){const f=[];for(let h=0;h<b.length;++h)f.push(b.charCodeAt(h)&255);return f}function Xr(b,f){let h,x,L;const $=[];for(let Z=0;Z<b.length&&!((f-=2)<0);++Z)h=b.charCodeAt(Z),x=h>>8,L=h%256,$.push(L),$.push(x);return $}function $e(b){return e.toByteArray(gn(b))}function De(b,f,h,x){let L;for(L=0;L<x&&!(L+h>=f.length||L>=b.length);++L)f[L+h]=b[L];return L}function Qt(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 Ye=(function(){const b="0123456789abcdef",f=new Array(256);for(let h=0;h<16;++h){const x=h*16;for(let L=0;L<16;++L)f[x+L]=b[h]+b[L]}return f})();function cn(b){return typeof BigInt>"u"?Je:b}function Je(){throw new Error("BigInt not supported")}})(dc)),dc}var xe=lc();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fn=BigInt(0),Ft=BigInt(1),wf=BigInt(2),e_=BigInt(8),t_={zip215:!0};function n_(t){const e=Da(t);return Os(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function r_(t){const e=n_(t),{Fp:n,n:r,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:d}=e,m=wf<<BigInt(a*8)-Ft,g=n.create,S=Cs(e.n,e.nBitLength);function I(v,R){const O=n.sqr(v),_=n.sqr(R),u=n.add(n.mul(e.a,O),_),l=n.add(n.ONE,n.mul(e.d,n.mul(O,_)));return n.eql(u,l)}if(!I(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:fn}}}),P=e.adjustScalarBytes||(v=>v),M=e.domain||((v,R,O)=>{if(Dn("phflag",O),R.length||O)throw new Error("Contexts/pre-hash are not supported");return v});function B(v,R,O=!1){const _=O?Ft:fn;sn("coordinate "+v,R,_,m)}function K(v){if(!(v instanceof U))throw new Error("ExtendedPoint expected")}const Y=wi((v,R)=>{const{ex:O,ey:_,ez:u}=v,l=v.is0();R==null&&(R=l?e_:n.inv(u));const E=g(O*R),T=g(_*R),D=g(u*R);if(l)return{x:fn,y:Ft};if(D!==Ft)throw new Error("invZ was invalid");return{x:E,y:T}}),j=wi(v=>{const{a:R,d:O}=e;if(v.is0())throw new Error("bad point: ZERO");const{ex:_,ey:u,ez:l,et:E}=v,T=g(_*_),D=g(u*u),W=g(l*l),se=g(W*W),ae=g(T*R),Me=g(W*g(ae+D)),ve=g(se+g(O*g(T*D)));if(Me!==ve)throw new Error("bad point: equation left != right (1)");const we=g(_*u),Fe=g(l*E);if(we!==Fe)throw new Error("bad point: equation left != right (2)");return!0});class U{constructor(R,O,_,u){B("x",R),B("y",O),B("z",_,!0),B("t",u),this.ex=R,this.ey=O,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 U)throw new Error("extended point not allowed");const{x:O,y:_}=R||{};return B("x",O),B("y",_),new U(O,_,Ft,g(O*_))}static normalizeZ(R){const O=Ca(n,R.map(_=>_.ez));return R.map((_,u)=>_.toAffine(O[u])).map(U.fromAffine)}static msm(R,O){return Ul(U,S,R,O)}_setWindowSize(R){ne.setWindowSize(this,R)}assertValidity(){j(this)}equals(R){K(R);const{ex:O,ey:_,ez:u}=this,{ex:l,ey:E,ez:T}=R,D=g(O*T),W=g(l*u),se=g(_*T),ae=g(E*u);return D===W&&se===ae}is0(){return this.equals(U.ZERO)}negate(){return new U(g(-this.ex),this.ey,this.ez,g(-this.et))}double(){const{a:R}=e,{ex:O,ey:_,ez:u}=this,l=g(O*O),E=g(_*_),T=g(wf*g(u*u)),D=g(R*l),W=O+_,se=g(g(W*W)-l-E),ae=D+E,Me=ae-T,ve=D-E,we=g(se*Me),Fe=g(ae*ve),Re=g(se*ve),Ne=g(Me*ae);return new U(we,Fe,Ne,Re)}add(R){K(R);const{a:O,d:_}=e,{ex:u,ey:l,ez:E,et:T}=this,{ex:D,ey:W,ez:se,et:ae}=R,Me=g(u*D),ve=g(l*W),we=g(T*_*ae),Fe=g(E*se),Re=g((u+l)*(D+W)-Me-ve),Ne=Fe-we,gn=Fe+we,Le=g(ve-O*Me),He=g(Re*Ne),Xr=g(gn*Le),$e=g(Re*Le),De=g(Ne*gn);return new U(He,Xr,De,$e)}subtract(R){return this.add(R.negate())}wNAF(R){return ne.wNAFCached(this,R,U.normalizeZ)}multiply(R){const O=R;sn("scalar",O,Ft,r);const{p:_,f:u}=this.wNAF(O);return U.normalizeZ([_,u])[0]}multiplyUnsafe(R,O=U.ZERO){const _=R;return sn("scalar",_,fn,r),_===fn?J:this.is0()||_===Ft?this:ne.wNAFCachedUnsafe(this,_,U.normalizeZ,O)}isSmallOrder(){return this.multiplyUnsafe(d).is0()}isTorsionFree(){return ne.unsafeLadder(this,r).is0()}toAffine(R){return Y(this,R)}clearCofactor(){const{h:R}=e;return R===Ft?this:this.multiplyUnsafe(R)}static fromHex(R,O=!1){const{d:_,a:u}=e,l=n.BYTES;R=Qe("pointHex",R,l),Dn("zip215",O);const E=R.slice(),T=R[l-1];E[l-1]=T&-129;const D=Ts(E),W=O?m:n.ORDER;sn("pointHex.y",D,fn,W);const se=g(D*D),ae=g(se-Ft),Me=g(_*se-u);let{isValid:ve,value:we}=N(ae,Me);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");const Fe=(we&Ft)===Ft,Re=(T&128)!==0;if(!O&&we===fn&&Re)throw new Error("Point.fromHex: x=0 and x_0=1");return Re!==Fe&&(we=g(-we)),U.fromAffine({x:we,y:D})}static fromPrivateKey(R){const{scalar:O}=C(R);return V.multiply(O)}toRawBytes(){const{x:R,y:O}=this.toAffine(),_=_i(O,n.BYTES);return _[_.length-1]|=R&Ft?128:0,_}toHex(){return Nr(this.toRawBytes())}}U.BASE=new U(e.Gx,e.Gy,Ft,g(e.Gx*e.Gy)),U.ZERO=new U(fn,Ft,Ft,fn);const{BASE:V,ZERO:J}=U,ne=Bl(U,a*8);function te(v){return Ve(v,r)}function z(v){return te(Ts(v))}function C(v){const R=n.BYTES;v=Qe("private key",v,R);const O=Qe("hashed private key",i(v),2*R),_=P(O.slice(0,R)),u=O.slice(R,2*R),l=z(_);return{head:_,prefix:u,scalar:l}}function F(v){const{head:R,prefix:O,scalar:_}=C(v),u=V.multiply(_),l=u.toRawBytes();return{head:R,prefix:O,scalar:_,point:u,pointBytes:l}}function q(v){return F(v).pointBytes}function w(v=Uint8Array.of(),...R){const O=Cr(...R);return z(i(M(O,Qe("context",v),!!s)))}function c(v,R,O={}){v=Qe("message",v),s&&(v=s(v));const{prefix:_,scalar:u,pointBytes:l}=F(R),E=w(O.context,_,v),T=V.multiply(E).toRawBytes(),D=w(O.context,T,l,v),W=te(E+D*u);sn("signature.s",W,fn,r);const se=Cr(T,_i(W,n.BYTES));return Qe("result",se,n.BYTES*2)}const p=t_;function y(v,R,O,_=p){const{context:u,zip215:l}=_,E=n.BYTES;v=Qe("signature",v,2*E),R=Qe("message",R),O=Qe("publicKey",O,E),l!==void 0&&Dn("zip215",l),s&&(R=s(R));const T=Ts(v.slice(E,2*E));let D,W,se;try{D=U.fromHex(O,l),W=U.fromHex(v.slice(0,E),l),se=V.multiplyUnsafe(T)}catch{return!1}if(!l&&D.isSmallOrder())return!1;const ae=w(u,W.toRawBytes(),D.toRawBytes(),R);return W.add(D.multiplyUnsafe(ae)).subtract(se).clearCofactor().equals(U.ZERO)}return V._setWindowSize(8),{CURVE:e,getPublicKey:q,sign:c,verify:y,ExtendedPoint:U,utils:{getExtendedPublicKey:F,randomPrivateKey:()=>o(n.BYTES),precompute(v=8,R=U.BASE){return R._setWindowSize(v),R.multiply(BigInt(3)),R}}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fc=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),vf=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const s_=BigInt(1),Rf=BigInt(2);BigInt(3);const i_=BigInt(5),o_=BigInt(8);function a_(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),s=BigInt(80),i=fc,a=t*t%i*t%i,d=Ke(a,Rf,i)*a%i,m=Ke(d,s_,i)*t%i,g=Ke(m,i_,i)*m%i,S=Ke(g,e,i)*g%i,I=Ke(S,n,i)*S%i,N=Ke(I,r,i)*I%i,P=Ke(N,s,i)*N%i,M=Ke(P,s,i)*N%i,B=Ke(M,e,i)*g%i;return{pow_p_5_8:Ke(B,Rf,i)*t%i,b2:a}}function c_(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}function u_(t,e){const n=fc,r=Ve(e*e*e,n),s=Ve(r*r*e,n),i=a_(t*s).pow_p_5_8;let o=Ve(t*r*i,n);const a=Ve(e*o*o,n),d=o,m=Ve(o*vf,n),g=a===t,S=a===Ve(-t,n),I=a===Ve(-t*vf,n);return g&&(o=d),(S||I)&&(o=m),s1(o,n)&&(o=Ve(-o,n)),{isValid:g||S,value:o}}const Af=Cs(fc,void 0,!0),d_={a:Af.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Af,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:o_,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Dy,randomBytes:Ad,adjustScalarBytes:c_,uvRatio:u_},hc=r_(d_);var zi={exports:{}};const l_=Za(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var f_=zi.exports,Sf;function xf(){return Sf||(Sf=1,(function(t){(function(e,n){function r(w,c){if(!w)throw new Error(c||"Assertion failed")}function s(w,c){w.super_=c;var p=function(){};p.prototype=c.prototype,w.prototype=new p,w.prototype.constructor=w}function i(w,c,p){if(i.isBN(w))return w;this.negative=0,this.words=null,this.length=0,this.red=null,w!==null&&((c==="le"||c==="be")&&(p=c,c=10),this._init(w||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=l_.Buffer}catch{}i.isBN=function(c){return c instanceof i?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===i.wordSize&&Array.isArray(c.words)},i.max=function(c,p){return c.cmp(p)>0?c:p},i.min=function(c,p){return c.cmp(p)<0?c:p},i.prototype._init=function(c,p,y){if(typeof c=="number")return this._initNumber(c,p,y);if(typeof c=="object")return this._initArray(c,p,y);p==="hex"&&(p=16),r(p===(p|0)&&p>=2&&p<=36),c=c.toString().replace(/\s+/g,"");var A=0;c[0]==="-"&&(A++,this.negative=1),A<c.length&&(p===16?this._parseHex(c,A,y):(this._parseBase(c,p,A),y==="le"&&this._initArray(this.toArray(),p,y)))},i.prototype._initNumber=function(c,p,y){c<0&&(this.negative=1,c=-c),c<67108864?(this.words=[c&67108863],this.length=1):c<4503599627370496?(this.words=[c&67108863,c/67108864&67108863],this.length=2):(r(c<9007199254740992),this.words=[c&67108863,c/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),p,y)},i.prototype._initArray=function(c,p,y){if(r(typeof c.length=="number"),c.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(c.length/3),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v,R,O=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<<O&67108863,this.words[v+1]=R>>>26-O&67108863,O+=24,O>=26&&(O-=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<<O&67108863,this.words[v+1]=R>>>26-O&67108863,O+=24,O>=26&&(O-=26,v++);return this._strip()};function a(w,c){var p=w.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 "+w)}function d(w,c,p){var y=a(w,p);return p-1>=c&&(y|=a(w,p-1)<<4),y}i.prototype._parseHex=function(c,p,y){this.length=Math.ceil((c.length-p)/6),this.words=new Array(this.length);for(var A=0;A<this.length;A++)this.words[A]=0;var v=0,R=0,O;if(y==="be")for(A=c.length-1;A>=p;A-=2)O=d(c,p,A)<<v,this.words[R]|=O&67108863,v>=18?(v-=18,R+=1,this.words[R]|=O>>>26):v+=8;else{var _=c.length-p;for(A=_%2===0?p+1:p;A<c.length;A+=2)O=d(c,p,A)<<v,this.words[R]|=O&67108863,v>=18?(v-=18,R+=1,this.words[R]|=O>>>26):v+=8}this._strip()};function m(w,c,p,y){for(var A=0,v=0,R=Math.min(w.length,p),O=c;O<R;O++){var _=w.charCodeAt(O)-48;A*=y,_>=49?v=_-49+10:_>=17?v=_-17+10:v=_,r(_>=0&&v<y,"Invalid character"),A+=v}return A}i.prototype._parseBase=function(c,p,y){this.words=[0],this.length=1;for(var A=0,v=1;v<=67108863;v*=p)A++;A--,v=v/p|0;for(var R=c.length-y,O=R%A,_=Math.min(R,R-O)+y,u=0,l=y;l<_;l+=A)u=m(c,l,l+A,p),this.imuln(v),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(O!==0){var E=1;for(u=m(c,l,c.length,p),l=0;l<O;l++)E*=p;this.imuln(E),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(w,c){w.words=c.words,w.length=c.length,w.negative=c.negative,w.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")]=S}catch{i.prototype.inspect=S}else i.prototype.inspect=S;function S(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var I=["","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],P=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];i.prototype.toString=function(c,p){c=c||10,p=p|0||1;var y;if(c===16||c==="hex"){y="";for(var A=0,v=0,R=0;R<this.length;R++){var O=this.words[R],_=((O<<A|v)&16777215).toString(16);v=O>>>24-A&16777215,A+=2,A>=26&&(A-=26,R--),v!==0||R!==this.length-1?y=I[6-_.length]+_+y:y=_+y}for(v!==0&&(y=v.toString(16)+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(c===(c|0)&&c>=2&&c<=36){var u=N[c],l=P[c];y="";var E=this.clone();for(E.negative=0;!E.isZero();){var T=E.modrn(l).toString(c);E=E.idivn(l),E.isZero()?y=T+y:y=I[u-T.length]+T+y}for(this.isZero()&&(y="0"+y);y.length%p!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(c,p){return this.toArrayLike(o,c,p)}),i.prototype.toArray=function(c,p){return this.toArrayLike(Array,c,p)};var M=function(c,p){return c.allocUnsafe?c.allocUnsafe(p):new c(p)};i.prototype.toArrayLike=function(c,p,y){this._strip();var A=this.byteLength(),v=y||Math.max(1,A);r(A<=v,"byte array longer than desired length"),r(v>0,"Requested array length <= 0");var R=M(c,v),O=p==="le"?"LE":"BE";return this["_toArrayLike"+O](R,A),R},i.prototype._toArrayLikeLE=function(c,p){for(var y=0,A=0,v=0,R=0;v<this.length;v++){var O=this.words[v]<<R|A;c[y++]=O&255,y<c.length&&(c[y++]=O>>8&255),y<c.length&&(c[y++]=O>>16&255),R===6?(y<c.length&&(c[y++]=O>>24&255),A=0,R=0):(A=O>>>24,R+=2)}if(y<c.length)for(c[y++]=A;y<c.length;)c[y++]=0},i.prototype._toArrayLikeBE=function(c,p){for(var y=c.length-1,A=0,v=0,R=0;v<this.length;v++){var O=this.words[v]<<R|A;c[y--]=O&255,y>=0&&(c[y--]=O>>8&255),y>=0&&(c[y--]=O>>16&255),R===6?(y>=0&&(c[y--]=O>>24&255),A=0,R=0):(A=O>>>24,R+=2)}if(y>=0)for(c[y--]=A;y>=0;)c[y--]=0},Math.clz32?i.prototype._countBits=function(c){return 32-Math.clz32(c)}:i.prototype._countBits=function(c){var p=c,y=0;return p>=4096&&(y+=13,p>>>=13),p>=64&&(y+=7,p>>>=7),p>=8&&(y+=4,p>>>=4),p>=2&&(y+=2,p>>>=2),y+p},i.prototype._zeroBits=function(c){if(c===0)return 26;var p=c,y=0;return(p&8191)===0&&(y+=13,p>>>=13),(p&127)===0&&(y+=7,p>>>=7),(p&15)===0&&(y+=4,p>>>=4),(p&3)===0&&(y+=2,p>>>=2),(p&1)===0&&y++,y},i.prototype.bitLength=function(){var c=this.words[this.length-1],p=this._countBits(c);return(this.length-1)*26+p};function B(w){for(var c=new Array(w.bitLength()),p=0;p<c.length;p++){var y=p/26|0,A=p%26;c[p]=w.words[y]>>>A&1}return c}i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,p=0;p<this.length;p++){var y=this._zeroBits(this.words[p]);if(c+=y,y!==26)break}return c},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(c){return this.negative!==0?this.abs().inotn(c).iaddn(1):this.clone()},i.prototype.fromTwos=function(c){return this.testn(c-1)?this.notn(c).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return this.negative!==0},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(c){for(;this.length<c.length;)this.words[this.length++]=0;for(var p=0;p<c.length;p++)this.words[p]=this.words[p]|c.words[p];return this._strip()},i.prototype.ior=function(c){return r((this.negative|c.negative)===0),this.iuor(c)},i.prototype.or=function(c){return this.length>c.length?this.clone().ior(c):c.clone().ior(this)},i.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},i.prototype.iuand=function(c){var p;this.length>c.length?p=c:p=this;for(var y=0;y<p.length;y++)this.words[y]=this.words[y]&c.words[y];return this.length=p.length,this._strip()},i.prototype.iand=function(c){return r((this.negative|c.negative)===0),this.iuand(c)},i.prototype.and=function(c){return this.length>c.length?this.clone().iand(c):c.clone().iand(this)},i.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},i.prototype.iuxor=function(c){var p,y;this.length>c.length?(p=this,y=c):(p=c,y=this);for(var A=0;A<y.length;A++)this.words[A]=p.words[A]^y.words[A];if(this!==p)for(;A<p.length;A++)this.words[A]=p.words[A];return this.length=p.length,this._strip()},i.prototype.ixor=function(c){return r((this.negative|c.negative)===0),this.iuxor(c)},i.prototype.xor=function(c){return this.length>c.length?this.clone().ixor(c):c.clone().ixor(this)},i.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},i.prototype.inotn=function(c){r(typeof c=="number"&&c>=0);var p=Math.ceil(c/26)|0,y=c%26;this._expand(p),y>0&&p--;for(var A=0;A<p;A++)this.words[A]=~this.words[A]&67108863;return y>0&&(this.words[A]=~this.words[A]&67108863>>26-y),this._strip()},i.prototype.notn=function(c){return this.clone().inotn(c)},i.prototype.setn=function(c,p){r(typeof c=="number"&&c>=0);var y=c/26|0,A=c%26;return this._expand(y+1),p?this.words[y]=this.words[y]|1<<A:this.words[y]=this.words[y]&~(1<<A),this._strip()},i.prototype.iadd=function(c){var p;if(this.negative!==0&&c.negative===0)return this.negative=0,p=this.isub(c),this.negative^=1,this._normSign();if(this.negative===0&&c.negative!==0)return c.negative=0,p=this.isub(c),c.negative=1,p._normSign();var y,A;this.length>c.length?(y=this,A=c):(y=c,A=this);for(var v=0,R=0;R<A.length;R++)p=(y.words[R]|0)+(A.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;for(;v!==0&&R<y.length;R++)p=(y.words[R]|0)+v,this.words[R]=p&67108863,v=p>>>26;if(this.length=y.length,v!==0)this.words[this.length]=v,this.length++;else if(y!==this)for(;R<y.length;R++)this.words[R]=y.words[R];return this},i.prototype.add=function(c){var p;return c.negative!==0&&this.negative===0?(c.negative=0,p=this.sub(c),c.negative^=1,p):c.negative===0&&this.negative!==0?(this.negative=0,p=c.sub(this),this.negative=1,p):this.length>c.length?this.clone().iadd(c):c.clone().iadd(this)},i.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var p=this.iadd(c);return c.negative=1,p._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var y=this.cmp(c);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var A,v;y>0?(A=this,v=c):(A=c,v=this);for(var R=0,O=0;O<v.length;O++)p=(A.words[O]|0)-(v.words[O]|0)+R,R=p>>26,this.words[O]=p&67108863;for(;R!==0&&O<A.length;O++)p=(A.words[O]|0)+R,R=p>>26,this.words[O]=p&67108863;if(R===0&&O<A.length&&A!==this)for(;O<A.length;O++)this.words[O]=A.words[O];return this.length=Math.max(this.length,O),A!==this&&(this.negative=1),this._strip()},i.prototype.sub=function(c){return this.clone().isub(c)};function K(w,c,p){p.negative=c.negative^w.negative;var y=w.length+c.length|0;p.length=y,y=y-1|0;var A=w.words[0]|0,v=c.words[0]|0,R=A*v,O=R&67108863,_=R/67108864|0;p.words[0]=O;for(var u=1;u<y;u++){for(var l=_>>>26,E=_&67108863,T=Math.min(u,c.length-1),D=Math.max(0,u-w.length+1);D<=T;D++){var W=u-D|0;A=w.words[W]|0,v=c.words[D]|0,R=A*v+E,l+=R/67108864|0,E=R&67108863}p.words[u]=E|0,_=l|0}return _!==0?p.words[u]=_|0:p.length--,p._strip()}var Y=function(c,p,y){var A=c.words,v=p.words,R=y.words,O=0,_,u,l,E=A[0]|0,T=E&8191,D=E>>>13,W=A[1]|0,se=W&8191,ae=W>>>13,Me=A[2]|0,ve=Me&8191,we=Me>>>13,Fe=A[3]|0,Re=Fe&8191,Ne=Fe>>>13,gn=A[4]|0,Le=gn&8191,He=gn>>>13,Xr=A[5]|0,$e=Xr&8191,De=Xr>>>13,Qt=A[6]|0,Ge=Qt&8191,Ye=Qt>>>13,cn=A[7]|0,Je=cn&8191,b=cn>>>13,f=A[8]|0,h=f&8191,x=f>>>13,L=A[9]|0,$=L&8191,Z=L>>>13,Ae=v[0]|0,Ee=Ae&8191,ye=Ae>>>13,ze=v[1]|0,pe=ze&8191,nt=ze>>>13,S0=v[2]|0,rt=S0&8191,st=S0>>>13,x0=v[3]|0,it=x0&8191,ot=x0>>>13,T0=v[4]|0,at=T0&8191,ct=T0>>>13,I0=v[5]|0,ut=I0&8191,dt=I0>>>13,O0=v[6]|0,lt=O0&8191,ft=O0>>>13,N0=v[7]|0,ht=N0&8191,pt=N0>>>13,C0=v[8]|0,mt=C0&8191,gt=C0>>>13,M0=v[9]|0,yt=M0&8191,bt=M0>>>13;y.negative=c.negative^p.negative,y.length=19,_=Math.imul(T,Ee),u=Math.imul(T,ye),u=u+Math.imul(D,Ee)|0,l=Math.imul(D,ye);var ru=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(ru>>>26)|0,ru&=67108863,_=Math.imul(se,Ee),u=Math.imul(se,ye),u=u+Math.imul(ae,Ee)|0,l=Math.imul(ae,ye),_=_+Math.imul(T,pe)|0,u=u+Math.imul(T,nt)|0,u=u+Math.imul(D,pe)|0,l=l+Math.imul(D,nt)|0;var su=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(su>>>26)|0,su&=67108863,_=Math.imul(ve,Ee),u=Math.imul(ve,ye),u=u+Math.imul(we,Ee)|0,l=Math.imul(we,ye),_=_+Math.imul(se,pe)|0,u=u+Math.imul(se,nt)|0,u=u+Math.imul(ae,pe)|0,l=l+Math.imul(ae,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 iu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(iu>>>26)|0,iu&=67108863,_=Math.imul(Re,Ee),u=Math.imul(Re,ye),u=u+Math.imul(Ne,Ee)|0,l=Math.imul(Ne,ye),_=_+Math.imul(ve,pe)|0,u=u+Math.imul(ve,nt)|0,u=u+Math.imul(we,pe)|0,l=l+Math.imul(we,nt)|0,_=_+Math.imul(se,rt)|0,u=u+Math.imul(se,st)|0,u=u+Math.imul(ae,rt)|0,l=l+Math.imul(ae,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 ou=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(ou>>>26)|0,ou&=67108863,_=Math.imul(Le,Ee),u=Math.imul(Le,ye),u=u+Math.imul(He,Ee)|0,l=Math.imul(He,ye),_=_+Math.imul(Re,pe)|0,u=u+Math.imul(Re,nt)|0,u=u+Math.imul(Ne,pe)|0,l=l+Math.imul(Ne,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(se,it)|0,u=u+Math.imul(se,ot)|0,u=u+Math.imul(ae,it)|0,l=l+Math.imul(ae,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 au=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(au>>>26)|0,au&=67108863,_=Math.imul($e,Ee),u=Math.imul($e,ye),u=u+Math.imul(De,Ee)|0,l=Math.imul(De,ye),_=_+Math.imul(Le,pe)|0,u=u+Math.imul(Le,nt)|0,u=u+Math.imul(He,pe)|0,l=l+Math.imul(He,nt)|0,_=_+Math.imul(Re,rt)|0,u=u+Math.imul(Re,st)|0,u=u+Math.imul(Ne,rt)|0,l=l+Math.imul(Ne,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(se,at)|0,u=u+Math.imul(se,ct)|0,u=u+Math.imul(ae,at)|0,l=l+Math.imul(ae,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 cu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(cu>>>26)|0,cu&=67108863,_=Math.imul(Ge,Ee),u=Math.imul(Ge,ye),u=u+Math.imul(Ye,Ee)|0,l=Math.imul(Ye,ye),_=_+Math.imul($e,pe)|0,u=u+Math.imul($e,nt)|0,u=u+Math.imul(De,pe)|0,l=l+Math.imul(De,nt)|0,_=_+Math.imul(Le,rt)|0,u=u+Math.imul(Le,st)|0,u=u+Math.imul(He,rt)|0,l=l+Math.imul(He,st)|0,_=_+Math.imul(Re,it)|0,u=u+Math.imul(Re,ot)|0,u=u+Math.imul(Ne,it)|0,l=l+Math.imul(Ne,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(se,ut)|0,u=u+Math.imul(se,dt)|0,u=u+Math.imul(ae,ut)|0,l=l+Math.imul(ae,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 uu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(uu>>>26)|0,uu&=67108863,_=Math.imul(Je,Ee),u=Math.imul(Je,ye),u=u+Math.imul(b,Ee)|0,l=Math.imul(b,ye),_=_+Math.imul(Ge,pe)|0,u=u+Math.imul(Ge,nt)|0,u=u+Math.imul(Ye,pe)|0,l=l+Math.imul(Ye,nt)|0,_=_+Math.imul($e,rt)|0,u=u+Math.imul($e,st)|0,u=u+Math.imul(De,rt)|0,l=l+Math.imul(De,st)|0,_=_+Math.imul(Le,it)|0,u=u+Math.imul(Le,ot)|0,u=u+Math.imul(He,it)|0,l=l+Math.imul(He,ot)|0,_=_+Math.imul(Re,at)|0,u=u+Math.imul(Re,ct)|0,u=u+Math.imul(Ne,at)|0,l=l+Math.imul(Ne,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(se,lt)|0,u=u+Math.imul(se,ft)|0,u=u+Math.imul(ae,lt)|0,l=l+Math.imul(ae,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 du=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(du>>>26)|0,du&=67108863,_=Math.imul(h,Ee),u=Math.imul(h,ye),u=u+Math.imul(x,Ee)|0,l=Math.imul(x,ye),_=_+Math.imul(Je,pe)|0,u=u+Math.imul(Je,nt)|0,u=u+Math.imul(b,pe)|0,l=l+Math.imul(b,nt)|0,_=_+Math.imul(Ge,rt)|0,u=u+Math.imul(Ge,st)|0,u=u+Math.imul(Ye,rt)|0,l=l+Math.imul(Ye,st)|0,_=_+Math.imul($e,it)|0,u=u+Math.imul($e,ot)|0,u=u+Math.imul(De,it)|0,l=l+Math.imul(De,ot)|0,_=_+Math.imul(Le,at)|0,u=u+Math.imul(Le,ct)|0,u=u+Math.imul(He,at)|0,l=l+Math.imul(He,ct)|0,_=_+Math.imul(Re,ut)|0,u=u+Math.imul(Re,dt)|0,u=u+Math.imul(Ne,ut)|0,l=l+Math.imul(Ne,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(se,ht)|0,u=u+Math.imul(se,pt)|0,u=u+Math.imul(ae,ht)|0,l=l+Math.imul(ae,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 lu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(lu>>>26)|0,lu&=67108863,_=Math.imul($,Ee),u=Math.imul($,ye),u=u+Math.imul(Z,Ee)|0,l=Math.imul(Z,ye),_=_+Math.imul(h,pe)|0,u=u+Math.imul(h,nt)|0,u=u+Math.imul(x,pe)|0,l=l+Math.imul(x,nt)|0,_=_+Math.imul(Je,rt)|0,u=u+Math.imul(Je,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(Ye,it)|0,l=l+Math.imul(Ye,ot)|0,_=_+Math.imul($e,at)|0,u=u+Math.imul($e,ct)|0,u=u+Math.imul(De,at)|0,l=l+Math.imul(De,ct)|0,_=_+Math.imul(Le,ut)|0,u=u+Math.imul(Le,dt)|0,u=u+Math.imul(He,ut)|0,l=l+Math.imul(He,dt)|0,_=_+Math.imul(Re,lt)|0,u=u+Math.imul(Re,ft)|0,u=u+Math.imul(Ne,lt)|0,l=l+Math.imul(Ne,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(se,mt)|0,u=u+Math.imul(se,gt)|0,u=u+Math.imul(ae,mt)|0,l=l+Math.imul(ae,gt)|0,_=_+Math.imul(T,yt)|0,u=u+Math.imul(T,bt)|0,u=u+Math.imul(D,yt)|0,l=l+Math.imul(D,bt)|0;var fu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(fu>>>26)|0,fu&=67108863,_=Math.imul($,pe),u=Math.imul($,nt),u=u+Math.imul(Z,pe)|0,l=Math.imul(Z,nt),_=_+Math.imul(h,rt)|0,u=u+Math.imul(h,st)|0,u=u+Math.imul(x,rt)|0,l=l+Math.imul(x,st)|0,_=_+Math.imul(Je,it)|0,u=u+Math.imul(Je,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(Ye,at)|0,l=l+Math.imul(Ye,ct)|0,_=_+Math.imul($e,ut)|0,u=u+Math.imul($e,dt)|0,u=u+Math.imul(De,ut)|0,l=l+Math.imul(De,dt)|0,_=_+Math.imul(Le,lt)|0,u=u+Math.imul(Le,ft)|0,u=u+Math.imul(He,lt)|0,l=l+Math.imul(He,ft)|0,_=_+Math.imul(Re,ht)|0,u=u+Math.imul(Re,pt)|0,u=u+Math.imul(Ne,ht)|0,l=l+Math.imul(Ne,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,_=_+Math.imul(se,yt)|0,u=u+Math.imul(se,bt)|0,u=u+Math.imul(ae,yt)|0,l=l+Math.imul(ae,bt)|0;var hu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(hu>>>26)|0,hu&=67108863,_=Math.imul($,rt),u=Math.imul($,st),u=u+Math.imul(Z,rt)|0,l=Math.imul(Z,st),_=_+Math.imul(h,it)|0,u=u+Math.imul(h,ot)|0,u=u+Math.imul(x,it)|0,l=l+Math.imul(x,ot)|0,_=_+Math.imul(Je,at)|0,u=u+Math.imul(Je,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(Ye,ut)|0,l=l+Math.imul(Ye,dt)|0,_=_+Math.imul($e,lt)|0,u=u+Math.imul($e,ft)|0,u=u+Math.imul(De,lt)|0,l=l+Math.imul(De,ft)|0,_=_+Math.imul(Le,ht)|0,u=u+Math.imul(Le,pt)|0,u=u+Math.imul(He,ht)|0,l=l+Math.imul(He,pt)|0,_=_+Math.imul(Re,mt)|0,u=u+Math.imul(Re,gt)|0,u=u+Math.imul(Ne,mt)|0,l=l+Math.imul(Ne,gt)|0,_=_+Math.imul(ve,yt)|0,u=u+Math.imul(ve,bt)|0,u=u+Math.imul(we,yt)|0,l=l+Math.imul(we,bt)|0;var pu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(pu>>>26)|0,pu&=67108863,_=Math.imul($,it),u=Math.imul($,ot),u=u+Math.imul(Z,it)|0,l=Math.imul(Z,ot),_=_+Math.imul(h,at)|0,u=u+Math.imul(h,ct)|0,u=u+Math.imul(x,at)|0,l=l+Math.imul(x,ct)|0,_=_+Math.imul(Je,ut)|0,u=u+Math.imul(Je,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(Ye,lt)|0,l=l+Math.imul(Ye,ft)|0,_=_+Math.imul($e,ht)|0,u=u+Math.imul($e,pt)|0,u=u+Math.imul(De,ht)|0,l=l+Math.imul(De,pt)|0,_=_+Math.imul(Le,mt)|0,u=u+Math.imul(Le,gt)|0,u=u+Math.imul(He,mt)|0,l=l+Math.imul(He,gt)|0,_=_+Math.imul(Re,yt)|0,u=u+Math.imul(Re,bt)|0,u=u+Math.imul(Ne,yt)|0,l=l+Math.imul(Ne,bt)|0;var mu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(mu>>>26)|0,mu&=67108863,_=Math.imul($,at),u=Math.imul($,ct),u=u+Math.imul(Z,at)|0,l=Math.imul(Z,ct),_=_+Math.imul(h,ut)|0,u=u+Math.imul(h,dt)|0,u=u+Math.imul(x,ut)|0,l=l+Math.imul(x,dt)|0,_=_+Math.imul(Je,lt)|0,u=u+Math.imul(Je,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(Ye,ht)|0,l=l+Math.imul(Ye,pt)|0,_=_+Math.imul($e,mt)|0,u=u+Math.imul($e,gt)|0,u=u+Math.imul(De,mt)|0,l=l+Math.imul(De,gt)|0,_=_+Math.imul(Le,yt)|0,u=u+Math.imul(Le,bt)|0,u=u+Math.imul(He,yt)|0,l=l+Math.imul(He,bt)|0;var gu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(gu>>>26)|0,gu&=67108863,_=Math.imul($,ut),u=Math.imul($,dt),u=u+Math.imul(Z,ut)|0,l=Math.imul(Z,dt),_=_+Math.imul(h,lt)|0,u=u+Math.imul(h,ft)|0,u=u+Math.imul(x,lt)|0,l=l+Math.imul(x,ft)|0,_=_+Math.imul(Je,ht)|0,u=u+Math.imul(Je,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(Ye,mt)|0,l=l+Math.imul(Ye,gt)|0,_=_+Math.imul($e,yt)|0,u=u+Math.imul($e,bt)|0,u=u+Math.imul(De,yt)|0,l=l+Math.imul(De,bt)|0;var yu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(yu>>>26)|0,yu&=67108863,_=Math.imul($,lt),u=Math.imul($,ft),u=u+Math.imul(Z,lt)|0,l=Math.imul(Z,ft),_=_+Math.imul(h,ht)|0,u=u+Math.imul(h,pt)|0,u=u+Math.imul(x,ht)|0,l=l+Math.imul(x,pt)|0,_=_+Math.imul(Je,mt)|0,u=u+Math.imul(Je,gt)|0,u=u+Math.imul(b,mt)|0,l=l+Math.imul(b,gt)|0,_=_+Math.imul(Ge,yt)|0,u=u+Math.imul(Ge,bt)|0,u=u+Math.imul(Ye,yt)|0,l=l+Math.imul(Ye,bt)|0;var bu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(bu>>>26)|0,bu&=67108863,_=Math.imul($,ht),u=Math.imul($,pt),u=u+Math.imul(Z,ht)|0,l=Math.imul(Z,pt),_=_+Math.imul(h,mt)|0,u=u+Math.imul(h,gt)|0,u=u+Math.imul(x,mt)|0,l=l+Math.imul(x,gt)|0,_=_+Math.imul(Je,yt)|0,u=u+Math.imul(Je,bt)|0,u=u+Math.imul(b,yt)|0,l=l+Math.imul(b,bt)|0;var _u=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(_u>>>26)|0,_u&=67108863,_=Math.imul($,mt),u=Math.imul($,gt),u=u+Math.imul(Z,mt)|0,l=Math.imul(Z,gt),_=_+Math.imul(h,yt)|0,u=u+Math.imul(h,bt)|0,u=u+Math.imul(x,yt)|0,l=l+Math.imul(x,bt)|0;var Eu=(O+_|0)+((u&8191)<<13)|0;O=(l+(u>>>13)|0)+(Eu>>>26)|0,Eu&=67108863,_=Math.imul($,yt),u=Math.imul($,bt),u=u+Math.imul(Z,yt)|0,l=Math.imul(Z,bt);var wu=(O+_|0)+((u&8191)<<13)|0;return O=(l+(u>>>13)|0)+(wu>>>26)|0,wu&=67108863,R[0]=ru,R[1]=su,R[2]=iu,R[3]=ou,R[4]=au,R[5]=cu,R[6]=uu,R[7]=du,R[8]=lu,R[9]=fu,R[10]=hu,R[11]=pu,R[12]=mu,R[13]=gu,R[14]=yu,R[15]=bu,R[16]=_u,R[17]=Eu,R[18]=wu,O!==0&&(R[19]=O,y.length++),y};Math.imul||(Y=K);function j(w,c,p){p.negative=c.negative^w.negative,p.length=w.length+c.length;for(var y=0,A=0,v=0;v<p.length-1;v++){var R=A;A=0;for(var O=y&67108863,_=Math.min(v,c.length-1),u=Math.max(0,v-w.length+1);u<=_;u++){var l=v-u,E=w.words[l]|0,T=c.words[u]|0,D=E*T,W=D&67108863;R=R+(D/67108864|0)|0,W=W+O|0,O=W&67108863,R=R+(W>>>26)|0,A+=R>>>26,R&=67108863}p.words[v]=O,y=R,R=A}return y!==0?p.words[v]=y:p.length--,p._strip()}function U(w,c,p){return j(w,c,p)}i.prototype.mulTo=function(c,p){var y,A=this.length+c.length;return this.length===10&&c.length===10?y=Y(this,c,p):A<63?y=K(this,c,p):A<1024?y=j(this,c,p):y=U(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),U(this,c,p)},i.prototype.imul=function(c){return this.clone().mulTo(c,this)},i.prototype.imuln=function(c){var p=c<0;p&&(c=-c),r(typeof c=="number"),r(c<67108864);for(var y=0,A=0;A<this.length;A++){var v=(this.words[A]|0)*c,R=(v&67108863)+(y&67108863);y>>=26,y+=v/67108864|0,y+=R>>>26,this.words[A]=R&67108863}return y!==0&&(this.words[A]=y,this.length++),this.length=c===0?1:this.length,p?this.ineg():this},i.prototype.muln=function(c){return this.clone().imuln(c)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(c){var p=B(c);if(p.length===0)return new i(1);for(var y=this,A=0;A<p.length&&p[A]===0;A++,y=y.sqr());if(++A<p.length)for(var v=y.sqr();A<p.length;A++,v=v.sqr())p[A]!==0&&(y=y.mul(v));return y},i.prototype.iushln=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=67108863>>>26-p<<26-p,v;if(p!==0){var R=0;for(v=0;v<this.length;v++){var O=this.words[v]&A,_=(this.words[v]|0)-O<<p;this.words[v]=_|R,R=O>>>26-p}R&&(this.words[v]=R,this.length++)}if(y!==0){for(v=this.length-1;v>=0;v--)this.words[v+y]=this.words[v];for(v=0;v<y;v++)this.words[v]=0;this.length+=y}return this._strip()},i.prototype.ishln=function(c){return r(this.negative===0),this.iushln(c)},i.prototype.iushrn=function(c,p,y){r(typeof c=="number"&&c>=0);var A;p?A=(p-p%26)/26:A=0;var v=c%26,R=Math.min((c-v)/26,this.length),O=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 E=this.words[u]|0;this.words[u]=l<<26-v|E>>>v,l=E&O}return _&&l!==0&&(_.words[_.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.ishrn=function(c,p,y){return r(this.negative===0),this.iushrn(c,p,y)},i.prototype.shln=function(c){return this.clone().ishln(c)},i.prototype.ushln=function(c){return this.clone().iushln(c)},i.prototype.shrn=function(c){return this.clone().ishrn(c)},i.prototype.ushrn=function(c){return this.clone().iushrn(c)},i.prototype.testn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return!1;var v=this.words[y];return!!(v&A)},i.prototype.imaskn=function(c){r(typeof c=="number"&&c>=0);var p=c%26,y=(c-p)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(p!==0&&y++,this.length=Math.min(y,this.length),p!==0){var A=67108863^67108863>>>p<<p;this.words[this.length-1]&=A}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},i.prototype.maskn=function(c){return this.clone().imaskn(c)},i.prototype.iaddn=function(c){return r(typeof c=="number"),r(c<67108864),c<0?this.isubn(-c):this.negative!==0?this.length===1&&(this.words[0]|0)<=c?(this.words[0]=c-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(c),this.negative=1,this):this._iaddn(c)},i.prototype._iaddn=function(c){this.words[0]+=c;for(var p=0;p<this.length&&this.words[p]>=67108864;p++)this.words[p]-=67108864,p===this.length-1?this.words[p+1]=1:this.words[p+1]++;return this.length=Math.max(this.length,p+1),this},i.prototype.isubn=function(c){if(r(typeof c=="number"),r(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var p=0;p<this.length&&this.words[p]<0;p++)this.words[p]+=67108864,this.words[p+1]-=1;return this._strip()},i.prototype.addn=function(c){return this.clone().iaddn(c)},i.prototype.subn=function(c){return this.clone().isubn(c)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(c,p,y){var A=c.length+y,v;this._expand(A);var R,O=0;for(v=0;v<c.length;v++){R=(this.words[v+y]|0)+O;var _=(c.words[v]|0)*p;R-=_&67108863,O=(R>>26)-(_/67108864|0),this.words[v+y]=R&67108863}for(;v<this.length-y;v++)R=(this.words[v+y]|0)+O,O=R>>26,this.words[v+y]=R&67108863;if(O===0)return this._strip();for(r(O===-1),O=0,v=0;v<this.length;v++)R=-(this.words[v]|0)+O,O=R>>26,this.words[v]=R&67108863;return this.negative=1,this._strip()},i.prototype._wordDiv=function(c,p){var y=this.length-c.length,A=this.clone(),v=c,R=v.words[v.length-1]|0,O=this._countBits(R);y=26-O,y!==0&&(v=v.ushln(y),A.iushln(y),R=v.words[v.length-1]|0);var _=A.length-v.length,u;if(p!=="mod"){u=new i(null),u.length=_+1,u.words=new Array(u.length);for(var l=0;l<u.length;l++)u.words[l]=0}var E=A.clone()._ishlnsubmul(v,1,_);E.negative===0&&(A=E,u&&(u.words[_]=1));for(var T=_-1;T>=0;T--){var D=(A.words[v.length+T]|0)*67108864+(A.words[v.length+T-1]|0);for(D=Math.min(D/R|0,67108863),A._ishlnsubmul(v,D,T);A.negative!==0;)D--,A.negative=0,A._ishlnsubmul(v,1,T),A.isZero()||(A.negative^=1);u&&(u.words[T]=D)}return u&&u._strip(),A._strip(),p!=="div"&&y!==0&&A.iushrn(y),{div:u||null,mod:A}},i.prototype.divmod=function(c,p,y){if(r(!c.isZero()),this.isZero())return{div:new i(0),mod:new i(0)};var A,v,R;return this.negative!==0&&c.negative===0?(R=this.neg().divmod(c,p),p!=="mod"&&(A=R.div.neg()),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.iadd(c)),{div:A,mod:v}):this.negative===0&&c.negative!==0?(R=this.divmod(c.neg(),p),p!=="mod"&&(A=R.div.neg()),{div:A,mod:R.mod}):(this.negative&c.negative)!==0?(R=this.neg().divmod(c.neg(),p),p!=="div"&&(v=R.mod.neg(),y&&v.negative!==0&&v.isub(c)),{div:R.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new i(0),mod:this}:c.length===1?p==="div"?{div:this.divn(c.words[0]),mod:null}:p==="mod"?{div:null,mod:new i(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new i(this.modrn(c.words[0]))}:this._wordDiv(c,p)},i.prototype.div=function(c){return this.divmod(c,"div",!1).div},i.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},i.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},i.prototype.divRound=function(c){var p=this.divmod(c);if(p.mod.isZero())return p.div;var y=p.div.negative!==0?p.mod.isub(c):p.mod,A=c.ushrn(1),v=c.andln(1),R=y.cmp(A);return R<0||v===1&&R===0?p.div:p.div.negative!==0?p.div.isubn(1):p.div.iaddn(1)},i.prototype.modrn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=(1<<26)%c,A=0,v=this.length-1;v>=0;v--)A=(y*A+(this.words[v]|0))%c;return p?-A:A},i.prototype.modn=function(c){return this.modrn(c)},i.prototype.idivn=function(c){var p=c<0;p&&(c=-c),r(c<=67108863);for(var y=0,A=this.length-1;A>=0;A--){var v=(this.words[A]|0)+y*67108864;this.words[A]=v/c|0,y=v%c}return this._strip(),p?this.ineg():this},i.prototype.divn=function(c){return this.clone().idivn(c)},i.prototype.egcd=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=new i(0),O=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 E=0,T=1;(p.words[0]&T)===0&&E<26;++E,T<<=1);if(E>0)for(p.iushrn(E);E-- >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()||O.isOdd())&&(R.iadd(u),O.isub(l)),R.iushrn(1),O.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(R),v.isub(O)):(y.isub(p),R.isub(A),O.isub(v))}return{a:R,b:O,gcd:y.iushln(_)}},i.prototype._invmp=function(c){r(c.negative===0),r(!c.isZero());var p=this,y=c.clone();p.negative!==0?p=p.umod(c):p=p.clone();for(var A=new i(1),v=new i(0),R=y.clone();p.cmpn(1)>0&&y.cmpn(1)>0;){for(var O=0,_=1;(p.words[0]&_)===0&&O<26;++O,_<<=1);if(O>0)for(p.iushrn(O);O-- >0;)A.isOdd()&&A.iadd(R),A.iushrn(1);for(var u=0,l=1;(y.words[0]&l)===0&&u<26;++u,l<<=1);if(u>0)for(y.iushrn(u);u-- >0;)v.isOdd()&&v.iadd(R),v.iushrn(1);p.cmp(y)>=0?(p.isub(y),A.isub(v)):(y.isub(p),v.isub(A))}var E;return p.cmpn(1)===0?E=A:E=v,E.cmpn(0)<0&&E.iadd(c),E},i.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var p=this.clone(),y=c.clone();p.negative=0,y.negative=0;for(var A=0;p.isEven()&&y.isEven();A++)p.iushrn(1),y.iushrn(1);do{for(;p.isEven();)p.iushrn(1);for(;y.isEven();)y.iushrn(1);var v=p.cmp(y);if(v<0){var R=p;p=y,y=R}else if(v===0||y.cmpn(1)===0)break;p.isub(y)}while(!0);return y.iushln(A)},i.prototype.invm=function(c){return this.egcd(c).a.umod(c)},i.prototype.isEven=function(){return(this.words[0]&1)===0},i.prototype.isOdd=function(){return(this.words[0]&1)===1},i.prototype.andln=function(c){return this.words[0]&c},i.prototype.bincn=function(c){r(typeof c=="number");var p=c%26,y=(c-p)/26,A=1<<p;if(this.length<=y)return this._expand(y+1),this.words[y]|=A,this;for(var v=A,R=y;v!==0&&R<this.length;R++){var O=this.words[R]|0;O+=v,v=O>>>26,O&=67108863,this.words[R]=O}return v!==0&&(this.words[R]=v,this.length++),this},i.prototype.isZero=function(){return this.length===1&&this.words[0]===0},i.prototype.cmpn=function(c){var p=c<0;if(this.negative!==0&&!p)return-1;if(this.negative===0&&p)return 1;this._strip();var y;if(this.length>1)y=1;else{p&&(c=-c),r(c<=67108863,"Number is too big");var A=this.words[0]|0;y=A===c?0:A<c?-1:1}return this.negative!==0?-y|0:y},i.prototype.cmp=function(c){if(this.negative!==0&&c.negative===0)return-1;if(this.negative===0&&c.negative!==0)return 1;var p=this.ucmp(c);return this.negative!==0?-p|0:p},i.prototype.ucmp=function(c){if(this.length>c.length)return 1;if(this.length<c.length)return-1;for(var p=0,y=this.length-1;y>=0;y--){var A=this.words[y]|0,v=c.words[y]|0;if(A!==v){A<v?p=-1:A>v&&(p=1);break}}return p},i.prototype.gtn=function(c){return this.cmpn(c)===1},i.prototype.gt=function(c){return this.cmp(c)===1},i.prototype.gten=function(c){return this.cmpn(c)>=0},i.prototype.gte=function(c){return this.cmp(c)>=0},i.prototype.ltn=function(c){return this.cmpn(c)===-1},i.prototype.lt=function(c){return this.cmp(c)===-1},i.prototype.lten=function(c){return this.cmpn(c)<=0},i.prototype.lte=function(c){return this.cmp(c)<=0},i.prototype.eqn=function(c){return this.cmpn(c)===0},i.prototype.eq=function(c){return this.cmp(c)===0},i.red=function(c){return new F(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 V={k256:null,p224:null,p192:null,p25519:null};function J(w,c){this.name=w,this.p=new i(c,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}J.prototype._tmp=function(){var c=new i(null);return c.words=new Array(Math.ceil(this.n/13)),c},J.prototype.ireduce=function(c){var p=c,y;do this.split(p,this.tmp),p=this.imulK(p),p=p.iadd(this.tmp),y=p.bitLength();while(y>this.n);var A=y<this.n?-1:p.ucmp(this.p);return A===0?(p.words[0]=0,p.length=1):A>0?p.isub(this.p):p.strip!==void 0?p.strip():p._strip(),p},J.prototype.split=function(c,p){c.iushrn(this.n,0,p)},J.prototype.imulK=function(c){return c.imul(this.k)};function ne(){J.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}s(ne,J),ne.prototype.split=function(c,p){for(var y=4194303,A=Math.min(c.length,9),v=0;v<A;v++)p.words[v]=c.words[v];if(p.length=A,c.length<=9){c.words[0]=0,c.length=1;return}var R=c.words[9];for(p.words[p.length++]=R&y,v=10;v<c.length;v++){var O=c.words[v]|0;c.words[v-10]=(O&y)<<4|R>>>22,R=O}R>>>=22,c.words[v-10]=R,R===0&&c.length>10?c.length-=10:c.length-=9},ne.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var p=0,y=0;y<c.length;y++){var A=c.words[y]|0;p+=A*977,c.words[y]=p&67108863,p=A*64+(p/67108864|0)}return c.words[c.length-1]===0&&(c.length--,c.words[c.length-1]===0&&c.length--),c};function te(){J.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}s(te,J);function z(){J.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}s(z,J);function C(){J.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}s(C,J),C.prototype.imulK=function(c){for(var p=0,y=0;y<c.length;y++){var A=(c.words[y]|0)*19+p,v=A&67108863;A>>>=26,c.words[y]=v,p=A}return p!==0&&(c.words[c.length++]=p),c},i._prime=function(c){if(V[c])return V[c];var p;if(c==="k256")p=new ne;else if(c==="p224")p=new te;else if(c==="p192")p=new z;else if(c==="p25519")p=new C;else throw new Error("Unknown prime "+c);return V[c]=p,p};function F(w){if(typeof w=="string"){var c=i._prime(w);this.m=c.p,this.prime=c}else r(w.gtn(1),"modulus must be greater than 1"),this.m=w,this.prime=null}F.prototype._verify1=function(c){r(c.negative===0,"red works only with positives"),r(c.red,"red works only with red numbers")},F.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")},F.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(g(c,c.umod(this.m)._forceRed(this)),c)},F.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},F.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)},F.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},F.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)},F.prototype.isub=function(c,p){this._verify2(c,p);var y=c.isub(p);return y.cmpn(0)<0&&y.iadd(this.m),y},F.prototype.shl=function(c,p){return this._verify1(c),this.imod(c.ushln(p))},F.prototype.imul=function(c,p){return this._verify2(c,p),this.imod(c.imul(p))},F.prototype.mul=function(c,p){return this._verify2(c,p),this.imod(c.mul(p))},F.prototype.isqr=function(c){return this.imul(c,c.clone())},F.prototype.sqr=function(c){return this.mul(c,c)},F.prototype.sqrt=function(c){if(c.isZero())return c.clone();var p=this.m.andln(3);if(r(p%2===1),p===3){var y=this.m.add(new i(1)).iushrn(2);return this.pow(c,y)}for(var A=this.m.subn(1),v=0;!A.isZero()&&A.andln(1)===0;)v++,A.iushrn(1);r(!A.isZero());var R=new i(1).toRed(this),O=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(O)!==0;)u.redIAdd(O);for(var l=this.pow(u,A),E=this.pow(c,A.addn(1).iushrn(1)),T=this.pow(c,A),D=v;T.cmp(R)!==0;){for(var W=T,se=0;W.cmp(R)!==0;se++)W=W.redSqr();r(se<D);var ae=this.pow(l,new i(1).iushln(D-se-1));E=E.redMul(ae),l=ae.redSqr(),T=T.redMul(l),D=se}return E},F.prototype.invm=function(c){var p=c._invmp(this.m);return p.negative!==0?(p.negative=0,this.imod(p).redNeg()):this.imod(p)},F.prototype.pow=function(c,p){if(p.isZero())return new i(1).toRed(this);if(p.cmpn(1)===0)return c.clone();var y=4,A=new Array(1<<y);A[0]=new i(1).toRed(this),A[1]=c;for(var v=2;v<A.length;v++)A[v]=this.mul(A[v-1],c);var R=A[0],O=0,_=0,u=p.bitLength()%26;for(u===0&&(u=26),v=p.length-1;v>=0;v--){for(var l=p.words[v],E=u-1;E>=0;E--){var T=l>>E&1;if(R!==A[0]&&(R=this.sqr(R)),T===0&&O===0){_=0;continue}O<<=1,O|=T,_++,!(_!==y&&(v!==0||E!==0))&&(R=this.mul(R,A[O]),_=0,O=0)}u=26}return R},F.prototype.convertTo=function(c){var p=c.umod(this.m);return p===c?p.clone():p},F.prototype.convertFrom=function(c){var p=c.clone();return p.red=null,p},i.mont=function(c){return new q(c)};function q(w){F.call(this,w),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}s(q,F),q.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},q.prototype.convertFrom=function(c){var p=this.imod(c.mul(this.rinv));return p.red=null,p},q.prototype.imul=function(c,p){if(c.isZero()||p.isZero())return c.words[0]=0,c.length=1,c;var y=c.imul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},q.prototype.mul=function(c,p){if(c.isZero()||p.isZero())return new i(0)._forceRed(this);var y=c.mul(p),A=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=y.isub(A).iushrn(this.shift),R=v;return v.cmp(this.m)>=0?R=v.isub(this.m):v.cmpn(0)<0&&(R=v.iadd(this.m)),R._forceRed(this)},q.prototype.invm=function(c){var p=this.imod(c._invmp(this.m).mul(this.r2));return p._forceRed(this)}})(t,f_)})(zi)),zi.exports}var h_=xf();const Tf=Wa(h_);var ji={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var If;function p_(){return If||(If=1,(function(t,e){var n=lc(),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 pc,Of;function m_(){if(Of)return pc;Of=1;var t=p_().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),S=Math.log(256)/Math.log(d);function I(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 B=0,K=0,Y=0,j=M.length;Y!==j&&M[Y]===0;)Y++,B++;for(var U=(j-Y)*S+1>>>0,V=new Uint8Array(U);Y!==j;){for(var J=M[Y],ne=0,te=U-1;(J!==0||ne<K)&&te!==-1;te--,ne++)J+=256*V[te]>>>0,V[te]=J%d>>>0,J=J/d>>>0;if(J!==0)throw new Error("Non-zero carry");K=ne,Y++}for(var z=U-K;z!==U&&V[z]===0;)z++;for(var C=m.repeat(B);z<U;++z)C+=n.charAt(V[z]);return C}function N(M){if(typeof M!="string")throw new TypeError("Expected String");if(M.length===0)return t.alloc(0);for(var B=0,K=0,Y=0;M[B]===m;)K++,B++;for(var j=(M.length-B)*g+1>>>0,U=new Uint8Array(j);B<M.length;){var V=M.charCodeAt(B);if(V>255)return;var J=r[V];if(J===255)return;for(var ne=0,te=j-1;(J!==0||ne<Y)&&te!==-1;te--,ne++)J+=d*U[te]>>>0,U[te]=J%256>>>0,J=J/256>>>0;if(J!==0)throw new Error("Non-zero carry");Y=ne,B++}for(var z=j-Y;z!==j&&U[z]===0;)z++;var C=t.allocUnsafe(K+(j-z));C.fill(0,0,K);for(var F=K;z!==j;)C[F++]=U[z++];return C}function P(M){var B=N(M);if(B)return B;throw new Error("Non-base"+d+" character")}return{encode:I,decodeUnsafe:N,decode:P}}return pc=e,pc}var mc,Nf;function Cf(){if(Nf)return mc;Nf=1;var t=m_(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return mc=t(e),mc}var g_=Cf();const $t=Wa(g_);var ke={};function In(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 y_(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 b_(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 Hi=-1;function gc(t){this.tokens=[].slice.call(t)}gc.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Hi},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 Pr=-1;function yc(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Gi="utf-8";function qi(t,e){if(!(this instanceof qi))return new qi(t,e);if(t=t!==void 0?String(t).toLowerCase():Gi,t!==Gi)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 __({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var s=new gc(r),i=[],o;!s.endOfStream()&&(o=this._decoder.handler(s,s.read()),o!==Pr);)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===Pr)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),b_(i)}};function Ki(t,e){if(!(this instanceof Ki))return new Ki(t,e);if(t=t!==void 0?String(t).toLowerCase():Gi,t!==Gi)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 E_(this._options)),this._streaming=!!n.stream;for(var r=[],s=new gc(y_(e)),i;!s.endOfStream()&&(i=this._encoder.handler(s,s.read()),i!==Pr);)Array.isArray(i)?r.push.apply(r,i):r.push(i);if(!this._streaming){for(;i=this._encoder.handler(s,s.read()),i!==Pr;)Array.isArray(i)?r.push.apply(r,i):r.push(i);this._encoder=null}return new Uint8Array(r)}};function __(t){var e=t.fatal,n=0,r=0,s=0,i=128,o=191;this.handler=function(a,d){if(d===Hi&&s!==0)return s=0,yc(e);if(d===Hi)return Pr;if(s===0){if(In(d,0,127))return d;if(In(d,194,223))s=1,n=d-192;else if(In(d,224,239))d===224&&(i=160),d===237&&(o=159),s=2,n=d-224;else if(In(d,240,244))d===240&&(i=144),d===244&&(o=143),s=3,n=d-240;else return yc(e);return n=n<<6*s,null}if(!In(d,i,o))return n=s=r=0,i=128,o=191,a.prepend(d),yc(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 E_(t){t.fatal,this.handler=function(e,n){if(n===Hi)return Pr;if(In(n,0,127))return n;var r,s;In(n,128,2047)?(r=1,s=192):In(n,2048,65535)?(r=2,s=224):In(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 w_=Za(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:qi,TextEncoder:Ki},Symbol.toStringTag,{value:"Module"})));var Mf;function v_(){if(Mf)return ke;Mf=1;var t=ke&&ke.__createBinding||(Object.create?(function(z,C,F,q){q===void 0&&(q=F),Object.defineProperty(z,q,{enumerable:!0,get:function(){return C[F]}})}):(function(z,C,F,q){q===void 0&&(q=F),z[q]=C[F]})),e=ke&&ke.__setModuleDefault||(Object.create?(function(z,C){Object.defineProperty(z,"default",{enumerable:!0,value:C})}):function(z,C){z.default=C}),n=ke&&ke.__decorate||function(z,C,F,q){var w=arguments.length,c=w<3?C:q===null?q=Object.getOwnPropertyDescriptor(C,F):q,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(z,C,F,q);else for(var y=z.length-1;y>=0;y--)(p=z[y])&&(c=(w<3?p(c):w>3?p(C,F,c):p(C,F))||c);return w>3&&c&&Object.defineProperty(C,F,c),c},r=ke&&ke.__importStar||function(z){if(z&&z.__esModule)return z;var C={};if(z!=null)for(var F in z)F!=="default"&&Object.hasOwnProperty.call(z,F)&&t(C,z,F);return e(C,z),C},s=ke&&ke.__importDefault||function(z){return z&&z.__esModule?z:{default:z}};Object.defineProperty(ke,"__esModule",{value:!0}),ke.deserializeUnchecked=ke.deserialize=ke.serialize=ke.BinaryReader=ke.BinaryWriter=ke.BorshError=ke.baseDecode=ke.baseEncode=void 0;const i=s(xf()),o=s(Cf()),a=r(w_),d=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,m=new d("utf-8",{fatal:!0});function g(z){return typeof z=="string"&&(z=Buffer.from(z,"utf8")),o.default.encode(Buffer.from(z))}ke.baseEncode=g;function S(z){return Buffer.from(o.default.decode(z))}ke.baseDecode=S;const I=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(".")}}ke.BorshError=N;class P{constructor(){this.buf=Buffer.alloc(I),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(I)]))}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(I)]),this.length+=C.length}writeString(C){this.maybeResize();const F=Buffer.from(C,"utf8");this.writeU32(F.length),this.writeBuffer(F)}writeFixedArray(C){this.writeBuffer(Buffer.from(C))}writeArray(C,F){this.maybeResize(),this.writeU32(C.length);for(const q of C)this.maybeResize(),F(q)}toArray(){return this.buf.subarray(0,this.length)}}ke.BinaryWriter=P;function M(z,C,F){const q=F.value;F.value=function(...w){try{return q.apply(this,w)}catch(c){if(c instanceof RangeError){const p=c.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(p)>=0)throw new N("Reached the end of buffer when deserializing")}throw c}}}class B{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 F=this.buf.slice(this.offset,this.offset+C);return this.offset+=C,F}readString(){const C=this.readU32(),F=this.readBuffer(C);try{return m.decode(F)}catch(q){throw new N(`Error decoding UTF-8 string: ${q}`)}}readFixedArray(C){return new Uint8Array(this.readBuffer(C))}readArray(C){const F=this.readU32(),q=Array();for(let w=0;w<F;++w)q.push(C());return q}}n([M],B.prototype,"readU8",null),n([M],B.prototype,"readU16",null),n([M],B.prototype,"readU32",null),n([M],B.prototype,"readU64",null),n([M],B.prototype,"readU128",null),n([M],B.prototype,"readU256",null),n([M],B.prototype,"readU512",null),n([M],B.prototype,"readString",null),n([M],B.prototype,"readFixedArray",null),n([M],B.prototype,"readArray",null),ke.BinaryReader=B;function K(z){return z.charAt(0).toUpperCase()+z.slice(1)}function Y(z,C,F,q,w){try{if(typeof q=="string")w[`write${K(q)}`](F);else if(q instanceof Array)if(typeof q[0]=="number"){if(F.length!==q[0])throw new N(`Expecting byte array of length ${q[0]}, but got ${F.length} bytes`);w.writeFixedArray(F)}else if(q.length===2&&typeof q[1]=="number"){if(F.length!==q[1])throw new N(`Expecting byte array of length ${q[1]}, but got ${F.length} bytes`);for(let c=0;c<q[1];c++)Y(z,null,F[c],q[0],w)}else w.writeArray(F,c=>{Y(z,C,c,q[0],w)});else if(q.kind!==void 0)switch(q.kind){case"option":{F==null?w.writeU8(0):(w.writeU8(1),Y(z,C,F,q.type,w));break}case"map":{w.writeU32(F.size),F.forEach((c,p)=>{Y(z,C,p,q.key,w),Y(z,C,c,q.value,w)});break}default:throw new N(`FieldType ${q} unrecognized`)}else j(z,F,w)}catch(c){throw c instanceof N&&c.addToFieldPath(C),c}}function j(z,C,F){if(typeof C.borshSerialize=="function"){C.borshSerialize(F);return}const q=z.get(C.constructor);if(!q)throw new N(`Class ${C.constructor.name} is missing in schema`);if(q.kind==="struct")q.fields.map(([w,c])=>{Y(z,w,C[w],c,F)});else if(q.kind==="enum"){const w=C[q.field];for(let c=0;c<q.values.length;++c){const[p,y]=q.values[c];if(p===w){F.writeU8(c),Y(z,p,C[p],y,F);break}}}else throw new N(`Unexpected schema kind: ${q.kind} for ${C.constructor.name}`)}function U(z,C,F=P){const q=new F;return j(z,C,q),q.toArray()}ke.serialize=U;function V(z,C,F,q){try{if(typeof F=="string")return q[`read${K(F)}`]();if(F instanceof Array){if(typeof F[0]=="number")return q.readFixedArray(F[0]);if(typeof F[1]=="number"){const w=[];for(let c=0;c<F[1];c++)w.push(V(z,null,F[0],q));return w}else return q.readArray(()=>V(z,C,F[0],q))}if(F.kind==="option")return q.readU8()?V(z,C,F.type,q):void 0;if(F.kind==="map"){let w=new Map;const c=q.readU32();for(let p=0;p<c;p++){const y=V(z,C,F.key,q),A=V(z,C,F.value,q);w.set(y,A)}return w}return J(z,F,q)}catch(w){throw w instanceof N&&w.addToFieldPath(C),w}}function J(z,C,F){if(typeof C.borshDeserialize=="function")return C.borshDeserialize(F);const q=z.get(C);if(!q)throw new N(`Class ${C.name} is missing in schema`);if(q.kind==="struct"){const w={};for(const[c,p]of z.get(C).fields)w[c]=V(z,c,p,F);return new C(w)}if(q.kind==="enum"){const w=F.readU8();if(w>=q.values.length)throw new N(`Enum index: ${w} is out of range`);const[c,p]=q.values[w],y=V(z,c,p,F);return new C({[c]:y})}throw new N(`Unexpected schema kind: ${q.kind} for ${C.constructor.name}`)}function ne(z,C,F,q=B){const w=new q(F),c=J(z,C,w);if(w.offset<F.length)throw new N(`Unexpected ${F.length-w.offset} bytes after deserialized data`);return c}ke.deserialize=ne;function te(z,C,F,q=B){const w=new q(F);return J(z,C,w)}return ke.deserializeUnchecked=te,ke}var bc=v_(),G={},kf;function R_(){if(kf)return G;kf=1,Object.defineProperty(G,"__esModule",{value:!0}),G.s16=G.s8=G.nu64be=G.u48be=G.u40be=G.u32be=G.u24be=G.u16be=G.nu64=G.u48=G.u40=G.u32=G.u24=G.u16=G.u8=G.offset=G.greedy=G.Constant=G.UTF8=G.CString=G.Blob=G.Boolean=G.BitField=G.BitStructure=G.VariantLayout=G.Union=G.UnionLayoutDiscriminator=G.UnionDiscriminator=G.Structure=G.Sequence=G.DoubleBE=G.Double=G.FloatBE=G.Float=G.NearInt64BE=G.NearInt64=G.NearUInt64BE=G.NearUInt64=G.IntBE=G.Int=G.UIntBE=G.UInt=G.OffsetLayout=G.GreedyCount=G.ExternalLayout=G.bindConstructorLayout=G.nameWithProperty=G.Layout=G.uint8ArrayToBuffer=G.checkUint8Array=void 0,G.constant=G.utf8=G.cstr=G.blob=G.unionLayoutDiscriminator=G.union=G.seq=G.bits=G.struct=G.f64be=G.f64=G.f32be=G.f32=G.ns64be=G.s48be=G.s40be=G.s32be=G.s24be=G.s16be=G.ns64=G.s48=G.s40=G.s32=G.s24=void 0;const t=lc();function e(u){if(!(u instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}G.checkUint8Array=e;function n(u){return e(u),t.Buffer.from(u.buffer,u.byteOffset,u.length)}G.uint8ArrayToBuffer=n;let r=class{constructor(l,E){if(!Number.isInteger(l))throw new TypeError("span must be an integer");this.span=l,this.property=E}makeDestinationObject(){return{}}getSpan(l,E){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(l){const E=Object.create(this.constructor.prototype);return Object.assign(E,this),E.property=l,E}fromArray(l){}};G.Layout=r;function s(u,l){return l.property?u+"["+l.property+"]":u}G.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(E,T){return l.encode(this,E,T)},writable:!0}),Object.defineProperty(u,"decode",{value(E,T){return l.decode(E,T)},writable:!0})}G.bindConstructorLayout=i;class o extends r{isCount(){throw new Error("ExternalLayout is abstract")}}G.ExternalLayout=o;class a extends o{constructor(l=1,E){if(!Number.isInteger(l)||0>=l)throw new TypeError("elementSpan must be a (positive) integer");super(-1,E),this.elementSpan=l}isCount(){return!0}decode(l,E=0){e(l);const T=l.length-E;return Math.floor(T/this.elementSpan)}encode(l,E,T){return 0}}G.GreedyCount=a;class d extends o{constructor(l,E=0,T){if(!(l instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(E))throw new TypeError("offset must be integer or undefined");super(l.span,T||l.property),this.layout=l,this.offset=E}isCount(){return this.layout instanceof m||this.layout instanceof g}decode(l,E=0){return this.layout.decode(l,E+this.offset)}encode(l,E,T=0){return this.layout.encode(l,E,T+this.offset)}}G.OffsetLayout=d;class m extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readUIntLE(E,this.span)}encode(l,E,T=0){return n(E).writeUIntLE(l,T,this.span),this.span}}G.UInt=m;class g extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readUIntBE(E,this.span)}encode(l,E,T=0){return n(E).writeUIntBE(l,T,this.span),this.span}}G.UIntBE=g;class S extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readIntLE(E,this.span)}encode(l,E,T=0){return n(E).writeIntLE(l,T,this.span),this.span}}G.Int=S;class I extends r{constructor(l,E){if(super(l,E),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(l,E=0){return n(l).readIntBE(E,this.span)}encode(l,E,T=0){return n(E).writeIntBE(l,T,this.span),this.span}}G.IntBE=I;const N=Math.pow(2,32);function P(u){const l=Math.floor(u/N),E=u-l*N;return{hi32:l,lo32:E}}function M(u,l){return u*N+l}class B extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),D=T.readUInt32LE(E),W=T.readUInt32LE(E+4);return M(W,D)}encode(l,E,T=0){const D=P(l),W=n(E);return W.writeUInt32LE(D.lo32,T),W.writeUInt32LE(D.hi32,T+4),8}}G.NearUInt64=B;class K extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),D=T.readUInt32BE(E),W=T.readUInt32BE(E+4);return M(D,W)}encode(l,E,T=0){const D=P(l),W=n(E);return W.writeUInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}G.NearUInt64BE=K;class Y extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),D=T.readUInt32LE(E),W=T.readInt32LE(E+4);return M(W,D)}encode(l,E,T=0){const D=P(l),W=n(E);return W.writeUInt32LE(D.lo32,T),W.writeInt32LE(D.hi32,T+4),8}}G.NearInt64=Y;class j extends r{constructor(l){super(8,l)}decode(l,E=0){const T=n(l),D=T.readInt32BE(E),W=T.readUInt32BE(E+4);return M(D,W)}encode(l,E,T=0){const D=P(l),W=n(E);return W.writeInt32BE(D.hi32,T),W.writeUInt32BE(D.lo32,T+4),8}}G.NearInt64BE=j;class U extends r{constructor(l){super(4,l)}decode(l,E=0){return n(l).readFloatLE(E)}encode(l,E,T=0){return n(E).writeFloatLE(l,T),4}}G.Float=U;class V extends r{constructor(l){super(4,l)}decode(l,E=0){return n(l).readFloatBE(E)}encode(l,E,T=0){return n(E).writeFloatBE(l,T),4}}G.FloatBE=V;class J extends r{constructor(l){super(8,l)}decode(l,E=0){return n(l).readDoubleLE(E)}encode(l,E,T=0){return n(E).writeDoubleLE(l,T),8}}G.Double=J;class ne extends r{constructor(l){super(8,l)}decode(l,E=0){return n(l).readDoubleBE(E)}encode(l,E,T=0){return n(E).writeDoubleBE(l,T),8}}G.DoubleBE=ne;class te extends r{constructor(l,E,T){if(!(l instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(E instanceof o&&E.isCount()||Number.isInteger(E)&&0<=E))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let D=-1;!(E instanceof o)&&0<l.span&&(D=E*l.span),super(D,T),this.elementLayout=l,this.count=E}getSpan(l,E=0){if(0<=this.span)return this.span;let T=0,D=this.count;if(D instanceof o&&(D=D.decode(l,E)),0<this.elementLayout.span)T=D*this.elementLayout.span;else{let W=0;for(;W<D;)T+=this.elementLayout.getSpan(l,E+T),++W}return T}decode(l,E=0){const T=[];let D=0,W=this.count;for(W instanceof o&&(W=W.decode(l,E));D<W;)T.push(this.elementLayout.decode(l,E)),E+=this.elementLayout.getSpan(l,E),D+=1;return T}encode(l,E,T=0){const D=this.elementLayout,W=l.reduce((se,ae)=>se+D.encode(ae,E,T+se),0);return this.count instanceof o&&this.count.encode(l.length,E,T),W}}G.Sequence=te;class z extends r{constructor(l,E,T){if(!(Array.isArray(l)&&l.reduce((W,se)=>W&&se instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof E=="boolean"&&T===void 0&&(T=E,E=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,se)=>W+se.getSpan(),0)}catch{}super(D,E),this.fields=l,this.decodePrefixes=!!T}getSpan(l,E=0){if(0<=this.span)return this.span;let T=0;try{T=this.fields.reduce((D,W)=>{const se=W.getSpan(l,E);return E+=se,D+se},0)}catch{throw new RangeError("indeterminate span")}return T}decode(l,E=0){e(l);const T=this.makeDestinationObject();for(const D of this.fields)if(D.property!==void 0&&(T[D.property]=D.decode(l,E)),E+=D.getSpan(l,E),this.decodePrefixes&&l.length===E)break;return T}encode(l,E,T=0){const D=T;let W=0,se=0;for(const ae of this.fields){let Me=ae.span;if(se=0<Me?Me:0,ae.property!==void 0){const ve=l[ae.property];ve!==void 0&&(se=ae.encode(ve,E,T),0>Me&&(Me=ae.getSpan(E,T)))}W=T,T+=Me}return W+se-D}fromArray(l){const E=this.makeDestinationObject();for(const T of this.fields)T.property!==void 0&&0<l.length&&(E[T.property]=l.shift());return E}layoutFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const E of this.fields)if(E.property===l)return E}offsetOf(l){if(typeof l!="string")throw new TypeError("property must be string");let E=0;for(const T of this.fields){if(T.property===l)return E;0>T.span?E=-1:0<=E&&(E+=T.span)}}}G.Structure=z;class C{constructor(l){this.property=l}decode(l,E){throw new Error("UnionDiscriminator is abstract")}encode(l,E,T){throw new Error("UnionDiscriminator is abstract")}}G.UnionDiscriminator=C;class F extends C{constructor(l,E){if(!(l instanceof o&&l.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(E||l.property||"variant"),this.layout=l}decode(l,E){return this.layout.decode(l,E)}encode(l,E,T){return this.layout.encode(l,E,T)}}G.UnionLayoutDiscriminator=F;class q extends r{constructor(l,E,T){let D;if(l instanceof m||l instanceof g)D=new F(new d(l));else if(l instanceof o&&l.isCount())D=new F(l);else if(l instanceof C)D=l;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(E===void 0&&(E=null),!(E===null||E instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(E!==null){if(0>E.span)throw new Error("defaultLayout must have constant span");E.property===void 0&&(E=E.replicate("content"))}let W=-1;E&&(W=E.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=E,this.registry={};let se=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(ae){return se(ae)},this.configGetSourceVariant=function(ae){se=ae.bind(this)}}getSpan(l,E=0){if(0<=this.span)return this.span;const T=this.getVariant(l,E);if(!T)throw new Error("unable to determine span for unrecognized variant");return T.getSpan(l,E)}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 E=this.registry[l[this.discriminator.property]];if(E&&(!E.layout||E.property&&Object.prototype.hasOwnProperty.call(l,E.property)))return E}else for(const E in this.registry){const T=this.registry[E];if(T.property&&Object.prototype.hasOwnProperty.call(l,T.property))return T}throw new Error("unable to infer src variant")}decode(l,E=0){let T;const D=this.discriminator,W=D.decode(l,E),se=this.registry[W];if(se===void 0){const ae=this.defaultLayout;let Me=0;this.usesPrefixDiscriminator&&(Me=D.layout.span),T=this.makeDestinationObject(),T[D.property]=W,T[ae.property]=ae.decode(l,E+Me)}else T=se.decode(l,E);return T}encode(l,E,T=0){const D=this.getSourceVariant(l);if(D===void 0){const W=this.discriminator,se=this.defaultLayout;let ae=0;return this.usesPrefixDiscriminator&&(ae=W.layout.span),W.encode(l[W.property],E,T),ae+se.encode(l[se.property],E,T+ae)}return D.encode(l,E,T)}addVariant(l,E,T){const D=new w(this,l,E,T);return this.registry[l]=D,D}getVariant(l,E=0){let T;return l instanceof Uint8Array?T=this.discriminator.decode(l,E):T=l,this.registry[T]}}G.Union=q;class w extends r{constructor(l,E,T,D){if(!(l instanceof q))throw new TypeError("union must be a Union");if(!Number.isInteger(E)||0>E)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=E,this.layout=T||null}getSpan(l,E=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,E+T)),T+D}decode(l,E=0){const T=this.makeDestinationObject();if(this!==this.union.getVariant(l,E))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,E+D):this.property?T[this.property]=!0:this.union.usesPrefixDiscriminator&&(T[this.union.discriminator.property]=this.variant),T}encode(l,E,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,E,T);let W=D;if(this.layout&&(this.layout.encode(l[this.property],E,T+D),W+=this.layout.getSpan(E,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)}}G.VariantLayout=w;function c(u){return 0>u&&(u+=4294967296),u}class p extends r{constructor(l,E,T){if(!(l instanceof m||l instanceof g))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof E=="string"&&T===void 0&&(T=E,E=!1),4<l.span)throw new RangeError("word cannot exceed 32 bits");super(l.span,T),this.word=l,this.msb=!!E,this.fields=[];let D=0;this._packedSetValue=function(W){return D=c(W),this},this._packedGetValue=function(){return D}}decode(l,E=0){const T=this.makeDestinationObject(),D=this.word.decode(l,E);this._packedSetValue(D);for(const W of this.fields)W.property!==void 0&&(T[W.property]=W.decode(l));return T}encode(l,E,T=0){const D=this.word.decode(E,T);this._packedSetValue(D);for(const W of this.fields)if(W.property!==void 0){const se=l[W.property];se!==void 0&&W.encode(se)}return this.word.encode(this._packedGetValue(),E,T)}addField(l,E){const T=new y(this,l,E);return this.fields.push(T),T}addBoolean(l){const E=new A(this,l);return this.fields.push(E),E}fieldFor(l){if(typeof l!="string")throw new TypeError("property must be string");for(const E of this.fields)if(E.property===l)return E}}G.BitStructure=p;class y{constructor(l,E,T){if(!(l instanceof p))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(E)||0>=E)throw new TypeError("bits must be positive integer");const D=8*l.span,W=l.fields.reduce((se,ae)=>se+ae.bits,0);if(E+W>D)throw new Error("bits too long for span remainder ("+(D-W)+" of "+D+" remain)");this.container=l,this.bits=E,this.valueMask=(1<<E)-1,E===32&&(this.valueMask=4294967295),this.start=W,this.container.msb&&(this.start=D-W-E),this.wordMask=c(this.valueMask<<this.start),this.property=T}decode(l,E){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 E=this.container._packedGetValue(),T=c(l<<this.start);this.container._packedSetValue(c(E&~this.wordMask)|T)}}G.BitField=y;class A extends y{constructor(l,E){super(l,1,E)}decode(l,E){return!!super.decode(l,E)}encode(l){typeof l=="boolean"&&(l=+l),super.encode(l)}}G.Boolean=A;class v extends r{constructor(l,E){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,E),this.length=l}getSpan(l,E){let T=this.span;return 0>T&&(T=this.length.decode(l,E)),T}decode(l,E=0){let T=this.span;return 0>T&&(T=this.length.decode(l,E)),n(l).slice(E,E+T)}encode(l,E,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>E.length)throw new RangeError("encoding overruns Uint8Array");const W=n(l);return n(E).write(W.toString("hex"),T,D,"hex"),this.length instanceof o&&this.length.encode(D,E,T),D}}G.Blob=v;class R extends r{constructor(l){super(-1,l)}getSpan(l,E=0){e(l);let T=E;for(;T<l.length&&l[T]!==0;)T+=1;return 1+T-E}decode(l,E=0){const T=this.getSpan(l,E);return n(l).slice(E,E+T-1).toString("utf-8")}encode(l,E,T=0){typeof l!="string"&&(l=String(l));const D=t.Buffer.from(l,"utf8"),W=D.length;if(T+W>E.length)throw new RangeError("encoding overruns Buffer");const se=n(E);return D.copy(se,T),se[T+W]=0,W+1}}G.CString=R;class O extends r{constructor(l,E){if(typeof l=="string"&&E===void 0&&(E=l,l=void 0),l===void 0)l=-1;else if(!Number.isInteger(l))throw new TypeError("maxSpan must be an integer");super(-1,E),this.maxSpan=l}getSpan(l,E=0){return e(l),l.length-E}decode(l,E=0){const T=this.getSpan(l,E);if(0<=this.maxSpan&&this.maxSpan<T)throw new RangeError("text length exceeds maxSpan");return n(l).slice(E,E+T).toString("utf-8")}encode(l,E,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>E.length)throw new RangeError("encoding overruns Buffer");return D.copy(n(E),T),W}}G.UTF8=O;class _ extends r{constructor(l,E){super(0,E),this.value=l}decode(l,E){return this.value}encode(l,E,T){return 0}}return G.Constant=_,G.greedy=((u,l)=>new a(u,l)),G.offset=((u,l,E)=>new d(u,l,E)),G.u8=(u=>new m(1,u)),G.u16=(u=>new m(2,u)),G.u24=(u=>new m(3,u)),G.u32=(u=>new m(4,u)),G.u40=(u=>new m(5,u)),G.u48=(u=>new m(6,u)),G.nu64=(u=>new B(u)),G.u16be=(u=>new g(2,u)),G.u24be=(u=>new g(3,u)),G.u32be=(u=>new g(4,u)),G.u40be=(u=>new g(5,u)),G.u48be=(u=>new g(6,u)),G.nu64be=(u=>new K(u)),G.s8=(u=>new S(1,u)),G.s16=(u=>new S(2,u)),G.s24=(u=>new S(3,u)),G.s32=(u=>new S(4,u)),G.s40=(u=>new S(5,u)),G.s48=(u=>new S(6,u)),G.ns64=(u=>new Y(u)),G.s16be=(u=>new I(2,u)),G.s24be=(u=>new I(3,u)),G.s32be=(u=>new I(4,u)),G.s40be=(u=>new I(5,u)),G.s48be=(u=>new I(6,u)),G.ns64be=(u=>new j(u)),G.f32=(u=>new U(u)),G.f32be=(u=>new V(u)),G.f64=(u=>new J(u)),G.f64be=(u=>new ne(u)),G.struct=((u,l,E)=>new z(u,l,E)),G.bits=((u,l,E)=>new p(u,l,E)),G.seq=((u,l,E)=>new te(u,l,E)),G.union=((u,l,E)=>new q(u,l,E)),G.unionLayoutDiscriminator=((u,l)=>new F(u,l)),G.blob=((u,l)=>new v(u,l)),G.cstr=(u=>new R(u)),G.utf8=((u,l)=>new O(u,l)),G.constant=((u,l)=>new _(u,l)),G}var k=R_(),A_=1,S_=2,x_=3,T_=4,I_=5,O_=6,N_=7,C_=8,M_=9,k_=10,B_=-32700,U_=-32603,L_=-32602,D_=-32601,P_=-32600,F_=-32016,$_=-32015,z_=-32014,j_=-32013,V_=-32012,H_=-32011,G_=-32010,q_=-32009,K_=-32008,W_=-32007,Z_=-32006,Y_=-32005,J_=-32004,X_=-32003,Q_=-32002,eE=-32001,tE=28e5,nE=2800001,rE=2800002,sE=2800003,iE=2800004,oE=2800005,aE=2800006,cE=2800007,uE=2800008,dE=2800009,lE=2800010,fE=2800011,hE=323e4,pE=32300001,mE=3230002,gE=3230003,yE=3230004,bE=361e4,_E=3610001,EE=3610002,wE=3610003,vE=3610004,RE=3610005,AE=3610006,SE=3610007,xE=3611e3,TE=3704e3,IE=3704001,OE=3704002,NE=3704003,CE=3704004,ME=4128e3,kE=4128001,BE=4128002,UE=4615e3,LE=4615001,DE=4615002,PE=4615003,FE=4615004,$E=4615005,zE=4615006,jE=4615007,VE=4615008,HE=4615009,GE=4615010,qE=4615011,KE=4615012,WE=4615013,ZE=4615014,YE=4615015,JE=4615016,XE=4615017,QE=4615018,ew=4615019,tw=4615020,nw=4615021,rw=4615022,sw=4615023,iw=4615024,ow=4615025,aw=4615026,cw=4615027,uw=4615028,dw=4615029,lw=4615030,fw=4615031,hw=4615032,pw=4615033,mw=4615034,gw=4615035,yw=4615036,bw=4615037,_w=4615038,Ew=4615039,ww=4615040,vw=4615041,Rw=4615042,Aw=4615043,Sw=4615044,xw=4615045,Tw=4615046,Iw=4615047,Ow=4615048,Nw=4615049,Cw=4615050,Mw=4615051,kw=4615052,Bw=4615053,Uw=4615054,Lw=5508e3,Dw=5508001,Pw=5508002,Fw=5508003,$w=5508004,zw=5508005,jw=5508006,Vw=5508007,Hw=5508008,Gw=5508009,qw=5508010,Kw=5508011,Ww=5663e3,Zw=5663001,Yw=5663002,Jw=5663003,Xw=5663004,Qw=5663005,ev=5663006,tv=5663007,nv=5663008,rv=5663009,sv=5663010,iv=5663011,ov=5663012,av=5663013,cv=5663014,uv=5663015,dv=5663016,lv=5663017,fv=5663018,hv=5663019,pv=5663020,mv=705e4,gv=7050001,yv=7050002,bv=7050003,_v=7050004,Ev=7050005,wv=7050006,vv=7050007,Rv=7050008,Av=7050009,Sv=7050010,xv=7050011,Tv=7050012,Iv=7050013,Ov=7050014,Nv=7050015,Cv=7050016,Mv=7050017,kv=7050018,Bv=7050019,Uv=7050020,Lv=7050021,Dv=7050022,Pv=7050023,Fv=7050024,$v=7050025,zv=7050026,jv=7050027,Vv=7050028,Hv=7050029,Gv=7050030,qv=7050031,Kv=7050032,Wv=7050033,Zv=7050034,Yv=7050035,Jv=7050036,Bf=8078e3,Uf=8078001,Xv=8078002,Qv=8078003,Lf=8078004,Df=8078005,Pf=8078006,eR=8078007,tR=8078008,nR=8078009,rR=8078010,Ff=8078011,sR=8078012,iR=8078013,oR=8078014,aR=8078015,cR=8078016,uR=8078017,dR=8078018,lR=8078019,fR=8078020,hR=8078021,pR=8078022,mR=81e5,gR=8100001,yR=8100002,bR=8100003,_R=819e4,ER=8190001,wR=8190002,vR=8190003,RR=8190004,AR=99e5,SR=9900001,xR=9900002,TR=9900003,IR=9900004;function $f(t){return Array.isArray(t)?"%5B"+t.map($f).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function OR([t,e]){return`${t}=${$f(e)}`}function NR(t){const e=Object.entries(t).map(OR).join("&");return btoa(e)}var CR={[hE]:"Account not found at address: $address",[yE]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[gE]:"Expected decoded account at address: $address",[mE]:"Failed to decode account data at address: $address",[pE]:"Accounts not found at addresses: $addresses",[dE]:"Unable to find a viable program address bump seed.",[rE]:"$putativeAddress is not a base58-encoded address.",[tE]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[sE]:"The `CryptoKey` must be an `Ed25519` public key.",[fE]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[uE]:"Invalid seeds; point must fall off the Ed25519 curve.",[iE]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[aE]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[cE]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[oE]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[lE]:"Program address cannot end with PDA marker.",[nE]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[T_]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[A_]:"The network has progressed past the last block for which this transaction could have been committed.",[Bf]:"Codec [$codecDescription] cannot decode empty byte arrays.",[pR]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[fR]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Df]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Pf]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Lf]:"Encoder and decoder must either both be fixed-size or variable-size.",[tR]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Xv]:"Expected a fixed-size codec, got a variable-size one.",[iR]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Qv]:"Expected a variable-size codec, got a fixed-size one.",[lR]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Uf]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[dR]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[nR]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[rR]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[aR]:"Invalid literal union variant. Expected one of [$variants], got $value.",[eR]:"Expected [$codecDescription] to have $expected items, got $actual.",[sR]:"Invalid value $value for base $base with alphabet $alphabet.",[cR]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Ff]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[oR]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[hR]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[uR]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[xE]:"No random values implementation could be found.",[HE]:"instruction requires an uninitialized account",[sw]:"instruction tries to borrow reference for an account which is already borrowed",[iw]:"instruction left account with an outstanding borrowed reference",[nw]:"program other than the account's owner changed the size of the account data",[$E]:"account data too small for instruction",[rw]:"instruction expected an executable account",[Tw]:"An account does not have enough lamports to be rent-exempt",[Ow]:"Program arithmetic overflowed",[xw]:"Failed to serialize or deserialize account data: $encodedData",[Uw]:"Builtin programs must consume compute units",[hw]:"Cross-program invocation call depth too deep",[_w]:"Computational budget exceeded",[aw]:"custom program error: #$code",[XE]:"instruction contains duplicate accounts",[ow]:"instruction modifications of multiply-passed account differ",[lw]:"executable accounts must be rent exempt",[uw]:"instruction changed executable accounts data",[dw]:"instruction changed the balance of an executable account",[QE]:"instruction changed executable bit of an account",[ZE]:"instruction modified data of an account it does not own",[WE]:"instruction spent from the balance of an account it does not own",[LE]:"generic instruction error",[Cw]:"Provided owner is not allowed",[Aw]:"Account is immutable",[Sw]:"Incorrect authority provided",[jE]:"incorrect program id for instruction",[zE]:"insufficient funds for instruction",[FE]:"invalid account data for instruction",[Iw]:"Invalid account owner",[DE]:"invalid program argument",[cw]:"program returned invalid error code",[PE]:"invalid instruction data",[bw]:"Failed to reallocate account data",[yw]:"Provided seeds do not result in a valid address",[Mw]:"Accounts data allocations exceeded the maximum allowed per transaction",[kw]:"Max accounts exceeded",[Bw]:"Max instruction trace length exceeded",[gw]:"Length of the seed is too long for address generation",[pw]:"An account required by the instruction is missing",[VE]:"missing required signature for instruction",[KE]:"instruction illegally modified the program id of an account",[tw]:"insufficient account keys for instruction",[Ew]:"Cross-program invocation with unauthorized signer or writable account",[ww]:"Failed to create program execution environment",[Rw]:"Program failed to compile",[vw]:"Program failed to complete",[JE]:"instruction modified data of a read-only account",[YE]:"instruction changed the balance of a read-only account",[mw]:"Cross-program invocation reentrancy not allowed for this instruction",[ew]:"instruction modified rent epoch of an account",[qE]:"sum of account balances before and after instruction do not match",[GE]:"instruction requires an initialized account",[UE]:"",[fw]:"Unsupported program id",[Nw]:"Unsupported sysvar",[ME]:"The instruction does not have any accounts.",[kE]:"The instruction does not have any data.",[BE]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[I_]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[S_]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[xR]:"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",[IR]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[SR]:"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",[AR]:"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",[TR]:"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",[U_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[L_]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[P_]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[D_]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[B_]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[V_]:"$__serverMessage",[eE]:"$__serverMessage",[J_]:"$__serverMessage",[z_]:"$__serverMessage",[G_]:"$__serverMessage",[q_]:"$__serverMessage",[F_]:"Minimum context slot has not been reached",[Y_]:"Node is unhealthy; behind by $numSlotsBehind slots",[K_]:"No snapshot",[Q_]:"Transaction simulation failed",[W_]:"$__serverMessage",[H_]:"Transaction history is not available from this node",[Z_]:"$__serverMessage",[j_]:"Transaction signature length mismatch",[X_]:"Transaction signature verification failure",[$_]:"$__serverMessage",[TE]:"Key pair bytes must be of length 64, got $byteLength.",[IE]:"Expected private key bytes with length 32. Actual length: $actualLength.",[OE]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[CE]:"The provided private key does not match the provided public key.",[NE]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[O_]:"Lamports value must be in the range [0, 2e64-1]",[N_]:"`$value` cannot be parsed as a `BigInt`",[k_]:"$message",[C_]:"`$value` cannot be parsed as a `Number`",[x_]:"No nonce account could be found at address `$nonceAccountAddress`",[_R]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[wR]:"WebSocket was closed before payload could be added to the send buffer",[vR]:"WebSocket connection closed",[RR]:"WebSocket failed to connect",[ER]:"Failed to obtain a subscription id from the server",[bR]:"Could not find an API plan for RPC method: `$method`",[mR]:"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`.",[yR]:"HTTP error ($statusCode): $message",[gR]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Lw]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Dw]:"The provided value does not implement the `KeyPairSigner` interface",[Fw]:"The provided value does not implement the `MessageModifyingSigner` interface",[$w]:"The provided value does not implement the `MessagePartialSigner` interface",[Pw]:"The provided value does not implement any of the `MessageSigner` interfaces",[jw]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Vw]:"The provided value does not implement the `TransactionPartialSigner` interface",[Hw]:"The provided value does not implement the `TransactionSendingSigner` interface",[zw]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Gw]:"More than one `TransactionSendingSigner` was identified.",[qw]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Kw]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[SE]:"Cannot export a non-extractable key.",[_E]:"No digest implementation could be found.",[bE]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[EE]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
29
|
+
|
|
30
|
+
Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
|
|
31
|
+
|
|
32
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[wE]:"No signature verification implementation could be found.",[vE]:"No key generation implementation could be found.",[RE]:"No signing implementation could be found.",[AE]:"No key export implementation could be found.",[M_]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Cv]:"Transaction processing left an account with an outstanding borrowed reference",[gv]:"Account in use",[yv]:"Account loaded twice",[bv]:"Attempt to debit an account but found no record of a prior credit.",[Pv]:"Transaction loads an address table account that doesn't exist",[vv]:"This transaction has already been processed",[Rv]:"Blockhash not found",[Av]:"Loader call chain is too deep",[Nv]:"Transactions are currently disabled due to cluster maintenance",[Gv]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ev]:"Insufficient funds for fee",[qv]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[wv]:"This account may not be used to pay transaction fees",[xv]:"Transaction contains an invalid account reference",[$v]:"Transaction loads an address table account with invalid data",[zv]:"Transaction address table lookup uses an invalid index",[Fv]:"Transaction loads an address table account with an invalid owner",[Wv]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Iv]:"This program may not be used for executing instructions",[jv]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Bv]:"Transaction loads a writable account that cannot be written",[Kv]:"Transaction exceeded max loaded accounts data size cap",[Sv]:"Transaction requires a fee but has no signature present",[_v]:"Attempt to load a program that does not exist",[Yv]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Zv]:"ResanitizationNeeded",[Ov]:"Transaction failed to sanitize accounts offsets correctly",[Tv]:"Transaction did not pass signature verification",[Dv]:"Transaction locked too many accounts",[Jv]:"Sum of account balances before and after transaction do not match",[mv]:"The transaction failed with the error `$errorName`",[kv]:"Transaction version is unsupported",[Lv]:"Transaction would exceed account data limit within the block",[Hv]:"Transaction would exceed total account data limit",[Uv]:"Transaction would exceed max account limit within the block",[Mv]:"Transaction would exceed max Block Cost Limit",[Vv]:"Transaction would exceed max Vote Cost Limit",[uv]:"Attempted to sign a transaction with an address that is not a signer for it",[sv]:"Transaction is missing an address at index: $index.",[dv]:"Transaction has no expected signers therefore it cannot be encoded",[pv]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[Yw]:"Transaction does not have a blockhash lifetime",[Jw]:"Transaction is not a durable nonce transaction",[Qw]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[ev]:"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",[nv]:"No fee payer set in CompiledTransaction",[tv]:"Could not find program address at index $index",[fv]:"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",[hv]:"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",[iv]:"Transaction is missing a fee payer.",[ov]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[cv]:"Transaction first instruction is not advance nonce account instruction.",[av]:"Transaction with no instructions cannot be durable nonce transaction.",[Ww]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Zw]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[lv]:"The transaction message expected the transaction to have $signerAddressesLength signatures, got $signaturesLength.",[rv]:"Transaction is missing signatures for addresses: $addresses.",[Xw]:"Transaction version must be in the range [0, 127]. `$actualVersion` given"},On="i",hn="t";function MR(t,e={}){const n=CR[t];if(n.length===0)return"";let r;function s(o){if(r[hn]===2){const a=n.slice(r[On]+1,o);i.push(a in e?`${e[a]}`:`$${a}`)}else r[hn]===1&&i.push(n.slice(r[On],o))}const i=[];return n.split("").forEach((o,a)=>{if(a===0){r={[On]:0,[hn]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let d;switch(r[hn]){case 0:d={[On]:a,[hn]:1};break;case 1:o==="\\"?d={[On]:a,[hn]:0}:o==="$"&&(d={[On]:a,[hn]:2});break;case 2:o==="\\"?d={[On]:a,[hn]:0}:o==="$"?d={[On]:a,[hn]:2}:o.match(/\w/)||(d={[On]:a,[hn]:1});break}d&&(r!==d&&s(a),r=d)}),s(),i.join("")}function kR(t,e={}){if(process.env.NODE_ENV!=="production")return MR(t,e);{let n=`Solana error #${t}; Decode this error by running \`npx @solana/errors decode -- ${t}`;return Object.keys(e).length&&(n+=` '${NR(e)}'`),`${n}\``}}var Fr=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=kR(t,n);super(s,r),this.context={__code:t,...n},this.name="SolanaError"}};function BR(t,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(t)}function UR(t){return Object.freeze({...t,encode:e=>{const n=new Uint8Array(BR(e,t));return t.write(e,n,0),n}})}function LR(t){return Object.freeze({...t,decode:(e,n=0)=>t.read(e,n)[0]})}function $r(t){return"fixedSize"in t&&typeof t.fixedSize=="number"}function DR(t,e){if($r(t)!==$r(e))throw new Fr(Lf);if($r(t)&&$r(e)&&t.fixedSize!==e.fixedSize)throw new Fr(Df,{decoderFixedSize:e.fixedSize,encoderFixedSize:t.fixedSize});if(!$r(t)&&!$r(e)&&t.maxSize!==e.maxSize)throw new Fr(Pf,{decoderMaxSize:e.maxSize,encoderMaxSize:t.maxSize});return{...e,...t,decode:e.decode,encode:t.encode,read:e.read,write:t.write}}function PR(t,e,n=0){if(e.length-n<=0)throw new Fr(Bf,{codecDescription:t})}function FR(t,e,n,r=0){const s=n.length-r;if(s<e)throw new Fr(Uf,{bytesLength:s,codecDescription:t,expected:e})}function $R(t,e,n,r){if(r<e||r>n)throw new Fr(Ff,{codecDescription:t,max:n,min:e,value:r})}function zf(t){return t?.endian!==1}function zR(t){return UR({fixedSize:t.size,write(e,n,r){t.range&&$R(t.name,t.range[0],t.range[1],e);const s=new ArrayBuffer(t.size);return t.set(new DataView(s),e,zf(t.config)),n.set(new Uint8Array(s),r),r+t.size}})}function jR(t){return LR({fixedSize:t.size,read(e,n=0){PR(t.name,e,n),FR(t.name,t.size,e,n);const r=new DataView(VR(e,n,t.size));return[t.get(r,zf(t.config)),n+t.size]}})}function VR(t,e,n){const r=t.byteOffset+(e??0),s=n??t.byteLength;return t.buffer.slice(r,r+s)}var HR=(t={})=>zR({config:t,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,n,r)=>e.setBigUint64(0,BigInt(n),r),size:8}),GR=(t={})=>jR({config:t,get:(e,n)=>e.getBigUint64(0,n),name:"u64",size:8}),qR=(t={})=>DR(HR(t),GR(t));class KR 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 WR(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 on(t){return typeof t=="symbol"?t.toString():typeof t=="string"?JSON.stringify(t):`${t}`}function ZR(t){const{done:e,value:n}=t.next();return e?void 0:n}function YR(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: \`${on(r)}\``}=t;return{value:r,type:o,refinement:a,key:s[s.length-1],path:s,branch:i,...t,message:d}}function*jf(t,e,n,r){WR(t)||(t=[t]);for(const s of t){const i=YR(s,e,n,r);i&&(yield i)}}function*_c(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,S]of e.entries(t,a)){const I=_c(g,S,{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 I)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):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 pn=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 jf(g,m,this,d)}:this.validator=()=>[],i?this.refiner=(d,m)=>{const g=i(d,m);return jf(g,m,this,d)}:this.refiner=()=>[]}assert(e,n){return JR(e,this,n)}create(e,n){return Ds(e,this,n)}is(e){return Vf(e,this)}mask(e,n){return XR(e,this,n)}validate(e,n={}){return Ps(e,this,n)}};function JR(t,e,n){const r=Ps(t,e,{message:n});if(r[0])throw r[0]}function Ds(t,e,n){const r=Ps(t,e,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function XR(t,e,n){const r=Ps(t,e,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}function Vf(t,e){return!Ps(t,e)[0]}function Ps(t,e,n={}){const r=_c(t,e,n),s=ZR(r);return s[0]?[new KR(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 pn({type:t,schema:null,validator:e})}function QR(){return fr("any",()=>!0)}function ce(t){return new pn({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: ${on(e)}`}})}function mn(){return fr("boolean",t=>typeof t=="boolean")}function Ec(t){return fr("instance",e=>e instanceof t||`Expected a \`${t.name}\` instance, but received: ${on(e)}`)}function qe(t){const e=on(t),n=typeof t;return new pn({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?t:null,validator(r){return r===t||`Expected the literal \`${e}\`, but received: ${on(r)}`}})}function eA(){return fr("never",()=>!1)}function ue(t){return new pn({...t,validator:(e,n)=>e===null||t.validator(e,n),refiner:(e,n)=>e===null||t.refiner(e,n)})}function H(){return fr("number",t=>typeof t=="number"&&!isNaN(t)||`Expected a number, but received: ${on(t)}`)}function he(t){return new pn({...t,validator:(e,n)=>e===void 0||t.validator(e,n),refiner:(e,n)=>e===void 0||t.refiner(e,n)})}function Hf(t,e){return new pn({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: ${on(n)}`},coercer(n){return Wi(n)?{...n}:n}})}function ie(){return fr("string",t=>typeof t=="string"||`Expected a string, but received: ${on(t)}`)}function wc(t){const e=eA();return new pn({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: ${on(n)}`},coercer(n){return Array.isArray(n)?n.slice():n}})}function ee(t){const e=Object.keys(t);return new pn({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: ${on(n)}`},coercer(n){return Wi(n)?{...n}:n}})}function zt(t){const e=t.map(n=>n.type).join(" | ");return new pn({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]=_c(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: ${on(n)}`,...s]}})}function zr(){return fr("unknown",()=>!0)}function Fs(t,e,n){return new pn({...t,coercer:(r,s)=>Vf(r,e)?t.coercer(n(r,s),s):t.coercer(r,s)})}var Zi,tA=new Uint8Array(16);function Gf(){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(tA)}const nA=/^(?:[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"&&nA.test(t)}for(var xt=[],vc=0;vc<256;++vc)xt.push((vc+256).toString(16).substr(1));function Ji(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(xt[t[e+0]]+xt[t[e+1]]+xt[t[e+2]]+xt[t[e+3]]+"-"+xt[t[e+4]]+xt[t[e+5]]+"-"+xt[t[e+6]]+xt[t[e+7]]+"-"+xt[t[e+8]]+xt[t[e+9]]+"-"+xt[t[e+10]]+xt[t[e+11]]+xt[t[e+12]]+xt[t[e+13]]+xt[t[e+14]]+xt[t[e+15]]).toLowerCase();if(!Yi(n))throw TypeError("Stringified UUID is invalid");return n}var qf,Rc,Ac=0,Sc=0;function rA(t,e,n){var r=e&&n||0,s=e||new Array(16);t=t||{};var i=t.node||qf,o=t.clockseq!==void 0?t.clockseq:Rc;if(i==null||o==null){var a=t.random||(t.rng||Gf)();i==null&&(i=qf=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),o==null&&(o=Rc=(a[6]<<8|a[7])&16383)}var d=t.msecs!==void 0?t.msecs:Date.now(),m=t.nsecs!==void 0?t.nsecs:Sc+1,g=d-Ac+(m-Sc)/1e4;if(g<0&&t.clockseq===void 0&&(o=o+1&16383),(g<0||d>Ac)&&t.nsecs===void 0&&(m=0),m>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ac=d,Sc=m,Rc=o,d+=122192928e5;var S=((d&268435455)*1e4+m)%4294967296;s[r++]=S>>>24&255,s[r++]=S>>>16&255,s[r++]=S>>>8&255,s[r++]=S&255;var I=d/4294967296*1e4&268435455;s[r++]=I>>>8&255,s[r++]=I&255,s[r++]=I>>>24&15|16,s[r++]=I>>>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||Ji(s)}function Kf(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 sA(t){t=unescape(encodeURIComponent(t));for(var e=[],n=0;n<t.length;++n)e.push(t.charCodeAt(n));return e}var iA="6ba7b810-9dad-11d1-80b4-00c04fd430c8",oA="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Wf(t,e,n){function r(s,i,o,a){if(typeof s=="string"&&(s=sA(s)),typeof i=="string"&&(i=Kf(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=iA,r.URL=oA,r}function aA(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 cA(uA(dA(t),t.length*8))}function cA(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 Zf(t){return(t+64>>>9<<4)+14+1}function uA(t,e){t[e>>5]|=128<<e%32,t[Zf(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=Ct(n,r,s,i,t[o],7,-680876936),i=Ct(i,n,r,s,t[o+1],12,-389564586),s=Ct(s,i,n,r,t[o+2],17,606105819),r=Ct(r,s,i,n,t[o+3],22,-1044525330),n=Ct(n,r,s,i,t[o+4],7,-176418897),i=Ct(i,n,r,s,t[o+5],12,1200080426),s=Ct(s,i,n,r,t[o+6],17,-1473231341),r=Ct(r,s,i,n,t[o+7],22,-45705983),n=Ct(n,r,s,i,t[o+8],7,1770035416),i=Ct(i,n,r,s,t[o+9],12,-1958414417),s=Ct(s,i,n,r,t[o+10],17,-42063),r=Ct(r,s,i,n,t[o+11],22,-1990404162),n=Ct(n,r,s,i,t[o+12],7,1804603682),i=Ct(i,n,r,s,t[o+13],12,-40341101),s=Ct(s,i,n,r,t[o+14],17,-1502002290),r=Ct(r,s,i,n,t[o+15],22,1236535329),n=Mt(n,r,s,i,t[o+1],5,-165796510),i=Mt(i,n,r,s,t[o+6],9,-1069501632),s=Mt(s,i,n,r,t[o+11],14,643717713),r=Mt(r,s,i,n,t[o],20,-373897302),n=Mt(n,r,s,i,t[o+5],5,-701558691),i=Mt(i,n,r,s,t[o+10],9,38016083),s=Mt(s,i,n,r,t[o+15],14,-660478335),r=Mt(r,s,i,n,t[o+4],20,-405537848),n=Mt(n,r,s,i,t[o+9],5,568446438),i=Mt(i,n,r,s,t[o+14],9,-1019803690),s=Mt(s,i,n,r,t[o+3],14,-187363961),r=Mt(r,s,i,n,t[o+8],20,1163531501),n=Mt(n,r,s,i,t[o+13],5,-1444681467),i=Mt(i,n,r,s,t[o+2],9,-51403784),s=Mt(s,i,n,r,t[o+7],14,1735328473),r=Mt(r,s,i,n,t[o+12],20,-1926607734),n=kt(n,r,s,i,t[o+5],4,-378558),i=kt(i,n,r,s,t[o+8],11,-2022574463),s=kt(s,i,n,r,t[o+11],16,1839030562),r=kt(r,s,i,n,t[o+14],23,-35309556),n=kt(n,r,s,i,t[o+1],4,-1530992060),i=kt(i,n,r,s,t[o+4],11,1272893353),s=kt(s,i,n,r,t[o+7],16,-155497632),r=kt(r,s,i,n,t[o+10],23,-1094730640),n=kt(n,r,s,i,t[o+13],4,681279174),i=kt(i,n,r,s,t[o],11,-358537222),s=kt(s,i,n,r,t[o+3],16,-722521979),r=kt(r,s,i,n,t[o+6],23,76029189),n=kt(n,r,s,i,t[o+9],4,-640364487),i=kt(i,n,r,s,t[o+12],11,-421815835),s=kt(s,i,n,r,t[o+15],16,530742520),r=kt(r,s,i,n,t[o+2],23,-995338651),n=Bt(n,r,s,i,t[o],6,-198630844),i=Bt(i,n,r,s,t[o+7],10,1126891415),s=Bt(s,i,n,r,t[o+14],15,-1416354905),r=Bt(r,s,i,n,t[o+5],21,-57434055),n=Bt(n,r,s,i,t[o+12],6,1700485571),i=Bt(i,n,r,s,t[o+3],10,-1894986606),s=Bt(s,i,n,r,t[o+10],15,-1051523),r=Bt(r,s,i,n,t[o+1],21,-2054922799),n=Bt(n,r,s,i,t[o+8],6,1873313359),i=Bt(i,n,r,s,t[o+15],10,-30611744),s=Bt(s,i,n,r,t[o+6],15,-1560198380),r=Bt(r,s,i,n,t[o+13],21,1309151649),n=Bt(n,r,s,i,t[o+4],6,-145523070),i=Bt(i,n,r,s,t[o+11],10,-1120210379),s=Bt(s,i,n,r,t[o+2],15,718787259),r=Bt(r,s,i,n,t[o+9],21,-343485551),n=qn(n,a),r=qn(r,d),s=qn(s,m),i=qn(i,g)}return[n,r,s,i]}function dA(t){if(t.length===0)return[];for(var e=t.length*8,n=new Uint32Array(Zf(e)),r=0;r<e;r+=8)n[r>>5]|=(t[r/8]&255)<<r%32;return n}function qn(t,e){var n=(t&65535)+(e&65535),r=(t>>16)+(e>>16)+(n>>16);return r<<16|n&65535}function lA(t,e){return t<<e|t>>>32-e}function Xi(t,e,n,r,s,i){return qn(lA(qn(qn(e,t),qn(r,i)),s),n)}function Ct(t,e,n,r,s,i,o){return Xi(e&n|~e&r,t,e,s,i,o)}function Mt(t,e,n,r,s,i,o){return Xi(e&r|n&~r,t,e,s,i,o)}function kt(t,e,n,r,s,i,o){return Xi(e^n^r,t,e,s,i,o)}function Bt(t,e,n,r,s,i,o){return Xi(n^(e|~r),t,e,s,i,o)}var fA=Wf("v3",48,aA);function hA(t,e,n){t=t||{};var r=t.random||(t.rng||Gf)();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 pA(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 xc(t,e){return t<<e|t>>>32-e}function mA(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 S=0;S<o;++S){for(var I=new Uint32Array(80),N=0;N<16;++N)I[N]=a[S][N];for(var P=16;P<80;++P)I[P]=xc(I[P-3]^I[P-8]^I[P-14]^I[P-16],1);for(var M=n[0],B=n[1],K=n[2],Y=n[3],j=n[4],U=0;U<80;++U){var V=Math.floor(U/20),J=xc(M,5)+pA(V,B,K,Y)+j+e[V]+I[U]>>>0;j=Y,Y=K,K=xc(B,30)>>>0,B=M,M=J}n[0]=n[0]+M>>>0,n[1]=n[1]+B>>>0,n[2]=n[2]+K>>>0,n[3]=n[3]+Y>>>0,n[4]=n[4]+j>>>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 gA=Wf("v5",80,mA);const yA="00000000-0000-0000-0000-000000000000";function bA(t){if(!Yi(t))throw TypeError("Invalid UUID");return parseInt(t.substr(14,1),16)}const Yf=Za(Object.freeze(Object.defineProperty({__proto__:null,NIL:yA,parse:Kf,stringify:Ji,v1:rA,v3:fA,v4:hA,v5:gA,validate:Yi,version:bA},Symbol.toStringTag,{value:"Module"})));var Tc,Jf;function _A(){if(Jf)return Tc;Jf=1;const t=Yf.v4;return Tc=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},Tc}var Ic,Xf;function EA(){if(Xf)return Ic;Xf=1;const t=Yf.v4,e=_A(),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 Ic=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 I=typeof o=="function";try{d=e(r,s,i,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(N){if(I){o(N);return}throw N}if(!I)return d}let S;try{S=JSON.stringify(d,this.options.replacer)}catch(I){o(I);return}return this.callServer(S,function(I,N){a._parseResponse(I,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)},Ic}EA();function Qf(t){try{return hc.ExtendedPoint.fromHex(t),!0}catch{return!1}}const eh=(t,e)=>hc.sign(t,e.slice(0,32)),wA=hc.verify,Oc=t=>xe.Buffer.isBuffer(t)?t:t instanceof Uint8Array?xe.Buffer.from(t.buffer,t.byteOffset,t.byteLength):xe.Buffer.from(t);class vA{constructor(e){Object.assign(this,e)}encode(){return xe.Buffer.from(bc.serialize(Qi,this))}static decode(e){return bc.deserialize(Qi,this,e)}static decodeUnchecked(e){return bc.deserializeUnchecked(Qi,this,e)}}const Qi=new Map;var th;const RA=32,Kn=32;function AA(t){return t._bn!==void 0}let nh=1;class be extends vA{constructor(e){if(super({}),this._bn=void 0,AA(e))this._bn=e._bn;else{if(typeof e=="string"){const n=$t.decode(e);if(n.length!=Kn)throw new Error("Invalid public key input");this._bn=new Tf(n)}else this._bn=new Tf(e);if(this._bn.byteLength()>Kn)throw new Error("Invalid public key input")}}static unique(){const e=new be(nh);return nh+=1,new be(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return $t.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===Kn)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=xa(s);return new be(i)}static createProgramAddressSync(e,n){let r=xe.Buffer.alloc(0);e.forEach(function(i){if(i.length>RA)throw new TypeError("Max seed length exceeded");r=xe.Buffer.concat([r,Oc(i)])}),r=xe.Buffer.concat([r,n.toBuffer(),xe.Buffer.from("ProgramDerivedAddress")]);const s=xa(r);if(Qf(s))throw new Error("Invalid seeds, address must fall off the curve");return new be(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 be(e);return Qf(n.toBytes())}}th=be,be.default=new th("11111111111111111111111111111111"),Qi.set(be,{kind:"struct",fields:[["_bn","u256"]]}),new be("BPFLoader1111111111111111111111111111111111");const jr=1232,Nc=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 Ie=(t="publicKey")=>k.blob(32,t),SA=(t="signature")=>k.blob(64,t),Vr=(t="string")=>{const e=k.struct([k.u32("length"),k.u32("lengthPadding"),k.blob(k.offset(k.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=>k.u32().span+k.u32().span+xe.Buffer.from(i,"utf8").length,s},xA=(t="authorized")=>k.struct([Ie("staker"),Ie("withdrawer")],t),TA=(t="lockup")=>k.struct([k.ns64("unixTimestamp"),k.ns64("epoch"),Ie("custodian")],t),IA=(t="voteInit")=>k.struct([Ie("nodePubkey"),Ie("authorizedVoter"),Ie("authorizedWithdrawer"),k.u8("commission")],t),OA=(t="voteAuthorizeWithSeedArgs")=>k.struct([k.u32("voteAuthorizationType"),Ie("currentAuthorityDerivedKeyOwnerPubkey"),Vr("currentAuthorityDerivedKeySeed"),Ie("newAuthorized")],t);function Yt(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 Jt(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 _t(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()];_t(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};{_t(n.length>0,"Expected at least one writable signer key");const[d]=n[0];_t(d===this.payer.toBase58(),"Expected first writable signer key to be the fee payer")}const a=[...n.map(([d])=>new be(d)),...r.map(([d])=>new be(d)),...s.map(([d])=>new be(d)),...i.map(([d])=>new be(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 be(i),d=e.findIndex(m=>m.equals(a));d>=0&&(_t(d<256,"Max lookup table index exceeded"),r.push(d),s.push(a),this.keyMetaMap.delete(i))}return[r,s]}}const rh="Reached end of buffer unexpectedly";function Nn(t){if(t.length===0)throw new Error(rh);return t.shift()}function Xt(t,...e){const[n]=e;if(e.length===2?n+(e[1]??0)>t.length:n>=t.length)throw new Error(rh);return t.splice(...e)}class Hr{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 be(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:$t.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:$t.encode(a.data)}));return new Hr({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=[];Jt(n,e);const r=this.instructions.map(S=>{const{accounts:I,programIdIndex:N}=S,P=Array.from($t.decode(S.data));let M=[];Jt(M,I.length);let B=[];return Jt(B,P.length),{programIdIndex:N,keyIndicesCount:xe.Buffer.from(M),keyIndices:I,dataLength:xe.Buffer.from(B),data:P}});let s=[];Jt(s,r.length);let i=xe.Buffer.alloc(jr);xe.Buffer.from(s).copy(i);let o=s.length;r.forEach(S=>{const N=k.struct([k.u8("programIdIndex"),k.blob(S.keyIndicesCount.length,"keyIndicesCount"),k.seq(k.u8("keyIndex"),S.keyIndices.length,"keyIndices"),k.blob(S.dataLength.length,"dataLength"),k.seq(k.u8("userdatum"),S.data.length,"data")]).encode(S,i,o);o+=N}),i=i.slice(0,o);const a=k.struct([k.blob(1,"numRequiredSignatures"),k.blob(1,"numReadonlySignedAccounts"),k.blob(1,"numReadonlyUnsignedAccounts"),k.blob(n.length,"keyCount"),k.seq(Ie("key"),e,"keys"),Ie("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(S=>Oc(S.toBytes())),recentBlockhash:$t.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=Nn(n);if(r!==(r&Nc))throw new Error("Versioned messages must be deserialized with VersionedMessage.deserialize()");const s=Nn(n),i=Nn(n),o=Yt(n);let a=[];for(let I=0;I<o;I++){const N=Xt(n,0,Kn);a.push(new be(xe.Buffer.from(N)))}const d=Xt(n,0,Kn),m=Yt(n);let g=[];for(let I=0;I<m;I++){const N=Nn(n),P=Yt(n),M=Xt(n,0,P),B=Yt(n),K=Xt(n,0,B),Y=$t.encode(xe.Buffer.from(K));g.push({programIdIndex:N,accounts:M,data:Y})}const S={header:{numRequiredSignatures:r,numReadonlySignedAccounts:s,numReadonlyUnsignedAccounts:i},recentBlockhash:$t.encode(xe.Buffer.from(d)),accountKeys:a,instructions:g};return new Hr(S)}}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 S=n.extractTableLookup(g);if(S!==void 0){const[I,{writable:N,readonly:P}]=S;r.push(I),s.writable.push(...N),s.readonly.push(...P)}}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();Jt(e,this.staticAccountKeys.length);const n=this.serializeInstructions(),r=Array();Jt(r,this.compiledInstructions.length);const s=this.serializeAddressTableLookups(),i=Array();Jt(i,this.addressTableLookups.length);const o=k.struct([k.u8("prefix"),k.struct([k.u8("numRequiredSignatures"),k.u8("numReadonlySignedAccounts"),k.u8("numReadonlyUnsignedAccounts")],"header"),k.blob(e.length,"staticAccountKeysLength"),k.seq(Ie(),this.staticAccountKeys.length,"staticAccountKeys"),Ie("recentBlockhash"),k.blob(r.length,"instructionsLength"),k.blob(n.length,"serializedInstructions"),k.blob(i.length,"addressTableLookupsLength"),k.blob(s.length,"serializedAddressTableLookups")]),a=new Uint8Array(jr),m=o.encode({prefix:128,header:this.header,staticAccountKeysLength:new Uint8Array(e),staticAccountKeys:this.staticAccountKeys.map(g=>g.toBytes()),recentBlockhash:$t.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(jr);for(const r of this.compiledInstructions){const s=Array();Jt(s,r.accountKeyIndexes.length);const i=Array();Jt(i,r.data.length);const o=k.struct([k.u8("programIdIndex"),k.blob(s.length,"encodedAccountKeyIndexesLength"),k.seq(k.u8(),r.accountKeyIndexes.length,"accountKeyIndexes"),k.blob(i.length,"encodedDataLength"),k.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(jr);for(const r of this.addressTableLookups){const s=Array();Jt(s,r.writableIndexes.length);const i=Array();Jt(i,r.readonlyIndexes.length);const o=k.struct([Ie("accountKey"),k.blob(s.length,"encodedWritableIndexesLength"),k.seq(k.u8(),r.writableIndexes.length,"writableIndexes"),k.blob(i.length,"encodedReadonlyIndexesLength"),k.seq(k.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&Nc;_t(r!==s,"Expected versioned message but received legacy message");const i=s;_t(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=Yt(n);for(let P=0;P<d;P++)a.push(new be(Xt(n,0,Kn)));const m=$t.encode(Xt(n,0,Kn)),g=Yt(n),S=[];for(let P=0;P<g;P++){const M=Nn(n),B=Yt(n),K=Xt(n,0,B),Y=Yt(n),j=new Uint8Array(Xt(n,0,Y));S.push({programIdIndex:M,accountKeyIndexes:K,data:j})}const I=Yt(n),N=[];for(let P=0;P<I;P++){const M=new be(Xt(n,0,Kn)),B=Yt(n),K=Xt(n,0,B),Y=Yt(n),j=Xt(n,0,Y);N.push({accountKey:M,writableIndexes:K,readonlyIndexes:j})}return new ro({header:o,staticAccountKeys:a,recentBlockhash:m,compiledInstructions:S,addressTableLookups:N})}}const Cc={deserializeMessageVersion(t){const e=t[0],n=e&Nc;return n===e?"legacy":n},deserialize:t=>{const e=Cc.deserializeMessageVersion(t);if(e==="legacy")return Hr.from(t);if(e===0)return ro.deserialize(t);throw new Error(`Transaction message version ${e} deserialization is not supported`)}},NA=xe.Buffer.alloc(eo).fill(0);class sh{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 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 sh(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 B=M.programId.toString();s.includes(B)||s.push(B)}),s.forEach(M=>{i.push({pubkey:new be(M),isSigner:!1,isWritable:!1})});const o=[];i.forEach(M=>{const B=M.pubkey.toString(),K=o.findIndex(Y=>Y.pubkey.toString()===B);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,B){if(M.isSigner!==B.isSigner)return M.isSigner?-1:1;if(M.isWritable!==B.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(B.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 B=o.findIndex(K=>K.pubkey.equals(M.publicKey));if(B>-1)o[B].isSigner||(o[B].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 S=[],I=[];o.forEach(({pubkey:M,isSigner:B,isWritable:K})=>{B?(S.push(M.toString()),d+=1,K||(m+=1)):(I.push(M.toString()),K||(g+=1))});const N=S.concat(I),P=n.map(M=>{const{data:B,programId:K}=M;return{programIdIndex:N.indexOf(K.toString()),accounts:M.keys.map(Y=>N.indexOf(Y.pubkey.toString())),data:$t.encode(B)}});return P.forEach(M=>{_t(M.programIdIndex>=0),M.accounts.forEach(B=>_t(B>=0))}),new Hr({header:{numRequiredSignatures:d,numReadonlySignedAccounts:m,numReadonlyUnsignedAccounts:g},accountKeys:N,recentBlockhash:e,instructions:P})}_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=eh(r,s.secretKey);this._addSignature(s.publicKey,Oc(i))})}addSignature(e,n){this._compile(),this._addSignature(e,n)}_addSignature(e,n){_t(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):wA(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
|
+
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=[];Jt(r,n.length);const s=r.length+n.length*64+e.length,i=xe.Buffer.alloc(s);return _t(n.length<256),xe.Buffer.from(r).copy(i,0),n.forEach(({signature:o},a)=>{o!==null&&(_t(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),_t(i.length<=jr,`Transaction too large: ${i.length} > ${jr}`),i}get keys(){return _t(this.instructions.length===1),this.instructions[0].keys.map(e=>e.pubkey)}get programId(){return _t(this.instructions.length===1),this.instructions[0].programId}get data(){return _t(this.instructions.length===1),this.instructions[0].data}static from(e){let n=[...e];const r=Yt(n);let s=[];for(let i=0;i<r;i++){const o=Xt(n,0,eo);s.push($t.encode(xe.Buffer.from(o)))}return so.populate(Hr.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==$t.encode(NA)?null:$t.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 sh({keys:i,programId:e.accountKeys[s.programIdIndex],data:$t.decode(s.data)}))}),r._message=e,r._json=r.toJSON(),r}}class Mc{get version(){return this.message.version}constructor(e,n){if(this.signatures=void 0,this.message=void 0,n!==void 0)_t(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();Jt(n,this.signatures.length);const r=k.struct([k.blob(n.length,"encodedSignaturesLength"),k.seq(SA(),this.signatures.length,"signatures"),k.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=Yt(n);for(let o=0;o<s;o++)r.push(new Uint8Array(Xt(n,0,eo)));const i=Cc.deserialize(new Uint8Array(n));return new Mc(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));_t(i>=0,`Cannot sign with non signer key ${s.publicKey.toBase58()}`),this.signatures[i]=eh(n,s.secretKey)}}addSignature(e,n){_t(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));_t(s>=0,`Can not add signature; \`${e.toBase58()}\` is not required to sign this transaction`),this.signatures[s]=n}}new be("SysvarC1ock11111111111111111111111111111111"),new be("SysvarEpochSchedu1e111111111111111111111111"),new be("Sysvar1nstructions1111111111111111111111111"),new be("SysvarRecentB1ockHashes11111111111111111111"),new be("SysvarRent111111111111111111111111111111111"),new be("SysvarRewards111111111111111111111111111111"),new be("SysvarS1otHashes111111111111111111111111111"),new be("SysvarS1otHistory11111111111111111111111111"),new be("SysvarStakeHistory1111111111111111111111111");const CA=k.nu64("lamportsPerSignature");k.struct([k.u32("version"),k.u32("state"),Ie("authorizedPubkey"),Ie("nonce"),k.struct([CA],"feeCalculator")]).span;function Gr(t){const e=k.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),s=e,i=qR();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:k.struct([k.u32("instruction"),k.ns64("lamports"),k.ns64("space"),Ie("programId")])},Assign:{index:1,layout:k.struct([k.u32("instruction"),Ie("programId")])},Transfer:{index:2,layout:k.struct([k.u32("instruction"),Gr("lamports")])},CreateWithSeed:{index:3,layout:k.struct([k.u32("instruction"),Ie("base"),Vr("seed"),k.ns64("lamports"),k.ns64("space"),Ie("programId")])},AdvanceNonceAccount:{index:4,layout:k.struct([k.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:k.struct([k.u32("instruction"),Ie("authorized")])},AuthorizeNonceAccount:{index:7,layout:k.struct([k.u32("instruction"),Ie("authorized")])},Allocate:{index:8,layout:k.struct([k.u32("instruction"),k.ns64("space")])},AllocateWithSeed:{index:9,layout:k.struct([k.u32("instruction"),Ie("base"),Vr("seed"),k.ns64("space"),Ie("programId")])},AssignWithSeed:{index:10,layout:k.struct([k.u32("instruction"),Ie("base"),Vr("seed"),Ie("programId")])},TransferWithSeed:{index:11,layout:k.struct([k.u32("instruction"),Gr("lamports"),Vr("seed"),Ie("programId")])},UpgradeNonceAccount:{index:12,layout:k.struct([k.u32("instruction")])}}),new be("11111111111111111111111111111111"),new be("BPFLoader2111111111111111111111111111111111"),k.struct([k.u32("typeIndex"),Gr("deactivationSlot"),k.nu64("lastExtendedSlot"),k.u8("lastExtendedStartIndex"),k.u8(),k.seq(Ie(),k.offset(k.u8(),-1),"authority")]);const Ze=Fs(Ec(be),ie(),t=>new be(t)),ih=wc([ie(),qe("base64")]),kc=Fs(Ec(xe.Buffer),ih,t=>xe.Buffer.from(t[0],"base64"));function oh(t){return zt([ee({jsonrpc:qe("2.0"),id:ie(),result:t}),ee({jsonrpc:qe("2.0"),id:ie(),error:ee({code:zr(),message:ie(),data:he(QR())})})])}const MA=oh(zr());function Pe(t){return Fs(oh(t),MA,e=>"error"in e?e:{...e,result:Ds(e.result,t)})}function an(t){return Pe(ee({context:ee({slot:H()}),value:t}))}function io(t){return ee({context:ee({slot:H()}),value:t})}const kA=ee({foundation:H(),foundationTerm:H(),initial:H(),taper:H(),terminal:H()});Pe(ce(ue(ee({epoch:H(),effectiveSlot:H(),amount:H(),postBalance:H(),commission:he(ue(H()))}))));const BA=ce(ee({slot:H(),prioritizationFee:H()})),UA=ee({total:H(),validator:H(),foundation:H(),epoch:H()}),LA=ee({epoch:H(),slotIndex:H(),slotsInEpoch:H(),absoluteSlot:H(),blockHeight:he(H()),transactionCount:he(H())}),DA=ee({slotsPerEpoch:H(),leaderScheduleSlotOffset:H(),warmup:mn(),firstNormalEpoch:H(),firstNormalSlot:H()}),PA=Hf(ie(),ce(H())),hr=ue(zt([ee({}),ie()])),FA=ee({err:hr}),$A=qe("receivedSignature");ee({"solana-core":ie(),"feature-set":he(H())});const zA=ee({program:ie(),programId:Ze,parsed:zr()}),jA=ee({programId:Ze,accounts:ce(Ze),data:ie()});an(ee({err:ue(zt([ee({}),ie()])),logs:ue(ce(ie())),accounts:he(ue(ce(ue(ee({executable:mn(),owner:ie(),lamports:H(),data:ce(ie()),rentEpoch:he(H())}))))),unitsConsumed:he(H()),returnData:he(ue(ee({programId:ie(),data:wc([ie(),qe("base64")])}))),innerInstructions:he(ue(ce(ee({index:H(),instructions:ce(zt([zA,jA]))}))))})),an(ee({byIdentity:Hf(ie(),ce(H())),range:ee({firstSlot:H(),lastSlot:H()})})),Pe(kA),Pe(UA),Pe(BA),Pe(LA),Pe(DA),Pe(PA),Pe(H()),an(ee({total:H(),circulating:H(),nonCirculating:H(),nonCirculatingAccounts:ce(Ze)}));const VA=ee({amount:ie(),uiAmount:ue(H()),decimals:H(),uiAmountString:he(ie())});an(ce(ee({address:Ze,amount:ie(),uiAmount:ue(H()),decimals:H(),uiAmountString:he(ie())}))),an(ce(ee({pubkey:Ze,account:ee({executable:mn(),owner:Ze,lamports:H(),data:kc,rentEpoch:H()})})));const Bc=ee({program:ie(),parsed:zr(),space:H()});an(ce(ee({pubkey:Ze,account:ee({executable:mn(),owner:Ze,lamports:H(),data:Bc,rentEpoch:H()})}))),an(ce(ee({lamports:H(),address:Ze})));const Uc=ee({executable:mn(),owner:Ze,lamports:H(),data:kc,rentEpoch:H()});ee({pubkey:Ze,account:Uc});const HA=Fs(zt([Ec(xe.Buffer),Bc]),zt([ih,Bc]),t=>Array.isArray(t)?Ds(t,kc):t),GA=ee({executable:mn(),owner:Ze,lamports:H(),data:HA,rentEpoch:H()});ee({pubkey:Ze,account:GA}),ee({state:zt([qe("active"),qe("inactive"),qe("activating"),qe("deactivating")]),active:H(),inactive:H()}),Pe(ce(ee({signature:ie(),slot:H(),err:hr,memo:ue(ie()),blockTime:he(ue(H()))}))),Pe(ce(ee({signature:ie(),slot:H(),err:hr,memo:ue(ie()),blockTime:he(ue(H()))}))),ee({subscription:H(),result:io(Uc)});const qA=ee({pubkey:Ze,account:Uc});ee({subscription:H(),result:io(qA)});const KA=ee({parent:H(),slot:H(),root:H()});ee({subscription:H(),result:KA});const WA=zt([ee({type:zt([qe("firstShredReceived"),qe("completed"),qe("optimisticConfirmation"),qe("root")]),slot:H(),timestamp:H()}),ee({type:qe("createdBank"),parent:H(),slot:H(),timestamp:H()}),ee({type:qe("frozen"),slot:H(),timestamp:H(),stats:ee({numTransactionEntries:H(),numSuccessfulTransactions:H(),numFailedTransactions:H(),maxTransactionsPerEntry:H()})}),ee({type:qe("dead"),slot:H(),timestamp:H(),err:ie()})]);ee({subscription:H(),result:WA}),ee({subscription:H(),result:io(zt([FA,$A]))}),ee({subscription:H(),result:H()}),ee({pubkey:ie(),gossip:ue(ie()),tpu:ue(ie()),rpc:ue(ie()),version:ue(ie())});const ah=ee({votePubkey:ie(),nodePubkey:ie(),activatedStake:H(),epochVoteAccount:mn(),epochCredits:ce(wc([H(),H(),H()])),commission:H(),lastVote:H(),rootSlot:ue(H())});Pe(ee({current:ce(ah),delinquent:ce(ah)}));const ZA=zt([qe("processed"),qe("confirmed"),qe("finalized")]),YA=ee({slot:H(),confirmations:ue(H()),err:hr,confirmationStatus:he(ZA)});an(ce(ue(YA))),Pe(H());const ch=ee({accountKey:Ze,writableIndexes:ce(H()),readonlyIndexes:ce(H())}),Lc=ee({signatures:ce(ie()),message:ee({accountKeys:ce(ie()),header:ee({numRequiredSignatures:H(),numReadonlySignedAccounts:H(),numReadonlyUnsignedAccounts:H()}),instructions:ce(ee({accounts:ce(H()),data:ie(),programIdIndex:H()})),recentBlockhash:ie(),addressTableLookups:he(ce(ch))})}),uh=ee({pubkey:Ze,signer:mn(),writable:mn(),source:he(zt([qe("transaction"),qe("lookupTable")]))}),dh=ee({accountKeys:ce(uh),signatures:ce(ie())}),lh=ee({parsed:zr(),program:ie(),programId:Ze}),fh=ee({accounts:ce(Ze),data:ie(),programId:Ze}),JA=zt([fh,lh]),XA=zt([ee({parsed:zr(),program:ie(),programId:ie()}),ee({accounts:ce(ie()),data:ie(),programId:ie()})]),hh=Fs(JA,XA,t=>"accounts"in t?Ds(t,fh):Ds(t,lh)),ph=ee({signatures:ce(ie()),message:ee({accountKeys:ce(uh),instructions:ce(hh),recentBlockhash:ie(),addressTableLookups:he(ue(ce(ch)))})}),oo=ee({accountIndex:H(),mint:ie(),owner:he(ie()),programId:he(ie()),uiTokenAmount:VA}),mh=ee({writable:ce(Ze),readonly:ce(Ze)}),ao=ee({err:hr,fee:H(),innerInstructions:he(ue(ce(ee({index:H(),instructions:ce(ee({accounts:ce(H()),data:ie(),programIdIndex:H()}))})))),preBalances:ce(H()),postBalances:ce(H()),logMessages:he(ue(ce(ie()))),preTokenBalances:he(ue(ce(oo))),postTokenBalances:he(ue(ce(oo))),loadedAddresses:he(mh),computeUnitsConsumed:he(H()),costUnits:he(H())}),Dc=ee({err:hr,fee:H(),innerInstructions:he(ue(ce(ee({index:H(),instructions:ce(hh)})))),preBalances:ce(H()),postBalances:ce(H()),logMessages:he(ue(ce(ie()))),preTokenBalances:he(ue(ce(oo))),postTokenBalances:he(ue(ce(oo))),loadedAddresses:he(mh),computeUnitsConsumed:he(H()),costUnits:he(H())}),qr=zt([qe(0),qe("legacy")]),pr=ee({pubkey:ie(),lamports:H(),postBalance:ue(H()),rewardType:ue(ie()),commission:he(ue(H()))});Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:Lc,meta:ue(ao),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:dh,meta:ue(ao),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:ph,meta:ue(Dc),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:dh,meta:ue(Dc),version:he(qr)})),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),rewards:he(ce(pr)),blockTime:ue(H()),blockHeight:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),transactions:ce(ee({transaction:Lc,meta:ue(ao)})),rewards:he(ce(pr)),blockTime:ue(H())}))),Pe(ue(ee({blockhash:ie(),previousBlockhash:ie(),parentSlot:H(),signatures:ce(ie()),blockTime:ue(H())}))),Pe(ue(ee({slot:H(),meta:ue(ao),blockTime:he(ue(H())),transaction:Lc,version:he(qr)}))),Pe(ue(ee({slot:H(),transaction:ph,meta:ue(Dc),blockTime:he(ue(H())),version:he(qr)}))),an(ee({blockhash:ie(),lastValidBlockHeight:H()})),an(mn());const QA=ee({slot:H(),numTransactions:H(),numSlots:H(),samplePeriodSecs:H()});Pe(ce(QA)),an(ue(ee({feeCalculator:ee({lamportsPerSignature:H()})}))),Pe(ie()),Pe(ie());const eS=ee({err:hr,logs:ce(ie()),signature:ie()});ee({result:io(eS),subscription:H()}),Object.freeze({CreateLookupTable:{index:0,layout:k.struct([k.u32("instruction"),Gr("recentSlot"),k.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:k.struct([k.u32("instruction")])},ExtendLookupTable:{index:2,layout:k.struct([k.u32("instruction"),Gr(),k.seq(Ie(),k.offset(k.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:k.struct([k.u32("instruction")])},CloseLookupTable:{index:4,layout:k.struct([k.u32("instruction")])}}),new be("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:k.struct([k.u8("instruction"),k.u32("units"),k.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:k.struct([k.u8("instruction"),k.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:k.struct([k.u8("instruction"),k.u32("units")])},SetComputeUnitPrice:{index:3,layout:k.struct([k.u8("instruction"),Gr("microLamports")])}}),new be("ComputeBudget111111111111111111111111111111"),k.struct([k.u8("numSignatures"),k.u8("padding"),k.u16("signatureOffset"),k.u16("signatureInstructionIndex"),k.u16("publicKeyOffset"),k.u16("publicKeyInstructionIndex"),k.u16("messageDataOffset"),k.u16("messageDataSize"),k.u16("messageInstructionIndex")]),new be("Ed25519SigVerify111111111111111111111111111"),ja.utils.isValidPrivateKey,ja.getPublicKey,k.struct([k.u8("numSignatures"),k.u16("signatureOffset"),k.u8("signatureInstructionIndex"),k.u16("ethAddressOffset"),k.u8("ethAddressInstructionIndex"),k.u16("messageDataOffset"),k.u16("messageDataSize"),k.u8("messageInstructionIndex"),k.blob(20,"ethAddress"),k.blob(64,"signature"),k.u8("recoveryId")]),new be("KeccakSecp256k11111111111111111111111111111");var gh;new be("StakeConfig11111111111111111111111111111111");class yh{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}}gh=yh,yh.default=new gh(0,0,be.default),Object.freeze({Initialize:{index:0,layout:k.struct([k.u32("instruction"),xA(),TA()])},Authorize:{index:1,layout:k.struct([k.u32("instruction"),Ie("newAuthorized"),k.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:k.struct([k.u32("instruction")])},Split:{index:3,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},Withdraw:{index:4,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},Deactivate:{index:5,layout:k.struct([k.u32("instruction")])},Merge:{index:7,layout:k.struct([k.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:k.struct([k.u32("instruction"),Ie("newAuthorized"),k.u32("stakeAuthorizationType"),Vr("authoritySeed"),Ie("authorityOwner")])}}),new be("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:k.struct([k.u32("instruction"),IA()])},Authorize:{index:1,layout:k.struct([k.u32("instruction"),Ie("newAuthorized"),k.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:k.struct([k.u32("instruction"),k.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:k.struct([k.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:k.struct([k.u32("instruction"),OA()])}}),new be("Vote111111111111111111111111111111111111111"),new be("Va1idator1nfo111111111111111111111111111111"),ee({name:ie(),website:he(ie()),details:he(ie()),iconUrl:he(ie()),keybaseUsername:he(ie())}),new be("Vote111111111111111111111111111111111111111"),k.struct([Ie("nodePubkey"),Ie("authorizedWithdrawer"),k.u8("commission"),k.nu64(),k.seq(k.struct([k.nu64("slot"),k.u32("confirmationCount")]),k.offset(k.u32(),-8),"votes"),k.u8("rootSlotValid"),k.nu64("rootSlot"),k.nu64(),k.seq(k.struct([k.nu64("epoch"),Ie("authorizedVoter")]),k.offset(k.u32(),-8),"authorizedVoters"),k.struct([k.seq(k.struct([Ie("authorizedPubkey"),k.nu64("epochOfLastAuthorizedSwitch"),k.nu64("targetEpoch")]),32,"buf"),k.nu64("idx"),k.u8("isEmpty")],"priorVoters"),k.nu64(),k.seq(k.struct([k.nu64("epoch"),k.nu64("credits"),k.nu64("prevCredits")]),k.offset(k.u32(),-8),"epochCredits"),k.struct([k.nu64("slot"),k.nu64("timestamp")],"lastTimestamp")]);const tS=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 bh(t){return Buffer.from(t.serialize({verifySignatures:!1})).toString("base64")}function nS(t){const e=Buffer.from(t,"base64");return Cc.deserializeMessageVersion(e)==="legacy"?Mc.deserialize(e):so.from(e)}function rS(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:bh(r)};return await t({method:"signAndSendTransaction",params:s})}if(n.method==="signTransaction"){const{transaction:r}=n.params,s={transaction:bh(r)},{signedTransaction:i}=await t({method:"signTransaction",params:s});return{signedTransaction:nS(i)}}}}const sS=({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=iS({back:this,emitter:e})},async disableWebNavigation(){n?.(),n=void 0}}};function iS({emitter:t,back:e}){const n=oS();if(n)return aS({emitter:t,back:e,navigation:n});if(typeof window<"u")return cS({emitter:t,back:e,window})}function oS(){if(typeof window<"u"&&window.navigation!==void 0)return window.navigation}function aS({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 cS({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 uS="0.1.1";function dS(){return uS}let lS=class Su extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof Su){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 Su&&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@${dS()}`}),this.cause=n.cause,this.details=r,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return _h(this,e)}};function _h(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?_h(t.cause,e):e?null:t}function Eh(t,e={}){const{raw:n=!1}=e,r=t;if(n)return t;if(r.error){const{code:s}=r.error,i=s===Kr.code?Kr:s===$s.code?$s:s===Zs.code?Zs:s===Ks.code?Ks:s===Gs.code?Gs:s===Ws.code?Ws:s===Hs.code?Hs:s===Ys.code?Ys:s===zs.code?zs:s===js.code?js:s===Vs.code?Vs:s===qs.code?qs:Kt;throw new i(r.error)}return r.result}let Kt=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 $s extends Kt{constructor(e={}){super({message:"Missing or invalid parameters.",...e,code:$s.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($s,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class zs extends Kt{constructor(e={}){super({message:"Requested resource not found.",...e,code:zs.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(zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class js extends Kt{constructor(e={}){super({message:"Requested resource not available.",...e,code:js.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(js,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class Vs extends Kt{constructor(e={}){super({message:"Transaction creation failed.",...e,code:Vs.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(Vs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class Hs extends Kt{constructor(e={}){super({message:"Method is not implemented.",...e,code:Hs.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(Hs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class Gs extends Kt{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 qs extends Kt{constructor(e={}){super({message:"JSON-RPC version not supported.",...e,code:qs.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(qs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class Ks extends Kt{constructor(e={}){super({message:"Input is not a valid JSON-RPC request.",...e,code:Ks.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(Ks,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Ws extends Kt{constructor(e={}){super({message:"Method does not exist.",...e,code:Ws.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(Ws,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Zs extends Kt{constructor(e={}){super({message:"Invalid method parameters.",...e,code:Zs.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(Zs,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class Kr extends Kt{constructor(e={}){super({message:"Internal JSON-RPC error.",...e,code:Kr.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(Kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class Ys extends Kt{constructor(e={}){super({message:"Failed to parse JSON-RPC response.",...e,code:Ys.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(Ys,"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 vh 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(vh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Rh 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(Rh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Ah 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(Ah,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Sh 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(Sh,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});function fS(){const t=new Zl;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 hS(t,e={}){const{includeEvents:n=!0}=e;if(!t)throw new pS;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?Eh(s):s}}}class pS extends lS{constructor(){super("`provider` is undefined."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Provider.IsUndefinedError"})}}function mS(t={}){let e=t.id??0;return{prepare(n){return gS({id:e++,...n})},get id(){return e}}}function gS(t){return{...t,jsonrpc:"2.0"}}/**
|
|
36
|
+
* @license
|
|
37
|
+
* Copyright 2019 Google LLC
|
|
38
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
39
|
+
*/const xh=Symbol("Comlink.proxy"),yS=Symbol("Comlink.endpoint"),bS=Symbol("Comlink.releaseProxy"),Pc=Symbol("Comlink.finalizer"),co=Symbol("Comlink.thrown"),Th=t=>typeof t=="object"&&t!==null||typeof t=="function",_S={canHandle:t=>Th(t)&&t[xh],serialize(t){const{port1:e,port2:n}=new MessageChannel;return Oh(t,e),[n,[n]]},deserialize(t){return t.start(),Ch(t)}},ES={canHandle:t=>Th(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}},Ih=new Map([["proxy",_S],["throw",ES]]);function wS(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(!wS(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((I,N)=>I[N],t),S=a.reduce((I,N)=>I[N],t);switch(o){case"GET":m=S;break;case"SET":g[a.slice(-1)[0]]=gr(s.data.value),m=!0;break;case"APPLY":m=S.apply(g,d);break;case"CONSTRUCT":{const I=new S(...d);m=TS(I)}break;case"ENDPOINT":{const{port1:I,port2:N}=new MessageChannel;Oh(t,N),m=xS(I,[I])}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[S,I]=ho(g);e.postMessage(Object.assign(Object.assign({},S),{id:i}),I),o==="RELEASE"&&(e.removeEventListener("message",r),Nh(e),Pc in t&&typeof t[Pc]=="function"&&t[Pc]())}).catch(g=>{const[S,I]=ho({value:new TypeError("Unserializable return value"),[co]:0});e.postMessage(Object.assign(Object.assign({},S),{id:i}),I)})}),e.start&&e.start()}function vS(t){return t.constructor.name==="MessagePort"}function Nh(t){vS(t)&&t.close()}function Ch(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 Mh(t){return Wr(t,new Map,{type:"RELEASE"}).then(()=>{Nh(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&&Mh(t)});function RS(t,e){const n=(lo.get(e)||0)+1;lo.set(e,n),fo&&fo.register(t,e,t)}function AS(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===bS)return()=>{AS(i),Mh(t),e.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>i};const d=Wr(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 Wr(t,e,{type:"SET",path:[...n,a].map(S=>S.toString()),value:m},g).then(gr)},apply(o,a,d){uo(s);const m=n[n.length-1];if(m===yS)return Wr(t,e,{type:"ENDPOINT"}).then(gr);if(m==="bind")return Fc(t,e,n.slice(0,-1));const[g,S]=kh(d);return Wr(t,e,{type:"APPLY",path:n.map(I=>I.toString()),argumentList:g},S).then(gr)},construct(o,a){uo(s);const[d,m]=kh(a);return Wr(t,e,{type:"CONSTRUCT",path:n.map(g=>g.toString()),argumentList:d},m).then(gr)}});return RS(i,t),i}function SS(t){return Array.prototype.concat.apply([],t)}function kh(t){const e=t.map(ho);return[e.map(n=>n[0]),SS(e.map(n=>n[1]))]}const Bh=new WeakMap;function xS(t,e){return Bh.set(t,e),t}function TS(t){return Object.assign(t,{[xh]:!0})}function IS(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 Ih)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 Ih.get(t.name).deserialize(t.value);case"RAW":return t.value}}function Wr(t,e,n,r){return new Promise(s=>{const i=OS();e.set(i,s),t.start&&t.start(),t.postMessage(Object.assign({id:i},n),r)})}function OS(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}const NS={postMessage(){},addEventListener:()=>{},removeEventListener:()=>{}},CS={postMessage:t=>{window.ReactNativeWebView.postMessage(JSON.stringify(t))},addEventListener:(t,e,...n)=>{document.addEventListener("FarcasterFrameCallback",e,...n)},removeEventListener:(t,e)=>{document.removeEventListener("FarcasterFrameCallback",e)}},MS=typeof window>"u"?NS:window?.ReactNativeWebView?CS:IS(window?.parent??window),_e=Ch(MS),$c=fS(),kS=mS();function BS({code:t,details:e}){switch(t){case 4001:return new wh;case 4100:return new vh;case 4200:return new Rh;case 4900:return new Ah;case 4901:return new Sh;default:return new mr(t,e??"Unknown provider RPC error")}}const Js=hS({...$c,async request(t){const e=kS.prepare(t);try{const n=await _e.ethProviderRequestV2(e).then(r=>Eh(r,{request:e,raw:!0}));if(n.error)throw BS(n.error);return n.result}catch(n){if(n instanceof Error&&n.message.match(/cannot read property 'apply'/i))return await _e.ethProviderRequest(e);throw n instanceof mr||n instanceof Kt?n:new Kr({message:n instanceof Error?n.message:void 0})}}});async function US(){try{const t=await _e.getCapabilities();return!t.includes("wallet.getEthereumProvider")&&!t.includes("wallet.getEvmProvider")?void 0:Js}catch{return Js}}function Uh(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",()=>{_e.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"&&Uh({info:e.info,provider:Js})}})),typeof window<"u"&&(window.addEventListener("eip6963:requestProvider",()=>{_e.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"&&Uh({info:e.info,provider:Js})}})),new TextEncoder;const Lh=new TextDecoder,LS=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},DS=t=>{let e=t;e instanceof Uint8Array&&(e=Lh.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return LS(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};function PS(t){return typeof t=="object"&&t!==null}function FS(t){if(!PS(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 jt extends Error{constructor(e,n){super(e,n),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,Error.captureStackTrace?.(this,this.constructor)}}jt.code="ERR_JOSE_GENERIC";class $S extends jt{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}}$S.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class zS extends jt{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}}zS.code="ERR_JWT_EXPIRED";class jS extends jt{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}jS.code="ERR_JOSE_ALG_NOT_ALLOWED";class VS extends jt{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}VS.code="ERR_JOSE_NOT_SUPPORTED";class HS extends jt{constructor(e="decryption operation failed",n){super(e,n),this.code="ERR_JWE_DECRYPTION_FAILED"}}HS.code="ERR_JWE_DECRYPTION_FAILED";class GS extends jt{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}GS.code="ERR_JWE_INVALID";class qS extends jt{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}qS.code="ERR_JWS_INVALID";class Wn extends jt{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}Wn.code="ERR_JWT_INVALID";class KS extends jt{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}KS.code="ERR_JWK_INVALID";class WS extends jt{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}WS.code="ERR_JWKS_INVALID";class ZS extends jt{constructor(e="no applicable key found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_NO_MATCHING_KEY"}}ZS.code="ERR_JWKS_NO_MATCHING_KEY";class YS extends jt{constructor(e="multiple matching keys found in the JSON Web Key Set",n){super(e,n),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}YS.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class JS extends jt{constructor(e="request timed out",n){super(e,n),this.code="ERR_JWKS_TIMEOUT"}}JS.code="ERR_JWKS_TIMEOUT";class XS extends jt{constructor(e="signature verification failed",n){super(e,n),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}XS.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function QS(t){if(typeof t!="string")throw new Wn("JWTs must use Compact JWS serialization, JWT must be a string");const{1:e,length:n}=t.split(".");if(n===5)throw new Wn("Only JWTs using Compact JWS serialization can be decoded");if(n!==3)throw new Wn("Invalid JWT");if(!e)throw new Wn("JWTs must contain a payload");let r;try{r=DS(e)}catch{throw new Wn("Failed to base64url decode the payload")}let s;try{s=JSON.parse(Lh.decode(r))}catch{throw new Wn("Failed to parse the decoded payload as JSON")}if(!FS(s))throw new Wn("Invalid JWT Claims Set");return s}function ex(t){return QS(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(`
|
|
40
|
+
`);super(s,n.cause?{cause:n.cause}:void 0),this.name="BaseError",this.cause=n.cause,this.details=r,this.shortMessage=e}}class Dh extends po{constructor({status:e}){super(`Request failed with status ${e}`),this.name="RequestFailedError"}}class tx extends po{constructor(e){super(e),this.name="InvalidToken"}}async function nx({origin:t}){const e=await fetch(`${t}/nonce`,{method:"POST"});if(!e.ok)throw new Dh({status:e.status});return await e.json()}async function rx({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 Dh({status:n.status});const r=await n.json();if(r.valid===!1)throw new tx(r.message??"unknown");return{token:r.token}}function sx(t={}){return{origin:t.origin??"https://auth.farcaster.xyz"}}function ix(t={}){const e=sx(t);return{generateNonce:()=>nx(e),verifySiwf:n=>rx(e,n)}}const ox=/^(?:(?<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)?/,ax=/(?: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 cx(t){const{scheme:e,statement:n,...r}=t.match(ox)?.groups??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:d,...m}=t.match(ax)?.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 Ph=(()=>{let t,e;async function n(r){const s=ix({origin:r.quickAuthServerOrigin}),{nonce:i}=await s.generateNonce(),o=await _e.signIn({nonce:i,acceptAuthAddress:!0});if(o.result){const a=cx(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:ex(d.token)},d}throw o.error.type==="rejected_by_user"?new Yl: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 ux(){const t=new Zl;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 Ut=ux(),{solanaProviderRequest:Fh}=_e;let $h;Fh&&($h=tS(rS(Fh)));async function zh(){let t;try{t=await _e.getCapabilities()}catch{}if(t?.includes("wallet.getSolanaProvider"))return $h}let jh=null;async function dx(t=1e3){if(jh===!0)return!0;if(typeof window>"u"||!window.ReactNativeWebView&&window===window.parent)return!1;const e=await Promise.race([_e.context.then(n=>!!n),new Promise(n=>{setTimeout(()=>n(!1),t)})]).catch(()=>!1);return e&&(jh=!0),e}const Vh=async()=>{const t=await _e.addFrame();if(t.result)return t.result;throw t.error.type==="invalid_domain_manifest"?new V1:t.error.type==="rejected_by_user"?new H1:new Error("Unreachable")},Hh={...Ut,getCapabilities:_e.getCapabilities,getChains:_e.getChains,isInMiniApp:dx,context:_e.context,back:sS({miniAppHost:_e,emitter:Ut}),quickAuth:Ph,actions:{setPrimaryButton:_e.setPrimaryButton.bind(_e),ready:async(t={})=>await _e.ready(t),close:_e.close.bind(_e),viewCast:_e.viewCast.bind(_e),viewProfile:_e.viewProfile.bind(_e),openMiniApp:_e.openMiniApp.bind(_e),signIn:async t=>{const e=await _e.signIn({...t,acceptAuthAddress:t.acceptAuthAddress??!0});if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new Yl:new Error("Unreachable")},openUrl:t=>{const e=typeof t=="string"?t:t.url;return _e.openUrl(e.trim())},addFrame:Vh,addMiniApp:Vh,composeCast(t={}){return _e.composeCast(t)},viewToken:_e.viewToken.bind(_e),sendToken:_e.sendToken.bind(_e),swapToken:_e.swapToken.bind(_e),requestCameraAndMicrophoneAccess:_e.requestCameraAndMicrophoneAccess.bind(_e)},experimental:{getSolanaProvider:zh,signManifest:async t=>{const e=await _e.signManifest(t);if(e.result)return e.result;throw e.error.type==="rejected_by_user"?new G1:e.error.type==="invalid_domain"?new q1:e.error.type==="generic_error"?new K1(e.error.message):new Error("Unreachable")},quickAuth(t){return Ph.getToken(t)}},wallet:{ethProvider:Js,getEthereumProvider:US,getSolanaProvider:zh},haptics:{impactOccurred:_e.impactOccurred.bind(_e),notificationOccurred:_e.notificationOccurred.bind(_e),selectionChanged:_e.selectionChanged.bind(_e)}};typeof document<"u"&&document.addEventListener("FarcasterFrameEvent",t=>{if(t instanceof MessageEvent){const e=t.data;e.event==="primary_button_clicked"?Ut.emit("primaryButtonClicked"):e.event==="miniapp_added"?Ut.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Ut.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Ut.emit("miniAppRemoved"):e.event==="notifications_enabled"?Ut.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Ut.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Ut.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"?Ut.emit("primaryButtonClicked"):e.event==="miniapp_added"?Ut.emit("miniAppAdded",{notificationDetails:e.notificationDetails}):e.event==="miniapp_add_rejected"?Ut.emit("miniAppAddRejected",{reason:e.reason}):e.event==="miniapp_removed"?Ut.emit("miniAppRemoved"):e.event==="notifications_enabled"?Ut.emit("notificationsEnabled",{notificationDetails:e.notificationDetails}):e.event==="notifications_disabled"?Ut.emit("notificationsDisabled"):e.event==="back_navigation_triggered"&&Ut.emit("backNavigationTriggered")}}),mo.type="farcasterMiniApp";let Zr,Yr,Jr;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.");Zr||(Zr=this.onAccountsChanged.bind(this),n.on("accountsChanged",Zr)),Yr||(Yr=this.onChainChanged.bind(this),n.on("chainChanged",Yr)),Jr||(Jr=this.onDisconnect.bind(this),n.on("disconnect",Jr));let i=await this.getChainId();return s&&i!==s&&(i=(await this.switchChain({chainId:s})).id),{accounts:r.map(o=>fi(o)),chainId:i}},async disconnect(){const e=await this.getProvider();Zr&&(e.removeListener("accountsChanged",Zr),Zr=void 0),Yr&&(e.removeListener("chainChanged",Yr),Yr=void 0),Jr&&(e.removeListener("disconnect",Jr),Jr=void 0)},async getAccounts(){return(await(await this.getProvider()).request({method:"eth_accounts"})).map(r=>fi(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:Ue(e)}]}),t.emitter.emit("change",{chainId:e}),r},onAccountsChanged(e){e.length===0?this.onDisconnect():t.emitter.emit("change",{accounts:e.map(n=>fi(n))})},onChainChanged(e){const n=Number(e);t.emitter.emit("change",{chainId:n})},async onDisconnect(){t.emitter.emit("disconnect")},async getProvider(){return Hh.wallet.ethProvider}})}const lx=mo;lx.type="farcasterFrame";const vt={EVM:"EVM",STARKNET:"STARKNET"},Te={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"},fx={type:vt.EVM,chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg",explorer:"https://arbiscan.io"},hx={type:vt.EVM,chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg",explorer:"https://sepolia.arbiscan.io"},px={type:vt.EVM,chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg",explorer:"https://snowtrace.io"},mx={type:vt.EVM,chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg",explorer:"https://testnet.snowtrace.io"},gx={type:vt.EVM,chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp",explorer:"https://basescan.org"},yx={type:vt.EVM,chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp",explorer:"https://sepolia.basescan.org"},bx={type:vt.EVM,chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp",explorer:"https://bscscan.com"},_x={type:vt.EVM,chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg",explorer:"https://etherscan.io"},Ex={type:vt.EVM,chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg",explorer:"https://sepolia.etherscan.io"},wx={type:vt.EVM,chainId:999,name:"HyperEVM",cctpDomain:19,logoURI:"/images/chains/hyperevm.webp",explorer:"https://liquidscan.io"},vx={type:vt.EVM,chainId:1135,name:"Lisk",cctpDomain:null,logoURI:"/images/chains/lisk.png",explorer:"https://blockscout.lisk.com"},Rx={type:vt.EVM,chainId:143,name:"Monad",cctpDomain:7,logoURI:"/images/chains/monad.png",explorer:"https://monadvision.com"},Ax={type:vt.EVM,chainId:10143,name:"Monad Testnet",cctpDomain:null,logoURI:"/images/chains/monad.png",explorer:"https://testnet.monadvision.com"},Sx={type:vt.EVM,chainId:10,name:"Optimism",cctpDomain:2,logoURI:"/images/chains/optimism.svg",explorer:"https://optimistic.etherscan.io"},xx={type:vt.EVM,chainId:11155420,name:"Optimism Testnet",cctpDomain:2,logoURI:"/images/chains/optimism.svg",explorer:"https://testnet-explorer.optimism.io"},Tx={type:vt.EVM,chainId:137,name:"Polygon",cctpDomain:7,logoURI:"/images/chains/polygon.svg",explorer:"https://polygonscan.com"},Ix={type:vt.STARKNET,chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:25,logoURI:"/images/chains/starknet.svg",explorer:""},Ox={type:vt.STARKNET,chainId:"0x534e5f5345504f4c4941",name:"Starknet Testnet",cctpDomain:null,logoURI:"/images/chains/starknet.svg",explorer:""};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 qh="2.43.4";let jc={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${qh}`};class Zn extends Error{constructor(e,n={}){const r=n.cause instanceof Zn?n.cause.details:n.cause?.message?n.cause.message:n.details,s=n.cause instanceof Zn&&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(`
|
|
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=qh}walk(e){return Kh(this,e)}}function Kh(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?Kh(t.cause,e):e?null:t}class Wh extends Zn{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"?Nx(t,{dir:e,size:n}):Cx(t,{dir:e,size:n})}function Nx(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Wh({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function Cx(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Wh({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 Mx extends Zn{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 kx extends Zn{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 kx({givenSize:Gh(t),maxSize:e})}function Bx(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 Mx({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 Ux=new TextEncoder;function Lx(t,e={}){return typeof t=="number"||typeof t=="bigint"?Px(t,e):typeof t=="boolean"?Dx(t,e):zc(t)?Yh(t,e):Jh(t,e)}function Dx(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 Zh(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 Yh(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=Zh(r.charCodeAt(a++)),m=Zh(r.charCodeAt(a++));if(d===void 0||m===void 0)throw new Zn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);i[o]=d*16+m}return i}function Px(t,e){const n=Bx(t,e);return Yh(n)}function Jh(t,e={}){const n=Ux.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),Xh=BigInt(32);function Fx(t,e=!1){return e?{h:Number(t&yo),l:Number(t>>Xh&yo)}:{h:Number(t>>Xh&yo)|0,l:Number(t&yo)|0}}function $x(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}=Fx(t[i],e);[r[i],s[i]]=[o,a]}return[r,s]}const zx=(t,e,n)=>t<<n|e>>>32-n,jx=(t,e,n)=>e<<n|t>>>32-n,Vx=(t,e,n)=>e<<n-32|t>>>64-n,Hx=(t,e,n)=>t<<n-32|e>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Gx(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Qh(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function bo(t,...e){if(!Gx(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 e0(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 qx(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 Kx(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function t0(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Wx=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Zx(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Yx(t){for(let e=0;e<t.length;e++)t[e]=Zx(t[e]);return t}const n0=Wx?t=>t:Yx;function Jx(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function r0(t){return typeof t=="string"&&(t=Jx(t)),bo(t),t}class Xx{}function Qx(t){const e=r=>t().update(r0(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}const eT=BigInt(0),Xs=BigInt(1),tT=BigInt(2),nT=BigInt(7),rT=BigInt(256),sT=BigInt(113),s0=[],i0=[],o0=[];for(let t=0,e=Xs,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],s0.push(2*(5*r+n)),i0.push((t+1)*(t+2)/2%64);let s=eT;for(let i=0;i<7;i++)e=(e<<Xs^(e>>nT)*sT)%rT,e&tT&&(s^=Xs<<(Xs<<BigInt(i))-Xs);o0.push(s)}const a0=$x(o0,!0),iT=a0[0],oT=a0[1],c0=(t,e,n)=>n>32?Vx(t,e,n):zx(t,e,n),u0=(t,e,n)=>n>32?Hx(t,e,n):jx(t,e,n);function aT(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],S=c0(m,g,1)^n[a],I=u0(m,g,1)^n[a+1];for(let N=0;N<50;N+=10)t[o+N]^=S,t[o+N+1]^=I}let s=t[2],i=t[3];for(let o=0;o<24;o++){const a=i0[o],d=c0(s,i,a),m=u0(s,i,a),g=s0[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]^=iT[r],t[1]^=oT[r]}t0(n)}class Hc extends Xx{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,Qh(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Kx(this.state)}clone(){return this._cloneInto()}keccak(){n0(this.state32),aT(this.state32,this.rounds),n0(this.state32),this.posOut=0,this.pos=0}update(e){e0(this),e=r0(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){e0(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 Qh(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(qx(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,t0(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new Hc(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 cT=(t,e,n)=>Qx(()=>new Hc(e,t,n)),uT=cT(1,136,256/8);function dT(t,e){return uT(zc(t,{strict:!1})?Lx(t):t)}class lT extends Zn{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 d0 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 Gc=new d0(8192);function l0(t,e){if(Gc.has(`${t}.${e}`))return Gc.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=dT(Jh(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 Gc.set(`${t}.${e}`,i),i}function Lt(t,e){if(!hT(t,{strict:!1}))throw new lT({address:t});return l0(t,e)}const fT=/^0x[a-fA-F0-9]{40}$/,qc=new d0(8192);function hT(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(qc.has(r))return qc.get(r);const s=fT.test(t)?t.toLowerCase()===t?!0:n?l0(t)===t:!0:!1;return qc.set(r,s),s}const Q={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"},Rt={[Te.ARBITRUM]:{[Q.DAI]:{address:Lt("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.USDC]:{address:Lt("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[Q.USDT]:{address:Lt("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:Lt("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Te.ARBITRUM_TESTNET]:{[Q.USDC]:{address:Lt("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Te.AVALANCHE]:{[Q.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.USDC]:{address:Lt("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Te.AVALANCHE_TESTNET]:{[Q.USDC]:{address:Lt("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Te.BASE]:{[Q.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:Q.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[Q.USDC]:{address:Lt("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.WETH]:{address:Lt("0x4200000000000000000000000000000000000006"),symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Te.BASE_TESTNET]:{[Q.USDC]:{address:Lt("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:Q.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Te.BSC]:{[Q.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[Q.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:Q.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[Q.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[Q.USDC]:{address:Lt("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:Q.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:Q.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Te.ETHEREUM]:{[Q.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:Q.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[Q.DAI]:{address:Lt("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:Q.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[Q.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:Q.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[Q.USDC]:{address:Lt("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:Lt("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:Lt("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Te.ETHEREUM_TESTNET]:{[Q.USDC]:{address:Lt("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:Q.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[Te.HYPEREVM]:{[Q.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Te.LISK]:{[Q.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Te.MONAD]:{[Q.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Te.MONAD_TESTNET]:{[Q.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Te.OPTIMISM]:{[Q.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[Q.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[Q.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Te.OPTIMISM_TESTNET]:{[Q.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[Te.POLYGON]:{[Q.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[Q.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[Q.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:Q.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[Te.STARKNET]:{[Q.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:Q.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[Q.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:Q.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[Q.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:Q.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[Q.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:Q.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[Q.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[Q.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:Q.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[Te.STARKNET_TESTNET]:{[Q.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:Q.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},pT={ARBITRUM_MAINNET:{...fx,tokens:Rt[Te.ARBITRUM]},ARBITRUM_TESTNET:{...hx,tokens:Rt[Te.ARBITRUM_TESTNET]},AVALANCHE_MAINNET:{...px,tokens:Rt[Te.AVALANCHE]},AVALANCHE_TESTNET:{...mx,tokens:Rt[Te.AVALANCHE_TESTNET]},BASE_MAINNET:{...gx,tokens:Rt[Te.BASE]},BASE_TESTNET:{...yx,tokens:Rt[Te.BASE_TESTNET]},BSC_MAINNET:{...bx,tokens:Rt[Te.BSC]},ETHEREUM_MAINNET:{..._x,tokens:Rt[Te.ETHEREUM]},ETHEREUM_TESTNET:{...Ex,tokens:Rt[Te.ETHEREUM_TESTNET]},HYPEREVM_MAINNET:{...wx,tokens:Rt[Te.HYPEREVM]},LISK_MAINNET:{...vx,tokens:Rt[Te.LISK]},MONAD_MAINNET:{...Rx,tokens:Rt[Te.MONAD]},MONAD_TESTNET:{...Ax,tokens:Rt[Te.MONAD_TESTNET]},OPTIMISM_MAINNET:{...Sx,tokens:Rt[Te.OPTIMISM]},OPTIMISM_TESTNET:{...xx,tokens:Rt[Te.OPTIMISM_TESTNET]},POLYGON_MAINNET:{...Tx,tokens:Rt[Te.POLYGON]},STARKNET_MAINNET:{...Ix,tokens:Rt[Te.STARKNET]},STARKNET_TESTNET:{...Ox,tokens:Rt[Te.STARKNET_TESTNET]}};new Set(Object.values(Te));async function mT(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:un.FARCASTER_CONNECTED,isConnected:!0,address:r.accounts[0],chainId:r.chainId};[Po,Fo].forEach(i=>{t.current?.contentWindow?.postMessage(s,i)})}}async function gT(t,e,n){if(!n||!e)throw new Error("Wagmi config not found");await U1(e);const r={type:un.FARCASTER_DISCONNECTED,isConnected:!1,address:null,chainId:null};[Po,Fo].forEach(s=>{t.current?.contentWindow?.postMessage(r,s)})}async function yT(t,e,n,r,s){if(!n||!e)throw new Error("Wagmi config not found");let i=null;try{return await F1(e,{chainId:t.chainId}),t.nativeToken?(i=await D1(e,{to:t.to,value:t.value,chainId:t.chainId}),i):(i=await $1(e,{abi:rm,address:t.token,functionName:"transfer",args:[t.to,t.value]}),i)}catch{[Po,Fo].forEach(a=>{r?.contentWindow?.postMessage({type:un.FARCASTER_SEND_TRANSACTION_RESULT,requestId:s.params,error:"an error occurred"},a)})}return i}async function bT(t){if(!t)throw new Error("Wagmi config not found");const e=new Set(L1(t).map(r=>r.id));return Object.entries(pT).filter(([,r])=>!e.has(r.chainId)).map(([r])=>r)}function _T(){return Jn.jsx("div",{role:"status",className:"payment-modal-loader",children:Jn.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Jn.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),Jn.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})})}const ET=["light","dark","system"],_o="https://app.chainrails.io",Eo="https://chainrails-frontend-git-staging-horus-labs.vercel.app";function wT(t){const{amount:e,styles:n,excludeChains:r,isOpen:s,isPending:i,open:o,close:a,onCancel:d,onSuccess:m,session_url:g,sessionToken:S,farcasterMiniApp:I,wagmiConfig:N}=t,[P,M]=Be.useState(0),[B,K]=Be.useState(""),[Y,j]=Be.useState(null),U=Be.useRef(null);Mn.config({api_key:"",env:t.env==="internal"?"internal":"production"}),Be.useEffect(()=>{K(Mn.getPayModalUrl(e))},[e]),Be.useEffect(()=>{const J=n?.theme;if(!J||ET.includes(J)){j(null);return}let ne=!1;return(async()=>{try{const z=Mn.getBaseUrl(),C=await fetch(`${z}/themes/${J}`);if(!C.ok)return;const F=await C.json();!ne&&F.status==="approved"&&F.cssContent&&j(F.cssContent)}catch(z){console.error("Failed to fetch theme:",z)}})(),()=>{ne=!0}},[n?.theme]),Be.useEffect(()=>{const J=document.body.style.overflow;s?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=J||"";const ne=async te=>{if(te.data===un.CLOSED&&(a(),d?.()),te.data===un.COMPLETED&&(window.setTimeout(a,2e3),m?.()),te.data===un.REQUEST_FARCASTER_CONNECT)try{await mT(U,N,I)}catch(C){console.error(C)}if(te.data===un.REQUEST_FARCASTER_DISCONNECT)try{await gT(U,N,I)}catch(C){console.error(C)}const z=te.data;if(z?.type===un.REQUEST_FARCASTER_SEND_TRANSACTION&&typeof z.requestId=="string"&&z.params)try{const C=await yT(z.params,N,I,U.current,z.requestId);C?[_o,Eo].forEach(F=>{U.current?.contentWindow?.postMessage({type:un.FARCASTER_SEND_TRANSACTION_RESULT,requestId:z.requestId,hash:C},F)}):[_o,Eo].forEach(F=>{U.current?.contentWindow?.postMessage({type:un.FARCASTER_SEND_TRANSACTION_RESULT,requestId:z.requestId,error:"sendTransaction not configured or returned no hash"},F)})}catch(C){console.log(C)}};return window.addEventListener("message",ne),()=>{document.body.style.overflow=J||"",window.removeEventListener("message",ne)}},[s,d,m,a,I,N]),Be.useEffect(()=>{if(!S)return;const J=t.css||Y||void 0,ne=async()=>{const z=await Hh.isInMiniApp(),C=z?await bT(N):[],q=[...r||[],...C];return{type:"session",session_token:S,environment:Mn.getEnv()||Lo.PRODUCTION,styles:n,props:{excludeChains:q.join(","),isFarcasterMiniApp:z},...J?{css:J}:{}}};let te=!1;return ne().then(z=>{te||([_o,Eo].forEach(C=>{U.current?.contentWindow?.postMessage(z,C)}),window.setTimeout(()=>{te||[_o,Eo].forEach(C=>{U.current?.contentWindow?.postMessage(z,C)})},1e3))}),()=>{te=!0}},[S,P,s,n,Y]);function V(){M(Math.random())}return Jn.jsxs("div",{className:nm("payment-modal-wrapper",P===0||i?"loading":"not-loading",s?"open":"closed"),children:[(P===0||i)&&Jn.jsx(_T,{}),Jn.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:B||void 0,onLoad:V,className:`payment-modal ${P===0||i?"invisible":"visible"}`,"data-id":e,ref:U},e)]})}const vT=Symbol(),Kc=Symbol(),Qs="a",f0="f",h0="p",p0="c",m0="t",Wc="h",ei="w",Zc="o",Yc="k";let RT=(t,e)=>new Proxy(t,e);const Jc=Object.getPrototypeOf,Xc=new WeakMap,g0=t=>t&&(Xc.has(t)?Xc.get(t):Jc(t)===Object.prototype||Jc(t)===Array.prototype),wo=t=>typeof t=="object"&&t!==null,AT=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),ST=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)},xT=(t,e)=>{const n={[f0]:e};let r=!1;const s=(a,d)=>{if(!r){let m=n[Qs].get(t);if(m||(m={},n[Qs].set(t,m)),a===ei)m[ei]=!0;else{let g=m[a];g||(g=new Set,m[a]=g),g.add(d)}}},i=()=>{r=!0,n[Qs].delete(t)},o={get(a,d){return d===Kc?t:(s(Yc,d),y0(Reflect.get(a,d),n[Qs],n[p0],n[m0]))},has(a,d){return d===vT?(i(),!0):(s(Wc,d),Reflect.has(a,d))},getOwnPropertyDescriptor(a,d){return s(Zc,d),Reflect.getOwnPropertyDescriptor(a,d)},ownKeys(a){return s(ei),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,n]},Qc=t=>t[Kc]||t,y0=(t,e,n,r)=>{if(!g0(t))return t;let s=r&&r.get(t);if(!s){const d=Qc(t);AT(d)?s=[d,ST(d)]:s=[d],r?.set(t,s)}const[i,o]=s;let a=n&&n.get(i);return(!a||a[1][f0]!==!!o)&&(a=xT(i,!!o),a[1][h0]=RT(o||i,a[0]),n&&n.set(i,a)),a[1][Qs]=e,a[1][p0]=n,a[1][m0]=r,a[1][h0]},TT=(t,e)=>{const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);return n.length!==r.length||n.some((s,i)=>s!==r[i])},b0=(t,e,n,r,s=Object.is)=>{if(s(t,e))return!1;if(!wo(t)||!wo(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[ei]===!0){if(o=TT(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=b0(t[a],e[a],n,r,s),o)return o;if(o===null)throw new Error("invalid used");return o},IT=t=>g0(t)&&t[Kc]||null,_0=(t,e=!0)=>{Xc.set(t,e)},OT=(t,e,n)=>{const r=[],s=new WeakSet,i=(o,a)=>{var d,m,g;if(s.has(o))return;wo(o)&&s.add(o);const S=wo(o)&&e.get(Qc(o));if(S){if((d=S[Wc])===null||d===void 0||d.forEach(I=>{const N=`:has(${String(I)})`;r.push(a?[...a,N]:[N])}),S[ei]===!0){const I=":ownKeys";r.push(a?[...a,I]:[I])}else(m=S[Zc])===null||m===void 0||m.forEach(I=>{const N=`:hasOwn(${String(I)})`;r.push(a?[...a,N]:[N])});(g=S[Yc])===null||g===void 0||g.forEach(I=>{"value"in(Object.getOwnPropertyDescriptor(o,I)||{})&&i(o[I],a?[...a,I]:[I])})}else a&&r.push(a)};return i(t),r},vo={},eu=t=>typeof t=="object"&&t!==null,NT=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),E0=(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 _0(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))_0(i,!1);else if(yr.has(i)){const[d,m]=yr.get(i);a.value=E0(d,m())}Object.defineProperty(r,s,a)}),Object.preventExtensions(r)},CT=(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&&(v0(m,o)||Ro.has(o)&&v0(m,Ro.get(o))))return!0;n(i),eu(o)&&(o=IT(o)||o);const g=!yr.has(o)&&kT(o)?R0(o):o;return e(i,g),Reflect.set(s,i,g,a),r(["set",[i],o,m]),!0}}),yr=new WeakMap,tu=new WeakSet,w0=new WeakMap,nu=[1],Ro=new WeakMap;let v0=Object.is,MT=(t,e)=>new Proxy(t,e),kT=NT,BT=E0,UT=CT;function R0(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=(B,K=++nu[0])=>{n!==K&&(i=n=K,r.forEach(Y=>Y(B,K)))};let i=n;const o=(B=nu[0])=>(i!==B&&(i=B,d.forEach(([K])=>{const Y=K[1](B);Y>n&&(n=Y)})),n),a=B=>(K,Y)=>{const j=[...K];j[1]=[B,...j[1]],s(j,Y)},d=new Map,m=(B,K)=>{const Y=!tu.has(K)&&yr.get(K);if(Y){if((vo?"production":void 0)!=="production"&&d.has(B))throw new Error("prop listener already exists");if(r.size){const j=Y[2](a(B));d.set(B,[Y,j])}else d.set(B,[Y])}},g=B=>{var K;const Y=d.get(B);Y&&(d.delete(B),(K=Y[1])==null||K.call(Y))},S=B=>(r.add(B),r.size===1&&d.forEach(([Y,j],U)=>{if((vo?"production":void 0)!=="production"&&j)throw new Error("remove already exists");const V=Y[2](a(U));d.set(U,[Y,V])}),()=>{r.delete(B),r.size===0&&d.forEach(([Y,j],U)=>{j&&(j(),d.set(U,[Y]))})});let I=!0;const N=UT(()=>I,m,g,s),P=MT(t,N);Ro.set(t,P);const M=[t,o,S];return yr.set(P,M),Reflect.ownKeys(t).forEach(B=>{const K=Object.getOwnPropertyDescriptor(t,B);"value"in K&&K.writable&&(P[B]=t[B])}),I=!1,P}function LT(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=>{i.push(g),s||(s=Promise.resolve().then(()=>{s=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,m()}}function A0(t){const e=yr.get(t);(vo?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[n,r]=e;return BT(n,r())}const DT={},PT=(t,e)=>{const n=Be.useRef(void 0);Be.useEffect(()=>{n.current=OT(t,e)}),Be.useDebugValue(n.current)},FT=new WeakMap;function $T(t,e){const r=Be.useMemo(()=>t&&new WeakMap,[t]),s=Be.useRef(void 0);let i=!0;const o=Be.useSyncExternalStore(Be.useCallback(d=>{const m=LT(t,d);return d(),m},[t,void 0]),()=>{const d=A0(t);try{if(!i&&s.current&&!b0(s.current,d,r,new WeakMap))return s.current}catch{}return d},()=>A0(t));i=!1,Be.useLayoutEffect(()=>{s.current=o}),(DT?"production":void 0)!=="production"&&PT(o,r);const a=Be.useMemo(()=>new WeakMap,[]);return y0(o,r,a,FT)}const Yn=R0({data:null,isPending:!1,error:null});function zT({session_url:t,onCancel:e,onSuccess:n,farcasterMiniApp:r,wagmiConfig:s}){const i=$T(Yn),[o,a]=Be.useState(!1),[d,m]=Be.useState(Date.now()),g=i?.data?.sessionToken,S=i?.data?.amount;function I(){g||window.setTimeout(()=>{g&&a(!0)},200),a(!0)}function N(){a(!1)}const P=()=>{const M=Date.now();Yn.isPending=!0,Yn.error=null,Yn.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(B=>B.json()).then(B=>{M<d||(Yn.data=B,Yn.isPending=!1,m(M))}).catch(B=>{M<d||(Yn.error=B?.toString(),Yn.isPending=!1,m(M),setInterval(P,5e3))})};return Be.useEffect(()=>{P()},[t]),{sessionToken:g,amount:S,isOpen:o,session_url:t,open:I,close:N,isPending:i.isPending,error:i.error,refetch:P,onSuccess:n,onCancel:e,farcasterMiniApp:r,wagmiConfig:s}}function jT({sessionToken:t,amount:e,onCancel:n,onSuccess:r,farcasterMiniApp:s,wagmiConfig:i}){const[o,a]=Be.useState(!1),[d,m]=Be.useState(t),[g,S]=Be.useState(e);function I({sessionToken:M,amount:B}){m(M),S(B)}Be.useEffect(()=>{m(t)},[t]);function N(){d||window.setTimeout(()=>{d&&a(!0)},200),a(!0)}function P(){a(!1)}return{sessionToken:d,updateSession:I,amount:g,isOpen:o,open:N,close:P,onSuccess:r,onCancel:n,farcasterMiniApp:s,wagmiConfig:i}}Vt.AmountSymbols=X,Vt.Chainrails=Mn,Vt.Chains=sp,Vt.PaymentModal=wT,Vt.crapi=tm,Vt.usePaymentModal=jT,Vt.usePaymentSession=zT,Object.defineProperty(Vt,Symbol.toStringTag,{value:"Module"})}));
|