@tokenflight/swap 0.2.3 → 0.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/ReceiveComponent-Cyn4ECRG.js +1 -0
  2. package/dist/ReceiveComponent.module-BGpemTAX.js +1 -0
  3. package/dist/SwapComponent-BwfaI3D9.js +1 -0
  4. package/dist/active-bridge-V8lTJ2Js.js +1 -0
  5. package/dist/bridge-Bq0QUltI.js +1 -0
  6. package/dist/bridge.d.ts +613 -0
  7. package/dist/bridge.js +1 -0
  8. package/dist/custom-elements.d.ts +1 -27
  9. package/dist/defaults-loader-DfcaO9j5.js +1 -0
  10. package/dist/en-US-CU2aSy93.js +1 -0
  11. package/dist/errors-Nd9setTj.js +3 -0
  12. package/dist/iframe-entry.d.ts +21 -0
  13. package/dist/iframe-entry.js +29 -0
  14. package/dist/iframe-receiver-PfhKUIZW.js +1 -0
  15. package/dist/iframe.d.ts +422 -0
  16. package/dist/iframe.js +45 -0
  17. package/dist/ja-JP-BoipV6-j.js +1 -0
  18. package/dist/ko-KR-DyFXZJsF.js +1 -0
  19. package/dist/protocol-CDxgudrl.js +1 -0
  20. package/dist/rank-offers-CR-1NeiW.js +1 -0
  21. package/dist/register-defaults-C_q7CG7x.js +1 -0
  22. package/dist/register-widget-DOzDJD94.js +1 -0
  23. package/dist/shared.module-C-kWMzqW.js +1 -0
  24. package/dist/solid-iWr5Czxc.js +1 -0
  25. package/dist/swap.css +1 -1
  26. package/dist/theme-C9tsVWlo.js +2 -0
  27. package/dist/tokenflight-swap.d.ts +106 -308
  28. package/dist/tokenflight-swap.js +1 -2
  29. package/dist/tokenflight-swap.umd.cjs +5 -4
  30. package/dist/widget-BadYytj9.js +2 -0
  31. package/dist/widget.d.ts +267 -27
  32. package/dist/widget.js +1 -1
  33. package/dist/zh-CN-epCUm9Io.js +1 -0
  34. package/dist/zh-TW-DSEboEJV.js +1 -0
  35. package/package.json +14 -2
  36. package/dist/en-US-DJW-hZLc.js +0 -1
  37. package/dist/ja-JP-BU7auPz-.js +0 -1
  38. package/dist/ko-KR-BIXVqnQ_.js +0 -1
  39. package/dist/register-widget-CXGm8Ih3.js +0 -3
  40. package/dist/zh-CN-RuuHh9p5.js +0 -1
  41. package/dist/zh-TW-Ddf7Ck1N.js +0 -1
@@ -22,11 +22,7 @@
22
22
  * to your component's `schemas` array. This import still registers the
23
23
  * elements in `HTMLElementTagNameMap` for `document.querySelector()` etc.
24
24
  */
25
- import type {
26
- TokenFlightReceiveAttributes,
27
- TokenFlightDepositAttributes,
28
- TokenFlightWidgetAttributes,
29
- } from "./index";
25
+ import type { TokenFlightWidgetAttributes } from "./index";
30
26
 
31
27
  /**
32
28
  * Standard HTML attributes common to all custom elements.
@@ -86,13 +82,9 @@ interface ReactHTMLAttributes {
86
82
  }
87
83
 
88
84
  /** Widget attributes + standard HTML attributes */
89
- type ReceiveElementAttributes = TokenFlightReceiveAttributes & BaseHTMLAttributes;
90
- type DepositElementAttributes = TokenFlightDepositAttributes & BaseHTMLAttributes;
91
85
  type WidgetElementAttributes = TokenFlightWidgetAttributes & BaseHTMLAttributes;
92
86
 
93
87
  /** With React/Preact camelCase aliases */
94
- type ReceiveReactAttributes = ReceiveElementAttributes & ReactHTMLAttributes;
95
- type DepositReactAttributes = DepositElementAttributes & ReactHTMLAttributes;
96
88
  type WidgetReactAttributes = WidgetElementAttributes & ReactHTMLAttributes;
97
89
 
98
90
  // ---------------------------------------------------------------------------
@@ -101,16 +93,12 @@ type WidgetReactAttributes = WidgetElementAttributes & ReactHTMLAttributes;
101
93
  // ---------------------------------------------------------------------------
