@orbs-network/spot-react 0.0.106 → 0.0.107

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-D8vjSZ9S.js";
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-ayJL01WX.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;
@@ -3236,7 +3236,7 @@ const d3 = async ({
3236
3236
  }) => (await Promise.all([
3237
3237
  s ? d3({ chainId: r, signal: e, page: t, limit: n, filters: { accounts: [a], configs: s.twapConfig ? [s.twapConfig] : [] } }) : Promise.resolve([]),
3238
3238
  r3({ chainId: r, signal: e, account: a, exchange: s == null ? void 0 : s.adapter })
3239
- ]).then(([c, l]) => [...c, ...l])).sort((c, l) => l.createdAt - c.createdAt), h3 = "0.0.106", b3 = {
3239
+ ]).then(([c, l]) => [...c, ...l])).sort((c, l) => l.createdAt - c.createdAt), h3 = "0.0.107", b3 = {
3240
3240
  version: h3
3241
3241
  };
3242
3242
  var vo = class {
@@ -5332,7 +5332,7 @@ const nh = (e) => {
5332
5332
  updateState: (r) => e((n) => ({ state: { ...n.state, ...r } })),
5333
5333
  updateSwapExecution: (r) => e((n) => ({ state: { ...n.state, swapExecution: { ...n.state.swapExecution, ...r } } })),
5334
5334
  resetSwapExecution: (r) => e((n) => ({ state: { ...n.state, swapExecution: { ...fd.swapExecution, ...r } } })),
5335
- resetState: () => {
5335
+ resetState: (r) => {
5336
5336
  e({
5337
5337
  state: {
5338
5338
  ...fd,
@@ -5342,7 +5342,8 @@ const nh = (e) => {
5342
5342
  acceptedMarketPrice: void 0,
5343
5343
  acceptedSrcAmount: void 0
5344
5344
  },
5345
- isMarketOrder: t().state.isMarketOrder
5345
+ isMarketOrder: t().state.isMarketOrder,
5346
+ ...r
5346
5347
  }
5347
5348
  }), setTimeout(() => {
5348
5349
  t().resetSwapExecution();
@@ -11897,7 +11898,7 @@ async function Tu(e, t) {
11897
11898
  });
11898
11899
  return ie === "0x" ? { data: void 0 } : { data: ie };
11899
11900
  } catch (O) {
11900
- const U = k7(O), { offchainLookup: N, offchainLookupSignature: L } = await import("./ccip-rPATnJwJ.js");
11901
+ const U = k7(O), { offchainLookup: N, offchainLookupSignature: L } = await import("./ccip-BfkC6SlB.js");
11901
11902
  if (e.ccipRead !== !1 && (U == null ? void 0 : U.slice(0, 10)) === L && C)
11902
11903
  return { data: await N(e, { data: U, to: C }) };
11903
11904
  throw T && (U == null ? void 0 : U.slice(0, 10)) === "0x101bb98d" ? new QE({ factory: f }) : f0(O, {
@@ -39919,10 +39920,10 @@ const ym = () => {
39919
39920
  const a = r.getQueryData(n);
39920
39921
  let o = !1;
39921
39922
  const i = [];
39922
- a && a.forEach((l) => {
39923
+ a && a.filter((l) => l.version === 2).forEach((l) => {
39923
39924
  var d;
39924
39925
  const u = s.find((f) => f.id === l.id);
39925
- !(u != null && u.twapAddress) && l.twapAddress && u && u.progress !== l.progress && (o = !0, i.push(u), u.status === gt.Completed && ((d = e == null ? void 0 : e.onOrderFilled) == null || d.call(e, u)));
39926
+ u && u.progress !== l.progress && (o = !0, i.push(u), u.status === gt.Completed && ((d = e == null ? void 0 : e.onOrderFilled) == null || d.call(e, u)));
39926
39927
  }), o && ((c = e == null ? void 0 : e.onOrdersProgressUpdate) == null || c.call(e, i), t == null || t());
39927
39928
  },
39928
39929
  [r, n, e, t]
@@ -39972,7 +39973,12 @@ const ym = () => {
39972
39973
  return X5(r, e.decimals, t.decimals);
39973
39974
  }, [r, e, t]), IW = (e, t, r) => Q(() => {
39974
39975
  if (!(!e || !t || !r))
39975
- return bb(r.srcAmountFilled, r.dstAmountFilled, e.decimals, t.decimals);
39976
+ return bb(
39977
+ r.srcAmountFilled,
39978
+ r.dstAmountFilled,
39979
+ e.decimals,
39980
+ t.decimals
39981
+ );
39976
39982
  }, [r, e, t]), BW = () => {
39977
39983
  const e = J((r) => r.updateState), t = J((r) => r.state.orderIdsToCancel);
39978
39984
  return ze(
@@ -44928,7 +44934,7 @@ const dY = () => {
44928
44934
  });
44929
44935
  }, yZ = () => {
44930
44936
  const { marketPrice: e, srcToken: t, dstToken: r, resetTypedInputAmount: n } = ne(), s = dY(), { amountUI: a } = Jr(), o = J((g) => g.resetState), i = J((g) => g.state.swapExecution), c = J((g) => g.updateSwapExecution), l = J((g) => g.resetSwapExecution), u = n2(), d = ze(() => {
44931
- (i == null ? void 0 : i.status) === yt.SUCCESS && n(), (i == null ? void 0 : i.status) !== yt.LOADING && o();
44937
+ (i == null ? void 0 : i.status) === yt.SUCCESS && n(), i != null && i.status && (i == null ? void 0 : i.status) !== yt.LOADING && o();
44932
44938
  }, [i == null ? void 0 : i.status, o, n]), f = ze(() => {
44933
44939
  (i == null ? void 0 : i.status) !== yt.LOADING && l({
44934
44940
  srcToken: t,
@@ -1,6 +1,6 @@
1
1
  declare const _default: {
2
2
  "name": "@orbs-network/spot-react",
3
- "version": "0.0.106",
3
+ "version": "0.0.107",
4
4
  "description": "Spot React Components - React components for Spot SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/spot-react.umd.cjs",
@@ -1 +1 @@
1
- {"version":3,"file":"order-hooks.d.ts","sourceRoot":"","sources":["../../../../src/hooks/order-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EAEL,SAAS,EAIT,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOjC,eAAO,MAAM,aAAa,GAAI,OAAO,SAAS,WAoB7C,CAAC;AAEF,eAAO,MAAM,YAAY,iBAoBxB,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAGhC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,KAAK,WAEjD,CAAC;AAUF,eAAO,MAAM,cAAc,gBAKf,KAAK,SAShB,CAAC;AAyCF,eAAO,MAAM,cAAc,sEAkC1B,CAAC;AAsBF,eAAO,MAAM,iBAAiB,eAS7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,WAAW,KAAK,EAChB,WAAW,KAAK,EAChB,QAAQ,KAAK,uBAUd,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,WAAW,KAAK,EAChB,WAAW,KAAK,EAChB,QAAQ,KAAK,uBAMd,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,WAAW,KAAK,EAChB,WAAW,KAAK,EAChB,QAAQ,KAAK,uBAMd,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAI/B,MAAM,SAad,CAAC;AAEF,eAAO,MAAM,qBAAqB,kBAIpB,WAAW,WAiBxB,CAAC;AAkBF,eAAO,MAAM,oBAAoB;;2BAsDf,KAAK;oDAlCQ,WAAW;0BAehC,MAAM;;;;;;;;;;;;;;;;;;;CA0Df,CAAC"}
1
+ {"version":3,"file":"order-hooks.d.ts","sourceRoot":"","sources":["../../../../src/hooks/order-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EAEL,SAAS,EAIT,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAK/B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAOjC,eAAO,MAAM,aAAa,GAAI,OAAO,SAAS,WAoB7C,CAAC;AAEF,eAAO,MAAM,YAAY,iBAoBxB,CAAC;AAEF,eAAO,MAAM,oBAAoB,cAGhC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,KAAK,WAEjD,CAAC;AAUF,eAAO,MAAM,cAAc,gBAKf,KAAK,SAShB,CAAC;AAyCF,eAAO,MAAM,cAAc,sEAkC1B,CAAC;AAsBF,eAAO,MAAM,iBAAiB,eAS7B,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,WAAW,KAAK,EAChB,WAAW,KAAK,EAChB,QAAQ,KAAK,uBAUd,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,WAAW,KAAK,EAChB,WAAW,KAAK,EAChB,QAAQ,KAAK,uBAMd,CAAC;AAEF,eAAO,MAAM,yBAAyB,GACpC,WAAW,KAAK,EAChB,WAAW,KAAK,EAChB,QAAQ,KAAK,uBAWd,CAAC;AAEF,eAAO,MAAM,2BAA2B,aAI/B,MAAM,SAad,CAAC;AAEF,eAAO,MAAM,qBAAqB,kBAIpB,WAAW,WAiBxB,CAAC;AAcF,eAAO,MAAM,oBAAoB;;2BAsDf,KAAK;oDAlCQ,WAAW;0BAehC,MAAM;;;;;;;;;;;;;;;;;;;CA2Df,CAAC"}
@@ -17,7 +17,7 @@ export declare const useSubmitOrderPanel: () => {
17
17
  allowanceLoading?: boolean;
18
18
  acceptedMarketPrice?: string;
19
19
  acceptedSrcAmount?: string;
20
- reset: () => void;
20
+ reset: (data?: Partial<import('..').State>) => void;
21
21
  onCloseModal: () => void;
22
22
  onOpenModal: () => void;
23
23
  onSubmit: () => Promise<import('../../../spot-ui/src/index.ts').Order>;
@@ -1 +1 @@
1
- {"version":3,"file":"spot-context.d.ts","sourceRoot":"","sources":["../../../src/spot-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAU7E,OAAO,EACL,SAAS,EACT,eAAe,EAGhB,MAAM,SAAS,CAAC;AAgEjB,eAAO,MAAM,WAAW,uCAA8C,CAAC;AAkLvE,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,4CAM5C,CAAC;AAEF,eAAO,MAAM,cAAc,uBAM1B,CAAC"}
1
+ {"version":3,"file":"spot-context.d.ts","sourceRoot":"","sources":["../../../src/spot-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAU7E,OAAO,EACL,SAAS,EACT,eAAe,EAGhB,MAAM,SAAS,CAAC;AAgEjB,eAAO,MAAM,WAAW,uCAA8C,CAAC;AAoLvE,eAAO,MAAM,YAAY,GAAI,OAAO,SAAS,4CAM5C,CAAC;AAEF,eAAO,MAAM,cAAc,uBAM1B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { State, SwapExecution } from './types';
2
2
  interface SpotStore {
3
- resetState: () => void;
3
+ resetState: (data?: Partial<State>) => void;
4
4
  updateState: (value: Partial<State>) => void;
5
5
  updateSwapExecution: (value: Partial<SwapExecution>) => void;
6
6
  resetSwapExecution: (value?: Partial<SwapExecution>) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG/C,UAAU,SAAS;IACjB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,mBAAmB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC7D,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC7D,KAAK,EAAE,KAAK,CAAC;CACd;AAQD,eAAO,MAAM,YAAY,wEAsBtB,CAAC"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG/C,UAAU,SAAS;IACjB,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC5C,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC7C,mBAAmB,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC7D,kBAAkB,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,KAAK,IAAI,CAAC;IAC7D,KAAK,EAAE,KAAK,CAAC;CACd;AAQD,eAAO,MAAM,YAAY,wEAuBtB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { a$ as e, C as r, ac as t, D as i, aK as n, aZ as E, aX as o, a_ as _, aY as T, aV as u, aO as P, aP as l, ap as A, aM as d, aL as O, N as S, ao as I, au as R, aJ as g, aB as L, az as D, aA as b, aD as m, aC as M, V as C, aS as U, aT as p, aR as N, aQ as c, aU as F, as as k, T as y, U as h, P as B, R as G, aW as x, aq as Y, aN as f, ay as v, S as H, O as W, Q as V, aE as w, ar as K, at as z, ad as Q, bn as X, an as j, Z as q, a3 as J, a9 as Z, _ as $, F as aa, am as sa, ax as ea, b4 as ra, bj as ta, b6 as ia, b0 as na, b1 as Ea, b3 as oa, bm as _a, b7 as Ta, ab as ua, bi as Pa, b9 as la, be as Aa, b5 as da, bl as Oa, bg as Sa, a2 as Ia, bf as Ra, bh as ga, af as La, ai as Da, ag as ba, aj as ma, a6 as Ma, ah as Ca, aI as Ua, bk as pa, b8 as Na, bc as ca, ba as Fa, bd as ka, bb as ya, b2 as ha, ak as Ba, aw as Ga, aa as xa, a1 as Ya, $ as fa, aH as va, a4 as Ha, a5 as Wa, aG as Va, al as wa, a0 as Ka, W as za, av as Qa, ae as Xa, a8 as ja, a7 as qa, bo as Ja, Y as Za, X as $a, y as as, q as ss, m as es, h as rs, j as ts, M as is, t as ns, r as Es, k as os, A as _s, E as Ts, o as us, J as Ps, x as ls, K as As, L as ds, I as Os, G as Ss, z as Is, p as Rs, v as gs, u as Ls, w as Ds, n as bs, aF as ms } from "./index-D8vjSZ9S.js";
1
+ import { a$ as e, C as r, ac as t, D as i, aK as n, aZ as E, aX as o, a_ as _, aY as T, aV as u, aO as P, aP as l, ap as A, aM as d, aL as O, N as S, ao as I, au as R, aJ as g, aB as L, az as D, aA as b, aD as m, aC as M, V as C, aS as U, aT as p, aR as N, aQ as c, aU as F, as as k, T as y, U as h, P as B, R as G, aW as x, aq as Y, aN as f, ay as v, S as H, O as W, Q as V, aE as w, ar as K, at as z, ad as Q, bn as X, an as j, Z as q, a3 as J, a9 as Z, _ as $, F as aa, am as sa, ax as ea, b4 as ra, bj as ta, b6 as ia, b0 as na, b1 as Ea, b3 as oa, bm as _a, b7 as Ta, ab as ua, bi as Pa, b9 as la, be as Aa, b5 as da, bl as Oa, bg as Sa, a2 as Ia, bf as Ra, bh as ga, af as La, ai as Da, ag as ba, aj as ma, a6 as Ma, ah as Ca, aI as Ua, bk as pa, b8 as Na, bc as ca, ba as Fa, bd as ka, bb as ya, b2 as ha, ak as Ba, aw as Ga, aa as xa, a1 as Ya, $ as fa, aH as va, a4 as Ha, a5 as Wa, aG as Va, al as wa, a0 as Ka, W as za, av as Qa, ae as Xa, a8 as ja, a7 as qa, bo as Ja, Y as Za, X as $a, y as as, q as ss, m as es, h as rs, j as ts, M as is, t as ns, r as Es, k as os, A as _s, E as Ts, o as us, J as Ps, x as ls, K as As, L as ds, I as Os, G as Ss, z as Is, p as Rs, v as gs, u as Ls, w as Ds, n as bs, aF as ms } from "./index-ayJL01WX.js";
2
2
  export {
3
3
  e as CRASH_ERROR_MESSAGE,
4
4
  r as Components,
@@ -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(m=>({...m,timestamp:new Date(m.timestamp).getTime()}))}})};class Vw extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const Ww=async({chainId:e,signal:t,page:r,limit:n,filters:s})=>{try{const a=await $w({chainId:e,signal:t,page:r,limit:n,filters:s}),[o,i]=await Promise.all([jw({chainId:e,orders:a,signal:t}),Gw({chainId:e,orders:a,signal:t})]),c=a.map(u=>{const d=o==null?void 0:o.filter(f=>f.TWAP_id===Number(u.Contract_id)&&Ds(f.exchange,u.exchange)&&Ds(f.twapAddress,u.twapAddress));return Rw(u,e,d,qw(u,d||[],i))}).sort((u,d)=>d.createdAt-u.createdAt),l=new Set;return c.filter(u=>l.has(u.id)?!1:(l.add(u.id),!0))}catch{return[]}},qw=(e,t,r)=>{var i;const n=(i=r==null?void 0:r.find(c=>c.twapId===e.Contract_id.toString()&&Ds(c.twapAddress,e.twapAddress)))==null?void 0:i.status,a=Uh(t).reduce((c,l)=>c.plus(l.inAmount),new G(0)).toFixed(),o=_h(e.ask_srcAmount,a);return Kw(o,e.ask_deadline*1e3,n)},_h=(e,t)=>{if(!t||!e)return 0;const r=G(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Kw=(e,t,r)=>e===100?ut.Completed:r==="CANCELLED"?ut.Cancelled:r==="COMPLETED"?ut.Completed:t>Date.now()?ut.Open:ut.Expired,Mh=async({signal:e,page:t,chainId:r,limit:n,config:s,account:a})=>(await Promise.all([s?Ww({chainId:r,signal:e,page:t,limit:n,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),Lw({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),Yw={version:"0.0.106"};var Ba=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(){}},Zw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Xw=(B5=class{constructor(){le(this,bn,Zw);le(this,ba,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,ba)&&e!==N(this,bn)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,bn),provider:e}),J(this,bn,e),process.env.NODE_ENV!=="production"&&J(this,ba,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&J(this,ba,!0),N(this,bn).setTimeout(e,t)}clearTimeout(e){N(this,bn).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&J(this,ba,!0),N(this,bn).setInterval(e,t)}clearInterval(e){N(this,bn).clearInterval(e)}},bn=new WeakMap,ba=new WeakMap,B5),Ns=new Xw;function Qw(e){setTimeout(e,0)}var Ls=typeof window>"u"||"Deno"in globalThis;function Gt(){}function Jw(e,t){return typeof e=="function"?e(t):e}function Cd(e){return typeof e=="number"&&e>=0&&e!==1/0}function Nh(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Jn(e,t){return typeof e=="function"?e(t):e}function wr(e,t){return typeof e=="function"?e(t):e}function Lh(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:o,stale:i}=e;if(o){if(n){if(t.queryHash!==Td(o,t.options))return!1}else if(!Ho(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 zh(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(zs(t.options.mutationKey)!==zs(a))return!1}else if(!Ho(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function Td(e,t){return((t==null?void 0:t.queryKeyHashFn)||zs)(e)}function zs(e){return JSON.stringify(e,(t,r)=>Sd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Ho(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Ho(e[r],t[r])):!1}var e3=Object.prototype.hasOwnProperty;function Ad(e,t){if(e===t)return e;const r=Rh(e)&&Rh(t);if(!r&&!(Sd(e)&&Sd(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:e3.call(e,u))&&c++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){i[u]=f;continue}const m=Ad(d,f);i[u]=m,m===d&&c++}return s===o&&c===s?e:i}function Lc(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 Rh(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sd(e){if(!Hh(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Hh(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Hh(e){return Object.prototype.toString.call(e)==="[object Object]"}function t3(e){return new Promise(t=>{Ns.setTimeout(t,e)})}function Pd(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 Ad(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 Ad(e,t)}return t}function r3(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function n3(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var zc=Symbol();function $h(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===zc&&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===zc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Gh(e,t){return typeof e=="function"?e(...t):!!e}var s3=(F5=class extends Ba{constructor(){super();le(this,ya);le(this,ks);le(this,Ao);J(this,Ao,t=>{if(!Ls&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){N(this,ks)||this.setEventListener(N(this,Ao))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,ks))==null||t.call(this),J(this,ks,void 0))}setEventListener(t){var r;J(this,Ao,t),(r=N(this,ks))==null||r.call(this),J(this,ks,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){N(this,ya)!==t&&(J(this,ya,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof N(this,ya)=="boolean"?N(this,ya):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},ya=new WeakMap,ks=new WeakMap,Ao=new WeakMap,F5),Id=new s3;function Bd(){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 a3=Qw;function o3(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=a3;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=o3(),i3=(O5=class extends Ba{constructor(){super();le(this,So,!0);le(this,Cs);le(this,Po);J(this,Po,t=>{if(!Ls&&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,Cs)||this.setEventListener(N(this,Po))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,Cs))==null||t.call(this),J(this,Cs,void 0))}setEventListener(t){var r;J(this,Po,t),(r=N(this,Cs))==null||r.call(this),J(this,Cs,t(this.setOnline.bind(this)))}setOnline(t){N(this,So)!==t&&(J(this,So,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return N(this,So)}},So=new WeakMap,Cs=new WeakMap,Po=new WeakMap,O5),Rc=new i3;function c3(e){return Math.min(1e3*2**e,3e4)}function jh(e){return(e??"online")==="online"?Rc.isOnline():!0}var Fd=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Vh(e){let t=!1,r=0,n;const s=Bd(),a=()=>s.status!=="pending",o=g=>{var E;if(!a()){const v=new Fd(g);f(v),(E=e.onCancel)==null||E.call(e,v)}},i=()=>{t=!0},c=()=>{t=!1},l=()=>Id.isFocused()&&(e.networkMode==="always"||Rc.isOnline())&&e.canRun(),u=()=>jh(e.networkMode)&&e.canRun(),d=g=>{a()||(n==null||n(),s.resolve(g))},f=g=>{a()||(n==null||n(),s.reject(g))},m=()=>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)}),b=()=>{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 L;if(a())return;const w=e.retry??(Ls?0:3),S=e.retryDelay??c3,T=typeof S=="function"?S(r,v):S,O=w===!0||typeof w=="number"&&r<w||typeof w=="function"&&w(r,v);if(t||!O){f(v);return}r++,(L=e.onFail)==null||L.call(e,r,v),t3(T).then(()=>l()?void 0:m()).then(()=>{t?f(v):b()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:i,continueRetry:c,canStart:u,start:()=>(u()?b():m().then(b),s)}}var Wh=(U5=class{constructor(){le(this,ga)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Cd(this.gcTime)&&J(this,ga,Ns.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ls?1/0:300*1e3))}clearGcTimeout(){N(this,ga)&&(Ns.clearTimeout(N(this,ga)),J(this,ga,void 0))}},ga=new WeakMap,U5),l3=(D5=class extends Wh{constructor(t){super();le(this,Xr);le(this,xa);le(this,Io);le(this,Fr);le(this,wa);le(this,Bt);le(this,Sc);le(this,va);J(this,va,!1),J(this,Sc,t.defaultOptions),this.setOptions(t.options),this.observers=[],J(this,wa,t.client),J(this,Fr,N(this,wa).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,J(this,xa,Yh(this.options)),this.state=t.state??N(this,xa),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,Sc),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Yh(this.options);r.data!==void 0&&(this.setState(Kh(r.data,r.dataUpdatedAt)),J(this,xa,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,Fr).remove(this)}setData(t,r){const n=Pd(this.state.data,t,this.options);return Se(this,Xr,Zn).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,Xr,Zn).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(Gt).catch(Gt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(N(this,xa))}isActive(){return this.observers.some(t=>wr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===zc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Jn(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:!Nh(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,Fr).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,va)?N(this,Bt).cancel({revert:!0}):N(this,Bt).cancelRetry()),this.scheduleGc()),N(this,Fr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Se(this,Xr,Zn).call(this,{type:"invalidate"})}async fetch(t,r){var c,l,u,d,f,m,b,g,E,v,w,S;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 T=this.observers.find(O=>O.options.queryFn);T&&this.setOptions(T.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=T=>{Object.defineProperty(T,"signal",{enumerable:!0,get:()=>(J(this,va,!0),n.signal)})},a=()=>{const T=$h(this.options,r),L=(()=>{const P={client:N(this,wa),queryKey:this.queryKey,meta:this.meta};return s(P),P})();return J(this,va,!1),this.options.persister?this.options.persister(T,L,this):T(L)},i=(()=>{const T={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:N(this,wa),state:this.state,fetchFn:a};return s(T),T})();(l=this.options.behavior)==null||l.onFetch(i,this),J(this,Io,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&Se(this,Xr,Zn).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta}),J(this,Bt,Vh({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:T=>{T instanceof Fd&&T.revert&&this.setState({...N(this,Io),fetchStatus:"idle"}),n.abort()},onFail:(T,O)=>{Se(this,Xr,Zn).call(this,{type:"failed",failureCount:T,error:O})},onPause:()=>{Se(this,Xr,Zn).call(this,{type:"pause"})},onContinue:()=>{Se(this,Xr,Zn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const T=await N(this,Bt).start();if(T===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(T),(m=(f=N(this,Fr).config).onSuccess)==null||m.call(f,T,this),(g=(b=N(this,Fr).config).onSettled)==null||g.call(b,T,this.state.error,this),T}catch(T){if(T instanceof Fd){if(T.silent)return N(this,Bt).promise;if(T.revert){if(this.state.data===void 0)throw T;return this.state.data}}throw Se(this,Xr,Zn).call(this,{type:"error",error:T}),(v=(E=N(this,Fr).config).onError)==null||v.call(E,T,this),(S=(w=N(this,Fr).config).onSettled)==null||S.call(w,this.state.data,T,this),T}finally{this.scheduleGc()}}},xa=new WeakMap,Io=new WeakMap,Fr=new WeakMap,wa=new WeakMap,Bt=new WeakMap,Sc=new WeakMap,va=new WeakMap,Xr=new WeakSet,Zn=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,...qh(n.data,this.options),fetchMeta:t.meta??null};case"success":const s={...n,...Kh(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return J(this,Io,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,Fr).notify({query:this,type:"updated",action:t})})},D5);function qh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jh(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Kh(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Yh(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 u3=(_5=class extends Ba{constructor(t,r){super();le(this,We);le(this,nr);le(this,_e);le(this,Pc);le(this,Wt);le(this,Ea);le(this,Bo);le(this,Vn);le(this,Ts);le(this,Ic);le(this,Fo);le(this,Oo);le(this,ka);le(this,Ca);le(this,As);le(this,Uo,new Set);this.options=r,J(this,nr,t),J(this,Ts,null),J(this,Vn,Bd()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,_e).addObserver(this),Zh(N(this,_e),this.options)?Se(this,We,Oc).call(this):this.updateResult(),Se(this,We,Om).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Od(N(this,_e),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Od(N(this,_e),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,We,Um).call(this),Se(this,We,Dm).call(this),N(this,_e).removeObserver(this)}setOptions(t){const r=this.options,n=N(this,_e);if(this.options=N(this,nr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof wr(this.options.enabled,N(this,_e))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Se(this,We,_m).call(this),N(this,_e).setOptions(this.options),r._defaulted&&!Lc(this.options,r)&&N(this,nr).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,_e),observer:this});const s=this.hasListeners();s&&Xh(N(this,_e),n,this.options,r)&&Se(this,We,Oc).call(this),this.updateResult(),s&&(N(this,_e)!==n||wr(this.options.enabled,N(this,_e))!==wr(r.enabled,N(this,_e))||Jn(this.options.staleTime,N(this,_e))!==Jn(r.staleTime,N(this,_e)))&&Se(this,We,Im).call(this);const a=Se(this,We,Bm).call(this);s&&(N(this,_e)!==n||wr(this.options.enabled,N(this,_e))!==wr(r.enabled,N(this,_e))||a!==N(this,As))&&Se(this,We,Fm).call(this,a)}getOptimisticResult(t){const r=N(this,nr).getQueryCache().build(N(this,nr),t),n=this.createResult(r,t);return p3(this,n)&&(J(this,Wt,n),J(this,Bo,this.options),J(this,Ea,N(this,_e).state)),n}getCurrentResult(){return N(this,Wt)}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,Vn).status==="pending"&&N(this,Vn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,s))})}trackProp(t){N(this,Uo).add(t)}getCurrentQuery(){return N(this,_e)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=N(this,nr).defaultQueryOptions(t),n=N(this,nr).getQueryCache().build(N(this,nr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Se(this,We,Oc).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,Wt)))}createResult(t,r){var y;const n=N(this,_e),s=this.options,a=N(this,Wt),o=N(this,Ea),i=N(this,Bo),l=t!==n?t.state:N(this,Pc),{state:u}=t;let d={...u},f=!1,m;if(r._optimisticResults){const x=this.hasListeners(),A=!x&&Zh(t,r),B=x&&Xh(t,n,r,s);(A||B)&&(d={...d,...qh(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:b,errorUpdatedAt:g,status:E}=d;m=d.data;let v=!1;if(r.placeholderData!==void 0&&m===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((y=N(this,Oo))==null?void 0:y.state.data,N(this,Oo)):r.placeholderData,x!==void 0&&(E="success",m=Pd(a==null?void 0:a.data,x,r),f=!0)}if(r.select&&m!==void 0&&!v)if(a&&m===(o==null?void 0:o.data)&&r.select===N(this,Ic))m=N(this,Fo);else try{J(this,Ic,r.select),m=r.select(m),m=Pd(a==null?void 0:a.data,m,r),J(this,Fo,m),J(this,Ts,null)}catch(x){J(this,Ts,x)}N(this,Ts)&&(b=N(this,Ts),m=N(this,Fo),g=Date.now(),E="error");const w=d.fetchStatus==="fetching",S=E==="pending",T=E==="error",O=S&&w,L=m!==void 0,h={status:E,fetchStatus:d.fetchStatus,isPending:S,isSuccess:E==="success",isError:T,isInitialLoading:O,isLoading:O,data:m,dataUpdatedAt:d.dataUpdatedAt,error:b,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&&!S,isLoadingError:T&&!L,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:T&&L,isStale:Ud(t,r),refetch:this.refetch,promise:N(this,Vn),isEnabled:wr(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const x=F=>{h.status==="error"?F.reject(h.error):h.data!==void 0&&F.resolve(h.data)},A=()=>{const F=J(this,Vn,h.promise=Bd());x(F)},B=N(this,Vn);switch(B.status){case"pending":t.queryHash===n.queryHash&&x(B);break;case"fulfilled":(h.status==="error"||h.data!==B.value)&&A();break;case"rejected":(h.status!=="error"||h.error!==B.reason)&&A();break}}return h}updateResult(){const t=N(this,Wt),r=this.createResult(N(this,_e),this.options);if(J(this,Ea,N(this,_e).state),J(this,Bo,this.options),N(this,Ea).data!==void 0&&J(this,Oo,N(this,_e)),Lc(r,t))return;J(this,Wt,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!N(this,Uo).size)return!0;const o=new Set(a??N(this,Uo));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,Wt)).some(i=>{const c=i;return N(this,Wt)[c]!==t[c]&&o.has(c)})};Se(this,We,K5).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,We,Om).call(this)}},nr=new WeakMap,_e=new WeakMap,Pc=new WeakMap,Wt=new WeakMap,Ea=new WeakMap,Bo=new WeakMap,Vn=new WeakMap,Ts=new WeakMap,Ic=new WeakMap,Fo=new WeakMap,Oo=new WeakMap,ka=new WeakMap,Ca=new WeakMap,As=new WeakMap,Uo=new WeakMap,We=new WeakSet,Oc=function(t){Se(this,We,_m).call(this);let r=N(this,_e).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Gt)),r},Im=function(){Se(this,We,Um).call(this);const t=Jn(this.options.staleTime,N(this,_e));if(Ls||N(this,Wt).isStale||!Cd(t))return;const n=Nh(N(this,Wt).dataUpdatedAt,t)+1;J(this,ka,Ns.setTimeout(()=>{N(this,Wt).isStale||this.updateResult()},n))},Bm=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,_e)):this.options.refetchInterval)??!1},Fm=function(t){Se(this,We,Dm).call(this),J(this,As,t),!(Ls||wr(this.options.enabled,N(this,_e))===!1||!Cd(N(this,As))||N(this,As)===0)&&J(this,Ca,Ns.setInterval(()=>{(this.options.refetchIntervalInBackground||Id.isFocused())&&Se(this,We,Oc).call(this)},N(this,As)))},Om=function(){Se(this,We,Im).call(this),Se(this,We,Fm).call(this,Se(this,We,Bm).call(this))},Um=function(){N(this,ka)&&(Ns.clearTimeout(N(this,ka)),J(this,ka,void 0))},Dm=function(){N(this,Ca)&&(Ns.clearInterval(N(this,Ca)),J(this,Ca,void 0))},_m=function(){const t=N(this,nr).getQueryCache().build(N(this,nr),this.options);if(t===N(this,_e))return;const r=N(this,_e);J(this,_e,t),J(this,Pc,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},K5=function(t){kt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(N(this,Wt))}),N(this,nr).getQueryCache().notify({query:N(this,_e),type:"observerResultsUpdated"})})},_5);function d3(e,t){return wr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Zh(e,t){return d3(e,t)||e.state.data!==void 0&&Od(e,t,t.refetchOnMount)}function Od(e,t,r){if(wr(t.enabled,e)!==!1&&Jn(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Ud(e,t)}return!1}function Xh(e,t,r,n){return(e!==t||wr(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Ud(e,r)}function Ud(e,t){return wr(t.enabled,e)!==!1&&e.isStaleByTime(Jn(t.staleTime,e))}function p3(e,t){return!Lc(e.getCurrentResult(),t)}function Qh(e){return{onFetch:(t,r)=>{var u,d,f,m,b;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=((m=t.state.data)==null?void 0:m.pages)||[],o=((b=t.state.data)==null?void 0:b.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const l=async()=>{let g=!1;const E=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=$h(t.options,t.fetchOptions),w=async(S,T,O)=>{if(g)return Promise.reject();if(T==null&&S.pages.length)return Promise.resolve(S);const P=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:T,direction:O?"backward":"forward",meta:t.options.meta};return E(A),A})(),h=await v(P),{maxPages:y}=t.options,x=O?n3:r3;return{pages:x(S.pages,h,y),pageParams:x(S.pageParams,T,y)}};if(s&&a.length){const S=s==="backward",T=S?f3:Jh,O={pages:a,pageParams:o},L=T(n,O);i=await w(O,L,S)}else{const S=e??a.length;do{const T=c===0?o[0]??n.initialPageParam:Jh(n,i);if(c>0&&T==null)break;i=await w(i,T),c++}while(c<S)}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 Jh(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 f3(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 m3=(M5=class extends Wh{constructor(t){super();le(this,gn);le(this,Bc);le(this,yn);le(this,qt);le(this,Ta);J(this,Bc,t.client),this.mutationId=t.mutationId,J(this,qt,t.mutationCache),J(this,yn,[]),this.state=t.state||e1(),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,yn).includes(t)||(N(this,yn).push(t),this.clearGcTimeout(),N(this,qt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){J(this,yn,N(this,yn).filter(r=>r!==t)),this.scheduleGc(),N(this,qt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,yn).length||(this.state.status==="pending"?this.scheduleGc():N(this,qt).remove(this))}continue(){var t;return((t=N(this,Ta))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,c,l,u,d,f,m,b,g,E,v,w,S,T,O,L,P,h,y;const r=()=>{Se(this,gn,Fs).call(this,{type:"continue"})},n={client:N(this,Bc),meta:this.options.meta,mutationKey:this.options.mutationKey};J(this,Ta,Vh({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(x,A)=>{Se(this,gn,Fs).call(this,{type:"failed",failureCount:x,error:A})},onPause:()=>{Se(this,gn,Fs).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,qt).canRun(this)}));const s=this.state.status==="pending",a=!N(this,Ta).canStart();try{if(s)r();else{Se(this,gn,Fs).call(this,{type:"pending",variables:t,isPaused:a}),await((i=(o=N(this,qt).config).onMutate)==null?void 0:i.call(o,t,this,n));const A=await((l=(c=this.options).onMutate)==null?void 0:l.call(c,t,n));A!==this.state.context&&Se(this,gn,Fs).call(this,{type:"pending",context:A,variables:t,isPaused:a})}const x=await N(this,Ta).start();return await((d=(u=N(this,qt).config).onSuccess)==null?void 0:d.call(u,x,t,this.state.context,this,n)),await((m=(f=this.options).onSuccess)==null?void 0:m.call(f,x,t,this.state.context,n)),await((g=(b=N(this,qt).config).onSettled)==null?void 0:g.call(b,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,gn,Fs).call(this,{type:"success",data:x}),x}catch(x){try{throw await((S=(w=N(this,qt).config).onError)==null?void 0:S.call(w,x,t,this.state.context,this,n)),await((O=(T=this.options).onError)==null?void 0:O.call(T,x,t,this.state.context,n)),await((P=(L=N(this,qt).config).onSettled)==null?void 0:P.call(L,void 0,x,this.state.variables,this.state.context,this,n)),await((y=(h=this.options).onSettled)==null?void 0:y.call(h,void 0,x,t,this.state.context,n)),x}finally{Se(this,gn,Fs).call(this,{type:"error",error:x})}}finally{N(this,qt).runNext(this)}}},Bc=new WeakMap,yn=new WeakMap,qt=new WeakMap,Ta=new WeakMap,gn=new WeakSet,Fs=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,yn).forEach(n=>{n.onMutationUpdate(t)}),N(this,qt).notify({mutation:this,type:"updated",action:t})})},M5);function e1(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var h3=(N5=class extends Ba{constructor(t={}){super();le(this,Wn);le(this,Qr);le(this,Fc);this.config=t,J(this,Wn,new Set),J(this,Qr,new Map),J(this,Fc,0)}build(t,r,n){const s=new m3({client:t,mutationCache:this,mutationId:++rd(this,Fc)._,options:t.defaultMutationOptions(r),state:n});return this.add(s),s}add(t){N(this,Wn).add(t);const r=Hc(t);if(typeof r=="string"){const n=N(this,Qr).get(r);n?n.push(t):N(this,Qr).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,Wn).delete(t)){const r=Hc(t);if(typeof r=="string"){const n=N(this,Qr).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,Qr).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Hc(t);if(typeof r=="string"){const n=N(this,Qr).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=Hc(t);if(typeof r=="string"){const s=(n=N(this,Qr).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,Wn).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,Wn).clear(),N(this,Qr).clear()})}getAll(){return Array.from(N(this,Wn))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>zh(r,n))}findAll(t={}){return this.getAll().filter(r=>zh(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(Gt))))}},Wn=new WeakMap,Qr=new WeakMap,Fc=new WeakMap,N5);function Hc(e){var t;return(t=e.options.scope)==null?void 0:t.id}var b3=(L5=class extends Ba{constructor(t,r){super();le(this,Yn);le(this,qn);le(this,Ss);le(this,sr);le(this,Kn);J(this,qn,t),this.setOptions(r),this.bindMethods(),Se(this,Yn,nd).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,qn).defaultMutationOptions(t),Lc(this.options,r)||N(this,qn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,sr),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&zs(r.mutationKey)!==zs(this.options.mutationKey)?this.reset():((n=N(this,sr))==null?void 0:n.state.status)==="pending"&&N(this,sr).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,sr))==null||t.removeObserver(this)}onMutationUpdate(t){Se(this,Yn,nd).call(this),Se(this,Yn,Mm).call(this,t)}getCurrentResult(){return N(this,Ss)}reset(){var t;(t=N(this,sr))==null||t.removeObserver(this),J(this,sr,void 0),Se(this,Yn,nd).call(this),Se(this,Yn,Mm).call(this)}mutate(t,r){var n;return J(this,Kn,r),(n=N(this,sr))==null||n.removeObserver(this),J(this,sr,N(this,qn).getMutationCache().build(N(this,qn),this.options)),N(this,sr).addObserver(this),N(this,sr).execute(t)}},qn=new WeakMap,Ss=new WeakMap,sr=new WeakMap,Kn=new WeakMap,Yn=new WeakSet,nd=function(){var r;const t=((r=N(this,sr))==null?void 0:r.state)??e1();J(this,Ss,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Mm=function(t){kt.batch(()=>{var r,n,s,a,o,i,c,l;if(N(this,Kn)&&this.hasListeners()){const u=N(this,Ss).variables,d=N(this,Ss).context,f={client:N(this,qn),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((n=(r=N(this,Kn)).onSuccess)==null||n.call(r,t.data,u,d,f),(a=(s=N(this,Kn)).onSettled)==null||a.call(s,t.data,null,u,d,f)):(t==null?void 0:t.type)==="error"&&((i=(o=N(this,Kn)).onError)==null||i.call(o,t.error,u,d,f),(l=(c=N(this,Kn)).onSettled)==null||l.call(c,void 0,t.error,u,d,f))}this.listeners.forEach(u=>{u(N(this,Ss))})})},L5),y3=(z5=class extends Ba{constructor(t={}){super();le(this,xn);this.config=t,J(this,xn,new Map)}build(t,r,n){const s=r.queryKey,a=r.queryHash??Td(s,r);let o=this.get(a);return o||(o=new l3({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){N(this,xn).has(t.queryHash)||(N(this,xn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=N(this,xn).get(t.queryHash);r&&(t.destroy(),r===t&&N(this,xn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,xn).get(t)}getAll(){return[...N(this,xn).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Lh(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Lh(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()})})}},xn=new WeakMap,z5),g3=(R5=class{constructor(e={}){le(this,mt);le(this,Ps);le(this,Is);le(this,Do);le(this,_o);le(this,Bs);le(this,Mo);le(this,No);J(this,mt,e.queryCache||new y3),J(this,Ps,e.mutationCache||new h3),J(this,Is,e.defaultOptions||{}),J(this,Do,new Map),J(this,_o,new Map),J(this,Bs,0)}mount(){rd(this,Bs)._++,N(this,Bs)===1&&(J(this,Mo,Id.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,mt).onFocus())})),J(this,No,Rc.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,mt).onOnline())})))}unmount(){var e,t;rd(this,Bs)._--,N(this,Bs)===0&&((e=N(this,Mo))==null||e.call(this),J(this,Mo,void 0),(t=N(this,No))==null||t.call(this),J(this,No,void 0))}isFetching(e){return N(this,mt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,Ps).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,mt).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=N(this,mt).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Jn(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return N(this,mt).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,mt).get(n.queryHash),a=s==null?void 0:s.state.data,o=Jw(t,a);if(o!==void 0)return N(this,mt).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return kt.batch(()=>N(this,mt).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,mt).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=N(this,mt);kt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=N(this,mt);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,mt).findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(Gt).catch(Gt)}invalidateQueries(e,t={}){return kt.batch(()=>(N(this,mt).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,mt).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(Gt)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(Gt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=N(this,mt).build(this,t);return r.isStaleByTime(Jn(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Gt).catch(Gt)}fetchInfiniteQuery(e){return e.behavior=Qh(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Gt).catch(Gt)}ensureInfiniteQueryData(e){return e.behavior=Qh(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Rc.isOnline()?N(this,Ps).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,mt)}getMutationCache(){return N(this,Ps)}getDefaultOptions(){return N(this,Is)}setDefaultOptions(e){J(this,Is,e)}setQueryDefaults(e,t){N(this,Do).set(zs(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,Do).values()],r={};return t.forEach(n=>{Ho(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){N(this,_o).set(zs(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,_o).values()],r={};return t.forEach(n=>{Ho(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,Is).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Td(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===zc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,Is).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,mt).clear(),N(this,Ps).clear()}},mt=new WeakMap,Ps=new WeakMap,Is=new WeakMap,Do=new WeakMap,_o=new WeakMap,Bs=new WeakMap,Mo=new WeakMap,No=new WeakMap,R5),t1=Et.createContext(void 0),Dd=e=>{const t=Et.useContext(t1);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},x3=({client:e,children:t})=>(Et.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),C.jsx(t1.Provider,{value:e,children:t})),r1=Et.createContext(!1),w3=()=>Et.useContext(r1);r1.Provider;function v3(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var E3=Et.createContext(v3()),k3=()=>Et.useContext(E3),C3=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},T3=e=>{Et.useEffect(()=>{e.clearReset()},[e])},A3=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||Gh(r,[e.error,n])),S3=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))}},P3=(e,t)=>e.isLoading&&e.isFetching&&!t,I3=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,n1=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function B3(e,t,r){var d,f,m,b,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=w3(),s=k3(),a=Dd(),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",S3(o),C3(o,s),T3(s);const i=!a.getQueryCache().get(o.queryHash),[c]=Et.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!n&&e.subscribed!==!1;if(Et.useSyncExternalStore(Et.useCallback(E=>{const v=u?c.subscribe(kt.batchCalls(E)):Gt;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Et.useEffect(()=>{c.setOptions(o)},[o,c]),I3(o,l))throw n1(o,c,s);if(A3({result:l,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;if((b=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||b.call(m,o,l),o.experimental_prefetchInRender&&!Ls&&P3(l,n)){const E=i?n1(o,c,s):(g=a.getQueryCache().get(o.queryHash))==null?void 0:g.promise;E==null||E.catch(Gt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?l:c.trackResult(l)}function F3(e,t){return B3(e,u3)}function en(e,t){const r=Dd(),[n]=Et.useState(()=>new b3(r,e));Et.useEffect(()=>{n.setOptions(e)},[n,e]);const s=Et.useSyncExternalStore(Et.useCallback(o=>n.subscribe(kt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=Et.useCallback((o,i)=>{n.mutate(o,i).catch(Gt)},[n]);if(s.error&&Gh(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const O3=M.createContext(null),_d={didCatch:!1,error:null};class U3 extends M.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=_d}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(_d)}}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&&D3(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(_d)}}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(O3.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},i)}}function D3(){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 s1=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(m=>m(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},_3=(e=>e?s1(e):s1),M3=e=>e;function N3(e,t=M3){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 a1=e=>{const t=_3(e),r=n=>N3(t,n);return Object.assign(r,t),r},L3=(e=>e?a1(e):a1),Md={disclaimerAccepted:!0,currentTime:Date.now(),swapExecution:{}},ee=L3((e,t)=>({state:Md,updateState:r=>e(n=>({state:{...n.state,...r}})),updateSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...n.state.swapExecution,...r}}})),resetSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...Md.swapExecution,...r}}})),resetState:()=>{e({state:{...Md,currentTime:Date.now(),swapExecution:{...t().state.swapExecution,acceptedMarketPrice:void 0,acceptedSrcAmount:void 0},isMarketOrder:t().state.isMarketOrder}}),setTimeout(()=>{t().resetSwapExecution()},1e3)}}));(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 Le=e=>`orbs_${e}`;function $o({children:e,className:t=""}){return C.jsx("p",{className:`${t} ${Le("Text")}`,children:e})}const o1=M.createContext({});function z3({children:e,...t}){return C.jsx(o1.Provider,{value:t,children:e})}const tn=()=>M.useContext(o1);var pt=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(pt||{});const R3=({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 C.jsx("div",{className:`${Le("Spinner")} ${e}`,style:a})};function $c({className:e="",body:t,footerLink:r,footerText:n,title:s,children:a}){return C.jsxs("div",{className:`${Le("TradeStepLayout")} ${e}`,children:[C.jsxs("div",{className:Le("TradeStepLayoutHeader"),children:[C.jsx(V3,{}),s&&C.jsx($o,{className:Le("TradeStepLayoutTitle"),children:s})]}),t&&C.jsx("div",{className:Le("TradeStepLayoutBody"),children:t}),C.jsx(H3,{link:r,text:n}),a]})}const H3=({link:e,text:t})=>{const{swapStatus:r}=tn();return!e&&!t?null:C.jsxs("div",{className:Le("TradeStepLayoutFooter"),children:[C.jsx(q3,{}),e?C.jsx($3,{link:e,text:t}):r===pt.FAILED?void 0:C.jsx($o,{children:t})]})},$3=({link:e,text:t})=>C.jsx("a",{target:"_blank",className:Le("TradeStepLayoutFooterLink"),href:e,children:t});function G3(){const{components:e}=tn();return e.SuccessIcon?e.SuccessIcon:C.jsxs("svg",{fill:"none",viewBox:"0 0 16 16",className:Le("TradeStepLayoutSuccessIcon"),children:[C.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#00C853"}),C.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#00C853",d:"M5 8l2 2 4-4"})]})}function j3(){const{components:e}=tn();return e.FailedIcon?e.FailedIcon:C.jsxs("svg",{className:Le("TradeStepLayoutErrorIcon"),viewBox:"0 0 16 16",fill:"none",children:[C.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#FF3D00"}),C.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#FF3D00",d:"M8 4v5M8 11h.01"})]})}const V3=()=>{const{swapStatus:e}=tn();return e===pt.SUCCESS?C.jsx(G3,{}):e===pt.FAILED?C.jsx(j3,{}):C.jsx(W3,{})},W3=()=>{const{components:e}=tn();return e.Loader?e.Loader:C.jsx(R3,{size:60,borderWidth:5,className:Le("TradeStepLayoutSpinner")})},q3=()=>{const{totalSteps:e,currentStepIndex:t=0,swapStatus:r}=tn();return r!==pt.LOADING||e===1?null:C.jsx("div",{className:Le("StepIndicator"),children:C.jsx("div",{style:{width:`${100/(e||0)}%`,left:`${t*100/(e||0)}%`},className:Le("StepIndicatorLine")})})},K3=({error:e,footerLink:t,footerText:r})=>C.jsx($c,{footerLink:t,footerText:r,body:e||C.jsx("p",{className:Le("FailedContentMsg"),children:"Something went wrong"}),className:Le("FailedContent")});function Y3(){return C.jsx("svg",{fill:"currentColor",viewBox:"0 0 16 16",className:Le("TradepPreviewIcon"),children:C.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}=tn();return C.jsxs("div",{className:Le("TradePreview"),children:[C.jsx(c1,{token:t,amount:n,Logo:a==null?void 0:a.SrcTokenLogo}),!e&&C.jsxs(C.Fragment,{children:[C.jsx(Y3,{}),C.jsx(c1,{token:r,amount:s,Logo:a==null?void 0:a.DstTokenLogo})]})]})},c1=({token:e,amount:t,Logo:r})=>C.jsxs("div",{className:Le("TradePreviewToken"),children:[r||C.jsx("img",{src:e==null?void 0:e.logoUrl,className:Le("TradepPreviewLogo"),alt:`${e==null?void 0:e.symbol} logo`}),C.jsxs($o,{children:[t," ",e==null?void 0:e.symbol]})]});function Z3({title:e,footerLink:t,footerText:r,hideTokens:n}){return C.jsx($c,{title:e,className:Le("Success"),body:!n&&C.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 C.jsx("div",{className:`${Le("FlexColumn")} ${n}`,style:a,children:r})};function u1({styles:e={},className:t=""}){return C.jsx("div",{style:e,className:`${Le("SkeletonLoader")} ${t}`})}const X3=()=>C.jsxs("div",{className:`${Le("MainContentLoader")}`,children:[C.jsx(u1,{className:`${Le("MainContentCircleLoader")}`}),C.jsx(u1,{className:`${Le("MainContentRectengularLoader")}`})]}),Q3=({fromTitle:e,toTitle:t,inUsd:r,outUsd:n})=>{const{swapStatus:s,outAmount:a,inAmount:o,inToken:i,outToken:c,components:l,totalSteps:u}=tn(),d=C.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?C.jsx(J3,{}):C.jsxs(l1,{children:[d,C.jsx(X3,{})]}):C.jsx(l1,{children:d})},d1=({amount:e,token:t,usd:r,title:n,Logo:s})=>C.jsxs("div",{className:`${Le("MainToken")}`,children:[C.jsxs("div",{className:`${Le("MainTokenLeft")}`,children:[C.jsx($o,{className:`${Le("MainTokenTitle")}`,children:n}),C.jsx($o,{className:` ${Le("MainTokenAmount")}`,children:`${e&&Number(e)>0?e:""} ${(t==null?void 0:t.symbol)||""}`}),r&&C.jsx("div",{className:` ${Le("MainTokenUsd")}`,children:r})]}),s||C.jsx("div",{className:` ${Le("MainTokenLogo")}`,children:t!=null&&t.logoUrl?C.jsx("img",{src:t==null?void 0:t.logoUrl,alt:"Token logo"}):null})]});function J3(){const{currentStep:e}=tn();return e?C.jsx($c,{footerLink:e.footerLink,footerText:e.footerText,title:e.title,body:e.hideTokens?void 0:C.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})=>C.jsxs("div",{className:`${Le("Main")}`,children:[C.jsx(d1,{title:e||"Swap from",usd:t,token:r,amount:o,Logo:c}),C.jsx(d1,{title:n||"Swap to",usd:s,token:a,amount:i,Logo:l})]}),es=e=>C.jsx(z3,{...e,children:C.jsx(e8,{})}),e8=()=>{const{swapStatus:e,components:t,className:r}=tn();return C.jsx("div",{className:`${Le("SwapFlow")} ${r}`,children:e===pt.SUCCESS?t==null?void 0:t.Success:e===pt.FAILED?t==null?void 0:t.Failed:t==null?void 0:t.Main})};es.Success=Z3,es.Failed=K3,es.Main=Q3,es.StepLayout=$c;var Rs=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(Rs||{});const t8="1.2.3";let Yt=class Nm extends Error{constructor(t,r={}){var o;const n=r.cause instanceof Nm?r.cause.details:(o=r.cause)!=null&&o.message?r.cause.message:r.details,s=r.cause instanceof Nm&&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@${t8}`].join(`
64
+ `,extractResults:d=>{var f;return(((f=d.data)==null?void 0:f.orderFilleds)||[]).map(m=>({...m,timestamp:new Date(m.timestamp).getTime()}))}})};class Vw extends Error{constructor(){super("No graph endpoint found"),this.name="NoGraphEndpointError"}}const Ww=async({chainId:e,signal:t,page:r,limit:n,filters:s})=>{try{const a=await $w({chainId:e,signal:t,page:r,limit:n,filters:s}),[o,i]=await Promise.all([jw({chainId:e,orders:a,signal:t}),Gw({chainId:e,orders:a,signal:t})]),c=a.map(u=>{const d=o==null?void 0:o.filter(f=>f.TWAP_id===Number(u.Contract_id)&&Ds(f.exchange,u.exchange)&&Ds(f.twapAddress,u.twapAddress));return Rw(u,e,d,qw(u,d||[],i))}).sort((u,d)=>d.createdAt-u.createdAt),l=new Set;return c.filter(u=>l.has(u.id)?!1:(l.add(u.id),!0))}catch{return[]}},qw=(e,t,r)=>{var i;const n=(i=r==null?void 0:r.find(c=>c.twapId===e.Contract_id.toString()&&Ds(c.twapAddress,e.twapAddress)))==null?void 0:i.status,a=Uh(t).reduce((c,l)=>c.plus(l.inAmount),new G(0)).toFixed(),o=_h(e.ask_srcAmount,a);return Kw(o,e.ask_deadline*1e3,n)},_h=(e,t)=>{if(!t||!e)return 0;const r=G(t).dividedBy(e).toNumber();return r>=.99?100:r<=0?0:Number((r*100).toFixed(2))},Kw=(e,t,r)=>e===100?ut.Completed:r==="CANCELLED"?ut.Cancelled:r==="COMPLETED"?ut.Completed:t>Date.now()?ut.Open:ut.Expired,Mh=async({signal:e,page:t,chainId:r,limit:n,config:s,account:a})=>(await Promise.all([s?Ww({chainId:r,signal:e,page:t,limit:n,filters:{accounts:[a],configs:s.twapConfig?[s.twapConfig]:[]}}):Promise.resolve([]),Lw({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),Yw={version:"0.0.107"};var Ba=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(){}},Zw={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Xw=(B5=class{constructor(){le(this,bn,Zw);le(this,ba,!1)}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&N(this,ba)&&e!==N(this,bn)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:N(this,bn),provider:e}),J(this,bn,e),process.env.NODE_ENV!=="production"&&J(this,ba,!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&J(this,ba,!0),N(this,bn).setTimeout(e,t)}clearTimeout(e){N(this,bn).clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&J(this,ba,!0),N(this,bn).setInterval(e,t)}clearInterval(e){N(this,bn).clearInterval(e)}},bn=new WeakMap,ba=new WeakMap,B5),Ns=new Xw;function Qw(e){setTimeout(e,0)}var Ls=typeof window>"u"||"Deno"in globalThis;function Gt(){}function Jw(e,t){return typeof e=="function"?e(t):e}function Cd(e){return typeof e=="number"&&e>=0&&e!==1/0}function Nh(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Jn(e,t){return typeof e=="function"?e(t):e}function wr(e,t){return typeof e=="function"?e(t):e}function Lh(e,t){const{type:r="all",exact:n,fetchStatus:s,predicate:a,queryKey:o,stale:i}=e;if(o){if(n){if(t.queryHash!==Td(o,t.options))return!1}else if(!Ho(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 zh(e,t){const{exact:r,status:n,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(r){if(zs(t.options.mutationKey)!==zs(a))return!1}else if(!Ho(t.options.mutationKey,a))return!1}return!(n&&t.state.status!==n||s&&!s(t))}function Td(e,t){return((t==null?void 0:t.queryKeyHashFn)||zs)(e)}function zs(e){return JSON.stringify(e,(t,r)=>Sd(r)?Object.keys(r).sort().reduce((n,s)=>(n[s]=r[s],n),{}):r)}function Ho(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Ho(e[r],t[r])):!1}var e3=Object.prototype.hasOwnProperty;function Ad(e,t){if(e===t)return e;const r=Rh(e)&&Rh(t);if(!r&&!(Sd(e)&&Sd(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:e3.call(e,u))&&c++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){i[u]=f;continue}const m=Ad(d,f);i[u]=m,m===d&&c++}return s===o&&c===s?e:i}function Lc(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 Rh(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Sd(e){if(!Hh(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!Hh(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Hh(e){return Object.prototype.toString.call(e)==="[object Object]"}function t3(e){return new Promise(t=>{Ns.setTimeout(t,e)})}function Pd(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 Ad(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 Ad(e,t)}return t}function r3(e,t,r=0){const n=[...e,t];return r&&n.length>r?n.slice(1):n}function n3(e,t,r=0){const n=[t,...e];return r&&n.length>r?n.slice(0,-1):n}var zc=Symbol();function $h(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===zc&&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===zc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Gh(e,t){return typeof e=="function"?e(...t):!!e}var s3=(F5=class extends Ba{constructor(){super();le(this,ya);le(this,ks);le(this,Ao);J(this,Ao,t=>{if(!Ls&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){N(this,ks)||this.setEventListener(N(this,Ao))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,ks))==null||t.call(this),J(this,ks,void 0))}setEventListener(t){var r;J(this,Ao,t),(r=N(this,ks))==null||r.call(this),J(this,ks,t(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(t){N(this,ya)!==t&&(J(this,ya,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof N(this,ya)=="boolean"?N(this,ya):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},ya=new WeakMap,ks=new WeakMap,Ao=new WeakMap,F5),Id=new s3;function Bd(){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 a3=Qw;function o3(){let e=[],t=0,r=i=>{i()},n=i=>{i()},s=a3;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=o3(),i3=(O5=class extends Ba{constructor(){super();le(this,So,!0);le(this,Cs);le(this,Po);J(this,Po,t=>{if(!Ls&&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,Cs)||this.setEventListener(N(this,Po))}onUnsubscribe(){var t;this.hasListeners()||((t=N(this,Cs))==null||t.call(this),J(this,Cs,void 0))}setEventListener(t){var r;J(this,Po,t),(r=N(this,Cs))==null||r.call(this),J(this,Cs,t(this.setOnline.bind(this)))}setOnline(t){N(this,So)!==t&&(J(this,So,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return N(this,So)}},So=new WeakMap,Cs=new WeakMap,Po=new WeakMap,O5),Rc=new i3;function c3(e){return Math.min(1e3*2**e,3e4)}function jh(e){return(e??"online")==="online"?Rc.isOnline():!0}var Fd=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Vh(e){let t=!1,r=0,n;const s=Bd(),a=()=>s.status!=="pending",o=g=>{var E;if(!a()){const v=new Fd(g);f(v),(E=e.onCancel)==null||E.call(e,v)}},i=()=>{t=!0},c=()=>{t=!1},l=()=>Id.isFocused()&&(e.networkMode==="always"||Rc.isOnline())&&e.canRun(),u=()=>jh(e.networkMode)&&e.canRun(),d=g=>{a()||(n==null||n(),s.resolve(g))},f=g=>{a()||(n==null||n(),s.reject(g))},m=()=>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)}),b=()=>{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 L;if(a())return;const w=e.retry??(Ls?0:3),S=e.retryDelay??c3,T=typeof S=="function"?S(r,v):S,O=w===!0||typeof w=="number"&&r<w||typeof w=="function"&&w(r,v);if(t||!O){f(v);return}r++,(L=e.onFail)==null||L.call(e,r,v),t3(T).then(()=>l()?void 0:m()).then(()=>{t?f(v):b()})})};return{promise:s,status:()=>s.status,cancel:o,continue:()=>(n==null||n(),s),cancelRetry:i,continueRetry:c,canStart:u,start:()=>(u()?b():m().then(b),s)}}var Wh=(U5=class{constructor(){le(this,ga)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Cd(this.gcTime)&&J(this,ga,Ns.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ls?1/0:300*1e3))}clearGcTimeout(){N(this,ga)&&(Ns.clearTimeout(N(this,ga)),J(this,ga,void 0))}},ga=new WeakMap,U5),l3=(D5=class extends Wh{constructor(t){super();le(this,Xr);le(this,xa);le(this,Io);le(this,Fr);le(this,wa);le(this,Bt);le(this,Sc);le(this,va);J(this,va,!1),J(this,Sc,t.defaultOptions),this.setOptions(t.options),this.observers=[],J(this,wa,t.client),J(this,Fr,N(this,wa).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,J(this,xa,Yh(this.options)),this.state=t.state??N(this,xa),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,Sc),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Yh(this.options);r.data!==void 0&&(this.setState(Kh(r.data,r.dataUpdatedAt)),J(this,xa,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&N(this,Fr).remove(this)}setData(t,r){const n=Pd(this.state.data,t,this.options);return Se(this,Xr,Zn).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,Xr,Zn).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(Gt).catch(Gt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(N(this,xa))}isActive(){return this.observers.some(t=>wr(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===zc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Jn(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:!Nh(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,Fr).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,va)?N(this,Bt).cancel({revert:!0}):N(this,Bt).cancelRetry()),this.scheduleGc()),N(this,Fr).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Se(this,Xr,Zn).call(this,{type:"invalidate"})}async fetch(t,r){var c,l,u,d,f,m,b,g,E,v,w,S;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 T=this.observers.find(O=>O.options.queryFn);T&&this.setOptions(T.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=T=>{Object.defineProperty(T,"signal",{enumerable:!0,get:()=>(J(this,va,!0),n.signal)})},a=()=>{const T=$h(this.options,r),L=(()=>{const P={client:N(this,wa),queryKey:this.queryKey,meta:this.meta};return s(P),P})();return J(this,va,!1),this.options.persister?this.options.persister(T,L,this):T(L)},i=(()=>{const T={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:N(this,wa),state:this.state,fetchFn:a};return s(T),T})();(l=this.options.behavior)==null||l.onFetch(i,this),J(this,Io,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=i.fetchOptions)==null?void 0:u.meta))&&Se(this,Xr,Zn).call(this,{type:"fetch",meta:(d=i.fetchOptions)==null?void 0:d.meta}),J(this,Bt,Vh({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,onCancel:T=>{T instanceof Fd&&T.revert&&this.setState({...N(this,Io),fetchStatus:"idle"}),n.abort()},onFail:(T,O)=>{Se(this,Xr,Zn).call(this,{type:"failed",failureCount:T,error:O})},onPause:()=>{Se(this,Xr,Zn).call(this,{type:"pause"})},onContinue:()=>{Se(this,Xr,Zn).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0}));try{const T=await N(this,Bt).start();if(T===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(T),(m=(f=N(this,Fr).config).onSuccess)==null||m.call(f,T,this),(g=(b=N(this,Fr).config).onSettled)==null||g.call(b,T,this.state.error,this),T}catch(T){if(T instanceof Fd){if(T.silent)return N(this,Bt).promise;if(T.revert){if(this.state.data===void 0)throw T;return this.state.data}}throw Se(this,Xr,Zn).call(this,{type:"error",error:T}),(v=(E=N(this,Fr).config).onError)==null||v.call(E,T,this),(S=(w=N(this,Fr).config).onSettled)==null||S.call(w,this.state.data,T,this),T}finally{this.scheduleGc()}}},xa=new WeakMap,Io=new WeakMap,Fr=new WeakMap,wa=new WeakMap,Bt=new WeakMap,Sc=new WeakMap,va=new WeakMap,Xr=new WeakSet,Zn=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,...qh(n.data,this.options),fetchMeta:t.meta??null};case"success":const s={...n,...Kh(t.data,t.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return J(this,Io,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,Fr).notify({query:this,type:"updated",action:t})})},D5);function qh(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jh(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Kh(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Yh(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 u3=(_5=class extends Ba{constructor(t,r){super();le(this,We);le(this,nr);le(this,_e);le(this,Pc);le(this,Wt);le(this,Ea);le(this,Bo);le(this,Vn);le(this,Ts);le(this,Ic);le(this,Fo);le(this,Oo);le(this,ka);le(this,Ca);le(this,As);le(this,Uo,new Set);this.options=r,J(this,nr,t),J(this,Ts,null),J(this,Vn,Bd()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(N(this,_e).addObserver(this),Zh(N(this,_e),this.options)?Se(this,We,Oc).call(this):this.updateResult(),Se(this,We,Om).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Od(N(this,_e),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Od(N(this,_e),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Se(this,We,Um).call(this),Se(this,We,Dm).call(this),N(this,_e).removeObserver(this)}setOptions(t){const r=this.options,n=N(this,_e);if(this.options=N(this,nr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof wr(this.options.enabled,N(this,_e))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Se(this,We,_m).call(this),N(this,_e).setOptions(this.options),r._defaulted&&!Lc(this.options,r)&&N(this,nr).getQueryCache().notify({type:"observerOptionsUpdated",query:N(this,_e),observer:this});const s=this.hasListeners();s&&Xh(N(this,_e),n,this.options,r)&&Se(this,We,Oc).call(this),this.updateResult(),s&&(N(this,_e)!==n||wr(this.options.enabled,N(this,_e))!==wr(r.enabled,N(this,_e))||Jn(this.options.staleTime,N(this,_e))!==Jn(r.staleTime,N(this,_e)))&&Se(this,We,Im).call(this);const a=Se(this,We,Bm).call(this);s&&(N(this,_e)!==n||wr(this.options.enabled,N(this,_e))!==wr(r.enabled,N(this,_e))||a!==N(this,As))&&Se(this,We,Fm).call(this,a)}getOptimisticResult(t){const r=N(this,nr).getQueryCache().build(N(this,nr),t),n=this.createResult(r,t);return p3(this,n)&&(J(this,Wt,n),J(this,Bo,this.options),J(this,Ea,N(this,_e).state)),n}getCurrentResult(){return N(this,Wt)}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,Vn).status==="pending"&&N(this,Vn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,s))})}trackProp(t){N(this,Uo).add(t)}getCurrentQuery(){return N(this,_e)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=N(this,nr).defaultQueryOptions(t),n=N(this,nr).getQueryCache().build(N(this,nr),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(t){return Se(this,We,Oc).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),N(this,Wt)))}createResult(t,r){var y;const n=N(this,_e),s=this.options,a=N(this,Wt),o=N(this,Ea),i=N(this,Bo),l=t!==n?t.state:N(this,Pc),{state:u}=t;let d={...u},f=!1,m;if(r._optimisticResults){const x=this.hasListeners(),A=!x&&Zh(t,r),B=x&&Xh(t,n,r,s);(A||B)&&(d={...d,...qh(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:b,errorUpdatedAt:g,status:E}=d;m=d.data;let v=!1;if(r.placeholderData!==void 0&&m===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((y=N(this,Oo))==null?void 0:y.state.data,N(this,Oo)):r.placeholderData,x!==void 0&&(E="success",m=Pd(a==null?void 0:a.data,x,r),f=!0)}if(r.select&&m!==void 0&&!v)if(a&&m===(o==null?void 0:o.data)&&r.select===N(this,Ic))m=N(this,Fo);else try{J(this,Ic,r.select),m=r.select(m),m=Pd(a==null?void 0:a.data,m,r),J(this,Fo,m),J(this,Ts,null)}catch(x){J(this,Ts,x)}N(this,Ts)&&(b=N(this,Ts),m=N(this,Fo),g=Date.now(),E="error");const w=d.fetchStatus==="fetching",S=E==="pending",T=E==="error",O=S&&w,L=m!==void 0,h={status:E,fetchStatus:d.fetchStatus,isPending:S,isSuccess:E==="success",isError:T,isInitialLoading:O,isLoading:O,data:m,dataUpdatedAt:d.dataUpdatedAt,error:b,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&&!S,isLoadingError:T&&!L,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:T&&L,isStale:Ud(t,r),refetch:this.refetch,promise:N(this,Vn),isEnabled:wr(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const x=F=>{h.status==="error"?F.reject(h.error):h.data!==void 0&&F.resolve(h.data)},A=()=>{const F=J(this,Vn,h.promise=Bd());x(F)},B=N(this,Vn);switch(B.status){case"pending":t.queryHash===n.queryHash&&x(B);break;case"fulfilled":(h.status==="error"||h.data!==B.value)&&A();break;case"rejected":(h.status!=="error"||h.error!==B.reason)&&A();break}}return h}updateResult(){const t=N(this,Wt),r=this.createResult(N(this,_e),this.options);if(J(this,Ea,N(this,_e).state),J(this,Bo,this.options),N(this,Ea).data!==void 0&&J(this,Oo,N(this,_e)),Lc(r,t))return;J(this,Wt,r);const n=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!N(this,Uo).size)return!0;const o=new Set(a??N(this,Uo));return this.options.throwOnError&&o.add("error"),Object.keys(N(this,Wt)).some(i=>{const c=i;return N(this,Wt)[c]!==t[c]&&o.has(c)})};Se(this,We,K5).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Se(this,We,Om).call(this)}},nr=new WeakMap,_e=new WeakMap,Pc=new WeakMap,Wt=new WeakMap,Ea=new WeakMap,Bo=new WeakMap,Vn=new WeakMap,Ts=new WeakMap,Ic=new WeakMap,Fo=new WeakMap,Oo=new WeakMap,ka=new WeakMap,Ca=new WeakMap,As=new WeakMap,Uo=new WeakMap,We=new WeakSet,Oc=function(t){Se(this,We,_m).call(this);let r=N(this,_e).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(Gt)),r},Im=function(){Se(this,We,Um).call(this);const t=Jn(this.options.staleTime,N(this,_e));if(Ls||N(this,Wt).isStale||!Cd(t))return;const n=Nh(N(this,Wt).dataUpdatedAt,t)+1;J(this,ka,Ns.setTimeout(()=>{N(this,Wt).isStale||this.updateResult()},n))},Bm=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(N(this,_e)):this.options.refetchInterval)??!1},Fm=function(t){Se(this,We,Dm).call(this),J(this,As,t),!(Ls||wr(this.options.enabled,N(this,_e))===!1||!Cd(N(this,As))||N(this,As)===0)&&J(this,Ca,Ns.setInterval(()=>{(this.options.refetchIntervalInBackground||Id.isFocused())&&Se(this,We,Oc).call(this)},N(this,As)))},Om=function(){Se(this,We,Im).call(this),Se(this,We,Fm).call(this,Se(this,We,Bm).call(this))},Um=function(){N(this,ka)&&(Ns.clearTimeout(N(this,ka)),J(this,ka,void 0))},Dm=function(){N(this,Ca)&&(Ns.clearInterval(N(this,Ca)),J(this,Ca,void 0))},_m=function(){const t=N(this,nr).getQueryCache().build(N(this,nr),this.options);if(t===N(this,_e))return;const r=N(this,_e);J(this,_e,t),J(this,Pc,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},K5=function(t){kt.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(N(this,Wt))}),N(this,nr).getQueryCache().notify({query:N(this,_e),type:"observerResultsUpdated"})})},_5);function d3(e,t){return wr(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Zh(e,t){return d3(e,t)||e.state.data!==void 0&&Od(e,t,t.refetchOnMount)}function Od(e,t,r){if(wr(t.enabled,e)!==!1&&Jn(t.staleTime,e)!=="static"){const n=typeof r=="function"?r(e):r;return n==="always"||n!==!1&&Ud(e,t)}return!1}function Xh(e,t,r,n){return(e!==t||wr(n.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Ud(e,r)}function Ud(e,t){return wr(t.enabled,e)!==!1&&e.isStaleByTime(Jn(t.staleTime,e))}function p3(e,t){return!Lc(e.getCurrentResult(),t)}function Qh(e){return{onFetch:(t,r)=>{var u,d,f,m,b;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=((m=t.state.data)==null?void 0:m.pages)||[],o=((b=t.state.data)==null?void 0:b.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const l=async()=>{let g=!1;const E=S=>{Object.defineProperty(S,"signal",{enumerable:!0,get:()=>(t.signal.aborted?g=!0:t.signal.addEventListener("abort",()=>{g=!0}),t.signal)})},v=$h(t.options,t.fetchOptions),w=async(S,T,O)=>{if(g)return Promise.reject();if(T==null&&S.pages.length)return Promise.resolve(S);const P=(()=>{const A={client:t.client,queryKey:t.queryKey,pageParam:T,direction:O?"backward":"forward",meta:t.options.meta};return E(A),A})(),h=await v(P),{maxPages:y}=t.options,x=O?n3:r3;return{pages:x(S.pages,h,y),pageParams:x(S.pageParams,T,y)}};if(s&&a.length){const S=s==="backward",T=S?f3:Jh,O={pages:a,pageParams:o},L=T(n,O);i=await w(O,L,S)}else{const S=e??a.length;do{const T=c===0?o[0]??n.initialPageParam:Jh(n,i);if(c>0&&T==null)break;i=await w(i,T),c++}while(c<S)}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 Jh(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 f3(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 m3=(M5=class extends Wh{constructor(t){super();le(this,gn);le(this,Bc);le(this,yn);le(this,qt);le(this,Ta);J(this,Bc,t.client),this.mutationId=t.mutationId,J(this,qt,t.mutationCache),J(this,yn,[]),this.state=t.state||e1(),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,yn).includes(t)||(N(this,yn).push(t),this.clearGcTimeout(),N(this,qt).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){J(this,yn,N(this,yn).filter(r=>r!==t)),this.scheduleGc(),N(this,qt).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){N(this,yn).length||(this.state.status==="pending"?this.scheduleGc():N(this,qt).remove(this))}continue(){var t;return((t=N(this,Ta))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var o,i,c,l,u,d,f,m,b,g,E,v,w,S,T,O,L,P,h,y;const r=()=>{Se(this,gn,Fs).call(this,{type:"continue"})},n={client:N(this,Bc),meta:this.options.meta,mutationKey:this.options.mutationKey};J(this,Ta,Vh({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(x,A)=>{Se(this,gn,Fs).call(this,{type:"failed",failureCount:x,error:A})},onPause:()=>{Se(this,gn,Fs).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>N(this,qt).canRun(this)}));const s=this.state.status==="pending",a=!N(this,Ta).canStart();try{if(s)r();else{Se(this,gn,Fs).call(this,{type:"pending",variables:t,isPaused:a}),await((i=(o=N(this,qt).config).onMutate)==null?void 0:i.call(o,t,this,n));const A=await((l=(c=this.options).onMutate)==null?void 0:l.call(c,t,n));A!==this.state.context&&Se(this,gn,Fs).call(this,{type:"pending",context:A,variables:t,isPaused:a})}const x=await N(this,Ta).start();return await((d=(u=N(this,qt).config).onSuccess)==null?void 0:d.call(u,x,t,this.state.context,this,n)),await((m=(f=this.options).onSuccess)==null?void 0:m.call(f,x,t,this.state.context,n)),await((g=(b=N(this,qt).config).onSettled)==null?void 0:g.call(b,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,gn,Fs).call(this,{type:"success",data:x}),x}catch(x){try{throw await((S=(w=N(this,qt).config).onError)==null?void 0:S.call(w,x,t,this.state.context,this,n)),await((O=(T=this.options).onError)==null?void 0:O.call(T,x,t,this.state.context,n)),await((P=(L=N(this,qt).config).onSettled)==null?void 0:P.call(L,void 0,x,this.state.variables,this.state.context,this,n)),await((y=(h=this.options).onSettled)==null?void 0:y.call(h,void 0,x,t,this.state.context,n)),x}finally{Se(this,gn,Fs).call(this,{type:"error",error:x})}}finally{N(this,qt).runNext(this)}}},Bc=new WeakMap,yn=new WeakMap,qt=new WeakMap,Ta=new WeakMap,gn=new WeakSet,Fs=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,yn).forEach(n=>{n.onMutationUpdate(t)}),N(this,qt).notify({mutation:this,type:"updated",action:t})})},M5);function e1(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var h3=(N5=class extends Ba{constructor(t={}){super();le(this,Wn);le(this,Qr);le(this,Fc);this.config=t,J(this,Wn,new Set),J(this,Qr,new Map),J(this,Fc,0)}build(t,r,n){const s=new m3({client:t,mutationCache:this,mutationId:++rd(this,Fc)._,options:t.defaultMutationOptions(r),state:n});return this.add(s),s}add(t){N(this,Wn).add(t);const r=Hc(t);if(typeof r=="string"){const n=N(this,Qr).get(r);n?n.push(t):N(this,Qr).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(N(this,Wn).delete(t)){const r=Hc(t);if(typeof r=="string"){const n=N(this,Qr).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,Qr).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=Hc(t);if(typeof r=="string"){const n=N(this,Qr).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=Hc(t);if(typeof r=="string"){const s=(n=N(this,Qr).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,Wn).forEach(t=>{this.notify({type:"removed",mutation:t})}),N(this,Wn).clear(),N(this,Qr).clear()})}getAll(){return Array.from(N(this,Wn))}find(t){const r={exact:!0,...t};return this.getAll().find(n=>zh(r,n))}findAll(t={}){return this.getAll().filter(r=>zh(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(Gt))))}},Wn=new WeakMap,Qr=new WeakMap,Fc=new WeakMap,N5);function Hc(e){var t;return(t=e.options.scope)==null?void 0:t.id}var b3=(L5=class extends Ba{constructor(t,r){super();le(this,Yn);le(this,qn);le(this,Ss);le(this,sr);le(this,Kn);J(this,qn,t),this.setOptions(r),this.bindMethods(),Se(this,Yn,nd).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,qn).defaultMutationOptions(t),Lc(this.options,r)||N(this,qn).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,sr),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&zs(r.mutationKey)!==zs(this.options.mutationKey)?this.reset():((n=N(this,sr))==null?void 0:n.state.status)==="pending"&&N(this,sr).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=N(this,sr))==null||t.removeObserver(this)}onMutationUpdate(t){Se(this,Yn,nd).call(this),Se(this,Yn,Mm).call(this,t)}getCurrentResult(){return N(this,Ss)}reset(){var t;(t=N(this,sr))==null||t.removeObserver(this),J(this,sr,void 0),Se(this,Yn,nd).call(this),Se(this,Yn,Mm).call(this)}mutate(t,r){var n;return J(this,Kn,r),(n=N(this,sr))==null||n.removeObserver(this),J(this,sr,N(this,qn).getMutationCache().build(N(this,qn),this.options)),N(this,sr).addObserver(this),N(this,sr).execute(t)}},qn=new WeakMap,Ss=new WeakMap,sr=new WeakMap,Kn=new WeakMap,Yn=new WeakSet,nd=function(){var r;const t=((r=N(this,sr))==null?void 0:r.state)??e1();J(this,Ss,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},Mm=function(t){kt.batch(()=>{var r,n,s,a,o,i,c,l;if(N(this,Kn)&&this.hasListeners()){const u=N(this,Ss).variables,d=N(this,Ss).context,f={client:N(this,qn),meta:this.options.meta,mutationKey:this.options.mutationKey};(t==null?void 0:t.type)==="success"?((n=(r=N(this,Kn)).onSuccess)==null||n.call(r,t.data,u,d,f),(a=(s=N(this,Kn)).onSettled)==null||a.call(s,t.data,null,u,d,f)):(t==null?void 0:t.type)==="error"&&((i=(o=N(this,Kn)).onError)==null||i.call(o,t.error,u,d,f),(l=(c=N(this,Kn)).onSettled)==null||l.call(c,void 0,t.error,u,d,f))}this.listeners.forEach(u=>{u(N(this,Ss))})})},L5),y3=(z5=class extends Ba{constructor(t={}){super();le(this,xn);this.config=t,J(this,xn,new Map)}build(t,r,n){const s=r.queryKey,a=r.queryHash??Td(s,r);let o=this.get(a);return o||(o=new l3({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(r),state:n,defaultOptions:t.getQueryDefaults(s)}),this.add(o)),o}add(t){N(this,xn).has(t.queryHash)||(N(this,xn).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=N(this,xn).get(t.queryHash);r&&(t.destroy(),r===t&&N(this,xn).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){kt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return N(this,xn).get(t)}getAll(){return[...N(this,xn).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(n=>Lh(r,n))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(n=>Lh(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()})})}},xn=new WeakMap,z5),g3=(R5=class{constructor(e={}){le(this,mt);le(this,Ps);le(this,Is);le(this,Do);le(this,_o);le(this,Bs);le(this,Mo);le(this,No);J(this,mt,e.queryCache||new y3),J(this,Ps,e.mutationCache||new h3),J(this,Is,e.defaultOptions||{}),J(this,Do,new Map),J(this,_o,new Map),J(this,Bs,0)}mount(){rd(this,Bs)._++,N(this,Bs)===1&&(J(this,Mo,Id.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,mt).onFocus())})),J(this,No,Rc.subscribe(async e=>{e&&(await this.resumePausedMutations(),N(this,mt).onOnline())})))}unmount(){var e,t;rd(this,Bs)._--,N(this,Bs)===0&&((e=N(this,Mo))==null||e.call(this),J(this,Mo,void 0),(t=N(this,No))==null||t.call(this),J(this,No,void 0))}isFetching(e){return N(this,mt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return N(this,Ps).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=N(this,mt).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=N(this,mt).build(this,t),n=r.state.data;return n===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Jn(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(n))}getQueriesData(e){return N(this,mt).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,mt).get(n.queryHash),a=s==null?void 0:s.state.data,o=Jw(t,a);if(o!==void 0)return N(this,mt).build(this,n).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return kt.batch(()=>N(this,mt).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,mt).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=N(this,mt);kt.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=N(this,mt);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,mt).findAll(e).map(s=>s.cancel(r)));return Promise.all(n).then(Gt).catch(Gt)}invalidateQueries(e,t={}){return kt.batch(()=>(N(this,mt).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,mt).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,r);return r.throwOnError||(a=a.catch(Gt)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(n).then(Gt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=N(this,mt).build(this,t);return r.isStaleByTime(Jn(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Gt).catch(Gt)}fetchInfiniteQuery(e){return e.behavior=Qh(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Gt).catch(Gt)}ensureInfiniteQueryData(e){return e.behavior=Qh(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Rc.isOnline()?N(this,Ps).resumePausedMutations():Promise.resolve()}getQueryCache(){return N(this,mt)}getMutationCache(){return N(this,Ps)}getDefaultOptions(){return N(this,Is)}setDefaultOptions(e){J(this,Is,e)}setQueryDefaults(e,t){N(this,Do).set(zs(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...N(this,Do).values()],r={};return t.forEach(n=>{Ho(e,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(e,t){N(this,_o).set(zs(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...N(this,_o).values()],r={};return t.forEach(n=>{Ho(e,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...N(this,Is).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Td(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===zc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...N(this,Is).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){N(this,mt).clear(),N(this,Ps).clear()}},mt=new WeakMap,Ps=new WeakMap,Is=new WeakMap,Do=new WeakMap,_o=new WeakMap,Bs=new WeakMap,Mo=new WeakMap,No=new WeakMap,R5),t1=Et.createContext(void 0),Dd=e=>{const t=Et.useContext(t1);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},x3=({client:e,children:t})=>(Et.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),C.jsx(t1.Provider,{value:e,children:t})),r1=Et.createContext(!1),w3=()=>Et.useContext(r1);r1.Provider;function v3(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var E3=Et.createContext(v3()),k3=()=>Et.useContext(E3),C3=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},T3=e=>{Et.useEffect(()=>{e.clearReset()},[e])},A3=({result:e,errorResetBoundary:t,throwOnError:r,query:n,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(s&&e.data===void 0||Gh(r,[e.error,n])),S3=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))}},P3=(e,t)=>e.isLoading&&e.isFetching&&!t,I3=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,n1=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function B3(e,t,r){var d,f,m,b,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=w3(),s=k3(),a=Dd(),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",S3(o),C3(o,s),T3(s);const i=!a.getQueryCache().get(o.queryHash),[c]=Et.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!n&&e.subscribed!==!1;if(Et.useSyncExternalStore(Et.useCallback(E=>{const v=u?c.subscribe(kt.batchCalls(E)):Gt;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),Et.useEffect(()=>{c.setOptions(o)},[o,c]),I3(o,l))throw n1(o,c,s);if(A3({result:l,errorResetBoundary:s,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;if((b=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||b.call(m,o,l),o.experimental_prefetchInRender&&!Ls&&P3(l,n)){const E=i?n1(o,c,s):(g=a.getQueryCache().get(o.queryHash))==null?void 0:g.promise;E==null||E.catch(Gt).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?l:c.trackResult(l)}function F3(e,t){return B3(e,u3)}function en(e,t){const r=Dd(),[n]=Et.useState(()=>new b3(r,e));Et.useEffect(()=>{n.setOptions(e)},[n,e]);const s=Et.useSyncExternalStore(Et.useCallback(o=>n.subscribe(kt.batchCalls(o)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),a=Et.useCallback((o,i)=>{n.mutate(o,i).catch(Gt)},[n]);if(s.error&&Gh(n.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}const O3=M.createContext(null),_d={didCatch:!1,error:null};class U3 extends M.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=_d}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(_d)}}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&&D3(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(_d)}}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(O3.Provider,{value:{didCatch:a,error:o,resetErrorBoundary:this.resetErrorBoundary}},i)}}function D3(){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 s1=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(m=>m(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},_3=(e=>e?s1(e):s1),M3=e=>e;function N3(e,t=M3){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 a1=e=>{const t=_3(e),r=n=>N3(t,n);return Object.assign(r,t),r},L3=(e=>e?a1(e):a1),Md={disclaimerAccepted:!0,currentTime:Date.now(),swapExecution:{}},ee=L3((e,t)=>({state:Md,updateState:r=>e(n=>({state:{...n.state,...r}})),updateSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...n.state.swapExecution,...r}}})),resetSwapExecution:r=>e(n=>({state:{...n.state,swapExecution:{...Md.swapExecution,...r}}})),resetState:r=>{e({state:{...Md,currentTime:Date.now(),swapExecution:{...t().state.swapExecution,acceptedMarketPrice:void 0,acceptedSrcAmount:void 0},isMarketOrder:t().state.isMarketOrder,...r}}),setTimeout(()=>{t().resetSwapExecution()},1e3)}}));(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 Le=e=>`orbs_${e}`;function $o({children:e,className:t=""}){return C.jsx("p",{className:`${t} ${Le("Text")}`,children:e})}const o1=M.createContext({});function z3({children:e,...t}){return C.jsx(o1.Provider,{value:t,children:e})}const tn=()=>M.useContext(o1);var pt=(e=>(e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED",e))(pt||{});const R3=({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 C.jsx("div",{className:`${Le("Spinner")} ${e}`,style:a})};function $c({className:e="",body:t,footerLink:r,footerText:n,title:s,children:a}){return C.jsxs("div",{className:`${Le("TradeStepLayout")} ${e}`,children:[C.jsxs("div",{className:Le("TradeStepLayoutHeader"),children:[C.jsx(V3,{}),s&&C.jsx($o,{className:Le("TradeStepLayoutTitle"),children:s})]}),t&&C.jsx("div",{className:Le("TradeStepLayoutBody"),children:t}),C.jsx(H3,{link:r,text:n}),a]})}const H3=({link:e,text:t})=>{const{swapStatus:r}=tn();return!e&&!t?null:C.jsxs("div",{className:Le("TradeStepLayoutFooter"),children:[C.jsx(q3,{}),e?C.jsx($3,{link:e,text:t}):r===pt.FAILED?void 0:C.jsx($o,{children:t})]})},$3=({link:e,text:t})=>C.jsx("a",{target:"_blank",className:Le("TradeStepLayoutFooterLink"),href:e,children:t});function G3(){const{components:e}=tn();return e.SuccessIcon?e.SuccessIcon:C.jsxs("svg",{fill:"none",viewBox:"0 0 16 16",className:Le("TradeStepLayoutSuccessIcon"),children:[C.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#00C853"}),C.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#00C853",d:"M5 8l2 2 4-4"})]})}function j3(){const{components:e}=tn();return e.FailedIcon?e.FailedIcon:C.jsxs("svg",{className:Le("TradeStepLayoutErrorIcon"),viewBox:"0 0 16 16",fill:"none",children:[C.jsx("circle",{cx:"8",cy:"8",r:"7",strokeWidth:"1.5",stroke:"#FF3D00"}),C.jsx("path",{strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",stroke:"#FF3D00",d:"M8 4v5M8 11h.01"})]})}const V3=()=>{const{swapStatus:e}=tn();return e===pt.SUCCESS?C.jsx(G3,{}):e===pt.FAILED?C.jsx(j3,{}):C.jsx(W3,{})},W3=()=>{const{components:e}=tn();return e.Loader?e.Loader:C.jsx(R3,{size:60,borderWidth:5,className:Le("TradeStepLayoutSpinner")})},q3=()=>{const{totalSteps:e,currentStepIndex:t=0,swapStatus:r}=tn();return r!==pt.LOADING||e===1?null:C.jsx("div",{className:Le("StepIndicator"),children:C.jsx("div",{style:{width:`${100/(e||0)}%`,left:`${t*100/(e||0)}%`},className:Le("StepIndicatorLine")})})},K3=({error:e,footerLink:t,footerText:r})=>C.jsx($c,{footerLink:t,footerText:r,body:e||C.jsx("p",{className:Le("FailedContentMsg"),children:"Something went wrong"}),className:Le("FailedContent")});function Y3(){return C.jsx("svg",{fill:"currentColor",viewBox:"0 0 16 16",className:Le("TradepPreviewIcon"),children:C.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}=tn();return C.jsxs("div",{className:Le("TradePreview"),children:[C.jsx(c1,{token:t,amount:n,Logo:a==null?void 0:a.SrcTokenLogo}),!e&&C.jsxs(C.Fragment,{children:[C.jsx(Y3,{}),C.jsx(c1,{token:r,amount:s,Logo:a==null?void 0:a.DstTokenLogo})]})]})},c1=({token:e,amount:t,Logo:r})=>C.jsxs("div",{className:Le("TradePreviewToken"),children:[r||C.jsx("img",{src:e==null?void 0:e.logoUrl,className:Le("TradepPreviewLogo"),alt:`${e==null?void 0:e.symbol} logo`}),C.jsxs($o,{children:[t," ",e==null?void 0:e.symbol]})]});function Z3({title:e,footerLink:t,footerText:r,hideTokens:n}){return C.jsx($c,{title:e,className:Le("Success"),body:!n&&C.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 C.jsx("div",{className:`${Le("FlexColumn")} ${n}`,style:a,children:r})};function u1({styles:e={},className:t=""}){return C.jsx("div",{style:e,className:`${Le("SkeletonLoader")} ${t}`})}const X3=()=>C.jsxs("div",{className:`${Le("MainContentLoader")}`,children:[C.jsx(u1,{className:`${Le("MainContentCircleLoader")}`}),C.jsx(u1,{className:`${Le("MainContentRectengularLoader")}`})]}),Q3=({fromTitle:e,toTitle:t,inUsd:r,outUsd:n})=>{const{swapStatus:s,outAmount:a,inAmount:o,inToken:i,outToken:c,components:l,totalSteps:u}=tn(),d=C.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?C.jsx(J3,{}):C.jsxs(l1,{children:[d,C.jsx(X3,{})]}):C.jsx(l1,{children:d})},d1=({amount:e,token:t,usd:r,title:n,Logo:s})=>C.jsxs("div",{className:`${Le("MainToken")}`,children:[C.jsxs("div",{className:`${Le("MainTokenLeft")}`,children:[C.jsx($o,{className:`${Le("MainTokenTitle")}`,children:n}),C.jsx($o,{className:` ${Le("MainTokenAmount")}`,children:`${e&&Number(e)>0?e:""} ${(t==null?void 0:t.symbol)||""}`}),r&&C.jsx("div",{className:` ${Le("MainTokenUsd")}`,children:r})]}),s||C.jsx("div",{className:` ${Le("MainTokenLogo")}`,children:t!=null&&t.logoUrl?C.jsx("img",{src:t==null?void 0:t.logoUrl,alt:"Token logo"}):null})]});function J3(){const{currentStep:e}=tn();return e?C.jsx($c,{footerLink:e.footerLink,footerText:e.footerText,title:e.title,body:e.hideTokens?void 0:C.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})=>C.jsxs("div",{className:`${Le("Main")}`,children:[C.jsx(d1,{title:e||"Swap from",usd:t,token:r,amount:o,Logo:c}),C.jsx(d1,{title:n||"Swap to",usd:s,token:a,amount:i,Logo:l})]}),es=e=>C.jsx(z3,{...e,children:C.jsx(e8,{})}),e8=()=>{const{swapStatus:e,components:t,className:r}=tn();return C.jsx("div",{className:`${Le("SwapFlow")} ${r}`,children:e===pt.SUCCESS?t==null?void 0:t.Success:e===pt.FAILED?t==null?void 0:t.Failed:t==null?void 0:t.Main})};es.Success=Z3,es.Failed=K3,es.Main=Q3,es.StepLayout=$c;var Rs=(e=>(e.WRAP="wrap",e.APPROVE="approve",e.CREATE="create",e))(Rs||{});const t8="1.2.3";let Yt=class Nm extends Error{constructor(t,r={}){var o;const n=r.cause instanceof Nm?r.cause.details:(o=r.cause)!=null&&o.message?r.cause.message:r.details,s=r.cause instanceof Nm&&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@${t8}`].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 En(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])?$/,m1=/^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)?$/,h1=/^\(.+?\).*?$/,b1=/^tuple(?<array>(\[(\d*)\])*)$/;function Nd(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+=Nd(a),s<r-1&&(t+=", ")}const n=En(b1,e.type);return t+=`)${(n==null?void 0:n.array)||""}`,Nd({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Fa(e){let t="";const r=e.length;for(let n=0;n<r;n++){const s=e[n];t+=Nd(s),n!==r-1&&(t+=", ")}return t}function Gc(e){var t;return e.type==="function"?`function ${e.name}(${Fa(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${(t=e.outputs)!=null&&t.length?` returns (${Fa(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Fa(e.inputs)})`:e.type==="error"?`error ${e.name}(${Fa(e.inputs)})`:e.type==="constructor"?`constructor(${Fa(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 r8(e){return y1.test(e)}function n8(e){return En(y1,e)}const g1=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function s8(e){return g1.test(e)}function a8(e){return En(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 o8(e){return x1.test(e)}function i8(e){return En(x1,e)}const w1=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function jc(e){return w1.test(e)}function c8(e){return En(w1,e)}const v1=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function l8(e){return v1.test(e)}function u8(e){return En(v1,e)}const E1=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function d8(e){return E1.test(e)}function p8(e){return En(E1,e)}const f8=/^receive\(\) external payable$/;function m8(e){return f8.test(e)}const k1=new Set(["memory","indexed","storage","calldata"]),h8=new Set(["indexed"]),Ld=new Set(["calldata","memory","storage"]);class b8 extends Yt{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 y8 extends Yt{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 g8 extends Yt{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 x8 extends Yt{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 w8 extends Yt{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class v8 extends Yt{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 E8 extends Yt{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 k8 extends Yt{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 C8 extends Yt{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 Oa extends Yt{constructor({signature:t,type:r}){super(`Invalid ${r} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class T8 extends Yt{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class A8 extends Yt{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 S8 extends Yt{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 P8 extends Yt{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 I8(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 zd=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 Rd(e,t={}){if(o8(e))return B8(e,t);if(s8(e))return F8(e,t);if(r8(e))return O8(e,t);if(l8(e))return U8(e,t);if(d8(e))return D8(e);if(m8(e))return{type:"receive",stateMutability:"payable"};throw new T8({signature:e})}function B8(e,t={}){const r=i8(e);if(!r)throw new Oa({signature:e,type:"function"});const n=or(r.parameters),s=[],a=n.length;for(let i=0;i<a;i++)s.push(kn(n[i],{modifiers:Ld,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(kn(i[l],{modifiers:Ld,structs:t,type:"function"}))}return{name:r.name,type:"function",stateMutability:r.stateMutability??"nonpayable",inputs:s,outputs:o}}function F8(e,t={}){const r=a8(e);if(!r)throw new Oa({signature:e,type:"event"});const n=or(r.parameters),s=[],a=n.length;for(let o=0;o<a;o++)s.push(kn(n[o],{modifiers:h8,structs:t,type:"event"}));return{name:r.name,type:"event",inputs:s}}function O8(e,t={}){const r=n8(e);if(!r)throw new Oa({signature:e,type:"error"});const n=or(r.parameters),s=[],a=n.length;for(let o=0;o<a;o++)s.push(kn(n[o],{structs:t,type:"error"}));return{name:r.name,type:"error",inputs:s}}function U8(e,t={}){const r=u8(e);if(!r)throw new Oa({signature:e,type:"constructor"});const n=or(r.parameters),s=[],a=n.length;for(let o=0;o<a;o++)s.push(kn(n[o],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:r.stateMutability??"nonpayable",inputs:s}}function D8(e){const t=p8(e);if(!t)throw new Oa({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const _8=/^(?<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$_]*))?$/,M8=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,N8=/^u?int$/;function kn(e,t){var d,f;const r=I8(e,t==null?void 0:t.type,t==null?void 0:t.structs);if(zd.has(r))return zd.get(r);const n=h1.test(e),s=En(n?M8:_8,e);if(!s)throw new w8({param:e});if(s.name&&z8(s.name))throw new v8({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 m=or(s.type),b=[],g=m.length;for(let E=0;E<g;E++)b.push(kn(m[E],{structs:i}));l={components:b}}else if(s.type in i)c="tuple",l={components:i[s.type]};else if(N8.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 g8({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 E8({param:e,type:t==null?void 0:t.type,modifier:s.modifier});if(Ld.has(s.modifier)&&!R8(c,!!s.array))throw new k8({param:e,type:t==null?void 0:t.type,modifier:s.modifier})}const u={type:`${c}${s.array??""}`,...a,...o,...l};return zd.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 P8({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)||m1.test(e)}const L8=/^(?: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 z8(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||f1.test(e)||m1.test(e)||L8.test(e)}function R8(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Hd(e){const t={},r=e.length;for(let o=0;o<r;o++){const i=e[o];if(!jc(i))continue;const c=c8(i);if(!c)throw new Oa({signature:i,type:"struct"});const l=c.properties.split(";"),u=[],d=l.length;for(let f=0;f<d;f++){const b=l[f].trim();if(!b)continue;const g=kn(b,{type:"struct"});u.push(g)}if(!u.length)throw new A8({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 H8=/^(?<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(h1.test(o.type))n.push(o);else{const c=En(H8,o.type);if(!(c!=null&&c.type))throw new C8({abiParameter:o});const{array:l,type:u}=c;if(u in t){if(r.has(u))throw new S8({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 y8({type:u})}}return n}function A1(e){const t=Hd(e),r=[],n=e.length;for(let s=0;s<n;s++){const a=e[s];jc(a)||r.push(Rd(a,t))}return r}function S1(e){let t;if(typeof e=="string")t=Rd(e);else{const r=Hd(e),n=e.length;for(let s=0;s<n;s++){const a=e[s];if(!jc(a)){t=Rd(a,r);break}}}if(!t)throw new b8({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(kn(r[s],{modifiers:k1}))}else{const r=Hd(e),n=e.length;for(let s=0;s<n;s++){const a=e[s];if(jc(a))continue;const o=or(a),i=o.length;for(let c=0;c<i;c++)t.push(kn(o[c],{modifiers:k1,structs:r}))}}if(t.length===0)throw new x8({params:e});return t}function se(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 _r(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new tv(e.type);return`${e.name}(${Vc(e.inputs,{includeName:t})})`}function Vc(e,{includeName:t=!1}={}){return e?e.map(r=>$8(r,{includeName:t})).join(t?", ":","):""}function $8(e,{includeName:t}){return e.type.startsWith("tuple")?`(${Vc(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function Mr(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function lt(e){return Mr(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const I1="2.43.3";let Go={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${I1}`},$=class Lm extends Error{constructor(t,r={}){var i;const n=(()=>{var c;return r.cause instanceof Lm?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof Lm&&r.cause.docsPath||r.docsPath,a=(i=Go.getDocsUrl)==null?void 0:i.call(Go,{...r,docsPath:s}),o=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...Go.version?[`Version: ${Go.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 G8 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 @@ te.version="2.30.1",Sz(et),te.fn=K,te.min=hH,te.max=bH,te.now=yH,te.utc=cn,te.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 GG(e){e=$G(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,s=e.onKeyDown;s===void 0&&(s=Z0);var a=e.onBlur;a===void 0&&(a=Z0);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,m=e.onValueChange,b=SG(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),g=Lu(e),E=g.decimalSeparator,v=g.allowedDecimalSeparators,w=function(I){return X2(I,e)},S=function(I,D){return RG(I,D,e)},T=xo(d)?u:d,O=f??zG(T,l,t);xo(d)?xo(u)||(O=O||typeof u=="number"):O=O||typeof d=="number";var L=function(I){return V2(I)?I:(typeof I=="number"&&(I=Y2(I)),O&&typeof i=="number"?Z2(I,i,!!c):I)},P=MG(L(d),L(u),!!O,w,S,m),h=P[0],y=h.numAsString,x=h.formattedValue,A=P[1],B=function(I){var D=I.target,U=I.key,z=D.selectionStart,H=D.selectionEnd,j=D.value;if(j===void 0&&(j=""),(U==="Backspace"||U==="Delete")&&H<l.length){I.preventDefault();return}if(z!==H){s(I);return}U==="Backspace"&&j[0]==="-"&&z===l.length+1&&r&&dc(D,1),i&&c&&(U==="Backspace"&&j[z-1]===E?(dc(D,z-1),I.preventDefault()):U==="Delete"&&j[z]===E&&I.preventDefault()),v!=null&&v.includes(U)&&j[z]===E&&dc(D,z+1);var Q=o===!0?",":o;U==="Backspace"&&j[z-1]===Q&&dc(D,z-1),U==="Delete"&&j[z]===Q&&dc(D,z+1),s(I)},F=function(I){var D=y;if(D.match(/\d/g)||(D=""),n||(D=UG(D)),c&&i&&(D=Z2(D,i,c)),D!==y){var U=X2(D,e);A({formattedValue:U,value:D,floatValue:parseFloat(D)},{event:I,source:Y0.event})}a(I)},_=function(I){return I===E?!0:j2(I)},k=function(I){var D=I.currentValue,U=I.lastValue,z=I.formattedValue,H=I.currentValueIndex,j=I.formattedValueIndex,Q=D[H],pe=z[j],be=DG(U,D),ie=be.to,de=function(Oe){return S(Oe).indexOf(".")+l.length};return d===0&&c&&i&&D[ie.start]===E&&de(D)<H&&de(z)>j?!1:H>=ie.start&&H<ie.end&&v&&v.includes(Q)&&pe===E?!0:Q===pe};return Object.assign(Object.assign({},b),{value:x,valueIsNumericString:!1,isValidInputCharacter:_,isCharacterSame:k,onValueChange:A,format:w,removeFormatting:S,getCaretBoundary:function(I){return HG(I,e)},onKeyDown:B,onBlur:F})}const Q2=(e,t)=>M.useMemo(()=>Ml(t,e),[e,t]),qr=(e,t)=>M.useMemo(()=>oa(t,e),[e,t]),wo=()=>{const{chainId:e}=re();return M.useMemo(()=>Ms(e),[e])},zu=e=>{const t=wo();return M.useMemo(()=>{if(!(!e||!t))return ao(e,t.id)},[e,t])},bs=(e,t)=>M.useMemo(()=>!e||!t||G(e||"0").isZero()||G(t||"0").isZero()?"":G(e||"0").times(t).toFixed(),[e,t]),jG=()=>{const{srcToken:e,dstToken:t,chainId:r}=re();return M.useMemo(()=>Wf(e,t,r),[e,t,r])},VG=()=>{const{srcToken:e,dstToken:t,chainId:r}=re();return M.useMemo(()=>qf(e,t,r),[e,t,r])},WG=()=>{const e=jG(),t=VG();return e||t},Ru=e=>{const{overrides:t}=re();return M.useMemo(()=>t!=null&&t.dateFormat?t.dateFormat(e||0):te(e).format("DD/MM/YYYY HH:mm"),[e,t==null?void 0:t.dateFormat])};function qG(){const{callbacks:e}=re();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 KG=(e,t)=>M.useMemo(()=>r6(e==null?void 0:e.toString(),t),[e,t]),Ar=({value:e,decimalScale:t=3,prefix:r,suffix:n})=>{var c;const s=KG(e,t),{overrides:a}=re(),o=a==null?void 0:a.numberFormat,i=GG({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()},YG={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",finalExecutionPrice:"Final execution price",marketPrice:"Market price",from:"From",to:"To",Open:"Open",Completed:"Completed",Expired:"Expired",Cancelled:"Cancelled",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",executionSummary:"Execution summary",orderInfo:"Order info",orderFills:"Order fills",fillTransactionHash:"Transaction hash",noFills:"No fills yet",backToOrder:"Back to {type} order",fillAmountOut:"Amount out",fillAmountReceived:"Amount received",fillIndex:"Index",fillTimestamp:"Timestamp",fillTxHash:"Tx hash",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 ZG(e){let t=e;const r=/\{[^{}]*\}/g;for(;r.test(t);)t=t.replace(r,"");return t}const Ie=()=>{const e=re();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])||YG[r];return ZG(a.replace(/{(\w+)}/g,(c,l)=>(n==null?void 0:n[l])||c))},[e.getTranslation,e.translations])},pn=({value:e,decimalScale:t=3,prefix:r,suffix:n,defaultValue:s="-"})=>{const a=Ar({value:e,decimalScale:t,prefix:r,suffix:n});return C.jsx(C.Fragment,{children:a??s})},Hu=({value:e})=>{const t=Ar({value:e,decimalScale:2});return t?C.jsx("small",{className:"twap-order-details__detail-row-value-usd",children:` ($${t})`}):null},XG=({deadline:e,label:t,tooltip:r})=>{const n=Ru(e);return C.jsx(Sr,{title:t,tooltip:r,children:n})},QG=({price:e,dstToken:t,label:r,tooltip:n,usd:s,srcToken:a})=>{const o=Ar({value:e,decimalScale:3});return G(e||0).isZero()?null:C.jsx(Sr,{title:r,tooltip:n,children:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["1 ",a==null?void 0:a.symbol," = ",`${o||"-"} ${t==null?void 0:t.symbol}`,C.jsx(Hu,{value:s})]})})},JG=({tradeSize:e,srcToken:t,trades:r,label:n,tooltip:s})=>r===1?null:C.jsxs(Sr,{title:n,tooltip:s,children:[e?C.jsx(pn,{value:e,decimalScale:3}):"-"," ",(t==null?void 0:t.symbol)||""]}),ej=({dstToken:e,dstMinAmountOut:t,label:r,tooltip:n,usd:s})=>{const a=Ar({value:t});return G(t||0).isZero()?null:C.jsxs(Sr,{title:r,tooltip:n,children:[`${t?a:"-"} ${e==null?void 0:e.symbol}`,C.jsx(Hu,{value:s})]})},tj=({trades:e,label:t,tooltip:r})=>e===1?null:C.jsx(Sr,{title:t,tooltip:r,children:e}),rj=()=>{var s;const e=Ie(),{account:t}=re(),r=(s=wo())==null?void 0:s.explorer,n=Nl(t);return C.jsx(Sr,{title:e("recipient")||"",children:r?C.jsx("a",{href:`${r}/address/${t}`,target:"_blank",children:n}):n})},nj=({fillDelayMillis:e,chunks:t=0,label:r,tooltip:n})=>{const s=M.useMemo(()=>t6(e),[e]);return t===1?null:C.jsx(Sr,{title:r,tooltip:n,children:s})},Sr=({title:e,tooltip:t,children:r,className:n="",onClick:s,style:a})=>{const{components:o}=re(),i=o.Tooltip;return C.jsxs("div",{className:`${n} twap-order-details__detail-row`,onClick:s,style:a,children:[C.jsxs("div",{className:"twap-order-details__detail-row-label",children:[C.jsx("p",{className:"twap-order-details__detail-row-label-value",children:e}),t&&i&&C.jsx(i,{tooltipText:t})]}),C.jsx("div",{className:"twap-order-details__detail-row-value",children:r})]})},sj=({id:e})=>{const{components:t}=re(),r=t==null?void 0:t.Tooltip,n=qG();return e.startsWith("0x")?C.jsx(Sr,{title:"ID",onClick:()=>n(e),style:{cursor:"pointer"},children:r&&C.jsx(r,{tooltipText:e,children:C.jsxs("div",{className:"twap-order-details__detail-row-value-id",children:[C.jsx("p",{children:Nl(e)}),C.jsx(Az.AiOutlineCopy,{})]})})}):C.jsx(Sr,{title:"ID",children:e})},aj=({version:e})=>C.jsx(Sr,{title:"Version",children:e});function he({children:e,className:t=""}){return C.jsx("div",{className:`${t} twap-order-details`,children:e})}const oj=({children:e})=>e,ij=({fees:e,label:t,usd:r,dstTokenSymbol:n})=>{const s=Ar({value:e});return C.jsxs(Sr,{title:t,children:[`${e?s:"-"} ${n}`,C.jsx(Hu,{value:r})]})};he.Deadline=XG,he.Fees=ij,he.TradeSize=JG,he.MinDestAmount=ej,he.TradesAmount=tj,he.Recipient=rj,he.TradeInterval=nj,he.DetailRow=Sr,he.Price=QG,he.OrderID=sj,he.Container=oj,he.OrderVersion=aj,he.USD=Hu;const Q0=()=>{const{publicClient:e}=re();return en({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},J2=e=>{const t=Ie(),r=e.limitPriceUsd,n=e.srcAmountPerTrade,s=e.srcAmountPerTradeUsd,a=M.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":G(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),o=M.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":G(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]),i=e.triggerPrice,c=e.triggerPriceUsd,l=e.srcUsd,u=e.dstUsd,d=e.dstAmount;return M.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,srcUsd:l||"",dstUsd:u||"",orderType:e.orderType,dstMinAmount:a,dstMinAmountUsd:o,limitPrice:{label:t("limitPrice"),tooltip:t("limitPriceTooltip"),value:e.limitPrice||"",usd:r||""},deadline:{tooltip:t("expirationTooltip"),label:t("expirationLabel"),value:e.deadline||0},createdAt:{label:t("createdAt"),value:e.createdAt||0},srcAmount:{label:t("amountOut"),value:e.srcAmount||"",usd:l||""},dstAmount:{value:d||"",usd:u||""},sizePerTrade:{tooltip:t("tradeSizeTooltip"),label:t("individualTradeSize"),value:n||"",usd:s},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:e.minDestAmountPerTrade||"",usd:e.minDestAmountPerTradeUsd},tradeInterval:{tooltip:t("tradeIntervalTooltip"),label:t("tradeIntervalLabel"),value:e.tradeInterval||0},triggerPrice:{tooltip:t("triggerPriceTooltip"),label:t("triggerPrice"),value:i||"",usd:c},recipient:{label:t("recipient"),value:e.account||""}}),[t,e.srcToken,e.dstToken,l,u,e.orderType,a,o,e.limitPrice,r,e.deadline,e.srcAmount,d,n,s,e.totalTrades,e.minDestAmountPerTrade,e.minDestAmountPerTradeUsd,e.tradeInterval,i,c,e.account,e.createdAt])},cj=(e,t,r)=>{const n=wo();return M.useMemo(()=>e==null?void 0:e.map(s=>({srcToken:t,dstToken:r,srcAmount:oa(s.inAmount,t==null?void 0:t.decimals),dstAmount:oa(s.outAmount,r==null?void 0:r.decimals),timestamp:s.timestamp,txHash:s.txHash,explorerUrl:ao(s.txHash,n==null?void 0:n.id),executionRate:ld(s.inAmount,s.outAmount,t==null?void 0:t.decimals,r==null?void 0:r.decimals)})).filter(s=>s.srcToken!==void 0&&s.dstToken!==void 0),[e,t,r,n])},ex=e=>{const{data:t}=vo(),{useToken:r,config:n}=re(),s=Ie(),a=M.useMemo(()=>t==null?void 0:t.find(O=>O.id===e),[t,e])||{},o=nx(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=qr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmount),u=uj(i,c,a),d=dj(i,c,a),f=pj(i,c,a),m=qr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountFilled),b=qr(c==null?void 0:c.decimals,a==null?void 0:a.dstAmountFilled),g=a==null?void 0:a.progress,E=qr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountPerTrade),v=qr(c==null?void 0:c.decimals,a==null?void 0:a.dstMinAmountPerTrade),w=M.useMemo(()=>a?a.version===2?a.fillDelay:n.twapConfig?cd(a,n.twapConfig):0:0,[a,n]),S=J2({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,orderType:a==null?void 0:a.type}),T=cj(a==null?void 0:a.fills,i,c)??[];return M.useMemo(()=>{if(a!=null&&a.id)return{original:a,fills:T,title:o,...S,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:m??""},amountOutFilled:{label:s("amountReceived"),value:b??"",token:c},progress:{label:s("progress"),value:g},executionPrice:{label:s((a==null?void 0:a.totalTradesAmount)===1?"finalExecutionPrice":"averageExecutionPrice"),value:f},version:{label:s("version"),value:a==null?void 0:a.version}}},[a,s,f,m,b,g,o,i,c,S])},tx=e=>{const t=Ie();return M.useMemo(()=>{switch(e){case Re.TWAP_MARKET:return t("twapMarket");case Re.LIMIT:return t("limit");case Re.TWAP_LIMIT:return t("twapLimit");case Re.STOP_LOSS_MARKET:return t("stopLossMarket");case Re.STOP_LOSS_LIMIT:return t("stopLossLimit");case Re.TAKE_PROFIT:return t("takeProfit");default:return t("twapMarket")}},[t,e])},J0=()=>{const{module:e}=re(),t=ee(r=>r.state.isMarketOrder);return M.useMemo(()=>e===ge.TWAP?t?Re.TWAP_MARKET:Re.TWAP_LIMIT:e===ge.LIMIT?Re.LIMIT:e===ge.STOP_LOSS?t?Re.STOP_LOSS_MARKET:Re.STOP_LOSS_LIMIT:e===ge.TAKE_PROFIT?Re.TAKE_PROFIT:Re.TWAP_MARKET,[e,t])},rx=()=>{const e=J0();return tx(e)},nx=e=>tx(e==null?void 0:e.type),sx=()=>{const{account:e,config:t,chainId:r}=re();return M.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,r],[e,t,r])},lj=()=>{const{callbacks:e,refetchBalances:t}=re(),r=Dd(),n=sx();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===ut.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])},vo=()=>{const{account:e,config:t,chainId:r}=re(),n=sx(),s=lj();return F3({refetchInterval:gz,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:o})=>{if(!e||!r||!t)return[];const i=await Mh({signal:o,chainId:r,config:t,account:e});return s(i),i.map(c=>t!=null&&t.twapConfig?{...c,fillDelayMillis:cd(c,t.twapConfig)}:c)}})},ax=(e=[],t=ar.All)=>{let r=e??[];return t===ar.Open&&(r=r.filter(n=>n.status===ut.Open)),t===ar.Completed&&(r=r.filter(n=>n.status===ut.Completed)),t===ar.Cancelled&&(r=r.filter(n=>n.status===ut.Cancelled)),t===ar.Expired&&(r=r.filter(n=>n.status===ut.Expired)),r.sort((n,s)=>s.createdAt-n.createdAt)},ox=()=>{const e=ee(r=>r.state.orderHistoryStatusFilter),{data:t}=vo();return M.useMemo(()=>ax(t,e),[e,t])},uj=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return Vm(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),dj=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return Wm(r,e.decimals,t.decimals)},[r,e,t]),pj=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return ld(r.srcAmountFilled,r.dstAmountFilled,e.decimals,t.decimals)},[r,e,t]),fj=()=>{const e=ee(r=>r.updateState),t=ee(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])},ix=()=>{const e=Ie();return M.useCallback(t=>{if(!t)return e("allOrders");switch(t){case ar.Open:return e("Open");case ar.Completed:return e("Completed");case ar.Expired:return e("Expired");case ar.Cancelled:return e("Cancelled");default:return e("allOrders")}},[e])},mj=()=>{const e=ix();return M.useMemo(()=>Object.values(ar).map(t=>({text:e(t),value:t})),[e])},hj=()=>{const{data:e,isLoading:t,refetch:r,isRefetching:n}=vo(),{mutateAsync:s,isPending:a}=lx(),o=ee(O=>O.state.selectedOrderID),i=ee(O=>O.updateState),c=ee(O=>O.state.orderHistoryStatusFilter),l=ee(O=>O.state.showSelectedOrderFills),u=M.useCallback(O=>i({orderHistoryStatusFilter:O}),[]),d=mj(),f=ox(),m=ex(o),b=M.useMemo(()=>ax(e,ar.Open),[e]),g=M.useCallback(O=>{i(O?{selectedOrderID:O}:{selectedOrderID:void 0,showSelectedOrderFills:!1})},[i]),E=M.useCallback(()=>r().then(O=>O.data),[r]),v=M.useCallback(async O=>s({orders:[O]}).then(L=>(L==null?void 0:L[0])||""),[s]),w=M.useCallback(()=>s({orders:b}),[s,e]),S=M.useCallback(()=>i({showSelectedOrderFills:!1}),[i]),T=M.useMemo(()=>{const O=c||d[0].value;return d.find(L=>L.value===O)},[d,c]);return{refetchOrders:E,onCancelOrder:v,onSelectOrderFilter:u,onDisplayOrder:g,onCancelAllOpenOrders:w,onHideOrderFills:S,isRefetching:n,allOrders:e??[],selectedOrders:f,isDisplayingOrderFills:l,isLoading:t,selectedOrder:o?m:void 0,openOrdersCount:(b==null?void 0:b.length)||0,isCancelOrderLoading:a,selectedOrderFilter:T,orderFilters:d}},cx=()=>{const{refetch:e}=vo();return en({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)===ut.Cancelled}))break;await new Promise(a=>setTimeout(a,1e3))}}})},lx=()=>{const{account:e,walletClient:t,publicClient:r,config:n,callbacks:s,chainId:a}=re(),o=Q0(),i=cx().mutateAsync,c=ee(d=>d.updateState),l=async d=>{dt.onCancelOrderRequest(d.map(f=>f.id.toString()),1);try{return(await Promise.all(d.map(m=>t.writeContract({account:e,address:m.twapAddress,abi:Hm,functionName:"cancel",args:[m.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 m=await t.writeContract({account:e,address:n.repermit,abi:Rm,functionName:"cancel",args:[d.map(g=>g.hash)],chain:t.chain}),b=await o(m);if(!b)throw new Error("failed to get transaction receipt");if(b.status==="reverted")throw new Error("failed to cancel order");return dt.onCancelOrderSuccess(m),(f=s==null?void 0:s.onCancelOrderSuccess)==null||f.call(s,{orders:d,txHash:m,explorerUrl:ao(m,a)}),b.transactionHash}catch(m){throw dt.onCancelOrderError(m),m}};return en({mutationFn:async({orders:d})=>{var f,m;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:pt.LOADING,cancelOrderTxHash:void 0,cancelOrderError:void 0});const b=d.filter(w=>w.version===1),g=d.filter(w=>w.version===2),[E,v]=await Promise.all([b.length?l(b):Promise.resolve(""),g.length?u(g):Promise.resolve("")]);return await i(d.map(w=>w.id)),c({cancelOrderStatus:pt.SUCCESS,orderIdsToCancel:[]}),[...E||[],v]}catch(b){console.error("cancel order error",b),(m=s==null?void 0:s.onCancelOrderFailed)==null||m.call(s,b),jf(b)?c({cancelOrderStatus:void 0}):(c({cancelOrderStatus:pt.FAILED}),dt.onCancelOrderError(b))}}})},$u=0,ys=1,Eo=2,ux=4;function dx(e){return()=>e}function bj(e){e()}function px(e,t){return r=>e(t(r))}function fx(e,t){return()=>e(t)}function yj(e,t){return r=>e(t,r)}function em(e){return e!==void 0}function gj(...e){return()=>{e.map(bj)}}function ko(){}function Gu(e,t){return t(e),e}function xj(e,t){return t(e)}function tt(...e){return e}function Ve(e,t){return e(ys,t)}function Ce(e,t){e($u,t)}function tm(e){e(Eo)}function at(e){return e(ux)}function ce(e,t){return Ve(e,yj(t,$u))}function Kr(e,t){const r=e(ys,n=>{r(),t(n)});return r}function mx(e){let t,r;return n=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{n(t)},e)}}function hx(e,t){return e===t}function rt(e=hx){let t;return r=>n=>{e(t,n)||(t=n,r(n))}}function fe(e){return t=>r=>{e(r)&&t(r)}}function ne(e){return t=>px(t,e)}function fn(e){return t=>()=>{t(e)}}function W(e,...t){const r=wj(...t);return(n,s)=>{switch(n){case Eo:tm(e);return;case ys:return Ve(e,r(s))}}}function mn(e,t){return r=>n=>{r(t=e(t,n))}}function pa(e){return t=>r=>{e>0?e--:t(r)}}function jn(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);Ve(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 wj(...e){return t=>e.reduceRight(xj,t)}function vj(e){let t,r;const n=()=>t==null?void 0:t();return function(s,a){switch(s){case ys:return a?r===a?void 0:(n(),r=a,t=Ve(e,a),t):(n(),ko);case Eo:n(),r=null;return}}}function Y(e){let t=e;const r=De();return(n,s)=>{switch(n){case $u:t=s;break;case ys:{s(t);break}case ux:return t}return r(n,s)}}function zt(e,t){return Gu(Y(t),r=>ce(e,r))}function De(){const e=[];return(t,r)=>{switch(t){case $u:e.slice().forEach(n=>{n(r)});return;case Eo:e.splice(0,e.length);return;case ys:return e.push(r),()=>{const n=e.indexOf(r);n>-1&&e.splice(n,1)}}}}function hr(e){return Gu(De(),t=>ce(e,t))}function Ge(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:Ej(),singleton:r}}const Ej=()=>Symbol();function kj(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 vt(...e){const t=De(),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);Ve(a,c=>{r[o]=c,n=n|i,n===s&&Ce(t,r)})}),function(a,o){switch(a){case Eo:{tm(t);return}case ys:return n===s&&o(r),Ve(t,o)}}}function me(e,t=hx){return W(e,rt(t))}function rm(...e){return function(t,r){switch(t){case Eo:return;case ys:return gj(...e.map(n=>Ve(n,r)))}}}var rr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(rr||{});const Cj={0:"debug",3:"error",1:"log",2:"warn"},Tj=()=>typeof globalThis>"u"?window:globalThis,gs=Ge(()=>{const e=Y(3);return{log:Y((t,r,n=1)=>{var s;const a=(s=Tj().VIRTUOSO_LOG_LEVEL)!=null?s:at(e);n>=a&&console[Cj[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function fa(e,t,r){return nm(e,t,r).callbackRef}function nm(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 Aj(e,t,r,n,s,a,o,i,c){const l=M.useCallback(u=>{const d=Sj(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const m=f.lastElementChild.dataset.viewportType==="window";let b;m&&(b=f.ownerDocument.defaultView);const g=o?i?o.scrollLeft:o.scrollTop:m?i?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,E=o?i?o.scrollWidth:o.scrollHeight:m?i?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,v=o?i?o.offsetWidth:o.offsetHeight:m?i?b.innerWidth:b.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:E,scrollTop:Math.max(g,0),viewportHeight:v}),a==null||a(i?bx("column-gap",getComputedStyle(u).columnGap,s):bx("row-gap",getComputedStyle(u).rowGap,s)),d!==null&&e(d)},[e,t,s,a,o,n,i]);return nm(l,r,c)}function Sj(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},rr.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 bx(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,rr.WARN),t==="normal"?0:parseInt(t??"0",10)}function yx(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 m=t.getBoundingClientRect(),b=l.top-m.top;f=m.height-Math.max(0,b),d=b+t.scrollTop}else{const m=o.current.ownerDocument.defaultView;f=m.innerHeight-Math.max(0,l.top),d=l.top+m.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:a,ref:o}=nm(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 Vt=Ge(()=>{const e=De(),t=De(),r=Y(0),n=De(),s=Y(0),a=De(),o=De(),i=Y(0),c=Y(0),l=Y(0),u=Y(0),d=De(),f=De(),m=Y(!1),b=Y(!1),g=Y(!1);return ce(W(e,ne(({scrollTop:E})=>E)),t),ce(W(e,ne(({scrollHeight:E})=>E)),o),ce(t,s),{deviation:r,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:i,horizontalDirection:b,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:m,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),pc={lvl:0};function gx(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 Ke(e){return e===pc}function fc(e,t){if(!Ke(e))return t===e.k?e.v:t<e.k?fc(e.l,t):fc(e.r,t)}function Yr(e,t,r="k"){if(Ke(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const n=Yr(e.r,t,r);return n[0]===-1/0?[e.k,e.v]:n}return Yr(e.l,t,r)}function br(e,t,r){return Ke(e)?vx(t,r,1):t===e.k?At(e,{k:t,v:r}):t<e.k?Ex(At(e,{l:br(e.l,t,r)})):Ex(At(e,{r:br(e.r,t,r)}))}function Co(){return pc}function To(e,t,r){if(Ke(e))return[];const n=Yr(e,t)[0];return Pj(am(e,n,r))}function sm(e,t){if(Ke(e))return pc;const{k:r,l:n,r:s}=e;if(t===r){if(Ke(n))return s;if(Ke(s))return n;{const[a,o]=wx(n);return ju(At(e,{k:a,l:xx(n),v:o}))}}else return t<r?ju(At(e,{l:sm(n,t)})):ju(At(e,{r:sm(s,t)}))}function ma(e){return Ke(e)?[]:[...ma(e.l),{k:e.k,v:e.v},...ma(e.r)]}function am(e,t,r){if(Ke(e))return[];const{k:n,l:s,r:a,v:o}=e;let i=[];return n>t&&(i=i.concat(am(s,t,r))),n>=t&&n<=r&&i.push({k:n,v:o}),n<=r&&(i=i.concat(am(a,t,r))),i}function ju(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(om(t))return kx(At(e,{lvl:r-1}));if(!Ke(t)&&!Ke(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(om(e))return im(At(e,{lvl:r-1}));if(!Ke(n)&&!Ke(n.l)){const s=n.l,a=om(s)?n.lvl-1:n.lvl;return At(s,{l:At(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:im(At(n,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return vx(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 xx(e){return Ke(e.r)?e.l:ju(At(e,{r:xx(e.r)}))}function om(e){return Ke(e)||e.lvl>e.r.lvl}function wx(e){return Ke(e.r)?[e.k,e.v]:wx(e.r)}function vx(e,t,r,n=pc,s=pc){return{k:e,l:n,lvl:r,r:s,v:t}}function Ex(e){return im(kx(e))}function kx(e){const{l:t}=e;return!Ke(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function im(e){const{lvl:t,r}=e;return!Ke(r)&&!Ke(r.r)&&r.lvl===t&&r.r.lvl===t?At(r,{l:At(e,{r:r.l}),lvl:t+1}):e}function Pj(e){return gx(e,({k:t,v:r})=>({index:t,value:r}))}function Cx(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function mc(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const cm=Ge(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function Tx(e,t,r){return e[Vu(e,t,r)]}function Vu(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 Ij(e,t,r,n){const s=Vu(e,t,n),a=Vu(e,r,n,s);return e.slice(s,a+1)}function xs(e,t){return Math.round(e.getBoundingClientRect()[t])}function Wu(e){return!Ke(e.groupOffsetTree)}function lm({index:e},t){return t===e?0:t<e?-1:1}function Bj(){return{groupIndices:[],groupOffsetTree:Co(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Co()}}function Fj(e,t){let r=Ke(e)?0:1/0;for(const n of t){const{endIndex:s,size:a,startIndex:o}=n;if(r=Math.min(r,o),Ke(e)){e=br(e,0,a);continue}const i=To(e,o-1,s+1);if(i.some(Lj(n)))continue;let c=!1,l=!1;for(const{end:u,start:d,value:f}of i)c?(s>=d||a===f)&&(e=sm(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 Uj({offset:e},t){return t===e?0:t<e?-1:1}function hc(e,t,r){if(t.length===0)return 0;const{index:n,offset:s,size:a}=Tx(t,e,lm),o=e-n,i=a*o+(o-1)*r+s;return i>0?i+r:i}function Ax(e,t){if(!Wu(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function Sx(e,t,r){if(Oj(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?r:e.index;let s=Ax(n,t);return s=Math.max(0,s,Math.min(r,s)),s}}function Dj(e,t,r,n=0){return n>0&&(t=Math.max(t,Tx(e,n,lm).offset)),gx(Ij(e,t,r,Uj),Nj)}function _j(e,[t,r,n,s]){t.length>0&&n("received item sizes",t,rr.DEBUG);const a=e.sizeTree;let o=a,i=0;if(r.length>0&&Ke(a)&&t.length===2){const f=t[0].size,m=t[1].size;o=r.reduce((b,g)=>br(br(b,g,f),g+1,m),o)}else[o,i]=Fj(o,t);if(o===a)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=um(e.offsetTree,i,o,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,m)=>br(f,m,hc(m,d,s)),Co()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Mj(e){return ma(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 Px(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 um(e,t,r,n){let s=e,a=0,o=0,i=0,c=0;if(t!==0){c=Vu(s,t-1,lm),i=s[c].offset;const l=Yr(r,t-1);a=l[0],o=l[1],s.length&&s[c].size===Yr(r,t)[1]&&(c-=1),s=s.slice(0,c+1)}else s=[];for(const{start:l,value:u}of To(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 Nj(e){return{index:e.index,value:e}}function Lj(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 zj={offsetHeight:"height",offsetWidth:"width"},hn=Ge(([{log:e},{recalcInProgress:t}])=>{const r=De(),n=De(),s=zt(n,0),a=De(),o=De(),i=Y(0),c=Y([]),l=Y(void 0),u=Y(void 0),d=Y(void 0),f=Y(void 0),m=Y((P,h)=>xs(P,zj[h])),b=Y(void 0),g=Y(0),E=Bj(),v=zt(W(r,Te(c,e,g),mn(_j,E),rt()),E),w=zt(W(c,rt(),mn((P,h)=>({current:h,prev:P.current}),{current:[],prev:[]}),ne(({prev:P})=>P)),[]);ce(W(c,fe(P=>P.length>0),Te(v,g),ne(([P,h,y])=>{const x=P.reduce((A,B,F)=>br(A,B,hc(B,h.offsetTree,y)||F),Co());return{...h,groupIndices:P,groupOffsetTree:x}})),v),ce(W(n,Te(v),fe(([P,{lastIndex:h}])=>P<h),ne(([P,{lastIndex:h,lastSize:y}])=>[{endIndex:h,size:y,startIndex:P}])),r),ce(l,u);const S=zt(W(l,ne(P=>P===void 0)),!0);ce(W(u,fe(P=>P!==void 0&&Ke(at(v).sizeTree)),ne(P=>{const h=at(d),y=at(c).length>0;return h?y?[{endIndex:0,size:h,startIndex:0},{endIndex:1,size:P,startIndex:1}]:[]:[{endIndex:0,size:P,startIndex:0}]})),r),ce(W(f,fe(P=>P!==void 0&&P.length>0&&Ke(at(v).sizeTree)),ne(P=>{const h=[];let y=P[0],x=0;for(let A=1;A<P.length;A++){const B=P[A];B!==y&&(h.push({endIndex:A-1,size:y,startIndex:x}),y=B,x=A)}return h.push({endIndex:P.length-1,size:y,startIndex:x}),h})),r),ce(W(c,Te(d,u),fe(([,P,h])=>P!==void 0&&h!==void 0),ne(([P,h,y])=>{const x=[];for(let A=0;A<P.length;A++){const B=P[A],F=P[A+1];x.push({startIndex:B,endIndex:B,size:h}),F!==void 0&&x.push({startIndex:B+1,endIndex:F-1,size:y})}return x})),r);const T=hr(W(r,Te(v),mn(({sizes:P},[h,y])=>({changed:y!==P,sizes:y}),{changed:!1,sizes:E}),ne(P=>P.changed)));Ve(W(i,mn((P,h)=>({diff:P.prev-h,prev:h}),{diff:0,prev:0}),ne(P=>P.diff)),P=>{const{groupIndices:h}=at(v);if(P>0)Ce(t,!0),Ce(a,P+Px(P,h));else if(P<0){const y=at(w);y.length>0&&(P-=Px(-P,y)),Ce(o,P)}}),Ve(W(i,Te(e)),([P,h])=>{P<0&&h("`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},rr.ERROR)});const O=hr(a);ce(W(a,Te(v),ne(([P,h])=>{const y=h.groupIndices.length>0,x=[],A=h.lastSize;if(y){const B=fc(h.sizeTree,0);let F=0,_=0;for(;F<P;){const I=h.groupIndices[_],D=h.groupIndices.length===_+1?1/0:h.groupIndices[_+1]-I-1;x.push({endIndex:I,size:B,startIndex:I}),x.push({endIndex:I+1+D-1,size:A,startIndex:I+1}),_++,F+=D+1}const k=ma(h.sizeTree);return F!==P&&k.shift(),k.reduce((I,{k:D,v:U})=>{let z=I.ranges;return I.prevSize!==0&&(z=[...I.ranges,{endIndex:D+P-1,size:I.prevSize,startIndex:I.prevIndex}]),{prevIndex:D+P,prevSize:U,ranges:z}},{prevIndex:P,prevSize:0,ranges:x}).ranges}return ma(h.sizeTree).reduce((B,{k:F,v:_})=>({prevIndex:F+P,prevSize:_,ranges:[...B.ranges,{endIndex:F+P-1,size:B.prevSize,startIndex:B.prevIndex}]}),{prevIndex:0,prevSize:A,ranges:[]}).ranges})),r);const L=hr(W(o,Te(v,g),ne(([P,{offsetTree:h},y])=>{const x=-P;return hc(x,h,y)})));return ce(W(o,Te(v,g),ne(([P,h,y])=>{if(h.groupIndices.length>0){if(Ke(h.sizeTree))return h;let x=Co();const A=at(w);let B=0,F=0,_=0;for(;B<-P;){_=A[F];const k=A[F+1]-_-1;F++,B+=k+1}if(x=ma(h.sizeTree).reduce((k,{k:I,v:D})=>br(k,Math.max(0,I+P),D),x),B!==-P){const k=fc(h.sizeTree,_);x=br(x,0,k);const I=Yr(h.sizeTree,-P+1)[1];x=br(x,1,I)}return{...h,sizeTree:x,...um(h.offsetTree,0,x,y)}}else{const x=ma(h.sizeTree).reduce((A,{k:B,v:F})=>br(A,Math.max(0,B+P),F),Co());return{...h,sizeTree:x,...um(h.offsetTree,0,x,y)}}})),v),{beforeUnshiftWith:O,data:b,defaultItemSize:u,firstItemIndex:i,fixedItemSize:l,fixedGroupSize:d,gap:g,groupIndices:c,heightEstimates:f,itemSize:m,listRefresh:T,shiftWith:o,shiftWithOffset:L,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:n,trackItemSizes:S,unshiftWith:a}},tt(gs,cm),{singleton:!0});function Rj(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const Ix=Ge(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:n,scrollTop:s}])=>{const a=De(),o=De(),i=hr(W(a,ne(Rj)));return ce(W(i,ne(c=>c.totalCount)),r),ce(W(i,ne(c=>c.groupIndices)),e),ce(W(vt(s,t,n),fe(([c,l])=>Wu(l)),ne(([c,l,u])=>Yr(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),rt(),ne(c=>[c])),o),{groupCounts:a,topItemsIndexes:o}},tt(hn,Vt)),ws=Ge(([{log:e}])=>{const t=Y(!1),r=hr(W(t,fe(n=>n),rt()));return Ve(t,n=>{n&&at(e)("props updated",{},rr.DEBUG)}),{didMount:r,propsReady:t}},tt(gs),{singleton:!0}),Hj=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Bx(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Hj)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bc=Ge(([{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 m=De(),b=De(),g=Y(0);let E=null,v=null,w=null;function S(){E&&(E(),E=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Ce(c,!1)}return ce(W(m,Te(r,d,n,g,i,o,f),Te(e,a,s),ne(([[T,O,L,P,h,y,x,A],B,F,_])=>{const k=Bx(T),{align:I,behavior:D,offset:U}=k,z=P-1,H=Sx(k,O,z);let j=hc(H,O.offsetTree,B)+y;I==="end"?(j+=F+Yr(O.sizeTree,H)[1]-L+_,H===z&&(j+=x)):I==="center"?j+=(F+Yr(O.sizeTree,H)[1]-L+_)/2:j-=h,U&&(j+=U);const Q=pe=>{S(),pe?(A("retrying to scroll to",{location:T},rr.DEBUG),Ce(m,T)):(Ce(b,!0),A("list did not change, scroll successful",{},rr.DEBUG))};if(S(),D==="smooth"){let pe=!1;w=Ve(t,be=>{pe=pe||be}),E=Kr(u,()=>{Q(pe)})}else E=Kr(W(t,$j(150)),Q);return v=setTimeout(()=>{S()},1200),Ce(c,!0),A("scrolling from index to",{behavior:D,index:H,top:j},rr.DEBUG),{behavior:D,top:j}})),l),{scrollTargetReached:b,scrollToIndex:m,topListHeight:g}},tt(hn,Vt,gs),{singleton:!0});function $j(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(r))}}}function dm(e,t){e==0?t():requestAnimationFrame(()=>{dm(e-1,t)})}function pm(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const yc=Ge(([{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),fn(!1)),i),ce(W(o,Te(c),fe(([u,d])=>!!d),fn(!1)),l),Ve(W(vt(t,o),Te(i,r,e,l),fe(([[,u],d,{sizeTree:f},m,b])=>u&&(!Ke(f)||em(m))&&!d&&!b),Te(c)),([,u])=>{Kr(s,()=>{Ce(l,!0)}),dm(4,()=>{Kr(n,()=>{Ce(i,!0)}),Ce(a,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:i}},tt(hn,Vt,bc,ws),{singleton:!0});function Fx(e,t){return Math.abs(e-t)<1.01}const gc="up",xc="down",Gj="none",jj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Vj=0,wc=Ge(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:n,scrollTop:s,viewportHeight:a}])=>{const o=Y(!1),i=Y(!0),c=De(),l=De(),u=Y(4),d=Y(Vj),f=zt(W(rm(W(me(s),pa(1),fn(!0)),W(me(s),pa(1),fn(!1),mx(100))),rt()),!1),m=zt(W(rm(W(r,fn(!0)),W(r,fn(!1),mx(200))),rt()),!1);ce(W(vt(me(s),me(d)),ne(([w,S])=>w<=S),rt()),i),ce(W(i,jn(50)),l);const b=hr(W(vt(n,me(a),me(t),me(e),me(u)),mn((w,[{scrollHeight:S,scrollTop:T},O,L,P,h])=>{const y=T+O-S>-h,x={scrollHeight:S,scrollTop:T,viewportHeight:O};if(y){let B,F;return T>w.state.scrollTop?(B="SCROLLED_DOWN",F=w.state.scrollTop-T):(B="SIZE_DECREASED",F=w.state.scrollTop-T||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:F,state:x}}let A;return x.scrollHeight>w.state.scrollHeight?A="SIZE_INCREASED":O<w.state.viewportHeight?A="VIEWPORT_HEIGHT_DECREASING":T<w.state.scrollTop?A="SCROLLING_UPWARDS":A="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:A,state:x}},jj),rt((w,S)=>w&&w.atBottom===S.atBottom))),g=zt(W(n,mn((w,{scrollHeight:S,scrollTop:T,viewportHeight:O})=>{if(Fx(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const L=S-(T+O)<1;return w.scrollTop!==T&&L?{changed:!0,jump:w.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),ne(w=>w.jump)),0);ce(W(b,ne(w=>w.atBottom)),o),ce(W(o,jn(50)),c);const E=Y(xc);ce(W(n,ne(({scrollTop:w})=>w),rt(),mn((w,S)=>at(m)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?gc:xc,prevScrollTop:S},{direction:xc,prevScrollTop:0}),ne(w=>w.direction)),E),ce(W(n,jn(50),fn(Gj)),E);const v=Y(0);return ce(W(f,fe(w=>!w),fn(0)),v),ce(W(s,jn(100),Te(f),fe(([w,S])=>!!S),mn(([w,S],[T])=>[S,T],[0,0]),ne(([w,S])=>S-w)),v),{atBottomState:b,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:g,scrollDirection:E,scrollVelocity:v}},tt(Vt)),vc="top",Ec="bottom",Ox="none";function Ux(e,t,r){return typeof e=="number"?r===gc&&t===vc||r===xc&&t===Ec?e:0:r===gc?t===vc?e.main:e.reverse:t===Ec?e.main:e.reverse}function Dx(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const fm=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:n,viewportHeight:s}])=>{const a=De(),o=Y(0),i=Y(0),c=Y(0),l=zt(W(vt(me(n),me(s),me(r),me(a,mc),me(c),me(o),me(t),me(e),me(i)),ne(([u,d,f,[m,b],g,E,v,w,S])=>{const T=u-w,O=E+v,L=Math.max(f-T,0);let P=Ox;const h=Dx(S,vc),y=Dx(S,Ec);return m-=w,m+=f+v,b+=f+v,b-=w,m>u+O-h&&(P=gc),b<u-L+d+y&&(P=xc),P!==Ox?[Math.max(T-f-Ux(g,vc,P)-h,0),T-L-v+d+Ux(g,Ec,P)+y]:null}),fe(u=>u!=null),rt(mc)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:c,topListHeight:o,visibleRange:l}},tt(Vt),{singleton:!0});function Wj(e,t,r){if(Wu(t)){const n=Ax(e,t);return[{index:Yr(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 mm={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function qu(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,m=l,b=f-u;return{bottom:u,firstItemIndex:a,items:Mx(e,s,a),offsetBottom:b,offsetTop:l,top:m,topItems:Mx(t,s,a),topListHeight:t.reduce((g,E)=>E.size+g,0),totalCount:r}}function _x(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=pm(t,i),l=Array.from({length:i}).map((u,d)=>({data:a[d+c],index:d+c,offset:0,size:0}));return qu(l,[],i,s,r,n)}function Mx(e,t,r){if(e.length===0)return[];if(!Wu(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=To(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 Nx(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const ha=Ge(([{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:m},{recalcInProgress:b}])=>{const g=Y([]),E=Y(0),v=De(),w=Y(0);ce(a.topItemsIndexes,g);const S=zt(W(vt(m,b,me(c,mc),me(s),me(n),me(l),u,me(g),me(t),me(r),me(w),e),fe(([P,h,,y,,,,,,,,x])=>{const A=x&&x.length!==y;return P&&!h&&!A}),ne(([,,[P,h],y,x,A,B,F,_,k,I,D])=>{var U,z,H,j;const Q=x,{offsetTree:pe,sizeTree:be}=Q,ie=at(E);if(y===0)return{...mm,totalCount:y};if(P===0&&h===0)return ie===0?{...mm,totalCount:y}:_x(ie,A,x,_,k,D||[]);if(Ke(be))return ie>0?null:qu(Wj(pm(A,y),Q,D),[],y,k,Q,_);const de=[];if(F.length>0){const Ae=F[0],Ee=F[F.length-1];let ye=0;for(const Xe of To(be,Ae,Ee)){const Ye=Xe.value,Qe=Math.max(Xe.start,Ae),Or=Math.min(Xe.end,Ee);for(let Ut=Qe;Ut<=Or;Ut++)de.push({data:D==null?void 0:D[Ut],index:Ut,offset:ye,size:Ye}),ye+=Ye}}if(!B)return qu([],de,y,k,Q,_);const Oe=F.length>0?F[F.length-1]+1:0,X=Dj(pe,P,h,Oe);if(X.length===0)return null;const ve=y-1,Me=Gu([],Ae=>{for(const Ee of X){const ye=Ee.value;let Xe=ye.offset,Ye=Ee.start;const Qe=ye.size;if(ye.offset<P){Ye+=Math.floor((P-ye.offset+k)/(Qe+k));const Ut=Ye-Ee.start;Xe+=Ut*Qe+Ut*k}Ye<Oe&&(Xe+=(Oe-Ye)*Qe,Ye=Oe);const Or=Math.min(Ee.end,ve);for(let Ut=Ye;Ut<=Or&&!(Xe>=h);Ut++)Ae.push({data:D==null?void 0:D[Ut],index:Ut,offset:Xe,size:Qe}),Xe+=Qe+k}}),je=Nx(I,vc),it=Nx(I,Ec);if(Me.length>0&&(je>0||it>0)){const Ae=Me[0],Ee=Me[Me.length-1];if(je>0&&Ae.index>Oe){const ye=Math.min(je,Ae.index-Oe),Xe=[];let Ye=Ae.offset;for(let Qe=Ae.index-1;Qe>=Ae.index-ye;Qe--){const Or=(z=(U=To(be,Qe,Qe)[0])==null?void 0:U.value)!=null?z:Ae.size;Ye-=Or+k,Xe.unshift({data:D==null?void 0:D[Qe],index:Qe,offset:Ye,size:Or})}Me.unshift(...Xe)}if(it>0&&Ee.index<ve){const ye=Math.min(it,ve-Ee.index);let Xe=Ee.offset+Ee.size+k;for(let Ye=Ee.index+1;Ye<=Ee.index+ye;Ye++){const Qe=(j=(H=To(be,Ye,Ye)[0])==null?void 0:H.value)!=null?j:Ee.size;Me.push({data:D==null?void 0:D[Ye],index:Ye,offset:Xe,size:Qe}),Xe+=Qe+k}}}return qu(Me,de,y,k,Q,_)}),fe(P=>P!==null),rt()),mm);ce(W(e,fe(em),ne(P=>P==null?void 0:P.length)),s),ce(W(S,ne(P=>P.topListHeight)),d),ce(d,i),ce(W(S,ne(P=>[P.top,P.bottom])),o),ce(W(S,ne(P=>P.items)),v);const T=hr(W(S,fe(({items:P})=>P.length>0),Te(s,e),fe(([{items:P},h])=>P[P.length-1].originalIndex===h-1),ne(([,P,h])=>[P-1,h]),rt(mc),ne(([P])=>P))),O=hr(W(S,jn(200),fe(({items:P,topItems:h})=>P.length>0&&P[0].originalIndex===h.length),ne(({items:P})=>P[0].index),rt())),L=hr(W(S,fe(({items:P})=>P.length>0),ne(({items:P})=>{let h=0,y=P.length-1;for(;P[h].type==="group"&&h<y;)h++;for(;P[y].type==="group"&&y>h;)y--;return{endIndex:P[y].index,startIndex:P[h].index}}),rt(Cx)));return{endReached:T,initialItemCount:E,itemsRendered:v,listState:S,minOverscanItemCount:w,rangeChanged:L,startReached:O,topItemsIndexes:g,...f}},tt(hn,Ix,fm,yc,bc,wc,ws,cm),{singleton:!0}),Lx=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:n},{listState:s}])=>{const a=De(),o=zt(W(vt(r,e,n,t,s),ne(([i,c,l,u,d])=>i+c+l+u+d.offsetBottom+d.bottom)),0);return ce(me(o),a),{totalListHeight:o,totalListHeightChanged:a}},tt(Vt,ha),{singleton:!0}),qj=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const r=Y(!1),n=zt(W(vt(r,e,t),fe(([s])=>s),ne(([,s,a])=>Math.max(0,s-a)),jn(0),rt()),0);return{alignToBottom:r,paddingTopAddition:n}},tt(Vt,Lx),{singleton:!0}),zx=Ge(()=>({context:Y(null)})),Kj=({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,Rx=Ge(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:o,scrollTop:i,viewportHeight:c},{scrollToIndex:l}])=>{const u=De();return ce(W(u,Te(t,c,r,a,s,n,i),Te(e),ne(([[d,f,m,b,g,E,v,w],S])=>{const{align:T,behavior:O,calculateViewLocation:L=Kj,done:P,...h}=d,y=Sx(d,f,b-1),x=hc(y,f.offsetTree,S)+g+E,A=x+Yr(f.sizeTree,y)[1],B=w+E,F=w+m-v,_=L({itemBottom:A,itemTop:x,locationParams:{align:T,behavior:O,...h},viewportBottom:F,viewportTop:B});return _?P&&Kr(W(o,fe(k=>!k),pa(at(o)?1:2)),P):P&&P(),_}),fe(d=>d!==null)),l),{scrollIntoView:u}},tt(hn,Vt,bc,ha,gs),{singleton:!0});function Hx(e){return e?e==="smooth"?"smooth":"auto":!1}const Yj=(e,t)=>typeof e=="function"?Hx(e(t)):t&&Hx(e),Zj=Ge(([{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:m}])=>{const b=Y(!1),g=De();let E=null;function v(O){Ce(o,{align:"end",behavior:O,index:"LAST"})}Ve(W(vt(W(me(t),pa(1)),c),Te(me(b),a,i,d),ne(([[O,L],P,h,y,x])=>{let A=L&&y,B="auto";return A&&(B=Yj(P,h||x),A=A&&!!B),{followOutputBehavior:B,shouldFollow:A,totalCount:O}}),fe(({shouldFollow:O})=>O)),({followOutputBehavior:O,totalCount:L})=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("following output to ",{totalCount:L},rr.DEBUG),v(O)}):E=Kr(e,()=>{at(u)("following output to ",{totalCount:L},rr.DEBUG),v(O),E=null})});function w(O){const L=Kr(s,P=>{O&&!P.atBottom&&P.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(at(u)("scrolling to bottom due to increased size",{},rr.DEBUG),v("auto"))});setTimeout(L,100)}Ve(W(vt(me(b),t,l),fe(([O,,L])=>O&&L),mn(({value:O},[,L])=>({refreshed:O===L,value:L}),{refreshed:!1,value:0}),fe(({refreshed:O})=>O),Te(b,t)),([,O])=>{at(i)&&w(O!==!1)}),Ve(g,()=>{w(at(b)!==!1)}),Ve(vt(me(b),s),([O,L])=>{O&&!L.atBottom&&L.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=Y(null),T=De();return ce(rm(W(me(n),ne(O=>{var L;return(L=O==null?void 0:O.length)!=null?L:0})),W(me(t))),T),Ve(W(vt(W(T,pa(1)),c),Te(me(S),i,d,f),ne(([[O,L],P,h,y,x])=>L&&h&&(P==null?void 0:P({context:x,totalCount:O,scrollingInProgress:y}))),fe(O=>!!O),jn(0)),O=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("scrolling into view",{}),Ce(m,O)}):E=Kr(e,()=>{at(u)("scrolling into view",{}),Ce(m,O),E=null})}),{autoscrollToBottom:g,followOutput:b,scrollIntoViewOnChange:S}},tt(hn,wc,bc,yc,ws,gs,Vt,zx,Rx)),Xj=Ge(([{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),ne(([[,c],l,u,d,f,m=[]])=>_x(c,l,u,d,f,m))),o),{}),tt(hn,yc,ha,ws),{singleton:!0}),Qj=Ge(([{didMount:e},{scrollTo:t},{listState:r}])=>{const n=Y(0);return Ve(W(e,Te(n),fe(([,s])=>s!==0),ne(([,s])=>({top:s}))),s=>{Kr(W(r,pa(1),fe(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ce(t,s)})})}),{initialScrollTop:n}},tt(ws,Vt,ha),{singleton:!0}),$x=Ge(([{scrollVelocity:e}])=>{const t=Y(!1),r=De(),n=Y(!1);return ce(W(e,Te(n,t,r),fe(([s,a])=>!!a),ne(([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),Ve(W(vt(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(wc),{singleton:!0}),hm=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const r=De(),n=De(),s=De(),a=Y(!1),o=Y(void 0);return ce(W(vt(r,n),ne(([{scrollHeight:i,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),ce(W(t,Te(n),ne(([i,{offsetTop:c}])=>({...i,top:i.top+c}))),s),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:n}},tt(Vt)),Jj=Ge(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:o,windowScrollContainerState:i,windowViewportRect:c}])=>{const l=De(),u=Y(void 0),d=Y(null),f=Y(null);return ce(i,d),ce(c,f),Ve(W(l,Te(t,n,o,d,f,r)),([m,b,g,E,v,w,S])=>{const T=Mj(b.sizeTree);E&&v!==null&&w!==null&&(g=v.scrollTop-w.offsetTop),g-=S,m({ranges:T,scrollTop:g})}),ce(W(u,fe(em),ne(eV)),s),ce(W(a,Te(u),fe(([,m])=>m!==void 0),rt(),ne(([,m])=>m.ranges)),e),{getState:l,restoreStateFrom:u}},tt(hn,Vt,yc,ws,hm));function eV(e){return{align:"start",index:0,offset:e.scrollTop}}const tV=Ge(([{topItemsIndexes:e}])=>{const t=Y(0);return ce(W(t,fe(r=>r>=0),ne(r=>Array.from({length:r}).map((n,s)=>s))),e),{topItemCount:t}},tt(ha));function Gx(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const rV=Gx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),nV=Ge(([{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:m},{recalcInProgress:b}])=>{const g=hr(W(c,Te(o),mn(([,v,w,S],[{bottom:T,items:O,offsetBottom:L,totalCount:P},h])=>{const y=T+L;let x=0;return w===P&&v.length>0&&O.length>0&&(O[0].originalIndex===0&&v[0].originalIndex===0||(x=y-S,x!==0&&(x+=h))),[x,O,P,y]},[0,[],0,0]),fe(([v])=>v!==0),Te(n,i,r,s,m,b),fe(([,v,w,S,,,T])=>!T&&!S&&v!==0&&w===gc),ne(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},rr.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 Ve(W(g,Te(e,a)),([v,w,S])=>{S&&rV()?Ce(e,w-v):E(-v)}),Ve(W(vt(zt(a,!1),e,b),fe(([v,w,S])=>!v&&!S&&w!==0),ne(([v,w])=>w),jn(1)),E),ce(W(d,ne(v=>({top:-v}))),t),Ve(W(l,Te(f,u),ne(([v,{groupIndices:w,lastSize:S,sizeTree:T},O])=>{function L(P){return P*(S+O)}if(w.length===0)return L(v);{let P=0;const h=fc(T,0);let y=0,x=0;for(;y<v;){y++,P+=h;let A=w.length===x+1?1/0:w[x+1]-w[x]-1;y+A>v&&(P-=h,A=v-y+1),y+=A,P+=L(A),x++}return P}})),v=>{Ce(e,v),requestAnimationFrame(()=>{Ce(t,{top:v}),requestAnimationFrame(()=>{Ce(e,0),Ce(b,!1)})})}),{deviation:e}},tt(Vt,wc,ha,hn,gs,cm)),sV=Ge(([e,t,r,n,s,a,o,i,c,l,u])=>({...e,...t,...r,...n,...s,...a,...o,...i,...c,...l,...u}),tt(fm,Xj,ws,$x,Lx,Qj,qj,hm,Rx,gs,zx)),jx=Ge(([{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:m},{initialItemFinalLocationReached:b,initialTopMostItemIndex:g,scrolledToInitialItem:E},v,w,S,T,{scrollToIndex:O},L,{topItemCount:P},{groupCounts:h},y])=>{const{listState:x,minOverscanItemCount:A,topItemsIndexes:B,rangeChanged:F,..._}=T;return ce(F,y.scrollSeekRangeChanged),ce(W(y.windowViewportRect,ne(k=>k.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:n,fixedGroupHeight:s,gap:a,groupCounts:h,heightEstimates:i,initialItemFinalLocationReached:b,initialTopMostItemIndex:g,scrolledToInitialItem:E,sizeRanges:l,topItemCount:P,topItemsIndexes:B,totalCount:f,...S,groupIndices:o,itemSize:c,listState:x,minOverscanItemCount:A,scrollToIndex:O,statefulTotalCount:d,trackItemSizes:m,rangeChanged:F,..._,...y,...v,sizes:u,...w}},tt(hn,yc,Vt,Jj,Zj,ha,bc,nV,tV,Ix,sV));function aV(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 Ku=typeof document<"u"?M.useLayoutEffect:M.useEffect;function Vx(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 S=E[t.required[w]];Ce(S,v[w])}for(const w of s)if(w in v){const S=E[t.optional[w]];Ce(S,v[w])}E.propsReady&&Ce(E.propsReady,!0)}function l(E){return a.reduce((v,w)=>(v[w]=S=>{const T=E[t.methods[w]];Ce(T,S)},v),{})}function u(E){return o.reduce((v,w)=>(v[w]=vj(E[t.events[w]]),v),{})}const d=M.forwardRef((E,v)=>{const{children:w,...S}=E,[T]=M.useState(()=>Gu(kj(e),P=>{c(P,S)})),[O]=M.useState(fx(u,T));Ku(()=>{for(const P of o)P in S&&Ve(O[P],S[P]);return()=>{Object.values(O).map(tm)}},[S,O,T]),Ku(()=>{c(T,S)}),M.useImperativeHandle(v,dx(l(T)));const L=r;return C.jsx(i.Provider,{value:T,children:r?C.jsx(L,{...aV([...n,...s,...o],S),children:w}):w})}),f=E=>{const v=M.useContext(i);return M.useCallback(w=>{Ce(v[E],w)},[v,E])},m=E=>{const v=M.useContext(i)[E],w=M.useCallback(S=>Ve(v,S),[v]);return M.useSyncExternalStore(w,()=>at(v),()=>at(v))},b=E=>{const v=M.useContext(i)[E],[w,S]=M.useState(fx(at,v));return Ku(()=>Ve(v,T=>{T!==w&&S(dx(T))}),[v,w]),w},g=M.version.startsWith("18")?m:b;return{Component:d,useEmitter:(E,v)=>{const w=M.useContext(i)[E];Ku(()=>Ve(w,v),[v,w])},useEmitterValue:g,usePublisher:f}}const Wx=M.createContext(void 0),qx=M.createContext(void 0),Kx=typeof document<"u"?M.useLayoutEffect:M.useEffect;function bm(e){return"self"in e}function oV(e){return"body"in e}function Yx(e,t,r,n=ko,s,a){const o=M.useRef(null),i=M.useRef(null),c=M.useRef(null),l=M.useCallback(f=>{let m,b,g;const E=f.target;if(oV(E)||bm(E)){const w=bm(E)?E:E.defaultView;g=a?w.scrollX:w.scrollY,m=a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=a?w.innerWidth:w.innerHeight}else g=a?E.scrollLeft:E.scrollTop,m=a?E.scrollWidth:E.scrollHeight,b=a?E.offsetWidth:E.offsetHeight;const v=()=>{e({scrollHeight:m,scrollTop:Math.max(g,0),viewportHeight:b})};f.suppressFlushSync?v():Os.flushSync(v),i.current!==null&&(g===i.current||g<=0||g===m-b)&&(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 m=o.current;if(!m||(a?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const b=f.behavior==="smooth";let g,E,v;bm(m)?(E=Math.max(xs(m.document.documentElement,a?"width":"height"),a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),g=a?m.innerWidth:m.innerHeight,v=a?window.scrollX:window.scrollY):(E=m[a?"scrollWidth":"scrollHeight"],g=xs(m,a?"width":"height"),v=m[a?"scrollLeft":"scrollTop"]);const w=E-g;if(f.top=Math.ceil(Math.max(Math.min(w,f.top),0)),Fx(g,E)||f.top===v){e({scrollHeight:E,scrollTop:v,viewportHeight:g}),b&&t(!0);return}b?(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}),m.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 ym="-webkit-sticky",Zx="sticky",gm=Gx(()=>{if(typeof document>"u")return Zx;const e=document.createElement("div");return e.style.position=ym,e.style.position===ym?ym:Zx});function xm(e){return e}const iV=Ge(()=>{const e=Y(i=>`Item ${i}`),t=Y(i=>`Group ${i}`),r=Y({}),n=Y(xm),s=Y("div"),a=Y(ko),o=(i,c=null)=>zt(W(r,ne(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")}}),cV=Ge(([e,t])=>({...e,...t}),tt(jx,iV)),lV=({height:e})=>C.jsx("div",{style:{height:e}}),uV={overflowAnchor:"none",position:gm(),zIndex:1},Xx={overflowAnchor:"none"},dV={...Xx,display:"inline-block",height:"100%"},Qx=M.memo(function({showTopList:e=!1}){const t=xe("listState"),r=Pr("sizeRanges"),n=xe("useWindowScroll"),s=xe("customScrollParent"),a=Pr("windowScrollContainerState"),o=Pr("scrollContainerState"),i=s||n?a:o,c=xe("itemContent"),l=xe("context"),u=xe("groupContent"),d=xe("trackItemSizes"),f=xe("itemSize"),m=xe("log"),b=Pr("gap"),g=xe("horizontalDirection"),{callbackRef:E}=Aj(r,f,d,e?ko:i,m,b,s,g,xe("skipAnimationFrameInResizeObserver")),[v,w]=M.useState(0);wm("deviation",_=>{v!==_&&w(_)});const S=xe("EmptyPlaceholder"),T=xe("ScrollSeekPlaceholder")||lV,O=xe("ListComponent"),L=xe("ItemComponent"),P=xe("GroupComponent"),h=xe("computeItemKey"),y=xe("isSeeking"),x=xe("groupIndices").length>0,A=xe("alignToBottom"),B=xe("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:A?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:A?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?C.jsx(S,{...Rt(S,l)}):C.jsx(O,{...Rt(O,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,I=h(k+t.firstItemIndex,_.data,l);return y?M.createElement(T,{...Rt(T,l),height:_.size,index:_.index,key:I,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?M.createElement(P,{...Rt(P,l),"data-index":k,"data-item-index":_.index,"data-known-size":_.size,key:I,style:uV},u(_.index,l)):M.createElement(L,{...Rt(L,l),...hV(L,_.data),"data-index":k,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:I,style:g?dV:Xx},x?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),pV={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},fV={outline:"none",overflowX:"auto",position:"relative"},Yu=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),mV={position:gm(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function hV(e,t){return{item:typeof e=="string"?void 0:t}}const bV=M.memo(function(){const e=xe("HeaderComponent"),t=Pr("headerHeight"),r=xe("HeaderFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,xe("skipAnimationFrameInResizeObserver")),s=xe("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null}),yV=M.memo(function(){const e=xe("FooterComponent"),t=Pr("footerHeight"),r=xe("HeaderFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,xe("skipAnimationFrameInResizeObserver")),s=xe("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null});function Jx({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:m,scrollToCallback:b}=Yx(i,l,c,u,void 0,d);return e("scrollTo",b),e("scrollBy",f),C.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...d?fV:pV,...s},tabIndex:0,...o,...Rt(c,a),children:n})})}function e5({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"),m=M.useRef(null),b=t("scrollerRef"),{scrollByCallback:g,scrollerRef:E,scrollToCallback:v}=Yx(i,l,c,b,f);return Kx(()=>{var w;return E.current=f||((w=m.current)==null?void 0:w.ownerDocument.defaultView),()=>{E.current=null}},[E,f]),e("windowScrollTo",v),e("scrollBy",g),C.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+d}:{}},...o,...Rt(c,a),children:n})})}const gV=({children:e})=>{const t=M.useContext(Wx),r=Pr("viewportHeight"),n=Pr("fixedItemHeight"),s=xe("alignToBottom"),a=xe("horizontalDirection"),o=M.useMemo(()=>px(r,c=>xs(c,a?"width":"height")),[r,a]),i=fa(o,!0,xe("skipAnimationFrameInResizeObserver"));return M.useEffect(()=>{t&&(r(t.viewportHeight),n(t.itemHeight))},[t,r,n]),C.jsx("div",{"data-viewport-type":"element",ref:i,style:Yu(s),children:e})},xV=({children:e})=>{const t=M.useContext(Wx),r=Pr("windowViewportRect"),n=Pr("fixedItemHeight"),s=xe("customScrollParent"),a=yx(r,s,xe("skipAnimationFrameInResizeObserver")),o=xe("alignToBottom");return M.useEffect(()=>{t&&(n(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,n]),C.jsx("div",{"data-viewport-type":"window",ref:a,style:Yu(o),children:e})},wV=({children:e})=>{const t=xe("TopItemListComponent")||"div",r=xe("headerHeight"),n={...mV,marginTop:`${r}px`},s=xe("context");return C.jsx(t,{style:n,...Rt(t,s),children:e})},vV=M.memo(function(e){const t=xe("useWindowScroll"),r=xe("topItemsIndexes").length>0,n=xe("customScrollParent"),s=xe("context");return C.jsxs(n||t?CV:kV,{...e,context:s,children:[r&&C.jsx(wV,{children:C.jsx(Qx,{showTopList:!0})}),C.jsxs(n||t?xV:gV,{children:[C.jsx(bV,{}),C.jsx(Qx,{}),C.jsx(yV,{})]})]})}),{Component:EV,useEmitter:wm,useEmitterValue:xe,usePublisher:Pr}=Vx(cV,{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"}},vV),kV=Jx({useEmitter:wm,useEmitterValue:xe,usePublisher:Pr}),CV=e5({useEmitter:wm,useEmitterValue:xe,usePublisher:Pr}),t5=EV;tt(jx,Ge(()=>{const e=Y(l=>C.jsxs("td",{children:["Item $",l]})),t=Y(null),r=Y(l=>C.jsxs("td",{colSpan:1e3,children:["Group ",l]})),n=Y(null),s=Y(null),a=Y({}),o=Y(xm),i=Y(ko),c=(l,u=null)=>zt(W(a,ne(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")}})),gm();const r5={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},TV={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:n5,floor:Zu,max:kc,min:vm,round:s5}=Math;function a5(e,t,r){return Array.from({length:t-e+1}).map((n,s)=>({data:r===null?null:r[s+e],index:s+e}))}function AV(e){return{...TV,items:e}}function Xu(e,t){return e&&e.width===t.width&&e.height===t.height}function SV(e,t){return e&&e.column===t.column&&e.row===t.row}const PV=Ge(([{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,m,{didMount:b,propsReady:g},{customScrollParent:E,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:T},O])=>{const L=Y(0),P=Y(0),h=Y(r5),y=Y({height:0,width:0}),x=Y({height:0,width:0}),A=De(),B=De(),F=Y(0),_=Y(null),k=Y({column:0,row:0}),I=De(),D=De(),U=Y(!1),z=Y(0),H=Y(!0),j=Y(!1),Q=Y(!1);Ve(W(b,Te(z),fe(([X,ve])=>!!ve)),()=>{Ce(H,!1)}),Ve(W(vt(b,H,x,y,z,j),fe(([X,ve,Me,je,,it])=>X&&!ve&&Me.height!==0&&je.height!==0&&!it)),([,,,,X])=>{Ce(j,!0),dm(1,()=>{Ce(A,X)}),Kr(W(l),()=>{Ce(t,[0,0]),Ce(H,!0)})}),ce(W(D,fe(X=>X!=null&&X.scrollTop>0),fn(0)),P),Ve(W(b,Te(D),fe(([,X])=>X!=null)),([,X])=>{X&&(Ce(y,X.viewport),Ce(x,X.item),Ce(k,X.gap),X.scrollTop>0&&(Ce(U,!0),Kr(W(l,pa(1)),ve=>{Ce(U,!1)}),Ce(c,{top:X.scrollTop})))}),ce(W(y,ne(({height:X})=>X)),d),ce(W(vt(me(y,Xu),me(x,Xu),me(k,(X,ve)=>X&&X.column===ve.column&&X.row===ve.row),me(l)),ne(([X,ve,Me,je])=>({gap:Me,item:ve,scrollTop:je,viewport:X}))),I),ce(W(vt(me(L),n,me(k,SV),me(x,Xu),me(y,Xu),me(_),me(P),me(U),me(H),me(z)),fe(([,,,,,,,X])=>!X),ne(([X,[ve,Me],je,it,Ae,Ee,ye,,Xe,Ye])=>{const{column:Qe,row:Or}=je,{height:Ut,width:Sm}=it,{width:H5}=Ae;if(ye===0&&(X===0||H5===0))return r5;if(Sm===0){const W5=pm(Ye,X),nq=W5+Math.max(ye-1,0);return AV(a5(W5,nq,Ee))}const ed=o5(H5,Sm,Qe);let Lo,Aa;Xe?ve===0&&Me===0&&ye>0?(Lo=0,Aa=ye-1):(Lo=ed*Zu((ve+Or)/(Ut+Or)),Aa=ed*n5((Me+Or)/(Ut+Or))-1,Aa=vm(X-1,kc(Aa,ed-1)),Lo=vm(Aa,kc(0,Lo))):(Lo=0,Aa=-1);const $5=a5(Lo,Aa,Ee),{bottom:G5,top:j5}=i5(Ae,je,it,$5),V5=n5(X/ed),rq=V5*Ut+(V5-1)*Or-G5;return{bottom:G5,itemHeight:Ut,items:$5,itemWidth:Sm,offsetBottom:rq,offsetTop:j5,top:j5}})),h),ce(W(_,fe(X=>X!==null),ne(X=>X.length)),L),ce(W(vt(y,x,h,k),fe(([X,ve,{items:Me}])=>Me.length>0&&ve.height!==0&&X.height!==0),ne(([X,ve,{items:Me},je])=>{const{bottom:it,top:Ae}=i5(X,je,ve,Me);return[Ae,it]}),rt(mc)),t);const pe=Y(!1);ce(W(l,Te(pe),ne(([X,ve])=>ve||X!==0)),pe);const be=hr(W(vt(h,L),fe(([{items:X}])=>X.length>0),Te(pe),fe(([[X,ve],Me])=>{const je=X.items[X.items.length-1].index===ve-1;return(Me||X.bottom>0&&X.itemHeight>0&&X.offsetBottom===0&&X.items.length===ve)&&je}),ne(([[,X]])=>X-1),rt())),ie=hr(W(me(h),fe(({items:X})=>X.length>0&&X[0].index===0),fn(0),rt())),de=hr(W(me(h),Te(U),fe(([{items:X},ve])=>X.length>0&&!ve),ne(([{items:X}])=>({endIndex:X[X.length-1].index,startIndex:X[0].index})),rt(Cx),jn(0)));ce(de,m.scrollSeekRangeChanged),ce(W(A,Te(y,x,L,k),ne(([X,ve,Me,je,it])=>{const Ae=Bx(X),{align:Ee,behavior:ye,offset:Xe}=Ae;let Ye=Ae.index;Ye==="LAST"&&(Ye=je-1),Ye=kc(0,Ye,vm(je-1,Ye));let Qe=Em(ve,it,Me,Ye);return Ee==="end"?Qe=s5(Qe-ve.height+Me.height):Ee==="center"&&(Qe=s5(Qe-ve.height/2+Me.height/2)),Xe&&(Qe+=Xe),{behavior:ye,top:Qe}})),c);const Oe=zt(W(h,ne(X=>X.offsetBottom+X.bottom)),0);return ce(W(T,ne(X=>({height:X.visibleHeight,width:X.visibleWidth}))),y),{customScrollParent:E,data:_,deviation:F,footerHeight:s,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:P,itemDimensions:x,overscan:r,restoreStateFrom:D,scrollBy:o,scrollContainerState:i,scrollHeight:B,scrollTo:c,scrollToIndex:A,scrollTop:l,smoothScrollTargetReached:u,totalCount:L,useWindowScroll:v,viewportDimensions:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:T,...m,gridState:h,horizontalDirection:Q,initialTopMostItemIndex:z,totalListHeight:Oe,...f,endReached:be,propsReady:g,rangeChanged:de,startReached:ie,stateChanged:I,stateRestoreInProgress:U,...O}},tt(fm,Vt,wc,$x,ws,hm,gs));function o5(e,t,r){return kc(1,Zu((e+r)/(Zu(t)+r)))}function i5(e,t,r,n){const{height:s}=r;if(s===void 0||n.length===0)return{bottom:0,top:0};const a=Em(e,t,r,n[0].index);return{bottom:Em(e,t,r,n[n.length-1].index)+s,top:a}}function Em(e,t,r,n){const s=o5(e.width,r.width,t.column),a=Zu(n/s),o=a*r.height+kc(0,a-1)*t.row;return o>0?o+t.row:o}const IV=Ge(()=>{const e=Y(d=>`Item ${d}`),t=Y({}),r=Y(null),n=Y("virtuoso-grid-item"),s=Y("virtuoso-grid-list"),a=Y(xm),o=Y("div"),i=Y(ko),c=(d,f=null)=>zt(W(t,ne(m=>m[d]),rt()),f),l=Y(!1),u=Y(!1);return ce(me(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")}}),BV=Ge(([e,t])=>({...e,...t}),tt(PV,IV)),FV=M.memo(function(){const e=ot("gridState"),t=ot("listClassName"),r=ot("itemClassName"),n=ot("itemContent"),s=ot("computeItemKey"),a=ot("isSeeking"),o=Ir("scrollHeight"),i=ot("ItemComponent"),c=ot("ListComponent"),l=ot("ScrollSeekPlaceholder"),u=ot("context"),d=Ir("itemDimensions"),f=Ir("gap"),m=ot("log"),b=ot("stateRestoreInProgress"),g=Ir("reportReadyState"),E=fa(M.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;o(w);const S=v.firstChild;if(S){const{height:T,width:O}=S.getBoundingClientRect();d({height:T,width:O})}f({column:l5("column-gap",getComputedStyle(v).columnGap,m),row:l5("row-gap",getComputedStyle(v).rowGap,m)})},[o,d,f,m]),!0,!1);return Kx(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),b?null:C.jsx(c,{className:t,ref:E,...Rt(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?C.jsx(l,{...Rt(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},w):M.createElement(i,{...Rt(i,u),className:r,"data-index":v.index,key:w},n(v.index,v.data,u))})})}),OV=M.memo(function(){const e=ot("HeaderComponent"),t=Ir("headerHeight"),r=ot("headerFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,!1),s=ot("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null}),UV=M.memo(function(){const e=ot("FooterComponent"),t=Ir("footerHeight"),r=ot("headerFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,!1),s=ot("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null}),DV=({children:e})=>{const t=M.useContext(qx),r=Ir("itemDimensions"),n=Ir("viewportDimensions"),s=fa(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]),C.jsx("div",{ref:s,style:Yu(!1),children:e})},_V=({children:e})=>{const t=M.useContext(qx),r=Ir("windowViewportRect"),n=Ir("itemDimensions"),s=ot("customScrollParent"),a=yx(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]),C.jsx("div",{ref:a,style:Yu(!1),children:e})},MV=M.memo(function({...e}){const t=ot("useWindowScroll"),r=ot("customScrollParent"),n=r||t?LV:NV,s=r||t?_V:DV,a=ot("context");return C.jsx(n,{...e,...Rt(n,a),children:C.jsxs(s,{children:[C.jsx(OV,{}),C.jsx(FV,{}),C.jsx(UV,{})]})})}),{useEmitter:c5,useEmitterValue:ot,usePublisher:Ir}=Vx(BV,{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"}},MV),NV=Jx({useEmitter:c5,useEmitterValue:ot,usePublisher:Ir}),LV=e5({useEmitter:c5,useEmitterValue:ot,usePublisher:Ir});function l5(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,rr.WARN),t==="normal"?0:parseInt(t??"0",10)}var km={},u5;function zV(){if(u5)return km;u5=1;var e=bu.GenIcon;return km.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)},km}var RV=zV();function d5({logo:e,className:t="",style:r={},alt:n="Token logo"}){const[s,a]=M.useState(!1);return M.useEffect(()=>{a(!1)},[e]),e&&!s?C.jsx("img",{alt:n,style:r,onError:()=>a(!0),className:`twap-token-logo ${t}`,src:e}):C.jsx(RV.AiFillQuestionCircle,{style:{width:20,height:20},className:"twap-token-svg"})}var Cm={},p5;function HV(){if(p5)return Cm;p5=1;var e=bu.GenIcon;return Cm.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)},Cm}var f5=HV();const $V=({count:e})=>{const t=Ie(),r=ee(n=>n.updateState);return C.jsxs("div",{className:"twap-orders__selected-order-fills-button",onClick:()=>r({showSelectedOrderFills:!0}),children:[C.jsxs("p",{children:[t("orderFills")," ",C.jsxs("span",{className:"twap-orders__selected-order-fills-button-count",children:["(",e,")"]})]}),C.jsx(V6.IoIosArrowDown,{})]})},m5=({token:e})=>{const{components:t}=re();return C.jsxs("div",{className:"twap-orders__selected-order-fills-token",children:[t.TokenLogo?C.jsx(t.TokenLogo,{token:e}):C.jsx(d5,{logo:e==null?void 0:e.logoUrl}),C.jsx("p",{className:"twap-orders__selected-order-fills-token-symbol",children:e==null?void 0:e.symbol})]})},GV=({srcToken:e,dstToken:t})=>C.jsxs("div",{className:"twap-orders__selected-order-fills-tokens",children:[C.jsx(m5,{token:e}),C.jsx("span",{className:"twap-orders__selected-order-fills-token-separator",children:C.jsx(f5.HiArrowRight,{})}),C.jsx(m5,{token:t})]}),jV=({fill:e,index:t,srcToken:r,dstToken:n})=>{const s=qr(r==null?void 0:r.decimals,e.inAmount),a=qr(n==null?void 0:n.decimals,e.outAmount),o=Ru(e.timestamp),i=zu(e.txHash),c=Ie();return C.jsxs(he,{className:"twap-fills-view__item",children:[C.jsx(he.DetailRow,{title:c("fillIndex"),className:"twap-fills-view__item-index",children:C.jsx("p",{children:`#${t}`})}),C.jsx(he.DetailRow,{title:c("fillTimestamp"),className:"twap-fills-view__item-date",children:o}),C.jsxs(he.DetailRow,{title:c("fillAmountOut"),className:"twap-fills-view__item-amount-in",children:[C.jsx(pn,{value:s})," ",(r==null?void 0:r.symbol)??""]}),C.jsxs(he.DetailRow,{title:c("fillAmountReceived"),className:"twap-fills-view__item-amount-out",children:[C.jsx(pn,{value:a})," ",(n==null?void 0:n.symbol)??""]}),e.txHash&&C.jsx(he.DetailRow,{title:c("fillTransactionHash"),className:"twap-fills-view__item-tx",children:C.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:e.txHash,children:Nl(e.txHash)})})]})},VV=({order:e})=>{var n;const t=Ie(),r=((n=e.original)==null?void 0:n.fills)??[];return C.jsxs("div",{className:"twap-orders__selected-order-fills",children:[C.jsx(GV,{srcToken:e.srcToken,dstToken:e.dstToken}),r.length===0?C.jsx("p",{className:"twap-orders__selected-order-fills-empty",children:t("noFills")}):C.jsx("div",{className:"twap-orders__selected-order-fills-list",children:C.jsx(t5,{style:{height:"100%"},totalCount:r.length,itemContent:s=>{const a=r[s];return a?C.jsx(jV,{fill:a,index:s+1,srcToken:e.srcToken,dstToken:e.dstToken}):null}})})]})},h5=M.createContext({}),Ht=()=>M.useContext(h5),WV=()=>{const e=ee(f=>f.state.selectedOrderID),t=ex(e),r=Ie(),[n,s]=M.useState("panel1"),a=ee(f=>f.updateState),o=ee(f=>f.state.showSelectedOrderFills),{components:i}=re(),c=i.TokenLogo;M.useEffect(()=>{s("panel1"),a({showSelectedOrderFills:!1})},[t==null?void 0:t.id.value]);const l=f=>{s(n===f?!1:f)};if(!t)return null;const u=t.fills??[],d=o?C.jsx(VV,{order:t}):C.jsxs(C.Fragment,{children:[C.jsx(p1,{SrcTokenLogo:c&&C.jsx(c,{token:t.srcToken}),DstTokenLogo:c&&C.jsx(c,{token:t.dstToken}),fromTitle:r("from"),inToken:t.srcToken,toTitle:r("to"),outToken:t.dstToken}),C.jsx(he.Container,{children:C.jsxs("div",{className:"twap-orders__selected-order-bottom",children:[C.jsxs("div",{className:"twap-orders__selected-order-accordions",children:[C.jsx(b5,{title:r("executionSummary"),onClick:()=>l("panel1"),expanded:n==="panel1",children:C.jsx(tW,{})}),C.jsx(b5,{title:r("orderInfo"),expanded:n==="panel2",onClick:()=>l("panel2"),children:C.jsx(qV,{})}),C.jsx($V,{count:u.length})]}),C.jsx(nW,{})]})})]});return C.jsx(h5.Provider,{value:{order:t},children:C.jsx("div",{className:`twap-orders__selected-order ${`twap-orders__selected-order-${t.original.status.toLowerCase()}`}`,children:d})})},b5=({expanded:e,onClick:t,children:r,title:n})=>C.jsxs("div",{className:"twap-orders__selected-order-accordion",children:[C.jsxs("div",{onClick:t,className:"twap-orders__selected-order-accordion-trigger",children:[C.jsx("p",{children:n}),C.jsx(V6.IoIosArrowDown,{style:{transform:e?"rotate(180deg)":"rotate(0deg)"}})]}),e&&C.jsx("div",{className:"twap-orders__selected-order-accordion-details",children:r})]}),qV=()=>C.jsxs(he,{children:[C.jsx(eW,{}),C.jsx(sW,{}),C.jsx(XV,{}),C.jsx(aW,{}),C.jsx(KV,{}),C.jsx(YV,{}),C.jsx(ZV,{}),C.jsx(QV,{}),C.jsx(JV,{}),C.jsx(uW,{}),C.jsx(he.Recipient,{})]}),KV=()=>{const{order:e}=Ht();return C.jsx(he.TradeSize,{tradeSize:e.sizePerTrade.value,srcToken:e.srcToken,label:e.sizePerTrade.label,tooltip:e.sizePerTrade.tooltip,trades:e.totalTrades.value})},YV=()=>{const{order:e}=Ht();return C.jsx(he.TradesAmount,{trades:e.totalTrades.value,label:e.totalTrades.label,tooltip:e.totalTrades.tooltip})},ZV=()=>{const{order:e}=Ht();return C.jsx(he.MinDestAmount,{dstToken:e.dstToken,dstMinAmountOut:e.minDestAmountPerTrade.value,label:e.minDestAmountPerTrade.label,tooltip:e.minDestAmountPerTrade.tooltip})},XV=()=>{const{order:e}=Ht();return C.jsx(he.Deadline,{deadline:e.deadline.value,label:e.deadline.label,tooltip:e.deadline.tooltip})},QV=()=>{const{order:e}=Ht();return C.jsx(he.TradeInterval,{fillDelayMillis:e.tradeInterval.value,chunks:e.totalTrades.value,label:e.tradeInterval.label,tooltip:e.tradeInterval.tooltip})},JV=()=>{const{order:e}=Ht();return C.jsx(he.Price,{srcToken:e.srcToken,dstToken:e.dstToken,price:e.triggerPrice.value,label:e.triggerPrice.label,tooltip:e.triggerPrice.tooltip})},eW=()=>{const{order:e}=Ht();return C.jsx(he.OrderID,{id:e.id.value||""})},tW=()=>C.jsxs(he,{children:[C.jsx(cW,{}),C.jsx(oW,{}),C.jsx(rW,{}),C.jsx(lW,{}),C.jsx(dW,{})]}),rW=()=>{var t;const{order:e}=Ht();return e.amountOutFilled.value?C.jsx(he.DetailRow,{title:e.amountOutFilled.label,children:C.jsxs("p",{children:[C.jsx(pn,{value:e.amountOutFilled.value})," ",(t=e.dstToken)==null?void 0:t.symbol]})}):null},nW=()=>{const{order:e}=Ht(),t=Ie(),{mutateAsync:r,isPending:n}=lx(),{components:s}=re(),a=s.Button,o=M.useCallback(async()=>r({orders:[e.original]}),[r,e]);return!e||e.original.status!==ut.Open||!a?null:C.jsx(a,{loading:n,onClick:o,disabled:n,className:"twap-cancel-order",text:t("cancelOrder"),children:t("cancelOrder")})},sW=()=>{const{order:e}=Ht(),t=Ie(),r=Ru(e.createdAt.value);return C.jsx(he.DetailRow,{title:t("createdAt")||"",children:C.jsx("p",{children:r})})},aW=()=>{var r;const{order:e}=Ht(),t=Ie();return C.jsx(he.DetailRow,{title:t("amountOut")||"",children:C.jsxs("p",{children:[C.jsx(pn,{value:e.srcAmount.value,decimalScale:3})," ",(r=e.srcToken)==null?void 0:r.symbol]})})},oW=()=>{var t;const{order:e}=Ht();return C.jsx(he.DetailRow,{title:e.amountInFilled.label,children:C.jsxs("p",{children:[C.jsx(pn,{value:e.amountInFilled.value,decimalScale:3})," ",(t=e.srcToken)==null?void 0:t.symbol]})})},iW=()=>{const{order:e}=Ht(),t=Ie();return M.useMemo(()=>{switch(e.original.status){case ut.Open:return t("Open")||"";case ut.Completed:return t("Completed")||"";case ut.Expired:return t("Expired")||"";case ut.Cancelled:return t("Cancelled")||""}},[e.original.status,t])},cW=()=>{const e=Ie(),t=iW();return C.jsx(he.DetailRow,{title:e("status")||"",children:C.jsx("p",{children:t})})},lW=()=>{const{order:e}=Ht();return C.jsx(he.DetailRow,{title:e.progress.label,children:C.jsxs("p",{children:[C.jsx(pn,{value:e.progress.value||0,decimalScale:2}),"%"]})})},uW=()=>{const{order:e}=Ht(),t=Ie();return e.limitPrice.value?C.jsx(he.Price,{label:t("limitPrice")||"",price:e.limitPrice.value,srcToken:e.srcToken,dstToken:e.dstToken,tooltip:e.limitPrice.tooltip}):null},dW=()=>{const{order:e}=Ht();return e.executionPrice.value?C.jsx(he.Price,{label:e.executionPrice.label,price:e.executionPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null},pW=()=>C.jsx("div",{className:"twap-orders__loader",children:C.jsx("p",{children:"Loading..."})}),fW=()=>{const{isLoading:e}=vo(),t=ox(),r=ee(a=>a.state.orderIdsToCancel),n=ee(a=>a.state.cancelOrdersMode),s=fj();return C.jsx(C.Fragment,{children:e?C.jsx(pW,{}):t!=null&&t.length?C.jsx("div",{className:`twap-orders__list ${n?"twap-orders__list-select-mode":""}`,children:C.jsx(t5,{style:{height:"100%"},data:t,itemContent:(a,o)=>C.jsx(mW,{cancelOrdersMode:!!n,selected:(r==null?void 0:r.includes(o.id))||!1,selectOrder:s,order:o},a)})}):C.jsx(hW,{})})},mW=({order:e,selectOrder:t,selected:r,cancelOrdersMode:n})=>{const s=ee(i=>i.updateState),a=Et.useCallback(()=>{s({selectedOrderID:e==null?void 0:e.id})},[s,e==null?void 0:e.id]),o=Et.useCallback(()=>{n?t(e==null?void 0:e.id):a()},[n,t,a,e==null?void 0:e.id]);return C.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:C.jsxs("div",{className:"twap-orders__list-item-content",children:[C.jsx(bW,{order:e}),C.jsx(yW,{value:e.progress||0}),C.jsxs("div",{className:"twap-orders__list-item-tokens",children:[C.jsx(y5,{address:e.srcTokenAddress}),C.jsx(f5.HiArrowRight,{className:"twap-orders__list-item-tokens-arrow"}),C.jsx(y5,{address:e.dstTokenAddress})]})]})})},hW=()=>{const e=ee(s=>s.state.orderHistoryStatusFilter),t=ix(),r=Ie(),n=t(e);return C.jsx("div",{className:"twap-orders__list-empty",children:C.jsx("p",{children:r("noOrders",{status:n})})})},bW=({order:e})=>{const t=e&&e.status,r=nx(e),n=Ru(e.createdAt);return C.jsxs("div",{className:"twap-orders__list-item-header",children:[C.jsxs("p",{className:"twap-orders__list-item-header-title",children:[r," ",C.jsx("span",{children:`(${n})`})]}),C.jsx("p",{className:"twap-orders__list-item-header-status",children:t})]})},y5=e=>{const{useToken:t,components:r}=re(),n=t==null?void 0:t(e.address);return C.jsx("div",{className:"twap-orders__list-item-token",children:n?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"twap-orders__list-item-token-logo",children:r.TokenLogo?C.jsx(r.TokenLogo,{token:n}):C.jsx(d5,{logo:n==null?void 0:n.logoUrl})}),C.jsx("p",{className:"twap-orders__list-item-token-symbol",children:n==null?void 0:n.symbol})]}):C.jsx("div",{})})};function yW(e){return C.jsxs("div",{className:"twap-orders__list-item-progress",children:[C.jsx("div",{className:"twap-orders__list-item-progress-bar",children:C.jsx("div",{className:"twap-orders__list-item-progress-bar-filled",style:{width:`${e.value}%`}})}),C.jsx("div",{className:"twap-orders__list-item-token-progress-label",children:C.jsx("p",{children:`${Math.round(e.value)}%`})})]})}const gW=()=>{const e=ee(r=>r.state.selectedOrderID),t=e!==void 0;return C.jsx("div",{className:`twap-orders ${e!==void 0?"twap-orders__show-selected":""}`,children:t?C.jsx(WV,{}):C.jsx(fW,{})})},xW=e=>{const t=Ie(),{marketPrice:r,typedInputAmount:n}=re();return M.useMemo(()=>{const{isError:a,value:o}=vh(e);if(!(!a||G(n||"0").isZero()||!r))return{type:Dt.MIN_FILL_DELAY,value:o,message:t("minFillDelayError",{fillDelay:`${Vf(o)} ${t("minutes")}`})}},[e,t,n,r])},vs=()=>{const{callbacks:e}=re(),t=ee(a=>a.state.typedFillDelay),r=ee(a=>a.updateState),n=M.useMemo(()=>t||Nc,[t]),s=xW(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}},wW=()=>{const{onChange:e,fillDelay:t,error:r}=vs(),n=Ie(),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")}},Zr=()=>{const{srcToken:e,typedInputAmount:t}=re(),r=Ie(),s=ee(a=>a.state.swapExecution.acceptedSrcAmount)||t;return{amountWei:Q2(e==null?void 0:e.decimals,s),amountUI:s,error:G(s||0).isZero()?r("enterAmount"):void 0}},vW=(e,t)=>{const{module:r,srcUsd1Token:n,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=re(),i=Ie();return M.useMemo(()=>{if(G(o||"0").isZero()||!s||G(n||"0").isZero())return;if(!e)return{type:Dt.MIN_CHUNKS,value:1,message:i("minChunksError",{minChunks:"1"})};const{isError:c}=kh(e,t,r);if(c)return{type:Dt.MAX_CHUNKS,value:t,message:i("maxChunksError",{maxChunks:`${t}`})};const{isError:l,value:u}=Eh(o||"",n||"",a||0);if(l)return{type:Dt.MIN_TRADE_SIZE,value:u,message:i("minTradeSizeError",{minTradeSize:`${u}`})}},[e,t,r,o,n,a,i,s])},Br=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:n}=re(),s=ee(g=>g.state.typedChunks),a=vs().fillDelay,o=ee(g=>g.updateState),{amountWei:i,amountUI:c}=Zr(),l=M.useMemo(()=>dh(a,c||"",t||"",n||0),[c,t,n,a]),u=M.useMemo(()=>uh(l,r,s),[l,s,r]),d=M.useCallback(g=>o({typedChunks:g}),[o]),f=M.useMemo(()=>mh(i||"",u),[i,u]),m=qr(e==null?void 0:e.decimals,f),b=M.useMemo(()=>t?G(m||"0").times(t||0).toString():"0",[m,t]);return{totalTrades:u,maxTrades:l,amountPerTradeUI:m,amountPerTradeWei:f,amountPerTradeUsd:b,onChange:d,error:vW(u,l)}},EW=()=>{const{srcToken:e,dstToken:t}=re(),r=Ie(),{onChange:n,totalTrades:s,amountPerTradeUsd:a,amountPerTradeUI:o,error:i,maxTrades:c,amountPerTradeWei:l}=Br(),u=Ar({value:o}),d=Ar({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}},kW=e=>{const{module:t,marketPrice:r}=re(),n=Ie();return M.useMemo(()=>{const s=xh(t,e),a=wh(e);if(r){if(s.isError)return{type:Dt.MAX_ORDER_DURATION,value:s.value,message:n("maxDurationError",{duration:`${Math.floor(s6(s.value)).toFixed(0)} ${n("days")}`})};if(a.isError)return{type:Dt.MIN_ORDER_DURATION,value:a.value,message:n("minDurationError",{duration:`${Math.floor(Vf(a.value)).toFixed(0)} ${n("minutes")}`})}}},[e,n,t,r])},Tm=()=>{const{module:e,callbacks:t}=re(),r=ee(c=>c.state.typedDuration),n=ee(c=>c.updateState),s=Br().totalTrades,a=vs().fillDelay,o=M.useMemo(()=>lh(e,s,a,r),[s,a,r,e]),i=kW(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}},CW=()=>{const{module:e}=re(),t=Ie(),{duration:r,setDuration:n,error:s}=Tm(),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===ge.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}},TW=()=>{const e=ee(a=>a.state.isMarketOrder),{module:t}=re(),r=Ie(),n=M.useMemo(()=>{if(e&&t===ge.STOP_LOSS)return{text:r("triggerMarketPriceDisclaimer"),url:hd}},[e,r,t]),s=M.useMemo(()=>{if(!(t!==ge.LIMIT&&t!==ge.TWAP))return{text:r(e?"marketOrderWarning":"limitPriceMessage"),url:"https://www.orbs.com/dtwap-and-dlimit-faq/"}},[e,r,t]);return n||s},Qu=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=re(),n=ee(l=>l.updateState),s=ee(l=>l.state.isInvertedTrade),a=ee(l=>l.state.typedTriggerPrice),o=ee(l=>l.state.typedLimitPrice),i=ee(l=>l.state.isMarketOrder);return{onInvert:M.useCallback(()=>{a!==void 0&&n({typedTriggerPrice:G(1).div(a).toFixed()}),o!==void 0&&n({typedLimitPrice:G(1).div(o).toFixed()}),n({isInvertedTrade:!s})},[n,s,a,o,r]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:i}},g5=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:n,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:i}=re(),{isInverted:c}=Qu(),l=M.useMemo(()=>G((()=>{if(e!==void 0){const E=c?G(e).isZero()?G(0):G(1).div(e):G(e);return Ml(E.toFixed(),t)}if(n!==void 0&&G(r||"0").gt(0)&&!G(r||"0").isNaN()){const E=G(r||"0"),v=G(n||0).div(100);return E.plus(E.multipliedBy(v)).decimalPlaces(0).toFixed()}return G(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||G(r).isZero())return"";if(n!=null)return n;if(l){const g=G(r),v=G(l).minus(g).div(g).multipliedBy(100).decimalPlaces(2).toString();return G(v||"0").isZero()?"":v}return""},[l,r,n]),m=M.useMemo(()=>{let g="";if(e!==void 0)g=e;else{const E=oa(l,t);if(G(E||"0").isZero())return"";g=c?G(1).div(E).toFixed():E}return g},[e,t,l,c]),b=bs(c?o:i,m||"0");return{amountWei:G(l).isNaN()?"":l,amountUI:G(m).isNaN()?"":m,selectedPercentage:f,onChange:u,onPercentageChange:d,isInverted:c,usd:G(b).isNaN()?"":b,isTypedValue:e!==void 0}},AW=()=>{const{module:e}=re();return M.useMemo(()=>e===ge.STOP_LOSS?eh:th,[e])},Am=()=>{const{module:e}=re(),t=ee(r=>r.state.isMarketOrder);return M.useMemo(()=>e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT||t?void 0:e===ge.STOP_LOSS?rh:nh,[e,t])},SW=(e="")=>{const{module:t,marketPrice:r,typedInputAmount:n}=re(),s=Ie();return M.useMemo(()=>{if(G(n||"0").isZero()||!r||t!==ge.STOP_LOSS&&t!==ge.TAKE_PROFIT)return;const a=hh(r||"",e||"",t);if(a!=null&&a.isError)return{type:Dt.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:a.value,message:s("StopLossTriggerPriceError")||""};const o=bh(r||"",e||"",t);if(o!=null&&o.isError)return{type:Dt.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:o.value,message:s("TakeProfitTriggerPriceError")||""};if(!e||G(e||0).isZero())return{type:Dt.EMPTY_TRIGGER_PRICE,value:e,message:s("emptyTriggerPrice")||""}},[r,e,t,s,n])},PW=e=>{const{srcToken:t,dstToken:r,module:n,dstUsd1Token:s}=re(),a=Br().amountPerTradeWei,o=ee(l=>l.state.isMarketOrder),i=M.useMemo(()=>ch(n,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,n]),c=qr((r==null?void 0:r.decimals)||0,i);return{amountWei:i,amountUI:c,usd:bs(c,s)}},Es=()=>{const{dstToken:e,marketPrice:t,module:r,callbacks:n}=re(),s=ee(b=>b.updateState),a=AW(),o=ee(b=>b.state.triggerPricePercent),i=o===void 0?a:o,c=r===ge.STOP_LOSS||r===ge.TAKE_PROFIT,l=g5({typedValue:ee(b=>b.state.typedTriggerPrice),percentage:i,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:c?t:void 0,setValue:M.useCallback(b=>{var g;s({typedTriggerPrice:b}),(g=n==null?void 0:n.onTriggerPriceChange)==null||g.call(n,b||"")},[s,n]),setPercentage:M.useCallback(b=>{var g;s({triggerPricePercent:b}),(g=n==null?void 0:n.onTriggerPricePercentChange)==null||g.call(n,b||"")},[s,n])}),u=SW(l.amountWei),{amountWei:d,amountUI:f,usd:m}=PW(l.amountWei);return M.useMemo(()=>({...l,error:u,pricePerChunkWei:d,pricePerChunkUI:f,pricePerChunkUsd:m}),[l,u,d,f,m])},IW=()=>{const{module:e,marketPrice:t,marketPriceLoading:r}=re(),n=Ie(),{amountUI:s,onChange:a,onPercentageChange:o,usd:i,selectedPercentage:c,error:l,pricePerChunkUI:u,pricePerChunkUsd:d,isTypedValue:f}=Es(),m=ee(O=>O.state.isMarketOrder),b=ee(O=>O.updateState),{isInverted:g,onInvert:E,fromToken:v,toToken:w}=Qu(),S=M.useCallback(()=>{b({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[b]),T=e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT;return{price:s,amountPerChunk:u,amountPerChunkUsd:d,error:l,label:n("stopLossLabel"),tooltip:e===ge.STOP_LOSS?n("stopLossTooltip"):n("takeProfitTooltip"),onChange:a,onPercentageChange:o,percentage:c,isActive:!m,onReset:S,usd:i,fromToken:v,toToken:w,prefix:"",isLoading:r||!t,isInverted:g,hide:T,onInvert:E,totalTrades:Br().totalTrades,isTypedValue:f}},BW=e=>{const{module:t,marketPrice:r,typedInputAmount:n}=re(),s=Ie(),{amountWei:a}=Es(),o=ee(i=>i.state.isMarketOrder);return M.useMemo(()=>{if(G(n||"0").isZero()||!a||!r)return;const i=yh(a,e,o,t),c=gh(a,e,o,t);if(i!=null&&i.isError)return{type:Dt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:i.value};if(c!=null&&c.isError)return{type:Dt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:c.value};if(e&&G(e||0).isZero())return{type:Dt.MISSING_LIMIT_PRICE,message:s("emptyLimitPrice")||"",value:e||""}},[e,s,a,t,o,n,r])},Cc=()=>{const{dstToken:e,marketPrice:t,callbacks:r}=re(),n=ee(l=>l.updateState),s=Am(),a=ee(l=>l.state.limitPricePercent),o=a===void 0?s:a,i=g5({typedValue:ee(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=BW(i.amountWei);return M.useMemo(()=>({...i,error:c}),[i,c])},FW=()=>{const{module:e}=re(),t=ee(i=>i.updateState),r=ee(i=>i.state.isMarketOrder),n=Am(),s=ee(i=>i.state.triggerPricePercent)||0,a=e===ge.LIMIT,o=M.useCallback(()=>{!r&&e===ge.STOP_LOSS&&t({limitPricePercent:n}),t({isMarketOrder:!r})},[t,s,e,r,n]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:a}},x5=()=>{const{module:e,marketPrice:t}=re(),r=Cc().amountWei,n=Es().amountWei,s=ee(a=>a.state.isMarketOrder);return e===ge.LIMIT||!s?r||"":e===ge.STOP_LOSS||e===ge.TAKE_PROFIT?n||"":t||""},Tc=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=re(),n=x5(),s=Zr().amountWei,a=M.useMemo(()=>oh(s||"",n,(e==null?void 0:e.decimals)||0),[s,n,e==null?void 0:e.decimals]),o=qr(t==null?void 0:t.decimals,a);return{amountWei:a,amountUI:o,usd:bs(o,r)}},Ac=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=re(),n=x5(),s=Br().amountPerTradeWei,a=ee(c=>c.state.isMarketOrder),o=M.useMemo(()=>ih(s,n,!!a,(e==null?void 0:e.decimals)||0),[s,n,a,e==null?void 0:e.decimals]),i=qr(t==null?void 0:t.decimals,o);return{amountWei:o,amountUI:i,usd:bs(i,r)}},OW=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:r}=re(),{amountUI:n,usd:s}=Tc(),o=WG()?e:n;return{value:o,valueWei:Q2(r==null?void 0:r.decimals,o),isLoading:t,usd:s}},UW=()=>{const{module:e,marketPriceLoading:t}=re(),r=Ie(),{amountUI:n,onChange:s,onPercentageChange:a,usd:o,selectedPercentage:i,error:c,isTypedValue:l}=Cc(),{amountUI:u,usd:d}=Ac(),f=ee(L=>L.updateState),m=Am(),{isLimitPrice:b,toggleLimitPrice:g}=FW(),{isInverted:E,onInvert:v,fromToken:w,toToken:S}=Qu(),T=M.useCallback(()=>{f({typedLimitPrice:void 0}),f({limitPricePercent:m})},[f,e,m]),O=M.useMemo(()=>e===ge.STOP_LOSS?r("stopLossLimitPriceTooltip"):r("limitPriceTooltip"),[r,e]);return{price:n,amountPerChunk:u,amountPerChunkUsd:d,error:c,label:r("limitPrice"),tooltip:O,onChange:s,onPercentageChange:a,onReset:T,usd:o,fromToken:w,tradesAmount:Br().totalTrades,toToken:S,percentage:i,isInverted:E,isLoading:t,isLimitPrice:b,toggleLimitPrice:g,onInvert:v,isTypedValue:l}},DW=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:r}=re(),n=Ie(),s=bs(t,r);return M.useMemo(()=>G(e).gt(G(s||"0"))?{type:Dt.MIN_TRADE_SIZE_ERROR,value:e,message:n("minTradeSizeError",{minTradeSize:`${e}`})}:void 0,[e,s,n])};function w5(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:r,srcUsd1Token:n,srcBalance:s,chainId:a}=re(),o=ee(E=>E.state.swapExecution.status),i=Ie(),{error:c}=Es(),{error:l}=Cc(),{error:u}=Br(),{error:d}=vs(),{error:f}=Tm(),m=DW(),b=Zr().amountWei,g=M.useMemo(()=>{if(s&&G(b).gt(s))return{type:Dt.INSUFFICIENT_BALANCE,message:i("insufficientFunds"),value:s||""}},[s,b,i,a]);return M.useMemo(()=>Ah({marketPrice:e,typedInputAmount:r,srcUsd1Token:n,marketPriceLoading:t,triggerPriceError:c,limitPriceError:l,tradesError:u,fillDelayError:d,durationError:f,balanceError:g,minTradeSizeError:m}),[e,t,r,c,l,u,d,f,g,o,n,m])}const _W=()=>{const e=ee(n=>n.state.isMarketOrder),t=ee(n=>n.updateState),r=M.useCallback(()=>{t({isMarketOrder:!e})},[t,e]);return{isMarketPrice:!e,togglePrice:r}},Ju=()=>{const e=ee(r=>r.state.currentTime),t=Tm().duration;return M.useMemo(()=>ph(e,t),[e,t])},MW=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=re(),r=Zr().amountUI,n=Tc().amountUI,s=bs(r,e),a=bs(n,t);return{srcAmountUsd:s,dstAmountUsd:a}},NW=()=>{const{fees:e,dstUsd1Token:t}=re(),{amountUI:r}=Tc(),n=M.useMemo(()=>!e||!r?"":G(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]);return{amount:n,percent:e,usd:bs(n,t)}},v5=()=>{const{srcToken:e,dstToken:t,account:r,chainId:n,slippage:s,config:a,module:o,fees:i}=re(),{amountWei:c}=Zr(),{amountPerTradeWei:l,totalTrades:u}=Br(),d=Ju(),{amountWei:f}=Ac(),{pricePerChunkWei:m}=Es(),{milliseconds:b}=vs();return M.useMemo(()=>{var g;return Ph({chainId:n,srcToken:_s((e==null?void 0:e.address)||"")?((g=Ms(n))==null?void 0:g.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:c,deadlineMillis:d,fillDelayMillis:!u||u===1?0:b,slippage:s*100,account:r,srcAmountPerTrade:l,dstMinAmountPerTrade:f,triggerAmountPerTrade:m,config:a,module:o,feePercentage:i})},[e,t,r,n,s,a,o,c,l,u,b,f,m,i])},E5=()=>{const{srcToken:e,dstToken:t,account:r}=re(),{amountWei:n}=Zr(),{amountWei:s}=Cc(),{amountPerTradeWei:a,totalTrades:o}=Br(),i=Ju(),{amountWei:c}=Ac(),{pricePerChunkWei:l}=Es(),{milliseconds:u}=vs(),d=v5();return M.useMemo(()=>({srcToken:e,dstToken:t,limitPrice:s,deadline:i,srcAmount:n,srcAmountPerTrade:a,totalTrades:o,minDestAmountPerTrade:c,tradeInterval:u,triggerPricePerTrade:l,maker:r,rePermitData:d}),[e,t,s,i,n,a,o,c,u,l,r,d])},k5=()=>{const{srcToken:e,dstToken:t,account:r}=re(),n=Ie(),{amountUI:s,usd:a}=Ac(),{amountPerTradeUI:o,amountPerTradeUsd:i,totalTrades:c}=Br(),{amountUI:l,usd:u}=Es(),d=Ju(),{amountUI:f,usd:m}=Cc(),{amount:b,percent:g,usd:E}=NW(),{milliseconds:v}=vs(),{amountUI:w}=Tc(),{srcAmountUsd:S,dstAmountUsd:T}=MW(),O=Zr().amountUI,L=ee(A=>A.state.isMarketOrder),P=ee(A=>A.state.currentTime),h=J2({srcToken:e,dstToken:t,account:r,limitPrice:L?void 0:f,limitPriceUsd:L?void 0:m,deadline:d,tradeInterval:v,srcAmount:O,totalTrades:c,srcAmountPerTrade:o,srcAmountPerTradeUsd:i,minDestAmountPerTrade:s,minDestAmountPerTradeUsd:a,triggerPrice:l,triggerPriceUsd:u,srcUsd:S,dstUsd:T,dstAmount:w,orderType:J0(),createdAt:P}),y=Ar({value:b}),x=Ar({value:E});return M.useMemo(()=>({...h,fees:{label:n("fees",{value:`${g}%`}),amount:y,usd:x||"",percentage:g}}),[h,y,x,g])},C5=M.createContext({}),LW=({children:e,...t})=>C.jsx(C5.Provider,{value:t,children:e}),zW=()=>M.useContext(C5),T5=()=>{var s,a;const e=Ie(),{wrapTxHash:t,srcToken:r}=ee(o=>o.state.swapExecution),n=(a=(s=wo())==null?void 0:s.wToken)==null?void 0:a.symbol;return t?C.jsx("p",{className:"twap-error-wrap-msg",children:e("wrapMsg",{symbol:(r==null?void 0:r.symbol)||"",wSymbol:n||""})}):null},A5=()=>{const e=Ie(),t=ee(n=>n.state.swapExecution.status),r=rx();return t===pt.SUCCESS?e("createOrderActionSuccess",{name:r}):e("createOrderAction",{name:r})},RW=()=>{const e=ee(b=>b.state.swapExecution.srcToken),t=Ie(),{step:r,wrapTxHash:n,approveTxHash:s}=ee(b=>b.state.swapExecution),a=wo(),o=zu(n),i=zu(n),c=zu(s),l=ee(b=>b.state.swapExecution.status),d=_s((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,m=A5();return M.useMemo(()=>r===Rs.WRAP?{title:t("wrapAction",{symbol:d}),footerLink:o,footerText:t(o?"viewOnExplorer":"proceedInWallet")}:r===Rs.APPROVE?{title:t("approveAction",{symbol:d}),footerLink:c,footerText:t(c?"viewOnExplorer":"proceedInWallet")}:{title:m,footerText:l===pt.LOADING?t("proceedInWallet"):void 0},[r,c,d,m,t,o,i,f,l])},HW=({error:e})=>C.jsxs("div",{className:"twap-error",children:[C.jsx("h2",{className:"twap-error-title",children:"Transaction failed"}),(e==null?void 0:e.code)&&C.jsxs("p",{className:"twap-error-code",children:["Error code: ",e==null?void 0:e.code]}),C.jsx(T5,{})]});function $W({error:e}){const{components:t}=re(),r=Ie(),n=ee(o=>{var i;return(i=o.state.swapExecution)==null?void 0:i.wrapTxHash}),s=t.SubmitOrderErrorView,a=C.jsx(es.Failed,{error:C.jsx(HW,{error:e}),footerLink:hd,footerText:r("viewOnExplorer")});return s?C.jsx(s,{wrapTxHash:n,error:e,children:a}):a}const GW=()=>{const{components:e}=re(),t=ee(u=>u.state.swapExecution.srcToken),r=ee(u=>u.state.swapExecution.dstToken),{reviewDetails:n}=zW(),s=Ie(),a=ee(u=>{var d;return!!((d=u.state.swapExecution)!=null&&d.status)}),o=k5(),i=e.USD,c=e.SubmitOrderMainView,l=C.jsxs(C.Fragment,{children:[C.jsx(es.Main,{fromTitle:s("from"),toTitle:s("to"),inUsd:i?C.jsx(i,{value:o.srcUsd,isLoading:!1}):C.jsx(pn,{value:o.srcUsd,decimalScale:2,prefix:"$"}),outUsd:i?C.jsx(i,{value:o.dstUsd,isLoading:!1}):C.jsx(pn,{value:o.dstUsd,decimalScale:2,prefix:"$"})}),!a&&C.jsxs("div",{className:"twap-create-order-bottom",children:[C.jsx(he.Container,{children:C.jsxs("div",{className:"twap-create-order-details",children:[C.jsx(he.Deadline,{deadline:o.deadline.value,label:o.deadline.label,tooltip:o.deadline.tooltip||""}),C.jsx(he.Price,{srcToken:t,price:o.triggerPrice.value,dstToken:r,label:o.triggerPrice.label,tooltip:o.triggerPrice.tooltip,usd:o.triggerPrice.usd}),C.jsx(he.Price,{srcToken:t,price:o.limitPrice.value,dstToken:r,label:o.limitPrice.label,usd:o.limitPrice.usd,tooltip:o.limitPrice.tooltip}),C.jsx(he.MinDestAmount,{dstToken:r,dstMinAmountOut:o.minDestAmountPerTrade.value,label:o.minDestAmountPerTrade.label,tooltip:o.minDestAmountPerTrade.tooltip||"",usd:o.minDestAmountPerTrade.usd}),C.jsx(he.TradeSize,{tradeSize:o.sizePerTrade.value,trades:o.totalTrades.value,srcToken:t,label:o.sizePerTrade.label,tooltip:o.sizePerTrade.tooltip}),C.jsx(he.TradesAmount,{trades:o.totalTrades.value,label:o.totalTrades.label,tooltip:o.totalTrades.tooltip}),C.jsx(he.TradeInterval,{chunks:o.totalTrades.value,fillDelayMillis:o.tradeInterval.value,label:o.tradeInterval.label,tooltip:o.tradeInterval.tooltip}),C.jsx(he.Recipient,{}),o.fees.amount&&C.jsx(he.Fees,{fees:o.fees.amount,label:o.fees.label,usd:o.fees.usd,dstTokenSymbol:r==null?void 0:r.symbol})]})}),n]})]});return c?C.jsx(c,{children:l}):l},jW=e=>{const{status:t,stepIndex:r,totalSteps:n,parsedError:s}=ee(w=>w.state.swapExecution),{components:a}=re(),o=a.Spinner,i=a.SuccessIcon,c=a.ErrorIcon,l=a.TokenLogo,{srcToken:u,dstToken:d}=re(),f=Zr().amountUI,m=Tc().amountUI,b=Ar({value:f,decimalScale:2}),g=Ar({value:m,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 C.jsx(LW,{...e,children:C.jsx(es,{inAmount:b,outAmount:g,swapStatus:t,totalSteps:n,currentStep:RW(),currentStepIndex:r,inToken:E,outToken:v,components:{SrcTokenLogo:l&&C.jsx(l,{token:u}),DstTokenLogo:l&&C.jsx(l,{token:d}),Failed:C.jsx($W,{error:s}),Success:C.jsx(VW,{}),Main:C.jsx(GW,{}),Loader:o,SuccessIcon:i,FailedIcon:c}})})},VW=()=>{const e=A5(),{components:t}=re(),r=ee(a=>a.state.swapExecution.orderId),n=t.SubmitOrderSuccessView,s=C.jsxs(C.Fragment,{children:[C.jsx(es.Success,{title:e}),C.jsx(T5,{})]});return n?C.jsx(n,{newOrderId:r,children:s}):s},WW=()=>{const{supportedChains:e}=re();return M.useMemo(()=>e,[e])},qW=()=>{const{config:e}=re();return M.useMemo(()=>({spender:e.repermit}),[e])},KW=()=>{var c;const{account:e,walletClient:t,overrides:r,refetchBalances:n,callbacks:s,chainId:a}=re(),o=(c=wo())==null?void 0:c.wToken,i=Q0();return en({mutationFn:async({onHash:l,srcAmountWei:u})=>{var m,b;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(),(m=s==null?void 0:s.onWrapRequest)==null||m.call(s),r!=null&&r.wrap?d=await r.wrap(u):d=await t.writeContract({abi:zm,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),(b=s==null?void 0:s.onWrapSuccess)==null||b.call(s,{txHash:f.transactionHash,explorerUrl:ao(f.transactionHash,a),amount:oa(u,o.decimals)}),n==null||n(),f},onError:l=>{throw dt.onWrapError(l),l}})},S5=()=>{const{account:e,walletClient:t,chainId:r,callbacks:n}=re(),{rePermitData:s}=E5(),{refetch:a}=vo();return en({mutationFn:async()=>{var b,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),(b=n==null?void 0:n.onSignOrderRequest)==null||b.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=u4(u),f={v:q(d.v||0),r:d.r,s:d.s},m=await Oh(o,f);return(v=n==null?void 0:n.onOrderCreated)==null||v.call(n,m),await a(),m}})},P5=()=>{const{account:e,publicClient:t,config:r}=re();return en({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=G(a||"0").lt(G(s).toString());return{allowance:a,approvalRequired:o}}})},YW=()=>{const{account:e,walletClient:t,overrides:r,config:n,chainId:s,callbacks:a}=re(),o=Q0(),{mutateAsync:i}=P5();return en({onError:c=>{dt.onApproveError(c)},mutationFn:async({token:c,onHash:l,srcAmountWei:u})=>{var b,g;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!n)throw new Error("missing config");(b=a==null?void 0:a.onApproveRequest)==null||b.call(a),dt.onApproveRequest();let d;if(r!=null&&r.approveOrder?d=await r.approveOrder({tokenAddress:c.address,spenderAddress:n.repermit,amount:Xs}):d=await t.writeContract({abi:Ty,functionName:"approve",account:e,address:c.address,args:[n.repermit,Xs],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 m=!1;for(let E=0;E<3;E++){const{approvalRequired:v}=await i({tokenAddress:c.address,srcAmountWei:u});if(!v){m=!0;break}E<2&&await new Promise(w=>setTimeout(w,3e3))}if(!m)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:ao(f.transactionHash,s),token:c,amount:oa(u,c.decimals)}),f}})},ZW=()=>{const{account:e,chainId:t,srcToken:r,dstToken:n,module:s,slippage:a}=re(),o=Es(),i=Zr().amountWei,c=Br().amountPerTradeWei,l=Ju(),u=Br().totalTrades,d=vs().fillDelay,f=Ac().amountWei,m=ee(b=>b.state.isMarketOrder);return en({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:m||!1,chunksAmount:u})}})};function XW(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 I5=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:n}=re(),s=YW().mutateAsync,a=KW().mutateAsync,o=S5().mutateAsync,{mutateAsync:i}=P5(),c=ee(d=>d.updateSwapExecution),{amountWei:l}=Zr(),u=ZW().mutate;return en({mutationFn:async()=>{var f,m;const d=_s((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 b=n6(e,r);c({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0});const{approvalRequired:g}=await i({tokenAddress:b.address,srcAmountWei:l});let E=0,v=1;d&&v++,g&&v++,c({totalSteps:v,stepIndex:E,allowanceLoading:!1,status:pt.LOADING}),u(),d&&(c({step:Rs.WRAP}),await a({onHash:S=>c({wrapTxHash:S}),srcAmountWei:l}),E++,c({stepIndex:E})),g&&(c({step:Rs.APPROVE}),await s({token:b,onHash:S=>c({approveTxHash:S}),srcAmountWei:l}),E++,c({stepIndex:E})),c({step:Rs.CREATE});const w=await o();return c({status:pt.SUCCESS,orderId:w.id}),w}catch(b){if(jf(b))(f=n==null?void 0:n.onSubmitOrderRejected)==null||f.call(n),c({step:void 0,status:void 0,stepIndex:void 0,error:b});else{const g=XW(b);(m=n==null?void 0:n.onSubmitOrderFailed)==null||m.call(n,g),c({status:pt.FAILED,parsedError:g,error:b})}throw b}}})},QW=()=>{const{marketPrice:e,srcToken:t,dstToken:r,resetTypedInputAmount:n}=re(),s=I5(),{amountUI:a}=Zr(),o=ee(g=>g.resetState),i=ee(g=>g.state.swapExecution),c=ee(g=>g.updateSwapExecution),l=ee(g=>g.resetSwapExecution),u=rx(),d=M.useCallback(()=>{(i==null?void 0:i.status)===pt.SUCCESS&&n(),(i==null?void 0:i.status)!==pt.LOADING&&o()},[i==null?void 0:i.status,o,n]),f=M.useCallback(()=>{(i==null?void 0:i.status)!==pt.LOADING&&l({srcToken:t,dstToken:r})},[l,t,r]),m=en({mutationFn:async()=>(c({acceptedSrcAmount:a,acceptedMarketPrice:e}),await s.mutateAsync())}),b=M.useCallback(()=>m.mutateAsync(),[m]);return M.useMemo(()=>({reset:o,onCloseModal:d,onOpenModal:f,onSubmit:b,orderTitle:u,...i,isLoading:(i==null?void 0:i.status)===pt.LOADING,isSuccess:(i==null?void 0:i.status)===pt.SUCCESS,isFailed:(i==null?void 0:i.status)===pt.FAILED}),[o,d,b,i,u])},JW=()=>{const e=Ie(),{marketPrice:t,srcToken:r,dstToken:n,marketPriceLoading:s,srcBalance:a,srcUsd1Token:o,noLiquidity:i,typedInputAmount:c}=re(),l=s||G(o||"0").isZero()||a===void 0||G(t||"0").isZero(),u=!!(r&&n&&c&&l),d=w5(),f=M.useMemo(()=>i?e("noLiquidity"):G(c||"0").isZero()?e("enterAmount"):e("placeOrder"),[d,e,c,i]),m=!!(d||i||u||G(c||"0").isZero()||!r||!n);return M.useMemo(()=>({disabled:m,text:f,loading:u}),[m,f,u])},eq=({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?Os.createPortal(e,a):null};Bh(Yw.version);const tq={SubmitOrderPanel:jW,Orders:gW,Portal:eq};R.CRASH_ERROR_MESSAGE=bw,R.Components=tq,R.Configs=Pe,R.DEFAULT_DURATION_OPTIONS=xz,R.DEFAULT_FILL_DELAY=Nc,R.DEFAULT_STOP_LOSS_LIMIT_PERCENTAGE=rh,R.DEFAULT_STOP_LOSS_PERCENTAGE=eh,R.DEFAULT_TAKE_PROFIT_LIMIT_PERCENTAGE=nh,R.DEFAULT_TAKE_PROFIT_PERCENTAGE=th,R.DISCLAIMER_URL=hw,R.EIP712_TYPES=Qm,R.EIP712_TYPES_DEV=Jm,R.ERC20_ABI=J5,R.EXCLUSIVITY_OVERRIDE_BPS=uw,R.FEES=lw,R.FormatNumber=pn,R.IWETH_ABI=zm,R.InputErrors=Dt,R.LEGACY_EXCHANGES_MAP=Xm,R.MAX_ORDER_DURATION_MILLIS=Pa,R.MIN_CHUNKS=cw,R.MIN_FILL_DELAY_MILLIS=_c,R.MIN_FILL_DELAY_MINUTES=qm,R.MIN_ORDER_DURATION_MILLIS=pd,R.Module=ge,R.ORBS_LOGO=pw,R.ORBS_LOGO_FALLBACK=fw,R.ORBS_SLTP_FAQ_URL=dw,R.ORBS_TWAP_FAQ_URL=hd,R.ORBS_WEBSITE_URL=mw,R.OrderFilter=ar,R.OrderStatus=ut,R.OrderType=Re,R.PRICE_PROTECTION_SETTINGS=wz,R.Partners=Jr,R.QUERY_PARAMS=Ia,R.REPERMIT_ABI=Rm,R.REPERMIT_PRIMARY_TYPE=md,R.SUGGEST_CHUNK_VALUE=iw,R.SpotProvider=yz,R.Steps=Rs,R.SwapStatus=pt,R.THE_GRAPH_ORDERS_API=Km,R.TWAP_ABI=Hm,R.TimeUnit=$t,R.analytics=dt,R.buildRePermitOrderData=Ph,R.buildV2Order=vd,R.copy=p4,R.ensureWrappedToken=n6,R.eqIgnoreCase=Ds,R.fillDelayText=t6,R.formatDecimals=r6,R.getAccountOrders=Mh,R.getApiEndpoint=dd,R.getChunks=uh,R.getConfig=yd,R.getDeadline=ph,R.getDestTokenAmount=oh,R.getDestTokenMinAmountPerChunk=ih,R.getDuration=lh,R.getErrors=Ah,R.getEstimatedDelayBetweenChunksMillis=fh,R.getExplorerUrl=ao,R.getMaxChunksError=kh,R.getMaxFillDelayError=vw,R.getMaxOrderDurationError=xh,R.getMaxPossibleChunks=dh,R.getMinChunkSizeUsd=Th,R.getMinFillDelayError=vh,R.getMinNativeBalance=m4,R.getMinOrderDurationError=wh,R.getMinTradeSizeError=Eh,R.getNetwork=Ms,R.getOrderExecutionRate=ld,R.getOrderFillDelayMillis=cd,R.getOrderLimitPriceRate=Vm,R.getOrderType=h4,R.getPartnerChains=jm,R.getPartnerIdentifier=_t,R.getPartners=Ch,R.getSrcTokenChunkAmount=mh,R.getStopLossLimitPriceError=yh,R.getStopLossPriceError=hh,R.getTakeProfitLimitPriceError=gh,R.getTakeProfitPriceError=bh,R.getTriggerPricePerChunk=ch,R.getTriggerPricePerTrade=Wm,R.isDev=Ro,R.isNativeAddress=_s,R.isTxRejected=jf,R.makeElipsisAddress=Nl,R.maxUint256=Mc,R.millisToDays=s6,R.millisToMinutes=Vf,R.nativeTokenAddresses=Zm,R.networks=Ft,R.parseError=f4,R.removeCommas=d4,R.setApiMode=ow,R.setUIVersion=Bh,R.shouldUnwrapOnly=qf,R.shouldWrapOnly=Wf,R.submitOrder=Oh,R.toAmountUi=oa,R.toAmountWei=Ml,R.useAddresses=qW,R.useDisclaimerPanel=TW,R.useDstTokenPanel=OW,R.useDurationPanel=CW,R.useFillDelayPanel=wW,R.useFormatNumber=Ar,R.useInputErrors=w5,R.useInvertTradePanel=Qu,R.useLimitPricePanel=UW,R.useOrder=E5,R.useOrderDisplay=k5,R.useOrderHistoryPanel=hj,R.useOrderType=J0,R.usePartnerChains=WW,R.useRePermitOrderData=v5,R.useRefetchUntilStatusSynced=cx,R.useSignOrder=S5,R.useSubmitOrder=I5,R.useSubmitOrderButton=JW,R.useSubmitOrderPanel=QW,R.useTogglePricePanel=_W,R.useTradesPanel=EW,R.useTranslations=Ie,R.useTriggerPricePanel=IW,R.zeroAddress=Ym,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
126
+ `),a=!1),Object.assign(Object.assign({},e),{allowNegative:a})}function GG(e){e=$G(e),e.decimalSeparator,e.allowedDecimalSeparators,e.thousandsGroupStyle;var t=e.suffix,r=e.allowNegative,n=e.allowLeadingZeros,s=e.onKeyDown;s===void 0&&(s=Z0);var a=e.onBlur;a===void 0&&(a=Z0);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,m=e.onValueChange,b=SG(e,["decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","suffix","allowNegative","allowLeadingZeros","onKeyDown","onBlur","thousandSeparator","decimalScale","fixedDecimalScale","prefix","defaultValue","value","valueIsNumericString","onValueChange"]),g=Lu(e),E=g.decimalSeparator,v=g.allowedDecimalSeparators,w=function(I){return X2(I,e)},S=function(I,D){return RG(I,D,e)},T=xo(d)?u:d,O=f??zG(T,l,t);xo(d)?xo(u)||(O=O||typeof u=="number"):O=O||typeof d=="number";var L=function(I){return V2(I)?I:(typeof I=="number"&&(I=Y2(I)),O&&typeof i=="number"?Z2(I,i,!!c):I)},P=MG(L(d),L(u),!!O,w,S,m),h=P[0],y=h.numAsString,x=h.formattedValue,A=P[1],B=function(I){var D=I.target,U=I.key,z=D.selectionStart,H=D.selectionEnd,j=D.value;if(j===void 0&&(j=""),(U==="Backspace"||U==="Delete")&&H<l.length){I.preventDefault();return}if(z!==H){s(I);return}U==="Backspace"&&j[0]==="-"&&z===l.length+1&&r&&dc(D,1),i&&c&&(U==="Backspace"&&j[z-1]===E?(dc(D,z-1),I.preventDefault()):U==="Delete"&&j[z]===E&&I.preventDefault()),v!=null&&v.includes(U)&&j[z]===E&&dc(D,z+1);var Q=o===!0?",":o;U==="Backspace"&&j[z-1]===Q&&dc(D,z-1),U==="Delete"&&j[z]===Q&&dc(D,z+1),s(I)},F=function(I){var D=y;if(D.match(/\d/g)||(D=""),n||(D=UG(D)),c&&i&&(D=Z2(D,i,c)),D!==y){var U=X2(D,e);A({formattedValue:U,value:D,floatValue:parseFloat(D)},{event:I,source:Y0.event})}a(I)},_=function(I){return I===E?!0:j2(I)},k=function(I){var D=I.currentValue,U=I.lastValue,z=I.formattedValue,H=I.currentValueIndex,j=I.formattedValueIndex,Q=D[H],pe=z[j],be=DG(U,D),ie=be.to,de=function(Oe){return S(Oe).indexOf(".")+l.length};return d===0&&c&&i&&D[ie.start]===E&&de(D)<H&&de(z)>j?!1:H>=ie.start&&H<ie.end&&v&&v.includes(Q)&&pe===E?!0:Q===pe};return Object.assign(Object.assign({},b),{value:x,valueIsNumericString:!1,isValidInputCharacter:_,isCharacterSame:k,onValueChange:A,format:w,removeFormatting:S,getCaretBoundary:function(I){return HG(I,e)},onKeyDown:B,onBlur:F})}const Q2=(e,t)=>M.useMemo(()=>Ml(t,e),[e,t]),qr=(e,t)=>M.useMemo(()=>oa(t,e),[e,t]),wo=()=>{const{chainId:e}=re();return M.useMemo(()=>Ms(e),[e])},zu=e=>{const t=wo();return M.useMemo(()=>{if(!(!e||!t))return ao(e,t.id)},[e,t])},bs=(e,t)=>M.useMemo(()=>!e||!t||G(e||"0").isZero()||G(t||"0").isZero()?"":G(e||"0").times(t).toFixed(),[e,t]),jG=()=>{const{srcToken:e,dstToken:t,chainId:r}=re();return M.useMemo(()=>Wf(e,t,r),[e,t,r])},VG=()=>{const{srcToken:e,dstToken:t,chainId:r}=re();return M.useMemo(()=>qf(e,t,r),[e,t,r])},WG=()=>{const e=jG(),t=VG();return e||t},Ru=e=>{const{overrides:t}=re();return M.useMemo(()=>t!=null&&t.dateFormat?t.dateFormat(e||0):te(e).format("DD/MM/YYYY HH:mm"),[e,t==null?void 0:t.dateFormat])};function qG(){const{callbacks:e}=re();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 KG=(e,t)=>M.useMemo(()=>r6(e==null?void 0:e.toString(),t),[e,t]),Ar=({value:e,decimalScale:t=3,prefix:r,suffix:n})=>{var c;const s=KG(e,t),{overrides:a}=re(),o=a==null?void 0:a.numberFormat,i=GG({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()},YG={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",finalExecutionPrice:"Final execution price",marketPrice:"Market price",from:"From",to:"To",Open:"Open",Completed:"Completed",Expired:"Expired",Cancelled:"Cancelled",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",executionSummary:"Execution summary",orderInfo:"Order info",orderFills:"Order fills",fillTransactionHash:"Transaction hash",noFills:"No fills yet",backToOrder:"Back to {type} order",fillAmountOut:"Amount out",fillAmountReceived:"Amount received",fillIndex:"Index",fillTimestamp:"Timestamp",fillTxHash:"Tx hash",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 ZG(e){let t=e;const r=/\{[^{}]*\}/g;for(;r.test(t);)t=t.replace(r,"");return t}const Ie=()=>{const e=re();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])||YG[r];return ZG(a.replace(/{(\w+)}/g,(c,l)=>(n==null?void 0:n[l])||c))},[e.getTranslation,e.translations])},pn=({value:e,decimalScale:t=3,prefix:r,suffix:n,defaultValue:s="-"})=>{const a=Ar({value:e,decimalScale:t,prefix:r,suffix:n});return C.jsx(C.Fragment,{children:a??s})},Hu=({value:e})=>{const t=Ar({value:e,decimalScale:2});return t?C.jsx("small",{className:"twap-order-details__detail-row-value-usd",children:` ($${t})`}):null},XG=({deadline:e,label:t,tooltip:r})=>{const n=Ru(e);return C.jsx(Sr,{title:t,tooltip:r,children:n})},QG=({price:e,dstToken:t,label:r,tooltip:n,usd:s,srcToken:a})=>{const o=Ar({value:e,decimalScale:3});return G(e||0).isZero()?null:C.jsx(Sr,{title:r,tooltip:n,children:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:["1 ",a==null?void 0:a.symbol," = ",`${o||"-"} ${t==null?void 0:t.symbol}`,C.jsx(Hu,{value:s})]})})},JG=({tradeSize:e,srcToken:t,trades:r,label:n,tooltip:s})=>r===1?null:C.jsxs(Sr,{title:n,tooltip:s,children:[e?C.jsx(pn,{value:e,decimalScale:3}):"-"," ",(t==null?void 0:t.symbol)||""]}),ej=({dstToken:e,dstMinAmountOut:t,label:r,tooltip:n,usd:s})=>{const a=Ar({value:t});return G(t||0).isZero()?null:C.jsxs(Sr,{title:r,tooltip:n,children:[`${t?a:"-"} ${e==null?void 0:e.symbol}`,C.jsx(Hu,{value:s})]})},tj=({trades:e,label:t,tooltip:r})=>e===1?null:C.jsx(Sr,{title:t,tooltip:r,children:e}),rj=()=>{var s;const e=Ie(),{account:t}=re(),r=(s=wo())==null?void 0:s.explorer,n=Nl(t);return C.jsx(Sr,{title:e("recipient")||"",children:r?C.jsx("a",{href:`${r}/address/${t}`,target:"_blank",children:n}):n})},nj=({fillDelayMillis:e,chunks:t=0,label:r,tooltip:n})=>{const s=M.useMemo(()=>t6(e),[e]);return t===1?null:C.jsx(Sr,{title:r,tooltip:n,children:s})},Sr=({title:e,tooltip:t,children:r,className:n="",onClick:s,style:a})=>{const{components:o}=re(),i=o.Tooltip;return C.jsxs("div",{className:`${n} twap-order-details__detail-row`,onClick:s,style:a,children:[C.jsxs("div",{className:"twap-order-details__detail-row-label",children:[C.jsx("p",{className:"twap-order-details__detail-row-label-value",children:e}),t&&i&&C.jsx(i,{tooltipText:t})]}),C.jsx("div",{className:"twap-order-details__detail-row-value",children:r})]})},sj=({id:e})=>{const{components:t}=re(),r=t==null?void 0:t.Tooltip,n=qG();return e.startsWith("0x")?C.jsx(Sr,{title:"ID",onClick:()=>n(e),style:{cursor:"pointer"},children:r&&C.jsx(r,{tooltipText:e,children:C.jsxs("div",{className:"twap-order-details__detail-row-value-id",children:[C.jsx("p",{children:Nl(e)}),C.jsx(Az.AiOutlineCopy,{})]})})}):C.jsx(Sr,{title:"ID",children:e})},aj=({version:e})=>C.jsx(Sr,{title:"Version",children:e});function he({children:e,className:t=""}){return C.jsx("div",{className:`${t} twap-order-details`,children:e})}const oj=({children:e})=>e,ij=({fees:e,label:t,usd:r,dstTokenSymbol:n})=>{const s=Ar({value:e});return C.jsxs(Sr,{title:t,children:[`${e?s:"-"} ${n}`,C.jsx(Hu,{value:r})]})};he.Deadline=XG,he.Fees=ij,he.TradeSize=JG,he.MinDestAmount=ej,he.TradesAmount=tj,he.Recipient=rj,he.TradeInterval=nj,he.DetailRow=Sr,he.Price=QG,he.OrderID=sj,he.Container=oj,he.OrderVersion=aj,he.USD=Hu;const Q0=()=>{const{publicClient:e}=re();return en({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},J2=e=>{const t=Ie(),r=e.limitPriceUsd,n=e.srcAmountPerTrade,s=e.srcAmountPerTradeUsd,a=M.useMemo(()=>!e.minDestAmountPerTrade||!e.totalTrades?"":G(e.minDestAmountPerTrade).multipliedBy(e.totalTrades).decimalPlaces(0).toFixed(),[e.minDestAmountPerTrade,e.totalTrades]),o=M.useMemo(()=>!e.minDestAmountPerTradeUsd||!e.totalTrades?"":G(e.minDestAmountPerTradeUsd).multipliedBy(e.totalTrades).decimalPlaces(2).toFixed(),[e.minDestAmountPerTradeUsd,e.totalTrades]),i=e.triggerPrice,c=e.triggerPriceUsd,l=e.srcUsd,u=e.dstUsd,d=e.dstAmount;return M.useMemo(()=>({srcToken:e.srcToken,dstToken:e.dstToken,srcUsd:l||"",dstUsd:u||"",orderType:e.orderType,dstMinAmount:a,dstMinAmountUsd:o,limitPrice:{label:t("limitPrice"),tooltip:t("limitPriceTooltip"),value:e.limitPrice||"",usd:r||""},deadline:{tooltip:t("expirationTooltip"),label:t("expirationLabel"),value:e.deadline||0},createdAt:{label:t("createdAt"),value:e.createdAt||0},srcAmount:{label:t("amountOut"),value:e.srcAmount||"",usd:l||""},dstAmount:{value:d||"",usd:u||""},sizePerTrade:{tooltip:t("tradeSizeTooltip"),label:t("individualTradeSize"),value:n||"",usd:s},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:e.minDestAmountPerTrade||"",usd:e.minDestAmountPerTradeUsd},tradeInterval:{tooltip:t("tradeIntervalTooltip"),label:t("tradeIntervalLabel"),value:e.tradeInterval||0},triggerPrice:{tooltip:t("triggerPriceTooltip"),label:t("triggerPrice"),value:i||"",usd:c},recipient:{label:t("recipient"),value:e.account||""}}),[t,e.srcToken,e.dstToken,l,u,e.orderType,a,o,e.limitPrice,r,e.deadline,e.srcAmount,d,n,s,e.totalTrades,e.minDestAmountPerTrade,e.minDestAmountPerTradeUsd,e.tradeInterval,i,c,e.account,e.createdAt])},cj=(e,t,r)=>{const n=wo();return M.useMemo(()=>e==null?void 0:e.map(s=>({srcToken:t,dstToken:r,srcAmount:oa(s.inAmount,t==null?void 0:t.decimals),dstAmount:oa(s.outAmount,r==null?void 0:r.decimals),timestamp:s.timestamp,txHash:s.txHash,explorerUrl:ao(s.txHash,n==null?void 0:n.id),executionRate:ld(s.inAmount,s.outAmount,t==null?void 0:t.decimals,r==null?void 0:r.decimals)})).filter(s=>s.srcToken!==void 0&&s.dstToken!==void 0),[e,t,r,n])},ex=e=>{const{data:t}=vo(),{useToken:r,config:n}=re(),s=Ie(),a=M.useMemo(()=>t==null?void 0:t.find(O=>O.id===e),[t,e])||{},o=nx(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=qr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmount),u=uj(i,c,a),d=dj(i,c,a),f=pj(i,c,a),m=qr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountFilled),b=qr(c==null?void 0:c.decimals,a==null?void 0:a.dstAmountFilled),g=a==null?void 0:a.progress,E=qr(i==null?void 0:i.decimals,a==null?void 0:a.srcAmountPerTrade),v=qr(c==null?void 0:c.decimals,a==null?void 0:a.dstMinAmountPerTrade),w=M.useMemo(()=>a?a.version===2?a.fillDelay:n.twapConfig?cd(a,n.twapConfig):0:0,[a,n]),S=J2({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,orderType:a==null?void 0:a.type}),T=cj(a==null?void 0:a.fills,i,c)??[];return M.useMemo(()=>{if(a!=null&&a.id)return{original:a,fills:T,title:o,...S,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:m??""},amountOutFilled:{label:s("amountReceived"),value:b??"",token:c},progress:{label:s("progress"),value:g},executionPrice:{label:s((a==null?void 0:a.totalTradesAmount)===1?"finalExecutionPrice":"averageExecutionPrice"),value:f},version:{label:s("version"),value:a==null?void 0:a.version}}},[a,s,f,m,b,g,o,i,c,S])},tx=e=>{const t=Ie();return M.useMemo(()=>{switch(e){case Re.TWAP_MARKET:return t("twapMarket");case Re.LIMIT:return t("limit");case Re.TWAP_LIMIT:return t("twapLimit");case Re.STOP_LOSS_MARKET:return t("stopLossMarket");case Re.STOP_LOSS_LIMIT:return t("stopLossLimit");case Re.TAKE_PROFIT:return t("takeProfit");default:return t("twapMarket")}},[t,e])},J0=()=>{const{module:e}=re(),t=ee(r=>r.state.isMarketOrder);return M.useMemo(()=>e===ge.TWAP?t?Re.TWAP_MARKET:Re.TWAP_LIMIT:e===ge.LIMIT?Re.LIMIT:e===ge.STOP_LOSS?t?Re.STOP_LOSS_MARKET:Re.STOP_LOSS_LIMIT:e===ge.TAKE_PROFIT?Re.TAKE_PROFIT:Re.TWAP_MARKET,[e,t])},rx=()=>{const e=J0();return tx(e)},nx=e=>tx(e==null?void 0:e.type),sx=()=>{const{account:e,config:t,chainId:r}=re();return M.useMemo(()=>["useTwapOrderHistoryManager",e,t==null?void 0:t.adapter,r],[e,t,r])},lj=()=>{const{callbacks:e,refetchBalances:t}=re(),r=Dd(),n=sx();return M.useCallback(s=>{var c;const a=r.getQueryData(n);let o=!1;const i=[];a&&a.filter(l=>l.version===2).forEach(l=>{var d;const u=s.find(f=>f.id===l.id);u&&u.progress!==l.progress&&(o=!0,i.push(u),u.status===ut.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])},vo=()=>{const{account:e,config:t,chainId:r}=re(),n=sx(),s=lj();return F3({refetchInterval:gz,refetchOnWindowFocus:!0,retry:!1,staleTime:1/0,queryKey:n,queryFn:async({signal:o})=>{if(!e||!r||!t)return[];const i=await Mh({signal:o,chainId:r,config:t,account:e});return s(i),i.map(c=>t!=null&&t.twapConfig?{...c,fillDelayMillis:cd(c,t.twapConfig)}:c)}})},ax=(e=[],t=ar.All)=>{let r=e??[];return t===ar.Open&&(r=r.filter(n=>n.status===ut.Open)),t===ar.Completed&&(r=r.filter(n=>n.status===ut.Completed)),t===ar.Cancelled&&(r=r.filter(n=>n.status===ut.Cancelled)),t===ar.Expired&&(r=r.filter(n=>n.status===ut.Expired)),r.sort((n,s)=>s.createdAt-n.createdAt)},ox=()=>{const e=ee(r=>r.state.orderHistoryStatusFilter),{data:t}=vo();return M.useMemo(()=>ax(t,e),[e,t])},uj=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r||r!=null&&r.isMarketPrice))return Vm(r,e==null?void 0:e.decimals,t==null?void 0:t.decimals)},[r,e,t]),dj=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return Wm(r,e.decimals,t.decimals)},[r,e,t]),pj=(e,t,r)=>M.useMemo(()=>{if(!(!e||!t||!r))return ld(r.srcAmountFilled,r.dstAmountFilled,e.decimals,t.decimals)},[r,e,t]),fj=()=>{const e=ee(r=>r.updateState),t=ee(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])},ix=()=>{const e=Ie();return M.useCallback(t=>{if(!t)return e("allOrders");switch(t){case ar.Open:return e("Open");case ar.Completed:return e("Completed");case ar.Expired:return e("Expired");case ar.Cancelled:return e("Cancelled");default:return e("allOrders")}},[e])},mj=()=>{const e=ix();return M.useMemo(()=>Object.values(ar).map(t=>({text:e(t),value:t})),[e])},hj=()=>{const{data:e,isLoading:t,refetch:r,isRefetching:n}=vo(),{mutateAsync:s,isPending:a}=lx(),o=ee(O=>O.state.selectedOrderID),i=ee(O=>O.updateState),c=ee(O=>O.state.orderHistoryStatusFilter),l=ee(O=>O.state.showSelectedOrderFills),u=M.useCallback(O=>i({orderHistoryStatusFilter:O}),[]),d=mj(),f=ox(),m=ex(o),b=M.useMemo(()=>ax(e,ar.Open),[e]),g=M.useCallback(O=>{i(O?{selectedOrderID:O}:{selectedOrderID:void 0,showSelectedOrderFills:!1})},[i]),E=M.useCallback(()=>r().then(O=>O.data),[r]),v=M.useCallback(async O=>s({orders:[O]}).then(L=>(L==null?void 0:L[0])||""),[s]),w=M.useCallback(()=>s({orders:b}),[s,e]),S=M.useCallback(()=>i({showSelectedOrderFills:!1}),[i]),T=M.useMemo(()=>{const O=c||d[0].value;return d.find(L=>L.value===O)},[d,c]);return{refetchOrders:E,onCancelOrder:v,onSelectOrderFilter:u,onDisplayOrder:g,onCancelAllOpenOrders:w,onHideOrderFills:S,isRefetching:n,allOrders:e??[],selectedOrders:f,isDisplayingOrderFills:l,isLoading:t,selectedOrder:o?m:void 0,openOrdersCount:(b==null?void 0:b.length)||0,isCancelOrderLoading:a,selectedOrderFilter:T,orderFilters:d}},cx=()=>{const{refetch:e}=vo();return en({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)===ut.Cancelled}))break;await new Promise(a=>setTimeout(a,1e3))}}})},lx=()=>{const{account:e,walletClient:t,publicClient:r,config:n,callbacks:s,chainId:a}=re(),o=Q0(),i=cx().mutateAsync,c=ee(d=>d.updateState),l=async d=>{dt.onCancelOrderRequest(d.map(f=>f.id.toString()),1);try{return(await Promise.all(d.map(m=>t.writeContract({account:e,address:m.twapAddress,abi:Hm,functionName:"cancel",args:[m.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 m=await t.writeContract({account:e,address:n.repermit,abi:Rm,functionName:"cancel",args:[d.map(g=>g.hash)],chain:t.chain}),b=await o(m);if(!b)throw new Error("failed to get transaction receipt");if(b.status==="reverted")throw new Error("failed to cancel order");return dt.onCancelOrderSuccess(m),(f=s==null?void 0:s.onCancelOrderSuccess)==null||f.call(s,{orders:d,txHash:m,explorerUrl:ao(m,a)}),b.transactionHash}catch(m){throw dt.onCancelOrderError(m),m}};return en({mutationFn:async({orders:d})=>{var f,m;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:pt.LOADING,cancelOrderTxHash:void 0,cancelOrderError:void 0});const b=d.filter(w=>w.version===1),g=d.filter(w=>w.version===2),[E,v]=await Promise.all([b.length?l(b):Promise.resolve(""),g.length?u(g):Promise.resolve("")]);return await i(d.map(w=>w.id)),c({cancelOrderStatus:pt.SUCCESS,orderIdsToCancel:[]}),[...E||[],v]}catch(b){console.error("cancel order error",b),(m=s==null?void 0:s.onCancelOrderFailed)==null||m.call(s,b),jf(b)?c({cancelOrderStatus:void 0}):(c({cancelOrderStatus:pt.FAILED}),dt.onCancelOrderError(b))}}})},$u=0,ys=1,Eo=2,ux=4;function dx(e){return()=>e}function bj(e){e()}function px(e,t){return r=>e(t(r))}function fx(e,t){return()=>e(t)}function yj(e,t){return r=>e(t,r)}function em(e){return e!==void 0}function gj(...e){return()=>{e.map(bj)}}function ko(){}function Gu(e,t){return t(e),e}function xj(e,t){return t(e)}function tt(...e){return e}function Ve(e,t){return e(ys,t)}function Ce(e,t){e($u,t)}function tm(e){e(Eo)}function at(e){return e(ux)}function ce(e,t){return Ve(e,yj(t,$u))}function Kr(e,t){const r=e(ys,n=>{r(),t(n)});return r}function mx(e){let t,r;return n=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{n(t)},e)}}function hx(e,t){return e===t}function rt(e=hx){let t;return r=>n=>{e(t,n)||(t=n,r(n))}}function fe(e){return t=>r=>{e(r)&&t(r)}}function ne(e){return t=>px(t,e)}function fn(e){return t=>()=>{t(e)}}function W(e,...t){const r=wj(...t);return(n,s)=>{switch(n){case Eo:tm(e);return;case ys:return Ve(e,r(s))}}}function mn(e,t){return r=>n=>{r(t=e(t,n))}}function pa(e){return t=>r=>{e>0?e--:t(r)}}function jn(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);Ve(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 wj(...e){return t=>e.reduceRight(xj,t)}function vj(e){let t,r;const n=()=>t==null?void 0:t();return function(s,a){switch(s){case ys:return a?r===a?void 0:(n(),r=a,t=Ve(e,a),t):(n(),ko);case Eo:n(),r=null;return}}}function Y(e){let t=e;const r=De();return(n,s)=>{switch(n){case $u:t=s;break;case ys:{s(t);break}case ux:return t}return r(n,s)}}function zt(e,t){return Gu(Y(t),r=>ce(e,r))}function De(){const e=[];return(t,r)=>{switch(t){case $u:e.slice().forEach(n=>{n(r)});return;case Eo:e.splice(0,e.length);return;case ys:return e.push(r),()=>{const n=e.indexOf(r);n>-1&&e.splice(n,1)}}}}function hr(e){return Gu(De(),t=>ce(e,t))}function Ge(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:Ej(),singleton:r}}const Ej=()=>Symbol();function kj(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 vt(...e){const t=De(),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);Ve(a,c=>{r[o]=c,n=n|i,n===s&&Ce(t,r)})}),function(a,o){switch(a){case Eo:{tm(t);return}case ys:return n===s&&o(r),Ve(t,o)}}}function me(e,t=hx){return W(e,rt(t))}function rm(...e){return function(t,r){switch(t){case Eo:return;case ys:return gj(...e.map(n=>Ve(n,r)))}}}var rr=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(rr||{});const Cj={0:"debug",3:"error",1:"log",2:"warn"},Tj=()=>typeof globalThis>"u"?window:globalThis,gs=Ge(()=>{const e=Y(3);return{log:Y((t,r,n=1)=>{var s;const a=(s=Tj().VIRTUOSO_LOG_LEVEL)!=null?s:at(e);n>=a&&console[Cj[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function fa(e,t,r){return nm(e,t,r).callbackRef}function nm(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 Aj(e,t,r,n,s,a,o,i,c){const l=M.useCallback(u=>{const d=Sj(u.children,t,i?"offsetWidth":"offsetHeight",s);let f=u.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const m=f.lastElementChild.dataset.viewportType==="window";let b;m&&(b=f.ownerDocument.defaultView);const g=o?i?o.scrollLeft:o.scrollTop:m?i?b.scrollX||b.document.documentElement.scrollLeft:b.scrollY||b.document.documentElement.scrollTop:i?f.scrollLeft:f.scrollTop,E=o?i?o.scrollWidth:o.scrollHeight:m?i?b.document.documentElement.scrollWidth:b.document.documentElement.scrollHeight:i?f.scrollWidth:f.scrollHeight,v=o?i?o.offsetWidth:o.offsetHeight:m?i?b.innerWidth:b.innerHeight:i?f.offsetWidth:f.offsetHeight;n({scrollHeight:E,scrollTop:Math.max(g,0),viewportHeight:v}),a==null||a(i?bx("column-gap",getComputedStyle(u).columnGap,s):bx("row-gap",getComputedStyle(u).rowGap,s)),d!==null&&e(d)},[e,t,s,a,o,n,i]);return nm(l,r,c)}function Sj(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},rr.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 bx(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,rr.WARN),t==="normal"?0:parseInt(t??"0",10)}function yx(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 m=t.getBoundingClientRect(),b=l.top-m.top;f=m.height-Math.max(0,b),d=b+t.scrollTop}else{const m=o.current.ownerDocument.defaultView;f=m.innerHeight-Math.max(0,l.top),d=l.top+m.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:u},e(n.current)},[e,t]),{callbackRef:a,ref:o}=nm(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 Vt=Ge(()=>{const e=De(),t=De(),r=Y(0),n=De(),s=Y(0),a=De(),o=De(),i=Y(0),c=Y(0),l=Y(0),u=Y(0),d=De(),f=De(),m=Y(!1),b=Y(!1),g=Y(!1);return ce(W(e,ne(({scrollTop:E})=>E)),t),ce(W(e,ne(({scrollHeight:E})=>E)),o),ce(t,s),{deviation:r,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:i,horizontalDirection:b,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:m,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:n,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),pc={lvl:0};function gx(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 Ke(e){return e===pc}function fc(e,t){if(!Ke(e))return t===e.k?e.v:t<e.k?fc(e.l,t):fc(e.r,t)}function Yr(e,t,r="k"){if(Ke(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const n=Yr(e.r,t,r);return n[0]===-1/0?[e.k,e.v]:n}return Yr(e.l,t,r)}function br(e,t,r){return Ke(e)?vx(t,r,1):t===e.k?At(e,{k:t,v:r}):t<e.k?Ex(At(e,{l:br(e.l,t,r)})):Ex(At(e,{r:br(e.r,t,r)}))}function Co(){return pc}function To(e,t,r){if(Ke(e))return[];const n=Yr(e,t)[0];return Pj(am(e,n,r))}function sm(e,t){if(Ke(e))return pc;const{k:r,l:n,r:s}=e;if(t===r){if(Ke(n))return s;if(Ke(s))return n;{const[a,o]=wx(n);return ju(At(e,{k:a,l:xx(n),v:o}))}}else return t<r?ju(At(e,{l:sm(n,t)})):ju(At(e,{r:sm(s,t)}))}function ma(e){return Ke(e)?[]:[...ma(e.l),{k:e.k,v:e.v},...ma(e.r)]}function am(e,t,r){if(Ke(e))return[];const{k:n,l:s,r:a,v:o}=e;let i=[];return n>t&&(i=i.concat(am(s,t,r))),n>=t&&n<=r&&i.push({k:n,v:o}),n<=r&&(i=i.concat(am(a,t,r))),i}function ju(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(om(t))return kx(At(e,{lvl:r-1}));if(!Ke(t)&&!Ke(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(om(e))return im(At(e,{lvl:r-1}));if(!Ke(n)&&!Ke(n.l)){const s=n.l,a=om(s)?n.lvl-1:n.lvl;return At(s,{l:At(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:im(At(n,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function At(e,t){return vx(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 xx(e){return Ke(e.r)?e.l:ju(At(e,{r:xx(e.r)}))}function om(e){return Ke(e)||e.lvl>e.r.lvl}function wx(e){return Ke(e.r)?[e.k,e.v]:wx(e.r)}function vx(e,t,r,n=pc,s=pc){return{k:e,l:n,lvl:r,r:s,v:t}}function Ex(e){return im(kx(e))}function kx(e){const{l:t}=e;return!Ke(t)&&t.lvl===e.lvl?At(t,{r:At(e,{l:t.r})}):e}function im(e){const{lvl:t,r}=e;return!Ke(r)&&!Ke(r.r)&&r.lvl===t&&r.r.lvl===t?At(r,{l:At(e,{r:r.l}),lvl:t+1}):e}function Pj(e){return gx(e,({k:t,v:r})=>({index:t,value:r}))}function Cx(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function mc(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const cm=Ge(()=>({recalcInProgress:Y(!1)}),[],{singleton:!0});function Tx(e,t,r){return e[Vu(e,t,r)]}function Vu(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 Ij(e,t,r,n){const s=Vu(e,t,n),a=Vu(e,r,n,s);return e.slice(s,a+1)}function xs(e,t){return Math.round(e.getBoundingClientRect()[t])}function Wu(e){return!Ke(e.groupOffsetTree)}function lm({index:e},t){return t===e?0:t<e?-1:1}function Bj(){return{groupIndices:[],groupOffsetTree:Co(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Co()}}function Fj(e,t){let r=Ke(e)?0:1/0;for(const n of t){const{endIndex:s,size:a,startIndex:o}=n;if(r=Math.min(r,o),Ke(e)){e=br(e,0,a);continue}const i=To(e,o-1,s+1);if(i.some(Lj(n)))continue;let c=!1,l=!1;for(const{end:u,start:d,value:f}of i)c?(s>=d||a===f)&&(e=sm(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 Uj({offset:e},t){return t===e?0:t<e?-1:1}function hc(e,t,r){if(t.length===0)return 0;const{index:n,offset:s,size:a}=Tx(t,e,lm),o=e-n,i=a*o+(o-1)*r+s;return i>0?i+r:i}function Ax(e,t){if(!Wu(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function Sx(e,t,r){if(Oj(e))return t.groupIndices[e.groupIndex]+1;{const n=e.index==="LAST"?r:e.index;let s=Ax(n,t);return s=Math.max(0,s,Math.min(r,s)),s}}function Dj(e,t,r,n=0){return n>0&&(t=Math.max(t,Tx(e,n,lm).offset)),gx(Ij(e,t,r,Uj),Nj)}function _j(e,[t,r,n,s]){t.length>0&&n("received item sizes",t,rr.DEBUG);const a=e.sizeTree;let o=a,i=0;if(r.length>0&&Ke(a)&&t.length===2){const f=t[0].size,m=t[1].size;o=r.reduce((b,g)=>br(br(b,g,f),g+1,m),o)}else[o,i]=Fj(o,t);if(o===a)return e;const{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=um(e.offsetTree,i,o,s);return{groupIndices:r,groupOffsetTree:r.reduce((f,m)=>br(f,m,hc(m,d,s)),Co()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function Mj(e){return ma(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 Px(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 um(e,t,r,n){let s=e,a=0,o=0,i=0,c=0;if(t!==0){c=Vu(s,t-1,lm),i=s[c].offset;const l=Yr(r,t-1);a=l[0],o=l[1],s.length&&s[c].size===Yr(r,t)[1]&&(c-=1),s=s.slice(0,c+1)}else s=[];for(const{start:l,value:u}of To(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 Nj(e){return{index:e.index,value:e}}function Lj(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 zj={offsetHeight:"height",offsetWidth:"width"},hn=Ge(([{log:e},{recalcInProgress:t}])=>{const r=De(),n=De(),s=zt(n,0),a=De(),o=De(),i=Y(0),c=Y([]),l=Y(void 0),u=Y(void 0),d=Y(void 0),f=Y(void 0),m=Y((P,h)=>xs(P,zj[h])),b=Y(void 0),g=Y(0),E=Bj(),v=zt(W(r,Te(c,e,g),mn(_j,E),rt()),E),w=zt(W(c,rt(),mn((P,h)=>({current:h,prev:P.current}),{current:[],prev:[]}),ne(({prev:P})=>P)),[]);ce(W(c,fe(P=>P.length>0),Te(v,g),ne(([P,h,y])=>{const x=P.reduce((A,B,F)=>br(A,B,hc(B,h.offsetTree,y)||F),Co());return{...h,groupIndices:P,groupOffsetTree:x}})),v),ce(W(n,Te(v),fe(([P,{lastIndex:h}])=>P<h),ne(([P,{lastIndex:h,lastSize:y}])=>[{endIndex:h,size:y,startIndex:P}])),r),ce(l,u);const S=zt(W(l,ne(P=>P===void 0)),!0);ce(W(u,fe(P=>P!==void 0&&Ke(at(v).sizeTree)),ne(P=>{const h=at(d),y=at(c).length>0;return h?y?[{endIndex:0,size:h,startIndex:0},{endIndex:1,size:P,startIndex:1}]:[]:[{endIndex:0,size:P,startIndex:0}]})),r),ce(W(f,fe(P=>P!==void 0&&P.length>0&&Ke(at(v).sizeTree)),ne(P=>{const h=[];let y=P[0],x=0;for(let A=1;A<P.length;A++){const B=P[A];B!==y&&(h.push({endIndex:A-1,size:y,startIndex:x}),y=B,x=A)}return h.push({endIndex:P.length-1,size:y,startIndex:x}),h})),r),ce(W(c,Te(d,u),fe(([,P,h])=>P!==void 0&&h!==void 0),ne(([P,h,y])=>{const x=[];for(let A=0;A<P.length;A++){const B=P[A],F=P[A+1];x.push({startIndex:B,endIndex:B,size:h}),F!==void 0&&x.push({startIndex:B+1,endIndex:F-1,size:y})}return x})),r);const T=hr(W(r,Te(v),mn(({sizes:P},[h,y])=>({changed:y!==P,sizes:y}),{changed:!1,sizes:E}),ne(P=>P.changed)));Ve(W(i,mn((P,h)=>({diff:P.prev-h,prev:h}),{diff:0,prev:0}),ne(P=>P.diff)),P=>{const{groupIndices:h}=at(v);if(P>0)Ce(t,!0),Ce(a,P+Px(P,h));else if(P<0){const y=at(w);y.length>0&&(P-=Px(-P,y)),Ce(o,P)}}),Ve(W(i,Te(e)),([P,h])=>{P<0&&h("`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},rr.ERROR)});const O=hr(a);ce(W(a,Te(v),ne(([P,h])=>{const y=h.groupIndices.length>0,x=[],A=h.lastSize;if(y){const B=fc(h.sizeTree,0);let F=0,_=0;for(;F<P;){const I=h.groupIndices[_],D=h.groupIndices.length===_+1?1/0:h.groupIndices[_+1]-I-1;x.push({endIndex:I,size:B,startIndex:I}),x.push({endIndex:I+1+D-1,size:A,startIndex:I+1}),_++,F+=D+1}const k=ma(h.sizeTree);return F!==P&&k.shift(),k.reduce((I,{k:D,v:U})=>{let z=I.ranges;return I.prevSize!==0&&(z=[...I.ranges,{endIndex:D+P-1,size:I.prevSize,startIndex:I.prevIndex}]),{prevIndex:D+P,prevSize:U,ranges:z}},{prevIndex:P,prevSize:0,ranges:x}).ranges}return ma(h.sizeTree).reduce((B,{k:F,v:_})=>({prevIndex:F+P,prevSize:_,ranges:[...B.ranges,{endIndex:F+P-1,size:B.prevSize,startIndex:B.prevIndex}]}),{prevIndex:0,prevSize:A,ranges:[]}).ranges})),r);const L=hr(W(o,Te(v,g),ne(([P,{offsetTree:h},y])=>{const x=-P;return hc(x,h,y)})));return ce(W(o,Te(v,g),ne(([P,h,y])=>{if(h.groupIndices.length>0){if(Ke(h.sizeTree))return h;let x=Co();const A=at(w);let B=0,F=0,_=0;for(;B<-P;){_=A[F];const k=A[F+1]-_-1;F++,B+=k+1}if(x=ma(h.sizeTree).reduce((k,{k:I,v:D})=>br(k,Math.max(0,I+P),D),x),B!==-P){const k=fc(h.sizeTree,_);x=br(x,0,k);const I=Yr(h.sizeTree,-P+1)[1];x=br(x,1,I)}return{...h,sizeTree:x,...um(h.offsetTree,0,x,y)}}else{const x=ma(h.sizeTree).reduce((A,{k:B,v:F})=>br(A,Math.max(0,B+P),F),Co());return{...h,sizeTree:x,...um(h.offsetTree,0,x,y)}}})),v),{beforeUnshiftWith:O,data:b,defaultItemSize:u,firstItemIndex:i,fixedItemSize:l,fixedGroupSize:d,gap:g,groupIndices:c,heightEstimates:f,itemSize:m,listRefresh:T,shiftWith:o,shiftWithOffset:L,sizeRanges:r,sizes:v,statefulTotalCount:s,totalCount:n,trackItemSizes:S,unshiftWith:a}},tt(gs,cm),{singleton:!0});function Rj(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const Ix=Ge(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:n,scrollTop:s}])=>{const a=De(),o=De(),i=hr(W(a,ne(Rj)));return ce(W(i,ne(c=>c.totalCount)),r),ce(W(i,ne(c=>c.groupIndices)),e),ce(W(vt(s,t,n),fe(([c,l])=>Wu(l)),ne(([c,l,u])=>Yr(l.groupOffsetTree,Math.max(c-u,0),"v")[0]),rt(),ne(c=>[c])),o),{groupCounts:a,topItemsIndexes:o}},tt(hn,Vt)),ws=Ge(([{log:e}])=>{const t=Y(!1),r=hr(W(t,fe(n=>n),rt()));return Ve(t,n=>{n&&at(e)("props updated",{},rr.DEBUG)}),{didMount:r,propsReady:t}},tt(gs),{singleton:!0}),Hj=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Bx(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Hj)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const bc=Ge(([{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 m=De(),b=De(),g=Y(0);let E=null,v=null,w=null;function S(){E&&(E(),E=null),w&&(w(),w=null),v&&(clearTimeout(v),v=null),Ce(c,!1)}return ce(W(m,Te(r,d,n,g,i,o,f),Te(e,a,s),ne(([[T,O,L,P,h,y,x,A],B,F,_])=>{const k=Bx(T),{align:I,behavior:D,offset:U}=k,z=P-1,H=Sx(k,O,z);let j=hc(H,O.offsetTree,B)+y;I==="end"?(j+=F+Yr(O.sizeTree,H)[1]-L+_,H===z&&(j+=x)):I==="center"?j+=(F+Yr(O.sizeTree,H)[1]-L+_)/2:j-=h,U&&(j+=U);const Q=pe=>{S(),pe?(A("retrying to scroll to",{location:T},rr.DEBUG),Ce(m,T)):(Ce(b,!0),A("list did not change, scroll successful",{},rr.DEBUG))};if(S(),D==="smooth"){let pe=!1;w=Ve(t,be=>{pe=pe||be}),E=Kr(u,()=>{Q(pe)})}else E=Kr(W(t,$j(150)),Q);return v=setTimeout(()=>{S()},1200),Ce(c,!0),A("scrolling from index to",{behavior:D,index:H,top:j},rr.DEBUG),{behavior:D,top:j}})),l),{scrollTargetReached:b,scrollToIndex:m,topListHeight:g}},tt(hn,Vt,gs),{singleton:!0});function $j(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return n=>{n&&(t(!0),clearTimeout(r))}}}function dm(e,t){e==0?t():requestAnimationFrame(()=>{dm(e-1,t)})}function pm(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const yc=Ge(([{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),fn(!1)),i),ce(W(o,Te(c),fe(([u,d])=>!!d),fn(!1)),l),Ve(W(vt(t,o),Te(i,r,e,l),fe(([[,u],d,{sizeTree:f},m,b])=>u&&(!Ke(f)||em(m))&&!d&&!b),Te(c)),([,u])=>{Kr(s,()=>{Ce(l,!0)}),dm(4,()=>{Kr(n,()=>{Ce(i,!0)}),Ce(a,u)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:i}},tt(hn,Vt,bc,ws),{singleton:!0});function Fx(e,t){return Math.abs(e-t)<1.01}const gc="up",xc="down",Gj="none",jj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Vj=0,wc=Ge(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:n,scrollTop:s,viewportHeight:a}])=>{const o=Y(!1),i=Y(!0),c=De(),l=De(),u=Y(4),d=Y(Vj),f=zt(W(rm(W(me(s),pa(1),fn(!0)),W(me(s),pa(1),fn(!1),mx(100))),rt()),!1),m=zt(W(rm(W(r,fn(!0)),W(r,fn(!1),mx(200))),rt()),!1);ce(W(vt(me(s),me(d)),ne(([w,S])=>w<=S),rt()),i),ce(W(i,jn(50)),l);const b=hr(W(vt(n,me(a),me(t),me(e),me(u)),mn((w,[{scrollHeight:S,scrollTop:T},O,L,P,h])=>{const y=T+O-S>-h,x={scrollHeight:S,scrollTop:T,viewportHeight:O};if(y){let B,F;return T>w.state.scrollTop?(B="SCROLLED_DOWN",F=w.state.scrollTop-T):(B="SIZE_DECREASED",F=w.state.scrollTop-T||w.scrollTopDelta),{atBottom:!0,atBottomBecause:B,scrollTopDelta:F,state:x}}let A;return x.scrollHeight>w.state.scrollHeight?A="SIZE_INCREASED":O<w.state.viewportHeight?A="VIEWPORT_HEIGHT_DECREASING":T<w.state.scrollTop?A="SCROLLING_UPWARDS":A="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:A,state:x}},jj),rt((w,S)=>w&&w.atBottom===S.atBottom))),g=zt(W(n,mn((w,{scrollHeight:S,scrollTop:T,viewportHeight:O})=>{if(Fx(w.scrollHeight,S))return{changed:!1,jump:0,scrollHeight:S,scrollTop:T};{const L=S-(T+O)<1;return w.scrollTop!==T&&L?{changed:!0,jump:w.scrollTop-T,scrollHeight:S,scrollTop:T}:{changed:!0,jump:0,scrollHeight:S,scrollTop:T}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),fe(w=>w.changed),ne(w=>w.jump)),0);ce(W(b,ne(w=>w.atBottom)),o),ce(W(o,jn(50)),c);const E=Y(xc);ce(W(n,ne(({scrollTop:w})=>w),rt(),mn((w,S)=>at(m)?{direction:w.direction,prevScrollTop:S}:{direction:S<w.prevScrollTop?gc:xc,prevScrollTop:S},{direction:xc,prevScrollTop:0}),ne(w=>w.direction)),E),ce(W(n,jn(50),fn(Gj)),E);const v=Y(0);return ce(W(f,fe(w=>!w),fn(0)),v),ce(W(s,jn(100),Te(f),fe(([w,S])=>!!S),mn(([w,S],[T])=>[S,T],[0,0]),ne(([w,S])=>S-w)),v),{atBottomState:b,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:i,isScrolling:f,lastJumpDueToItemResize:g,scrollDirection:E,scrollVelocity:v}},tt(Vt)),vc="top",Ec="bottom",Ox="none";function Ux(e,t,r){return typeof e=="number"?r===gc&&t===vc||r===xc&&t===Ec?e:0:r===gc?t===vc?e.main:e.reverse:t===Ec?e.main:e.reverse}function Dx(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const fm=Ge(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:n,viewportHeight:s}])=>{const a=De(),o=Y(0),i=Y(0),c=Y(0),l=zt(W(vt(me(n),me(s),me(r),me(a,mc),me(c),me(o),me(t),me(e),me(i)),ne(([u,d,f,[m,b],g,E,v,w,S])=>{const T=u-w,O=E+v,L=Math.max(f-T,0);let P=Ox;const h=Dx(S,vc),y=Dx(S,Ec);return m-=w,m+=f+v,b+=f+v,b-=w,m>u+O-h&&(P=gc),b<u-L+d+y&&(P=xc),P!==Ox?[Math.max(T-f-Ux(g,vc,P)-h,0),T-L-v+d+Ux(g,Ec,P)+y]:null}),fe(u=>u!=null),rt(mc)),[0,0]);return{increaseViewportBy:i,listBoundary:a,overscan:c,topListHeight:o,visibleRange:l}},tt(Vt),{singleton:!0});function Wj(e,t,r){if(Wu(t)){const n=Ax(e,t);return[{index:Yr(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 mm={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function qu(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,m=l,b=f-u;return{bottom:u,firstItemIndex:a,items:Mx(e,s,a),offsetBottom:b,offsetTop:l,top:m,topItems:Mx(t,s,a),topListHeight:t.reduce((g,E)=>E.size+g,0),totalCount:r}}function _x(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=pm(t,i),l=Array.from({length:i}).map((u,d)=>({data:a[d+c],index:d+c,offset:0,size:0}));return qu(l,[],i,s,r,n)}function Mx(e,t,r){if(e.length===0)return[];if(!Wu(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=To(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 Nx(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const ha=Ge(([{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:m},{recalcInProgress:b}])=>{const g=Y([]),E=Y(0),v=De(),w=Y(0);ce(a.topItemsIndexes,g);const S=zt(W(vt(m,b,me(c,mc),me(s),me(n),me(l),u,me(g),me(t),me(r),me(w),e),fe(([P,h,,y,,,,,,,,x])=>{const A=x&&x.length!==y;return P&&!h&&!A}),ne(([,,[P,h],y,x,A,B,F,_,k,I,D])=>{var U,z,H,j;const Q=x,{offsetTree:pe,sizeTree:be}=Q,ie=at(E);if(y===0)return{...mm,totalCount:y};if(P===0&&h===0)return ie===0?{...mm,totalCount:y}:_x(ie,A,x,_,k,D||[]);if(Ke(be))return ie>0?null:qu(Wj(pm(A,y),Q,D),[],y,k,Q,_);const de=[];if(F.length>0){const Ae=F[0],Ee=F[F.length-1];let ye=0;for(const Xe of To(be,Ae,Ee)){const Ye=Xe.value,Qe=Math.max(Xe.start,Ae),Or=Math.min(Xe.end,Ee);for(let Ut=Qe;Ut<=Or;Ut++)de.push({data:D==null?void 0:D[Ut],index:Ut,offset:ye,size:Ye}),ye+=Ye}}if(!B)return qu([],de,y,k,Q,_);const Oe=F.length>0?F[F.length-1]+1:0,X=Dj(pe,P,h,Oe);if(X.length===0)return null;const ve=y-1,Me=Gu([],Ae=>{for(const Ee of X){const ye=Ee.value;let Xe=ye.offset,Ye=Ee.start;const Qe=ye.size;if(ye.offset<P){Ye+=Math.floor((P-ye.offset+k)/(Qe+k));const Ut=Ye-Ee.start;Xe+=Ut*Qe+Ut*k}Ye<Oe&&(Xe+=(Oe-Ye)*Qe,Ye=Oe);const Or=Math.min(Ee.end,ve);for(let Ut=Ye;Ut<=Or&&!(Xe>=h);Ut++)Ae.push({data:D==null?void 0:D[Ut],index:Ut,offset:Xe,size:Qe}),Xe+=Qe+k}}),je=Nx(I,vc),it=Nx(I,Ec);if(Me.length>0&&(je>0||it>0)){const Ae=Me[0],Ee=Me[Me.length-1];if(je>0&&Ae.index>Oe){const ye=Math.min(je,Ae.index-Oe),Xe=[];let Ye=Ae.offset;for(let Qe=Ae.index-1;Qe>=Ae.index-ye;Qe--){const Or=(z=(U=To(be,Qe,Qe)[0])==null?void 0:U.value)!=null?z:Ae.size;Ye-=Or+k,Xe.unshift({data:D==null?void 0:D[Qe],index:Qe,offset:Ye,size:Or})}Me.unshift(...Xe)}if(it>0&&Ee.index<ve){const ye=Math.min(it,ve-Ee.index);let Xe=Ee.offset+Ee.size+k;for(let Ye=Ee.index+1;Ye<=Ee.index+ye;Ye++){const Qe=(j=(H=To(be,Ye,Ye)[0])==null?void 0:H.value)!=null?j:Ee.size;Me.push({data:D==null?void 0:D[Ye],index:Ye,offset:Xe,size:Qe}),Xe+=Qe+k}}}return qu(Me,de,y,k,Q,_)}),fe(P=>P!==null),rt()),mm);ce(W(e,fe(em),ne(P=>P==null?void 0:P.length)),s),ce(W(S,ne(P=>P.topListHeight)),d),ce(d,i),ce(W(S,ne(P=>[P.top,P.bottom])),o),ce(W(S,ne(P=>P.items)),v);const T=hr(W(S,fe(({items:P})=>P.length>0),Te(s,e),fe(([{items:P},h])=>P[P.length-1].originalIndex===h-1),ne(([,P,h])=>[P-1,h]),rt(mc),ne(([P])=>P))),O=hr(W(S,jn(200),fe(({items:P,topItems:h})=>P.length>0&&P[0].originalIndex===h.length),ne(({items:P})=>P[0].index),rt())),L=hr(W(S,fe(({items:P})=>P.length>0),ne(({items:P})=>{let h=0,y=P.length-1;for(;P[h].type==="group"&&h<y;)h++;for(;P[y].type==="group"&&y>h;)y--;return{endIndex:P[y].index,startIndex:P[h].index}}),rt(Cx)));return{endReached:T,initialItemCount:E,itemsRendered:v,listState:S,minOverscanItemCount:w,rangeChanged:L,startReached:O,topItemsIndexes:g,...f}},tt(hn,Ix,fm,yc,bc,wc,ws,cm),{singleton:!0}),Lx=Ge(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:n},{listState:s}])=>{const a=De(),o=zt(W(vt(r,e,n,t,s),ne(([i,c,l,u,d])=>i+c+l+u+d.offsetBottom+d.bottom)),0);return ce(me(o),a),{totalListHeight:o,totalListHeightChanged:a}},tt(Vt,ha),{singleton:!0}),qj=Ge(([{viewportHeight:e},{totalListHeight:t}])=>{const r=Y(!1),n=zt(W(vt(r,e,t),fe(([s])=>s),ne(([,s,a])=>Math.max(0,s-a)),jn(0),rt()),0);return{alignToBottom:r,paddingTopAddition:n}},tt(Vt,Lx),{singleton:!0}),zx=Ge(()=>({context:Y(null)})),Kj=({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,Rx=Ge(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:o,scrollTop:i,viewportHeight:c},{scrollToIndex:l}])=>{const u=De();return ce(W(u,Te(t,c,r,a,s,n,i),Te(e),ne(([[d,f,m,b,g,E,v,w],S])=>{const{align:T,behavior:O,calculateViewLocation:L=Kj,done:P,...h}=d,y=Sx(d,f,b-1),x=hc(y,f.offsetTree,S)+g+E,A=x+Yr(f.sizeTree,y)[1],B=w+E,F=w+m-v,_=L({itemBottom:A,itemTop:x,locationParams:{align:T,behavior:O,...h},viewportBottom:F,viewportTop:B});return _?P&&Kr(W(o,fe(k=>!k),pa(at(o)?1:2)),P):P&&P(),_}),fe(d=>d!==null)),l),{scrollIntoView:u}},tt(hn,Vt,bc,ha,gs),{singleton:!0});function Hx(e){return e?e==="smooth"?"smooth":"auto":!1}const Yj=(e,t)=>typeof e=="function"?Hx(e(t)):t&&Hx(e),Zj=Ge(([{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:m}])=>{const b=Y(!1),g=De();let E=null;function v(O){Ce(o,{align:"end",behavior:O,index:"LAST"})}Ve(W(vt(W(me(t),pa(1)),c),Te(me(b),a,i,d),ne(([[O,L],P,h,y,x])=>{let A=L&&y,B="auto";return A&&(B=Yj(P,h||x),A=A&&!!B),{followOutputBehavior:B,shouldFollow:A,totalCount:O}}),fe(({shouldFollow:O})=>O)),({followOutputBehavior:O,totalCount:L})=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("following output to ",{totalCount:L},rr.DEBUG),v(O)}):E=Kr(e,()=>{at(u)("following output to ",{totalCount:L},rr.DEBUG),v(O),E=null})});function w(O){const L=Kr(s,P=>{O&&!P.atBottom&&P.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(at(u)("scrolling to bottom due to increased size",{},rr.DEBUG),v("auto"))});setTimeout(L,100)}Ve(W(vt(me(b),t,l),fe(([O,,L])=>O&&L),mn(({value:O},[,L])=>({refreshed:O===L,value:L}),{refreshed:!1,value:0}),fe(({refreshed:O})=>O),Te(b,t)),([,O])=>{at(i)&&w(O!==!1)}),Ve(g,()=>{w(at(b)!==!1)}),Ve(vt(me(b),s),([O,L])=>{O&&!L.atBottom&&L.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const S=Y(null),T=De();return ce(rm(W(me(n),ne(O=>{var L;return(L=O==null?void 0:O.length)!=null?L:0})),W(me(t))),T),Ve(W(vt(W(T,pa(1)),c),Te(me(S),i,d,f),ne(([[O,L],P,h,y,x])=>L&&h&&(P==null?void 0:P({context:x,totalCount:O,scrollingInProgress:y}))),fe(O=>!!O),jn(0)),O=>{E&&(E(),E=null),at(r)?requestAnimationFrame(()=>{at(u)("scrolling into view",{}),Ce(m,O)}):E=Kr(e,()=>{at(u)("scrolling into view",{}),Ce(m,O),E=null})}),{autoscrollToBottom:g,followOutput:b,scrollIntoViewOnChange:S}},tt(hn,wc,bc,yc,ws,gs,Vt,zx,Rx)),Xj=Ge(([{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),ne(([[,c],l,u,d,f,m=[]])=>_x(c,l,u,d,f,m))),o),{}),tt(hn,yc,ha,ws),{singleton:!0}),Qj=Ge(([{didMount:e},{scrollTo:t},{listState:r}])=>{const n=Y(0);return Ve(W(e,Te(n),fe(([,s])=>s!==0),ne(([,s])=>({top:s}))),s=>{Kr(W(r,pa(1),fe(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{Ce(t,s)})})}),{initialScrollTop:n}},tt(ws,Vt,ha),{singleton:!0}),$x=Ge(([{scrollVelocity:e}])=>{const t=Y(!1),r=De(),n=Y(!1);return ce(W(e,Te(n,t,r),fe(([s,a])=>!!a),ne(([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),Ve(W(vt(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(wc),{singleton:!0}),hm=Ge(([{scrollContainerState:e,scrollTo:t}])=>{const r=De(),n=De(),s=De(),a=Y(!1),o=Y(void 0);return ce(W(vt(r,n),ne(([{scrollHeight:i,scrollTop:c,viewportHeight:l},{offsetTop:u}])=>({scrollHeight:i,scrollTop:Math.max(0,c-u),viewportHeight:l}))),e),ce(W(t,Te(n),ne(([i,{offsetTop:c}])=>({...i,top:i.top+c}))),s),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:n}},tt(Vt)),Jj=Ge(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:o,windowScrollContainerState:i,windowViewportRect:c}])=>{const l=De(),u=Y(void 0),d=Y(null),f=Y(null);return ce(i,d),ce(c,f),Ve(W(l,Te(t,n,o,d,f,r)),([m,b,g,E,v,w,S])=>{const T=Mj(b.sizeTree);E&&v!==null&&w!==null&&(g=v.scrollTop-w.offsetTop),g-=S,m({ranges:T,scrollTop:g})}),ce(W(u,fe(em),ne(eV)),s),ce(W(a,Te(u),fe(([,m])=>m!==void 0),rt(),ne(([,m])=>m.ranges)),e),{getState:l,restoreStateFrom:u}},tt(hn,Vt,yc,ws,hm));function eV(e){return{align:"start",index:0,offset:e.scrollTop}}const tV=Ge(([{topItemsIndexes:e}])=>{const t=Y(0);return ce(W(t,fe(r=>r>=0),ne(r=>Array.from({length:r}).map((n,s)=>s))),e),{topItemCount:t}},tt(ha));function Gx(e){let t=!1,r;return()=>(t||(t=!0,r=e()),r)}const rV=Gx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),nV=Ge(([{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:m},{recalcInProgress:b}])=>{const g=hr(W(c,Te(o),mn(([,v,w,S],[{bottom:T,items:O,offsetBottom:L,totalCount:P},h])=>{const y=T+L;let x=0;return w===P&&v.length>0&&O.length>0&&(O[0].originalIndex===0&&v[0].originalIndex===0||(x=y-S,x!==0&&(x+=h))),[x,O,P,y]},[0,[],0,0]),fe(([v])=>v!==0),Te(n,i,r,s,m,b),fe(([,v,w,S,,,T])=>!T&&!S&&v!==0&&w===gc),ne(([[v],,,,,w])=>(w("Upward scrolling compensation",{amount:v},rr.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 Ve(W(g,Te(e,a)),([v,w,S])=>{S&&rV()?Ce(e,w-v):E(-v)}),Ve(W(vt(zt(a,!1),e,b),fe(([v,w,S])=>!v&&!S&&w!==0),ne(([v,w])=>w),jn(1)),E),ce(W(d,ne(v=>({top:-v}))),t),Ve(W(l,Te(f,u),ne(([v,{groupIndices:w,lastSize:S,sizeTree:T},O])=>{function L(P){return P*(S+O)}if(w.length===0)return L(v);{let P=0;const h=fc(T,0);let y=0,x=0;for(;y<v;){y++,P+=h;let A=w.length===x+1?1/0:w[x+1]-w[x]-1;y+A>v&&(P-=h,A=v-y+1),y+=A,P+=L(A),x++}return P}})),v=>{Ce(e,v),requestAnimationFrame(()=>{Ce(t,{top:v}),requestAnimationFrame(()=>{Ce(e,0),Ce(b,!1)})})}),{deviation:e}},tt(Vt,wc,ha,hn,gs,cm)),sV=Ge(([e,t,r,n,s,a,o,i,c,l,u])=>({...e,...t,...r,...n,...s,...a,...o,...i,...c,...l,...u}),tt(fm,Xj,ws,$x,Lx,Qj,qj,hm,Rx,gs,zx)),jx=Ge(([{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:m},{initialItemFinalLocationReached:b,initialTopMostItemIndex:g,scrolledToInitialItem:E},v,w,S,T,{scrollToIndex:O},L,{topItemCount:P},{groupCounts:h},y])=>{const{listState:x,minOverscanItemCount:A,topItemsIndexes:B,rangeChanged:F,..._}=T;return ce(F,y.scrollSeekRangeChanged),ce(W(y.windowViewportRect,ne(k=>k.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:n,fixedGroupHeight:s,gap:a,groupCounts:h,heightEstimates:i,initialItemFinalLocationReached:b,initialTopMostItemIndex:g,scrolledToInitialItem:E,sizeRanges:l,topItemCount:P,topItemsIndexes:B,totalCount:f,...S,groupIndices:o,itemSize:c,listState:x,minOverscanItemCount:A,scrollToIndex:O,statefulTotalCount:d,trackItemSizes:m,rangeChanged:F,..._,...y,...v,sizes:u,...w}},tt(hn,yc,Vt,Jj,Zj,ha,bc,nV,tV,Ix,sV));function aV(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 Ku=typeof document<"u"?M.useLayoutEffect:M.useEffect;function Vx(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 S=E[t.required[w]];Ce(S,v[w])}for(const w of s)if(w in v){const S=E[t.optional[w]];Ce(S,v[w])}E.propsReady&&Ce(E.propsReady,!0)}function l(E){return a.reduce((v,w)=>(v[w]=S=>{const T=E[t.methods[w]];Ce(T,S)},v),{})}function u(E){return o.reduce((v,w)=>(v[w]=vj(E[t.events[w]]),v),{})}const d=M.forwardRef((E,v)=>{const{children:w,...S}=E,[T]=M.useState(()=>Gu(kj(e),P=>{c(P,S)})),[O]=M.useState(fx(u,T));Ku(()=>{for(const P of o)P in S&&Ve(O[P],S[P]);return()=>{Object.values(O).map(tm)}},[S,O,T]),Ku(()=>{c(T,S)}),M.useImperativeHandle(v,dx(l(T)));const L=r;return C.jsx(i.Provider,{value:T,children:r?C.jsx(L,{...aV([...n,...s,...o],S),children:w}):w})}),f=E=>{const v=M.useContext(i);return M.useCallback(w=>{Ce(v[E],w)},[v,E])},m=E=>{const v=M.useContext(i)[E],w=M.useCallback(S=>Ve(v,S),[v]);return M.useSyncExternalStore(w,()=>at(v),()=>at(v))},b=E=>{const v=M.useContext(i)[E],[w,S]=M.useState(fx(at,v));return Ku(()=>Ve(v,T=>{T!==w&&S(dx(T))}),[v,w]),w},g=M.version.startsWith("18")?m:b;return{Component:d,useEmitter:(E,v)=>{const w=M.useContext(i)[E];Ku(()=>Ve(w,v),[v,w])},useEmitterValue:g,usePublisher:f}}const Wx=M.createContext(void 0),qx=M.createContext(void 0),Kx=typeof document<"u"?M.useLayoutEffect:M.useEffect;function bm(e){return"self"in e}function oV(e){return"body"in e}function Yx(e,t,r,n=ko,s,a){const o=M.useRef(null),i=M.useRef(null),c=M.useRef(null),l=M.useCallback(f=>{let m,b,g;const E=f.target;if(oV(E)||bm(E)){const w=bm(E)?E:E.defaultView;g=a?w.scrollX:w.scrollY,m=a?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,b=a?w.innerWidth:w.innerHeight}else g=a?E.scrollLeft:E.scrollTop,m=a?E.scrollWidth:E.scrollHeight,b=a?E.offsetWidth:E.offsetHeight;const v=()=>{e({scrollHeight:m,scrollTop:Math.max(g,0),viewportHeight:b})};f.suppressFlushSync?v():Os.flushSync(v),i.current!==null&&(g===i.current||g<=0||g===m-b)&&(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 m=o.current;if(!m||(a?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const b=f.behavior==="smooth";let g,E,v;bm(m)?(E=Math.max(xs(m.document.documentElement,a?"width":"height"),a?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),g=a?m.innerWidth:m.innerHeight,v=a?window.scrollX:window.scrollY):(E=m[a?"scrollWidth":"scrollHeight"],g=xs(m,a?"width":"height"),v=m[a?"scrollLeft":"scrollTop"]);const w=E-g;if(f.top=Math.ceil(Math.max(Math.min(w,f.top),0)),Fx(g,E)||f.top===v){e({scrollHeight:E,scrollTop:v,viewportHeight:g}),b&&t(!0);return}b?(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}),m.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 ym="-webkit-sticky",Zx="sticky",gm=Gx(()=>{if(typeof document>"u")return Zx;const e=document.createElement("div");return e.style.position=ym,e.style.position===ym?ym:Zx});function xm(e){return e}const iV=Ge(()=>{const e=Y(i=>`Item ${i}`),t=Y(i=>`Group ${i}`),r=Y({}),n=Y(xm),s=Y("div"),a=Y(ko),o=(i,c=null)=>zt(W(r,ne(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")}}),cV=Ge(([e,t])=>({...e,...t}),tt(jx,iV)),lV=({height:e})=>C.jsx("div",{style:{height:e}}),uV={overflowAnchor:"none",position:gm(),zIndex:1},Xx={overflowAnchor:"none"},dV={...Xx,display:"inline-block",height:"100%"},Qx=M.memo(function({showTopList:e=!1}){const t=xe("listState"),r=Pr("sizeRanges"),n=xe("useWindowScroll"),s=xe("customScrollParent"),a=Pr("windowScrollContainerState"),o=Pr("scrollContainerState"),i=s||n?a:o,c=xe("itemContent"),l=xe("context"),u=xe("groupContent"),d=xe("trackItemSizes"),f=xe("itemSize"),m=xe("log"),b=Pr("gap"),g=xe("horizontalDirection"),{callbackRef:E}=Aj(r,f,d,e?ko:i,m,b,s,g,xe("skipAnimationFrameInResizeObserver")),[v,w]=M.useState(0);wm("deviation",_=>{v!==_&&w(_)});const S=xe("EmptyPlaceholder"),T=xe("ScrollSeekPlaceholder")||lV,O=xe("ListComponent"),L=xe("ItemComponent"),P=xe("GroupComponent"),h=xe("computeItemKey"),y=xe("isSeeking"),x=xe("groupIndices").length>0,A=xe("alignToBottom"),B=xe("initialItemFinalLocationReached"),F=e?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:v!==0?v:A?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:A?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...B?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&S?C.jsx(S,{...Rt(S,l)}):C.jsx(O,{...Rt(O,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,I=h(k+t.firstItemIndex,_.data,l);return y?M.createElement(T,{...Rt(T,l),height:_.size,index:_.index,key:I,type:_.type||"item",..._.type==="group"?{}:{groupIndex:_.groupIndex}}):_.type==="group"?M.createElement(P,{...Rt(P,l),"data-index":k,"data-item-index":_.index,"data-known-size":_.size,key:I,style:uV},u(_.index,l)):M.createElement(L,{...Rt(L,l),...hV(L,_.data),"data-index":k,"data-item-group-index":_.groupIndex,"data-item-index":_.index,"data-known-size":_.size,key:I,style:g?dV:Xx},x?c(_.index,_.groupIndex,_.data,l):c(_.index,_.data,l))})})}),pV={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},fV={outline:"none",overflowX:"auto",position:"relative"},Yu=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),mV={position:gm(),top:0,width:"100%",zIndex:1};function Rt(e,t){if(typeof e!="string")return{context:t}}function hV(e,t){return{item:typeof e=="string"?void 0:t}}const bV=M.memo(function(){const e=xe("HeaderComponent"),t=Pr("headerHeight"),r=xe("HeaderFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,xe("skipAnimationFrameInResizeObserver")),s=xe("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null}),yV=M.memo(function(){const e=xe("FooterComponent"),t=Pr("footerHeight"),r=xe("HeaderFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,xe("skipAnimationFrameInResizeObserver")),s=xe("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null});function Jx({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:m,scrollToCallback:b}=Yx(i,l,c,u,void 0,d);return e("scrollTo",b),e("scrollBy",f),C.jsx(c,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{...d?fV:pV,...s},tabIndex:0,...o,...Rt(c,a),children:n})})}function e5({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"),m=M.useRef(null),b=t("scrollerRef"),{scrollByCallback:g,scrollerRef:E,scrollToCallback:v}=Yx(i,l,c,b,f);return Kx(()=>{var w;return E.current=f||((w=m.current)==null?void 0:w.ownerDocument.defaultView),()=>{E.current=null}},[E,f]),e("windowScrollTo",v),e("scrollBy",g),C.jsx(c,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...u!==0?{height:u+d}:{}},...o,...Rt(c,a),children:n})})}const gV=({children:e})=>{const t=M.useContext(Wx),r=Pr("viewportHeight"),n=Pr("fixedItemHeight"),s=xe("alignToBottom"),a=xe("horizontalDirection"),o=M.useMemo(()=>px(r,c=>xs(c,a?"width":"height")),[r,a]),i=fa(o,!0,xe("skipAnimationFrameInResizeObserver"));return M.useEffect(()=>{t&&(r(t.viewportHeight),n(t.itemHeight))},[t,r,n]),C.jsx("div",{"data-viewport-type":"element",ref:i,style:Yu(s),children:e})},xV=({children:e})=>{const t=M.useContext(Wx),r=Pr("windowViewportRect"),n=Pr("fixedItemHeight"),s=xe("customScrollParent"),a=yx(r,s,xe("skipAnimationFrameInResizeObserver")),o=xe("alignToBottom");return M.useEffect(()=>{t&&(n(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,n]),C.jsx("div",{"data-viewport-type":"window",ref:a,style:Yu(o),children:e})},wV=({children:e})=>{const t=xe("TopItemListComponent")||"div",r=xe("headerHeight"),n={...mV,marginTop:`${r}px`},s=xe("context");return C.jsx(t,{style:n,...Rt(t,s),children:e})},vV=M.memo(function(e){const t=xe("useWindowScroll"),r=xe("topItemsIndexes").length>0,n=xe("customScrollParent"),s=xe("context");return C.jsxs(n||t?CV:kV,{...e,context:s,children:[r&&C.jsx(wV,{children:C.jsx(Qx,{showTopList:!0})}),C.jsxs(n||t?xV:gV,{children:[C.jsx(bV,{}),C.jsx(Qx,{}),C.jsx(yV,{})]})]})}),{Component:EV,useEmitter:wm,useEmitterValue:xe,usePublisher:Pr}=Vx(cV,{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"}},vV),kV=Jx({useEmitter:wm,useEmitterValue:xe,usePublisher:Pr}),CV=e5({useEmitter:wm,useEmitterValue:xe,usePublisher:Pr}),t5=EV;tt(jx,Ge(()=>{const e=Y(l=>C.jsxs("td",{children:["Item $",l]})),t=Y(null),r=Y(l=>C.jsxs("td",{colSpan:1e3,children:["Group ",l]})),n=Y(null),s=Y(null),a=Y({}),o=Y(xm),i=Y(ko),c=(l,u=null)=>zt(W(a,ne(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")}})),gm();const r5={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},TV={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:n5,floor:Zu,max:kc,min:vm,round:s5}=Math;function a5(e,t,r){return Array.from({length:t-e+1}).map((n,s)=>({data:r===null?null:r[s+e],index:s+e}))}function AV(e){return{...TV,items:e}}function Xu(e,t){return e&&e.width===t.width&&e.height===t.height}function SV(e,t){return e&&e.column===t.column&&e.row===t.row}const PV=Ge(([{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,m,{didMount:b,propsReady:g},{customScrollParent:E,useWindowScroll:v,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:T},O])=>{const L=Y(0),P=Y(0),h=Y(r5),y=Y({height:0,width:0}),x=Y({height:0,width:0}),A=De(),B=De(),F=Y(0),_=Y(null),k=Y({column:0,row:0}),I=De(),D=De(),U=Y(!1),z=Y(0),H=Y(!0),j=Y(!1),Q=Y(!1);Ve(W(b,Te(z),fe(([X,ve])=>!!ve)),()=>{Ce(H,!1)}),Ve(W(vt(b,H,x,y,z,j),fe(([X,ve,Me,je,,it])=>X&&!ve&&Me.height!==0&&je.height!==0&&!it)),([,,,,X])=>{Ce(j,!0),dm(1,()=>{Ce(A,X)}),Kr(W(l),()=>{Ce(t,[0,0]),Ce(H,!0)})}),ce(W(D,fe(X=>X!=null&&X.scrollTop>0),fn(0)),P),Ve(W(b,Te(D),fe(([,X])=>X!=null)),([,X])=>{X&&(Ce(y,X.viewport),Ce(x,X.item),Ce(k,X.gap),X.scrollTop>0&&(Ce(U,!0),Kr(W(l,pa(1)),ve=>{Ce(U,!1)}),Ce(c,{top:X.scrollTop})))}),ce(W(y,ne(({height:X})=>X)),d),ce(W(vt(me(y,Xu),me(x,Xu),me(k,(X,ve)=>X&&X.column===ve.column&&X.row===ve.row),me(l)),ne(([X,ve,Me,je])=>({gap:Me,item:ve,scrollTop:je,viewport:X}))),I),ce(W(vt(me(L),n,me(k,SV),me(x,Xu),me(y,Xu),me(_),me(P),me(U),me(H),me(z)),fe(([,,,,,,,X])=>!X),ne(([X,[ve,Me],je,it,Ae,Ee,ye,,Xe,Ye])=>{const{column:Qe,row:Or}=je,{height:Ut,width:Sm}=it,{width:H5}=Ae;if(ye===0&&(X===0||H5===0))return r5;if(Sm===0){const W5=pm(Ye,X),nq=W5+Math.max(ye-1,0);return AV(a5(W5,nq,Ee))}const ed=o5(H5,Sm,Qe);let Lo,Aa;Xe?ve===0&&Me===0&&ye>0?(Lo=0,Aa=ye-1):(Lo=ed*Zu((ve+Or)/(Ut+Or)),Aa=ed*n5((Me+Or)/(Ut+Or))-1,Aa=vm(X-1,kc(Aa,ed-1)),Lo=vm(Aa,kc(0,Lo))):(Lo=0,Aa=-1);const $5=a5(Lo,Aa,Ee),{bottom:G5,top:j5}=i5(Ae,je,it,$5),V5=n5(X/ed),rq=V5*Ut+(V5-1)*Or-G5;return{bottom:G5,itemHeight:Ut,items:$5,itemWidth:Sm,offsetBottom:rq,offsetTop:j5,top:j5}})),h),ce(W(_,fe(X=>X!==null),ne(X=>X.length)),L),ce(W(vt(y,x,h,k),fe(([X,ve,{items:Me}])=>Me.length>0&&ve.height!==0&&X.height!==0),ne(([X,ve,{items:Me},je])=>{const{bottom:it,top:Ae}=i5(X,je,ve,Me);return[Ae,it]}),rt(mc)),t);const pe=Y(!1);ce(W(l,Te(pe),ne(([X,ve])=>ve||X!==0)),pe);const be=hr(W(vt(h,L),fe(([{items:X}])=>X.length>0),Te(pe),fe(([[X,ve],Me])=>{const je=X.items[X.items.length-1].index===ve-1;return(Me||X.bottom>0&&X.itemHeight>0&&X.offsetBottom===0&&X.items.length===ve)&&je}),ne(([[,X]])=>X-1),rt())),ie=hr(W(me(h),fe(({items:X})=>X.length>0&&X[0].index===0),fn(0),rt())),de=hr(W(me(h),Te(U),fe(([{items:X},ve])=>X.length>0&&!ve),ne(([{items:X}])=>({endIndex:X[X.length-1].index,startIndex:X[0].index})),rt(Cx),jn(0)));ce(de,m.scrollSeekRangeChanged),ce(W(A,Te(y,x,L,k),ne(([X,ve,Me,je,it])=>{const Ae=Bx(X),{align:Ee,behavior:ye,offset:Xe}=Ae;let Ye=Ae.index;Ye==="LAST"&&(Ye=je-1),Ye=kc(0,Ye,vm(je-1,Ye));let Qe=Em(ve,it,Me,Ye);return Ee==="end"?Qe=s5(Qe-ve.height+Me.height):Ee==="center"&&(Qe=s5(Qe-ve.height/2+Me.height/2)),Xe&&(Qe+=Xe),{behavior:ye,top:Qe}})),c);const Oe=zt(W(h,ne(X=>X.offsetBottom+X.bottom)),0);return ce(W(T,ne(X=>({height:X.visibleHeight,width:X.visibleWidth}))),y),{customScrollParent:E,data:_,deviation:F,footerHeight:s,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:P,itemDimensions:x,overscan:r,restoreStateFrom:D,scrollBy:o,scrollContainerState:i,scrollHeight:B,scrollTo:c,scrollToIndex:A,scrollTop:l,smoothScrollTargetReached:u,totalCount:L,useWindowScroll:v,viewportDimensions:y,windowScrollContainerState:w,windowScrollTo:S,windowViewportRect:T,...m,gridState:h,horizontalDirection:Q,initialTopMostItemIndex:z,totalListHeight:Oe,...f,endReached:be,propsReady:g,rangeChanged:de,startReached:ie,stateChanged:I,stateRestoreInProgress:U,...O}},tt(fm,Vt,wc,$x,ws,hm,gs));function o5(e,t,r){return kc(1,Zu((e+r)/(Zu(t)+r)))}function i5(e,t,r,n){const{height:s}=r;if(s===void 0||n.length===0)return{bottom:0,top:0};const a=Em(e,t,r,n[0].index);return{bottom:Em(e,t,r,n[n.length-1].index)+s,top:a}}function Em(e,t,r,n){const s=o5(e.width,r.width,t.column),a=Zu(n/s),o=a*r.height+kc(0,a-1)*t.row;return o>0?o+t.row:o}const IV=Ge(()=>{const e=Y(d=>`Item ${d}`),t=Y({}),r=Y(null),n=Y("virtuoso-grid-item"),s=Y("virtuoso-grid-list"),a=Y(xm),o=Y("div"),i=Y(ko),c=(d,f=null)=>zt(W(t,ne(m=>m[d]),rt()),f),l=Y(!1),u=Y(!1);return ce(me(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")}}),BV=Ge(([e,t])=>({...e,...t}),tt(PV,IV)),FV=M.memo(function(){const e=ot("gridState"),t=ot("listClassName"),r=ot("itemClassName"),n=ot("itemContent"),s=ot("computeItemKey"),a=ot("isSeeking"),o=Ir("scrollHeight"),i=ot("ItemComponent"),c=ot("ListComponent"),l=ot("ScrollSeekPlaceholder"),u=ot("context"),d=Ir("itemDimensions"),f=Ir("gap"),m=ot("log"),b=ot("stateRestoreInProgress"),g=Ir("reportReadyState"),E=fa(M.useMemo(()=>v=>{const w=v.parentElement.parentElement.scrollHeight;o(w);const S=v.firstChild;if(S){const{height:T,width:O}=S.getBoundingClientRect();d({height:T,width:O})}f({column:l5("column-gap",getComputedStyle(v).columnGap,m),row:l5("row-gap",getComputedStyle(v).rowGap,m)})},[o,d,f,m]),!0,!1);return Kx(()=>{e.itemHeight>0&&e.itemWidth>0&&g(!0)},[e]),b?null:C.jsx(c,{className:t,ref:E,...Rt(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?C.jsx(l,{...Rt(l,u),height:e.itemHeight,index:v.index,width:e.itemWidth},w):M.createElement(i,{...Rt(i,u),className:r,"data-index":v.index,key:w},n(v.index,v.data,u))})})}),OV=M.memo(function(){const e=ot("HeaderComponent"),t=Ir("headerHeight"),r=ot("headerFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,!1),s=ot("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null}),UV=M.memo(function(){const e=ot("FooterComponent"),t=Ir("footerHeight"),r=ot("headerFooterTag"),n=fa(M.useMemo(()=>a=>{t(xs(a,"height"))},[t]),!0,!1),s=ot("context");return e?C.jsx(r,{ref:n,children:C.jsx(e,{...Rt(e,s)})}):null}),DV=({children:e})=>{const t=M.useContext(qx),r=Ir("itemDimensions"),n=Ir("viewportDimensions"),s=fa(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]),C.jsx("div",{ref:s,style:Yu(!1),children:e})},_V=({children:e})=>{const t=M.useContext(qx),r=Ir("windowViewportRect"),n=Ir("itemDimensions"),s=ot("customScrollParent"),a=yx(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]),C.jsx("div",{ref:a,style:Yu(!1),children:e})},MV=M.memo(function({...e}){const t=ot("useWindowScroll"),r=ot("customScrollParent"),n=r||t?LV:NV,s=r||t?_V:DV,a=ot("context");return C.jsx(n,{...e,...Rt(n,a),children:C.jsxs(s,{children:[C.jsx(OV,{}),C.jsx(FV,{}),C.jsx(UV,{})]})})}),{useEmitter:c5,useEmitterValue:ot,usePublisher:Ir}=Vx(BV,{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"}},MV),NV=Jx({useEmitter:c5,useEmitterValue:ot,usePublisher:Ir}),LV=e5({useEmitter:c5,useEmitterValue:ot,usePublisher:Ir});function l5(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,rr.WARN),t==="normal"?0:parseInt(t??"0",10)}var km={},u5;function zV(){if(u5)return km;u5=1;var e=bu.GenIcon;return km.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)},km}var RV=zV();function d5({logo:e,className:t="",style:r={},alt:n="Token logo"}){const[s,a]=M.useState(!1);return M.useEffect(()=>{a(!1)},[e]),e&&!s?C.jsx("img",{alt:n,style:r,onError:()=>a(!0),className:`twap-token-logo ${t}`,src:e}):C.jsx(RV.AiFillQuestionCircle,{style:{width:20,height:20},className:"twap-token-svg"})}var Cm={},p5;function HV(){if(p5)return Cm;p5=1;var e=bu.GenIcon;return Cm.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)},Cm}var f5=HV();const $V=({count:e})=>{const t=Ie(),r=ee(n=>n.updateState);return C.jsxs("div",{className:"twap-orders__selected-order-fills-button",onClick:()=>r({showSelectedOrderFills:!0}),children:[C.jsxs("p",{children:[t("orderFills")," ",C.jsxs("span",{className:"twap-orders__selected-order-fills-button-count",children:["(",e,")"]})]}),C.jsx(V6.IoIosArrowDown,{})]})},m5=({token:e})=>{const{components:t}=re();return C.jsxs("div",{className:"twap-orders__selected-order-fills-token",children:[t.TokenLogo?C.jsx(t.TokenLogo,{token:e}):C.jsx(d5,{logo:e==null?void 0:e.logoUrl}),C.jsx("p",{className:"twap-orders__selected-order-fills-token-symbol",children:e==null?void 0:e.symbol})]})},GV=({srcToken:e,dstToken:t})=>C.jsxs("div",{className:"twap-orders__selected-order-fills-tokens",children:[C.jsx(m5,{token:e}),C.jsx("span",{className:"twap-orders__selected-order-fills-token-separator",children:C.jsx(f5.HiArrowRight,{})}),C.jsx(m5,{token:t})]}),jV=({fill:e,index:t,srcToken:r,dstToken:n})=>{const s=qr(r==null?void 0:r.decimals,e.inAmount),a=qr(n==null?void 0:n.decimals,e.outAmount),o=Ru(e.timestamp),i=zu(e.txHash),c=Ie();return C.jsxs(he,{className:"twap-fills-view__item",children:[C.jsx(he.DetailRow,{title:c("fillIndex"),className:"twap-fills-view__item-index",children:C.jsx("p",{children:`#${t}`})}),C.jsx(he.DetailRow,{title:c("fillTimestamp"),className:"twap-fills-view__item-date",children:o}),C.jsxs(he.DetailRow,{title:c("fillAmountOut"),className:"twap-fills-view__item-amount-in",children:[C.jsx(pn,{value:s})," ",(r==null?void 0:r.symbol)??""]}),C.jsxs(he.DetailRow,{title:c("fillAmountReceived"),className:"twap-fills-view__item-amount-out",children:[C.jsx(pn,{value:a})," ",(n==null?void 0:n.symbol)??""]}),e.txHash&&C.jsx(he.DetailRow,{title:c("fillTransactionHash"),className:"twap-fills-view__item-tx",children:C.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:e.txHash,children:Nl(e.txHash)})})]})},VV=({order:e})=>{var n;const t=Ie(),r=((n=e.original)==null?void 0:n.fills)??[];return C.jsxs("div",{className:"twap-orders__selected-order-fills",children:[C.jsx(GV,{srcToken:e.srcToken,dstToken:e.dstToken}),r.length===0?C.jsx("p",{className:"twap-orders__selected-order-fills-empty",children:t("noFills")}):C.jsx("div",{className:"twap-orders__selected-order-fills-list",children:C.jsx(t5,{style:{height:"100%"},totalCount:r.length,itemContent:s=>{const a=r[s];return a?C.jsx(jV,{fill:a,index:s+1,srcToken:e.srcToken,dstToken:e.dstToken}):null}})})]})},h5=M.createContext({}),Ht=()=>M.useContext(h5),WV=()=>{const e=ee(f=>f.state.selectedOrderID),t=ex(e),r=Ie(),[n,s]=M.useState("panel1"),a=ee(f=>f.updateState),o=ee(f=>f.state.showSelectedOrderFills),{components:i}=re(),c=i.TokenLogo;M.useEffect(()=>{s("panel1"),a({showSelectedOrderFills:!1})},[t==null?void 0:t.id.value]);const l=f=>{s(n===f?!1:f)};if(!t)return null;const u=t.fills??[],d=o?C.jsx(VV,{order:t}):C.jsxs(C.Fragment,{children:[C.jsx(p1,{SrcTokenLogo:c&&C.jsx(c,{token:t.srcToken}),DstTokenLogo:c&&C.jsx(c,{token:t.dstToken}),fromTitle:r("from"),inToken:t.srcToken,toTitle:r("to"),outToken:t.dstToken}),C.jsx(he.Container,{children:C.jsxs("div",{className:"twap-orders__selected-order-bottom",children:[C.jsxs("div",{className:"twap-orders__selected-order-accordions",children:[C.jsx(b5,{title:r("executionSummary"),onClick:()=>l("panel1"),expanded:n==="panel1",children:C.jsx(tW,{})}),C.jsx(b5,{title:r("orderInfo"),expanded:n==="panel2",onClick:()=>l("panel2"),children:C.jsx(qV,{})}),C.jsx($V,{count:u.length})]}),C.jsx(nW,{})]})})]});return C.jsx(h5.Provider,{value:{order:t},children:C.jsx("div",{className:`twap-orders__selected-order ${`twap-orders__selected-order-${t.original.status.toLowerCase()}`}`,children:d})})},b5=({expanded:e,onClick:t,children:r,title:n})=>C.jsxs("div",{className:"twap-orders__selected-order-accordion",children:[C.jsxs("div",{onClick:t,className:"twap-orders__selected-order-accordion-trigger",children:[C.jsx("p",{children:n}),C.jsx(V6.IoIosArrowDown,{style:{transform:e?"rotate(180deg)":"rotate(0deg)"}})]}),e&&C.jsx("div",{className:"twap-orders__selected-order-accordion-details",children:r})]}),qV=()=>C.jsxs(he,{children:[C.jsx(eW,{}),C.jsx(sW,{}),C.jsx(XV,{}),C.jsx(aW,{}),C.jsx(KV,{}),C.jsx(YV,{}),C.jsx(ZV,{}),C.jsx(QV,{}),C.jsx(JV,{}),C.jsx(uW,{}),C.jsx(he.Recipient,{})]}),KV=()=>{const{order:e}=Ht();return C.jsx(he.TradeSize,{tradeSize:e.sizePerTrade.value,srcToken:e.srcToken,label:e.sizePerTrade.label,tooltip:e.sizePerTrade.tooltip,trades:e.totalTrades.value})},YV=()=>{const{order:e}=Ht();return C.jsx(he.TradesAmount,{trades:e.totalTrades.value,label:e.totalTrades.label,tooltip:e.totalTrades.tooltip})},ZV=()=>{const{order:e}=Ht();return C.jsx(he.MinDestAmount,{dstToken:e.dstToken,dstMinAmountOut:e.minDestAmountPerTrade.value,label:e.minDestAmountPerTrade.label,tooltip:e.minDestAmountPerTrade.tooltip})},XV=()=>{const{order:e}=Ht();return C.jsx(he.Deadline,{deadline:e.deadline.value,label:e.deadline.label,tooltip:e.deadline.tooltip})},QV=()=>{const{order:e}=Ht();return C.jsx(he.TradeInterval,{fillDelayMillis:e.tradeInterval.value,chunks:e.totalTrades.value,label:e.tradeInterval.label,tooltip:e.tradeInterval.tooltip})},JV=()=>{const{order:e}=Ht();return C.jsx(he.Price,{srcToken:e.srcToken,dstToken:e.dstToken,price:e.triggerPrice.value,label:e.triggerPrice.label,tooltip:e.triggerPrice.tooltip})},eW=()=>{const{order:e}=Ht();return C.jsx(he.OrderID,{id:e.id.value||""})},tW=()=>C.jsxs(he,{children:[C.jsx(cW,{}),C.jsx(oW,{}),C.jsx(rW,{}),C.jsx(lW,{}),C.jsx(dW,{})]}),rW=()=>{var t;const{order:e}=Ht();return e.amountOutFilled.value?C.jsx(he.DetailRow,{title:e.amountOutFilled.label,children:C.jsxs("p",{children:[C.jsx(pn,{value:e.amountOutFilled.value})," ",(t=e.dstToken)==null?void 0:t.symbol]})}):null},nW=()=>{const{order:e}=Ht(),t=Ie(),{mutateAsync:r,isPending:n}=lx(),{components:s}=re(),a=s.Button,o=M.useCallback(async()=>r({orders:[e.original]}),[r,e]);return!e||e.original.status!==ut.Open||!a?null:C.jsx(a,{loading:n,onClick:o,disabled:n,className:"twap-cancel-order",text:t("cancelOrder"),children:t("cancelOrder")})},sW=()=>{const{order:e}=Ht(),t=Ie(),r=Ru(e.createdAt.value);return C.jsx(he.DetailRow,{title:t("createdAt")||"",children:C.jsx("p",{children:r})})},aW=()=>{var r;const{order:e}=Ht(),t=Ie();return C.jsx(he.DetailRow,{title:t("amountOut")||"",children:C.jsxs("p",{children:[C.jsx(pn,{value:e.srcAmount.value,decimalScale:3})," ",(r=e.srcToken)==null?void 0:r.symbol]})})},oW=()=>{var t;const{order:e}=Ht();return C.jsx(he.DetailRow,{title:e.amountInFilled.label,children:C.jsxs("p",{children:[C.jsx(pn,{value:e.amountInFilled.value,decimalScale:3})," ",(t=e.srcToken)==null?void 0:t.symbol]})})},iW=()=>{const{order:e}=Ht(),t=Ie();return M.useMemo(()=>{switch(e.original.status){case ut.Open:return t("Open")||"";case ut.Completed:return t("Completed")||"";case ut.Expired:return t("Expired")||"";case ut.Cancelled:return t("Cancelled")||""}},[e.original.status,t])},cW=()=>{const e=Ie(),t=iW();return C.jsx(he.DetailRow,{title:e("status")||"",children:C.jsx("p",{children:t})})},lW=()=>{const{order:e}=Ht();return C.jsx(he.DetailRow,{title:e.progress.label,children:C.jsxs("p",{children:[C.jsx(pn,{value:e.progress.value||0,decimalScale:2}),"%"]})})},uW=()=>{const{order:e}=Ht(),t=Ie();return e.limitPrice.value?C.jsx(he.Price,{label:t("limitPrice")||"",price:e.limitPrice.value,srcToken:e.srcToken,dstToken:e.dstToken,tooltip:e.limitPrice.tooltip}):null},dW=()=>{const{order:e}=Ht();return e.executionPrice.value?C.jsx(he.Price,{label:e.executionPrice.label,price:e.executionPrice.value,srcToken:e.srcToken,dstToken:e.dstToken}):null},pW=()=>C.jsx("div",{className:"twap-orders__loader",children:C.jsx("p",{children:"Loading..."})}),fW=()=>{const{isLoading:e}=vo(),t=ox(),r=ee(a=>a.state.orderIdsToCancel),n=ee(a=>a.state.cancelOrdersMode),s=fj();return C.jsx(C.Fragment,{children:e?C.jsx(pW,{}):t!=null&&t.length?C.jsx("div",{className:`twap-orders__list ${n?"twap-orders__list-select-mode":""}`,children:C.jsx(t5,{style:{height:"100%"},data:t,itemContent:(a,o)=>C.jsx(mW,{cancelOrdersMode:!!n,selected:(r==null?void 0:r.includes(o.id))||!1,selectOrder:s,order:o},a)})}):C.jsx(hW,{})})},mW=({order:e,selectOrder:t,selected:r,cancelOrdersMode:n})=>{const s=ee(i=>i.updateState),a=Et.useCallback(()=>{s({selectedOrderID:e==null?void 0:e.id})},[s,e==null?void 0:e.id]),o=Et.useCallback(()=>{n?t(e==null?void 0:e.id):a()},[n,t,a,e==null?void 0:e.id]);return C.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:C.jsxs("div",{className:"twap-orders__list-item-content",children:[C.jsx(bW,{order:e}),C.jsx(yW,{value:e.progress||0}),C.jsxs("div",{className:"twap-orders__list-item-tokens",children:[C.jsx(y5,{address:e.srcTokenAddress}),C.jsx(f5.HiArrowRight,{className:"twap-orders__list-item-tokens-arrow"}),C.jsx(y5,{address:e.dstTokenAddress})]})]})})},hW=()=>{const e=ee(s=>s.state.orderHistoryStatusFilter),t=ix(),r=Ie(),n=t(e);return C.jsx("div",{className:"twap-orders__list-empty",children:C.jsx("p",{children:r("noOrders",{status:n})})})},bW=({order:e})=>{const t=e&&e.status,r=nx(e),n=Ru(e.createdAt);return C.jsxs("div",{className:"twap-orders__list-item-header",children:[C.jsxs("p",{className:"twap-orders__list-item-header-title",children:[r," ",C.jsx("span",{children:`(${n})`})]}),C.jsx("p",{className:"twap-orders__list-item-header-status",children:t})]})},y5=e=>{const{useToken:t,components:r}=re(),n=t==null?void 0:t(e.address);return C.jsx("div",{className:"twap-orders__list-item-token",children:n?C.jsxs(C.Fragment,{children:[C.jsx("div",{className:"twap-orders__list-item-token-logo",children:r.TokenLogo?C.jsx(r.TokenLogo,{token:n}):C.jsx(d5,{logo:n==null?void 0:n.logoUrl})}),C.jsx("p",{className:"twap-orders__list-item-token-symbol",children:n==null?void 0:n.symbol})]}):C.jsx("div",{})})};function yW(e){return C.jsxs("div",{className:"twap-orders__list-item-progress",children:[C.jsx("div",{className:"twap-orders__list-item-progress-bar",children:C.jsx("div",{className:"twap-orders__list-item-progress-bar-filled",style:{width:`${e.value}%`}})}),C.jsx("div",{className:"twap-orders__list-item-token-progress-label",children:C.jsx("p",{children:`${Math.round(e.value)}%`})})]})}const gW=()=>{const e=ee(r=>r.state.selectedOrderID),t=e!==void 0;return C.jsx("div",{className:`twap-orders ${e!==void 0?"twap-orders__show-selected":""}`,children:t?C.jsx(WV,{}):C.jsx(fW,{})})},xW=e=>{const t=Ie(),{marketPrice:r,typedInputAmount:n}=re();return M.useMemo(()=>{const{isError:a,value:o}=vh(e);if(!(!a||G(n||"0").isZero()||!r))return{type:Dt.MIN_FILL_DELAY,value:o,message:t("minFillDelayError",{fillDelay:`${Vf(o)} ${t("minutes")}`})}},[e,t,n,r])},vs=()=>{const{callbacks:e}=re(),t=ee(a=>a.state.typedFillDelay),r=ee(a=>a.updateState),n=M.useMemo(()=>t||Nc,[t]),s=xW(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}},wW=()=>{const{onChange:e,fillDelay:t,error:r}=vs(),n=Ie(),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")}},Zr=()=>{const{srcToken:e,typedInputAmount:t}=re(),r=Ie(),s=ee(a=>a.state.swapExecution.acceptedSrcAmount)||t;return{amountWei:Q2(e==null?void 0:e.decimals,s),amountUI:s,error:G(s||0).isZero()?r("enterAmount"):void 0}},vW=(e,t)=>{const{module:r,srcUsd1Token:n,marketPrice:s,minChunkSizeUsd:a,typedInputAmount:o}=re(),i=Ie();return M.useMemo(()=>{if(G(o||"0").isZero()||!s||G(n||"0").isZero())return;if(!e)return{type:Dt.MIN_CHUNKS,value:1,message:i("minChunksError",{minChunks:"1"})};const{isError:c}=kh(e,t,r);if(c)return{type:Dt.MAX_CHUNKS,value:t,message:i("maxChunksError",{maxChunks:`${t}`})};const{isError:l,value:u}=Eh(o||"",n||"",a||0);if(l)return{type:Dt.MIN_TRADE_SIZE,value:u,message:i("minTradeSizeError",{minTradeSize:`${u}`})}},[e,t,r,o,n,a,i,s])},Br=()=>{const{srcToken:e,srcUsd1Token:t,module:r,minChunkSizeUsd:n}=re(),s=ee(g=>g.state.typedChunks),a=vs().fillDelay,o=ee(g=>g.updateState),{amountWei:i,amountUI:c}=Zr(),l=M.useMemo(()=>dh(a,c||"",t||"",n||0),[c,t,n,a]),u=M.useMemo(()=>uh(l,r,s),[l,s,r]),d=M.useCallback(g=>o({typedChunks:g}),[o]),f=M.useMemo(()=>mh(i||"",u),[i,u]),m=qr(e==null?void 0:e.decimals,f),b=M.useMemo(()=>t?G(m||"0").times(t||0).toString():"0",[m,t]);return{totalTrades:u,maxTrades:l,amountPerTradeUI:m,amountPerTradeWei:f,amountPerTradeUsd:b,onChange:d,error:vW(u,l)}},EW=()=>{const{srcToken:e,dstToken:t}=re(),r=Ie(),{onChange:n,totalTrades:s,amountPerTradeUsd:a,amountPerTradeUI:o,error:i,maxTrades:c,amountPerTradeWei:l}=Br(),u=Ar({value:o}),d=Ar({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}},kW=e=>{const{module:t,marketPrice:r}=re(),n=Ie();return M.useMemo(()=>{const s=xh(t,e),a=wh(e);if(r){if(s.isError)return{type:Dt.MAX_ORDER_DURATION,value:s.value,message:n("maxDurationError",{duration:`${Math.floor(s6(s.value)).toFixed(0)} ${n("days")}`})};if(a.isError)return{type:Dt.MIN_ORDER_DURATION,value:a.value,message:n("minDurationError",{duration:`${Math.floor(Vf(a.value)).toFixed(0)} ${n("minutes")}`})}}},[e,n,t,r])},Tm=()=>{const{module:e,callbacks:t}=re(),r=ee(c=>c.state.typedDuration),n=ee(c=>c.updateState),s=Br().totalTrades,a=vs().fillDelay,o=M.useMemo(()=>lh(e,s,a,r),[s,a,r,e]),i=kW(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}},CW=()=>{const{module:e}=re(),t=Ie(),{duration:r,setDuration:n,error:s}=Tm(),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===ge.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}},TW=()=>{const e=ee(a=>a.state.isMarketOrder),{module:t}=re(),r=Ie(),n=M.useMemo(()=>{if(e&&t===ge.STOP_LOSS)return{text:r("triggerMarketPriceDisclaimer"),url:hd}},[e,r,t]),s=M.useMemo(()=>{if(!(t!==ge.LIMIT&&t!==ge.TWAP))return{text:r(e?"marketOrderWarning":"limitPriceMessage"),url:"https://www.orbs.com/dtwap-and-dlimit-faq/"}},[e,r,t]);return n||s},Qu=()=>{const{srcToken:e,dstToken:t,marketPriceLoading:r}=re(),n=ee(l=>l.updateState),s=ee(l=>l.state.isInvertedTrade),a=ee(l=>l.state.typedTriggerPrice),o=ee(l=>l.state.typedLimitPrice),i=ee(l=>l.state.isMarketOrder);return{onInvert:M.useCallback(()=>{a!==void 0&&n({typedTriggerPrice:G(1).div(a).toFixed()}),o!==void 0&&n({typedLimitPrice:G(1).div(o).toFixed()}),n({isInvertedTrade:!s})},[n,s,a,o,r]),isInverted:s,fromToken:s?t:e,toToken:s?e:t,isMarketPrice:i}},g5=({typedValue:e,tokenDecimals:t=18,initialPrice:r="0",percentage:n,setValue:s,setPercentage:a})=>{const{srcUsd1Token:o,dstUsd1Token:i}=re(),{isInverted:c}=Qu(),l=M.useMemo(()=>G((()=>{if(e!==void 0){const E=c?G(e).isZero()?G(0):G(1).div(e):G(e);return Ml(E.toFixed(),t)}if(n!==void 0&&G(r||"0").gt(0)&&!G(r||"0").isNaN()){const E=G(r||"0"),v=G(n||0).div(100);return E.plus(E.multipliedBy(v)).decimalPlaces(0).toFixed()}return G(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||G(r).isZero())return"";if(n!=null)return n;if(l){const g=G(r),v=G(l).minus(g).div(g).multipliedBy(100).decimalPlaces(2).toString();return G(v||"0").isZero()?"":v}return""},[l,r,n]),m=M.useMemo(()=>{let g="";if(e!==void 0)g=e;else{const E=oa(l,t);if(G(E||"0").isZero())return"";g=c?G(1).div(E).toFixed():E}return g},[e,t,l,c]),b=bs(c?o:i,m||"0");return{amountWei:G(l).isNaN()?"":l,amountUI:G(m).isNaN()?"":m,selectedPercentage:f,onChange:u,onPercentageChange:d,isInverted:c,usd:G(b).isNaN()?"":b,isTypedValue:e!==void 0}},AW=()=>{const{module:e}=re();return M.useMemo(()=>e===ge.STOP_LOSS?eh:th,[e])},Am=()=>{const{module:e}=re(),t=ee(r=>r.state.isMarketOrder);return M.useMemo(()=>e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT||t?void 0:e===ge.STOP_LOSS?rh:nh,[e,t])},SW=(e="")=>{const{module:t,marketPrice:r,typedInputAmount:n}=re(),s=Ie();return M.useMemo(()=>{if(G(n||"0").isZero()||!r||t!==ge.STOP_LOSS&&t!==ge.TAKE_PROFIT)return;const a=hh(r||"",e||"",t);if(a!=null&&a.isError)return{type:Dt.STOP_LOSS_TRIGGER_PRICE_GREATER_THAN_MARKET_PRICE,value:a.value,message:s("StopLossTriggerPriceError")||""};const o=bh(r||"",e||"",t);if(o!=null&&o.isError)return{type:Dt.TAKE_PROFIT_TRIGGER_PRICE_LESS_THAN_MARKET_PRICE,value:o.value,message:s("TakeProfitTriggerPriceError")||""};if(!e||G(e||0).isZero())return{type:Dt.EMPTY_TRIGGER_PRICE,value:e,message:s("emptyTriggerPrice")||""}},[r,e,t,s,n])},PW=e=>{const{srcToken:t,dstToken:r,module:n,dstUsd1Token:s}=re(),a=Br().amountPerTradeWei,o=ee(l=>l.state.isMarketOrder),i=M.useMemo(()=>ch(n,a,e,(t==null?void 0:t.decimals)||0),[e,a,o,t==null?void 0:t.decimals,n]),c=qr((r==null?void 0:r.decimals)||0,i);return{amountWei:i,amountUI:c,usd:bs(c,s)}},Es=()=>{const{dstToken:e,marketPrice:t,module:r,callbacks:n}=re(),s=ee(b=>b.updateState),a=AW(),o=ee(b=>b.state.triggerPricePercent),i=o===void 0?a:o,c=r===ge.STOP_LOSS||r===ge.TAKE_PROFIT,l=g5({typedValue:ee(b=>b.state.typedTriggerPrice),percentage:i,tokenDecimals:(e==null?void 0:e.decimals)||18,initialPrice:c?t:void 0,setValue:M.useCallback(b=>{var g;s({typedTriggerPrice:b}),(g=n==null?void 0:n.onTriggerPriceChange)==null||g.call(n,b||"")},[s,n]),setPercentage:M.useCallback(b=>{var g;s({triggerPricePercent:b}),(g=n==null?void 0:n.onTriggerPricePercentChange)==null||g.call(n,b||"")},[s,n])}),u=SW(l.amountWei),{amountWei:d,amountUI:f,usd:m}=PW(l.amountWei);return M.useMemo(()=>({...l,error:u,pricePerChunkWei:d,pricePerChunkUI:f,pricePerChunkUsd:m}),[l,u,d,f,m])},IW=()=>{const{module:e,marketPrice:t,marketPriceLoading:r}=re(),n=Ie(),{amountUI:s,onChange:a,onPercentageChange:o,usd:i,selectedPercentage:c,error:l,pricePerChunkUI:u,pricePerChunkUsd:d,isTypedValue:f}=Es(),m=ee(O=>O.state.isMarketOrder),b=ee(O=>O.updateState),{isInverted:g,onInvert:E,fromToken:v,toToken:w}=Qu(),S=M.useCallback(()=>{b({triggerPricePercent:void 0,typedTriggerPrice:void 0})},[b]),T=e!==ge.STOP_LOSS&&e!==ge.TAKE_PROFIT;return{price:s,amountPerChunk:u,amountPerChunkUsd:d,error:l,label:n("stopLossLabel"),tooltip:e===ge.STOP_LOSS?n("stopLossTooltip"):n("takeProfitTooltip"),onChange:a,onPercentageChange:o,percentage:c,isActive:!m,onReset:S,usd:i,fromToken:v,toToken:w,prefix:"",isLoading:r||!t,isInverted:g,hide:T,onInvert:E,totalTrades:Br().totalTrades,isTypedValue:f}},BW=e=>{const{module:t,marketPrice:r,typedInputAmount:n}=re(),s=Ie(),{amountWei:a}=Es(),o=ee(i=>i.state.isMarketOrder);return M.useMemo(()=>{if(G(n||"0").isZero()||!a||!r)return;const i=yh(a,e,o,t),c=gh(a,e,o,t);if(i!=null&&i.isError)return{type:Dt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:i.value};if(c!=null&&c.isError)return{type:Dt.TRIGGER_LIMIT_PRICE_GREATER_THAN_TRIGGER_PRICE,message:s("triggerLimitPriceError")||"",value:c.value};if(e&&G(e||0).isZero())return{type:Dt.MISSING_LIMIT_PRICE,message:s("emptyLimitPrice")||"",value:e||""}},[e,s,a,t,o,n,r])},Cc=()=>{const{dstToken:e,marketPrice:t,callbacks:r}=re(),n=ee(l=>l.updateState),s=Am(),a=ee(l=>l.state.limitPricePercent),o=a===void 0?s:a,i=g5({typedValue:ee(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=BW(i.amountWei);return M.useMemo(()=>({...i,error:c}),[i,c])},FW=()=>{const{module:e}=re(),t=ee(i=>i.updateState),r=ee(i=>i.state.isMarketOrder),n=Am(),s=ee(i=>i.state.triggerPricePercent)||0,a=e===ge.LIMIT,o=M.useCallback(()=>{!r&&e===ge.STOP_LOSS&&t({limitPricePercent:n}),t({isMarketOrder:!r})},[t,s,e,r,n]);return{isLimitPrice:!r,toggleLimitPrice:o,hide:a}},x5=()=>{const{module:e,marketPrice:t}=re(),r=Cc().amountWei,n=Es().amountWei,s=ee(a=>a.state.isMarketOrder);return e===ge.LIMIT||!s?r||"":e===ge.STOP_LOSS||e===ge.TAKE_PROFIT?n||"":t||""},Tc=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=re(),n=x5(),s=Zr().amountWei,a=M.useMemo(()=>oh(s||"",n,(e==null?void 0:e.decimals)||0),[s,n,e==null?void 0:e.decimals]),o=qr(t==null?void 0:t.decimals,a);return{amountWei:a,amountUI:o,usd:bs(o,r)}},Ac=()=>{const{srcToken:e,dstToken:t,dstUsd1Token:r}=re(),n=x5(),s=Br().amountPerTradeWei,a=ee(c=>c.state.isMarketOrder),o=M.useMemo(()=>ih(s,n,!!a,(e==null?void 0:e.decimals)||0),[s,n,a,e==null?void 0:e.decimals]),i=qr(t==null?void 0:t.decimals,o);return{amountWei:o,amountUI:i,usd:bs(i,r)}},OW=()=>{const{typedInputAmount:e,marketPriceLoading:t,dstToken:r}=re(),{amountUI:n,usd:s}=Tc(),o=WG()?e:n;return{value:o,valueWei:Q2(r==null?void 0:r.decimals,o),isLoading:t,usd:s}},UW=()=>{const{module:e,marketPriceLoading:t}=re(),r=Ie(),{amountUI:n,onChange:s,onPercentageChange:a,usd:o,selectedPercentage:i,error:c,isTypedValue:l}=Cc(),{amountUI:u,usd:d}=Ac(),f=ee(L=>L.updateState),m=Am(),{isLimitPrice:b,toggleLimitPrice:g}=FW(),{isInverted:E,onInvert:v,fromToken:w,toToken:S}=Qu(),T=M.useCallback(()=>{f({typedLimitPrice:void 0}),f({limitPricePercent:m})},[f,e,m]),O=M.useMemo(()=>e===ge.STOP_LOSS?r("stopLossLimitPriceTooltip"):r("limitPriceTooltip"),[r,e]);return{price:n,amountPerChunk:u,amountPerChunkUsd:d,error:c,label:r("limitPrice"),tooltip:O,onChange:s,onPercentageChange:a,onReset:T,usd:o,fromToken:w,tradesAmount:Br().totalTrades,toToken:S,percentage:i,isInverted:E,isLoading:t,isLimitPrice:b,toggleLimitPrice:g,onInvert:v,isTypedValue:l}},DW=()=>{const{minChunkSizeUsd:e,typedInputAmount:t,srcUsd1Token:r}=re(),n=Ie(),s=bs(t,r);return M.useMemo(()=>G(e).gt(G(s||"0"))?{type:Dt.MIN_TRADE_SIZE_ERROR,value:e,message:n("minTradeSizeError",{minTradeSize:`${e}`})}:void 0,[e,s,n])};function w5(){const{marketPrice:e,marketPriceLoading:t,typedInputAmount:r,srcUsd1Token:n,srcBalance:s,chainId:a}=re(),o=ee(E=>E.state.swapExecution.status),i=Ie(),{error:c}=Es(),{error:l}=Cc(),{error:u}=Br(),{error:d}=vs(),{error:f}=Tm(),m=DW(),b=Zr().amountWei,g=M.useMemo(()=>{if(s&&G(b).gt(s))return{type:Dt.INSUFFICIENT_BALANCE,message:i("insufficientFunds"),value:s||""}},[s,b,i,a]);return M.useMemo(()=>Ah({marketPrice:e,typedInputAmount:r,srcUsd1Token:n,marketPriceLoading:t,triggerPriceError:c,limitPriceError:l,tradesError:u,fillDelayError:d,durationError:f,balanceError:g,minTradeSizeError:m}),[e,t,r,c,l,u,d,f,g,o,n,m])}const _W=()=>{const e=ee(n=>n.state.isMarketOrder),t=ee(n=>n.updateState),r=M.useCallback(()=>{t({isMarketOrder:!e})},[t,e]);return{isMarketPrice:!e,togglePrice:r}},Ju=()=>{const e=ee(r=>r.state.currentTime),t=Tm().duration;return M.useMemo(()=>ph(e,t),[e,t])},MW=()=>{const{srcUsd1Token:e,dstUsd1Token:t}=re(),r=Zr().amountUI,n=Tc().amountUI,s=bs(r,e),a=bs(n,t);return{srcAmountUsd:s,dstAmountUsd:a}},NW=()=>{const{fees:e,dstUsd1Token:t}=re(),{amountUI:r}=Tc(),n=M.useMemo(()=>!e||!r?"":G(r).multipliedBy(e).dividedBy(100).toFixed(),[r,e]);return{amount:n,percent:e,usd:bs(n,t)}},v5=()=>{const{srcToken:e,dstToken:t,account:r,chainId:n,slippage:s,config:a,module:o,fees:i}=re(),{amountWei:c}=Zr(),{amountPerTradeWei:l,totalTrades:u}=Br(),d=Ju(),{amountWei:f}=Ac(),{pricePerChunkWei:m}=Es(),{milliseconds:b}=vs();return M.useMemo(()=>{var g;return Ph({chainId:n,srcToken:_s((e==null?void 0:e.address)||"")?((g=Ms(n))==null?void 0:g.wToken.address)||"":(e==null?void 0:e.address)||"",dstToken:(t==null?void 0:t.address)||"",srcAmount:c,deadlineMillis:d,fillDelayMillis:!u||u===1?0:b,slippage:s*100,account:r,srcAmountPerTrade:l,dstMinAmountPerTrade:f,triggerAmountPerTrade:m,config:a,module:o,feePercentage:i})},[e,t,r,n,s,a,o,c,l,u,b,f,m,i])},E5=()=>{const{srcToken:e,dstToken:t,account:r}=re(),{amountWei:n}=Zr(),{amountWei:s}=Cc(),{amountPerTradeWei:a,totalTrades:o}=Br(),i=Ju(),{amountWei:c}=Ac(),{pricePerChunkWei:l}=Es(),{milliseconds:u}=vs(),d=v5();return M.useMemo(()=>({srcToken:e,dstToken:t,limitPrice:s,deadline:i,srcAmount:n,srcAmountPerTrade:a,totalTrades:o,minDestAmountPerTrade:c,tradeInterval:u,triggerPricePerTrade:l,maker:r,rePermitData:d}),[e,t,s,i,n,a,o,c,u,l,r,d])},k5=()=>{const{srcToken:e,dstToken:t,account:r}=re(),n=Ie(),{amountUI:s,usd:a}=Ac(),{amountPerTradeUI:o,amountPerTradeUsd:i,totalTrades:c}=Br(),{amountUI:l,usd:u}=Es(),d=Ju(),{amountUI:f,usd:m}=Cc(),{amount:b,percent:g,usd:E}=NW(),{milliseconds:v}=vs(),{amountUI:w}=Tc(),{srcAmountUsd:S,dstAmountUsd:T}=MW(),O=Zr().amountUI,L=ee(A=>A.state.isMarketOrder),P=ee(A=>A.state.currentTime),h=J2({srcToken:e,dstToken:t,account:r,limitPrice:L?void 0:f,limitPriceUsd:L?void 0:m,deadline:d,tradeInterval:v,srcAmount:O,totalTrades:c,srcAmountPerTrade:o,srcAmountPerTradeUsd:i,minDestAmountPerTrade:s,minDestAmountPerTradeUsd:a,triggerPrice:l,triggerPriceUsd:u,srcUsd:S,dstUsd:T,dstAmount:w,orderType:J0(),createdAt:P}),y=Ar({value:b}),x=Ar({value:E});return M.useMemo(()=>({...h,fees:{label:n("fees",{value:`${g}%`}),amount:y,usd:x||"",percentage:g}}),[h,y,x,g])},C5=M.createContext({}),LW=({children:e,...t})=>C.jsx(C5.Provider,{value:t,children:e}),zW=()=>M.useContext(C5),T5=()=>{var s,a;const e=Ie(),{wrapTxHash:t,srcToken:r}=ee(o=>o.state.swapExecution),n=(a=(s=wo())==null?void 0:s.wToken)==null?void 0:a.symbol;return t?C.jsx("p",{className:"twap-error-wrap-msg",children:e("wrapMsg",{symbol:(r==null?void 0:r.symbol)||"",wSymbol:n||""})}):null},A5=()=>{const e=Ie(),t=ee(n=>n.state.swapExecution.status),r=rx();return t===pt.SUCCESS?e("createOrderActionSuccess",{name:r}):e("createOrderAction",{name:r})},RW=()=>{const e=ee(b=>b.state.swapExecution.srcToken),t=Ie(),{step:r,wrapTxHash:n,approveTxHash:s}=ee(b=>b.state.swapExecution),a=wo(),o=zu(n),i=zu(n),c=zu(s),l=ee(b=>b.state.swapExecution.status),d=_s((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,m=A5();return M.useMemo(()=>r===Rs.WRAP?{title:t("wrapAction",{symbol:d}),footerLink:o,footerText:t(o?"viewOnExplorer":"proceedInWallet")}:r===Rs.APPROVE?{title:t("approveAction",{symbol:d}),footerLink:c,footerText:t(c?"viewOnExplorer":"proceedInWallet")}:{title:m,footerText:l===pt.LOADING?t("proceedInWallet"):void 0},[r,c,d,m,t,o,i,f,l])},HW=({error:e})=>C.jsxs("div",{className:"twap-error",children:[C.jsx("h2",{className:"twap-error-title",children:"Transaction failed"}),(e==null?void 0:e.code)&&C.jsxs("p",{className:"twap-error-code",children:["Error code: ",e==null?void 0:e.code]}),C.jsx(T5,{})]});function $W({error:e}){const{components:t}=re(),r=Ie(),n=ee(o=>{var i;return(i=o.state.swapExecution)==null?void 0:i.wrapTxHash}),s=t.SubmitOrderErrorView,a=C.jsx(es.Failed,{error:C.jsx(HW,{error:e}),footerLink:hd,footerText:r("viewOnExplorer")});return s?C.jsx(s,{wrapTxHash:n,error:e,children:a}):a}const GW=()=>{const{components:e}=re(),t=ee(u=>u.state.swapExecution.srcToken),r=ee(u=>u.state.swapExecution.dstToken),{reviewDetails:n}=zW(),s=Ie(),a=ee(u=>{var d;return!!((d=u.state.swapExecution)!=null&&d.status)}),o=k5(),i=e.USD,c=e.SubmitOrderMainView,l=C.jsxs(C.Fragment,{children:[C.jsx(es.Main,{fromTitle:s("from"),toTitle:s("to"),inUsd:i?C.jsx(i,{value:o.srcUsd,isLoading:!1}):C.jsx(pn,{value:o.srcUsd,decimalScale:2,prefix:"$"}),outUsd:i?C.jsx(i,{value:o.dstUsd,isLoading:!1}):C.jsx(pn,{value:o.dstUsd,decimalScale:2,prefix:"$"})}),!a&&C.jsxs("div",{className:"twap-create-order-bottom",children:[C.jsx(he.Container,{children:C.jsxs("div",{className:"twap-create-order-details",children:[C.jsx(he.Deadline,{deadline:o.deadline.value,label:o.deadline.label,tooltip:o.deadline.tooltip||""}),C.jsx(he.Price,{srcToken:t,price:o.triggerPrice.value,dstToken:r,label:o.triggerPrice.label,tooltip:o.triggerPrice.tooltip,usd:o.triggerPrice.usd}),C.jsx(he.Price,{srcToken:t,price:o.limitPrice.value,dstToken:r,label:o.limitPrice.label,usd:o.limitPrice.usd,tooltip:o.limitPrice.tooltip}),C.jsx(he.MinDestAmount,{dstToken:r,dstMinAmountOut:o.minDestAmountPerTrade.value,label:o.minDestAmountPerTrade.label,tooltip:o.minDestAmountPerTrade.tooltip||"",usd:o.minDestAmountPerTrade.usd}),C.jsx(he.TradeSize,{tradeSize:o.sizePerTrade.value,trades:o.totalTrades.value,srcToken:t,label:o.sizePerTrade.label,tooltip:o.sizePerTrade.tooltip}),C.jsx(he.TradesAmount,{trades:o.totalTrades.value,label:o.totalTrades.label,tooltip:o.totalTrades.tooltip}),C.jsx(he.TradeInterval,{chunks:o.totalTrades.value,fillDelayMillis:o.tradeInterval.value,label:o.tradeInterval.label,tooltip:o.tradeInterval.tooltip}),C.jsx(he.Recipient,{}),o.fees.amount&&C.jsx(he.Fees,{fees:o.fees.amount,label:o.fees.label,usd:o.fees.usd,dstTokenSymbol:r==null?void 0:r.symbol})]})}),n]})]});return c?C.jsx(c,{children:l}):l},jW=e=>{const{status:t,stepIndex:r,totalSteps:n,parsedError:s}=ee(w=>w.state.swapExecution),{components:a}=re(),o=a.Spinner,i=a.SuccessIcon,c=a.ErrorIcon,l=a.TokenLogo,{srcToken:u,dstToken:d}=re(),f=Zr().amountUI,m=Tc().amountUI,b=Ar({value:f,decimalScale:2}),g=Ar({value:m,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 C.jsx(LW,{...e,children:C.jsx(es,{inAmount:b,outAmount:g,swapStatus:t,totalSteps:n,currentStep:RW(),currentStepIndex:r,inToken:E,outToken:v,components:{SrcTokenLogo:l&&C.jsx(l,{token:u}),DstTokenLogo:l&&C.jsx(l,{token:d}),Failed:C.jsx($W,{error:s}),Success:C.jsx(VW,{}),Main:C.jsx(GW,{}),Loader:o,SuccessIcon:i,FailedIcon:c}})})},VW=()=>{const e=A5(),{components:t}=re(),r=ee(a=>a.state.swapExecution.orderId),n=t.SubmitOrderSuccessView,s=C.jsxs(C.Fragment,{children:[C.jsx(es.Success,{title:e}),C.jsx(T5,{})]});return n?C.jsx(n,{newOrderId:r,children:s}):s},WW=()=>{const{supportedChains:e}=re();return M.useMemo(()=>e,[e])},qW=()=>{const{config:e}=re();return M.useMemo(()=>({spender:e.repermit}),[e])},KW=()=>{var c;const{account:e,walletClient:t,overrides:r,refetchBalances:n,callbacks:s,chainId:a}=re(),o=(c=wo())==null?void 0:c.wToken,i=Q0();return en({mutationFn:async({onHash:l,srcAmountWei:u})=>{var m,b;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(),(m=s==null?void 0:s.onWrapRequest)==null||m.call(s),r!=null&&r.wrap?d=await r.wrap(u):d=await t.writeContract({abi:zm,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),(b=s==null?void 0:s.onWrapSuccess)==null||b.call(s,{txHash:f.transactionHash,explorerUrl:ao(f.transactionHash,a),amount:oa(u,o.decimals)}),n==null||n(),f},onError:l=>{throw dt.onWrapError(l),l}})},S5=()=>{const{account:e,walletClient:t,chainId:r,callbacks:n}=re(),{rePermitData:s}=E5(),{refetch:a}=vo();return en({mutationFn:async()=>{var b,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),(b=n==null?void 0:n.onSignOrderRequest)==null||b.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=u4(u),f={v:q(d.v||0),r:d.r,s:d.s},m=await Oh(o,f);return(v=n==null?void 0:n.onOrderCreated)==null||v.call(n,m),await a(),m}})},P5=()=>{const{account:e,publicClient:t,config:r}=re();return en({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=G(a||"0").lt(G(s).toString());return{allowance:a,approvalRequired:o}}})},YW=()=>{const{account:e,walletClient:t,overrides:r,config:n,chainId:s,callbacks:a}=re(),o=Q0(),{mutateAsync:i}=P5();return en({onError:c=>{dt.onApproveError(c)},mutationFn:async({token:c,onHash:l,srcAmountWei:u})=>{var b,g;if(!e)throw new Error("missing account");if(!t)throw new Error("missing walletClient");if(!n)throw new Error("missing config");(b=a==null?void 0:a.onApproveRequest)==null||b.call(a),dt.onApproveRequest();let d;if(r!=null&&r.approveOrder?d=await r.approveOrder({tokenAddress:c.address,spenderAddress:n.repermit,amount:Xs}):d=await t.writeContract({abi:Ty,functionName:"approve",account:e,address:c.address,args:[n.repermit,Xs],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 m=!1;for(let E=0;E<3;E++){const{approvalRequired:v}=await i({tokenAddress:c.address,srcAmountWei:u});if(!v){m=!0;break}E<2&&await new Promise(w=>setTimeout(w,3e3))}if(!m)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:ao(f.transactionHash,s),token:c,amount:oa(u,c.decimals)}),f}})},ZW=()=>{const{account:e,chainId:t,srcToken:r,dstToken:n,module:s,slippage:a}=re(),o=Es(),i=Zr().amountWei,c=Br().amountPerTradeWei,l=Ju(),u=Br().totalTrades,d=vs().fillDelay,f=Ac().amountWei,m=ee(b=>b.state.isMarketOrder);return en({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:m||!1,chunksAmount:u})}})};function XW(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 I5=()=>{const{srcToken:e,dstToken:t,chainId:r,callbacks:n}=re(),s=YW().mutateAsync,a=KW().mutateAsync,o=S5().mutateAsync,{mutateAsync:i}=P5(),c=ee(d=>d.updateSwapExecution),{amountWei:l}=Zr(),u=ZW().mutate;return en({mutationFn:async()=>{var f,m;const d=_s((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 b=n6(e,r);c({allowanceLoading:!0,wrapTxHash:void 0,approveTxHash:void 0});const{approvalRequired:g}=await i({tokenAddress:b.address,srcAmountWei:l});let E=0,v=1;d&&v++,g&&v++,c({totalSteps:v,stepIndex:E,allowanceLoading:!1,status:pt.LOADING}),u(),d&&(c({step:Rs.WRAP}),await a({onHash:S=>c({wrapTxHash:S}),srcAmountWei:l}),E++,c({stepIndex:E})),g&&(c({step:Rs.APPROVE}),await s({token:b,onHash:S=>c({approveTxHash:S}),srcAmountWei:l}),E++,c({stepIndex:E})),c({step:Rs.CREATE});const w=await o();return c({status:pt.SUCCESS,orderId:w.id}),w}catch(b){if(jf(b))(f=n==null?void 0:n.onSubmitOrderRejected)==null||f.call(n),c({step:void 0,status:void 0,stepIndex:void 0,error:b});else{const g=XW(b);(m=n==null?void 0:n.onSubmitOrderFailed)==null||m.call(n,g),c({status:pt.FAILED,parsedError:g,error:b})}throw b}}})},QW=()=>{const{marketPrice:e,srcToken:t,dstToken:r,resetTypedInputAmount:n}=re(),s=I5(),{amountUI:a}=Zr(),o=ee(g=>g.resetState),i=ee(g=>g.state.swapExecution),c=ee(g=>g.updateSwapExecution),l=ee(g=>g.resetSwapExecution),u=rx(),d=M.useCallback(()=>{(i==null?void 0:i.status)===pt.SUCCESS&&n(),i!=null&&i.status&&(i==null?void 0:i.status)!==pt.LOADING&&o()},[i==null?void 0:i.status,o,n]),f=M.useCallback(()=>{(i==null?void 0:i.status)!==pt.LOADING&&l({srcToken:t,dstToken:r})},[l,t,r]),m=en({mutationFn:async()=>(c({acceptedSrcAmount:a,acceptedMarketPrice:e}),await s.mutateAsync())}),b=M.useCallback(()=>m.mutateAsync(),[m]);return M.useMemo(()=>({reset:o,onCloseModal:d,onOpenModal:f,onSubmit:b,orderTitle:u,...i,isLoading:(i==null?void 0:i.status)===pt.LOADING,isSuccess:(i==null?void 0:i.status)===pt.SUCCESS,isFailed:(i==null?void 0:i.status)===pt.FAILED}),[o,d,b,i,u])},JW=()=>{const e=Ie(),{marketPrice:t,srcToken:r,dstToken:n,marketPriceLoading:s,srcBalance:a,srcUsd1Token:o,noLiquidity:i,typedInputAmount:c}=re(),l=s||G(o||"0").isZero()||a===void 0||G(t||"0").isZero(),u=!!(r&&n&&c&&l),d=w5(),f=M.useMemo(()=>i?e("noLiquidity"):G(c||"0").isZero()?e("enterAmount"):e("placeOrder"),[d,e,c,i]),m=!!(d||i||u||G(c||"0").isZero()||!r||!n);return M.useMemo(()=>({disabled:m,text:f,loading:u}),[m,f,u])},eq=({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?Os.createPortal(e,a):null};Bh(Yw.version);const tq={SubmitOrderPanel:jW,Orders:gW,Portal:eq};R.CRASH_ERROR_MESSAGE=bw,R.Components=tq,R.Configs=Pe,R.DEFAULT_DURATION_OPTIONS=xz,R.DEFAULT_FILL_DELAY=Nc,R.DEFAULT_STOP_LOSS_LIMIT_PERCENTAGE=rh,R.DEFAULT_STOP_LOSS_PERCENTAGE=eh,R.DEFAULT_TAKE_PROFIT_LIMIT_PERCENTAGE=nh,R.DEFAULT_TAKE_PROFIT_PERCENTAGE=th,R.DISCLAIMER_URL=hw,R.EIP712_TYPES=Qm,R.EIP712_TYPES_DEV=Jm,R.ERC20_ABI=J5,R.EXCLUSIVITY_OVERRIDE_BPS=uw,R.FEES=lw,R.FormatNumber=pn,R.IWETH_ABI=zm,R.InputErrors=Dt,R.LEGACY_EXCHANGES_MAP=Xm,R.MAX_ORDER_DURATION_MILLIS=Pa,R.MIN_CHUNKS=cw,R.MIN_FILL_DELAY_MILLIS=_c,R.MIN_FILL_DELAY_MINUTES=qm,R.MIN_ORDER_DURATION_MILLIS=pd,R.Module=ge,R.ORBS_LOGO=pw,R.ORBS_LOGO_FALLBACK=fw,R.ORBS_SLTP_FAQ_URL=dw,R.ORBS_TWAP_FAQ_URL=hd,R.ORBS_WEBSITE_URL=mw,R.OrderFilter=ar,R.OrderStatus=ut,R.OrderType=Re,R.PRICE_PROTECTION_SETTINGS=wz,R.Partners=Jr,R.QUERY_PARAMS=Ia,R.REPERMIT_ABI=Rm,R.REPERMIT_PRIMARY_TYPE=md,R.SUGGEST_CHUNK_VALUE=iw,R.SpotProvider=yz,R.Steps=Rs,R.SwapStatus=pt,R.THE_GRAPH_ORDERS_API=Km,R.TWAP_ABI=Hm,R.TimeUnit=$t,R.analytics=dt,R.buildRePermitOrderData=Ph,R.buildV2Order=vd,R.copy=p4,R.ensureWrappedToken=n6,R.eqIgnoreCase=Ds,R.fillDelayText=t6,R.formatDecimals=r6,R.getAccountOrders=Mh,R.getApiEndpoint=dd,R.getChunks=uh,R.getConfig=yd,R.getDeadline=ph,R.getDestTokenAmount=oh,R.getDestTokenMinAmountPerChunk=ih,R.getDuration=lh,R.getErrors=Ah,R.getEstimatedDelayBetweenChunksMillis=fh,R.getExplorerUrl=ao,R.getMaxChunksError=kh,R.getMaxFillDelayError=vw,R.getMaxOrderDurationError=xh,R.getMaxPossibleChunks=dh,R.getMinChunkSizeUsd=Th,R.getMinFillDelayError=vh,R.getMinNativeBalance=m4,R.getMinOrderDurationError=wh,R.getMinTradeSizeError=Eh,R.getNetwork=Ms,R.getOrderExecutionRate=ld,R.getOrderFillDelayMillis=cd,R.getOrderLimitPriceRate=Vm,R.getOrderType=h4,R.getPartnerChains=jm,R.getPartnerIdentifier=_t,R.getPartners=Ch,R.getSrcTokenChunkAmount=mh,R.getStopLossLimitPriceError=yh,R.getStopLossPriceError=hh,R.getTakeProfitLimitPriceError=gh,R.getTakeProfitPriceError=bh,R.getTriggerPricePerChunk=ch,R.getTriggerPricePerTrade=Wm,R.isDev=Ro,R.isNativeAddress=_s,R.isTxRejected=jf,R.makeElipsisAddress=Nl,R.maxUint256=Mc,R.millisToDays=s6,R.millisToMinutes=Vf,R.nativeTokenAddresses=Zm,R.networks=Ft,R.parseError=f4,R.removeCommas=d4,R.setApiMode=ow,R.setUIVersion=Bh,R.shouldUnwrapOnly=qf,R.shouldWrapOnly=Wf,R.submitOrder=Oh,R.toAmountUi=oa,R.toAmountWei=Ml,R.useAddresses=qW,R.useDisclaimerPanel=TW,R.useDstTokenPanel=OW,R.useDurationPanel=CW,R.useFillDelayPanel=wW,R.useFormatNumber=Ar,R.useInputErrors=w5,R.useInvertTradePanel=Qu,R.useLimitPricePanel=UW,R.useOrder=E5,R.useOrderDisplay=k5,R.useOrderHistoryPanel=hj,R.useOrderType=J0,R.usePartnerChains=WW,R.useRePermitOrderData=v5,R.useRefetchUntilStatusSynced=cx,R.useSignOrder=S5,R.useSubmitOrder=I5,R.useSubmitOrderButton=JW,R.useSubmitOrderPanel=QW,R.useTogglePricePanel=_W,R.useTradesPanel=EW,R.useTranslations=Ie,R.useTriggerPricePanel=IW,R.zeroAddress=Ym,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbs-network/spot-react",
3
- "version": "0.0.106",
3
+ "version": "0.0.107",
4
4
  "description": "Spot React Components - React components for Spot SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/spot-react.umd.cjs",