@orbs-network/spot-react 0.0.65 → 0.0.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-
|
|
1
|
+
import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-kry-P1XK.js";
|
|
2
2
|
class S extends p {
|
|
3
3
|
constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
|
|
4
4
|
var o;
|
|
@@ -2937,7 +2937,7 @@ const Zw = async ({
|
|
|
2937
2937
|
}) => (await Promise.all([
|
|
2938
2938
|
s ? Zw({ chainId: r, signal: e, page: t, limit: n, filters: { accounts: [a], configs: s.twapConfig ? [s.twapConfig] : [] } }) : Promise.resolve([]),
|
|
2939
2939
|
$w({ chainId: r, signal: e, account: a, exchange: s == null ? void 0 : s.adapter })
|
|
2940
|
-
]).then(([c, l]) => [...c, ...l])).sort((c, l) => l.createdAt - c.createdAt), e3 = "0.0.
|
|
2940
|
+
]).then(([c, l]) => [...c, ...l])).sort((c, l) => l.createdAt - c.createdAt), e3 = "0.0.68", t3 = {
|
|
2941
2941
|
version: e3
|
|
2942
2942
|
};
|
|
2943
2943
|
var yo = class {
|
|
@@ -11591,7 +11591,7 @@ async function yu(e, t) {
|
|
|
11591
11591
|
});
|
|
11592
11592
|
return ie === "0x" ? { data: void 0 } : { data: ie };
|
|
11593
11593
|
} catch (U) {
|
|
11594
|
-
const F = c7(U), { offchainLookup: R, offchainLookupSignature: L } = await import("./ccip-
|
|
11594
|
+
const F = c7(U), { offchainLookup: R, offchainLookupSignature: L } = await import("./ccip-BVuhVMsW.js");
|
|
11595
11595
|
if (e.ccipRead !== !1 && (F == null ? void 0 : F.slice(0, 10)) === L && C)
|
|
11596
11596
|
return { data: await R(e, { data: F, to: C }) };
|
|
11597
11597
|
throw S && (F == null ? void 0 : F.slice(0, 10)) === "0x101bb98d" ? new RE({ factory: f }) : c0(U, {
|
|
@@ -43644,7 +43644,7 @@ const cK = () => {
|
|
|
43644
43644
|
const { dstToken: e, marketPrice: t, module: r, callbacks: n } = oe(), s = ee((y) => y.updateState), a = pK(), o = ee((y) => y.state.triggerPricePercent), i = o === void 0 ? a : o, c = r === xe.STOP_LOSS || r === xe.TAKE_PROFIT, l = Nx({
|
|
43645
43645
|
typedValue: ee((y) => y.state.typedTriggerPrice),
|
|
43646
43646
|
percentage: i,
|
|
43647
|
-
tokenDecimals: e == null ? void 0 : e.decimals,
|
|
43647
|
+
tokenDecimals: (e == null ? void 0 : e.decimals) || 18,
|
|
43648
43648
|
initialPrice: c ? t : void 0,
|
|
43649
43649
|
setValue: $e((y) => {
|
|
43650
43650
|
var g;
|
|
@@ -43719,7 +43719,7 @@ const cK = () => {
|
|
|
43719
43719
|
const { dstToken: e, marketPrice: t, callbacks: r } = oe(), n = ee((l) => l.updateState), s = Pm(), a = ee((l) => l.state.limitPricePercent), o = a === void 0 ? s : a, i = Nx({
|
|
43720
43720
|
typedValue: ee((l) => l.state.typedLimitPrice),
|
|
43721
43721
|
percentage: o,
|
|
43722
|
-
tokenDecimals: e == null ? void 0 : e.decimals,
|
|
43722
|
+
tokenDecimals: (e == null ? void 0 : e.decimals) || 18,
|
|
43723
43723
|
initialPrice: t,
|
|
43724
43724
|
setValue: $e((l) => {
|
|
43725
43725
|
var u;
|
package/dist/spot-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aS as e, C as r, a6 as t, D as i, aC as n, aQ as E, aO as o, aR as _, aP as T, aM as P, aG as u, aj as A, aE as l, aD as I, ai as R, an as O, aB as S, at as d, ar as g, as as L, av as D, au as M, M as C, aJ as m, aK as U, aI as b, aH as p, aL as N, O as c, K as F, P as k, J as y, aN as B, ak as G, aF as h, aq as x, S as f, G as Y, I as H, aw as W, al as v, am as w, a7 as K, be as V, ah as z, R as Q, Z as X, a3 as j, T as q, W as J, ag as Z, ap as $, aX as aa, ba as sa, aZ as ea, aT as ra, aU as ta, aW as ia, bd as na, a_ as Ea, a5 as oa, b9 as _a, b0 as Ta, b5 as Pa, aY as ua, bc as Aa, b7 as la, Y as Ia, b6 as Ra, b8 as Oa, a9 as Sa, ac as da, aa as ga, ad as La, a0 as Da, ab as Ma, aA as Ca, bb as ma, a$ as Ua, b3 as ba, b1 as pa, b4 as Na, b2 as ca, aV as Fa, ae as ka, a4 as ya, X as Ba, U as Ga, az as ha, _ as xa, $ as fa, ay as Ya, af as Ha, V as Wa, L as va, ao as wa, a8 as Ka, a2 as Va, a1 as za, bf as Qa, Q as Xa, N as ja, y as qa, q as Ja, m as Za, h as $a, j as as, F as ss, t as es, r as rs, k as ts, A as is, o as ns, E as Es, x as os, z as _s, p as Ts, v as Ps, u as us, w as As, n as ls, ax as Is } from "./index-
|
|
1
|
+
import { aS as e, C as r, a6 as t, D as i, aC as n, aQ as E, aO as o, aR as _, aP as T, aM as P, aG as u, aj as A, aE as l, aD as I, ai as R, an as O, aB as S, at as d, ar as g, as as L, av as D, au as M, M as C, aJ as m, aK as U, aI as b, aH as p, aL as N, O as c, K as F, P as k, J as y, aN as B, ak as G, aF as h, aq as x, S as f, G as Y, I as H, aw as W, al as v, am as w, a7 as K, be as V, ah as z, R as Q, Z as X, a3 as j, T as q, W as J, ag as Z, ap as $, aX as aa, ba as sa, aZ as ea, aT as ra, aU as ta, aW as ia, bd as na, a_ as Ea, a5 as oa, b9 as _a, b0 as Ta, b5 as Pa, aY as ua, bc as Aa, b7 as la, Y as Ia, b6 as Ra, b8 as Oa, a9 as Sa, ac as da, aa as ga, ad as La, a0 as Da, ab as Ma, aA as Ca, bb as ma, a$ as Ua, b3 as ba, b1 as pa, b4 as Na, b2 as ca, aV as Fa, ae as ka, a4 as ya, X as Ba, U as Ga, az as ha, _ as xa, $ as fa, ay as Ya, af as Ha, V as Wa, L as va, ao as wa, a8 as Ka, a2 as Va, a1 as za, bf as Qa, Q as Xa, N as ja, y as qa, q as Ja, m as Za, h as $a, j as as, F as ss, t as es, r as rs, k as ts, A as is, o as ns, E as Es, x as os, z as _s, p as Ts, v as Ps, u as us, w as As, n as ls, ax as Is } from "./index-kry-P1XK.js";
|
|
2
2
|
export {
|
|
3
3
|
e as CRASH_ERROR_MESSAGE,
|
|
4
4
|
r as Components,
|
package/dist/spot-react.umd.cjs
CHANGED
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
dollarValueOut
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`,extractResults:d=>{var f;return(((f=d.data)==null?void 0:f.orderFilleds)||[]).map(h=>({...h,timestamp:new Date(h.timestamp).getTime()}))}})};class Tw extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const Aw=async({chainId:e,signal:t,page:r,limit:n,filters:s})=>{try{const a=await Ew({chainId:e,signal:t,page:r,limit:n,filters:s}),[o,i]=await Promise.all([Cw({chainId:e,orders:a,signal:t}),kw({chainId:e,orders:a,signal:t})]);return a.map(l=>{const u=o==null?void 0:o.filter(d=>d.TWAP_id===Number(l.Contract_id)&&Ps(d.exchange,l.exchange)&&Ps(d.twapAddress,l.twapAddress));return ww(l,e,u,Sw(l,u||[],i))}).sort((l,u)=>u.createdAt-l.createdAt)}catch{return[]}},Sw=(e,t,r)=>{var i;const n=(i=r==null?void 0:r.find(c=>c.twapId===e.Contract_id.toString()&&Ps(c.twapAddress,e.twapAddress)))==null?void 0:i.status,a=Um(t).reduce((c,l)=>c.plus(l.inAmount),new j(0)).toFixed(),o=Dm(e.ask_srcAmount,a);return Pw(o,e.ask_deadline*1e3,n)},Dm=(e,t)=>{if(!t||!e)return 0;const r=j(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Pw=(e,t,r)=>e===100?ct.Completed:r==="CANCELED"?ct.Canceled:r==="COMPLETED"?ct.Completed:t>Date.now()?ct.Open:ct.Expired,_m=async({signal:e,page:t,chainId:r,limit:n,config:s,account:a})=>(await Promise.all([s?Aw({chainId:r,signal:e,page:t,limit:n,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),gw({chainId:r,signal:e,account:a,exchange:s==null?void 0:s.adapter})]).then(([c,l])=>[...c,...l])).sort((c,l)=>l.createdAt-c.createdAt),Iw={version:"0.0.65"};var Aa=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Bw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fw=(g5=class{constructor(){le(this,pn,Bw);le(this,pa,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,pa)&&e!==N(this,pn)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,pn),provider:e}),J(this,pn,e),process.env.NODE_ENV!=="production"&&J(this,pa,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&J(this,pa,!0),N(this,pn).setTimeout(e,t)}clearTimeout(e){N(this,pn).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&J(this,pa,!0),N(this,pn).setInterval(e,t)}clearInterval(e){N(this,pn).clearInterval(e)}},pn=new WeakMap,pa=new WeakMap,g5),Fs=new Fw;function Uw(e){setTimeout(e,0)}var Us=typeof window>"u"||"Deno"in globalThis;function jt(){}function Ow(e,t){return typeof e=="function"?e(t):e}function md(e){return typeof e=="number"&&e>=0&&e!==1/0}function Mm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Zn(e,t){return typeof e=="function"?e(t):e}function wr(e,t){return typeof e=="function"?e(t):e}function Nm(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:o,stale:i}=e;if(o){if(n){if(t.queryHash!==bd(o,t.options))return!1}else if(!Oo(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||s&&s!==t.state.fetchStatus||a&&!a(t))}function Lm(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(Os(t.options.mutationKey)!==Os(a))return!1}else if(!Oo(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function bd(e,t){return((t==null?void 0:t.queryKeyHashFn)||Os)(e)}function Os(e){return JSON.stringify(e,(t,r)=>gd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Oo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Oo(e[r],t[r])):!1}var Dw=Object.prototype.hasOwnProperty;function yd(e,t){if(e===t)return e;const r=zm(e)&&zm(t);if(!r&&!(gd(e)&&gd(t)))return t;const s=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,i=r?new Array(o):{};let c=0;for(let l=0;l<o;l++){const u=r?l:a[l],d=e[u],f=t[u];if(d===f){i[u]=d,(r?l<s:Dw.call(e,u))&&c++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){i[u]=f;continue}const h=yd(d,f);i[u]=h,h===d&&c++}return s===o&&c===s?e:i}function Uc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function zm(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function gd(e){if(!Rm(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Rm(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Rm(e){return Object.prototype.toString.call(e)==="[object Object]"}function _w(e){return new Promise(t=>{Fs.setTimeout(t,e)})}function xd(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return yd(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`),n}return yd(e,t)}return t}function Mw(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Nw(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var Oc=Symbol();function Hm(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Oc&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Oc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function $m(e,t){return typeof e=="function"?e(...t):!!e}var Lw=(x5=class extends Aa{constructor(){super();le(this,fa);le(this,ys);le(this,xo);J(this,xo,t=>{if(!Us&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){N(this,ys)||this.setEventListener(N(this,xo))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,ys))==null||t.call(this),J(this,ys,void 0))}setEventListener(t){var r;J(this,xo,t),(r=N(this,ys))==null||r.call(this),J(this,ys,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){N(this,fa)!==t&&(J(this,fa,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof N(this,fa)=="boolean"?N(this,fa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},fa=new WeakMap,ys=new WeakMap,xo=new WeakMap,x5),wd=new Lw;function vd(){let e,t;const r=new Promise((s,a)=>{e=s,t=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),e(s)},r.reject=s=>{n({status:"rejected",reason:s}),t(s)},r}var zw=Uw;function Rw(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=zw;const a=i=>{t?e.push(i):s(()=>{r(i)})},o=()=>{const i=e;e=[],i.length&&s(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;t++;try{c=i()}finally{t--,t||o()}return c},batchCalls:i=>(...c)=>{a(()=>{i(...c)})},schedule:a,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{s=i}}}var kt=Rw(),Hw=(w5=class extends Aa{constructor(){super();le(this,wo,!0);le(this,gs);le(this,vo);J(this,vo,t=>{if(!Us&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){N(this,gs)||this.setEventListener(N(this,vo))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,gs))==null||t.call(this),J(this,gs,void 0))}setEventListener(t){var r;J(this,vo,t),(r=N(this,gs))==null||r.call(this),J(this,gs,t(this.setOnline.bind(this)))}setOnline(t){N(this,wo)!==t&&(J(this,wo,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return N(this,wo)}},wo=new WeakMap,gs=new WeakMap,vo=new WeakMap,w5),Dc=new Hw;function $w(e){return Math.min(1e3*2**e,3e4)}function Gm(e){return(e??"online")==="online"?Dc.isOnline():!0}var Ed=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function jm(e){let t=!1,r=0,n;const s=vd(),a=()=>s.status!=="pending",o=g=>{var E;if(!a()){const v=new Ed(g);f(v),(E=e.onCancel)==null||E.call(e,v)}},i=()=>{t=!0},c=()=>{t=!1},l=()=>wd.isFocused()&&(e.networkMode==="always"||Dc.isOnline())&&e.canRun(),u=()=>Gm(e.networkMode)&&e.canRun(),d=g=>{a()||(n==null||n(),s.resolve(g))},f=g=>{a()||(n==null||n(),s.reject(g))},h=()=>new Promise(g=>{var E;n=v=>{(a()||l())&&g(v)},(E=e.onPause)==null||E.call(e)}).then(()=>{var g;n=void 0,a()||(g=e.onContinue)==null||g.call(e)}),y=()=>{if(a())return;let g;const E=r===0?e.initialPromise:void 0;try{g=E??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(d).catch(v=>{var z;if(a())return;const w=e.retry??(Us?0:3),A=e.retryDelay??$w,C=typeof A=="function"?A(r,v):A,D=w===!0||typeof w=="number"&&r<w||typeof w=="function"&&w(r,v);if(t||!D){f(v);return}r++,(z=e.onFail)==null||z.call(e,r,v),_w(C).then(()=>l()?void 0:h()).then(()=>{t?f(v):y()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:i,continueRetry:c,canStart:u,start:()=>(u()?y():h().then(y),s)}}var Vm=(v5=class{constructor(){le(this,ha)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),md(this.gcTime)&&J(this,ha,Fs.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Us?1/0:300*1e3))}clearGcTimeout(){N(this,ha)&&(Fs.clearTimeout(N(this,ha)),J(this,ha,void 0))}},ha=new WeakMap,v5),Gw=(E5=class extends Vm{constructor(t){super();le(this,Kr);le(this,ma);le(this,Eo);le(this,Ir);le(this,ba);le(this,Bt);le(this,vc);le(this,ya);J(this,ya,!1),J(this,vc,t.defaultOptions),this.setOptions(t.options),this.observers=[],J(this,ba,t.client),J(this,Ir,N(this,ba).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,J(this,ma,Km(this.options)),this.state=t.state??N(this,ma),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=N(this,Bt))==null?void 0:t.promise}setOptions(t){if(this.options={...N(this,vc),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Km(this.options);r.data!==void 0&&(this.setState(qm(r.data,r.dataUpdatedAt)),J(this,ma,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,Ir).remove(this)}setData(t,r){const n=xd(this.state.data,t,this.options);return Se(this,Kr,qn).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){Se(this,Kr,qn).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n,s;const r=(n=N(this,Bt))==null?void 0:n.promise;return(s=N(this,Bt))==null||s.cancel(t),r?r.then(jt).catch(jt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(N(this,ma))}isActive(){return this.observers.some(t=>wr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Zn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Mm(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),N(this,Ir).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(N(this,Bt)&&(N(this,ya)?N(this,Bt).cancel({revert:!0}):N(this,Bt).cancelRetry()),this.scheduleGc()),N(this,Ir).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Se(this,Kr,qn).call(this,{type:"invalidate"})}async fetch(t,r){var c,l,u,d,f,h,y,g,E,v,w,A;if(this.state.fetchStatus!=="idle"&&((c=N(this,Bt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(N(this,Bt))return N(this,Bt).continueRetry(),N(this,Bt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const C=this.observers.find(D=>D.options.queryFn);C&&this.setOptions(C.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,s=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(J(this,ya,!0),n.signal)})},a=()=>{const C=Hm(this.options,r),z=(()=>{const T={client:N(this,ba),queryKey:this.queryKey,meta:this.meta};return s(T),T})();return J(this,ya,!1),this.options.persister?this.options.persister(C,z,this):C(z)},i=(()=>{const C={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:N(this,ba),state:this.state,fetchFn:a};return s(C),C})();(l=this.options.behavior)==null||l.onFetch(i,this),J(this,Eo,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&Se(this,Kr,qn).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta}),J(this,Bt,jm({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:C=>{C instanceof Ed&&C.revert&&this.setState({...N(this,Eo),fetchStatus:"idle"}),n.abort()},onFail:(C,D)=>{Se(this,Kr,qn).call(this,{type:"failed",failureCount:C,error:D})},onPause:()=>{Se(this,Kr,qn).call(this,{type:"pause"})},onContinue:()=>{Se(this,Kr,qn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const C=await N(this,Bt).start();if(C===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(C),(h=(f=N(this,Ir).config).onSuccess)==null||h.call(f,C,this),(g=(y=N(this,Ir).config).onSettled)==null||g.call(y,C,this.state.error,this),C}catch(C){if(C instanceof Ed){if(C.silent)return N(this,Bt).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Se(this,Kr,qn).call(this,{type:"error",error:C}),(v=(E=N(this,Ir).config).onError)==null||v.call(E,C,this),(A=(w=N(this,Ir).config).onSettled)==null||A.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},ma=new WeakMap,Eo=new WeakMap,Ir=new WeakMap,ba=new WeakMap,Bt=new WeakMap,vc=new WeakMap,ya=new WeakMap,Kr=new WeakSet,qn=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Wm(n.data,this.options),fetchMeta:t.meta??null};case"success":const s={...n,...qm(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return J(this,Eo,t.manual?s:void 0),s;case"error":const a=t.error;return{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),kt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),N(this,Ir).notify({query:this,type:"updated",action:t})})},E5);function Wm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qm(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Km(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var jw=(k5=class extends Aa{constructor(t,r){super();le(this,Ve);le(this,sr);le(this,Oe);le(this,Ec);le(this,qt);le(this,ga);le(this,ko);le(this,$n);le(this,xs);le(this,kc);le(this,Co);le(this,To);le(this,xa);le(this,wa);le(this,ws);le(this,Ao,new Set);this.options=r,J(this,sr,t),J(this,xs,null),J(this,$n,vd()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,Oe).addObserver(this),Ym(N(this,Oe),this.options)?Se(this,Ve,Ac).call(this):this.updateResult(),Se(this,Ve,Ih).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kd(N(this,Oe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kd(N(this,Oe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,Ve,Bh).call(this),Se(this,Ve,Fh).call(this),N(this,Oe).removeObserver(this)}setOptions(t){const r=this.options,n=N(this,Oe);if(this.options=N(this,sr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof wr(this.options.enabled,N(this,Oe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Se(this,Ve,Uh).call(this),N(this,Oe).setOptions(this.options),r._defaulted&&!Uc(this.options,r)&&N(this,sr).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,Oe),observer:this});const s=this.hasListeners();s&&Zm(N(this,Oe),n,this.options,r)&&Se(this,Ve,Ac).call(this),this.updateResult(),s&&(N(this,Oe)!==n||wr(this.options.enabled,N(this,Oe))!==wr(r.enabled,N(this,Oe))||Zn(this.options.staleTime,N(this,Oe))!==Zn(r.staleTime,N(this,Oe)))&&Se(this,Ve,Ah).call(this);const a=Se(this,Ve,Sh).call(this);s&&(N(this,Oe)!==n||wr(this.options.enabled,N(this,Oe))!==wr(r.enabled,N(this,Oe))||a!==N(this,ws))&&Se(this,Ve,Ph).call(this,a)}getOptimisticResult(t){const r=N(this,sr).getQueryCache().build(N(this,sr),t),n=this.createResult(r,t);return Ww(this,n)&&(J(this,qt,n),J(this,ko,this.options),J(this,ga,N(this,Oe).state)),n}getCurrentResult(){return N(this,qt)}trackResult(t,r){return new Proxy(t,{get:(n,s)=>(this.trackProp(s),r==null||r(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&N(this,$n).status==="pending"&&N(this,$n).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,s))})}trackProp(t){N(this,Ao).add(t)}getCurrentQuery(){return N(this,Oe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=N(this,sr).defaultQueryOptions(t),n=N(this,sr).getQueryCache().build(N(this,sr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Se(this,Ve,Ac).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,qt)))}createResult(t,r){var b;const n=N(this,Oe),s=this.options,a=N(this,qt),o=N(this,ga),i=N(this,ko),l=t!==n?t.state:N(this,Ec),{state:u}=t;let d={...u},f=!1,h;if(r._optimisticResults){const x=this.hasListeners(),S=!x&&Ym(t,r),I=x&&Zm(t,n,r,s);(S||I)&&(d={...d,...Wm(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:y,errorUpdatedAt:g,status:E}=d;h=d.data;let v=!1;if(r.placeholderData!==void 0&&h===void 0&&E==="pending"){let x;a!=null&&a.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(x=a.data,v=!0):x=typeof r.placeholderData=="function"?r.placeholderData((b=N(this,To))==null?void 0:b.state.data,N(this,To)):r.placeholderData,x!==void 0&&(E="success",h=xd(a==null?void 0:a.data,x,r),f=!0)}if(r.select&&h!==void 0&&!v)if(a&&h===(o==null?void 0:o.data)&&r.select===N(this,kc))h=N(this,Co);else try{J(this,kc,r.select),h=r.select(h),h=xd(a==null?void 0:a.data,h,r),J(this,Co,h),J(this,xs,null)}catch(x){J(this,xs,x)}N(this,xs)&&(y=N(this,xs),h=N(this,Co),g=Date.now(),E="error");const w=d.fetchStatus==="fetching",A=E==="pending",C=E==="error",D=A&&w,z=h!==void 0,m={status:E,fetchStatus:d.fetchStatus,isPending:A,isSuccess:E==="success",isError:C,isInitialLoading:D,isLoading:D,data:h,dataUpdatedAt:d.dataUpdatedAt,error:y,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:w,isRefetching:w&&!A,isLoadingError:C&&!z,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:C&&z,isStale:Cd(t,r),refetch:this.refetch,promise:N(this,$n),isEnabled:wr(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const x=F=>{m.status==="error"?F.reject(m.error):m.data!==void 0&&F.resolve(m.data)},S=()=>{const F=J(this,$n,m.promise=vd());x(F)},I=N(this,$n);switch(I.status){case"pending":t.queryHash===n.queryHash&&x(I);break;case"fulfilled":(m.status==="error"||m.data!==I.value)&&S();break;case"rejected":(m.status!=="error"||m.error!==I.reason)&&S();break}}return m}updateResult(){const t=N(this,qt),r=this.createResult(N(this,Oe),this.options);if(J(this,ga,N(this,Oe).state),J(this,ko,this.options),N(this,ga).data!==void 0&&J(this,To,N(this,Oe)),Uc(r,t))return;J(this,qt,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!N(this,Ao).size)return!0;const o=new Set(a??N(this,Ao));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,qt)).some(i=>{const c=i;return N(this,qt)[c]!==t[c]&&o.has(c)})};Se(this,Ve,M5).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,Ve,Ih).call(this)}},sr=new WeakMap,Oe=new WeakMap,Ec=new WeakMap,qt=new WeakMap,ga=new WeakMap,ko=new WeakMap,$n=new WeakMap,xs=new WeakMap,kc=new WeakMap,Co=new WeakMap,To=new WeakMap,xa=new WeakMap,wa=new WeakMap,ws=new WeakMap,Ao=new WeakMap,Ve=new WeakSet,Ac=function(t){Se(this,Ve,Uh).call(this);let r=N(this,Oe).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(jt)),r},Ah=function(){Se(this,Ve,Bh).call(this);const t=Zn(this.options.staleTime,N(this,Oe));if(Us||N(this,qt).isStale||!md(t))return;const n=Mm(N(this,qt).dataUpdatedAt,t)+1;J(this,xa,Fs.setTimeout(()=>{N(this,qt).isStale||this.updateResult()},n))},Sh=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,Oe)):this.options.refetchInterval)??!1},Ph=function(t){Se(this,Ve,Fh).call(this),J(this,ws,t),!(Us||wr(this.options.enabled,N(this,Oe))===!1||!md(N(this,ws))||N(this,ws)===0)&&J(this,wa,Fs.setInterval(()=>{(this.options.refetchIntervalInBackground||wd.isFocused())&&Se(this,Ve,Ac).call(this)},N(this,ws)))},Ih=function(){Se(this,Ve,Ah).call(this),Se(this,Ve,Ph).call(this,Se(this,Ve,Sh).call(this))},Bh=function(){N(this,xa)&&(Fs.clearTimeout(N(this,xa)),J(this,xa,void 0))},Fh=function(){N(this,wa)&&(Fs.clearInterval(N(this,wa)),J(this,wa,void 0))},Uh=function(){const t=N(this,sr).getQueryCache().build(N(this,sr),this.options);if(t===N(this,Oe))return;const r=N(this,Oe);J(this,Oe,t),J(this,Ec,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},M5=function(t){kt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(N(this,qt))}),N(this,sr).getQueryCache().notify({query:N(this,Oe),type:"observerResultsUpdated"})})},k5);function Vw(e,t){return wr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ym(e,t){return Vw(e,t)||e.state.data!==void 0&&kd(e,t,t.refetchOnMount)}function kd(e,t,r){if(wr(t.enabled,e)!==!1&&Zn(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Cd(e,t)}return!1}function Zm(e,t,r,n){return(e!==t||wr(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Cd(e,r)}function Cd(e,t){return wr(t.enabled,e)!==!1&&e.isStaleByTime(Zn(t.staleTime,e))}function Ww(e,t){return!Uc(e.getCurrentResult(),t)}function Xm(e){return{onFetch:(t,r)=>{var u,d,f,h,y;const n=t.options,s=(f=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,a=((h=t.state.data)==null?void 0:h.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const l=async()=>{let g=!1;const E=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=Hm(t.options,t.fetchOptions),w=async(A,C,D)=>{if(g)return Promise.reject();if(C==null&&A.pages.length)return Promise.resolve(A);const T=(()=>{const S={client:t.client,queryKey:t.queryKey,pageParam:C,direction:D?"backward":"forward",meta:t.options.meta};return E(S),S})(),m=await v(T),{maxPages:b}=t.options,x=D?Nw:Mw;return{pages:x(A.pages,m,b),pageParams:x(A.pageParams,C,b)}};if(s&&a.length){const A=s==="backward",C=A?qw:Qm,D={pages:a,pageParams:o},z=C(n,D);i=await w(D,z,A)}else{const A=e??a.length;do{const C=c===0?o[0]??n.initialPageParam:Qm(n,i);if(c>0&&C==null)break;i=await w(i,C),c++}while(c<A)}return i};t.options.persister?t.fetchFn=()=>{var g,E;return(E=(g=t.options).persister)==null?void 0:E.call(g,l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=l}}}function Qm(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function qw(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Kw=(C5=class extends Vm{constructor(t){super();le(this,hn);le(this,Cc);le(this,fn);le(this,Kt);le(this,va);J(this,Cc,t.client),this.mutationId=t.mutationId,J(this,Kt,t.mutationCache),J(this,fn,[]),this.state=t.state||Jm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){N(this,fn).includes(t)||(N(this,fn).push(t),this.clearGcTimeout(),N(this,Kt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){J(this,fn,N(this,fn).filter(r=>r!==t)),this.scheduleGc(),N(this,Kt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,fn).length||(this.state.status==="pending"?this.scheduleGc():N(this,Kt).remove(this))}continue(){var t;return((t=N(this,va))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,c,l,u,d,f,h,y,g,E,v,w,A,C,D,z,T,m,b;const r=()=>{Se(this,hn,Ts).call(this,{type:"continue"})},n={client:N(this,Cc),meta:this.options.meta,mutationKey:this.options.mutationKey};J(this,va,jm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(x,S)=>{Se(this,hn,Ts).call(this,{type:"failed",failureCount:x,error:S})},onPause:()=>{Se(this,hn,Ts).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,Kt).canRun(this)}));const s=this.state.status==="pending",a=!N(this,va).canStart();try{if(s)r();else{Se(this,hn,Ts).call(this,{type:"pending",variables:t,isPaused:a}),await((i=(o=N(this,Kt).config).onMutate)==null?void 0:i.call(o,t,this,n));const S=await((l=(c=this.options).onMutate)==null?void 0:l.call(c,t,n));S!==this.state.context&&Se(this,hn,Ts).call(this,{type:"pending",context:S,variables:t,isPaused:a})}const x=await N(this,va).start();return await((d=(u=N(this,Kt).config).onSuccess)==null?void 0:d.call(u,x,t,this.state.context,this,n)),await((h=(f=this.options).onSuccess)==null?void 0:h.call(f,x,t,this.state.context,n)),await((g=(y=N(this,Kt).config).onSettled)==null?void 0:g.call(y,x,null,this.state.variables,this.state.context,this,n)),await((v=(E=this.options).onSettled)==null?void 0:v.call(E,x,null,t,this.state.context,n)),Se(this,hn,Ts).call(this,{type:"success",data:x}),x}catch(x){try{throw await((A=(w=N(this,Kt).config).onError)==null?void 0:A.call(w,x,t,this.state.context,this,n)),await((D=(C=this.options).onError)==null?void 0:D.call(C,x,t,this.state.context,n)),await((T=(z=N(this,Kt).config).onSettled)==null?void 0:T.call(z,void 0,x,this.state.variables,this.state.context,this,n)),await((b=(m=this.options).onSettled)==null?void 0:b.call(m,void 0,x,t,this.state.context,n)),x}finally{Se(this,hn,Ts).call(this,{type:"error",error:x})}}finally{N(this,Kt).runNext(this)}}},Cc=new WeakMap,fn=new WeakMap,Kt=new WeakMap,va=new WeakMap,hn=new WeakSet,Ts=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),kt.batch(()=>{N(this,fn).forEach(n=>{n.onMutationUpdate(t)}),N(this,Kt).notify({mutation:this,type:"updated",action:t})})},C5);function Jm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yw=(T5=class extends Aa{constructor(t={}){super();le(this,Gn);le(this,Yr);le(this,Tc);this.config=t,J(this,Gn,new Set),J(this,Yr,new Map),J(this,Tc,0)}build(t,r,n){const s=new Kw({client:t,mutationCache:this,mutationId:++Yu(this,Tc)._,options:t.defaultMutationOptions(r),state:n});return this.add(s),s}add(t){N(this,Gn).add(t);const r=_c(t);if(typeof r=="string"){const n=N(this,Yr).get(r);n?n.push(t):N(this,Yr).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,Gn).delete(t)){const r=_c(t);if(typeof r=="string"){const n=N(this,Yr).get(r);if(n)if(n.length>1){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}else n[0]===t&&N(this,Yr).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=_c(t);if(typeof r=="string"){const n=N(this,Yr).get(r),s=n==null?void 0:n.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var n;const r=_c(t);if(typeof r=="string"){const s=(n=N(this,Yr).get(r))==null?void 0:n.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){kt.batch(()=>{N(this,Gn).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,Gn).clear(),N(this,Yr).clear()})}getAll(){return Array.from(N(this,Gn))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Lm(r,n))}findAll(t={}){return this.getAll().filter(r=>Lm(t,r))}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return kt.batch(()=>Promise.all(t.map(r=>r.continue().catch(jt))))}},Gn=new WeakMap,Yr=new WeakMap,Tc=new WeakMap,T5);function _c(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Zw=(A5=class extends Aa{constructor(t,r){super();le(this,Wn);le(this,jn);le(this,vs);le(this,ar);le(this,Vn);J(this,jn,t),this.setOptions(r),this.bindMethods(),Se(this,Wn,Zu).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=N(this,jn).defaultMutationOptions(t),Uc(this.options,r)||N(this,jn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,ar),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Os(r.mutationKey)!==Os(this.options.mutationKey)?this.reset():((n=N(this,ar))==null?void 0:n.state.status)==="pending"&&N(this,ar).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,ar))==null||t.removeObserver(this)}onMutationUpdate(t){Se(this,Wn,Zu).call(this),Se(this,Wn,Oh).call(this,t)}getCurrentResult(){return N(this,vs)}reset(){var t;(t=N(this,ar))==null||t.removeObserver(this),J(this,ar,void 0),Se(this,Wn,Zu).call(this),Se(this,Wn,Oh).call(this)}mutate(t,r){var n;return J(this,Vn,r),(n=N(this,ar))==null||n.removeObserver(this),J(this,ar,N(this,jn).getMutationCache().build(N(this,jn),this.options)),N(this,ar).addObserver(this),N(this,ar).execute(t)}},jn=new WeakMap,vs=new WeakMap,ar=new WeakMap,Vn=new WeakMap,Wn=new WeakSet,Zu=function(){var r;const t=((r=N(this,ar))==null?void 0:r.state)??Jm();J(this,vs,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Oh=function(t){kt.batch(()=>{var r,n,s,a,o,i,c,l;if(N(this,Vn)&&this.hasListeners()){const u=N(this,vs).variables,d=N(this,vs).context,f={client:N(this,jn),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((n=(r=N(this,Vn)).onSuccess)==null||n.call(r,t.data,u,d,f),(a=(s=N(this,Vn)).onSettled)==null||a.call(s,t.data,null,u,d,f)):(t==null?void 0:t.type)==="error"&&((i=(o=N(this,Vn)).onError)==null||i.call(o,t.error,u,d,f),(l=(c=N(this,Vn)).onSettled)==null||l.call(c,void 0,t.error,u,d,f))}this.listeners.forEach(u=>{u(N(this,vs))})})},A5),Xw=(S5=class extends Aa{constructor(t={}){super();le(this,mn);this.config=t,J(this,mn,new Map)}build(t,r,n){const s=r.queryKey,a=r.queryHash??bd(s,r);let o=this.get(a);return o||(o=new Gw({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){N(this,mn).has(t.queryHash)||(N(this,mn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=N(this,mn).get(t.queryHash);r&&(t.destroy(),r===t&&N(this,mn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,mn).get(t)}getAll(){return[...N(this,mn).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Nm(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Nm(t,n)):r}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){kt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){kt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mn=new WeakMap,S5),Qw=(P5=class{constructor(e={}){le(this,ft);le(this,Es);le(this,ks);le(this,So);le(this,Po);le(this,Cs);le(this,Io);le(this,Bo);J(this,ft,e.queryCache||new Xw),J(this,Es,e.mutationCache||new Yw),J(this,ks,e.defaultOptions||{}),J(this,So,new Map),J(this,Po,new Map),J(this,Cs,0)}mount(){Yu(this,Cs)._++,N(this,Cs)===1&&(J(this,Io,wd.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onFocus())})),J(this,Bo,Dc.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onOnline())})))}unmount(){var e,t;Yu(this,Cs)._--,N(this,Cs)===0&&((e=N(this,Io))==null||e.call(this),J(this,Io,void 0),(t=N(this,Bo))==null||t.call(this),J(this,Bo,void 0))}isFetching(e){return N(this,ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,Es).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=N(this,ft).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Zn(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return N(this,ft).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),s=N(this,ft).get(n.queryHash),a=s==null?void 0:s.state.data,o=Ow(t,a);if(o!==void 0)return N(this,ft).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return kt.batch(()=>N(this,ft).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=N(this,ft);kt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=N(this,ft);return kt.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=kt.batch(()=>N(this,ft).findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(jt).catch(jt)}invalidateQueries(e,t={}){return kt.batch(()=>(N(this,ft).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=kt.batch(()=>N(this,ft).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(jt)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(jt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=N(this,ft).build(this,t);return r.isStaleByTime(Zn(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(jt).catch(jt)}fetchInfiniteQuery(e){return e.behavior=Xm(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(jt).catch(jt)}ensureInfiniteQueryData(e){return e.behavior=Xm(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Dc.isOnline()?N(this,Es).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,ft)}getMutationCache(){return N(this,Es)}getDefaultOptions(){return N(this,ks)}setDefaultOptions(e){J(this,ks,e)}setQueryDefaults(e,t){N(this,So).set(Os(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,So).values()],r={};return t.forEach(n=>{Oo(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){N(this,Po).set(Os(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,Po).values()],r={};return t.forEach(n=>{Oo(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,ks).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=bd(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Oc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,ks).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,ft).clear(),N(this,Es).clear()}},ft=new WeakMap,Es=new WeakMap,ks=new WeakMap,So=new WeakMap,Po=new WeakMap,Cs=new WeakMap,Io=new WeakMap,Bo=new WeakMap,P5),e1=xt.createContext(void 0),Td=e=>{const t=xt.useContext(e1);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Jw=({client:e,children:t})=>(xt.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),B.jsx(e1.Provider,{value:e,children:t})),t1=xt.createContext(!1),e3=()=>xt.useContext(t1);t1.Provider;function t3(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var r3=xt.createContext(t3()),n3=()=>xt.useContext(r3),s3=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},a3=e=>{xt.useEffect(()=>{e.clearReset()},[e])},o3=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||$m(r,[e.error,n])),i3=e=>{if(e.suspense){const r=s=>s==="static"?s:Math.max(s??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...s)=>r(n(...s)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},c3=(e,t)=>e.isLoading&&e.isFetching&&!t,l3=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,r1=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function u3(e,t,r){var d,f,h,y,g;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=e3(),s=n3(),a=Td(),o=a.defaultQueryOptions(e);(f=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||f.call(d,o),process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=n?"isRestoring":"optimistic",i3(o),s3(o,s),a3(s);const i=!a.getQueryCache().get(o.queryHash),[c]=xt.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!n&&e.subscribed!==!1;if(xt.useSyncExternalStore(xt.useCallback(E=>{const v=u?c.subscribe(kt.batchCalls(E)):jt;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),xt.useEffect(()=>{c.setOptions(o)},[o,c]),l3(o,l))throw r1(o,c,s);if(o3({result:l,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;if((y=(h=a.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||y.call(h,o,l),o.experimental_prefetchInRender&&!Us&&c3(l,n)){const E=i?r1(o,c,s):(g=a.getQueryCache().get(o.queryHash))==null?void 0:g.promise;E==null||E.catch(jt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?l:c.trackResult(l)}function d3(e,t){return u3(e,jw)}function Zr(e,t){const r=Td(),[n]=xt.useState(()=>new Zw(r,e));xt.useEffect(()=>{n.setOptions(e)},[n,e]);const s=xt.useSyncExternalStore(xt.useCallback(o=>n.subscribe(kt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=xt.useCallback((o,i)=>{n.mutate(o,i).catch(jt)},[n]);if(s.error&&$m(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const p3=M.createContext(null),Ad={didCatch:!1,error:null};class f3 extends M.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ad}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var r,n,s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];(r=(n=this.props).onReset)===null||r===void 0||r.call(n,{args:a,reason:"imperative-api"}),this.setState(Ad)}}componentDidCatch(t,r){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,r)}componentDidUpdate(t,r){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&r.error!==null&&h3(t.resetKeys,s)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(Ad)}}render(){const{children:t,fallbackRender:r,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let i=t;if(a){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof r=="function")i=r(c);else if(n)i=M.createElement(n,c);else if(s!==void 0)i=s;else throw o}return M.createElement(p3.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},i)}}function h3(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((r,n)=>!Object.is(r,t[n]))}const n1=e=>{let t;const r=new Set,n=(l,u)=>{const d=typeof l=="function"?l(t):l;if(!Object.is(d,t)){const f=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(h=>h(t,f))}},s=()=>t,i={setState:n,getState:s,getInitialState:()=>c,subscribe:l=>(r.add(l),()=>r.delete(l))},c=t=e(n,s,i);return i},m3=(e=>e?n1(e):n1),b3=e=>e;function y3(e,t=b3){const r=M.useSyncExternalStore(e.subscribe,M.useCallback(()=>t(e.getState()),[e,t]),M.useCallback(()=>t(e.getInitialState()),[e,t]));return M.useDebugValue(r),r}const s1=e=>{const t=m3(e),r=n=>y3(t,n);return Object.assign(r,t),r},g3=(e=>e?s1(e):s1),a1={disclaimerAccepted:!0,currentTime:Date.now(),swapExecution:{}},te=g3((e,t)=>({state:a1,updateState:r=>e(n=>({state:{...n.state,...r}})),updateSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...n.state.swapExecution,...r}}})),resetState:()=>{e({state:{...a1,currentTime:Date.now(),swapExecution:t().state.swapExecution,isMarketOrder:t().state.isMarketOrder}})}}));(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".orbs_OrbsLogo{object-fit:contain;display:inline}.orbs_PoweredBy{border-radius:8px;margin-left:auto;margin-right:auto}.orbs_PoweredBy a{display:flex;align-items:center;justify-content:center;text-decoration:none;color:inherit}.orbs_PoweredBy span{font-size:14px}.orbs_PoweredBy .orbs_OrbsLogo{margin-left:6px;margin-right:6px;width:18px;height:18px}.orbs_Text{margin:0;padding:0}.orbs_Spinner{width:var(--size, 38px);height:var(--size, 38px);border:var(--border-width, 3px) solid var(--border-color, white);border-bottom-color:var(--bottom-border-color, rgba(255, 255, 255, .2));border-radius:50%;display:inline-block;box-sizing:border-box;animation:orbs_rotation 1s linear infinite}@keyframes orbs_rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.orbs_TradeStepLayout{--layout-min-height: 220px;--layout-width: 100%;--layout-display: flex;--layout-direction: column;--layout-align: center;--layout-overflow: visible;display:var(--layout-display);flex-direction:var(--layout-direction);align-items:var(--layout-align);width:var(--layout-width);min-height:var(--layout-min-height);overflow:var(--layout-overflow)}.orbs_TradeStepLayoutBody{--body-gap: 20px;--body-margin-top: 30px;--body-width: 100%;--body-display: flex;--body-direction: column;--body-align: center;--body-overflow: visible;gap:var(--body-gap);align-items:var(--body-align);display:var(--body-display);flex-direction:var(--body-direction);width:var(--body-width);margin-top:var(--body-margin-top);overflow:var(--body-overflow)}.orbs_TradeStepLayoutHeader{--header-gap: 30px;--header-display: flex;--header-direction: column;--header-align: center;--header-justify: center;--header-overflow: visible;display:var(--header-display);flex-direction:var(--header-direction);align-items:var(--header-align);justify-content:var(--header-justify);gap:var(--header-gap);overflow:var(--header-overflow)}.orbs_TradeStepLayoutTitle{--title-font-size: 18px;--title-font-weight: 500;--title-line-height: normal;--title-color: inherit;--title-text-align: center;--title-margin: 0;--title-padding: 0;font-size:var(--title-font-size);font-weight:var(--title-font-weight);line-height:var(--title-line-height);color:var(--title-color);text-align:var(--title-text-align);margin:var(--title-margin);padding:var(--title-padding)}.orbs_StepIndicator{--indicator-display: flex;--indicator-align: center;--indicator-justify: flex-start;--indicator-height: 7px;--indicator-width: 120px;--indicator-border-radius: 999px;--indicator-bg-color: white;--indicator-margin-bottom: 20px;--indicator-position: relative;--indicator-overflow: hidden;--indicator-border: none;--indicator-box-shadow: none;display:var(--indicator-display);align-items:var(--indicator-align);justify-content:var(--indicator-justify);height:var(--indicator-height);width:var(--indicator-width);border-radius:var(--indicator-border-radius);overflow:var(--indicator-overflow);background-color:var(--indicator-bg-color);margin-bottom:var(--indicator-margin-bottom);position:var(--indicator-position);border:var(--indicator-border);box-shadow:var(--indicator-box-shadow)}.orbs_StepIndicatorLine{--line-height: 100%;--line-bg-color: black;--line-position: absolute;--line-top: 0;--line-left: 0;--line-right: 0;--line-bottom: 0;--line-transition: all .3s ease;--line-border-radius: inherit;--line-box-shadow: none;height:var(--line-height);background-color:var(--line-bg-color);position:var(--line-position);top:var(--line-top);left:var(--line-left);right:var(--line-right);bottom:var(--line-bottom);transition:var(--line-transition);border-radius:var(--line-border-radius);box-shadow:var(--line-box-shadow)}.orbs_TradeStepLayoutFooter{--footer-display: flex;--footer-align: center;--footer-justify: center;--footer-direction: column;--footer-margin-top: auto;--footer-padding-top: 30px;--footer-width: 100%;--footer-overflow: visible;--footer-border-top: none;display:var(--footer-display);align-items:var(--footer-align);justify-content:var(--footer-justify);flex-direction:var(--footer-direction);margin-top:var(--footer-margin-top);padding-top:var(--footer-padding-top);width:var(--footer-width);overflow:var(--footer-overflow);border-top:var(--footer-border-top)}.orbs_TradeStepLayoutFooter p{--footer-text-font-size: 15px;--footer-text-line-height: normal;--footer-text-color: inherit;--footer-text-margin: 0;--footer-text-padding: 0;font-size:var(--footer-text-font-size);line-height:var(--footer-text-line-height);color:var(--footer-text-color);margin:var(--footer-text-margin);padding:var(--footer-text-padding)}.orbs_TradeStepLayoutFooterLink{--link-color: inherit;--link-text-decoration: none;--link-font-size: 15px;--link-text-align: center;--link-margin: auto;--link-outline: none;--link-line-height: normal;--link-padding: 0;--link-transition: color .2s ease;--link-hover-color: inherit;--link-hover-text-decoration: underline;color:var(--link-color);text-decoration:var(--link-text-decoration);font-size:var(--link-font-size);text-align:var(--link-text-align);margin-left:var(--link-margin);margin-right:var(--link-margin);outline:var(--link-outline);line-height:var(--link-line-height);padding:var(--link-padding);transition:var(--link-transition)}.orbs_TradeStepLayoutFooterLink:hover{color:var(--link-hover-color);text-decoration:var(--link-hover-text-decoration)}.orbs_TradeStepLayoutSuccessIcon{--success-icon-display: flex;--success-icon-justify: center;--success-icon-align: center;--success-icon-width: 60px;--success-icon-height: 60px;--success-icon-border-radius: 50%;--success-icon-overflow: visible;--success-icon-bg-color: transparent;--success-icon-border: none;--success-icon-box-shadow: none;display:var(--success-icon-display);justify-content:var(--success-icon-justify);align-items:var(--success-icon-align);width:var(--success-icon-width);height:var(--success-icon-height);border-radius:var(--success-icon-border-radius);overflow:var(--success-icon-overflow);background-color:var(--success-icon-bg-color);border:var(--success-icon-border);box-shadow:var(--success-icon-box-shadow)}.orbs_TradeStepLayoutErrorIcon{--error-icon-width: 80px;--error-icon-height: 80px;--error-icon-display: flex;--error-icon-justify: center;--error-icon-align: center;--error-icon-overflow: visible;--error-icon-bg-color: transparent;--error-icon-border: none;--error-icon-box-shadow: none;width:var(--error-icon-width);height:var(--error-icon-height);display:var(--error-icon-display);justify-content:var(--error-icon-justify);align-items:var(--error-icon-align);overflow:var(--error-icon-overflow);background-color:var(--error-icon-bg-color);border:var(--error-icon-border);box-shadow:var(--error-icon-box-shadow)}.orbs_FailedContentMsg{font-size:22px;font-weight:500}.orbs_TradePreview{display:flex;align-items:center;justify-content:center;gap:8px;width:100%}.orbs_TradePreviewToken{display:flex;align-items:center;gap:6px;max-width:calc(50% - 30px)}.orbs_TradePreviewToken p{--token-font-size: 15px;--token-white-space: nowrap;--token-overflow: hidden;--token-text-overflow: ellipsis;--token-flex: 1;--token-margin: 0;--token-padding: 0;font-size:var(--token-font-size);white-space:var(--token-white-space);overflow:var(--token-overflow);text-overflow:var(--token-text-overflow);flex:var(--token-flex);margin:var(--token-margin)}.orbs_TradepPreviewIcon{width:22px;height:22px}.orbs_TradepPreviewLogo{width:24px;height:24px;border-radius:50%;overflow:hidden}.orbs_FlexRow{display:flex;flex-direction:row}.orbs_FlexColumn{display:flex;flex-direction:column}@keyframes orbs_skeletonAnimation{0%{opacity:.2}to{opacity:.4}}.orbs_SkeletonLoader{animation:orbs_skeletonAnimation 1s linear infinite alternate;background-color:#fff}.orbs_Main-wrapper{width:100%}.orbs_Main{width:100%;display:flex;flex-direction:column;gap:28px}.orbs_MainToken{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;gap:8px}.orbs_MainTokenLeft{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.orbs_MainTokenUsd{display:flex;align-items:center;gap:5px}.orbs_MainTokenUsd small{font-size:12px;opacity:.6}.orbs_MainContentLoader{width:100%;display:flex;gap:15px;align-items:center;margin-top:20px}.orbs_MainContentRectengularLoader{flex:1;height:20px;max-width:250px;border-radius:20px}.orbs_MainContentCircleLoader{width:30px;height:30px;border-radius:50%}.orbs_MainTokenLogo{--width: 40px;--height: 40px;width:var(--width);height:var(--height)}.orbs_MainTokenLogo img{width:100%;height:100%;object-fit:cover}.orbs_SwapFlow{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%}.orbs_SwapFlow *{box-sizing:border-box}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();const Ne=e=>`orbs_${e}`;function Do({children:e,className:t=""}){return B.jsx("p",{className:`${t} ${Ne("Text")}`,children:e})}const o1=M.createContext({});function x3({children:e,...t}){return B.jsx(o1.Provider,{value:t,children:e})}const Xr=()=>M.useContext(o1);var ht=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(ht||{});const w3=({className:e="",size:t=38,borderWidth:r=3,borderColor:n="white",bottomBorderColor:s="rgba(255, 255, 255, 0.2)"})=>{const a={"--size":`${t}px`,"--border-width":`${r}px`,"--border-color":n,"--bottom-border-color":s};return B.jsx("div",{className:`${Ne("Spinner")} ${e}`,style:a})};function Mc({className:e="",body:t,footerLink:r,footerText:n,title:s,children:a}){return B.jsxs("div",{className:`${Ne("TradeStepLayout")} ${e}`,children:[B.jsxs("div",{className:Ne("TradeStepLayoutHeader"),children:[B.jsx(T3,{}),s&&B.jsx(Do,{className:Ne("TradeStepLayoutTitle"),children:s})]}),t&&B.jsx("div",{className:Ne("TradeStepLayoutBody"),children:t}),B.jsx(v3,{link:r,text:n}),a]})}const v3=({link:e,text:t})=>{const{swapStatus:r}=Xr();return!e&&!t?null:B.jsxs("div",{className:Ne("TradeStepLayoutFooter"),children:[B.jsx(S3,{}),e?B.jsx(E3,{link:e,text:t}):r===ht.FAILED?void 0:B.jsx(Do,{children:t})]})},E3=({link:e,text:t})=>B.jsx("a",{target:"_blank",className:Ne("TradeStepLayoutFooterLink"),href:e,children:t});function k3(){const{components:e}=Xr();return e.SuccessIcon?e.SuccessIcon:B.jsxs("svg",{fill:"none",viewBox:"0 0 16 16",className:Ne("TradeStepLayoutSuccessIcon"),children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#00C853"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#00C853",d:"M5 8l2 2 4-4"})]})}function C3(){const{components:e}=Xr();return e.FailedIcon?e.FailedIcon:B.jsxs("svg",{className:Ne("TradeStepLayoutErrorIcon"),viewBox:"0 0 16 16",fill:"none",children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#FF3D00"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#FF3D00",d:"M8 4v5M8 11h.01"})]})}const T3=()=>{const{swapStatus:e}=Xr();return e===ht.SUCCESS?B.jsx(k3,{}):e===ht.FAILED?B.jsx(C3,{}):B.jsx(A3,{})},A3=()=>{const{components:e}=Xr();return e.Loader?e.Loader:B.jsx(w3,{size:60,borderWidth:5,className:Ne("TradeStepLayoutSpinner")})},S3=()=>{const{totalSteps:e,currentStepIndex:t=0,swapStatus:r}=Xr();return r!==ht.LOADING||e===1?null:B.jsx("div",{className:Ne("StepIndicator"),children:B.jsx("div",{style:{width:`${100/(e||0)}%`,left:`${t*100/(e||0)}%`},className:Ne("StepIndicatorLine")})})},P3=({error:e,footerLink:t,footerText:r})=>B.jsx(Mc,{footerLink:t,footerText:r,body:e||B.jsx("p",{className:Ne("FailedContentMsg"),children:"Something went wrong"}),className:Ne("FailedContent")});function I3(){return B.jsx("svg",{fill:"currentColor",viewBox:"0 0 16 16",className:Ne("TradepPreviewIcon"),children:B.jsx("path",{fillRule:"evenodd",d:"M4 8a.5.5 0 01.5-.5h5.793L8.146 5.354a.5.5 0 11.708-.708l3 3a.5.5 0 010 .708l-3 3a.5.5 0 01-.708-.708L10.293 8.5H4.5A.5.5 0 014 8z"})})}const i1=({inTokenOnly:e})=>{const{inToken:t,outToken:r,inAmount:n,outAmount:s,components:a}=Xr();return B.jsxs("div",{className:Ne("TradePreview"),children:[B.jsx(c1,{token:t,amount:n,Logo:a==null?void 0:a.SrcTokenLogo}),!e&&B.jsxs(B.Fragment,{children:[B.jsx(I3,{}),B.jsx(c1,{token:r,amount:s,Logo:a==null?void 0:a.DstTokenLogo})]})]})},c1=({token:e,amount:t,Logo:r})=>B.jsxs("div",{className:Ne("TradePreviewToken"),children:[r||B.jsx("img",{src:e==null?void 0:e.logoUrl,className:Ne("TradepPreviewLogo"),alt:`${e==null?void 0:e.symbol} logo`}),B.jsxs(Do,{children:[t," ",e==null?void 0:e.symbol]})]});function B3({title:e,footerLink:t,footerText:r,hideTokens:n}){return B.jsx(Mc,{title:e,className:Ne("Success"),body:!n&&B.jsx(i1,{}),footerLink:t,footerText:r})}const l1=({$gap:e=10,$alignItems:t="flex-start",children:r,className:n="",customStyles:s={}})=>{const a={gap:`${e}px`,alignItems:t,width:"100%",...s};return B.jsx("div",{className:`${Ne("FlexColumn")} ${n}`,style:a,children:r})};function u1({styles:e={},className:t=""}){return B.jsx("div",{style:e,className:`${Ne("SkeletonLoader")} ${t}`})}const F3=()=>B.jsxs("div",{className:`${Ne("MainContentLoader")}`,children:[B.jsx(u1,{className:`${Ne("MainContentCircleLoader")}`}),B.jsx(u1,{className:`${Ne("MainContentRectengularLoader")}`})]}),U3=({fromTitle:e,toTitle:t,inUsd:r,outUsd:n})=>{const{swapStatus:s,outAmount:a,inAmount:o,inToken:i,outToken:c,components:l,totalSteps:u}=Xr(),d=B.jsx(p1,{fromTitle:e,inUsd:r,inToken:i,toTitle:t,outUsd:n,outToken:c,inAmount:o,outAmount:a,SrcTokenLogo:l.SrcTokenLogo,DstTokenLogo:l.DstTokenLogo});return s?u?B.jsx(O3,{}):B.jsxs(l1,{children:[d,B.jsx(F3,{})]}):B.jsx(l1,{children:d})},d1=({amount:e,token:t,usd:r,title:n,Logo:s})=>B.jsxs("div",{className:`${Ne("MainToken")}`,children:[B.jsxs("div",{className:`${Ne("MainTokenLeft")}`,children:[B.jsx(Do,{className:`${Ne("MainTokenTitle")}`,children:n}),B.jsx(Do,{className:` ${Ne("MainTokenAmount")}`,children:`${e&&Number(e)>0?e:""} ${(t==null?void 0:t.symbol)||""}`}),r&&B.jsx("div",{className:` ${Ne("MainTokenUsd")}`,children:r})]}),s||B.jsx("div",{className:` ${Ne("MainTokenLogo")}`,children:t!=null&&t.logoUrl?B.jsx("img",{src:t==null?void 0:t.logoUrl,alt:"Token logo"}):null})]});function O3(){const{currentStep:e}=Xr();return e?B.jsx(Mc,{footerLink:e.footerLink,footerText:e.footerText,title:e.title,body:e.hideTokens?void 0:B.jsx(i1,{inTokenOnly:e==null?void 0:e.inTokenOnly})}):null}const p1=({fromTitle:e,inUsd:t,inToken:r,toTitle:n,outUsd:s,outToken:a,inAmount:o,outAmount:i,SrcTokenLogo:c,DstTokenLogo:l})=>B.jsxs("div",{className:`${Ne("Main")}`,children:[B.jsx(d1,{title:e||"Swap from",usd:t,token:r,amount:o,Logo:c}),B.jsx(d1,{title:n||"Swap to",usd:s,token:a,amount:i,Logo:l})]}),Xn=e=>B.jsx(x3,{...e,children:B.jsx(D3,{})}),D3=()=>{const{swapStatus:e,components:t,className:r}=Xr();return B.jsx("div",{className:`${Ne("SwapFlow")} ${r}`,children:e===ht.SUCCESS?t==null?void 0:t.Success:e===ht.FAILED?t==null?void 0:t.Failed:t==null?void 0:t.Main})};Xn.Success=B3,Xn.Failed=P3,Xn.Main=U3,Xn.StepLayout=Mc;var Ds=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(Ds||{});const _3="1.2.3";let Zt=class Dh extends Error{constructor(t,r={}){var o;const n=r.cause instanceof Dh?r.cause.details:(o=r.cause)!=null&&o.message?r.cause.message:r.details,s=r.cause instanceof Dh&&r.cause.docsPath||r.docsPath,a=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...n?[`Details: ${n}`]:[],`Version: abitype@${_3}`].join(`
|
|
64
|
+
`,extractResults:d=>{var f;return(((f=d.data)==null?void 0:f.orderFilleds)||[]).map(h=>({...h,timestamp:new Date(h.timestamp).getTime()}))}})};class Tw extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const Aw=async({chainId:e,signal:t,page:r,limit:n,filters:s})=>{try{const a=await Ew({chainId:e,signal:t,page:r,limit:n,filters:s}),[o,i]=await Promise.all([Cw({chainId:e,orders:a,signal:t}),kw({chainId:e,orders:a,signal:t})]);return a.map(l=>{const u=o==null?void 0:o.filter(d=>d.TWAP_id===Number(l.Contract_id)&&Ps(d.exchange,l.exchange)&&Ps(d.twapAddress,l.twapAddress));return ww(l,e,u,Sw(l,u||[],i))}).sort((l,u)=>u.createdAt-l.createdAt)}catch{return[]}},Sw=(e,t,r)=>{var i;const n=(i=r==null?void 0:r.find(c=>c.twapId===e.Contract_id.toString()&&Ps(c.twapAddress,e.twapAddress)))==null?void 0:i.status,a=Um(t).reduce((c,l)=>c.plus(l.inAmount),new j(0)).toFixed(),o=Dm(e.ask_srcAmount,a);return Pw(o,e.ask_deadline*1e3,n)},Dm=(e,t)=>{if(!t||!e)return 0;const r=j(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Pw=(e,t,r)=>e===100?ct.Completed:r==="CANCELED"?ct.Canceled:r==="COMPLETED"?ct.Completed:t>Date.now()?ct.Open:ct.Expired,_m=async({signal:e,page:t,chainId:r,limit:n,config:s,account:a})=>(await Promise.all([s?Aw({chainId:r,signal:e,page:t,limit:n,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),gw({chainId:r,signal:e,account:a,exchange:s==null?void 0:s.adapter})]).then(([c,l])=>[...c,...l])).sort((c,l)=>l.createdAt-c.createdAt),Iw={version:"0.0.68"};var Aa=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Bw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fw=(g5=class{constructor(){le(this,pn,Bw);le(this,pa,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,pa)&&e!==N(this,pn)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,pn),provider:e}),J(this,pn,e),process.env.NODE_ENV!=="production"&&J(this,pa,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&J(this,pa,!0),N(this,pn).setTimeout(e,t)}clearTimeout(e){N(this,pn).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&J(this,pa,!0),N(this,pn).setInterval(e,t)}clearInterval(e){N(this,pn).clearInterval(e)}},pn=new WeakMap,pa=new WeakMap,g5),Fs=new Fw;function Uw(e){setTimeout(e,0)}var Us=typeof window>"u"||"Deno"in globalThis;function jt(){}function Ow(e,t){return typeof e=="function"?e(t):e}function md(e){return typeof e=="number"&&e>=0&&e!==1/0}function Mm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Zn(e,t){return typeof e=="function"?e(t):e}function wr(e,t){return typeof e=="function"?e(t):e}function Nm(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:o,stale:i}=e;if(o){if(n){if(t.queryHash!==bd(o,t.options))return!1}else if(!Oo(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof i=="boolean"&&t.isStale()!==i||s&&s!==t.state.fetchStatus||a&&!a(t))}function Lm(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(Os(t.options.mutationKey)!==Os(a))return!1}else if(!Oo(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function bd(e,t){return((t==null?void 0:t.queryKeyHashFn)||Os)(e)}function Os(e){return JSON.stringify(e,(t,r)=>gd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Oo(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Oo(e[r],t[r])):!1}var Dw=Object.prototype.hasOwnProperty;function yd(e,t){if(e===t)return e;const r=zm(e)&&zm(t);if(!r&&!(gd(e)&&gd(t)))return t;const s=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,i=r?new Array(o):{};let c=0;for(let l=0;l<o;l++){const u=r?l:a[l],d=e[u],f=t[u];if(d===f){i[u]=d,(r?l<s:Dw.call(e,u))&&c++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){i[u]=f;continue}const h=yd(d,f);i[u]=h,h===d&&c++}return s===o&&c===s?e:i}function Uc(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function zm(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function gd(e){if(!Rm(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Rm(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Rm(e){return Object.prototype.toString.call(e)==="[object Object]"}function _w(e){return new Promise(t=>{Fs.setTimeout(t,e)})}function xd(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return yd(e,t)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${n}`),n}return yd(e,t)}return t}function Mw(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function Nw(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var Oc=Symbol();function Hm(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Oc&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Oc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function $m(e,t){return typeof e=="function"?e(...t):!!e}var Lw=(x5=class extends Aa{constructor(){super();le(this,fa);le(this,ys);le(this,xo);J(this,xo,t=>{if(!Us&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){N(this,ys)||this.setEventListener(N(this,xo))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,ys))==null||t.call(this),J(this,ys,void 0))}setEventListener(t){var r;J(this,xo,t),(r=N(this,ys))==null||r.call(this),J(this,ys,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){N(this,fa)!==t&&(J(this,fa,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof N(this,fa)=="boolean"?N(this,fa):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},fa=new WeakMap,ys=new WeakMap,xo=new WeakMap,x5),wd=new Lw;function vd(){let e,t;const r=new Promise((s,a)=>{e=s,t=a});r.status="pending",r.catch(()=>{});function n(s){Object.assign(r,s),delete r.resolve,delete r.reject}return r.resolve=s=>{n({status:"fulfilled",value:s}),e(s)},r.reject=s=>{n({status:"rejected",reason:s}),t(s)},r}var zw=Uw;function Rw(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=zw;const a=i=>{t?e.push(i):s(()=>{r(i)})},o=()=>{const i=e;e=[],i.length&&s(()=>{n(()=>{i.forEach(c=>{r(c)})})})};return{batch:i=>{let c;t++;try{c=i()}finally{t--,t||o()}return c},batchCalls:i=>(...c)=>{a(()=>{i(...c)})},schedule:a,setNotifyFunction:i=>{r=i},setBatchNotifyFunction:i=>{n=i},setScheduler:i=>{s=i}}}var kt=Rw(),Hw=(w5=class extends Aa{constructor(){super();le(this,wo,!0);le(this,gs);le(this,vo);J(this,vo,t=>{if(!Us&&window.addEventListener){const r=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",n)}}})}onSubscribe(){N(this,gs)||this.setEventListener(N(this,vo))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,gs))==null||t.call(this),J(this,gs,void 0))}setEventListener(t){var r;J(this,vo,t),(r=N(this,gs))==null||r.call(this),J(this,gs,t(this.setOnline.bind(this)))}setOnline(t){N(this,wo)!==t&&(J(this,wo,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return N(this,wo)}},wo=new WeakMap,gs=new WeakMap,vo=new WeakMap,w5),Dc=new Hw;function $w(e){return Math.min(1e3*2**e,3e4)}function Gm(e){return(e??"online")==="online"?Dc.isOnline():!0}var Ed=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function jm(e){let t=!1,r=0,n;const s=vd(),a=()=>s.status!=="pending",o=g=>{var E;if(!a()){const v=new Ed(g);f(v),(E=e.onCancel)==null||E.call(e,v)}},i=()=>{t=!0},c=()=>{t=!1},l=()=>wd.isFocused()&&(e.networkMode==="always"||Dc.isOnline())&&e.canRun(),u=()=>Gm(e.networkMode)&&e.canRun(),d=g=>{a()||(n==null||n(),s.resolve(g))},f=g=>{a()||(n==null||n(),s.reject(g))},h=()=>new Promise(g=>{var E;n=v=>{(a()||l())&&g(v)},(E=e.onPause)==null||E.call(e)}).then(()=>{var g;n=void 0,a()||(g=e.onContinue)==null||g.call(e)}),y=()=>{if(a())return;let g;const E=r===0?e.initialPromise:void 0;try{g=E??e.fn()}catch(v){g=Promise.reject(v)}Promise.resolve(g).then(d).catch(v=>{var z;if(a())return;const w=e.retry??(Us?0:3),A=e.retryDelay??$w,C=typeof A=="function"?A(r,v):A,D=w===!0||typeof w=="number"&&r<w||typeof w=="function"&&w(r,v);if(t||!D){f(v);return}r++,(z=e.onFail)==null||z.call(e,r,v),_w(C).then(()=>l()?void 0:h()).then(()=>{t?f(v):y()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:i,continueRetry:c,canStart:u,start:()=>(u()?y():h().then(y),s)}}var Vm=(v5=class{constructor(){le(this,ha)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),md(this.gcTime)&&J(this,ha,Fs.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Us?1/0:300*1e3))}clearGcTimeout(){N(this,ha)&&(Fs.clearTimeout(N(this,ha)),J(this,ha,void 0))}},ha=new WeakMap,v5),Gw=(E5=class extends Vm{constructor(t){super();le(this,Kr);le(this,ma);le(this,Eo);le(this,Ir);le(this,ba);le(this,Bt);le(this,vc);le(this,ya);J(this,ya,!1),J(this,vc,t.defaultOptions),this.setOptions(t.options),this.observers=[],J(this,ba,t.client),J(this,Ir,N(this,ba).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,J(this,ma,Km(this.options)),this.state=t.state??N(this,ma),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=N(this,Bt))==null?void 0:t.promise}setOptions(t){if(this.options={...N(this,vc),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Km(this.options);r.data!==void 0&&(this.setState(qm(r.data,r.dataUpdatedAt)),J(this,ma,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,Ir).remove(this)}setData(t,r){const n=xd(this.state.data,t,this.options);return Se(this,Kr,qn).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(t,r){Se(this,Kr,qn).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var n,s;const r=(n=N(this,Bt))==null?void 0:n.promise;return(s=N(this,Bt))==null||s.cancel(t),r?r.then(jt).catch(jt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(N(this,ma))}isActive(){return this.observers.some(t=>wr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Zn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Mm(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(n=>n.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}onOnline(){var r;const t=this.observers.find(n=>n.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=N(this,Bt))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),N(this,Ir).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(N(this,Bt)&&(N(this,ya)?N(this,Bt).cancel({revert:!0}):N(this,Bt).cancelRetry()),this.scheduleGc()),N(this,Ir).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Se(this,Kr,qn).call(this,{type:"invalidate"})}async fetch(t,r){var c,l,u,d,f,h,y,g,E,v,w,A;if(this.state.fetchStatus!=="idle"&&((c=N(this,Bt))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(N(this,Bt))return N(this,Bt).continueRetry(),N(this,Bt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const C=this.observers.find(D=>D.options.queryFn);C&&this.setOptions(C.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const n=new AbortController,s=C=>{Object.defineProperty(C,"signal",{enumerable:!0,get:()=>(J(this,ya,!0),n.signal)})},a=()=>{const C=Hm(this.options,r),z=(()=>{const T={client:N(this,ba),queryKey:this.queryKey,meta:this.meta};return s(T),T})();return J(this,ya,!1),this.options.persister?this.options.persister(C,z,this):C(z)},i=(()=>{const C={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:N(this,ba),state:this.state,fetchFn:a};return s(C),C})();(l=this.options.behavior)==null||l.onFetch(i,this),J(this,Eo,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&Se(this,Kr,qn).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta}),J(this,Bt,jm({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:C=>{C instanceof Ed&&C.revert&&this.setState({...N(this,Eo),fetchStatus:"idle"}),n.abort()},onFail:(C,D)=>{Se(this,Kr,qn).call(this,{type:"failed",failureCount:C,error:D})},onPause:()=>{Se(this,Kr,qn).call(this,{type:"pause"})},onContinue:()=>{Se(this,Kr,qn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const C=await N(this,Bt).start();if(C===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(C),(h=(f=N(this,Ir).config).onSuccess)==null||h.call(f,C,this),(g=(y=N(this,Ir).config).onSettled)==null||g.call(y,C,this.state.error,this),C}catch(C){if(C instanceof Ed){if(C.silent)return N(this,Bt).promise;if(C.revert){if(this.state.data===void 0)throw C;return this.state.data}}throw Se(this,Kr,qn).call(this,{type:"error",error:C}),(v=(E=N(this,Ir).config).onError)==null||v.call(E,C,this),(A=(w=N(this,Ir).config).onSettled)==null||A.call(w,this.state.data,C,this),C}finally{this.scheduleGc()}}},ma=new WeakMap,Eo=new WeakMap,Ir=new WeakMap,ba=new WeakMap,Bt=new WeakMap,vc=new WeakMap,ya=new WeakMap,Kr=new WeakSet,qn=function(t){const r=n=>{switch(t.type){case"failed":return{...n,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...n,fetchStatus:"paused"};case"continue":return{...n,fetchStatus:"fetching"};case"fetch":return{...n,...Wm(n.data,this.options),fetchMeta:t.meta??null};case"success":const s={...n,...qm(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return J(this,Eo,t.manual?s:void 0),s;case"error":const a=t.error;return{...n,error:a,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...t.state}}};this.state=r(this.state),kt.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),N(this,Ir).notify({query:this,type:"updated",action:t})})},E5);function Wm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Gm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function qm(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Km(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,n=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var jw=(k5=class extends Aa{constructor(t,r){super();le(this,Ve);le(this,sr);le(this,Oe);le(this,Ec);le(this,qt);le(this,ga);le(this,ko);le(this,$n);le(this,xs);le(this,kc);le(this,Co);le(this,To);le(this,xa);le(this,wa);le(this,ws);le(this,Ao,new Set);this.options=r,J(this,sr,t),J(this,xs,null),J(this,$n,vd()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,Oe).addObserver(this),Ym(N(this,Oe),this.options)?Se(this,Ve,Ac).call(this):this.updateResult(),Se(this,Ve,Ih).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kd(N(this,Oe),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kd(N(this,Oe),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,Ve,Bh).call(this),Se(this,Ve,Fh).call(this),N(this,Oe).removeObserver(this)}setOptions(t){const r=this.options,n=N(this,Oe);if(this.options=N(this,sr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof wr(this.options.enabled,N(this,Oe))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Se(this,Ve,Uh).call(this),N(this,Oe).setOptions(this.options),r._defaulted&&!Uc(this.options,r)&&N(this,sr).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,Oe),observer:this});const s=this.hasListeners();s&&Zm(N(this,Oe),n,this.options,r)&&Se(this,Ve,Ac).call(this),this.updateResult(),s&&(N(this,Oe)!==n||wr(this.options.enabled,N(this,Oe))!==wr(r.enabled,N(this,Oe))||Zn(this.options.staleTime,N(this,Oe))!==Zn(r.staleTime,N(this,Oe)))&&Se(this,Ve,Ah).call(this);const a=Se(this,Ve,Sh).call(this);s&&(N(this,Oe)!==n||wr(this.options.enabled,N(this,Oe))!==wr(r.enabled,N(this,Oe))||a!==N(this,ws))&&Se(this,Ve,Ph).call(this,a)}getOptimisticResult(t){const r=N(this,sr).getQueryCache().build(N(this,sr),t),n=this.createResult(r,t);return Ww(this,n)&&(J(this,qt,n),J(this,ko,this.options),J(this,ga,N(this,Oe).state)),n}getCurrentResult(){return N(this,qt)}trackResult(t,r){return new Proxy(t,{get:(n,s)=>(this.trackProp(s),r==null||r(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&N(this,$n).status==="pending"&&N(this,$n).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,s))})}trackProp(t){N(this,Ao).add(t)}getCurrentQuery(){return N(this,Oe)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=N(this,sr).defaultQueryOptions(t),n=N(this,sr).getQueryCache().build(N(this,sr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Se(this,Ve,Ac).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,qt)))}createResult(t,r){var b;const n=N(this,Oe),s=this.options,a=N(this,qt),o=N(this,ga),i=N(this,ko),l=t!==n?t.state:N(this,Ec),{state:u}=t;let d={...u},f=!1,h;if(r._optimisticResults){const x=this.hasListeners(),S=!x&&Ym(t,r),I=x&&Zm(t,n,r,s);(S||I)&&(d={...d,...Wm(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:y,errorUpdatedAt:g,status:E}=d;h=d.data;let v=!1;if(r.placeholderData!==void 0&&h===void 0&&E==="pending"){let x;a!=null&&a.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(x=a.data,v=!0):x=typeof r.placeholderData=="function"?r.placeholderData((b=N(this,To))==null?void 0:b.state.data,N(this,To)):r.placeholderData,x!==void 0&&(E="success",h=xd(a==null?void 0:a.data,x,r),f=!0)}if(r.select&&h!==void 0&&!v)if(a&&h===(o==null?void 0:o.data)&&r.select===N(this,kc))h=N(this,Co);else try{J(this,kc,r.select),h=r.select(h),h=xd(a==null?void 0:a.data,h,r),J(this,Co,h),J(this,xs,null)}catch(x){J(this,xs,x)}N(this,xs)&&(y=N(this,xs),h=N(this,Co),g=Date.now(),E="error");const w=d.fetchStatus==="fetching",A=E==="pending",C=E==="error",D=A&&w,z=h!==void 0,m={status:E,fetchStatus:d.fetchStatus,isPending:A,isSuccess:E==="success",isError:C,isInitialLoading:D,isLoading:D,data:h,dataUpdatedAt:d.dataUpdatedAt,error:y,errorUpdatedAt:g,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>l.dataUpdateCount||d.errorUpdateCount>l.errorUpdateCount,isFetching:w,isRefetching:w&&!A,isLoadingError:C&&!z,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:C&&z,isStale:Cd(t,r),refetch:this.refetch,promise:N(this,$n),isEnabled:wr(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const x=F=>{m.status==="error"?F.reject(m.error):m.data!==void 0&&F.resolve(m.data)},S=()=>{const F=J(this,$n,m.promise=vd());x(F)},I=N(this,$n);switch(I.status){case"pending":t.queryHash===n.queryHash&&x(I);break;case"fulfilled":(m.status==="error"||m.data!==I.value)&&S();break;case"rejected":(m.status!=="error"||m.error!==I.reason)&&S();break}}return m}updateResult(){const t=N(this,qt),r=this.createResult(N(this,Oe),this.options);if(J(this,ga,N(this,Oe).state),J(this,ko,this.options),N(this,ga).data!==void 0&&J(this,To,N(this,Oe)),Uc(r,t))return;J(this,qt,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!N(this,Ao).size)return!0;const o=new Set(a??N(this,Ao));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,qt)).some(i=>{const c=i;return N(this,qt)[c]!==t[c]&&o.has(c)})};Se(this,Ve,M5).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,Ve,Ih).call(this)}},sr=new WeakMap,Oe=new WeakMap,Ec=new WeakMap,qt=new WeakMap,ga=new WeakMap,ko=new WeakMap,$n=new WeakMap,xs=new WeakMap,kc=new WeakMap,Co=new WeakMap,To=new WeakMap,xa=new WeakMap,wa=new WeakMap,ws=new WeakMap,Ao=new WeakMap,Ve=new WeakSet,Ac=function(t){Se(this,Ve,Uh).call(this);let r=N(this,Oe).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(jt)),r},Ah=function(){Se(this,Ve,Bh).call(this);const t=Zn(this.options.staleTime,N(this,Oe));if(Us||N(this,qt).isStale||!md(t))return;const n=Mm(N(this,qt).dataUpdatedAt,t)+1;J(this,xa,Fs.setTimeout(()=>{N(this,qt).isStale||this.updateResult()},n))},Sh=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,Oe)):this.options.refetchInterval)??!1},Ph=function(t){Se(this,Ve,Fh).call(this),J(this,ws,t),!(Us||wr(this.options.enabled,N(this,Oe))===!1||!md(N(this,ws))||N(this,ws)===0)&&J(this,wa,Fs.setInterval(()=>{(this.options.refetchIntervalInBackground||wd.isFocused())&&Se(this,Ve,Ac).call(this)},N(this,ws)))},Ih=function(){Se(this,Ve,Ah).call(this),Se(this,Ve,Ph).call(this,Se(this,Ve,Sh).call(this))},Bh=function(){N(this,xa)&&(Fs.clearTimeout(N(this,xa)),J(this,xa,void 0))},Fh=function(){N(this,wa)&&(Fs.clearInterval(N(this,wa)),J(this,wa,void 0))},Uh=function(){const t=N(this,sr).getQueryCache().build(N(this,sr),this.options);if(t===N(this,Oe))return;const r=N(this,Oe);J(this,Oe,t),J(this,Ec,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},M5=function(t){kt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(N(this,qt))}),N(this,sr).getQueryCache().notify({query:N(this,Oe),type:"observerResultsUpdated"})})},k5);function Vw(e,t){return wr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Ym(e,t){return Vw(e,t)||e.state.data!==void 0&&kd(e,t,t.refetchOnMount)}function kd(e,t,r){if(wr(t.enabled,e)!==!1&&Zn(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Cd(e,t)}return!1}function Zm(e,t,r,n){return(e!==t||wr(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Cd(e,r)}function Cd(e,t){return wr(t.enabled,e)!==!1&&e.isStaleByTime(Zn(t.staleTime,e))}function Ww(e,t){return!Uc(e.getCurrentResult(),t)}function Xm(e){return{onFetch:(t,r)=>{var u,d,f,h,y;const n=t.options,s=(f=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,a=((h=t.state.data)==null?void 0:h.pages)||[],o=((y=t.state.data)==null?void 0:y.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const l=async()=>{let g=!1;const E=A=>{Object.defineProperty(A,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=Hm(t.options,t.fetchOptions),w=async(A,C,D)=>{if(g)return Promise.reject();if(C==null&&A.pages.length)return Promise.resolve(A);const T=(()=>{const S={client:t.client,queryKey:t.queryKey,pageParam:C,direction:D?"backward":"forward",meta:t.options.meta};return E(S),S})(),m=await v(T),{maxPages:b}=t.options,x=D?Nw:Mw;return{pages:x(A.pages,m,b),pageParams:x(A.pageParams,C,b)}};if(s&&a.length){const A=s==="backward",C=A?qw:Qm,D={pages:a,pageParams:o},z=C(n,D);i=await w(D,z,A)}else{const A=e??a.length;do{const C=c===0?o[0]??n.initialPageParam:Qm(n,i);if(c>0&&C==null)break;i=await w(i,C),c++}while(c<A)}return i};t.options.persister?t.fetchFn=()=>{var g,E;return(E=(g=t.options).persister)==null?void 0:E.call(g,l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=l}}}function Qm(e,{pages:t,pageParams:r}){const n=t.length-1;return t.length>0?e.getNextPageParam(t[n],t,r[n],r):void 0}function qw(e,{pages:t,pageParams:r}){var n;return t.length>0?(n=e.getPreviousPageParam)==null?void 0:n.call(e,t[0],t,r[0],r):void 0}var Kw=(C5=class extends Vm{constructor(t){super();le(this,hn);le(this,Cc);le(this,fn);le(this,Kt);le(this,va);J(this,Cc,t.client),this.mutationId=t.mutationId,J(this,Kt,t.mutationCache),J(this,fn,[]),this.state=t.state||Jm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){N(this,fn).includes(t)||(N(this,fn).push(t),this.clearGcTimeout(),N(this,Kt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){J(this,fn,N(this,fn).filter(r=>r!==t)),this.scheduleGc(),N(this,Kt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,fn).length||(this.state.status==="pending"?this.scheduleGc():N(this,Kt).remove(this))}continue(){var t;return((t=N(this,va))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,c,l,u,d,f,h,y,g,E,v,w,A,C,D,z,T,m,b;const r=()=>{Se(this,hn,Ts).call(this,{type:"continue"})},n={client:N(this,Cc),meta:this.options.meta,mutationKey:this.options.mutationKey};J(this,va,jm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(x,S)=>{Se(this,hn,Ts).call(this,{type:"failed",failureCount:x,error:S})},onPause:()=>{Se(this,hn,Ts).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,Kt).canRun(this)}));const s=this.state.status==="pending",a=!N(this,va).canStart();try{if(s)r();else{Se(this,hn,Ts).call(this,{type:"pending",variables:t,isPaused:a}),await((i=(o=N(this,Kt).config).onMutate)==null?void 0:i.call(o,t,this,n));const S=await((l=(c=this.options).onMutate)==null?void 0:l.call(c,t,n));S!==this.state.context&&Se(this,hn,Ts).call(this,{type:"pending",context:S,variables:t,isPaused:a})}const x=await N(this,va).start();return await((d=(u=N(this,Kt).config).onSuccess)==null?void 0:d.call(u,x,t,this.state.context,this,n)),await((h=(f=this.options).onSuccess)==null?void 0:h.call(f,x,t,this.state.context,n)),await((g=(y=N(this,Kt).config).onSettled)==null?void 0:g.call(y,x,null,this.state.variables,this.state.context,this,n)),await((v=(E=this.options).onSettled)==null?void 0:v.call(E,x,null,t,this.state.context,n)),Se(this,hn,Ts).call(this,{type:"success",data:x}),x}catch(x){try{throw await((A=(w=N(this,Kt).config).onError)==null?void 0:A.call(w,x,t,this.state.context,this,n)),await((D=(C=this.options).onError)==null?void 0:D.call(C,x,t,this.state.context,n)),await((T=(z=N(this,Kt).config).onSettled)==null?void 0:T.call(z,void 0,x,this.state.variables,this.state.context,this,n)),await((b=(m=this.options).onSettled)==null?void 0:b.call(m,void 0,x,t,this.state.context,n)),x}finally{Se(this,hn,Ts).call(this,{type:"error",error:x})}}finally{N(this,Kt).runNext(this)}}},Cc=new WeakMap,fn=new WeakMap,Kt=new WeakMap,va=new WeakMap,hn=new WeakSet,Ts=function(t){const r=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),kt.batch(()=>{N(this,fn).forEach(n=>{n.onMutationUpdate(t)}),N(this,Kt).notify({mutation:this,type:"updated",action:t})})},C5);function Jm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yw=(T5=class extends Aa{constructor(t={}){super();le(this,Gn);le(this,Yr);le(this,Tc);this.config=t,J(this,Gn,new Set),J(this,Yr,new Map),J(this,Tc,0)}build(t,r,n){const s=new Kw({client:t,mutationCache:this,mutationId:++Yu(this,Tc)._,options:t.defaultMutationOptions(r),state:n});return this.add(s),s}add(t){N(this,Gn).add(t);const r=_c(t);if(typeof r=="string"){const n=N(this,Yr).get(r);n?n.push(t):N(this,Yr).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,Gn).delete(t)){const r=_c(t);if(typeof r=="string"){const n=N(this,Yr).get(r);if(n)if(n.length>1){const s=n.indexOf(t);s!==-1&&n.splice(s,1)}else n[0]===t&&N(this,Yr).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=_c(t);if(typeof r=="string"){const n=N(this,Yr).get(r),s=n==null?void 0:n.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var n;const r=_c(t);if(typeof r=="string"){const s=(n=N(this,Yr).get(r))==null?void 0:n.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){kt.batch(()=>{N(this,Gn).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,Gn).clear(),N(this,Yr).clear()})}getAll(){return Array.from(N(this,Gn))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Lm(r,n))}findAll(t={}){return this.getAll().filter(r=>Lm(t,r))}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>r.state.isPaused);return kt.batch(()=>Promise.all(t.map(r=>r.continue().catch(jt))))}},Gn=new WeakMap,Yr=new WeakMap,Tc=new WeakMap,T5);function _c(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Zw=(A5=class extends Aa{constructor(t,r){super();le(this,Wn);le(this,jn);le(this,vs);le(this,ar);le(this,Vn);J(this,jn,t),this.setOptions(r),this.bindMethods(),Se(this,Wn,Zu).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var n;const r=this.options;this.options=N(this,jn).defaultMutationOptions(t),Uc(this.options,r)||N(this,jn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,ar),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&Os(r.mutationKey)!==Os(this.options.mutationKey)?this.reset():((n=N(this,ar))==null?void 0:n.state.status)==="pending"&&N(this,ar).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,ar))==null||t.removeObserver(this)}onMutationUpdate(t){Se(this,Wn,Zu).call(this),Se(this,Wn,Oh).call(this,t)}getCurrentResult(){return N(this,vs)}reset(){var t;(t=N(this,ar))==null||t.removeObserver(this),J(this,ar,void 0),Se(this,Wn,Zu).call(this),Se(this,Wn,Oh).call(this)}mutate(t,r){var n;return J(this,Vn,r),(n=N(this,ar))==null||n.removeObserver(this),J(this,ar,N(this,jn).getMutationCache().build(N(this,jn),this.options)),N(this,ar).addObserver(this),N(this,ar).execute(t)}},jn=new WeakMap,vs=new WeakMap,ar=new WeakMap,Vn=new WeakMap,Wn=new WeakSet,Zu=function(){var r;const t=((r=N(this,ar))==null?void 0:r.state)??Jm();J(this,vs,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Oh=function(t){kt.batch(()=>{var r,n,s,a,o,i,c,l;if(N(this,Vn)&&this.hasListeners()){const u=N(this,vs).variables,d=N(this,vs).context,f={client:N(this,jn),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((n=(r=N(this,Vn)).onSuccess)==null||n.call(r,t.data,u,d,f),(a=(s=N(this,Vn)).onSettled)==null||a.call(s,t.data,null,u,d,f)):(t==null?void 0:t.type)==="error"&&((i=(o=N(this,Vn)).onError)==null||i.call(o,t.error,u,d,f),(l=(c=N(this,Vn)).onSettled)==null||l.call(c,void 0,t.error,u,d,f))}this.listeners.forEach(u=>{u(N(this,vs))})})},A5),Xw=(S5=class extends Aa{constructor(t={}){super();le(this,mn);this.config=t,J(this,mn,new Map)}build(t,r,n){const s=r.queryKey,a=r.queryHash??bd(s,r);let o=this.get(a);return o||(o=new Gw({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){N(this,mn).has(t.queryHash)||(N(this,mn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=N(this,mn).get(t.queryHash);r&&(t.destroy(),r===t&&N(this,mn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,mn).get(t)}getAll(){return[...N(this,mn).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Nm(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Nm(t,n)):r}notify(t){kt.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){kt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){kt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},mn=new WeakMap,S5),Qw=(P5=class{constructor(e={}){le(this,ft);le(this,Es);le(this,ks);le(this,So);le(this,Po);le(this,Cs);le(this,Io);le(this,Bo);J(this,ft,e.queryCache||new Xw),J(this,Es,e.mutationCache||new Yw),J(this,ks,e.defaultOptions||{}),J(this,So,new Map),J(this,Po,new Map),J(this,Cs,0)}mount(){Yu(this,Cs)._++,N(this,Cs)===1&&(J(this,Io,wd.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onFocus())})),J(this,Bo,Dc.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,ft).onOnline())})))}unmount(){var e,t;Yu(this,Cs)._--,N(this,Cs)===0&&((e=N(this,Io))==null||e.call(this),J(this,Io,void 0),(t=N(this,Bo))==null||t.call(this),J(this,Bo,void 0))}isFetching(e){return N(this,ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,Es).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=N(this,ft).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Zn(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return N(this,ft).findAll(e).map(({queryKey:t,state:r})=>{const n=r.data;return[t,n]})}setQueryData(e,t,r){const n=this.defaultQueryOptions({queryKey:e}),s=N(this,ft).get(n.queryHash),a=s==null?void 0:s.state.data,o=Ow(t,a);if(o!==void 0)return N(this,ft).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return kt.batch(()=>N(this,ft).findAll(e).map(({queryKey:n})=>[n,this.setQueryData(n,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,ft).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=N(this,ft);kt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=N(this,ft);return kt.batch(()=>(r.findAll(e).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},n=kt.batch(()=>N(this,ft).findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(jt).catch(jt)}invalidateQueries(e,t={}){return kt.batch(()=>(N(this,ft).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},n=kt.batch(()=>N(this,ft).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(jt)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(jt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=N(this,ft).build(this,t);return r.isStaleByTime(Zn(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(jt).catch(jt)}fetchInfiniteQuery(e){return e.behavior=Xm(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(jt).catch(jt)}ensureInfiniteQueryData(e){return e.behavior=Xm(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Dc.isOnline()?N(this,Es).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,ft)}getMutationCache(){return N(this,Es)}getDefaultOptions(){return N(this,ks)}setDefaultOptions(e){J(this,ks,e)}setQueryDefaults(e,t){N(this,So).set(Os(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,So).values()],r={};return t.forEach(n=>{Oo(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){N(this,Po).set(Os(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,Po).values()],r={};return t.forEach(n=>{Oo(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,ks).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=bd(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Oc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,ks).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,ft).clear(),N(this,Es).clear()}},ft=new WeakMap,Es=new WeakMap,ks=new WeakMap,So=new WeakMap,Po=new WeakMap,Cs=new WeakMap,Io=new WeakMap,Bo=new WeakMap,P5),e1=xt.createContext(void 0),Td=e=>{const t=xt.useContext(e1);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Jw=({client:e,children:t})=>(xt.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),B.jsx(e1.Provider,{value:e,children:t})),t1=xt.createContext(!1),e3=()=>xt.useContext(t1);t1.Provider;function t3(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var r3=xt.createContext(t3()),n3=()=>xt.useContext(r3),s3=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},a3=e=>{xt.useEffect(()=>{e.clearReset()},[e])},o3=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||$m(r,[e.error,n])),i3=e=>{if(e.suspense){const r=s=>s==="static"?s:Math.max(s??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...s)=>r(n(...s)):r(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},c3=(e,t)=>e.isLoading&&e.isFetching&&!t,l3=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,r1=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function u3(e,t,r){var d,f,h,y,g;if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const n=e3(),s=n3(),a=Td(),o=a.defaultQueryOptions(e);(f=(d=a.getDefaultOptions().queries)==null?void 0:d._experimental_beforeQuery)==null||f.call(d,o),process.env.NODE_ENV!=="production"&&(o.queryFn||console.error(`[${o.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),o._optimisticResults=n?"isRestoring":"optimistic",i3(o),s3(o,s),a3(s);const i=!a.getQueryCache().get(o.queryHash),[c]=xt.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!n&&e.subscribed!==!1;if(xt.useSyncExternalStore(xt.useCallback(E=>{const v=u?c.subscribe(kt.batchCalls(E)):jt;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),xt.useEffect(()=>{c.setOptions(o)},[o,c]),l3(o,l))throw r1(o,c,s);if(o3({result:l,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;if((y=(h=a.getDefaultOptions().queries)==null?void 0:h._experimental_afterQuery)==null||y.call(h,o,l),o.experimental_prefetchInRender&&!Us&&c3(l,n)){const E=i?r1(o,c,s):(g=a.getQueryCache().get(o.queryHash))==null?void 0:g.promise;E==null||E.catch(jt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?l:c.trackResult(l)}function d3(e,t){return u3(e,jw)}function Zr(e,t){const r=Td(),[n]=xt.useState(()=>new Zw(r,e));xt.useEffect(()=>{n.setOptions(e)},[n,e]);const s=xt.useSyncExternalStore(xt.useCallback(o=>n.subscribe(kt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=xt.useCallback((o,i)=>{n.mutate(o,i).catch(jt)},[n]);if(s.error&&$m(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const p3=M.createContext(null),Ad={didCatch:!1,error:null};class f3 extends M.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=Ad}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var r,n,s=arguments.length,a=new Array(s),o=0;o<s;o++)a[o]=arguments[o];(r=(n=this.props).onReset)===null||r===void 0||r.call(n,{args:a,reason:"imperative-api"}),this.setState(Ad)}}componentDidCatch(t,r){var n,s;(n=(s=this.props).onError)===null||n===void 0||n.call(s,t,r)}componentDidUpdate(t,r){const{didCatch:n}=this.state,{resetKeys:s}=this.props;if(n&&r.error!==null&&h3(t.resetKeys,s)){var a,o;(a=(o=this.props).onReset)===null||a===void 0||a.call(o,{next:s,prev:t.resetKeys,reason:"keys"}),this.setState(Ad)}}render(){const{children:t,fallbackRender:r,FallbackComponent:n,fallback:s}=this.props,{didCatch:a,error:o}=this.state;let i=t;if(a){const c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof r=="function")i=r(c);else if(n)i=M.createElement(n,c);else if(s!==void 0)i=s;else throw o}return M.createElement(p3.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},i)}}function h3(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((r,n)=>!Object.is(r,t[n]))}const n1=e=>{let t;const r=new Set,n=(l,u)=>{const d=typeof l=="function"?l(t):l;if(!Object.is(d,t)){const f=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),r.forEach(h=>h(t,f))}},s=()=>t,i={setState:n,getState:s,getInitialState:()=>c,subscribe:l=>(r.add(l),()=>r.delete(l))},c=t=e(n,s,i);return i},m3=(e=>e?n1(e):n1),b3=e=>e;function y3(e,t=b3){const r=M.useSyncExternalStore(e.subscribe,M.useCallback(()=>t(e.getState()),[e,t]),M.useCallback(()=>t(e.getInitialState()),[e,t]));return M.useDebugValue(r),r}const s1=e=>{const t=m3(e),r=n=>y3(t,n);return Object.assign(r,t),r},g3=(e=>e?s1(e):s1),a1={disclaimerAccepted:!0,currentTime:Date.now(),swapExecution:{}},te=g3((e,t)=>({state:a1,updateState:r=>e(n=>({state:{...n.state,...r}})),updateSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...n.state.swapExecution,...r}}})),resetState:()=>{e({state:{...a1,currentTime:Date.now(),swapExecution:t().state.swapExecution,isMarketOrder:t().state.isMarketOrder}})}}));(function(){try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".orbs_OrbsLogo{object-fit:contain;display:inline}.orbs_PoweredBy{border-radius:8px;margin-left:auto;margin-right:auto}.orbs_PoweredBy a{display:flex;align-items:center;justify-content:center;text-decoration:none;color:inherit}.orbs_PoweredBy span{font-size:14px}.orbs_PoweredBy .orbs_OrbsLogo{margin-left:6px;margin-right:6px;width:18px;height:18px}.orbs_Text{margin:0;padding:0}.orbs_Spinner{width:var(--size, 38px);height:var(--size, 38px);border:var(--border-width, 3px) solid var(--border-color, white);border-bottom-color:var(--bottom-border-color, rgba(255, 255, 255, .2));border-radius:50%;display:inline-block;box-sizing:border-box;animation:orbs_rotation 1s linear infinite}@keyframes orbs_rotation{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.orbs_TradeStepLayout{--layout-min-height: 220px;--layout-width: 100%;--layout-display: flex;--layout-direction: column;--layout-align: center;--layout-overflow: visible;display:var(--layout-display);flex-direction:var(--layout-direction);align-items:var(--layout-align);width:var(--layout-width);min-height:var(--layout-min-height);overflow:var(--layout-overflow)}.orbs_TradeStepLayoutBody{--body-gap: 20px;--body-margin-top: 30px;--body-width: 100%;--body-display: flex;--body-direction: column;--body-align: center;--body-overflow: visible;gap:var(--body-gap);align-items:var(--body-align);display:var(--body-display);flex-direction:var(--body-direction);width:var(--body-width);margin-top:var(--body-margin-top);overflow:var(--body-overflow)}.orbs_TradeStepLayoutHeader{--header-gap: 30px;--header-display: flex;--header-direction: column;--header-align: center;--header-justify: center;--header-overflow: visible;display:var(--header-display);flex-direction:var(--header-direction);align-items:var(--header-align);justify-content:var(--header-justify);gap:var(--header-gap);overflow:var(--header-overflow)}.orbs_TradeStepLayoutTitle{--title-font-size: 18px;--title-font-weight: 500;--title-line-height: normal;--title-color: inherit;--title-text-align: center;--title-margin: 0;--title-padding: 0;font-size:var(--title-font-size);font-weight:var(--title-font-weight);line-height:var(--title-line-height);color:var(--title-color);text-align:var(--title-text-align);margin:var(--title-margin);padding:var(--title-padding)}.orbs_StepIndicator{--indicator-display: flex;--indicator-align: center;--indicator-justify: flex-start;--indicator-height: 7px;--indicator-width: 120px;--indicator-border-radius: 999px;--indicator-bg-color: white;--indicator-margin-bottom: 20px;--indicator-position: relative;--indicator-overflow: hidden;--indicator-border: none;--indicator-box-shadow: none;display:var(--indicator-display);align-items:var(--indicator-align);justify-content:var(--indicator-justify);height:var(--indicator-height);width:var(--indicator-width);border-radius:var(--indicator-border-radius);overflow:var(--indicator-overflow);background-color:var(--indicator-bg-color);margin-bottom:var(--indicator-margin-bottom);position:var(--indicator-position);border:var(--indicator-border);box-shadow:var(--indicator-box-shadow)}.orbs_StepIndicatorLine{--line-height: 100%;--line-bg-color: black;--line-position: absolute;--line-top: 0;--line-left: 0;--line-right: 0;--line-bottom: 0;--line-transition: all .3s ease;--line-border-radius: inherit;--line-box-shadow: none;height:var(--line-height);background-color:var(--line-bg-color);position:var(--line-position);top:var(--line-top);left:var(--line-left);right:var(--line-right);bottom:var(--line-bottom);transition:var(--line-transition);border-radius:var(--line-border-radius);box-shadow:var(--line-box-shadow)}.orbs_TradeStepLayoutFooter{--footer-display: flex;--footer-align: center;--footer-justify: center;--footer-direction: column;--footer-margin-top: auto;--footer-padding-top: 30px;--footer-width: 100%;--footer-overflow: visible;--footer-border-top: none;display:var(--footer-display);align-items:var(--footer-align);justify-content:var(--footer-justify);flex-direction:var(--footer-direction);margin-top:var(--footer-margin-top);padding-top:var(--footer-padding-top);width:var(--footer-width);overflow:var(--footer-overflow);border-top:var(--footer-border-top)}.orbs_TradeStepLayoutFooter p{--footer-text-font-size: 15px;--footer-text-line-height: normal;--footer-text-color: inherit;--footer-text-margin: 0;--footer-text-padding: 0;font-size:var(--footer-text-font-size);line-height:var(--footer-text-line-height);color:var(--footer-text-color);margin:var(--footer-text-margin);padding:var(--footer-text-padding)}.orbs_TradeStepLayoutFooterLink{--link-color: inherit;--link-text-decoration: none;--link-font-size: 15px;--link-text-align: center;--link-margin: auto;--link-outline: none;--link-line-height: normal;--link-padding: 0;--link-transition: color .2s ease;--link-hover-color: inherit;--link-hover-text-decoration: underline;color:var(--link-color);text-decoration:var(--link-text-decoration);font-size:var(--link-font-size);text-align:var(--link-text-align);margin-left:var(--link-margin);margin-right:var(--link-margin);outline:var(--link-outline);line-height:var(--link-line-height);padding:var(--link-padding);transition:var(--link-transition)}.orbs_TradeStepLayoutFooterLink:hover{color:var(--link-hover-color);text-decoration:var(--link-hover-text-decoration)}.orbs_TradeStepLayoutSuccessIcon{--success-icon-display: flex;--success-icon-justify: center;--success-icon-align: center;--success-icon-width: 60px;--success-icon-height: 60px;--success-icon-border-radius: 50%;--success-icon-overflow: visible;--success-icon-bg-color: transparent;--success-icon-border: none;--success-icon-box-shadow: none;display:var(--success-icon-display);justify-content:var(--success-icon-justify);align-items:var(--success-icon-align);width:var(--success-icon-width);height:var(--success-icon-height);border-radius:var(--success-icon-border-radius);overflow:var(--success-icon-overflow);background-color:var(--success-icon-bg-color);border:var(--success-icon-border);box-shadow:var(--success-icon-box-shadow)}.orbs_TradeStepLayoutErrorIcon{--error-icon-width: 80px;--error-icon-height: 80px;--error-icon-display: flex;--error-icon-justify: center;--error-icon-align: center;--error-icon-overflow: visible;--error-icon-bg-color: transparent;--error-icon-border: none;--error-icon-box-shadow: none;width:var(--error-icon-width);height:var(--error-icon-height);display:var(--error-icon-display);justify-content:var(--error-icon-justify);align-items:var(--error-icon-align);overflow:var(--error-icon-overflow);background-color:var(--error-icon-bg-color);border:var(--error-icon-border);box-shadow:var(--error-icon-box-shadow)}.orbs_FailedContentMsg{font-size:22px;font-weight:500}.orbs_TradePreview{display:flex;align-items:center;justify-content:center;gap:8px;width:100%}.orbs_TradePreviewToken{display:flex;align-items:center;gap:6px;max-width:calc(50% - 30px)}.orbs_TradePreviewToken p{--token-font-size: 15px;--token-white-space: nowrap;--token-overflow: hidden;--token-text-overflow: ellipsis;--token-flex: 1;--token-margin: 0;--token-padding: 0;font-size:var(--token-font-size);white-space:var(--token-white-space);overflow:var(--token-overflow);text-overflow:var(--token-text-overflow);flex:var(--token-flex);margin:var(--token-margin)}.orbs_TradepPreviewIcon{width:22px;height:22px}.orbs_TradepPreviewLogo{width:24px;height:24px;border-radius:50%;overflow:hidden}.orbs_FlexRow{display:flex;flex-direction:row}.orbs_FlexColumn{display:flex;flex-direction:column}@keyframes orbs_skeletonAnimation{0%{opacity:.2}to{opacity:.4}}.orbs_SkeletonLoader{animation:orbs_skeletonAnimation 1s linear infinite alternate;background-color:#fff}.orbs_Main-wrapper{width:100%}.orbs_Main{width:100%;display:flex;flex-direction:column;gap:28px}.orbs_MainToken{display:flex;flex-direction:row;align-items:center;justify-content:space-between;width:100%;gap:8px}.orbs_MainTokenLeft{display:flex;flex-direction:column;align-items:flex-start;gap:8px}.orbs_MainTokenUsd{display:flex;align-items:center;gap:5px}.orbs_MainTokenUsd small{font-size:12px;opacity:.6}.orbs_MainContentLoader{width:100%;display:flex;gap:15px;align-items:center;margin-top:20px}.orbs_MainContentRectengularLoader{flex:1;height:20px;max-width:250px;border-radius:20px}.orbs_MainContentCircleLoader{width:30px;height:30px;border-radius:50%}.orbs_MainTokenLogo{--width: 40px;--height: 40px;width:var(--width);height:var(--height)}.orbs_MainTokenLogo img{width:100%;height:100%;object-fit:cover}.orbs_SwapFlow{display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%}.orbs_SwapFlow *{box-sizing:border-box}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();const Ne=e=>`orbs_${e}`;function Do({children:e,className:t=""}){return B.jsx("p",{className:`${t} ${Ne("Text")}`,children:e})}const o1=M.createContext({});function x3({children:e,...t}){return B.jsx(o1.Provider,{value:t,children:e})}const Xr=()=>M.useContext(o1);var ht=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(ht||{});const w3=({className:e="",size:t=38,borderWidth:r=3,borderColor:n="white",bottomBorderColor:s="rgba(255, 255, 255, 0.2)"})=>{const a={"--size":`${t}px`,"--border-width":`${r}px`,"--border-color":n,"--bottom-border-color":s};return B.jsx("div",{className:`${Ne("Spinner")} ${e}`,style:a})};function Mc({className:e="",body:t,footerLink:r,footerText:n,title:s,children:a}){return B.jsxs("div",{className:`${Ne("TradeStepLayout")} ${e}`,children:[B.jsxs("div",{className:Ne("TradeStepLayoutHeader"),children:[B.jsx(T3,{}),s&&B.jsx(Do,{className:Ne("TradeStepLayoutTitle"),children:s})]}),t&&B.jsx("div",{className:Ne("TradeStepLayoutBody"),children:t}),B.jsx(v3,{link:r,text:n}),a]})}const v3=({link:e,text:t})=>{const{swapStatus:r}=Xr();return!e&&!t?null:B.jsxs("div",{className:Ne("TradeStepLayoutFooter"),children:[B.jsx(S3,{}),e?B.jsx(E3,{link:e,text:t}):r===ht.FAILED?void 0:B.jsx(Do,{children:t})]})},E3=({link:e,text:t})=>B.jsx("a",{target:"_blank",className:Ne("TradeStepLayoutFooterLink"),href:e,children:t});function k3(){const{components:e}=Xr();return e.SuccessIcon?e.SuccessIcon:B.jsxs("svg",{fill:"none",viewBox:"0 0 16 16",className:Ne("TradeStepLayoutSuccessIcon"),children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#00C853"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#00C853",d:"M5 8l2 2 4-4"})]})}function C3(){const{components:e}=Xr();return e.FailedIcon?e.FailedIcon:B.jsxs("svg",{className:Ne("TradeStepLayoutErrorIcon"),viewBox:"0 0 16 16",fill:"none",children:[B.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#FF3D00"}),B.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#FF3D00",d:"M8 4v5M8 11h.01"})]})}const T3=()=>{const{swapStatus:e}=Xr();return e===ht.SUCCESS?B.jsx(k3,{}):e===ht.FAILED?B.jsx(C3,{}):B.jsx(A3,{})},A3=()=>{const{components:e}=Xr();return e.Loader?e.Loader:B.jsx(w3,{size:60,borderWidth:5,className:Ne("TradeStepLayoutSpinner")})},S3=()=>{const{totalSteps:e,currentStepIndex:t=0,swapStatus:r}=Xr();return r!==ht.LOADING||e===1?null:B.jsx("div",{className:Ne("StepIndicator"),children:B.jsx("div",{style:{width:`${100/(e||0)}%`,left:`${t*100/(e||0)}%`},className:Ne("StepIndicatorLine")})})},P3=({error:e,footerLink:t,footerText:r})=>B.jsx(Mc,{footerLink:t,footerText:r,body:e||B.jsx("p",{className:Ne("FailedContentMsg"),children:"Something went wrong"}),className:Ne("FailedContent")});function I3(){return B.jsx("svg",{fill:"currentColor",viewBox:"0 0 16 16",className:Ne("TradepPreviewIcon"),children:B.jsx("path",{fillRule:"evenodd",d:"M4 8a.5.5 0 01.5-.5h5.793L8.146 5.354a.5.5 0 11.708-.708l3 3a.5.5 0 010 .708l-3 3a.5.5 0 01-.708-.708L10.293 8.5H4.5A.5.5 0 014 8z"})})}const i1=({inTokenOnly:e})=>{const{inToken:t,outToken:r,inAmount:n,outAmount:s,components:a}=Xr();return B.jsxs("div",{className:Ne("TradePreview"),children:[B.jsx(c1,{token:t,amount:n,Logo:a==null?void 0:a.SrcTokenLogo}),!e&&B.jsxs(B.Fragment,{children:[B.jsx(I3,{}),B.jsx(c1,{token:r,amount:s,Logo:a==null?void 0:a.DstTokenLogo})]})]})},c1=({token:e,amount:t,Logo:r})=>B.jsxs("div",{className:Ne("TradePreviewToken"),children:[r||B.jsx("img",{src:e==null?void 0:e.logoUrl,className:Ne("TradepPreviewLogo"),alt:`${e==null?void 0:e.symbol} logo`}),B.jsxs(Do,{children:[t," ",e==null?void 0:e.symbol]})]});function B3({title:e,footerLink:t,footerText:r,hideTokens:n}){return B.jsx(Mc,{title:e,className:Ne("Success"),body:!n&&B.jsx(i1,{}),footerLink:t,footerText:r})}const l1=({$gap:e=10,$alignItems:t="flex-start",children:r,className:n="",customStyles:s={}})=>{const a={gap:`${e}px`,alignItems:t,width:"100%",...s};return B.jsx("div",{className:`${Ne("FlexColumn")} ${n}`,style:a,children:r})};function u1({styles:e={},className:t=""}){return B.jsx("div",{style:e,className:`${Ne("SkeletonLoader")} ${t}`})}const F3=()=>B.jsxs("div",{className:`${Ne("MainContentLoader")}`,children:[B.jsx(u1,{className:`${Ne("MainContentCircleLoader")}`}),B.jsx(u1,{className:`${Ne("MainContentRectengularLoader")}`})]}),U3=({fromTitle:e,toTitle:t,inUsd:r,outUsd:n})=>{const{swapStatus:s,outAmount:a,inAmount:o,inToken:i,outToken:c,components:l,totalSteps:u}=Xr(),d=B.jsx(p1,{fromTitle:e,inUsd:r,inToken:i,toTitle:t,outUsd:n,outToken:c,inAmount:o,outAmount:a,SrcTokenLogo:l.SrcTokenLogo,DstTokenLogo:l.DstTokenLogo});return s?u?B.jsx(O3,{}):B.jsxs(l1,{children:[d,B.jsx(F3,{})]}):B.jsx(l1,{children:d})},d1=({amount:e,token:t,usd:r,title:n,Logo:s})=>B.jsxs("div",{className:`${Ne("MainToken")}`,children:[B.jsxs("div",{className:`${Ne("MainTokenLeft")}`,children:[B.jsx(Do,{className:`${Ne("MainTokenTitle")}`,children:n}),B.jsx(Do,{className:` ${Ne("MainTokenAmount")}`,children:`${e&&Number(e)>0?e:""} ${(t==null?void 0:t.symbol)||""}`}),r&&B.jsx("div",{className:` ${Ne("MainTokenUsd")}`,children:r})]}),s||B.jsx("div",{className:` ${Ne("MainTokenLogo")}`,children:t!=null&&t.logoUrl?B.jsx("img",{src:t==null?void 0:t.logoUrl,alt:"Token logo"}):null})]});function O3(){const{currentStep:e}=Xr();return e?B.jsx(Mc,{footerLink:e.footerLink,footerText:e.footerText,title:e.title,body:e.hideTokens?void 0:B.jsx(i1,{inTokenOnly:e==null?void 0:e.inTokenOnly})}):null}const p1=({fromTitle:e,inUsd:t,inToken:r,toTitle:n,outUsd:s,outToken:a,inAmount:o,outAmount:i,SrcTokenLogo:c,DstTokenLogo:l})=>B.jsxs("div",{className:`${Ne("Main")}`,children:[B.jsx(d1,{title:e||"Swap from",usd:t,token:r,amount:o,Logo:c}),B.jsx(d1,{title:n||"Swap to",usd:s,token:a,amount:i,Logo:l})]}),Xn=e=>B.jsx(x3,{...e,children:B.jsx(D3,{})}),D3=()=>{const{swapStatus:e,components:t,className:r}=Xr();return B.jsx("div",{className:`${Ne("SwapFlow")} ${r}`,children:e===ht.SUCCESS?t==null?void 0:t.Success:e===ht.FAILED?t==null?void 0:t.Failed:t==null?void 0:t.Main})};Xn.Success=B3,Xn.Failed=P3,Xn.Main=U3,Xn.StepLayout=Mc;var Ds=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(Ds||{});const _3="1.2.3";let Zt=class Dh extends Error{constructor(t,r={}){var o;const n=r.cause instanceof Dh?r.cause.details:(o=r.cause)!=null&&o.message?r.cause.message:r.details,s=r.cause instanceof Dh&&r.cause.docsPath||r.docsPath,a=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...n?[`Details: ${n}`]:[],`Version: abitype@${_3}`].join(`
|
|
65
65
|
`);super(a),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),r.cause&&(this.cause=r.cause),this.details=n,this.docsPath=s,this.metaMessages=r.metaMessages,this.shortMessage=t}};function gn(e,t){const r=e.exec(t);return r==null?void 0:r.groups}const f1=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,h1=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,m1=/^\(.+?\).*?$/,b1=/^tuple(?<array>(\[(\d*)\])*)$/;function Sd(e){let t=e.type;if(b1.test(e.type)&&"components"in e){t="(";const r=e.components.length;for(let s=0;s<r;s++){const a=e.components[s];t+=Sd(a),s<r-1&&(t+=", ")}const n=gn(b1,e.type);return t+=`)${(n==null?void 0:n.array)||""}`,Sd({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Sa(e){let t="";const r=e.length;for(let n=0;n<r;n++){const s=e[n];t+=Sd(s),n!==r-1&&(t+=", ")}return t}function Nc(e){var t;return e.type==="function"?`function ${e.name}(${Sa(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${(t=e.outputs)!=null&&t.length?` returns (${Sa(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Sa(e.inputs)})`:e.type==="error"?`error ${e.name}(${Sa(e.inputs)})`:e.type==="constructor"?`constructor(${Sa(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const y1=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function M3(e){return y1.test(e)}function N3(e){return gn(y1,e)}const g1=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function L3(e){return g1.test(e)}function z3(e){return gn(g1,e)}const x1=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function R3(e){return x1.test(e)}function H3(e){return gn(x1,e)}const w1=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Lc(e){return w1.test(e)}function $3(e){return gn(w1,e)}const v1=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function G3(e){return v1.test(e)}function j3(e){return gn(v1,e)}const E1=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function V3(e){return E1.test(e)}function W3(e){return gn(E1,e)}const q3=/^receive\(\) external payable$/;function K3(e){return q3.test(e)}const k1=new Set(["memory","indexed","storage","calldata"]),Y3=new Set(["indexed"]),Pd=new Set(["calldata","memory","storage"]);class Z3 extends Zt{constructor({signature:t}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class X3 extends Zt{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class Q3 extends Zt{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class J3 extends Zt{constructor({params:t}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class e8 extends Zt{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class t8 extends Zt{constructor({param:t,name:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${r}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class r8 extends Zt{constructor({param:t,type:r,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class n8 extends Zt{constructor({param:t,type:r,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class s8 extends Zt{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Pa extends Zt{constructor({signature:t,type:r}){super(`Invalid ${r} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class a8 extends Zt{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class o8 extends Zt{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class i8 extends Zt{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class c8 extends Zt{constructor({current:t,depth:r}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${r>0?"opening":"closing"} parentheses.`],details:`Depth "${r}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function l8(e,t,r){let n="";if(r)for(const s of Object.entries(r)){if(!s)continue;let a="";for(const o of s[1])a+=`[${o.type}${o.name?`:${o.name}`:""}]`;n+=`(${s[0]}{${a}})`}return t?`${t}:${e}${n}`:`${e}${n}`}const Id=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function Bd(e,t={}){if(R3(e))return u8(e,t);if(L3(e))return d8(e,t);if(M3(e))return p8(e,t);if(G3(e))return f8(e,t);if(V3(e))return h8(e);if(K3(e))return{type:"receive",stateMutability:"payable"};throw new a8({signature:e})}function u8(e,t={}){const r=H3(e);if(!r)throw new Pa({signature:e,type:"function"});const n=or(r.parameters),s=[],a=n.length;for(let i=0;i<a;i++)s.push(xn(n[i],{modifiers:Pd,structs:t,type:"function"}));const o=[];if(r.returns){const i=or(r.returns),c=i.length;for(let l=0;l<c;l++)o.push(xn(i[l],{modifiers:Pd,structs:t,type:"function"}))}return{name:r.name,type:"function",stateMutability:r.stateMutability??"nonpayable",inputs:s,outputs:o}}function d8(e,t={}){const r=z3(e);if(!r)throw new Pa({signature:e,type:"event"});const n=or(r.parameters),s=[],a=n.length;for(let o=0;o<a;o++)s.push(xn(n[o],{modifiers:Y3,structs:t,type:"event"}));return{name:r.name,type:"event",inputs:s}}function p8(e,t={}){const r=N3(e);if(!r)throw new Pa({signature:e,type:"error"});const n=or(r.parameters),s=[],a=n.length;for(let o=0;o<a;o++)s.push(xn(n[o],{structs:t,type:"error"}));return{name:r.name,type:"error",inputs:s}}function f8(e,t={}){const r=j3(e);if(!r)throw new Pa({signature:e,type:"constructor"});const n=or(r.parameters),s=[],a=n.length;for(let o=0;o<a;o++)s.push(xn(n[o],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:r.stateMutability??"nonpayable",inputs:s}}function h8(e){const t=W3(e);if(!t)throw new Pa({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const m8=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,b8=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,y8=/^u?int$/;function xn(e,t){var d,f;const r=l8(e,t==null?void 0:t.type,t==null?void 0:t.structs);if(Id.has(r))return Id.get(r);const n=m1.test(e),s=gn(n?b8:m8,e);if(!s)throw new e8({param:e});if(s.name&&x8(s.name))throw new t8({param:e,name:s.name});const a=s.name?{name:s.name}:{},o=s.modifier==="indexed"?{indexed:!0}:{},i=(t==null?void 0:t.structs)??{};let c,l={};if(n){c="tuple";const h=or(s.type),y=[],g=h.length;for(let E=0;E<g;E++)y.push(xn(h[E],{structs:i}));l={components:y}}else if(s.type in i)c="tuple",l={components:i[s.type]};else if(y8.test(s.type))c=`${s.type}256`;else if(s.type==="address payable")c="address";else if(c=s.type,(t==null?void 0:t.type)!=="struct"&&!C1(c))throw new Q3({type:c});if(s.modifier){if(!((f=(d=t==null?void 0:t.modifiers)==null?void 0:d.has)!=null&&f.call(d,s.modifier)))throw new r8({param:e,type:t==null?void 0:t.type,modifier:s.modifier});if(Pd.has(s.modifier)&&!w8(c,!!s.array))throw new n8({param:e,type:t==null?void 0:t.type,modifier:s.modifier})}const u={type:`${c}${s.array??""}`,...a,...o,...l};return Id.set(r,u),u}function or(e,t=[],r="",n=0){const s=e.trim().length;for(let a=0;a<s;a++){const o=e[a],i=e.slice(a+1);switch(o){case",":return n===0?or(i,[...t,r.trim()]):or(i,t,`${r}${o}`,n);case"(":return or(i,t,`${r}${o}`,n+1);case")":return or(i,t,`${r}${o}`,n-1);default:return or(i,t,`${r}${o}`,n)}}if(r==="")return t;if(n!==0)throw new c8({current:r,depth:n});return t.push(r.trim()),t}function C1(e){return e==="address"||e==="bool"||e==="function"||e==="string"||f1.test(e)||h1.test(e)}const g8=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function x8(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||f1.test(e)||h1.test(e)||g8.test(e)}function w8(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Fd(e){const t={},r=e.length;for(let o=0;o<r;o++){const i=e[o];if(!Lc(i))continue;const c=$3(i);if(!c)throw new Pa({signature:i,type:"struct"});const l=c.properties.split(";"),u=[],d=l.length;for(let f=0;f<d;f++){const y=l[f].trim();if(!y)continue;const g=xn(y,{type:"struct"});u.push(g)}if(!u.length)throw new o8({signature:i});t[c.name]=u}const n={},s=Object.entries(t),a=s.length;for(let o=0;o<a;o++){const[i,c]=s[o];n[i]=T1(c,t)}return n}const v8=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function T1(e=[],t={},r=new Set){const n=[],s=e.length;for(let a=0;a<s;a++){const o=e[a];if(m1.test(o.type))n.push(o);else{const c=gn(v8,o.type);if(!(c!=null&&c.type))throw new s8({abiParameter:o});const{array:l,type:u}=c;if(u in t){if(r.has(u))throw new i8({type:u});n.push({...o,type:`tuple${l??""}`,components:T1(t[u],t,new Set([...r,u]))})}else if(C1(u))n.push(o);else throw new X3({type:u})}}return n}function A1(e){const t=Fd(e),r=[],n=e.length;for(let s=0;s<n;s++){const a=e[s];Lc(a)||r.push(Bd(a,t))}return r}function S1(e){let t;if(typeof e=="string")t=Bd(e);else{const r=Fd(e),n=e.length;for(let s=0;s<n;s++){const a=e[s];if(!Lc(a)){t=Bd(a,r);break}}}if(!t)throw new Z3({signature:e});return t}function P1(e){const t=[];if(typeof e=="string"){const r=or(e),n=r.length;for(let s=0;s<n;s++)t.push(xn(r[s],{modifiers:k1}))}else{const r=Fd(e),n=e.length;for(let s=0;s<n;s++){const a=e[s];if(Lc(a))continue;const o=or(a),i=o.length;for(let c=0;c<i;c++)t.push(xn(o[c],{modifiers:k1,structs:r}))}}if(t.length===0)throw new J3({params:e});return t}function ne(e,t,r){const n=e[t.name];if(typeof n=="function")return n;const s=e[r];return typeof s=="function"?s:a=>t(e,a)}function Or(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new _8(e.type);return`${e.name}(${zc(e.inputs,{includeName:t})})`}function zc(e,{includeName:t=!1}={}){return e?e.map(r=>E8(r,{includeName:t})).join(t?", ":","):""}function E8(e,{includeName:t}){return e.type.startsWith("tuple")?`(${zc(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function Dr(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function ut(e){return Dr(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const I1="2.43.3";let _o={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${I1}`},$=class _h extends Error{constructor(t,r={}){var i;const n=(()=>{var c;return r.cause instanceof _h?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof _h&&r.cause.docsPath||r.docsPath,a=(i=_o.getDocsUrl)==null?void 0:i.call(_o,{...r,docsPath:s}),o=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],..._o.version?[`Version: ${_o.version}`]:[]].join(`
|
|
66
66
|
`);super(o,r.cause?{cause:r.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=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=I1}walk(t){return B1(this,t)}};function B1(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?B1(e.cause,t):t?null:e}class k8 extends ${constructor({docsPath:t}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(`
|
|
67
67
|
`),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class F1 extends ${constructor({docsPath:t}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(`
|
|
@@ -123,4 +123,4 @@ ee.version="2.30.1",cz(et),ee.fn=K,ee.min=ZR,ee.max=XR,ee.now=QR,ee.utc=nn,ee.un
|
|
|
123
123
|
Prefix can't start with '-' when allowNegative is true.
|
|
124
124
|
prefix: `+s+`
|
|
125
125
|
allowNegative: `+a+`
|
|
126
|
-
`),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function CG(e){e=kG(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,s=e.onKeyDown;s===void 0&&(s=G0);var a=e.onBlur;a===void 0&&(a=G0);var o=e.thousandSeparator,i=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l="");var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,h=e.onValueChange,y=cG(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),g=Fu(e),E=g.decimalSeparator,v=g.allowedDecimalSeparators,w=function(P){return K2(P,e)},A=function(P,O){return vG(P,O,e)},C=ho(d)?u:d,D=f??wG(C,l,t);ho(d)?ho(u)||(D=D||typeof u=="number"):D=D||typeof d=="number";var z=function(P){return $2(P)?P:(typeof P=="number"&&(P=W2(P)),D&&typeof i=="number"?q2(P,i,!!c):P)},T=yG(z(d),z(u),!!D,w,A,h),m=T[0],b=m.numAsString,x=m.formattedValue,S=T[1],I=function(P){var O=P.target,U=P.key,L=O.selectionStart,H=O.selectionEnd,G=O.value;if(G===void 0&&(G=""),(U==="Backspace"||U==="Delete")&&H<l.length){P.preventDefault();return}if(L!==H){s(P);return}U==="Backspace"&&G[0]==="-"&&L===l.length+1&&r&&ac(O,1),i&&c&&(U==="Backspace"&&G[L-1]===E?(ac(O,L-1),P.preventDefault()):U==="Delete"&&G[L]===E&&P.preventDefault()),v!=null&&v.includes(U)&&G[L]===E&&ac(O,L+1);var Q=o===!0?",":o;U==="Backspace"&&G[L-1]===Q&&ac(O,L-1),U==="Delete"&&G[L]===Q&&ac(O,L+1),s(P)},F=function(P){var O=b;if(O.match(/\d/g)||(O=""),n||(O=hG(O)),c&&i&&(O=q2(O,i,c)),O!==b){var U=K2(O,e);S({formattedValue:U,value:O,floatValue:parseFloat(O)},{event:P,source:$0.event})}a(P)},_=function(P){return P===E?!0:H2(P)},k=function(P){var O=P.currentValue,U=P.lastValue,L=P.formattedValue,H=P.currentValueIndex,G=P.formattedValueIndex,Q=O[H],pe=L[G],me=mG(U,O),ie=me.to,de=function(Be){return A(Be).indexOf(".")+l.length};return d===0&&c&&i&&O[ie.start]===E&&de(O)<H&&de(L)>G?!1:H>=ie.start&&H<ie.end&&v&&v.includes(Q)&&pe===E?!0:Q===pe};return Object.assign(Object.assign({},y),{value:x,valueIsNumericString:!1,isValidInputCharacter:_,isCharacterSame:k,onValueChange:S,format:w,removeFormatting:A,getCaretBoundary:function(P){return EG(P,e)},onKeyDown:I,onBlur:F})}const Y2=(e,t)=>M.useMemo(()=>Bl(t,e),[e,t]),Rn=(e,t)=>M.useMemo(()=>Ii(t,e),[e,t]),oc=()=>{const{chainId:e}=oe();return M.useMemo(()=>Bs(e),[e])},V0=e=>{const t=oc();return M.useMemo(()=>{if(!(!e||!t))return Bi(e,t.id)},[e,t])},aa=(e,t)=>M.useMemo(()=>!e||!t||j(e||"0").isZero()||j(t||"0").isZero()?"":j(e||"0").times(t).toFixed(),[e,t]),TG=()=>{const{srcToken:e,dstToken:t,chainId:r}=oe();return M.useMemo(()=>Lf(e,t,r),[e,t,r])},AG=()=>{const{srcToken:e,dstToken:t,chainId:r}=oe();return M.useMemo(()=>zf(e,t,r),[e,t,r])},SG=()=>{const e=TG(),t=AG();return e||t},W0=e=>{const{overrides:t}=oe();return M.useMemo(()=>t!=null&&t.dateFormat?t.dateFormat(e||0):ee(e).format("DD/MM/YYYY HH:mm"),[e,t==null?void 0:t.dateFormat])};function PG(){const{callbacks:e}=oe();return M.useCallback(async t=>{var r;try{await navigator.clipboard.writeText(t),(r=e==null?void 0:e.onCopy)==null||r.call(e)}catch(n){console.error("Copy failed:",n)}},[e==null?void 0:e.onCopy])}const Z2=(e,t)=>M.useMemo(()=>_f(e==null?void 0:e.toString(),t),[e,t]),Ze=({value:e,decimalScale:t=3,prefix:r,suffix:n})=>{var c;const s=Z2(e,t),{overrides:a}=oe(),o=a==null?void 0:a.numberFormat,i=CG({allowLeadingZeros:!0,thousandSeparator:",",displayType:"text",value:s||"",decimalScale:18,prefix:r,suffix:n});return o?o(e||""):(c=i.value)==null?void 0:c.toString()},IG={expirationTooltip:"This is the date and time marking the end of the period which you have selected for your order to be executed.",tradeSizeTooltip:"The number of input tokens that will be removed from your balance and swapped for the output token in each individual trade.",totalTradesTooltip:"The total number of individual trades that will be scheduled as part of your order. Note that in limit orders, not all trades that are scheduled will be executed.",minDstAmountTooltip:" This is the minimum number of tokens that may be received. NOTE: This minimum only refers to executed trades. Some trades may not be executed if the limit price is higher than the available market prices and your order may only be partially filled.",limitPriceTooltip:"Trades will only execute if the available market price is better than the limit price, potentially resulting in partial fills or orders remaining unfilled upon expiration.",maxDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, partially filled, or remain unfilled based on the specified parameters.",tradeIntervalTooltip:"The estimated time that will elapse between each trade in your order. Note that as this time includes an allowance of two minutes for bidder auction and block settlement, which cannot be predicted exactly, actual time may vary.",triggerPriceTooltip:"The price at which the order will be executed. If the market price is higher than the trigger price, the order will be executed at the market price.",placeOrder:"Place order",enterAmount:"Enter an amount",emptyLimitPrice:"Limit price is required",insufficientFunds:"Insufficient Balance",tradeIntervalLabel:"Trade interval",expirationLabel:"Expiration",limitPrice:"Limit Price",finalExcecutionPrice:"Final execution price",marketPrice:"Market price",from:"From",to:"To (estimated)",Open:"Open",Completed:"Completed",Expired:"Expired",Canceled:"Canceled",cancelOrder:"Cancel Order",minReceivedPerTrade:"Min. received per trade",triggerPricePerChunk:"Trigger Price per trade",maxChunksError:"Max. trades amount is {maxChunks}",minChunksError:"Min. trades amount is {minChunks}",minTradeSizeError:"Min. trade size is ${minTradeSize}",allOrders:"All",minFillDelayError:"Min. trade interval is {fillDelay}",maxFillDelayError:"Max. trade interval is {fillDelay}",recipient:"Recipient",marketOrderWarning:"Each individual trade in this order will be filled at the current market price at the time of execution.",limitPriceMessage:"Limit orders may not execute when the token's price is equal or close to the limit price, due to gas and standard swap fees.",limit:"Limit",maxDurationError:"Max. expiry is {duration}",minDurationError:"Min. expiry is {duration}",expiry:"Expiry",individualTradeSize:"Individual trade size",numberOfTrades:"No. of trades",averageExecutionPrice:"Avg. execution price",twapMarket:"TWAP-market",twapLimit:"TWAP-limit",stopLoss:"Stop-loss",stopLossMarket:"Stop-loss market",stopLossLimit:"Stop-loss limit",takeProfit:"Take-profit",minReceived:"Min. received",noOrders:"No {status} Orders",noLiquidity:"No liquidity for this pair",excecutionSummary:"Execution summary",orderInfo:"Order info",wrapAction:"Wrap {symbol}",approveAction:"Approve {symbol}",createOrderAction:"Create {name} order",amountReceived:"Amount received",createdAt:"Created at",amountOut:"Amount out",status:"Status",progress:"Progress",minutes:"minutes",days:"days",tradeIntervalTitle:"Every",tradesAmountTitle:"Over",stopLossTooltip:"The trigger price at which your stop-loss order will be activated.",takeProfitTooltip:"The trigger price at which your take-profit order will be activated.",stopLossLabel:"Trigger Price",StopLossTriggerPriceError:"Trigger price must be less than market price",TakeProfitTriggerPriceError:"Trigger price must be greater than market price",triggerLimitPriceError:"Limit price must be less than trigger price",triggerPrice:"Trigger Price",tradePrice:"Trade Price",triggerMarketPriceDisclaimer:" In extreme market movements, slippage may occur and the executed price of the market order may be worse than the specified trigger price.",stopLossLimitPriceTooltip:"The stop loss order will execute at the specified limit price or better, once the stop price is triggered.",stopLossDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, or remain unfilled based on the specified parameters.",emptyTriggerPrice:"Trigger price is required",id:"ID",fees:"Fees {value}",version:"Version",maxOrderSizeError:"Max. trade size is {maxOrderSize} USD",viewOnExplorer:"View on explorer",proceedInWallet:"Proceed in wallet",wrapMsg:"Note: {symbol} was wrapped to {wSymbol}",createOrderActionSuccess:"{name} order placed"};function BG(e){let t=e;const r=/\{[^{}]*\}/g;for(;r.test(t);)t=t.replace(r,"");return t}const Me=()=>{const e=oe();return M.useCallback((r,n)=>{var o,i;const s=(o=e.getTranslation)==null?void 0:o.call(e,r,n);if(s&&s!==r)return s;const a=((i=e.translations)==null?void 0:i[r])||IG[r];return BG(a.replace(/{(\w+)}/g,(c,l)=>(n==null?void 0:n[l])||c))},[e.getTranslation,e.translations])},Uu=({value:e})=>{const t=Ze({value:e,decimalScale:2});return t?B.jsx("small",{className:"twap-order-details__detail-row-value-usd",children:` ($${t})`}):null},FG=({deadline:e,label:t,tooltip:r})=>{const n=W0(e);return B.jsx(Ar,{title:t,tooltip:r,children:n})},UG=({price:e,dstToken:t,label:r,tooltip:n,usd:s,srcToken:a})=>{const o=Ze({value:e});return j(e||0).isZero()?null:B.jsx(Ar,{title:r,tooltip:n,children:B.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["1 ",a==null?void 0:a.symbol," = ",`${o||"-"} ${t==null?void 0:t.symbol}`,B.jsx(Uu,{value:s})]})})},OG=({tradeSize:e,srcToken:t,trades:r,label:n,tooltip:s})=>r===1?null:B.jsx(Ar,{title:n,tooltip:s,children:`${e||"-"} ${(t==null?void 0:t.symbol)||""}`}),DG=({dstToken:e,dstMinAmountOut:t,label:r,tooltip:n,usd:s})=>{const a=Ze({value:t});return j(t||0).isZero()?null:B.jsxs(Ar,{title:r,tooltip:n,children:[`${t?a:"-"} ${e==null?void 0:e.symbol}`,B.jsx(Uu,{value:s})]})},_G=({trades:e,label:t,tooltip:r})=>e===1?null:B.jsx(Ar,{title:t,tooltip:r,children:e}),MG=()=>{var s;const e=Me(),{account:t}=oe(),r=(s=oc())==null?void 0:s.explorer,n=Df(t);return B.jsx(Ar,{title:e("recipient")||"",children:r?B.jsx("a",{href:`${r}/address/${t}`,target:"_blank",children:n}):n})},NG=({fillDelayMillis:e,chunks:t=0,label:r,tooltip:n})=>{const s=M.useMemo(()=>t6(e),[e]);return t===1?null:B.jsx(Ar,{title:r,tooltip:n,children:s})},Ar=({title:e,tooltip:t,children:r,className:n="",onClick:s,style:a})=>{const{components:o}=oe(),i=o.Tooltip;return B.jsxs("div",{className:`${n} twap-order-details__detail-row`,onClick:s,style:a,children:[B.jsxs("div",{className:"twap-order-details__detail-row-label",children:[B.jsx("p",{className:"twap-order-details__detail-row-label-value",children:e}),t&&i&&B.jsx(i,{tooltipText:t})]}),B.jsx("div",{className:"twap-order-details__detail-row-value",children:r})]})},LG=({id:e})=>{const{components:t}=oe(),r=t==null?void 0:t.Tooltip,n=PG();return e.startsWith("0x")?B.jsx(Ar,{title:"ID",onClick:()=>n(e),style:{cursor:"pointer"},children:r&&B.jsx(r,{tooltipText:e,children:B.jsxs("div",{className:"twap-order-details__detail-row-value-id",children:[B.jsx("p",{children:Df(e)}),B.jsx(iz.AiOutlineCopy,{})]})})}):B.jsx(Ar,{title:"ID",children:e})},zG=({version:e})=>B.jsx(Ar,{title:"Version",children:e});function Ee({children:e,className:t=""}){return B.jsx("div",{className:`${t} twap-order-details`,children:e})}const RG=({children:e})=>e,HG=({fees:e,label:t,usd:r,dstTokenSymbol:n})=>{const s=Ze({value:e});return B.jsxs(Ar,{title:t,children:[`${e?s:"-"} ${n}`,B.jsx(Uu,{value:r})]})};Ee.Deadline=FG,Ee.Fees=HG,Ee.TradeSize=OG,Ee.MinDestAmount=DG,Ee.TradesAmount=_G,Ee.Recipient=MG,Ee.TradeInterval=NG,Ee.DetailRow=Ar,Ee.Price=UG,Ee.OrderID=LG,Ee.Container=RG,Ee.OrderVersion=zG,Ee.USD=Uu;const q0=()=>{const{publicClient:e}=oe();return Zr({mutationFn:async t=>{if(!e)throw new Error("publicClient is not defined");const r=10;let n=0,s=1e3;for(;n<r;)try{return await e.waitForTransactionReceipt({hash:t,confirmations:2,retryDelay:s})}catch(a){if(n++,n>=r)throw new Error(`Failed after ${r} attempts: ${a}`);await new Promise(o=>setTimeout(o,s)),s*=2}}}).mutateAsync},X2=e=>{const t=Me(),r=Ze({value:e.srcAmount}),n=Ze({value:e.limitPrice}),s=Ze({value:e.limitPriceUsd}),a=Ze({value:e.srcAmountPerTrade}),o=Ze({value:e.srcAmountPerTradeUsd,decimalScale:2}),i=Ze({value:e.minDestAmountPerTrade}),c=Ze({value:e.minDestAmountPerTradeUsd,decimalScale:2}),l=Ze({value:e.triggerPrice}),u=Ze({value:e.triggerPriceUsd,decimalScale:2}),d=Ze({value:e.srcUsd,decimalScale:2}),f=Ze({value:e.dstUsd,decimalScale:2}),h=Ze({value:e.dstAmount});return M.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,srcUsd:d||"",dstUsd:f||"",limitPrice:{label:t("limitPrice"),tooltip:t("limitPriceTooltip"),value:n||"",usd:s||""},deadline:{tooltip:t("expirationTooltip"),label:t("expirationLabel"),value:e.deadline||0},srcAmount:{label:t("amountOut"),value:r||"",usd:d||""},dstAmount:{value:h||"",usd:f||""},sizePerTrade:{tooltip:t("tradeSizeTooltip"),label:t("individualTradeSize"),value:a||"",usd:o},totalTrades:{tooltip:t("totalTradesTooltip"),label:t("numberOfTrades"),value:e.totalTrades||0},minDestAmountPerTrade:{tooltip:t("minDstAmountTooltip"),label:t(e.totalTrades&&e.totalTrades>1?"minReceivedPerTrade":"minReceived"),value:i||"",usd:c},tradeInterval:{tooltip:t("tradeIntervalTooltip"),label:t("tradeIntervalLabel"),value:e.tradeInterval||0},triggerPrice:{tooltip:t("triggerPriceTooltip"),label:t("triggerPrice"),value:l||"",usd:u},recipient:{label:t("recipient"),value:e.account||""}}),[d,f,n,r,a,o,i,l,u,n,s,h,f,c])},Q2=e=>{const{orders:t}=Ou(),{useToken:r,config:n}=oe(),s=Me(),a=M.useMemo(()=>t==null?void 0:t.all.find(C=>C.id===e),[t,e])||{},o=tx(a),i=r==null?void 0:r(a==null?void 0:a.srcTokenAddress),c=r==null?void 0:r(a==null?void 0:a.dstTokenAddress),l=Rn(i==null?void 0:i.decimals,a==null?void 0:a.srcAmount),u=jG(i,c,a),d=VG(i,c,a),f=WG(i,c,a),h=Rn(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountFilled),y=Rn(c==null?void 0:c.decimals,a==null?void 0:a.dstAmountFilled),g=a==null?void 0:a.progress,E=Rn(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountPerTrade),v=Rn(c==null?void 0:c.decimals,a==null?void 0:a.dstMinAmountPerTrade),w=M.useMemo(()=>a?a.version===2?a.fillDelay:n.twapConfig?td(a,n.twapConfig):0:0,[a,n]),A=X2({srcToken:i,dstToken:c,account:a==null?void 0:a.maker,limitPrice:u,deadline:a==null?void 0:a.deadline,tradeInterval:w,srcAmount:l,totalTrades:a==null?void 0:a.totalTradesAmount,srcAmountPerTrade:E,minDestAmountPerTrade:v,triggerPrice:d});return M.useMemo(()=>({original:a,title:o,...A,createdAt:{label:s("createdAt"),value:a==null?void 0:a.createdAt},id:{label:s("id"),value:a==null?void 0:a.id},amountInFilled:{label:s("amountOut"),value:h},amountOutFilled:{label:s("amountReceived"),value:y,token:c},progress:{label:s("progress"),value:g},excecutionPrice:{label:s((a==null?void 0:a.totalTradesAmount)===1?"finalExcecutionPrice":"averageExecutionPrice"),value:f},version:{label:s("version"),value:a==null?void 0:a.version}}),[a,s,f,h,y,g,o,i,c,A])},J2=e=>{const t=Me();return M.useMemo(()=>{switch(e){case ze.TWAP_MARKET:return t("twapMarket");case ze.TWAP_LIMIT:return t("twapLimit");case ze.STOP_LOSS_MARKET:return t("stopLossMarket");case ze.STOP_LOSS_LIMIT:return t("stopLossLimit");case ze.TAKE_PROFIT:return t("takeProfit");default:return t("twapMarket")}},[t,e])},$G=()=>{const{module:e}=oe(),t=te(r=>r.state.isMarketOrder);return M.useMemo(()=>e===ye.TWAP?t?ze.TWAP_MARKET:ze.TWAP_LIMIT:e===ye.LIMIT?t?ze.LIMIT:ze.TWAP_LIMIT:e===ye.STOP_LOSS?t?ze.STOP_LOSS_MARKET:ze.STOP_LOSS_LIMIT:e===ye.TAKE_PROFIT?ze.TAKE_PROFIT:ze.TWAP_MARKET,[e,t])},ex=()=>{const e=$G();return J2(e)},tx=e=>J2(e==null?void 0:e.type),rx=()=>{const{account:e,config:t,chainId:r}=oe();return M.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,r],[e,t,r])},GG=()=>{const{callbacks:e,refetchBalances:t}=oe(),r=Td(),n=rx();return M.useCallback(s=>{var c;const a=r.getQueryData(n);let o=!1;const i=[];a&&a.forEach(l=>{var d;const u=s.find(f=>f.id===l.id);!(u!=null&&u.twapAddress)&&l.twapAddress&&u&&u.progress!==l.progress&&(o=!0,i.push(u),u.status===ct.Completed&&((d=e==null?void 0:e.onOrderFilled)==null||d.call(e,u)))}),o&&((c=e==null?void 0:e.onOrdersProgressUpdate)==null||c.call(e,i),t==null||t())},[r,n,e,t])},K0=()=>{const{account:e,config:t,chainId:r}=oe(),n=rx(),s=GG();return d3({refetchInterval:QL,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:o})=>{if(!e||!r||!t)return[];const i=await _m({signal:o,chainId:r,config:t,account:e});return s(i),i.map(c=>t!=null&&t.twapConfig?{...c,fillDelayMillis:td(c,t.twapConfig)}:c)}})},Ou=()=>{const{data:e,isLoading:t,error:r,refetch:n,isRefetching:s}=K0(),{mutateAsync:a}=Y0();return M.useMemo(()=>({orders:{all:e??[],open:Du(e??[],ct.Open),completed:Du(e??[],ct.Completed),expired:Du(e??[],ct.Expired),canceled:Du(e??[],ct.Canceled)},isLoading:t,error:r,refetch:()=>n().then(o=>o.data),cancelOrder:a,isRefetching:s}),[e,t,r,n,a,s])},nx=()=>{const e=te(r=>r.state.orderHistoryStatusFilter),{orders:t}=Ou();return M.useMemo(()=>e?t.all.filter(r=>r.status.toLowerCase()===e.toLowerCase())||[]:t.all,[e,t])},Du=(e,t)=>e.filter(r=>r.status===t).sort((r,n)=>n.createdAt-r.createdAt),jG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return jh(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),VG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return Vh(r,e.decimals,t.decimals)},[r,e,t]),WG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return Gh(r,e.decimals,t.decimals)},[r,e,t]),sx=()=>{const e=te(r=>r.updateState),t=te(r=>r.state.orderIdsToCancel);return M.useCallback(r=>{t!=null&&t.includes(r)?e({orderIdsToCancel:t==null?void 0:t.filter(n=>n!==r)}):e({orderIdsToCancel:[...t||[],r]})},[e,t])},qG=()=>{var T,m;const e=Me(),{orders:t,isLoading:r,refetch:n,isRefetching:s}=Ou(),{mutateAsync:a,isPending:o}=Y0(),i=nx(),c=te(b=>b.updateState),l=te(b=>b.state.orderHistoryStatusFilter),u=te(b=>b.state.cancelOrdersMode),d=te(b=>b.state.orderIdsToCancel),f=M.useCallback(b=>c({cancelOrdersMode:b,orderIdsToCancel:[]}),[c]),h=M.useCallback(()=>c({selectedOrderID:void 0}),[c]),y=M.useCallback(b=>a({orders:b}),[a]),g=M.useCallback(b=>c({orderHistoryStatusFilter:b}),[]),E=M.useMemo(()=>{const b=Object.keys(ct).map(x=>({text:x,value:x}));return[{text:e("allOrders"),value:""},...b]},[e]),v=sx(),w=te(b=>b.state.selectedOrderID),A=Q2(w),C=M.useMemo(()=>t.all.filter(b=>d==null?void 0:d.includes(b.id)),[t,d]),D=M.useCallback(()=>c({orderIdsToCancel:t.open.map(b=>b.id)}),[c,t]),z=M.useCallback(b=>a({orders:[b]}).then(x=>(x==null?void 0:x[0])||""),[a]);return{refetch:n,onHideSelectedOrder:h,onCancelOrders:y,onCancelOrder:z,onSelectStatus:g,onToggleCancelOrdersMode:f,onSelectOrder:v,isRefetching:s,orders:t,ordersToDisplay:i,isLoading:r,selectedOrder:w?A:void 0,openOrdersCount:((T=t==null?void 0:t.open)==null?void 0:T.length)||0,isCancelOrdersLoading:o,selectedStatus:l||((m=E[0])==null?void 0:m.value)||"",statuses:E,cancelOrdersMode:u,ordersToCancel:C,onSelectAllOrdersToCancel:D}},KG=()=>{const{refetch:e}=K0();return Zr({mutationFn:async t=>{var r;for(;;){const n=(r=await e())==null?void 0:r.data;if(!n)throw new Error("orders not found");if(t.every(a=>{const o=n.find(i=>i.id===a);return(o==null?void 0:o.status)===ct.Canceled}))break;await new Promise(a=>setTimeout(a,1e3))}}})},Y0=()=>{const{account:e,walletClient:t,publicClient:r,config:n,callbacks:s,chainId:a}=oe(),o=q0(),i=KG().mutateAsync,c=te(d=>d.updateState),l=async d=>{dt.onCancelOrderRequest(d.map(f=>f.id.toString()),1);try{return(await Promise.all(d.map(h=>t.writeContract({account:e,address:h.twapAddress,abi:Lh,functionName:"cancel",args:[h.id],chain:t.chain}))))[0]}catch(f){throw dt.onCancelOrderError(f),f}},u=async d=>{var f;try{dt.onCancelOrderRequest(d.map(g=>g.hash),2);const h=await t.writeContract({account:e,address:n.repermit,abi:Nh,functionName:"cancel",args:[d.map(g=>g.hash)],chain:t.chain}),y=await o(h);if(!y)throw new Error("failed to get transaction receipt");if(y.status==="reverted")throw new Error("failed to cancel order");return dt.onCancelOrderSuccess(h),(f=s==null?void 0:s.onCancelOrderSuccess)==null||f.call(s,{orders:d,txHash:h,explorerUrl:Bi(h,a)}),y.transactionHash}catch(h){throw dt.onCancelOrderError(h),h}};return Zr({mutationFn:async({orders:d})=>{var f,h;if(!e||!t||!r||!n)throw new Error("missing required parameters");try{(f=s==null?void 0:s.onCancelOrderRequest)==null||f.call(s,d),c({cancelOrderStatus:ht.LOADING,cancelOrderTxHash:void 0,cancelOrderError:void 0});const y=d.filter(w=>w.version===1),g=d.filter(w=>w.version===2),[E,v]=await Promise.all([y.length?l(y):Promise.resolve(""),g.length?u(g):Promise.resolve("")]);return await i(d.map(w=>w.id)),c({cancelOrderStatus:ht.SUCCESS,orderIdsToCancel:[]}),[...E||[],v]}catch(y){console.error("cancel order error",y),(h=s==null?void 0:s.onCancelOrderFailed)==null||h.call(s,y),Mf(y)?c({cancelOrderStatus:void 0}):(c({cancelOrderStatus:ht.FAILED}),dt.onCancelOrderError(y))}}})},ax=M.createContext({}),zt=()=>M.useContext(ax),YG=()=>{const e=te(c=>c.state.selectedOrderID),t=Q2(e),r=Me(),[n,s]=M.useState("panel1"),{components:a}=oe(),o=a.TokenLogo;M.useEffect(()=>{s("panel1")},[t.id.value]);const i=c=>{s(n===c?!1:c)};return t?B.jsx(ax.Provider,{value:{order:t},children:B.jsxs("div",{className:"twap-orders__selected-order",children:[B.jsx(p1,{SrcTokenLogo:o&&B.jsx(o,{token:t.srcToken}),DstTokenLogo:o&&B.jsx(o,{token:t.dstToken}),fromTitle:r("from"),inToken:t.srcToken,toTitle:r("to"),outToken:t.dstToken}),B.jsx(Ee.Container,{children:B.jsxs("div",{className:"twap-orders__selected-order-bottom",children:[B.jsxs("div",{className:"twap-orders__selected-order-accordions",children:[B.jsx(ox,{title:r("excecutionSummary"),onClick:()=>i("panel1"),expanded:n==="panel1",children:B.jsx(sj,{})}),B.jsx(ox,{title:r("orderInfo"),expanded:n==="panel2",onClick:()=>i("panel2"),children:B.jsx(ZG,{})})]}),B.jsx(oj,{})]})})]})}):null},ox=({expanded:e,onClick:t,children:r,title:n})=>B.jsxs("div",{className:"twap-orders__selected-order-accordion",children:[B.jsxs("div",{onClick:t,className:"twap-orders__selected-order-accordion-trigger",children:[B.jsx("p",{children:n}),B.jsx(az.IoIosArrowDown,{style:{transform:e?"rotate(180deg)":"rotate(0deg)"}})]}),e&&B.jsx("div",{className:"twap-orders__selected-order-accordion-details",children:r})]}),ZG=()=>B.jsxs(Ee,{children:[B.jsx(nj,{}),B.jsx(ij,{}),B.jsx(ej,{}),B.jsx(cj,{}),B.jsx(XG,{}),B.jsx(QG,{}),B.jsx(JG,{}),B.jsx(tj,{}),B.jsx(rj,{}),B.jsx(fj,{}),B.jsx(Ee.Recipient,{})]}),XG=()=>{const{order:e}=zt();return B.jsx(Ee.TradeSize,{tradeSize:e.sizePerTrade.value,srcToken:e.srcToken,label:e.sizePerTrade.label,tooltip:e.sizePerTrade.tooltip,trades:e.totalTrades.value})},QG=()=>{const{order:e}=zt();return B.jsx(Ee.TradesAmount,{trades:e.totalTrades.value,label:e.totalTrades.label,tooltip:e.totalTrades.tooltip})},JG=()=>{const{order:e}=zt();return B.jsx(Ee.MinDestAmount,{dstToken:e.dstToken,dstMinAmountOut:e.minDestAmountPerTrade.value,label:e.minDestAmountPerTrade.label,tooltip:e.minDestAmountPerTrade.tooltip})},ej=()=>{const{order:e}=zt();return B.jsx(Ee.Deadline,{deadline:e.deadline.value,label:e.deadline.label,tooltip:e.deadline.tooltip})},tj=()=>{const{order:e}=zt();return B.jsx(Ee.TradeInterval,{fillDelayMillis:e.tradeInterval.value,chunks:e.totalTrades.value,label:e.tradeInterval.label,tooltip:e.tradeInterval.tooltip})},rj=()=>{const{order:e}=zt();return B.jsx(Ee.Price,{srcToken:e.srcToken,dstToken:e.dstToken,price:e.triggerPrice.value,label:e.triggerPrice.label,tooltip:e.triggerPrice.tooltip})},nj=()=>{const{order:e}=zt();return B.jsx(Ee.OrderID,{id:e.id.value||""})},sj=()=>B.jsxs(Ee,{children:[B.jsx(dj,{}),B.jsx(lj,{}),B.jsx(aj,{}),B.jsx(pj,{}),B.jsx(hj,{})]}),aj=()=>{var r;const{order:e}=zt(),t=Ze({value:e.amountOutFilled.value,decimalScale:3});return e.amountOutFilled.value?B.jsx(Ee.DetailRow,{title:e.amountOutFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.dstToken)==null?void 0:r.symbol]})}):null},oj=()=>{const{order:e}=zt(),t=Me(),{mutateAsync:r,isPending:n}=Y0(),{components:s}=oe(),a=s.Button,o=M.useCallback(async()=>r({orders:[e.original]}),[r,e]);return!e||e.original.status!==ct.Open||!a?null:B.jsx(a,{loading:n,onClick:o,disabled:n,className:"twap-cancel-order",text:t("cancelOrder"),children:t("cancelOrder")})},ij=()=>{const{order:e}=zt(),t=Me(),r=W0(e.createdAt.value);return B.jsx(Ee.DetailRow,{title:t("createdAt")||"",children:B.jsx("p",{children:r})})},cj=()=>{var n;const{order:e}=zt(),t=Me(),r=Ze({value:e.srcAmount.value,decimalScale:3});return B.jsx(Ee.DetailRow,{title:t("amountOut")||"",children:B.jsxs("p",{children:[r||0," ",(n=e.srcToken)==null?void 0:n.symbol]})})},lj=()=>{var r;const{order:e}=zt(),t=Ze({value:e.amountInFilled.value,decimalScale:3});return B.jsx(Ee.DetailRow,{title:e.amountInFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.srcToken)==null?void 0:r.symbol]})})},uj=()=>{const{order:e}=zt(),t=Me();return M.useMemo(()=>{switch(e.original.status){case ct.Open:return t("Open")||"";case ct.Completed:return t("Completed")||"";case ct.Expired:return t("Expired")||"";case ct.Canceled:return t("Canceled")||""}},[e.original.status,t])},dj=()=>{const e=Me(),t=uj();return B.jsx(Ee.DetailRow,{title:e("status")||"",children:B.jsx("p",{children:t})})},pj=()=>{const{order:e}=zt(),t=Ze({value:e.progress.value,decimalScale:2});return B.jsx(Ee.DetailRow,{title:e.progress.label,children:B.jsxs("p",{children:[t||0,"%"]})})},fj=()=>{const{order:e}=zt(),t=Me();return e.limitPrice.value?B.jsx(Ee.Price,{label:t("limitPrice")||"",price:e.limitPrice.value,srcToken:e.srcToken,dstToken:e.dstToken,tooltip:e.limitPrice.tooltip}):null},hj=()=>{const{order:e}=zt();return e.excecutionPrice.value?B.jsx(Ee.Price,{label:e.excecutionPrice.label,price:e.excecutionPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null};var Z0={},ix;function mj(){if(ix)return Z0;ix=1;var e=lu.GenIcon;return Z0.HiArrowRight=function(r){return e({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"}}]})(r)},Z0}var bj=mj();const _u=0,fs=1,mo=2,cx=4;function lx(e){return()=>e}function yj(e){e()}function ux(e,t){return r=>e(t(r))}function dx(e,t){return()=>e(t)}function gj(e,t){return r=>e(t,r)}function X0(e){return e!==void 0}function xj(...e){return()=>{e.map(yj)}}function bo(){}function Mu(e,t){return t(e),e}function wj(e,t){return t(e)}function tt(...e){return e}function je(e,t){return e(fs,t)}function Ce(e,t){e(_u,t)}function Q0(e){e(mo)}function at(e){return e(cx)}function ce(e,t){return je(e,gj(t,_u))}function Vr(e,t){const r=e(fs,n=>{r(),t(n)});return r}function px(e){let t,r;return n=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{n(t)},e)}}function fx(e,t){return e===t}function rt(e=fx){let t;return r=>n=>{e(t,n)||(t=n,r(n))}}function fe(e){return t=>r=>{e(r)&&t(r)}}function re(e){return t=>ux(t,e)}function cn(e){return t=>()=>{t(e)}}function W(e,...t){const r=vj(...t);return(n,s)=>{switch(n){case mo:Q0(e);return;case fs:return je(e,r(s))}}}function ln(e,t){return r=>n=>{r(t=e(t,n))}}function oa(e){return t=>r=>{e>0?e--:t(r)}}function Hn(e){let t=null,r;return n=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,n(t)},e))}}function Te(...e){const t=new Array(e.length);let r=0,n=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{const l=r;r=r|i,t[o]=c,l!==s&&r===s&&n&&(n(),n=null)})}),a=>o=>{const i=()=>{a([o].concat(t))};r===s?i():n=i}}function vj(...e){return t=>e.reduceRight(wj,t)}function Ej(e){let t,r;const n=()=>t==null?void 0:t();return function(s,a){switch(s){case fs:return a?r===a?void 0:(n(),r=a,t=je(e,a),t):(n(),bo);case mo:n(),r=null;return}}}function Y(e){let t=e;const r=Ue();return(n,s)=>{switch(n){case _u:t=s;break;case fs:{s(t);break}case cx:return t}return r(n,s)}}function Rt(e,t){return Mu(Y(t),r=>ce(e,r))}function Ue(){const e=[];return(t,r)=>{switch(t){case _u:e.slice().forEach(n=>{n(r)});return;case mo:e.splice(0,e.length);return;case fs:return e.push(r),()=>{const n=e.indexOf(r);n>-1&&e.splice(n,1)}}}}function mr(e){return Mu(Ue(),t=>ce(e,t))}function $e(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:kj(),singleton:r}}const kj=()=>Symbol();function Cj(e){const t=new Map,r=({constructor:n,dependencies:s,id:a,singleton:o})=>{if(o&&t.has(a))return t.get(a);const i=n(s.map(c=>r(c)));return o&&t.set(a,i),i};return r(e)}function Et(...e){const t=Ue(),r=new Array(e.length);let n=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{r[o]=c,n=n|i,n===s&&Ce(t,r)})}),function(a,o){switch(a){case mo:{Q0(t);return}case fs:return n===s&&o(r),je(t,o)}}}function he(e,t=fx){return W(e,rt(t))}function J0(...e){return function(t,r){switch(t){case mo:return;case fs:return xj(...e.map(n=>je(n,r)))}}}var nr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(nr||{});const Tj={0:"debug",3:"error",1:"log",2:"warn"},Aj=()=>typeof globalThis>"u"?window:globalThis,hs=$e(()=>{const e=Y(3);return{log:Y((t,r,n=1)=>{var s;const a=(s=Aj().VIRTUOSO_LOG_LEVEL)!=null?s:at(e);n>=a&&console[Tj[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function ia(e,t,r){return eh(e,t,r).callbackRef}function eh(e,t,r){const n=M.useRef(null);let s=o=>{};const a=M.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const i=()=>{const c=o[0].target;c.offsetParent!==null&&e(c)};r?i():requestAnimationFrame(i)}):null,[e,r]);return s=o=>{o&&t?(a==null||a.observe(o),n.current=o):(n.current&&(a==null||a.unobserve(n.current)),n.current=null)},{callbackRef:s,ref:n}}function Sj(e,t,r,n,s,a,o,i,c){const l=M.useCallback(u=>{const d=Pj(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const h=f.lastElementChild.dataset.viewportType==="window";let y;h&&(y=f.ownerDocument.defaultView);const g=o?i?o.scrollLeft:o.scrollTop:h?i?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,E=o?i?o.scrollWidth:o.scrollHeight:h?i?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,v=o?i?o.offsetWidth:o.offsetHeight:h?i?y.innerWidth:y.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:E,scrollTop:Math.max(g,0),viewportHeight:v}),a==null||a(i?hx("column-gap",getComputedStyle(u).columnGap,s):hx("row-gap",getComputedStyle(u).rowGap,s)),d!==null&&e(d)},[e,t,s,a,o,n,i]);return eh(l,r,c)}function Pj(e,t,r,n){const s=e.length;if(s===0)return null;const a=[];for(let o=0;o<s;o++){const i=e.item(o);if(i.dataset.index===void 0)continue;const c=parseInt(i.dataset.index),l=parseFloat(i.dataset.knownSize),u=t(i,r);if(u===0&&n("Zero-sized element, this should not happen",{child:i},nr.ERROR),u===l)continue;const d=a[a.length-1];a.length===0||d.size!==u||d.endIndex!==c-1?a.push({endIndex:c,size:u,startIndex:c}):a[a.length-1].endIndex++}return a}function hx(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}function mx(e,t,r){const n=M.useRef(null),s=M.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),u=l.width;let d,f;if(t){const h=t.getBoundingClientRect(),y=l.top-h.top;f=h.height-Math.max(0,y),d=y+t.scrollTop}else{const h=o.current.ownerDocument.defaultView;f=h.innerHeight-Math.max(0,l.top),d=l.top+h.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:a,ref:o}=eh(s,!0,r),i=M.useCallback(()=>{s(o.current)},[s,o]);return M.useEffect(()=>{var c;if(t){t.addEventListener("scroll",i);const l=new ResizeObserver(()=>{requestAnimationFrame(i)});return l.observe(t),()=>{t.removeEventListener("scroll",i),l.unobserve(t)}}else{const l=(c=o.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",i),l==null||l.addEventListener("resize",i),()=>{l==null||l.removeEventListener("scroll",i),l==null||l.removeEventListener("resize",i)}}},[i,t,o]),a}const Wt=$e(()=>{const e=Ue(),t=Ue(),r=Y(0),n=Ue(),s=Y(0),a=Ue(),o=Ue(),i=Y(0),c=Y(0),l=Y(0),u=Y(0),d=Ue(),f=Ue(),h=Y(!1),y=Y(!1),g=Y(!1);return ce(W(e,re(({scrollTop:E})=>E)),t),ce(W(e,re(({scrollHeight:E})=>E)),o),ce(t,s),{deviation:r,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:i,horizontalDirection:y,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:h,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),ic={lvl:0};function bx(e,t){const r=e.length;if(r===0)return[];let{index:n,value:s}=t(e[0]);const a=[];for(let o=1;o<r;o++){const{index:i,value:c}=t(e[o]);a.push({end:i-1,start:n,value:s}),n=i,s=c}return a.push({end:1/0,start:n,value:s}),a}function qe(e){return e===ic}function cc(e,t){if(!qe(e))return t===e.k?e.v:t<e.k?cc(e.l,t):cc(e.r,t)}function Wr(e,t,r="k"){if(qe(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const n=Wr(e.r,t,r);return n[0]===-1/0?[e.k,e.v]:n}return Wr(e.l,t,r)}function br(e,t,r){return qe(e)?xx(t,r,1):t===e.k?At(e,{k:t,v:r}):t<e.k?wx(At(e,{l:br(e.l,t,r)})):wx(At(e,{r:br(e.r,t,r)}))}function yo(){return ic}function go(e,t,r){if(qe(e))return[];const n=Wr(e,t)[0];return Ij(rh(e,n,r))}function th(e,t){if(qe(e))return ic;const{k:r,l:n,r:s}=e;if(t===r){if(qe(n))return s;if(qe(s))return n;{const[a,o]=gx(n);return Nu(At(e,{k:a,l:yx(n),v:o}))}}else return t<r?Nu(At(e,{l:th(n,t)})):Nu(At(e,{r:th(s,t)}))}function ca(e){return qe(e)?[]:[...ca(e.l),{k:e.k,v:e.v},...ca(e.r)]}function rh(e,t,r){if(qe(e))return[];const{k:n,l:s,r:a,v:o}=e;let i=[];return n>t&&(i=i.concat(rh(s,t,r))),n>=t&&n<=r&&i.push({k:n,v:o}),n<=r&&(i=i.concat(rh(a,t,r))),i}function Nu(e){const{l:t,lvl:r,r:n}=e;if(n.lvl>=r-1&&t.lvl>=r-1)return e;if(r>n.lvl+1){if(nh(t))return vx(At(e,{lvl:r-1}));if(!qe(t)&&!qe(t.r))return At(t.r,{l:At(t,{r:t.r.l}),lvl:r,r:At(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(nh(e))return sh(At(e,{lvl:r-1}));if(!qe(n)&&!qe(n.l)){const s=n.l,a=nh(s)?n.lvl-1:n.lvl;return At(s,{l:At(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:sh(At(n,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return xx(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function yx(e){return qe(e.r)?e.l:Nu(At(e,{r:yx(e.r)}))}function nh(e){return qe(e)||e.lvl>e.r.lvl}function gx(e){return qe(e.r)?[e.k,e.v]:gx(e.r)}function xx(e,t,r,n=ic,s=ic){return{k:e,l:n,lvl:r,r:s,v:t}}function wx(e){return sh(vx(e))}function vx(e){const{l:t}=e;return!qe(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function sh(e){const{lvl:t,r}=e;return!qe(r)&&!qe(r.r)&&r.lvl===t&&r.r.lvl===t?At(r,{l:At(e,{r:r.l}),lvl:t+1}):e}function Ij(e){return bx(e,({k:t,v:r})=>({index:t,value:r}))}function Ex(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function lc(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ah=$e(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function kx(e,t,r){return e[Lu(e,t,r)]}function Lu(e,t,r,n=0){let s=e.length-1;for(;n<=s;){const a=Math.floor((n+s)/2),o=e[a],i=r(o,t);if(i===0)return a;if(i===-1){if(s-n<2)return a-1;s=a-1}else{if(s===n)return a;n=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Bj(e,t,r,n){const s=Lu(e,t,n),a=Lu(e,r,n,s);return e.slice(s,a+1)}function ms(e,t){return Math.round(e.getBoundingClientRect()[t])}function zu(e){return!qe(e.groupOffsetTree)}function oh({index:e},t){return t===e?0:t<e?-1:1}function Fj(){return{groupIndices:[],groupOffsetTree:yo(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:yo()}}function Uj(e,t){let r=qe(e)?0:1/0;for(const n of t){const{endIndex:s,size:a,startIndex:o}=n;if(r=Math.min(r,o),qe(e)){e=br(e,0,a);continue}const i=go(e,o-1,s+1);if(i.some(zj(n)))continue;let c=!1,l=!1;for(const{end:u,start:d,value:f}of i)c?(s>=d||a===f)&&(e=th(e,d)):(l=f!==a,c=!0),u>s&&s>=d&&f!==a&&(e=br(e,s+1,f));l&&(e=br(e,o,a))}return[e,r]}function Oj(e){return typeof e.groupIndex<"u"}function Dj({offset:e},t){return t===e?0:t<e?-1:1}function uc(e,t,r){if(t.length===0)return 0;const{index:n,offset:s,size:a}=kx(t,e,oh),o=e-n,i=a*o+(o-1)*r+s;return i>0?i+r:i}function Cx(e,t){if(!zu(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function Tx(e,t,r){if(Oj(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?r:e.index;let s=Cx(n,t);return s=Math.max(0,s,Math.min(r,s)),s}}function _j(e,t,r,n=0){return n>0&&(t=Math.max(t,kx(e,n,oh).offset)),bx(Bj(e,t,r,Dj),Lj)}function Mj(e,[t,r,n,s]){t.length>0&&n("received item sizes",t,nr.DEBUG);const a=e.sizeTree;let o=a,i=0;if(r.length>0&&qe(a)&&t.length===2){const f=t[0].size,h=t[1].size;o=r.reduce((y,g)=>br(br(y,g,f),g+1,h),o)}else[o,i]=Uj(o,t);if(o===a)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=ih(e.offsetTree,i,o,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,h)=>br(f,h,uc(h,d,s)),yo()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Nj(e){return ca(e).map(({k:t,v:r},n,s)=>{const a=s[n+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function Ax(e,t){let r=0,n=0;for(;r<e;)r+=t[n+1]-t[n]-1,n++;return n-(r===e?0:1)}function ih(e,t,r,n){let s=e,a=0,o=0,i=0,c=0;if(t!==0){c=Lu(s,t-1,oh),i=s[c].offset;const l=Wr(r,t-1);a=l[0],o=l[1],s.length&&s[c].size===Wr(r,t)[1]&&(c-=1),s=s.slice(0,c+1)}else s=[];for(const{start:l,value:u}of go(r,t,1/0)){const d=l-a,f=d*o+i+d*n;s.push({index:l,offset:f,size:u}),a=l,i=f,o=u}return{lastIndex:a,lastOffset:i,lastSize:o,offsetTree:s}}function Lj(e){return{index:e.index,value:e}}function zj(e){const{endIndex:t,size:r,startIndex:n}=e;return s=>s.start===n&&(s.end===t||s.end===1/0)&&s.value===r}const Rj={offsetHeight:"height",offsetWidth:"width"},un=$e(([{log:e},{recalcInProgress:t}])=>{const r=Ue(),n=Ue(),s=Rt(n,0),a=Ue(),o=Ue(),i=Y(0),c=Y([]),l=Y(void 0),u=Y(void 0),d=Y(void 0),f=Y(void 0),h=Y((T,m)=>ms(T,Rj[m])),y=Y(void 0),g=Y(0),E=Fj(),v=Rt(W(r,Te(c,e,g),ln(Mj,E),rt()),E),w=Rt(W(c,rt(),ln((T,m)=>({current:m,prev:T.current}),{current:[],prev:[]}),re(({prev:T})=>T)),[]);ce(W(c,fe(T=>T.length>0),Te(v,g),re(([T,m,b])=>{const x=T.reduce((S,I,F)=>br(S,I,uc(I,m.offsetTree,b)||F),yo());return{...m,groupIndices:T,groupOffsetTree:x}})),v),ce(W(n,Te(v),fe(([T,{lastIndex:m}])=>T<m),re(([T,{lastIndex:m,lastSize:b}])=>[{endIndex:m,size:b,startIndex:T}])),r),ce(l,u);const A=Rt(W(l,re(T=>T===void 0)),!0);ce(W(u,fe(T=>T!==void 0&&qe(at(v).sizeTree)),re(T=>{const m=at(d),b=at(c).length>0;return m?b?[{endIndex:0,size:m,startIndex:0},{endIndex:1,size:T,startIndex:1}]:[]:[{endIndex:0,size:T,startIndex:0}]})),r),ce(W(f,fe(T=>T!==void 0&&T.length>0&&qe(at(v).sizeTree)),re(T=>{const m=[];let b=T[0],x=0;for(let S=1;S<T.length;S++){const I=T[S];I!==b&&(m.push({endIndex:S-1,size:b,startIndex:x}),b=I,x=S)}return m.push({endIndex:T.length-1,size:b,startIndex:x}),m})),r),ce(W(c,Te(d,u),fe(([,T,m])=>T!==void 0&&m!==void 0),re(([T,m,b])=>{const x=[];for(let S=0;S<T.length;S++){const I=T[S],F=T[S+1];x.push({startIndex:I,endIndex:I,size:m}),F!==void 0&&x.push({startIndex:I+1,endIndex:F-1,size:b})}return x})),r);const C=mr(W(r,Te(v),ln(({sizes:T},[m,b])=>({changed:b!==T,sizes:b}),{changed:!1,sizes:E}),re(T=>T.changed)));je(W(i,ln((T,m)=>({diff:T.prev-m,prev:m}),{diff:0,prev:0}),re(T=>T.diff)),T=>{const{groupIndices:m}=at(v);if(T>0)Ce(t,!0),Ce(a,T+Ax(T,m));else if(T<0){const b=at(w);b.length>0&&(T-=Ax(-T,b)),Ce(o,T)}}),je(W(i,Te(e)),([T,m])=>{T<0&&m("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},nr.ERROR)});const D=mr(a);ce(W(a,Te(v),re(([T,m])=>{const b=m.groupIndices.length>0,x=[],S=m.lastSize;if(b){const I=cc(m.sizeTree,0);let F=0,_=0;for(;F<T;){const P=m.groupIndices[_],O=m.groupIndices.length===_+1?1/0:m.groupIndices[_+1]-P-1;x.push({endIndex:P,size:I,startIndex:P}),x.push({endIndex:P+1+O-1,size:S,startIndex:P+1}),_++,F+=O+1}const k=ca(m.sizeTree);return F!==T&&k.shift(),k.reduce((P,{k:O,v:U})=>{let L=P.ranges;return P.prevSize!==0&&(L=[...P.ranges,{endIndex:O+T-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:O+T,prevSize:U,ranges:L}},{prevIndex:T,prevSize:0,ranges:x}).ranges}return ca(m.sizeTree).reduce((I,{k:F,v:_})=>({prevIndex:F+T,prevSize:_,ranges:[...I.ranges,{endIndex:F+T-1,size:I.prevSize,startIndex:I.prevIndex}]}),{prevIndex:0,prevSize:S,ranges:[]}).ranges})),r);const z=mr(W(o,Te(v,g),re(([T,{offsetTree:m},b])=>{const x=-T;return uc(x,m,b)})));return ce(W(o,Te(v,g),re(([T,m,b])=>{if(m.groupIndices.length>0){if(qe(m.sizeTree))return m;let x=yo();const S=at(w);let I=0,F=0,_=0;for(;I<-T;){_=S[F];const k=S[F+1]-_-1;F++,I+=k+1}if(x=ca(m.sizeTree).reduce((k,{k:P,v:O})=>br(k,Math.max(0,P+T),O),x),I!==-T){const k=cc(m.sizeTree,_);x=br(x,0,k);const P=Wr(m.sizeTree,-T+1)[1];x=br(x,1,P)}return{...m,sizeTree:x,...ih(m.offsetTree,0,x,b)}}else{const x=ca(m.sizeTree).reduce((S,{k:I,v:F})=>br(S,Math.max(0,I+T),F),yo());return{...m,sizeTree:x,...ih(m.offsetTree,0,x,b)}}})),v),{beforeUnshiftWith:D,data:y,defaultItemSize:u,firstItemIndex:i,fixedItemSize:l,fixedGroupSize:d,gap:g,groupIndices:c,heightEstimates:f,itemSize:h,listRefresh:C,shiftWith:o,shiftWithOffset:z,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:n,trackItemSizes:A,unshiftWith:a}},tt(hs,ah),{singleton:!0});function Hj(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const Sx=$e(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:n,scrollTop:s}])=>{const a=Ue(),o=Ue(),i=mr(W(a,re(Hj)));return ce(W(i,re(c=>c.totalCount)),r),ce(W(i,re(c=>c.groupIndices)),e),ce(W(Et(s,t,n),fe(([c,l])=>zu(l)),re(([c,l,u])=>Wr(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),rt(),re(c=>[c])),o),{groupCounts:a,topItemsIndexes:o}},tt(un,Wt)),bs=$e(([{log:e}])=>{const t=Y(!1),r=mr(W(t,fe(n=>n),rt()));return je(t,n=>{n&&at(e)("props updated",{},nr.DEBUG)}),{didMount:r,propsReady:t}},tt(hs),{singleton:!0}),$j=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Px(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!$j)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const dc=$e(([{gap:e,listRefresh:t,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:o,headerHeight:i,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{const h=Ue(),y=Ue(),g=Y(0);let E=null,v=null,w=null;function A(){E&&(E(),E=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Ce(c,!1)}return ce(W(h,Te(r,d,n,g,i,o,f),Te(e,a,s),re(([[C,D,z,T,m,b,x,S],I,F,_])=>{const k=Px(C),{align:P,behavior:O,offset:U}=k,L=T-1,H=Tx(k,D,L);let G=uc(H,D.offsetTree,I)+b;P==="end"?(G+=F+Wr(D.sizeTree,H)[1]-z+_,H===L&&(G+=x)):P==="center"?G+=(F+Wr(D.sizeTree,H)[1]-z+_)/2:G-=m,U&&(G+=U);const Q=pe=>{A(),pe?(S("retrying to scroll to",{location:C},nr.DEBUG),Ce(h,C)):(Ce(y,!0),S("list did not change, scroll successful",{},nr.DEBUG))};if(A(),O==="smooth"){let pe=!1;w=je(t,me=>{pe=pe||me}),E=Vr(u,()=>{Q(pe)})}else E=Vr(W(t,Gj(150)),Q);return v=setTimeout(()=>{A()},1200),Ce(c,!0),S("scrolling from index to",{behavior:O,index:H,top:G},nr.DEBUG),{behavior:O,top:G}})),l),{scrollTargetReached:y,scrollToIndex:h,topListHeight:g}},tt(un,Wt,hs),{singleton:!0});function Gj(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(r))}}}function ch(e,t){e==0?t():requestAnimationFrame(()=>{ch(e-1,t)})}function lh(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const pc=$e(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:n},{scrollTargetReached:s,scrollToIndex:a},{didMount:o}])=>{const i=Y(!0),c=Y(0),l=Y(!0);return ce(W(o,Te(c),fe(([u,d])=>!!d),cn(!1)),i),ce(W(o,Te(c),fe(([u,d])=>!!d),cn(!1)),l),je(W(Et(t,o),Te(i,r,e,l),fe(([[,u],d,{sizeTree:f},h,y])=>u&&(!qe(f)||X0(h))&&!d&&!y),Te(c)),([,u])=>{Vr(s,()=>{Ce(l,!0)}),ch(4,()=>{Vr(n,()=>{Ce(i,!0)}),Ce(a,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:i}},tt(un,Wt,dc,bs),{singleton:!0});function Ix(e,t){return Math.abs(e-t)<1.01}const fc="up",hc="down",jj="none",Vj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Wj=0,mc=$e(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:n,scrollTop:s,viewportHeight:a}])=>{const o=Y(!1),i=Y(!0),c=Ue(),l=Ue(),u=Y(4),d=Y(Wj),f=Rt(W(J0(W(he(s),oa(1),cn(!0)),W(he(s),oa(1),cn(!1),px(100))),rt()),!1),h=Rt(W(J0(W(r,cn(!0)),W(r,cn(!1),px(200))),rt()),!1);ce(W(Et(he(s),he(d)),re(([w,A])=>w<=A),rt()),i),ce(W(i,Hn(50)),l);const y=mr(W(Et(n,he(a),he(t),he(e),he(u)),ln((w,[{scrollHeight:A,scrollTop:C},D,z,T,m])=>{const b=C+D-A>-m,x={scrollHeight:A,scrollTop:C,viewportHeight:D};if(b){let I,F;return C>w.state.scrollTop?(I="SCROLLED_DOWN",F=w.state.scrollTop-C):(I="SIZE_DECREASED",F=w.state.scrollTop-C||w.scrollTopDelta),{atBottom:!0,atBottomBecause:I,scrollTopDelta:F,state:x}}let S;return x.scrollHeight>w.state.scrollHeight?S="SIZE_INCREASED":D<w.state.viewportHeight?S="VIEWPORT_HEIGHT_DECREASING":C<w.state.scrollTop?S="SCROLLING_UPWARDS":S="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:S,state:x}},Vj),rt((w,A)=>w&&w.atBottom===A.atBottom))),g=Rt(W(n,ln((w,{scrollHeight:A,scrollTop:C,viewportHeight:D})=>{if(Ix(w.scrollHeight,A))return{changed:!1,jump:0,scrollHeight:A,scrollTop:C};{const z=A-(C+D)<1;return w.scrollTop!==C&&z?{changed:!0,jump:w.scrollTop-C,scrollHeight:A,scrollTop:C}:{changed:!0,jump:0,scrollHeight:A,scrollTop:C}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),re(w=>w.jump)),0);ce(W(y,re(w=>w.atBottom)),o),ce(W(o,Hn(50)),c);const E=Y(hc);ce(W(n,re(({scrollTop:w})=>w),rt(),ln((w,A)=>at(h)?{direction:w.direction,prevScrollTop:A}:{direction:A<w.prevScrollTop?fc:hc,prevScrollTop:A},{direction:hc,prevScrollTop:0}),re(w=>w.direction)),E),ce(W(n,Hn(50),cn(jj)),E);const v=Y(0);return ce(W(f,fe(w=>!w),cn(0)),v),ce(W(s,Hn(100),Te(f),fe(([w,A])=>!!A),ln(([w,A],[C])=>[A,C],[0,0]),re(([w,A])=>A-w)),v),{atBottomState:y,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:g,scrollDirection:E,scrollVelocity:v}},tt(Wt)),bc="top",yc="bottom",Bx="none";function Fx(e,t,r){return typeof e=="number"?r===fc&&t===bc||r===hc&&t===yc?e:0:r===fc?t===bc?e.main:e.reverse:t===yc?e.main:e.reverse}function Ux(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const uh=$e(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:n,viewportHeight:s}])=>{const a=Ue(),o=Y(0),i=Y(0),c=Y(0),l=Rt(W(Et(he(n),he(s),he(r),he(a,lc),he(c),he(o),he(t),he(e),he(i)),re(([u,d,f,[h,y],g,E,v,w,A])=>{const C=u-w,D=E+v,z=Math.max(f-C,0);let T=Bx;const m=Ux(A,bc),b=Ux(A,yc);return h-=w,h+=f+v,y+=f+v,y-=w,h>u+D-m&&(T=fc),y<u-z+d+b&&(T=hc),T!==Bx?[Math.max(C-f-Fx(g,bc,T)-m,0),C-z-v+d+Fx(g,yc,T)+b]:null}),fe(u=>u!=null),rt(lc)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:c,topListHeight:o,visibleRange:l}},tt(Wt),{singleton:!0});function qj(e,t,r){if(zu(t)){const n=Cx(e,t);return[{index:Wr(t.groupOffsetTree,n)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:n,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const dh={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ru(e,t,r,n,s,a){const{lastIndex:o,lastOffset:i,lastSize:c}=s;let l=0,u=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];u=g.offset+g.size}const d=r-o,f=i+d*c+(d-1)*n,h=l,y=f-u;return{bottom:u,firstItemIndex:a,items:Dx(e,s,a),offsetBottom:y,offsetTop:l,top:h,topItems:Dx(t,s,a),topListHeight:t.reduce((g,E)=>E.size+g,0),totalCount:r}}function Ox(e,t,r,n,s,a){let o=0;if(r.groupIndices.length>0)for(const u of r.groupIndices){if(u-o>=e)break;o++}const i=e+o,c=lh(t,i),l=Array.from({length:i}).map((u,d)=>({data:a[d+c],index:d+c,offset:0,size:0}));return Ru(l,[],i,s,r,n)}function Dx(e,t,r){if(e.length===0)return[];if(!zu(t))return e.map(l=>({...l,index:l.index+r,originalIndex:l.index}));const n=e[0].index,s=e[e.length-1].index,a=[],o=go(t.groupOffsetTree,n,s);let i,c=0;for(const l of e){(!i||i.end<l.index)&&(i=o.shift(),c=t.groupIndices.indexOf(i.start));let u;l.index===i.start?u={index:c,type:"group"}:u={groupIndex:c,index:l.index-(c+1)+r},a.push({...u,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return a}function _x(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const la=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n,totalCount:s},a,{listBoundary:o,topListHeight:i,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:h},{recalcInProgress:y}])=>{const g=Y([]),E=Y(0),v=Ue(),w=Y(0);ce(a.topItemsIndexes,g);const A=Rt(W(Et(h,y,he(c,lc),he(s),he(n),he(l),u,he(g),he(t),he(r),he(w),e),fe(([T,m,,b,,,,,,,,x])=>{const S=x&&x.length!==b;return T&&!m&&!S}),re(([,,[T,m],b,x,S,I,F,_,k,P,O])=>{var U,L,H,G;const Q=x,{offsetTree:pe,sizeTree:me}=Q,ie=at(E);if(b===0)return{...dh,totalCount:b};if(T===0&&m===0)return ie===0?{...dh,totalCount:b}:Ox(ie,S,x,_,k,O||[]);if(qe(me))return ie>0?null:Ru(qj(lh(S,b),Q,O),[],b,k,Q,_);const de=[];if(F.length>0){const Ae=F[0],ve=F[F.length-1];let be=0;for(const Xe of go(me,Ae,ve)){const Ke=Xe.value,Qe=Math.max(Xe.start,Ae),Br=Math.min(Xe.end,ve);for(let Ot=Qe;Ot<=Br;Ot++)de.push({data:O==null?void 0:O[Ot],index:Ot,offset:be,size:Ke}),be+=Ke}}if(!I)return Ru([],de,b,k,Q,_);const Be=F.length>0?F[F.length-1]+1:0,X=_j(pe,T,m,Be);if(X.length===0)return null;const we=b-1,De=Mu([],Ae=>{for(const ve of X){const be=ve.value;let Xe=be.offset,Ke=ve.start;const Qe=be.size;if(be.offset<T){Ke+=Math.floor((T-be.offset+k)/(Qe+k));const Ot=Ke-ve.start;Xe+=Ot*Qe+Ot*k}Ke<Be&&(Xe+=(Be-Ke)*Qe,Ke=Be);const Br=Math.min(ve.end,we);for(let Ot=Ke;Ot<=Br&&!(Xe>=m);Ot++)Ae.push({data:O==null?void 0:O[Ot],index:Ot,offset:Xe,size:Qe}),Xe+=Qe+k}}),Ge=_x(P,bc),it=_x(P,yc);if(De.length>0&&(Ge>0||it>0)){const Ae=De[0],ve=De[De.length-1];if(Ge>0&&Ae.index>Be){const be=Math.min(Ge,Ae.index-Be),Xe=[];let Ke=Ae.offset;for(let Qe=Ae.index-1;Qe>=Ae.index-be;Qe--){const Br=(L=(U=go(me,Qe,Qe)[0])==null?void 0:U.value)!=null?L:Ae.size;Ke-=Br+k,Xe.unshift({data:O==null?void 0:O[Qe],index:Qe,offset:Ke,size:Br})}De.unshift(...Xe)}if(it>0&&ve.index<we){const be=Math.min(it,we-ve.index);let Xe=ve.offset+ve.size+k;for(let Ke=ve.index+1;Ke<=ve.index+be;Ke++){const Qe=(G=(H=go(me,Ke,Ke)[0])==null?void 0:H.value)!=null?G:ve.size;De.push({data:O==null?void 0:O[Ke],index:Ke,offset:Xe,size:Qe}),Xe+=Qe+k}}}return Ru(De,de,b,k,Q,_)}),fe(T=>T!==null),rt()),dh);ce(W(e,fe(X0),re(T=>T==null?void 0:T.length)),s),ce(W(A,re(T=>T.topListHeight)),d),ce(d,i),ce(W(A,re(T=>[T.top,T.bottom])),o),ce(W(A,re(T=>T.items)),v);const C=mr(W(A,fe(({items:T})=>T.length>0),Te(s,e),fe(([{items:T},m])=>T[T.length-1].originalIndex===m-1),re(([,T,m])=>[T-1,m]),rt(lc),re(([T])=>T))),D=mr(W(A,Hn(200),fe(({items:T,topItems:m})=>T.length>0&&T[0].originalIndex===m.length),re(({items:T})=>T[0].index),rt())),z=mr(W(A,fe(({items:T})=>T.length>0),re(({items:T})=>{let m=0,b=T.length-1;for(;T[m].type==="group"&&m<b;)m++;for(;T[b].type==="group"&&b>m;)b--;return{endIndex:T[b].index,startIndex:T[m].index}}),rt(Ex)));return{endReached:C,initialItemCount:E,itemsRendered:v,listState:A,minOverscanItemCount:w,rangeChanged:z,startReached:D,topItemsIndexes:g,...f}},tt(un,Sx,uh,pc,dc,mc,bs,ah),{singleton:!0}),Mx=$e(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:n},{listState:s}])=>{const a=Ue(),o=Rt(W(Et(r,e,n,t,s),re(([i,c,l,u,d])=>i+c+l+u+d.offsetBottom+d.bottom)),0);return ce(he(o),a),{totalListHeight:o,totalListHeightChanged:a}},tt(Wt,la),{singleton:!0}),Kj=$e(([{viewportHeight:e},{totalListHeight:t}])=>{const r=Y(!1),n=Rt(W(Et(r,e,t),fe(([s])=>s),re(([,s,a])=>Math.max(0,s-a)),Hn(0),rt()),0);return{alignToBottom:r,paddingTopAddition:n}},tt(Wt,Mx),{singleton:!0}),Nx=$e(()=>({context:Y(null)})),Yj=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:n,...s},viewportBottom:a,viewportTop:o})=>t<o?{...s,align:r??"start",behavior:n}:e>a?{...s,align:r??"end",behavior:n}:null,Lx=$e(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:o,scrollTop:i,viewportHeight:c},{scrollToIndex:l}])=>{const u=Ue();return ce(W(u,Te(t,c,r,a,s,n,i),Te(e),re(([[d,f,h,y,g,E,v,w],A])=>{const{align:C,behavior:D,calculateViewLocation:z=Yj,done:T,...m}=d,b=Tx(d,f,y-1),x=uc(b,f.offsetTree,A)+g+E,S=x+Wr(f.sizeTree,b)[1],I=w+E,F=w+h-v,_=z({itemBottom:S,itemTop:x,locationParams:{align:C,behavior:D,...m},viewportBottom:F,viewportTop:I});return _?T&&Vr(W(o,fe(k=>!k),oa(at(o)?1:2)),T):T&&T(),_}),fe(d=>d!==null)),l),{scrollIntoView:u}},tt(un,Wt,dc,la,hs),{singleton:!0});function zx(e){return e?e==="smooth"?"smooth":"auto":!1}const Zj=(e,t)=>typeof e=="function"?zx(e(t)):t&&zx(e),Xj=$e(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:n},{atBottomState:s,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:i},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:h}])=>{const y=Y(!1),g=Ue();let E=null;function v(D){Ce(o,{align:"end",behavior:D,index:"LAST"})}je(W(Et(W(he(t),oa(1)),c),Te(he(y),a,i,d),re(([[D,z],T,m,b,x])=>{let S=z&&b,I="auto";return S&&(I=Zj(T,m||x),S=S&&!!I),{followOutputBehavior:I,shouldFollow:S,totalCount:D}}),fe(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:z})=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("following output to ",{totalCount:z},nr.DEBUG),v(D)}):E=Vr(e,()=>{at(u)("following output to ",{totalCount:z},nr.DEBUG),v(D),E=null})});function w(D){const z=Vr(s,T=>{D&&!T.atBottom&&T.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(at(u)("scrolling to bottom due to increased size",{},nr.DEBUG),v("auto"))});setTimeout(z,100)}je(W(Et(he(y),t,l),fe(([D,,z])=>D&&z),ln(({value:D},[,z])=>({refreshed:D===z,value:z}),{refreshed:!1,value:0}),fe(({refreshed:D})=>D),Te(y,t)),([,D])=>{at(i)&&w(D!==!1)}),je(g,()=>{w(at(y)!==!1)}),je(Et(he(y),s),([D,z])=>{D&&!z.atBottom&&z.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const A=Y(null),C=Ue();return ce(J0(W(he(n),re(D=>{var z;return(z=D==null?void 0:D.length)!=null?z:0})),W(he(t))),C),je(W(Et(W(C,oa(1)),c),Te(he(A),i,d,f),re(([[D,z],T,m,b,x])=>z&&m&&(T==null?void 0:T({context:x,totalCount:D,scrollingInProgress:b}))),fe(D=>!!D),Hn(0)),D=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("scrolling into view",{}),Ce(h,D)}):E=Vr(e,()=>{at(u)("scrolling into view",{}),Ce(h,D),E=null})}),{autoscrollToBottom:g,followOutput:y,scrollIntoViewOnChange:A}},tt(un,mc,dc,pc,bs,hs,Wt,Nx,Lx)),Qj=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n},{initialTopMostItemIndex:s},{initialItemCount:a,listState:o},{didMount:i}])=>(ce(W(i,Te(a),fe(([,c])=>c!==0),Te(s,n,t,r,e),re(([[,c],l,u,d,f,h=[]])=>Ox(c,l,u,d,f,h))),o),{}),tt(un,pc,la,bs),{singleton:!0}),Jj=$e(([{didMount:e},{scrollTo:t},{listState:r}])=>{const n=Y(0);return je(W(e,Te(n),fe(([,s])=>s!==0),re(([,s])=>({top:s}))),s=>{Vr(W(r,oa(1),fe(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ce(t,s)})})}),{initialScrollTop:n}},tt(bs,Wt,la),{singleton:!0}),Rx=$e(([{scrollVelocity:e}])=>{const t=Y(!1),r=Ue(),n=Y(!1);return ce(W(e,Te(n,t,r),fe(([s,a])=>!!a),re(([s,a,o,i])=>{const{enter:c,exit:l}=a;if(o){if(l(s,i))return!1}else if(c(s,i))return!0;return o}),rt()),t),je(W(Et(t,e,r),Te(n)),([[s,a,o],i])=>{s&&i&&i.change&&i.change(a,o)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:r,scrollVelocity:e}},tt(mc),{singleton:!0}),ph=$e(([{scrollContainerState:e,scrollTo:t}])=>{const r=Ue(),n=Ue(),s=Ue(),a=Y(!1),o=Y(void 0);return ce(W(Et(r,n),re(([{scrollHeight:i,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),ce(W(t,Te(n),re(([i,{offsetTop:c}])=>({...i,top:i.top+c}))),s),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:n}},tt(Wt)),eV=$e(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:o,windowScrollContainerState:i,windowViewportRect:c}])=>{const l=Ue(),u=Y(void 0),d=Y(null),f=Y(null);return ce(i,d),ce(c,f),je(W(l,Te(t,n,o,d,f,r)),([h,y,g,E,v,w,A])=>{const C=Nj(y.sizeTree);E&&v!==null&&w!==null&&(g=v.scrollTop-w.offsetTop),g-=A,h({ranges:C,scrollTop:g})}),ce(W(u,fe(X0),re(tV)),s),ce(W(a,Te(u),fe(([,h])=>h!==void 0),rt(),re(([,h])=>h.ranges)),e),{getState:l,restoreStateFrom:u}},tt(un,Wt,pc,bs,ph));function tV(e){return{align:"start",index:0,offset:e.scrollTop}}const rV=$e(([{topItemsIndexes:e}])=>{const t=Y(0);return ce(W(t,fe(r=>r>=0),re(r=>Array.from({length:r}).map((n,s)=>s))),e),{topItemCount:t}},tt(la));function Hx(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const nV=Hx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),sV=$e(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:n},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:i},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:h},{recalcInProgress:y}])=>{const g=mr(W(c,Te(o),ln(([,v,w,A],[{bottom:C,items:D,offsetBottom:z,totalCount:T},m])=>{const b=C+z;let x=0;return w===T&&v.length>0&&D.length>0&&(D[0].originalIndex===0&&v[0].originalIndex===0||(x=b-A,x!==0&&(x+=m))),[x,D,T,b]},[0,[],0,0]),fe(([v])=>v!==0),Te(n,i,r,s,h,y),fe(([,v,w,A,,,C])=>!C&&!A&&v!==0&&w===fc),re(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},nr.DEBUG),v))));function E(v){v>0?(Ce(t,{behavior:"auto",top:-v}),Ce(e,0)):(Ce(e,0),Ce(t,{behavior:"auto",top:-v}))}return je(W(g,Te(e,a)),([v,w,A])=>{A&&nV()?Ce(e,w-v):E(-v)}),je(W(Et(Rt(a,!1),e,y),fe(([v,w,A])=>!v&&!A&&w!==0),re(([v,w])=>w),Hn(1)),E),ce(W(d,re(v=>({top:-v}))),t),je(W(l,Te(f,u),re(([v,{groupIndices:w,lastSize:A,sizeTree:C},D])=>{function z(T){return T*(A+D)}if(w.length===0)return z(v);{let T=0;const m=cc(C,0);let b=0,x=0;for(;b<v;){b++,T+=m;let S=w.length===x+1?1/0:w[x+1]-w[x]-1;b+S>v&&(T-=m,S=v-b+1),b+=S,T+=z(S),x++}return T}})),v=>{Ce(e,v),requestAnimationFrame(()=>{Ce(t,{top:v}),requestAnimationFrame(()=>{Ce(e,0),Ce(y,!1)})})}),{deviation:e}},tt(Wt,mc,la,un,hs,ah)),aV=$e(([e,t,r,n,s,a,o,i,c,l,u])=>({...e,...t,...r,...n,...s,...a,...o,...i,...c,...l,...u}),tt(uh,Qj,bs,Rx,Mx,Jj,Kj,ph,Lx,hs,Nx)),$x=$e(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:n,fixedGroupSize:s,gap:a,groupIndices:o,heightEstimates:i,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:h},{initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E},v,w,A,C,{scrollToIndex:D},z,{topItemCount:T},{groupCounts:m},b])=>{const{listState:x,minOverscanItemCount:S,topItemsIndexes:I,rangeChanged:F,..._}=C;return ce(F,b.scrollSeekRangeChanged),ce(W(b.windowViewportRect,re(k=>k.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:n,fixedGroupHeight:s,gap:a,groupCounts:m,heightEstimates:i,initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E,sizeRanges:l,topItemCount:T,topItemsIndexes:I,totalCount:f,...A,groupIndices:o,itemSize:c,listState:x,minOverscanItemCount:S,scrollToIndex:D,statefulTotalCount:d,trackItemSizes:h,rangeChanged:F,..._,...b,...v,sizes:u,...w}},tt(un,pc,Wt,eV,Xj,la,dc,sV,rV,Sx,aV));function oV(e,t){const r={},n={};let s=0;const a=e.length;for(;s<a;)n[e[s]]=1,s+=1;for(const o in t)Object.hasOwn(n,o)||(r[o]=t[o]);return r}const Hu=typeof document<"u"?M.useLayoutEffect:M.useEffect;function Gx(e,t,r){const n=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),i=M.createContext({});function c(E,v){E.propsReady&&Ce(E.propsReady,!1);for(const w of n){const A=E[t.required[w]];Ce(A,v[w])}for(const w of s)if(w in v){const A=E[t.optional[w]];Ce(A,v[w])}E.propsReady&&Ce(E.propsReady,!0)}function l(E){return a.reduce((v,w)=>(v[w]=A=>{const C=E[t.methods[w]];Ce(C,A)},v),{})}function u(E){return o.reduce((v,w)=>(v[w]=Ej(E[t.events[w]]),v),{})}const d=M.forwardRef((E,v)=>{const{children:w,...A}=E,[C]=M.useState(()=>Mu(Cj(e),T=>{c(T,A)})),[D]=M.useState(dx(u,C));Hu(()=>{for(const T of o)T in A&&je(D[T],A[T]);return()=>{Object.values(D).map(Q0)}},[A,D,C]),Hu(()=>{c(C,A)}),M.useImperativeHandle(v,lx(l(C)));const z=r;return B.jsx(i.Provider,{value:C,children:r?B.jsx(z,{...oV([...n,...s,...o],A),children:w}):w})}),f=E=>{const v=M.useContext(i);return M.useCallback(w=>{Ce(v[E],w)},[v,E])},h=E=>{const v=M.useContext(i)[E],w=M.useCallback(A=>je(v,A),[v]);return M.useSyncExternalStore(w,()=>at(v),()=>at(v))},y=E=>{const v=M.useContext(i)[E],[w,A]=M.useState(dx(at,v));return Hu(()=>je(v,C=>{C!==w&&A(lx(C))}),[v,w]),w},g=M.version.startsWith("18")?h:y;return{Component:d,useEmitter:(E,v)=>{const w=M.useContext(i)[E];Hu(()=>je(w,v),[v,w])},useEmitterValue:g,usePublisher:f}}const jx=M.createContext(void 0),Vx=M.createContext(void 0),Wx=typeof document<"u"?M.useLayoutEffect:M.useEffect;function fh(e){return"self"in e}function iV(e){return"body"in e}function qx(e,t,r,n=bo,s,a){const o=M.useRef(null),i=M.useRef(null),c=M.useRef(null),l=M.useCallback(f=>{let h,y,g;const E=f.target;if(iV(E)||fh(E)){const w=fh(E)?E:E.defaultView;g=a?w.scrollX:w.scrollY,h=a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,y=a?w.innerWidth:w.innerHeight}else g=a?E.scrollLeft:E.scrollTop,h=a?E.scrollWidth:E.scrollHeight,y=a?E.offsetWidth:E.offsetHeight;const v=()=>{e({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:y})};f.suppressFlushSync?v():As.flushSync(v),i.current!==null&&(g===i.current||g<=0||g===h-y)&&(i.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,a]);M.useEffect(()=>{const f=s||o.current;return n(s||o.current),l({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",l,{passive:!0}),()=>{n(null),f.removeEventListener("scroll",l)}},[o,l,r,n,s]);function u(f){const h=o.current;if(!h||(a?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const y=f.behavior==="smooth";let g,E,v;fh(h)?(E=Math.max(ms(h.document.documentElement,a?"width":"height"),a?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=a?h.innerWidth:h.innerHeight,v=a?window.scrollX:window.scrollY):(E=h[a?"scrollWidth":"scrollHeight"],g=ms(h,a?"width":"height"),v=h[a?"scrollLeft":"scrollTop"]);const w=E-g;if(f.top=Math.ceil(Math.max(Math.min(w,f.top),0)),Ix(g,E)||f.top===v){e({scrollHeight:E,scrollTop:v,viewportHeight:g}),y&&t(!0);return}y?(i.current=f.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,i.current=null,t(!0)},1e3)):i.current=null,a&&(f={behavior:f.behavior,left:f.top}),h.scrollTo(f)}function d(f){a&&(f={behavior:f.behavior,left:f.top}),o.current.scrollBy(f)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}const hh="-webkit-sticky",Kx="sticky",mh=Hx(()=>{if(typeof document>"u")return Kx;const e=document.createElement("div");return e.style.position=hh,e.style.position===hh?hh:Kx});function bh(e){return e}const cV=$e(()=>{const e=Y(i=>`Item ${i}`),t=Y(i=>`Group ${i}`),r=Y({}),n=Y(bh),s=Y("div"),a=Y(bo),o=(i,c=null)=>Rt(W(r,re(l=>l[i]),rt()),c);return{components:r,computeItemKey:n,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:t,HeaderComponent:o("Header"),HeaderFooterTag:s,ItemComponent:o("Item","div"),itemContent:e,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}),lV=$e(([e,t])=>({...e,...t}),tt($x,cV)),uV=({height:e})=>B.jsx("div",{style:{height:e}}),dV={overflowAnchor:"none",position:mh(),zIndex:1},Yx={overflowAnchor:"none"},pV={...Yx,display:"inline-block",height:"100%"},Zx=M.memo(function({showTopList:e=!1}){const t=ge("listState"),r=Sr("sizeRanges"),n=ge("useWindowScroll"),s=ge("customScrollParent"),a=Sr("windowScrollContainerState"),o=Sr("scrollContainerState"),i=s||n?a:o,c=ge("itemContent"),l=ge("context"),u=ge("groupContent"),d=ge("trackItemSizes"),f=ge("itemSize"),h=ge("log"),y=Sr("gap"),g=ge("horizontalDirection"),{callbackRef:E}=Sj(r,f,d,e?bo:i,h,y,s,g,ge("skipAnimationFrameInResizeObserver")),[v,w]=M.useState(0);yh("deviation",_=>{v!==_&&w(_)});const A=ge("EmptyPlaceholder"),C=ge("ScrollSeekPlaceholder")||uV,D=ge("ListComponent"),z=ge("ItemComponent"),T=ge("GroupComponent"),m=ge("computeItemKey"),b=ge("isSeeking"),x=ge("groupIndices").length>0,S=ge("alignToBottom"),I=ge("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:S?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:S?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...I?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&A?B.jsx(A,{...Ht(A,l)}):B.jsx(D,{...Ht(D,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:F,children:(e?t.topItems:t.items).map(_=>{const k=_.originalIndex,P=m(k+t.firstItemIndex,_.data,l);return b?M.createElement(C,{...Ht(C,l),height:_.size,index:_.index,key:P,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?M.createElement(T,{...Ht(T,l),"data-index":k,"data-item-index":_.index,"data-known-size":_.size,key:P,style:dV},u(_.index,l)):M.createElement(z,{...Ht(z,l),...bV(z,_.data),"data-index":k,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:P,style:g?pV:Yx},x?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),fV={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},hV={outline:"none",overflowX:"auto",position:"relative"},$u=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),mV={position:mh(),top:0,width:"100%",zIndex:1};function Ht(e,t){if(typeof e!="string")return{context:t}}function bV(e,t){return{item:typeof e=="string"?void 0:t}}const yV=M.memo(function(){const e=ge("HeaderComponent"),t=Sr("headerHeight"),r=ge("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,ge("skipAnimationFrameInResizeObserver")),s=ge("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null}),gV=M.memo(function(){const e=ge("FooterComponent"),t=Sr("footerHeight"),r=ge("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,ge("skipAnimationFrameInResizeObserver")),s=ge("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null});function Xx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("scrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("scrollerRef"),d=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:h,scrollToCallback:y}=qx(i,l,c,u,void 0,d);return e("scrollTo",y),e("scrollBy",f),B.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...d?hV:fV,...s},tabIndex:0,...o,...Ht(c,a),children:n})})}function Qx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("windowScrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("totalListHeight"),d=t("deviation"),f=t("customScrollParent"),h=M.useRef(null),y=t("scrollerRef"),{scrollByCallback:g,scrollerRef:E,scrollToCallback:v}=qx(i,l,c,y,f);return Wx(()=>{var w;return E.current=f||((w=h.current)==null?void 0:w.ownerDocument.defaultView),()=>{E.current=null}},[E,f]),e("windowScrollTo",v),e("scrollBy",g),B.jsx(c,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+d}:{}},...o,...Ht(c,a),children:n})})}const xV=({children:e})=>{const t=M.useContext(jx),r=Sr("viewportHeight"),n=Sr("fixedItemHeight"),s=ge("alignToBottom"),a=ge("horizontalDirection"),o=M.useMemo(()=>ux(r,c=>ms(c,a?"width":"height")),[r,a]),i=ia(o,!0,ge("skipAnimationFrameInResizeObserver"));return M.useEffect(()=>{t&&(r(t.viewportHeight),n(t.itemHeight))},[t,r,n]),B.jsx("div",{"data-viewport-type":"element",ref:i,style:$u(s),children:e})},wV=({children:e})=>{const t=M.useContext(jx),r=Sr("windowViewportRect"),n=Sr("fixedItemHeight"),s=ge("customScrollParent"),a=mx(r,s,ge("skipAnimationFrameInResizeObserver")),o=ge("alignToBottom");return M.useEffect(()=>{t&&(n(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,n]),B.jsx("div",{"data-viewport-type":"window",ref:a,style:$u(o),children:e})},vV=({children:e})=>{const t=ge("TopItemListComponent")||"div",r=ge("headerHeight"),n={...mV,marginTop:`${r}px`},s=ge("context");return B.jsx(t,{style:n,...Ht(t,s),children:e})},EV=M.memo(function(e){const t=ge("useWindowScroll"),r=ge("topItemsIndexes").length>0,n=ge("customScrollParent"),s=ge("context");return B.jsxs(n||t?TV:CV,{...e,context:s,children:[r&&B.jsx(vV,{children:B.jsx(Zx,{showTopList:!0})}),B.jsxs(n||t?wV:xV,{children:[B.jsx(yV,{}),B.jsx(Zx,{}),B.jsx(gV,{})]})]})}),{Component:kV,useEmitter:yh,useEmitterValue:ge,usePublisher:Sr}=Gx(lV,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},EV),CV=Xx({useEmitter:yh,useEmitterValue:ge,usePublisher:Sr}),TV=Qx({useEmitter:yh,useEmitterValue:ge,usePublisher:Sr}),AV=kV;tt($x,$e(()=>{const e=Y(l=>B.jsxs("td",{children:["Item $",l]})),t=Y(null),r=Y(l=>B.jsxs("td",{colSpan:1e3,children:["Group ",l]})),n=Y(null),s=Y(null),a=Y({}),o=Y(bh),i=Y(bo),c=(l,u=null)=>Rt(W(a,re(d=>d[l]),rt()),u);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:s,fixedHeaderContent:n,itemContent:e,groupContent:r,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),mh();const Jx={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},SV={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:e5,floor:Gu,max:gc,min:gh,round:t5}=Math;function r5(e,t,r){return Array.from({length:t-e+1}).map((n,s)=>({data:r===null?null:r[s+e],index:s+e}))}function PV(e){return{...SV,items:e}}function ju(e,t){return e&&e.width===t.width&&e.height===t.height}function IV(e,t){return e&&e.column===t.column&&e.row===t.row}const BV=$e(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:n},{footerHeight:s,headerHeight:a,scrollBy:o,scrollContainerState:i,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,h,{didMount:y,propsReady:g},{customScrollParent:E,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C},D])=>{const z=Y(0),T=Y(0),m=Y(Jx),b=Y({height:0,width:0}),x=Y({height:0,width:0}),S=Ue(),I=Ue(),F=Y(0),_=Y(null),k=Y({column:0,row:0}),P=Ue(),O=Ue(),U=Y(!1),L=Y(0),H=Y(!0),G=Y(!1),Q=Y(!1);je(W(y,Te(L),fe(([X,we])=>!!we)),()=>{Ce(H,!1)}),je(W(Et(y,H,x,b,L,G),fe(([X,we,De,Ge,,it])=>X&&!we&&De.height!==0&&Ge.height!==0&&!it)),([,,,,X])=>{Ce(G,!0),ch(1,()=>{Ce(S,X)}),Vr(W(l),()=>{Ce(t,[0,0]),Ce(H,!0)})}),ce(W(O,fe(X=>X!=null&&X.scrollTop>0),cn(0)),T),je(W(y,Te(O),fe(([,X])=>X!=null)),([,X])=>{X&&(Ce(b,X.viewport),Ce(x,X.item),Ce(k,X.gap),X.scrollTop>0&&(Ce(U,!0),Vr(W(l,oa(1)),we=>{Ce(U,!1)}),Ce(c,{top:X.scrollTop})))}),ce(W(b,re(({height:X})=>X)),d),ce(W(Et(he(b,ju),he(x,ju),he(k,(X,we)=>X&&X.column===we.column&&X.row===we.row),he(l)),re(([X,we,De,Ge])=>({gap:De,item:we,scrollTop:Ge,viewport:X}))),P),ce(W(Et(he(z),n,he(k,IV),he(x,ju),he(b,ju),he(_),he(T),he(U),he(H),he(L)),fe(([,,,,,,,X])=>!X),re(([X,[we,De],Ge,it,Ae,ve,be,,Xe,Ke])=>{const{column:Qe,row:Br}=Ge,{height:Ot,width:Ch}=it,{width:I5}=Ae;if(be===0&&(X===0||I5===0))return Jx;if(Ch===0){const D5=lh(Ke,X),MW=D5+Math.max(be-1,0);return PV(r5(D5,MW,ve))}const qu=n5(I5,Ch,Qe);let Fo,Ea;Xe?we===0&&De===0&&be>0?(Fo=0,Ea=be-1):(Fo=qu*Gu((we+Br)/(Ot+Br)),Ea=qu*e5((De+Br)/(Ot+Br))-1,Ea=gh(X-1,gc(Ea,qu-1)),Fo=gh(Ea,gc(0,Fo))):(Fo=0,Ea=-1);const B5=r5(Fo,Ea,ve),{bottom:F5,top:U5}=s5(Ae,Ge,it,B5),O5=e5(X/qu),_W=O5*Ot+(O5-1)*Br-F5;return{bottom:F5,itemHeight:Ot,items:B5,itemWidth:Ch,offsetBottom:_W,offsetTop:U5,top:U5}})),m),ce(W(_,fe(X=>X!==null),re(X=>X.length)),z),ce(W(Et(b,x,m,k),fe(([X,we,{items:De}])=>De.length>0&&we.height!==0&&X.height!==0),re(([X,we,{items:De},Ge])=>{const{bottom:it,top:Ae}=s5(X,Ge,we,De);return[Ae,it]}),rt(lc)),t);const pe=Y(!1);ce(W(l,Te(pe),re(([X,we])=>we||X!==0)),pe);const me=mr(W(Et(m,z),fe(([{items:X}])=>X.length>0),Te(pe),fe(([[X,we],De])=>{const Ge=X.items[X.items.length-1].index===we-1;return(De||X.bottom>0&&X.itemHeight>0&&X.offsetBottom===0&&X.items.length===we)&&Ge}),re(([[,X]])=>X-1),rt())),ie=mr(W(he(m),fe(({items:X})=>X.length>0&&X[0].index===0),cn(0),rt())),de=mr(W(he(m),Te(U),fe(([{items:X},we])=>X.length>0&&!we),re(([{items:X}])=>({endIndex:X[X.length-1].index,startIndex:X[0].index})),rt(Ex),Hn(0)));ce(de,h.scrollSeekRangeChanged),ce(W(S,Te(b,x,z,k),re(([X,we,De,Ge,it])=>{const Ae=Px(X),{align:ve,behavior:be,offset:Xe}=Ae;let Ke=Ae.index;Ke==="LAST"&&(Ke=Ge-1),Ke=gc(0,Ke,gh(Ge-1,Ke));let Qe=xh(we,it,De,Ke);return ve==="end"?Qe=t5(Qe-we.height+De.height):ve==="center"&&(Qe=t5(Qe-we.height/2+De.height/2)),Xe&&(Qe+=Xe),{behavior:be,top:Qe}})),c);const Be=Rt(W(m,re(X=>X.offsetBottom+X.bottom)),0);return ce(W(C,re(X=>({height:X.visibleHeight,width:X.visibleWidth}))),b),{customScrollParent:E,data:_,deviation:F,footerHeight:s,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:T,itemDimensions:x,overscan:r,restoreStateFrom:O,scrollBy:o,scrollContainerState:i,scrollHeight:I,scrollTo:c,scrollToIndex:S,scrollTop:l,smoothScrollTargetReached:u,totalCount:z,useWindowScroll:v,viewportDimensions:b,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C,...h,gridState:m,horizontalDirection:Q,initialTopMostItemIndex:L,totalListHeight:Be,...f,endReached:me,propsReady:g,rangeChanged:de,startReached:ie,stateChanged:P,stateRestoreInProgress:U,...D}},tt(uh,Wt,mc,Rx,bs,ph,hs));function n5(e,t,r){return gc(1,Gu((e+r)/(Gu(t)+r)))}function s5(e,t,r,n){const{height:s}=r;if(s===void 0||n.length===0)return{bottom:0,top:0};const a=xh(e,t,r,n[0].index);return{bottom:xh(e,t,r,n[n.length-1].index)+s,top:a}}function xh(e,t,r,n){const s=n5(e.width,r.width,t.column),a=Gu(n/s),o=a*r.height+gc(0,a-1)*t.row;return o>0?o+t.row:o}const FV=$e(()=>{const e=Y(d=>`Item ${d}`),t=Y({}),r=Y(null),n=Y("virtuoso-grid-item"),s=Y("virtuoso-grid-list"),a=Y(bh),o=Y("div"),i=Y(bo),c=(d,f=null)=>Rt(W(t,re(h=>h[d]),rt()),f),l=Y(!1),u=Y(!1);return ce(he(u),l),{components:t,computeItemKey:a,context:r,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:o,itemClassName:n,ItemComponent:c("Item","div"),itemContent:e,listClassName:s,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),UV=$e(([e,t])=>({...e,...t}),tt(BV,FV)),OV=M.memo(function(){const e=ot("gridState"),t=ot("listClassName"),r=ot("itemClassName"),n=ot("itemContent"),s=ot("computeItemKey"),a=ot("isSeeking"),o=Pr("scrollHeight"),i=ot("ItemComponent"),c=ot("ListComponent"),l=ot("ScrollSeekPlaceholder"),u=ot("context"),d=Pr("itemDimensions"),f=Pr("gap"),h=ot("log"),y=ot("stateRestoreInProgress"),g=Pr("reportReadyState"),E=ia(M.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;o(w);const A=v.firstChild;if(A){const{height:C,width:D}=A.getBoundingClientRect();d({height:C,width:D})}f({column:o5("column-gap",getComputedStyle(v).columnGap,h),row:o5("row-gap",getComputedStyle(v).rowGap,h)})},[o,d,f,h]),!0,!1);return Wx(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),y?null:B.jsx(c,{className:t,ref:E,...Ht(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const w=s(v.index,v.data,u);return a?B.jsx(l,{...Ht(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},w):M.createElement(i,{...Ht(i,u),className:r,"data-index":v.index,key:w},n(v.index,v.data,u))})})}),DV=M.memo(function(){const e=ot("HeaderComponent"),t=Pr("headerHeight"),r=ot("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,!1),s=ot("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null}),_V=M.memo(function(){const e=ot("FooterComponent"),t=Pr("footerHeight"),r=ot("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,!1),s=ot("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null}),MV=({children:e})=>{const t=M.useContext(Vx),r=Pr("itemDimensions"),n=Pr("viewportDimensions"),s=ia(M.useMemo(()=>a=>{n(a.getBoundingClientRect())},[n]),!0,!1);return M.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,n,r]),B.jsx("div",{ref:s,style:$u(!1),children:e})},NV=({children:e})=>{const t=M.useContext(Vx),r=Pr("windowViewportRect"),n=Pr("itemDimensions"),s=ot("customScrollParent"),a=mx(r,s,!1);return M.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,n]),B.jsx("div",{ref:a,style:$u(!1),children:e})},LV=M.memo(function({...e}){const t=ot("useWindowScroll"),r=ot("customScrollParent"),n=r||t?RV:zV,s=r||t?NV:MV,a=ot("context");return B.jsx(n,{...e,...Ht(n,a),children:B.jsxs(s,{children:[B.jsx(DV,{}),B.jsx(OV,{}),B.jsx(_V,{})]})})}),{useEmitter:a5,useEmitterValue:ot,usePublisher:Pr}=Gx(UV,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},LV),zV=Xx({useEmitter:a5,useEmitterValue:ot,usePublisher:Pr}),RV=Qx({useEmitter:a5,useEmitterValue:ot,usePublisher:Pr});function o5(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}var wh={},i5;function HV(){if(i5)return wh;i5=1;var e=lu.GenIcon;return wh.AiFillQuestionCircle=function(r){return e({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 708c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zm62.9-219.5a48.3 48.3 0 0 0-30.9 44.8V620c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-21.5c0-23.1 6.7-45.9 19.9-64.9 12.9-18.6 30.9-32.8 52.1-40.9 34-13.1 56-41.6 56-72.7 0-44.1-43.1-80-96-80s-96 35.9-96 80v7.6c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V420c0-39.3 17.2-76 48.4-103.3C430.4 290.4 470 276 512 276s81.6 14.5 111.6 40.7C654.8 344 672 380.7 672 420c0 57.8-38.1 109.8-97.1 132.5z"}}]})(r)},wh}var $V=HV();function GV({logo:e,className:t="",style:r={},alt:n="Token logo"}){const[s,a]=M.useState(!1);return M.useEffect(()=>{a(!1)},[e]),e&&!s?B.jsx("img",{alt:n,style:r,onError:()=>a(!0),className:`twap-token-logo ${t}`,src:e}):B.jsx($V.AiFillQuestionCircle,{style:{width:20,height:20},className:"twap-token-svg"})}const jV=()=>B.jsx("div",{className:"twap-orders__loader",children:B.jsx("p",{children:"Loading..."})}),VV=()=>{const{isLoading:e}=Ou(),t=nx(),r=te(a=>a.state.orderIdsToCancel),n=te(a=>a.state.cancelOrdersMode),s=sx();return B.jsx(B.Fragment,{children:e?B.jsx(jV,{}):t!=null&&t.length?B.jsx("div",{className:`twap-orders__list ${n?"twap-orders__list-select-mode":""}`,children:B.jsx(AV,{style:{height:"100%"},data:t,itemContent:(a,o)=>B.jsx(WV,{cancelOrdersMode:!!n,selected:(r==null?void 0:r.includes(o.id))||!1,selectOrder:s,order:o},a)})}):B.jsx(qV,{})})},WV=({order:e,selectOrder:t,selected:r,cancelOrdersMode:n})=>{const s=te(i=>i.updateState),a=xt.useCallback(()=>{s({selectedOrderID:e==null?void 0:e.id})},[s,e==null?void 0:e.id]),o=xt.useCallback(()=>{n?t(e==null?void 0:e.id):a()},[n,t,a,e==null?void 0:e.id]);return B.jsx("div",{className:`twap-orders__list-item twap-orders__list-item-${e.status} ${n?"twap-orders__list-item-select-mode":""} ${r?"twap-orders__list-item-selected":""}`,onClick:o,children:B.jsxs("div",{className:"twap-orders__list-item-content",children:[B.jsx(KV,{order:e}),B.jsx(YV,{value:e.progress||0}),B.jsxs("div",{className:"twap-orders__list-item-tokens",children:[B.jsx(c5,{address:e.srcTokenAddress}),B.jsx(bj.HiArrowRight,{className:"twap-orders__list-item-tokens-arrow"}),B.jsx(c5,{address:e.dstTokenAddress})]})]})})},qV=()=>{const e=te(n=>n.state.orderHistoryStatusFilter),t=Me(),r=xt.useMemo(()=>e||"",[e]);return B.jsx("div",{className:"twap-orders__list-empty",children:B.jsx("p",{children:t("noOrders",{status:r})})})},KV=({order:e})=>{const t=e&&e.status,r=tx(e),n=W0(e.createdAt);return B.jsxs("div",{className:"twap-orders__list-item-header",children:[B.jsxs("p",{className:"twap-orders__list-item-header-title",children:[r," ",B.jsx("span",{children:`(${n})`})]}),B.jsx("p",{className:"twap-orders__list-item-header-status",children:t})]})},c5=e=>{const{useToken:t,components:r}=oe(),n=t==null?void 0:t(e.address);return B.jsx("div",{className:"twap-orders__list-item-token",children:n?B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"twap-orders__list-item-token-logo",children:r.TokenLogo?B.jsx(r.TokenLogo,{token:n}):B.jsx(GV,{logo:n==null?void 0:n.logoUrl})}),B.jsx("p",{className:"twap-orders__list-item-token-symbol",children:n==null?void 0:n.symbol})]}):B.jsx("div",{})})};function YV(e){return B.jsxs("div",{className:"twap-orders__list-item-progress",children:[B.jsx("div",{className:"twap-orders__list-item-progress-bar",children:B.jsx("div",{className:"twap-orders__list-item-progress-bar-filled",style:{width:`${e.value}%`}})}),B.jsx("div",{className:"twap-orders__list-item-token-progress-label",children:B.jsx("p",{children:`${Math.round(e.value)}%`})})]})}const ZV=()=>{const e=te(r=>r.state.selectedOrderID),t=e!==void 0;return B.jsx("div",{className:`twap-orders ${e!==void 0?"twap-orders__show-selected":""}`,children:t?B.jsx(YG,{}):B.jsx(VV,{})})},XV=e=>{const t=Me(),{marketPrice:r,typedInputAmount:n}=oe();return M.useMemo(()=>{const{isError:a,value:o}=vm(e);if(!(!a||j(n||"0").isZero()||!r))return{type:Gt.MIN_FILL_DELAY,value:o,message:t("minFillDelayError",{fillDelay:`${Nf(o)} ${t("minutes")}`})}},[e,t,n,r])},ua=()=>{const{callbacks:e}=oe(),t=te(a=>a.state.typedFillDelay),r=te(a=>a.updateState),n=M.useMemo(()=>t||Fc,[t]),s=XV(n);return{fillDelay:n,onChange:M.useCallback(a=>{var o;r({typedFillDelay:a}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,a)},[r,e]),error:s,milliseconds:n.unit*n.value}},QV=()=>{const{onChange:e,fillDelay:t,error:r}=ua(),n=Me(),s=M.useCallback(o=>e({unit:t.unit,value:Number(o)}),[e,t]),a=M.useCallback(o=>e({unit:o,value:t.value}),[e,t]);return{onInputChange:s,onUnitSelect:a,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:r,label:n("tradeIntervalTitle"),tooltip:n("tradeIntervalTooltip")}},dn=()=>{const{srcToken:e,typedInputAmount:t}=oe(),r=Me(),s=te(a=>a.state.acceptedSrcAmount)||t;return{amountWei:Y2(e==null?void 0:e.decimals,s),amountUI:s,error:j(s||0).isZero()?r("enterAmount"):void 0}},JV=(e,t)=>{const{module:r,srcUsd1Token:n,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=oe(),i=Me();return M.useMemo(()=>{if(j(o||"0").isZero()||!s||j(n||"0").isZero())return;if(!e)return{type:Gt.MIN_CHUNKS,value:1,message:i("minChunksError",{minChunks:"1"})};const{isError:c}=km(e,t,r);if(c)return{type:Gt.MAX_CHUNKS,value:t,message:i("maxChunksError",{maxChunks:`${t}`})};const{isError:l,value:u}=Em(o||"",n||"",a||0);if(l)return{type:Gt.MIN_TRADE_SIZE,value:u,message:i("minTradeSizeError",{minTradeSize:`${u}`})}},[e,t,r,o,n,a,i,s])},qr=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:n}=oe(),s=te(g=>g.state.typedChunks),a=ua().fillDelay,o=te(g=>g.updateState),{amountWei:i,amountUI:c}=dn(),l=M.useMemo(()=>dm(a,c||"",t||"",n||0),[c,t,n,a]),u=M.useMemo(()=>um(l,r,s),[l,s,r]),d=M.useCallback(g=>o({typedChunks:g}),[o]),f=M.useMemo(()=>hm(i||"",u),[i,u]),h=Rn(e==null?void 0:e.decimals,f),y=M.useMemo(()=>t?j(h||"0").times(t||0).toString():"0",[h,t]);return{totalTrades:u,maxTrades:l,amountPerTradeUI:h,amountPerTradeWei:f,amountPerTradeUsd:y,onChange:d,error:JV(u,l)}},eW=()=>{const{srcToken:e,dstToken:t}=oe(),r=Me(),{onChange:n,totalTrades:s,amountPerTradeUsd:a,amountPerTradeUI:o,error:i,maxTrades:c,amountPerTradeWei:l}=qr(),u=Ze({value:o}),d=Ze({value:a});return{error:i,maxTrades:c,totalTrades:s,amountPerTrade:u,amountPerTradeWei:l,onChange:n,label:r("tradesAmountTitle"),tooltip:r("totalTradesTooltip"),amountPerTradeUsd:d,fromToken:e,toToken:t}},tW=e=>{const{module:t,marketPrice:r}=oe(),n=Me();return M.useMemo(()=>{const s=xm(t,e),a=wm(e);if(r){if(s.isError)return{type:Gt.MAX_ORDER_DURATION,value:s.value,message:n("maxDurationError",{duration:`${Math.floor(n6(s.value)).toFixed(0)} ${n("days")}`})};if(a.isError)return{type:Gt.MIN_ORDER_DURATION,value:a.value,message:n("minDurationError",{duration:`${Math.floor(Nf(a.value)).toFixed(0)} ${n("minutes")}`})}}},[e,n,t,r])},vh=()=>{const{module:e,callbacks:t}=oe(),r=te(c=>c.state.typedDuration),n=te(c=>c.updateState),s=qr().totalTrades,a=ua().fillDelay,o=M.useMemo(()=>lm(e,s,a,r),[s,a,r,e]),i=tW(o);return{duration:o,setDuration:M.useCallback(c=>{var l;n({typedDuration:c}),(l=t==null?void 0:t.onDurationChange)==null||l.call(t,c)},[n,t]),error:i}},rW=()=>{const{module:e}=oe(),t=Me(),{duration:r,setDuration:n,error:s}=vh(),a=M.useCallback(c=>{n({unit:r.unit,value:Number(c)})},[n,r]),o=M.useCallback(c=>{n({unit:c,value:r.value})},[n,r]),i=M.useMemo(()=>e===ye.STOP_LOSS?t("stopLossDurationTooltip"):t("maxDurationTooltip"),[t,e]);return{duration:r,onChange:n,milliseconds:r.unit*r.value,onInputChange:a,onUnitSelect:o,label:t("expiry"),tooltip:i,error:s}},nW=()=>{const e=te(a=>a.state.isMarketOrder),{module:t}=oe(),r=Me(),n=M.useMemo(()=>{if(e&&t===ye.STOP_LOSS)return{text:r("triggerMarketPriceDisclaimer"),url:id}},[e,r,t]),s=M.useMemo(()=>{if(!(t!==ye.LIMIT&&t!==ye.TWAP))return{text:r(e?"marketOrderWarning":"limitPriceMessage"),url:"https://www.orbs.com/dtwap-and-dlimit-faq/"}},[e,r,t]);return n||s},Vu=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=oe(),n=te(l=>l.updateState),s=te(l=>l.state.isInvertedTrade),a=te(l=>l.state.typedTriggerPrice),o=te(l=>l.state.typedLimitPrice),i=te(l=>l.state.isMarketOrder);return{onInvert:M.useCallback(()=>{a!==void 0&&n({typedTriggerPrice:j(1).div(a).toFixed()}),o!==void 0&&n({typedLimitPrice:j(1).div(o).toFixed()}),n({isInvertedTrade:!s})},[n,s,a,o,r]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:i}},l5=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:n,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:i}=oe(),{isInverted:c}=Vu(),l=M.useMemo(()=>j((()=>{if(e!==void 0){const E=c?j(e).isZero()?j(0):j(1).div(e):j(e);return Bl(E.toFixed(),t)}if(n!==void 0&&j(r||"0").gt(0)&&!j(r||"0").isNaN()){const E=j(r||"0"),v=j(n||0).div(100);return E.plus(E.multipliedBy(v)).decimalPlaces(0).toFixed()}return j(r).gt(0)?r:""})()).decimalPlaces(0).toFixed(),[e,n,t,r,c]),u=M.useCallback(g=>{s(g),a(null)},[s,a]),d=M.useCallback(g=>{s(void 0),a(g)},[s,a]),f=M.useMemo(()=>{if(!r||j(r).isZero())return"";if(n!=null)return n;if(l){const g=j(r),v=j(l).minus(g).div(g).multipliedBy(100).decimalPlaces(2).toString();return j(v||"0").isZero()?"":v}return""},[l,r,n]),h=M.useMemo(()=>{let g="";if(e!==void 0)g=e;else{const E=Ii(l,t);if(j(E||"0").isZero())return"";g=c?j(1).div(E).toFixed():E}return _f(g,6,t)},[e,t,l,c]),y=aa(c?o:i,h||"0");return{amountWei:j(l).isNaN()?"":l,amountUI:j(h).isNaN()?"":h,selectedPercentage:f,onChange:u,onPercentageChange:d,isInverted:c,usd:j(y).isNaN()?"":y}},sW=()=>{const{module:e}=oe();return M.useMemo(()=>e===ye.STOP_LOSS?em:tm,[e])},Eh=()=>{const{module:e}=oe(),t=te(r=>r.state.isMarketOrder);return M.useMemo(()=>e!==ye.STOP_LOSS&&e!==ye.TAKE_PROFIT||t?void 0:e===ye.STOP_LOSS?rm:nm,[e,t])},aW=(e="")=>{const{module:t,marketPrice:r,typedInputAmount:n}=oe(),s=Me();return M.useMemo(()=>{if(j(n||"0").isZero()||!r||t!==ye.STOP_LOSS&&t!==ye.TAKE_PROFIT)return;const a=mm(r||"",e||"",t);if(a!=null&&a.isError)return{type:Gt.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:a.value,message:s("StopLossTriggerPriceError")||""};const o=bm(r||"",e||"",t);if(o!=null&&o.isError)return{type:Gt.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:o.value,message:s("TakeProfitTriggerPriceError")||""};if(!e||j(e||0).isZero())return{type:Gt.EMPTY_TRIGGER_PRICE,value:e,message:s("emptyTriggerPrice")||""}},[r,e,t,s,n])},oW=e=>{const{srcToken:t,dstToken:r,module:n,dstUsd1Token:s}=oe(),a=qr().amountPerTradeWei,o=te(l=>l.state.isMarketOrder),i=M.useMemo(()=>cm(n,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,n]),c=Rn((r==null?void 0:r.decimals)||0,i);return{amountWei:i,amountUI:c,usd:aa(c,s)}},da=()=>{const{dstToken:e,marketPrice:t,module:r,callbacks:n}=oe(),s=te(y=>y.updateState),a=sW(),o=te(y=>y.state.triggerPricePercent),i=o===void 0?a:o,c=r===ye.STOP_LOSS||r===ye.TAKE_PROFIT,l=l5({typedValue:te(y=>y.state.typedTriggerPrice),percentage:i,tokenDecimals:e==null?void 0:e.decimals,initialPrice:c?t:void 0,setValue:M.useCallback(y=>{var g;s({typedTriggerPrice:y}),(g=n==null?void 0:n.onTriggerPriceChange)==null||g.call(n,y||"")},[s,n]),setPercentage:M.useCallback(y=>{var g;s({triggerPricePercent:y}),(g=n==null?void 0:n.onTriggerPricePercentChange)==null||g.call(n,y||"")},[s,n])}),u=aW(l.amountWei),{amountWei:d,amountUI:f,usd:h}=oW(l.amountWei);return M.useMemo(()=>({...l,error:u,pricePerChunkWei:d,pricePerChunkUI:f,pricePerChunkUsd:h}),[l,u,d,f,h])},iW=()=>{const{module:e,marketPrice:t,marketPriceLoading:r}=oe(),n=Me(),{amountUI:s,onChange:a,onPercentageChange:o,usd:i,selectedPercentage:c,error:l,pricePerChunkUI:u,pricePerChunkUsd:d}=da(),f=te(C=>C.state.isMarketOrder),h=te(C=>C.updateState),{isInverted:y,onInvert:g,fromToken:E,toToken:v}=Vu(),w=M.useCallback(()=>{h({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[h]),A=e!==ye.STOP_LOSS&&e!==ye.TAKE_PROFIT;return{price:s,amountPerChunk:u,amountPerChunkUsd:d,error:l,label:n("stopLossLabel"),tooltip:e===ye.STOP_LOSS?n("stopLossTooltip"):n("takeProfitTooltip"),onChange:a,onPercentageChange:o,percentage:c,isActive:!f,onReset:w,usd:i,fromToken:E,toToken:v,prefix:"",isLoading:r||!t,isInverted:y,hide:A,onInvert:g,totalTrades:qr().totalTrades}},cW=e=>{const{module:t,marketPrice:r,typedInputAmount:n}=oe(),s=Me(),{amountWei:a}=da(),o=te(i=>i.state.isMarketOrder);return M.useMemo(()=>{if(j(n||"0").isZero()||!a||!r)return;const i=ym(a,e,o,t),c=gm(a,e,o,t);if(i!=null&&i.isError)return{type:Gt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:i.value};if(c!=null&&c.isError)return{type:Gt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:c.value};if(e&&j(e||0).isZero())return{type:Gt.MISSING_LIMIT_PRICE,message:s("emptyLimitPrice")||"",value:e||""}},[e,s,a,t,o,n,r])},xc=()=>{const{dstToken:e,marketPrice:t,callbacks:r}=oe(),n=te(l=>l.updateState),s=Eh(),a=te(l=>l.state.limitPricePercent),o=a===void 0?s:a,i=l5({typedValue:te(l=>l.state.typedLimitPrice),percentage:o,tokenDecimals:e==null?void 0:e.decimals,initialPrice:t,setValue:M.useCallback(l=>{var u;n({typedLimitPrice:l}),(u=r==null?void 0:r.onLimitPriceChange)==null||u.call(r,l||"")},[n,r]),setPercentage:M.useCallback(l=>{var u;n({limitPricePercent:l}),(u=r==null?void 0:r.onLimitPricePercentChange)==null||u.call(r,l||"")},[n,r])}),c=cW(i.amountWei);return M.useMemo(()=>({...i,error:c}),[i,c])},lW=()=>{const{module:e}=oe(),t=te(i=>i.updateState),r=te(i=>i.state.isMarketOrder),n=Eh(),s=te(i=>i.state.triggerPricePercent)||0,a=e===ye.LIMIT,o=M.useCallback(()=>{!r&&e===ye.STOP_LOSS&&t({limitPricePercent:n}),t({isMarketOrder:!r})},[t,s,e,r,n]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:a}},u5=()=>{const{module:e,marketPrice:t}=oe(),r=xc().amountWei,n=da().amountWei,s=te(a=>a.state.isMarketOrder);return e===ye.LIMIT||!s?r||"":e===ye.STOP_LOSS||e===ye.TAKE_PROFIT?n||"":t||""},wc=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=oe(),n=u5(),s=dn().amountWei,a=M.useMemo(()=>om(s||"",n,(e==null?void 0:e.decimals)||0),[s,n,e==null?void 0:e.decimals]),o=Rn(t==null?void 0:t.decimals,a);return{amountWei:a,amountUI:o,usd:aa(o,r)}},Wu=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=oe(),n=u5(),s=qr().amountPerTradeWei,a=te(c=>c.state.isMarketOrder),o=M.useMemo(()=>im(s,n,!!a,(e==null?void 0:e.decimals)||0),[s,n,a,e==null?void 0:e.decimals]),i=Rn(t==null?void 0:t.decimals,o);return{amountWei:o,amountUI:i,usd:aa(i,r)}},uW=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:r}=oe(),{amountUI:n,usd:s}=wc(),o=SG()?e:n;return{value:Z2(o,7),valueWei:Y2(r==null?void 0:r.decimals,o),isLoading:t,usd:s}},dW=()=>{const{module:e,marketPriceLoading:t}=oe(),r=Me(),{amountUI:n,onChange:s,onPercentageChange:a,usd:o,selectedPercentage:i,error:c}=xc(),{amountUI:l,usd:u}=Wu(),d=te(D=>D.updateState),f=Eh(),{isLimitPrice:h,toggleLimitPrice:y}=lW(),{isInverted:g,onInvert:E,fromToken:v,toToken:w}=Vu(),A=M.useCallback(()=>{d({typedLimitPrice:void 0}),d({limitPricePercent:f})},[d,e,f]),C=M.useMemo(()=>e===ye.STOP_LOSS?r("stopLossLimitPriceTooltip"):r("limitPriceTooltip"),[r,e]);return{price:n,amountPerChunk:l,amountPerChunkUsd:u,error:c,label:r("limitPrice"),tooltip:C,onChange:s,onPercentageChange:a,onReset:A,usd:o,fromToken:v,tradesAmount:qr().totalTrades,toToken:w,percentage:i,isInverted:g,isLoading:t,isLimitPrice:h,toggleLimitPrice:y,onInvert:E}};function d5(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:r,srcUsd1Token:n,srcBalance:s,chainId:a}=oe(),o=te(g=>g.state.swapExecution.status),i=Me(),{error:c}=da(),{error:l}=xc(),{error:u}=qr(),{error:d}=ua(),{error:f}=vh(),h=dn().amountWei,y=M.useMemo(()=>{if(s&&j(h).gt(s))return{type:Gt.INSUFFICIENT_BALANCE,message:i("insufficientFunds"),value:s||""}},[s,h,i,a]);return M.useMemo(()=>Am({marketPrice:e,typedInputAmount:r,srcUsd1Token:n,marketPriceLoading:t,triggerPriceError:c,limitPriceError:l,tradesError:u,fillDelayError:d,durationError:f,balanceError:y}),[e,t,r,c,l,u,d,f,y,o,n])}const pW=()=>{const e=te(n=>n.state.isMarketOrder),t=te(n=>n.updateState),r=M.useCallback(()=>{t({isMarketOrder:!e})},[t,e]);return{isMarketPrice:!e,togglePrice:r}},kh=()=>{const e=te(r=>r.state.currentTime),t=vh().duration;return M.useMemo(()=>pm(e,t),[e,t])},fW=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=oe(),r=dn().amountUI,n=wc().amountUI,s=aa(r,e),a=aa(n,t);return{srcAmountUsd:s,dstAmountUsd:a}},hW=()=>{const{fees:e,dstUsd1Token:t}=oe(),{amountUI:r}=wc(),n=M.useMemo(()=>!e||!r?"":j(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]);return{amount:n,percent:e,usd:aa(n,t)}},p5=()=>{const{srcToken:e,dstToken:t,account:r,chainId:n,slippage:s,config:a,module:o}=oe(),{amountWei:i}=dn(),{amountWei:c}=xc(),{amountPerTradeWei:l,totalTrades:u}=qr(),d=kh(),{amountWei:f}=Wu(),{pricePerChunkWei:h}=da(),{milliseconds:y}=ua();return M.useMemo(()=>{var g;return{srcToken:e,dstToken:t,limitPrice:c,deadline:d,srcAmount:i,srcAmountPerTrade:l,totalTrades:u,minDestAmountPerTrade:f,tradeInterval:y,triggerPricePerTrade:h,maker:r,rePermitData:Sm({chainId:n,srcToken:Is((e==null?void 0:e.address)||"")?((g=Bs(n))==null?void 0:g.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:i,deadlineMillis:d,fillDelayMillis:!u||u===1?0:y,slippage:s*100,account:r,srcAmountPerTrade:l,dstMinAmountPerTrade:f,triggerAmountPerTrade:h,config:a,module:o})}},[e,t,c,d,i,l,u,f,h,r,y,s,n,a,o])},f5=()=>{const{srcToken:e,dstToken:t,account:r}=oe(),n=Me(),{amountUI:s,usd:a}=Wu(),{amountPerTradeUI:o,amountPerTradeUsd:i,totalTrades:c}=qr(),{amountUI:l,usd:u}=da(),d=kh(),{amountUI:f,usd:h}=xc(),{amount:y,percent:g,usd:E}=hW(),{milliseconds:v}=ua(),{amountUI:w}=wc(),{srcAmountUsd:A,dstAmountUsd:C}=fW(),D=dn().amountUI,z=te(x=>x.state.isMarketOrder),T=X2({srcToken:e,dstToken:t,account:r,limitPrice:z?void 0:f,limitPriceUsd:z?void 0:h,deadline:d,tradeInterval:v,srcAmount:D,totalTrades:c,srcAmountPerTrade:o,srcAmountPerTradeUsd:i,minDestAmountPerTrade:s,minDestAmountPerTradeUsd:a,triggerPrice:l,triggerPriceUsd:u,srcUsd:A,dstUsd:C,dstAmount:w}),m=Ze({value:y}),b=Ze({value:E});return M.useMemo(()=>({...T,fees:{label:n("fees",{value:`${g}%`}),amount:m,usd:b||"",percentage:g}}),[T,m,b,g])},h5=M.createContext({}),mW=({children:e,...t})=>B.jsx(h5.Provider,{value:t,children:e}),bW=()=>M.useContext(h5),m5=()=>{var s,a;const e=Me(),{wrapTxHash:t,srcToken:r}=te(o=>o.state.swapExecution),n=(a=(s=oc())==null?void 0:s.wToken)==null?void 0:a.symbol;return t?B.jsx("p",{className:"twap-error-wrap-msg",children:e("wrapMsg",{symbol:(r==null?void 0:r.symbol)||"",wSymbol:n||""})}):null},b5=()=>{const e=Me(),t=te(n=>n.state.swapExecution.status),r=ex();return t===ht.SUCCESS?e("createOrderActionSuccess",{name:r}):e("createOrderAction",{name:r})},yW=()=>{const e=te(y=>y.state.swapExecution.srcToken),t=Me(),{step:r,wrapTxHash:n,approveTxHash:s}=te(y=>y.state.swapExecution),a=oc(),o=V0(n),i=V0(n),c=V0(s),l=te(y=>y.state.swapExecution.status),d=Is((e==null?void 0:e.address)||"")?(a==null?void 0:a.native.symbol)||"":(e==null?void 0:e.symbol)||"",f=a==null?void 0:a.wToken.symbol,h=b5();return M.useMemo(()=>r===Ds.WRAP?{title:t("wrapAction",{symbol:d}),footerLink:o,footerText:t(o?"viewOnExplorer":"proceedInWallet")}:r===Ds.APPROVE?{title:t("approveAction",{symbol:d}),footerLink:c,footerText:t(c?"viewOnExplorer":"proceedInWallet")}:{title:h,footerText:l===ht.LOADING?t("proceedInWallet"):void 0},[r,c,d,h,t,o,i,f,l])},gW=({error:e})=>B.jsxs("div",{className:"twap-error",children:[B.jsx("h2",{className:"twap-error-title",children:"Transaction failed"}),(e==null?void 0:e.code)&&B.jsxs("p",{className:"twap-error-code",children:["Error code: ",e==null?void 0:e.code]}),B.jsx(m5,{})]});function xW({error:e}){const{components:t}=oe(),r=Me(),n=te(o=>{var i;return(i=o.state.swapExecution)==null?void 0:i.wrapTxHash}),s=t.SubmitOrderErrorView,a=B.jsx(Xn.Failed,{error:B.jsx(gW,{error:e}),footerLink:id,footerText:r("viewOnExplorer")});return s?B.jsx(s,{wrapTxHash:n,error:e,children:a}):a}const wW=()=>{const{components:e}=oe(),t=te(u=>u.state.swapExecution.srcToken),r=te(u=>u.state.swapExecution.dstToken),{reviewDetails:n}=bW(),s=Me(),a=te(u=>{var d;return!!((d=u.state.swapExecution)!=null&&d.status)}),o=f5(),i=e.USD,c=e.SubmitOrderMainView,l=B.jsxs(B.Fragment,{children:[B.jsx(Xn.Main,{fromTitle:s("from"),toTitle:s("to"),inUsd:i?B.jsx(i,{value:o.srcUsd,isLoading:!1}):`$${o.srcUsd}`,outUsd:i?B.jsx(i,{value:o.dstUsd,isLoading:!1}):`$${o.dstUsd}`}),!a&&B.jsxs("div",{className:"twap-create-order-bottom",children:[B.jsx(Ee.Container,{children:B.jsxs("div",{className:"twap-create-order-details",children:[B.jsx(Ee.Deadline,{deadline:o.deadline.value,label:o.deadline.label,tooltip:o.deadline.tooltip||""}),B.jsx(Ee.Price,{srcToken:t,price:o.triggerPrice.value,dstToken:r,label:o.triggerPrice.label,tooltip:o.triggerPrice.tooltip,usd:o.triggerPrice.usd}),B.jsx(Ee.Price,{srcToken:t,price:o.limitPrice.value,dstToken:r,label:o.limitPrice.label,usd:o.limitPrice.usd,tooltip:o.limitPrice.tooltip}),B.jsx(Ee.MinDestAmount,{dstToken:r,dstMinAmountOut:o.minDestAmountPerTrade.value,label:o.minDestAmountPerTrade.label,tooltip:o.minDestAmountPerTrade.tooltip||"",usd:o.minDestAmountPerTrade.usd}),B.jsx(Ee.TradeSize,{tradeSize:o.sizePerTrade.value,trades:o.totalTrades.value,srcToken:t,label:o.sizePerTrade.label,tooltip:o.sizePerTrade.tooltip}),B.jsx(Ee.TradesAmount,{trades:o.totalTrades.value,label:o.totalTrades.label,tooltip:o.totalTrades.tooltip}),B.jsx(Ee.TradeInterval,{chunks:o.totalTrades.value,fillDelayMillis:o.tradeInterval.value,label:o.tradeInterval.label,tooltip:o.tradeInterval.tooltip}),B.jsx(Ee.Recipient,{}),o.fees.amount&&B.jsx(Ee.Fees,{fees:o.fees.amount,label:o.fees.label,usd:o.fees.usd,dstTokenSymbol:r==null?void 0:r.symbol})]})}),n]})]});return c?B.jsx(c,{children:l}):l},vW=e=>{const{status:t,stepIndex:r,totalSteps:n,parsedError:s}=te(w=>w.state.swapExecution),{components:a}=oe(),o=a.Spinner,i=a.SuccessIcon,c=a.ErrorIcon,l=a.TokenLogo,{srcToken:u,dstToken:d}=oe(),f=dn().amountUI,h=wc().amountUI,y=Ze({value:f,decimalScale:2}),g=Ze({value:h,decimalScale:2}),E=M.useMemo(()=>({symbol:u==null?void 0:u.symbol,logoUrl:u==null?void 0:u.logoUrl}),[u]),v=M.useMemo(()=>({symbol:d==null?void 0:d.symbol,logoUrl:d==null?void 0:d.logoUrl}),[d]);return B.jsx(mW,{...e,children:B.jsx(Xn,{inAmount:y,outAmount:g,swapStatus:t,totalSteps:n,currentStep:yW(),currentStepIndex:r,inToken:E,outToken:v,components:{SrcTokenLogo:l&&B.jsx(l,{token:u}),DstTokenLogo:l&&B.jsx(l,{token:d}),Failed:B.jsx(xW,{error:s}),Success:B.jsx(EW,{}),Main:B.jsx(wW,{}),Loader:o,SuccessIcon:i,FailedIcon:c}})})},EW=()=>{const e=b5(),{components:t}=oe(),r=te(a=>a.state.swapExecution.orderId),n=t.SubmitOrderSuccessView,s=B.jsxs(B.Fragment,{children:[B.jsx(Xn.Success,{title:e}),B.jsx(m5,{})]});return n?B.jsx(n,{newOrderId:r,children:s}):s},kW=()=>{const{supportedChains:e}=oe();return M.useMemo(()=>e,[e])},CW=()=>{const{config:e}=oe();return M.useMemo(()=>({spender:e.repermit}),[e])},TW=()=>{var c;const{account:e,walletClient:t,overrides:r,refetchBalances:n,callbacks:s,chainId:a}=oe(),o=(c=oc())==null?void 0:c.wToken,i=q0();return Zr({mutationFn:async({onHash:l,srcAmountWei:u})=>{var h,y;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!o)throw new Error("tokenAddress is not defined");let d;dt.onWrapRequest(),(h=s==null?void 0:s.onWrapRequest)==null||h.call(s),r!=null&&r.wrap?d=await r.wrap(u):d=await t.writeContract({abi:Mh,functionName:"deposit",account:e,address:o.address,value:BigInt(u),chain:t.chain}),l==null||l(d);const f=await i(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to wrap token");return dt.onWrapSuccess(d),(y=s==null?void 0:s.onWrapSuccess)==null||y.call(s,{txHash:f.transactionHash,explorerUrl:Bi(f.transactionHash,a),amount:Ii(u,o.decimals)}),n==null||n(),f},onError:l=>{throw dt.onWrapError(l),l}})},AW=()=>{const{account:e,walletClient:t,chainId:r,callbacks:n}=oe(),s=p5().rePermitData,{refetch:a}=K0();return Zr({mutationFn:async()=>{var y,g,E,v;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!r)throw new Error("missing chainId");const{order:o,domain:i,types:c,primaryType:l}=s;dt.onSignOrderRequest(o),(y=n==null?void 0:n.onSignOrderRequest)==null||y.call(n),console.log({domain:i,types:c,primaryType:l,message:o,account:e}),console.log("Using domain:",i),console.log("Using types:",c),console.log("Order data to sign:",JSON.stringify(o,null,2)),console.log(`Account address: ${e}`);let u;try{u=await(t==null?void 0:t.signTypedData({domain:i,types:c,primaryType:l,message:o,account:e}))}catch(w){throw(g=n==null?void 0:n.onSignOrderError)==null||g.call(n,w),dt.onSignOrderError(w),w}dt.onSignOrderSuccess(u),(E=n==null?void 0:n.onSignOrderSuccess)==null||E.call(n,u);const d=jT(u),f={v:q(d.v||0),r:d.r,s:d.s},h=await Fm(o,f);return(v=n==null?void 0:n.onOrderCreated)==null||v.call(n,h),await a(),h}})},y5=()=>{const{account:e,publicClient:t,config:r}=oe();return Zr({mutationFn:async({tokenAddress:n,srcAmountWei:s})=>{if(!t)throw new Error("missing publicClient");if(!e)throw new Error("missing account");if(!r)throw new Error("missing config");const a=await t.readContract({address:n,abi:Ty,functionName:"allowance",args:[e,r.repermit]}).then(i=>i.toString()),o=j(a||"0").lt(j(s).toString());return{allowance:a,approvalRequired:o}}})},SW=()=>{const{account:e,walletClient:t,overrides:r,config:n,chainId:s,callbacks:a}=oe(),o=q0(),{mutateAsync:i}=y5();return Zr({onError:c=>{dt.onApproveError(c)},mutationFn:async({token:c,onHash:l,srcAmountWei:u})=>{var y,g;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!n)throw new Error("missing config");(y=a==null?void 0:a.onApproveRequest)==null||y.call(a),dt.onApproveRequest();let d;if(r!=null&&r.approveOrder?d=await r.approveOrder({tokenAddress:c.address,spenderAddress:n.repermit,amount:Vs}):d=await t.writeContract({abi:Ty,functionName:"approve",account:e,address:c.address,args:[n.repermit,Vs],chain:t.chain}),!d)throw new Error("failed to approve token");l(d);const f=await o(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to approve token");let h=!1;for(let E=0;E<3;E++){const{approvalRequired:v}=await i({tokenAddress:c.address,srcAmountWei:u});if(!v){h=!0;break}E<2&&await new Promise(w=>setTimeout(w,3e3))}if(!h)throw new Error(`Insufficient ${c.symbol} allowance to perform the swap. Please approve the token first.`);return dt.onApproveSuccess(f.transactionHash),(g=a==null?void 0:a.onApproveSuccess)==null||g.call(a,{txHash:f.transactionHash,explorerUrl:Bi(f.transactionHash,s),token:c,amount:Ii(u,c.decimals)}),f}})},PW=()=>{const{account:e,chainId:t,srcToken:r,dstToken:n,module:s,slippage:a}=oe(),o=da(),i=dn().amountWei,c=qr().amountPerTradeWei,l=kh(),u=qr().totalTrades,d=ua().fillDelay,f=Wu().amountWei,h=te(y=>y.state.isMarketOrder);return Zr({mutationFn:async()=>{dt.onRequestOrder({account:e,chainId:t,module:s,srcToken:r,dstToken:n,fromTokenAmount:i,srcChunkAmount:c,triggerPricePerTrade:o.pricePerChunkWei,deadline:l,fillDelay:d.unit*d.value,minDstAmountOutPerTrade:f,slippage:a,isMarketOrder:h||!1,chunksAmount:u})}})};function IW(e){const t=e.message,r=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:r?Number(r[1]):0}}const BW=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:n}=oe(),s=SW().mutateAsync,a=TW().mutateAsync,o=AW().mutateAsync,{mutateAsync:i}=y5(),c=te(d=>d.updateSwapExecution),{amountWei:l}=dn(),u=PW().mutate;return Zr({mutationFn:async()=>{var f,h;const d=Is((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!r)throw new Error("missing chainId");const y=r6(e,r);c({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0});const{approvalRequired:g}=await i({tokenAddress:y.address,srcAmountWei:l});let E=0,v=1;d&&v++,g&&v++,c({totalSteps:v,stepIndex:E,allowanceLoading:!1,status:ht.LOADING}),u(),d&&(c({step:Ds.WRAP}),await a({onHash:A=>c({wrapTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),g&&(c({step:Ds.APPROVE}),await s({token:y,onHash:A=>c({approveTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),c({step:Ds.CREATE});const w=await o();return c({status:ht.SUCCESS,orderId:w.id}),w}catch(y){if(Mf(y))(f=n==null?void 0:n.onSubmitOrderRejected)==null||f.call(n),c({step:void 0,status:void 0,stepIndex:void 0,error:y});else{const g=IW(y);(h=n==null?void 0:n.onSubmitOrderFailed)==null||h.call(n,g),c({status:ht.FAILED,parsedError:g,error:y})}throw y}}})},FW=()=>{const{marketPrice:e,srcToken:t,dstToken:r,resetTypedInputAmount:n}=oe(),s=BW(),a=te(g=>g.updateState),{amountUI:o}=dn(),i=te(g=>g.resetState),c=te(g=>g.state.swapExecution),l=te(g=>g.updateSwapExecution),u=ex(),d=M.useCallback(()=>{(c==null?void 0:c.status)===ht.SUCCESS&&(n(),i())},[c==null?void 0:c.status,i,n]),f=M.useCallback(()=>{(c==null?void 0:c.status)!==ht.LOADING&&(a({acceptedSrcAmount:void 0,acceptedMarketPrice:void 0}),l({srcToken:t,dstToken:r,error:void 0,parsedError:void 0,status:void 0,orderId:void 0}))},[a,t,r]),h=Zr({mutationFn:async()=>(a({acceptedSrcAmount:o,acceptedMarketPrice:e}),await s.mutateAsync())}),y=M.useCallback(()=>h.mutateAsync(),[h]);return M.useMemo(()=>({reset:i,onCloseModal:d,onOpenModal:f,onSubmit:y,orderTitle:u,...c,isLoading:(c==null?void 0:c.status)===ht.LOADING,isSuccess:(c==null?void 0:c.status)===ht.SUCCESS,isFailed:(c==null?void 0:c.status)===ht.FAILED}),[i,d,y,c,u])},UW=()=>{const e=Me(),{marketPrice:t,srcToken:r,dstToken:n,marketPriceLoading:s,srcBalance:a,srcUsd1Token:o,noLiquidity:i,typedInputAmount:c}=oe(),l=s||j(o||"0").isZero()||a===void 0||j(t||"0").isZero(),u=!!(r&&n&&c&&l),d=d5(),f=M.useMemo(()=>i?e("noLiquidity"):j(c||"0").isZero()?e("enterAmount"):e("placeOrder"),[d,e,c,i]),h=!!(d||i||u||j(c||"0").isZero()||!r||!n);return M.useMemo(()=>({disabled:h,text:f,loading:u}),[h,f,u])},OW=({children:e,container:t})=>{const[r,n]=M.useState(!1),s=M.useRef(null);if(M.useLayoutEffect(()=>(n(!0),s.current=t??document.body,()=>{s.current=null}),[]),typeof document>"u"||!r)return null;const a=s.current;return a?As.createPortal(e,a):null};Im(Iw.version);const DW={SubmitOrderPanel:vW,Orders:ZV,Portal:OW};R.CRASH_ERROR_MESSAGE=rw,R.Components=DW,R.Configs=Dt,R.DEFAULT_DURATION_OPTIONS=JL,R.DEFAULT_FILL_DELAY=Fc,R.DEFAULT_STOP_LOSS_LIMIT_PERCENTAGE=rm,R.DEFAULT_STOP_LOSS_PERCENTAGE=em,R.DEFAULT_TAKE_PROFIT_LIMIT_PERCENTAGE=nm,R.DEFAULT_TAKE_PROFIT_PERCENTAGE=tm,R.DISCLAIMER_URL=tw,R.EIP712_TYPES=Jh,R.ERC20_ABI=H5,R.EXCLUSIVITY_OVERRIDE_BPS=Z5,R.FEES=Y5,R.IWETH_ABI=Mh,R.InputErrors=Gt,R.LEGACY_EXCHANGES_MAP=Xh,R.MAX_ORDER_DURATION_MILLIS=Ca,R.MIN_CHUNKS=K5,R.MIN_FILL_DELAY_MILLIS=Ic,R.MIN_FILL_DELAY_MINUTES=qh,R.MIN_ORDER_DURATION_MILLIS=ad,R.Module=ye,R.ORBS_LOGO=Q5,R.ORBS_LOGO_FALLBACK=J5,R.ORBS_SLTP_FAQ_URL=X5,R.ORBS_TWAP_FAQ_URL=id,R.ORBS_WEBSITE_URL=ew,R.OrderStatus=ct,R.OrderType=ze,R.PRICE_PROTECTION_SETTINGS=ez,R.Partners=zh,R.QUERY_PARAMS=Ta,R.REPERMIT_ABI=Nh,R.REPERMIT_PRIMARY_TYPE=Qh,R.SUGGEST_CHUNK_VALUE=q5,R.SpotProvider=XL,R.Steps=Ds,R.SwapStatus=ht,R.THE_GRAPH_ORDERS_API=Kh,R.TWAP_ABI=Lh,R.TimeUnit=$t,R.analytics=dt,R.buildRePermitOrderData=Sm,R.buildV2Order=pd,R.copy=WT,R.ensureWrappedToken=r6,R.eqIgnoreCase=Ps,R.fillDelayText=t6,R.formatDecimals=_f,R.getAccountOrders=_m,R.getApiEndpoint=sd,R.getChunks=um,R.getConfig=ld,R.getDeadline=pm,R.getDestTokenAmount=om,R.getDestTokenMinAmountPerChunk=im,R.getDuration=lm,R.getErrors=Am,R.getEstimatedDelayBetweenChunksMillis=fm,R.getExplorerUrl=Bi,R.getMaxChunksError=km,R.getMaxFillDelayError=iw,R.getMaxOrderDurationError=xm,R.getMaxPossibleChunks=dm,R.getMinChunkSizeUsd=Tm,R.getMinFillDelayError=vm,R.getMinNativeBalance=KT,R.getMinOrderDurationError=wm,R.getMinTradeSizeError=Em,R.getNetwork=Bs,R.getOrderExcecutionRate=Gh,R.getOrderFillDelayMillis=td,R.getOrderLimitPriceRate=jh,R.getOrderType=YT,R.getPartnerChains=$h,R.getPartnerIdentifier=_t,R.getPartners=Cm,R.getSrcTokenChunkAmount=hm,R.getStopLossLimitPriceError=ym,R.getStopLossPriceError=mm,R.getTakeProfitLimitPriceError=gm,R.getTakeProfitPriceError=bm,R.getTriggerPricePerChunk=cm,R.getTriggerPricePerTrade=Vh,R.isNativeAddress=Is,R.isTxRejected=Mf,R.makeElipsisAddress=Df,R.maxUint256=Bc,R.millisToDays=n6,R.millisToMinutes=Nf,R.nativeTokenAddresses=Zh,R.networks=Ft,R.parseError=qT,R.removeCommas=VT,R.setApiMode=W5,R.setUIVersion=Im,R.shouldUnwrapOnly=zf,R.shouldWrapOnly=Lf,R.submitOrder=Fm,R.toAmountUi=Ii,R.toAmountWei=Bl,R.useAddresses=CW,R.useDisclaimerPanel=nW,R.useDstTokenPanel=uW,R.useDurationPanel=rW,R.useFillDelayPanel=QV,R.useFormatNumber=Ze,R.useInputErrors=d5,R.useInvertTradePanel=Vu,R.useLimitPricePanel=dW,R.useOrder=p5,R.useOrderHistoryPanel=qG,R.useOrderInfo=f5,R.usePartnerChains=kW,R.useSubmitOrderButton=UW,R.useSubmitOrderPanel=FW,R.useTogglePricePanel=pW,R.useTradesPanel=eW,R.useTranslations=Me,R.useTriggerPricePanel=iW,R.zeroAddress=Yh,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|
|
126
|
+
`),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function CG(e){e=kG(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,s=e.onKeyDown;s===void 0&&(s=G0);var a=e.onBlur;a===void 0&&(a=G0);var o=e.thousandSeparator,i=e.decimalScale,c=e.fixedDecimalScale,l=e.prefix;l===void 0&&(l="");var u=e.defaultValue,d=e.value,f=e.valueIsNumericString,h=e.onValueChange,y=cG(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),g=Fu(e),E=g.decimalSeparator,v=g.allowedDecimalSeparators,w=function(P){return K2(P,e)},A=function(P,O){return vG(P,O,e)},C=ho(d)?u:d,D=f??wG(C,l,t);ho(d)?ho(u)||(D=D||typeof u=="number"):D=D||typeof d=="number";var z=function(P){return $2(P)?P:(typeof P=="number"&&(P=W2(P)),D&&typeof i=="number"?q2(P,i,!!c):P)},T=yG(z(d),z(u),!!D,w,A,h),m=T[0],b=m.numAsString,x=m.formattedValue,S=T[1],I=function(P){var O=P.target,U=P.key,L=O.selectionStart,H=O.selectionEnd,G=O.value;if(G===void 0&&(G=""),(U==="Backspace"||U==="Delete")&&H<l.length){P.preventDefault();return}if(L!==H){s(P);return}U==="Backspace"&&G[0]==="-"&&L===l.length+1&&r&&ac(O,1),i&&c&&(U==="Backspace"&&G[L-1]===E?(ac(O,L-1),P.preventDefault()):U==="Delete"&&G[L]===E&&P.preventDefault()),v!=null&&v.includes(U)&&G[L]===E&&ac(O,L+1);var Q=o===!0?",":o;U==="Backspace"&&G[L-1]===Q&&ac(O,L-1),U==="Delete"&&G[L]===Q&&ac(O,L+1),s(P)},F=function(P){var O=b;if(O.match(/\d/g)||(O=""),n||(O=hG(O)),c&&i&&(O=q2(O,i,c)),O!==b){var U=K2(O,e);S({formattedValue:U,value:O,floatValue:parseFloat(O)},{event:P,source:$0.event})}a(P)},_=function(P){return P===E?!0:H2(P)},k=function(P){var O=P.currentValue,U=P.lastValue,L=P.formattedValue,H=P.currentValueIndex,G=P.formattedValueIndex,Q=O[H],pe=L[G],me=mG(U,O),ie=me.to,de=function(Be){return A(Be).indexOf(".")+l.length};return d===0&&c&&i&&O[ie.start]===E&&de(O)<H&&de(L)>G?!1:H>=ie.start&&H<ie.end&&v&&v.includes(Q)&&pe===E?!0:Q===pe};return Object.assign(Object.assign({},y),{value:x,valueIsNumericString:!1,isValidInputCharacter:_,isCharacterSame:k,onValueChange:S,format:w,removeFormatting:A,getCaretBoundary:function(P){return EG(P,e)},onKeyDown:I,onBlur:F})}const Y2=(e,t)=>M.useMemo(()=>Bl(t,e),[e,t]),Rn=(e,t)=>M.useMemo(()=>Ii(t,e),[e,t]),oc=()=>{const{chainId:e}=oe();return M.useMemo(()=>Bs(e),[e])},V0=e=>{const t=oc();return M.useMemo(()=>{if(!(!e||!t))return Bi(e,t.id)},[e,t])},aa=(e,t)=>M.useMemo(()=>!e||!t||j(e||"0").isZero()||j(t||"0").isZero()?"":j(e||"0").times(t).toFixed(),[e,t]),TG=()=>{const{srcToken:e,dstToken:t,chainId:r}=oe();return M.useMemo(()=>Lf(e,t,r),[e,t,r])},AG=()=>{const{srcToken:e,dstToken:t,chainId:r}=oe();return M.useMemo(()=>zf(e,t,r),[e,t,r])},SG=()=>{const e=TG(),t=AG();return e||t},W0=e=>{const{overrides:t}=oe();return M.useMemo(()=>t!=null&&t.dateFormat?t.dateFormat(e||0):ee(e).format("DD/MM/YYYY HH:mm"),[e,t==null?void 0:t.dateFormat])};function PG(){const{callbacks:e}=oe();return M.useCallback(async t=>{var r;try{await navigator.clipboard.writeText(t),(r=e==null?void 0:e.onCopy)==null||r.call(e)}catch(n){console.error("Copy failed:",n)}},[e==null?void 0:e.onCopy])}const Z2=(e,t)=>M.useMemo(()=>_f(e==null?void 0:e.toString(),t),[e,t]),Ze=({value:e,decimalScale:t=3,prefix:r,suffix:n})=>{var c;const s=Z2(e,t),{overrides:a}=oe(),o=a==null?void 0:a.numberFormat,i=CG({allowLeadingZeros:!0,thousandSeparator:",",displayType:"text",value:s||"",decimalScale:18,prefix:r,suffix:n});return o?o(e||""):(c=i.value)==null?void 0:c.toString()},IG={expirationTooltip:"This is the date and time marking the end of the period which you have selected for your order to be executed.",tradeSizeTooltip:"The number of input tokens that will be removed from your balance and swapped for the output token in each individual trade.",totalTradesTooltip:"The total number of individual trades that will be scheduled as part of your order. Note that in limit orders, not all trades that are scheduled will be executed.",minDstAmountTooltip:" This is the minimum number of tokens that may be received. NOTE: This minimum only refers to executed trades. Some trades may not be executed if the limit price is higher than the available market prices and your order may only be partially filled.",limitPriceTooltip:"Trades will only execute if the available market price is better than the limit price, potentially resulting in partial fills or orders remaining unfilled upon expiration.",maxDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, partially filled, or remain unfilled based on the specified parameters.",tradeIntervalTooltip:"The estimated time that will elapse between each trade in your order. Note that as this time includes an allowance of two minutes for bidder auction and block settlement, which cannot be predicted exactly, actual time may vary.",triggerPriceTooltip:"The price at which the order will be executed. If the market price is higher than the trigger price, the order will be executed at the market price.",placeOrder:"Place order",enterAmount:"Enter an amount",emptyLimitPrice:"Limit price is required",insufficientFunds:"Insufficient Balance",tradeIntervalLabel:"Trade interval",expirationLabel:"Expiration",limitPrice:"Limit Price",finalExcecutionPrice:"Final execution price",marketPrice:"Market price",from:"From",to:"To (estimated)",Open:"Open",Completed:"Completed",Expired:"Expired",Canceled:"Canceled",cancelOrder:"Cancel Order",minReceivedPerTrade:"Min. received per trade",triggerPricePerChunk:"Trigger Price per trade",maxChunksError:"Max. trades amount is {maxChunks}",minChunksError:"Min. trades amount is {minChunks}",minTradeSizeError:"Min. trade size is ${minTradeSize}",allOrders:"All",minFillDelayError:"Min. trade interval is {fillDelay}",maxFillDelayError:"Max. trade interval is {fillDelay}",recipient:"Recipient",marketOrderWarning:"Each individual trade in this order will be filled at the current market price at the time of execution.",limitPriceMessage:"Limit orders may not execute when the token's price is equal or close to the limit price, due to gas and standard swap fees.",limit:"Limit",maxDurationError:"Max. expiry is {duration}",minDurationError:"Min. expiry is {duration}",expiry:"Expiry",individualTradeSize:"Individual trade size",numberOfTrades:"No. of trades",averageExecutionPrice:"Avg. execution price",twapMarket:"TWAP-market",twapLimit:"TWAP-limit",stopLoss:"Stop-loss",stopLossMarket:"Stop-loss market",stopLossLimit:"Stop-loss limit",takeProfit:"Take-profit",minReceived:"Min. received",noOrders:"No {status} Orders",noLiquidity:"No liquidity for this pair",excecutionSummary:"Execution summary",orderInfo:"Order info",wrapAction:"Wrap {symbol}",approveAction:"Approve {symbol}",createOrderAction:"Create {name} order",amountReceived:"Amount received",createdAt:"Created at",amountOut:"Amount out",status:"Status",progress:"Progress",minutes:"minutes",days:"days",tradeIntervalTitle:"Every",tradesAmountTitle:"Over",stopLossTooltip:"The trigger price at which your stop-loss order will be activated.",takeProfitTooltip:"The trigger price at which your take-profit order will be activated.",stopLossLabel:"Trigger Price",StopLossTriggerPriceError:"Trigger price must be less than market price",TakeProfitTriggerPriceError:"Trigger price must be greater than market price",triggerLimitPriceError:"Limit price must be less than trigger price",triggerPrice:"Trigger Price",tradePrice:"Trade Price",triggerMarketPriceDisclaimer:" In extreme market movements, slippage may occur and the executed price of the market order may be worse than the specified trigger price.",stopLossLimitPriceTooltip:"The stop loss order will execute at the specified limit price or better, once the stop price is triggered.",stopLossDurationTooltip:"This is the time period during which the order will be active. Please note that orders may be completed earlier than this time, or remain unfilled based on the specified parameters.",emptyTriggerPrice:"Trigger price is required",id:"ID",fees:"Fees {value}",version:"Version",maxOrderSizeError:"Max. trade size is {maxOrderSize} USD",viewOnExplorer:"View on explorer",proceedInWallet:"Proceed in wallet",wrapMsg:"Note: {symbol} was wrapped to {wSymbol}",createOrderActionSuccess:"{name} order placed"};function BG(e){let t=e;const r=/\{[^{}]*\}/g;for(;r.test(t);)t=t.replace(r,"");return t}const Me=()=>{const e=oe();return M.useCallback((r,n)=>{var o,i;const s=(o=e.getTranslation)==null?void 0:o.call(e,r,n);if(s&&s!==r)return s;const a=((i=e.translations)==null?void 0:i[r])||IG[r];return BG(a.replace(/{(\w+)}/g,(c,l)=>(n==null?void 0:n[l])||c))},[e.getTranslation,e.translations])},Uu=({value:e})=>{const t=Ze({value:e,decimalScale:2});return t?B.jsx("small",{className:"twap-order-details__detail-row-value-usd",children:` ($${t})`}):null},FG=({deadline:e,label:t,tooltip:r})=>{const n=W0(e);return B.jsx(Ar,{title:t,tooltip:r,children:n})},UG=({price:e,dstToken:t,label:r,tooltip:n,usd:s,srcToken:a})=>{const o=Ze({value:e});return j(e||0).isZero()?null:B.jsx(Ar,{title:r,tooltip:n,children:B.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["1 ",a==null?void 0:a.symbol," = ",`${o||"-"} ${t==null?void 0:t.symbol}`,B.jsx(Uu,{value:s})]})})},OG=({tradeSize:e,srcToken:t,trades:r,label:n,tooltip:s})=>r===1?null:B.jsx(Ar,{title:n,tooltip:s,children:`${e||"-"} ${(t==null?void 0:t.symbol)||""}`}),DG=({dstToken:e,dstMinAmountOut:t,label:r,tooltip:n,usd:s})=>{const a=Ze({value:t});return j(t||0).isZero()?null:B.jsxs(Ar,{title:r,tooltip:n,children:[`${t?a:"-"} ${e==null?void 0:e.symbol}`,B.jsx(Uu,{value:s})]})},_G=({trades:e,label:t,tooltip:r})=>e===1?null:B.jsx(Ar,{title:t,tooltip:r,children:e}),MG=()=>{var s;const e=Me(),{account:t}=oe(),r=(s=oc())==null?void 0:s.explorer,n=Df(t);return B.jsx(Ar,{title:e("recipient")||"",children:r?B.jsx("a",{href:`${r}/address/${t}`,target:"_blank",children:n}):n})},NG=({fillDelayMillis:e,chunks:t=0,label:r,tooltip:n})=>{const s=M.useMemo(()=>t6(e),[e]);return t===1?null:B.jsx(Ar,{title:r,tooltip:n,children:s})},Ar=({title:e,tooltip:t,children:r,className:n="",onClick:s,style:a})=>{const{components:o}=oe(),i=o.Tooltip;return B.jsxs("div",{className:`${n} twap-order-details__detail-row`,onClick:s,style:a,children:[B.jsxs("div",{className:"twap-order-details__detail-row-label",children:[B.jsx("p",{className:"twap-order-details__detail-row-label-value",children:e}),t&&i&&B.jsx(i,{tooltipText:t})]}),B.jsx("div",{className:"twap-order-details__detail-row-value",children:r})]})},LG=({id:e})=>{const{components:t}=oe(),r=t==null?void 0:t.Tooltip,n=PG();return e.startsWith("0x")?B.jsx(Ar,{title:"ID",onClick:()=>n(e),style:{cursor:"pointer"},children:r&&B.jsx(r,{tooltipText:e,children:B.jsxs("div",{className:"twap-order-details__detail-row-value-id",children:[B.jsx("p",{children:Df(e)}),B.jsx(iz.AiOutlineCopy,{})]})})}):B.jsx(Ar,{title:"ID",children:e})},zG=({version:e})=>B.jsx(Ar,{title:"Version",children:e});function Ee({children:e,className:t=""}){return B.jsx("div",{className:`${t} twap-order-details`,children:e})}const RG=({children:e})=>e,HG=({fees:e,label:t,usd:r,dstTokenSymbol:n})=>{const s=Ze({value:e});return B.jsxs(Ar,{title:t,children:[`${e?s:"-"} ${n}`,B.jsx(Uu,{value:r})]})};Ee.Deadline=FG,Ee.Fees=HG,Ee.TradeSize=OG,Ee.MinDestAmount=DG,Ee.TradesAmount=_G,Ee.Recipient=MG,Ee.TradeInterval=NG,Ee.DetailRow=Ar,Ee.Price=UG,Ee.OrderID=LG,Ee.Container=RG,Ee.OrderVersion=zG,Ee.USD=Uu;const q0=()=>{const{publicClient:e}=oe();return Zr({mutationFn:async t=>{if(!e)throw new Error("publicClient is not defined");const r=10;let n=0,s=1e3;for(;n<r;)try{return await e.waitForTransactionReceipt({hash:t,confirmations:2,retryDelay:s})}catch(a){if(n++,n>=r)throw new Error(`Failed after ${r} attempts: ${a}`);await new Promise(o=>setTimeout(o,s)),s*=2}}}).mutateAsync},X2=e=>{const t=Me(),r=Ze({value:e.srcAmount}),n=Ze({value:e.limitPrice}),s=Ze({value:e.limitPriceUsd}),a=Ze({value:e.srcAmountPerTrade}),o=Ze({value:e.srcAmountPerTradeUsd,decimalScale:2}),i=Ze({value:e.minDestAmountPerTrade}),c=Ze({value:e.minDestAmountPerTradeUsd,decimalScale:2}),l=Ze({value:e.triggerPrice}),u=Ze({value:e.triggerPriceUsd,decimalScale:2}),d=Ze({value:e.srcUsd,decimalScale:2}),f=Ze({value:e.dstUsd,decimalScale:2}),h=Ze({value:e.dstAmount});return M.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,srcUsd:d||"",dstUsd:f||"",limitPrice:{label:t("limitPrice"),tooltip:t("limitPriceTooltip"),value:n||"",usd:s||""},deadline:{tooltip:t("expirationTooltip"),label:t("expirationLabel"),value:e.deadline||0},srcAmount:{label:t("amountOut"),value:r||"",usd:d||""},dstAmount:{value:h||"",usd:f||""},sizePerTrade:{tooltip:t("tradeSizeTooltip"),label:t("individualTradeSize"),value:a||"",usd:o},totalTrades:{tooltip:t("totalTradesTooltip"),label:t("numberOfTrades"),value:e.totalTrades||0},minDestAmountPerTrade:{tooltip:t("minDstAmountTooltip"),label:t(e.totalTrades&&e.totalTrades>1?"minReceivedPerTrade":"minReceived"),value:i||"",usd:c},tradeInterval:{tooltip:t("tradeIntervalTooltip"),label:t("tradeIntervalLabel"),value:e.tradeInterval||0},triggerPrice:{tooltip:t("triggerPriceTooltip"),label:t("triggerPrice"),value:l||"",usd:u},recipient:{label:t("recipient"),value:e.account||""}}),[d,f,n,r,a,o,i,l,u,n,s,h,f,c])},Q2=e=>{const{orders:t}=Ou(),{useToken:r,config:n}=oe(),s=Me(),a=M.useMemo(()=>t==null?void 0:t.all.find(C=>C.id===e),[t,e])||{},o=tx(a),i=r==null?void 0:r(a==null?void 0:a.srcTokenAddress),c=r==null?void 0:r(a==null?void 0:a.dstTokenAddress),l=Rn(i==null?void 0:i.decimals,a==null?void 0:a.srcAmount),u=jG(i,c,a),d=VG(i,c,a),f=WG(i,c,a),h=Rn(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountFilled),y=Rn(c==null?void 0:c.decimals,a==null?void 0:a.dstAmountFilled),g=a==null?void 0:a.progress,E=Rn(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountPerTrade),v=Rn(c==null?void 0:c.decimals,a==null?void 0:a.dstMinAmountPerTrade),w=M.useMemo(()=>a?a.version===2?a.fillDelay:n.twapConfig?td(a,n.twapConfig):0:0,[a,n]),A=X2({srcToken:i,dstToken:c,account:a==null?void 0:a.maker,limitPrice:u,deadline:a==null?void 0:a.deadline,tradeInterval:w,srcAmount:l,totalTrades:a==null?void 0:a.totalTradesAmount,srcAmountPerTrade:E,minDestAmountPerTrade:v,triggerPrice:d});return M.useMemo(()=>({original:a,title:o,...A,createdAt:{label:s("createdAt"),value:a==null?void 0:a.createdAt},id:{label:s("id"),value:a==null?void 0:a.id},amountInFilled:{label:s("amountOut"),value:h},amountOutFilled:{label:s("amountReceived"),value:y,token:c},progress:{label:s("progress"),value:g},excecutionPrice:{label:s((a==null?void 0:a.totalTradesAmount)===1?"finalExcecutionPrice":"averageExecutionPrice"),value:f},version:{label:s("version"),value:a==null?void 0:a.version}}),[a,s,f,h,y,g,o,i,c,A])},J2=e=>{const t=Me();return M.useMemo(()=>{switch(e){case ze.TWAP_MARKET:return t("twapMarket");case ze.TWAP_LIMIT:return t("twapLimit");case ze.STOP_LOSS_MARKET:return t("stopLossMarket");case ze.STOP_LOSS_LIMIT:return t("stopLossLimit");case ze.TAKE_PROFIT:return t("takeProfit");default:return t("twapMarket")}},[t,e])},$G=()=>{const{module:e}=oe(),t=te(r=>r.state.isMarketOrder);return M.useMemo(()=>e===ye.TWAP?t?ze.TWAP_MARKET:ze.TWAP_LIMIT:e===ye.LIMIT?t?ze.LIMIT:ze.TWAP_LIMIT:e===ye.STOP_LOSS?t?ze.STOP_LOSS_MARKET:ze.STOP_LOSS_LIMIT:e===ye.TAKE_PROFIT?ze.TAKE_PROFIT:ze.TWAP_MARKET,[e,t])},ex=()=>{const e=$G();return J2(e)},tx=e=>J2(e==null?void 0:e.type),rx=()=>{const{account:e,config:t,chainId:r}=oe();return M.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,r],[e,t,r])},GG=()=>{const{callbacks:e,refetchBalances:t}=oe(),r=Td(),n=rx();return M.useCallback(s=>{var c;const a=r.getQueryData(n);let o=!1;const i=[];a&&a.forEach(l=>{var d;const u=s.find(f=>f.id===l.id);!(u!=null&&u.twapAddress)&&l.twapAddress&&u&&u.progress!==l.progress&&(o=!0,i.push(u),u.status===ct.Completed&&((d=e==null?void 0:e.onOrderFilled)==null||d.call(e,u)))}),o&&((c=e==null?void 0:e.onOrdersProgressUpdate)==null||c.call(e,i),t==null||t())},[r,n,e,t])},K0=()=>{const{account:e,config:t,chainId:r}=oe(),n=rx(),s=GG();return d3({refetchInterval:QL,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:o})=>{if(!e||!r||!t)return[];const i=await _m({signal:o,chainId:r,config:t,account:e});return s(i),i.map(c=>t!=null&&t.twapConfig?{...c,fillDelayMillis:td(c,t.twapConfig)}:c)}})},Ou=()=>{const{data:e,isLoading:t,error:r,refetch:n,isRefetching:s}=K0(),{mutateAsync:a}=Y0();return M.useMemo(()=>({orders:{all:e??[],open:Du(e??[],ct.Open),completed:Du(e??[],ct.Completed),expired:Du(e??[],ct.Expired),canceled:Du(e??[],ct.Canceled)},isLoading:t,error:r,refetch:()=>n().then(o=>o.data),cancelOrder:a,isRefetching:s}),[e,t,r,n,a,s])},nx=()=>{const e=te(r=>r.state.orderHistoryStatusFilter),{orders:t}=Ou();return M.useMemo(()=>e?t.all.filter(r=>r.status.toLowerCase()===e.toLowerCase())||[]:t.all,[e,t])},Du=(e,t)=>e.filter(r=>r.status===t).sort((r,n)=>n.createdAt-r.createdAt),jG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return jh(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),VG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return Vh(r,e.decimals,t.decimals)},[r,e,t]),WG=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return Gh(r,e.decimals,t.decimals)},[r,e,t]),sx=()=>{const e=te(r=>r.updateState),t=te(r=>r.state.orderIdsToCancel);return M.useCallback(r=>{t!=null&&t.includes(r)?e({orderIdsToCancel:t==null?void 0:t.filter(n=>n!==r)}):e({orderIdsToCancel:[...t||[],r]})},[e,t])},qG=()=>{var T,m;const e=Me(),{orders:t,isLoading:r,refetch:n,isRefetching:s}=Ou(),{mutateAsync:a,isPending:o}=Y0(),i=nx(),c=te(b=>b.updateState),l=te(b=>b.state.orderHistoryStatusFilter),u=te(b=>b.state.cancelOrdersMode),d=te(b=>b.state.orderIdsToCancel),f=M.useCallback(b=>c({cancelOrdersMode:b,orderIdsToCancel:[]}),[c]),h=M.useCallback(()=>c({selectedOrderID:void 0}),[c]),y=M.useCallback(b=>a({orders:b}),[a]),g=M.useCallback(b=>c({orderHistoryStatusFilter:b}),[]),E=M.useMemo(()=>{const b=Object.keys(ct).map(x=>({text:x,value:x}));return[{text:e("allOrders"),value:""},...b]},[e]),v=sx(),w=te(b=>b.state.selectedOrderID),A=Q2(w),C=M.useMemo(()=>t.all.filter(b=>d==null?void 0:d.includes(b.id)),[t,d]),D=M.useCallback(()=>c({orderIdsToCancel:t.open.map(b=>b.id)}),[c,t]),z=M.useCallback(b=>a({orders:[b]}).then(x=>(x==null?void 0:x[0])||""),[a]);return{refetch:n,onHideSelectedOrder:h,onCancelOrders:y,onCancelOrder:z,onSelectStatus:g,onToggleCancelOrdersMode:f,onSelectOrder:v,isRefetching:s,orders:t,ordersToDisplay:i,isLoading:r,selectedOrder:w?A:void 0,openOrdersCount:((T=t==null?void 0:t.open)==null?void 0:T.length)||0,isCancelOrdersLoading:o,selectedStatus:l||((m=E[0])==null?void 0:m.value)||"",statuses:E,cancelOrdersMode:u,ordersToCancel:C,onSelectAllOrdersToCancel:D}},KG=()=>{const{refetch:e}=K0();return Zr({mutationFn:async t=>{var r;for(;;){const n=(r=await e())==null?void 0:r.data;if(!n)throw new Error("orders not found");if(t.every(a=>{const o=n.find(i=>i.id===a);return(o==null?void 0:o.status)===ct.Canceled}))break;await new Promise(a=>setTimeout(a,1e3))}}})},Y0=()=>{const{account:e,walletClient:t,publicClient:r,config:n,callbacks:s,chainId:a}=oe(),o=q0(),i=KG().mutateAsync,c=te(d=>d.updateState),l=async d=>{dt.onCancelOrderRequest(d.map(f=>f.id.toString()),1);try{return(await Promise.all(d.map(h=>t.writeContract({account:e,address:h.twapAddress,abi:Lh,functionName:"cancel",args:[h.id],chain:t.chain}))))[0]}catch(f){throw dt.onCancelOrderError(f),f}},u=async d=>{var f;try{dt.onCancelOrderRequest(d.map(g=>g.hash),2);const h=await t.writeContract({account:e,address:n.repermit,abi:Nh,functionName:"cancel",args:[d.map(g=>g.hash)],chain:t.chain}),y=await o(h);if(!y)throw new Error("failed to get transaction receipt");if(y.status==="reverted")throw new Error("failed to cancel order");return dt.onCancelOrderSuccess(h),(f=s==null?void 0:s.onCancelOrderSuccess)==null||f.call(s,{orders:d,txHash:h,explorerUrl:Bi(h,a)}),y.transactionHash}catch(h){throw dt.onCancelOrderError(h),h}};return Zr({mutationFn:async({orders:d})=>{var f,h;if(!e||!t||!r||!n)throw new Error("missing required parameters");try{(f=s==null?void 0:s.onCancelOrderRequest)==null||f.call(s,d),c({cancelOrderStatus:ht.LOADING,cancelOrderTxHash:void 0,cancelOrderError:void 0});const y=d.filter(w=>w.version===1),g=d.filter(w=>w.version===2),[E,v]=await Promise.all([y.length?l(y):Promise.resolve(""),g.length?u(g):Promise.resolve("")]);return await i(d.map(w=>w.id)),c({cancelOrderStatus:ht.SUCCESS,orderIdsToCancel:[]}),[...E||[],v]}catch(y){console.error("cancel order error",y),(h=s==null?void 0:s.onCancelOrderFailed)==null||h.call(s,y),Mf(y)?c({cancelOrderStatus:void 0}):(c({cancelOrderStatus:ht.FAILED}),dt.onCancelOrderError(y))}}})},ax=M.createContext({}),zt=()=>M.useContext(ax),YG=()=>{const e=te(c=>c.state.selectedOrderID),t=Q2(e),r=Me(),[n,s]=M.useState("panel1"),{components:a}=oe(),o=a.TokenLogo;M.useEffect(()=>{s("panel1")},[t.id.value]);const i=c=>{s(n===c?!1:c)};return t?B.jsx(ax.Provider,{value:{order:t},children:B.jsxs("div",{className:"twap-orders__selected-order",children:[B.jsx(p1,{SrcTokenLogo:o&&B.jsx(o,{token:t.srcToken}),DstTokenLogo:o&&B.jsx(o,{token:t.dstToken}),fromTitle:r("from"),inToken:t.srcToken,toTitle:r("to"),outToken:t.dstToken}),B.jsx(Ee.Container,{children:B.jsxs("div",{className:"twap-orders__selected-order-bottom",children:[B.jsxs("div",{className:"twap-orders__selected-order-accordions",children:[B.jsx(ox,{title:r("excecutionSummary"),onClick:()=>i("panel1"),expanded:n==="panel1",children:B.jsx(sj,{})}),B.jsx(ox,{title:r("orderInfo"),expanded:n==="panel2",onClick:()=>i("panel2"),children:B.jsx(ZG,{})})]}),B.jsx(oj,{})]})})]})}):null},ox=({expanded:e,onClick:t,children:r,title:n})=>B.jsxs("div",{className:"twap-orders__selected-order-accordion",children:[B.jsxs("div",{onClick:t,className:"twap-orders__selected-order-accordion-trigger",children:[B.jsx("p",{children:n}),B.jsx(az.IoIosArrowDown,{style:{transform:e?"rotate(180deg)":"rotate(0deg)"}})]}),e&&B.jsx("div",{className:"twap-orders__selected-order-accordion-details",children:r})]}),ZG=()=>B.jsxs(Ee,{children:[B.jsx(nj,{}),B.jsx(ij,{}),B.jsx(ej,{}),B.jsx(cj,{}),B.jsx(XG,{}),B.jsx(QG,{}),B.jsx(JG,{}),B.jsx(tj,{}),B.jsx(rj,{}),B.jsx(fj,{}),B.jsx(Ee.Recipient,{})]}),XG=()=>{const{order:e}=zt();return B.jsx(Ee.TradeSize,{tradeSize:e.sizePerTrade.value,srcToken:e.srcToken,label:e.sizePerTrade.label,tooltip:e.sizePerTrade.tooltip,trades:e.totalTrades.value})},QG=()=>{const{order:e}=zt();return B.jsx(Ee.TradesAmount,{trades:e.totalTrades.value,label:e.totalTrades.label,tooltip:e.totalTrades.tooltip})},JG=()=>{const{order:e}=zt();return B.jsx(Ee.MinDestAmount,{dstToken:e.dstToken,dstMinAmountOut:e.minDestAmountPerTrade.value,label:e.minDestAmountPerTrade.label,tooltip:e.minDestAmountPerTrade.tooltip})},ej=()=>{const{order:e}=zt();return B.jsx(Ee.Deadline,{deadline:e.deadline.value,label:e.deadline.label,tooltip:e.deadline.tooltip})},tj=()=>{const{order:e}=zt();return B.jsx(Ee.TradeInterval,{fillDelayMillis:e.tradeInterval.value,chunks:e.totalTrades.value,label:e.tradeInterval.label,tooltip:e.tradeInterval.tooltip})},rj=()=>{const{order:e}=zt();return B.jsx(Ee.Price,{srcToken:e.srcToken,dstToken:e.dstToken,price:e.triggerPrice.value,label:e.triggerPrice.label,tooltip:e.triggerPrice.tooltip})},nj=()=>{const{order:e}=zt();return B.jsx(Ee.OrderID,{id:e.id.value||""})},sj=()=>B.jsxs(Ee,{children:[B.jsx(dj,{}),B.jsx(lj,{}),B.jsx(aj,{}),B.jsx(pj,{}),B.jsx(hj,{})]}),aj=()=>{var r;const{order:e}=zt(),t=Ze({value:e.amountOutFilled.value,decimalScale:3});return e.amountOutFilled.value?B.jsx(Ee.DetailRow,{title:e.amountOutFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.dstToken)==null?void 0:r.symbol]})}):null},oj=()=>{const{order:e}=zt(),t=Me(),{mutateAsync:r,isPending:n}=Y0(),{components:s}=oe(),a=s.Button,o=M.useCallback(async()=>r({orders:[e.original]}),[r,e]);return!e||e.original.status!==ct.Open||!a?null:B.jsx(a,{loading:n,onClick:o,disabled:n,className:"twap-cancel-order",text:t("cancelOrder"),children:t("cancelOrder")})},ij=()=>{const{order:e}=zt(),t=Me(),r=W0(e.createdAt.value);return B.jsx(Ee.DetailRow,{title:t("createdAt")||"",children:B.jsx("p",{children:r})})},cj=()=>{var n;const{order:e}=zt(),t=Me(),r=Ze({value:e.srcAmount.value,decimalScale:3});return B.jsx(Ee.DetailRow,{title:t("amountOut")||"",children:B.jsxs("p",{children:[r||0," ",(n=e.srcToken)==null?void 0:n.symbol]})})},lj=()=>{var r;const{order:e}=zt(),t=Ze({value:e.amountInFilled.value,decimalScale:3});return B.jsx(Ee.DetailRow,{title:e.amountInFilled.label,children:B.jsxs("p",{children:[t||"-"," ",(r=e.srcToken)==null?void 0:r.symbol]})})},uj=()=>{const{order:e}=zt(),t=Me();return M.useMemo(()=>{switch(e.original.status){case ct.Open:return t("Open")||"";case ct.Completed:return t("Completed")||"";case ct.Expired:return t("Expired")||"";case ct.Canceled:return t("Canceled")||""}},[e.original.status,t])},dj=()=>{const e=Me(),t=uj();return B.jsx(Ee.DetailRow,{title:e("status")||"",children:B.jsx("p",{children:t})})},pj=()=>{const{order:e}=zt(),t=Ze({value:e.progress.value,decimalScale:2});return B.jsx(Ee.DetailRow,{title:e.progress.label,children:B.jsxs("p",{children:[t||0,"%"]})})},fj=()=>{const{order:e}=zt(),t=Me();return e.limitPrice.value?B.jsx(Ee.Price,{label:t("limitPrice")||"",price:e.limitPrice.value,srcToken:e.srcToken,dstToken:e.dstToken,tooltip:e.limitPrice.tooltip}):null},hj=()=>{const{order:e}=zt();return e.excecutionPrice.value?B.jsx(Ee.Price,{label:e.excecutionPrice.label,price:e.excecutionPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null};var Z0={},ix;function mj(){if(ix)return Z0;ix=1;var e=lu.GenIcon;return Z0.HiArrowRight=function(r){return e({tag:"svg",attr:{viewBox:"0 0 20 20",fill:"currentColor"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",clipRule:"evenodd"}}]})(r)},Z0}var bj=mj();const _u=0,fs=1,mo=2,cx=4;function lx(e){return()=>e}function yj(e){e()}function ux(e,t){return r=>e(t(r))}function dx(e,t){return()=>e(t)}function gj(e,t){return r=>e(t,r)}function X0(e){return e!==void 0}function xj(...e){return()=>{e.map(yj)}}function bo(){}function Mu(e,t){return t(e),e}function wj(e,t){return t(e)}function tt(...e){return e}function je(e,t){return e(fs,t)}function Ce(e,t){e(_u,t)}function Q0(e){e(mo)}function at(e){return e(cx)}function ce(e,t){return je(e,gj(t,_u))}function Vr(e,t){const r=e(fs,n=>{r(),t(n)});return r}function px(e){let t,r;return n=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{n(t)},e)}}function fx(e,t){return e===t}function rt(e=fx){let t;return r=>n=>{e(t,n)||(t=n,r(n))}}function fe(e){return t=>r=>{e(r)&&t(r)}}function re(e){return t=>ux(t,e)}function cn(e){return t=>()=>{t(e)}}function W(e,...t){const r=vj(...t);return(n,s)=>{switch(n){case mo:Q0(e);return;case fs:return je(e,r(s))}}}function ln(e,t){return r=>n=>{r(t=e(t,n))}}function oa(e){return t=>r=>{e>0?e--:t(r)}}function Hn(e){let t=null,r;return n=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,n(t)},e))}}function Te(...e){const t=new Array(e.length);let r=0,n=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{const l=r;r=r|i,t[o]=c,l!==s&&r===s&&n&&(n(),n=null)})}),a=>o=>{const i=()=>{a([o].concat(t))};r===s?i():n=i}}function vj(...e){return t=>e.reduceRight(wj,t)}function Ej(e){let t,r;const n=()=>t==null?void 0:t();return function(s,a){switch(s){case fs:return a?r===a?void 0:(n(),r=a,t=je(e,a),t):(n(),bo);case mo:n(),r=null;return}}}function Y(e){let t=e;const r=Ue();return(n,s)=>{switch(n){case _u:t=s;break;case fs:{s(t);break}case cx:return t}return r(n,s)}}function Rt(e,t){return Mu(Y(t),r=>ce(e,r))}function Ue(){const e=[];return(t,r)=>{switch(t){case _u:e.slice().forEach(n=>{n(r)});return;case mo:e.splice(0,e.length);return;case fs:return e.push(r),()=>{const n=e.indexOf(r);n>-1&&e.splice(n,1)}}}}function mr(e){return Mu(Ue(),t=>ce(e,t))}function $e(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:kj(),singleton:r}}const kj=()=>Symbol();function Cj(e){const t=new Map,r=({constructor:n,dependencies:s,id:a,singleton:o})=>{if(o&&t.has(a))return t.get(a);const i=n(s.map(c=>r(c)));return o&&t.set(a,i),i};return r(e)}function Et(...e){const t=Ue(),r=new Array(e.length);let n=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,o)=>{const i=Math.pow(2,o);je(a,c=>{r[o]=c,n=n|i,n===s&&Ce(t,r)})}),function(a,o){switch(a){case mo:{Q0(t);return}case fs:return n===s&&o(r),je(t,o)}}}function he(e,t=fx){return W(e,rt(t))}function J0(...e){return function(t,r){switch(t){case mo:return;case fs:return xj(...e.map(n=>je(n,r)))}}}var nr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(nr||{});const Tj={0:"debug",3:"error",1:"log",2:"warn"},Aj=()=>typeof globalThis>"u"?window:globalThis,hs=$e(()=>{const e=Y(3);return{log:Y((t,r,n=1)=>{var s;const a=(s=Aj().VIRTUOSO_LOG_LEVEL)!=null?s:at(e);n>=a&&console[Tj[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function ia(e,t,r){return eh(e,t,r).callbackRef}function eh(e,t,r){const n=M.useRef(null);let s=o=>{};const a=M.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const i=()=>{const c=o[0].target;c.offsetParent!==null&&e(c)};r?i():requestAnimationFrame(i)}):null,[e,r]);return s=o=>{o&&t?(a==null||a.observe(o),n.current=o):(n.current&&(a==null||a.unobserve(n.current)),n.current=null)},{callbackRef:s,ref:n}}function Sj(e,t,r,n,s,a,o,i,c){const l=M.useCallback(u=>{const d=Pj(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const h=f.lastElementChild.dataset.viewportType==="window";let y;h&&(y=f.ownerDocument.defaultView);const g=o?i?o.scrollLeft:o.scrollTop:h?i?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,E=o?i?o.scrollWidth:o.scrollHeight:h?i?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,v=o?i?o.offsetWidth:o.offsetHeight:h?i?y.innerWidth:y.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:E,scrollTop:Math.max(g,0),viewportHeight:v}),a==null||a(i?hx("column-gap",getComputedStyle(u).columnGap,s):hx("row-gap",getComputedStyle(u).rowGap,s)),d!==null&&e(d)},[e,t,s,a,o,n,i]);return eh(l,r,c)}function Pj(e,t,r,n){const s=e.length;if(s===0)return null;const a=[];for(let o=0;o<s;o++){const i=e.item(o);if(i.dataset.index===void 0)continue;const c=parseInt(i.dataset.index),l=parseFloat(i.dataset.knownSize),u=t(i,r);if(u===0&&n("Zero-sized element, this should not happen",{child:i},nr.ERROR),u===l)continue;const d=a[a.length-1];a.length===0||d.size!==u||d.endIndex!==c-1?a.push({endIndex:c,size:u,startIndex:c}):a[a.length-1].endIndex++}return a}function hx(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}function mx(e,t,r){const n=M.useRef(null),s=M.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const l=c.getBoundingClientRect(),u=l.width;let d,f;if(t){const h=t.getBoundingClientRect(),y=l.top-h.top;f=h.height-Math.max(0,y),d=y+t.scrollTop}else{const h=o.current.ownerDocument.defaultView;f=h.innerHeight-Math.max(0,l.top),d=l.top+h.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:a,ref:o}=eh(s,!0,r),i=M.useCallback(()=>{s(o.current)},[s,o]);return M.useEffect(()=>{var c;if(t){t.addEventListener("scroll",i);const l=new ResizeObserver(()=>{requestAnimationFrame(i)});return l.observe(t),()=>{t.removeEventListener("scroll",i),l.unobserve(t)}}else{const l=(c=o.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",i),l==null||l.addEventListener("resize",i),()=>{l==null||l.removeEventListener("scroll",i),l==null||l.removeEventListener("resize",i)}}},[i,t,o]),a}const Wt=$e(()=>{const e=Ue(),t=Ue(),r=Y(0),n=Ue(),s=Y(0),a=Ue(),o=Ue(),i=Y(0),c=Y(0),l=Y(0),u=Y(0),d=Ue(),f=Ue(),h=Y(!1),y=Y(!1),g=Y(!1);return ce(W(e,re(({scrollTop:E})=>E)),t),ce(W(e,re(({scrollHeight:E})=>E)),o),ce(t,s),{deviation:r,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:i,horizontalDirection:y,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:h,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),ic={lvl:0};function bx(e,t){const r=e.length;if(r===0)return[];let{index:n,value:s}=t(e[0]);const a=[];for(let o=1;o<r;o++){const{index:i,value:c}=t(e[o]);a.push({end:i-1,start:n,value:s}),n=i,s=c}return a.push({end:1/0,start:n,value:s}),a}function qe(e){return e===ic}function cc(e,t){if(!qe(e))return t===e.k?e.v:t<e.k?cc(e.l,t):cc(e.r,t)}function Wr(e,t,r="k"){if(qe(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const n=Wr(e.r,t,r);return n[0]===-1/0?[e.k,e.v]:n}return Wr(e.l,t,r)}function br(e,t,r){return qe(e)?xx(t,r,1):t===e.k?At(e,{k:t,v:r}):t<e.k?wx(At(e,{l:br(e.l,t,r)})):wx(At(e,{r:br(e.r,t,r)}))}function yo(){return ic}function go(e,t,r){if(qe(e))return[];const n=Wr(e,t)[0];return Ij(rh(e,n,r))}function th(e,t){if(qe(e))return ic;const{k:r,l:n,r:s}=e;if(t===r){if(qe(n))return s;if(qe(s))return n;{const[a,o]=gx(n);return Nu(At(e,{k:a,l:yx(n),v:o}))}}else return t<r?Nu(At(e,{l:th(n,t)})):Nu(At(e,{r:th(s,t)}))}function ca(e){return qe(e)?[]:[...ca(e.l),{k:e.k,v:e.v},...ca(e.r)]}function rh(e,t,r){if(qe(e))return[];const{k:n,l:s,r:a,v:o}=e;let i=[];return n>t&&(i=i.concat(rh(s,t,r))),n>=t&&n<=r&&i.push({k:n,v:o}),n<=r&&(i=i.concat(rh(a,t,r))),i}function Nu(e){const{l:t,lvl:r,r:n}=e;if(n.lvl>=r-1&&t.lvl>=r-1)return e;if(r>n.lvl+1){if(nh(t))return vx(At(e,{lvl:r-1}));if(!qe(t)&&!qe(t.r))return At(t.r,{l:At(t,{r:t.r.l}),lvl:r,r:At(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(nh(e))return sh(At(e,{lvl:r-1}));if(!qe(n)&&!qe(n.l)){const s=n.l,a=nh(s)?n.lvl-1:n.lvl;return At(s,{l:At(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:sh(At(n,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return xx(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function yx(e){return qe(e.r)?e.l:Nu(At(e,{r:yx(e.r)}))}function nh(e){return qe(e)||e.lvl>e.r.lvl}function gx(e){return qe(e.r)?[e.k,e.v]:gx(e.r)}function xx(e,t,r,n=ic,s=ic){return{k:e,l:n,lvl:r,r:s,v:t}}function wx(e){return sh(vx(e))}function vx(e){const{l:t}=e;return!qe(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function sh(e){const{lvl:t,r}=e;return!qe(r)&&!qe(r.r)&&r.lvl===t&&r.r.lvl===t?At(r,{l:At(e,{r:r.l}),lvl:t+1}):e}function Ij(e){return bx(e,({k:t,v:r})=>({index:t,value:r}))}function Ex(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function lc(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const ah=$e(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function kx(e,t,r){return e[Lu(e,t,r)]}function Lu(e,t,r,n=0){let s=e.length-1;for(;n<=s;){const a=Math.floor((n+s)/2),o=e[a],i=r(o,t);if(i===0)return a;if(i===-1){if(s-n<2)return a-1;s=a-1}else{if(s===n)return a;n=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function Bj(e,t,r,n){const s=Lu(e,t,n),a=Lu(e,r,n,s);return e.slice(s,a+1)}function ms(e,t){return Math.round(e.getBoundingClientRect()[t])}function zu(e){return!qe(e.groupOffsetTree)}function oh({index:e},t){return t===e?0:t<e?-1:1}function Fj(){return{groupIndices:[],groupOffsetTree:yo(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:yo()}}function Uj(e,t){let r=qe(e)?0:1/0;for(const n of t){const{endIndex:s,size:a,startIndex:o}=n;if(r=Math.min(r,o),qe(e)){e=br(e,0,a);continue}const i=go(e,o-1,s+1);if(i.some(zj(n)))continue;let c=!1,l=!1;for(const{end:u,start:d,value:f}of i)c?(s>=d||a===f)&&(e=th(e,d)):(l=f!==a,c=!0),u>s&&s>=d&&f!==a&&(e=br(e,s+1,f));l&&(e=br(e,o,a))}return[e,r]}function Oj(e){return typeof e.groupIndex<"u"}function Dj({offset:e},t){return t===e?0:t<e?-1:1}function uc(e,t,r){if(t.length===0)return 0;const{index:n,offset:s,size:a}=kx(t,e,oh),o=e-n,i=a*o+(o-1)*r+s;return i>0?i+r:i}function Cx(e,t){if(!zu(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function Tx(e,t,r){if(Oj(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?r:e.index;let s=Cx(n,t);return s=Math.max(0,s,Math.min(r,s)),s}}function _j(e,t,r,n=0){return n>0&&(t=Math.max(t,kx(e,n,oh).offset)),bx(Bj(e,t,r,Dj),Lj)}function Mj(e,[t,r,n,s]){t.length>0&&n("received item sizes",t,nr.DEBUG);const a=e.sizeTree;let o=a,i=0;if(r.length>0&&qe(a)&&t.length===2){const f=t[0].size,h=t[1].size;o=r.reduce((y,g)=>br(br(y,g,f),g+1,h),o)}else[o,i]=Uj(o,t);if(o===a)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=ih(e.offsetTree,i,o,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,h)=>br(f,h,uc(h,d,s)),yo()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Nj(e){return ca(e).map(({k:t,v:r},n,s)=>{const a=s[n+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function Ax(e,t){let r=0,n=0;for(;r<e;)r+=t[n+1]-t[n]-1,n++;return n-(r===e?0:1)}function ih(e,t,r,n){let s=e,a=0,o=0,i=0,c=0;if(t!==0){c=Lu(s,t-1,oh),i=s[c].offset;const l=Wr(r,t-1);a=l[0],o=l[1],s.length&&s[c].size===Wr(r,t)[1]&&(c-=1),s=s.slice(0,c+1)}else s=[];for(const{start:l,value:u}of go(r,t,1/0)){const d=l-a,f=d*o+i+d*n;s.push({index:l,offset:f,size:u}),a=l,i=f,o=u}return{lastIndex:a,lastOffset:i,lastSize:o,offsetTree:s}}function Lj(e){return{index:e.index,value:e}}function zj(e){const{endIndex:t,size:r,startIndex:n}=e;return s=>s.start===n&&(s.end===t||s.end===1/0)&&s.value===r}const Rj={offsetHeight:"height",offsetWidth:"width"},un=$e(([{log:e},{recalcInProgress:t}])=>{const r=Ue(),n=Ue(),s=Rt(n,0),a=Ue(),o=Ue(),i=Y(0),c=Y([]),l=Y(void 0),u=Y(void 0),d=Y(void 0),f=Y(void 0),h=Y((T,m)=>ms(T,Rj[m])),y=Y(void 0),g=Y(0),E=Fj(),v=Rt(W(r,Te(c,e,g),ln(Mj,E),rt()),E),w=Rt(W(c,rt(),ln((T,m)=>({current:m,prev:T.current}),{current:[],prev:[]}),re(({prev:T})=>T)),[]);ce(W(c,fe(T=>T.length>0),Te(v,g),re(([T,m,b])=>{const x=T.reduce((S,I,F)=>br(S,I,uc(I,m.offsetTree,b)||F),yo());return{...m,groupIndices:T,groupOffsetTree:x}})),v),ce(W(n,Te(v),fe(([T,{lastIndex:m}])=>T<m),re(([T,{lastIndex:m,lastSize:b}])=>[{endIndex:m,size:b,startIndex:T}])),r),ce(l,u);const A=Rt(W(l,re(T=>T===void 0)),!0);ce(W(u,fe(T=>T!==void 0&&qe(at(v).sizeTree)),re(T=>{const m=at(d),b=at(c).length>0;return m?b?[{endIndex:0,size:m,startIndex:0},{endIndex:1,size:T,startIndex:1}]:[]:[{endIndex:0,size:T,startIndex:0}]})),r),ce(W(f,fe(T=>T!==void 0&&T.length>0&&qe(at(v).sizeTree)),re(T=>{const m=[];let b=T[0],x=0;for(let S=1;S<T.length;S++){const I=T[S];I!==b&&(m.push({endIndex:S-1,size:b,startIndex:x}),b=I,x=S)}return m.push({endIndex:T.length-1,size:b,startIndex:x}),m})),r),ce(W(c,Te(d,u),fe(([,T,m])=>T!==void 0&&m!==void 0),re(([T,m,b])=>{const x=[];for(let S=0;S<T.length;S++){const I=T[S],F=T[S+1];x.push({startIndex:I,endIndex:I,size:m}),F!==void 0&&x.push({startIndex:I+1,endIndex:F-1,size:b})}return x})),r);const C=mr(W(r,Te(v),ln(({sizes:T},[m,b])=>({changed:b!==T,sizes:b}),{changed:!1,sizes:E}),re(T=>T.changed)));je(W(i,ln((T,m)=>({diff:T.prev-m,prev:m}),{diff:0,prev:0}),re(T=>T.diff)),T=>{const{groupIndices:m}=at(v);if(T>0)Ce(t,!0),Ce(a,T+Ax(T,m));else if(T<0){const b=at(w);b.length>0&&(T-=Ax(-T,b)),Ce(o,T)}}),je(W(i,Te(e)),([T,m])=>{T<0&&m("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:i},nr.ERROR)});const D=mr(a);ce(W(a,Te(v),re(([T,m])=>{const b=m.groupIndices.length>0,x=[],S=m.lastSize;if(b){const I=cc(m.sizeTree,0);let F=0,_=0;for(;F<T;){const P=m.groupIndices[_],O=m.groupIndices.length===_+1?1/0:m.groupIndices[_+1]-P-1;x.push({endIndex:P,size:I,startIndex:P}),x.push({endIndex:P+1+O-1,size:S,startIndex:P+1}),_++,F+=O+1}const k=ca(m.sizeTree);return F!==T&&k.shift(),k.reduce((P,{k:O,v:U})=>{let L=P.ranges;return P.prevSize!==0&&(L=[...P.ranges,{endIndex:O+T-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:O+T,prevSize:U,ranges:L}},{prevIndex:T,prevSize:0,ranges:x}).ranges}return ca(m.sizeTree).reduce((I,{k:F,v:_})=>({prevIndex:F+T,prevSize:_,ranges:[...I.ranges,{endIndex:F+T-1,size:I.prevSize,startIndex:I.prevIndex}]}),{prevIndex:0,prevSize:S,ranges:[]}).ranges})),r);const z=mr(W(o,Te(v,g),re(([T,{offsetTree:m},b])=>{const x=-T;return uc(x,m,b)})));return ce(W(o,Te(v,g),re(([T,m,b])=>{if(m.groupIndices.length>0){if(qe(m.sizeTree))return m;let x=yo();const S=at(w);let I=0,F=0,_=0;for(;I<-T;){_=S[F];const k=S[F+1]-_-1;F++,I+=k+1}if(x=ca(m.sizeTree).reduce((k,{k:P,v:O})=>br(k,Math.max(0,P+T),O),x),I!==-T){const k=cc(m.sizeTree,_);x=br(x,0,k);const P=Wr(m.sizeTree,-T+1)[1];x=br(x,1,P)}return{...m,sizeTree:x,...ih(m.offsetTree,0,x,b)}}else{const x=ca(m.sizeTree).reduce((S,{k:I,v:F})=>br(S,Math.max(0,I+T),F),yo());return{...m,sizeTree:x,...ih(m.offsetTree,0,x,b)}}})),v),{beforeUnshiftWith:D,data:y,defaultItemSize:u,firstItemIndex:i,fixedItemSize:l,fixedGroupSize:d,gap:g,groupIndices:c,heightEstimates:f,itemSize:h,listRefresh:C,shiftWith:o,shiftWithOffset:z,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:n,trackItemSizes:A,unshiftWith:a}},tt(hs,ah),{singleton:!0});function Hj(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const Sx=$e(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:n,scrollTop:s}])=>{const a=Ue(),o=Ue(),i=mr(W(a,re(Hj)));return ce(W(i,re(c=>c.totalCount)),r),ce(W(i,re(c=>c.groupIndices)),e),ce(W(Et(s,t,n),fe(([c,l])=>zu(l)),re(([c,l,u])=>Wr(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),rt(),re(c=>[c])),o),{groupCounts:a,topItemsIndexes:o}},tt(un,Wt)),bs=$e(([{log:e}])=>{const t=Y(!1),r=mr(W(t,fe(n=>n),rt()));return je(t,n=>{n&&at(e)("props updated",{},nr.DEBUG)}),{didMount:r,propsReady:t}},tt(hs),{singleton:!0}),$j=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Px(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!$j)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const dc=$e(([{gap:e,listRefresh:t,sizes:r,totalCount:n},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:o,headerHeight:i,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{const h=Ue(),y=Ue(),g=Y(0);let E=null,v=null,w=null;function A(){E&&(E(),E=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Ce(c,!1)}return ce(W(h,Te(r,d,n,g,i,o,f),Te(e,a,s),re(([[C,D,z,T,m,b,x,S],I,F,_])=>{const k=Px(C),{align:P,behavior:O,offset:U}=k,L=T-1,H=Tx(k,D,L);let G=uc(H,D.offsetTree,I)+b;P==="end"?(G+=F+Wr(D.sizeTree,H)[1]-z+_,H===L&&(G+=x)):P==="center"?G+=(F+Wr(D.sizeTree,H)[1]-z+_)/2:G-=m,U&&(G+=U);const Q=pe=>{A(),pe?(S("retrying to scroll to",{location:C},nr.DEBUG),Ce(h,C)):(Ce(y,!0),S("list did not change, scroll successful",{},nr.DEBUG))};if(A(),O==="smooth"){let pe=!1;w=je(t,me=>{pe=pe||me}),E=Vr(u,()=>{Q(pe)})}else E=Vr(W(t,Gj(150)),Q);return v=setTimeout(()=>{A()},1200),Ce(c,!0),S("scrolling from index to",{behavior:O,index:H,top:G},nr.DEBUG),{behavior:O,top:G}})),l),{scrollTargetReached:y,scrollToIndex:h,topListHeight:g}},tt(un,Wt,hs),{singleton:!0});function Gj(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(r))}}}function ch(e,t){e==0?t():requestAnimationFrame(()=>{ch(e-1,t)})}function lh(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const pc=$e(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:n},{scrollTargetReached:s,scrollToIndex:a},{didMount:o}])=>{const i=Y(!0),c=Y(0),l=Y(!0);return ce(W(o,Te(c),fe(([u,d])=>!!d),cn(!1)),i),ce(W(o,Te(c),fe(([u,d])=>!!d),cn(!1)),l),je(W(Et(t,o),Te(i,r,e,l),fe(([[,u],d,{sizeTree:f},h,y])=>u&&(!qe(f)||X0(h))&&!d&&!y),Te(c)),([,u])=>{Vr(s,()=>{Ce(l,!0)}),ch(4,()=>{Vr(n,()=>{Ce(i,!0)}),Ce(a,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:i}},tt(un,Wt,dc,bs),{singleton:!0});function Ix(e,t){return Math.abs(e-t)<1.01}const fc="up",hc="down",jj="none",Vj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Wj=0,mc=$e(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:n,scrollTop:s,viewportHeight:a}])=>{const o=Y(!1),i=Y(!0),c=Ue(),l=Ue(),u=Y(4),d=Y(Wj),f=Rt(W(J0(W(he(s),oa(1),cn(!0)),W(he(s),oa(1),cn(!1),px(100))),rt()),!1),h=Rt(W(J0(W(r,cn(!0)),W(r,cn(!1),px(200))),rt()),!1);ce(W(Et(he(s),he(d)),re(([w,A])=>w<=A),rt()),i),ce(W(i,Hn(50)),l);const y=mr(W(Et(n,he(a),he(t),he(e),he(u)),ln((w,[{scrollHeight:A,scrollTop:C},D,z,T,m])=>{const b=C+D-A>-m,x={scrollHeight:A,scrollTop:C,viewportHeight:D};if(b){let I,F;return C>w.state.scrollTop?(I="SCROLLED_DOWN",F=w.state.scrollTop-C):(I="SIZE_DECREASED",F=w.state.scrollTop-C||w.scrollTopDelta),{atBottom:!0,atBottomBecause:I,scrollTopDelta:F,state:x}}let S;return x.scrollHeight>w.state.scrollHeight?S="SIZE_INCREASED":D<w.state.viewportHeight?S="VIEWPORT_HEIGHT_DECREASING":C<w.state.scrollTop?S="SCROLLING_UPWARDS":S="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:S,state:x}},Vj),rt((w,A)=>w&&w.atBottom===A.atBottom))),g=Rt(W(n,ln((w,{scrollHeight:A,scrollTop:C,viewportHeight:D})=>{if(Ix(w.scrollHeight,A))return{changed:!1,jump:0,scrollHeight:A,scrollTop:C};{const z=A-(C+D)<1;return w.scrollTop!==C&&z?{changed:!0,jump:w.scrollTop-C,scrollHeight:A,scrollTop:C}:{changed:!0,jump:0,scrollHeight:A,scrollTop:C}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),re(w=>w.jump)),0);ce(W(y,re(w=>w.atBottom)),o),ce(W(o,Hn(50)),c);const E=Y(hc);ce(W(n,re(({scrollTop:w})=>w),rt(),ln((w,A)=>at(h)?{direction:w.direction,prevScrollTop:A}:{direction:A<w.prevScrollTop?fc:hc,prevScrollTop:A},{direction:hc,prevScrollTop:0}),re(w=>w.direction)),E),ce(W(n,Hn(50),cn(jj)),E);const v=Y(0);return ce(W(f,fe(w=>!w),cn(0)),v),ce(W(s,Hn(100),Te(f),fe(([w,A])=>!!A),ln(([w,A],[C])=>[A,C],[0,0]),re(([w,A])=>A-w)),v),{atBottomState:y,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:g,scrollDirection:E,scrollVelocity:v}},tt(Wt)),bc="top",yc="bottom",Bx="none";function Fx(e,t,r){return typeof e=="number"?r===fc&&t===bc||r===hc&&t===yc?e:0:r===fc?t===bc?e.main:e.reverse:t===yc?e.main:e.reverse}function Ux(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const uh=$e(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:n,viewportHeight:s}])=>{const a=Ue(),o=Y(0),i=Y(0),c=Y(0),l=Rt(W(Et(he(n),he(s),he(r),he(a,lc),he(c),he(o),he(t),he(e),he(i)),re(([u,d,f,[h,y],g,E,v,w,A])=>{const C=u-w,D=E+v,z=Math.max(f-C,0);let T=Bx;const m=Ux(A,bc),b=Ux(A,yc);return h-=w,h+=f+v,y+=f+v,y-=w,h>u+D-m&&(T=fc),y<u-z+d+b&&(T=hc),T!==Bx?[Math.max(C-f-Fx(g,bc,T)-m,0),C-z-v+d+Fx(g,yc,T)+b]:null}),fe(u=>u!=null),rt(lc)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:c,topListHeight:o,visibleRange:l}},tt(Wt),{singleton:!0});function qj(e,t,r){if(zu(t)){const n=Cx(e,t);return[{index:Wr(t.groupOffsetTree,n)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:n,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const dh={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ru(e,t,r,n,s,a){const{lastIndex:o,lastOffset:i,lastSize:c}=s;let l=0,u=0;if(e.length>0){l=e[0].offset;const g=e[e.length-1];u=g.offset+g.size}const d=r-o,f=i+d*c+(d-1)*n,h=l,y=f-u;return{bottom:u,firstItemIndex:a,items:Dx(e,s,a),offsetBottom:y,offsetTop:l,top:h,topItems:Dx(t,s,a),topListHeight:t.reduce((g,E)=>E.size+g,0),totalCount:r}}function Ox(e,t,r,n,s,a){let o=0;if(r.groupIndices.length>0)for(const u of r.groupIndices){if(u-o>=e)break;o++}const i=e+o,c=lh(t,i),l=Array.from({length:i}).map((u,d)=>({data:a[d+c],index:d+c,offset:0,size:0}));return Ru(l,[],i,s,r,n)}function Dx(e,t,r){if(e.length===0)return[];if(!zu(t))return e.map(l=>({...l,index:l.index+r,originalIndex:l.index}));const n=e[0].index,s=e[e.length-1].index,a=[],o=go(t.groupOffsetTree,n,s);let i,c=0;for(const l of e){(!i||i.end<l.index)&&(i=o.shift(),c=t.groupIndices.indexOf(i.start));let u;l.index===i.start?u={index:c,type:"group"}:u={groupIndex:c,index:l.index-(c+1)+r},a.push({...u,data:l.data,offset:l.offset,originalIndex:l.index,size:l.size})}return a}function _x(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const la=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n,totalCount:s},a,{listBoundary:o,topListHeight:i,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:h},{recalcInProgress:y}])=>{const g=Y([]),E=Y(0),v=Ue(),w=Y(0);ce(a.topItemsIndexes,g);const A=Rt(W(Et(h,y,he(c,lc),he(s),he(n),he(l),u,he(g),he(t),he(r),he(w),e),fe(([T,m,,b,,,,,,,,x])=>{const S=x&&x.length!==b;return T&&!m&&!S}),re(([,,[T,m],b,x,S,I,F,_,k,P,O])=>{var U,L,H,G;const Q=x,{offsetTree:pe,sizeTree:me}=Q,ie=at(E);if(b===0)return{...dh,totalCount:b};if(T===0&&m===0)return ie===0?{...dh,totalCount:b}:Ox(ie,S,x,_,k,O||[]);if(qe(me))return ie>0?null:Ru(qj(lh(S,b),Q,O),[],b,k,Q,_);const de=[];if(F.length>0){const Ae=F[0],ve=F[F.length-1];let be=0;for(const Xe of go(me,Ae,ve)){const Ke=Xe.value,Qe=Math.max(Xe.start,Ae),Br=Math.min(Xe.end,ve);for(let Ot=Qe;Ot<=Br;Ot++)de.push({data:O==null?void 0:O[Ot],index:Ot,offset:be,size:Ke}),be+=Ke}}if(!I)return Ru([],de,b,k,Q,_);const Be=F.length>0?F[F.length-1]+1:0,X=_j(pe,T,m,Be);if(X.length===0)return null;const we=b-1,De=Mu([],Ae=>{for(const ve of X){const be=ve.value;let Xe=be.offset,Ke=ve.start;const Qe=be.size;if(be.offset<T){Ke+=Math.floor((T-be.offset+k)/(Qe+k));const Ot=Ke-ve.start;Xe+=Ot*Qe+Ot*k}Ke<Be&&(Xe+=(Be-Ke)*Qe,Ke=Be);const Br=Math.min(ve.end,we);for(let Ot=Ke;Ot<=Br&&!(Xe>=m);Ot++)Ae.push({data:O==null?void 0:O[Ot],index:Ot,offset:Xe,size:Qe}),Xe+=Qe+k}}),Ge=_x(P,bc),it=_x(P,yc);if(De.length>0&&(Ge>0||it>0)){const Ae=De[0],ve=De[De.length-1];if(Ge>0&&Ae.index>Be){const be=Math.min(Ge,Ae.index-Be),Xe=[];let Ke=Ae.offset;for(let Qe=Ae.index-1;Qe>=Ae.index-be;Qe--){const Br=(L=(U=go(me,Qe,Qe)[0])==null?void 0:U.value)!=null?L:Ae.size;Ke-=Br+k,Xe.unshift({data:O==null?void 0:O[Qe],index:Qe,offset:Ke,size:Br})}De.unshift(...Xe)}if(it>0&&ve.index<we){const be=Math.min(it,we-ve.index);let Xe=ve.offset+ve.size+k;for(let Ke=ve.index+1;Ke<=ve.index+be;Ke++){const Qe=(G=(H=go(me,Ke,Ke)[0])==null?void 0:H.value)!=null?G:ve.size;De.push({data:O==null?void 0:O[Ke],index:Ke,offset:Xe,size:Qe}),Xe+=Qe+k}}}return Ru(De,de,b,k,Q,_)}),fe(T=>T!==null),rt()),dh);ce(W(e,fe(X0),re(T=>T==null?void 0:T.length)),s),ce(W(A,re(T=>T.topListHeight)),d),ce(d,i),ce(W(A,re(T=>[T.top,T.bottom])),o),ce(W(A,re(T=>T.items)),v);const C=mr(W(A,fe(({items:T})=>T.length>0),Te(s,e),fe(([{items:T},m])=>T[T.length-1].originalIndex===m-1),re(([,T,m])=>[T-1,m]),rt(lc),re(([T])=>T))),D=mr(W(A,Hn(200),fe(({items:T,topItems:m})=>T.length>0&&T[0].originalIndex===m.length),re(({items:T})=>T[0].index),rt())),z=mr(W(A,fe(({items:T})=>T.length>0),re(({items:T})=>{let m=0,b=T.length-1;for(;T[m].type==="group"&&m<b;)m++;for(;T[b].type==="group"&&b>m;)b--;return{endIndex:T[b].index,startIndex:T[m].index}}),rt(Ex)));return{endReached:C,initialItemCount:E,itemsRendered:v,listState:A,minOverscanItemCount:w,rangeChanged:z,startReached:D,topItemsIndexes:g,...f}},tt(un,Sx,uh,pc,dc,mc,bs,ah),{singleton:!0}),Mx=$e(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:n},{listState:s}])=>{const a=Ue(),o=Rt(W(Et(r,e,n,t,s),re(([i,c,l,u,d])=>i+c+l+u+d.offsetBottom+d.bottom)),0);return ce(he(o),a),{totalListHeight:o,totalListHeightChanged:a}},tt(Wt,la),{singleton:!0}),Kj=$e(([{viewportHeight:e},{totalListHeight:t}])=>{const r=Y(!1),n=Rt(W(Et(r,e,t),fe(([s])=>s),re(([,s,a])=>Math.max(0,s-a)),Hn(0),rt()),0);return{alignToBottom:r,paddingTopAddition:n}},tt(Wt,Mx),{singleton:!0}),Nx=$e(()=>({context:Y(null)})),Yj=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:n,...s},viewportBottom:a,viewportTop:o})=>t<o?{...s,align:r??"start",behavior:n}:e>a?{...s,align:r??"end",behavior:n}:null,Lx=$e(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:o,scrollTop:i,viewportHeight:c},{scrollToIndex:l}])=>{const u=Ue();return ce(W(u,Te(t,c,r,a,s,n,i),Te(e),re(([[d,f,h,y,g,E,v,w],A])=>{const{align:C,behavior:D,calculateViewLocation:z=Yj,done:T,...m}=d,b=Tx(d,f,y-1),x=uc(b,f.offsetTree,A)+g+E,S=x+Wr(f.sizeTree,b)[1],I=w+E,F=w+h-v,_=z({itemBottom:S,itemTop:x,locationParams:{align:C,behavior:D,...m},viewportBottom:F,viewportTop:I});return _?T&&Vr(W(o,fe(k=>!k),oa(at(o)?1:2)),T):T&&T(),_}),fe(d=>d!==null)),l),{scrollIntoView:u}},tt(un,Wt,dc,la,hs),{singleton:!0});function zx(e){return e?e==="smooth"?"smooth":"auto":!1}const Zj=(e,t)=>typeof e=="function"?zx(e(t)):t&&zx(e),Xj=$e(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:n},{atBottomState:s,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:i},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:h}])=>{const y=Y(!1),g=Ue();let E=null;function v(D){Ce(o,{align:"end",behavior:D,index:"LAST"})}je(W(Et(W(he(t),oa(1)),c),Te(he(y),a,i,d),re(([[D,z],T,m,b,x])=>{let S=z&&b,I="auto";return S&&(I=Zj(T,m||x),S=S&&!!I),{followOutputBehavior:I,shouldFollow:S,totalCount:D}}),fe(({shouldFollow:D})=>D)),({followOutputBehavior:D,totalCount:z})=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("following output to ",{totalCount:z},nr.DEBUG),v(D)}):E=Vr(e,()=>{at(u)("following output to ",{totalCount:z},nr.DEBUG),v(D),E=null})});function w(D){const z=Vr(s,T=>{D&&!T.atBottom&&T.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(at(u)("scrolling to bottom due to increased size",{},nr.DEBUG),v("auto"))});setTimeout(z,100)}je(W(Et(he(y),t,l),fe(([D,,z])=>D&&z),ln(({value:D},[,z])=>({refreshed:D===z,value:z}),{refreshed:!1,value:0}),fe(({refreshed:D})=>D),Te(y,t)),([,D])=>{at(i)&&w(D!==!1)}),je(g,()=>{w(at(y)!==!1)}),je(Et(he(y),s),([D,z])=>{D&&!z.atBottom&&z.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const A=Y(null),C=Ue();return ce(J0(W(he(n),re(D=>{var z;return(z=D==null?void 0:D.length)!=null?z:0})),W(he(t))),C),je(W(Et(W(C,oa(1)),c),Te(he(A),i,d,f),re(([[D,z],T,m,b,x])=>z&&m&&(T==null?void 0:T({context:x,totalCount:D,scrollingInProgress:b}))),fe(D=>!!D),Hn(0)),D=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("scrolling into view",{}),Ce(h,D)}):E=Vr(e,()=>{at(u)("scrolling into view",{}),Ce(h,D),E=null})}),{autoscrollToBottom:g,followOutput:y,scrollIntoViewOnChange:A}},tt(un,mc,dc,pc,bs,hs,Wt,Nx,Lx)),Qj=$e(([{data:e,firstItemIndex:t,gap:r,sizes:n},{initialTopMostItemIndex:s},{initialItemCount:a,listState:o},{didMount:i}])=>(ce(W(i,Te(a),fe(([,c])=>c!==0),Te(s,n,t,r,e),re(([[,c],l,u,d,f,h=[]])=>Ox(c,l,u,d,f,h))),o),{}),tt(un,pc,la,bs),{singleton:!0}),Jj=$e(([{didMount:e},{scrollTo:t},{listState:r}])=>{const n=Y(0);return je(W(e,Te(n),fe(([,s])=>s!==0),re(([,s])=>({top:s}))),s=>{Vr(W(r,oa(1),fe(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ce(t,s)})})}),{initialScrollTop:n}},tt(bs,Wt,la),{singleton:!0}),Rx=$e(([{scrollVelocity:e}])=>{const t=Y(!1),r=Ue(),n=Y(!1);return ce(W(e,Te(n,t,r),fe(([s,a])=>!!a),re(([s,a,o,i])=>{const{enter:c,exit:l}=a;if(o){if(l(s,i))return!1}else if(c(s,i))return!0;return o}),rt()),t),je(W(Et(t,e,r),Te(n)),([[s,a,o],i])=>{s&&i&&i.change&&i.change(a,o)}),{isSeeking:t,scrollSeekConfiguration:n,scrollSeekRangeChanged:r,scrollVelocity:e}},tt(mc),{singleton:!0}),ph=$e(([{scrollContainerState:e,scrollTo:t}])=>{const r=Ue(),n=Ue(),s=Ue(),a=Y(!1),o=Y(void 0);return ce(W(Et(r,n),re(([{scrollHeight:i,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),ce(W(t,Te(n),re(([i,{offsetTop:c}])=>({...i,top:i.top+c}))),s),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:n}},tt(Wt)),eV=$e(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:o,windowScrollContainerState:i,windowViewportRect:c}])=>{const l=Ue(),u=Y(void 0),d=Y(null),f=Y(null);return ce(i,d),ce(c,f),je(W(l,Te(t,n,o,d,f,r)),([h,y,g,E,v,w,A])=>{const C=Nj(y.sizeTree);E&&v!==null&&w!==null&&(g=v.scrollTop-w.offsetTop),g-=A,h({ranges:C,scrollTop:g})}),ce(W(u,fe(X0),re(tV)),s),ce(W(a,Te(u),fe(([,h])=>h!==void 0),rt(),re(([,h])=>h.ranges)),e),{getState:l,restoreStateFrom:u}},tt(un,Wt,pc,bs,ph));function tV(e){return{align:"start",index:0,offset:e.scrollTop}}const rV=$e(([{topItemsIndexes:e}])=>{const t=Y(0);return ce(W(t,fe(r=>r>=0),re(r=>Array.from({length:r}).map((n,s)=>s))),e),{topItemCount:t}},tt(la));function Hx(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const nV=Hx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),sV=$e(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:n},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:i},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:h},{recalcInProgress:y}])=>{const g=mr(W(c,Te(o),ln(([,v,w,A],[{bottom:C,items:D,offsetBottom:z,totalCount:T},m])=>{const b=C+z;let x=0;return w===T&&v.length>0&&D.length>0&&(D[0].originalIndex===0&&v[0].originalIndex===0||(x=b-A,x!==0&&(x+=m))),[x,D,T,b]},[0,[],0,0]),fe(([v])=>v!==0),Te(n,i,r,s,h,y),fe(([,v,w,A,,,C])=>!C&&!A&&v!==0&&w===fc),re(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},nr.DEBUG),v))));function E(v){v>0?(Ce(t,{behavior:"auto",top:-v}),Ce(e,0)):(Ce(e,0),Ce(t,{behavior:"auto",top:-v}))}return je(W(g,Te(e,a)),([v,w,A])=>{A&&nV()?Ce(e,w-v):E(-v)}),je(W(Et(Rt(a,!1),e,y),fe(([v,w,A])=>!v&&!A&&w!==0),re(([v,w])=>w),Hn(1)),E),ce(W(d,re(v=>({top:-v}))),t),je(W(l,Te(f,u),re(([v,{groupIndices:w,lastSize:A,sizeTree:C},D])=>{function z(T){return T*(A+D)}if(w.length===0)return z(v);{let T=0;const m=cc(C,0);let b=0,x=0;for(;b<v;){b++,T+=m;let S=w.length===x+1?1/0:w[x+1]-w[x]-1;b+S>v&&(T-=m,S=v-b+1),b+=S,T+=z(S),x++}return T}})),v=>{Ce(e,v),requestAnimationFrame(()=>{Ce(t,{top:v}),requestAnimationFrame(()=>{Ce(e,0),Ce(y,!1)})})}),{deviation:e}},tt(Wt,mc,la,un,hs,ah)),aV=$e(([e,t,r,n,s,a,o,i,c,l,u])=>({...e,...t,...r,...n,...s,...a,...o,...i,...c,...l,...u}),tt(uh,Qj,bs,Rx,Mx,Jj,Kj,ph,Lx,hs,Nx)),$x=$e(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:n,fixedGroupSize:s,gap:a,groupIndices:o,heightEstimates:i,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:h},{initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E},v,w,A,C,{scrollToIndex:D},z,{topItemCount:T},{groupCounts:m},b])=>{const{listState:x,minOverscanItemCount:S,topItemsIndexes:I,rangeChanged:F,..._}=C;return ce(F,b.scrollSeekRangeChanged),ce(W(b.windowViewportRect,re(k=>k.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:n,fixedGroupHeight:s,gap:a,groupCounts:m,heightEstimates:i,initialItemFinalLocationReached:y,initialTopMostItemIndex:g,scrolledToInitialItem:E,sizeRanges:l,topItemCount:T,topItemsIndexes:I,totalCount:f,...A,groupIndices:o,itemSize:c,listState:x,minOverscanItemCount:S,scrollToIndex:D,statefulTotalCount:d,trackItemSizes:h,rangeChanged:F,..._,...b,...v,sizes:u,...w}},tt(un,pc,Wt,eV,Xj,la,dc,sV,rV,Sx,aV));function oV(e,t){const r={},n={};let s=0;const a=e.length;for(;s<a;)n[e[s]]=1,s+=1;for(const o in t)Object.hasOwn(n,o)||(r[o]=t[o]);return r}const Hu=typeof document<"u"?M.useLayoutEffect:M.useEffect;function Gx(e,t,r){const n=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),i=M.createContext({});function c(E,v){E.propsReady&&Ce(E.propsReady,!1);for(const w of n){const A=E[t.required[w]];Ce(A,v[w])}for(const w of s)if(w in v){const A=E[t.optional[w]];Ce(A,v[w])}E.propsReady&&Ce(E.propsReady,!0)}function l(E){return a.reduce((v,w)=>(v[w]=A=>{const C=E[t.methods[w]];Ce(C,A)},v),{})}function u(E){return o.reduce((v,w)=>(v[w]=Ej(E[t.events[w]]),v),{})}const d=M.forwardRef((E,v)=>{const{children:w,...A}=E,[C]=M.useState(()=>Mu(Cj(e),T=>{c(T,A)})),[D]=M.useState(dx(u,C));Hu(()=>{for(const T of o)T in A&&je(D[T],A[T]);return()=>{Object.values(D).map(Q0)}},[A,D,C]),Hu(()=>{c(C,A)}),M.useImperativeHandle(v,lx(l(C)));const z=r;return B.jsx(i.Provider,{value:C,children:r?B.jsx(z,{...oV([...n,...s,...o],A),children:w}):w})}),f=E=>{const v=M.useContext(i);return M.useCallback(w=>{Ce(v[E],w)},[v,E])},h=E=>{const v=M.useContext(i)[E],w=M.useCallback(A=>je(v,A),[v]);return M.useSyncExternalStore(w,()=>at(v),()=>at(v))},y=E=>{const v=M.useContext(i)[E],[w,A]=M.useState(dx(at,v));return Hu(()=>je(v,C=>{C!==w&&A(lx(C))}),[v,w]),w},g=M.version.startsWith("18")?h:y;return{Component:d,useEmitter:(E,v)=>{const w=M.useContext(i)[E];Hu(()=>je(w,v),[v,w])},useEmitterValue:g,usePublisher:f}}const jx=M.createContext(void 0),Vx=M.createContext(void 0),Wx=typeof document<"u"?M.useLayoutEffect:M.useEffect;function fh(e){return"self"in e}function iV(e){return"body"in e}function qx(e,t,r,n=bo,s,a){const o=M.useRef(null),i=M.useRef(null),c=M.useRef(null),l=M.useCallback(f=>{let h,y,g;const E=f.target;if(iV(E)||fh(E)){const w=fh(E)?E:E.defaultView;g=a?w.scrollX:w.scrollY,h=a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,y=a?w.innerWidth:w.innerHeight}else g=a?E.scrollLeft:E.scrollTop,h=a?E.scrollWidth:E.scrollHeight,y=a?E.offsetWidth:E.offsetHeight;const v=()=>{e({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:y})};f.suppressFlushSync?v():As.flushSync(v),i.current!==null&&(g===i.current||g<=0||g===h-y)&&(i.current=null,t(!0),c.current&&(clearTimeout(c.current),c.current=null))},[e,t,a]);M.useEffect(()=>{const f=s||o.current;return n(s||o.current),l({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",l,{passive:!0}),()=>{n(null),f.removeEventListener("scroll",l)}},[o,l,r,n,s]);function u(f){const h=o.current;if(!h||(a?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;const y=f.behavior==="smooth";let g,E,v;fh(h)?(E=Math.max(ms(h.document.documentElement,a?"width":"height"),a?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=a?h.innerWidth:h.innerHeight,v=a?window.scrollX:window.scrollY):(E=h[a?"scrollWidth":"scrollHeight"],g=ms(h,a?"width":"height"),v=h[a?"scrollLeft":"scrollTop"]);const w=E-g;if(f.top=Math.ceil(Math.max(Math.min(w,f.top),0)),Ix(g,E)||f.top===v){e({scrollHeight:E,scrollTop:v,viewportHeight:g}),y&&t(!0);return}y?(i.current=f.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,i.current=null,t(!0)},1e3)):i.current=null,a&&(f={behavior:f.behavior,left:f.top}),h.scrollTo(f)}function d(f){a&&(f={behavior:f.behavior,left:f.top}),o.current.scrollBy(f)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}const hh="-webkit-sticky",Kx="sticky",mh=Hx(()=>{if(typeof document>"u")return Kx;const e=document.createElement("div");return e.style.position=hh,e.style.position===hh?hh:Kx});function bh(e){return e}const cV=$e(()=>{const e=Y(i=>`Item ${i}`),t=Y(i=>`Group ${i}`),r=Y({}),n=Y(bh),s=Y("div"),a=Y(bo),o=(i,c=null)=>Rt(W(r,re(l=>l[i]),rt()),c);return{components:r,computeItemKey:n,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:t,HeaderComponent:o("Header"),HeaderFooterTag:s,ItemComponent:o("Item","div"),itemContent:e,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}),lV=$e(([e,t])=>({...e,...t}),tt($x,cV)),uV=({height:e})=>B.jsx("div",{style:{height:e}}),dV={overflowAnchor:"none",position:mh(),zIndex:1},Yx={overflowAnchor:"none"},pV={...Yx,display:"inline-block",height:"100%"},Zx=M.memo(function({showTopList:e=!1}){const t=ge("listState"),r=Sr("sizeRanges"),n=ge("useWindowScroll"),s=ge("customScrollParent"),a=Sr("windowScrollContainerState"),o=Sr("scrollContainerState"),i=s||n?a:o,c=ge("itemContent"),l=ge("context"),u=ge("groupContent"),d=ge("trackItemSizes"),f=ge("itemSize"),h=ge("log"),y=Sr("gap"),g=ge("horizontalDirection"),{callbackRef:E}=Sj(r,f,d,e?bo:i,h,y,s,g,ge("skipAnimationFrameInResizeObserver")),[v,w]=M.useState(0);yh("deviation",_=>{v!==_&&w(_)});const A=ge("EmptyPlaceholder"),C=ge("ScrollSeekPlaceholder")||uV,D=ge("ListComponent"),z=ge("ItemComponent"),T=ge("GroupComponent"),m=ge("computeItemKey"),b=ge("isSeeking"),x=ge("groupIndices").length>0,S=ge("alignToBottom"),I=ge("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:S?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:S?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...I?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&A?B.jsx(A,{...Ht(A,l)}):B.jsx(D,{...Ht(D,l),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:F,children:(e?t.topItems:t.items).map(_=>{const k=_.originalIndex,P=m(k+t.firstItemIndex,_.data,l);return b?M.createElement(C,{...Ht(C,l),height:_.size,index:_.index,key:P,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?M.createElement(T,{...Ht(T,l),"data-index":k,"data-item-index":_.index,"data-known-size":_.size,key:P,style:dV},u(_.index,l)):M.createElement(z,{...Ht(z,l),...bV(z,_.data),"data-index":k,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:P,style:g?pV:Yx},x?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),fV={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},hV={outline:"none",overflowX:"auto",position:"relative"},$u=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),mV={position:mh(),top:0,width:"100%",zIndex:1};function Ht(e,t){if(typeof e!="string")return{context:t}}function bV(e,t){return{item:typeof e=="string"?void 0:t}}const yV=M.memo(function(){const e=ge("HeaderComponent"),t=Sr("headerHeight"),r=ge("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,ge("skipAnimationFrameInResizeObserver")),s=ge("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null}),gV=M.memo(function(){const e=ge("FooterComponent"),t=Sr("footerHeight"),r=ge("HeaderFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,ge("skipAnimationFrameInResizeObserver")),s=ge("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null});function Xx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("scrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("scrollerRef"),d=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:h,scrollToCallback:y}=qx(i,l,c,u,void 0,d);return e("scrollTo",y),e("scrollBy",f),B.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...d?hV:fV,...s},tabIndex:0,...o,...Ht(c,a),children:n})})}function Qx({useEmitter:e,useEmitterValue:t,usePublisher:r}){return M.memo(function({children:n,style:s,context:a,...o}){const i=r("windowScrollContainerState"),c=t("ScrollerComponent"),l=r("smoothScrollTargetReached"),u=t("totalListHeight"),d=t("deviation"),f=t("customScrollParent"),h=M.useRef(null),y=t("scrollerRef"),{scrollByCallback:g,scrollerRef:E,scrollToCallback:v}=qx(i,l,c,y,f);return Wx(()=>{var w;return E.current=f||((w=h.current)==null?void 0:w.ownerDocument.defaultView),()=>{E.current=null}},[E,f]),e("windowScrollTo",v),e("scrollBy",g),B.jsx(c,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+d}:{}},...o,...Ht(c,a),children:n})})}const xV=({children:e})=>{const t=M.useContext(jx),r=Sr("viewportHeight"),n=Sr("fixedItemHeight"),s=ge("alignToBottom"),a=ge("horizontalDirection"),o=M.useMemo(()=>ux(r,c=>ms(c,a?"width":"height")),[r,a]),i=ia(o,!0,ge("skipAnimationFrameInResizeObserver"));return M.useEffect(()=>{t&&(r(t.viewportHeight),n(t.itemHeight))},[t,r,n]),B.jsx("div",{"data-viewport-type":"element",ref:i,style:$u(s),children:e})},wV=({children:e})=>{const t=M.useContext(jx),r=Sr("windowViewportRect"),n=Sr("fixedItemHeight"),s=ge("customScrollParent"),a=mx(r,s,ge("skipAnimationFrameInResizeObserver")),o=ge("alignToBottom");return M.useEffect(()=>{t&&(n(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,n]),B.jsx("div",{"data-viewport-type":"window",ref:a,style:$u(o),children:e})},vV=({children:e})=>{const t=ge("TopItemListComponent")||"div",r=ge("headerHeight"),n={...mV,marginTop:`${r}px`},s=ge("context");return B.jsx(t,{style:n,...Ht(t,s),children:e})},EV=M.memo(function(e){const t=ge("useWindowScroll"),r=ge("topItemsIndexes").length>0,n=ge("customScrollParent"),s=ge("context");return B.jsxs(n||t?TV:CV,{...e,context:s,children:[r&&B.jsx(vV,{children:B.jsx(Zx,{showTopList:!0})}),B.jsxs(n||t?wV:xV,{children:[B.jsx(yV,{}),B.jsx(Zx,{}),B.jsx(gV,{})]})]})}),{Component:kV,useEmitter:yh,useEmitterValue:ge,usePublisher:Sr}=Gx(lV,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},EV),CV=Xx({useEmitter:yh,useEmitterValue:ge,usePublisher:Sr}),TV=Qx({useEmitter:yh,useEmitterValue:ge,usePublisher:Sr}),AV=kV;tt($x,$e(()=>{const e=Y(l=>B.jsxs("td",{children:["Item $",l]})),t=Y(null),r=Y(l=>B.jsxs("td",{colSpan:1e3,children:["Group ",l]})),n=Y(null),s=Y(null),a=Y({}),o=Y(bh),i=Y(bo),c=(l,u=null)=>Rt(W(a,re(d=>d[l]),rt()),u);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c("EmptyPlaceholder"),FillerRow:c("FillerRow"),fixedFooterContent:s,fixedHeaderContent:n,itemContent:e,groupContent:r,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder"),TableBodyComponent:c("TableBody","tbody"),TableComponent:c("Table","table"),TableFooterComponent:c("TableFoot","tfoot"),TableHeadComponent:c("TableHead","thead"),TableRowComponent:c("TableRow","tr"),GroupComponent:c("Group","tr")}})),mh();const Jx={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},SV={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:e5,floor:Gu,max:gc,min:gh,round:t5}=Math;function r5(e,t,r){return Array.from({length:t-e+1}).map((n,s)=>({data:r===null?null:r[s+e],index:s+e}))}function PV(e){return{...SV,items:e}}function ju(e,t){return e&&e.width===t.width&&e.height===t.height}function IV(e,t){return e&&e.column===t.column&&e.row===t.row}const BV=$e(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:n},{footerHeight:s,headerHeight:a,scrollBy:o,scrollContainerState:i,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,h,{didMount:y,propsReady:g},{customScrollParent:E,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C},D])=>{const z=Y(0),T=Y(0),m=Y(Jx),b=Y({height:0,width:0}),x=Y({height:0,width:0}),S=Ue(),I=Ue(),F=Y(0),_=Y(null),k=Y({column:0,row:0}),P=Ue(),O=Ue(),U=Y(!1),L=Y(0),H=Y(!0),G=Y(!1),Q=Y(!1);je(W(y,Te(L),fe(([X,we])=>!!we)),()=>{Ce(H,!1)}),je(W(Et(y,H,x,b,L,G),fe(([X,we,De,Ge,,it])=>X&&!we&&De.height!==0&&Ge.height!==0&&!it)),([,,,,X])=>{Ce(G,!0),ch(1,()=>{Ce(S,X)}),Vr(W(l),()=>{Ce(t,[0,0]),Ce(H,!0)})}),ce(W(O,fe(X=>X!=null&&X.scrollTop>0),cn(0)),T),je(W(y,Te(O),fe(([,X])=>X!=null)),([,X])=>{X&&(Ce(b,X.viewport),Ce(x,X.item),Ce(k,X.gap),X.scrollTop>0&&(Ce(U,!0),Vr(W(l,oa(1)),we=>{Ce(U,!1)}),Ce(c,{top:X.scrollTop})))}),ce(W(b,re(({height:X})=>X)),d),ce(W(Et(he(b,ju),he(x,ju),he(k,(X,we)=>X&&X.column===we.column&&X.row===we.row),he(l)),re(([X,we,De,Ge])=>({gap:De,item:we,scrollTop:Ge,viewport:X}))),P),ce(W(Et(he(z),n,he(k,IV),he(x,ju),he(b,ju),he(_),he(T),he(U),he(H),he(L)),fe(([,,,,,,,X])=>!X),re(([X,[we,De],Ge,it,Ae,ve,be,,Xe,Ke])=>{const{column:Qe,row:Br}=Ge,{height:Ot,width:Ch}=it,{width:I5}=Ae;if(be===0&&(X===0||I5===0))return Jx;if(Ch===0){const D5=lh(Ke,X),MW=D5+Math.max(be-1,0);return PV(r5(D5,MW,ve))}const qu=n5(I5,Ch,Qe);let Fo,Ea;Xe?we===0&&De===0&&be>0?(Fo=0,Ea=be-1):(Fo=qu*Gu((we+Br)/(Ot+Br)),Ea=qu*e5((De+Br)/(Ot+Br))-1,Ea=gh(X-1,gc(Ea,qu-1)),Fo=gh(Ea,gc(0,Fo))):(Fo=0,Ea=-1);const B5=r5(Fo,Ea,ve),{bottom:F5,top:U5}=s5(Ae,Ge,it,B5),O5=e5(X/qu),_W=O5*Ot+(O5-1)*Br-F5;return{bottom:F5,itemHeight:Ot,items:B5,itemWidth:Ch,offsetBottom:_W,offsetTop:U5,top:U5}})),m),ce(W(_,fe(X=>X!==null),re(X=>X.length)),z),ce(W(Et(b,x,m,k),fe(([X,we,{items:De}])=>De.length>0&&we.height!==0&&X.height!==0),re(([X,we,{items:De},Ge])=>{const{bottom:it,top:Ae}=s5(X,Ge,we,De);return[Ae,it]}),rt(lc)),t);const pe=Y(!1);ce(W(l,Te(pe),re(([X,we])=>we||X!==0)),pe);const me=mr(W(Et(m,z),fe(([{items:X}])=>X.length>0),Te(pe),fe(([[X,we],De])=>{const Ge=X.items[X.items.length-1].index===we-1;return(De||X.bottom>0&&X.itemHeight>0&&X.offsetBottom===0&&X.items.length===we)&&Ge}),re(([[,X]])=>X-1),rt())),ie=mr(W(he(m),fe(({items:X})=>X.length>0&&X[0].index===0),cn(0),rt())),de=mr(W(he(m),Te(U),fe(([{items:X},we])=>X.length>0&&!we),re(([{items:X}])=>({endIndex:X[X.length-1].index,startIndex:X[0].index})),rt(Ex),Hn(0)));ce(de,h.scrollSeekRangeChanged),ce(W(S,Te(b,x,z,k),re(([X,we,De,Ge,it])=>{const Ae=Px(X),{align:ve,behavior:be,offset:Xe}=Ae;let Ke=Ae.index;Ke==="LAST"&&(Ke=Ge-1),Ke=gc(0,Ke,gh(Ge-1,Ke));let Qe=xh(we,it,De,Ke);return ve==="end"?Qe=t5(Qe-we.height+De.height):ve==="center"&&(Qe=t5(Qe-we.height/2+De.height/2)),Xe&&(Qe+=Xe),{behavior:be,top:Qe}})),c);const Be=Rt(W(m,re(X=>X.offsetBottom+X.bottom)),0);return ce(W(C,re(X=>({height:X.visibleHeight,width:X.visibleWidth}))),b),{customScrollParent:E,data:_,deviation:F,footerHeight:s,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:T,itemDimensions:x,overscan:r,restoreStateFrom:O,scrollBy:o,scrollContainerState:i,scrollHeight:I,scrollTo:c,scrollToIndex:S,scrollTop:l,smoothScrollTargetReached:u,totalCount:z,useWindowScroll:v,viewportDimensions:b,windowScrollContainerState:w,windowScrollTo:A,windowViewportRect:C,...h,gridState:m,horizontalDirection:Q,initialTopMostItemIndex:L,totalListHeight:Be,...f,endReached:me,propsReady:g,rangeChanged:de,startReached:ie,stateChanged:P,stateRestoreInProgress:U,...D}},tt(uh,Wt,mc,Rx,bs,ph,hs));function n5(e,t,r){return gc(1,Gu((e+r)/(Gu(t)+r)))}function s5(e,t,r,n){const{height:s}=r;if(s===void 0||n.length===0)return{bottom:0,top:0};const a=xh(e,t,r,n[0].index);return{bottom:xh(e,t,r,n[n.length-1].index)+s,top:a}}function xh(e,t,r,n){const s=n5(e.width,r.width,t.column),a=Gu(n/s),o=a*r.height+gc(0,a-1)*t.row;return o>0?o+t.row:o}const FV=$e(()=>{const e=Y(d=>`Item ${d}`),t=Y({}),r=Y(null),n=Y("virtuoso-grid-item"),s=Y("virtuoso-grid-list"),a=Y(bh),o=Y("div"),i=Y(bo),c=(d,f=null)=>Rt(W(t,re(h=>h[d]),rt()),f),l=Y(!1),u=Y(!1);return ce(he(u),l),{components:t,computeItemKey:a,context:r,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:o,itemClassName:n,ItemComponent:c("Item","div"),itemContent:e,listClassName:s,ListComponent:c("List","div"),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),UV=$e(([e,t])=>({...e,...t}),tt(BV,FV)),OV=M.memo(function(){const e=ot("gridState"),t=ot("listClassName"),r=ot("itemClassName"),n=ot("itemContent"),s=ot("computeItemKey"),a=ot("isSeeking"),o=Pr("scrollHeight"),i=ot("ItemComponent"),c=ot("ListComponent"),l=ot("ScrollSeekPlaceholder"),u=ot("context"),d=Pr("itemDimensions"),f=Pr("gap"),h=ot("log"),y=ot("stateRestoreInProgress"),g=Pr("reportReadyState"),E=ia(M.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;o(w);const A=v.firstChild;if(A){const{height:C,width:D}=A.getBoundingClientRect();d({height:C,width:D})}f({column:o5("column-gap",getComputedStyle(v).columnGap,h),row:o5("row-gap",getComputedStyle(v).rowGap,h)})},[o,d,f,h]),!0,!1);return Wx(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),y?null:B.jsx(c,{className:t,ref:E,...Ht(c,u),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const w=s(v.index,v.data,u);return a?B.jsx(l,{...Ht(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},w):M.createElement(i,{...Ht(i,u),className:r,"data-index":v.index,key:w},n(v.index,v.data,u))})})}),DV=M.memo(function(){const e=ot("HeaderComponent"),t=Pr("headerHeight"),r=ot("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,!1),s=ot("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null}),_V=M.memo(function(){const e=ot("FooterComponent"),t=Pr("footerHeight"),r=ot("headerFooterTag"),n=ia(M.useMemo(()=>a=>{t(ms(a,"height"))},[t]),!0,!1),s=ot("context");return e?B.jsx(r,{ref:n,children:B.jsx(e,{...Ht(e,s)})}):null}),MV=({children:e})=>{const t=M.useContext(Vx),r=Pr("itemDimensions"),n=Pr("viewportDimensions"),s=ia(M.useMemo(()=>a=>{n(a.getBoundingClientRect())},[n]),!0,!1);return M.useEffect(()=>{t&&(n({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,n,r]),B.jsx("div",{ref:s,style:$u(!1),children:e})},NV=({children:e})=>{const t=M.useContext(Vx),r=Pr("windowViewportRect"),n=Pr("itemDimensions"),s=ot("customScrollParent"),a=mx(r,s,!1);return M.useEffect(()=>{t&&(n({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,n]),B.jsx("div",{ref:a,style:$u(!1),children:e})},LV=M.memo(function({...e}){const t=ot("useWindowScroll"),r=ot("customScrollParent"),n=r||t?RV:zV,s=r||t?NV:MV,a=ot("context");return B.jsx(n,{...e,...Ht(n,a),children:B.jsxs(s,{children:[B.jsx(DV,{}),B.jsx(OV,{}),B.jsx(_V,{})]})})}),{useEmitter:a5,useEmitterValue:ot,usePublisher:Pr}=Gx(UV,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},LV),zV=Xx({useEmitter:a5,useEmitterValue:ot,usePublisher:Pr}),RV=Qx({useEmitter:a5,useEmitterValue:ot,usePublisher:Pr});function o5(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,nr.WARN),t==="normal"?0:parseInt(t??"0",10)}var wh={},i5;function HV(){if(i5)return wh;i5=1;var e=lu.GenIcon;return wh.AiFillQuestionCircle=function(r){return e({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 708c-22.1 0-40-17.9-40-40s17.9-40 40-40 40 17.9 40 40-17.9 40-40 40zm62.9-219.5a48.3 48.3 0 0 0-30.9 44.8V620c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8v-21.5c0-23.1 6.7-45.9 19.9-64.9 12.9-18.6 30.9-32.8 52.1-40.9 34-13.1 56-41.6 56-72.7 0-44.1-43.1-80-96-80s-96 35.9-96 80v7.6c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V420c0-39.3 17.2-76 48.4-103.3C430.4 290.4 470 276 512 276s81.6 14.5 111.6 40.7C654.8 344 672 380.7 672 420c0 57.8-38.1 109.8-97.1 132.5z"}}]})(r)},wh}var $V=HV();function GV({logo:e,className:t="",style:r={},alt:n="Token logo"}){const[s,a]=M.useState(!1);return M.useEffect(()=>{a(!1)},[e]),e&&!s?B.jsx("img",{alt:n,style:r,onError:()=>a(!0),className:`twap-token-logo ${t}`,src:e}):B.jsx($V.AiFillQuestionCircle,{style:{width:20,height:20},className:"twap-token-svg"})}const jV=()=>B.jsx("div",{className:"twap-orders__loader",children:B.jsx("p",{children:"Loading..."})}),VV=()=>{const{isLoading:e}=Ou(),t=nx(),r=te(a=>a.state.orderIdsToCancel),n=te(a=>a.state.cancelOrdersMode),s=sx();return B.jsx(B.Fragment,{children:e?B.jsx(jV,{}):t!=null&&t.length?B.jsx("div",{className:`twap-orders__list ${n?"twap-orders__list-select-mode":""}`,children:B.jsx(AV,{style:{height:"100%"},data:t,itemContent:(a,o)=>B.jsx(WV,{cancelOrdersMode:!!n,selected:(r==null?void 0:r.includes(o.id))||!1,selectOrder:s,order:o},a)})}):B.jsx(qV,{})})},WV=({order:e,selectOrder:t,selected:r,cancelOrdersMode:n})=>{const s=te(i=>i.updateState),a=xt.useCallback(()=>{s({selectedOrderID:e==null?void 0:e.id})},[s,e==null?void 0:e.id]),o=xt.useCallback(()=>{n?t(e==null?void 0:e.id):a()},[n,t,a,e==null?void 0:e.id]);return B.jsx("div",{className:`twap-orders__list-item twap-orders__list-item-${e.status} ${n?"twap-orders__list-item-select-mode":""} ${r?"twap-orders__list-item-selected":""}`,onClick:o,children:B.jsxs("div",{className:"twap-orders__list-item-content",children:[B.jsx(KV,{order:e}),B.jsx(YV,{value:e.progress||0}),B.jsxs("div",{className:"twap-orders__list-item-tokens",children:[B.jsx(c5,{address:e.srcTokenAddress}),B.jsx(bj.HiArrowRight,{className:"twap-orders__list-item-tokens-arrow"}),B.jsx(c5,{address:e.dstTokenAddress})]})]})})},qV=()=>{const e=te(n=>n.state.orderHistoryStatusFilter),t=Me(),r=xt.useMemo(()=>e||"",[e]);return B.jsx("div",{className:"twap-orders__list-empty",children:B.jsx("p",{children:t("noOrders",{status:r})})})},KV=({order:e})=>{const t=e&&e.status,r=tx(e),n=W0(e.createdAt);return B.jsxs("div",{className:"twap-orders__list-item-header",children:[B.jsxs("p",{className:"twap-orders__list-item-header-title",children:[r," ",B.jsx("span",{children:`(${n})`})]}),B.jsx("p",{className:"twap-orders__list-item-header-status",children:t})]})},c5=e=>{const{useToken:t,components:r}=oe(),n=t==null?void 0:t(e.address);return B.jsx("div",{className:"twap-orders__list-item-token",children:n?B.jsxs(B.Fragment,{children:[B.jsx("div",{className:"twap-orders__list-item-token-logo",children:r.TokenLogo?B.jsx(r.TokenLogo,{token:n}):B.jsx(GV,{logo:n==null?void 0:n.logoUrl})}),B.jsx("p",{className:"twap-orders__list-item-token-symbol",children:n==null?void 0:n.symbol})]}):B.jsx("div",{})})};function YV(e){return B.jsxs("div",{className:"twap-orders__list-item-progress",children:[B.jsx("div",{className:"twap-orders__list-item-progress-bar",children:B.jsx("div",{className:"twap-orders__list-item-progress-bar-filled",style:{width:`${e.value}%`}})}),B.jsx("div",{className:"twap-orders__list-item-token-progress-label",children:B.jsx("p",{children:`${Math.round(e.value)}%`})})]})}const ZV=()=>{const e=te(r=>r.state.selectedOrderID),t=e!==void 0;return B.jsx("div",{className:`twap-orders ${e!==void 0?"twap-orders__show-selected":""}`,children:t?B.jsx(YG,{}):B.jsx(VV,{})})},XV=e=>{const t=Me(),{marketPrice:r,typedInputAmount:n}=oe();return M.useMemo(()=>{const{isError:a,value:o}=vm(e);if(!(!a||j(n||"0").isZero()||!r))return{type:Gt.MIN_FILL_DELAY,value:o,message:t("minFillDelayError",{fillDelay:`${Nf(o)} ${t("minutes")}`})}},[e,t,n,r])},ua=()=>{const{callbacks:e}=oe(),t=te(a=>a.state.typedFillDelay),r=te(a=>a.updateState),n=M.useMemo(()=>t||Fc,[t]),s=XV(n);return{fillDelay:n,onChange:M.useCallback(a=>{var o;r({typedFillDelay:a}),(o=e==null?void 0:e.onFillDelayChange)==null||o.call(e,a)},[r,e]),error:s,milliseconds:n.unit*n.value}},QV=()=>{const{onChange:e,fillDelay:t,error:r}=ua(),n=Me(),s=M.useCallback(o=>e({unit:t.unit,value:Number(o)}),[e,t]),a=M.useCallback(o=>e({unit:o,value:t.value}),[e,t]);return{onInputChange:s,onUnitSelect:a,onChange:e,milliseconds:t.unit*t.value,fillDelay:t,error:r,label:n("tradeIntervalTitle"),tooltip:n("tradeIntervalTooltip")}},dn=()=>{const{srcToken:e,typedInputAmount:t}=oe(),r=Me(),s=te(a=>a.state.acceptedSrcAmount)||t;return{amountWei:Y2(e==null?void 0:e.decimals,s),amountUI:s,error:j(s||0).isZero()?r("enterAmount"):void 0}},JV=(e,t)=>{const{module:r,srcUsd1Token:n,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=oe(),i=Me();return M.useMemo(()=>{if(j(o||"0").isZero()||!s||j(n||"0").isZero())return;if(!e)return{type:Gt.MIN_CHUNKS,value:1,message:i("minChunksError",{minChunks:"1"})};const{isError:c}=km(e,t,r);if(c)return{type:Gt.MAX_CHUNKS,value:t,message:i("maxChunksError",{maxChunks:`${t}`})};const{isError:l,value:u}=Em(o||"",n||"",a||0);if(l)return{type:Gt.MIN_TRADE_SIZE,value:u,message:i("minTradeSizeError",{minTradeSize:`${u}`})}},[e,t,r,o,n,a,i,s])},qr=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:n}=oe(),s=te(g=>g.state.typedChunks),a=ua().fillDelay,o=te(g=>g.updateState),{amountWei:i,amountUI:c}=dn(),l=M.useMemo(()=>dm(a,c||"",t||"",n||0),[c,t,n,a]),u=M.useMemo(()=>um(l,r,s),[l,s,r]),d=M.useCallback(g=>o({typedChunks:g}),[o]),f=M.useMemo(()=>hm(i||"",u),[i,u]),h=Rn(e==null?void 0:e.decimals,f),y=M.useMemo(()=>t?j(h||"0").times(t||0).toString():"0",[h,t]);return{totalTrades:u,maxTrades:l,amountPerTradeUI:h,amountPerTradeWei:f,amountPerTradeUsd:y,onChange:d,error:JV(u,l)}},eW=()=>{const{srcToken:e,dstToken:t}=oe(),r=Me(),{onChange:n,totalTrades:s,amountPerTradeUsd:a,amountPerTradeUI:o,error:i,maxTrades:c,amountPerTradeWei:l}=qr(),u=Ze({value:o}),d=Ze({value:a});return{error:i,maxTrades:c,totalTrades:s,amountPerTrade:u,amountPerTradeWei:l,onChange:n,label:r("tradesAmountTitle"),tooltip:r("totalTradesTooltip"),amountPerTradeUsd:d,fromToken:e,toToken:t}},tW=e=>{const{module:t,marketPrice:r}=oe(),n=Me();return M.useMemo(()=>{const s=xm(t,e),a=wm(e);if(r){if(s.isError)return{type:Gt.MAX_ORDER_DURATION,value:s.value,message:n("maxDurationError",{duration:`${Math.floor(n6(s.value)).toFixed(0)} ${n("days")}`})};if(a.isError)return{type:Gt.MIN_ORDER_DURATION,value:a.value,message:n("minDurationError",{duration:`${Math.floor(Nf(a.value)).toFixed(0)} ${n("minutes")}`})}}},[e,n,t,r])},vh=()=>{const{module:e,callbacks:t}=oe(),r=te(c=>c.state.typedDuration),n=te(c=>c.updateState),s=qr().totalTrades,a=ua().fillDelay,o=M.useMemo(()=>lm(e,s,a,r),[s,a,r,e]),i=tW(o);return{duration:o,setDuration:M.useCallback(c=>{var l;n({typedDuration:c}),(l=t==null?void 0:t.onDurationChange)==null||l.call(t,c)},[n,t]),error:i}},rW=()=>{const{module:e}=oe(),t=Me(),{duration:r,setDuration:n,error:s}=vh(),a=M.useCallback(c=>{n({unit:r.unit,value:Number(c)})},[n,r]),o=M.useCallback(c=>{n({unit:c,value:r.value})},[n,r]),i=M.useMemo(()=>e===ye.STOP_LOSS?t("stopLossDurationTooltip"):t("maxDurationTooltip"),[t,e]);return{duration:r,onChange:n,milliseconds:r.unit*r.value,onInputChange:a,onUnitSelect:o,label:t("expiry"),tooltip:i,error:s}},nW=()=>{const e=te(a=>a.state.isMarketOrder),{module:t}=oe(),r=Me(),n=M.useMemo(()=>{if(e&&t===ye.STOP_LOSS)return{text:r("triggerMarketPriceDisclaimer"),url:id}},[e,r,t]),s=M.useMemo(()=>{if(!(t!==ye.LIMIT&&t!==ye.TWAP))return{text:r(e?"marketOrderWarning":"limitPriceMessage"),url:"https://www.orbs.com/dtwap-and-dlimit-faq/"}},[e,r,t]);return n||s},Vu=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=oe(),n=te(l=>l.updateState),s=te(l=>l.state.isInvertedTrade),a=te(l=>l.state.typedTriggerPrice),o=te(l=>l.state.typedLimitPrice),i=te(l=>l.state.isMarketOrder);return{onInvert:M.useCallback(()=>{a!==void 0&&n({typedTriggerPrice:j(1).div(a).toFixed()}),o!==void 0&&n({typedLimitPrice:j(1).div(o).toFixed()}),n({isInvertedTrade:!s})},[n,s,a,o,r]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:i}},l5=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:n,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:i}=oe(),{isInverted:c}=Vu(),l=M.useMemo(()=>j((()=>{if(e!==void 0){const E=c?j(e).isZero()?j(0):j(1).div(e):j(e);return Bl(E.toFixed(),t)}if(n!==void 0&&j(r||"0").gt(0)&&!j(r||"0").isNaN()){const E=j(r||"0"),v=j(n||0).div(100);return E.plus(E.multipliedBy(v)).decimalPlaces(0).toFixed()}return j(r).gt(0)?r:""})()).decimalPlaces(0).toFixed(),[e,n,t,r,c]),u=M.useCallback(g=>{s(g),a(null)},[s,a]),d=M.useCallback(g=>{s(void 0),a(g)},[s,a]),f=M.useMemo(()=>{if(!r||j(r).isZero())return"";if(n!=null)return n;if(l){const g=j(r),v=j(l).minus(g).div(g).multipliedBy(100).decimalPlaces(2).toString();return j(v||"0").isZero()?"":v}return""},[l,r,n]),h=M.useMemo(()=>{let g="";if(e!==void 0)g=e;else{const E=Ii(l,t);if(j(E||"0").isZero())return"";g=c?j(1).div(E).toFixed():E}return _f(g,6,t)},[e,t,l,c]),y=aa(c?o:i,h||"0");return{amountWei:j(l).isNaN()?"":l,amountUI:j(h).isNaN()?"":h,selectedPercentage:f,onChange:u,onPercentageChange:d,isInverted:c,usd:j(y).isNaN()?"":y}},sW=()=>{const{module:e}=oe();return M.useMemo(()=>e===ye.STOP_LOSS?em:tm,[e])},Eh=()=>{const{module:e}=oe(),t=te(r=>r.state.isMarketOrder);return M.useMemo(()=>e!==ye.STOP_LOSS&&e!==ye.TAKE_PROFIT||t?void 0:e===ye.STOP_LOSS?rm:nm,[e,t])},aW=(e="")=>{const{module:t,marketPrice:r,typedInputAmount:n}=oe(),s=Me();return M.useMemo(()=>{if(j(n||"0").isZero()||!r||t!==ye.STOP_LOSS&&t!==ye.TAKE_PROFIT)return;const a=mm(r||"",e||"",t);if(a!=null&&a.isError)return{type:Gt.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:a.value,message:s("StopLossTriggerPriceError")||""};const o=bm(r||"",e||"",t);if(o!=null&&o.isError)return{type:Gt.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:o.value,message:s("TakeProfitTriggerPriceError")||""};if(!e||j(e||0).isZero())return{type:Gt.EMPTY_TRIGGER_PRICE,value:e,message:s("emptyTriggerPrice")||""}},[r,e,t,s,n])},oW=e=>{const{srcToken:t,dstToken:r,module:n,dstUsd1Token:s}=oe(),a=qr().amountPerTradeWei,o=te(l=>l.state.isMarketOrder),i=M.useMemo(()=>cm(n,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,n]),c=Rn((r==null?void 0:r.decimals)||0,i);return{amountWei:i,amountUI:c,usd:aa(c,s)}},da=()=>{const{dstToken:e,marketPrice:t,module:r,callbacks:n}=oe(),s=te(y=>y.updateState),a=sW(),o=te(y=>y.state.triggerPricePercent),i=o===void 0?a:o,c=r===ye.STOP_LOSS||r===ye.TAKE_PROFIT,l=l5({typedValue:te(y=>y.state.typedTriggerPrice),percentage:i,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:c?t:void 0,setValue:M.useCallback(y=>{var g;s({typedTriggerPrice:y}),(g=n==null?void 0:n.onTriggerPriceChange)==null||g.call(n,y||"")},[s,n]),setPercentage:M.useCallback(y=>{var g;s({triggerPricePercent:y}),(g=n==null?void 0:n.onTriggerPricePercentChange)==null||g.call(n,y||"")},[s,n])}),u=aW(l.amountWei),{amountWei:d,amountUI:f,usd:h}=oW(l.amountWei);return M.useMemo(()=>({...l,error:u,pricePerChunkWei:d,pricePerChunkUI:f,pricePerChunkUsd:h}),[l,u,d,f,h])},iW=()=>{const{module:e,marketPrice:t,marketPriceLoading:r}=oe(),n=Me(),{amountUI:s,onChange:a,onPercentageChange:o,usd:i,selectedPercentage:c,error:l,pricePerChunkUI:u,pricePerChunkUsd:d}=da(),f=te(C=>C.state.isMarketOrder),h=te(C=>C.updateState),{isInverted:y,onInvert:g,fromToken:E,toToken:v}=Vu(),w=M.useCallback(()=>{h({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[h]),A=e!==ye.STOP_LOSS&&e!==ye.TAKE_PROFIT;return{price:s,amountPerChunk:u,amountPerChunkUsd:d,error:l,label:n("stopLossLabel"),tooltip:e===ye.STOP_LOSS?n("stopLossTooltip"):n("takeProfitTooltip"),onChange:a,onPercentageChange:o,percentage:c,isActive:!f,onReset:w,usd:i,fromToken:E,toToken:v,prefix:"",isLoading:r||!t,isInverted:y,hide:A,onInvert:g,totalTrades:qr().totalTrades}},cW=e=>{const{module:t,marketPrice:r,typedInputAmount:n}=oe(),s=Me(),{amountWei:a}=da(),o=te(i=>i.state.isMarketOrder);return M.useMemo(()=>{if(j(n||"0").isZero()||!a||!r)return;const i=ym(a,e,o,t),c=gm(a,e,o,t);if(i!=null&&i.isError)return{type:Gt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:i.value};if(c!=null&&c.isError)return{type:Gt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:c.value};if(e&&j(e||0).isZero())return{type:Gt.MISSING_LIMIT_PRICE,message:s("emptyLimitPrice")||"",value:e||""}},[e,s,a,t,o,n,r])},xc=()=>{const{dstToken:e,marketPrice:t,callbacks:r}=oe(),n=te(l=>l.updateState),s=Eh(),a=te(l=>l.state.limitPricePercent),o=a===void 0?s:a,i=l5({typedValue:te(l=>l.state.typedLimitPrice),percentage:o,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:t,setValue:M.useCallback(l=>{var u;n({typedLimitPrice:l}),(u=r==null?void 0:r.onLimitPriceChange)==null||u.call(r,l||"")},[n,r]),setPercentage:M.useCallback(l=>{var u;n({limitPricePercent:l}),(u=r==null?void 0:r.onLimitPricePercentChange)==null||u.call(r,l||"")},[n,r])}),c=cW(i.amountWei);return M.useMemo(()=>({...i,error:c}),[i,c])},lW=()=>{const{module:e}=oe(),t=te(i=>i.updateState),r=te(i=>i.state.isMarketOrder),n=Eh(),s=te(i=>i.state.triggerPricePercent)||0,a=e===ye.LIMIT,o=M.useCallback(()=>{!r&&e===ye.STOP_LOSS&&t({limitPricePercent:n}),t({isMarketOrder:!r})},[t,s,e,r,n]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:a}},u5=()=>{const{module:e,marketPrice:t}=oe(),r=xc().amountWei,n=da().amountWei,s=te(a=>a.state.isMarketOrder);return e===ye.LIMIT||!s?r||"":e===ye.STOP_LOSS||e===ye.TAKE_PROFIT?n||"":t||""},wc=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=oe(),n=u5(),s=dn().amountWei,a=M.useMemo(()=>om(s||"",n,(e==null?void 0:e.decimals)||0),[s,n,e==null?void 0:e.decimals]),o=Rn(t==null?void 0:t.decimals,a);return{amountWei:a,amountUI:o,usd:aa(o,r)}},Wu=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=oe(),n=u5(),s=qr().amountPerTradeWei,a=te(c=>c.state.isMarketOrder),o=M.useMemo(()=>im(s,n,!!a,(e==null?void 0:e.decimals)||0),[s,n,a,e==null?void 0:e.decimals]),i=Rn(t==null?void 0:t.decimals,o);return{amountWei:o,amountUI:i,usd:aa(i,r)}},uW=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:r}=oe(),{amountUI:n,usd:s}=wc(),o=SG()?e:n;return{value:Z2(o,7),valueWei:Y2(r==null?void 0:r.decimals,o),isLoading:t,usd:s}},dW=()=>{const{module:e,marketPriceLoading:t}=oe(),r=Me(),{amountUI:n,onChange:s,onPercentageChange:a,usd:o,selectedPercentage:i,error:c}=xc(),{amountUI:l,usd:u}=Wu(),d=te(D=>D.updateState),f=Eh(),{isLimitPrice:h,toggleLimitPrice:y}=lW(),{isInverted:g,onInvert:E,fromToken:v,toToken:w}=Vu(),A=M.useCallback(()=>{d({typedLimitPrice:void 0}),d({limitPricePercent:f})},[d,e,f]),C=M.useMemo(()=>e===ye.STOP_LOSS?r("stopLossLimitPriceTooltip"):r("limitPriceTooltip"),[r,e]);return{price:n,amountPerChunk:l,amountPerChunkUsd:u,error:c,label:r("limitPrice"),tooltip:C,onChange:s,onPercentageChange:a,onReset:A,usd:o,fromToken:v,tradesAmount:qr().totalTrades,toToken:w,percentage:i,isInverted:g,isLoading:t,isLimitPrice:h,toggleLimitPrice:y,onInvert:E}};function d5(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:r,srcUsd1Token:n,srcBalance:s,chainId:a}=oe(),o=te(g=>g.state.swapExecution.status),i=Me(),{error:c}=da(),{error:l}=xc(),{error:u}=qr(),{error:d}=ua(),{error:f}=vh(),h=dn().amountWei,y=M.useMemo(()=>{if(s&&j(h).gt(s))return{type:Gt.INSUFFICIENT_BALANCE,message:i("insufficientFunds"),value:s||""}},[s,h,i,a]);return M.useMemo(()=>Am({marketPrice:e,typedInputAmount:r,srcUsd1Token:n,marketPriceLoading:t,triggerPriceError:c,limitPriceError:l,tradesError:u,fillDelayError:d,durationError:f,balanceError:y}),[e,t,r,c,l,u,d,f,y,o,n])}const pW=()=>{const e=te(n=>n.state.isMarketOrder),t=te(n=>n.updateState),r=M.useCallback(()=>{t({isMarketOrder:!e})},[t,e]);return{isMarketPrice:!e,togglePrice:r}},kh=()=>{const e=te(r=>r.state.currentTime),t=vh().duration;return M.useMemo(()=>pm(e,t),[e,t])},fW=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=oe(),r=dn().amountUI,n=wc().amountUI,s=aa(r,e),a=aa(n,t);return{srcAmountUsd:s,dstAmountUsd:a}},hW=()=>{const{fees:e,dstUsd1Token:t}=oe(),{amountUI:r}=wc(),n=M.useMemo(()=>!e||!r?"":j(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]);return{amount:n,percent:e,usd:aa(n,t)}},p5=()=>{const{srcToken:e,dstToken:t,account:r,chainId:n,slippage:s,config:a,module:o}=oe(),{amountWei:i}=dn(),{amountWei:c}=xc(),{amountPerTradeWei:l,totalTrades:u}=qr(),d=kh(),{amountWei:f}=Wu(),{pricePerChunkWei:h}=da(),{milliseconds:y}=ua();return M.useMemo(()=>{var g;return{srcToken:e,dstToken:t,limitPrice:c,deadline:d,srcAmount:i,srcAmountPerTrade:l,totalTrades:u,minDestAmountPerTrade:f,tradeInterval:y,triggerPricePerTrade:h,maker:r,rePermitData:Sm({chainId:n,srcToken:Is((e==null?void 0:e.address)||"")?((g=Bs(n))==null?void 0:g.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:i,deadlineMillis:d,fillDelayMillis:!u||u===1?0:y,slippage:s*100,account:r,srcAmountPerTrade:l,dstMinAmountPerTrade:f,triggerAmountPerTrade:h,config:a,module:o})}},[e,t,c,d,i,l,u,f,h,r,y,s,n,a,o])},f5=()=>{const{srcToken:e,dstToken:t,account:r}=oe(),n=Me(),{amountUI:s,usd:a}=Wu(),{amountPerTradeUI:o,amountPerTradeUsd:i,totalTrades:c}=qr(),{amountUI:l,usd:u}=da(),d=kh(),{amountUI:f,usd:h}=xc(),{amount:y,percent:g,usd:E}=hW(),{milliseconds:v}=ua(),{amountUI:w}=wc(),{srcAmountUsd:A,dstAmountUsd:C}=fW(),D=dn().amountUI,z=te(x=>x.state.isMarketOrder),T=X2({srcToken:e,dstToken:t,account:r,limitPrice:z?void 0:f,limitPriceUsd:z?void 0:h,deadline:d,tradeInterval:v,srcAmount:D,totalTrades:c,srcAmountPerTrade:o,srcAmountPerTradeUsd:i,minDestAmountPerTrade:s,minDestAmountPerTradeUsd:a,triggerPrice:l,triggerPriceUsd:u,srcUsd:A,dstUsd:C,dstAmount:w}),m=Ze({value:y}),b=Ze({value:E});return M.useMemo(()=>({...T,fees:{label:n("fees",{value:`${g}%`}),amount:m,usd:b||"",percentage:g}}),[T,m,b,g])},h5=M.createContext({}),mW=({children:e,...t})=>B.jsx(h5.Provider,{value:t,children:e}),bW=()=>M.useContext(h5),m5=()=>{var s,a;const e=Me(),{wrapTxHash:t,srcToken:r}=te(o=>o.state.swapExecution),n=(a=(s=oc())==null?void 0:s.wToken)==null?void 0:a.symbol;return t?B.jsx("p",{className:"twap-error-wrap-msg",children:e("wrapMsg",{symbol:(r==null?void 0:r.symbol)||"",wSymbol:n||""})}):null},b5=()=>{const e=Me(),t=te(n=>n.state.swapExecution.status),r=ex();return t===ht.SUCCESS?e("createOrderActionSuccess",{name:r}):e("createOrderAction",{name:r})},yW=()=>{const e=te(y=>y.state.swapExecution.srcToken),t=Me(),{step:r,wrapTxHash:n,approveTxHash:s}=te(y=>y.state.swapExecution),a=oc(),o=V0(n),i=V0(n),c=V0(s),l=te(y=>y.state.swapExecution.status),d=Is((e==null?void 0:e.address)||"")?(a==null?void 0:a.native.symbol)||"":(e==null?void 0:e.symbol)||"",f=a==null?void 0:a.wToken.symbol,h=b5();return M.useMemo(()=>r===Ds.WRAP?{title:t("wrapAction",{symbol:d}),footerLink:o,footerText:t(o?"viewOnExplorer":"proceedInWallet")}:r===Ds.APPROVE?{title:t("approveAction",{symbol:d}),footerLink:c,footerText:t(c?"viewOnExplorer":"proceedInWallet")}:{title:h,footerText:l===ht.LOADING?t("proceedInWallet"):void 0},[r,c,d,h,t,o,i,f,l])},gW=({error:e})=>B.jsxs("div",{className:"twap-error",children:[B.jsx("h2",{className:"twap-error-title",children:"Transaction failed"}),(e==null?void 0:e.code)&&B.jsxs("p",{className:"twap-error-code",children:["Error code: ",e==null?void 0:e.code]}),B.jsx(m5,{})]});function xW({error:e}){const{components:t}=oe(),r=Me(),n=te(o=>{var i;return(i=o.state.swapExecution)==null?void 0:i.wrapTxHash}),s=t.SubmitOrderErrorView,a=B.jsx(Xn.Failed,{error:B.jsx(gW,{error:e}),footerLink:id,footerText:r("viewOnExplorer")});return s?B.jsx(s,{wrapTxHash:n,error:e,children:a}):a}const wW=()=>{const{components:e}=oe(),t=te(u=>u.state.swapExecution.srcToken),r=te(u=>u.state.swapExecution.dstToken),{reviewDetails:n}=bW(),s=Me(),a=te(u=>{var d;return!!((d=u.state.swapExecution)!=null&&d.status)}),o=f5(),i=e.USD,c=e.SubmitOrderMainView,l=B.jsxs(B.Fragment,{children:[B.jsx(Xn.Main,{fromTitle:s("from"),toTitle:s("to"),inUsd:i?B.jsx(i,{value:o.srcUsd,isLoading:!1}):`$${o.srcUsd}`,outUsd:i?B.jsx(i,{value:o.dstUsd,isLoading:!1}):`$${o.dstUsd}`}),!a&&B.jsxs("div",{className:"twap-create-order-bottom",children:[B.jsx(Ee.Container,{children:B.jsxs("div",{className:"twap-create-order-details",children:[B.jsx(Ee.Deadline,{deadline:o.deadline.value,label:o.deadline.label,tooltip:o.deadline.tooltip||""}),B.jsx(Ee.Price,{srcToken:t,price:o.triggerPrice.value,dstToken:r,label:o.triggerPrice.label,tooltip:o.triggerPrice.tooltip,usd:o.triggerPrice.usd}),B.jsx(Ee.Price,{srcToken:t,price:o.limitPrice.value,dstToken:r,label:o.limitPrice.label,usd:o.limitPrice.usd,tooltip:o.limitPrice.tooltip}),B.jsx(Ee.MinDestAmount,{dstToken:r,dstMinAmountOut:o.minDestAmountPerTrade.value,label:o.minDestAmountPerTrade.label,tooltip:o.minDestAmountPerTrade.tooltip||"",usd:o.minDestAmountPerTrade.usd}),B.jsx(Ee.TradeSize,{tradeSize:o.sizePerTrade.value,trades:o.totalTrades.value,srcToken:t,label:o.sizePerTrade.label,tooltip:o.sizePerTrade.tooltip}),B.jsx(Ee.TradesAmount,{trades:o.totalTrades.value,label:o.totalTrades.label,tooltip:o.totalTrades.tooltip}),B.jsx(Ee.TradeInterval,{chunks:o.totalTrades.value,fillDelayMillis:o.tradeInterval.value,label:o.tradeInterval.label,tooltip:o.tradeInterval.tooltip}),B.jsx(Ee.Recipient,{}),o.fees.amount&&B.jsx(Ee.Fees,{fees:o.fees.amount,label:o.fees.label,usd:o.fees.usd,dstTokenSymbol:r==null?void 0:r.symbol})]})}),n]})]});return c?B.jsx(c,{children:l}):l},vW=e=>{const{status:t,stepIndex:r,totalSteps:n,parsedError:s}=te(w=>w.state.swapExecution),{components:a}=oe(),o=a.Spinner,i=a.SuccessIcon,c=a.ErrorIcon,l=a.TokenLogo,{srcToken:u,dstToken:d}=oe(),f=dn().amountUI,h=wc().amountUI,y=Ze({value:f,decimalScale:2}),g=Ze({value:h,decimalScale:2}),E=M.useMemo(()=>({symbol:u==null?void 0:u.symbol,logoUrl:u==null?void 0:u.logoUrl}),[u]),v=M.useMemo(()=>({symbol:d==null?void 0:d.symbol,logoUrl:d==null?void 0:d.logoUrl}),[d]);return B.jsx(mW,{...e,children:B.jsx(Xn,{inAmount:y,outAmount:g,swapStatus:t,totalSteps:n,currentStep:yW(),currentStepIndex:r,inToken:E,outToken:v,components:{SrcTokenLogo:l&&B.jsx(l,{token:u}),DstTokenLogo:l&&B.jsx(l,{token:d}),Failed:B.jsx(xW,{error:s}),Success:B.jsx(EW,{}),Main:B.jsx(wW,{}),Loader:o,SuccessIcon:i,FailedIcon:c}})})},EW=()=>{const e=b5(),{components:t}=oe(),r=te(a=>a.state.swapExecution.orderId),n=t.SubmitOrderSuccessView,s=B.jsxs(B.Fragment,{children:[B.jsx(Xn.Success,{title:e}),B.jsx(m5,{})]});return n?B.jsx(n,{newOrderId:r,children:s}):s},kW=()=>{const{supportedChains:e}=oe();return M.useMemo(()=>e,[e])},CW=()=>{const{config:e}=oe();return M.useMemo(()=>({spender:e.repermit}),[e])},TW=()=>{var c;const{account:e,walletClient:t,overrides:r,refetchBalances:n,callbacks:s,chainId:a}=oe(),o=(c=oc())==null?void 0:c.wToken,i=q0();return Zr({mutationFn:async({onHash:l,srcAmountWei:u})=>{var h,y;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!o)throw new Error("tokenAddress is not defined");let d;dt.onWrapRequest(),(h=s==null?void 0:s.onWrapRequest)==null||h.call(s),r!=null&&r.wrap?d=await r.wrap(u):d=await t.writeContract({abi:Mh,functionName:"deposit",account:e,address:o.address,value:BigInt(u),chain:t.chain}),l==null||l(d);const f=await i(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to wrap token");return dt.onWrapSuccess(d),(y=s==null?void 0:s.onWrapSuccess)==null||y.call(s,{txHash:f.transactionHash,explorerUrl:Bi(f.transactionHash,a),amount:Ii(u,o.decimals)}),n==null||n(),f},onError:l=>{throw dt.onWrapError(l),l}})},AW=()=>{const{account:e,walletClient:t,chainId:r,callbacks:n}=oe(),s=p5().rePermitData,{refetch:a}=K0();return Zr({mutationFn:async()=>{var y,g,E,v;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!r)throw new Error("missing chainId");const{order:o,domain:i,types:c,primaryType:l}=s;dt.onSignOrderRequest(o),(y=n==null?void 0:n.onSignOrderRequest)==null||y.call(n),console.log({domain:i,types:c,primaryType:l,message:o,account:e}),console.log("Using domain:",i),console.log("Using types:",c),console.log("Order data to sign:",JSON.stringify(o,null,2)),console.log(`Account address: ${e}`);let u;try{u=await(t==null?void 0:t.signTypedData({domain:i,types:c,primaryType:l,message:o,account:e}))}catch(w){throw(g=n==null?void 0:n.onSignOrderError)==null||g.call(n,w),dt.onSignOrderError(w),w}dt.onSignOrderSuccess(u),(E=n==null?void 0:n.onSignOrderSuccess)==null||E.call(n,u);const d=jT(u),f={v:q(d.v||0),r:d.r,s:d.s},h=await Fm(o,f);return(v=n==null?void 0:n.onOrderCreated)==null||v.call(n,h),await a(),h}})},y5=()=>{const{account:e,publicClient:t,config:r}=oe();return Zr({mutationFn:async({tokenAddress:n,srcAmountWei:s})=>{if(!t)throw new Error("missing publicClient");if(!e)throw new Error("missing account");if(!r)throw new Error("missing config");const a=await t.readContract({address:n,abi:Ty,functionName:"allowance",args:[e,r.repermit]}).then(i=>i.toString()),o=j(a||"0").lt(j(s).toString());return{allowance:a,approvalRequired:o}}})},SW=()=>{const{account:e,walletClient:t,overrides:r,config:n,chainId:s,callbacks:a}=oe(),o=q0(),{mutateAsync:i}=y5();return Zr({onError:c=>{dt.onApproveError(c)},mutationFn:async({token:c,onHash:l,srcAmountWei:u})=>{var y,g;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!n)throw new Error("missing config");(y=a==null?void 0:a.onApproveRequest)==null||y.call(a),dt.onApproveRequest();let d;if(r!=null&&r.approveOrder?d=await r.approveOrder({tokenAddress:c.address,spenderAddress:n.repermit,amount:Vs}):d=await t.writeContract({abi:Ty,functionName:"approve",account:e,address:c.address,args:[n.repermit,Vs],chain:t.chain}),!d)throw new Error("failed to approve token");l(d);const f=await o(d);if(!f)throw new Error("failed to get transaction receipt");if(f.status==="reverted")throw new Error("failed to approve token");let h=!1;for(let E=0;E<3;E++){const{approvalRequired:v}=await i({tokenAddress:c.address,srcAmountWei:u});if(!v){h=!0;break}E<2&&await new Promise(w=>setTimeout(w,3e3))}if(!h)throw new Error(`Insufficient ${c.symbol} allowance to perform the swap. Please approve the token first.`);return dt.onApproveSuccess(f.transactionHash),(g=a==null?void 0:a.onApproveSuccess)==null||g.call(a,{txHash:f.transactionHash,explorerUrl:Bi(f.transactionHash,s),token:c,amount:Ii(u,c.decimals)}),f}})},PW=()=>{const{account:e,chainId:t,srcToken:r,dstToken:n,module:s,slippage:a}=oe(),o=da(),i=dn().amountWei,c=qr().amountPerTradeWei,l=kh(),u=qr().totalTrades,d=ua().fillDelay,f=Wu().amountWei,h=te(y=>y.state.isMarketOrder);return Zr({mutationFn:async()=>{dt.onRequestOrder({account:e,chainId:t,module:s,srcToken:r,dstToken:n,fromTokenAmount:i,srcChunkAmount:c,triggerPricePerTrade:o.pricePerChunkWei,deadline:l,fillDelay:d.unit*d.value,minDstAmountOutPerTrade:f,slippage:a,isMarketOrder:h||!1,chunksAmount:u})}})};function IW(e){const t=e.message,r=t.match(/,\s*code\s*:\s*(\d+)/i);return{message:t.replace(/^error\s*:/i,"").replace(/,\s*code\s*:\s*\d+/i,"").trim()||"",code:r?Number(r[1]):0}}const BW=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:n}=oe(),s=SW().mutateAsync,a=TW().mutateAsync,o=AW().mutateAsync,{mutateAsync:i}=y5(),c=te(d=>d.updateSwapExecution),{amountWei:l}=dn(),u=PW().mutate;return Zr({mutationFn:async()=>{var f,h;const d=Is((e==null?void 0:e.address)||" ");try{if(!e)throw new Error("missing srcToken");if(!t)throw new Error("missing dstToken");if(!r)throw new Error("missing chainId");const y=r6(e,r);c({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0});const{approvalRequired:g}=await i({tokenAddress:y.address,srcAmountWei:l});let E=0,v=1;d&&v++,g&&v++,c({totalSteps:v,stepIndex:E,allowanceLoading:!1,status:ht.LOADING}),u(),d&&(c({step:Ds.WRAP}),await a({onHash:A=>c({wrapTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),g&&(c({step:Ds.APPROVE}),await s({token:y,onHash:A=>c({approveTxHash:A}),srcAmountWei:l}),E++,c({stepIndex:E})),c({step:Ds.CREATE});const w=await o();return c({status:ht.SUCCESS,orderId:w.id}),w}catch(y){if(Mf(y))(f=n==null?void 0:n.onSubmitOrderRejected)==null||f.call(n),c({step:void 0,status:void 0,stepIndex:void 0,error:y});else{const g=IW(y);(h=n==null?void 0:n.onSubmitOrderFailed)==null||h.call(n,g),c({status:ht.FAILED,parsedError:g,error:y})}throw y}}})},FW=()=>{const{marketPrice:e,srcToken:t,dstToken:r,resetTypedInputAmount:n}=oe(),s=BW(),a=te(g=>g.updateState),{amountUI:o}=dn(),i=te(g=>g.resetState),c=te(g=>g.state.swapExecution),l=te(g=>g.updateSwapExecution),u=ex(),d=M.useCallback(()=>{(c==null?void 0:c.status)===ht.SUCCESS&&(n(),i())},[c==null?void 0:c.status,i,n]),f=M.useCallback(()=>{(c==null?void 0:c.status)!==ht.LOADING&&(a({acceptedSrcAmount:void 0,acceptedMarketPrice:void 0}),l({srcToken:t,dstToken:r,error:void 0,parsedError:void 0,status:void 0,orderId:void 0}))},[a,t,r]),h=Zr({mutationFn:async()=>(a({acceptedSrcAmount:o,acceptedMarketPrice:e}),await s.mutateAsync())}),y=M.useCallback(()=>h.mutateAsync(),[h]);return M.useMemo(()=>({reset:i,onCloseModal:d,onOpenModal:f,onSubmit:y,orderTitle:u,...c,isLoading:(c==null?void 0:c.status)===ht.LOADING,isSuccess:(c==null?void 0:c.status)===ht.SUCCESS,isFailed:(c==null?void 0:c.status)===ht.FAILED}),[i,d,y,c,u])},UW=()=>{const e=Me(),{marketPrice:t,srcToken:r,dstToken:n,marketPriceLoading:s,srcBalance:a,srcUsd1Token:o,noLiquidity:i,typedInputAmount:c}=oe(),l=s||j(o||"0").isZero()||a===void 0||j(t||"0").isZero(),u=!!(r&&n&&c&&l),d=d5(),f=M.useMemo(()=>i?e("noLiquidity"):j(c||"0").isZero()?e("enterAmount"):e("placeOrder"),[d,e,c,i]),h=!!(d||i||u||j(c||"0").isZero()||!r||!n);return M.useMemo(()=>({disabled:h,text:f,loading:u}),[h,f,u])},OW=({children:e,container:t})=>{const[r,n]=M.useState(!1),s=M.useRef(null);if(M.useLayoutEffect(()=>(n(!0),s.current=t??document.body,()=>{s.current=null}),[]),typeof document>"u"||!r)return null;const a=s.current;return a?As.createPortal(e,a):null};Im(Iw.version);const DW={SubmitOrderPanel:vW,Orders:ZV,Portal:OW};R.CRASH_ERROR_MESSAGE=rw,R.Components=DW,R.Configs=Dt,R.DEFAULT_DURATION_OPTIONS=JL,R.DEFAULT_FILL_DELAY=Fc,R.DEFAULT_STOP_LOSS_LIMIT_PERCENTAGE=rm,R.DEFAULT_STOP_LOSS_PERCENTAGE=em,R.DEFAULT_TAKE_PROFIT_LIMIT_PERCENTAGE=nm,R.DEFAULT_TAKE_PROFIT_PERCENTAGE=tm,R.DISCLAIMER_URL=tw,R.EIP712_TYPES=Jh,R.ERC20_ABI=H5,R.EXCLUSIVITY_OVERRIDE_BPS=Z5,R.FEES=Y5,R.IWETH_ABI=Mh,R.InputErrors=Gt,R.LEGACY_EXCHANGES_MAP=Xh,R.MAX_ORDER_DURATION_MILLIS=Ca,R.MIN_CHUNKS=K5,R.MIN_FILL_DELAY_MILLIS=Ic,R.MIN_FILL_DELAY_MINUTES=qh,R.MIN_ORDER_DURATION_MILLIS=ad,R.Module=ye,R.ORBS_LOGO=Q5,R.ORBS_LOGO_FALLBACK=J5,R.ORBS_SLTP_FAQ_URL=X5,R.ORBS_TWAP_FAQ_URL=id,R.ORBS_WEBSITE_URL=ew,R.OrderStatus=ct,R.OrderType=ze,R.PRICE_PROTECTION_SETTINGS=ez,R.Partners=zh,R.QUERY_PARAMS=Ta,R.REPERMIT_ABI=Nh,R.REPERMIT_PRIMARY_TYPE=Qh,R.SUGGEST_CHUNK_VALUE=q5,R.SpotProvider=XL,R.Steps=Ds,R.SwapStatus=ht,R.THE_GRAPH_ORDERS_API=Kh,R.TWAP_ABI=Lh,R.TimeUnit=$t,R.analytics=dt,R.buildRePermitOrderData=Sm,R.buildV2Order=pd,R.copy=WT,R.ensureWrappedToken=r6,R.eqIgnoreCase=Ps,R.fillDelayText=t6,R.formatDecimals=_f,R.getAccountOrders=_m,R.getApiEndpoint=sd,R.getChunks=um,R.getConfig=ld,R.getDeadline=pm,R.getDestTokenAmount=om,R.getDestTokenMinAmountPerChunk=im,R.getDuration=lm,R.getErrors=Am,R.getEstimatedDelayBetweenChunksMillis=fm,R.getExplorerUrl=Bi,R.getMaxChunksError=km,R.getMaxFillDelayError=iw,R.getMaxOrderDurationError=xm,R.getMaxPossibleChunks=dm,R.getMinChunkSizeUsd=Tm,R.getMinFillDelayError=vm,R.getMinNativeBalance=KT,R.getMinOrderDurationError=wm,R.getMinTradeSizeError=Em,R.getNetwork=Bs,R.getOrderExcecutionRate=Gh,R.getOrderFillDelayMillis=td,R.getOrderLimitPriceRate=jh,R.getOrderType=YT,R.getPartnerChains=$h,R.getPartnerIdentifier=_t,R.getPartners=Cm,R.getSrcTokenChunkAmount=hm,R.getStopLossLimitPriceError=ym,R.getStopLossPriceError=mm,R.getTakeProfitLimitPriceError=gm,R.getTakeProfitPriceError=bm,R.getTriggerPricePerChunk=cm,R.getTriggerPricePerTrade=Vh,R.isNativeAddress=Is,R.isTxRejected=Mf,R.makeElipsisAddress=Df,R.maxUint256=Bc,R.millisToDays=n6,R.millisToMinutes=Nf,R.nativeTokenAddresses=Zh,R.networks=Ft,R.parseError=qT,R.removeCommas=VT,R.setApiMode=W5,R.setUIVersion=Im,R.shouldUnwrapOnly=zf,R.shouldWrapOnly=Lf,R.submitOrder=Fm,R.toAmountUi=Ii,R.toAmountWei=Bl,R.useAddresses=CW,R.useDisclaimerPanel=nW,R.useDstTokenPanel=uW,R.useDurationPanel=rW,R.useFillDelayPanel=QV,R.useFormatNumber=Ze,R.useInputErrors=d5,R.useInvertTradePanel=Vu,R.useLimitPricePanel=dW,R.useOrder=p5,R.useOrderHistoryPanel=qG,R.useOrderInfo=f5,R.usePartnerChains=kW,R.useSubmitOrderButton=UW,R.useSubmitOrderPanel=FW,R.useTogglePricePanel=pW,R.useTradesPanel=eW,R.useTranslations=Me,R.useTriggerPricePanel=iW,R.zeroAddress=Yh,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|