102
94
  declare global {
103
95
  interface HTMLElementTagNameMap {
104
- "tokenflight-receive": HTMLElement;
105
- "tokenflight-deposit": HTMLElement;
106
96
  "tokenflight-widget": HTMLElement;
107
97
  }
108
98
 
109
99
  // eslint-disable-next-line @typescript-eslint/no-namespace
110
100
  namespace svelteHTML {
111
101
  interface IntrinsicElements {
112
- "tokenflight-receive": ReceiveElementAttributes;
113
- "tokenflight-deposit": DepositElementAttributes;
114
102
  "tokenflight-widget": WidgetElementAttributes;
115
103
  }
116
104
  }
@@ -123,8 +111,6 @@ declare module "react/jsx-runtime" {
123
111
  // eslint-disable-next-line @typescript-eslint/no-namespace
124
112
  namespace JSX {
125
113
  interface IntrinsicElements {
126
- "tokenflight-receive": ReceiveReactAttributes;
127
- "tokenflight-deposit": DepositReactAttributes;
128
114
  "tokenflight-widget": WidgetReactAttributes;
129
115
  }
130
116
  }
@@ -137,8 +123,6 @@ declare module "react" {
137
123
  // eslint-disable-next-line @typescript-eslint/no-namespace
138
124
  namespace JSX {
139
125
  interface IntrinsicElements {
140
- "tokenflight-receive": ReceiveReactAttributes;
141
- "tokenflight-deposit": DepositReactAttributes;
142
126
  "tokenflight-widget": WidgetReactAttributes;
143
127
  }
144
128
  }
@@ -151,8 +135,6 @@ declare module "preact" {
151
135
  // eslint-disable-next-line @typescript-eslint/no-namespace
152
136
  namespace JSX {
153
137
  interface IntrinsicElements {
154
- "tokenflight-receive": ReceiveReactAttributes;
155
- "tokenflight-deposit": DepositReactAttributes;
156
138
  "tokenflight-widget": WidgetReactAttributes;
157
139
  }
158
140
  }
@@ -163,8 +145,6 @@ declare module "preact" {
163
145
  // ---------------------------------------------------------------------------
164
146
  declare module "vue" {
165
147
  interface GlobalComponents {
166
- "tokenflight-receive": ReceiveElementAttributes;
167
- "tokenflight-deposit": DepositElementAttributes;
168
148
  "tokenflight-widget": WidgetElementAttributes;
169
149
  }
170
150
  }
@@ -176,8 +156,6 @@ declare module "solid-js" {
176
156
  // eslint-disable-next-line @typescript-eslint/no-namespace
177
157
  namespace JSX {
178
158
  interface IntrinsicElements {
179
- "tokenflight-receive": ReceiveElementAttributes;
180
- "tokenflight-deposit": DepositElementAttributes;
181
159
  "tokenflight-widget": WidgetElementAttributes;
182
160
  }
183
161
  }
@@ -188,8 +166,6 @@ declare module "solid-js" {
188
166
  // ---------------------------------------------------------------------------
189
167
  declare module "svelte/elements" {
190
168
  interface SvelteHTMLElements {
191
- "tokenflight-receive": ReceiveElementAttributes;
192
- "tokenflight-deposit": DepositElementAttributes;
193
169
  "tokenflight-widget": WidgetElementAttributes;
194
170
  }
195
171
  }
@@ -199,8 +175,6 @@ declare module "svelte/elements" {
199
175
  // ---------------------------------------------------------------------------
200
176
  declare namespace astroHTML.JSX {
201
177
  interface IntrinsicElements {
202
- "tokenflight-receive": ReceiveElementAttributes;
203
- "tokenflight-deposit": DepositElementAttributes;
204
178
  "tokenflight-widget": WidgetElementAttributes;
205
179
  }
206
180
  }
@@ -0,0 +1 @@
1
+ var e;function t(t){return{lang:t?.lang??e?.lang,message:t?.message,abortEarly:t?.abortEarly??e?.abortEarly,abortPipeEarly:t?.abortPipeEarly??e?.abortPipeEarly}}var n;function r(e){return n?.get(e)}var i;function a(e){return i?.get(e)}var o;function s(e,t){return o?.get(e)?.get(t)}function c(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function l(e,t,n,i,o){let l=o&&`input`in o?o.input:n.value,u=o?.expected??e.expects??null,d=o?.received??c(l),f={kind:e.kind,type:e.type,input:l,expected:u,received:d,message:`Invalid ${t}: ${u?`Expected ${u} but r`:`R`}eceived ${d}`,requirement:e.requirement,path:o?.path,issues:o?.issues,lang:i.lang,abortEarly:i.abortEarly,abortPipeEarly:i.abortPipeEarly},p=e.kind===`schema`,m=o?.message??e.message??s(e.reference,f.lang)??(p?a(f.lang):null)??i.message??r(f.lang);m!==void 0&&(f.message=typeof m==`function`?m(f):m),p&&(n.typed=!1),n.issues?n.issues.push(f):n.issues=[f]}function u(e){return{version:1,vendor:`valibot`,validate(n){return e[`~run`]({value:n},t())}}}function d(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function f(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}function p(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function m(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function h(e,t){return{kind:`schema`,type:`array`,reference:h,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return u(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else l(this,`type`,e,t);return e}}}function g(e){return{kind:`schema`,type:`boolean`,reference:g,expects:`boolean`,async:!1,message:e,get"~standard"(){return u(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:l(this,`type`,e,t),e}}}function _(e){return{kind:`schema`,type:`number`,reference:_,expects:`number`,async:!1,message:e,get"~standard"(){return u(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:l(this,`type`,e,t),e}}}function v(e,t){return{kind:`schema`,type:`object`,reference:v,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return u(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:m(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=p(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(l(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}}else l(this,`type`,e,t);return e}}}function y(e,t){return{kind:`schema`,type:`optional`,reference:y,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return u(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=m(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function b(e,t){return{kind:`schema`,type:`picklist`,reference:b,expects:f(e.map(c),`|`),async:!1,options:e,message:t,get"~standard"(){return u(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:l(this,`type`,e,t),e}}}function x(e,t,n){return{kind:`schema`,type:`record`,reference:x,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return u(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){e.typed=!0,e.value={};for(let r in n)if(d(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else l(this,`type`,e,t);return e}}}function S(e){return{kind:`schema`,type:`string`,reference:S,expects:`string`,async:!1,message:e,get"~standard"(){return u(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:l(this,`type`,e,t),e}}}function C(e,t){let n={};for(let r in e.entries)n[r]=!t||t.includes(r)?y(e.entries[r]):e.entries[r];return{...e,entries:n,get"~standard"(){return u(this)}}}function w(e,n,r){let i=e[`~run`]({value:n},t(r));return{typed:i.typed,success:!i.issues,output:i.value,issues:i.issues}}var T=C(v({apiEndpoint:S(),fiatApiEndpoint:S(),theme:b([`light`,`dark`,`auto`]),locale:S(),customColors:x(S(),S()),hideTitle:g(),hidePoweredBy:g(),hideProvider:g(),noBackground:g(),noBorder:g(),methods:h(b([`crypto`,`card`])),supportedChainIds:h(_()),rpcOverrides:x(S(),S()),reownProjectId:S()})),E=`https://embed.tokenflight.ai/api/config/defaults.json`,D=5e3,O=null;function k(){return O||(typeof fetch==`function`?(O=(async()=>{let e=new AbortController,t=setTimeout(()=>e.abort(),D);try{let t=await fetch(E,{credentials:`omit`,signal:e.signal});if(!t.ok)return null;let n=w(T,await t.json());return n.success?n.output:null}catch{return null}finally{clearTimeout(t)}})(),O):(O=Promise.resolve(null),O))}export{k as loadDefaults};
@@ -0,0 +1 @@
1
+ var e=e=>`Pay ${e.amount}`,ee=`Waiting for confirmation...`,te=`View on Explorer`,t=`Delivery unsuccessful`,n=`Select Fiat Provider`,r=`Enter amount`,i=e=>`${e.count} more`,a=`Order expired`,o=e=>`Pay ${e.amount} via ${e.provider}`,s=`Copied`,c=`We'll find the best rate for you`,l=e=>`Continue via ${e.provider}`,u=`Try selecting a different chain or search for a specific token`,d=`Coming soon`,f=e=>`via ${e.provider}`,p=`Search results`,m=`Tokens delivered to your wallet`,h=`You pay`,g=`Your tokens have been delivered`,_=e=>`≈ $${e.formatUsd}`,v=`Recipient Address`,y=`Confirm`,b=`Connect your wallet to see payment options`,x=`No tokens found`,S=`Connect wallet or enter an address to get a quote`,C=`Confirm in your wallet...`,w=`Refund tx`,T=e=>`Buy ${e.amt} ${e.sym}`,E=`Exchange`,D=`Swapping via DEX...`,O=`Transaction failed — Retry`,k=`No filler accepted the order`,A=`Back`,ne=`Pay`,j=`Executing...`,M=`Select destination token`,N=e=>`Filled on ${e.chain}`,P=`Payment confirmed`,re=`Buy`,F=`Close`,I=`No offer available`,L=`Refund in progress`,R=e=>`Deposit on ${e.chain}`,z=`Route`,B=`Crypto`,V=`Signed in wallet`,H=`Order failed`,U=`Enter amount to get started`,W=`Recipient`,G=e=>`≈ $${e.addThousandsSeparator}`,K=`Buy with credit or debit card`,q=`View All Chains`,J=`Swap`,Y=`Sender`,X=`Processing your order...`,Z=`Select payment token`,Q=e=>`Via ${e.provider}`,ie=`Quote details`,ae=`Total fee`,oe=`Paid`,se=`Try Again`,ce=`Review Swap`,le=`Provider filling your order`,ue=`Swapping tokens`,$=`Your tokens`,de=e=>`Returning tokens on ${e.chain}`,fe=`Card`,pe=`Swap tokens`,me=`Copy error`,he=`Fiat payment`,ge=`Processing...`,_e=`Purchase failed`,ve=`New Purchase`,ye=`Pay with credit or debit card`,be=`Confirmed on-chain`,xe=`Sign in wallet`,Se=`From`,Ce=`Required to receive your tokens`,we=`MAX`,Te=`Fee`,Ee=`Could not be completed`,De=`Top tokens`,Oe=`Fill tx`,ke=e=>`Delivered in ${e.seconds}s`,Ae=`Pay with`,je=`Swap Successful`,Me=`Tokens delivered`,Ne=`Receive`,Pe=`Min`,Fe=`Search by name or address`,Ie=e=>`~${e.value}s`,Le=`0`,Re=`Provider`,ze=`Est. time`,Be=`Insufficient balance`,Ve=`Invalid address for this chain`,He=`Enter destination address`,Ue=`No tokens available`,We=`Max`,Ge=`Transfer tx`,Ke=`Confirm Swap`,qe=`This token is not directly available for card purchase. We buy USDC first, then swap it to your desired token automatically.`,Je=`Quote Failed`,Ye=e=>`Compare ${e.count} more providers`,Xe=e=>`Buy ${e.arg0} directly`,Ze=e=>`on ${e.chain}`,Qe=e=>`~${e.value}m`,$e=`No routes available`,et=`Tokens Landed!`,tt=`Awaiting payment`,nt=e=>`Routed through ${e.token} for the best rate`,rt=`New Swap`,it=`Enter recipient address`,at=`Wallet doesn't match source chain`,ot=`View`,st=`BEST RATE`,ct=`Your order could not be completed.`,lt=e=>`Delivering ${e.symbol} to your wallet...`,ut=`Your funds have been returned to your wallet.`,dt=`View quote details`,ft=`Signature submitted`,pt=`Deposit tx`,mt=`Connect Wallet`,ht=`Pay with tokens from your wallet`,gt=`You receive`,_t=`Purchase Complete`,vt=`Selected token is unavailable for this purchase`,yt=`Enter Recipient Address`,bt=`Recommended`,xt=`Wallet account`,St=e=>`Balance: ${e.fromBalance}`,Ct=`Purchase complete`,wt=`Retry`,Tt=`Select token`,Et={"10189s3":e,"10ioi7e":ee,"10v0i5g":te,"115lknq":t,"118a77s":n,"119fv83":r,"11k1vkl":i,"12rrl0i":a,"132vna6":o,"13bzcw5":s,"13i9oqu":c,"13l4n4r":l,"13x5i2v":u,"14ho4vt":d,"14j1lze":f,"15bw477":p,"1685rko":m,"17kq51m":h,"17wtaao":g,"188897k":_,"18cmny0":v,"18tbqwf":y,"18y1lrp":b,"19is1h8":x,"19ne1ha":S,"1bze7sg":C,"1c5n7ll":w,"1cei180":T,"1dyojgg":E,"1g8tdk7":D,"1hb73om":O,"1hdpo6q":k,"1hzmxtu":A,"1i7coq1":`Pay`,"1ih47b3":j,"1ix1b7w":M,"1ixbbo7":N,"1jhuo24":P,"1ka8utn":`Buy`,"1l0xxoj":F,"1ne9nkz":I,"1nhkl7x":L,"1nn0owb":R,"1nvxkfy":z,"1o1b4a8":B,"1o4ofyx":V,"1ok4m5g":H,"1olegnl":U,"1oncz6g":W,"1ovj1tk":G,"1q45kup":K,"1qbiehv":q,"1rkfalq":J,"1rnxx1g":Y,"1spu5st":X,"1t0r88u":Z,"1t86tnu":Q,"1tn6f91":ie,"1viukn9":ae,"1w0n607":oe,"1w68n16":se,"1x5xdes":ce,"1y28pgi":le,"1y6hn5o":ue,"1yijk6g":$,"27fhcv":de,"2b8ghr":fe,"2eikro":pe,"2mzna2":me,"2zh3gr":he,"344av8":ge,"3pklqf":_e,"3u5vqs":ve,"6c0jc7":ye,"6c5l2f":be,"6gkge0":xe,"6s9hn9":Se,"7m2ht3":Ce,"7v6g6x":`MAX`,"9l4mg3":`Fee`,"9p7amh":Ee,bdctly:De,bdo3n8:Oe,biwlqk:ke,cgzgvn:Ae,cjn1xs:je,cnwfg3:Me,cwk7r6:Ne,cx9lh3:`Min`,dizog6:Fe,ek03j3:Ie,epw9f3:`0`,evz7q4:Re,f45rwo:ze,fcy4ey:Be,fo0vw0:Ve,fpand1:He,g7pjpv:Ue,gtvgs9:`Max`,hzq69q:Ge,ibrnk6:Ke,ifug2i:qe,jf8ts4:Je,jmpbi6:Ye,jnzipx:Xe,k47stp:Ze,knrcsh:Qe,ln9xiv:$e,mnlddk:et,n9zkql:tt,ofi1rq:nt,pmqvh0:rt,pom1h2:it,q4mqcd:at,q5w460:ot,r7v9s7:st,rvctng:ct,sykid7:lt,t1rvqg:ut,tbygoy:dt,tgp8yw:ft,tjg3i3:pt,u61kge:mt,udneg1:ht,va18uh:gt,vum0cd:_t,wuxjl9:vt,wx5bee:yt,xel5qk:bt,xphk5n:xt,y6jqu9:St,yhtv6l:Ct,zkouah:wt,zz4mrw:Tt};export{Ke as _100907z,gt as _108j3sk,oe as _10lgc56,Y as _10n9ta8,h as _113vzpe,it as _11ncipg,B as _11p3b1r,$e as _12qyh2x,L as _13ym6k2,fe as _14oyo32,De as _15iyda3,S as _15vbpgm,s as _16j2pbi,qe as _16ln1wz,je as _16pzx0g,Ee as _16rump9,M as _17g2rjk,_ as _18346vt,re as _1982g2x,xt as _1biskvr,D as _1bjtgx1,Me as _1cmz8k7,ht as _1cpadi9,G as _1d7sodl,at as _1e023il,u as _1e5aqjt,R as _1ea99j0,te as _1f4czmp,be as _1f8nqa3,ce as _1f8umlr,W as _1fe46d3,Ce as _1fikhaa,rt as _1fu9qvd,E as _1g7ofg0,Ae as _1gfjrn0,ke as _1gma9hv,de as _1hs819x,ft as _1ht75o0,t as _1i8i0au,Ye as _1i9sfkh,F as _1ib6ekl,K as _1ievltk,st as _1in1gel,U as _1in9ocp,He as _1ju6xlj,T as _1jvje3y,Te as _1kd3yrp,A as _1kez60s,ue as _1krtsvx,nt as _1kvlpuf,ye as _1l1rqi2,J as _1l2nmmx,ne as _1lra4kg,dt as _1mmcyfz,vt as _1n1igys,O as _1na1vy4,me as _1nd7gbf,o as _1nwhws6,Ie as _1o0vi1j,Ge as _1o2h7a2,l as _1o8feo7,Ue as _1om32zr,w as _1oqs23j,wt as _1popw3r,ee as _1qamgmj,z as _1rggu8s,Qe as _1s54fdc,c as _1s9ryeq,xe as _1t3gki9,i as _1ulsa90,m as _1urf8wf,n as _1w2bswr,N as _1wwy4yj,e as _1wx2fw2,lt as _1y7hba4,x as _1yv1ajq,yt as _3mtvnb,Re as _3w8t28,Z as _41y3qp,q as _454sub,ot as _49235i,H as _4itr6p,V as _4opuqb,he as _5af8qp,y as _5r87wo,b as _78b61s,Se as _8edkty,Oe as _a5vz6z,Fe as _al7a0k,we as _bii6w9,Le as _cnghfj,j as _czpegb,pt as _d7bf51,Je as _doc1yy,I as _g3pfjv,tt as _gkmqsa,f as _hyiyqa,d as _i9ury1,v as _ide9vv,mt as _ig1w2,St as _jpt8np,ae as _kmeu9o,le as _kqdlbv,bt as _l5s0fl,Xe as _l78r94,$ as _l800fy,g as _ly147p,Ne as _mdvri5,X as _np8jou,a as _nrzzox,Ze as _o3um2w,P as _oj2fr8,_t as _p5ybee,k as _pqml54,_e as _pr6lte,ge as _q0rsrj,ut as _qm85b2,p as _r3yix2,C as _sf0mgy,Tt as _si8n6l,We as _swoaip,Ct as _t0vnn4,Q as _t91lwj,Ve as _ty2nen,ct as _u7tj7p,ze as _uc0jju,r as _uu4paz,et as _vogk37,ie as _wa8i8c,se as _xavgbs,pe as _xkdtbf,ve as _ystooe,Pe as _z6jr7i,Be as _zzusn5,Et as default};
@@ -0,0 +1,3 @@
1
+ import{_ as e,b as t,v as n,x as r,y as i}from"./shared.module-C-kWMzqW.js";function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class extends Error{constructor(e,t,n){let r=`${e.status||e.status===0?e.status:``} ${e.statusText??``}`.trim(),i=r?`status code ${r}`:`an unknown error`;super(`Request failed with ${i}: ${t.method} ${t.url}`),c(this,`response`,void 0),c(this,`request`,void 0),c(this,`options`,void 0),this.name=`HTTPError`,this.response=e,this.request=t,this.options=n}},u=class extends Error{constructor(e){let t=`Non-error value was thrown`;try{typeof e==`string`?t=e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`&&(t=e.message)}catch{}super(t),c(this,`name`,`NonError`),c(this,`value`,void 0),this.value=e}},d=class extends Error{constructor(e){let t=e?.cause?e.cause instanceof Error?e.cause:new u(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:`Forced retry`,t?{cause:t}:void 0),c(this,`name`,`ForceRetryError`),c(this,`customDelay`,void 0),c(this,`code`,void 0),c(this,`customRequest`,void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},f=(()=>{let e=!1,t=!1,n=typeof globalThis.ReadableStream==`function`,r=typeof globalThis.Request==`function`;if(n&&r)try{t=new globalThis.Request(`https://empty.invalid`,{body:new globalThis.ReadableStream,method:`POST`,get duplex(){return e=!0,`half`}}).headers.has(`Content-Type`)}catch(e){if(e instanceof Error&&e.message===`unsupported BodyInit type`)return!1;throw e}return e&&!t})(),p=typeof globalThis.AbortController==`function`,m=typeof globalThis.AbortSignal==`function`&&typeof globalThis.AbortSignal.any==`function`,h=typeof globalThis.ReadableStream==`function`,g=typeof globalThis.FormData==`function`,_=[`get`,`post`,`put`,`patch`,`head`,`delete`],ee={json:`application/json`,text:`text/*`,formData:`multipart/form-data`,arrayBuffer:`*/*`,blob:`*/*`,bytes:`*/*`},v=2147483647,te=new TextEncoder().encode(`------WebKitFormBoundaryaxpyiPgbbPti10Rw`).length,y=Symbol(`stop`),b=class{constructor(e){c(this,`options`,void 0),this.options=e}},ne=e=>new b(e),re={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},ie={next:!0},ae={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},oe=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[n,r]of e)t+=te,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,t+=typeof r==`string`?new TextEncoder().encode(r).length:r.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e==`string`)return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if(`byteLength`in e)return e.byteLength;if(typeof e==`object`&&e)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},x=(e,t,n)=>{let r,i=0;return e.pipeThrough(new TransformStream({transform(e,a){if(a.enqueue(e),r){i+=r.byteLength;let e=t===0?0:i/t;e>=1&&(e=1-2**-52),n?.({percent:e,totalBytes:Math.max(t,i),transferredBytes:i},r)}r=e},flush(){r&&(i+=r.byteLength,n?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},r))}}))},se=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let n=Math.max(0,Number(e.headers.get(`content-length`))||0);return new Response(x(e.body,n,t),{status:e.status,statusText:e.statusText,headers:e.headers})},ce=(e,t,n)=>{if(!e.body)return e;let r=oe(n??e.body);return new Request(e,{duplex:`half`,body:x(e.body,r,t)})},S=e=>typeof e==`object`&&!!e,C=(...e)=>{for(let t of e)if((!S(t)||Array.isArray(t))&&t!==void 0)throw TypeError("The `options` argument must be an object");return D({},...e)},w=(e={},t={})=>{let n=new globalThis.Headers(e),r=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[e,t]of i.entries())r&&t===`undefined`||t===void 0?n.delete(e):n.set(e,t);return n};function T(e,t,n){return Object.hasOwn(t,n)&&t[n]===void 0?[]:D(e[n]??[],t[n]??[])}var E=(e={},t={})=>({beforeRequest:T(e,t,`beforeRequest`),beforeRetry:T(e,t,`beforeRetry`),afterResponse:T(e,t,`afterResponse`),beforeError:T(e,t,`beforeError`)}),le=(e,t)=>{let n=new URLSearchParams;for(let r of[e,t])if(r!==void 0)if(r instanceof URLSearchParams)for(let[e,t]of r.entries())n.append(e,t);else if(Array.isArray(r))for(let e of r){if(!Array.isArray(e)||e.length!==2)throw TypeError(`Array search parameters must be provided in [[key, value], ...] format`);n.append(String(e[0]),String(e[1]))}else if(S(r))for(let[e,t]of Object.entries(r))t!==void 0&&n.append(e,String(t));else{let e=new URLSearchParams(r);for(let[t,r]of e.entries())n.append(t,r)}return n},D=(...e)=>{let t={},n={},r={},i,a=[];for(let o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(S(o)){for(let[e,n]of Object.entries(o)){if(e===`signal`&&n instanceof globalThis.AbortSignal){a.push(n);continue}if(e===`context`){if(n!=null&&(!S(n)||Array.isArray(n)))throw TypeError("The `context` option must be an object");t={...t,context:n==null?{}:{...t.context,...n}};continue}if(e===`searchParams`){i=n==null?void 0:i===void 0?n:le(i,n);continue}S(n)&&e in t&&(n=D(t[e],n)),t={...t,[e]:n}}S(o.hooks)&&(r=E(r,o.hooks),t.hooks=r),S(o.headers)&&(n=w(n,o.headers),t.headers=n)}return i!==void 0&&(t.searchParams=i),a.length>0&&(a.length===1?t.signal=a[0]:m?t.signal=AbortSignal.any(a):t.signal=a.at(-1)),t},ue=e=>_.includes(e)?e.toUpperCase():e,O={limit:2,methods:[`get`,`put`,`head`,`delete`,`options`,`trace`],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:1/0,backoffLimit:1/0,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},de=(e={})=>{if(typeof e==`number`)return{...O,limit:e};if(e.methods&&!Array.isArray(e.methods))throw Error(`retry.methods must be an array`);if(e.methods&&(e.methods=e.methods.map(e=>e.toLowerCase())),e.statusCodes&&!Array.isArray(e.statusCodes))throw Error(`retry.statusCodes must be an array`);let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0));return{...O,...t}},k=class extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`),c(this,`request`,void 0),this.name=`TimeoutError`,this.request=e}};async function fe(e,t,n,r){return new Promise((i,a)=>{let o=setTimeout(()=>{n&&n.abort(),a(new k(e))},r.timeout);r.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function pe(e,{signal:t}){return new Promise((n,r)=>{t&&(t.throwIfAborted(),t.addEventListener(`abort`,i,{once:!0}));function i(){clearTimeout(a),r(t.reason)}let a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e)})}var me=(e,t)=>{let n={};for(let r in t)Object.hasOwn(t,r)&&!(r in ae)&&!(r in re)&&(!(r in e)||r in ie)&&(n[r]=t[r]);return n},he=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e==`object`?Object.keys(e).length>0:typeof e==`string`?e.trim().length>0:!!e;function ge(e){return e instanceof l||e?.name===l.name}function _e(e){return e instanceof k||e?.name===k.name}var A=new WeakMap,j=new WeakMap,M=new WeakMap,N=new WeakMap,P=new WeakMap,F=new WeakMap,I=new WeakMap,L=new WeakSet,R=class a{static create(e,t){let r=new a(e,t),o=i(L,r,U).call(r,async()=>{if(typeof n(N,r).timeout==`number`&&n(N,r).timeout>2147483647)throw RangeError(`The \`timeout\` option cannot be greater than ${v}`);await Promise.resolve();let e=await i(L,r,be).call(r);for(let t of n(N,r).hooks.afterResponse){let a=i(L,r,B).call(r,e.clone()),o;try{o=await t(r.request,i(L,r,W).call(r),a,{retryCount:n(j,r)})}catch(t){throw i(L,r,H).call(r,a),i(L,r,H).call(r,e),t}if(o instanceof b)throw i(L,r,H).call(r,a),i(L,r,H).call(r,e),new d(o.options);let s=o instanceof globalThis.Response?o:e;a!==s&&i(L,r,H).call(r,a),e!==s&&i(L,r,H).call(r,e),e=s}if(i(L,r,B).call(r,e),!e.ok&&(typeof n(N,r).throwHttpErrors==`function`?n(N,r).throwHttpErrors(e.status):n(N,r).throwHttpErrors)){let t=new l(e,r.request,i(L,r,W).call(r));for(let e of n(N,r).hooks.beforeError)t=await e(t,{retryCount:n(j,r)});throw t}if(n(N,r).onDownloadProgress){if(typeof n(N,r).onDownloadProgress!=`function`)throw TypeError("The `onDownloadProgress` option must be a function");if(!h)throw Error("Streams are not supported in your environment. `ReadableStream` is missing.");let t=e.clone();return i(L,r,H).call(r,e),se(t,n(N,r).onDownloadProgress)}return e}).finally(()=>{let e=n(P,r);i(L,r,V).call(r,e?.body??void 0),i(L,r,V).call(r,r.request.body??void 0)});for(let[e,n]of Object.entries(ee))e===`bytes`&&typeof globalThis.Response?.prototype?.bytes!=`function`||(o[e]=async()=>{r.request.headers.set(`accept`,r.request.headers.get(`accept`)||n);let i=await o;if(e===`json`){if(i.status===204)return``;let e=await i.text();return e===``?``:t.parseJson?t.parseJson(e):JSON.parse(e)}return i[e]()});return o}constructor(o,s={}){if(r(this,L),c(this,`request`,void 0),t(this,A,void 0),t(this,j,0),t(this,M,void 0),t(this,N,void 0),t(this,P,void 0),t(this,F,void 0),t(this,I,void 0),e(M,this,o),e(N,this,{...s,headers:w(n(M,this).headers,s.headers),hooks:E({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:ue(s.method??n(M,this).method??`GET`),prefixUrl:String(s.prefixUrl||``),retry:de(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}}),typeof n(M,this)!=`string`&&!(n(M,this)instanceof URL||n(M,this)instanceof globalThis.Request))throw TypeError("`input` must be a string, URL, or Request");if(n(N,this).prefixUrl&&typeof n(M,this)==`string`){if(n(M,this).startsWith(`/`))throw Error("`input` must not begin with a slash when using `prefixUrl`");n(N,this).prefixUrl.endsWith(`/`)||(n(N,this).prefixUrl+=`/`),e(M,this,n(N,this).prefixUrl+n(M,this))}p&&m&&(e(F,this,n(N,this).signal??n(M,this).signal),e(A,this,new globalThis.AbortController),n(N,this).signal=n(F,this)?AbortSignal.any([n(F,this),n(A,this).signal]):n(A,this).signal),f&&(n(N,this).duplex=`half`),n(N,this).json!==void 0&&(n(N,this).body=n(N,this).stringifyJson?.(n(N,this).json)??JSON.stringify(n(N,this).json),n(N,this).headers.set(`content-type`,n(N,this).headers.get(`content-type`)??`application/json`));let l=s.headers&&new globalThis.Headers(s.headers).has(`content-type`);if(n(M,this)instanceof globalThis.Request&&(g&&n(N,this).body instanceof globalThis.FormData||n(N,this).body instanceof URLSearchParams)&&!l&&n(N,this).headers.delete(`content-type`),this.request=new globalThis.Request(n(M,this),n(N,this)),he(n(N,this).searchParams)){let e=`?`+(typeof n(N,this).searchParams==`string`?n(N,this).searchParams.replace(/^\?/,``):new URLSearchParams(ve.call(a,n(N,this).searchParams)).toString()),t=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,e);this.request=new globalThis.Request(t,n(N,this))}if(n(N,this).onUploadProgress){if(typeof n(N,this).onUploadProgress!=`function`)throw TypeError("The `onUploadProgress` option must be a function");if(!f)throw Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=i(L,this,K).call(this,this.request,n(N,this).body??void 0)}}};function ve(e){return e&&typeof e==`object`&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)):e}function z(){let e=n(N,this).retry.delay(n(j,this)),t=e;n(N,this).retry.jitter===!0?t=Math.random()*e:typeof n(N,this).retry.jitter==`function`&&(t=n(N,this).retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e));let r=n(N,this).retry.backoffLimit??1/0;return Math.min(r,t)}async function ye(t){var r;if(e(j,this,(r=n(j,this),r++,r)),n(j,this)>n(N,this).retry.limit)throw t;let a=t instanceof Error?t:new u(t);if(a instanceof d)return a.customDelay??i(L,this,z).call(this);if(!n(N,this).retry.methods.includes(this.request.method.toLowerCase()))throw t;if(n(N,this).retry.shouldRetry!==void 0){let e=await n(N,this).retry.shouldRetry({error:a,retryCount:n(j,this)});if(e===!1)throw t;if(e===!0)return i(L,this,z).call(this)}if(_e(t)&&!n(N,this).retry.retryOnTimeout)throw t;if(ge(t)){if(!n(N,this).retry.statusCodes.includes(t.response.status))throw t;let e=t.response.headers.get(`Retry-After`)??t.response.headers.get(`RateLimit-Reset`)??t.response.headers.get(`X-RateLimit-Retry-After`)??t.response.headers.get(`X-RateLimit-Reset`)??t.response.headers.get(`X-Rate-Limit-Reset`);if(e&&n(N,this).retry.afterStatusCodes.includes(t.response.status)){let t=Number(e)*1e3;Number.isNaN(t)?t=Date.parse(e)-Date.now():t>=Date.parse(`2024-01-01`)&&(t-=Date.now());let r=n(N,this).retry.maxRetryAfter??t;return t<r?t:r}if(t.response.status===413)throw t}return i(L,this,z).call(this)}function B(e){return n(N,this).parseJson&&(e.json=async()=>n(N,this).parseJson(await e.text())),e}function V(e){e&&e.cancel().catch(()=>void 0)}function H(e){i(L,this,V).call(this,e.body??void 0)}async function U(e){try{return await e()}catch(t){let r=Math.min(await i(L,this,ye).call(this,t),v);if(n(j,this)<1)throw t;if(await pe(r,n(F,this)?{signal:n(F,this)}:{}),t instanceof d&&t.customRequest){let e=n(N,this).signal?new globalThis.Request(t.customRequest,{signal:n(N,this).signal}):new globalThis.Request(t.customRequest);i(L,this,G).call(this,e)}for(let e of n(N,this).hooks.beforeRetry){let r=await e({request:this.request,options:i(L,this,W).call(this),error:t,retryCount:n(j,this)});if(r instanceof globalThis.Request){i(L,this,G).call(this,r);break}if(r instanceof globalThis.Response)return r;if(r===y)return}return i(L,this,U).call(this,e)}}async function be(){n(A,this)?.signal.aborted&&(e(A,this,new globalThis.AbortController),n(N,this).signal=n(F,this)?AbortSignal.any([n(F,this),n(A,this).signal]):n(A,this).signal,this.request=new globalThis.Request(this.request,{signal:n(N,this).signal}));for(let e of n(N,this).hooks.beforeRequest){let t=await e(this.request,i(L,this,W).call(this),{retryCount:n(j,this)});if(t instanceof Response)return t;if(t instanceof globalThis.Request){i(L,this,G).call(this,t);break}}let t=me(this.request,n(N,this));return e(P,this,this.request),this.request=n(P,this).clone(),n(N,this).timeout===!1?n(N,this).fetch(n(P,this),t):fe(n(P,this),t,n(A,this),n(N,this))}function W(){if(!n(I,this)){let{hooks:t,...r}=n(N,this);e(I,this,Object.freeze(r))}return n(I,this)}function G(t){e(I,this,void 0),this.request=i(L,this,K).call(this,t)}function K(e,t){return!n(N,this).onUploadProgress||!e.body?e:ce(e,n(N,this).onUploadProgress,t??n(N,this).body??void 0)}var q=e=>{let t=(t,n)=>R.create(t,C(e,n));for(let n of _)t[n]=(t,r)=>R.create(t,C(e,r,{method:n}));return t.create=e=>q(C(e)),t.extend=t=>(typeof t==`function`&&(t=t(e??{})),q(C(e,t))),t.stop=y,t.retry=ne,t},xe=q(),J={API_REQUEST_FAILED:`TF3001`,API_TIMEOUT:`TF3002`,API_INVALID_RESPONSE:`TF3003`,QUOTE_FAILED:`TF3004`,QUOTE_EXPIRED:`TF3005`,DEPOSIT_BUILD_FAILED:`TF3006`,DEPOSIT_SUBMIT_FAILED:`TF3007`,ORDER_FAILED:`TF3008`,API_ABORTED:`TF3009`,FIAT_QUOTE_FAILED:`TF6001`,FIAT_ORDER_FAILED:`TF6002`,FIAT_STATUS_FAILED:`TF6003`,FIAT_PROVIDER_ERROR:`TF6004`,FIAT_AMOUNT_OUT_OF_RANGE:`TF6005`,FIAT_POPUP_BLOCKED:`TF6006`,FIAT_CHECKOUT_UNAVAILABLE:`TF6007`},Y={[J.API_REQUEST_FAILED]:`API request failed`,[J.API_TIMEOUT]:`API request timed out`,[J.API_INVALID_RESPONSE]:`Invalid API response`,[J.QUOTE_FAILED]:`Failed to get quote`,[J.QUOTE_EXPIRED]:`Quote has expired`,[J.DEPOSIT_BUILD_FAILED]:`Failed to build deposit transaction`,[J.DEPOSIT_SUBMIT_FAILED]:`Failed to submit deposit`,[J.ORDER_FAILED]:`Order processing failed`,[J.API_ABORTED]:`Request was aborted`,[J.FIAT_QUOTE_FAILED]:`Failed to get fiat quote`,[J.FIAT_ORDER_FAILED]:`Failed to create fiat order`,[J.FIAT_STATUS_FAILED]:`Failed to get fiat order status`,[J.FIAT_PROVIDER_ERROR]:`Fiat provider error`,[J.FIAT_AMOUNT_OUT_OF_RANGE]:`Fiat amount is out of range`,[J.FIAT_POPUP_BLOCKED]:`Payment popup was blocked by the browser`,[J.FIAT_CHECKOUT_UNAVAILABLE]:`Fiat checkout requires a browser window`},X=class extends Error{constructor(e,t,n){let r=typeof t==`string`?t:t instanceof Error||typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:Y[e]??`Unknown error`;super(r),this.name=`TokenFlightError`,this.code=e,this.details=n}},Se=class extends X{constructor(e,t){super(J.API_TIMEOUT,e,t),this.name=`ApiTimeoutError`}},Z=class extends X{constructor(e,t){super(J.API_ABORTED,e,t),this.name=`ApiAbortedError`}},Q=class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`ApiValidationError`}},Ce={ValidationException:Q,ZodValidationException:Q,BadRequestException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`BadRequestError`}},QuoteNotFoundException:class extends X{constructor(e,t){super(J.QUOTE_FAILED,e,t),this.name=`QuoteNotFoundError`}},QuoteExpiredException:class extends X{constructor(e,t){super(J.QUOTE_EXPIRED,e,t),this.name=`QuoteExpiredError`}},CannotFillException:class extends X{constructor(e,t){super(J.QUOTE_FAILED,e,t),this.name=`CannotFillError`}},NotSupportedTokenException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`NotSupportedTokenError`}},NotSupportedChainException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`NotSupportedChainError`}},NotSupportedDepositMethodException:class extends X{constructor(e,t){super(J.DEPOSIT_BUILD_FAILED,e,t),this.name=`NotSupportedDepositMethodError`}},UnexpectedFromAddressException:class extends X{constructor(e,t){super(J.DEPOSIT_BUILD_FAILED,e,t),this.name=`UnexpectedFromAddressError`}},IntentNotFoundException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`IntentNotFoundError`}},DuplicateRecordException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`DuplicateRecordError`}},BroadcastException:class extends X{constructor(e,t){super(J.DEPOSIT_SUBMIT_FAILED,e,t),this.name=`BroadcastError`}},InternalErrorException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`InternalServerError`}}};function we(e,t,n){if(typeof e==`object`&&e){let r=e,i=typeof r.name==`string`?r.name:null,a=typeof r.message==`string`?r.message:t;if(i&&Ce[i]){let t=Ce[i];return new t(a,n??e)}return new X(J.API_REQUEST_FAILED,a,n??e)}return new X(J.API_REQUEST_FAILED,t,n)}function Te(e){return xe.create({prefixUrl:e.baseUrl,timeout:e.timeout??15e3,retry:0,...e.fetch?{fetch:e.fetch}:{},headers:{"X-TF-SDK-Version":De(),...e.headers}})}function Ee(e){return e.replace(/\/$/,``)}function De(){return`0.3.0-rc.1`}async function Oe(e,t){try{return await e}catch(e){if(e instanceof X)throw e;if(e instanceof k)throw new Se(t.timeoutMessage,e);if(e instanceof DOMException&&e.name===`AbortError`)throw new Z(`Request was aborted`,e);if(e instanceof l){let n=``;try{n=await e.response.json()}catch{n=await e.response.text().catch(()=>``)}let r=`${t.failureMessage}: ${e.response.status} ${e.response.statusText}`;throw we(n,r,{status:e.response.status,body:n})}throw new X(J.API_REQUEST_FAILED,`${t.failureMessage}: ${String(e)}`,e)}}async function*ke(e){if(!e.ok){let t=``;try{t=await e.json()}catch{t=await e.text().catch(()=>``)}throw we(t,`API request failed: ${e.status} ${e.statusText}`,{status:e.status,body:t})}if(!e.body)throw new X(J.API_INVALID_RESPONSE,`Streaming response has no body`);let t=e.body.getReader(),n=new TextDecoder(`utf-8`),r=``;try{for(;;){let{value:e,done:i}=await t.read();e&&(r+=n.decode(e,{stream:!0}));let a=r.indexOf(`
2
+ `);for(;a!==-1;){let e=r.slice(0,a).trim();r=r.slice(a+1),e&&(yield Ae(e)),a=r.indexOf(`
3
+ `)}if(i){let e=r.trim();e&&(yield Ae(e));return}}}finally{t.releaseLock()}}function Ae(e){try{return JSON.parse(e)}catch(t){throw new X(J.API_INVALID_RESPONSE,`Failed to parse NDJSON frame: ${String(t)}`,{line:e})}}var je=`https://api.hyperstream.dev`,Me=2e3,Ne=500,Pe=5e3,Fe=class{constructor(e){this.baseUrl=Ee(e.baseUrl),this.ky=Te({baseUrl:this.baseUrl,timeout:e.timeout,fetch:e.fetch,headers:e.headers}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.extraHeaders=e.headers??{}}request(e){return Oe(e,{timeoutMessage:`API request timed out`,failureMessage:`API request failed`})}getQuotes(e,t){return this.request(this.ky.post(`v1/quotes`,{json:e,signal:t?.signal}).json())}async*streamQuotes(e,t){yield*ke(await this.fetchImpl(`${this.baseUrl}/v1/quotes?mode=stream`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-TF-SDK-Version":De(),...this.extraHeaders},body:JSON.stringify(e),signal:t?.signal}))}buildDeposit(e,t){return this.request(this.ky.post(`v1/deposit/build`,{json:e,signal:t?.signal}).json())}submitDeposit(e,t){return this.request(this.ky.put(`v1/deposit/submit`,{json:e,signal:t?.signal}).json())}getOrdersByAddress(e,t){let n={};return t?.orderIds?.length&&(n.orderIds=t.orderIds.join(`,`)),t?.limit&&(n.limit=t.limit.toString()),t?.cursor&&(n.cursor=t.cursor.toString()),this.request(this.ky.get(`v1/orders/${e}`,{searchParams:n,signal:t?.signal}).json())}async getOrderById(e,t,n){return(await this.getOrdersByAddress(e,{orderIds:[t],signal:n?.signal})).data[0]??null}getOrder(e,t){return this.request(this.ky.get(`v1/orders/by-id/${e}`,{signal:t?.signal}).json())}trackOrder(e,t={}){let n=Math.max(Ne,t.intervalMs??Me);return new Promise((r,i)=>{let a=!1,o=null,s=()=>{o&&(clearTimeout(o),o=null),t.signal&&t.signal.removeEventListener(`abort`,c)},c=()=>{a||(a=!0,s(),i(new Z(`Order tracking was aborted`)))};if(t.signal){if(t.signal.aborted){c();return}t.signal.addEventListener(`abort`,c)}let l=async()=>{if(!a)try{let i=await this.getOrder(e,{signal:t.signal});if(a)return;if(t.onStatus?.(i),Ie.includes(i.status)){a=!0,s(),r(i);return}o=setTimeout(l,n)}catch(e){if(a)return;if(e instanceof Z){a=!0,s(),i(e);return}o=setTimeout(l,Pe)}};l()})}getTokens(e){let t={};return e?.q&&(t.q=e.q),e?.chainIds?.length&&(t.chainIds=e.chainIds.join(`,`)),e?.limit&&(t.limit=e.limit.toString()),e?.cursor&&(t.cursor=e.cursor.toString()),this.request(this.ky.get(`v1/tokens`,{searchParams:t,signal:e?.signal}).json())}searchTokens(e,t){let n={q:e};return t?.chainIds?.length&&(n.chainIds=t.chainIds.join(`,`)),this.request(this.ky.get(`v1/tokens/search`,{searchParams:n,signal:t?.signal}).json())}getTopTokens(e){let t={};return e?.chainIds?.length&&(t.chainIds=e.chainIds.join(`,`)),this.request(this.ky.get(`v1/tokens/top`,{searchParams:t,signal:e?.signal}).json())}getTokenBalances(e,t){let n={};return t?.chainIds?.length&&(n.chainIds=t.chainIds.join(`,`)),this.request(this.ky.get(`v1/tokens/balances/${e}`,{searchParams:n,signal:t?.signal}).json())}getTokenAutocomplete(e,t){let n={};return t?.chainIds?.length&&(n.chainIds=t.chainIds.join(`,`)),t?.limit&&(n.limit=t.limit.toString()),this.request(this.ky.get(`v1/tokens/autocomplete/${encodeURIComponent(e)}`,{searchParams:n,signal:t?.signal}).json())}getTokenAutocompleteSuggestions(e){return this.request(this.ky.get(`v1/tokens/autocomplete/suggestions`,{signal:e?.signal}).json())}getChains(e){return this.request(this.ky.get(`v1/chains`,{signal:e?.signal}).json())}getArcadiaConfig(e){return this.request(this.ky.get(`v1/config/arcadia`,{signal:e?.signal}).json())}getVaults(e){return this.request(this.ky.get(`v1/vaults`,{signal:e?.signal}).json())}getMTokens(e){return this.request(this.ky.get(`v1/mtokens`,{signal:e?.signal}).json())}getIntent(e,t){return this.request(this.ky.get(`v1/intent/${e}`,{signal:t?.signal}).json())}getIntentByDeposit(e,t){return this.request(this.ky.get(`v1/intent/deposit`,{searchParams:{chainId:e.chainId.toString(),txHash:e.txHash},signal:t?.signal}).json())}getIntentsByAuthor(e,t){let n={};return t?.limit&&(n.limit=t.limit.toString()),t?.cursor&&(n.cursor=t.cursor.toString()),t?.fromChainId&&(n.fromChainId=t.fromChainId.toString()),t?.toChainId&&(n.toChainId=t.toChainId.toString()),this.request(this.ky.get(`v1/intents/${e}`,{searchParams:n,signal:t?.signal}).json())}},Ie=[`filled`,`refunded`,`failed`],Le=500,Re=700,ze=2e3,Be=500,Ve=5e3;function He(e,t){let n=typeof window.outerWidth==`number`?window.outerWidth:0,r=typeof window.outerHeight==`number`?window.outerHeight:0,i=typeof window.screenX==`number`?window.screenX:0,a=typeof window.screenY==`number`?window.screenY:0,o=n>0?n:screen.width,s=r>0?r:screen.height,c=n>0?i:0,l=r>0?a:0;return`width=${e},height=${t},left=${Math.max(0,Math.round(c+(o-e)/2))},top=${Math.max(0,Math.round(l+(s-t)/2))}`}function Ue(e){return e===`completed`?`completed`:e===`canceled`?`canceled`:`failed`}function We(e,t,n={}){if(typeof window>`u`)return Promise.reject(new X(J.FIAT_CHECKOUT_UNAVAILABLE,`Fiat checkout requires a browser window`));let r=n.popup?.width??Le,i=n.popup?.height??Re,a=n.minPollIntervalMs??ze,o=window.open(t.wrapperUrl,`tf-fiat-${t.orderId}`,He(r,i));if(!o||o.closed)return Promise.reject(new X(J.FIAT_POPUP_BLOCKED,`Payment popup was blocked by the browser`));let s;try{s=new URL(e.baseUrl).origin}catch{return o.close(),Promise.reject(new X(J.FIAT_CHECKOUT_UNAVAILABLE,`Fiat API base URL is malformed`))}return new Promise((r,i)=>{let c=!1,l=!1,u=null,d=null,f=()=>{window.removeEventListener(`message`,m),u&&(clearTimeout(u),u=null),d&&(clearInterval(d),d=null),n.signal&&n.signal.removeEventListener(`abort`,h)},p=async n=>{if(!c){c=!0,f();try{let i=await e.getStatus(t.orderId);o.closed||o.close(),r({orderId:t.orderId,finalStatus:i,outcome:n})}catch(e){o.closed||o.close(),i(e)}}},m=e=>{if(e.origin!==s)return;let r=e.data;if(!(!r||typeof r!=`object`||r.type!==`FIAT_WIDGET_EVENT`)&&!(r.orderId&&r.orderId!==t.orderId))switch(n.onEvent?.(r),r.event){case`widget_ready`:l=!0;break;case`order_completed`:p(`completed`);break;case`order_failed`:l&&p(`failed`);break;case`widget_close`:break}},h=()=>{o.closed||o.close(),p(`canceled`)};if(window.addEventListener(`message`,m),n.signal){if(n.signal.aborted){h();return}n.signal.addEventListener(`abort`,h)}d=setInterval(()=>{o.closed&&!c&&p(`canceled`)},Be);let g=async()=>{if(!c)try{let r=await e.getStatus(t.orderId);if(c)return;if(n.onStatus?.(r),r.polling.isTerminal){p(Ue(r.status));return}let i=Math.max(a,r.polling.suggestedIntervalMs);u=setTimeout(g,i)}catch{c||(u=setTimeout(g,Ve))}};g()})}var Ge=`https://fiat.hyperstream.dev`,Ke=class{constructor(e){this.baseUrl=Ee(e.baseUrl),this.ky=Te({baseUrl:this.baseUrl,timeout:e.timeout,fetch:e.fetch,headers:e.headers})}request(e){return Oe(e,{timeoutMessage:`Fiat API request timed out`,failureMessage:`Fiat API request failed`})}getProviders(e){return this.request(this.ky.get(`v1/fiat/providers`,{signal:e?.signal}).json())}getQuote(e,t){return this.request(this.ky.post(`v1/fiat/quote`,{json:e,signal:t?.signal}).json())}createOrder(e,t){return this.request(this.ky.post(`v1/fiat/order`,{json:e,signal:t?.signal}).json())}getStatus(e,t){let n=t?.force?{force:`1`}:void 0;return this.request(this.ky.get(`v1/fiat/status/${e}`,{signal:t?.signal,searchParams:n}).json())}startCheckout(e,t){return We(this,e,t)}getOrdersByAddress(e,t){let n={};return t?.status&&(n.status=t.status),t?.limit&&(n.limit=t.limit.toString()),t?.cursor&&(n.cursor=t.cursor.toString()),this.request(this.ky.get(`v1/fiat/orders/${e}`,{searchParams:n,signal:t?.signal}).json())}};function qe(e,t){if(e)return`${e.replace(/\/$/,``)}/v1/chain/${t}/icon`}var Je=new Set([`completed`,`failed`,`canceled`]),$={...J,INVALID_CONFIG:`TF1001`,INVALID_TOKEN_IDENTIFIER:`TF1002`,INVALID_AMOUNT:`TF1003`,WALLET_CONNECTION_FAILED:`TF2002`,WALLET_ACTION_FAILED:`TF2003`,TRANSACTION_FAILED:`TF4001`,ELEMENT_NOT_FOUND:`TF5001`},Ye={[$.INVALID_CONFIG]:`Invalid configuration provided`,[$.INVALID_TOKEN_IDENTIFIER]:`Invalid token identifier format`,[$.INVALID_AMOUNT]:`Invalid amount value`,[$.WALLET_CONNECTION_FAILED]:`Failed to connect wallet`,[$.WALLET_ACTION_FAILED]:`Wallet action failed`,[$.TRANSACTION_FAILED]:`Transaction failed`,[$.ELEMENT_NOT_FOUND]:`Target DOM element not found`};({...Y,...Ye});export{Ie as a,X as c,Fe as i,je as l,qe as n,Ge as o,Je as r,Ke as s,$ as t,c as u};
@@ -0,0 +1,21 @@
1
+ import { QueryClient } from '@tanstack/solid-query';
2
+
3
+ /**
4
+ * Mount the iframe receiver app into a target element. Establishes a
5
+ * postMessage bridge with the host page, applies theme/customColors to
6
+ * `<html>`, and renders `<WidgetComponent>` bound to the bridge wallet
7
+ * adapter.
8
+ *
9
+ * Returns a cleanup function that disposes the Solid root and tears down
10
+ * the receiver.
11
+ */
12
+ export declare function mountIframeReceiver(options?: MountIframeReceiverOptions): () => void;
13
+
14
+ export declare interface MountIframeReceiverOptions {
15
+ /** Mount target — CSS selector or HTMLElement. Default: `#root`. */
16
+ target?: HTMLElement | string;
17
+ /** Optional QueryClient override (uses the package singleton if omitted). */
18
+ queryClient?: QueryClient;
19
+ }
20
+
21
+ export { }
@@ -0,0 +1,29 @@
1
+ import{S as e,m as t,o as n,p as r,u as i,v as a}from"./solid-iWr5Czxc.js";import{h as o,l as s,n as c,r as l,u}from"./shared.module-C-kWMzqW.js";import{i as d,o as f,r as p,t as m}from"./theme-C9tsVWlo.js";import{n as h,t as g}from"./widget-BadYytj9.js";import{n as _,r as v,t as y}from"./iframe-receiver-PfhKUIZW.js";function b(e=document){return e.querySelector(`[data-widget-root="stable"]`)??e.querySelector(`[part="container"]`)}function x(e,t=document){let n=()=>{let n=b(t);return n?(e.observeResize(n),!0):!1};if(n())return;let r=new MutationObserver(()=>{n()&&r.disconnect()});r.observe(document.body,{childList:!0,subtree:!0})}var S=o(`<div style="position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:9999;padding:6px 12px;border-radius:999px;background:color-mix(in srgb, var(--tf-primary) 15%, transparent);color:var(--tf-primary);border:1px solid color-mix(in srgb, var(--tf-primary) 35%, transparent);font-family:'DM Sans', sans-serif;font-size:11px;font-weight:600;letter-spacing:0.03em;user-select:none;pointer-events:none">Standalone preview · embed via &lt;tokenflight-iframe-widget&gt;`),C=o(`<div style="color:#95a8c4;font-family:'DM Sans', sans-serif;font-size:13px;text-align:center;padding-top:60px">Waiting for host bridge…`);function w(e={}){if(typeof window>`u`)return()=>{};E(),D();let t=T(e.target);if(!t)return()=>{};let n=e.queryClient??c,r=u(()=>i(P,{queryClient:n}),t);return()=>r()}function T(e){return typeof e==`string`?document.querySelector(e):e||document.getElementById(`root`)}function E(){if(!g||document.querySelector(`style[data-tokenflight-widget]`))return;let e=document.createElement(`style`);e.setAttribute(`data-tokenflight-widget`,``),e.textContent=g,document.head.appendChild(e)}function D(){if(document.querySelector(`style[data-tokenflight-flat]`))return;let e=document.createElement(`style`);e.setAttribute(`data-tokenflight-flat`,``),e.textContent=`
2
+ html, body {
3
+ margin: 0;
4
+ padding: 0;
5
+ background: transparent;
6
+ }
7
+ [part="container"] {
8
+ width: 100% !important;
9
+ max-width: none !important;
10
+ min-width: 0 !important;
11
+ border: none !important;
12
+ border-radius: 0 !important;
13
+ box-shadow: none !important;
14
+ background: transparent !important;
15
+ }
16
+ `,document.head.appendChild(e)}function O(){if(document.querySelector(`style[data-tokenflight-standalone-fill]`))return;let e=document.createElement(`style`);e.setAttribute(`data-tokenflight-standalone-fill`,``),e.textContent=`
17
+ html, body {
18
+ width: 100%;
19
+ height: 100%;
20
+ overflow: hidden;
21
+ }
22
+ #root {
23
+ width: 100%;
24
+ height: 100%;
25
+ }
26
+ [part="container"] {
27
+ height: 100dvh !important;
28
+ }
29
+ `,document.head.appendChild(e)}function k(e){x(e)}function A(){let e={};if(typeof location>`u`)return e;let t=new URLSearchParams(location.search),n=e=>t.get(e)??void 0;n(`api-endpoint`)&&(e.apiEndpoint=n(`api-endpoint`)),n(`fiat-api-endpoint`)&&(e.fiatApiEndpoint=n(`fiat-api-endpoint`));let r=n(`theme`);(r===`dark`||r===`light`||r===`auto`)&&(e.theme=r),n(`locale`)&&(e.locale=n(`locale`)),n(`from-token`)&&(e.fromToken=n(`from-token`)),n(`to-token`)&&(e.toToken=n(`to-token`));let i=n(`trade-type`);(i===`EXACT_INPUT`||i===`EXACT_OUTPUT`)&&(e.tradeType=i);let a=n(`quote-card`);(a===`hidden`||a===`visible`)&&(e.quoteCard=a),n(`amount`)&&(e.amount=n(`amount`)),n(`recipient`)&&(e.recipient=n(`recipient`));let o=n(`methods`);return o&&(e.methods=o.split(`,`).map(e=>e.trim())),n(`title-text`)&&(e.titleText=n(`title-text`)),t.has(`hide-title`)&&(e.hideTitle=!0),t.has(`hide-powered-by`)&&(e.hidePoweredBy=!0),e}function j(){return S()}function M(e){if(!e)return;let t=document.documentElement;for(let[n,r]of Object.entries(e))n.startsWith(`--`)&&t.style.setProperty(n,r)}function N(e){let t=document.documentElement;for(let[n,r]of Object.entries(e))t.style.setProperty(n,r)}function P(o){let[c,u]=a(null),[g,b]=a(null),[x,S]=a(!1),w=t(()=>{let e=g();if(e)return{onSwapSuccess:t=>e.emitEvent(`swapComplete`,t),onDepositSuccess:t=>e.emitEvent(`swapComplete`,t),onSwapError:t=>e.emitEvent(`error`,t),onDepositError:t=>e.emitEvent(`error`,t),onFiatOrderCreated:t=>e.emitEvent(`fiatOrderCreated`,t),onFiatOrderCompleted:t=>e.emitEvent(`fiatOrderCompleted`,t)}});queueMicrotask(()=>{if(!v()){O(),S(!0),u(A());return}let e=_();if(!e)return;let t=new y(e,{onInit:(e,t)=>{u(e),M(t?.vars)},onConfigUpdate:e=>{u({...c()??{},...e})},onStyleUpdate:e=>{M(e.vars)}});b(t),k(t)}),e(()=>g()?.destroy());let T=null;r(()=>{let e=c();if(!e)return;let t=e.theme??`light`;N(d(t)),e.customColors&&m(document.documentElement,e.customColors),document.body.className=t===`dark`?`dark`:`light`,T?.(),T=null,t===`auto`&&(T=f(t=>{N(t),e.customColors&&m(document.documentElement,e.customColors),document.body.className=t===p?`dark`:`light`}))}),e(()=>T?.());let E=t(()=>c()||null);return i(l,{get client(){return o.queryClient},get children(){return[s(()=>s(()=>!!x())()?i(j,{}):null),i(n,{get when(){return E()},get fallback(){return C()},children:e=>i(h,{get config(){return e()},get walletAdapter(){return g()?.walletAdapter},get callbacks(){return w()}})})]}})}export{w as mountIframeReceiver};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i}from"./protocol-CDxgudrl.js";import{n as a}from"./active-bridge-V8lTJ2Js.js";var o=12e4,s=6e4,c=class{constructor(t){this.name=`IframeBridge`,this.supportedActionTypes=[`eip1193_request`,`solana_signTransaction`,`solana_signAndSendTransaction`],this.connected=!1,this.address=null,this.lastWalletSeq=0,this.eventListeners=new Map,this.pendingRequests=new Map,this.pendingConnect=null,this.pendingDisconnect=null,this.destroyed=!1,this.handleMessage=t=>{if(this.destroyed||t.origin!==this.hostOrigin)return;let n=r(t.data);n&&(e(n,`tf:walletState`)?this.handleWalletState(n.payload,n.seq):e(n,`tf:signResult`)&&this.handleSignResult(n.payload.requestId,n.payload.result,n.payload.error))},this.hostOrigin=t,window.addEventListener(`message`,this.handleMessage)}async connect(e){return this.postToHost(n(`connectWallet`,{chainType:e})),new Promise((e,t)=>{this.pendingConnect={resolve:e,reject:t},setTimeout(()=>{this.pendingConnect&&(this.pendingConnect.reject(Error(`Wallet connection timed out`)),this.pendingConnect=null)},s)})}async disconnect(){return this.postToHost(n(`disconnectWallet`,{})),new Promise((e,t)=>{this.pendingDisconnect={resolve:e,reject:t},setTimeout(()=>{this.pendingDisconnect&&(this.pendingDisconnect.reject(Error(`Wallet disconnect timed out`)),this.pendingDisconnect=null)},s)})}isConnected(e){return this.connected}async getAddress(e){return this.address}async executeWalletAction(e){let t=i();return new Promise((r,i)=>{let a=setTimeout(()=>{this.pendingRequests.delete(t),i(Error(`Wallet action timed out`))},o);this.pendingRequests.set(t,{resolve:r,reject:i,timer:a}),this.postToHost(n(`signRequest`,{requestId:t,action:e}))})}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n)),n.add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}destroy(){if(!this.destroyed){this.destroyed=!0,window.removeEventListener(`message`,this.handleMessage);for(let[,e]of this.pendingRequests)clearTimeout(e.timer),e.reject(Error(`Bridge destroyed`));this.pendingRequests.clear(),this.pendingConnect&&(this.pendingConnect.reject(Error(`Bridge destroyed`)),this.pendingConnect=null),this.pendingDisconnect&&(this.pendingDisconnect.reject(Error(`Bridge destroyed`)),this.pendingDisconnect=null),this.eventListeners.clear()}}setInitialState(e,t,n){this.connected=e,this.address=t,this.chainType=n}handleWalletState(e,t){if(t<=this.lastWalletSeq)return;this.lastWalletSeq=t;let n=this.connected;this.connected=e.connected,this.address=e.address,e.chainType&&(this.chainType=e.chainType),e.connected&&this.pendingConnect&&(this.pendingConnect.resolve(),this.pendingConnect=null),!e.connected&&this.pendingDisconnect&&(this.pendingDisconnect.resolve(),this.pendingDisconnect=null),e.event?this.emit(e.event,{type:e.event,data:e}):e.connected&&!n?this.emit(`connect`,{type:`connect`,data:e}):!e.connected&&n?this.emit(`disconnect`,{type:`disconnect`,data:e}):e.connected&&this.emit(`accountsChanged`,{type:`accountsChanged`,data:e})}handleSignResult(e,n,r){let i=this.pendingRequests.get(e);i&&(this.pendingRequests.delete(e),clearTimeout(i.timer),r?i.reject(t(r)):n?i.resolve(n):i.reject(Error(`Invalid sign result: missing both result and error`)))}postToHost(e){this.destroyed||typeof window>`u`||!window.parent||window.parent.postMessage(e,this.hostOrigin)}emit(e,t){let n=this.eventListeners.get(e);if(n)for(let e of n)try{e(t)}catch{}}},l=`__TF_VERSION__`,u=class{constructor(t,i){this.destroyed=!1,this.resizeObserver=null,this.lastReportedHeight=0,this.popupClosedHandlers=new Set,this.providerEventHandlers=new Set,this.handleMessage=t=>{if(this.destroyed||t.origin!==this.hostOrigin)return;let n=r(t.data);if(n){if(e(n,`tf:init`))this.handleInit(n.payload);else if(e(n,`tf:setConfig`))this.callbacks.onConfigUpdate(n.payload);else if(e(n,`tf:setStyle`))this.callbacks.onStyleUpdate(n.payload);else if(e(n,`tf:fiatPopupClosed`)){let e=n.payload.orderId;this.callbacks.onFiatPopupClosed?.(e);for(let t of this.popupClosedHandlers)t(e)}else if(e(n,`tf:fiatProviderEvent`)){let e=n.payload;this.callbacks.onFiatProviderEvent?.(e);for(let t of this.providerEventHandlers)t(e)}}},this.hostOrigin=t,this.callbacks=i,this.walletAdapter=new c(t),window.addEventListener(`message`,this.handleMessage),a(this.getFiatBridge()),this.postToHost(n(`ready`,{version:l,protocolVersion:1}))}getFiatBridge(){return{requestPreOpenPopup:()=>this.requestPreOpenPopup(),requestNavigatePopup:(e,t)=>this.requestNavigatePopup(e,t),onPopupClosed:e=>(this.popupClosedHandlers.add(e),()=>this.popupClosedHandlers.delete(e)),onProviderEvent:e=>(this.providerEventHandlers.add(e),()=>this.providerEventHandlers.delete(e))}}observeResize(e){this.resizeObserver=new ResizeObserver(e=>{let t=e[0];if(!t)return;let r=Math.ceil(t.borderBoxSize?.[0]?.blockSize??t.contentRect.height);Math.abs(r-this.lastReportedHeight)<2||(this.lastReportedHeight=r,this.postToHost(n(`resize`,{height:r})))}),this.resizeObserver.observe(e)}emitEvent(e,t){this.postToHost(n(`event`,{name:e,data:t}))}requestPreOpenPopup(){this.postToHost(n(`preOpenPopup`,{}))}requestNavigatePopup(e,t){this.postToHost(n(`navigatePopup`,{url:e,orderId:t}))}destroy(){this.destroyed||(this.destroyed=!0,window.removeEventListener(`message`,this.handleMessage),this.walletAdapter.destroy(),this.popupClosedHandlers.clear(),this.providerEventHandlers.clear(),a(null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null))}handleInit(e){this.walletAdapter.setInitialState(e.connected??!1,e.walletAddress??null,e.chainType),this.callbacks.onInit(e.config,e.style)}postToHost(e){this.destroyed||window.parent.postMessage(e,this.hostOrigin)}};function d(){try{return window!==window.top}catch{return!0}}function f(){if(!d())return null;try{if(document.referrer)return new URL(document.referrer).origin}catch{}return null}export{c as i,f as n,d as r,u as t};