@chainrails/vanilla 0.0.4 → 0.0.5

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/README.md CHANGED
@@ -13,10 +13,7 @@ npm install @chainrails/vanilla
13
13
  ## Usage
14
14
 
15
15
  ```ts
16
- import { Chainrails, createPaymentSession } from "@chainrails/vanilla";
17
- import "@chainrails/vanilla";
18
-
19
- Chainrails.config({ api_key: "your_api_key" });
16
+ import { createPaymentSession } from "@chainrails/vanilla";
20
17
 
21
18
  const modal = document.createElement("chainrails-payment-modal");
22
19
  document.body.appendChild(modal);
@@ -1769,7 +1769,7 @@ const Zt = {
1769
1769
  return this._sessionToken;
1770
1770
  }
1771
1771
  set sessionToken(e) {
1772
- this._sessionToken = e ?? null, this.postAuth();
1772
+ console.log({ value: e }), this._sessionToken = e ?? null, this.postAuth();
1773
1773
  }
1774
1774
  get amount() {
1775
1775
  return this._amount;
@@ -1895,7 +1895,7 @@ const Zt = {
1895
1895
  props: { excludeChains: this._excludeChains?.join(",") },
1896
1896
  ...this.themeCss ? { css: this.themeCss } : {}
1897
1897
  };
1898
- this.iframe.contentWindow.postMessage(e, se), this.iframe.contentWindow.postMessage(e, ne), window.setTimeout(() => {
1898
+ console.log({ auth: e }), this.iframe.contentWindow.postMessage(e, se), this.iframe.contentWindow.postMessage(e, ne), window.setTimeout(() => {
1899
1899
  this.iframe?.contentWindow && (this.iframe.contentWindow.postMessage(e, se), this.iframe.contentWindow.postMessage(e, ne));
1900
1900
  }, 1e3);
1901
1901
  }
@@ -1769,7 +1769,7 @@ const Zt = {
1769
1769
  return this._sessionToken;
1770
1770
  }
1771
1771
  set sessionToken(e) {
1772
- this._sessionToken = e ?? null, this.postAuth();
1772
+ console.log({ value: e }), this._sessionToken = e ?? null, this.postAuth();
1773
1773
  }
1774
1774
  get amount() {
1775
1775
  return this._amount;
@@ -1895,7 +1895,7 @@ const Zt = {
1895
1895
  props: { excludeChains: this._excludeChains?.join(",") },
1896
1896
  ...this.themeCss ? { css: this.themeCss } : {}
1897
1897
  };
1898
- this.iframe.contentWindow.postMessage(e, se), this.iframe.contentWindow.postMessage(e, ne), window.setTimeout(() => {
1898
+ console.log({ auth: e }), this.iframe.contentWindow.postMessage(e, se), this.iframe.contentWindow.postMessage(e, ne), window.setTimeout(() => {
1899
1899
  this.iframe?.contentWindow && (this.iframe.contentWindow.postMessage(e, se), this.iframe.contentWindow.postMessage(e, ne));
1900
1900
  }, 1e3);
1901
1901
  }
@@ -1,6 +1,6 @@
1
1
  (function(g,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(g=typeof globalThis<"u"?globalThis:g||self,S(g.Chainrails={}))})(this,(function(g){"use strict";var S=document.createElement("style");S.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}.open.not-loading .payment-modal-loader{display:none!important}.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(S);class N extends Error{response;request;options;constructor(e,s,n){const i=e.status||e.status===0?e.status:"",a=e.statusText??"",r=`${i} ${a}`.trim(),c=r?`status code ${r}`:"an unknown error";super(`Request failed with ${c}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=e,this.request=s,this.options=n}}class V 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 B extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const s=e?.cause?e.cause instanceof Error?e.cause:new V(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 G=(()=>{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(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),Ie=typeof globalThis.AbortController=="function",Y=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",xe=typeof globalThis.ReadableStream=="function",Ne=typeof globalThis.FormData=="function",J=["get","post","put","patch","head","delete"],Be={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},O=2147483647,Oe=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,X=Symbol("stop");class Z{options;constructor(e){this.options=e}}const Pe=t=>new Z(t),Me={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},_e={next:!0},Fe={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},Le=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[s,n]of t)e+=Oe,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},Q=(t,e,s)=>{let n,i=0;return t.pipeThrough(new TransformStream({transform(a,r){if(r.enqueue(a),n){i+=n.byteLength;let c=e===0?0:i/e;c>=1&&(c=1-Number.EPSILON),s?.({percent:c,totalBytes:Math.max(e,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,s?.({percent:1,totalBytes:Math.max(e,i),transferredBytes:i},n))}}))},je=(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(Q(t.body,s,e),{status:t.status,statusText:t.statusText,headers:t.headers})},$e=(t,e,s)=>{if(!t.body)return t;const n=Le(s??t.body);return new Request(t,{duplex:"half",body:Q(t.body,n,e)})},T=t=>t!==null&&typeof t=="object",v=(...t)=>{for(const e of t)if((!T(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return P({},...t)},ee=(t={},e={})=>{const s=new globalThis.Headers(t),n=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[a,r]of i.entries())n&&r==="undefined"||r===void 0?s.delete(a):s.set(a,r);return s};function k(t,e,s){return Object.hasOwn(e,s)&&e[s]===void 0?[]:P(t[s]??[],e[s]??[])}const te=(t={},e={})=>({beforeRequest:k(t,e,"beforeRequest"),beforeRetry:k(t,e,"beforeRetry"),afterResponse:k(t,e,"afterResponse"),beforeError:k(t,e,"beforeError")}),He=(t,e)=>{const s=new URLSearchParams;for(const n of[t,e])if(n!==void 0)if(n instanceof URLSearchParams)for(const[i,a]of n.entries())s.append(i,a);else if(Array.isArray(n))for(const i of n){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(i[0]),String(i[1]))}else if(T(n))for(const[i,a]of Object.entries(n))a!==void 0&&s.append(i,String(a));else{const i=new URLSearchParams(n);for(const[a,r]of i.entries())s.append(a,r)}return s},P=(...t)=>{let e={},s={},n={},i;const a=[];for(const r of t)if(Array.isArray(r))Array.isArray(e)||(e=[]),e=[...e,...r];else if(T(r)){for(let[c,l]of Object.entries(r)){if(c==="signal"&&l instanceof globalThis.AbortSignal){a.push(l);continue}if(c==="context"){if(l!=null&&(!T(l)||Array.isArray(l)))throw new TypeError("The `context` option must be an object");e={...e,context:l==null?{}:{...e.context,...l}};continue}if(c==="searchParams"){l==null?i=void 0:i=i===void 0?l:He(i,l);continue}T(l)&&c in e&&(l=P(e[c],l)),e={...e,[c]:l}}T(r.hooks)&&(n=te(n,r.hooks),e.hooks=n),T(r.headers)&&(s=ee(s,r.headers),e.headers=s)}return i!==void 0&&(e.searchParams=i),a.length>0&&(a.length===1?e.signal=a[0]:Y?e.signal=AbortSignal.any(a):e.signal=a.at(-1)),e.context===void 0&&(e.context={}),e},ze=t=>J.includes(t)?t.toUpperCase():t,se={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},qe=(t={})=>{if(typeof t=="number")return{...se,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{...se,...t}};class M extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function We(t,e,s,n){return new Promise((i,a)=>{const r=setTimeout(()=>{s&&s.abort(),a(new M(t))},n.timeout);n.fetch(t,e).then(i).catch(a).then(()=>{clearTimeout(r)})})}async function Ke(t,{signal:e}){return new Promise((s,n)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(e.reason)}const a=setTimeout(()=>{e?.removeEventListener("abort",i),s()},t)})}const Ve=(t,e)=>{const s={};for(const n in e)Object.hasOwn(e,n)&&!(n in Fe)&&!(n in Me)&&(!(n in t)||n in _e)&&(s[n]=e[n]);return s},Ge=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 Ye(t){return t instanceof N||t?.name===N.name}function Je(t){return t instanceof M||t?.name===M.name}class w{static create(e,s){const n=new w(e,s),i=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>O)throw new RangeError(`The \`timeout\` option cannot be greater than ${O}`);await Promise.resolve();let r=await n.#g();for(const c of n.#e.hooks.afterResponse){const l=n.#u(r.clone()),m=await c(n.request,n.#a(),l,{retryCount:n.#s});if(m instanceof globalThis.Response&&(r=m),m instanceof Z)throw await Promise.all([l.body?.cancel(),r.body?.cancel()]),new B(m.options)}if(n.#u(r),!r.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(r.status):n.#e.throwHttpErrors)){let c=new N(r,n.request,n.#a());for(const l of n.#e.hooks.beforeError)c=await l(c,{retryCount:n.#s});throw c}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!xe)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return je(r.clone(),n.#e.onDownloadProgress)}return r},a=n.#d(i).finally(async()=>{const r=n.#o,c=[];r&&!r.bodyUsed&&c.push(r.body?.cancel()),n.request.bodyUsed||c.push(n.request.body?.cancel()),await Promise.all(c)});for(const[r,c]of Object.entries(Be))r==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(a[r]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||c);const l=await a;if(r==="json"){if(l.status===204)return"";const m=await l.text();return m===""?"":s.parseJson?s.parseJson(m):JSON.parse(m)}return l[r]()});return a}static#f(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;#o;#i;#r;constructor(e,s={}){if(this.#t=e,this.#e={...s,headers:ee(this.#t.headers,s.headers),hooks:te({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:ze(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:qe(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}Ie&&Y&&(this.#i=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),G&&(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&&(Ne&&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),Ge(this.#e.searchParams)){const a="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(w.#f(this.#e.searchParams)).toString()),r=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);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(!G)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#h(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 V(e);if(s instanceof B)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(Je(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Ye(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 i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const a=this.#e.retry.maxRetryAfter??i;return i<a?i:a}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),O);if(this.#s<1)throw s;if(await Ke(n,this.#i?{signal:this.#i}:{}),s instanceof B&&s.customRequest){const i=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#l(i)}for(const i of this.#e.hooks.beforeRetry){const a=await i({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(a instanceof globalThis.Request){this.#l(a);break}if(a instanceof globalThis.Response)return a;if(a===X)return}return this.#d(e)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,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=Ve(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):We(this.#o,e,this.#n,this.#e)}#a(){if(!this.#r){const{hooks:e,...s}=this.#e;this.#r=Object.freeze(s)}return this.#r}#l(e){this.#r=void 0,this.request=this.#h(e)}#h(e,s){return!this.#e.onUploadProgress||!e.body?e:$e(e,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const _=t=>{const e=(s,n)=>w.create(s,v(t,n));for(const s of J)e[s]=(n,i)=>w.create(n,v(t,i,{method:s}));return e.create=s=>_(v(s)),e.extend=s=>(typeof s=="function"&&(s=s(t??{})),_(v(t,s))),e.stop=X,e.retry=Pe,e},Xe=_(),h={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"},Ze={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 F(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 F(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ie="2.43.4";let L={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${ie}`};class b extends Error{constructor(e,s={}){const n=s.cause instanceof b?s.cause.details:s.cause?.message?s.cause.message:s.details,i=s.cause instanceof b&&s.cause.docsPath||s.docsPath,a=L.getDocsUrl?.({...s,docsPath:i}),r=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...L.version?[`Version: ${L.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=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=ie}walk(e){return oe(this,e)}}function oe(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?oe(t.cause,e):e?null:t}class re extends b{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 D(t,{dir:e,size:s=32}={}){return typeof t=="string"?Qe(t,{dir:e,size:s}):et(t,{dir:e,size:s})}function Qe(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new re({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function et(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new re({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const a=e==="right";n[a?i:s-i-1]=t[a?i:t.length-i-1]}return n}class tt extends b{constructor({max:e,min:s,signed:n,size:i,value:a}){super(`Number "${a}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class st extends b{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function j(t,{size:e}){if(ne(t)>e)throw new st({givenSize:ne(t),maxSize:e})}function nt(t,e={}){const{signed:s,size:n}=e,i=BigInt(t);let a;n?s?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const r=typeof a=="bigint"&&s?-a-1n:0;if(a&&i>a||i<r){const l=typeof t=="bigint"?"n":"";throw new tt({max:a?`${a}${l}`:void 0,min:`${r}${l}`,signed:s,size:n,value:`${t}${l}`})}const c=`0x${(s&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?D(c,{size:n}):c}const it=new TextEncoder;function ot(t,e={}){return typeof t=="number"||typeof t=="bigint"?at(t,e):typeof t=="boolean"?rt(t,e):F(t)?ce(t,e):le(t,e)}function rt(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(j(s,{size:e.size}),D(s,{size:e.size})):s}const y={zero:48,nine:57,A:65,F:70,a:97,f:102};function ae(t){if(t>=y.zero&&t<=y.nine)return t-y.zero;if(t>=y.A&&t<=y.F)return t-(y.A-10);if(t>=y.a&&t<=y.f)return t-(y.a-10)}function ce(t,e={}){let s=t;e.size&&(j(s,{size:e.size}),s=D(s,{dir:"right",size:e.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,a=new Uint8Array(i);for(let r=0,c=0;r<i;r++){const l=ae(n.charCodeAt(c++)),m=ae(n.charCodeAt(c++));if(l===void 0||m===void 0)throw new b(`Invalid byte sequence ("${n[c-2]}${n[c-1]}" in "${n}").`);a[r]=l*16+m}return a}function at(t,e){const s=nt(t,e);return ce(s)}function le(t,e={}){const s=it.encode(t);return typeof e.size=="number"?(j(s,{size:e.size}),D(s,{dir:"right",size:e.size})):s}const R=BigInt(2**32-1),ue=BigInt(32);function ct(t,e=!1){return e?{h:Number(t&R),l:Number(t>>ue&R)}:{h:Number(t>>ue&R)|0,l:Number(t&R)|0}}function lt(t,e=!1){const s=t.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let a=0;a<s;a++){const{h:r,l:c}=ct(t[a],e);[n[a],i[a]]=[r,c]}return[n,i]}const ut=(t,e,s)=>t<<s|e>>>32-s,dt=(t,e,s)=>e<<s|t>>>32-s,ht=(t,e,s)=>e<<s-32|t>>>64-s,ft=(t,e,s)=>t<<s-32|e>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function de(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function I(t,...e){if(!mt(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 he(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 gt(t,e){I(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function pt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function fe(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const yt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bt(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Tt(t){for(let e=0;e<t.length;e++)t[e]=bt(t[e]);return t}const me=yt?t=>t:Tt;function Et(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ge(t){return typeof t=="string"&&(t=Et(t)),I(t),t}class St{}function Ct(t){const e=n=>t().update(ge(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}const wt=BigInt(0),U=BigInt(1),Ut=BigInt(2),At=BigInt(7),vt=BigInt(256),kt=BigInt(113),pe=[],ye=[],be=[];for(let t=0,e=U,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],pe.push(2*(5*n+s)),ye.push((t+1)*(t+2)/2%64);let i=wt;for(let a=0;a<7;a++)e=(e<<U^(e>>At)*kt)%vt,e&Ut&&(i^=U<<(U<<BigInt(a))-U);be.push(i)}const Te=lt(be,!0),Dt=Te[0],Rt=Te[1],Ee=(t,e,s)=>s>32?ht(t,e,s):ut(t,e,s),Se=(t,e,s)=>s>32?ft(t,e,s):dt(t,e,s);function It(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 c=(r+8)%10,l=(r+2)%10,m=s[l],E=s[l+1],Qt=Ee(m,E,1)^s[c],es=Se(m,E,1)^s[c+1];for(let x=0;x<50;x+=10)t[r+x]^=Qt,t[r+x+1]^=es}let i=t[2],a=t[3];for(let r=0;r<24;r++){const c=ye[r],l=Ee(i,a,c),m=Se(i,a,c),E=pe[r];i=t[E],a=t[E+1],t[E]=l,t[E+1]=m}for(let r=0;r<50;r+=10){for(let c=0;c<10;c++)s[c]=t[r+c];for(let c=0;c<10;c++)t[r+c]^=~s[(c+2)%10]&s[(c+4)%10]}t[0]^=Dt[n],t[1]^=Rt[n]}fe(s)}class $ extends St{constructor(e,s,n,i=!1,a=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=i,this.rounds=a,de(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pt(this.state)}clone(){return this._cloneInto()}keccak(){me(this.state32),It(this.state32,this.rounds),me(this.state32),this.posOut=0,this.pos=0}update(e){he(this),e=ge(e),I(e);const{blockLen:s,state:n}=this,i=e.length;for(let a=0;a<i;){const r=Math.min(s-this.pos,i-a);for(let c=0;c<r;c++)n[this.pos++]^=e[a++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:i}=this;e[n]^=s,(s&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){he(this,!1),I(e),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,a=e.length;i<a;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,a-i);e.set(s.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=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 de(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gt(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,fe(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:i,rounds:a,enableXOF:r}=this;return e||(e=new $(s,n,i,r,a)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=a,e.suffix=n,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}const xt=(t,e,s)=>Ct(()=>new $(e,t,s)),Nt=xt(1,136,256/8);function Bt(t,e){return Nt(F(t,{strict:!1})?ot(t):t)}class Ot extends b{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 Ce 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 H=new Ce(8192);function we(t,e){if(H.has(`${t}.${e}`))return H.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),n=Bt(le(s)),i=s.split("");for(let r=0;r<40;r+=2)n[r>>1]>>4>=8&&i[r]&&(i[r]=i[r].toUpperCase()),(n[r>>1]&15)>=8&&i[r+1]&&(i[r+1]=i[r+1].toUpperCase());const a=`0x${i.join("")}`;return H.set(`${t}.${e}`,a),a}function f(t,e){if(!Mt(t,{strict:!1}))throw new Ot({address:t});return we(t,e)}const Pt=/^0x[a-fA-F0-9]{40}$/,z=new Ce(8192);function Mt(t,e){const{strict:s=!0}=e??{},n=`${t}.${s}`;if(z.has(n))return z.get(n);const i=Pt.test(t)?t.toLowerCase()===t?!0:s?we(t)===t:!0:!1;return z.set(n,i),i}const o={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};o.USDC;const Ue={[h.ARBITRUM]:{[o.DAI]:{address:f("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.USDC]:{address:f("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[o.USDT]:{address:f("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:f("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.ARBITRUM_TESTNET]:{[o.USDC]:{address:f("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.AVALANCHE]:{[o.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.USDC]:{address:f("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.AVALANCHE_TESTNET]:{[o.USDC]:{address:f("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.BASE]:{[o.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:o.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[o.USDC]:{address:f("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.WETH]:{address:f("0x4200000000000000000000000000000000000006"),symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.BASE_TESTNET]:{[o.USDC]:{address:f("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.BSC]:{[o.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:o.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[o.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:o.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[o.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[o.USDC]:{address:f("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:o.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:o.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[h.ETHEREUM]:{[o.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:o.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[o.DAI]:{address:f("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:o.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[o.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:o.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[o.USDC]:{address:f("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:f("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:f("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.ETHEREUM_TESTNET]:{[o.USDC]:{address:f("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:o.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.HYPEREVM]:{[o.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.LISK]:{[o.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.MONAD]:{[o.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.MONAD_TESTNET]:{[o.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.OPTIMISM]:{[o.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[o.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.OPTIMISM_TESTNET]:{[o.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.POLYGON]:{[o.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[o.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.STARKNET]:{[o.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[o.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:o.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[o.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:o.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[o.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[h.STARKNET_TESTNET]:{[o.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},_t=new Set(Object.values(h));function p(t){if(Ft(t))return t;const e=h[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 Ft(t){return _t.has(t)}function Lt(t,e){const s=e.toLowerCase().trim(),n=Ue[t];if(!n)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let i;for(const a in n){const r=n[a];if(r&&r.address.toLowerCase()===s.toLowerCase()){i=r;break}}if(!i)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 i}function q(t,e,s){const n=Lt(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 jt(t,e){return Ue[t]?.[e]}function Ae(t,e){return jt(t,e)?.address}var W=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(W||{});class u{constructor({api_key:e,env:s,seesion_token:n,props:i}){this.api_key=e||"",this.sessionToken=n||"",this.env=s??W.PRODUCTION,this.props=i}static async config(e){if(!u.app){if(!e)throw new Error("Please provide an api_key");u.app=new u(e)}return e&&(e.api_key!==void 0&&(u.app.api_key=e.api_key),e.seesion_token!==void 0&&(u.app.sessionToken=e.seesion_token),e.env!==void 0&&(u.app.env=e.env),e.props!==void 0&&(u.app.props=e.props)),u.app}static getApiKey(){if(!u.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return u.app.api_key}static getSessionToken(){if(!u.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return u.app.sessionToken}static getProps(){if(!u.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return u.app.props}static getEnv(){if(!u.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return u.app.env==="internal"?"staging":u.app.env}static getBaseUrl(){if(!u.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(u.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(!u.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=u.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(e),i=e&&!isNaN(Number(e))&&n>0?"/pay/":"/deposit/",a=`${e&&!isNaN(Number(e))&&n>0?n*100:""}`;return s+i+a}}let K=null;function $t(){K=Xe.create({prefixUrl:u.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=u.getSessionToken()||u.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function d(){return K||$t(),K}class Ht{async getById(e){return await d().get("intents/"+e).json()}async getForSender(e){return await d().get("intents/user/"+e).json()}async getForAddress(e){return await d().get("intents/address/"+e).json()}async getForSession(e){return await d().get("modal/sessions/intents/"+e).json()}async getAll(e){return await d().get("intents",{searchParams:e}).json()}async create(e){const s=p(e.source_chain),n=p(e.destination_chain);return await d().post("intents",{json:{...e,source_chain:s,destination_chain:n}}).json()}async createForSession(e){const s=p(e.sourceChain);return await d().post("modal/sessions/intents",{json:{...e,sourceChain:s}}).json()}async update(e,s){return await d().post("intents",{json:s}).json()}async triggerProcessing(e){return await d().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await d().post(`modal/sessions/intents/${e}/process`).json()}}class zt{async getFromSpecificBridge(e){const s=p(e.sourceChain);q(s,e.tokenIn,e.amountSymbol);const n=p(e.destinationChain);return await d().get("quotes/single",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getFromAllBridges(e){const s=p(e.sourceChain);q(s,e.tokenIn,e.amountSymbol);const n=p(e.destinationChain);return await d().get("quotes/multiple",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getBestAcrossBridges(e){const s=p(e.sourceChain);q(s,e.tokenIn,e.amountSymbol);const n=p(e.destinationChain);return await d().get("quotes/best",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAll(e){const s=p(e.destinationChain);return await d().get("quotes/multi-source",{searchParams:{...e,destinationChain:s}}).json()}async getAllForSession(e){return await d().get("modal/sessions/quotes",{searchParams:e}).json()}}class qt{async getOptimalRoutes(e){const s=p(e.sourceChain),n=p(e.destinationChain);return await d().get("router/optimal-route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAllSupportedBridges(){return await d().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const s=p(e.sourceChain),n=p(e.destinationChain);return await d().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getSupportedRoutes(e){return await d().get("router/supported-routes/bridge/"+e).json()}}class Wt{async getSupported(e){return await d().get("chains",{searchParams:e}).json()}async getBalance(e){return await d().get(`chains/balances/${e.address}`,{searchParams:e}).json()}}class Kt{async getClientInfo(){return await d().get("client/auth/client-info").json()}async getClientInfoForSession(){return await d().get("modal/sessions/client").json()}}class Vt{async getSessionToken(e){const s=p(e.destinationChain);let n=Ae(s,e.token);n||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),n=Ae(s,"USDC"));const i={recipient:e.recipient,tokenOut:n,destinationChain:s,amount:e.amount};return d().post("modal/sessions",{json:i}).json().then(a=>({...a,amount:i.amount}))}}const Gt={router:new qt,quotes:new zt,intents:new Ht,chains:new Wt,client:new Kt,auth:new Vt},Yt=["light","dark","system"],ve="https://app.chainrails.io",ke="https://chainrails-frontend-git-staging-horus-labs.vercel.app",A=class A extends HTMLElement{constructor(){super(...arguments),this.key=0,this.initialized=!1,this.iframe=null,this.loader=null,this.themeCss=null,this.previousBodyOverflow="",this._sessionToken=null,this._env="production",this._isOpen=!1,this._isPending=!1,this.handleMessage=e=>{e.data==="closed"&&(this.close(),this._onCancel?.(),this.dispatchEvent(new CustomEvent("cancelled"))),e.data==="completed"&&(window.setTimeout(()=>this.close(),2e3),this._onSuccess?.(),this.dispatchEvent(new CustomEvent("completed")))}}static get observedAttributes(){return A.observed}connectedCallback(){this.setup(),this.syncFromAttributes(),this.refreshUi(),window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage),this._isOpen&&(document.body.style.overflow=this.previousBodyOverflow||"")}attributeChangedCallback(e,s,n){if(this.initialized){if(e==="session-token"){this.sessionToken=n;return}if(e==="amount"){this.amount=n??void 0;return}if(e==="session-url"){this.sessionUrl=n??void 0;return}if(e==="is-open"){this.isOpen=n!==null&&n!=="false";return}if(e==="is-pending"){this.isPending=n!==null&&n!=="false";return}if(e==="env"){this.env=n==="internal"?"internal":"production";return}if(e==="exclude-chains"){this.excludeChains=n?n.split(",").map(i=>i.trim()).filter(Boolean):void 0;return}if(e==="theme"||e==="accent-color"){const i=this.styles||{};this.styles={...i,theme:this.getAttribute("theme")??i.theme,accentColor:this.getAttribute("accent-color")??i.accentColor}}}}get sessionToken(){return this._sessionToken}set sessionToken(e){this._sessionToken=e??null,this.postAuth()}get amount(){return this._amount}set amount(e){this._amount=e,this.key=0,this.setIframeSrc(),this.refreshUi()}get sessionUrl(){return this._sessionUrl}set sessionUrl(e){this._sessionUrl=e}get styles(){return this._styles}set styles(e){this._styles=e,this.resolveThemeCss().finally(()=>this.postAuth())}get excludeChains(){return this._excludeChains}set excludeChains(e){this._excludeChains=e,this.postAuth()}get env(){return this._env}set env(e){this._env=e,this.configureSdk(),this.setIframeSrc(),this.postAuth()}get isOpen(){return this._isOpen}set isOpen(e){this._isOpen=!!e,this.refreshUi()}get isPending(){return this._isPending}set isPending(e){this._isPending=!!e,this.refreshUi()}get onCancel(){return this._onCancel}set onCancel(e){this._onCancel=e}get onSuccess(){return this._onSuccess}set onSuccess(e){this._onSuccess=e}open(){this.sessionToken||window.setTimeout(()=>{this.sessionToken&&(this.isOpen=!0)},200),this.isOpen=!0}close(){this.isOpen=!1}setProps(e){typeof e.sessionToken<"u"&&(this.sessionToken=e.sessionToken),typeof e.amount<"u"&&(this.amount=e.amount),typeof e.sessionUrl<"u"&&(this.sessionUrl=e.sessionUrl),typeof e.styles<"u"&&(this.styles=e.styles),typeof e.excludeChains<"u"&&(this.excludeChains=e.excludeChains),typeof e.env<"u"&&(this.env=e.env),typeof e.isPending<"u"&&(this.isPending=e.isPending),typeof e.isOpen<"u"&&(this.isOpen=e.isOpen),typeof e.onCancel<"u"&&(this.onCancel=e.onCancel),typeof e.onSuccess<"u"&&(this.onSuccess=e.onSuccess)}setup(){this.initialized||(this.classList.add("payment-modal-wrapper"),this.loader=document.createElement("div"),this.loader.className="payment-modal-loader",this.loader.setAttribute("role","status"),this.loader.innerHTML=`<svg aria-hidden="true" class="icon" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ /*$vite$:1*/`,document.head.appendChild(S);class N extends Error{response;request;options;constructor(e,s,n){const i=e.status||e.status===0?e.status:"",a=e.statusText??"",r=`${i} ${a}`.trim(),c=r?`status code ${r}`:"an unknown error";super(`Request failed with ${c}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=e,this.request=s,this.options=n}}class V 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 B extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const s=e?.cause?e.cause instanceof Error?e.cause:new V(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 G=(()=>{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(i){if(i instanceof Error&&i.message==="unsupported BodyInit type")return!1;throw i}return t&&!e})(),Ie=typeof globalThis.AbortController=="function",Y=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",xe=typeof globalThis.ReadableStream=="function",Ne=typeof globalThis.FormData=="function",J=["get","post","put","patch","head","delete"],Be={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},O=2147483647,Oe=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,X=Symbol("stop");class Z{options;constructor(e){this.options=e}}const Pe=t=>new Z(t),Me={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},_e={next:!0},Fe={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},Le=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[s,n]of t)e+=Oe,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},Q=(t,e,s)=>{let n,i=0;return t.pipeThrough(new TransformStream({transform(a,r){if(r.enqueue(a),n){i+=n.byteLength;let c=e===0?0:i/e;c>=1&&(c=1-Number.EPSILON),s?.({percent:c,totalBytes:Math.max(e,i),transferredBytes:i},n)}n=a},flush(){n&&(i+=n.byteLength,s?.({percent:1,totalBytes:Math.max(e,i),transferredBytes:i},n))}}))},je=(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(Q(t.body,s,e),{status:t.status,statusText:t.statusText,headers:t.headers})},$e=(t,e,s)=>{if(!t.body)return t;const n=Le(s??t.body);return new Request(t,{duplex:"half",body:Q(t.body,n,e)})},T=t=>t!==null&&typeof t=="object",v=(...t)=>{for(const e of t)if((!T(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return P({},...t)},ee=(t={},e={})=>{const s=new globalThis.Headers(t),n=e instanceof globalThis.Headers,i=new globalThis.Headers(e);for(const[a,r]of i.entries())n&&r==="undefined"||r===void 0?s.delete(a):s.set(a,r);return s};function k(t,e,s){return Object.hasOwn(e,s)&&e[s]===void 0?[]:P(t[s]??[],e[s]??[])}const te=(t={},e={})=>({beforeRequest:k(t,e,"beforeRequest"),beforeRetry:k(t,e,"beforeRetry"),afterResponse:k(t,e,"afterResponse"),beforeError:k(t,e,"beforeError")}),He=(t,e)=>{const s=new URLSearchParams;for(const n of[t,e])if(n!==void 0)if(n instanceof URLSearchParams)for(const[i,a]of n.entries())s.append(i,a);else if(Array.isArray(n))for(const i of n){if(!Array.isArray(i)||i.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(i[0]),String(i[1]))}else if(T(n))for(const[i,a]of Object.entries(n))a!==void 0&&s.append(i,String(a));else{const i=new URLSearchParams(n);for(const[a,r]of i.entries())s.append(a,r)}return s},P=(...t)=>{let e={},s={},n={},i;const a=[];for(const r of t)if(Array.isArray(r))Array.isArray(e)||(e=[]),e=[...e,...r];else if(T(r)){for(let[c,l]of Object.entries(r)){if(c==="signal"&&l instanceof globalThis.AbortSignal){a.push(l);continue}if(c==="context"){if(l!=null&&(!T(l)||Array.isArray(l)))throw new TypeError("The `context` option must be an object");e={...e,context:l==null?{}:{...e.context,...l}};continue}if(c==="searchParams"){l==null?i=void 0:i=i===void 0?l:He(i,l);continue}T(l)&&c in e&&(l=P(e[c],l)),e={...e,[c]:l}}T(r.hooks)&&(n=te(n,r.hooks),e.hooks=n),T(r.headers)&&(s=ee(s,r.headers),e.headers=s)}return i!==void 0&&(e.searchParams=i),a.length>0&&(a.length===1?e.signal=a[0]:Y?e.signal=AbortSignal.any(a):e.signal=a.at(-1)),e.context===void 0&&(e.context={}),e},ze=t=>J.includes(t)?t.toUpperCase():t,se={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},qe=(t={})=>{if(typeof t=="number")return{...se,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{...se,...t}};class M extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function We(t,e,s,n){return new Promise((i,a)=>{const r=setTimeout(()=>{s&&s.abort(),a(new M(t))},n.timeout);n.fetch(t,e).then(i).catch(a).then(()=>{clearTimeout(r)})})}async function Ke(t,{signal:e}){return new Promise((s,n)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",i,{once:!0}));function i(){clearTimeout(a),n(e.reason)}const a=setTimeout(()=>{e?.removeEventListener("abort",i),s()},t)})}const Ve=(t,e)=>{const s={};for(const n in e)Object.hasOwn(e,n)&&!(n in Fe)&&!(n in Me)&&(!(n in t)||n in _e)&&(s[n]=e[n]);return s},Ge=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 Ye(t){return t instanceof N||t?.name===N.name}function Je(t){return t instanceof M||t?.name===M.name}class w{static create(e,s){const n=new w(e,s),i=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>O)throw new RangeError(`The \`timeout\` option cannot be greater than ${O}`);await Promise.resolve();let r=await n.#g();for(const c of n.#e.hooks.afterResponse){const l=n.#d(r.clone()),m=await c(n.request,n.#a(),l,{retryCount:n.#s});if(m instanceof globalThis.Response&&(r=m),m instanceof Z)throw await Promise.all([l.body?.cancel(),r.body?.cancel()]),new B(m.options)}if(n.#d(r),!r.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(r.status):n.#e.throwHttpErrors)){let c=new N(r,n.request,n.#a());for(const l of n.#e.hooks.beforeError)c=await l(c,{retryCount:n.#s});throw c}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!xe)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return je(r.clone(),n.#e.onDownloadProgress)}return r},a=n.#u(i).finally(async()=>{const r=n.#o,c=[];r&&!r.bodyUsed&&c.push(r.body?.cancel()),n.request.bodyUsed||c.push(n.request.body?.cancel()),await Promise.all(c)});for(const[r,c]of Object.entries(Be))r==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(a[r]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||c);const l=await a;if(r==="json"){if(l.status===204)return"";const m=await l.text();return m===""?"":s.parseJson?s.parseJson(m):JSON.parse(m)}return l[r]()});return a}static#f(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;#o;#i;#r;constructor(e,s={}){if(this.#t=e,this.#e={...s,headers:ee(this.#t.headers,s.headers),hooks:te({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:ze(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:qe(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}Ie&&Y&&(this.#i=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,this.#n.signal]):this.#n.signal),G&&(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&&(Ne&&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),Ge(this.#e.searchParams)){const a="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(w.#f(this.#e.searchParams)).toString()),r=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,a);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(!G)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#h(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 V(e);if(s instanceof B)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(Je(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Ye(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 i=Number(n)*1e3;Number.isNaN(i)?i=Date.parse(n)-Date.now():i>=Date.parse("2024-01-01")&&(i-=Date.now());const a=this.#e.retry.maxRetryAfter??i;return i<a?i:a}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#u(e){try{return await e()}catch(s){const n=Math.min(await this.#m(s),O);if(this.#s<1)throw s;if(await Ke(n,this.#i?{signal:this.#i}:{}),s instanceof B&&s.customRequest){const i=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#l(i)}for(const i of this.#e.hooks.beforeRetry){const a=await i({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(a instanceof globalThis.Request){this.#l(a);break}if(a instanceof globalThis.Response)return a;if(a===X)return}return this.#u(e)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#i?AbortSignal.any([this.#i,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=Ve(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):We(this.#o,e,this.#n,this.#e)}#a(){if(!this.#r){const{hooks:e,...s}=this.#e;this.#r=Object.freeze(s)}return this.#r}#l(e){this.#r=void 0,this.request=this.#h(e)}#h(e,s){return!this.#e.onUploadProgress||!e.body?e:$e(e,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const _=t=>{const e=(s,n)=>w.create(s,v(t,n));for(const s of J)e[s]=(n,i)=>w.create(n,v(t,i,{method:s}));return e.create=s=>_(v(s)),e.extend=s=>(typeof s=="function"&&(s=s(t??{})),_(v(t,s))),e.stop=X,e.retry=Pe,e},Xe=_(),h={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"},Ze={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 F(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 F(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const ie="2.43.4";let L={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${ie}`};class b extends Error{constructor(e,s={}){const n=s.cause instanceof b?s.cause.details:s.cause?.message?s.cause.message:s.details,i=s.cause instanceof b&&s.cause.docsPath||s.docsPath,a=L.getDocsUrl?.({...s,docsPath:i}),r=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...L.version?[`Version: ${L.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=i,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=ie}walk(e){return oe(this,e)}}function oe(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?oe(t.cause,e):e?null:t}class re extends b{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 D(t,{dir:e,size:s=32}={}){return typeof t=="string"?Qe(t,{dir:e,size:s}):et(t,{dir:e,size:s})}function Qe(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new re({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function et(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new re({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let i=0;i<s;i++){const a=e==="right";n[a?i:s-i-1]=t[a?i:t.length-i-1]}return n}class tt extends b{constructor({max:e,min:s,signed:n,size:i,value:a}){super(`Number "${a}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class st extends b{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function j(t,{size:e}){if(ne(t)>e)throw new st({givenSize:ne(t),maxSize:e})}function nt(t,e={}){const{signed:s,size:n}=e,i=BigInt(t);let a;n?s?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const r=typeof a=="bigint"&&s?-a-1n:0;if(a&&i>a||i<r){const l=typeof t=="bigint"?"n":"";throw new tt({max:a?`${a}${l}`:void 0,min:`${r}${l}`,signed:s,size:n,value:`${t}${l}`})}const c=`0x${(s&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?D(c,{size:n}):c}const it=new TextEncoder;function ot(t,e={}){return typeof t=="number"||typeof t=="bigint"?at(t,e):typeof t=="boolean"?rt(t,e):F(t)?ce(t,e):le(t,e)}function rt(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(j(s,{size:e.size}),D(s,{size:e.size})):s}const y={zero:48,nine:57,A:65,F:70,a:97,f:102};function ae(t){if(t>=y.zero&&t<=y.nine)return t-y.zero;if(t>=y.A&&t<=y.F)return t-(y.A-10);if(t>=y.a&&t<=y.f)return t-(y.a-10)}function ce(t,e={}){let s=t;e.size&&(j(s,{size:e.size}),s=D(s,{dir:"right",size:e.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,a=new Uint8Array(i);for(let r=0,c=0;r<i;r++){const l=ae(n.charCodeAt(c++)),m=ae(n.charCodeAt(c++));if(l===void 0||m===void 0)throw new b(`Invalid byte sequence ("${n[c-2]}${n[c-1]}" in "${n}").`);a[r]=l*16+m}return a}function at(t,e){const s=nt(t,e);return ce(s)}function le(t,e={}){const s=it.encode(t);return typeof e.size=="number"?(j(s,{size:e.size}),D(s,{dir:"right",size:e.size})):s}const R=BigInt(2**32-1),de=BigInt(32);function ct(t,e=!1){return e?{h:Number(t&R),l:Number(t>>de&R)}:{h:Number(t>>de&R)|0,l:Number(t&R)|0}}function lt(t,e=!1){const s=t.length;let n=new Uint32Array(s),i=new Uint32Array(s);for(let a=0;a<s;a++){const{h:r,l:c}=ct(t[a],e);[n[a],i[a]]=[r,c]}return[n,i]}const dt=(t,e,s)=>t<<s|e>>>32-s,ut=(t,e,s)=>e<<s|t>>>32-s,ht=(t,e,s)=>e<<s-32|t>>>64-s,ft=(t,e,s)=>t<<s-32|e>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function mt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ue(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function I(t,...e){if(!mt(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 he(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 gt(t,e){I(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function pt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function fe(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const yt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bt(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function Tt(t){for(let e=0;e<t.length;e++)t[e]=bt(t[e]);return t}const me=yt?t=>t:Tt;function Et(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function ge(t){return typeof t=="string"&&(t=Et(t)),I(t),t}class St{}function Ct(t){const e=n=>t().update(ge(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}const wt=BigInt(0),U=BigInt(1),Ut=BigInt(2),At=BigInt(7),vt=BigInt(256),kt=BigInt(113),pe=[],ye=[],be=[];for(let t=0,e=U,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],pe.push(2*(5*n+s)),ye.push((t+1)*(t+2)/2%64);let i=wt;for(let a=0;a<7;a++)e=(e<<U^(e>>At)*kt)%vt,e&Ut&&(i^=U<<(U<<BigInt(a))-U);be.push(i)}const Te=lt(be,!0),Dt=Te[0],Rt=Te[1],Ee=(t,e,s)=>s>32?ht(t,e,s):dt(t,e,s),Se=(t,e,s)=>s>32?ft(t,e,s):ut(t,e,s);function It(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 c=(r+8)%10,l=(r+2)%10,m=s[l],E=s[l+1],Qt=Ee(m,E,1)^s[c],es=Se(m,E,1)^s[c+1];for(let x=0;x<50;x+=10)t[r+x]^=Qt,t[r+x+1]^=es}let i=t[2],a=t[3];for(let r=0;r<24;r++){const c=ye[r],l=Ee(i,a,c),m=Se(i,a,c),E=pe[r];i=t[E],a=t[E+1],t[E]=l,t[E+1]=m}for(let r=0;r<50;r+=10){for(let c=0;c<10;c++)s[c]=t[r+c];for(let c=0;c<10;c++)t[r+c]^=~s[(c+2)%10]&s[(c+4)%10]}t[0]^=Dt[n],t[1]^=Rt[n]}fe(s)}class $ extends St{constructor(e,s,n,i=!1,a=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=i,this.rounds=a,ue(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=pt(this.state)}clone(){return this._cloneInto()}keccak(){me(this.state32),It(this.state32,this.rounds),me(this.state32),this.posOut=0,this.pos=0}update(e){he(this),e=ge(e),I(e);const{blockLen:s,state:n}=this,i=e.length;for(let a=0;a<i;){const r=Math.min(s-this.pos,i-a);for(let c=0;c<r;c++)n[this.pos++]^=e[a++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:i}=this;e[n]^=s,(s&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){he(this,!1),I(e),this.finish();const s=this.state,{blockLen:n}=this;for(let i=0,a=e.length;i<a;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,a-i);e.set(s.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=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 ue(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gt(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,fe(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:i,rounds:a,enableXOF:r}=this;return e||(e=new $(s,n,i,r,a)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=a,e.suffix=n,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}const xt=(t,e,s)=>Ct(()=>new $(e,t,s)),Nt=xt(1,136,256/8);function Bt(t,e){return Nt(F(t,{strict:!1})?ot(t):t)}class Ot extends b{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 Ce 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 H=new Ce(8192);function we(t,e){if(H.has(`${t}.${e}`))return H.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),n=Bt(le(s)),i=s.split("");for(let r=0;r<40;r+=2)n[r>>1]>>4>=8&&i[r]&&(i[r]=i[r].toUpperCase()),(n[r>>1]&15)>=8&&i[r+1]&&(i[r+1]=i[r+1].toUpperCase());const a=`0x${i.join("")}`;return H.set(`${t}.${e}`,a),a}function f(t,e){if(!Mt(t,{strict:!1}))throw new Ot({address:t});return we(t,e)}const Pt=/^0x[a-fA-F0-9]{40}$/,z=new Ce(8192);function Mt(t,e){const{strict:s=!0}=e??{},n=`${t}.${s}`;if(z.has(n))return z.get(n);const i=Pt.test(t)?t.toLowerCase()===t?!0:s?we(t)===t:!0:!1;return z.set(n,i),i}const o={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};o.USDC;const Ue={[h.ARBITRUM]:{[o.DAI]:{address:f("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.USDC]:{address:f("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[o.USDT]:{address:f("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:f("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.ARBITRUM_TESTNET]:{[o.USDC]:{address:f("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.AVALANCHE]:{[o.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.USDC]:{address:f("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.AVALANCHE_TESTNET]:{[o.USDC]:{address:f("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.BASE]:{[o.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:o.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[o.USDC]:{address:f("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.WETH]:{address:f("0x4200000000000000000000000000000000000006"),symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.BASE_TESTNET]:{[o.USDC]:{address:f("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:o.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.BSC]:{[o.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:o.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp",nativeToken:!0},[o.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:o.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[o.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[o.USDC]:{address:f("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:o.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:o.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[h.ETHEREUM]:{[o.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:o.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png",nativeToken:!1},[o.DAI]:{address:f("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:o.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png",nativeToken:!1},[o.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:o.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[o.USDC]:{address:f("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:f("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:f("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.ETHEREUM_TESTNET]:{[o.USDC]:{address:f("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:o.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1}},[h.HYPEREVM]:{[o.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.LISK]:{[o.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.MONAD]:{[o.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.MONAD_TESTNET]:{[o.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.OPTIMISM]:{[o.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!0},[o.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[o.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.OPTIMISM_TESTNET]:{[o.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}},[h.POLYGON]:{[o.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1},[o.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1},[o.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:o.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png",nativeToken:!1}},[h.STARKNET]:{[o.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:o.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png",nativeToken:!1},[o.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:o.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg",nativeToken:!1},[o.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:o.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png",nativeToken:!1},[o.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:o.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg",nativeToken:!1},[o.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png",nativeToken:!1},[o.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:o.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png",nativeToken:!1}},[h.STARKNET_TESTNET]:{[o.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:o.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",nativeToken:!1}}},_t=new Set(Object.values(h));function p(t){if(Ft(t))return t;const e=h[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 Ft(t){return _t.has(t)}function Lt(t,e){const s=e.toLowerCase().trim(),n=Ue[t];if(!n)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let i;for(const a in n){const r=n[a];if(r&&r.address.toLowerCase()===s.toLowerCase()){i=r;break}}if(!i)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 i}function q(t,e,s){const n=Lt(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 jt(t,e){return Ue[t]?.[e]}function Ae(t,e){return jt(t,e)?.address}var W=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(W||{});class d{constructor({api_key:e,env:s,seesion_token:n,props:i}){this.api_key=e||"",this.sessionToken=n||"",this.env=s??W.PRODUCTION,this.props=i}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),i=e&&!isNaN(Number(e))&&n>0?"/pay/":"/deposit/",a=`${e&&!isNaN(Number(e))&&n>0?n*100:""}`;return s+i+a}}let K=null;function $t(){K=Xe.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 u(){return K||$t(),K}class Ht{async getById(e){return await u().get("intents/"+e).json()}async getForSender(e){return await u().get("intents/user/"+e).json()}async getForAddress(e){return await u().get("intents/address/"+e).json()}async getForSession(e){return await u().get("modal/sessions/intents/"+e).json()}async getAll(e){return await u().get("intents",{searchParams:e}).json()}async create(e){const s=p(e.source_chain),n=p(e.destination_chain);return await u().post("intents",{json:{...e,source_chain:s,destination_chain:n}}).json()}async createForSession(e){const s=p(e.sourceChain);return await u().post("modal/sessions/intents",{json:{...e,sourceChain:s}}).json()}async update(e,s){return await u().post("intents",{json:s}).json()}async triggerProcessing(e){return await u().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await u().post(`modal/sessions/intents/${e}/process`).json()}}class zt{async getFromSpecificBridge(e){const s=p(e.sourceChain);q(s,e.tokenIn,e.amountSymbol);const n=p(e.destinationChain);return await u().get("quotes/single",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getFromAllBridges(e){const s=p(e.sourceChain);q(s,e.tokenIn,e.amountSymbol);const n=p(e.destinationChain);return await u().get("quotes/multiple",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getBestAcrossBridges(e){const s=p(e.sourceChain);q(s,e.tokenIn,e.amountSymbol);const n=p(e.destinationChain);return await u().get("quotes/best",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAll(e){const s=p(e.destinationChain);return await u().get("quotes/multi-source",{searchParams:{...e,destinationChain:s}}).json()}async getAllForSession(e){return await u().get("modal/sessions/quotes",{searchParams:e}).json()}}class qt{async getOptimalRoutes(e){const s=p(e.sourceChain),n=p(e.destinationChain);return await u().get("router/optimal-route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAllSupportedBridges(){return await u().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const s=p(e.sourceChain),n=p(e.destinationChain);return await u().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getSupportedRoutes(e){return await u().get("router/supported-routes/bridge/"+e).json()}}class Wt{async getSupported(e){return await u().get("chains",{searchParams:e}).json()}async getBalance(e){return await u().get(`chains/balances/${e.address}`,{searchParams:e}).json()}}class Kt{async getClientInfo(){return await u().get("client/auth/client-info").json()}async getClientInfoForSession(){return await u().get("modal/sessions/client").json()}}class Vt{async getSessionToken(e){const s=p(e.destinationChain);let n=Ae(s,e.token);n||(console.error(`${e.token} on ${e.destinationChain} is currently unsupported, defaulting to usdc`),n=Ae(s,"USDC"));const i={recipient:e.recipient,tokenOut:n,destinationChain:s,amount:e.amount};return u().post("modal/sessions",{json:i}).json().then(a=>({...a,amount:i.amount}))}}const Gt={router:new qt,quotes:new zt,intents:new Ht,chains:new Wt,client:new Kt,auth:new Vt},Yt=["light","dark","system"],ve="https://app.chainrails.io",ke="https://chainrails-frontend-git-staging-horus-labs.vercel.app",A=class A extends HTMLElement{constructor(){super(...arguments),this.key=0,this.initialized=!1,this.iframe=null,this.loader=null,this.themeCss=null,this.previousBodyOverflow="",this._sessionToken=null,this._env="production",this._isOpen=!1,this._isPending=!1,this.handleMessage=e=>{e.data==="closed"&&(this.close(),this._onCancel?.(),this.dispatchEvent(new CustomEvent("cancelled"))),e.data==="completed"&&(window.setTimeout(()=>this.close(),2e3),this._onSuccess?.(),this.dispatchEvent(new CustomEvent("completed")))}}static get observedAttributes(){return A.observed}connectedCallback(){this.setup(),this.syncFromAttributes(),this.refreshUi(),window.addEventListener("message",this.handleMessage)}disconnectedCallback(){window.removeEventListener("message",this.handleMessage),this._isOpen&&(document.body.style.overflow=this.previousBodyOverflow||"")}attributeChangedCallback(e,s,n){if(this.initialized){if(e==="session-token"){this.sessionToken=n;return}if(e==="amount"){this.amount=n??void 0;return}if(e==="session-url"){this.sessionUrl=n??void 0;return}if(e==="is-open"){this.isOpen=n!==null&&n!=="false";return}if(e==="is-pending"){this.isPending=n!==null&&n!=="false";return}if(e==="env"){this.env=n==="internal"?"internal":"production";return}if(e==="exclude-chains"){this.excludeChains=n?n.split(",").map(i=>i.trim()).filter(Boolean):void 0;return}if(e==="theme"||e==="accent-color"){const i=this.styles||{};this.styles={...i,theme:this.getAttribute("theme")??i.theme,accentColor:this.getAttribute("accent-color")??i.accentColor}}}}get sessionToken(){return this._sessionToken}set sessionToken(e){console.log({value:e}),this._sessionToken=e??null,this.postAuth()}get amount(){return this._amount}set amount(e){this._amount=e,this.key=0,this.setIframeSrc(),this.refreshUi()}get sessionUrl(){return this._sessionUrl}set sessionUrl(e){this._sessionUrl=e}get styles(){return this._styles}set styles(e){this._styles=e,this.resolveThemeCss().finally(()=>this.postAuth())}get excludeChains(){return this._excludeChains}set excludeChains(e){this._excludeChains=e,this.postAuth()}get env(){return this._env}set env(e){this._env=e,this.configureSdk(),this.setIframeSrc(),this.postAuth()}get isOpen(){return this._isOpen}set isOpen(e){this._isOpen=!!e,this.refreshUi()}get isPending(){return this._isPending}set isPending(e){this._isPending=!!e,this.refreshUi()}get onCancel(){return this._onCancel}set onCancel(e){this._onCancel=e}get onSuccess(){return this._onSuccess}set onSuccess(e){this._onSuccess=e}open(){this.sessionToken||window.setTimeout(()=>{this.sessionToken&&(this.isOpen=!0)},200),this.isOpen=!0}close(){this.isOpen=!1}setProps(e){typeof e.sessionToken<"u"&&(this.sessionToken=e.sessionToken),typeof e.amount<"u"&&(this.amount=e.amount),typeof e.sessionUrl<"u"&&(this.sessionUrl=e.sessionUrl),typeof e.styles<"u"&&(this.styles=e.styles),typeof e.excludeChains<"u"&&(this.excludeChains=e.excludeChains),typeof e.env<"u"&&(this.env=e.env),typeof e.isPending<"u"&&(this.isPending=e.isPending),typeof e.isOpen<"u"&&(this.isOpen=e.isOpen),typeof e.onCancel<"u"&&(this.onCancel=e.onCancel),typeof e.onSuccess<"u"&&(this.onSuccess=e.onSuccess)}setup(){this.initialized||(this.classList.add("payment-modal-wrapper"),this.loader=document.createElement("div"),this.loader.className="payment-modal-loader",this.loader.setAttribute("role","status"),this.loader.innerHTML=`<svg aria-hidden="true" class="icon" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
4
4
  <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" />
5
5
  <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" />
6
- </svg>`,this.iframe=document.createElement("iframe"),this.iframe.className="payment-modal invisible",this.iframe.setAttribute("allow","clipboard-read *; clipboard-write *"),this.iframe.addEventListener("load",()=>{this.key=Math.random(),this.refreshUi(),this.postAuth()}),this.appendChild(this.loader),this.appendChild(this.iframe),this.configureSdk(),this.setIframeSrc(),this.initialized=!0)}syncFromAttributes(){this.sessionToken=this.getAttribute("session-token");const e=this.getAttribute("amount");e&&(this.amount=e);const s=this.getAttribute("session-url");s&&(this.sessionUrl=s),this.isOpen=this.hasAttribute("is-open"),this.isPending=this.hasAttribute("is-pending");const n=this.getAttribute("env");this.env=n==="internal"?"internal":"production";const i=this.getAttribute("theme")??void 0,a=this.getAttribute("accent-color")??void 0;(i||a)&&(this.styles={theme:i,accentColor:a});const r=this.getAttribute("exclude-chains");r&&(this.excludeChains=r.split(",").map(c=>c.trim()).filter(Boolean))}configureSdk(){u.config({api_key:"",env:this._env})}setIframeSrc(){this.iframe&&(this.iframe.src=u.getPayModalUrl(this._amount))}refreshUi(){const e=this.key===0||this._isPending;this.classList.toggle("loading",e),this.classList.toggle("not-loading",!e),this.classList.toggle("open",this._isOpen),this.classList.toggle("closed",!this._isOpen),this.iframe&&(this.iframe.classList.toggle("invisible",e),this.iframe.classList.toggle("visible",!e),this.iframe.dataset.id=this._amount??""),this._isOpen?(this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden"):document.body.style.overflow=this.previousBodyOverflow||""}async resolveThemeCss(){const e=this._styles?.theme;if(!e||Yt.includes(e)){this.themeCss=null;return}try{const s=u.getBaseUrl(),n=await fetch(`${s}/themes/${e}`);if(!n.ok)return;const i=await n.json();i.status==="approved"&&i.cssContent&&(this.themeCss=i.cssContent)}catch(s){console.error("Failed to fetch theme:",s)}}postAuth(){if(!this._sessionToken||!this.iframe?.contentWindow)return;const e={type:"session",session_token:this._sessionToken,environment:u.getEnv()||W.PRODUCTION,styles:this._styles,props:{excludeChains:this._excludeChains?.join(",")},...this.themeCss?{css:this.themeCss}:{}};this.iframe.contentWindow.postMessage(e,ve),this.iframe.contentWindow.postMessage(e,ke),window.setTimeout(()=>{this.iframe?.contentWindow&&(this.iframe.contentWindow.postMessage(e,ve),this.iframe.contentWindow.postMessage(e,ke))},1e3)}};A.tagName="chainrails-payment-modal",A.observed=["session-token","amount","session-url","is-open","is-pending","theme","accent-color","exclude-chains","env"];let C=A;function De(){customElements.get(C.tagName)||customElements.define(C.tagName,C)}class Re extends EventTarget{constructor({session_url:e,onCancel:s,onSuccess:n}){super(),this.data=null,this.error=null,this.isPending=!1,this.isOpen=!1,this.current=Date.now(),this.retryIntervalId=null,this.sessionUrl=e,this.onCancel=s,this.onSuccess=n}get sessionToken(){return this.data?.sessionToken??null}get amount(){return this.data?.amount}get session_url(){return this.sessionUrl}snapshot(){return{data:this.data,error:this.error,isPending:this.isPending,isOpen:this.isOpen,sessionToken:this.sessionToken,amount:this.amount,session_url:this.sessionUrl}}subscribe(e){const s=()=>e(this.snapshot());return this.addEventListener("change",s),e(this.snapshot()),()=>this.removeEventListener("change",s)}open(){this.sessionToken||window.setTimeout(()=>{this.sessionToken&&this.setOpen(!0)},200),this.setOpen(!0)}close(){this.setOpen(!1)}async refetch(){const e=Date.now();this.isPending=!0,this.error=null,this.data=null,this.dispatchChange();try{const n=await(await fetch(this.sessionUrl,{headers:{"Content-Type":"application/json"}})).json();if(e<this.current)return;this.data=n,this.isPending=!1,this.current=e,this.clearRetry(),this.dispatchChange()}catch(s){if(e<this.current)return;this.error=s?.toString()??"Unknown error",this.isPending=!1,this.current=e,this.dispatchChange(),this.retryIntervalId===null&&(this.retryIntervalId=window.setInterval(()=>{this.refetch()},5e3))}}bind(e){e.setProps({sessionToken:this.sessionToken,amount:this.amount,sessionUrl:this.sessionUrl,isOpen:this.isOpen,isPending:this.isPending,onCancel:()=>{this.close(),this.onCancel?.()},onSuccess:()=>{this.onSuccess?.()}});const s=this.subscribe(n=>{e.setProps({sessionToken:n.sessionToken,amount:n.amount,isOpen:n.isOpen,isPending:n.isPending})});return()=>{s()}}destroy(){this.clearRetry()}setOpen(e){this.isOpen=e,this.dispatchChange()}dispatchChange(){this.dispatchEvent(new Event("change"))}clearRetry(){this.retryIntervalId!==null&&(window.clearInterval(this.retryIntervalId),this.retryIntervalId=null)}}function Jt(t){const e=new Re(t);return e.refetch(),e}function Xt(t){return typeof t=="number"&&Number.isInteger(t)?BigInt(t).toString():String(t)}function Zt(t,e){return Number(t)*Math.pow(10,e)}De(),g.AmountSymbols=o,g.Chainrails=u,g.ChainrailsPaymentModalElement=C,g.Chains=Ze,g.PaymentSessionController=Re,g.convertToBaseUnits=Zt,g.convertToNormalNumber=Xt,g.crapi=Gt,g.createPaymentSession=Jt,g.definePaymentModalElement=De,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
6
+ </svg>`,this.iframe=document.createElement("iframe"),this.iframe.className="payment-modal invisible",this.iframe.setAttribute("allow","clipboard-read *; clipboard-write *"),this.iframe.addEventListener("load",()=>{this.key=Math.random(),this.refreshUi(),this.postAuth()}),this.appendChild(this.loader),this.appendChild(this.iframe),this.configureSdk(),this.setIframeSrc(),this.initialized=!0)}syncFromAttributes(){this.sessionToken=this.getAttribute("session-token");const e=this.getAttribute("amount");e&&(this.amount=e);const s=this.getAttribute("session-url");s&&(this.sessionUrl=s),this.isOpen=this.hasAttribute("is-open"),this.isPending=this.hasAttribute("is-pending");const n=this.getAttribute("env");this.env=n==="internal"?"internal":"production";const i=this.getAttribute("theme")??void 0,a=this.getAttribute("accent-color")??void 0;(i||a)&&(this.styles={theme:i,accentColor:a});const r=this.getAttribute("exclude-chains");r&&(this.excludeChains=r.split(",").map(c=>c.trim()).filter(Boolean))}configureSdk(){d.config({api_key:"",env:this._env})}setIframeSrc(){this.iframe&&(this.iframe.src=d.getPayModalUrl(this._amount))}refreshUi(){const e=this.key===0||this._isPending;this.classList.toggle("loading",e),this.classList.toggle("not-loading",!e),this.classList.toggle("open",this._isOpen),this.classList.toggle("closed",!this._isOpen),this.iframe&&(this.iframe.classList.toggle("invisible",e),this.iframe.classList.toggle("visible",!e),this.iframe.dataset.id=this._amount??""),this._isOpen?(this.previousBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden"):document.body.style.overflow=this.previousBodyOverflow||""}async resolveThemeCss(){const e=this._styles?.theme;if(!e||Yt.includes(e)){this.themeCss=null;return}try{const s=d.getBaseUrl(),n=await fetch(`${s}/themes/${e}`);if(!n.ok)return;const i=await n.json();i.status==="approved"&&i.cssContent&&(this.themeCss=i.cssContent)}catch(s){console.error("Failed to fetch theme:",s)}}postAuth(){if(!this._sessionToken||!this.iframe?.contentWindow)return;const e={type:"session",session_token:this._sessionToken,environment:d.getEnv()||W.PRODUCTION,styles:this._styles,props:{excludeChains:this._excludeChains?.join(",")},...this.themeCss?{css:this.themeCss}:{}};console.log({auth:e}),this.iframe.contentWindow.postMessage(e,ve),this.iframe.contentWindow.postMessage(e,ke),window.setTimeout(()=>{this.iframe?.contentWindow&&(this.iframe.contentWindow.postMessage(e,ve),this.iframe.contentWindow.postMessage(e,ke))},1e3)}};A.tagName="chainrails-payment-modal",A.observed=["session-token","amount","session-url","is-open","is-pending","theme","accent-color","exclude-chains","env"];let C=A;function De(){customElements.get(C.tagName)||customElements.define(C.tagName,C)}class Re extends EventTarget{constructor({session_url:e,onCancel:s,onSuccess:n}){super(),this.data=null,this.error=null,this.isPending=!1,this.isOpen=!1,this.current=Date.now(),this.retryIntervalId=null,this.sessionUrl=e,this.onCancel=s,this.onSuccess=n}get sessionToken(){return this.data?.sessionToken??null}get amount(){return this.data?.amount}get session_url(){return this.sessionUrl}snapshot(){return{data:this.data,error:this.error,isPending:this.isPending,isOpen:this.isOpen,sessionToken:this.sessionToken,amount:this.amount,session_url:this.sessionUrl}}subscribe(e){const s=()=>e(this.snapshot());return this.addEventListener("change",s),e(this.snapshot()),()=>this.removeEventListener("change",s)}open(){this.sessionToken||window.setTimeout(()=>{this.sessionToken&&this.setOpen(!0)},200),this.setOpen(!0)}close(){this.setOpen(!1)}async refetch(){const e=Date.now();this.isPending=!0,this.error=null,this.data=null,this.dispatchChange();try{const n=await(await fetch(this.sessionUrl,{headers:{"Content-Type":"application/json"}})).json();if(e<this.current)return;this.data=n,this.isPending=!1,this.current=e,this.clearRetry(),this.dispatchChange()}catch(s){if(e<this.current)return;this.error=s?.toString()??"Unknown error",this.isPending=!1,this.current=e,this.dispatchChange(),this.retryIntervalId===null&&(this.retryIntervalId=window.setInterval(()=>{this.refetch()},5e3))}}bind(e){e.setProps({sessionToken:this.sessionToken,amount:this.amount,sessionUrl:this.sessionUrl,isOpen:this.isOpen,isPending:this.isPending,onCancel:()=>{this.close(),this.onCancel?.()},onSuccess:()=>{this.onSuccess?.()}});const s=this.subscribe(n=>{e.setProps({sessionToken:n.sessionToken,amount:n.amount,isOpen:n.isOpen,isPending:n.isPending})});return()=>{s()}}destroy(){this.clearRetry()}setOpen(e){this.isOpen=e,this.dispatchChange()}dispatchChange(){this.dispatchEvent(new Event("change"))}clearRetry(){this.retryIntervalId!==null&&(window.clearInterval(this.retryIntervalId),this.retryIntervalId=null)}}function Jt(t){const e=new Re(t);return e.refetch(),e}function Xt(t){return typeof t=="number"&&Number.isInteger(t)?BigInt(t).toString():String(t)}function Zt(t,e){return Number(t)*Math.pow(10,e)}De(),g.AmountSymbols=o,g.Chainrails=d,g.ChainrailsPaymentModalElement=C,g.Chains=Ze,g.PaymentSessionController=Re,g.convertToBaseUnits=Zt,g.convertToNormalNumber=Xt,g.crapi=Gt,g.createPaymentSession=Jt,g.definePaymentModalElement=De,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
@@ -1 +1 @@
1
- {"version":3,"file":"payment-modal-element.d.ts","sourceRoot":"","sources":["../src/payment-modal-element.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"payment-modal-element.d.ts","sourceRoot":"","sources":["../src/payment-modal-element.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sideEffects": [
4
4
  "**/*.css"
5
5
  ],
6
- "version": "0.0.4",
6
+ "version": "0.0.5",
7
7
  "description": "Vanilla Web Component bindings for Chainrails payments",
8
8
  "license": "MIT",
9
9
  "repository": {