@dodoex/widgets 3.0.2-zetachain.108.ton.4 → 3.0.2-zetachain.108.ton.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{helper-ClDVNp1x.cjs → helper-BbdldHPL.cjs} +1 -1
- package/dist/{helper-CLElCboD.js → helper-CWI4O5M8.js} +1 -1
- package/dist/{index-CNqXq0K8.js → index-BrbFWPgV.js} +1 -1
- package/dist/{index-d550SLmT.cjs → index-CBQvCF6p.cjs} +1 -1
- package/dist/{index-BZUoTGh3.js → index-Cf-tLacC.js} +1 -1
- package/dist/{index-Cl9wvOiK.cjs → index-CynxaUqF.cjs} +1 -1
- package/dist/{index-r-jtP40I.js → index-D9d6DgUD.js} +1 -1
- package/dist/{index-CSUUT5Yj.cjs → index-KaqAuGX5.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -31,4 +31,4 @@ var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected
|
|
|
31
31
|
object-assign
|
|
32
32
|
(c) Sindre Sorhus
|
|
33
33
|
@license MIT
|
|
34
|
-
*/function cv(){if(Ky)return Yy;Ky=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Yy=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(i,o){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(i),l=1;l<arguments.length;l++){for(var d in r=Object(arguments[l]))t.call(r,d)&&(s[d]=r[d]);if(e){a=e(r);for(var c=0;c<a.length;c++)n.call(r,a[c])&&(s[a[c]]=r[a[c]])}}return s},Yy}function uv(){if(Jy)return Xy;Jy=1;return Xy="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function pv(){return tv?ev:(tv=1,ev=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var hv=dv();$y.exports=function(){if(rv)return ov;rv=1;var e=dv(),t=cv(),n=uv(),i=pv(),o=function(){if(iv)return nv;iv=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=uv(),n={},i=pv();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,r,a,s,l){if("production"!==process.env.NODE_ENV)for(var d in o)if(i(o,d)){var c;try{if("function"!=typeof o[d]){var u=Error((s||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=o[d](r,d,s,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((s||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof c+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),c instanceof Error&&!(c.message in n)){n[c.message]=!0;var p=l?l():"";e("Failed "+a+" type: "+c.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},nv=o}(),r=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(r=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),ov=function(s,l){var d="function"==typeof Symbol&&Symbol.iterator,c="@@iterator",u="<<anonymous>>",p={array:f("array"),bigint:f("bigint"),bool:f("boolean"),func:f("function"),number:f("number"),object:f("object"),string:f("string"),symbol:f("symbol"),any:g(a),arrayOf:function(e){return g((function(t,i,o,r,a){if("function"!=typeof e)return new m("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[i];if(!Array.isArray(s))return new m("Invalid "+r+" `"+a+"` of type `"+v(s)+"` supplied to `"+o+"`, expected an array.");for(var l=0;l<s.length;l++){var d=e(s,l,o,r,a+"["+l+"]",n);if(d instanceof Error)return d}return null}))},element:g((function(e,t,n,i,o){var r=e[t];return s(r)?null:new m("Invalid "+i+" `"+o+"` of type `"+v(r)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:g((function(t,n,i,o,r){var a=t[n];return e.isValidElementType(a)?null:new m("Invalid "+o+" `"+r+"` of type `"+v(a)+"` supplied to `"+i+"`, expected a single ReactElement type.")})),instanceOf:function(e){return g((function(t,n,i,o,r){if(!(t[n]instanceof e)){var a=e.name||u;return new m("Invalid "+o+" `"+r+"` of type `"+((s=t[n]).constructor&&s.constructor.name?s.constructor.name:u)+"` supplied to `"+i+"`, expected instance of `"+a+"`.")}var s;return null}))},node:g((function(e,t,n,i,o){return y(e[t])?null:new m("Invalid "+i+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return g((function(t,o,r,a,s){if("function"!=typeof e)return new m("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var l=t[o],d=v(l);if("object"!==d)return new m("Invalid "+a+" `"+s+"` of type `"+d+"` supplied to `"+r+"`, expected an object.");for(var c in l)if(i(l,c)){var u=e(l,c,r,a,s+"."+c,n);if(u instanceof Error)return u}return null}))},oneOf:function(e){return Array.isArray(e)?g((function(t,n,i,o,r){for(var a=t[n],s=0;s<e.length;s++)if(h(a,e[s]))return null;var l=JSON.stringify(e,(function(e,t){return"symbol"===b(t)?String(t):t}));return new m("Invalid "+o+" `"+r+"` of value `"+String(a)+"` supplied to `"+i+"`, expected one of "+l+".")})):("production"!==process.env.NODE_ENV&&r(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&r("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+j(o)+" at index "+t+"."),a}return g((function(t,o,r,a,s){for(var l=[],d=0;d<e.length;d++){var c=(0,e[d])(t,o,r,a,s,n);if(null==c)return null;c.data&&i(c.data,"expectedType")&&l.push(c.data.expectedType)}return new m("Invalid "+a+" `"+s+"` supplied to `"+r+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")}))},shape:function(e){return g((function(t,i,o,r,a){var s=t[i],l=v(s);if("object"!==l)return new m("Invalid "+r+" `"+a+"` of type `"+l+"` supplied to `"+o+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return x(o,r,a,d,b(c));var u=c(s,d,o,r,a+"."+d,n);if(u)return u}return null}))},exact:function(e){return g((function(o,r,a,s,l){var d=o[r],c=v(d);if("object"!==c)return new m("Invalid "+s+" `"+l+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},o[r],e);for(var p in u){var h=e[p];if(i(e,p)&&"function"!=typeof h)return x(a,s,l,p,b(h));if(!h)return new m("Invalid "+s+" `"+l+"` key `"+p+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(o[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var g=h(d,p,a,s,l+"."+p,n);if(g)return g}return null}))}};function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function m(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function g(e){if("production"!==process.env.NODE_ENV)var t={},i=0;function o(o,a,s,d,c,p,h){if(d=d||u,p=p||s,h!==n){if(l){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var f=d+":"+s;!t[f]&&i<3&&(r("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+d+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[f]=!0,i++)}}return null==a[s]?o?null===a[s]?new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `null`."):new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `undefined`."):null:e(a,s,d,c,p)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function f(e){return g((function(t,n,i,o,r,a){var s=t[n];return v(s)!==e?new m("Invalid "+o+" `"+r+"` of type `"+b(s)+"` supplied to `"+i+"`, expected `"+e+"`.",{expectedType:e}):null}))}function x(e,t,n,i,o){return new m((e||"React class")+": "+t+" type `"+n+"."+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function y(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(y);if(null===e||s(e))return!0;var t=function(e){var t=e&&(d&&e[d]||e[c]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,i=t.call(e);if(t!==e.entries){for(;!(n=i.next()).done;)if(!y(n.value))return!1}else for(;!(n=i.next()).done;){var o=n.value;if(o&&!y(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function j(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return m.prototype=Error.prototype,p.checkPropTypes=o,p.resetWarningCache=o.resetWarningCache,p.PropTypes=p,p},ov}()(hv.isElement,!0)}else $y.exports=function(){if(sv)return av;sv=1;var e=uv();function t(){}function n(){}return n.resetWarningCache=t,av=function(){function i(t,n,i,o,r,a){if(a!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return i}i.isRequired=i;var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r}}()();var mv=Hn($y.exports);function gv(e,t){return"production"===process.env.NODE_ENV?()=>null:function(...n){return e(...n)||t(...n)}}function fv(e,t,n,i,o){const r=e[t],a=o||t;if(null==r||"undefined"==typeof window)return null;let s;const l=r.type;return"function"!=typeof l||function(e){const{prototype:t={}}=e;return Boolean(t.isReactComponent)}(l)||(s="Did you accidentally use a plain function component for an element instead?"),void 0!==s?new Error(`Invalid ${i} \`${a}\` supplied to \`${n}\`. Expected an element that can hold a ref. ${s} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const xv=gv(mv.element,fv);xv.isRequired=gv(mv.element.isRequired,fv);const yv="exact-prop: ";function vv(e){return e&&e.ownerDocument||document}const bv="undefined"!=typeof window?W.useLayoutEffect:W.useEffect;function jv(e){const t=W.useRef(e);return bv((()=>{t.current=e})),W.useRef(((...e)=>(0,t.current)(...e))).current}function Cv(...e){return W.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{!function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(e,t)}))}),e)}const wv={};const kv=[];class Tv{static create(){return new Tv}currentId=null;start(e,t){this.clear(),this.currentId=setTimeout((()=>{this.currentId=null,t()}),e)}clear=()=>{null!==this.currentId&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Iv(){const e=function(e,t){const n=W.useRef(wv);return n.current===wv&&(n.current=e(t)),n}(Tv.create).current;var t;return t=e.disposeEffect,W.useEffect(t,kv),e}const Sv={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Ev(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Ev(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Av(){for(var e,t,n=0,i="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Ev(e))&&(i&&(i+=" "),i+=t);return i}function Ov(e,t=[]){if(void 0===e)return{};const n={};return Object.keys(e).filter((n=>n.match(/^on[A-Z]/)&&"function"==typeof e[n]&&!t.includes(n))).forEach((t=>{n[t]=e[t]})),n}function Lv(e){if(void 0===e)return{};const t={};return Object.keys(e).filter((t=>!(t.match(/^on[A-Z]/)&&"function"==typeof e[t]))).forEach((n=>{t[n]=e[n]})),t}function Rv(e){const{elementType:t,externalSlotProps:n,ownerState:i,skipResolvingSlotProps:o=!1,...r}=e,a=o?{}:function(e,t,n){return"function"==typeof e?e(t,n):e}(n,i),{props:s,internalRef:l}=function(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:i,externalForwardedProps:o,className:r}=e;if(!t){const e=Av(n?.className,r,o?.className,i?.className),t={...n?.style,...o?.style,...i?.style},a={...n,...o,...i};return e.length>0&&(a.className=e),Object.keys(t).length>0&&(a.style=t),{props:a,internalRef:void 0}}const a=Ov({...o,...i}),s=Lv(i),l=Lv(o),d=t(a),c=Av(d?.className,n?.className,r,o?.className,i?.className),u={...d?.style,...n?.style,...o?.style,...i?.style},p={...d,...n,...l,...s};return c.length>0&&(p.className=c),Object.keys(u).length>0&&(p.style=u),{props:p,internalRef:d.ref}}({...r,externalSlotProps:a}),d=function(e,t,n){return void 0===e||"string"==typeof e?t:{...t,ownerState:{...t.ownerState,...n}}}(t,{...s,ref:Cv(l,a?.ref,e.additionalProps?.ref)},i);return d}function Pv(e){return e.substring(2).toLowerCase()}function _v(e){const{children:t,disableReactTree:n=!1,mouseEvent:i="onClick",onClickAway:o,touchEvent:r="onTouchEnd"}=e,a=W.useRef(!1),s=W.useRef(null),l=W.useRef(!1),d=W.useRef(!1);W.useEffect((()=>(setTimeout((()=>{l.current=!0}),0),()=>{l.current=!1})),[]);const c=Cv((u=t)&&W.isValidElement(u)?u.props.propertyIsEnumerable("ref")?u.props.ref:u.ref:null,s);var u;const p=jv((e=>{const t=d.current;d.current=!1;const i=vv(s.current);if(!l.current||!s.current||"clientX"in e&&function(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}(e,i))return;if(a.current)return void(a.current=!1);let r;r=e.composedPath?e.composedPath().indexOf(s.current)>-1:!i.documentElement.contains(e.target)||s.current.contains(e.target),r||!n&&t||o(e)})),h=e=>n=>{d.current=!0;const i=t.props[e];i&&i(n)},m={ref:c};return!1!==r&&(m[r]=h(r)),W.useEffect((()=>{if(!1!==r){const e=Pv(r),t=vv(s.current),n=()=>{a.current=!0};return t.addEventListener(e,p),t.addEventListener("touchmove",n),()=>{t.removeEventListener(e,p),t.removeEventListener("touchmove",n)}}}),[p,r]),!1!==i&&(m[i]=h(i)),W.useEffect((()=>{if(!1!==i){const e=Pv(i),t=vv(s.current);return t.addEventListener(e,p),()=>{t.removeEventListener(e,p)}}}),[p,i]),Yn.jsx(W.Fragment,{children:W.cloneElement(t,m)})}"production"!==process.env.NODE_ENV&&(_v.propTypes={children:xv.isRequired,disableReactTree:mv.bool,mouseEvent:mv.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mv.func.isRequired,touchEvent:mv.oneOf(["onTouchEnd","onTouchStart",!1])}),"production"!==process.env.NODE_ENV&&(_v.propTypes=function(e){return"production"===process.env.NODE_ENV?e:{...e,[yv]:t=>{const n=Object.keys(t).filter((t=>!e.hasOwnProperty(t)));return n.length>0?new Error(`The following props are not supported: ${n.map((e=>`\`${e}\``)).join(", ")}. Please remove them.`):null}}}(_v.propTypes));const Mv="base";function Bv(e,t){const n=Sv[t];return n?`${Mv}--${n}`:function(e,t){return`${Mv}-${e}-${t}`}(e,t)}const Dv="Snackbar";function Nv(e){return Bv(Dv,e)}!function(e,t){const n={};t.forEach((t=>{n[t]=Bv(e,t)}))}(Dv,["root"]);const Fv={disableDefaultClasses:!1},Uv=W.createContext(Fv);"production"!==process.env.NODE_ENV&&(Uv.displayName="ClassNameConfiguratorContext");const qv=()=>function(e,t,n){const i={};for(const o in e){const r=e[o];let a="";for(let e=0;e<r.length;e+=1){const i=r[e];i&&(a+=t(i)+" ",n&&n[i]&&(a+=n[i]+" "))}i[o]=a}return i}({root:["root"]},function(e){const{disableDefaultClasses:t}=W.useContext(Uv);return n=>t?"":e(n)}(Nv)),Vv=W.forwardRef((function(e,t){const{autoHideDuration:n=null,children:i,disableWindowBlurListener:o=!1,exited:r=!0,onBlur:a,onClose:s,onFocus:l,onMouseEnter:d,onMouseLeave:c,open:u,resumeHideDuration:p,slotProps:h={},slots:m={},...g}=e,f=qv(),{getRootProps:x,onClickAway:y}=function(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:i,open:o,resumeHideDuration:r}=e,a=Iv();W.useEffect((()=>{if(o)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)};function e(e){e.defaultPrevented||"Escape"===e.key&&i?.(e,"escapeKeyDown")}}),[o,i]);const s=jv(((e,t)=>{i?.(e,t)})),l=jv((e=>{i&&null!=e&&a.start(e,(()=>{s(null,"timeout")}))}));W.useEffect((()=>(o&&l(t),a.clear)),[o,t,l,a]);const d=a.clear,c=W.useCallback((()=>{null!=t&&l(null!=r?r:.5*t)}),[t,r,l]),u=e=>t=>{const n=e.onFocus;n?.(t),d()},p=e=>t=>{const n=e.onMouseEnter;n?.(t),d()},h=e=>t=>{const n=e.onMouseLeave;n?.(t),c()};return W.useEffect((()=>{if(!n&&o)return window.addEventListener("focus",c),window.addEventListener("blur",d),()=>{window.removeEventListener("focus",c),window.removeEventListener("blur",d)}}),[n,o,c,d]),{getRootProps:(t={})=>{const n={...Ov(e),...Ov(t)};return{role:"presentation",...t,...n,onBlur:(i=n,e=>{const t=i.onBlur;t?.(e),c()}),onFocus:u(n),onMouseEnter:p(n),onMouseLeave:h(n)};var i},onClickAway:e=>{i?.(e,"clickaway")}}}({...e,autoHideDuration:n,disableWindowBlurListener:o,onClose:s,open:u,resumeHideDuration:p}),v=e,b=m.root||"div",j=Rv({elementType:b,getSlotProps:x,externalForwardedProps:g,externalSlotProps:h.root,additionalProps:{ref:t},ownerState:v,className:f.root}),C=Rv({elementType:_v,externalSlotProps:h.clickAwayListener,additionalProps:{onClickAway:y},ownerState:v});return delete C.ownerState,!u&&r?null:Yn.jsx(_v,{...C,children:Yn.jsx(b,{...j,children:i})})}));function Wv({size:e,color:t,time:n,strokeWidth:o=2,sx:r}){const[a,s]=z("0 1069"),l=e/2,d=l-1;return Q((()=>{s(2*Math.PI*d+" 0")}),[]),Yn.jsx(i,{width:e,height:e,component:"svg",sx:Object.assign({position:"absolute",top:`-${o}`,left:`-${o}`,transform:"rotate(-90deg)"},r),children:Yn.jsx(i,{component:"circle",cx:l,cy:l,r:d,strokeWidth:o,stroke:t,fill:"none",strokeDasharray:a,sx:{transition:`stroke-dasharray ${n}`}})})}"production"!==process.env.NODE_ENV&&(Vv.propTypes={autoHideDuration:mv.number,children:mv.node,disableWindowBlurListener:mv.bool,exited:mv.bool,onClose:mv.func,open:mv.bool,resumeHideDuration:mv.number,slotProps:mv.shape({clickAwayListener:mv.oneOfType([mv.func,mv.shape({children:mv.element.isRequired,disableReactTree:mv.bool,mouseEvent:mv.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mv.func,touchEvent:mv.oneOf(["onTouchEnd","onTouchStart",!1])})]),root:mv.oneOfType([mv.func,mv.object])}),slots:mv.shape({root:mv.elementType})});var Hv=H.memo(Wv);const $v=st((e=>({notify:null,toast:t=>{e({notify:t})},close:()=>{e({notify:null})}}))),zv={entering:"translateX(0)",entered:"translateX(0)",exiting:"translateX(500px)",exited:"translateX(500px)",unmounted:"translateX(500px)"};function Zv(){const e=a(),{notify:t,close:n}=$v(),[o,r]=H.useState(!0),s=H.useRef(null),l=null==t?void 0:t.timeout,d=!!t;let c=Yn.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("circle",{cx:"18",cy:"18",r:"16.5",stroke:"#2FBA90",strokeWidth:"3"}),Yn.jsx("path",{d:"M25.1384 11.334L14.8873 21.5851L10.8584 17.5718L8.66504 19.7651L14.8873 25.9873L27.3317 13.5429L25.1384 11.334Z",fill:"#2FBA90"})]});switch(null==t?void 0:t.type){case"error":c=Yn.jsxs("svg",{width:"36",height:"37",viewBox:"0 0 36 37",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("circle",{cx:"18",cy:"18.5",r:"16.5",stroke:"#FF6187",strokeWidth:"3"}),Yn.jsx("path",{d:"M25.3331 13.0452L19.8782 18.5L25.3331 23.9548L23.5148 25.7731L18.06 20.3183L12.6051 25.7731L10.7869 23.9548L16.2417 18.5L10.7869 13.0452L12.6051 11.2269L18.06 16.6817L23.5148 11.2269L25.3331 13.0452Z",fill:"#FF6187"})]});break;case"warning":c=Yn.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.4065 3.6189L9.62438 3.59576L3.39812 9.78928L3.37498 18.5714L9.5685 24.7976L18.3506 24.8208L24.5769 18.6273L24.6 9.84516L18.4065 3.6189ZM26.9359 8.88481L19.3791 1.28812L8.66403 1.25988L1.06734 8.81663L1.0391 19.5317L8.59585 27.1284L19.311 27.1567L26.9076 19.5999L26.9359 8.88481Z",fill:"#B15600"}),Yn.jsx("path",{d:"M15.1664 7.58398H12.8331V16.9173H15.1664V7.58398Z",fill:"#B15600"}),Yn.jsx("path",{d:"M13.9998 21.6395C14.8896 21.6395 15.6109 20.9181 15.6109 20.0283C15.6109 19.1386 14.8896 18.4172 13.9998 18.4172C13.11 18.4172 12.3887 19.1386 12.3887 20.0283C12.3887 20.9181 13.11 21.6395 13.9998 21.6395Z",fill:"#B15600"})]})}return Yn.jsx(i,{component:Vv,open:d,autoHideDuration:l,onClose:(e,t)=>{"clickaway"!==t&&n()},exited:o,sx:{position:"fixed",top:20,left:20,right:20,zIndex:1,[e.breakpoints.up("tablet")]:{left:"auto"}},children:Yn.jsx(ln,{timeout:{enter:400,exit:400},in:d,appear:!0,unmountOnExit:!0,onEnter:()=>{r(!1)},onExited:()=>{r(!0)},nodeRef:s,children:o=>Yn.jsxs(i,{ref:s,sx:{display:"flex",justifyContent:"space-between",p:12,borderRadius:8,backgroundColor:"background.paper",color:"text.primary",border:"solid 1px",borderColor:"border.main",boxShadow:"0px 6px 12px 0px rgba(0, 0, 0, 0.10)",transform:zv[o],transition:"transform 300ms ease",[e.breakpoints.up("tablet")]:{p:20,width:"auto",maxWidth:328}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{mt:7,"& > svg":{width:28,height:28},[e.breakpoints.up("tablet")]:{"& > svg":{width:36,height:36}}},children:t?c:""}),Yn.jsxs(i,{sx:{ml:20},children:[Yn.jsx(i,{sx:{typography:"caption"},children:null==t?void 0:t.message}),(null==t?void 0:t.link)?Yn.jsxs(i,{component:"a",target:"_blank",rel:"noopener noreferrer",href:t.link.outerLink,sx:{display:"inline-flex",alignItems:"center",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},children:[t.link.text,Yn.jsx(i,{component:"svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{ml:4,width:18,height:18},children:Yn.jsx("path",{d:"M4.22703 13.2122L10.6811 6.75812L4.75206 6.75812L4.75736 5.25729H13.2426V13.7426H11.7471L11.7418 7.81878L5.28769 14.2729L4.22703 13.2122Z",fill:"currentColor"})})]}):"",(null==t?void 0:t.content)?Yn.jsx(i,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:t.content}):""]})]}),Yn.jsxs(i,{sx:{position:"relative",top:10,ml:12,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:12,borderStyle:"solid",borderWidth:l?"2.4px":0,borderColor:e.palette.border.main,backgroundColor:l?"transparent":e.palette.background.paperDarkContrast,cursor:"pointer",boxSizing:"border-box",[e.breakpoints.up("tablet")]:{ml:28}},onClick:n,children:[l?Yn.jsx(Hv,{size:24,strokeWidth:"2.4px",time:`${l}ms`,color:e.palette.text.disabled}):"",Yn.jsx(i,{component:"svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:16,height:16,border:"none",color:e.palette.text.disabled},children:Yn.jsx("g",{children:Yn.jsx("path",{d:"M12.8897 4.36345L9.25313 8L12.8897 11.6365L11.6775 12.8487L8.04095 9.21218L4.4044 12.8487L3.19221 11.6365L6.82876 8L3.19221 4.36345L4.4044 3.15127L8.04095 6.78782L11.6775 3.15127L12.8897 4.36345Z",fill:"currentColor"})})})]})]})})})}var Gv;function Qv(){return Qv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Qv.apply(null,arguments)}const Yv=e=>W.createElement("svg",Qv({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Gv||(Gv=W.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},W.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},W.createElement("g",{transform:"translate(18.000000, 291.000000)"},W.createElement("g",{transform:"translate(40.000000, 83.000000)"},W.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"}))))))),Kv=6;function Xv(){var e;const t=a();return Yn.jsx(i,{sx:{mx:"auto",border:`${Kv}px solid ${null===(e=t.palette)||void 0===e?void 0:e.background.input}`,borderRadius:"50%",width:"64px",height:"64px",position:"relative",animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}},children:Yn.jsx(i,{component:Yv,sx:{position:"absolute",top:`-${Kv}px`,right:`-${Kv}px`,color:"primary.main"}})})}function Jv({showingDone:e,errorMessage:t}){return a(),t?Yn.jsx(i,{component:li.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?Yn.jsx(i,{component:li.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):Yn.jsx(Xv,{})}function eb({showingDone:e,showing:t}){return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[Yn.jsx(i,{sx:{mt:60},children:e?(null==t?void 0:t.brief)===Iy?se._({id:"EcVqOR",message:"{0} Submitted",values:{0:null==t?void 0:t.brief}}):se._({id:"4xbbt/",message:"{0} confirmed",values:{0:null==t?void 0:t.brief}}):se._({id:"/nzjSF",message:"{0} pending",values:{0:null==t?void 0:t.brief}})}),(null==t?void 0:t.subtitle)?Yn.jsx(i,{sx:{mt:20,typography:"body2"},children:null==t?void 0:t.subtitle}):""]})}function tb({isStarted:t,isEnded:n,tx:o,currentRequestChainId:a}){const[s,l]=z(0),{chainId:d}=dg(),c=$((()=>tg(a||d||1,o,"tx")),[a,d,o]),u=$((()=>{const e=Math.floor(s/60),t=s%60;return e?`${e}m ${t}s`:`${t}s`}),[s]),p=G();return Q((()=>(t&&(l(0),window.clearInterval(p.current),p.current=window.setInterval((()=>{l((e=>e+1))}),1e3)),()=>{window.clearInterval(p.current)})),[t]),Q((()=>{n&&window.clearInterval(p.current)}),[n]),Yn.jsxs(i,{sx:{mt:20,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.secondary",border:"solid 1px transparent",borderTopColor:"border.main"},children:[Yn.jsxs(i,{children:[Yn.jsx(e,{id:"+Jkdiu",message:"Transaction Time:"}),u]}),Yn.jsxs(r,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:c,target:"_blank",rel:"noopener noreferrer",children:[Yn.jsx(e,{id:"S3piC2",message:"Tx"}),Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function nb(t){var n,o,{children:r,executionStatus:a,showSubmitLoadingDialog:s}=t;const l=Mg(qn(t,["children","executionStatus","showSubmitLoadingDialog"])),{ctxVal:d,showing:u,closeShowing:p,setShowing:h,showingDone:m,errorMessage:g,transactionTx:f,requests:x}=Object.assign(Object.assign({},l),a),{isMobile:y}=Tg(),{noSubmissionDialog:v,submissionDialogModal:b}=Jn(),j=()=>{h((e=>{if(!e)return e;const t=Object.assign({},e);return delete t.submitState,t}))},C=m&&(null==u?void 0:u.brief)===Iy&&!g,w=null===(o=null===(n=null==x?void 0:x.get(f))||void 0===n?void 0:n[0].metadata)||void 0===o?void 0:o.chainId;return Yn.jsxs(Ng.Provider,{value:d,children:[r,s&&Yn.jsx(Of,{modal:!0,open:!!(null==u?void 0:u.submitState),onClose:j,children:!!u&&Yn.jsxs(i,{sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",gap:20,p:20,minHeight:208,width:y?"100%":340,textAlign:"center"},children:[Yn.jsxs(i,{sx:{textAlign:"center",color:"text.secondary"},children:[u.brief,Yn.jsx(i,{component:li.Error,sx:{position:"absolute",top:20,right:20,color:"text.secondary",cursor:"pointer"},onClick:j})]}),"submitted"===u.submitState?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.ArrowSubmit,sx:{width:64,height:64}}),Yn.jsxs("div",{children:[Yn.jsx("div",{children:se._({id:"EcVqOR",message:"{0} Submitted",values:{0:u.brief}})}),u.subtitle&&Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]}),Yn.jsx(c,{variant:c.Variant.outlined,fullWidth:!0,onClick:j,sx:{mt:4},children:Yn.jsx(e,{id:"zga9sT",message:"OK"})})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Xv,{}),Yn.jsxs("div",{children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"7y/8M6",message:"Please confirm in wallet"})}),u.subtitle&&Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]})]})]})}),Yn.jsx(Of,{open:!!u&&"loading"!==u.submitState&&!v,onClose:p,id:"submission",modal:!!y||b,children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",px:20,pb:20,flex:1,overflowY:"auto",width:y?void 0:b?340:void 0},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{textAlign:"center",pt:60},children:Yn.jsx(Jv,{showingDone:m,errorMessage:g})}),g?Yn.jsxs(i,{sx:{textAlign:"center",mt:60},children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"kf83Ld",message:"Something went wrong."})}),Yn.jsx(i,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:g})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(eb,{showingDone:m,showing:u}),Yn.jsx(tb,{isStarted:!!u,isEnded:m,tx:f,currentRequestChainId:w})]})]}),C&&Yn.jsx(c,{variant:c.Variant.outlined,fullWidth:!0,size:c.Size.big,onClick:()=>{yg(fg.Initial),p(),xg.setState({crossChainSubmittedCounter:1}),setTimeout((()=>{xg.setState({crossChainSubmittedCounter:0})}),300)},sx:{mt:y?20:"auto"},children:"Check in order list"}),Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:()=>{yg(fg.Initial),p()},sx:{mt:C?12:y?20:"auto"},children:g?Yn.jsx(e,{id:"1QfxQT",message:"Dismiss"}):Yn.jsx(e,{id:"yz7wBu",message:"Close"})})]})})]})}const ib="dodo-widget-container";function ob(e){return e.noLangProvider?Yn.jsx(Yn.Fragment,{children:e.children}):Yn.jsx(Vy,{locale:e.locale,children:Yn.jsx(nb,{...e,children:e.children})})}function rb(e){return Rf(e),wg(),function(){const{chainId:e,evmProvider:t}=dg();H.useEffect((()=>{const n=n=>{if(n===e){const e=ah.get(n);if(null==e?void 0:e.isEVMChain)return t}return null},i=new sn({multiCallAddressList:ct,getProvider:n,rpc:qu()});np.setGetConfigProvider(n),ut(i),Ie(i)}),[e,t])}(),e.noUI?Yn.jsx(ob,{...e,children:e.children}):null}function ab(e){var t;const n=G(null);return Yn.jsx(Xn,{...Object.assign(Object.assign({},e),{widgetRef:null!==(t=e.widgetRef)&&void 0!==t?t:n}),children:Yn.jsx(rb,{...e})})}function sb(e){const t=u({mode:e.colorMode,theme:e.theme,lang:e.locale||Ry});return e.apikey||e.apiServices||console.error("apikey and apiServices must have a."),Yn.jsxs(p,{theme:t,children:[Yn.jsx(h,{container:`.${ib}, .${m}, .${g}`}),Yn.jsx(rt,{client:Wy,children:Yn.jsxs(ab,{...e,children:[e.children,Yn.jsx(Zv,{})]})})]})}function lb(e){var{sx:t}=e,n=qn(e,["sx"]);const{width:i}=Jn(),o=$((()=>{let e="";return"number"==typeof i?e=`${i}px`:i&&(e=i),e?`calc(${e} - 40px)`:"auto"}),[i]);return Yn.jsx(f,{container:document.querySelector(`.${ib}`),maxWidth:o,sx:Object.assign({cursor:"help"},t),...n})}function db({route:t}){const n=a();ah.get(t.fromChainId);const o=ah.get(t.toChainId),[s,l]=z(!1),[c,u]=z(!1),p=df({fees:t.fees});return Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{py:20,borderStyle:"solid",borderWidth:n.spacing(1,0,0),borderColor:n.palette.border.main},children:Yn.jsx(x,{children:Yn.jsx(y,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[Yn.jsx(i,{component:li.DetailBorder,sx:{mr:6,width:18,height:18}}),Yn.jsx(e,{id:"rRDi3Y",message:"Detail"})]}),Yn.jsx(i,{component:li.CaretUp,sx:{width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]}),children:Yn.jsxs(i,{sx:{mt:16},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary",flexShrink:0},children:Yn.jsx(e,{id:"lt8yMa",message:"Send to:"})}),Yn.jsxs(i,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[o?Yn.jsx(i,{component:o.logo,sx:{width:18,height:18}}):null,Yn.jsx(i,{sx:{display:"inline-block",mx:6,width:"1px",height:12,backgroundColor:"border.main"}}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},children:eg(t.toAddress)}),Yn.jsx(r,{component:"a",href:tg(t.toChainId,t.toAddress,"address"),target:"_blank",rel:"noopener noreferrer",sx:{ml:6,width:18,height:18,color:"text.secondary",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:18,height:18}})})]})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:Yn.jsx(e,{id:"sMMlTX",message:"Total fees"})}),Yn.jsxs(i,{component:d,onClick:()=>l(!s),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[Yn.jsx(i,{sx:{fontWeight:600,color:n.palette.text.primary},children:t.feeUSD?`~$${t.feeUSD}`:"-"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:s?Yn.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):Yn.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),s&&p.map((e=>Yn.jsxs(i,{sx:{mt:8,pl:22,pr:22,display:"flex",alignItems:"center",justifyContent:"space-between",color:"text.secondary",typography:"body2",position:"relative"},children:[Yn.jsx(i,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:"10",height:"25",viewBox:"0 0 10 25",fill:"none",sx:{width:10,height:25,position:"absolute",left:10,bottom:10},children:Yn.jsx("path",{d:"M9 24L2 24C1.44772 24 1 23.5523 1 23L1 1",stroke:"currentColor",strokeOpacity:"0.5",strokeLinecap:"round",strokeDasharray:"2 2"})}),Yn.jsx(i,{sx:{flex:1},children:e.title}),e.isFree?Yn.jsx(i,{sx:{color:n.palette.primary.main},children:"Free"}):null!==e.value?Yn.jsxs(i,{sx:{color:n.palette.text.primary},children:["~$",e.value]}):Yn.jsx(i,{sx:{color:n.palette.text.primary},children:"-"})]},e.title))),Yn.jsxs(i,{sx:{mt:8,mb:c?8:0,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"body2",fontWeight:600,color:"success.main",flexShrink:0},children:"Fee comparison"}),Yn.jsxs(i,{component:d,onClick:()=>u(!c),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary},children:"ZUNO"}),Yn.jsx(i,{sx:{px:8,borderRadius:12,backgroundColor:n.palette.success.main,typography:"h6",fontWeight:600,color:n.palette.success.contrastText,textTransform:"uppercase"},children:"Cheapest"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:c?Yn.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):Yn.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),c&&Yn.jsx(If,{feeUSD:t.feeUSD}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:[Yn.jsx(e,{id:"CMHmbm",message:"Slippage"}),Yn.jsx(lb,{onlyHover:!0,title:Yn.jsx(e,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:6})]}),Yn.jsxs(i,{sx:{typography:"body2"},children:[100*t.slippage,"%"]})]})]})})})}),Yn.jsx(i,{sx:{pt:0,pb:0,borderStyle:"solid",borderWidth:n.spacing(1,0,0),borderColor:n.palette.border.main},children:Yn.jsx(x,{children:Yn.jsx(y,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:Yn.jsxs(i,{sx:{py:20,display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[Yn.jsx(i,{component:li.DetailBorder,sx:{mr:6,width:18,height:18}}),Yn.jsx(e,{id:"QNWt8A",message:"Estimated Time"})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:[t.executionDuration?hf({start:Date.now(),end:Date.now()+1e3*t.executionDuration}):"-",Yn.jsx(i,{component:li.CaretUp,sx:{ml:6,width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]})]}),children:Yn.jsx(hy,{route:t,isMobile:!0})})})})]})}function cb({open:t,onClose:n,route:o,bridgeOrderTxRequest:r,clearToAmt:s,clearFromAmt:l,isDialogModal:d}){const u=a(),{contractStatus:p}=xg(),h=Ey({route:o,bridgeOrderTxRequest:r});return Q((()=>{p!==fg.Pending&&n(),p===fg.TxSuccess&&(s(),l())}),[p]),Yn.jsx(Of,{title:Yn.jsx(e,{id:"tKE4Ak",message:"Cross Chain Summary"}),open:t,id:"cross-chain-summary",onClose:()=>{yg(fg.Initial),n()},modal:d,children:Yn.jsxs(Yn.Fragment,{children:[o?Yn.jsxs(i,{sx:{px:16,pb:20,flex:1,overflowY:"auto"},children:[Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"36% 28% 36%",py:20,borderStyle:"solid",borderWidth:u.spacing(1,0,0),borderColor:u.palette.border.main},children:[Yn.jsx(Ly,{token:o.fromToken,chainId:o.fromChainId,amount:o.fromAmount}),Yn.jsx(Oy,{children:Yn.jsx(i,{sx:{display:"flex",px:3,py:3,backgroundColor:u.palette.background.paperContrast,border:`1px solid ${u.palette.border.main}`,borderRadius:"50%",alignItems:"center",width:24,height:24,overflow:"hidden"},children:Yn.jsx(Ay,{size:"medium",toolDetails:o.step.toolDetails,nameMarginLeft:8})})}),Yn.jsx(Ly,{token:o.toToken,chainId:o.toChainId,amount:o.toTokenAmount})]}),Yn.jsx(db,{route:o})]}):"",Yn.jsx(i,{sx:{px:16,py:20},children:Yn.jsx(c,{fullWidth:!0,isLoading:p==fg.Pending,disabled:!o,onClick:()=>{h(),yg(fg.Pending)},children:p==fg.Pending?Yn.jsx(e,{id:"P+K/3O",message:"Confirming"}):Yn.jsx(e,{id:"PZqJog",message:"Confirm Cross Chain"})})})]})})}function ub({message:t,onClose:n,isDialogModal:o}){return Yn.jsx(Of,{open:!!t,onClose:n,id:"error-message",modal:o,children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{flex:1,textAlign:"center"},children:[Yn.jsx(i,{component:li.ErrorWarn,sx:{mt:60,width:64,height:64,color:"error.main"}}),t?Yn.jsxs(i,{sx:{textAlign:"center",mt:60},children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"kf83Ld",message:"Something went wrong."})}),Yn.jsx(i,{sx:{color:"text.secondary",mt:12,mx:20,typography:"body2",wordBreak:"break-all",overflow:"auto",height:"300px"},children:t})]}):""]}),Yn.jsx(i,{sx:{px:16,py:20},children:Yn.jsx(c,{onClick:n,fullWidth:!0,children:Yn.jsx(e,{id:"1QfxQT",message:"Dismiss"})})})]})})}function pb(){const[e,t]=z(!1);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(d,{sx:{mt:16,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:4,typography:"body2",fontWeight:600,color:"text.link","&:hover":{color:"text.primary"}},onClick:()=>t(!0),children:[Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"19",height:"19",viewBox:"0 0 19 19",fill:"none",children:Yn.jsx("path",{d:"M3.5 16.25V4.25C3.5 3.8375 3.64687 3.48438 3.94063 3.19063C4.23438 2.89687 4.5875 2.75 5 2.75H9.5C9.9125 2.75 10.2656 2.89687 10.5594 3.19063C10.8531 3.48438 11 3.8375 11 4.25V9.5H11.75C12.1625 9.5 12.5156 9.64688 12.8094 9.94063C13.1031 10.2344 13.25 10.5875 13.25 11V14.375C13.25 14.5875 13.3219 14.7656 13.4656 14.9094C13.6094 15.0531 13.7875 15.125 14 15.125C14.2125 15.125 14.3906 15.0531 14.5344 14.9094C14.6781 14.7656 14.75 14.5875 14.75 14.375V8.975C14.6375 9.0375 14.5188 9.07813 14.3938 9.09688C14.2688 9.11563 14.1375 9.125 14 9.125C13.475 9.125 13.0312 8.94375 12.6688 8.58125C12.3063 8.21875 12.125 7.775 12.125 7.25C12.125 6.85 12.2344 6.49063 12.4531 6.17188C12.6719 5.85313 12.9625 5.625 13.325 5.4875L11.75 3.9125L12.5375 3.125L15.3125 5.825C15.5 6.0125 15.6406 6.23125 15.7344 6.48125C15.8281 6.73125 15.875 6.9875 15.875 7.25V14.375C15.875 14.9 15.6938 15.3438 15.3313 15.7063C14.9688 16.0688 14.525 16.25 14 16.25C13.475 16.25 13.0312 16.0688 12.6688 15.7063C12.3063 15.3438 12.125 14.9 12.125 14.375V10.625H11V16.25H3.5ZM5 8H9.5V4.25H5V8ZM14 8C14.2125 8 14.3906 7.92813 14.5344 7.78438C14.6781 7.64062 14.75 7.4625 14.75 7.25C14.75 7.0375 14.6781 6.85938 14.5344 6.71563C14.3906 6.57188 14.2125 6.5 14 6.5C13.7875 6.5 13.6094 6.57188 13.4656 6.71563C13.3219 6.85938 13.25 7.0375 13.25 7.25C13.25 7.4625 13.3219 7.64062 13.4656 7.78438C13.6094 7.92813 13.7875 8 14 8Z",fill:"currentColor"})}),"Gas Refuel>"]}),Yn.jsx(Of,{open:e,onClose:()=>t(!1),title:"Gas refuel",modal:!0,children:Yn.jsxs(i,{sx:{maxWidth:540,minHeight:600,px:20,pb:24,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[Yn.jsx(i,{sx:{pt:20,borderTopWidth:1,borderTopStyle:"solid",borderColor:"border.main",typography:"body2",color:"text.secondary"},children:"A solution for gas refueling that allows you to refill your wallet anonymously and gas-free."}),Yn.jsx(i,{component:"iframe",src:"https://smolrefuel.com/?partner=0x1271CAba4bf23f8Fb31F97448605d65EE302CA51",width:"100%",sx:{borderRadius:12,overflow:"hidden",flex:1,border:"none"}})]})})]})}function hb({open:t,execute:n,onClose:o,toToken:r,fromToken:s,fromAmount:l,toAmount:u,priceImpact:p,clearFromAmt:h,clearToAmt:m,baseFeeAmount:g,curToFiatPrice:f,curFromFiatPrice:x,pricePerFromToken:y,additionalFeeAmount:b,loading:j,slippage:C,isDialogModal:w}){var k,T;const I=a(),{contractStatus:S}=xg(),E=$((()=>new Pe(p).gt(mh)),[p]),[A,O]=z(!1),[L,R]=z(!1);return Q((()=>{S!==fg.Pending&&o(),S===fg.TxSuccess&&(m(),h())}),[S]),Q((()=>{O(!1)}),[f]),Yn.jsx(Of,{open:t,onClose:()=>{yg(fg.Initial),o()},id:"swap-summary",title:Yn.jsx(e,{id:"QR4/RH",message:"Swap summary"}),modal:w,children:Yn.jsxs(i,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${I.palette.border.main}`},children:[Yn.jsxs(i,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${I.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[Yn.jsx(Df,{width:16,height:16,url:null==s?void 0:s.logoURI,address:null!==(k=null==s?void 0:s.address)&&void 0!==k?k:"",marginRight:6}),Yn.jsx(i,{children:`${Am({input:l,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`})]}),Yn.jsx(i,{sx:{mt:4,typography:"h6",color:I.palette.text.secondary},children:x?`$${Em({input:x,showDecimals:1})}`:"-"})]}),Yn.jsx(i,{sx:{width:16,mx:16},component:li.DoubleRight}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex"},children:[Yn.jsx(Df,{width:16,height:16,marginRight:6,url:null==r?void 0:r.logoURI,address:null!==(T=null==r?void 0:r.address)&&void 0!==T?T:""}),Yn.jsx(v,{loading:j,loadingProps:{width:30},children:`${Am({input:u,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),Yn.jsx(v,{loading:j,loadingProps:{width:30},sx:{typography:"h6",mt:4,color:I.palette.text.secondary},children:f?`$${Em({input:f,showDecimals:1})}`:"-"})]})]}),Yn.jsxs(i,{sx:{mt:12,display:"flex",alignItems:"center",typography:"h6"},children:["1 ",null==s?void 0:s.symbol," = ",Yn.jsx(v,{loading:j,loadingProps:{width:30},children:Am({input:new Pe(u).dividedBy(new Pe(l)),decimals:null==r?void 0:r.decimals})})," ",null==r?void 0:r.symbol]})]}),Yn.jsxs(i,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${I.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:I.palette.text.secondary},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{width:16,mr:7},component:li.DetailBorder}),Yn.jsx(e,{id:"XeovX3",message:"Swap Detail"})]}),Yn.jsx(i,{component:d,children:Yn.jsx(i,{onClick:()=>R(!L),sx:{width:10,color:"text.secondary",transform:L?"rotateX(0deg)":"rotateX(180deg)"},component:li.CaretUp})})]}),Yn.jsxs(i,{sx:{mt:16,display:L?"initial":"none"},children:[Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"93m8jT",message:"Basic Fee"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"8Z29ZO",message:"Estimated service provider fees"}),ml:5})]}),Yn.jsx(v,{loading:j,loadingProps:{width:30},children:g?`${Am({input:g,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`:"0"})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"J39pAJ",message:"Additional Fee"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"ZXvy7b",message:"Additional routing fees set by the Widget user"}),ml:5})]}),Yn.jsx(v,{loading:j,loadingProps:{width:30},children:b?`${Am({input:b,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`:"0"})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"T+qgFw",message:"Price Impact"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),Yn.jsx(i,{children:`${p}%`})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"CMHmbm",message:"Slippage"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"GAypnX",message:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),Yn.jsxs(i,{children:[C,"%"]})]})]})]}),Yn.jsx(i,{sx:{flex:1}}),E&&Yn.jsxs(i,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>O(!A),children:[Yn.jsx(i,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:A?Yn.jsx(i,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:Yn.jsx(i,{component:li.Done,sx:{width:14,color:"secondary.contrastText"}})}):Yn.jsx(i,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${I.palette.text.secondary}`}})}),Yn.jsx(i,{children:Yn.jsx(e,{components:{0:Yn.jsx(i,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:p},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),Yn.jsx(c,{isLoading:S==fg.Pending,disabled:E&&!A,fullWidth:!0,onClick:()=>{n(),yg(fg.Pending)},children:S==fg.Pending?Yn.jsx(e,{id:"P+K/3O",message:"Confirming"}):Yn.jsx(e,{id:"lQ6r7x",message:"Confirm swap"})})]})})}function mb(e){var{sx:t,maxVal:n,decimals:i=2,onInputChange:o}=e,r=qn(e,["sx","maxVal","decimals","onInputChange"]);return Yn.jsx(b,{...r,onChange:e=>{const t=0===e.target.value.length?null:Rm(e.target.value,i),r=n&&t&&new _e(t).gt(n)?n.toString():t;o&&o(r)}})}function gb({open:t,onClose:n,isBridge:o,isDialogModal:r}){const s=a(),{slippage:l}=xg(),d=$((()=>Number(l)>=fh),[l]),{defaultSlippage:c}=Kg(o);return Yn.jsx(Of,{open:t,onClose:n,id:"swap-settings",title:Yn.jsx(e,{id:"Tz0i8g",message:"Settings"}),modal:r,children:Yn.jsx(i,{sx:{mx:20},children:Yn.jsxs(i,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[Yn.jsxs(i,{sx:{mb:16,display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"lqTDfd",message:"Slippage Tolerance"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column"},children:[Yn.jsx(mb,{fullWidth:!0,maxVal:100,value:null!=l?l:"",placeholder:c.toString(),onInputChange:e=>{!function(e,t){null===t?localStorage.removeItem(e?ph:uh):localStorage.setItem(e?ph:uh,String(t))}(!!o,e),bg(e)},suffix:Yn.jsx(i,{sx:{color:"text.disabled"},children:"%"}),height:36,sx:{mt:12}}),d&&Yn.jsx(i,{sx:{typography:"h6",mt:6,color:"error.main"},children:Yn.jsx(e,{id:"Zm56FI",message:"Maximum slippage do not exceed 50%"})})]})]})})})}const fb="position-y-dot";function xb(){return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(j,{width:"100%",height:12}),Yn.jsx(j,{width:"100%",height:12})]})}function yb({data:e,loading:t}){var n,o;const r=a(),s=r.palette.primary.main,l=H.useRef(null),d=e.length;return Yn.jsx(i,{sx:{height:105,flex:1,[`& .${fb}`]:{}},ref:l,children:t?Yn.jsx(xb,{}):Yn.jsx(i,{component:dn,sx:{typography:"h6","& .recharts-cartesian-axis text":{fill:r.palette.background.paperContrast}},children:Yn.jsxs(cn,{data:e,margin:{top:0,right:0,left:0,bottom:0},children:[Yn.jsx(un,{dataKey:"forecastSlippage",axisLine:!1,tickLine:!1,interval:"preserveStartEnd",tickFormatter:e=>Vm({input:e}),type:"number",domain:[d&&null!==(n=e[0].forecastSlippage)&&void 0!==n?n:0,d&&null!==(o=e[d-1].forecastSlippage)&&void 0!==o?o:"auto"]}),Yn.jsx(pn,{dataKey:"confidenceRatio",axisLine:!1,tickLine:!1,hide:!0}),Yn.jsx("defs",{children:Yn.jsxs("linearGradient",{id:"count-linear",x1:"0",y1:"0",x2:"0",y2:"1",children:[Yn.jsx("stop",{offset:"0",stopColor:s,stopOpacity:.3}),Yn.jsx("stop",{offset:"100%",stopColor:s,stopOpacity:0})]})}),Yn.jsx(hn,{type:"monotone",dataKey:"confidenceRatio",stroke:s,strokeWidth:2,fill:"url(#count-linear)"}),e.map((e=>Yn.jsx(mn,{x:e.forecastSlippage,y:e.confidenceRatio,r:1,fill:r.palette.text.primary,stroke:"none",className:fb},e.confidenceRatio)))]})})})}var vb=H.memo(yb);const bb=C(w)((({theme:e})=>({height:2,padding:"15px 0",margin:0,"& .base-Slider-valueLabel":{fontSize:12,fontWeight:"normal",top:-6,backgroundColor:"unset",color:e.palette.text.primary,"&:before":{display:"none"},"& *":{background:"transparent",color:e.palette.text.primary}},"& .base-Slider-track":{display:"none"},"& .base-Slider-rail":{backgroundColor:e.palette.text.disabled,height:1,opacity:1},"& .base-Slider-mark":{display:"none",opacity:1,backgroundColor:e.palette.success.main,height:6,width:4,borderRadius:4},"& .base-Slider-markLabel":{display:"none",fontSize:"12px",lineHeight:"17px"}})));function jb(t){var{hidden:n,sx:o,value:r,color:a,min:s,max:l,formatValue:d,getSliderYPosition:c}=t,u=qn(t,["hidden","sx","value","color","min","max","formatValue","getSliderYPosition"]);const{children:p}=u,h=qn(u,["children"]),{isMobile:m}=k(),g=H.useRef(null),f=c(r),x=m?4:0,y=f?f-39-x:void 0,v=null!=a?a:"text.primary",b=r===s,j=r===l;return Yn.jsxs(i,{...h,ref:g,sx:Object.assign({position:"absolute","&&&":{display:n?"none":"block",backgroundColor:"transparent",boxShadow:"none",bottom:8+x,width:"auto",height:"auto",top:"auto",marginLeft:0,transform:"none"}},o),children:[p,Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[y?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:v,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),Yn.jsx(i,{sx:{height:y,width:"0",borderStyle:"dashed",borderWidth:1,borderColor:v}})]}):"",Yn.jsx(i,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:v,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),Yn.jsxs(i,{sx:Object.assign(Object.assign({typography:"h6",position:"absolute",bottom:-20,color:v,whiteSpace:"nowrap",backgroundColor:"background.paperContrast"},b?{left:0}:{}),j?{right:0}:{}),children:[j?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:"span",sx:{color:"success.main"},children:Yn.jsx(e,{id:"cOvZFM",message:"Dynamic"})}),Yn.jsx("span",{children:" • "})]}):"",d(r)]})]})]})}function Cb(e){var{hoverValue:t,formatValue:n,getSliderYPosition:i}=e,o=qn(e,["hoverValue","formatValue","getSliderYPosition"]);const{isMobile:r}=k(),a=r?"primary.main":void 0,s=r?void 0:"primary.main";return Yn.jsx(bb,{slots:{thumb:e=>{const l=o.value&&"number"==typeof o.value&&(o.min&&o.value<o.min||o.max&&o.value>o.max),d={value:o.value,min:o.min,max:o.max,hidden:!!l,color:a,formatValue:n,getSliderYPosition:i},c=Object.assign(Object.assign({},e),d);if(null!==t&&o.max&&o.min&&o.value!==t){const e=o.max-o.min,n=t-o.min,i=n?n/e*100:0;if(r){const e=!!t&&(!!o.min&&t<o.min||!!o.max&&t>o.max);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(jb,{...d,value:t,color:s,hidden:e,sx:{left:i+"%"}}),Yn.jsx(jb,{...c})]})}return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(jb,{...c}),Yn.jsx(jb,{...d,value:t,hidden:!1,color:s,sx:{left:i+"%"}})]})}return Yn.jsx(jb,{...c})}},...o})}const wb=(e,{time:t=100,wrapper:n=document,retryCount:i=50}={})=>new Promise((o=>{n.querySelector(e)?o(!0):setTimeout((()=>Vn(void 0,void 0,void 0,(function*(){if(n.querySelector(e))o(!0);else if(i){const r=yield wb(e,{time:t,wrapper:n,retryCount:i-1});o(r)}else o(!1)}))),t)}));function kb({data:t,activeSlippage:n,loading:o,sx:r,handleChangeCustomSlippage:a}){const s=H.useMemo((()=>{var e;return null!==(e=null==t?void 0:t.length)&&void 0!==e?e:0}),[t]),{isMobile:l}=k(),[d,c]=H.useState([]),u=H.useRef(null);H.useEffect((()=>{(()=>{Vn(this,void 0,void 0,(function*(){var e;if(u.current&&s){const t=`.${fb}`;yield wb(t,{wrapper:u.current});const n=u.current.querySelectorAll(t),{y:i,height:o}=u.current.getBoundingClientRect(),r=null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0,a=[];for(let e=0;e<r;e++){const t=n[e];const r=(t.children[0]?t.children[0].getBoundingClientRect().y:t.getBoundingClientRect().y)-i-.5;a.push(o-r)}c(a)}}))})()}),[s]);const p=(({activeSlippage:e,data:t,yPositions:n})=>{const[i,o]=H.useState(0),r=H.useMemo((()=>1e6),[]),[a,s]=H.useMemo((()=>{var e,n;const i=null==t?void 0:t.length;return i?[new Pe(null!==(e=t[0].forecastSlippage)&&void 0!==e?e:0).times(null!=r?r:0).dp(0,1).toNumber(),new Pe(null!==(n=t[i-1].forecastSlippage)&&void 0!==n?n:0).times(null!=r?r:0).dp(0,1).toNumber()]:[0,0]}),[t,r]),l=H.useCallback((e=>{if(void 0===e)return"";const n=new Pe(e);if((null==t?void 0:t.length)&&r){const e=t.find((e=>{var t;return new Pe(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(r).dp(0,1).isEqualTo(n)}));if(null==e?void 0:e.forecastSlippage)return Vm({input:e.forecastSlippage,showDecimals:4})}return Vm({input:r?n.div(r):n,showDecimals:4})}),[r,t]),d=H.useCallback((e=>{let i=0;return e&&(null==t?void 0:t.length)&&r?(t.some(((o,a)=>{var s,l;const d=null!==(s=o.forecastSlippage)&&void 0!==s?s:0,c=new Pe(d).times(r).dp(0,1).toNumber();if(e===c)return i=n[a],!0;if(e<c){if(0===a)return i=0,!0;const o=d-(null!==(l=t[a-1].forecastSlippage)&&void 0!==l?l:0),s=n[a]-n[a-1],c=d-new Pe(e).div(r).toNumber();return i=n[a]-s/o*c,!0}})),i):i}),[n,t,r]),c=H.useCallback((e=>{o(e);const n=new Pe(e);let i,a=-1;if((null==t?void 0:t.length)&&r){a=t.findIndex((e=>{var t;return new Pe(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(r).dp(0,1).isEqualTo(n)}));const e=-1!==a?t[a]:void 0;i=null==e?void 0:e.forecastSlippage}return i||(i=n.div(null!=r?r:0).toNumber()),i}),[t,r]);return H.useEffect((()=>{if(r&&e){const t=new Pe(e).times(r).dp(0,1);t.isEqualTo(i)||o(t.toNumber())}}),[e]),{min:a,max:s,value:i,decimalConversion:r,formatValue:l,getSliderYPosition:d,handleChangeValue:c}})({data:t,activeSlippage:n,yPositions:d}),{hoverValue:h,setHoverValue:m}=function(e,{slippageSlider:t}){const{isMobile:n}=k(),[i,o]=H.useState(null),r=H.useRef(!1);return H.useEffect((()=>{if(e.current&&t.max){const a=e.current;let{width:s,x:l}=a.getBoundingClientRect();const d=e=>{if(r.current)return;const n=e.pageX-l,a=t.max-t.min,d=new Pe(n/s*a).integerValue().plus(t.min).toNumber();d!==i&&o(d)},c=()=>{o(null)},u=()=>{r.current=!1},p=()=>{r.current=!0};return n||(a.addEventListener("mousemove",d),a.addEventListener("mouseleave",c),a.addEventListener("mouseup",u),a.addEventListener("mousedown",p)),()=>{n&&(a.removeEventListener("mousemove",d),a.removeEventListener("mouseleave",c),a.removeEventListener("mouseUp",u),a.removeEventListener("mouseDown",p))}}}),[e,n]),{hoverValue:i,setHoverValue:o}}(u,{slippageSlider:p}),{successRate:g,hoverSuccessRate:f}=function({data:e,activeSlippage:t,hoverValue:n,decimalConversion:i}){const o=H.useMemo((()=>{var n,i;let o="-";if(t&&(null==e?void 0:e.length)){const r=e.some(((n,i)=>{var r,a,s,l,d,c;const u=null!==(r=n.forecastSlippage)&&void 0!==r?r:0;if(t===u)return o=Vm({input:null!==(a=null==n?void 0:n.confidenceRatio)&&void 0!==a?a:0}),!0;if(t<u){if(0===i)o=`< ${Vm({input:null!==(s=null==n?void 0:n.confidenceRatio)&&void 0!==s?s:0})}`;else{const t=Vm({input:null!==(d=null===(l=e[i-1])||void 0===l?void 0:l.confidenceRatio)&&void 0!==d?d:0}),r=Vm({input:null!==(c=null==n?void 0:n.confidenceRatio)&&void 0!==c?c:0});o=`${t} - ${r}`}return!0}return!1}));r||(o=`> ${Vm({input:null!==(i=null===(n=e[e.length-1])||void 0===n?void 0:n.confidenceRatio)&&void 0!==i?i:0})}`)}return o}),[e,t]),r=H.useMemo((()=>{var t,o;let r="";if(n&&(null==e?void 0:e.length)&&i){const a=e.some(((t,o)=>{var a,s,l,d,c,u;const p=null!==(a=t.forecastSlippage)&&void 0!==a?a:0,h=new Pe(p).times(i).dp(0,1).toNumber();if(n===h)return r=Vm({input:null!==(s=null==t?void 0:t.confidenceRatio)&&void 0!==s?s:0}),!0;if(n<h){if(0===o)r=`< ${Vm({input:null!==(l=null==t?void 0:t.confidenceRatio)&&void 0!==l?l:0})}`;else{const n=Vm({input:null!==(c=null===(d=e[o-1])||void 0===d?void 0:d.confidenceRatio)&&void 0!==c?c:0}),i=Vm({input:null!==(u=null==t?void 0:t.confidenceRatio)&&void 0!==u?u:0});r=`${n} - ${i}`}return!0}return!1}));a||(r=`> ${Vm({input:null!==(o=null===(t=e[e.length-1])||void 0===t?void 0:t.confidenceRatio)&&void 0!==o?o:0})}`)}return r}),[n,i,e]);return{successRate:o,hoverSuccessRate:r}}({data:t,activeSlippage:n,hoverValue:h,decimalConversion:p.decimalConversion});return t?Yn.jsxs(i,{sx:Object.assign({p:12,pb:28,borderRadius:12,backgroundColor:"background.paperContrast"},r),children:[Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{typography:"h6",fontWeight:600,color:"text.secondary"},children:Yn.jsx(e,{id:"88dol0",message:"Success Rate"})}),Yn.jsx(v,{loading:o,loadingProps:{width:100},sx:{mt:4,typography:"caption",color:f?"primary.main":"text.primary"},children:f||g})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"flex-end",pr:4},children:[Yn.jsx(i,{sx:{pb:8,mr:16,typography:"h6",fontWeight:600},children:Yn.jsx(e,{id:"CMHmbm",message:"Slippage"})}),Yn.jsxs(i,{sx:{flex:1},ref:u,children:[Yn.jsx(vb,{data:t,loading:o}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:!o&&s?Yn.jsx(Cb,{value:l?h||-1:p.value,min:p.min,max:p.max,disabled:!l,marks:[{value:p.max,label:p.max}],formatValue:p.formatValue,getSliderYPosition:p.getSliderYPosition,hoverValue:l?p.value:h,onChange:(e,t)=>{if("number"==typeof t){if(l)return void m(t);const e=p.handleChangeValue(t);a(e)}},onChangeCommitted:()=>{m(null)}}):""})]})]})]}):null}var Tb,Ib=H.memo(kb);function Sb({title:t,desc:n,doNotChecked:o,onChangeDoNotChecked:r}){const s=a();if($((()=>o),[]))return null;const l=s.palette.warning.main;return Yn.jsxs(i,{sx:{backgroundColor:T(l,.1),borderRadius:8,padding:12},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,typography:"body2",color:l,fontWeight:700},children:[Yn.jsx(li.Warn,{}),t]}),Yn.jsx(i,{sx:{mt:8,typography:"body2",fontWeight:500,color:s.palette.text.secondary,textAlign:"center"},children:n}),!!r&&Yn.jsxs(i,{sx:{width:"100%",mt:20,color:s.palette.text.secondary,typography:"h6",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:8,cursor:"pointer"},component:"label",children:[Yn.jsx(I,{checked:o,size:16,onChange:e=>{const{checked:t}=e.target;r(t)}}),Yn.jsx(e,{id:"3WdxUv",message:"Do not remind again"})]})]})}function Eb({fromToken:t,toToken:n}){var o,r;const s=a(),{slippageAdvanced:d,notRemindAgainSlippageHigher:c,notRemindAgainSlippageLower:u}=Gg(),{customSlippage:p,customSlippageNum:h,handleSlippageChange:m,forecastSlippage:g,forecastSlippageQuery:x,recommendSlippage:y}=tf({fromToken:t,toToken:n}),j=!!g,[C,w]=H.useState(!1),[k,L]=H.useState();!k&&t&&n&&L(p?Tb.custom:Tb.recommend);const R=k===Tb.custom,P=H.useRef(null),_=H.useMemo((()=>k===Tb.custom?h?new Pe(h).div(100).toNumber():void 0:new Pe(y).div(100).toNumber()),[k,y,h]),M=H.useCallback((e=>{R||L(Tb.custom),m({slippage:new Pe(e).times(100).toString(),disabled:!1,deleted:!1,recommend:String(y)})}),[R,y,m]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{mt:24,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[Yn.jsx(e,{id:"x6GJ4a",message:"Max Slippage"}),Yn.jsx(f,{title:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"qoii6e",message:"The dynamic slippage is provided by ZUNO team through analyzing historical transactions."}),Yn.jsx("br",{}),Yn.jsxs(i,{component:"a",href:se._({id:"zABfk1",message:"https://blog.dodoex.io/introducing-the-dodo-smart-slippage-3d32d13a4fef"}),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[Yn.jsx(e,{id:"NgeSlx",message:"Learn More"}),">"]})]}),ml:7})]}),x.isLoading||(null===(o=x.slippageData.slippageList)||void 0===o?void 0:o.length)?Yn.jsxs(v,{loading:x.isLoading,loadingProps:{width:100},component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[Yn.jsx(e,{id:"sxkWRg",message:"Advanced"}),Yn.jsx(I,{sx:{top:-1},size:16,checked:d,onChange:e=>{const{checked:t}=e.target;Gg.setState({slippageAdvanced:t})}})]}):""]}),!!k&&Yn.jsxs(S,{value:k,onChange:(e,t)=>{L(t),t===Tb.custom&&w(!0)},children:[Yn.jsxs(E,{variant:"inPaper",sx:{mt:16,'&:not(:hover) [aria-selected="true"] .weak':{color:T(s.palette.secondary.contrastText,.5)}},children:[Yn.jsx(A,{value:Tb.recommend,variant:"inPaper",sx:{position:"relative"},children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:"span",sx:{position:"absolute",top:4,left:4,ml:4,typography:"h6",fontWeight:600,padding:s.spacing(0,8),borderRadius:4,backgroundColor:R?T(s.palette.purple.main,.1):"#FFF"},children:Yn.jsx(i,{component:"span",sx:{background:R?`linear-gradient(90deg, ${s.palette.purple.main} -1.33%, ${"dark"===s.palette.mode?"#E6D9FF":"#BFAFF3"} 98.67%)`:`linear-gradient(90deg, ${s.palette.purple.main} -1.33%, #BFAFF3 98.67%)`,backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"New"})}),Yn.jsxs(i,{sx:{textAlign:"center"},children:[j?Yn.jsxs(i,{sx:{flexGrow:1,typography:"body2",fontWeight:600},children:[y.toString()||"-","%"]}):Yn.jsx(l,{title:Yn.jsx(e,{id:"wSpNR+",message:"This trading pair does not have enough historical data and has used the default dynamic slippage."}),sx:{ml:0,maxWidth:240},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"body2",fontWeight:600,color:s.palette.warning.main,gap:4},children:[Yn.jsx(i,{component:li.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),Yn.jsxs("span",{children:[y.toString()||"-","%"]})]})}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:600},className:"weak",children:Yn.jsx(e,{id:"cOvZFM",message:"Dynamic"})})]})]})}),Yn.jsx(A,{value:Tb.custom,variant:"inPaper",sx:{position:"relative",p:0},children:Yn.jsxs(i,{sx:{px:16,py:12,typography:"body2",fontWeight:600,textAlign:"center"},onClick:()=>{setTimeout((()=>{w(!0)}))},children:[C?Yn.jsx(b,{ref:P,placeholder:"-",sx:{backgroundColor:"transparent",borderWidth:0,"& input":{textAlign:"center",typography:"body2",p:0,boxSizing:"border-box",height:19,color:R?s.palette.secondary.contrastText:s.palette.text.secondary,"&::placeholder":{color:"custom.input.placeholder",opacity:1}}},inputMode:"decimal",value:p||"",autoFocus:!0,onChange:e=>{const t=e.target.value;m({slippage:t,disabled:!1,recommend:String(y)})},onBlur:()=>{setTimeout((()=>{if(w(!1),!h)return void L(Tb.recommend);const e=!h||h<0;e&&p&&m({slippage:p,disabled:e,deleted:e,recommend:String(y)})}),10)},onKeyDown:e=>{var t;"Enter"===e.code&&(e.preventDefault(),null===(t=P.current)||void 0===t||t.blur())}}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,color:p&&R?s.palette.warning.main:void 0},children:[p&&Yn.jsx(i,{component:li.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),p||"-","%"]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"h6",fontWeight:600},className:"weak",children:Yn.jsx(e,{id:"8Tg/JR",message:"Custom"})})]})})]}),Yn.jsx(O,{value:Tb.recommend,children:(null===(r=x.slippageData.slippageList)||void 0===r?void 0:r.length)&&d?Yn.jsx(Ib,{data:x.slippageData.slippageList,activeSlippage:_,loading:x.isLoading,handleChangeCustomSlippage:M,sx:{mt:8}}):""}),Yn.jsxs(O,{value:Tb.custom,children:[Yn.jsx(i,{sx:{mt:8}}),h>y&&Yn.jsx(Sb,{title:se._({id:"8XNsbx",message:"Higher than dynamic slippage"}),desc:se._({id:"iLj1a9",message:"Dynamic slippage is {recommendSlippage}%,the current slippage setting is higher than the dynamic slippage, which means you are willing to accept a worse final execution price.",values:{recommendSlippage:y}}),doNotChecked:c,onChangeDoNotChecked:e=>Gg.setState({notRemindAgainSlippageHigher:e})}),!!h&&h<y&&Yn.jsx(Sb,{title:se._({id:"TTlkRL",message:"Lower than dynamic slippage"}),desc:se._({id:"yq+Q9s",message:"Dynamic slippage is {recommendSlippage}% , the current slippage setting may increase the failure rate of transactions.",values:{recommendSlippage:y}}),doNotChecked:u,onChangeDoNotChecked:e=>Gg.setState({notRemindAgainSlippageLower:e})})]})]})]})}function Ab({checked:t,onChange:n,sx:o,disabled:r}){const s=a();let l=s.palette.background.tag;return t&&(l=s.palette.secondary.main),Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",position:"relative",borderRadius:8,backgroundColor:s.palette.background.input,opacity:r?.5:1},o),component:d,disabled:r,onClick:()=>{r||n(!t)},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:s.palette.text.primary,whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"az8lvo",message:"Off"})}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:t?s.palette.secondary.contrastText:s.palette.text.primary,whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"Z5HWHd",message:"On"})}),Yn.jsx(i,{sx:{borderRadius:6,backgroundColor:l,zIndex:0,position:"absolute",top:2,bottom:2,width:"calc(50% - 2px - 2px)",left:t?"calc(50% + 2px)":"2px",transition:"left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"}})]})}function Ob({show:t,onClick:n}){const o=a();return Yn.jsxs(r,{weak:!0,sx:{display:t?"flex":"none",alignItems:"center",position:"absolute",bottom:28,left:"50%",transform:"translateX(-50%)",p:o.spacing(8,20),fontWeight:600,borderRadius:20,border:`solid 1px ${o.palette.border.main}`,backgroundColor:"background.paperContrast",boxShadow:`0px 8px 16px 0px ${T("light"===o.palette.mode?"#FFF":"#000",.1)}`,cursor:"pointer",whiteSpace:"nowrap",gap:4},onClick:n,children:[Yn.jsx(e,{id:"F8yRdq",message:"More trade settings"}),Yn.jsx(i,{component:"svg",width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:Yn.jsx("path",{d:"M12.5 19L6.5 13L7.9 11.6L12.5 16.175L17.1 11.6L18.5 13L12.5 19ZM12.5 13L6.5 6.99998L7.9 5.59998L12.5 10.175L17.1 5.59998L18.5 6.99998L12.5 13Z",fill:"currentColor"})})]})}function Lb({selected:e,name:t,logo:n,onClick:o}){const r=a();return Yn.jsxs(i,{component:d,onClick:o,sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,py:19,mt:16,mx:8,width:"calc(33.33% - 8px - 8px)",borderRadius:8,backgroundColor:r.palette.background.paperContrast,borderColor:e?r.palette.secondary.main:r.palette.background.paperContrast,borderWidth:1,borderStyle:"solid","&:hover":{borderColor:r.palette.secondary.main},position:"relative",overflow:"hidden"},children:[Yn.jsx("img",{src:n,alt:t,style:{height:40,width:40}}),Yn.jsx(i,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:600},children:t}),e&&Yn.jsx(i,{sx:{right:0,top:0,position:"absolute",width:32,height:24,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r.palette.secondary.main,borderRadius:"0px 0px 0px 8px"},children:Yn.jsx("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M11.8709 3.16663L5.03682 10.0007L2.35089 7.32514L0.888672 8.78737L5.03682 12.9355L13.3331 4.63922L11.8709 3.16663Z",fill:r.palette.secondary.contrastText})})})]})}function Rb({privacySwapSupplierEndpoints:e,endpointStatusMap:t,refetchEndpointStatus:n,setIsSelectSupplierMode:o}){var r,s;const l=a(),[d,u]=z(null!==(s=null===(r=null==e?void 0:e[0])||void 0===r?void 0:r.key)&&void 0!==s?s:null),[p,h]=z(t);p!==t&&(h(t),Array.from(t.entries()).forEach((([e,t])=>{t&&u(e)})));const m=d?null==e?void 0:e.find((e=>e.key===d)):void 0,g=!d||t.get(d),f=Z((()=>{n(),o(!1)}),[n,o]),{switchTo:x}=function({chainId:e,successCallback:t,selectedSupplier:n}){return{switchTo:Z((()=>Vn(this,void 0,void 0,(function*(){if(n)try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[n.addChainParameters]}),t()}catch(e){console.error(e)}}))),[n,t])}}({successCallback:f,selectedSupplier:m});return Yn.jsxs(i,{sx:{display:"flex",alignItems:"stretch",flexDirection:"column",minHeight:"100%"},children:[Yn.jsx(i,{sx:{mt:20,pt:12,display:"flex",alignItems:"flex-start",flexWrap:"wrap",mx:-8},children:null==e?void 0:e.map(((e,t)=>{const n=d===e.key;return Yn.jsx(Lb,{selected:n,name:e.name,logo:e.logo,onClick:()=>u(e.key)},t)}))}),Yn.jsx(i,{sx:{mt:24,width:"100%",height:"1px",flexShrink:0,flexGrow:0,backgroundColor:l.palette.border.main}}),Yn.jsxs(i,{sx:{mt:24,mb:24,typography:"body2",fontWeight:500,color:l.palette.text.secondary},children:[Yn.jsx(i,{children:"*Choose your privacy transaction server. Later, a new network will be added to your wallet, and transactions submitted under this network can only be seen by the privacy transaction server. The server will protect you from the impact of MEV. You can also disable the privacy transaction by switching back to the original network."}),m&&Yn.jsx(i,{sx:{color:l.palette.primary.main},component:"a",href:null==m?void 0:m.docUrl,target:"_blank",rel:"noopener noreferrer",children:"Learn more>"})]}),Yn.jsx(c,{size:c.Size.big,variant:c.Variant.contained,fullWidth:!0,sx:{marginTop:"auto",flexShrink:0,flexGrow:0},disabled:g,onClick:x,children:"Enable Privacy Swap"}),Yn.jsx(i,{sx:{height:28,width:"100%"}})]})}function Pb({open:t,onClose:n,fromToken:o,toToken:r,privacySwapEnableAble:s,privacySwapEnable:l,privacySwapSupplierEndpoints:d,endpointStatusMap:c,refetchEndpointStatus:u,isDialogModal:p}){const h=a(),{ddl:m,expertMode:g,disableIndirectRouting:f}=Gg(),[x,y]=z(!1),v=H.useRef(null),[j,C]=H.useState(!1);return H.useEffect((()=>{const e=v.current,t=new ResizeObserver((()=>{e&&C(e.scrollHeight!==e.offsetHeight)})),n=re((()=>{if(!e)return;const t=e.scrollTop+e.clientHeight<e.scrollHeight-2;C(t)}),50);return e&&(C(e.scrollHeight!==e.clientHeight),t.observe(e),e.addEventListener("scroll",n)),()=>{e&&(t.unobserve(e),e.removeEventListener("scroll",n))}}),[null==v?void 0:v.current]),Yn.jsx(Of,{open:t,onClose:x?()=>y(!1):n,id:"swap-settings",title:x?"Select A Supplier":Yn.jsx(e,{id:"Tz0i8g",message:"Settings"}),modal:p,children:Yn.jsx(i,{sx:{px:20,pb:34,overflowY:"auto"},ref:v,children:x?Yn.jsx(Rb,{privacySwapSupplierEndpoints:d,endpointStatusMap:c,refetchEndpointStatus:u,setIsSelectSupplierMode:y,privacySwapEnable:l,privacySwapEnableAble:s}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Eb,{fromToken:o,toToken:r}),Yn.jsxs(i,{sx:{mt:24,pt:14,borderTop:`solid 1px ${h.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[Yn.jsx(e,{id:"zSMRJ/",message:"Transaction Deadline"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"wmCrk7",message:"You may modify the transaction deadline, the maximum time allowed for a trade to be processed on-chain. However, please note that this may lead to your trade executing at a subpar price, as the market price may change during that time."}),ml:7})]}),Yn.jsxs(i,{sx:{mt:16,display:"flex",alignItems:"center",gap:8,typography:"body2"},children:[Yn.jsx(b,{sx:{width:80,height:34,lineHeight:1,typography:"body2","& input":{px:16,py:6}},placeholder:String(xh),value:m,onChange:e=>{Gg.setState({ddl:e.target.value})}}),Yn.jsx(e,{id:"H9HlDe",message:"minutes"})]})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,mt:24,pt:14,borderTop:`solid 1px ${h.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{fontWeight:600},children:[Yn.jsx(e,{id:"MXQodB",message:"Disable Indirect Routing"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"Y0Knz4",message:"Checking this option means that the routing algorithm will only route to liquidity pools between the two tokens in the trading pair and will ignore routes with any intermediary tokens."}),ml:7})]}),Yn.jsx(Ab,{checked:f,onChange:e=>{Gg.setState({disableIndirectRouting:e})}})]}),s&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{fontWeight:600},children:[Yn.jsx(e,{id:"U1Bq/+",message:"Privacy Swap"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"fsEEap",message:"Privacy Swap can effectively protect users from sandwich attacks that could come about due to the differences between the slippage settings and the current price in the liquidity pool. This feature is free for a limited time."}),ml:7})]}),Yn.jsx(Ab,{checked:l,disabled:l,onChange:e=>{e&&y(!0)}})]})]}),Yn.jsx(Ob,{show:j,onClick:()=>{var e,t;null===(e=v.current)||void 0===e||e.scrollTo({top:null===(t=v.current)||void 0===t?void 0:t.scrollHeight,behavior:"smooth"})}})]})})})}function _b({onClick:e,disabled:t,plus:n}){const o=a(),r=t||n||!e;return Yn.jsx(i,{sx:{width:"100%",position:"relative"},children:Yn.jsx(i,{component:d,sx:Object.assign({width:44,height:44,borderRadius:"50%",backgroundColor:o.palette.background.paper,border:"4px solid #E4E1D4",display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%) rotate(-90deg)",color:"text.secondary"},r?{cursor:"inherit"}:{"&:hover":{color:"text.primary"},"&:focus-visible":{"&::before":{content:'""',position:"absolute",display:"block",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"50%",width:36,height:36,border:"solid 1px",borderColor:"text.secondary"}}}),disabled:r,onClick:()=>{r||e&&e()},children:n?Yn.jsx(i,{component:li.Plus,sx:{width:24,height:24}}):Yn.jsx(i,{component:li.ArrowBack,sx:{width:24,height:24}})})})}!function(e){e.recommend="recommend",e.custom="custom"}(Tb||(Tb={}));const Mb=()=>{const{requests:e,updateText:t}=Fg(),n=H.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if((n===Ig.Running||n===Ig.Success)&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&(!e.doneTime||Math.ceil(Date.now()/1e3)-e.doneTime<300)){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),i=H.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if(n===Ig.Success&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&e.doneTime&&Math.ceil(Date.now()/1e3)-e.doneTime<300){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),o=H.useCallback(((e,n,i)=>{const o=e[n];if(!o)return!1;return!!(Pe.isBigNumber(i)?i:new Pe(i)).isEqualTo(o)||(t((e=>{var t;const i=Object.assign({},e.metadata);return(null===(t=null==i?void 0:i.logBalance)||void 0===t?void 0:t[n])?(delete i.logBalance[n],Object.keys(i.logBalance).length||delete i.logBalance,{brief:e.brief,spec:e.spec,metadata:i}):null})),!1)}),[t]),r=H.useCallback(((e,t)=>o(n,e,t)),[n,o]),a=H.useCallback(((e,t)=>o(i,e,t)),[i,o]);return{balanceData:n,balanceDataDone:i,isTokenLoading:r,isTokenLoadingDone:a}};function Bb({onClick:t,balance:n,decimals:o,address:r,showMaxBtn:s,canClickBalance:l,loading:c,balanceText:u}){const{palette:p}=a(),h=l&&(null==n?void 0:n.gt(0))&&t;return Yn.jsxs(i,{sx:Object.assign({typography:"body2",alignItems:"center",color:p.text.secondary,wordBreak:"break-word",textAlign:"right"},h?{"&:hover":{color:p.text.primary,cursor:"pointer"}}:{}),onClick:h?()=>t(n?n.toString():""):void 0,children:[null!=u?u:Yn.jsx(e,{id:"0QDjxt",message:"Balance:"})," ",c?Yn.jsx(L,{sx:{position:"relative",top:-2,verticalAlign:"middle"}}):Yn.jsxs(Yn.Fragment,{children:[r?Am({input:n,decimals:Math.min(o||4,4)}):"-",s&&n&&n.gt(0)&&t&&Yn.jsx(i,{component:d,sx:{ml:6,color:(null==n?void 0:n.gt(0))?p.primary.main:p.text.disabled,cursor:r?"pointer":"unset",typography:"body2"},onClick:()=>t&&t(n?n.toString():""),children:Yn.jsx(e,{id:"CK1KXz",message:"Max"})})]})]})}const Db=X((function({readOnly:e,sx:t,value:n,decimals:o,onChange:r,suffix:s,suffixGap:l=0,withClear:c,onFocus:u,placeholder:p,readonlyShowSuffix:h,typography:m},g){const f=a(),x=$((()=>s||(c&&n&&r?Yn.jsx(i,{component:d,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{r&&r("")},children:Yn.jsx(i,{component:li.Error,sx:{width:12}})}):void 0)),[r,s,f.palette.text.primary,n,c]);return Yn.jsx(b,{fullWidth:!0,value:n,readOnly:e,placeholder:p||"0.00",onFocus:u,onChange:e=>{const t=e.target.value,n=0===t.length?"":Rm(t,o);r&&r(n)},"data-testid":"number-input-wrapper",suffix:(!e||h)&&x,suffixGap:l,ref:g,sx:Object.assign({border:"none","& input":{fontSize:24,typography:m,border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:m,color:"text.disabled"}}},t)})}));function Nb({token:t,onClick:n,showChainLogo:o,readonly:r,showChainName:s}){var l,c;const u=a(),p=(null==t?void 0:t.chainId)?ah.get(t.chainId):null,h=s&&!!p;return Yn.jsxs(i,{component:d,sx:{display:"flex",alignItems:"center",gap:8,color:u.palette.text.primary,typography:h?"body2":"body1",fontWeight:600,"&:focus-visible":{opacity:.5}},onClick:e=>{r||n&&n(e)},"data-testid":jh,children:[!!(null==t?void 0:t.address)&&Yn.jsx(Df,{url:null==t?void 0:t.logoURI,address:null!==(l=null==t?void 0:t.address)&&void 0!==l?l:"",chainId:null==t?void 0:t.chainId,noShowChain:!o,width:32,height:32,chainSize:16,logoOffset:6,marginRight:0}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[(null==t?void 0:t.address)?Yn.jsx(Yn.Fragment,{children:Yn.jsx(i,{children:null!==(c=null==t?void 0:t.symbol)&&void 0!==c?c:"-"})}):Yn.jsx(e,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&Yn.jsx("svg",{width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 11.75L12 7.25H6L9 11.75Z",fill:"currentColor"})})]}),!!h&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[p.name,Yn.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]})}function Fb({chain:e,active:t,onClick:n}){return Yn.jsx(l,{title:e.name,placement:"top",onlyHover:!0,children:Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,cursor:"pointer",border:"1px solid"},t?{backgroundColor:"tabActive.main",borderColor:"tabActive.main",color:"primary.main"}:{borderColor:"border.main","&:hover":{backgroundColor:"hover.default"}}),onClick:n,children:[Yn.jsx(i,{component:e.logo,sx:{width:24,height:24}}),t&&Yn.jsx(i,{sx:{typography:"body2",color:"primary.main"},children:e.name})]})},e.chainId)}var Ub=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],i=0;i<e.rangeCount;i++)n.push(e.getRangeAt(i));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}},qb={"text/plain":"Text","text/html":"Url",default:"Text"};var Vb=function(e,t){var n,i,o,r,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=Ub(),r=document.createRange(),a=document.getSelection(),(s=document.createElement("span")).textContent=e,s.ariaHidden="true",s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(i){if(i.stopPropagation(),t.format)if(i.preventDefault(),void 0===i.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=qb[t.format]||qb.default;window.clipboardData.setData(o,e)}else i.clipboardData.clearData(),i.clipboardData.setData(t.format,e);t.onCopy&&(i.preventDefault(),t.onCopy(i.clipboardData))})),document.body.appendChild(s),r.selectNodeContents(s),a.addRange(r),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),l=!0}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),i=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(i,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(r):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l},Wb=Hn(Vb);function Hb({copyText:e,size:t,sx:n,componentProps:o,onClick:r,children:a}){var s;const[l,c]=H.useState(!1);return Yn.jsx(R,{title:se._({id:"6V3Ea3",message:"Copied"}),open:l,onClose:()=>c(!1),arrow:!1,children:Yn.jsxs(i,{...o,component:null!==(s=null==o?void 0:o.component)&&void 0!==s?s:d,onClick:t=>{if(null==o?void 0:o.onClick)return o.onClick(t);t.stopPropagation(),e&&(Wb(e),c(!0)),r&&r()},sx:Object.assign({cursor:"pointer"},null==o?void 0:o.sx),children:[Yn.jsx(i,{component:li.Copy,sx:Object.assign({width:t||"auto",height:t||"auto"},n)}),a]})})}function $b({truncate:e,address:t,disabledAddress:n,sx:o,handleOpen:r,addressHoverColor:a,addressHoverShowIcon:s}){return n?Yn.jsx(i,{children:e?eg(t):t}):Yn.jsx(P,{lineSx:{bottom:-1},lineColor:null!=a?a:(null==o?void 0:o.color)||"",hoverSx:{color:"addressHoverColor","& svg":{display:"inline-block"}},className:"truncate-address-link",children:Yn.jsxs(i,{onClick:e=>{null==r||r(e,"address")},sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[e?eg(t):t,s?Yn.jsx(i,{component:li.ArrowRight,sx:{display:"none",width:14,height:14}}):""]})})}function zb({address:e,truncate:t,showCopy:n,size:o="medium",iconSize:s,iconSpace:l,sx:d,iconDarkHover:c,disabledAddress:u,addressHoverColor:p,addressHoverShowIcon:h,customChainId:m,handleOpen:g,onAddressClick:f,onShareClick:x}){const y=a(),{chainId:v}=dg(),b=null!=m?m:v,j="medium"===o,C=c?_:r,w=e=>{let t=e?12:8;return l&&(t=l),c&&(t-=3),t},k="big"===o?"h5":j?"body1":"body2",T=(t,n)=>{g?g(t,n):b&&(t.stopPropagation(),window.open(tg(b,e,"address")))},I=s||(j?16:14);return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",typography:k,color:y.palette.text.primary,lineHeight:"normal"},d||{}),children:[Yn.jsx($b,{truncate:t,address:e,disabledAddress:u,sx:d,typography:k,handleOpen:null!=f?f:T,addressHoverColor:p,addressHoverShowIcon:h}),Yn.jsx(C,{sx:{display:"inline-flex",ml:w(j),cursor:"pointer"},onClick:e=>{T(e,"icon")},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:I,height:I}})}),n?Yn.jsx(Hb,{size:I,copyText:e,componentProps:{component:C,sx:{ml:w(j),display:"inline-flex",alignItems:"center",justifyContent:"center"}}}):null,!!x&&Yn.jsx(C,{sx:{display:"inline-flex",ml:w(j),cursor:"pointer"},onClick:e=>{x(e)},children:Yn.jsx(i,{component:li.Share,sx:{width:I,height:I,ml:w(j)}})})]})}function Zb({token:e,disabled:t,style:n,balance:o,onSelect:r}){const s=a(),l=$((()=>o?Am({input:o,decimals:e.decimals}):""),[o,e.decimals]);return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",px:8,py:8,borderRadius:8,cursor:t?"auto":"pointer",opacity:t?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:n,onClick:()=>{t||r(e)},"data-testid":kh,children:[Yn.jsx(Df,{token:e,width:32,height:32,noShowChain:!0,noBorder:!0}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:2},children:[Yn.jsx(i,{sx:{textAlign:"left",color:"text.primary",typography:"body2",fontWeight:600},children:e.symbol}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:{color:"text.secondary",typography:"h6",fontWeight:500,maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.name,children:e.name}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,showCopy:!0,truncate:!0,iconSpace:2,iconSize:12,size:"small",sx:{typography:"h6",color:"text.disabled"}})]})]}),Yn.jsx(i,{sx:{ml:"auto",typography:"body1",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"flex-end"},children:(null==o?void 0:o.gte(0))?l:Yn.jsx(i,{component:li.Loading,width:18,sx:{"& path":{fill:s.palette.text.disabled},animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}}})})]})}function Gb(){return Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between"},children:[Yn.jsx(j,{variant:"circular",width:32,sx:{mt:8}}),Yn.jsxs(i,{sx:{ml:8,flex:"1 0 auto"},children:[Yn.jsx(j,{sx:{borderRadius:4},height:24}),Yn.jsx(j,{sx:{mt:4,borderRadius:4},height:19,width:137})]})]})}function Qb({data:e,index:t,style:n}){const i=e.tokenList[t],o=e.getIsDisabled(i),r=e.getBalance(i);return Yn.jsx(Zb,{token:i,disabled:o,style:n,onSelect:e.onSelectToken,balance:r},i.address+i.chainId)}function Yb({fixedSizeHeight:e,tokenList:t,onSelectToken:n,getIsDisabled:i,getBalance:o}){const r=$((()=>({onSelectToken:n,tokenList:t,getIsDisabled:i,getBalance:o})),[n,t,i,o]);return Yn.jsx(Cn,{height:e,width:"100%",itemSize:56,itemData:r,itemCount:t.length,children:Qb})}function Kb({chainId:e,value:t,onChange:n,occupiedAddrs:o,occupiedChainId:r,hiddenAddrs:a,showAddrs:s,visible:l,side:d,defaultLoadBalance:c,multiple:u,searchPlaceholder:p,searchOtherAddress:h,sx:m,filterBySupportTargetChain:g}){const{chainList:f,selectChainId:x,setSelectChainId:y}=function(e){const{crossChain:t,defaultChainId:n,IS_TEST_ENV:i}=Jn(),[o,r]=z(e?Array.isArray(e)?e[0]?e[0].chainId:n:e.chainId:n),a=$((()=>t?i?Array.from(ah.values()):Array.from(ah.values()).filter((e=>!e.isTestNet)):[]),[i,t]);return{chainList:a,selectChainId:o,setSelectChainId:r}}(t),{showTokenList:v,filter:b,setFilter:j,onSelectToken:C,popularTokenList:w,tokenInfoMap:k}=function({value:e,onChange:t,occupiedAddrs:n,occupiedChainId:i,hiddenAddrs:o,showAddrs:r,side:a,chainId:s,visible:l,defaultLoadBalance:d,multiple:c,filterBySupportTargetChain:u}){const[p,h]=z(""),m=Lg(),g=null!=s?s:m,{tokenList:f,popularTokenList:x}=Th(),y=$((()=>new Set(o?o.map((e=>e.toLowerCase())):void 0)),[o]),v=$((()=>r?new Set(r.map((e=>e.toLowerCase()))):void 0),[r]),b=Z((e=>{const t=new Set;return e.filter((e=>{if(e.chainId!==g)return!1;let n=!0;if(n=v?v.has(e.address.toLowerCase()):!y.has(e.address.toLowerCase()),n)if(a)n=!e.side||e.side===a;else{const i=`${e.chainId}-${e.address}`;n=!t.has(i),t.add(i)}return n}))}),[g,v,y,a]),j=Z((e=>{var t;if(e.chainId!==g)return!1;if(!u)return!0;if(null==i||i===g)return!0;if(!e.supportTargetChain)return!1;if(i!==le.SOLANA)return!0;if(g!==le.ZETACHAIN)return!1;const o=null===(t=null==n?void 0:n[0])||void 0===t?void 0:t.toLowerCase(),r=e.address.toLowerCase();if(!o)return!0;const a=we[i];switch(o){case a.address.toLowerCase():case a.wrappedTokenAddress.toLowerCase():return r==="0x4bC32034caCcc9B7e02536945eDbC286bACbA073".toLowerCase();case"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".toLowerCase():return r==="0x8344d6f84d26f998fa070BbEA6D2E15E359e2641".toLowerCase();case"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB".toLowerCase():return r==="0xEe9CC614D03e7Dbe994b514079f4914a605B4719".toLowerCase();default:return!0}}),[g,u,n,i]),C=$((()=>b(f.filter(j))),[j,b,f]),w=$((()=>b(x.filter(j))),[j,b,x]),k=Z((o=>{const r=o.address.toLowerCase(),a=!(i&&o.chainId!==i||!(null==n?void 0:n.some((e=>e.toLowerCase()===r))));if(Array.isArray(e)||c&&!e){const n=[...e],i=n.findIndex((e=>e.address.toLocaleLowerCase()===r));-1!==i?n.splice(i,1):n.push(o),t(n,a)}else t(o,a)}),[t,n,i]),T=Pf({chainId:g,tokenList:C,popularTokenList:w,value:e,visible:l,defaultLoadBalance:d}),I=Z((t=>{if(null===t)return null;const i=[];p?t.forEach((e=>{const t=Bf(e,p,{matchAddress:!0});t&&i.push({sort:t,token:e})})):t.forEach((e=>{i.push({sort:0,token:e})}));const o=[];return i.sort(((t,i)=>{var o,r;const a=t.token,s=i.token;if(e)if(Array.isArray(e)){const t=e.map((e=>e.address)),n=t.indexOf(a.address),i=t.indexOf(s.address),o=-1!==n,r=-1!==i;if(o||r)return o&&n<i||!r?-1:1}else{if(a.address===e.address)return-1;if(s.address===e.address)return 1}if(null==n?void 0:n.includes(a.address))return-1;if(null==n?void 0:n.includes(s.address))return 1;const l=(null===(o=T.get(`${a.chainId}-${a.address}`))||void 0===o?void 0:o.balance)||new Pe(0),d=(null===(r=T.get(`${s.chainId}-${s.address}`))||void 0===r?void 0:r.balance)||new Pe(0),c=w.map((e=>e.address));return(null==c?void 0:c.includes(a.address))?-1:(null==c?void 0:c.includes(s.address))?1:l.eq(d)?t.sort!==i.sort?t.sort>i.sort?1:-1:a.symbol.localeCompare(s.symbol):l.gt(d)?-1:1})).some((e=>!!(p&&o.length>21)||(o.push(e.token),!1))),o}),[p,T,n,e,w]),S=$((()=>I(C)||[]),[I,C]);return{filter:p,setFilter:h,showTokenList:S,onSelectToken:k,popularTokenList:w,tokenInfoMap:T}}({value:t,onChange:n,occupiedAddrs:o,occupiedChainId:r,hiddenAddrs:a,showAddrs:s,side:d,chainId:null!=e?e:x,visible:l,defaultLoadBalance:c,multiple:u,filterBySupportTargetChain:g}),T=G(null),I=G(null),[S,E]=z(329);Q((()=>{if(T.current){const e=new ResizeObserver((e=>{for(const t of e)if(t.target===T.current){const e=t.contentRect.height-1;e>0&&E(e)}}));return e.observe(T.current),()=>{e.disconnect()}}}),[]);const A=et({queryKey:["token-picker-searchOtherAddress",b],queryFn:()=>h?h(b):null,enabled:Jm(b)&&!!h}),O=Z((e=>!!t&&(Array.isArray(t)?t.some((t=>t.address===e.address&&t.chainId===e.chainId)):t.address===e.address&&t.chainId===e.chainId)),[t]),L=Z((e=>{var t;return null===(t=k.get(`${e.chainId}-${e.address}`))||void 0===t?void 0:t.balance}),[k]);return Yn.jsxs(i,{sx:Object.assign({display:"flex",flexDirection:"column",px:16,flexGrow:1,overflow:"hidden"},m),children:[Yn.jsx(M,{fullWidth:!0,height:48,value:b,onChange:e=>j(e.target.value),clearValue:()=>j(""),placeholder:null!=p?p:se._({id:"72/M0o",message:"Enter the token symbol or address"}),sx:{mb:16}}),void 0===e&&f.length>0&&Yn.jsx(i,{ref:I,sx:{position:"relative",display:"flex",gap:8,flexWrap:"wrap",pb:32,"&::after":{content:'""',position:"absolute",bottom:16,left:0,right:0,height:"1px",backgroundColor:"border.main"}},children:f.map((e=>Yn.jsx(Fb,{chain:e,active:e.chainId===x,onClick:()=>{y(e.chainId)}},e.chainId)))}),Yn.jsx(i,{sx:{pb:15,flexGrow:1},ref:T,children:v.length?Yn.jsx(Yb,{fixedSizeHeight:S,tokenList:v,onSelectToken:C,getIsDisabled:O,getBalance:L}):Yn.jsx(i,{sx:{height:S,overflowY:"auto"},children:A.isLoading?Yn.jsx(Gb,{}):A.data?A.data:Yn.jsx(ti,{hasSearch:!0,sx:{mt:80}})})})]})}function Xb(t){const{height:n,TokenPickerDialog:i}=Jn(),{isMobile:o}=Tg();if(i)return Yn.jsx(i,{...t});const{open:r,title:a,value:s,onClose:l,occupiedAddrs:d,hiddenAddrs:c,showAddrs:u,occupiedChainId:p,onTokenChange:h,side:m,defaultLoadBalance:g,multiple:f,searchPlaceholder:x,searchOtherAddress:y,chainId:v,modal:b,filterBySupportTargetChain:j}=t;return Yn.jsx(Of,{height:b?"80vh":n,open:r,onClose:l,title:null!=a?a:Yn.jsx(e,{id:"T0Y2+3",message:"Select a token"}),id:"select-token",testId:wh,modal:b,children:Yn.jsx(Kb,{value:s,visible:r,onChange:h,occupiedAddrs:d,occupiedChainId:p,hiddenAddrs:c,showAddrs:u,side:m,defaultLoadBalance:g,multiple:f,searchPlaceholder:x,searchOtherAddress:y,chainId:v,sx:b?{width:o?"100%":420,borderRadius:16}:void 0,filterBySupportTargetChain:j})})}const Jb=/^ST[0-9A-HJ-NP-Z]{39}$/,ej=/^0x[a-fA-F0-9]{64}$/,tj=/^[A-Za-z0-9_-]{48}$/;const nj=({chainId:e,open:t,onClose:n,inputToAddress:o,setInputToAddress:r})=>{const s=a(),[l,u]=z(o||""),p=function(e,t){return $((()=>{if(!e)return!1;const n=ah.get(t);if(!n)return!1;try{if(n.isEVMChain)return!!sm(e);if(n.isSolanaChain)return new Fe(e),!0;if(n.isBTCChain){if(Jb.test(e))return!0;try{return t===le.BTC_SIGNET?en.address.toOutputScript(e,by):en.address.toOutputScript(e,en.networks.bitcoin),!0}catch(e){return!1}}else{if(n.isSUIChain)return ej.test(e);if(n.isTONChain)return tj.test(e)}return!1}catch(e){return!1}}),[e,t])}(l,e),h=$((()=>ah.get(e)),[e]);return Yn.jsx(Of,{open:t,onClose:n,title:"Receive address",modal:!0,children:Yn.jsxs(i,{sx:{minWidth:420,p:20,borderTop:`1px solid ${s.palette.border.main}`,display:"flex",flexDirection:"column",gap:20},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(b,{fullWidth:!0,value:l,placeholder:`Enter ${null==h?void 0:h.name} address`,onChange:e=>{u(e.target.value)},height:48,suffix:l?Yn.jsx(i,{component:d,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{u("")},children:Yn.jsx(i,{component:li.Error,sx:{width:12}})}):null}),!p&&l&&Yn.jsx(i,{sx:{typography:"h6",color:"error.main"},children:"Invalid address"})]}),Yn.jsx(c,{fullWidth:!0,variant:c.Variant.contained,size:c.Size.middle,disabled:!l||!p,onClick:()=>{r(l),n()},children:"Confirm"})]})})},ij=({token:e,enterAddressEnabled:t=!1,inputToAddress:n,setInputToAddress:o,account:r})=>{var a,s,l,d,c,u;const p=e.chainId,{open:h,disconnect:m,suiConnectModalOpen:g,setSuiConnectModalOpen:f}=dg(),[x,y]=z(!1),v=$((()=>ah.get(p)),[p]),b=Yn.jsxs("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("path",{d:"M12.001 6.3667C12.7373 6.3667 13.3339 6.9634 13.334 7.69971V9.03369H10.1338C9.54481 9.03383 9.06738 9.51108 9.06738 10.1001C9.06751 10.689 9.54488 11.1664 10.1338 11.1665H13.334V12.4995C13.334 13.2359 12.7374 13.8335 12.001 13.8335H4.00098C3.2646 13.8335 2.66797 13.2359 2.66797 12.4995V7.69971C2.66806 6.9634 3.26465 6.3667 4.00098 6.3667H12.001Z",fill:"currentColor"}),Yn.jsx("ellipse",{cx:"10.1349",cy:"10.1002",rx:"0.533334",ry:"0.533333",fill:"currentColor"}),Yn.jsx("path",{d:"M8.54243 3.63688C9.14948 3.36708 9.86253 3.5853 10.2146 4.14863L10.9341 5.29984H4.80078L8.54243 3.63688Z",fill:"currentColor"})]});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(B,{triggerChildren:(null===(a=null==r?void 0:r.appKitAccount)||void 0===a?void 0:a.isConnected)?Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:[b,eg(null===(s=null==r?void 0:r.appKitAccount)||void 0===s?void 0:s.address),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:Yn.jsx("path",{d:"M12.667 6.93016L11.5703 5.8335L8.00033 9.39572L4.43033 5.8335L3.33366 6.93016L8.00033 11.5968L12.667 6.93016Z",fill:"currentColor",fillOpacity:"0.5"})})]}):Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:["Wallet address:",eg(null===(l=null==r?void 0:r.appKitAccount)||void 0===l?void 0:l.address),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:Yn.jsx("path",{d:"M3.33301 10.0698L4.42967 11.1665L7.99967 7.60428L11.5697 11.1665L12.6663 10.0698L7.99967 5.40317L3.33301 10.0698Z",fill:"currentColor",fillOpacity:"0.5"})})]}),titleSx:{display:"flex",flexDirection:"column",gap:8},children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsxs(i,{sx:{typography:"h6",lineHeight:"16px",color:"text.secondary"},children:["Connected(",lg(p),")"]}),(null===(d=null==r?void 0:r.appKitAccount)||void 0===d?void 0:d.isConnected)?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,px:8,py:8,color:"text.primary",borderRadius:8,backgroundColor:"background.paperContrast",typography:"body2",lineHeight:"19px"},children:[n?b:v&&Yn.jsx(i,{component:v.logo,sx:{width:16,height:16}}),eg(null===(c=null==r?void 0:r.appKitAccount)||void 0===c?void 0:c.address),Yn.jsx(i,{sx:{ml:"auto",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},onClick:()=>{n?o(null):m({namespace:null==r?void 0:r.namespace})},children:Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.25 2.25H9.75V9.75H8.25V2.25ZM12.3075 4.94244L13.3725 3.87744C14.8275 5.11494 15.75 6.94494 15.75 8.99994C15.75 12.7274 12.7275 15.7499 9 15.7499C5.2725 15.7499 2.25 12.7274 2.25 8.99994C2.25 6.94494 3.1725 5.11494 4.6275 3.87744L5.685 4.93494C4.5075 5.89494 3.75 7.35744 3.75 8.99994C3.75 11.9024 6.0975 14.2499 9 14.2499C11.9025 14.2499 14.25 11.9024 14.25 8.99994C14.25 7.35744 13.4925 5.89494 12.3075 4.94244Z",fill:"#ED4A25"})})})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),"sui"===(null==r?void 0:r.namespace)?Yn.jsx(Pt,{trigger:Yn.jsx(i,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},children:"Connect a new wallet"}),open:g,onOpenChange:e=>{console.log("walletconnectbtn isOpen",e),f(e)}}):Yn.jsx(i,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{h({namespace:null==r?void 0:r.namespace})},children:"Connect a new wallet"})]}),t&&Yn.jsxs(Yn.Fragment,{children:[(null===(u=null==r?void 0:r.appKitAccount)||void 0===u?void 0:u.isConnected)&&Yn.jsx(i,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),Yn.jsx(i,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{y(!0)},children:"Enter receive address"})]})]})}),x&&Yn.jsx(nj,{open:x,onClose:()=>y(!1),chainId:p,inputToAddress:n,setInputToAddress:o})]})};function oj({sx:t,amt:n,token:o,readOnly:r,showMaxBtn:s,canClickBalance:l,onMaxClick:d,fiatPriceTxt:u,failedReason:p,occupiedAddrs:h,occupiedChainId:m,showAddrs:g,onInputFocus:f,onTokenClick:x,onInputChange:y,onTokenChange:v,side:b,showChainLogo:j,showChainName:C,defaultLoadBalance:w,overrideBalance:k,overrideBalanceLoading:T,balanceText:I,showPercentage:S,inputReadonlyTooltip:E,inputTypography:A,hideToken:O,checkLogBalance:L,notTokenPickerModal:P,enterAddressEnabled:_,inputToAddress:M,setInputToAddress:B,account:D,tokenQuery:N,filterBySupportTargetChain:F}){var U,q;const V=a(),[W,H]=z(!1),$=null!==(q=null!=k?k:null===(U=N.data)||void 0===U?void 0:U.balance)&&void 0!==q?q:null,{isTokenLoading:Z}=Mb();let Y=null!=T?T:N.isLoading;!Y&&$&&(L?Y=Object.entries(L).some((([e,t])=>Z(e,t))):o&&(Y=Z(o.address,$))),Cg({tokenList:o?[o]:[]});const[K,X]=z(0),J=G("");Q((()=>{n!==J.current&&X(0)}),[n]);const{gotoBuyToken:ee}=Jn();let te=ee&&$&&n&&$.lt(n);const ne=!!y||!!E,ie={"& input":{typography:"h2",height:"44px",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{typography:"h2",height:"44px",color:"text.disabled"}},backgroundColor:"background.paper"};return Yn.jsxs(i,{sx:Object.assign({minHeight:ne?133:"auto",padding:V.spacing(20,20,24),overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",borderRadius:12,backgroundColor:V.palette.background.paper},t),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[O?Yn.jsx(i,{}):Yn.jsx(Nb,{token:o,showChainLogo:j,showChainName:C,onClick:()=>H(!0),readonly:!v}),o&&Yn.jsx(ij,{token:o,enterAddressEnabled:_,inputToAddress:M,setInputToAddress:B,account:D})]}),ne&&(r&&E?Yn.jsx(R,{title:E,arrow:!1,children:Yn.jsx(i,{children:Yn.jsx(Db,{value:n,readOnly:!0,withClear:!0,sx:Object.assign({mt:16},ie)})})}):Yn.jsx(Db,{value:n,onFocus:f,onChange:y?e=>{y(e),X(0)}:void 0,readOnly:r,withClear:!0,suffix:te?Yn.jsx(c,{variant:c.Variant.tag,backgroundColor:V.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{var t;e.stopPropagation(),(null===(t=null==D?void 0:D.appKitAccount)||void 0===t?void 0:t.address)&&(null==ee||ee({token:o,account:D.appKitAccount.address}))},children:Yn.jsx(e,{id:"qiOIiY",message:"Buy"})}):void 0,typography:A,sx:Object.assign({mt:16},ie)})),p&&Yn.jsx(i,{sx:{mt:4,typography:"h6",lineHeight:"16px",fontWeight:500,color:V.palette.error.main},children:p}),Yn.jsxs(i,{sx:{mt:S?9:4,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{typography:"h6",color:V.palette.text.secondary},children:u}),Yn.jsx(Bb,{balance:$,balanceText:I,onClick:r||!d&&!y?void 0:e=>{d?d(e):y&&y(e),0!==K&&1!==K&&(X(1),J.current=e)},showMaxBtn:s,canClickBalance:l,address:null==o?void 0:o.address,decimals:null==o?void 0:o.decimals,loading:Y})]}),Yn.jsx(Xb,{value:o,open:W,side:b,chainId:void 0,showAddrs:g,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:w,onClose:()=>{H(!1),x&&x()},onTokenChange:(e,t)=>{H(!1),setTimeout((()=>{!Array.isArray(e)&&v&&v(e,t)}),Sf)},modal:!P,filterBySupportTargetChain:F})]})}function rj({rawRouteData:e,chainId:t}){const n=H.useMemo((()=>{if(!e)return[];try{const n=JSON.parse(e);return n.subRoute[0].midPath.map((e=>{const{fromToken:n,toToken:i,oneSplitTotalPart:o}=e,r=new Map;return e.poolDetails.forEach((e=>{var t;const n={poolPart:Vm({input:new Pe(e.poolPart).div(o)}),poolAddress:e.pool||null};r.has(e.poolName)?null===(t=r.get(e.poolName))||void 0===t||t.push(n):r.set(e.poolName,[n])})),{fromToken:n,toToken:i,chainId:t,poolDetails:r}}))}catch(e){console.error(e)}return[]}),[t,e]);return{routeData:n}}const aj=({routeInfo:t,toToken:n,fromToken:o})=>{const[r,s]=z(!1),l=a(),{isMobile:d}=Tg(),c=$((()=>{const e=[{key:"from",logo:Yn.jsx(Df,{token:o,noShowChain:!0,height:14,width:14,marginRight:0})}];return e.push({key:"to",logo:Yn.jsx(Df,{token:n,noShowChain:!0,height:14,width:14,marginRight:0})}),e}),[o,n]),{routeData:u}=rj({rawRouteData:t,chainId:null==o?void 0:o.chainId});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{py:4,pl:8,pr:4,display:"flex",alignItems:"center",gap:4,borderRadius:12,backgroundColor:l.palette.background.tag,cursor:"pointer",typography:"h6",fontWeight:500,color:l.palette.text.secondary,"&:hover":{color:l.palette.text.primary}},onClick:()=>{s(!0)},children:[Yn.jsx(i,{sx:{color:l.palette.text.primary},children:"Route:"}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:0},children:c.map(((e,t)=>Yn.jsx(J,{children:e.logo},e.key)))}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:Yn.jsx("path",{d:"M2.91699 11.0833V7.58332H4.08366V9.91666H6.41699V11.0833H2.91699ZM9.91699 6.41666V4.08332H7.58366V2.91666H11.0837V6.41666H9.91699Z",fill:"currentColor"})})]}),Yn.jsx(Of,{open:r,title:Yn.jsx(e,{id:"rT8e1f",message:"Route"}),onClose:()=>s(!1),modal:!0,children:Yn.jsx(i,{sx:{minWidth:d?"100%":800,py:20,px:20,borderTop:`1px solid ${l.palette.border.main}`},children:d?Yn.jsx($f,{routeData:u,fromTokenRaw:o,toTokenRaw:n}):Yn.jsx(zf,{routeData:u,fromTokenRaw:o,toTokenRaw:n})})})]})};function sj({toToken:t,fromToken:n,priceStatus:o,pricePerToToken:r,pricePerFromToken:s,routeInfo:l}){const c=a(),[u,p]=z("-"),[h,m]=z(null),[g,f]=z("-"),[x,y]=z(null);Q((()=>{p(null==n?void 0:n.symbol),f(null==t?void 0:t.symbol),m(r),y(s)}),[n,t,r,s]);const v=Z((()=>{p(g),f(u),m(x),y(h)}),[u,h,g,x]);return Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:{[Qg.Initial]:"-",[Qg.Loading]:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(L,{sx:{mr:5}}),Yn.jsx(e,{id:"JdNn1Y",message:"Fetching best price..."})]}),[Qg.Failed]:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.Warn,sx:{width:15,mr:5,color:"warning.main"}}),Yn.jsx(e,{id:"NVAuTg",message:"Quote not available"})]}),[Qg.Success]:Yn.jsxs(i,{sx:{width:"100%",mt:16,px:11,py:7,borderRadius:12,border:`solid 1px ${c.palette.border.main}`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"flex-start",gap:6},children:[Yn.jsxs(i,{sx:{typography:"body2",lineHeight:"18px",color:c.palette.text.primary},children:["1 ",u," ",Yn.jsx("span",{style:{color:c.palette.text.secondary},children:"="})," ",Em({input:x,showDecimals:4})," ",g]}),Yn.jsx(i,{component:d,sx:{width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:Yn.jsx(i,{sx:{width:16,color:"text.secondary"},onClick:v,component:li.Switch})})]}),n&&t&&Yn.jsx(aj,{routeInfo:l,fromToken:n,toToken:t})]})}[o]})}function lj({getAutoSlippage:t,onPayTokenChange:n,onReceiveTokenChange:o}={}){var r,s,u,p,h,m;const g=a(),{isInflight:f}=Ug(),{noPowerBy:x,onlyChainId:y}=Jn(),{isMobile:v}=Tg(),{open:b,disconnect:j,suiConnectModalOpen:C,setSuiConnectModalOpen:w,getAppKitAccountByChainId:k,chainId:T,appKitActiveNetwork:I}=dg(),[S,E]=z(!1),[A,O]=z(""),[R,P]=z(""),[_,M]=z(""),[B,D]=z(""),[N,F]=z(null),[U,q]=z(null),[V,W]=z(!1),[H,G]=z(!1),[Y,K]=z(!1),[X,J]=z(null),ee=$((()=>k(null==N?void 0:N.chainId)),[null==N?void 0:N.chainId,k]),te=$((()=>{const e=k(null==U?void 0:U.chainId);if(e)return X?Object.assign(Object.assign({},e),{appKitAccount:Object.assign(Object.assign({},e.appKitAccount),{isConnected:!0,address:X})}):e}),[k,null==U?void 0:U.chainId,X]),ne=$((()=>ae((e=>M(e)),300)),[]),ie=$((()=>ae((e=>D(e)),300)),[]),oe=$((()=>{if(N&&U)return!(!(null==N?void 0:N.chainId)||!(null==U?void 0:U.chainId)||N.chainId===U.chainId)}),[N,U]),{toFiatPrice:re,fromFiatPrice:de}=Wg({toToken:U,fromToken:N}),{marginAmount:ce}=function({token:e,fiatPrice:t}){return{marginAmount:$((()=>{var n;const i=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,o=null!=t?new Pe(500).div(t):new Pe(0),r=Pm(o,i);return(r.lt(new Pe(1).times(new Pe(10).pow(i-3)))?new Pe(0):r).toString(10)}),[null==e?void 0:e.decimals,t])}}({token:S?U:N,fiatPrice:S?re:de});kg({fromToken:N,toToken:U,getAutoSlippage:t});const{slippage:ue,slippageLoading:pe}=tf({fromToken:N,toToken:U}),{slippage:he}=function(){const{defaultSlippage:e}=Kg(!0);return{slippage:xg((t=>t.slippage||e))}}(),{privacySwapSupplierEndpoints:me,privacySwapEnable:ge,privacySwapEnableAble:fe,endpointStatusMap:xe,refetchEndpointStatus:ye}=ef({chainId:null==N?void 0:N.chainId,account:null==ee?void 0:ee.appKitAccount.address}),ve=function(e){var t,n;const{getAppKitAccountByChainId:i}=dg(),{latestBlockNumber:o}=xg(),r=ip.getFetchTokenQuery(e&&(null===(t=ah.get(e))||void 0===t?void 0:t.isEVMChain)?e:void 0,e?we[e].address:void 0,null===(n=i(e))||void 0===n?void 0:n.appKitAccount.address);return et(Object.assign(Object.assign({},r),{queryKey:[...r.queryKey,o]}))}(null==N?void 0:N.chainId),{sendRouteLoading:be,sendRouteError:je,setSendRouteError:ke,bridgeOrderTxRequest:Te,handleClickSend:Ie}=function(){const e=gg(),{evmProvider:t}=dg(),[n,i]=z(),[o,r]=z(!1),[a,s]=z(""),l=Z((n=>Vn(this,[n],void 0,(function*({selectedRoute:n,fromEtherTokenBalance:o,goNext:a}){var l,d;if(!n)return;const{encodeParams:c}=n;if(c&&c.interfaceParams){s(""),r(!0);try{const u=yield e.getData(Ce.graphql.cross_chain_swap_zetachain_transactionEncode.toString(),{data:{interfaceParams:c.interfaceParams}});if(!u||!u.cross_chain_swap_zetachain_transactionEncode)throw new Error("cross_chain_swap_transactionEncode is null");const{data:p,to:h,value:m,from:g,chainId:f}=u.cross_chain_swap_zetachain_transactionEncode;if(!(p&&h&&m&&g&&f))throw new Error("cross_chain_swap_transactionEncode is null");const x=ah.get(f);if(null==x?void 0:x.isEVMChain){if(!o)throw new Error("fromEtherTokenBalance is null");const{fromToken:e,fromAmount:i}=n,a=we[f],c=_m(m,18),u=a&&e.address.toLowerCase()===a.address.toLowerCase(),x=c.minus(u?i:0);if(!c.isNaN()&&c.gt(0)&&o.lt(c))return s(se._({id:"F9xwHA",message:"Insufficient cross-chain fees, need at least {0} {1}",values:{0:Am({input:x,decimals:null!==(l=null==a?void 0:a.decimals)&&void 0!==l?l:18}),1:null!==(d=null==a?void 0:a.symbol)&&void 0!==d?d:"-"}})),void r(!1);if(!t||!(yield ug({from:g,to:h,value:m,data:p},t)))throw new Error("failed to estimate gas")}i({data:p,to:h,value:m,from:g,chainId:f}),a()}catch(e){console.error("[failed to construct transaction request]: ",e);const{message:t}=e;s(t)}r(!1)}}))),[e,t]);return{sendRouteLoading:o,sendRouteError:a,setSendRouteError:s,bridgeOrderTxRequest:n,handleClickSend:l}}(),{bridgeRouteList:Se,status:Ee,failedReason:Ae}=function({fromAccount:e,toAccount:t,fromToken:n,toToken:i,fromAmount:o,enabled:r,slippage:a}){var s,l,d,c;const{tokenList:u}=Th(),{GRAPHQL_URL:p}=Jn(),h=$((()=>n&&o?new Pe(o).multipliedBy(new Pe(10).pow(n.decimals)).dp(0,Pe.ROUND_DOWN):null),[o,n]),m=null!==(l=null===(s=null==e?void 0:e.appKitAccount)||void 0===s?void 0:s.address)&&void 0!==l?l:rh(null==n?void 0:n.chainId),g=null!==(c=null===(d=null==t?void 0:t.appKitAccount)||void 0===d?void 0:d.address)&&void 0!==c?c:rh(null==i?void 0:i.chainId),{data:f,error:x,isLoading:y,refetch:v}=et({retry:!1,queryKey:["graphql","cross_chain_swap_zetachain_routes",null==n?void 0:n.chainId,null==n?void 0:n.address,null==i?void 0:i.chainId,null==i?void 0:i.address,m,g,null==h?void 0:h.toString(),a],queryFn:()=>Vn(this,void 0,void 0,(function*(){const e=yield fetch(`${p}?opname=Cross_chain_swap_zetachain_routes`,{headers:{"content-type":"application/json"},body:`{"query":"\\n query Cross_chain_swap_zetachain_routes($where: Cross_chain_swap_zetachainrouteParams) {\\n cross_chain_swap_zetachain_routes(where: $where) {\\n routeId\\n fromChainId\\n fromTokenAddress\\n fromAmount\\n fromAmountWithOutDecimals\\n fromAmountUSD\\n toChainId\\n toTokenAddress\\n toAmount\\n toAmountWithOutDecimals\\n toAmountUSD\\n fromAddress\\n toAddress\\n slippage\\n approveTarget\\n fees\\n omniPlan\\n encodeParams\\n }\\n}\\n ","variables":{"where":{"fromChainId":${null==n?void 0:n.chainId},"fromTokenAddress":"${null==n?void 0:n.address}","toChainId":${null==i?void 0:i.chainId},"toTokenAddress":"${null==i?void 0:i.address}","fromAddress":"${m}","toAddress":"${g}","fromAmount":"${null==h?void 0:h.toString()}","slippage":${a?Number(a)/100:null}}},"operationName":"Cross_chain_swap_zetachain_routes"}`,method:"POST"}),t=yield e.json();if(t.errors)throw new Error(t.errors[0].message);return t.data})),refetchInterval:15e3,enabled:!!n&&!!i&&!!h&&h.isFinite()&&h.gt(0)&&n.chainId!==i.chainId&&r}),{status:b,failedReason:j,bridgeRouteList:C}=$((()=>{if(y)return{status:Eh.Loading,bridgeRouteList:[]};if(x){let e;if(console.error("error:",x),x.message.includes("NOT_ROUTE_MIN_AMOUNT:min-")){const t=x.message.split("min-")[1];t&&(e=`(Enter min amount: ${t})`)}return{status:Eh.Failed,failedReason:e,bridgeRouteList:[]}}if(f&&f.cross_chain_swap_zetachain_routes){const e=[],{routeId:t,fromChainId:n,fromTokenAddress:i,fromAmount:o,fromAmountWithOutDecimals:r,fromAmountUSD:a,toChainId:s,toTokenAddress:l,toAmount:d,fromAddress:c,toAddress:p,slippage:h,approveTarget:m,fees:g,omniPlan:x,encodeParams:y}=f.cross_chain_swap_zetachain_routes,v=ah.get(n);if(t&&n&&i&&r&&s&&l&&d&&c&&p&&h&&(!(null==v?void 0:v.isEVMChain)||m)&&g&&x&&x.length>0&&y){const o=u.find((e=>e.address.toLowerCase()===i.toLowerCase()&&e.chainId===n)),a=u.find((e=>e.address.toLowerCase()===l.toLowerCase()&&e.chainId===s)),v=new Pe(d);if(o&&a&&v.isFinite()&&v.gt(0)){const i=Sh({omniPlan:x,tokenList:u});if(i.includedSteps.length>0){const l=g.reduce(((e,t)=>{var n;return e.plus(null!==(n=t.amountUSD)&&void 0!==n?n:0)}),new Pe(0)).dp(4,Pe.ROUND_DOWN).toString(),d={key:t,id:t,fromChainId:n,toChainId:s,fromToken:o,toToken:a,fromAmount:r,toTokenAmount:v.div(`1e${a.decimals}`),fromAddress:c,toAddress:p,product:"zetachain",slippage:h,roundedRouteCostTime:0,spenderContractAddress:null!=m?m:null,feeUSD:l,fees:g,executionDuration:null,step:i,encodeParams:y,productParams:null,sourceRoute:f.cross_chain_swap_zetachain_routes};e.push(d)}}}return e.length>0?{status:Eh.Success,bridgeRouteList:e}:{status:Eh.Failed,bridgeRouteList:[]}}return{status:Eh.Initial,bridgeRouteList:[]}}),[y,x,f,u]);return{status:b,failedReason:j,refetch:v,bridgeRouteList:C}}({toToken:U,fromToken:N,fromAmount:_,fromAccount:ee,toAccount:te,enabled:!Y&&!be,slippage:he}),Oe=$((()=>{if(Se&&Se.length>0)return Se[0]}),[Se]),{isApproving:Le,isGetApproveLoading:Re,needApprove:_e,insufficientBalance:Me,submitApprove:Be,getMaxBalance:De,tokenQuery:Ne}=lf(N,{amount:_,contractAddress:null!==(r=null==Oe?void 0:Oe.spenderContractAddress)&&void 0!==r?r:void 0,account:null==ee?void 0:ee.appKitAccount.address}),{tokenQuery:Fe}=lf(U,{account:null==te?void 0:te.appKitAccount.address}),Ue=Z((()=>{Je(De())}),[De]),qe=$((()=>!(!(null==ee?void 0:ee.appKitAccount.address)||Me||Le||Re||_e)),[null==ee?void 0:ee.appKitAccount.address,Me,Le,Re,_e]),{status:Ve,rawBrief:We,executeSwap:He}=Yg({toToken:U,fromToken:N,marginAmount:ce,fromAmount:_,toAmount:B,estimateGas:qe,isReverseRouting:S,slippage:ue,slippageLoading:pe}),{resAmount:$e,priceImpact:ze,baseFeeAmount:Ze,additionalFeeAmount:Ge,resPricePerToToken:Qe,resPricePerFromToken:Ye,routeInfo:Ke}=$((()=>We||{resAmount:null,priceImpact:null,baseFeeAmount:null,additionalFeeAmount:null,resPricePerToToken:null,resPricePerFromToken:null,routeInfo:null}),[We]),Xe=jg(oe),Je=Z((e=>{const t=e.toString();O(t),ne(t)}),[O,ne]),tt=Z((e=>{const t=e.toString();P(t),ie(t)}),[P,ie]),nt=Z((e=>F((t=>{var i;const o="function"==typeof e?e(t):e;return T||xg.setState({fromTokenChainId:null!==(i=null==o?void 0:o.chainId)&&void 0!==i?i:void 0}),n&&o&&o!==t&&n(o),o}))),[n,T]),it=Z((e=>q((t=>{const n="function"==typeof e?e(t):e;return o&&n&&n!==t&&o(n),n}))),[o]);!function({fromToken:e,toToken:t,setFromToken:n,setToToken:i,updateFromAmt:o,updateToAmt:r,setIsReverseRouting:a}){const{tokenList:s}=Th(),{crossChain:l,defaultFromToken:d,defaultToToken:c,onlyChainId:u}=Jn(),{chainId:p}=dg(),h=Z((()=>{let h,m=null;const g=l?void 0:null!=u?u:p;if(!e){const e=Xg({side:"from",defaultToken:d,tokenList:s,chainId:g});m=e.findToken,h=e.setDefaultAmount,m&&(n(m),void 0!==h&&(a(!1),o(h)))}if(!t){const{findToken:e,setDefaultAmount:t}=Xg({side:"to",defaultToken:c,tokenList:s,occupyToken:m,chainId:g});e&&(i(e),void 0===h&&void 0!==t&&(a(!0),r(t)))}}),[p,l,d,c,e,u,n,a,i,t,s,o,r]);Q((()=>{const e=setTimeout((()=>{h()}),10);return()=>clearTimeout(e)}),[h])}({fromToken:N,toToken:U,setFromToken:nt,setToToken:it,updateFromAmt:Je,updateToAmt:tt,setIsReverseRouting:E});const ot=Z((()=>{Je(""),tt(""),nt(U),it(N),ch("from",U),ch("to",N)}),[nt,U,it,N,Je,tt]),rt=Z(((e,t)=>{if(t)return ot();Je(""),tt(""),nt(e),ch("from",e)}),[ot,Je,tt,nt,ch]),at=Z(((e,t)=>{if(t)return ot();Je(""),tt(""),it(e),ch("to",e)}),[ot,Je,tt,nt,ch]),st=Z((()=>{S&&Je(""),E(!1)}),[S,Je]),lt=Z((()=>{S||tt(""),E(!0)}),[S,tt]),dt=(e=>{const{defaultSlippage:t}=Kg(void 0===e),n=xg((e=>e.slippage||t));return $((()=>(void 0===e?Number(n):e)>5),[n,e])})(oe?void 0:ue),ct=$((()=>(100*Number(ze)).toFixed(2)),[ze]),ut=$((()=>{const e=S?$e:_;return e&&de?new Pe(de).multipliedBy(e):null}),[de,_,S,$e]),pt=$((()=>{var e;if(!re||void 0===oe)return null;if(oe)return(null===(e=null==Oe?void 0:Oe.toTokenAmount)||void 0===e?void 0:e.gt(0))?Oe.toTokenAmount.multipliedBy(re):null;const t=S?B:$e;return t?new Pe(re).multipliedBy(t):null}),[re,B,S,$e,Oe,oe]),ht=$((()=>Yn.jsxs(i,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[Yn.jsx(lb,{title:Yn.jsx(e,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),Yn.jsxs(i,{sx:{display:"flex"},children:[Yn.jsx(e,{id:"6+mYrD",message:"Current price impact"}),Yn.jsxs(i,{sx:{color:g.palette.error.main,ml:4},children:[ct,"%"]})]})]})),[ct,g.palette.error.main]),mt=$((()=>Yn.jsx(sj,{toToken:U,fromToken:N,priceStatus:Ve,pricePerToToken:Qe,pricePerFromToken:Ye,routeInfo:Ke})),[U,N,Ve,Qe,Ye,Ke]),gt=$((()=>!le[(null==N?void 0:N.chainId)||1]),[null==N?void 0:N.chainId]),ft=$((()=>{if(!N)return!1;const e=k(N.chainId);return!!e&&(!!e.chain.isEVMChain&&(!!T&&!!(null==N?void 0:N.chainId)&&(null==N?void 0:N.chainId)!==T))}),[T,N,k]),xt=function({fromToken:e,toToken:t}){const n=Th(Ih);return $((()=>!(!e||n.some((t=>t.chainId===e.chainId&&t.address===e.address&&(!t.side||"to"===t.side))))||!(!t||n.some((e=>e.chainId===t.chainId&&e.address===t.address&&(!e.side||"from"===e.side))))),[e,t,n])}({fromToken:N,toToken:U}),yt=$((()=>Yn.jsx(l,{open:Xe.showSwitchSlippage,title:oe?Yn.jsx(e,{id:"qLkska",message:"The setting has been switched to cross chain mode"}):Yn.jsx(e,{id:"NSCBTb",message:"The setting has been switched to swap mode"}),placement:"bottom-end",onClose:()=>Xe.setShowSwitchSlippage(!1),onlyClick:!0,children:Yn.jsx(i,{component:d,onClick:()=>G(!0),sx:{p:4,backgroundColor:g.palette.background.paper,borderRadius:4,height:28,width:28,display:"flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.Setting,sx:{width:20,height:20,color:"text.primary",cursor:"pointer"}})})})),[oe,Xe,g.palette.background.paper]),vt=$((()=>dt&&new Pe(S?B:_).gt(0)&&!Me&&(oe?Ee===Qg.Success:Ve===Qg.Success)?Yn.jsxs(i,{sx:{textAlign:"center",mb:8},children:[Yn.jsx(i,{component:li.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),se._({id:"//95jS",message:"The current slippage protection coefficient set exceeds {maxSlippageWarning}%, which may result in losses.",values:{maxSlippageWarning:5}})]}):null),[dt,S,B,_,Me,oe,Ee,Ve]),bt=$((()=>ft?Yn.jsxs(i,{sx:{textAlign:"center"},children:[Yn.jsx(i,{component:li.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),Yn.jsx(e,{id:"54ffaC",message:"The current network is inconsistent with the wallet - please switch in wallet"})]}):oe&&Ee===Qg.Initial?"-":Ve===Qg.Loading||oe&&Ee===Qg.Loading?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(L,{sx:{mr:5}}),Yn.jsx(e,{id:"JdNn1Y",message:"Fetching best price..."})]})}):gt?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.Warn,sx:{mr:6,width:16,color:"warning.main"}}),Yn.jsx(e,{id:"udsWDJ",message:"Unsupported network - switch to trade"})]}):oe&&Se.length?Yn.jsxs(Yn.Fragment,{children:[vt,Yn.jsx(gy,{route:Oe})]}):oe&&(Ee===Qg.Success&&!Se.length||Ee===Qg.Failed)&&A?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.Warn,sx:{width:15,mr:5,color:"warning.main"}}),Yn.jsx(e,{id:"NVAuTg",message:"Quote not available"})]}):Yn.jsxs(Yn.Fragment,{children:[!oe&&A&&new Pe(ct).gt(mh)&&ht,vt,mt]})),[Ve,mt,A,ht,ct,gt,oe,Ee,Se,Oe,ft,vt]),jt=$((()=>S?new Pe(R).gt(0)?Am({input:$e,decimals:null==N?void 0:N.decimals}):"-":A),[A,R,$e,N,S]),Ct=$((()=>{var e;return S?R:oe?(null===(e=null==Oe?void 0:Oe.toTokenAmount)||void 0===e?void 0:e.gt(0))&&Ee!==Qg.Loading?Am({input:Oe.toTokenAmount,decimals:null==U?void 0:U.decimals}):"-":new Pe(A).gt(0)?Am({input:$e,decimals:null==U?void 0:U.decimals}):"-"}),[A,R,$e,U,S,Oe,oe,Ee]),wt=$((()=>{var t,n,o,r;if(!(null===(t=null==ee?void 0:ee.appKitAccount)||void 0===t?void 0:t.isConnected)){const e=`Connect to ${lg(null==N?void 0:N.chainId)} wallet`,t=Yn.jsx(c,{fullWidth:!0,disabled:!0,children:e});if(!(null==N?void 0:N.chainId))return t;const i=null===(n=ah.get(N.chainId))||void 0===n?void 0:n.caipNetwork;if(!i)return t;const o=sg.getChainNamespace(i);return"sui"===o?Yn.jsx(Pt,{trigger:Yn.jsx(c,{fullWidth:!0,children:e}),open:C,onOpenChange:e=>{console.log("swap from button isOpen",e),w(e)}}):Yn.jsx(c,{fullWidth:!0,onClick:()=>{b({namespace:o})},children:e})}if(ee.chain.isEVMChain&&ee.chain.chainId!==T)return Yn.jsx(c,{fullWidth:!0,onClick:()=>{I.switchNetwork(ee.chain.caipNetwork)},children:Yn.jsx(e,{id:"1+P9RR",message:"Switch to {0}",values:{0:ee.chain.name}})});if(ee.chain.isSolanaChain&&ee.chain.chainId!==T)return Yn.jsx(c,{fullWidth:!0,onClick:()=>{I.switchNetwork(ee.chain.caipNetwork)},children:Yn.jsx(e,{id:"1+P9RR",message:"Switch to {0}",values:{0:ee.chain.name}})});if(!(null===(o=null==te?void 0:te.appKitAccount)||void 0===o?void 0:o.isConnected)){const e=`Connect to ${lg(null==U?void 0:U.chainId)} wallet`,t=Yn.jsx(c,{fullWidth:!0,disabled:!0,children:e});if(!(null==U?void 0:U.chainId))return t;const n=null===(r=ah.get(U.chainId))||void 0===r?void 0:r.caipNetwork;if(!n)return t;const i=sg.getChainNamespace(n);return"sui"===i?Yn.jsx(Pt,{trigger:Yn.jsx(c,{fullWidth:!0,children:e}),open:C,onOpenChange:e=>{console.log("swap to button isOpen",e),w(e)}}):Yn.jsx(c,{fullWidth:!0,onClick:()=>{b({namespace:i})},children:e})}if(f)return Yn.jsx(c,{fullWidth:!0,isLoading:!0,disabled:!0,children:Yn.jsx(e,{id:"FRBvjQ",message:"Transaction Pending"})});if(!N||!U)return Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:Yn.jsx(e,{id:"KlvBGJ",message:"Select Tokens"})});if(!new Pe(S?B:_).gt(0))return Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:Yn.jsx(e,{id:"iPMIoT",message:"Enter an amount"})});if(oe?Ee===Qg.Loading||Re:Ve===Qg.Loading)return Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:Yn.jsx(e,{id:"OauUE6",message:"Fetching Price..."})});let a=!1;return a=oe?!Se.length||Ee===Qg.Failed:!$e||Ve===Qg.Failed,a?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:Yn.jsx(e,{id:"NVAuTg",message:"Quote not available"})}):Me?Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:Yn.jsx(e,{id:"znqB4T",message:"Insufficient balance"})}):_e?Yn.jsx(c,{fullWidth:!0,disabled:Le,onClick:()=>Be(),children:Le?Yn.jsx(e,{id:"j2Uisd",message:"Approving"}):Yn.jsx(e,{id:"Z7ZXbT",message:"Approve"})}):oe?Yn.jsx(c,{fullWidth:!0,onClick:()=>{var e,t;return Ie({selectedRoute:Oe,fromEtherTokenBalance:null!==(t=null===(e=ve.data)||void 0===e?void 0:e.balance)&&void 0!==t?t:null,goNext:()=>K(!0)})},"data-testid":bh,disabled:!Oe,isLoading:be,children:Yn.jsx(e,{id:"SXnevP",message:"Review Cross Chain"})}):ge?Yn.jsxs(c,{fullWidth:!0,onClick:()=>W(!0),"data-testid":bh,children:[Yn.jsx(l,{placement:"top",onlyHover:!0,maxWidth:240,title:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:500,color:"text.primary"},children:"Privacy Swap is Enabled"}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:"text.secondary"},children:"Your transactions on the Ethereum network will be protected from sandwich attacks."})]}),children:Yn.jsx(i,{sx:{mr:8},children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"30",viewBox:"0 0 25 30",fill:"none",children:[Yn.jsx("path",{d:"M12.5 4L3.5 8V14C3.5 19.55 7.34 24.74 12.5 26C17.66 24.74 21.5 19.55 21.5 14V8L12.5 4Z",fill:"white"}),Yn.jsx("path",{d:"M23 14C23 20.1791 18.7457 26.0187 12.8555 27.457L12.5 27.5439L12.1445 27.457C6.25427 26.0187 2 20.1791 2 14V7.02539L2.89062 6.62891L11.8906 2.62891L12.5 2.3584L13.1094 2.62891L22.1094 6.62891L23 7.02539V14Z",stroke:"white",strokeOpacity:"0.5",strokeWidth:"3"}),Yn.jsx("path",{d:"M16.3937 11.3638L10.8021 16.9553L8.60457 14.7662L7.4082 15.9626L10.8021 19.3565L17.59 12.5686L16.3937 11.3638Z",fill:"#154618"})]})})}),Yn.jsx(e,{id:"K/Ay/d",message:"Review Swap"})]}):Yn.jsx(c,{fullWidth:!0,onClick:()=>W(!0),"data-testid":bh,children:Yn.jsx(e,{id:"K/Ay/d",message:"Review Swap"})})}),[null===(s=null==ee?void 0:ee.appKitAccount)||void 0===s?void 0:s.isConnected,null==ee?void 0:ee.chain.isEVMChain,null==ee?void 0:ee.chain.chainId,null==ee?void 0:ee.chain.isSolanaChain,null==ee?void 0:ee.chain.name,null==ee?void 0:ee.chain.caipNetwork,T,null===(u=null==te?void 0:te.appKitAccount)||void 0===u?void 0:u.isConnected,f,N,U,S,B,_,oe,Ee,Re,Ve,Me,_e,ge,C,w,b,I,Se.length,$e,Le,Be,Oe,be,Ie,null===(p=ve.data)||void 0===p?void 0:p.balance]),kt=$((()=>N&&U?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{token:N,width:16,height:16,marginRight:6,chainId:N.chainId,noShowChain:!!y}),`${Am({input:S?$e:_,decimals:null==N?void 0:N.decimals})} ${null==N?void 0:N.symbol}`,Yn.jsx(i,{component:li.DoubleRight,sx:{width:12,height:12,mx:16}}),Yn.jsx(Df,{token:U,width:16,height:16,marginRight:6,chainId:U.chainId,noShowChain:!!y}),`${Am({input:S?B:$e,decimals:null==U?void 0:U.decimals})} ${null==U?void 0:U.symbol}`]}):Yn.jsx(i,{})),[N,U,_,B,$e,S,y]);return Yn.jsxs(i,{sx:{width:"100%",overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",borderRadius:16,backgroundColor:g.palette.background.skeleton,[g.breakpoints.up("laptop")]:{width:450,backgroundColor:g.palette.background.skeleton,backdropFilter:"blur(4px)"}},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",px:16,py:20},children:[Yn.jsx(i,{sx:{typography:"caption",color:g.palette.text.primary},children:"Universal Swap"}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",borderRadius:4,p:1,backgroundColor:g.palette.background.tag},children:[Yn.jsxs(i,{sx:{color:g.palette.text.secondary,typography:"h6",px:6,py:4},children:[oe?(null==Oe?void 0:Oe.slippage)?100*Oe.slippage:null!=he?he:"-":ue,"%"]}),yt]})]}),Yn.jsxs(i,{sx:{flex:1,px:16,pb:20,overflowY:"auto"},children:[Yn.jsxs(i,{children:[Yn.jsx(oj,{sx:{mb:4},token:N,side:"from",amt:jt,defaultLoadBalance:!0,onMaxClick:Ue,onInputChange:Je,onInputFocus:oe?void 0:st,showMaxBtn:!S&&!A,occupiedAddrs:[null!==(h=null==U?void 0:U.address)&&void 0!==h?h:""],occupiedChainId:null==U?void 0:U.chainId,fiatPriceTxt:ut?`$${Am({input:ut,decimals:2})}`:"$-",onTokenChange:rt,readOnly:S,showChainLogo:!y,showChainName:!y,notTokenPickerModal:!v,enterAddressEnabled:!1,inputToAddress:X,setInputToAddress:J,account:ee,failedReason:Ae,tokenQuery:Ne}),Yn.jsx(_b,{onClick:ot,disabled:xt}),Yn.jsx(oj,{token:U,side:"to",amt:Ct,onInputChange:tt,onInputFocus:oe?void 0:lt,occupiedAddrs:[null!==(m=null==N?void 0:N.address)&&void 0!==m?m:""],occupiedChainId:null==N?void 0:N.chainId,fiatPriceTxt:pt?Yn.jsxs(Yn.Fragment,{children:["$",Am({input:pt,decimals:2})]}):"$-",onTokenChange:at,readOnly:oe||!S,showChainLogo:!y,showChainName:!y,notTokenPickerModal:!v,enterAddressEnabled:oe,inputToAddress:X,setInputToAddress:J,account:te,sx:{padding:g.spacing(24,20,20)},tokenQuery:Fe,filterBySupportTargetChain:!1}),Yn.jsx(i,{sx:{py:16,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:bt})]}),wt,Yn.jsx(pb,{}),x?"":Yn.jsxs(i,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:g.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[Yn.jsx(i,{sx:{width:18,height:18,transform:"translate(1px, 2px)","& path":{fill:g.palette.text.disabled}},component:li.Dodo}),Yn.jsx(e,{id:"QIsI8+",message:"Powered by ZUNO protocol"})]})]}),Yn.jsx(hb,{toToken:U,fromToken:N,fromAmount:S?$e:_,toAmount:S?B:$e,open:V,baseFeeAmount:Ze,priceImpact:ct,additionalFeeAmount:Ge,curToFiatPrice:pt,execute:()=>He(kt),clearFromAmt:()=>Je(""),clearToAmt:()=>tt(""),curFromFiatPrice:ut,pricePerFromToken:Ye,onClose:()=>W(!1),loading:Ve===Qg.Loading,slippage:ue,isDialogModal:v}),oe?Yn.jsx(gb,{open:H,onClose:()=>G(!1),isBridge:!0,isDialogModal:v}):Yn.jsx(Pb,{open:H,onClose:()=>G(!1),fromToken:N,toToken:U,privacySwapEnableAble:fe,privacySwapEnable:ge,privacySwapSupplierEndpoints:me,endpointStatusMap:xe,refetchEndpointStatus:ye,isDialogModal:v}),Yn.jsx(cb,{open:Y,onClose:()=>K(!1),route:Oe,bridgeOrderTxRequest:Te,clearFromAmt:()=>Je(""),clearToAmt:()=>tt(""),isDialogModal:v}),Yn.jsx(ub,{message:je,onClose:()=>ke(""),isDialogModal:v})]})}const dj=[.25,.5,.75,1];function cj({value:e,onChange:t,sx:n}){const o=a(),r="light"===o.palette.mode,{isMobile:s}=Tg();return Yn.jsx(i,{sx:Object.assign({display:"grid",gap:s?10:14,gridTemplateColumns:`repeat(${dj.length}, 1fr)`},n),children:dj.map((n=>{const i=n===e;return Yn.jsxs(d,{disabled:!t,sx:{typography:"h6",borderRadius:4,padding:o.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:disabled":{color:"text.disabled"},"&:not(:disabled)&:hover":{color:o.palette.text.primary,backgroundColor:T(o.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?o.palette.primary.main:T(o.palette.text.primary,.4)}},onClick:()=>{!i&&t&&t(n)},className:i?"selected":void 0,children:[100*n,"%"]},n)}))})}function uj(){return a(),Yn.jsx(i,{sx:{height:4,position:"relative",color:"text.secondary"},children:Yn.jsx(i,{sx:{width:44,height:44,backgroundColor:"background.input",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",borderWidth:4,borderStyle:"solid",borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",color:"text.secondary"},children:Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",fill:"none",children:Yn.jsx("path",{d:"M19.0142 13H13.0142V19H11.0142V13H5.01416V11H11.0142V5H13.0142V11H19.0142V13Z",fill:"currentColor"})})})})}function pj(){return Yn.jsx(i,{sx:{position:"relative",height:4},children:Yn.jsx(i,{sx:{width:44,height:44,borderRadius:22,backgroundColor:"background.input",borderWidth:4,borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%) rotate(90deg)",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:Yn.jsx(i,{component:li.Plus})})})}function hj({sx:t,inputSx:n,amt:o,token:r,readOnly:s,showMaxBtn:l,canClickBalance:d,onMaxClick:u,fiatPriceTxt:p,occupiedAddrs:h,occupiedChainId:m,onInputFocus:g,onTokenClick:f,onInputChange:x,onTokenChange:y,side:v,showChainLogo:b,showChainName:j,defaultLoadBalance:C,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:I,inputReadonlyTooltip:S,inputTypography:E,chainId:A,hideToken:O,checkLogBalance:L,notTokenPickerModal:P}){var _,M;const{account:B}=dg(),D=a(),[N,F]=z(!1),U=et(ip.getFetchTokenQuery(null==r?void 0:r.chainId,null==r?void 0:r.address,B)),q=null!==(M=null!=w?w:null===(_=U.data)||void 0===_?void 0:_.balance)&&void 0!==M?M:null,{isTokenLoading:V}=Mb();let W=null!=k?k:U.isLoading;!W&&q&&(L?W=Object.entries(L).some((([e,t])=>V(e,t))):r&&(W=V(r.address,q))),Cg({tokenList:r?[r]:[]});const[H,$]=z(0),Z=G("");Q((()=>{o!==Z.current&&$(0)}),[o]);const{gotoBuyToken:Y}=Jn();let K=Y&&q&&o&&q.lt(o);const X=!!x||!!S;return Yn.jsxs(i,{sx:Object.assign({minHeight:X?133:"auto",padding:D.spacing(20,20,24),borderRadius:16,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:D.palette.background.input},t),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[O?Yn.jsx(i,{}):Yn.jsx(Nb,{token:r,showChainLogo:b,showChainName:j,onClick:()=>F(!0),readonly:!y}),Yn.jsx(Bb,{balance:q,balanceText:T,onClick:s||!u&&!x?void 0:e=>{u?u(e):x&&x(e),0!==H&&1!==H&&($(1),Z.current=e)},showMaxBtn:l,canClickBalance:d,address:null==r?void 0:r.address,decimals:null==r?void 0:r.decimals,loading:W})]}),X&&(s&&S?Yn.jsx(R,{title:S,arrow:!1,children:Yn.jsx(i,{children:Yn.jsx(Db,{value:o,readOnly:!0,withClear:!0,sx:Object.assign({mt:12},n)})})}):Yn.jsx(Db,{value:o,onFocus:g,onChange:x?e=>{x(e),$(0)}:void 0,readOnly:s,withClear:!0,suffix:K?Yn.jsx(c,{variant:c.Variant.tag,backgroundColor:D.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{e.stopPropagation(),null==Y||Y({token:r,account:B})},children:Yn.jsx(e,{id:"qiOIiY",message:"Buy"})}):void 0,typography:E,sx:Object.assign({mt:12},n)})),!s&&I?Yn.jsx(cj,{sx:{mt:16},value:H,onChange:q&&void 0!==(null==r?void 0:r.decimals)?e=>{if(q&&(null==r?void 0:r.decimals))if($(e),1===e){const e=q.toString();u?u(e):x&&x(e),Z.current=e}else if(x){const t=q.multipliedBy(e).dp(r.decimals).toString();x(t),Z.current=t}}:void 0}):"",void 0!==p?Yn.jsx(i,{sx:{mt:I?9:0,typography:"h6",color:D.palette.text.secondary},children:p}):"",Yn.jsx(Xb,{value:r,open:N,side:v,chainId:A,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:C,onClose:()=>{F(!1),f&&f()},onTokenChange:(e,t)=>{F(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),Sf)},modal:!P})]})}var mj;function gj(){return gj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},gj.apply(null,arguments)}const fj=e=>W.createElement("svg",gj({width:12,height:12,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),mj||(mj=W.createElement("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"}))),xj=e=>Object.keys(new Array(e+1).join(","));function yj(e){return null!=e&&""!==e}var vj;function bj(){return bj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bj.apply(null,arguments)}const jj=e=>W.createElement("svg",bj({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),vj||(vj=W.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},W.createElement("path",{d:"m114.622644 327.195472 52.004717 13.810198v-18.05949l4.245283-4.249292h29.716982v21.246459 14.872523h-31.839624l-39.268868-16.997169z",fill:"#cdbdb2"}),W.createElement("path",{d:"m199.528305 327.195472 50.943397 13.810198v-18.05949l4.245283-4.249292h29.716981v21.246459 14.872523h-31.839623l-39.268868-16.997169z",fill:"#cdbdb2",transform:"matrix(-1 0 0 1 483.96227 0)"}),W.createElement("path",{d:"m170.872644 287.889523-4.245283 35.056657 5.306604-4.249292h55.18868l6.367925 4.249292-4.245284-35.056657-8.490565-5.311615-42.452832 1.062323z",fill:"#393939"}),W.createElement("path",{d:"m142.216984 50.9915022 25.471698 59.4900858 11.674528 173.158643h41.391511l12.735849-173.158643 23.349056-59.4900858z",fill:"#f89c35"}),W.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),W.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),W.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),W.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),W.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),W.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),W.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),W.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),W.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),W.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),W.createElement("path",{d:"m229.245286 327.195472 55.18868-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3",transform:"matrix(-1 0 0 1 513.679252 0)"}),W.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),W.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),W.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"}),W.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},W.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),W.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),W.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),W.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),W.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),W.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),W.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),W.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),W.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),W.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),W.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),W.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"})))));function Cj(e){const{switchNetwork:t}=Nt();return $((()=>{var n;if(!e)return;const i=null===(n=ah.get(e))||void 0===n?void 0:n.caipNetwork;return i?()=>t(i):void 0}),[e,t])}function wj({token:e,size:t="small",sx:n,children:o}){const[r,a]=z(!1),{evmProvider:s,chainId:l}=dg(),d=Cj(e.chainId);return Yn.jsxs(i,{sx:ne({margin:"0",border:"none",padding:"0",background:"none",cursor:"pointer","&:focus":{outline:"none"},"&:active":{outline:"none"},display:"inline-flex",alignItems:"center",justifyContent:"center"},n),onClick:t=>Vn(this,void 0,void 0,(function*(){if(t.stopPropagation(),void 0!==e.chainId&&e.chainId!==l&&d)return void(null==d||d());if(r)return;if(!s)return;a(!0);const{result:n,failMsg:i}=yield function(e,t){return Vn(this,void 0,void 0,(function*(){if(!e)return{result:!1};try{return{result:yield e.send("wallet_watchAsset",{type:"ERC20",options:{address:t.address,symbol:t.symbol,decimals:t.decimals,image:t.logoURI}})}}catch(e){return console.error(e),{result:!1,failMsg:null==e?void 0:e.message}}}))}(s,e);n?$v.getState().toast({message:se._({id:"DupCvC",message:"Added successful"}),type:"success",timeout:3e3}):$v.getState().toast({message:`${se._({id:"v4wgrk",message:"Failed to add"})}${i?`: ${i}`:""}`,type:"error"}),a(!1)})),component:"button",children:[Yn.jsx(i,{component:jj,sx:Object.assign({},"medium"===t?{width:16,height:16}:{width:14,height:14})}),o]})}function kj({tokens:e,width:t=24,height:n=24,gap:o=-4,cross:r,mr:s,chainId:l,showChainLogo:d,sx:c}){var u;const p=a(),{onlyChainId:h}=Jn(),m=d&&!h,g=t/2;return!e||e.length<=0?Yn.jsx(i,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:s,position:"relative",zIndex:0},c),children:Yn.jsx(i,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:52,height:24,viewBox:"0 0 52 24",fill:"none",sx:{height:t,width:"auto",color:T(p.palette.text.primary,"light"===p.palette.mode?.11:.13),animation:"pulseKeyframe 2s ease-in-out 0.5s infinite","@keyframes pulseKeyframe":{"0%":{opacity:1},"50%":{opacity:.4},"100%":{opacity:1}}},children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3746 4.50813C19.1755 1.76008 15.7933 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24C15.7933 24 19.1755 22.2399 21.3746 19.4919C19.8788 17.3743 19 14.7898 19 12C19 9.21023 19.8788 6.62571 21.3746 4.50813ZM22 5.36441C24.1498 2.13102 27.8261 0 32 0C38.3911 0 43.6152 4.99623 43.9797 11.296C41.0986 12.163 39 14.8364 39 18C39 19.1371 39.2711 20.2108 39.7523 21.1602C37.6611 22.9317 34.9553 24 32 24C27.8261 24 24.1498 21.869 22 18.6356C20.7363 16.735 20 14.4535 20 12C20 9.54653 20.7363 7.26502 22 5.36441ZM52 18C52 21.3137 49.3137 24 46 24C43.5588 24 41.458 22.542 40.5211 20.4493C40.5042 20.4116 40.4876 20.3736 40.4715 20.3355C40.1679 19.6176 40 18.8284 40 18C40 15.3894 41.6673 13.1682 43.9952 12.3431C44.6221 12.1209 45.2969 12 46 12C49.3137 12 52 14.6863 52 18Z",fill:"currentColor"})})}):Yn.jsxs(i,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:s,position:"relative",zIndex:0},c),children:[e.map(((e,n)=>Yn.jsx(i,{sx:{display:"inline-flex",width:t,height:t,ml:n>0?o:0,borderRadius:"50%",backgroundColor:p.palette.background.default},children:"object"==typeof e?Yn.jsx(Df,{address:e.address,width:t,height:t,chainId:l,url:e.logoURI,cross:r,noShowChain:!0,noBorder:!0,marginRight:0}):Yn.jsx(i,{component:"img",height:t,src:e})},n))),m&&ah.has(l)?Yn.jsx(i,{component:null===(u=ah.get(l))||void 0===u?void 0:u.logo,sx:{position:"absolute",bottom:0,right:0,zIndex:e.length+1,transform:"translateX(50%)",width:g,height:g}}):""]})}function Tj({loading:e,empty:t,hasSearch:n,children:o,refetch:r}){return e?Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",gap:24,px:24,height:320},children:xj(4).map(((e,t)=>Yn.jsx(j,{width:"100%",height:45},t)))}):r?Yn.jsx(ai,{refresh:r,sx:{height:320}}):t?Yn.jsx(ti,{hasSearch:n,sx:{height:320}}):Yn.jsx(Yn.Fragment,{children:o})}function Ij({show:e,onClick:t,sx:n}){return Yn.jsx(i,{component:d,sx:Object.assign({p:3,transform:e?"rotate(180deg)":"none",transition:"all 100ms",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center"},n),onClick:t,children:Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.58398 11.376C8.78189 11.6728 9.21811 11.6728 9.41603 11.376L12.4818 6.77735C12.7033 6.44507 12.4651 6 12.0657 6H5.93426C5.53491 6 5.29672 6.44507 5.51823 6.77735L8.58398 11.376Z",fill:"currentColor"})})})}function Sj({isMobile:e,statusText:t,statusColor:n,time:o,alphaColor:r,sx:s,children:l}){const d=a(),c=T(n,.1),u=r?T(n,r):n;return Yn.jsxs(i,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:e?"center":"flex-start",gap:2,typography:"h6",color:"text.secondary"},s),children:[Yn.jsxs(i,{sx:{padding:d.spacing(4,16),borderRadius:4,backgroundColor:c,color:u,textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center"},children:[t,l]}),o]})}function Ej({token:e,amount:t,canAddMetamask:n,title:o,linkVisible:r=!0}){var a,s;return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2},children:[Yn.jsxs(i,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:[o,": ",Am({input:t,decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),n&&e&&Yn.jsx(wj,{token:e})]}),Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:4,typography:"h6",fontWeight:500,color:"text.secondary"},children:[e&&null!==(s=null===(a=ah.get(e.chainId))||void 0===a?void 0:a.name)&&void 0!==s?s:"-",r&&Yn.jsx(fj,{})]})]})}function Aj({token:e,amount:t,showChain:n,hideLogo:o,canAddMetamask:r,sx:a}){var s,l;let d="";n&&(d=null!==(l=null===(s=ah.get(e.chainId))||void 0===s?void 0:s.name)&&void 0!==l?l:"");const c=Am({input:t,decimals:e.decimals});return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:[!o&&Yn.jsx(Df,{address:e.address,chainId:e.chainId,width:20,height:20}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:2},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,wordBreak:"break-word",typography:"body1",fontWeight:600},children:[`${c} ${e.symbol}`,r&&Yn.jsx(wj,{token:e})]}),!!d&&Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:2,typography:"h6",fontWeight:500,color:"text.secondary"},children:[d,Yn.jsx(fj,{})]})]})]})}function Oj({height:t=64,sx:n,onClick:o,hasMore:r,loading:s}){return a(),r?Yn.jsx(d,{sx:Object.assign({display:"flex",justifyContent:"center",alignItems:"center",height:t,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},n),onClick:o,children:s?Yn.jsx(L,{}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})}):null}function Lj(e){var{sx:t,children:n,hasMore:o,loadMore:r,loadMoreLoading:a}=e,s=qn(e,["sx","children","hasMore","loadMore","loadMoreLoading"]);return Yn.jsxs(i,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",pt:12,px:20,pb:20},t),...s,children:[Yn.jsx(i,{component:"table",sx:{width:"100%",borderCollapse:"separate",borderSpacing:"0 4px","& th":{py:12,px:24,typography:"body2",textAlign:"left",color:"text.secondary",backgroundColor:"background.paper"},"& th:first-of-type":{borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px"},"& th:last-of-type":{borderTopRightRadius:"8px",borderBottomRightRadius:"8px"},"& td":{px:24,py:20,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,"&::after":{content:'""',display:"table-row",height:"0"}}},children:n}),!!r&&Yn.jsx(Oj,{loading:a,hasMore:o,onClick:r})]})}function Rj({fromToken:e,toToken:t,fromTokenPrice:n,toTokenPrice:o,sx:r,children:s}){const l=a(),[c,u]=z(!1),p=$((()=>new Pe(n&&o?c?o:n:0)),[n,o,c]);return Yn.jsxs(i,{component:d,sx:Object.assign({display:"flex",alignItems:"center",gap:8,color:"text.primary",typography:"body1",fontWeight:600,"&:hover>svg>path":{fill:l.palette.text.primary}},r),onClick:()=>u((e=>!e)),children:[Yn.jsxs(i,{children:[s,"1 ",c?t.symbol:e.symbol," = ",p&&p.isFinite()?Am({input:p,decimals:c?e.decimals:t.decimals}):"-"," ",c?e.symbol:t.symbol]}),Yn.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("circle",{cx:"9",cy:"9",r:"9",fill:l.palette.border.main}),Yn.jsx("path",{d:"M9.5 6.5H4.5V8H13.5L9.5 4.25V6.5ZM8.25 13.75V11.5H13.5V10H4.5L8.25 13.75Z",fill:l.palette.text.secondary})]})]})}function Pj({showFold:e,isMobile:t,data:n}){const o=a(),r=$((()=>{var e,t,i,o,r,a,s,l,d,c,u,p,h,m;const g=[{title:"Total time spent",value:null!==(i=hf({start:null!==(e=n.startTime)&&void 0!==e?e:void 0,end:null!==(t=n.endTime)&&void 0!==t?t:void 0}))&&void 0!==i?i:"-"},{title:"Pay",value:Yn.jsx(zb,{address:null!==(o=n.fromAddress)&&void 0!==o?o:"",customChainId:null!==(r=n.routeData.fromChainId)&&void 0!==r?r:le.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:"Receive",value:Yn.jsx(zb,{address:null!==(a=n.toAddress)&&void 0!==a?a:"",customChainId:null!==(s=n.routeData.toChainId)&&void 0!==s?s:le.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:Yn.jsxs(Yn.Fragment,{children:["Fill Gas (Destination gas)",Yn.jsx(lb,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(c=null===(d=null===(l=n.fees)||void 0===l?void 0:l.find((e=>"destinationFee"===e.type)))||void 0===d?void 0:d.amountUSD)&&void 0!==c?c:"-"}`},{title:Yn.jsxs(Yn.Fragment,{children:["Bridge Fee",Yn.jsx(lb,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(h=null===(p=null===(u=n.fees)||void 0===u?void 0:u.find((e=>"platformFee"===e.type)))||void 0===p?void 0:p.amountUSD)&&void 0!==h?h:"-"}`}],f=null===(m=n.fees)||void 0===m?void 0:m.find((e=>"svmRentFee"===e.type));return f&&g.push({title:Yn.jsxs(Yn.Fragment,{children:["Rent",Yn.jsx(lb,{onlyHover:!0,title:"Rent (only first transaction of SPL token)",ml:0})]}),value:`$${f.amountUSD}`}),g}),[n.endTime,n.fees,n.fromAddress,n.routeData.fromChainId,n.routeData.toChainId,n.startTime,n.toAddress]);return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:16,p:e?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${o.palette.background.skeleton} 0%, ${o.palette.background.skeleton} 100%), ${o.palette.background.paper}`,maxHeight:e?"auto":0,transition:"all 300ms",overflow:"hidden",[o.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px",gap:24}},children:[Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:8,[o.breakpoints.up("tablet")]:{alignItems:"center",flexDirection:"row",gap:20}},children:r.map(((e,t)=>Yn.jsxs(i,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",[o.breakpoints.up("tablet")]:{flexBasis:"20%",flexGrow:1,flexShrink:1,flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",gap:4}},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.secondary",typography:"h6"},children:e.title}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:e.value})]},t)))}),null!=n.routeData.fromChainId&&null!=n.routeData.toChainId&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{height:"1px",width:"100%",backgroundColor:"border.disabled"}}),Yn.jsx(hy,{route:{fromChainId:n.routeData.fromChainId,toChainId:n.routeData.toChainId,step:n.routeData.step},isMobile:t})]})]})}function _j({data:e}){const t=a(),n="refund_success"===e.subStatus,{isMobile:o}=Tg();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2,[t.breakpoints.up("tablet")]:{gap:8}},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,color:n?t.palette.success.main:t.palette.text.disabled,borderRadius:"50%",backgroundColor:n?T(t.palette.success.main,.1):t.palette.background.tag,[t.breakpoints.up("tablet")]:{width:24,height:24}},children:n?Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o?"12":"16",height:o?"12":"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{d:"M12.7601 3.55554L5.92598 10.3896L3.24005 7.71406L1.77783 9.17628L5.92598 13.3244L14.2223 5.02813L12.7601 3.55554Z",fill:"currentColor"})}):Yn.jsx(L,{sx:{width:12,color:t.palette.text.disabled,[t.breakpoints.up("tablet")]:{width:16}}})}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2,[t.breakpoints.up("tablet")]:{flexDirection:"column",alignItems:"flex-start"}},children:[e.refundChainId&&e.refundHash?Yn.jsx(zb,{address:e.refundHash,customChainId:e.refundChainId,showCopy:!1,truncate:!0,iconSpace:o?2:8,sx:{typography:"h6",[t.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},handleOpen:t=>{t.stopPropagation(),window.open(tg(e.refundChainId,e.refundHash,"tx"))}}):Yn.jsx(i,{sx:{typography:"h6",[t.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},children:"-"}),Yn.jsx(i,{sx:{display:"none",[t.breakpoints.up("tablet")]:{display:"block",typography:"h6",color:t.palette.text.secondary}},children:n?"Refunded to this address.":"Refund in progress."}),n?null:Yn.jsx(i,{sx:{typography:"h6",color:t.palette.text.secondary,[t.breakpoints.up("tablet")]:{display:"none"}},children:"(Refund in progress.)"})]})]})}function Mj({data:e,isMobile:t,isErrorRefund:n}){var o,r,s,d,c,u,p,h,m,g;const f=a(),{statusText:x,statusColor:y,statusAlphaColor:v}=$((()=>{let t="Loading",n=f.palette.text.primary;switch(e.status){case"pending":t="Pending",n=f.palette.text.secondary;break;case"success":t="Succeeded",n=f.palette.success.main;break;case"failure_revert":t="Swap failed",n=f.palette.error.main;break;case"abort":t="Aborted",n=f.palette.error.main}return{statusText:t,statusColor:n,statusAlphaColor:undefined}}),[e.status,f.palette.error.main,f.palette.success.main,f.palette.text.primary,f.palette.text.secondary]),[b,j]=H.useState(!1),C=e.createdAt?gf(new Date(e.createdAt)):"-";return t?Yn.jsxs(i,{sx:{backgroundColor:f.palette.background.paper,borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{width:24,height:24,address:null===(o=e.fromToken)||void 0===o?void 0:o.address,chainId:null===(r=e.fromToken)||void 0===r?void 0:r.chainId}),Yn.jsx(i,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:Yn.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),Yn.jsx(Df,{width:24,height:24,address:null===(s=e.toToken)||void 0===s?void 0:s.address,chainId:null===(d=e.toToken)||void 0===d?void 0:d.chainId})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8},children:Yn.jsx(Sj,{isMobile:!1,statusText:x,statusColor:y,alphaColor:v,children:"success"!==e.status&&Yn.jsx(lb,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:y}})})})]}),Yn.jsx(i,{sx:{typography:"h6",color:f.palette.text.secondary},children:C})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(Ej,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay",linkVisible:!1}),Yn.jsx(Ej,{token:e.toToken,amount:e.toAmount,canAddMetamask:e.fromToken&&null!==(u=null===(c=ah.get(e.fromToken.chainId))||void 0===c?void 0:c.isEVMChain)&&void 0!==u&&u,title:"Receive",linkVisible:!1}),n&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2},children:[Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:"Refunds TX:"}),Yn.jsx(_j,{data:e})]})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${f.palette.border.main}`},children:Yn.jsx(Ij,{show:b,onClick:()=>j((e=>!e)),sx:{color:"text.secondary"}})})]})]}),Yn.jsx(Pj,{showFold:b,data:e,isMobile:t})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("tr",{children:[Yn.jsx(i,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:b?0:8},children:e.fromToken&&Yn.jsx(Aj,{token:e.fromToken,amount:null!==(p=e.fromAmount)&&void 0!==p?p:"",showChain:!0})}),Yn.jsx("td",{children:e.toToken&&Yn.jsx(Aj,{token:e.toToken,amount:null!==(h=e.toAmount)&&void 0!==h?h:"",showChain:!0,canAddMetamask:null!==(g=null===(m=ah.get(e.toToken.chainId))||void 0===m?void 0:m.isEVMChain)&&void 0!==g&&g})}),Yn.jsx("td",{children:Yn.jsx(Sj,{isMobile:t,statusText:x,statusColor:y,alphaColor:v,time:C,children:"success"!==e.status&&Yn.jsx(lb,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:y}})})}),n?Yn.jsx("td",{children:Yn.jsx(_j,{data:e})}):Yn.jsx("td",{children:e.fromToken&&e.toToken&&Yn.jsx(Rj,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),Yn.jsx(i,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:b?0:8},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[!n&&"refund_success"===e.subStatus&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(l,{title:"refund TX",placement:"top",onlyHover:!0,children:Yn.jsx(i,{component:"a",href:e.refundChainId&&e.refundHash?tg(e.refundChainId,e.refundHash,"tx"):void 0,target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:18,height:18}})})}),Yn.jsx(i,{sx:{height:16,width:"1px",backgroundColor:"border.main"}})]}),Yn.jsx(Ij,{show:b,onClick:()=>j((e=>!e))})]})})]}),Yn.jsx("tr",{children:Yn.jsx(i,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:Yn.jsx(Pj,{showFold:b,data:e})})})]})}function Bj({account:t,type:n}){const{isMobile:o}=Tg(),r=function({account:e,limit:t=5,type:n}){var i;const{tokenList:o}=Th(),r=gg().getInfiniteQuery(Ce.graphql.cross_chain_swap_zetachain_orderList,"page",{where:{user:e,pageSize:t,type:n}}),a=at(Object.assign(Object.assign({},r),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_orderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),s=$((()=>{var e,t,n,i;return null!==(i=null===(n=null===(t=null===(e=a.data)||void 0===e?void 0:e.pages)||void 0===t?void 0:t.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_orderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===n?void 0:n.map((e=>{const t=o.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.fromTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.fromChainId)})),n=o.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.toTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.toChainId)})),i=(null==e?void 0:e.fromAmount)&&t?new Pe(e.fromAmount).div(10**t.decimals).dp(t.decimals,Pe.ROUND_DOWN):null,r=(null==e?void 0:e.toAmount)&&n?new Pe(e.toAmount).div(10**n.decimals).dp(n.decimals,Pe.ROUND_DOWN):null;return{hash:null==e?void 0:e.fromHash,refundHash:null==e?void 0:e.refundHash,externalId:null==e?void 0:e.externalId,refundCridgeContract:void 0,refundChainId:(null==e?void 0:e.refundChainId)?Number(e.refundChainId):void 0,fromToken:t,toToken:n,fromAmount:i,toAmount:r,startTime:(null==e?void 0:e.startTime)?1e3*e.startTime:void 0,endTime:(null==e?void 0:e.endTime)?1e3*e.endTime:void 0,createdAt:null==e?void 0:e.createdAt,fromAddress:null==e?void 0:e.fromAddress,toAddress:null==e?void 0:e.toAddress,routeData:{fromChainId:null==e?void 0:e.fromChainId,toChainId:null==e?void 0:e.toChainId,step:Sh({omniPlan:null==e?void 0:e.omniPlan,tokenList:o})},fees:null==e?void 0:e.fees,status:null==e?void 0:e.status,subStatus:null==e?void 0:e.subStatus,transactionHash:null==e?void 0:e.fromHash,fromTokenPrice:i&&r&&t?r.div(i).dp(t.decimals,Pe.ROUND_DOWN).toString():null,toTokenPrice:i&&r&&n?i.div(r).dp(n.decimals,Pe.ROUND_DOWN).toString():null}})))&&void 0!==i?i:[]}),[null===(i=a.data)||void 0===i?void 0:i.pages,o]);return Object.assign(Object.assign({},a),{orderList:s})}({account:t,limit:o?10:5,type:n}),a="error_refund"===n;return Yn.jsx(Tj,{isMobile:o,empty:!r.orderList.length,loading:r.isLoading,children:o?Yn.jsxs(i,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[r.orderList.map((e=>Yn.jsx(Mj,{data:e,isMobile:o,isErrorRefund:a},e.hash))),Yn.jsx(Oj,{loading:r.isFetchingNextPage,onClick:r.fetchNextPage,hasMore:r.hasNextPage,height:68})]}):Yn.jsx(Yn.Fragment,{children:Yn.jsxs(Lj,{loadMoreLoading:r.isFetchingNextPage,loadMore:r.fetchNextPage,hasMore:r.hasNextPage,children:[Yn.jsx("thead",{children:Yn.jsxs("tr",{children:[Yn.jsx("th",{children:Yn.jsx(e,{id:"4fL/V7",message:"Pay"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"lDgVWA",message:"Receive"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"uAQUqI",message:"Status"})}),a?Yn.jsx("th",{children:Yn.jsx(e,{id:"VmAUk7",message:"Refunds TX"})}):Yn.jsx("th",{children:Yn.jsx(e,{id:"fqDzSu",message:"Rate"})}),Yn.jsx(i,{component:"th",sx:{width:a?110:140,textAlign:"right !important"},children:Yn.jsx(e,{id:"URmyfc",message:"Details"})})]})}),Yn.jsx("tbody",{children:r.orderList.map((e=>Yn.jsx(Mj,{data:e,isMobile:o,isErrorRefund:a},e.hash)))})]})})})}function Dj({account:e,limit:t=5}){var n,i,o,r;const a=void 0,s=gg().getInfiniteQuery(Ce.graphql.cross_chain_swap_zetachain_swapOrderList,"page",{where:{userAddress:null==e?void 0:e.toLowerCase(),pageSize:t}}),l=at(Object.assign(Object.assign({},s),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_swapOrderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),d=null!==(r=null===(o=null===(i=null===(n=l.data)||void 0===n?void 0:n.pages)||void 0===i?void 0:i.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_swapOrderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===o?void 0:o.map((t=>{var n,i,o,r,s,l,d,c,u,p,h,m,g,f,x,y,v,b,j;let C="";const w=null!==(i=null===(n=null==t?void 0:t.extra)||void 0===n?void 0:n.safeTxHash)&&void 0!==i?i:void 0;return w&&a&&e&&(C=a(w,null==t?void 0:t.chainId,e)),{hash:null!==(o=null==t?void 0:t.hash)&&void 0!==o?o:"",fromToken:ag({address:null!==(r=null==t?void 0:t.fromTokenAddress)&&void 0!==r?r:"",decimals:null==t?void 0:t.fromTokenDecimals,symbol:null!==(s=null==t?void 0:t.fromTokenSymbol)&&void 0!==s?s:"",name:null!==(l=null==t?void 0:t.fromTokenSymbol)&&void 0!==l?l:""},null==t?void 0:t.chainId),toToken:ag({address:null!==(d=null==t?void 0:t.toTokenAddress)&&void 0!==d?d:"",decimals:null==t?void 0:t.toTokenDecimals,symbol:null!==(c=null==t?void 0:t.toTokenSymbol)&&void 0!==c?c:"",name:null!==(u=null==t?void 0:t.toTokenSymbol)&&void 0!==u?u:""},null==t?void 0:t.chainId),fromAmount:null!==(p=null==t?void 0:t.fromAmount)&&void 0!==p?p:"",toAmount:null!==(h=null==t?void 0:t.toAmount)&&void 0!==h?h:"",minAmount:null!==(m=null==t?void 0:t.minAmount)&&void 0!==m?m:"",fromTokenPrice:null!==(g=null==t?void 0:t.fromTokenPrice)&&void 0!==g?g:"",toTokenPrice:null!==(f=null==t?void 0:t.toTokenPrice)&&void 0!==f?f:"",createdAt:null!==(x=null==t?void 0:t.createdAt)&&void 0!==x?x:"",routeData:null!==(v=null===(y=null==t?void 0:t.extra)||void 0===y?void 0:y.routeData)&&void 0!==v?v:"",safeTxHash:w,safeTxUrl:C,status:null!==(b=null==t?void 0:t.status)&&void 0!==b?b:"",transactionHash:null===(j=null==t?void 0:t.extra)||void 0===j?void 0:j.transactionHash}})))&&void 0!==r?r:[];return Object.assign(Object.assign({},l),{orderList:d})}var Nj,Fj;function Uj({showFold:t,isMobile:n,data:o}){const r=a(),{routeData:s}=rj({rawRouteData:o.routeData,chainId:o.fromToken.chainId}),l=$((()=>o.fromTokenPrice?new Pe(o.fromTokenPrice):new Pe(0)),[o.fromTokenPrice]);return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:24,p:t?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${r.palette.background.skeleton} 0%, ${r.palette.background.skeleton} 100%), ${r.palette.background.paper}`,maxHeight:t?400:0,transition:"all 300ms",overflow:"hidden",[r.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px"}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"h6",color:r.palette.text.secondary},children:[Yn.jsx(e,{id:"URmyfc",message:"Details"}),n&&Yn.jsxs(i,{children:["Rate: 1 ",o.fromToken.symbol,"=",l&&l.isFinite()?Am({input:l,decimals:o.toToken.decimals}):"-"," ",o.toToken.symbol]})]}),n?Yn.jsx($f,{routeData:s,fromTokenRaw:o.fromToken,toTokenRaw:o.toToken}):Yn.jsx(zf,{routeData:s,fromTokenRaw:o.fromToken,toTokenRaw:o.toToken})]})}function qj({data:e,isMobile:t}){var n,o,r,s,l,d;const c=a(),[u,p]=H.useState(!1),{statusText:h,statusColor:m,statusAlphaColor:g}=function({status:e,stateTextMap:t}){let n=t?t[e]:e;const i=a();let o,r=se._({id:"yQE2r9",message:"Loading"}),s=i.palette.text.primary;switch(e){case Nj.Warning:r=se._({id:"GGWsTU",message:"Canceled"}),o=.1;break;case Nj.Failed:r=se._({id:"7Bj3x9",message:"Failed"}),s=i.palette.error.main;break;case Nj.Success:r=se._({id:"KAbcm2",message:"Succeeded"}),s=i.palette.success.main}return{state:n,statusText:r,statusColor:s,statusAlphaColor:o}}({status:e.status}),f=gf(new Date(e.createdAt));return t?Yn.jsxs(i,{sx:{backgroundColor:c.palette.background.paper,borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},onClick:()=>window.open(tg(e.fromToken.chainId,e.hash,"tx"),"_blank"),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{width:24,height:24,address:e.fromToken.address,chainId:e.fromToken.chainId}),Yn.jsx(i,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:Yn.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),Yn.jsx(Df,{width:24,height:24,address:e.toToken.address,chainId:e.toToken.chainId})]}),Yn.jsx(Sj,{isMobile:!1,statusText:h,statusColor:m,alphaColor:g})]}),Yn.jsx(i,{sx:{typography:"h6",color:c.palette.text.secondary},children:f})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(Ej,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay"}),Yn.jsx(Ej,{token:e.toToken,amount:e.toAmount,canAddMetamask:null!==(o=null===(n=ah.get(e.fromToken.chainId))||void 0===n?void 0:n.isEVMChain)&&void 0!==o&&o,title:"Receive"})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${c.palette.border.main}`},children:Yn.jsx(Ij,{show:u,onClick:()=>p((e=>!e)),sx:{color:"text.secondary"}})})]})]}),Yn.jsx(Uj,{showFold:u,data:e,isMobile:!0})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("tr",{children:[Yn.jsx(i,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:u?0:8},children:Yn.jsx(Aj,{token:e.fromToken,amount:null!==(r=e.fromAmount)&&void 0!==r?r:"",showChain:!0})}),Yn.jsx("td",{children:Yn.jsx(Aj,{token:e.toToken,amount:null!==(s=e.toAmount)&&void 0!==s?s:"",showChain:!0,canAddMetamask:null!==(d=null===(l=ah.get(e.toToken.chainId))||void 0===l?void 0:l.isEVMChain)&&void 0!==d&&d})}),Yn.jsx("td",{children:Yn.jsx(Sj,{isMobile:t,statusText:h,statusColor:m,alphaColor:g,time:f})}),Yn.jsx("td",{children:Yn.jsx(Rj,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),Yn.jsx(i,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:u?0:8},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{component:"a",href:tg(e.fromToken.chainId,e.hash,"tx"),target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:18,height:18}})}),Yn.jsx(i,{sx:{height:16,width:"1px",backgroundColor:"border.main"}}),Yn.jsx(Ij,{show:u,onClick:()=>p((e=>!e))})]})})]}),Yn.jsx("tr",{children:Yn.jsx(i,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:Yn.jsx(Uj,{showFold:u,data:e})})})]})}function Vj({account:t}){const{isMobile:n}=Tg(),o=Dj({account:t,limit:n?10:5});return Yn.jsx(Tj,{isMobile:n,empty:!o.orderList.length,loading:o.isLoading,children:n?Yn.jsxs(i,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[o.orderList.map((e=>Yn.jsx(qj,{data:e,isMobile:n},e.hash))),Yn.jsx(Oj,{loading:o.isFetchingNextPage,onClick:o.fetchNextPage,hasMore:o.hasNextPage,height:68})]}):Yn.jsx(Yn.Fragment,{children:Yn.jsxs(Lj,{loadMoreLoading:o.isFetchingNextPage,loadMore:o.fetchNextPage,hasMore:o.hasNextPage,children:[Yn.jsx("thead",{children:Yn.jsxs("tr",{children:[Yn.jsx("th",{children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8},children:Yn.jsx(e,{id:"4fL/V7",message:"Pay"})})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"lDgVWA",message:"Receive"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"uAQUqI",message:"Status"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"fqDzSu",message:"Rate"})}),Yn.jsx(i,{component:"th",sx:{width:140},children:Yn.jsx(e,{id:"URmyfc",message:"Details"})})]})}),Yn.jsx("tbody",{children:o.orderList.map((e=>Yn.jsx(qj,{data:e,isMobile:n},e.hash)))})]})})})}function Wj(e){var{sx:t}=e,n=qn(e,["sx"]);return Yn.jsx(O,{...n,sx:Object.assign(Object.assign({},t),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function Hj(){const e=a(),{isMobile:t}=Tg(),n=G(null),o=G(null),{crossChainSubmittedCounter:r}=xg(),s=nt(),l=G(),d=G(s),{evmAccount:c,solanaAccount:u,bitcoinAccount:p,suiAccount:h,tonAccount:m,currentAccount:g}=dg(),[f,x]=z(Fj.sameChain),[y,v]=z(),b=$((()=>[{key:Fj.sameChain,value:"Same chain Swaps"},{key:Fj.crossChain,value:"Cross Chain Swaps"},{key:Fj.errorRefunds,value:"Error Refunds"}]),[]),j=$((()=>{var e,t,n,i,o;const r=[];if(c.isConnected&&c.address){const t=null===(e=ah.entries().find((([e,t])=>t.isEVMChain)))||void 0===e?void 0:e[1];t&&r.push({account:sm(c.address),firstChain:t})}if(u.isConnected&&u.address){const e=null===(t=ah.entries().find((([e,t])=>t.isSolanaChain)))||void 0===t?void 0:t[1];e&&r.push({account:u.address,firstChain:e})}if(p.isConnected&&p.address){const e=null===(n=ah.entries().find((([e,t])=>t.isBTCChain)))||void 0===n?void 0:n[1];e&&r.push({account:p.address,firstChain:e})}if(h.isConnected&&h.address){const e=null===(i=ah.entries().find((([e,t])=>t.isSUIChain)))||void 0===i?void 0:i[1];e&&r.push({account:h.address,firstChain:e})}if(m.isConnected&&m.address){const e=null===(o=ah.entries().find((([e,t])=>t.isTONChain)))||void 0===o?void 0:o[1];e&&r.push({account:m.address,firstChain:e})}return r}),[p.address,p.isConnected,c.address,c.isConnected,u.address,u.isConnected,h.address,h.isConnected,m.address,m.isConnected]);Q((()=>{v((()=>{if(j.length>0)return j[0].account}))}),[j]);const C=Z(((e,t,i)=>{v(e),n.current&&(t?n.current.scrollTo({left:n.current.scrollWidth,behavior:"smooth"}):i&&n.current.scrollTo({left:0,behavior:"smooth"}))}),[]);return Q((()=>{const e=null==g?void 0:g.address;if(!e)return;const t=j.find((t=>t.account.toLowerCase()===e.toLowerCase()));t&&(l.current=t.account)}),[j,null==g?void 0:g.address]),Q((()=>{d.current=s}),[s]),Q((()=>{0!==r&&setTimeout((()=>{var e;null===(e=o.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"}),x(Fj.crossChain),l.current&&(v(l.current),d.current.invalidateQueries({queryKey:["graphql","getInfiniteQuery","page",Ce.graphql.cross_chain_swap_zetachain_orderList]}))}),300)}),[r]),Yn.jsxs(S,{value:f,onChange:(e,t)=>{x(t)},sx:{width:"100%",display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%",borderRadius:16,backgroundColor:"background.skeleton",backdropFilter:"blur(4px)",[e.breakpoints.up("laptop")]:{}},className:t?void 0:"gradient-card-border",children:[Yn.jsx(i,{ref:o,sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",px:16,pt:20,[e.breakpoints.up("laptop")]:{px:24}},children:Yn.jsx(D,{tabs:b,variant:"default",tabsListSx:{justifyContent:"space-between",borderBottomWidth:0},tabSx:{mr:28,typography:"body2",lineHeight:"19px",minHeight:39,padding:"0px 0px 20px 0px",[e.breakpoints.up("laptop")]:{typography:"body1",lineHeight:"22px",minHeight:42}}})}),Yn.jsx(i,{ref:n,sx:{px:16,py:12,display:"flex",alignItems:"center",gap:12,overflowX:"auto",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",[e.breakpoints.up("laptop")]:{px:24},"&::-webkit-scrollbar":{display:"none"},msOverflowStyle:"none",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",userSelect:"none"},children:j.map(((t,n)=>{const o=y===t.account,r=n===j.length-1,a=0===n;return Yn.jsxs(i,{sx:Object.assign(Object.assign({display:"flex",alignItems:"center",gap:4,pl:8,py:8,pr:10,borderRadius:4,backgroundColor:"transparent",cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.secondary",flexShrink:0},o&&{backgroundColor:T(e.palette.success.main,.1),color:"success.main"}),{"&:hover":{backgroundColor:o?T(e.palette.success.main,.1):e.palette.background.paperDarkContrast}}),onClick:()=>C(t.account,r,a),children:[t.firstChain&&Yn.jsx(i,{component:t.firstChain.logo,sx:{width:16,height:16}}),"(",lg(t.firstChain.chainId),")",eg(t.account)]},t.account)}))}),y?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Wj,{value:Fj.sameChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsx(Vj,{account:y})}),Yn.jsx(Wj,{value:Fj.crossChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsx(Bj,{account:y})}),Yn.jsx(Wj,{value:Fj.errorRefunds,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsx(Bj,{account:y,type:"error_refund"})})]}):Yn.jsx(Tj,{isMobile:t,empty:!0,loading:!1})]})}!function(e){e.Running="pending",e.Success="success",e.Failed="failed",e.Warning="reset"}(Nj||(Nj={})),function(e){e.sameChain="same-chain",e.crossChain="cross-chain",e.errorRefunds="error-refunds"}(Fj||(Fj={}));const $j="widget-module-container",zj=H.forwardRef((function(e,t){var{sx:n}=e,o=qn(e,["sx"]);const{isMobile:r}=Tg();return Yn.jsx(i,{className:$j,ref:t,sx:Object.assign(Object.assign({flex:1,backgroundColor:"transparent"},r?{padding:0,height:"100%",width:"100%",overflowX:"hidden"}:{padding:0,height:"auto"}),n),...o})}));var Zj;!function(e){e.Pool="pool",e.PoolDetail="poolDetail",e.CurvePoolDetail="curvePoolDetail",e.CreatePool="createPool",e.ModifyPool="modifyPool",e.MiningList="miningList",e.MiningDetail="miningDetail",e.createPoolAMMV2="createPoolAMMV2",e.createPoolAMMV3="createPoolAMMV3"}(Zj||(Zj={}));const Gj=st(((e,t)=>({page:void 0,historyList:[],push:t=>{e((e=>{var n;const i=[...e.historyList,null!==(n=e.page)&&void 0!==n?n:{type:Zj.Pool}];return{page:t,historyList:i}}))},back:()=>{e((e=>{const t=e.historyList.length;if(!t)return"undefined"!=typeof window&&window.history&&history.back(),e;const n=[...e.historyList];return{page:n.splice(t-1,1)[0],historyList:n}}))}})));function Qj({title:e,descList:t,linkTo:n,sx:o}){const r=a();return Yn.jsxs(i,{sx:Object.assign({backgroundColor:r.palette.background.paper,backdropFilter:"blur(4px)",borderRadius:12,padding:24,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24},o),children:[Yn.jsx(i,{sx:{color:r.palette.text.primary,typography:"body1",fontWeight:500,lineHeight:"24px"},children:e}),Yn.jsx(i,{sx:{display:"flex",alignItems:"stretch",gap:24},children:t.map(((e,t)=>Yn.jsxs(i,{sx:{flex:1,padding:16,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:8,borderWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:{color:r.palette.primary.contrastText,typography:"h6",fontWeight:600,lineHeight:"20px",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:r.palette.primary.main},children:t+1}),Yn.jsx(i,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:500,lineHeight:"24px"},children:e.title})]}),Yn.jsx(i,{sx:{color:r.palette.text.secondary,typography:"h6",fontWeight:500,lineHeight:"18px"},children:e.desc})]},t)))}),Yn.jsx(i,{component:"a",href:n,target:"_blank",rel:"noopener noreferrer",sx:{px:24,py:12,borderRadius:8,backgroundColor:r.palette.background.tag,color:r.palette.text.primary,typography:"body2",fontWeight:700,lineHeight:"21px",textDecoration:"none"},children:"Read Docs"})]})}const Yj=[{value:0,label:"0%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:75,label:"75%"},{value:100,label:"100%"}];function Kj({disabled:e,value:t,onChange:n,sx:o}){return Yn.jsxs(i,{sx:Object.assign({p:20,backgroundColor:"background.cardInput",borderRadius:12},o),children:[Yn.jsx(Db,{value:String(t),onChange:e=>n(+e),readOnly:!0,readonlyShowSuffix:!0,suffix:Yn.jsx(i,{sx:{typography:"h2"},children:"%"}),sx:{mt:12,backgroundColor:"background.cardInput","& input":{pl:0,typography:"h1"}}}),Yn.jsx(i,{sx:{mt:20},children:Yn.jsx(w,{marks:Yj,step:1,disabled:e,value:t,onChange:(e,t)=>n(t)})})]})}function Xj({active:t,sx:n,onClick:o}){const r=a(),s="light"===r.palette.mode;let l=r.palette.primary.main,c="transparent";return t&&(l=r.palette.primary.contrastText,c=T(r.palette.primary.main,.8)),Yn.jsx(i,{component:d,sx:Object.assign({typography:"body2",p:t?r.spacing(8,20,9):r.spacing(7,19,8),minWidth:79,border:t?void 0:`1px solid ${l}`,color:l,backgroundColor:c,borderRadius:8,fontWeight:600,"&:hover":{color:t?r.palette.primary.contrastText:r.palette.primary.main,backgroundColor:t?r.palette.primary.main:s?"rgba(26, 26, 27, 0.04)":"rgba(241, 249, 2, 0.08)"}},n),onClick:o,children:Yn.jsx(e,{id:"R9Khdg",message:"Auto"})})}const Jj="auto",eC="0.1",tC="0.5",nC="0.5",iC=.01,oC=({address:e,type:t})=>{const[n,i]=z(Jj),o=$((()=>n===Jj?"AMMV3"===t?new Pe(nC).div(100).toNumber():"AMMV2"===t?new Pe(tC).div(100).toNumber():new Pe(eC).div(100).toNumber():n),[n,t]);return{slipper:n,setSlipper:i,slipperValue:o,resetSlipper:()=>{i(Jj)}}};function rC({type:t,disabled:n,value:o,onChange:r,sx:s}){const d=a(),c=o===Jj,[u,p]=z(c?"":new Pe(o).times(100).toNumber()),h="AMMV3"==t?nC:"AMMV2"==t?tC:eC;return Yn.jsx(l,{disabled:n,onlyClick:!0,title:Yn.jsxs(i,{sx:{backgroundColor:d.palette.background.paper,padding:d.spacing(12,20),borderRadius:8,width:318,maxWidth:"90vw",boxSizing:"border-box"},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"lqTDfd",message:"Slippage Tolerance"})}),Yn.jsxs("span",{children:[c?h:o&&new Pe(o).times(100).toNumber(),"%"]})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",margin:d.spacing(16,0,0,0)},children:[Yn.jsx(Xj,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{p(""),r(Jj)},active:c}),Yn.jsx(b,{placeholder:String(h),value:u,onChange:e=>{const{value:t}=e.target;p(t),r(t?new Pe(t).div(100).toNumber():Jj)},onBlur:()=>{(!c&&new Pe(o).gt(.1)||new Pe(o).lte(0))&&(p(10),r(.1))},suffix:Yn.jsx(i,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:Yn.jsx(_,{sx:Object.assign({width:"max-content",alignItems:"right",margin:d.spacing(0,0,0,"auto"),p:d.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast"},s),children:Yn.jsx(i,{component:li.Setting,sx:{width:18,height:18,"& path:last-child":{fill:d.palette.text.primary}}})})})}const aC=50;var sC,lC,dC;function cC(t){var n,i,o,{chainId:r,includeButton:a}=t,s=qn(t,["chainId","includeButton"]);const{chainId:l,getAppKitAccountByChainId:d,open:u}=dg(),[p,h]=H.useState(!1),m=Cj(r),g=void 0!==l&&void 0!==r&&l!==r,f=d(r);return!(null==f?void 0:f.appKitAccount.address)||p||void 0===l||r&&r!==l?Yn.jsx(Yn.Fragment,{children:Yn.jsx(c,{...s,isLoading:p,onClick:()=>Vn(this,void 0,void 0,(function*(){if(g)return m?(h(!0),yield m(),void h(!1)):void 0;h(!0),u({namespace:null==f?void 0:f.namespace}),h(!1)})),children:p?Yn.jsx(e,{id:"J28zul",message:"Connecting..."}):g&&r?se._({id:"1+P9RR",message:"Switch to {0}",values:{0:null!==(o=null===(i=ah.get(r))||void 0===i?void 0:i.name)&&void 0!==o?o:"unknown"}}):Yn.jsx(e,{id:"r7ScnQ",message:"Connect to a wallet"})})}):a?Yn.jsx(Yn.Fragment,{children:null!==(n=s.children)&&void 0!==n?n:null}):Yn.jsx(c,{...s})}!function(e){e[e.quantity=1]="quantity",e[e.percentage=2]="percentage"}(sC||(sC={})),function(e){e.CURRENCY_A="CURRENCY_A",e.CURRENCY_B="CURRENCY_B"}(lC||(lC={})),function(e){e.LOWER="LOWER",e.UPPER="UPPER"}(dC||(dC={}));const uC={xs:"4px",sm:"8px",md:"12px",lg:"24px",xl:"32px"},pC=({children:e,sx:t})=>(a(),Yn.jsx(i,{sx:Object.assign({display:"flex",flexDirection:"column",gap:20,px:20,py:20,borderRadius:12},t),children:e})),hC=({children:e,sx:t})=>{const n=a();return Yn.jsx(pC,{sx:Object.assign(Object.assign({},t),{backgroundColor:n.palette.background.paperContrast}),children:e})},mC=({children:e})=>{const t=a();return Yn.jsxs(i,{sx:{p:8,borderRadius:8,backgroundColor:T(t.palette.warning.main,.1),display:"flex",alignItems:"center",gap:8},children:[Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 16.125L9 1.875L17.25 16.125H0.75ZM14.6475 14.625L8.99998 4.86749L3.35247 14.625H14.6475ZM9.75004 12.375H8.25003V13.875H9.75004V12.375ZM8.25003 7.875H9.75004V10.875H8.25003V7.875Z",fill:t.palette.warning.main})}),Yn.jsx(i,{sx:{typography:"h6",color:t.palette.warning.main,textAlign:"left"},children:e})]})};function gC({gap:e,flex:t,children:n,style:o}){return Yn.jsx(i,{sx:Object.assign(Object.assign(Object.assign({display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:e&&uC[e]||e},t&&{flex:t}),{width:"100%",alignItems:"center"}),o),children:n})}function fC({gap:e,justify:t,grow:n,children:o,style:r}){return Yn.jsx(i,{sx:Object.assign({display:"grid",gridAutoRows:"auto",gridRowGap:e&&uC[e]||e,justifyItems:t,flexGrow:n&&1},r),children:o})}function xC({gap:e,children:t,sx:n}){return Yn.jsx(i,{sx:Object.assign({width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"flex-start",gap:e&&uC[e]||e},n),children:t})}function yC({children:e,style:t}){return Yn.jsx(xC,{sx:Object.assign({justifyContent:"space-between"},t),children:e})}function vC({gap:e,justify:t,children:n,sx:i}){return Yn.jsx(xC,{sx:Object.assign({position:"relative",width:"fit-content",margin:`-${e}`},i),children:n})}function bC({children:e,disabled:t,sx:n}){return Yn.jsx(xC,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:"stretch",gap:12,opacity:t?.2:1,pointerEvents:t?"none":"auto"},n),children:e})}const jC=({chainId:t,approvalA:n,approvalB:o,parsedAmounts:r,isValid:a,depositADisabled:s,depositBDisabled:l,errorMessage:d,setShowConfirm:u})=>{var p,h;const m=n.needApprove&&!!r[lC.CURRENCY_A]||n.isApproving,g=o.needApprove&&!!r[lC.CURRENCY_B]||o.isApproving;return Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:t,children:Yn.jsxs(fC,{gap:"md",style:{width:"100%"},children:[(m||g)&&a&&Yn.jsxs(i,{sx:{width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"space-between",gap:8},children:[m&&Yn.jsx(c,{size:c.Size.big,isLoading:n.isApproving,onClick:n.submitApprove,disabled:n.insufficientBalance,width:g?"50%":"100%",children:n.isApproving?Yn.jsx(e,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(p=n.token)||void 0===p?void 0:p.symbol}}):n.approveTitle}),g&&Yn.jsx(c,{size:c.Size.big,isLoading:o.isApproving,onClick:o.submitApprove,disabled:o.insufficientBalance,width:m?"50%":"100%",children:o.isApproving?Yn.jsx(e,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(h=o.token)||void 0===h?void 0:h.symbol}}):o.approveTitle})]}),Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:()=>{u(!0)},disabled:!a||n.needApprove&&!s||o.needApprove&&!l,danger:!a&&!!r[lC.CURRENCY_A]&&!!r[lC.CURRENCY_B],children:d||se._({id:"rdUucN",message:"Preview"})})]})})},CC=({chainId:e,disabled:t,isLoading:n,onConfirm:i})=>Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:e,children:Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:i,disabled:t,isLoading:n,children:se._({id:"h5pjuM",message:"Collect fees"})})});function wC(e){const t=G();return Q((()=>{t.current=e})),t.current}const kC=[.25,.5,.75,1];function TC({currentValue:e,onClick:t,sx:n}){const o=a(),r="light"===o.palette.mode,{isMobile:s}=Tg(),[l,c]=z(null),u=G(0);Q((()=>{e?(u.current+=1,u.current>=2&&(c(null),u.current=0)):c(null)}),[e]);const p=wC(e);return Q((()=>{p===e&&1===l&&(u.current=1)}),[e,p,l]),Yn.jsx(i,{sx:Object.assign({display:"grid",gap:s?10:14,gridTemplateColumns:`repeat(${kC.length}, 1fr)`},n),children:kC.map((e=>{const n=e===l;return Yn.jsxs(d,{sx:{typography:"h6",borderRadius:4,padding:o.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:hover":{color:o.palette.text.primary,backgroundColor:T(o.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?o.palette.primary.main:T(o.palette.text.primary,.4)}},onClick:()=>{n||(u.current=0,c(e),t(e))},className:n?"selected":void 0,children:[100*e,"%"]},e)}))})}const IC=({value:t,onUserInput:n,maxAmount:o,balance:r,currency:s,locked:l})=>{var c,u;const p=a(),h=Z((e=>{if(!o||!s)return;const t=o.toExact().multipliedBy(e).dp(s.decimals).toString();n(t)}),[s,o,n]),m=$((()=>r?Am({input:r.toExact(),decimals:null==s?void 0:s.decimals}):"-"),[null==s?void 0:s.decimals,r]);return Yn.jsxs(i,{sx:{pt:20,pb:20,px:20,borderRadius:16,backgroundColor:p.palette.background.cardInput},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,color:p.palette.text.primary,typography:"h5"},children:[(null==s?void 0:s.address)&&Yn.jsx(Df,{address:null!==(c=null==s?void 0:s.address)&&void 0!==c?c:"",chainId:null==s?void 0:s.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:(null==s?void 0:s.address)?Yn.jsx(i,{children:null!==(u=null==s?void 0:s.symbol)&&void 0!==u?u:"-"}):Yn.jsx(e,{id:"sIPJGT",message:"SELECT TOKEN"})})]}),Yn.jsxs(i,{component:d,sx:{color:p.palette.text.secondary,"&:hover":{color:p.palette.text.primary},cursor:"pointer",display:"flex",flexWrap:"wrap",justifyContent:"flex-end",typography:"body2"},onClick:()=>{h(1)},children:[Yn.jsxs(i,{sx:{wordBreak:"keep-all"},children:[se._({id:"fsBGk0",message:"Balance"}),": "]}),Yn.jsx(i,{sx:{wordBreak:"break-all",textAlign:"right",display:"flex",alignItems:"center"},children:m})]})]}),Yn.jsx(Db,{sx:{mt:4,backgroundColor:p.palette.background.cardInput},suffix:void 0,value:t,onChange:n,readOnly:l,withClear:!l}),l?null:Yn.jsx(TC,{sx:{mt:20,mb:0},onClick:h,currentValue:t})]})},SC={},EC={};var AC,OC;Object.values(le).filter((e=>"number"==typeof e)).map((e=>{const t=pt(e),n=ht(e);t&&(SC[e]=t),n&&(EC[e]=n)})),le.MAINNET,le.ARBITRUM_ONE,le.SEPOLIA,le.TAIKO,function(e){e[e.EXACT_INPUT=0]="EXACT_INPUT",e[e.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(AC||(AC={})),function(e){e[e.ROUND_DOWN=0]="ROUND_DOWN",e[e.ROUND_HALF_UP=1]="ROUND_HALF_UP",e[e.ROUND_UP=2]="ROUND_UP"}(OC||(OC={}));const LC=wn.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),RC={[OC.ROUND_DOWN]:Pe.ROUND_DOWN,[OC.ROUND_HALF_UP]:Pe.ROUND_HALF_UP,[OC.ROUND_UP]:Pe.ROUND_UP},PC={[OC.ROUND_DOWN]:Pe.ROUND_DOWN,[OC.ROUND_HALF_UP]:Pe.ROUND_HALF_UP,[OC.ROUND_UP]:Pe.ROUND_UP};class _C{constructor(e,t=wn.BigInt(1)){this.numerator=wn.BigInt(e),this.denominator=wn.BigInt(t)}static tryParseFraction(e){if(e instanceof wn||"number"==typeof e||"string"==typeof e)return new _C(e);if("numerator"in e&&"denominator"in e)return e;throw new Error("Could not parse fraction")}get quotient(){return wn.divide(this.numerator,this.denominator)}get remainder(){return new _C(wn.remainder(this.numerator,this.denominator),this.denominator)}invert(){return new _C(this.denominator,this.numerator)}add(e){const t=_C.tryParseFraction(e);return wn.equal(this.denominator,t.denominator)?new _C(wn.add(this.numerator,t.numerator),this.denominator):new _C(wn.add(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator)),wn.multiply(this.denominator,t.denominator))}subtract(e){const t=_C.tryParseFraction(e);return wn.equal(this.denominator,t.denominator)?new _C(wn.subtract(this.numerator,t.numerator),this.denominator):new _C(wn.subtract(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator)),wn.multiply(this.denominator,t.denominator))}lessThan(e){const t=_C.tryParseFraction(e);return wn.lessThan(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator))}equalTo(e){const t=_C.tryParseFraction(e);return wn.equal(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator))}greaterThan(e){const t=_C.tryParseFraction(e);return wn.greaterThan(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator))}multiply(e){const t=_C.tryParseFraction(e);return new _C(wn.multiply(this.numerator,t.numerator),wn.multiply(this.denominator,t.denominator))}divide(e){const t=_C.tryParseFraction(e);return new _C(wn.multiply(this.numerator,t.denominator),wn.multiply(this.denominator,t.numerator))}toSignificant(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=OC.ROUND_HALF_UP){kn(Number.isInteger(e),`${e} is not an integer.`),kn(e>0,`${e} is not positive.`);const i=RC[n],o=new Pe(this.numerator.toString()).div(this.denominator.toString()).precision(e,i);return o.toFormat(o.decimalPlaces(),i,t)}toFixed(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=OC.ROUND_HALF_UP){kn(Number.isInteger(e),`${e} is not an integer.`),kn(e>=0,`${e} is negative.`);const i=PC[n];return new Pe(this.numerator.toString()).decimalPlaces(e,i).div(this.denominator.toString()).toFormat(e,i,t)}get asFraction(){return new _C(this.numerator,this.denominator)}}class MC extends _C{static fromRawAmount(e,t){return new MC(e,t)}static fromFractionalAmount(e,t,n){return new MC(e,t,n)}constructor(e,t,n){super(t,n),kn(wn.lessThanOrEqual(this.quotient,LC),"AMOUNT"),this.currency=e,this.decimalScale=wn.exponentiate(wn.BigInt(10),wn.BigInt(e.decimals))}add(e){kn(this.currency.equals(e.currency),"CURRENCY");const t=super.add(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}subtract(e){kn(this.currency.equals(e.currency),"CURRENCY");const t=super.subtract(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}multiply(e){const t=super.multiply(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}divide(e){const t=super.divide(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}toSignificant(e=6,t,n=OC.ROUND_DOWN){return super.divide(this.decimalScale).toSignificant(e,t,n)}toFixed(e=this.currency.decimals,t,n=OC.ROUND_DOWN){return kn(e<=this.currency.decimals,"DECIMALS"),super.divide(this.decimalScale).toFixed(e,t,n)}toExact(){return new Pe(this.quotient.toString()).div(this.decimalScale.toString())}get wrapped(){return this.currency.isToken?this:MC.fromFractionalAmount(this.currency.wrapped,this.numerator,this.denominator)}}const BC=new _C(wn.BigInt(100));function DC(e){return new NC(e.numerator,e.denominator)}class NC extends _C{constructor(){super(...arguments),this.isPercent=!0}add(e){return DC(super.add(e))}subtract(e){return DC(super.subtract(e))}multiply(e){return DC(super.multiply(e))}divide(e){return DC(super.divide(e))}toSignificant(e=5,t,n){return super.multiply(BC).toSignificant(e,t,n)}toFixed(e=2,t,n){return super.multiply(BC).toFixed(e,t,n)}}class FC extends _C{constructor(...e){let t,n,i,o;if(4===e.length)[t,n,i,o]=e;else{const r=e[0].quoteAmount.divide(e[0].baseAmount);[t,n,i,o]=[e[0].baseAmount.currency,e[0].quoteAmount.currency,r.denominator,r.numerator]}super(o,i),this.baseCurrency=t,this.quoteCurrency=n,this.scalar=new _C(wn.exponentiate(wn.BigInt(10),wn.BigInt(t.decimals)),wn.exponentiate(wn.BigInt(10),wn.BigInt(n.decimals)))}invert(){return new FC(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)}multiply(e){kn(this.quoteCurrency.equals(e.baseCurrency),"TOKEN");const t=super.multiply(e);return new FC(this.baseCurrency,e.quoteCurrency,t.denominator,t.numerator)}quote(e){kn(e.currency.equals(this.baseCurrency),"TOKEN");const t=super.multiply(e);return MC.fromFractionalAmount(this.quoteCurrency,t.numerator,t.denominator)}get adjustedForDecimals(){return super.multiply(this.scalar)}toSignificant(e=6,t,n){return this.adjustedForDecimals.toSignificant(e,t,n)}toFixed(e=4,t,n){return this.adjustedForDecimals.toFixed(e,t,n)}}class UC{constructor(e,t,n,i){kn(Number.isSafeInteger(e),"CHAIN_ID"),kn(t>=0&&t<255&&Number.isInteger(t),"DECIMALS"),this.chainId=e,this.decimals=t,this.symbol=n,this.name=i}}function qC(e){try{return sm(e)}catch(t){throw new Error(`${e} is not a valid address.`)}}const VC=/^0x[0-9a-fA-F]{40}$/;class WC extends UC{constructor(e,t,n,i,o,r,a,s){super(e,n,i,o),this.isNative=!1,this.isToken=!0,this.address=r?function(e){if(VC.test(e))return e;throw new Error(`${e} is not a valid address.`)}(t):qC(t),a&&kn(a.gte($t.from(0)),"NON-NEGATIVE FOT FEES"),s&&kn(s.gte($t.from(0)),"NON-NEGATIVE FOT FEES"),this.buyFeeBps=a,this.sellFeeBps=s}equals(e){return e.isToken&&this.chainId===e.chainId&&this.address.toLowerCase()===e.address.toLowerCase()}sortsBefore(e){return kn(this.chainId===e.chainId,"CHAIN_IDS"),kn(this.address.toLowerCase()!==e.address.toLowerCase(),"ADDRESSES"),this.address.toLowerCase()<e.address.toLowerCase()}get wrapped(){return this}}const HC=wn.BigInt(Number.MAX_SAFE_INTEGER),$C=wn.BigInt(0),zC=wn.BigInt(1),ZC=wn.BigInt(2);const GC=wn.BigInt(0),QC=1e4;new NC(wn.BigInt(1),QC),new NC(1,100),new NC(3,100),new NC(5,100),new NC(10,100),new NC(15,100);const YC=new NC(0);new NC(1);const KC="0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";var XC;!function(e){e[e.LOWEST=100]="LOWEST",e[e.LOW_200=200]="LOW_200",e[e.LOW_300=300]="LOW_300",e[e.LOW_400=400]="LOW_400",e[e.LOW=500]="LOW",e[e.MEDIUM=3e3]="MEDIUM",e[e.HIGH=1e4]="HIGH"}(XC||(XC={}));const JC={[XC.LOWEST]:1,[XC.LOW_200]:4,[XC.LOW_300]:6,[XC.LOW_400]:8,[XC.LOW]:10,[XC.MEDIUM]:60,[XC.HIGH]:200},ew=wn.BigInt(-1),tw=wn.BigInt(0),nw=wn.BigInt(1),iw=wn.exponentiate(wn.BigInt(2),wn.BigInt(96)),ow=wn.exponentiate(iw,wn.BigInt(2)),rw=new Nh("properties/5.8.0");function aw(e,t,n){Object.defineProperty(e,t,{enumerable:!0,value:n,writable:!1})}function sw(e,t){for(let n=0;n<32;n++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null}const lw={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function dw(e){if(null==e||lw[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const t=Object.keys(e);for(let n=0;n<t.length;n++){let i=null;try{i=e[t[n]]}catch(e){continue}if(!dw(i))return!1}return!0}return rw.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function cw(e){if(dw(e))return e;if(Array.isArray(e))return Object.freeze(e.map((e=>uw(e))));if("object"==typeof e){const t={};for(const n in e){const i=e[n];void 0!==i&&aw(t,n,uw(i))}return t}return rw.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function uw(e){return cw(e)}class pw{constructor(e){for(const t in e)this[t]=uw(e[t])}}const hw="abi/5.8.0",mw=new Nh(hw),gw={};let fw={calldata:!0,memory:!0,storage:!0},xw={calldata:!0,memory:!0};function yw(e,t){if("bytes"===e||"string"===e){if(fw[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&xw[t])return!0;return(fw[t]||"payable"===t)&&mw.throwArgumentError("invalid modifier","name",t),!1}function vw(e,t){for(let n in t)aw(e,n,t[n])}const bw=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),jw=new RegExp(/^(.*)\[([0-9]*)\]$/);class Cw{constructor(e,t){e!==gw&&mw.throwError("use fromString",Nh.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),vw(this,t);let n=this.type.match(jw);vw(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:Cw.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==bw.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===bw.full?", ":",")+")"):t+=this.type,e!==bw.sighash&&(!0===this.indexed&&(t+=" indexed"),e===bw.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?Cw.fromString(e,t):Cw.fromObject(e)}static fromObject(e){return Cw.isParamType(e)?e:new Cw(gw,{name:e.name||null,type:Pw(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(Cw.fromObject):null})}static fromString(e,t){return n=function(e,t){let n=e;function i(t){mw.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function o(e){let n={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(n.indexed=!1),n}e=e.replace(/\s/g," ");let r={type:"",name:"",state:{allowType:!0}},a=r;for(let n=0;n<e.length;n++){let r=e[n];switch(r){case"(":a.state.allowType&&""===a.type?a.type="tuple":a.state.allowParams||i(n),a.state.allowType=!1,a.type=Pw(a.type),a.components=[o(a)],a=a.components[0];break;case")":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),yw(a.type,a.name)&&(a.name=""),a.type=Pw(a.type);let e=a;a=a.parent,a||i(n),delete e.parent,a.state.allowParams=!1,a.state.allowName=!0,a.state.allowArray=!0;break;case",":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),yw(a.type,a.name)&&(a.name=""),a.type=Pw(a.type);let s=o(a.parent);a.parent.components.push(s),delete a.parent,a=s;break;case" ":a.state.allowType&&""!==a.type&&(a.type=Pw(a.type),delete a.state.allowType,a.state.allowName=!0,a.state.allowParams=!0),a.state.allowName&&""!==a.name&&("indexed"===a.name?(t||i(n),a.indexed&&i(n),a.indexed=!0,a.name=""):yw(a.type,a.name)?a.name="":a.state.allowName=!1);break;case"[":a.state.allowArray||i(n),a.type+=r,a.state.allowArray=!1,a.state.allowName=!1,a.state.readArray=!0;break;case"]":a.state.readArray||i(n),a.type+=r,a.state.readArray=!1,a.state.allowArray=!0,a.state.allowName=!0;break;default:a.state.allowType?(a.type+=r,a.state.allowParams=!0,a.state.allowArray=!0):a.state.allowName?(a.name+=r,delete a.state.allowArray):a.state.readArray?a.type+=r:i(n)}}return a.parent&&mw.throwArgumentError("unexpected eof","param",e),delete r.state,"indexed"===a.name?(t||i(n.length-7),a.indexed&&i(n.length-7),a.indexed=!0,a.name=""):yw(a.type,a.name)&&(a.name=""),r.type=Pw(r.type),r}(e,!!t),Cw.fromObject({name:n.name,type:n.type,indexed:n.indexed,components:n.components});var n}static isParamType(e){return!(null==e||!e._isParamType)}}function ww(e,t){return function(e){e=e.trim();let t=[],n="",i=0;for(let o=0;o<e.length;o++){let r=e[o];","===r&&0===i?(t.push(n),n=""):(n+=r,"("===r?i++:")"===r&&(i--,-1===i&&mw.throwArgumentError("unbalanced parenthesis","value",e)))}n&&t.push(n);return t}(e).map((e=>Cw.fromString(e,t)))}class kw{constructor(e,t){e!==gw&&mw.throwError("use a static from method",Nh.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),vw(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return kw.isFragment(e)?e:"string"==typeof e?kw.fromString(e):kw.fromObject(e)}static fromObject(e){if(kw.isFragment(e))return e;switch(e.type){case"function":return Ow.fromObject(e);case"event":return Tw.fromObject(e);case"constructor":return Aw.fromObject(e);case"error":return Rw.fromObject(e);case"fallback":case"receive":return null}return mw.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Tw.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?Ow.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?Aw.fromString(e.trim()):"error"===e.split(" ")[0]?Rw.fromString(e.substring(5).trim()):mw.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class Tw extends kw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==bw.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ",e!==bw.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?Tw.fromString(e):Tw.fromObject(e)}static fromObject(e){if(Tw.isEventFragment(e))return e;"event"!==e.type&&mw.throwArgumentError("invalid event object","value",e);const t={name:Mw(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Cw.fromObject):[],type:"event"};return new Tw(gw,t)}static fromString(e){let t=e.match(Bw);t||mw.throwArgumentError("invalid event string","value",e);let n=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":n=!0;break;case"":break;default:mw.warn("unknown modifier: "+e)}})),Tw.fromObject({name:t[1].trim(),anonymous:n,inputs:ww(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function Iw(e,t){t.gas=null;let n=e.split("@");return 1!==n.length?(n.length>2&&mw.throwArgumentError("invalid human-readable ABI signature","value",e),n[1].match(/^[0-9]+$/)||mw.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=$t.from(n[1]),n[0]):e}function Sw(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function Ew(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&mw.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&mw.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||mw.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&mw.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&mw.throwArgumentError("unable to determine stateMutability","value",e),t}class Aw extends kw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===bw.sighash&&mw.throwError("cannot format a constructor for sighash",Nh.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?Aw.fromString(e):Aw.fromObject(e)}static fromObject(e){if(Aw.isConstructorFragment(e))return e;"constructor"!==e.type&&mw.throwArgumentError("invalid constructor object","value",e);let t=Ew(e);t.constant&&mw.throwArgumentError("constructor cannot be constant","value",e);const n={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Cw.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?$t.from(e.gas):null};return new Aw(gw,n)}static fromString(e){let t={type:"constructor"},n=(e=Iw(e,t)).match(Bw);return n&&"constructor"===n[1].trim()||mw.throwArgumentError("invalid constructor string","value",e),t.inputs=ww(n[2].trim(),!1),Sw(n[3].trim(),t),Aw.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class Ow extends Aw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==bw.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ",e!==bw.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?Ow.fromString(e):Ow.fromObject(e)}static fromObject(e){if(Ow.isFunctionFragment(e))return e;"function"!==e.type&&mw.throwArgumentError("invalid function object","value",e);let t=Ew(e);const n={type:e.type,name:Mw(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(Cw.fromObject):[],outputs:e.outputs?e.outputs.map(Cw.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?$t.from(e.gas):null};return new Ow(gw,n)}static fromString(e){let t={type:"function"},n=(e=Iw(e,t)).split(" returns ");n.length>2&&mw.throwArgumentError("invalid function string","value",e);let i=n[0].match(Bw);if(i||mw.throwArgumentError("invalid function signature","value",e),t.name=i[1].trim(),t.name&&Mw(t.name),t.inputs=ww(i[2],!1),Sw(i[3].trim(),t),n.length>1){let i=n[1].match(Bw);""==i[1].trim()&&""==i[3].trim()||mw.throwArgumentError("unexpected tokens","value",e),t.outputs=ww(i[2],!1)}else t.outputs=[];return Ow.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function Lw(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||mw.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class Rw extends kw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==bw.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?Rw.fromString(e):Rw.fromObject(e)}static fromObject(e){if(Rw.isErrorFragment(e))return e;"error"!==e.type&&mw.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:Mw(e.name),inputs:e.inputs?e.inputs.map(Cw.fromObject):[]};return Lw(new Rw(gw,t))}static fromString(e){let t={type:"error"},n=e.match(Bw);return n||mw.throwArgumentError("invalid error signature","value",e),t.name=n[1].trim(),t.name&&Mw(t.name),t.inputs=ww(n[2],!1),Lw(Rw.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function Pw(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const _w=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Mw(e){return e&&e.match(_w)||mw.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const Bw=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Dw=new Nh(hw);class Nw{constructor(e,t,n,i){this.name=e,this.type=t,this.localName=n,this.dynamic=i}_throwError(e,t){Dw.throwArgumentError(e,this.localName,t)}}class Fw{constructor(e){aw(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return function(e){let t="0x";return e.forEach((e=>{t+=Qh(e).substring(2)})),t}(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData($h(e._data))}writeBytes(e){let t=Hh(e);const n=t.length%this.wordSize;return n&&(t=$h([t,this._padding.slice(n)])),this._writeData(t)}_getValue(e){let t=Hh($t.from(e));return t.length>this.wordSize&&Dw.throwError("value out-of-bounds",Nh.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=$h([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class Uw{constructor(e,t,n,i){aw(this,"_data",Hh(e)),aw(this,"wordSize",t||32),aw(this,"_coerceFunc",n),aw(this,"allowLoose",i),this._offset=0}get data(){return Qh(this._data)}get consumed(){return this._offset}static coerce(e,t){let n=e.match("^u?int([0-9]+)$");return n&&parseInt(n[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):Uw.coerce(e,t)}_peekBytes(e,t,n){let i=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&n&&this._offset+t<=this._data.length?i=t:Dw.throwError("data out-of-bounds",Nh.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(e){return new Uw(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let n=this._peekBytes(0,e,!!t);return this._offset+=n.length,n.slice(0,e)}readValue(){return $t.from(this.readBytes(this.wordSize))}}class qw extends Nw{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=sm(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return sm(Xh(e.readValue().toHexString(),20))}}class Vw extends Nw{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const Ww=new Nh(hw);function Hw(e,t,n){let i=null;if(Array.isArray(n))i=n;else if(n&&"object"==typeof n){let e={};i=t.map((t=>{const i=t.localName;return i||Ww.throwError("cannot encode object for signature with missing names",Nh.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]&&Ww.throwError("cannot encode object for signature with duplicate names",Nh.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]=!0,n[i]}))}else Ww.throwArgumentError("invalid tuple value","tuple",n);t.length!==i.length&&Ww.throwArgumentError("types/value length mismatch","tuple",n);let o=new Fw(e.wordSize),r=new Fw(e.wordSize),a=[];t.forEach(((e,t)=>{let n=i[t];if(e.dynamic){let t=r.length;e.encode(r,n);let i=o.writeUpdatableValue();a.push((e=>{i(e+t)}))}else e.encode(o,n)})),a.forEach((e=>{e(o.length)}));let s=e.appendWriter(o);return s+=e.appendWriter(r),s}function $w(e,t){let n=[],i=e.subReader(0);t.forEach((t=>{let o=null;if(t.dynamic){let n=e.readValue(),r=i.subReader(n.toNumber());try{o=t.decode(r)}catch(e){if(e.code===Nh.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}}else try{o=t.decode(e)}catch(e){if(e.code===Nh.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}null!=o&&n.push(o)}));const o=t.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});t.forEach(((e,t)=>{let i=e.localName;if(!i||1!==o[i])return;if("length"===i&&(i="_length"),null!=n[i])return;const r=n[t];r instanceof Error?Object.defineProperty(n,i,{enumerable:!0,get:()=>{throw r}}):n[i]=r}));for(let e=0;e<n.length;e++){const t=n[e];t instanceof Error&&Object.defineProperty(n,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(n)}class zw extends Nw{constructor(e,t,n){super("array",e.type+"["+(t>=0?t:"")+"]",n,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let n=this.length;-1===n&&(n=t.length,e.writeValue(t.length)),Ww.checkArgumentCount(t.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let e=0;e<t.length;e++)i.push(this.coder);return Hw(e,i,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&Ww.throwError("insufficient data length",Nh.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let n=[];for(let e=0;e<t;e++)n.push(new Vw(this.coder));return e.coerce(this.name,$w(e,n))}}class Zw extends Nw{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class Gw extends Nw{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Hh(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class Qw extends Gw{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Qh(super.decode(e)))}}class Yw extends Nw{constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let n=Hh(t);return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return e.coerce(this.name,Qh(e.readBytes(this.size)))}}class Kw extends Nw{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}class Xw extends Nw{constructor(e,t,n){const i=(t?"int":"uint")+8*e;super(i,i,n,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let n=$t.from(t),i=pm.mask(8*e.wordSize);if(this.signed){let e=i.mask(8*this.size-1);(n.gt(e)||n.lt(e.add(um).mul(dm)))&&this._throwError("value out-of-bounds",t)}else(n.lt(cm)||n.gt(i.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return n=n.toTwos(8*this.size).mask(8*this.size),this.signed&&(n=n.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(n)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class Jw extends Gw{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,ym(t))}decode(e){return vm(super.decode(e))}}class ek extends Nw{constructor(e,t){let n=!1;const i=[];e.forEach((e=>{e.dynamic&&(n=!0),i.push(e.type)}));super("tuple","tuple("+i.join(",")+")",t,n),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});return this.coders.forEach(((n,i)=>{let o=n.localName;o&&1===t[o]&&("length"===o&&(o="_length"),null==e[o]&&(e[o]=e[i]))})),Object.freeze(e)}encode(e,t){return Hw(e,this.coders,t)}decode(e){return e.coerce(this.name,$w(e,this.coders))}}const tk=new Nh(hw),nk=new RegExp(/^bytes([0-9]*)$/),ik=new RegExp(/^(u?int)([0-9]*)$/);const ok=new class{constructor(e){aw(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new qw(e.name);case"bool":return new Zw(e.name);case"string":return new Jw(e.name);case"bytes":return new Qw(e.name);case"array":return new zw(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new ek((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new Kw(e.name)}let t=e.type.match(ik);if(t){let n=parseInt(t[2]||"256");return(0===n||n>256||n%8!=0)&&tk.throwArgumentError("invalid "+t[1]+" bit length","param",e),new Xw(n/8,"int"===t[1],e.name)}if(t=e.type.match(nk),t){let n=parseInt(t[1]);return(0===n||n>32)&&tk.throwArgumentError("invalid bytes length","param",e),new Yw(n,e.name)}return tk.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new Uw(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new Fw(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(Cw.from(e))));return new ek(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&tk.throwError("types/values length mismatch",Nh.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const n=e.map((e=>this._getCoder(Cw.from(e)))),i=new ek(n,"_"),o=this._getWriter();return i.encode(o,t),o.data}decode(e,t,n){const i=e.map((e=>this._getCoder(Cw.from(e))));return new ek(i,"_").decode(this._getReader(Hh(t),n))}};function rk(e){return tm(ym(e))}const ak=new Nh(hw);class sk extends pw{}class lk extends pw{}class dk extends pw{}class ck extends pw{static isIndexed(e){return!(!e||!e._isIndexed)}}const uk={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function pk(e,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return n.error=t,n}class hk{constructor(e){let t=[];t="string"==typeof e?JSON.parse(e):e,aw(this,"fragments",t.map((e=>kw.from(e))).filter((e=>null!=e))),aw(this,"_abiCoder",sw(new.target,"getAbiCoder")()),aw(this,"functions",{}),aw(this,"errors",{}),aw(this,"events",{}),aw(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void ak.warn("duplicate definition - constructor"):void aw(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let n=e.format();t[n]?ak.warn("duplicate definition - "+n):t[n]=e})),this.deploy||aw(this,"deploy",Aw.from({payable:!1,type:"constructor"})),aw(this,"_isInterface",!0)}format(e){e||(e=bw.full),e===bw.sighash&&ak.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===bw.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return ok}static getAddress(e){return sm(e)}static getSighash(e){return Kh(rk(e.format()),0,4)}static getEventTopic(e){return rk(e.format())}getFunction(e){if(Zh(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];ak.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===n.length?ak.throwArgumentError("no matching function","name",t):n.length>1&&ak.throwArgumentError("multiple matching functions","name",t),this.functions[n[0]]}const t=this.functions[Ow.fromString(e).format()];return t||ak.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(Zh(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];ak.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===n.length?ak.throwArgumentError("no matching event","name",t):n.length>1&&ak.throwArgumentError("multiple matching events","name",t),this.events[n[0]]}const t=this.events[Tw.fromString(e).format()];return t||ak.throwArgumentError("no matching event","signature",e),t}getError(e){if(Zh(e)){const t=sw(this.constructor,"getSighash");for(const n in this.errors){if(e===t(this.errors[n]))return this.errors[n]}ak.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===n.length?ak.throwArgumentError("no matching error","name",t):n.length>1&&ak.throwArgumentError("multiple matching errors","name",t),this.errors[n[0]]}const t=this.errors[Ow.fromString(e).format()];return t||ak.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return sw(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),sw(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const n=Hh(t);return Qh(n.slice(0,4))!==this.getSighash(e)&&ak.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Qh(n)),this._decodeParams(e.inputs,n.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),Qh($h([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const n=Hh(t);return Qh(n.slice(0,4))!==this.getSighash(e)&&ak.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Qh(n)),this._decodeParams(e.inputs,n.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Qh($h([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let n=Hh(t),i=null,o="",r=null,a=null,s=null;switch(n.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,n)}catch(e){}break;case 4:{const e=Qh(n.slice(0,4)),t=uk[e];if(t)r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.signature,t.reason&&(i=r[0]),"Error"===a?o=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(r[0])}`:"Panic"===a&&(o=`; VM Exception while processing transaction: reverted with panic code ${r[0]}`);else try{const t=this.getError(e);r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.format()}catch(e){}break}}return ak.throwError("call revert exception"+o,Nh.errors.CALL_EXCEPTION,{method:e.format(),data:Qh(t),errorArgs:r,errorName:a,errorSignature:s,reason:i})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Qh(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&ak.throwError("too many arguments for "+e.format(),Nh.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let n=[];e.anonymous||n.push(this.getEventTopic(e));const i=(e,t)=>"string"===e.type?rk(t):"bytes"===e.type?tm(Qh(t)):("bool"===e.type&&"boolean"==typeof t&&(t=t?"0x01":"0x00"),e.type.match(/^u?int/)&&(t=$t.from(t).toHexString()),"address"===e.type&&this._abiCoder.encode(["address"],[t]),Xh(Qh(t),32));for(t.forEach(((t,o)=>{let r=e.inputs[o];r.indexed?null==t?n.push(null):"array"===r.baseType||"tuple"===r.baseType?ak.throwArgumentError("filtering with tuples or arrays not supported","contract."+r.name,t):Array.isArray(t)?n.push(t.map((e=>i(r,e)))):n.push(i(r,t)):null!=t&&ak.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+r.name,t)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const n=[],i=[],o=[];return e.anonymous||n.push(this.getEventTopic(e)),t.length!==e.inputs.length&&ak.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,r)=>{const a=t[r];if(e.indexed)if("string"===e.type)n.push(rk(a));else if("bytes"===e.type)n.push(tm(a));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");n.push(this._abiCoder.encode([e.type],[a]))}else i.push(e),o.push(a)})),{data:this._abiCoder.encode(i,o),topics:n}}decodeEventLog(e,t,n){if("string"==typeof e&&(e=this.getEvent(e)),null!=n&&!e.anonymous){let t=this.getEventTopic(e);Zh(n[0],32)&&n[0].toLowerCase()===t||ak.throwError("fragment/topic mismatch",Nh.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:n[0]}),n=n.slice(1)}let i=[],o=[],r=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(Cw.fromObject({type:"bytes32",name:e.name})),r.push(!0)):(i.push(e),r.push(!1)):(o.push(e),r.push(!1))}));let a=null!=n?this._abiCoder.decode(i,$h(n)):null,s=this._abiCoder.decode(o,t,!0),l=[],d=0,c=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==a)l[t]=new ck({_isIndexed:!0,hash:null});else if(r[t])l[t]=new ck({_isIndexed:!0,hash:a[c++]});else try{l[t]=a[c++]}catch(e){l[t]=e}else try{l[t]=s[d++]}catch(e){l[t]=e}if(e.name&&null==l[e.name]){const n=l[t];n instanceof Error?Object.defineProperty(l,e.name,{enumerable:!0,get:()=>{throw pk(`property ${JSON.stringify(e.name)}`,n)}}):l[e.name]=n}}));for(let e=0;e<l.length;e++){const t=l[e];t instanceof Error&&Object.defineProperty(l,e,{enumerable:!0,get:()=>{throw pk(`index ${e}`,t)}})}return Object.freeze(l)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new lk({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:$t.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new sk({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=Qh(e);let n=this.getError(t.substring(0,10).toLowerCase());return n?new dk({args:this._abiCoder.decode(n.inputs,"0x"+t.substring(10)),errorFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n)}):null}static isInterface(e){return!(!e||!e._isInterface)}}function mk({factoryAddress:e,tokenA:t,tokenB:n,fee:i,initCodeHashManualOverride:o,chainId:r}){const[a,s]=t.sortsBefore(n)?[t,n]:[n,t],l=Sm(["bytes"],[ok.encode(["address","address","uint24"],[a.address,s.address,i])]),d=null!=o?o:function(e){switch(e){case le.TAIKO:case le.ZETACHAIN:case le.ZETACHAIN_TESTNET:return"0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";case le.SEPOLIA:return"0x4509fa1e2d1989ac1632a56fe87c53e8d1e9d05847694e00f62b23e28cec98c4";default:return KC}}(r);return lm(e,l,d)}const gk=wn.BigInt(2),fk=[128,64,32,16,8,4,2,1].map((e=>[e,wn.exponentiate(gk,wn.BigInt(e))]));function xk(e,t){return wn.signedRightShift(wn.multiply(e,wn.BigInt(t)),wn.BigInt(128))}const yk=wn.exponentiate(wn.BigInt(2),wn.BigInt(32));class vk{constructor(){}static getSqrtRatioAtTick(e){kn(e>=vk.MIN_TICK&&e<=vk.MAX_TICK&&Number.isInteger(e),"TICK");const t=e<0?-1*e:e;let n=1&t?wn.BigInt("0xfffcb933bd6fad37aa2d162d1a594001"):wn.BigInt("0x100000000000000000000000000000000");return 2&t&&(n=xk(n,"0xfff97272373d413259a46990580e213a")),4&t&&(n=xk(n,"0xfff2e50f5f656932ef12357cf3c7fdcc")),8&t&&(n=xk(n,"0xffe5caca7e10e4e61c3624eaa0941cd0")),16&t&&(n=xk(n,"0xffcb9843d60f6159c9db58835c926644")),32&t&&(n=xk(n,"0xff973b41fa98c081472e6896dfb254c0")),64&t&&(n=xk(n,"0xff2ea16466c96a3843ec78b326b52861")),128&t&&(n=xk(n,"0xfe5dee046a99a2a811c461f1969c3053")),256&t&&(n=xk(n,"0xfcbe86c7900a88aedcffc83b479aa3a4")),512&t&&(n=xk(n,"0xf987a7253ac413176f2b074cf7815e54")),1024&t&&(n=xk(n,"0xf3392b0822b70005940c7a398e4b70f3")),2048&t&&(n=xk(n,"0xe7159475a2c29b7443b29c7fa6e889d9")),4096&t&&(n=xk(n,"0xd097f3bdfd2022b8845ad8f792aa5825")),8192&t&&(n=xk(n,"0xa9f746462d870fdf8a65dc1f90e061e5")),16384&t&&(n=xk(n,"0x70d869a156d2a1b890bb3df62baf32f7")),32768&t&&(n=xk(n,"0x31be135f97d08fd981231505542fcfa6")),65536&t&&(n=xk(n,"0x9aa508b5b7a84e1c677de54f3e99bc9")),131072&t&&(n=xk(n,"0x5d6af8dedb81196699c329225ee604")),262144&t&&(n=xk(n,"0x2216e584f5fa1ea926041bedfe98")),524288&t&&(n=xk(n,"0x48a170391f7dc42444e8fa2")),e>0&&(n=wn.divide(LC,n)),wn.greaterThan(wn.remainder(n,yk),tw)?wn.add(wn.divide(n,yk),nw):wn.divide(n,yk)}static getTickAtSqrtRatio(e){kn(wn.greaterThanOrEqual(e,vk.MIN_SQRT_RATIO)&&wn.lessThan(e,vk.MAX_SQRT_RATIO),"SQRT_RATIO");const t=wn.leftShift(e,wn.BigInt(32)),n=function(e){kn(wn.greaterThan(e,tw),"ZERO"),kn(wn.lessThanOrEqual(e,LC),"MAX");let t=0;for(const[n,i]of fk)wn.greaterThanOrEqual(e,i)&&(e=wn.signedRightShift(e,wn.BigInt(n)),t+=n);return t}(t);let i;i=wn.greaterThanOrEqual(wn.BigInt(n),wn.BigInt(128))?wn.signedRightShift(t,wn.BigInt(n-127)):wn.leftShift(t,wn.BigInt(127-n));let o=wn.leftShift(wn.subtract(wn.BigInt(n),wn.BigInt(128)),wn.BigInt(64));for(let e=0;e<14;e++){i=wn.signedRightShift(wn.multiply(i,i),wn.BigInt(127));const t=wn.signedRightShift(i,wn.BigInt(128));o=wn.bitwiseOr(o,wn.leftShift(t,wn.BigInt(63-e))),i=wn.signedRightShift(i,t)}const r=wn.multiply(o,wn.BigInt("255738958999603826347141")),a=wn.toNumber(wn.signedRightShift(wn.subtract(r,wn.BigInt("3402992956809132418596140100660247210")),wn.BigInt(128))),s=wn.toNumber(wn.signedRightShift(wn.add(r,wn.BigInt("291339464771989622907027621153398088495")),wn.BigInt(128)));return a===s?a:wn.lessThanOrEqual(vk.getSqrtRatioAtTick(s),e)?s:a}}vk.MIN_TICK=-887272,vk.MAX_TICK=-vk.MIN_TICK,vk.MIN_SQRT_RATIO=wn.BigInt("4295128739"),vk.MAX_SQRT_RATIO=wn.BigInt("1461446703485210103287273052203988822378723970342");class bk{constructor(){}static mulDivRoundingUp(e,t,n){const i=wn.multiply(e,t);let o=wn.divide(i,n);return wn.notEqual(wn.remainder(i,n),tw)&&(o=wn.add(o,nw)),o}}const jk=wn.subtract(wn.exponentiate(wn.BigInt(2),wn.BigInt(160)),nw);function Ck(e,t){const n=wn.multiply(e,t);return wn.bitwiseAnd(n,LC)}class wk{constructor(){}static getAmount0Delta(e,t,n,i){wn.greaterThan(e,t)&&([e,t]=[t,e]);const o=wn.leftShift(n,wn.BigInt(96)),r=wn.subtract(t,e);return i?bk.mulDivRoundingUp(bk.mulDivRoundingUp(o,r,t),nw,e):wn.divide(wn.divide(wn.multiply(o,r),t),e)}static getAmount1Delta(e,t,n,i){return wn.greaterThan(e,t)&&([e,t]=[t,e]),i?bk.mulDivRoundingUp(n,wn.subtract(t,e),iw):wn.divide(wn.multiply(n,wn.subtract(t,e)),iw)}static getNextSqrtPriceFromInput(e,t,n,i){return kn(wn.greaterThan(e,tw)),kn(wn.greaterThan(t,tw)),i?this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!0):this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!0)}static getNextSqrtPriceFromOutput(e,t,n,i){return kn(wn.greaterThan(e,tw)),kn(wn.greaterThan(t,tw)),i?this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!1):this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!1)}static getNextSqrtPriceFromAmount0RoundingUp(e,t,n,i){if(wn.equal(n,tw))return e;const o=wn.leftShift(t,wn.BigInt(96));if(i){let t=Ck(n,e);if(wn.equal(wn.divide(t,n),e)){const n=function(e,t){const n=wn.add(e,t);return wn.bitwiseAnd(n,LC)}(o,t);if(wn.greaterThanOrEqual(n,o))return bk.mulDivRoundingUp(o,e,n)}return bk.mulDivRoundingUp(o,nw,wn.add(wn.divide(o,e),n))}{let t=Ck(n,e);kn(wn.equal(wn.divide(t,n),e)),kn(wn.greaterThan(o,t));const i=wn.subtract(o,t);return bk.mulDivRoundingUp(o,e,i)}}static getNextSqrtPriceFromAmount1RoundingDown(e,t,n,i){if(i){const i=wn.lessThanOrEqual(n,jk)?wn.divide(wn.leftShift(n,wn.BigInt(96)),t):wn.divide(wn.multiply(n,iw),t);return wn.add(e,i)}{const i=bk.mulDivRoundingUp(n,iw,t);return kn(wn.greaterThan(e,i)),wn.subtract(e,i)}}}const kk=wn.exponentiate(wn.BigInt(10),wn.BigInt(6));class Tk{constructor(){}static computeSwapStep(e,t,n,i,o){const r={};o=wn.BigInt(o);const a=wn.greaterThanOrEqual(e,t),s=wn.greaterThanOrEqual(i,tw);if(s){const s=wn.divide(wn.multiply(i,wn.subtract(kk,o)),kk);r.amountIn=a?wk.getAmount0Delta(t,e,n,!0):wk.getAmount1Delta(e,t,n,!0),wn.greaterThanOrEqual(s,r.amountIn)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=wk.getNextSqrtPriceFromInput(e,n,s,a)}else r.amountOut=a?wk.getAmount1Delta(t,e,n,!1):wk.getAmount0Delta(e,t,n,!1),wn.greaterThanOrEqual(wn.multiply(i,ew),r.amountOut)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=wk.getNextSqrtPriceFromOutput(e,n,wn.multiply(i,ew),a);const l=wn.equal(t,r.sqrtRatioNextX96);return a?(r.amountIn=l&&s?r.amountIn:wk.getAmount0Delta(r.sqrtRatioNextX96,e,n,!0),r.amountOut=l&&!s?r.amountOut:wk.getAmount1Delta(r.sqrtRatioNextX96,e,n,!1)):(r.amountIn=l&&s?r.amountIn:wk.getAmount1Delta(e,r.sqrtRatioNextX96,n,!0),r.amountOut=l&&!s?r.amountOut:wk.getAmount0Delta(e,r.sqrtRatioNextX96,n,!1)),!s&&wn.greaterThan(r.amountOut,wn.multiply(i,ew))&&(r.amountOut=wn.multiply(i,ew)),s&&wn.notEqual(r.sqrtRatioNextX96,t)?r.feeAmount=wn.subtract(i,r.amountIn):r.feeAmount=bk.mulDivRoundingUp(r.amountIn,o,wn.subtract(kk,o)),[r.sqrtRatioNextX96,r.amountIn,r.amountOut,r.feeAmount]}}class Ik{constructor(){}static addDelta(e,t){return wn.lessThan(t,tw)?wn.subtract(e,wn.multiply(t,ew)):wn.add(e,t)}}class Sk{getTick(e){return Vn(this,void 0,void 0,(function*(){throw new Error(Sk.ERROR_MESSAGE)}))}nextInitializedTickWithinOneWord(e,t,n){return Vn(this,void 0,void 0,(function*(){throw new Error(Sk.ERROR_MESSAGE)}))}}function Ek(e,t){return e.index-t.index}Sk.ERROR_MESSAGE="No tick data provider was given";class Ak{constructor(){}static validateList(e,t){kn(t>0,"TICK_SPACING_NONZERO"),kn(e.every((({index:e})=>e%t==0)),"TICK_SPACING"),kn(wn.equal(e.reduce(((e,{liquidityNet:t})=>wn.add(e,t)),tw),tw),"ZERO_NET"),kn(function(e,t){for(let n=0;n<e.length-1;n++)if(t(e[n],e[n+1])>0)return!1;return!0}(e,Ek),"SORTED")}static isBelowSmallest(e,t){return kn(e.length>0,"LENGTH"),t<e[0].index}static isAtOrAboveLargest(e,t){return kn(e.length>0,"LENGTH"),t>=e[e.length-1].index}static getTick(e,t){const n=e[this.binarySearch(e,t)];return kn(n.index===t,"NOT_CONTAINED"),n}static binarySearch(e,t){kn(!this.isBelowSmallest(e,t),"BELOW_SMALLEST");let n,i=0,o=e.length-1;for(;;){if(n=Math.floor((i+o)/2),e[n].index<=t&&(n===e.length-1||e[n+1].index>t))return n;e[n].index<t?i=n+1:o=n-1}}static nextInitializedTick(e,t,n){if(n){if(kn(!Ak.isBelowSmallest(e,t),"BELOW_SMALLEST"),Ak.isAtOrAboveLargest(e,t))return e[e.length-1];return e[this.binarySearch(e,t)]}if(kn(!this.isAtOrAboveLargest(e,t),"AT_OR_ABOVE_LARGEST"),this.isBelowSmallest(e,t))return e[0];return e[this.binarySearch(e,t)+1]}static nextInitializedTickWithinOneWord(e,t,n,i){const o=Math.floor(t/i);if(n){const r=(o>>8<<8)*i;if(Ak.isBelowSmallest(e,t))return[r,!1];const a=Ak.nextInitializedTick(e,t,n).index,s=Math.max(r,a);return[s,s===a]}{const r=(((o+1>>8)+1<<8)-1)*i;if(this.isAtOrAboveLargest(e,t))return[r,!1];const a=this.nextInitializedTick(e,t,n).index,s=Math.min(r,a);return[s,s===a]}}}function Ok(e){let t=wn.BigInt(e).toString(16);return t.length%2!=0&&(t=`0${t}`),`0x${t}`}function Lk(e,t){const n=wn.leftShift(wn.BigInt(e),wn.BigInt(192)),i=wn.BigInt(t);return function(e){if(kn(wn.greaterThanOrEqual(e,$C),"NEGATIVE"),wn.lessThan(e,HC))return wn.BigInt(Math.floor(Math.sqrt(wn.toNumber(e))));let t,n;for(t=e,n=wn.add(wn.divide(e,ZC),zC);wn.lessThan(n,t);)t=n,n=wn.divide(wn.add(wn.divide(e,n),n),ZC);return t}(wn.divide(n,i))}function Rk(e,t,n){wn.greaterThan(e,t)&&([e,t]=[t,e]);const i=wn.divide(wn.multiply(e,t),iw);return wn.divide(wn.multiply(wn.BigInt(n),i),wn.subtract(t,e))}function Pk(e,t,n){wn.greaterThan(e,t)&&([e,t]=[t,e]);const i=wn.multiply(wn.multiply(wn.BigInt(n),e),t),o=wn.multiply(iw,wn.subtract(t,e));return wn.divide(i,o)}function _k(e,t,n){return wn.greaterThan(e,t)&&([e,t]=[t,e]),wn.divide(wn.multiply(wn.BigInt(n),iw),wn.subtract(t,e))}function Mk(e,t,n,i,o,r){wn.greaterThan(t,n)&&([t,n]=[n,t]);const a=r?Pk:Rk;if(wn.lessThanOrEqual(e,t))return a(t,n,i);if(wn.lessThan(e,n)){const r=a(e,n,i),s=_k(t,e,o);return wn.lessThan(r,s)?r:s}return _k(t,n,o)}function Bk(e,t){kn(Number.isInteger(e)&&Number.isInteger(t),"INTEGERS"),kn(t>0,"TICK_SPACING"),kn(e>=vk.MIN_TICK&&e<=vk.MAX_TICK,"TICK_BOUND");const n=Math.round(e/t)*t;return n<vk.MIN_TICK?n+t:n>vk.MAX_TICK?n-t:n}function Dk(e,t,n){const i=vk.getSqrtRatioAtTick(n),o=wn.multiply(i,i);return e.sortsBefore(t)?new FC(e,t,ow,o):new FC(e,t,o,ow)}function Nk(e){const t=e.baseCurrency.sortsBefore(e.quoteCurrency),n=t?Lk(e.numerator,e.denominator):Lk(e.denominator,e.numerator);let i=vk.getTickAtSqrtRatio(n);const o=Dk(e.baseCurrency,e.quoteCurrency,i+1);return t?e.lessThan(o)||i++:e.greaterThan(o)||i++,i}wn.exponentiate(wn.BigInt(2),wn.BigInt(128)),wn.exponentiate(wn.BigInt(2),wn.BigInt(256));class Fk{constructor({index:e,liquidityGross:t,liquidityNet:n}){kn(e>=vk.MIN_TICK&&e<=vk.MAX_TICK,"TICK"),this.index=e,this.liquidityGross=wn.BigInt(t),this.liquidityNet=wn.BigInt(n)}}class Uk{constructor(e,t){const n=e.map((e=>e instanceof Fk?e:new Fk(e)));Ak.validateList(n,t),this.ticks=n}getTick(e){return Vn(this,void 0,void 0,(function*(){return Ak.getTick(this.ticks,e)}))}nextInitializedTickWithinOneWord(e,t,n){return Vn(this,void 0,void 0,(function*(){return Ak.nextInitializedTickWithinOneWord(this.ticks,e,t,n)}))}}const qk=new Sk;let Vk=class e{static getAddress(e,t,n,i,o){return mk({factoryAddress:null!=o?o:"0x78172691DD3B8ADa7aEbd9bFfB487FB11D735DB2",fee:n,tokenA:e,tokenB:t,initCodeHashManualOverride:i})}constructor(e,t,n,i,o,r,a=qk){kn(Number.isInteger(n)&&n<1e6,"FEE");const s=vk.getSqrtRatioAtTick(r),l=vk.getSqrtRatioAtTick(r+1);kn(wn.greaterThanOrEqual(wn.BigInt(i),s)&&wn.lessThanOrEqual(wn.BigInt(i),l),"PRICE_BOUNDS"),[this.token0,this.token1]=e.sortsBefore(t)?[e,t]:[t,e],this.fee=n,this.sqrtRatioX96=wn.BigInt(i),this.liquidity=wn.BigInt(o),this.tickCurrent=r,this.tickDataProvider=Array.isArray(a)?new Uk(a,JC[n]):a}involvesToken(e){return e.equals(this.token0)||e.equals(this.token1)}get token0Price(){var e;return null!==(e=this._token0Price)&&void 0!==e?e:this._token0Price=new FC(this.token0,this.token1,ow,wn.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}get token1Price(){var e;return null!==(e=this._token1Price)&&void 0!==e?e:this._token1Price=new FC(this.token1,this.token0,wn.multiply(this.sqrtRatioX96,this.sqrtRatioX96),ow)}priceOf(e){return kn(this.involvesToken(e),"TOKEN"),e.equals(this.token0)?this.token0Price:this.token1Price}get chainId(){return this.token0.chainId}getOutputAmount(t,n){return Vn(this,void 0,void 0,(function*(){kn(this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token0),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,t.quotient,n),l=i?this.token1:this.token0;return[MC.fromRawAmount(l,wn.multiply(o,ew)),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}getInputAmount(t,n){return Vn(this,void 0,void 0,(function*(){kn(t.currency.isToken&&this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token1),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,wn.multiply(t.quotient,ew),n),l=i?this.token0:this.token1;return[MC.fromRawAmount(l,o),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}swap(e,t,n){return Vn(this,void 0,void 0,(function*(){return function(e,t,n,i,o,r,a,s,l){return Vn(this,void 0,void 0,(function*(){l||(l=a?wn.add(vk.MIN_SQRT_RATIO,nw):wn.subtract(vk.MAX_SQRT_RATIO,nw)),a?(kn(wn.greaterThan(l,vk.MIN_SQRT_RATIO),"RATIO_MIN"),kn(wn.lessThan(l,t),"RATIO_CURRENT")):(kn(wn.lessThan(l,vk.MAX_SQRT_RATIO),"RATIO_MAX"),kn(wn.greaterThan(l,t),"RATIO_CURRENT"));const d=wn.greaterThanOrEqual(s,tw),c={amountSpecifiedRemaining:s,amountCalculated:tw,sqrtPriceX96:t,tick:n,liquidity:i};for(;wn.notEqual(c.amountSpecifiedRemaining,tw)&&c.sqrtPriceX96!==l;){let t={};if(t.sqrtPriceStartX96=c.sqrtPriceX96,[t.tickNext,t.initialized]=yield r.nextInitializedTickWithinOneWord(c.tick,a,o),t.tickNext<vk.MIN_TICK?t.tickNext=vk.MIN_TICK:t.tickNext>vk.MAX_TICK&&(t.tickNext=vk.MAX_TICK),t.sqrtPriceNextX96=vk.getSqrtRatioAtTick(t.tickNext),[c.sqrtPriceX96,t.amountIn,t.amountOut,t.feeAmount]=Tk.computeSwapStep(c.sqrtPriceX96,(a?wn.lessThan(t.sqrtPriceNextX96,l):wn.greaterThan(t.sqrtPriceNextX96,l))?l:t.sqrtPriceNextX96,c.liquidity,c.amountSpecifiedRemaining,e),d?(c.amountSpecifiedRemaining=wn.subtract(c.amountSpecifiedRemaining,wn.add(t.amountIn,t.feeAmount)),c.amountCalculated=wn.subtract(c.amountCalculated,t.amountOut)):(c.amountSpecifiedRemaining=wn.add(c.amountSpecifiedRemaining,t.amountOut),c.amountCalculated=wn.add(c.amountCalculated,wn.add(t.amountIn,t.feeAmount))),wn.equal(c.sqrtPriceX96,t.sqrtPriceNextX96)){if(t.initialized){let e=wn.BigInt((yield r.getTick(t.tickNext)).liquidityNet);a&&(e=wn.multiply(e,ew)),c.liquidity=Ik.addDelta(c.liquidity,e)}c.tick=a?t.tickNext-1:t.tickNext}else wn.notEqual(c.sqrtPriceX96,t.sqrtPriceStartX96)&&(c.tick=vk.getTickAtSqrtRatio(c.sqrtPriceX96))}return{amountCalculated:c.amountCalculated,sqrtRatioX96:c.sqrtPriceX96,liquidity:c.liquidity,tickCurrent:c.tick}}))}(wn.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,t,n)}))}get tickSpacing(){return JC[this.fee]}};class Wk{constructor({pool:e,liquidity:t,tickLower:n,tickUpper:i}){this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,kn(n<i,"TICK_ORDER"),kn(n>=vk.MIN_TICK&&n%e.tickSpacing==0,"TICK_LOWER"),kn(i<=vk.MAX_TICK&&i%e.tickSpacing==0,"TICK_UPPER"),this.pool=e,this.tickLower=n,this.tickUpper=i,this.liquidity=wn.BigInt(t)}get token0PriceLower(){return Dk(this.pool.token0,this.pool.token1,this.tickLower)}get token0PriceUpper(){return Dk(this.pool.token0,this.pool.token1,this.tickUpper)}get amount0(){return null===this._token0Amount&&(this.pool.tickCurrent<this.tickLower?this._token0Amount=MC.fromRawAmount(this.pool.token0,wk.getAmount0Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this.pool.tickCurrent<this.tickUpper?this._token0Amount=MC.fromRawAmount(this.pool.token0,wk.getAmount0Delta(this.pool.sqrtRatioX96,vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this._token0Amount=MC.fromRawAmount(this.pool.token0,tw)),this._token0Amount}get amount1(){return null===this._token1Amount&&(this.pool.tickCurrent<this.tickLower?this._token1Amount=MC.fromRawAmount(this.pool.token1,tw):this.pool.tickCurrent<this.tickUpper?this._token1Amount=MC.fromRawAmount(this.pool.token1,wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!1)):this._token1Amount=MC.fromRawAmount(this.pool.token1,wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}ratiosAfterSlippage(e){const t=this.pool.token0Price.asFraction.multiply(new NC(1).subtract(e)),n=this.pool.token0Price.asFraction.multiply(e.add(1));let i=Lk(t.numerator,t.denominator);wn.lessThanOrEqual(i,vk.MIN_SQRT_RATIO)&&(i=wn.add(vk.MIN_SQRT_RATIO,wn.BigInt(1)));let o=Lk(n.numerator,n.denominator);return wn.greaterThanOrEqual(o,vk.MAX_SQRT_RATIO)&&(o=wn.subtract(vk.MAX_SQRT_RATIO,wn.BigInt(1))),{sqrtRatioX96Lower:i,sqrtRatioX96Upper:o}}mintAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,n,0,vk.getTickAtSqrtRatio(n)),o=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,t,0,vk.getTickAtSqrtRatio(t)),r=Wk.fromAmounts(Object.assign(Object.assign({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts),{useFullPrecision:!1})),{amount0:a}=new Wk({pool:o,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts,{amount1:s}=new Wk({pool:i,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts;return{amount0:a,amount1:s}}burnAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,n,0,vk.getTickAtSqrtRatio(n)),o=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,t,0,vk.getTickAtSqrtRatio(t)),r=new Wk({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,a=new Wk({pool:i,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:r.quotient,amount1:a.quotient}}get mintAmounts(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:wk.getAmount0Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:tw}:this.pool.tickCurrent<this.tickUpper?{amount0:wk.getAmount0Delta(this.pool.sqrtRatioX96,vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:tw,amount1:wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}static fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:o,useFullPrecision:r}){const a=vk.getSqrtRatioAtTick(t),s=vk.getSqrtRatioAtTick(n);return new Wk({pool:e,tickLower:t,tickUpper:n,liquidity:Mk(e.sqrtRatioX96,a,s,i,o,r)})}static fromAmount0({pool:e,tickLower:t,tickUpper:n,amount0:i,useFullPrecision:o}){return Wk.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:LC,useFullPrecision:o})}static fromAmount1({pool:e,tickLower:t,tickUpper:n,amount1:i}){return Wk.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:LC,amount1:i,useFullPrecision:!0})}}var Hk=[{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"}];class $k{constructor(){}static encodeMulticall(e){return Array.isArray(e)||(e=[e]),1===e.length?e[0]:$k.INTERFACE.encodeFunctionData("multicall",[e])}static decodeMulticall(e){return $k.INTERFACE.decodeFunctionData("multicall",e).data}}$k.INTERFACE=new hk(Hk);var zk=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"},{internalType:"address",name:"_tokenDescriptor_",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"address",name:"recipient",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"Collect",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"DecreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"IncreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint128",name:"amount0Max",type:"uint128"},{internalType:"uint128",name:"amount1Max",type:"uint128"}],internalType:"struct INonfungiblePositionManager.CollectParams",name:"params",type:"tuple"}],name:"collect",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceX96",type:"uint160"}],name:"createAndInitializePoolIfNecessary",outputs:[{internalType:"address",name:"pool",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.DecreaseLiquidityParams",name:"params",type:"tuple"}],name:"decreaseLiquidity",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.IncreaseLiquidityParams",name:"params",type:"tuple"}],name:"increaseLiquidity",outputs:[{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.MintParams",name:"params",type:"tuple"}],name:"mint",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"positions",outputs:[{internalType:"uint96",name:"nonce",type:"uint96"},{internalType:"address",name:"operator",type:"address"},{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"feeGrowthInside0LastX128",type:"uint256"},{internalType:"uint256",name:"feeGrowthInside1LastX128",type:"uint256"},{internalType:"uint128",name:"tokensOwed0",type:"uint128"},{internalType:"uint128",name:"tokensOwed1",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount0Owed",type:"uint256"},{internalType:"uint256",name:"amount1Owed",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"uniswapV3MintCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],Zk=[{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"}];class Gk{constructor(){}static encodeFeeBips(e){return Ok(e.multiply(1e4).quotient)}static encodeUnwrapWETH9(e,t,n){if(t=qC(t),n){const i=this.encodeFeeBips(n.fee),o=qC(n.recipient);return Gk.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[Ok(e),t,i,o])}return Gk.INTERFACE.encodeFunctionData("unwrapWETH9",[Ok(e),t])}static encodeSweepToken(e,t,n,i){if(n=qC(n),i){const o=this.encodeFeeBips(i.fee),r=qC(i.recipient);return Gk.INTERFACE.encodeFunctionData("sweepTokenWithFee",[e.address,Ok(t),n,o,r])}return Gk.INTERFACE.encodeFunctionData("sweepToken",[e.address,Ok(t),n])}static encodeRefundETH(){return Gk.INTERFACE.encodeFunctionData("refundETH")}}Gk.INTERFACE=new hk(Zk);var Qk=[{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"}];class Yk{constructor(){}static encodePermit(e,t){return"nonce"in t?Yk.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,Ok(t.nonce),Ok(t.expiry),t.v,t.r,t.s]):Yk.INTERFACE.encodeFunctionData("selfPermit",[e.address,Ok(t.amount),Ok(t.deadline),t.v,t.r,t.s])}}Yk.INTERFACE=new hk(Qk);const Kk=Ok(wn.subtract(wn.exponentiate(wn.BigInt(2),wn.BigInt(128)),wn.BigInt(1)));function Xk(e){return Object.keys(e).some((e=>"recipient"===e))}const Jk={Permit:[{name:"spender",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};class eT{constructor(){}static encodeCreate(e){return eT.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,Ok(e.sqrtRatioX96)])}static createCallParameters(e){return{calldata:this.encodeCreate(e),value:Ok(0)}}static addCallParameters(e,t){kn(wn.greaterThan(e.liquidity,tw),"ZERO_LIQUIDITY");const n=[],{amount0:i,amount1:o}=e.mintAmounts,r=e.mintAmountsWithSlippage(t.slippageTolerance),a=Ok(r.amount0),s=Ok(r.amount1),l=Ok(t.deadline);if(Xk(t)&&t.createPool&&n.push(this.encodeCreate(e.pool)),t.token0Permit&&n.push(Yk.encodePermit(e.pool.token0,t.token0Permit)),t.token1Permit&&n.push(Yk.encodePermit(e.pool.token1,t.token1Permit)),Xk(t)){const r=qC(t.recipient);n.push(eT.INTERFACE.encodeFunctionData("mint",[{token0:e.pool.token0.address,token1:e.pool.token1.address,fee:e.pool.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0Desired:Ok(i),amount1Desired:Ok(o),amount0Min:a,amount1Min:s,recipient:r,deadline:l}]))}else n.push(eT.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:Ok(t.tokenId),amount0Desired:Ok(i),amount1Desired:Ok(o),amount0Min:a,amount1Min:s,deadline:l}]));let d=Ok(0);if(t.useNative){const r=t.useNative.wrapped;kn(e.pool.token0.equals(r)||e.pool.token1.equals(r),"NO_WETH");const a=e.pool.token0.equals(r)?i:o;wn.greaterThan(a,tw)&&n.push(Gk.encodeRefundETH()),d=Ok(a)}return{calldata:$k.encodeMulticall(n),value:d}}static encodeCollect(e){const t=[],n=Ok(e.tokenId),i=e.expectedCurrencyOwed0.currency.isNative||e.expectedCurrencyOwed1.currency.isNative,o=qC(e.recipient);if(t.push(eT.INTERFACE.encodeFunctionData("collect",[{tokenId:n,recipient:i?"0x0000000000000000000000000000000000000000":o,amount0Max:Kk,amount1Max:Kk}])),i){const n=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed0.quotient:e.expectedCurrencyOwed1.quotient,i=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.currency:e.expectedCurrencyOwed0.currency,r=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.quotient:e.expectedCurrencyOwed0.quotient;t.push(Gk.encodeUnwrapWETH9(n,o)),t.push(Gk.encodeSweepToken(i,r,o))}return t}static collectCallParameters(e){const t=eT.encodeCollect(e);return{calldata:$k.encodeMulticall(t),value:Ok(0)}}static removeCallParameters(e,t){const n=[],i=Ok(t.deadline),o=Ok(t.tokenId),r=new Wk({pool:e.pool,liquidity:t.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});kn(wn.greaterThan(r.liquidity,tw),"ZERO_LIQUIDITY");const{amount0:a,amount1:s}=r.burnAmountsWithSlippage(t.slippageTolerance);t.permit&&n.push(eT.INTERFACE.encodeFunctionData("permit",[qC(t.permit.spender),o,Ok(t.permit.deadline),t.permit.v,t.permit.r,t.permit.s])),n.push(eT.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:o,liquidity:Ok(r.liquidity),amount0Min:Ok(a),amount1Min:Ok(s),deadline:i}]));const l=t.collectOptions,{expectedCurrencyOwed0:d,expectedCurrencyOwed1:c}=l,u=qn(l,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return n.push(...eT.encodeCollect(Object.assign({tokenId:Ok(t.tokenId),expectedCurrencyOwed0:d.add(MC.fromRawAmount(d.currency,a)),expectedCurrencyOwed1:c.add(MC.fromRawAmount(c.currency,s))},u))),t.liquidityPercentage.equalTo(nw)?t.burnToken&&n.push(eT.INTERFACE.encodeFunctionData("burn",[o])):kn(!0!==t.burnToken,"CANNOT_BURN"),{calldata:$k.encodeMulticall(n),value:Ok(0)}}static safeTransferFromParameters(e){const t=qC(e.recipient),n=qC(e.sender);let i;return i=e.data?eT.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[n,t,Ok(e.tokenId),e.data]):eT.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[n,t,Ok(e.tokenId)]),{calldata:i,value:Ok(0)}}static getPermitData(e,t,n){return{domain:{name:"Uniswap V3 Positions NFT-V1",chainId:n,version:"1",verifyingContract:t},types:Jk,values:e}}}eT.INTERFACE=new hk(zk);var tT=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactInputSingleParams",name:"params",type:"tuple"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactOutputSingleParams",name:"params",type:"tuple"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}];new hk([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}]),new hk(tT);new hk([{inputs:[{internalType:"contract IUniswapV3Factory",name:"_factory",type:"address"},{internalType:"contract INonfungiblePositionManager",name:"_nonfungiblePositionManager",type:"address"},{internalType:"uint256",name:"_maxIncentiveStartLeadTime",type:"uint256"},{internalType:"uint256",name:"_maxIncentiveDuration",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"oldOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"DepositTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{indexed:!0,internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"},{indexed:!1,internalType:"address",name:"refundee",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"IncentiveCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"refund",type:"uint256"}],name:"IncentiveEnded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"RewardClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"}],name:"TokenStaked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"TokenUnstaked",type:"event"},{inputs:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountRequested",type:"uint256"}],name:"claimReward",outputs:[{internalType:"uint256",name:"reward",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"reward",type:"uint256"}],name:"createIncentive",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"deposits",outputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint48",name:"numberOfStakes",type:"uint48"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"}],name:"endIncentive",outputs:[{internalType:"uint256",name:"refund",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"contract IUniswapV3Factory",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getRewardInfo",outputs:[{internalType:"uint256",name:"reward",type:"uint256"},{internalType:"uint160",name:"secondsInsideX128",type:"uint160"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"incentives",outputs:[{internalType:"uint256",name:"totalRewardUnclaimed",type:"uint256"},{internalType:"uint160",name:"totalSecondsClaimedX128",type:"uint160"},{internalType:"uint96",name:"numberOfStakes",type:"uint96"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveStartLeadTime",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"nonfungiblePositionManager",outputs:[{internalType:"contract INonfungiblePositionManager",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20Minimal",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"rewards",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"stakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"stakes",outputs:[{internalType:"uint160",name:"secondsPerLiquidityInsideInitialX128",type:"uint160"},{internalType:"uint128",name:"liquidity",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"transferDeposit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"unstakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"withdrawToken",outputs:[],stateMutability:"nonpayable",type:"function"}]);function nT({removed:e,inRange:t}){const n=a(),o={py:4,px:8,color:n.palette.success.main,borderRadius:4,backgroundColor:T(n.palette.success.main,.1),typography:"h6"};return e?Yn.jsx(l,{title:se._({id:"MZPP7t",message:"Your position has 0 liquidity, and is not earning fees."}),maxWidth:240,children:Yn.jsx(i,{sx:Object.assign(Object.assign({},o),{color:n.palette.warning.main,backgroundColor:T(n.palette.warning.main,.1)}),children:se._({id:"D87pha",message:"Closed"})})}):t?Yn.jsx(l,{title:se._({id:"aIvv/z",message:"The price of this pool is within your selected range. Your position is currently earning fees."}),maxWidth:240,children:Yn.jsx(i,{sx:o,children:se._({id:"vOyUlD",message:"In range"})})}):Yn.jsx(l,{title:se._({id:"IwiTcw",message:"The price of this pool is outside of your selected range. Your position is not currently earning fees."}),maxWidth:240,children:Yn.jsx(i,{sx:Object.assign(Object.assign({},o),{color:n.palette.error.main,backgroundColor:T(n.palette.error.main,.1)}),children:se._({id:"i3Z+/Z",message:"Out of range"})})})}new hk([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"}],internalType:"struct ISwapRouter.ExactInputParams",name:"params",type:"tuple"}],name:"exactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactInputSingleParams",name:"params",type:"tuple"}],name:"exactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"}],internalType:"struct ISwapRouter.ExactOutputParams",name:"params",type:"tuple"}],name:"exactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactOutputSingleParams",name:"params",type:"tuple"}],name:"exactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}]);const iT=({token:e,amount:t})=>{var n;const o=a();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(Df,{address:null!==(n=null==e?void 0:e.address)&&void 0!==n?n:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:18,height:18,marginRight:0}),Yn.jsxs(i,{sx:{typography:"body1",color:o.palette.text.primary},children:[Am({input:t.toSignificant(),decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),Yn.jsx(d,{sx:{display:"flex",alignItems:"center",color:o.palette.text.secondary,"&:hover":{color:o.palette.text.primary}},onClick:()=>{window.open(tg(e.chainId,null==e?void 0:e.address,"address"))},children:Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{opacity:"0.5",fillRule:"evenodd",clipRule:"evenodd",d:"M3.33333 3.33333V12.6667H12.6667V8H14V12.6667C14 13.4 13.4 14 12.6667 14H3.33333C2.59333 14 2 13.4 2 12.6667V3.33333C2 2.6 2.59333 2 3.33333 2H8V3.33333H3.33333ZM9.33333 3.33333V2H14V6.66667H12.6667V4.27333L6.11333 10.8267L5.17333 9.88667L11.7267 3.33333H9.33333Z",fill:"currentColor"})})})]})},oT=({position:t,inRange:n})=>{var o;const r=a(),s=t.pool.token0,l=t.pool.token1,c=t.pool.chainId,u=(null==t?void 0:t.liquidity)&&wn.equal(null==t?void 0:t.liquidity,wn.BigInt(0)),p=$((()=>Vk.getAddress(t.pool.token0,t.pool.token1,t.pool.fee,void 0,c?SC[c]:void 0)),[c,t.pool.fee,t.pool.token0,t.pool.token1]);return Yn.jsxs(i,{sx:{border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:r.spacing(12,20),borderBottomStyle:"solid",borderBottomColor:"border.main",borderBottomWidth:1},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[Yn.jsxs(i,{sx:{typography:"body2",color:r.palette.text.primary},children:[se._({id:"PVa3KL",message:"Position on"})," ",null==s?void 0:s.symbol,"/",null==l?void 0:l.symbol]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(nT,{removed:u,inRange:n}),Yn.jsx(i,{sx:{py:4,px:8,color:r.palette.text.secondary,borderRadius:4,backgroundColor:r.palette.background.tag,typography:"h6"},children:Vm({input:(null===(o=null==t?void 0:t.pool)||void 0===o?void 0:o.fee)/1e6})})]})]}),Yn.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:0,typography:"body2",color:r.palette.text.secondary,"&:hover":{color:r.palette.text.primary}},onClick:()=>{window.open(tg(c,p,"address"))},children:[se._({id:"URmyfc",message:"Details"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M7.5 5L6.4425 6.0575L9.8775 9.5L6.4425 12.9425L7.5 14L12 9.5L7.5 5Z",fill:"currentColor"})})]})]}),Yn.jsxs(i,{sx:{p:r.spacing(12,20)},children:[Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),Yn.jsxs(i,{sx:{mt:12},children:[Yn.jsx(iT,{token:s,amount:t.amount0}),Yn.jsx(iT,{token:l,amount:t.amount1})]})]})]})};function rT({price:e,atLimit:t,direction:n}){return t[n]?n===dC.LOWER?"0":"∞":"string"==typeof e&&"∞"===e?"∞":Am({input:"string"==typeof e?e:null==e?void 0:e.toSignificant()})}const aT=({baseToken:e,quoteToken:t,handleRateToggle:n,sx:o})=>{const r=a(),s=null==e?void 0:e.wrapped,l=null==t?void 0:t.wrapped,c=s&&l&&s.sortsBefore(l);return Yn.jsx(i,{component:d,onClick:n,sx:Object.assign({display:"flex",alignItems:"center",p:1,borderRadius:8,backgroundColor:r.palette.border.main},o),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",width:"100%",[r.breakpoints.up("tablet")]:{width:"auto"}},children:[Yn.jsx(i,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},c?{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}:{color:r.palette.text.secondary,backgroundColor:"transparent"}),children:c?e.symbol:null==t?void 0:t.symbol}),Yn.jsx(i,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},c?{color:r.palette.text.secondary,backgroundColor:"transparent"}:{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}),children:c?t.symbol:null==e?void 0:e.symbol})]})})},sT=({position:t,title:n,baseCurrencyDefault:o,ticksAtLimit:r})=>{const s=t.pool.token0,l=t.pool.token1,d=a(),[c,u]=z(o?o===s?s:o===l?l:s:s),p=c===s,h=p?l:s,m=p?t.pool.priceOf(t.pool.token0):t.pool.priceOf(t.pool.token1),g=p?t.token0PriceLower:t.token0PriceUpper.invert(),f=p?t.token0PriceUpper:t.token0PriceLower.invert(),x=Z((()=>{u(h)}),[h]);return Yn.jsxs(fC,{gap:"md",children:[Yn.jsxs(yC,{children:[n?Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:d.palette.text.secondary},children:n}):Yn.jsx("div",{}),Yn.jsx(aT,{baseToken:p?s:l,quoteToken:p?l:s,handleRateToggle:x})]}),Yn.jsxs(yC,{children:[Yn.jsxs(hC,{sx:{width:"48%",py:12,gap:12},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:[Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"body2"},children:Yn.jsx(e,{id:"EQs1sJ",message:"Min price"})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"caption"},children:rT({price:g,atLimit:r,direction:dC.LOWER})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==c?void 0:c.symbol}})})]}),Yn.jsxs(hC,{sx:{width:"48%",py:12,gap:12},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:[Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"body2"},children:Yn.jsx(e,{id:"5etEUX",message:"Max price"})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"caption"},children:rT({price:f,atLimit:r,direction:dC.UPPER})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==h?void 0:h.symbol}})})]})]}),Yn.jsxs(hC,{sx:{py:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(fC,{gap:"4px",justify:"flex-start",children:[Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"body2"},children:Yn.jsx(e,{id:"DWd30U",message:"Current price"})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"caption"},children:`${Am({input:m.toSignificant()})} `})]})]})},lT=({chainId:e,disabled:t,removed:n,isLoading:i,error:o,onConfirm:r})=>Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:e,children:Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:r,disabled:t,isLoading:i,children:n?se._({id:"D87pha",message:"Closed"}):null!=o?o:se._({id:"t/YqKh",message:"Remove"})})}),dT={[XC.LOWEST]:{label:"0.01%"},[XC.LOW_200]:{label:"0.02%"},[XC.LOW_300]:{label:"0.03%"},[XC.LOW_400]:{label:"0.04%"},[XC.LOW]:{label:"0.05%"},[XC.MEDIUM]:{label:"0.30%"},[XC.HIGH]:{label:"1.00%"}},cT=({poolType:e})=>{const t="AMM V2"===e?N.error.main:"AMM V3"===e?N.purple.main:N.success.main;return Yn.jsx(i,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:T(t,.1),color:t,whiteSpace:"nowrap"},children:e})},uT=({isAMMV2:t,isAMMV3:n,lpFeeRate:o,mtFeeRate:r})=>{var a,s;return Yn.jsx(l,{title:Yn.jsx(e,{id:"O6RUgz",message:"Fee rate"}),children:Yn.jsx(i,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:n?null!==(s=null===(a=dT[o])||void 0===a?void 0:a.label)&&void 0!==s?s:"-":Vm({input:new Pe(null!=o?o:0).plus(r?_m(r,t?4:18):0)})})})},pT=({sx:e})=>Yn.jsx(cT,{poolType:"AMM V3"}),hT=({position:t,title:n,inRange:o,baseCurrencyDefault:r,ticksAtLimit:a})=>{var s,l,d;const c=t.pool.token0,u=t.pool.token1,p=(null==t?void 0:t.liquidity)&&wn.equal(null==t?void 0:t.liquidity,wn.BigInt(0));return Yn.jsxs(fC,{gap:"md",style:{marginTop:"0.5rem"},children:[Yn.jsxs(yC,{style:{gap:4},children:[Yn.jsxs(vC,{children:[Yn.jsx(kj,{tokens:[{address:c.address},{address:u.address}],mr:8,chainId:c.chainId}),Yn.jsxs(i,{sx:{typography:"h5"},children:[null==c?void 0:c.symbol," / ",null==u?void 0:u.symbol]})]}),Yn.jsx(pT,{sx:{ml:"auto"}}),Yn.jsx(nT,{removed:p,inRange:o})]}),Yn.jsxs(hC,{children:[Yn.jsxs(fC,{gap:"md",children:[Yn.jsxs(yC,{children:[Yn.jsxs(vC,{children:[Yn.jsx(Df,{address:null!==(s=null==c?void 0:c.address)&&void 0!==s?s:"",chainId:null==c?void 0:c.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),Yn.jsx(i,{sx:{ml:8},children:null==c?void 0:c.symbol})]}),Yn.jsx(vC,{children:Yn.jsx(i,{sx:{mr:8},children:Am({input:t.amount0.toSignificant(),decimals:null==c?void 0:c.decimals})})})]}),Yn.jsxs(yC,{children:[Yn.jsxs(vC,{children:[Yn.jsx(Df,{address:null!==(l=null==u?void 0:u.address)&&void 0!==l?l:"",chainId:null==u?void 0:u.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),Yn.jsx(i,{ml:"8px",children:null==u?void 0:u.symbol})]}),Yn.jsx(vC,{children:Yn.jsx(i,{mr:"8px",children:Am({input:t.amount1.toSignificant(),decimals:null==u?void 0:u.decimals})})})]})]}),Yn.jsxs(yC,{children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"EU3wU4",message:"Fee tier"})}),Yn.jsx(i,{children:Vm({input:(null===(d=null==t?void 0:t.pool)||void 0===d?void 0:d.fee)/1e6})})]})]}),Yn.jsx(sT,{position:t,title:n,baseCurrencyDefault:r,ticksAtLimit:a})]})},mT=({on:e,onClose:t,position:n,outOfRange:o,ticksAtLimit:r,onConfirm:a,loading:s})=>{const{isMobile:l}=Tg();return Yn.jsx(Of,{open:e,onClose:t,modal:!0,title:se._({id:"E6MqGy",message:"Add liquidity"}),height:683,children:Yn.jsxs(i,{sx:{flex:1,px:20,pb:24,display:"flex",flexDirection:"column",justifyContent:"space-between",width:l?void 0:420},children:[Yn.jsx(i,{sx:{pt:0,px:0},children:n?Yn.jsx(hT,{position:n,inRange:!o,ticksAtLimit:r,title:se._({id:"3VUfrF",message:"Selected Range"})}):null}),Yn.jsx(c,{size:c.Size.big,fullWidth:!0,isLoading:s,sx:{mt:20},onClick:a,children:se._({id:"m16xKo",message:"Add"})})]})})};class gT{static getPoolAddress(e,t,n,i,o){this.addresses.length>this.MAX_ENTRIES&&(this.addresses=this.addresses.slice(0,this.MAX_ENTRIES/2));const{address:r}=t,{address:a}=n,s=`${e}:${r}:${a}:${i.toString()}`,l=this.addresses.find((e=>e.key===s));if(l)return l.address;const d={key:s,address:mk({factoryAddress:e,tokenA:t,tokenB:n,fee:i,chainId:o})};return this.addresses.unshift(d),d.address}static getPool(e,t,n,i,o,r){this.pools.length>this.MAX_ENTRIES&&(this.pools=this.pools.slice(0,this.MAX_ENTRIES/2));const a=this.pools.find((a=>a.token0===e&&a.token1===t&&a.fee===n&&wn.EQ(a.sqrtRatioX96,i)&&wn.EQ(a.liquidity,o)&&a.tickCurrent===r));if(a)return a;const s=new Vk(e,t,n,i,o,r);return this.pools.unshift(s),s}}var fT;function xT(e,t,n){const i=$((()=>[[e,t,n]]),[e,t,n]);return function(e,t){const n=$((()=>e?t.map((([e,t,n])=>{if(e&&t&&n){const i=e.wrapped,o=t.wrapped;if(i.equals(o))return;return i.sortsBefore(o)?[i,o,n]:[o,i,n]}})):new Array(t.length)),[e,t]),i=$((()=>{const t=e&&SC[e];return t?n.map((n=>n&&gT.getPoolAddress(t,...n,e))):new Array(n.length)}),[e,n]),{data:o}=tt({queries:i.map((t=>zm.getV3PoolSlot0(e,t))),combine:e=>({data:e.map((e=>e.data))})}),{data:r}=tt({queries:i.map((t=>zm.getV3PoolLiquidity(e,t))),combine:e=>({data:e.map((e=>e.data))})});return $((()=>t.map(((e,t)=>{const i=n[t];if(!i)return[fT.INVALID,null];const[a,s,l]=i;if(!o[t])return[fT.NOT_EXISTS,null];const d=o[t];if(!r[t])return[fT.NOT_EXISTS,null];const c=r[t];if(!d||!c)return[fT.NOT_EXISTS,null];if(!d.sqrtPriceX96||d.sqrtPriceX96.eq(0))return[fT.NOT_EXISTS,null];try{const e=gT.getPool(a,s,l,d.sqrtPriceX96,c[0],d.tick);return[fT.EXISTS,e]}catch(e){return console.error(e,{tags:{file:"usePools",function:"usePools"},extra:{token0:a.address,token1:s.address,chainId:a.chainId,fee:l}}),[fT.NOT_EXISTS,null]}}))),[r,t,o,n])}(null==e?void 0:e.chainId,i)[0]}gT.MAX_ENTRIES=128,gT.pools=[],gT.addresses=[],function(e){e[e.LOADING=0]="LOADING",e[e.NOT_EXISTS=1]="NOT_EXISTS",e[e.EXISTS=2]="EXISTS",e[e.INVALID=3]="INVALID"}(fT||(fT={}));class yT{constructor(e){const t=we[e];this.chainId=e,this.decimals=t.decimals,this.name=t.name,this.symbol=t.symbol,this.isNative=!0,this.isToken=!1,this.address=vT(this.chainId)}equals(e){return e.isNative&&e.chainId===this.chainId}get wrapped(){const e=we[this.chainId];return new WC(this.chainId,e.wrappedTokenAddress,e.decimals,e.wrappedTokenSymbol,e.name)}static onChain(e){var t;return null!==(t=this._cachedNativeCurrency[e])&&void 0!==t?t:this._cachedNativeCurrency[e]=new yT(e)}}function vT(e){return we[e].address}function bT(e,t){const n=null==e?void 0:e.toLowerCase(),i=null==t?void 0:t.toLowerCase();return null!==n&&null!==i&&n===i}yT._cachedNativeCurrency={};const jT=(e,t)=>!t||bT(t,vT(e));function CT(e){if(!e)return;const{name:t,chainId:n,address:i,decimals:o,symbol:r}=e;return function(e,t){return!jT(e,t)}(n,i)?new WC(n,i,o,null!=r?r:void 0,null!=t?t:void 0):new yT(n)}function wT(e){var t,n;if(e)return{chainId:e.chainId,address:e.address,decimals:e.decimals,symbol:null!==(t=e.symbol)&&void 0!==t?t:"",name:null!==(n=e.name)&&void 0!==n?n:""}}function kT(e,t,n){if(e&&t&&"number"==typeof n)return Dk(e,t,n)}function TT(e,t){if(e&&t&&!isNaN(parseFloat(e)))try{const n=Tn(function(e,t){const n=e.split(/[.,]/),i=e.includes(".")?".":",";return n.length>1&&n[1].length>t?n[0]+i+n[1].slice(0,t):e}(e,t.decimals),t.decimals).toString();if("0"!==n)return MC.fromRawAmount(t,wn.BigInt(n))}catch(t){console.error("tryParseCurrencyAmount","tryParseCurrencyAmount",`Failed to parse input amount: "${e}"`,t)}}function IT(e,t,n,i){if(!(e&&t&&n&&i))return;const o=function(e,t,n){var i;if(!e||!t||!n)return;if(!n.match(/^\d*\.?\d+$/))return;const[o,r]=n.split("."),a=null!==(i=null==r?void 0:r.length)&&void 0!==i?i:0,s=wn.BigInt((null!=o?o:"")+(null!=r?r:""));return new FC(e,t,wn.multiply(wn.BigInt(10**a),wn.BigInt(10**e.decimals)),wn.multiply(s,wn.BigInt(10**t.decimals)))}(e,t,i);if(!o)return;let r;const a=Lk(o.numerator,o.denominator);return r=wn.greaterThanOrEqual(a,vk.MAX_SQRT_RATIO)?vk.MAX_TICK:wn.lessThanOrEqual(a,vk.MIN_SQRT_RATIO)?vk.MIN_TICK:Nk(o),Bk(r,JC[n])}function ST({state:e,existingPosition:t,chainId:n}){var i,o,r,a,s,l,d,c,u,p,h,m,g;const{account:f}=dg(),{feeAmount:x,independentField:y,typedValue:v,leftRangeTypedValue:b,rightRangeTypedValue:j,startPriceTypedValue:C}=e,w=null!==(i=e.baseToken)&&void 0!==i?i:void 0,k=null!==(o=e.baseToken)&&void 0!==o?o:void 0,T=null!==(r=e.quoteToken)&&void 0!==r?r:void 0,I=y===lC.CURRENCY_A?lC.CURRENCY_B:lC.CURRENCY_A,S=$((()=>({[lC.CURRENCY_A]:w,[lC.CURRENCY_B]:T})),[w,T]),[E,A,O]=$((()=>[null==w?void 0:w.wrapped,null==T?void 0:T.wrapped,null==k?void 0:k.wrapped]),[w,T,k]),[L,R]=$((()=>E&&A?E.sortsBefore(A)?[E,A]:[A,E]:[void 0,void 0]),[E,A]),P=et(ip.getFetchTokenQuery(null===(a=S[lC.CURRENCY_A])||void 0===a?void 0:a.chainId,null===(s=S[lC.CURRENCY_A])||void 0===s?void 0:s.address,f)),_=et(ip.getFetchTokenQuery(null===(l=S[lC.CURRENCY_B])||void 0===l?void 0:l.chainId,null===(d=S[lC.CURRENCY_B])||void 0===d?void 0:d.address,f)),M=$((()=>{var e,t,n,i,o,r;return{[lC.CURRENCY_A]:S[lC.CURRENCY_A]?(null===(e=P.data)||void 0===e?void 0:e.balance)?MC.fromRawAmount(S[lC.CURRENCY_A],wn.BigInt(null===(t=P.data)||void 0===t?void 0:t.balance.multipliedBy(Math.pow(10,null!==(n=S[lC.CURRENCY_A].decimals)&&void 0!==n?n:18)).toString())):MC.fromRawAmount(S[lC.CURRENCY_A],0):void 0,[lC.CURRENCY_B]:S[lC.CURRENCY_B]?(null===(i=_.data)||void 0===i?void 0:i.balance)?MC.fromRawAmount(S[lC.CURRENCY_B],wn.BigInt(null===(o=_.data)||void 0===o?void 0:o.balance.multipliedBy(Math.pow(10,null!==(r=S[lC.CURRENCY_B].decimals)&&void 0!==r?r:18)).toString())):MC.fromRawAmount(S[lC.CURRENCY_B],0):void 0}}),[S,null===(c=P.data)||void 0===c?void 0:c.balance,null===(u=_.data)||void 0===u?void 0:u.balance]),[B,D]=xT(S[lC.CURRENCY_A],S[lC.CURRENCY_B],x),N=B===fT.NOT_EXISTS,F=Boolean(O&&L&&!O.equals(L)),U=$((()=>{var e;if(!N)return D&&L?D.priceOf(L):void 0;{const t=TT(C,F?L:R);if(t&&L&&R){const n=TT("1",F?R:L),i=n&&t?new FC(n.currency,t.currency,n.quotient,t.quotient):void 0;return null!==(e=F?null==i?void 0:i.invert():i)&&void 0!==e?e:void 0}}}),[N,C,F,R,L,D]),q=$((()=>{const e=U?Lk(U.numerator,U.denominator):void 0;return U&&e&&!(wn.greaterThanOrEqual(e,vk.MIN_SQRT_RATIO)&&wn.lessThan(e,vk.MAX_SQRT_RATIO))}),[U]),V=$((()=>{if(E&&A&&x&&U&&!q){const e=Nk(U),t=vk.getSqrtRatioAtTick(e);return new Vk(E,A,x,t,wn.BigInt(0),e,[])}}),[x,q,U,E,A]),W=null!=D?D:V,H=$((()=>({[dC.LOWER]:x?Bk(vk.MIN_TICK,JC[x]):void 0,[dC.UPPER]:x?Bk(vk.MAX_TICK,JC[x]):void 0})),[x]),Z=$((()=>({[dC.LOWER]:"number"==typeof(null==t?void 0:t.tickLower)?t.tickLower:F&&"boolean"==typeof j||!F&&"boolean"==typeof b?H[dC.LOWER]:F?IT(R,L,x,j.toString()):IT(L,R,x,b.toString()),[dC.UPPER]:"number"==typeof(null==t?void 0:t.tickUpper)?t.tickUpper:!F&&"boolean"==typeof j||F&&"boolean"==typeof b?H[dC.UPPER]:F?IT(R,L,x,b.toString()):IT(L,R,x,j.toString())})),[t,x,F,b,j,H,L,R]),{[dC.LOWER]:G,[dC.UPPER]:Q}=Z||{},Y=$((()=>({[dC.LOWER]:x&&G===H.LOWER,[dC.UPPER]:x&&Q===H.UPPER})),[H,G,Q,x]),K=Boolean("number"==typeof G&&"number"==typeof Q&&G>=Q),X=$((()=>({[dC.LOWER]:kT(L,R,H.LOWER),[dC.UPPER]:kT(L,R,H.UPPER)})),[L,R,H.LOWER,H.UPPER]),J=$((()=>({[dC.LOWER]:kT(L,R,Z[dC.LOWER]),[dC.UPPER]:kT(L,R,Z[dC.UPPER])})),[L,R,Z]),{[dC.LOWER]:ee,[dC.UPPER]:te}=J,ne=Boolean(!K&&U&&ee&&te&&(U.lessThan(ee)||U.greaterThan(te))),ie=TT(v,S[y]),oe=$((()=>{const e=null==ie?void 0:ie.wrapped,t=I===lC.CURRENCY_B?T:w;if(ie&&e&&"number"==typeof G&&"number"==typeof Q&&W){if(ne||K)return;const n=e.currency.equals(W.token0)?Wk.fromAmount0({pool:W,tickLower:G,tickUpper:Q,amount0:ie.quotient,useFullPrecision:!0}):Wk.fromAmount1({pool:W,tickLower:G,tickUpper:Q,amount1:ie.quotient}),i=e.currency.equals(W.token0)?n.amount1:n.amount0;return t&&MC.fromRawAmount(t,i.quotient)}}),[ie,ne,I,T,w,G,Q,W,K]),re=$((()=>({[lC.CURRENCY_A]:y===lC.CURRENCY_A?ie:oe,[lC.CURRENCY_B]:y===lC.CURRENCY_A?oe:ie})),[oe,ie,y]),ae=Boolean("number"==typeof Q&&W&&W.tickCurrent>=Q),le=Boolean("number"==typeof G&&W&&W.tickCurrent<=G),de=K||Boolean(ae&&W&&E&&W.token0.equals(E)||le&&W&&E&&W.token1.equals(E)),ce=K||Boolean(ae&&W&&A&&W.token0.equals(A)||le&&W&&A&&W.token1.equals(A)),{inputTax:ue,outputTax:pe}=function(e,t,n){const[{inputTax:i,outputTax:o},r]=z({inputTax:YC,outputTax:YC});return{inputTax:i,outputTax:o}}((null==w?void 0:w.isToken)&&w.address,(null==T?void 0:T.isToken)&&T.address),he=$((()=>{var e,t;if(!W||!E||!A||"number"!=typeof G||"number"!=typeof Q||K)return;const n=ae?GC:null===(e=null==re?void 0:re[E.equals(W.token0)?lC.CURRENCY_A:lC.CURRENCY_B])||void 0===e?void 0:e.quotient,i=le?GC:null===(t=null==re?void 0:re[E.equals(W.token0)?lC.CURRENCY_B:lC.CURRENCY_A])||void 0===t?void 0:t.quotient;return void 0!==n&&void 0!==i?Wk.fromAmounts({pool:W,tickLower:G,tickUpper:Q,amount0:n,amount1:i,useFullPrecision:!0}):void 0}),[re,W,E,A,ae,le,K,G,Q]);let me;f||(me=se._({id:"r7ScnQ",message:"Connect to a wallet"})),B===fT.INVALID&&(me=null!=me?me:se._({id:"R7D79P",message:"Invalid pair"})),q&&(me=null!=me?me:se._({id:"HXBqgG",message:"Invalid price input"})),(re[lC.CURRENCY_A]||de)&&(re[lC.CURRENCY_B]||ce)||(me=null!=me?me:se._({id:"iPMIoT",message:"Enter an amount"}));const{[lC.CURRENCY_A]:ge,[lC.CURRENCY_B]:fe}=re;ge&&(null===(p=null==M?void 0:M[lC.CURRENCY_A])||void 0===p?void 0:p.lessThan(ge))&&(me=se._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(h=S[lC.CURRENCY_A])||void 0===h?void 0:h.symbol}})),fe&&(null===(m=null==M?void 0:M[lC.CURRENCY_B])||void 0===m?void 0:m.lessThan(fe))&&(me=se._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(g=S[lC.CURRENCY_B])||void 0===g?void 0:g.symbol}}));const xe=ue.greaterThan(0)||pe.greaterThan(0),ye=B===fT.INVALID||xe;return{dependentField:I,currencies:S,pool:D,poolState:B,currencyBalances:M,parsedAmounts:re,ticks:Z,price:U,pricesAtTicks:J,pricesAtLimit:X,position:he,noLiquidity:N,errorMessage:me,invalidPool:ye,invalidRange:K,outOfRange:ne,depositADisabled:de,depositBDisabled:ce,invertPrice:F,ticksAtLimit:Y,isTaxed:xe}}var ET;function AT(e,t){switch(t.type){case ET.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:CT(n)})}case ET.UpdateDefaultBaseToken:{const n=t.payload;return e.baseToken?e:Object.assign(Object.assign({},e),{baseToken:CT(n)})}case ET.UpdateQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{quoteToken:CT(n)})}case ET.UpdateDefaultQuoteToken:{const n=t.payload;return e.quoteToken?e:Object.assign(Object.assign({},e),{quoteToken:CT(n)})}case ET.UpdateBaseTokenAndClearQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:CT(n),quoteToken:null})}case ET.UpdateFeeAmount:return Object.assign(Object.assign({},e),{feeAmount:t.payload});case ET.ToggleRate:{const{baseToken:t,quoteToken:n}=e;return Object.assign(Object.assign({},e),{baseToken:n,quoteToken:t})}case ET.setFullRange:return Object.assign(Object.assign({},e),{leftRangeTypedValue:!0,rightRangeTypedValue:!0});case ET.typeStartPriceInput:return Object.assign(Object.assign({},e),{startPriceTypedValue:t.payload.typedValue});case ET.typeLeftRangeInput:return Object.assign(Object.assign({},e),{leftRangeTypedValue:t.payload.typedValue});case ET.typeRightRangeInput:return Object.assign(Object.assign({},e),{rightRangeTypedValue:t.payload.typedValue});case ET.typeInput:{const{payload:{field:n,typedValue:i,noLiquidity:o}}=t;return o?(e.independentField,Object.assign(Object.assign({},e),{independentField:n,typedValue:i})):Object.assign(Object.assign({},e),{independentField:n,typedValue:i})}default:throw Error("Unknown action: "+t.type)}}function OT({noLiquidity:e,dispatch:t}){return{onFieldAInput:Z((n=>{t({type:ET.typeInput,payload:{field:lC.CURRENCY_A,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onFieldBInput:Z((n=>{t({type:ET.typeInput,payload:{field:lC.CURRENCY_B,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onLeftRangeInput:Z((e=>{t({type:ET.typeLeftRangeInput,payload:{typedValue:e}})}),[t]),onRightRangeInput:Z((e=>{t({type:ET.typeRightRangeInput,payload:{typedValue:e}})}),[t]),onStartPriceInput:Z((e=>{t({type:ET.typeStartPriceInput,payload:{typedValue:e}})}),[t])}}function LT(e){return e?EC[e]:void 0}function RT(e,t){const n=LT(t),i=$((()=>e?e.map((e=>[e])):[]),[e]),o=et(zm.getPositions(t,n,i)),r=o.isLoading,a=o.error,s=$((()=>{var t;if(!r&&!a&&e)return null===(t=o.data)||void 0===t?void 0:t.map(((t,n)=>({tokenId:e[n],fee:t.fee,feeGrowthInside0LastX128:t.feeGrowthInside0LastX128.toString(),feeGrowthInside1LastX128:t.feeGrowthInside1LastX128.toString(),liquidity:t.liquidity.toString(),nonce:t.nonce.toString(),operator:t.operator,tickLower:t.tickLower,tickUpper:t.tickUpper,token0:t.token0,token1:t.token1,tokensOwed0:t.tokensOwed0.toString(),tokensOwed1:t.tokensOwed1.toString()})))}),[r,a,o,e]);return{loading:r,positions:null==s?void 0:s.map(((e,t)=>Object.assign(Object.assign({},e),{tokenId:i[t][0]})))}}!function(e){e[e.UpdateBaseToken=0]="UpdateBaseToken",e[e.UpdateDefaultBaseToken=1]="UpdateDefaultBaseToken",e[e.UpdateQuoteToken=2]="UpdateQuoteToken",e[e.UpdateDefaultQuoteToken=3]="UpdateDefaultQuoteToken",e[e.UpdateBaseTokenAndClearQuoteToken=4]="UpdateBaseTokenAndClearQuoteToken",e[e.UpdateFeeAmount=5]="UpdateFeeAmount",e[e.ToggleRate=6]="ToggleRate",e[e.setFullRange=7]="setFullRange",e[e.typeStartPriceInput=8]="typeStartPriceInput",e[e.typeLeftRangeInput=9]="typeLeftRangeInput",e[e.typeRightRangeInput=10]="typeRightRangeInput",e[e.typeInput=11]="typeInput"}(ET||(ET={}));const PT=wn.exponentiate(wn.BigInt(10),wn.BigInt(16));function _T(e){if(e)return e.currency.isNative?wn.greaterThan(e.quotient,PT)?MC.fromRawAmount(e.currency,wn.subtract(e.quotient,PT)):MC.fromRawAmount(e.currency,wn.BigInt(0)):e}const MT=1e4,BT=100*MT;function DT(e){const t=Math.floor(Number(e)*MT);return new NC(t,BT)}const NT=({token:e,amount:t})=>{var n;const o=a();return Yn.jsxs(i,{sx:{py:8,display:"flex",alignItems:"center",gap:6,typography:"h5",color:o.palette.text.primary},children:[Yn.jsx(Df,{address:null!==(n=null==e?void 0:e.address)&&void 0!==n?n:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),Yn.jsx(i,{children:null==e?void 0:e.symbol}),Yn.jsx(i,{sx:{ml:"auto"},children:Am({input:null==t?void 0:t.toSignificant(),decimals:null==e?void 0:e.decimals})})]})},FT=({chainId:e,baseToken:t,quoteToken:n,feeAmount:o,tokenId:r,onClose:s})=>{var l,d;const{isMobile:c}=Tg(),u=a(),p=Fg(),h=nt(),{account:m}=dg(),{position:g,loading:f}=function(e,t){var n;const i=RT(e?[e]:void 0,t);return{loading:i.loading,position:null===(n=i.positions)||void 0===n?void 0:n[0]}}(r,e),x=!!g&&!f,{position:y}=function(e,t,n){const i=$((()=>t?CT(t):void 0),[t]),o=$((()=>n?CT(n):void 0),[n]),[,r]=xT(null!=i?i:void 0,null!=o?o:void 0,null==e?void 0:e.fee);let a;return r&&e&&(a=new Wk({pool:r,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})),{position:a,pool:null!=r?r:void 0}}(g,t,n),[v,b]=z("stake"),[j,C]=z(!1),[w,k]=z(aC),[T,I]=ee(AT,{baseToken:CT(t),quoteToken:CT(n),feeAmount:o,independentField:lC.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""}),{independentField:E,typedValue:A,startPriceTypedValue:L}=T,{pool:R,ticks:P,dependentField:_,price:M,pricesAtTicks:B,pricesAtLimit:D,parsedAmounts:N,currencyBalances:U,position:q,noLiquidity:V,currencies:W,errorMessage:H,invalidPool:Z,invalidRange:G,outOfRange:Q,depositADisabled:Y,depositBDisabled:K,invertPrice:X,ticksAtLimit:J,isTaxed:te}=ST({state:T,existingPosition:y,chainId:e}),{position:ne,liquidityPercentage:ie,liquidityValue0:oe,liquidityValue1:re,feeValue0:ae,feeValue1:le,error:de}=function({percent:e,position:t,asWETH:n,baseToken:i,quoteToken:o}){const{account:r}=dg(),[a,s]=$((()=>[null==i?void 0:i.wrapped,null==o?void 0:o.wrapped]),[i,o]),[l,d]=$((()=>a&&s?a.sortsBefore(s)?[a,s]:[s,a]:[void 0,void 0]),[a,s]),[,c]=xT(null!=l?l:void 0,null!=d?d:void 0,null==t?void 0:t.fee),u=$((()=>c&&(null==t?void 0:t.liquidity)&&"number"==typeof(null==t?void 0:t.tickLower)&&"number"==typeof(null==t?void 0:t.tickUpper)?new Wk({pool:c,liquidity:t.liquidity.toString(),tickLower:t.tickLower,tickUpper:t.tickUpper}):void 0),[c,t]),p=new NC(e,100),h=u?p.multiply(u.amount0.quotient).quotient:void 0,m=u?p.multiply(u.amount1.quotient).quotient:void 0,g=l&&h?MC.fromRawAmount(l,h):void 0,f=d&&m?MC.fromRawAmount(d,m):void 0,x=!(!c||!t)&&(c.tickCurrent<t.tickLower||c.tickCurrent>t.tickUpper);let y;return r||(y=se._({id:"r7ScnQ",message:"Connect to a wallet"})),0===e&&(y=null!=y?y:se._({id:"Sta9CR",message:"Enter a percent"})),{position:u,liquidityPercentage:p,liquidityValue0:g,liquidityValue1:f,feeValue0:void 0,feeValue1:void 0,outOfRange:x,error:y}}({position:g,asWETH:void 0,percent:w,baseToken:T.baseToken,quoteToken:T.quoteToken}),ce="0"===(null==g?void 0:g.liquidity),[ue,pe]=function({chainId:e,pool:t,tokenId:n,asWETH:i}){var o;const r=LT(e),a=null===(o=$t.from(n))||void 0===o?void 0:o.toHexString(),s=et(zm.getOwner(e,r,n)),l=et(zm.getCollect(e,r,a,s.data&&Array.isArray(s.data)?s.data[0]:void 0));return t&&l&&l.data&&l.data.amount0&&l.data.amount1?[MC.fromRawAmount(t.token0,l.data.amount0.toString()),MC.fromRawAmount(t.token1,l.data.amount1.toString())]:[void 0,void 0]}({pool:null!=R?R:void 0,tokenId:r,asWETH:!1,chainId:e}),he=pe,me=ue;$((()=>{var e;return null===(e=X?null==M?void 0:M.invert():M)||void 0===e?void 0:e.toSignificant()}),[X,M]);const{onFieldAInput:ge,onFieldBInput:fe,onLeftRangeInput:xe,onRightRangeInput:ye,onStartPriceInput:ve}=OT({noLiquidity:V,dispatch:I}),{slipper:be,setSlipper:je,slipperValue:Ce,resetSlipper:we}=oC({address:void 0,type:"AMMV3"}),Te=!H&&!G,Ie=$((()=>{var e,t;return{[E]:A,[_]:null!==(t=null===(e=N[_])||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""}}),[_,E,N,A]),Se=$((()=>[lC.CURRENCY_A,lC.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:_T(U[t])})),{})),[U]),Ee=lf(wT(null===(l=N[lC.CURRENCY_A])||void 0===l?void 0:l.currency),{contractAddress:EC[e],overrideBalance:U[lC.CURRENCY_A]?new Pe(U[lC.CURRENCY_A].toSignificant()):void 0,amount:N[lC.CURRENCY_A]?new Pe(N[lC.CURRENCY_A].toSignificant()):void 0}),Ae=lf(wT(null===(d=N[lC.CURRENCY_B])||void 0===d?void 0:d.currency),{contractAddress:EC[e],overrideBalance:U[lC.CURRENCY_B]?new Pe(U[lC.CURRENCY_B].toSignificant()):void 0,amount:N[lC.CURRENCY_B]?new Pe(N[lC.CURRENCY_B].toSignificant()):void 0}),{[dC.LOWER]:Oe,[dC.UPPER]:Le}=P,{[dC.LOWER]:Re,[dC.UPPER]:_e}=B,{deadLine:Me}=Jn(),Be=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(!m||!e||!q)return;if(!T.baseToken||!T.quoteToken)return;const t=Math.ceil(Date.now()/1e3)+(null!=Me?Me:600),n=T.baseToken.isNative?T.baseToken:T.quoteToken.isNative?T.quoteToken:void 0;try{const{calldata:i,value:o}=eT.addCallParameters(q,{tokenId:r,slippageTolerance:DT(100*Ce),deadline:t.toString(),useNative:n});let a={to:EC[e],data:i,value:o};(yield p.execute(se._({id:"OBdohg",message:"Add Liquidity"}),Object.assign({opcode:Pg.TX},a),{early:!1,metadata:{[Sg.addAMMV3Pool]:"1"}}))===Eg.Success&&(C(!1),setTimeout((()=>{null==s||s()}),100)),h.invalidateQueries({queryKey:[ke,"ammv3"],refetchType:"all"})}catch(e){console.error("onAddMutation",e)}}))}),De=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(!(m&&e&&ne&&ie&&oe&&re))return;const t=Math.ceil(Date.now()/1e3)+(null!=Me?Me:600);try{const{calldata:n,value:i}=eT.removeCallParameters(ne,{tokenId:r.toString(),liquidityPercentage:ie,slippageTolerance:DT(100*Ce),deadline:t.toString(),collectOptions:{expectedCurrencyOwed0:null!=ae?ae:MC.fromRawAmount(oe.currency,0),expectedCurrencyOwed1:null!=le?le:MC.fromRawAmount(re.currency,0),recipient:m}});let o={to:EC[e],data:n,value:i};(yield p.execute(se._({id:"3XBvkd",message:"Remove Liquidity"}),Object.assign({opcode:Pg.TX},o),{early:!1,metadata:{[Sg.removeAMMV3Pool]:"1"}}))===Eg.Success&&setTimeout((()=>{null==s||s()}),100),h.invalidateQueries({queryKey:[ke,"ammv3"],refetchType:"all"})}catch(e){console.error("onRemoveMutation",e)}}))}),Ne=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(m&&e&&R)try{const{calldata:t,value:n}=eT.collectCallParameters({tokenId:r.toString(),expectedCurrencyOwed0:null!=ue?ue:MC.fromRawAmount(R.token0,0),expectedCurrencyOwed1:null!=pe?pe:MC.fromRawAmount(R.token1,0),recipient:m});let i={to:EC[e],data:t,value:n};(yield p.execute(se._({id:"zXCpR0",message:"Claim Rewards"}),Object.assign({opcode:Pg.TX},i),{early:!1,metadata:{[Sg.claimAMMV3Pool]:"1"}}))===Eg.Success&&setTimeout((()=>{null==s||s()}),100),h.invalidateQueries({queryKey:[ke,"ammv3"],refetchType:"all"})}catch(e){console.error("onClaimMutation",e)}}))}),Fe=$((()=>{var t,n,o,r;const a=[{key:"stake",value:se._({id:"m16xKo",message:"Add"})},{key:"unstake",value:se._({id:"t/YqKh",message:"Remove"})},{key:"claim",value:se._({id:"hom7qf",message:"Claim"})}];return Yn.jsxs(i,{sx:{borderRadius:16,backgroundColor:u.palette.background.paper},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:u.palette.background.paper},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:se._({id:"E6MqGy",message:"Add liquidity"})}),s?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16},onClick:()=>{s()}})}):void 0]}),x&&y&&Yn.jsx(i,{sx:{mx:20,mb:16},children:Yn.jsx(oT,{position:y,inRange:!Q})}),Yn.jsxs(S,{value:v,onChange:(e,t)=>{b(t)},children:[Yn.jsx(F,{tabs:a,variant:"inPaper",tabsListSx:{mx:20}}),Yn.jsxs(O,{value:"stake",children:[x&&y&&Yn.jsx(i,{sx:{mt:16,mx:20},children:Yn.jsx(sT,{position:y,title:se._({id:"3VUfrF",message:"Selected Range"}),ticksAtLimit:J})}),Yn.jsxs(i,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.secondary,textAlign:"left"},children:se._({id:"BRi+RY",message:"Add more liquidity"})}),Yn.jsxs(i,{children:[Yn.jsx(IC,{value:Ie[lC.CURRENCY_A],onUserInput:ge,maxAmount:Se[lC.CURRENCY_A],balance:U[lC.CURRENCY_A],currency:null!==(t=W[lC.CURRENCY_A])&&void 0!==t?t:null,locked:Y}),Yn.jsx(uj,{}),Yn.jsx(IC,{value:Ie[lC.CURRENCY_B],onUserInput:fe,maxAmount:Se[lC.CURRENCY_B],balance:U[lC.CURRENCY_B],currency:null!==(n=W[lC.CURRENCY_B])&&void 0!==n?n:null,locked:K})]}),Yn.jsx(rC,{value:be,onChange:je,disabled:!1,type:"AMMV3"})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:u.palette.background.paper},children:Yn.jsx(jC,{chainId:e,approvalA:Ee,approvalB:Ae,parsedAmounts:N,isValid:Te,depositADisabled:Y,depositBDisabled:K,errorMessage:H,setShowConfirm:C})}),Yn.jsx(mT,{parsedAmounts:N,position:q,existingPosition:void 0,priceLower:Re,priceUpper:_e,outOfRange:Q,ticksAtLimit:J,on:j,onClose:()=>{C(!1)},onConfirm:Be.mutate,loading:Be.isPending})]}),Yn.jsxs(O,{value:"unstake",children:[Yn.jsxs(i,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[Yn.jsx(Kj,{disabled:!1,value:w,onChange:e=>k(e)}),Yn.jsx(rC,{value:be,onChange:je,disabled:!1,type:"AMMV3"})]}),Yn.jsxs(i,{sx:{mt:16,mx:20,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{typography:"body2",color:u.palette.text.secondary},children:"Receive"}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:[Yn.jsx(i,{component:"span",sx:{color:u.palette.primary.main},children:oe?Am({input:oe.toExact(),decimals:oe.currency.decimals}):"-"})," ",null===(o=null==oe?void 0:oe.currency)||void 0===o?void 0:o.symbol]}),Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:[Yn.jsx(i,{component:"span",sx:{color:u.palette.primary.main},children:re?Am({input:re.toExact(),decimals:re.currency.decimals}):"-"})," ",null===(r=null==re?void 0:re.currency)||void 0===r?void 0:r.symbol]})]})]}),Yn.jsx(i,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:u.palette.background.paper},children:Yn.jsx(lT,{chainId:e,disabled:ce||0===w||!oe,removed:ce,error:de,onConfirm:De.mutate,isLoading:De.isPending})})]}),Yn.jsxs(O,{value:"claim",children:[Yn.jsxs(i,{sx:{mx:20,mt:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:u.palette.border.main},children:[Yn.jsx(i,{sx:{py:12,px:20,typography:"body1",color:u.palette.text.primary,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:u.palette.border.main},children:se._({id:"tu/fxg",message:"Claim fees"})}),Yn.jsxs(i,{sx:{p:20},children:[Yn.jsx(NT,{token:null==he?void 0:he.currency,amount:he}),Yn.jsx(NT,{token:null==me?void 0:me.currency,amount:me})]})]}),Yn.jsx(i,{sx:{mx:20,mt:16,typography:"h6",color:u.palette.text.secondary},children:se._({id:"Joa5Dk",message:"*Collecting fees will withdraw currently available fees for you."})}),Yn.jsx(i,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:u.palette.background.paper},children:Yn.jsx(CC,{chainId:e,disabled:Ne.isPending,onConfirm:Ne.mutate,isLoading:Ne.isPending})})]})]})]})}),[Ee,Ae,e,W,U,Y,K,de,H,y,me,he,Ie,x,Te,oe,re,Se,Be.isPending,Be.mutate,Ne.isPending,Ne.mutate,s,ge,fe,De.isPending,De.mutate,v,Q,N,q,Re,_e,ce,je,j,w,be,u.palette.background.paper,u.palette.border.main,u.palette.primary.main,u.palette.text.primary,u.palette.text.secondary,J]);return c?Yn.jsx(Of,{open:null!=t&&null!=n,onClose:s,scope:!c,modal:c,id:"pool-operate",children:Fe}):Fe};const UT=({outOfRange:e})=>{const t=a();return Yn.jsx(l,{title:e?se._({id:"i3Z+/Z",message:"Out of range"}):se._({id:"vOyUlD",message:"In range"}),children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:e?Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.583252 12.5416L6.99992 1.45825L13.4166 12.5416H0.583252ZM11.3924 11.3749L6.9999 3.78575L2.6074 11.3749H11.3924ZM7.58328 9.62492H6.41661V10.7916H7.58328V9.62492ZM6.41661 6.12492H7.58328V8.45825H6.41661V6.12492Z",fill:t.palette.warning.main})}):Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:Yn.jsx("circle",{cx:"4",cy:"4",r:"4",fill:t.palette.success.main})})})})},qT=({p:e,currency0:t,currency1:n,onClickManage:o})=>{const r=a(),[,s]=xT(null!=t?t:void 0,null!=n?n:void 0,e.fee),l=$((()=>{if(s)return new Wk({pool:s,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})}),[e.liquidity,e.tickLower,e.tickUpper,s]),d=(u=e.fee,p=e.tickLower,h=e.tickUpper,$((()=>({[dC.LOWER]:u&&p?p===Bk(vk.MIN_TICK,JC[u]):void 0,[dC.UPPER]:u&&h?h===Bk(vk.MAX_TICK,JC[u]):void 0})),[u,p,h]));var u,p,h;const m=null==l?void 0:l.token0PriceLower,g=null==l?void 0:l.token0PriceUpper,f=null==l?void 0:l.amount1.currency,x=null==l?void 0:l.amount0.currency,y=!!s&&(s.tickCurrent<e.tickLower||s.tickCurrent>=e.tickUpper),v=t==t?null==l?void 0:l.pool.priceOf(null==l?void 0:l.pool.token0):null==l?void 0:l.pool.priceOf(null==l?void 0:l.pool.token1);return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,px:20,py:20,pb:12,borderRadius:12,backgroundColor:r.palette.background.paperContrast},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h5",color:r.palette.text.primary},children:[Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:m,atLimit:d,direction:dC.LOWER})," "]}),null==f?void 0:f.symbol]})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:g,atLimit:d,direction:dC.UPPER})," "]}),null==f?void 0:f.symbol]})})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(UT,{outOfRange:y}),Yn.jsxs(i,{sx:{typography:"h6",color:r.palette.text.secondary},children:[se._({id:"DWd30U",message:"Current price"}),": ",`${Am({input:null==v?void 0:v.toSignificant()})}`," ",null==f?void 0:f.symbol," per ",null==x?void 0:x.symbol]})]})]}),Yn.jsx(c,{variant:c.Variant.outlined,size:c.Size.small,fullWidth:!0,onClick:o,children:se._({id:"wckWOP",message:"Manage"})})]})},VT=({chainId:e,baseToken:t,quoteToken:n,feeAmount:o,onClose:r,handleGoToAddLiquidityV3:s})=>{const{isMobile:l}=Tg(),d=a(),{account:u}=dg(),{positions:p,loading:h}=function(e,t){const n=LT(t),{isLoading:i,data:o}=et(zm.getBalanceOf(t,n,null!=e?e:void 0)),r=$((()=>{if(e&&o&&o.isFinite()){const t=[];for(let n=0;n<o.toNumber();n++)t.push([e,n]);return t}return[]}),[e,o]),a=et(zm.getTokenOfOwnerByIndex(t,n,r)),s=a.isLoading,l=$((()=>e&&a.data?a.data.map((e=>{if(Array.isArray(e)&&e.length>0)return e[0].toString()})):[]),[e,a]),{positions:d,loading:c}=RT(l,t);return{loading:s||i||c,positions:d}}(u,e),m=$((()=>t?CT(t):void 0),[t]),g=$((()=>n?CT(n):void 0),[n]),[f,x]=$((()=>[null==m?void 0:m.wrapped,null==g?void 0:g.wrapped]),[m,g]),[y,v]=$((()=>f&&x?f.sortsBefore(x)?[f,x]:[x,f]:[void 0,void 0]),[f,x]),b=$((()=>{if(void 0!==p)return p.filter((e=>bT(null==y?void 0:y.address,e.token0)&&bT(null==v?void 0:v.address,e.token1)&&e.fee===o))}),[o,p,null==y?void 0:y.address,null==v?void 0:v.address]),[j,C]=z(null),w=$((()=>{var e;return Yn.jsxs(i,{sx:{p:20,display:"flex",flexDirection:"column",gap:16,borderRadius:16,backgroundColor:d.palette.background.paper,minHeight:480},children:[Yn.jsxs(i,{sx:{pb:16,borderBottomColor:d.palette.border.main,borderBottomStyle:"solid",borderBottomWidth:1,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:d.palette.text.primary},children:[se._({id:"Gs02OK",message:"My Positions"})," (",null!==(e=null==b?void 0:b.length)&&void 0!==e?e:0,")"]}),r?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16},onClick:()=>{r()}})}):void 0]}),b&&b.length>0?Yn.jsxs(Yn.Fragment,{children:[null==b?void 0:b.map((e=>Yn.jsx(qT,{p:e,currency0:m,currency1:g,onClickManage:()=>{C(e)}},e.tokenId))),Yn.jsxs(c,{size:c.Size.big,variant:c.Variant.second,onClick:()=>{s({from:t.address,to:n.address,fee:String(o)})},sx:{gap:8},children:[Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:Yn.jsx("path",{d:"M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z",fill:"currentColor"})}),se._({id:"FQ4aT9",message:"Add Position"})]})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{mt:100,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[Yn.jsx(ei,{sx:{width:60,height:60,borderRadius:24/105*60}}),Yn.jsx(i,{sx:{typography:"body1",color:d.palette.text.secondary},children:se._({id:"/6L4mj",message:"Your position is empty"})})]}),Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:void 0!==b&&0===b.length?Yn.jsx(c,{size:c.Size.small,onClick:()=>{s({from:t.address,to:n.address,fee:String(o)})},children:se._({id:"FQ4aT9",message:"Add Position"})}):Yn.jsx(cC,{size:c.Size.small})})]})]})}),[d.palette.background.paper,d.palette.border.main,d.palette.text.primary,d.palette.text.secondary,b,r,m,g,s,t.address,n.address,o]);return null!==j?Yn.jsx(FT,{baseToken:t,quoteToken:n,feeAmount:o,tokenId:j.tokenId,chainId:e,onClose:()=>{C(null)}}):l?Yn.jsx(Of,{open:null!=t&&null!=n,onClose:r,scope:!l,modal:l,id:"pool-operate",children:w}):w};function WT({children:e,sx:t,gap:n=20,repeatBaseForLargeScreen:o=3}){const{isMobile:r,minDevice:a}=Tg();let s={};if(r)s={display:"flex",flexDirection:"column",gap:n};else{let e=2;[1418,1761,2104].some(((t,n)=>{if(a(t))return e=o+n,!0})),s={display:"grid",gap:n,gridTemplateColumns:`repeat(${e}, 1fr)`}}return Yn.jsx(i,{sx:Object.assign(Object.assign({},s),t),children:e})}function HT({text:e,onClick:t}){const n=a();return Yn.jsxs(i,{sx:{typography:"body2",display:"inline-flex",alignItems:"center",p:n.spacing(0,4,0,8),width:"max-content",height:32,backgroundColor:"hover.default",color:"primary.main",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:t,children:[e,Yn.jsx(i,{component:li.ArrowBack,sx:{ml:2,width:16,height:16,transform:"rotate(180deg)"}})]})}function $T({tags:e,onDeleteTag:t,sx:n}){return e.length?Yn.jsx(i,{sx:Object.assign({display:"inline-flex",alignItems:"center"},n),children:e.map((e=>Yn.jsxs(i,{sx:{typography:"body2",display:"flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},children:[Yn.jsx(Df,{address:e.address,width:20,height:20,chainId:e.chainId,url:e.logoURI,noShowChain:!0,marginRight:8}),e.symbol,Yn.jsx(i,{component:li.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t(e)})]},e.address)))}):null}function zT({chainId:e,address:t,type:n=Zj.PoolDetail}){const{isMobile:o}=Tg();return Yn.jsx(i,{component:"button",onClick:i=>{i.stopPropagation(),Gj.getState().push({type:n,params:{chainId:e,address:t}})},sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,cursor:"pointer",flexShrink:0,color:"text.primary","&:hover":{opacity:.5}},o?{width:64,height:36,backgroundColor:"background.tag"}:{width:40,height:32,backgroundColor:"transparent",borderWidth:1,borderStyle:"solid",borderColor:"border.main"}),children:Yn.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.83333 14.1667H7.5V8.33333H5.83333V14.1667ZM9.16667 14.1667H10.8333V5.83333H9.16667V14.1667ZM12.5 14.1667H14.1667V10.8333H12.5V14.1667ZM4.16667 17.5C3.70833 17.5 3.31597 17.3368 2.98958 17.0104C2.66319 16.684 2.5 16.2917 2.5 15.8333V4.16667C2.5 3.70833 2.66319 3.31597 2.98958 2.98958C3.31597 2.66319 3.70833 2.5 4.16667 2.5H15.8333C16.2917 2.5 16.684 2.66319 17.0104 2.98958C17.3368 3.31597 17.5 3.70833 17.5 4.16667V15.8333C17.5 16.2917 17.3368 16.684 17.0104 17.0104C16.684 17.3368 16.2917 17.5 15.8333 17.5H4.16667ZM4.16667 15.8333H15.8333V4.16667H4.16667V15.8333Z",fill:"currentColor"})})})}function ZT(t){var{sx:n,children:o,empty:r,loading:s,hasMore:l,loadMore:c,loadMoreLoading:u}=t,p=qn(t,["sx","children","empty","loading","hasMore","loadMore","loadMoreLoading"]);const h=a();return Yn.jsxs(i,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",borderRadius:16},n),...p,children:[Yn.jsx(i,{component:"table",sx:Object.assign({width:"100%",borderCollapse:"collapse","& th":{px:24,py:12,typography:"h6",lineHeight:"20px",textAlign:"left",color:"text.secondary"},"& td":{px:24,py:12,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,backgroundColor:"background.tag"},"& tbody tr":{borderWidth:"1px 0px 1px 0px",borderStyle:"solid",borderColor:"border.main"}},!r&&!s&&{"& th:last-child, & td:last-child":{position:"sticky",right:0,zIndex:1,"&::before":{content:'""',position:"absolute",top:0,bottom:0,left:1,width:"1px",boxShadow:`${"dark"===h.palette.mode?"#1A1A1B":T("#1A1A1B",.1)} -2px 0px 4px 0px`}}}),children:o}),l&&Yn.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:c,children:u?Yn.jsx(L,{}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})})]})}function GT({sx:t}){const{supportAMMV2:n,supportAMMV3:o}=Jn(),r=n||o;return Yn.jsxs(i,{sx:Object.assign({px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},t),children:[Yn.jsx(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(kj,{width:24,tokens:[],mr:6,showChainLogo:!0}),Yn.jsx(j,{variant:"rounded",height:20,width:88})]})}),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[r&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:Yn.jsx(j,{variant:"rounded",height:24,width:100})}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})})]}),Yn.jsxs(i,{children:[Yn.jsx(j,{variant:"rounded",height:24,width:100}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]}),Yn.jsxs(i,{children:[Yn.jsx(j,{variant:"rounded",height:24,width:100}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),r&&Yn.jsxs(i,{children:[Yn.jsx(j,{variant:"rounded",height:24,width:100}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"Q8W3SC",message:"Volume (1D)"})})]})]}),Yn.jsx(j,{variant:"rounded",height:32,sx:{mt:20}})]})}function QT({sx:t,value:n,onChange:o,searchAddress:r}){const[a,s]=H.useState(!1),{isMobile:l}=Tg();return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:Object.assign(Object.assign({typography:"body2",display:"flex",alignItems:"center",justifyContent:"flex-start",px:12,height:32,backgroundColor:"background.tag",color:"text.secondary",borderRadius:8,fontWeight:600},l?{width:"100%"}:{minWidth:220}),t),onClick:()=>s(!0),children:[Yn.jsx(i,{component:li.Search,sx:{width:16,height:16,mr:8,flexShrink:0}}),Yn.jsx(e,{id:"A1taO8",message:"Search"})]}),Yn.jsx(Xb,{value:n,open:a,multiple:!0,title:Yn.jsx(e,{id:"o8aMNm",message:"Select a liquidity pool"}),searchPlaceholder:se._({id:"4nzwq3",message:"Search by token or pool address"}),onClose:()=>{s(!1)},onTokenChange:e=>{if(Array.isArray(e)){if(e.length>2){const t=[e[0],e[2]];o(t)}else o(e);s(!1)}},searchOtherAddress:e=>r(e,(()=>s(!1))),modal:!0})]})}var YT;function KT({apy:e,dailyApy:t,weeklyApy:n,sx:o}){const r=a();return Yn.jsx(l,{title:Yn.jsxs(i,{sx:{maxWidth:216,typography:"h6",fontWeight:500,color:"text.secondary"},children:[Yn.jsx(i,{sx:{fontWeight:700},children:"Base vAPY (annualized)"}),Yn.jsxs(i,{component:"ul",sx:{pl:16,my:0,listStyleType:"disc"},children:[Yn.jsxs("li",{children:["Daily: ",Vm({input:t,showDecimals:2})]}),Yn.jsxs("li",{children:["Weekly: ",Vm({input:n,showDecimals:2})]})]}),Yn.jsx("br",{}),"*Variable APY based on today’s trading activity"]}),children:Yn.jsx(i,{component:"span",sx:Object.assign({fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto",typography:"h5",[r.breakpoints.up("tablet")]:{typography:"body2"}},o),children:Vm({input:e,showDecimals:2})})})}!function(e){e[e.Add=1]="Add",e[e.Remove=2]="Remove"}(YT||(YT={}));const XT=({pool:e,separate:t,wrap:n})=>{const o=a();if(!e)return null;const r=e.coins.slice(0,8),s=r.length,d=t?s>=6&&n?18:24:s>3?24:36,c=(u=s,n?u<=3?{rows:1,cols:u,itemsPerRow:[u]}:4===u?{rows:2,cols:2,itemsPerRow:[2,2]}:5===u?{rows:2,cols:3,itemsPerRow:[3,2]}:6===u?{rows:2,cols:3,itemsPerRow:[3,3]}:7===u?{rows:2,cols:4,itemsPerRow:[4,3]}:8===u?{rows:2,cols:4,itemsPerRow:[4,4]}:{rows:1,cols:u,itemsPerRow:[u]}:{rows:1,cols:u,itemsPerRow:[u]});var u;return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:Array.from({length:c.rows},((n,a)=>Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:t?2:0,[o.breakpoints.up("tablet")]:{gap:t?4:0}},children:r.slice(c.itemsPerRow.slice(0,a).reduce(((e,t)=>e+t),0),c.itemsPerRow.slice(0,a+1).reduce(((e,t)=>e+t),0)).map(((n,o)=>Yn.jsx(l,{title:n.symbol,placement:"top",onlyHover:!0,leaveDelay:100,sx:{maxWidth:240},children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:o,position:"relative",marginLeft:t?0:o>0?"-8px":0},children:Yn.jsx(Df,{address:n.address,width:d,height:d,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0})})},n.address)))},a)))})};function JT({lqList:e,onDeleteTag:t,sx:n}){if(!(null==e?void 0:e.length))return null;const{name:o}=e[0];return Yn.jsxs(i,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},n),children:[o,Yn.jsx(i,{component:li.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t()})]})}function eI({list:e,onClick:t}){return Yn.jsx(Yn.Fragment,{children:null==e?void 0:e.map((e=>Yn.jsxs(i,{onClick:t,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(XT,{pool:e,separate:!1,wrap:!1}),Yn.jsx(i,{sx:{typography:"h5"},children:e.name})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{color:"custom.status.green.default",fontWeight:600},children:["$",e.tvl?qm(new Pe(e.tvl)):"-"]}),Yn.jsx(i,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:"TVL"})]})]},e.address)))})}const tI=new Se({contractRequests:np});function nI(e,t){var n,i,o,r,a,s,l,d,c,u,p,h,m,g;if(!e||!t)return[];const f=[];for(const x of e){if(!(null==x?void 0:x.pool))continue;const e=x.pool,y=((null===(n=e.coins)||void 0===n?void 0:n.map((e=>({chainId:t,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex)),v={chainId:t,name:e.name||"",address:e.address||e.id||"",symbol:e.symbol,decimals:e.decimals,fee:(null===(i=e.fee)||void 0===i?void 0:i.toString())||"0",coins:y,apy:(null===(o=e.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(r=e.tvl)||void 0===r?void 0:r.toString())||null,volume:(null===(a=e.volume)||void 0===a?void 0:a.toString())||null,dailyVolumeUsd:(null===(s=e.dailyVolumeUsd)||void 0===s?void 0:s.toString())||null,traderCount:(null===(l=e.traderCount)||void 0===l?void 0:l.toString())||null,liquidityUtilization:(null===(d=e.liquidityUtilization)||void 0===d?void 0:d.toString())||null,lpTokenBalance:(null===(u=null===(c=x.liquidityPositions)||void 0===c?void 0:c[0])||void 0===u?void 0:u.liquidityTokenBalance)||null,daoFee:(null===(p=e.daoFee)||void 0===p?void 0:p.toString())||null,virtualPrice:(null===(h=e.virtualPrice)||void 0===h?void 0:h.toString())||null,poolType:e.poolType||"plain",a:(null===(m=e.a)||void 0===m?void 0:m.toString())||null,offpegFeeMultiplier:(null===(g=e.offpegFeeMultiplier)||void 0===g?void 0:g.toString())||null};f.push(v)}return f}function iI({poolList:t,isMyPool:n,setOperateCurvePool:o}){const r=a();return Yn.jsx(Yn.Fragment,{children:t.map((t=>Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",border:`1px solid ${r.palette.border.main}`,borderRadius:16},className:"gradient-card-border",onClick:()=>{Gj.getState().push({type:Zj.CurvePoolDetail,params:{chainId:t.chainId,address:t.address}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600},children:t.name}),Yn.jsx(i,{sx:{maxWidth:146,wordBreak:"break-word",typography:"body2",color:r.palette.text.secondary},children:t.coins.map(((e,n)=>Yn.jsxs(i,{component:"span",children:[e.symbol,n!==t.coins.length-1&&"/"]},e.address)))})]}),Yn.jsx(XT,{pool:t,separate:!0,wrap:!0})]}),Yn.jsxs(i,{sx:{mt:40},children:[Yn.jsx(KT,{apy:t.apy,dailyApy:t.dailyApy,weeklyApy:t.weeklyApy}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:20},children:[Yn.jsxs(i,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",t.tvl?qm(new Pe(t.tvl)):"-"]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),Yn.jsx(i,{sx:{flexShrink:0,flexGrow:0,width:"1px",height:24,backgroundColor:r.palette.border.main}}),Yn.jsxs(i,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[Yn.jsx(i,{sx:{typography:"h5"},children:n?t.lpTokenBalance?Am({input:t.lpTokenBalance,decimals:t.decimals}):"-":Yn.jsxs(Yn.Fragment,{children:["$",t.volume?qm(new Pe(t.volume)):"-"]})}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:n?"My LP tokens":"Volume"})]})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[n&&Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({pool:t,type:YT.Remove})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({pool:t,type:YT.Add})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})}),Yn.jsx(zT,{chainId:t.chainId,address:t.address,type:Zj.CurvePoolDetail})]})]},`${t.chainId}-${t.address}`)))})}function oI({poolList:e,isMyPool:t,loading:n,operateCurvePool:o,setOperateCurvePool:r,hasMore:s,loadMore:l,loadMoreLoading:d}){const u=a();return Yn.jsxs(ZT,{hasMore:s,loadMore:l,loadMoreLoading:d,empty:!(null==e?void 0:e.length),loading:n,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:"Pool"}),Yn.jsx(i,{component:"th",children:"Assets"}),Yn.jsx(i,{component:"th",children:"APY"}),Yn.jsx(i,{component:"th",children:"TVL"}),Yn.jsx(i,{component:"th",children:t?"My LP tokens":"Volume"}),Yn.jsx(i,{component:"th",sx:{width:t?249:155}})]})}),Yn.jsx(i,{component:"tbody",children:e.map((e=>{var n;let a="";if((null===(n=null==o?void 0:o.pool)||void 0===n?void 0:n.address.toLowerCase())===e.address.toLowerCase())if(o.type===YT.Remove)a=se._({id:"0+31GV",message:"Removing"});else a=se._({id:"1yHVE+",message:"Adding"});const s=u.palette.hover.default;return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(a?", & td":"")]:{backgroundImage:`linear-gradient(${s}, ${s})`}},children:[Yn.jsxs(i,{component:"td",children:[Yn.jsx(i,{sx:{typography:"body2",lineHeight:"19px",fontWeight:600},children:e.name}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),Yn.jsx(i,{component:"td",children:Yn.jsx(XT,{pool:e,separate:!0,wrap:!1})}),Yn.jsx(i,{component:"td",children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:Yn.jsx(KT,{apy:e.apy,dailyApy:e.dailyApy,weeklyApy:e.weeklyApy})})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},title:`$${Am({input:e.tvl,decimals:2})}`,children:["$",e.tvl?qm(new Pe(e.tvl)):"-"]})}),Yn.jsx(i,{component:"td",children:t?Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},title:`$${Am({input:e.lpTokenBalance,decimals:2})}`,children:e.lpTokenBalance?Am({input:e.lpTokenBalance,decimals:e.decimals}):"-"}):Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},title:`$${Am({input:e.volume,decimals:2})}`,children:["$",e.volume?qm(new Pe(e.volume)):"-"]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[Yn.jsx(zT,{chainId:e.chainId,address:e.address,type:Zj.CurvePoolDetail}),a?Yn.jsx(HT,{text:a,onClick:()=>r(null)}):Yn.jsxs(Yn.Fragment,{children:[t&&Yn.jsx(c,{variant:c.Variant.second,size:c.Size.small,onClick:()=>{r({pool:e,type:YT.Remove})},sx:{py:0,height:32},children:se._({id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{size:c.Size.small,onClick:()=>{r({pool:e,type:YT.Add})},sx:{py:0,height:32},children:se._({id:"m16xKo",message:"Add"})})]})]})})]},`${e.chainId}-${e.address}`)}))})]})}const rI=({account:e,scrollParentRef:t,activeChainId:n,operateCurvePool:o,setOperateCurvePool:r,children:s,isMyPool:l=!1})=>{var d,c;const u=a(),{isMobile:p}=Tg(),h=gg(),m=nt(),{onlyChainId:g}=Jn(),{filterTokens:f,filterAddressLqList:x,handleDeleteToken:y,handleChangeFilterTokens:v,handleChangeFilterAddress:b}=function(){const[e,t]=H.useState([]),[n,i]=H.useState([]);return{filterTokens:e,filterAddressLqList:n,handleDeleteToken:e=>{t((t=>{const n=[...t],i=n.indexOf(e);return-1!==i&&n.splice(i,1),n}))},handleChangeFilterTokens:e=>{i([]),e.length>0?t([e[e.length-1]]):t([])},handleChangeFilterAddress:e=>{i(e),t([])}}}(),j=$((()=>{var t,i;return{chainId:n,pageSize:p?4:8,order:{orderBy:"tvl",orderDirection:"desc"},user:l?null==e?void 0:e.toLowerCase():null,filterState:{tokenAddress:null!==(i=null===(t=f[0])||void 0===t?void 0:t.address.toLowerCase())&&void 0!==i?i:null}}}),[n,p,l,e,f]),C=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign({},j)}),w=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign({},j)}),k=at(Object.assign(Object.assign({},C),{enabled:!l,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getAllPools)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getAllPools;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),T=at(Object.assign(Object.assign({},w),{enabled:l&&null!=e,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getMyLiquidity)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getMyLiquidity;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),I=!!(null==x?void 0:x.length),S=$((()=>{var e,t;let i=[];return I?i=[...x]:l?null===(t=T.data)||void 0===t||t.pages.forEach((e=>{var t;const o=nI(null===(t=e.curve_stableswap_ng_getMyLiquidity)||void 0===t?void 0:t.lqList,n);i=[...i,...o]})):null===(e=k.data)||void 0===e||e.pages.forEach((e=>{var t;const o=nI(null===(t=e.curve_stableswap_ng_getAllPools)||void 0===t?void 0:t.lqList,n);i=[...i,...o]})),i}),[I,l,x,null===(d=k.data)||void 0===d?void 0:d.pages,n,null===(c=T.data)||void 0===c?void 0:c.pages]),E=(l?T.hasNextPage:k.hasNextPage)&&!I,A=l?T:k;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:20,display:"flex",flexDirection:"column",gap:12,[u.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[u.breakpoints.up("tablet")]:{mr:"auto"}},children:s}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},p?{}:{"& > button":{flex:1}}),children:Yn.jsx(QT,{value:f,onChange:v,searchAddress:(e,t)=>Vn(void 0,void 0,void 0,(function*(){var i,o;const r=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign(Object.assign({},j),{filterState:{poolAddress:e.toLowerCase()}})}),a=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign(Object.assign({},j),{filterState:{poolAddress:e.toLowerCase()}})}),s=nI(l?null===(i=(yield m.fetchQuery(a)).curve_stableswap_ng_getMyLiquidity)||void 0===i?void 0:i.lqList:null===(o=(yield m.fetchQuery(r)).curve_stableswap_ng_getAllPools)||void 0===o?void 0:o.lqList,n);return(null==s?void 0:s.length)?Yn.jsx(eI,{list:s,onClick:()=>{b(s),t()}}):null}))})}),(I||!!f.length)&&Yn.jsxs(i,{sx:{my:0},children:[I?Yn.jsx(JT,{lqList:x,onDeleteTag:()=>b([])}):null,Yn.jsx($T,{tags:f,onDeleteTag:y})]})]})]}),p?Yn.jsx(In,{hasMore:E,threshold:300,loadMore:ae((()=>{A.hasNextPage&&!A.isFetching&&A.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>t.current||null,loader:Yn.jsx(GT,{sx:{mt:20}},"loader"),children:Yn.jsxs(WT,{children:[A.isLoading?Yn.jsx(GT,{}):"",!A.isLoading&&!(null==S?void 0:S.length)&&!A.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!(!n||g)}),!!A.error&&Yn.jsx(ai,{refresh:A.refetch,sx:{mt:40}}),Yn.jsx(iI,{isMyPool:l,poolList:S,setOperateCurvePool:r})]})}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(oI,{isMyPool:l,poolList:S,loading:A.isLoading,operateCurvePool:o,setOperateCurvePool:r,hasMore:E,loadMoreLoading:A.isFetchingNextPage,loadMore:()=>{A.hasNextPage&&!A.isFetching&&A.fetchNextPage()}}),Yn.jsx(Tj,{loading:A.isLoading,refetch:A.error?A.refetch:void 0,empty:!(null==S?void 0:S.length),hasSearch:!(!n||g)})]})]})};function aI({children:e}){const t=a();return Yn.jsx(i,{sx:{px:20,py:16,boxShadow:"0px -1px 0px 0px rgba(55, 55, 57, 0.10)",backgroundColor:"background.paper",borderBottomLeftRadius:16,borderBottomRightRadius:16,position:"fixed",bottom:0,left:0,right:0,[t.breakpoints.up("tablet")]:{position:"static"}},children:e})}const sI=e=>{const t=a();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,px:12,height:36,borderRadius:8,border:`1px solid ${t.palette.border.main}`},children:[Yn.jsxs(i,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px",color:t.palette.text.secondary,textTransform:"capitalize"},children:["Slippage Bonus (incl. pricing)",Yn.jsx(lb,{title:"Bonus comes as an advantage from current coin prices which usually appears for coins which are low in balance"})]}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:t.palette.success.main},children:"-"})]})};function lI({pool:e,account:t}){var n;const i=et(tI.getBalanceOf(null==e?void 0:e.chainId,null==e?void 0:e.address,t)),o=et(tI.getBalances(null==e?void 0:e.chainId,null==e?void 0:e.address,null!==(n=null==e?void 0:e.coins)&&void 0!==n?n:[])),r=et(tI.getTotalSupply(null==e?void 0:e.chainId,null==e?void 0:e.address)),a=$((()=>r.data?null==(null==e?void 0:e.decimals)?null:r.data.div(10**e.decimals).dp(e.decimals,Pe.ROUND_DOWN):null),[r.data,null==e?void 0:e.decimals]),s=$((()=>i.data?null==(null==e?void 0:e.decimals)?null:i.data.div(10**e.decimals).dp(e.decimals,Pe.ROUND_DOWN):null),[i.data,null==e?void 0:e.decimals]),l=$((()=>o.data?null==(null==e?void 0:e.coins)?null:o.data.map(((t,n)=>{const i=e.coins[n];return t.div(10**i.decimals).dp(i.decimals,Pe.ROUND_DOWN)})):null),[o.data,null==e?void 0:e.coins]),d=$((()=>l&&s&&a?null==(null==e?void 0:e.coins)?null:l.map(((t,n)=>{const i=e.coins[n];return t.multipliedBy(s).div(a).dp(i.decimals,Pe.ROUND_DOWN)})):null),[l,s,a,null==e?void 0:e.coins]);return{lpTokenTotalSupply:a,tokenBalances:l,lpTokenBalance:s,userTokenBalances:d,lpTokenBalanceLoading:i.isLoading||o.isLoading||r.isLoading}}const dI=({operateCurvePool:e})=>{const t=a(),{account:n,chainId:o}=dg(),r=Fg(),s=nt(),[l,u]=z(!1),[p,h]=z({}),m=G(p);m.current=p;const{slipper:g,setSlipper:f,slipperValue:x,resetSlipper:y}=oC({address:e.pool.address}),{lpTokenTotalSupply:v,tokenBalances:b,lpTokenBalance:j,userTokenBalances:C}=lI({pool:e.pool,account:n}),w=Z((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),h(t)}),[e.pool.coins]);Q((()=>{w()}),[w]);const k=(t,n)=>{h((i=>{const o=Object.assign(Object.assign({},i),{[t]:n});if(l&&b){const i=e.pool.coins.findIndex((e=>e.address===t));if(-1!==i){const r=b[i],a=new Pe(n||"0");a.isZero()||""===n?e.pool.coins.forEach((e=>{e.address!==t&&(o[e.address]="0")})):r&&r.gt(0)&&a.gt(0)&&e.pool.coins.forEach(((e,t)=>{if(t!==i){const n=b[t];if(n&&n.gt(0)){const t=n.div(r),i=a.multipliedBy(t).dp(e.decimals,Pe.ROUND_DOWN).toString();o[e.address]=i}else o[e.address]="0"}}))}}return o}))},T=tt({queries:e.pool.coins.map((t=>{const i=ip.getFetchTokenQuery(t.chainId,t.address,n,e.pool.address);return{queryKey:i.queryKey,enabled:i.enabled&&null!=t.chainId&&null!=t.address&&null!=n&&null!=e.pool.address,queryFn:i.queryFn}})),combine:e=>({data:e.map((e=>{var t,n,i,o;return{address:null===(t=e.data)||void 0===t?void 0:t.address,symbol:null===(n=e.data)||void 0===n?void 0:n.symbol,balance:null===(i=e.data)||void 0===i?void 0:i.balance,allowance:null===(o=e.data)||void 0===o?void 0:o.allowance}})),loading:e.some((e=>e.isLoading))})}),{getApprovalState:I,getBalanceState:S,getPendingRest:E,submitApprove:A}=(({account:e,chainId:t,offset:n,contractAddress:i})=>{var o,r;const a=Fg(),s=nt(),{runningRequests:l}=Ug(),{updateBlockNumber:d}=wg(),c=H.useMemo((()=>null!=i?i:Te[t].DODO_APPROVE),[t,i]),u=H.useMemo((()=>{var e;return t?null===(e=we[t])||void 0===e?void 0:e.address:null}),[t]),p=it({mutationFn:n=>Vn(void 0,[n],void 0,(function*({token:n,isReset:i,submittedBack:o,canceledCallback:r,successBack:l,failedCallback:u}){if(!c||!e||!n)return;const p=og(n),h=i?new Pe(0):void 0,m=i?se._({id:"OfhWJH",message:"Reset"}):se._({id:"Z7ZXbT",message:"Approve"}),g=yield a.execute(`${m} ${p}`,{opcode:Pg.Approval,token:n,contract:c,amt:h},{submittedBack:o,metadata:{[Sg.approve]:!0}});if(g===Eg.Canceled&&(null==r||r()),g===Eg.Success&&l&&l(),g===Eg.Failed&&(null==u||u()),g!==Eg.Success)return g;yield d(),s.invalidateQueries({queryKey:ip.getFetchTokenQuery(t,null==n?void 0:n.address,e,c).queryKey,refetchType:"all"})}))}),h=Z(((t,i,o,r)=>{var a,s;if(!t)return of.Loading;const d=l.some((e=>{var n,i,o;return(null===(n=e.spec)||void 0===n?void 0:n.opcode)===Pg.Approval&&(null===(i=e.spec)||void 0===i?void 0:i.token.address)===(null==t?void 0:t.address)&&(null===(o=e.spec)||void 0===o?void 0:o.contract)===c})),h=(null===(s=null===(a=p.variables)||void 0===a?void 0:a.token)||void 0===s?void 0:s.address)===(null==t?void 0:t.address)&&p.isPending,m=new Pe(null!=i?i:0);return e?!o||m.minus(null!=n?n:0).gt(o)||m.isZero()?of.Unchecked:t&&t.address===u?of.Sufficient:d||h?of.Approving:r?m.minus(null!=n?n:0).gt(r)?of.Insufficient:of.Sufficient:of.Loading:of.Unchecked}),[e,u,c,n,l,p.isPending,null===(r=null===(o=p.variables)||void 0===o?void 0:o.token)||void 0===r?void 0:r.address]);return{getApprovalState:h,getPendingRest:Z(((e,t)=>("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)),[]),getBalanceState:Z(((t,i,o)=>e?o?t.minus(null!=n?n:0).gt(o)?rf.Insufficient:rf.Sufficient:rf.Loading:rf.Unchecked),[e,n]),submitApprove:Z(((e,t,n,i,o,r)=>Vn(void 0,void 0,void 0,(function*(){p.mutate({token:e,isReset:t,submittedBack:n,canceledCallback:i,successBack:o,failedCallback:r})}))),[p]),getMaxBalance:Z(((e,n)=>{const i=new Pe(0);return e&&void 0!==t&&n||i}),[t])}})({account:n,chainId:e.pool.chainId,contractAddress:e.pool.address}),O=Z(((t,n,i)=>{var o;if(!b)return{};const r={},a=n||p,s=i||T.data,l=b.findIndex((e=>e&&e.gt(0)));if(-1!==l){const n=b[l],i=e.pool.coins[l];let d;if(void 0!==t)d=t;else{const e=Object.values(a).find((e=>e&&"0"!==e&&""!==e));if(e)d=e;else{const e=null===(o=null==s?void 0:s.find((e=>{var t,n;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(n=i.address)||void 0===n?void 0:n.toLowerCase())})))||void 0===o?void 0:o.balance;d=e&&e.gt(0)?e.dp(i.decimals,Pe.ROUND_DOWN).toString():"1"}}const c=new Pe(d);r[i.address]=d,e.pool.coins.forEach(((e,t)=>{if(t!==l){const i=b[t];if(i&&i.gt(0)&&n.gt(0)){const t=i.div(n),o=c.multipliedBy(t).dp(e.decimals,Pe.ROUND_DOWN).toString();r[e.address]=o}else r[e.address]="0"}}))}return r}),[e.pool.coins,b,p,T.data]),L=et(tI.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=p[e.address]||"0",n=new Pe(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,Pe.ROUND_DOWN).toString():"0"})),!0)),R=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n&&L.data)try{const t=new hk([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_min_mint_amount",type:"uint256"}],name:"add_liquidity",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=p[e.address]||"0",n=new Pe(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,Pe.ROUND_DOWN).toString():"0"})),i=L.data.multipliedBy(1-x).dp(0,Pe.ROUND_DOWN).toString(),o=t.encodeFunctionData("add_liquidity",[n,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("add_liquidity",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveAddLiquidity]:!0},submittedBack:()=>{a()},successBack:()=>{a(),w()}})}catch(e){console.error("curve add_liquidity",e)}}))}),P=$((()=>{var t,i;if(!n||e.pool.chainId!==o)return Yn.jsx(cC,{chainId:e.pool.chainId,fullWidth:!0});if(T.loading)return Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!Object.values(p).some((e=>e&&"0"!==e)))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const n of e.pool.coins){const e=p[n.address];if(!e||"0"===e)continue;const o=new Pe(e);if(!o.isFinite())return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"});const r=T.data.find((e=>{var t,i;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(i=n.address)||void 0===i?void 0:i.toLowerCase())})),a=null!==(t=null==r?void 0:r.balance)&&void 0!==t?t:null,s=null!==(i=null==r?void 0:r.allowance)&&void 0!==i?i:null,l=S(o,n,a),d=E(n,s),u=I(n,o,a,s);if(l===rf.Loading||u===of.Loading)return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Loading..."});if(l===rf.Insufficient)return Yn.jsxs(c,{fullWidth:!0,disabled:!0,children:["Insufficient ",n.symbol," balance"]});if(u===of.Approving)return Yn.jsxs(c,{fullWidth:!0,disabled:!0,children:[n.symbol," Approval Pending"]});if(u===of.Insufficient)return Yn.jsxs(c,{fullWidth:!0,onClick:()=>{A(n,d)},children:["Approve ",n.symbol]})}return L.isLoading||!L.data?Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):L.data.lte(0)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"}):Yn.jsx(c,{fullWidth:!0,disabled:R.isPending,isLoading:R.isPending,onClick:()=>{R.mutate()},children:"Add"})}),[n,o,I,S,E,L.data,L.isLoading,R,e.pool.chainId,e.pool.coins,A,p,T.data,T.loading]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[t.breakpoints.up("tablet")]:{pb:20}},children:[Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:4},children:e.pool.coins.map((e=>{var n;const o=null===(n=T.data.find((t=>{var n,i;return(null===(n=t.address)||void 0===n?void 0:n.toLowerCase())===(null===(i=e.address)||void 0===i?void 0:i.toLowerCase())})))||void 0===n?void 0:n.balance;return Yn.jsxs(i,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:t.palette.background.cardInput},children:[Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(Df,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:e.symbol})]}),Yn.jsxs(i,{component:d,onClick:()=>{o&&((e,t,n)=>{if(!t)return;const i=t.dp(n,Pe.ROUND_DOWN).toString();k(e,i)})(e.address,o,e.decimals)},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:t.palette.text.secondary,"&:hover":{color:t.palette.text.primary}},children:["Balance: ",o?Am({input:o,decimals:e.decimals}):"-"]})]}),Yn.jsx(Db,{value:p[e.address]||"",onChange:t=>{k(e.address,t)},decimals:e.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]},e.symbol)}))}),Yn.jsxs(i,{sx:{mt:-8,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[Yn.jsxs(i,{component:d,onClick:()=>{const e=!l;if(u(e),e&&b){const e=O(void 0,m.current,T.data);h(e)}},sx:{px:11,py:3,borderRadius:20,border:`1px solid ${l?t.palette.primary.main:t.palette.border.main}`,typography:"body2",fontWeight:500,lineHeight:"19px",color:l?t.palette.primary.contrastText:t.palette.text.primary,backgroundColor:l?t.palette.primary.main:"transparent","&:hover":{opacity:.8}},children:["Balanced proportion: ",l?"ON":"OFF"]}),Yn.jsx(rC,{value:g,onChange:f,sx:{width:"auto",display:"inline-flex",ml:0}})]}),Yn.jsx(sI,{})]}),Yn.jsx(aI,{children:P})]})};function cI({disabled:e,selected:t,onClick:n,children:o,iconVisible:r}){const s=a(),l=t?s.palette.success.main:s.palette.text.secondary;return Yn.jsxs(i,{component:d,disabled:e,onClick:n,sx:{flexGrow:1,flexShrink:1,flexBasis:"100%",display:"flex",alignItems:"center",gap:8},children:[r&&Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:t?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:l}),Yn.jsx("rect",{x:"4.5",y:"5",width:"9",height:"9",rx:"4.5",fill:l,stroke:l})]}):Yn.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:l})}),Yn.jsx(i,{sx:{flexGrow:1,display:"flex",alignItems:"center",gap:8,typography:"body2",fontWeight:500,lineHeight:"19px",color:s.palette.text.primary},children:o})]})}const uI=({operateCurvePool:e})=>{const t=a(),{account:n,chainId:o}=dg(),r=Fg(),s=nt(),[l,u]=z(""),[p,h]=z("oneCoin"),[m,g]=z(0),[f,x]=z({}),{slipper:y,setSlipper:v,slipperValue:b,resetSlipper:j}=oC({address:e.pool.address}),{lpTokenBalance:C,userTokenBalances:w,lpTokenBalanceLoading:k}=lI({pool:e.pool,account:n}),T=Z((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),x(t)}),[e.pool.coins]);Q((()=>{T()}),[T]);const I=$((()=>{const e=new _e(l);return e.isFinite()?e:null}),[l]),S=et(tI.calcWithdrawOneCoin(e.pool.chainId,e.pool.address,I?I.multipliedBy(10**e.pool.decimals).dp(0,_e.ROUND_DOWN).toString():"0",m)),E=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n&&S.data)try{const t=new hk([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"i",type:"int128"},{name:"_min_received",type:"uint256"}],name:"remove_liquidity_one_coin",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,_e.ROUND_DOWN).toString():"0",i=S.data.multipliedBy(1-b).dp(0,_e.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_one_coin",[n,m,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("remove_liquidity_one_coin",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveRemoveLiquidityOneCoin]:!0},submittedBack:()=>{a()},successBack:()=>{a(),u("")}})}catch(e){console.error("curve remove_liquidity_one_coin",e)}}))}),A=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n)try{const t=new hk([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"_min_amounts",type:"uint256[]"}],name:"remove_liquidity",outputs:[{name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,_e.ROUND_DOWN).toString():"0",i=e.pool.coins.map(((e,t)=>(null==w?void 0:w[t])&&I&&C&&C.gt(0)?w[t].multipliedBy(I).div(C).multipliedBy(10**e.decimals).multipliedBy(1-b).dp(0,_e.ROUND_DOWN).toString():"0")),o=t.encodeFunctionData("remove_liquidity",[n,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("remove_liquidity",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveRemoveLiquidity]:!0},submittedBack:()=>{a()},successBack:()=>{a(),u("")}})}catch(e){console.error("curve remove_liquidity",e)}}))}),O=et(Object.assign({},tI.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new _e(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,_e.ROUND_DOWN).toString():"0"})),!1)));Q((()=>{if("custom"===p&&O.isSuccess&&O.data){const t=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,_e.ROUND_DOWN);u(t.toString())}}),[O.isSuccess,O.data,p,e.pool.decimals]);const L=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n&&O.data)try{const t=new hk([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_max_burn_amount",type:"uint256"}],name:"remove_liquidity_imbalance",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new _e(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,_e.ROUND_DOWN).toString():"0"})),i=O.data.multipliedBy(1+b).dp(0,_e.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_imbalance",[n,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("remove_liquidity_imbalance",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveRemoveLiquidityImBalance]:!0},submittedBack:()=>{a()},successBack:()=>{a(),u(""),T()}})}catch(e){console.error("curve remove_liquidity_imbalance",e)}}))}),R=$((()=>{if(!n||e.pool.chainId!==o)return Yn.jsx(cC,{chainId:e.pool.chainId,fullWidth:!0});if(!l||"0"===l)return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Please enter amount"});const t=new _e(l);if(!t.isFinite())return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"});if(k)return Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!C||C.lte(0))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"No LP token balance"});if(t.gt(C))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"});if("oneCoin"===p)return S.isLoading||!S.data?Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):S.data.lte(0)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"}):Yn.jsx(c,{fullWidth:!0,disabled:E.isPending,isLoading:E.isPending,onClick:()=>{E.mutate()},children:"Remove"});if("balanced"===p)return Yn.jsx(c,{fullWidth:!0,disabled:A.isPending,isLoading:A.isPending,onClick:()=>{A.mutate()},children:"Remove"});if("custom"===p){if(!Object.values(f).some((e=>e&&"0"!==e)))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const t of e.pool.coins){const e=f[t.address];if(!e||"0"===e)continue;if(!new _e(e).isFinite())return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"})}if(O.isLoading||!O.data)return Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."});if(O.data.lte(0))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"});const n=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,_e.ROUND_DOWN);return n.gt(t)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Insufficient input amount"}):n.gt(C)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"}):Yn.jsx(c,{fullWidth:!0,disabled:L.isPending,isLoading:L.isPending,onClick:()=>{L.mutate()},children:"Remove"})}return null}),[n,e.pool.chainId,e.pool.decimals,e.pool.coins,o,l,k,C,p,S.isLoading,S.data,E,A,f,O.isLoading,O.data,L]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[t.breakpoints.up("tablet")]:{pb:20}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[Yn.jsxs(i,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:t.palette.background.cardInput},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:"LP Tokens"}),Yn.jsxs(i,{component:d,onClick:()=>{C&&u(C.dp(e.pool.decimals,_e.ROUND_DOWN).toString())},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:t.palette.text.secondary,"&:hover":{color:t.palette.text.primary}},children:["Balance: ",C?Am({input:C,decimals:e.pool.decimals}):"-"]})]}),Yn.jsx(Db,{value:l,onChange:e=>{u(e)},decimals:e.pool.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]}),Yn.jsxs(i,{sx:{p:12,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,borderRadius:8,border:`1px solid ${t.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(cI,{iconVisible:!0,disabled:!1,selected:"oneCoin"===p,onClick:()=>{h("oneCoin")},children:"One coin"}),Yn.jsx(cI,{iconVisible:!0,disabled:!1,selected:"balanced"===p,onClick:()=>{h("balanced")},children:"Balanced"}),Yn.jsx(cI,{iconVisible:!0,disabled:!1,selected:"custom"===p,onClick:()=>{h("custom")},children:"Custom"})]}),Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:12},children:e.pool.coins.map(((e,n)=>{var o;return Yn.jsxs(cI,{iconVisible:"oneCoin"===p||"balanced"===p,disabled:!1,selected:"oneCoin"!==p||m===n,onClick:()=>{"oneCoin"===p&&g(n)},children:[Yn.jsx(Df,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:e.symbol}),"oneCoin"===p&&Yn.jsx(i,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:m===n?Am({input:null===(o=S.data)||void 0===o?void 0:o.div(10**e.decimals),decimals:e.decimals}):"0"}),"balanced"===p&&Yn.jsx(i,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:(null==w?void 0:w[n])&&I&&C&&C.gt(0)?Am({input:w[n].multipliedBy(I).div(C),decimals:e.decimals}):"-"}),"custom"===p&&Yn.jsx(i,{sx:{ml:"auto"},children:Yn.jsx(Db,{value:f[e.address]||"",onChange:t=>{var n,i;n=e.address,i=t,x((e=>Object.assign(Object.assign({},e),{[n]:i})))},decimals:e.decimals,sx:{mt:0,"& input":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,textAlign:"right",border:`1px solid ${t.palette.border.main}`,borderRadius:8,outline:"none",padding:0,color:"text.primary",height:38,width:160,px:12,"&::placeholder":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,color:"text.disabled"}}}})})]},e.address)}))})]}),Yn.jsx(rC,{value:y,onChange:v,sx:{}})]}),Yn.jsx(sI,{})]}),Yn.jsx(aI,{children:R})]})},pI=({onClose:e,poolDetailBtnVisible:t=!0,operateCurvePool:n})=>{const o=a(),{account:r}=dg(),[s,c]=z(n.type),[u,p]=z(n.type);u!==n.type&&(p(n.type),c(n.type));const{lpTokenBalance:h,userTokenBalances:m}=lI({pool:n.pool,account:r});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{position:"relative",display:"flex",flexDirection:"column",gap:16,px:20,pt:20},children:[e&&Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid",borderColor:o.palette.border.main},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",pb:17},children:"Liquidity"}),Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:e,component:d,children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16}})})]}),Yn.jsxs(i,{children:[t&&Yn.jsxs(i,{sx:{px:20,py:12,borderTopLeftRadius:8,borderTopRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,borderBottom:"none",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:"text.primary"},children:n.pool.name}),Yn.jsx(zb,{address:n.pool.address,customChainId:n.pool.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),Yn.jsxs(i,{component:d,onClick:()=>{Gj.getState().push({type:Zj.CurvePoolDetail,params:{address:n.pool.address,chainId:n.pool.chainId}})},sx:{display:"flex",alignItems:"center",color:"text.secondary","&:hover":{color:"text.primary"}},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px"},children:"details"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M7.49988 5L6.44238 6.0575L9.87738 9.5L6.44238 12.9425L7.49988 14L11.9999 9.5L7.49988 5Z",fill:"currentColor"})})]})]}),Yn.jsxs(i,{sx:{px:20,py:12,borderTopLeftRadius:t?0:8,borderTopRightRadius:t?0:8,borderBottomLeftRadius:8,borderBottomRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:12},children:[Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,lineHeight:"16px",color:"text.secondary"},children:"My LP tokens"}),Yn.jsx(l,{title:Yn.jsx(i,{sx:{m:8,display:"flex",flexDirection:"column",gap:20,minWidth:216},children:null==m?void 0:m.map(((e,t)=>{const o=n.pool.coins[t];return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600,lineHeight:"14px"},children:[Yn.jsx(Df,{width:14,height:14,address:o.address,chainId:o.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsx(i,{children:o.symbol}),Yn.jsx(i,{sx:{ml:"auto"},children:Am({input:e,decimals:o.decimals})})]},t)}))}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:500,lineHeight:"22px",color:o.palette.text.primary},children:Am({input:h,decimals:n.pool.decimals})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00016 1.33325C4.32016 1.33325 1.3335 4.31992 1.3335 7.99992C1.3335 11.6799 4.32016 14.6666 8.00016 14.6666C11.6802 14.6666 14.6668 11.6799 14.6668 7.99992C14.6668 4.31992 11.6802 1.33325 8.00016 1.33325ZM7.3335 4.66658V5.99992H8.66683V4.66658H7.3335ZM7.3335 7.33325V11.3333H8.66683V7.33325H7.3335ZM2.66683 7.99992C2.66683 10.9399 5.06016 13.3333 8.00016 13.3333C10.9402 13.3333 13.3335 10.9399 13.3335 7.99992C13.3335 5.05992 10.9402 2.66659 8.00016 2.66659C5.06016 2.66659 2.66683 5.05992 2.66683 7.99992Z",fill:o.palette.text.secondary})})]})})]})]})]}),Yn.jsxs(S,{value:s,onChange:(e,t)=>{c(t)},children:[Yn.jsx(F,{tabs:[{key:YT.Add,value:"Add"},{key:YT.Remove,value:"Remove"}],variant:"inPaper",tabsListSx:{mt:16,mx:20}}),Yn.jsx(O,{value:YT.Add,children:Yn.jsx(dI,{operateCurvePool:n})}),Yn.jsx(O,{value:YT.Remove,children:Yn.jsx(uI,{operateCurvePool:n})})]})]})},hI=({poolDetailBtnVisible:e,operateCurvePool:t,setOperateCurvePool:n})=>{const{isMobile:o}=Tg(),r=$((()=>{if(n)return()=>{n(null)}}),[n]);return o?Yn.jsx(Of,{open:!0,onClose:r,scope:!o,modal:o,id:"curve-pool-operate",children:Yn.jsx(pI,{onClose:r,operateCurvePool:t,poolDetailBtnVisible:e})}):Yn.jsx(i,{sx:{borderRadius:16,backgroundColor:"background.paper"},children:Yn.jsx(pI,{onClose:r,operateCurvePool:t,poolDetailBtnVisible:e})})};function mI(e,t,n,i){return"CLASSICAL"===i&&e&&t&&e.isEqualTo(t)?e.times(`1e${n}`).minus(1).div(`1e${n}`):e}function gI(e,t){return e.lte(0)?new _e(0):t.div(e)}function fI(e,t,n,i,o,r,a){const s=o&&function(e){return-1!==["0x9D9793e1E18CDEe6cf63818315D55244f73EC006","0x0D04146B2Fe5d267629a7eb341Fb4388DcdBD22f","0x3D9d765b0fbAf594F90F07bc42889473e6613C7A","0x3854BdcB1a7cBA4b1A5f9a7C8719e247Df4c42c6","0xA46F5eC3219f956d14C6816Ef9cf6CaBf13bdD77","0xB16f2Ff8E8499E31B257d2A02D25e8956Ae6aFe7"].findIndex((t=>t.toLowerCase()===e.toLowerCase()))}(o);let l,d;const c="CLASSICAL"===r?i:n;if(e&&t&&c&&void 0!==a){if(d=gI(t,c),l=e.times(d),"CLASSICAL"===r&&s){if(!i)return[void 0,void 0];l.gt(i)&&n&&(d=gI(t,_e.min(i,n)),l=l.times(d))}return[d,l.dp(Number(a),_e.ROUND_DOWN)]}return[void 0,void 0]}function xI({account:e,pool:t}){var n,i;const{chainId:o,address:r,type:a,baseTokenDecimals:s,quoteTokenDecimals:l,baseLpTokenDecimals:d,quoteLpTokenDecimals:c}=null!=t?t:{},u=et($m.getTotalBaseLpQuery(o,r,a,d)),p=et($m.getTotalQuoteLpQuery(o,r,a,c)),h=et($m.getUserBaseLpQuery(o,r,a,d,e)),m=et($m.getUserQuoteLpQuery(o,r,a,c,e)),g=et($m.getReserveLpQuery(o,r,a,s,l)),f=et($m.getClassicalTargetQuery(o,r,a,s,l)),x=u.data,y=p.data,{baseReserve:v,quoteReserve:b}=g.data||{},j=null===(n=f.data)||void 0===n?void 0:n.baseTarget,C=null===(i=f.data)||void 0===i?void 0:i.quoteTarget,w="DPP"===a,k=w?v:mI(h.data,x,d,a),T=w?b:mI(m.data,y,c,a),[I,S]=w?[new _e(1),v]:fI(k,x,v,j,r,a,s);let E,A;if(b){let e=p.data;e||p.isLoading||p.error||!x||(e=x);const t=m.isFetched&&!m.error&&null===T?k:T;w?(E=new _e(1),A=b):m.isLoading||m.error||f.error||t?[E,A]=fI(t,e,b,C,r,a,l):A=new _e(0)}const O=h.isLoading||m.isLoading,L=h.isError||m.isError,R=()=>{h.refetch(),m.refetch(),u.refetch(),p.refetch(),g.refetch(),f.refetch()},P=O||u.isLoading||p.isLoading||g.isLoading||f.isLoading,_=L||u.isError||p.isError||g.isError||f.isError,M="DVM"===(null==t?void 0:t.type)&&(!b||b.isZero());return{totalBaseLpBalance:x,totalQuoteLpBalance:y,baseReserve:v,quoteReserve:b,classicalBaseTarget:j,classicalQuoteTarget:C,userBaseLpBalance:k,userQuoteLpBalance:T,userBaseLpToTokenBalance:S,userQuoteLpToTokenBalance:A,baseLpToTokenProportion:I,quoteLpToTokenProportion:E,isSinglePool:M,userLpBalanceLoading:O,userLpToTokenBalanceLoading:P,userLpBalanceError:L,userLpToTokenBalanceError:_,userLpToTokenBalanceRefetch:R,error:_,loading:P,refetch:R}}const yI=new Ee({contractRequests:np});function vI({chainId:e,address:t,showName:n,size:o,offset:r,rightContent:a}){const s=Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:r},children:[Yn.jsx(Df,{chainId:e,address:t,width:o,height:o,noShowChain:!0,marginRight:0}),n]});return a?Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s,a]}):s}function bI({miningItem:e}){var t,n;const{account:i}=dg(),o=null!==(t=null==e?void 0:e.rewardTokenInfos)&&void 0!==t?t:[],r=[],a=[];if(e){const t=e.version,s=null!==(n=e.miningContractAddress)&&void 0!==n?n:"";o.forEach((n=>{var o,l,d,c,u,p,h,m,g;const f={address:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",decimals:null==n?void 0:n.decimals,symbol:null!==(l=null==n?void 0:n.symbol)&&void 0!==l?l:"",usdPrice:null!==(d=null==n?void 0:n.price)&&void 0!==d?d:""};if("3"===t)r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,f.address,f.decimals,t));else switch(e.type){case"classical":r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,null!==(u=null===(c=e.baseLpToken)||void 0===c?void 0:c.address)&&void 0!==u?u:"",f.decimals,"2")),r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,null!==(h=null===(p=e.quoteLpToken)||void 0===p?void 0:p.address)&&void 0!==h?h:"",f.decimals,"2"));break;case"vdodo":case"single":r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,null!==(g=null===(m=e.baseToken)||void 0===m?void 0:m.address)&&void 0!==g?g:"",f.decimals,"2"));break;default:throw new Error(`type: ${e.type} is not valid.`)}}))}return tt({queries:a,combine:e=>{let t=new Pe(0),n=new Pe(0);return{data:e.map(((e,i)=>{const o=r[i],a=e.data;if(a){t=a.plus(t);const e=null==o?void 0:o.usdPrice;e&&(n=n.plus(a.times(e)))}return Object.assign(Object.assign({},o),{amount:a})})),pending:e.some((e=>e.isPending)),error:e.some((e=>e.isError)),totalReward:t,totalRewardUSD:n,refetch:()=>{e.forEach((e=>e.refetch()))}}}})}function jI({value:e,label:t,tokenList:n,loading:o}){const r=a();return Yn.jsxs(i,{sx:{flexGrow:0,flexShrink:1,width:"30%"},children:[Yn.jsx(i,{sx:{typography:"h6",color:r.palette.text.secondary},children:t}),Yn.jsxs(i,{sx:{mt:8,typography:"body1",fontWeight:600,color:r.palette.text.primary,display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(v,{loading:o,loadingProps:{width:30},children:e?`$${Am({input:e,decimals:2})}`:"-"}),Yn.jsx(l,{placement:"top",title:Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:8,width:190,color:"text.primary",fontWeight:600},children:n.map((e=>{var t;return Yn.jsx(vI,{chainId:e.chainId,address:e.address,showName:null!==(t=e.symbolEle)&&void 0!==t?t:e.symbol,rightContent:e.amount,size:20,offset:6},e.address+e.chainId)}))}),children:Yn.jsx(i,{component:d,sx:{display:"flex",alignItems:"center",color:r.palette.text.secondary,width:16,height:16,"&:hover":{color:"text.primary"}},children:Yn.jsx(li.DetailBorder,{})})})]})]})}function CI({chainId:t,loading:n,miningItem:o,miningContractAddress:r,stakedTokenUSD:s,stakedTokenUSDLoading:l,miningTitle:d,associatedMineSectionShort:c,stakedTokenList:u,isEnded:p}){var h,m;const g=a(),f=bI({miningItem:o});return Yn.jsxs(i,{sx:{backgroundColor:g.palette.background.paper,borderRadius:8,borderColor:g.palette.border.main,borderStyle:"solid",borderWidth:1,mb:20},children:[c?null:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{py:12,px:20,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(v,{loading:n,loadingProps:{width:100},children:Yn.jsx(kj,{width:24,tokens:u,gap:-6,chainId:t,mr:4,showChainLogo:!1})}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{color:g.palette.text.primary,typography:"body2",fontWeight:600,display:"flex",alignItems:"center"},children:null!=d?d:"-"}),p&&Yn.jsx(i,{sx:{backgroundColor:g.palette.border.disabled,borderRadius:4,typography:"h6",fontWeight:500,px:8,color:g.palette.text.disabled},children:Yn.jsx(e,{id:"237hSL",message:"Ended"})})]}),Yn.jsx(zb,{size:"small",truncate:!0,address:null!=r?r:"",iconSpace:4,sx:{color:g.palette.text.secondary,typography:"h6"},customChainId:t})]})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:g.palette.text.secondary,typography:"h6",cursor:"pointer"},onClick:()=>{Gj.getState().push({type:Zj.MiningDetail,params:{address:r,chainId:t}})},children:[Yn.jsx(e,{id:"URmyfc",message:"Details"}),Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Yn.jsx("path",{d:"M7.5 4.5L6.4425 5.5575L9.8775 9L6.4425 12.4425L7.5 13.5L12 9L7.5 4.5Z",fill:"currentColor"})})]})]}),Yn.jsx(i,{sx:{width:"100%",height:"1px",backgroundColor:g.palette.border.main}})]}),Yn.jsxs(i,{sx:{py:12,px:20,display:"flex",alignItems:"center",gap:20},children:[Yn.jsx(jI,{value:s,label:se._({id:"luOvdJ",message:"My Staked"}),tokenList:u,loading:n||l}),Yn.jsx(i,{sx:{width:"1px",height:30,backgroundColor:g.palette.border.main,flexGrow:0,flexShrink:0}}),Yn.jsx(jI,{value:f.totalRewardUSD,label:se._({id:"4cJ0hF",message:"Rewards"}),tokenList:null!==(m=null===(h=f.data)||void 0===h?void 0:h.map((e=>Object.assign(Object.assign({chainId:t},e),{name:e.symbol,amount:Am({input:e.amount,decimals:e.decimals})}))))&&void 0!==m?m:[],loading:f.pending||n})]})]})}const wI=({miningItem:e,successBack:t})=>{const{account:n}=dg(),i=Fg();return it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){const o=yield Vn(void 0,void 0,void 0,(function*(){if(!n||!(null==e?void 0:e.miningContractAddress))return null;let t="";const i=yield Ee.encode.claimAllMining(e.miningContractAddress);if(i&&i.data)return i.value=0,i;throw t="invalid data",new Error(t)}));if(!o)return;return yield i.execute(se._({id:"hom7qf",message:"Claim"}),Object.assign({opcode:Pg.TX},o),{metadata:{[Sg.claimMining]:"1"},successBack:t})}))})};function kI({miningItem:t}){const n=bI({miningItem:t}),i=wI({miningItem:t,successBack:()=>{n.refetch()}});return Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:null==t?void 0:t.chainId,children:Yn.jsx(c,{fullWidth:!0,isLoading:i.isPending,disabled:n.totalReward.isZero(),onClick:()=>{i.mutate()},children:i.isPending?Yn.jsx(e,{id:"KvG1xW",message:"Claiming"}):Yn.jsx(e,{id:"dUdltF",message:"One-Click Claim"})})})}function TI({tokenSymbol:e,goLpLink:t}){const n=a();return Yn.jsxs(P,{sx:{color:n.palette.text.secondary,typography:"h6",display:"flex",alignItems:"center"},component:d,onClick:t,children:[se._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:e}}),Yn.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.83324 3.88867L5.01074 4.71117L7.68241 7.38867L5.01074 10.0662L5.83324 10.8887L9.33324 7.38867L5.83324 3.88867Z",fill:"currentColor"})})]})}function II({miningItem:t,loading:n,sx:o}){const r=a(),s=bI({miningItem:t});return Yn.jsxs(i,{sx:Object.assign({borderWidth:1,borderRadius:12},o),children:[Yn.jsxs(i,{sx:{typography:"body1",color:r.palette.text.secondary,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12},children:[Yn.jsx(e,{id:"4cJ0hF",message:"Rewards"}),":",Yn.jsx(v,{loading:n||s.pending,loadingProps:{width:100},sx:{color:r.palette.text.primary,fontWeight:600},children:s.pending||s.error?"-":`$${Am({input:s.totalRewardUSD,decimals:2})}`})]}),Yn.jsxs(i,{sx:{borderTopWidth:1,px:20,pt:4,pb:8},children:[(n||s.pending)&&Yn.jsx(v,{loading:n,loadingProps:{width:150}}),!n&&!s.pending&&!!t&&s.data.map((e=>Yn.jsxs(i,{sx:{mt:16,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.address&&e.symbol&&Yn.jsx(vI,{chainId:t.chainId,address:e.address,showName:e.symbol,size:24,offset:6}),Yn.jsxs(i,{sx:{ml:"auto"},children:[Yn.jsx(i,{sx:{typography:"h5",textAlign:"right"},children:Am({input:e.amount,decimals:e.decimals})}),Yn.jsx(i,{sx:{mt:2,typography:"body2",color:r.palette.text.secondary,textAlign:"right"},children:e.usdPrice&&e.amount?`≈ $${Am({input:new Pe(e.amount).multipliedBy(e.usdPrice).dp(4,Pe.ROUND_DOWN),decimals:4})}`:"-"})]})]},e.address)))]})]})}function SI({status:t,children:n,buttonProps:i}){return!t.needShowTokenStatusButton&&n?Yn.jsx(Yn.Fragment,{children:n}):t.insufficientBalance?Yn.jsx(c,{fullWidth:!0,disabled:!0,...i,children:Yn.jsx(e,{id:"znqB4T",message:"Insufficient balance"})}):Yn.jsx(c,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance,...i,children:t.isApproving?Yn.jsx(e,{id:"j2Uisd",message:"Approving"}):t.approveTitle})}function EI(e){if(!e&&"number"!=typeof e)return e;let t="";return t=Pe.isBigNumber(e)?e.toString(16):new Pe(e).toString(16),t.length%2?"0x0"+t:"0x"+t}function AI(e){return EI(Pm(e,18))}const OI=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:o})=>{const{chainId:r,account:a}=dg(),s=Fg(),l=we[r];return it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){const r=yield Vn(void 0,void 0,void 0,(function*(){var n,i;if(!(a&&e&&e.baseToken&&e.miningContractAddress))return null;let o="";const r=new Pe(t),s=Number(e.baseToken.decimals),d=yield Ee.encode.depositMining(e.miningContractAddress,r,s);if(!d||!d.data)throw o="invalid data",new Error(o);try{return t&&(null===(i=null===(n=e.baseLpToken)||void 0===n?void 0:n.address)||void 0===i?void 0:i.toLocaleLowerCase())===l.address.toLocaleLowerCase()?d.value=AI(r):d.value=0,d}catch(e){throw console.error("2.0 sendTransaction error",e),o=`2.0 sendTransaction error; ERROR: ${e}`,new Error(o)}}));if(!r)return;return yield s.execute(se._({id:"JYKRJS",message:"Stake"}),Object.assign({opcode:Pg.TX},r),{metadata:{[Sg.stakeMining]:"1",logBalance:o},submittedBack:n,successBack:i})}))})};function LI({goLpLink:t,amount:n,miningItem:i,balanceInfo:o,submittedBack:r,successBack:a,logBalance:s}){var l,d,u,p;const h=OI({miningItem:i,amount:n,submittedBack:r,successBack:a,logBalance:s}),m=i?`${null===(l=i.baseToken)||void 0===l?void 0:l.symbol}-${null===(d=i.quoteToken)||void 0===d?void 0:d.symbol} LP`:"",g=lf(i?ag(Object.assign(Object.assign({},i.baseLpToken),{symbol:m}),i.chainId):null,{contractAddress:null!==(u=null==i?void 0:i.miningContractAddress)&&void 0!==u?u:"",overrideBalance:o.userBaseLpBalance,amount:n});return t&&m&&(null===(p=o.userBaseLpBalance)||void 0===p?void 0:p.isZero())?Yn.jsx(c,{fullWidth:!0,onClick:()=>t(),children:se._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:m}})}):Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:null==i?void 0:i.chainId,children:Yn.jsx(SI,{status:g,children:Yn.jsx(c,{fullWidth:!0,isLoading:h.isPending,disabled:!Number(n),onClick:()=>{h.mutate()},children:h.isPending?Yn.jsx(e,{id:"KsqhWn",message:"Staking"}):Yn.jsx(e,{id:"JYKRJS",message:"Stake"})})})})}const RI=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:o})=>{const{account:r}=dg(),a=Fg();return it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){const s=yield Vn(void 0,void 0,void 0,(function*(){if(!(r&&e&&e.baseToken&&e.miningContractAddress))return null;let n="";const i=new Pe(t),o=Number(e.baseToken.decimals),a=yield Ee.encode.withdrawMining(e.miningContractAddress,i,o);if(a&&a.data)return a.value=0,a;throw n="invalid data",new Error(n)}));if(!s)return;return yield a.execute(se._({id:"OFjZGo",message:"Unstake"}),Object.assign({opcode:Pg.TX},s),{metadata:{[Sg.unstakeMining]:"1",logBalance:o},submittedBack:n,successBack:i})}))})};function PI({amount:t,miningItem:n,overrideBalance:i,submittedBack:o,successBack:r,logBalance:a}){var s,l;const d=RI({miningItem:n,amount:t,submittedBack:o,successBack:r,logBalance:a}),u=n?`${null===(s=n.baseToken)||void 0===s?void 0:s.symbol}-${null===(l=n.quoteToken)||void 0===l?void 0:l.symbol} LP`:"",p=lf(n?ag(Object.assign(Object.assign({},n.baseLpToken),{symbol:u}),n.chainId):null,{overrideBalance:i,amount:t,skipQuery:!0});return Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:null==n?void 0:n.chainId,children:Yn.jsx(SI,{status:p,children:Yn.jsx(c,{fullWidth:!0,isLoading:d.isPending,disabled:!Number(t),onClick:()=>{d.mutate()},children:d.isPending?Yn.jsx(e,{id:"1gWStS",message:"Unstaking"}):Yn.jsx(e,{id:"OFjZGo",message:"Unstake"})})})})}function _I(e){var{sx:t}=e,n=qn(e,["sx"]);const o=a();return Yn.jsx(i,{sx:Object.assign({paddingTop:20,backgroundColor:o.palette.background.paper,position:"sticky",bottom:0},t),...n})}function MI({chainId:e,poolAddress:t,status:n,loading:o,operateType:r,setOperateType:s,miningItem:l,associatedMineSectionVisible:d,goLpLink:c}){var u,p,h,m,g,f,x,y,v,b,j,C,w,k,T,I,E;const A=a(),{account:L}=dg(),{miningContractAddress:R}=null!=l?l:{},P=ag(null==l?void 0:l.baseToken,e),_=ag(null==l?void 0:l.quoteToken,e),[M,B]=H.useState(""),[D,N]=H.useState(""),U=[{key:"stake",value:se._({id:"JYKRJS",message:"Stake"})},{key:"unstake",value:se._({id:"OFjZGo",message:"Unstake"})},{key:"claim",value:se._({id:"hom7qf",message:"Claim"})}],q=l&&P&&_&&["classical","lptoken"].includes(null!==(u=l.type)&&void 0!==u?u:"")?{chainId:e,address:t,type:"lptoken"===l.type?"DSP":"CLASSICAL",baseToken:P,quoteToken:_}:void 0,V=xI({account:L,pool:l&&P&&_&&l.baseLpToken&&l.quoteLpToken&&["classical","lptoken"].includes(null!==(p=l.type)&&void 0!==p?p:"")?{chainId:e,address:t,type:"lptoken"===l.type?"DSP":"CLASSICAL",baseTokenDecimals:P.decimals,quoteTokenDecimals:_.decimals,baseLpTokenDecimals:null!==(h=l.baseLpToken.decimals)&&void 0!==h?h:18,quoteLpTokenDecimals:null!==(m=l.quoteLpToken.decimals)&&void 0!==m?m:18}:void 0}),W=et($m.getPMMStateQuery(null==q?void 0:q.chainId,null==q?void 0:q.address,null==q?void 0:q.type,null===(g=null==q?void 0:q.baseToken)||void 0===g?void 0:g.decimals,null===(f=null==q?void 0:q.quoteToken)||void 0===f?void 0:f.decimals)),$=et(yI.getLpStakedBalance(null==l?void 0:l.chainId,(null==l?void 0:l.miningContractAddress)||void 0,L,null!==(y=null===(x=null==l?void 0:l.baseLpToken)||void 0===x?void 0:x.address)&&void 0!==y?y:"",null===(v=null==l?void 0:l.baseToken)||void 0===v?void 0:v.decimals,null==l?void 0:l.version)),z=$.isLoading||W.isLoading;let Z,G,Q;if($.data&&V.baseLpToTokenProportion&&V.quoteLpToTokenProportion&&!W.isLoading){const e=null===(b=null==l?void 0:l.baseToken)||void 0===b?void 0:b.price,t=null===(j=null==l?void 0:l.quoteToken)||void 0===j?void 0:j.price,n=null===(C=W.data)||void 0===C?void 0:C.midPrice;G=$.data.times(V.baseLpToTokenProportion),Q=$.data.times(V.quoteLpToTokenProportion),n?t?Z=G.times(n).plus(Q).times(t):e&&(Z=Q.times(n).plus(G).times(e)):e&&t&&(Z=G.times(e).plus(Q.times(t)))}const Y=P&&_?[Object.assign(Object.assign({},P),{amount:Am({input:G,decimals:P.decimals})}),Object.assign(Object.assign({},_),{amount:Am({input:Q,decimals:_.decimals})})]:[],K=P&&_?`${P.symbol}-${_.symbol} LP`:"- LP",X=n===Ae.ended,J=(null===(w=null==l?void 0:l.baseLpToken)||void 0===w?void 0:w.address)&&V.userBaseLpBalance?{[null===(k=null==l?void 0:l.baseLpToken)||void 0===k?void 0:k.address]:V.userBaseLpBalance.toString()}:{},ee=()=>{V.refetch(),W.refetch(),$.refetch()};return Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:{paddingTop:20,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:A.palette.background.paper,px:20,paddingBottom:0,borderBottomLeftRadius:0,borderBottomRightRadius:0},children:[d&&Yn.jsx(CI,{chainId:e,miningContractAddress:null!=R?R:"",loading:o,miningItem:l,stakedTokenUSD:Z,stakedTokenUSDLoading:z,miningTitle:null!==(T=null==l?void 0:l.title)&&void 0!==T?T:"",stakedTokenList:Y}),Yn.jsxs(S,{value:r,onChange:(e,t)=>{s(t)},children:[Yn.jsx(F,{tabs:U,variant:"inPaper",tabsListSx:{mt:16}}),Yn.jsxs(O,{value:"stake",children:[Yn.jsxs(i,{sx:{mt:20,borderColor:A.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:16},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(kj,{width:Y.length>1?20:28,tokens:Y,chainId:e}),Yn.jsx(i,{sx:{ml:8,typography:"body1",color:A.palette.text.primary,fontWeight:600},children:K})]}),!!c&&Yn.jsx(TI,{tokenSymbol:K,goLpLink:c})]}),Yn.jsx(hj,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:se._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:V.userBaseLpBalance||new Pe("-"),overrideBalanceLoading:V.loading,amt:M,canClickBalance:!0,onInputChange:e=>{B(e)},readOnly:X||o,token:P,checkLogBalance:J,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),Yn.jsx(_I,{children:Yn.jsx(LI,{miningItem:l,balanceInfo:V,amount:M,goLpLink:c,submittedBack:()=>B(""),successBack:ee,logBalance:J})})]}),Yn.jsxs(O,{value:"unstake",children:[Yn.jsx(hj,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:se._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:$.data||new Pe("-"),overrideBalanceLoading:$.isLoading,amt:X?null!==(E=null===(I=$.data)||void 0===I?void 0:I.toString())&&void 0!==E?E:"":D,onInputChange:e=>{N(e)},canClickBalance:!0,readOnly:X||o,token:P,checkLogBalance:J,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),Yn.jsx(_I,{children:Yn.jsx(PI,{miningItem:l,overrideBalance:$.data,amount:D,submittedBack:()=>N(""),successBack:ee,logBalance:J})})]}),Yn.jsxs(O,{value:"claim",children:[Yn.jsx(II,{miningItem:l,loading:o,sx:{mt:20}}),Yn.jsx(_I,{children:Yn.jsx(kI,{miningItem:l})})]})]})]})})}function BI({chainId:e,account:t,poolAddress:n,goLpLink:i}){var o,r,a;const s=gg().getQuery(Ee.graphql.fetchMiningList,{where:{chainIds:[e],user:t,filterState:{address:n}}}),l=et(Object.assign(Object.assign({},s),{enabled:!!n})),d=null===(a=null===(r=null===(o=l.data)||void 0===o?void 0:o.mining_list)||void 0===r?void 0:r.list)||void 0===a?void 0:a[0],{status:c}=function({miningItem:e}){var t,n;let i=Ae.active,o=[];if(null==e?void 0:e.rewardTokenInfos)if("classical"!==e.type){const r=Ee.utils.getMiningStatusByTimestamp({startTime:null!==(t=e.startTime)&&void 0!==t?t:"",endTime:null!==(n=e.endTime)&&void 0!==n?n:"",rewardTokenInfoList:e.rewardTokenInfos.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))});i=r.status,o.push(r)}else if(e.rewardQuoteTokenInfos){o=[e.rewardTokenInfos,e.rewardQuoteTokenInfos].map((t=>{var n,i;return Ee.utils.getMiningStatusByTimestamp({startTime:null!==(n=e.startTime)&&void 0!==n?n:"",endTime:null!==(i=e.endTime)&&void 0!==i?i:"",rewardTokenInfoList:t.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))})}));const[{status:t},{status:n}]=o;Ae.active,(t===Ae.upcoming&&n===Ae.upcoming||t===Ae.upcoming&&n===Ae.ended||t===Ae.ended&&n===Ae.upcoming)&&Ae.upcoming,t===Ae.ended&&n===Ae.ended&&Ae.ended}return{status:i,miningStatusList:o}}({miningItem:d}),[u,p]=H.useState(c===Ae.ended?"unstake":"stake");return Yn.jsx(MI,{chainId:e,loading:l.isLoading||l.isPending,operateType:u,setOperateType:p,associatedMineSectionVisible:!0,miningItem:d,status:c,goLpLink:i,poolAddress:n})}const DI=()=>{const t=a();return Yn.jsx(l,{placement:"top-end",leaveDelay:100,title:Yn.jsx(i,{sx:{maxWidth:240,color:t.palette.warning.main,typography:"h6",fontWeight:500,"&>a":{textDecoration:"underline",color:t.palette.warning.main},"&>a:hover":{color:T(t.palette.warning.main,.5)}},children:Yn.jsx(e,{id:"QtgfjM",message:"The creator of the liquidity pool can adjust the liquidity distribution by modifying the market-making price parameters. <0>Learn more</0>",components:{0:Yn.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://docs.dodoex.io/en/product/pmm-algorithm"})}})}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2,py:4,px:8,borderRadius:8,backgroundColor:T(t.palette.warning.main,.1),color:t.palette.warning.main,typography:"h6",fontWeight:500,lineHeight:"16px",cursor:"help"},children:[Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{d:"M8.00008 10.6666C8.18897 10.6666 8.3473 10.6027 8.47508 10.4749C8.60286 10.3471 8.66675 10.1888 8.66675 9.99992C8.66675 9.81103 8.60286 9.6527 8.47508 9.52492C8.3473 9.39714 8.18897 9.33325 8.00008 9.33325C7.81119 9.33325 7.65286 9.39714 7.52508 9.52492C7.3973 9.6527 7.33341 9.81103 7.33341 9.99992C7.33341 10.1888 7.3973 10.3471 7.52508 10.4749C7.65286 10.6027 7.81119 10.6666 8.00008 10.6666ZM7.33341 7.99992H8.66675V4.66659H7.33341V7.99992ZM8.00008 14.6666C6.45564 14.2777 5.18064 13.3916 4.17508 12.0083C3.16953 10.6249 2.66675 9.08881 2.66675 7.39992V3.33325L8.00008 1.33325L13.3334 3.33325V7.39992C13.3334 9.08881 12.8306 10.6249 11.8251 12.0083C10.8195 13.3916 9.54453 14.2777 8.00008 14.6666ZM8.00008 13.2666C9.15564 12.8999 10.1112 12.1666 10.8667 11.0666C11.6223 9.96659 12.0001 8.74436 12.0001 7.39992V4.24992L8.00008 2.74992L4.00008 4.24992V7.39992C4.00008 8.74436 4.37786 9.96659 5.13341 11.0666C5.88897 12.1666 6.84453 12.8999 8.00008 13.2666Z",fill:"currentColor"})}),Yn.jsx(e,{id:"iDGO1l",message:"Disclaimer"})]})})};var NI;function FI(t){const{ConfirmComponent:n}=Jn();if(n)return Yn.jsx(n,{...t});const{open:o,onClose:r,title:a,children:s,singleBtn:l,danger:d,singleBtnText:u,cancelText:p,confirmText:h,disabledConfirm:m,confirmLoading:g,isManualClose:f,onConfirm:x,modal:y}=t;return Yn.jsx(Of,{open:o,onClose:r,title:a,modal:y,children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1},children:[Yn.jsx(i,{sx:{typography:"body2",color:a?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:s}),l?Yn.jsx(i,{sx:{px:20},children:Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,danger:d,sx:{mt:32,mb:20},onClick:()=>{r()},children:u||Yn.jsx(e,{id:"DPfwMq",message:"Done"})})}):Yn.jsxs(i,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{r()},children:p||Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),Yn.jsx(c,{sx:{ml:8},variant:c.Variant.outlined,danger:d,disabled:m,isLoading:g,onClick:()=>{x&&x(),f||r()},children:h||Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})]})]})})}function UI(e){var{sx:t,label:n,children:o}=e,r=qn(e,["sx","label","children"]);return Yn.jsxs(i,{sx:Object.assign({display:"flex",justifyContent:"space-between"},t),...r,children:[Yn.jsx(i,{children:n}),Yn.jsx(i,{sx:{textAlign:"right",fontWeight:600},children:o})]})}function qI({baseToken:e,quoteToken:t,midPrice:n,loading:o,disabled:r}){const s=a(),[d,c]=z(!1),u=d?null==t?void 0:t.symbol:null==e?void 0:e.symbol,p=d&&n?new Pe(1).div(n):n,h=d?null==e?void 0:e.symbol:null==t?void 0:t.symbol;return Yn.jsxs(v,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:o,loadingProps:{width:50},children:[e&&t?Yn.jsx(l,{title:`1 ${u} = ${p?Em({input:p}):""} ${h}`,children:n?Yn.jsx(i,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${u} = ${p?Em({input:p}):""} ${h}`}):Yn.jsxs(i,{children:[`1 ${u} = `,Yn.jsx(v,{loading:o,loadingProps:{width:30},component:"span",sx:{display:"inline-block"},children:"-"}),` ${h}`]})}):"-",Yn.jsx(i,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,backgroundColor:"background.paperDarkContrast",borderRadius:"50%"},!r&&{cursor:"pointer","&:hover":{backgroundColor:T(s.palette.text.primary,.04)}}),onClick:()=>{r||c((e=>!e))},children:Yn.jsx(i,{component:li.Switch,sx:{width:18,height:18}})})]})}function VI({baseToken:t,quoteToken:n,loading:o,midPrice:r,shareOfPool:s,sx:l}){const d=a(),c=!t||!n;return Yn.jsxs(i,{sx:Object.assign({mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},l),children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[Yn.jsx(i,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"kNeEXg",message:"Current Price"})}),Yn.jsx(qI,{baseToken:t,quoteToken:n,loading:o,disabled:c,midPrice:r})]}),Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:d.spacing(1,0,0),borderColor:"border.main"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"SbBMxj",message:"Share of pool"})}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:Yn.jsx(v,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:o,loadingProps:{width:50},children:s||"-%"})})]})]})}function WI({open:t,onClose:n,slippage:o,baseToken:r,quoteToken:s,baseAmount:l,quoteAmount:d,lpAmount:u,fee:p,price:h,shareOfPool:m,pairAddress:g,createMutation:f}){const x=a(),{isMobile:y}=Tg();return Yn.jsx(Of,{modal:!0,open:t,onClose:n,title:u?Yn.jsx(e,{id:"AeZIvT",message:"You will receive"}):Yn.jsx(e,{id:"aM1tos",message:"You are creating a pool"}),children:Yn.jsxs(i,{sx:{px:20,py:24,borderTopWidth:1,width:y?"100%":420},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h3"},children:[Yn.jsx(kj,{width:24,height:24,tokens:r&&s?[r,s]:[],chainId:null==r?void 0:r.chainId}),u?Am({input:u,decimals:18}):""]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:x.palette.text.secondary,gap:4,fontWeight:600},children:[Yn.jsx(e,{id:"syToc5",message:"{0}/{1} Pool Tokens",values:{0:null==r?void 0:r.symbol,1:null==s?void 0:s.symbol}}),Yn.jsx(cT,{poolType:"AMM V2"})]})]}),Yn.jsx(i,{sx:{mt:16,typography:"h6",color:"text.secondary",textAlign:"center"},children:Yn.jsx(e,{id:"rQ9c+8",message:"Output is estimated. If the price changes by more than {0} your transaction will revert.",values:{0:Vm({input:o})}})}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,mt:20,p:20,typography:"body2",borderRadius:12,backgroundColor:x.palette.background.paperContrast},children:[Yn.jsx(UI,{label:Yn.jsx(e,{id:"YG004A",message:"{0} deposited",values:{0:null==r?void 0:r.symbol}}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[Yn.jsx(Df,{width:18,height:18,marginRight:4,token:r}),Am({input:l,decimals:null==r?void 0:r.decimals})]})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"YG004A",message:"{0} deposited",values:{0:null==s?void 0:s.symbol}}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{width:18,height:18,marginRight:4,token:s}),Am({input:d,decimals:null==s?void 0:s.decimals})]})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"EU3wU4",message:"Fee tier"}),children:Vm({input:p})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"fqDzSu",message:"Rate"}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{width:18,height:18,marginRight:4,token:r}),Yn.jsx(qI,{baseToken:r,quoteToken:s,midPrice:h})]})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"SbBMxj",message:"Share of pool"}),children:m}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"ESQO1L",message:"Pool address"}),children:Yn.jsx(zb,{showCopy:!1,address:null!=g?g:"",customChainId:null==r?void 0:r.chainId,truncate:!0,iconSpace:4,sx:{typography:"body2"}})})]}),Yn.jsx(c,{fullWidth:!0,size:c.Size.big,sx:{mt:20},isLoading:f.isPending,onClick:()=>{f.mutate()},children:f.isPending?Yn.jsx(e,{id:"pwUZo2",message:"Confirming..."}):Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})]})})}function HI(e,t,n){const i=new Pe(e),o=new Pe(t),r=i.minus(o),a=i.gt(o),s=i.lt(o);return{now:o,target:i,isChange:a||s,change:r,changeText:(s?"":"+")+Em({input:r,showDecimals:n>6?6:4,showPrecisionDecimals:2}),isAdd:a,isRemove:s}}!function(e){e[e.Liquidity=1]="Liquidity",e[e.Mining=2]="Mining"}(NI||(NI={}));const $I=e=>Vn(void 0,[e],void 0,(function*({chainId:e,account:t,srcPool:n,baseToken:i,quoteToken:o,baseAmount:r,quoteAmount:a,feeRate:s,initPrice:l,slippageCoefficient:d,ddl:c,SLIPPAGE_PROTECTION:u}){const p=e?we[e]:void 0,h=function({srcPool:e,newPool:t}){if(!e)return null;const{baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=t,{baseReserve:a,quoteReserve:s}=e;return{baseAmount:HI(o,a,n.decimals),quoteAmount:HI(r,s,i.decimals),feeRate:HI(new Pe(t.feeRate).div(100),e.feeRate,6),initPrice:HI(t.initPrice,e.i,10),slippageCoefficient:HI(t.slippageCoefficient||"1",e.k,4)}}({srcPool:n,newPool:{baseToken:i,quoteToken:o,baseAmount:r,quoteAmount:a,feeRate:s,initPrice:l,slippageCoefficient:d}});if(!(t&&e&&h&&n))return null;const m=Number(i.decimals),g=Number(o.decimals);let f;const x=h.slippageCoefficient.target;try{const t=i.symbol===(null==p?void 0:p.symbol),r=o.symbol===(null==p?void 0:p.symbol);if(h.baseAmount.isRemove&&h.quoteAmount.isRemove){const t=[yield $m.getDPPOwnerProxyAddressQuery(e,n.address).queryFn(),h.feeRate.target.multipliedBy(1e4).toNumber(),h.initPrice.target.toNumber(),x.toNumber(),zt(h.baseAmount.change.abs().dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),zt(h.quoteAmount.change.abs().dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),zt(h.baseAmount.now.multipliedBy(1-u).dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),zt(h.quoteAmount.now.multipliedBy(1-u).dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),m,g];f=yield ye.encode.removeDPPPoolABI(...t)}else{const t=[e,n.address,h.feeRate.target.multipliedBy(1e4).toNumber(),h.initPrice.target.toNumber(),x.toNumber(),h.baseAmount.isAdd?zt(h.baseAmount.change.abs().dp(m,Pe.ROUND_FLOOR).toString(),m).toString():"0",h.quoteAmount.isAdd?zt(h.quoteAmount.change.abs().dp(g,Pe.ROUND_FLOOR).toString(),g).toString():"0",h.baseAmount.isAdd?"0":zt(h.baseAmount.change.abs().dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),h.quoteAmount.isAdd?"0":zt(h.quoteAmount.change.abs().dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),zt(h.baseAmount.now.multipliedBy(1-u).dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),zt(h.quoteAmount.now.multipliedBy(1-u).dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),0,m,g,Math.ceil(Date.now()/1e3)+(null!=c?c:600)];f=yield ye.encode.resetDPPPoolABI(...t)}return t&&h.baseAmount.isAdd&&(f.value=AI(h.baseAmount.change)),r&&h.quoteAmount.isAdd&&(f.value=AI(h.quoteAmount.change)),f}catch(e){throw console.error("2.0 resetDPPPool error",e),new Error(`2.0 resetDPPPool error;ERROR:${e}`)}})),zI=(e,t,n)=>t?e&&"0"!==e?n?t.minus(e).toString():t.plus(e).toString():t.toString():e;function ZI({pool:e}){var t,n;const{account:i}=dg(),o=Fg(),r=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(t=null==e?void 0:e.baseToken)||void 0===t?void 0:t.decimals,null===(n=null==e?void 0:e.quoteToken)||void 0===n?void 0:n.decimals)),a=et($m.getLPFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type)),{deadLine:s}=Jn(),l=it({mutationFn:t=>Vn(this,[t],void 0,(function*({baseAmount:t,quoteAmount:n,isRemove:l=!1,feeRate:d,initPrice:c,slippageCoefficient:u,txTitle:p,submittedBack:h}){var m;if(!e)throw new Error("pool is undefined");const g=a.data;if(!g)throw new Error("lpFeeRate is undefined");if(!r.data)throw new Error("pmmStateQuery.data is undefined");const{pmmParamsBG:f,baseReserve:x,quoteReserve:y}=r.data,v=f.i.toNumber(),b=f.k.toNumber(),j=yield $I({account:i,chainId:null==e?void 0:e.chainId,SLIPPAGE_PROTECTION:iC,srcPool:Object.assign(Object.assign({},e),{baseReserve:x,quoteReserve:y,i:v,k:b,feeRate:g.times(100).toString()}),baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,baseAmount:zI(t,x?new Pe(x):void 0,l),quoteAmount:zI(n,y?new Pe(y):void 0,l),feeRate:null!=d?d:g.times(100).toString(),initPrice:null!=c?c:String(v),slippageCoefficient:null!=u?u:String(b),ddl:s});if(!j)throw new Error(`modify pool failed: ${e.address}`);return o.execute(p,Object.assign(Object.assign({opcode:Pg.TX},j),{value:null!==(m=j.value)&&void 0!==m?m:0}),{metadata:{[l?Sg.removeLiquidity:Sg.addLiquidity]:!0},submittedBack:h})}))});return{modifyDPPMutation:l}}const GI=e=>{const{account:t,chainId:n}=dg(),i=Fg(),o=nt(),{deadLine:r}=Jn(),{modifyDPPMutation:a}=ZI({pool:e}),s=it({mutationFn:a=>Vn(void 0,void 0,void 0,(function*(){var s,l,d,c,u;if(!e||!t||!a.balanceInfo)return;const{isRemove:p,baseAmount:h,quoteAmount:m,slippageProtection:g,balanceInfo:f,SLIPPAGE_PROTECTION:x,submittedBack:y,successBack:v,txTitle:b,withdrawInfo:j}=a,C=!p,{address:w,type:k,baseToken:T,quoteToken:I}=e,S=T.address.toLowerCase(),E=I.address.toLowerCase(),A=we[n].address.toLowerCase(),O=A===S,L=A===E,R="DSP"===k||"GSP"===k,P="CLASSICAL"===k,_=w.toLocaleLowerCase(),M=new Pe(h),B=new Pe(m),D=M.isNaN(),N=B.isNaN(),F=+T.decimals,U=+I.decimals,q=T.symbol,V=I.symbol,W=g;let H,$=D?"0":zt(M.multipliedBy(1-W).dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),z=N?"0":zt(B.multipliedBy(1-W).dp(U,Pe.ROUND_FLOOR).toString(),U).toString();try{if(C)if(P){const e=!D&&(null==f?void 0:f.classicalBaseTarget)&&f.classicalBaseTarget.gt(0)&&f.totalBaseLpBalance?zt(M.multipliedBy(f.totalBaseLpBalance).multipliedBy(1-x).div(f.classicalBaseTarget).dp(F,Pe.ROUND_FLOOR).toString(),F).toString():"0",t=!N&&(null==f?void 0:f.classicalBaseTarget)&&f.totalQuoteLpBalance&&f.classicalQuoteTarget&&f.classicalQuoteTarget.gt(0)?zt(B.multipliedBy(f.totalQuoteLpBalance).multipliedBy(1-x).div(f.classicalQuoteTarget).dp(U,Pe.ROUND_FLOOR).toString(),U).toString():"0",i=[n,_,D?"0":zt(M.dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),N?"0":zt(B.dp(U,Pe.ROUND_FLOOR).toString(),U).toString(),e,t,O?1:L?2:0,Math.ceil(Date.now()/1e3)+(null!=r?r:600)];H=yield ye.encode.addClassicalLiquidityABI(...i)}else{const e=[n,_,D?"0":zt(M.dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),N?"0":zt(B.dp(U,Pe.ROUND_FLOOR).toString(),U).toString(),$,z,O?1:L?2:0,Math.ceil(Date.now()/1e3)+(null!=r?r:600)];H=R?yield ye.encode.addDSPLiquidityABI(...e):yield ye.encode.addDVMLiquidityABI(...e)}else if(P){if("base"===(D?"quote":"base")){const e=M.dp(F,Pe.ROUND_FLOOR).toString(),t=j&&j.receiveAmountBg?zt(j.receiveAmountBg.multipliedBy(1-W).dp(F,Pe.ROUND_FLOOR).toString(),F).toString():$,i=[n,_,zt(e,F).toString(),t];H=yield ye.encode.removeClassicalBaseABI(...i)}else{const e=B.dp(U,Pe.ROUND_FLOOR).toString(),t=j&&j.receiveAmountBg?zt(j.receiveAmountBg.multipliedBy(1-W).dp(U,Pe.ROUND_FLOOR).toString(),U).toString():z,i=[n,_,zt(e,U).toString(),t];H=yield ye.encode.removeClassicalQuoteABI(...i)}}else{if(!((null==f?void 0:f.baseReserve)&&f.quoteReserve&&f.totalBaseLpBalance&&f.userBaseLpBalance&&f.userBaseLpToTokenBalance))return;let e=new Pe(0);if(null===(s=f.totalBaseLpBalance)||void 0===s?void 0:s.lte(0))e=f.userBaseLpBalance||new Pe(0);else if(f.baseReserve.gt(0)&&f.quoteReserve.eq(0)){let t=M;M.gte(f.userBaseLpToTokenBalance)&&(t=f.userBaseLpToTokenBalance),e=t.multipliedBy(f.totalBaseLpBalance).div(f.baseReserve)}else if(f.baseReserve.gt(0)&&f.quoteReserve.gt(0)){let t=M;M.gte(f.userBaseLpToTokenBalance)&&(t=f.userBaseLpToTokenBalance);let n,i=B;if(f.userQuoteLpToTokenBalance&&B.gte(f.userQuoteLpToTokenBalance)&&(i=f.userQuoteLpToTokenBalance),i.gt(0)&&(null===(l=f.userQuoteLpToTokenBalance)||void 0===l?void 0:l.gt(0))&&(n=i.div(f.userQuoteLpToTokenBalance)),t.gt(0)&&f.userBaseLpToTokenBalance.gt(0)&&(n=t.div(f.userBaseLpToTokenBalance)),(null==n?void 0:n.gte(1))&&(n=new Pe(1)),!n)return;e=n.multipliedBy(f.userBaseLpBalance);const o=e.dp(F,Pe.ROUND_FLOOR).div(f.totalBaseLpBalance);t=o.multipliedBy(f.baseReserve).dp(F,Pe.ROUND_FLOOR),i=o.multipliedBy(f.quoteReserve).dp(U,Pe.ROUND_FLOOR),$=zt(t.multipliedBy(1-W).dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),z=zt(i.multipliedBy(1-W).dp(U,Pe.ROUND_FLOOR).toString(),U).toString()}const i=O||L,o=[n,_,t,e.isNaN()?"0":zt(e.dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),$,z,i,Math.ceil(Date.now()/1e3)+(null!=r?r:600)];H=R?yield ye.encode.removeDSPLiquidityABI(...o):yield ye.encode.removeDVMLiquidityABI(...o)}}catch(e){throw new Error(`v2 addDVMLiquidity or removeDVMLiquidity or removeDSPLiquidity error: ${e}`)}if(H&&H.data){const r={};if(h){const i=null===(d=o.getQueryData(ip.getFetchTokenQuery(n,T.address,t).queryKey))||void 0===d?void 0:d.balance;i&&(r[T.address]=i.toString()),e.baseLpToken&&(null==f?void 0:f.userBaseLpBalance)&&(r[e.baseLpToken.id]=f.userBaseLpBalance.toString())}if(m){const i=null===(c=o.getQueryData(ip.getFetchTokenQuery(n,I.address,t).queryKey))||void 0===c?void 0:c.balance;i&&(r[I.address]=i.toString()),e.quoteLpToken&&(null==f?void 0:f.userQuoteLpBalance)&&(r[e.quoteLpToken.id]=f.userQuoteLpBalance.toString())}try{let e;C&&O&&(H.value=AI(D?"0":M)),C&&L&&(H.value=AI(N?"0":B)),D||(e=`${M.toString()}${q}`),N||(e=D?`${B.toString()}${V}`:`${e} & ${B.toString()}${V}`);(yield i.execute(b,Object.assign(Object.assign({opcode:Pg.TX},H),{value:null!==(u=H.value)&&void 0!==u?u:0}),{subtitle:e,metadata:{[C?Sg.addLiquidity:Sg.removeLiquidity]:!0,logBalance:r},submittedBack:y}))===Eg.Success&&v&&v()}catch(e){throw Error(`v2 sendTransaction error: ${e}`)}}}))}),l="DPP"===(null==e?void 0:e.type)?a:s;return H.useEffect((()=>{l.reset()}),[e]),{operateLiquidityMutation:l}};function QI({baseToken:e,quoteToken:n,baseAmount:i,quoteAmount:o,slippage:r,fee:a,isExists:s,successBack:l,submittedBack:d}){const c=Fg(),{account:u}=dg();t();const{deadLine:p}=Jn();return it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){var t,h;if(!e||!n)throw new Error("token is undefined");if(!u)throw new Error("account is undefined");if(!a)throw new Error("fee is undefined");const m=e.chainId,g=we[m].address.toLowerCase(),f=dt(m),x=mt(m),y=!f,v=f||x;if(!v)throw new Error("AMMV2 contract address is not valid.");let b="",j="0x0";const C=e.address.toLowerCase()===g,w=n.address.toLowerCase()===g,k=Pm(i,e.decimals),T=Pm(o,n.decimals),I=k.times(1-r).dp(0,Pe.ROUND_FLOOR),S=T.times(1-r).dp(0,Pe.ROUND_FLOOR),E=Pm(a,4).toString(),A=Math.ceil(Date.now()/1e3)+(null!=p?p:600);try{if(C){const e=n.address,i=T.toString(),o=S.toString(),r=I.toString();j=null!==(t=EI(k))&&void 0!==t?t:"",b=y?gt(e,i,o,r,u,A):ft(e,E,i,o,r,u,A)}else if(w){const t=e.address,n=k.toString(),i=I.toString(),o=S.toString();j=null!==(h=EI(T))&&void 0!==h?h:"",b=y?gt(t,n,i,o,u,A):ft(t,E,n,i,o,u,A)}else b=y?xt(e.address,n.address,k.toString(),T.toString(),I.toString(),S.toString(),u,A):yt(e.address,n.address,E,k.toString(),T.toString(),I.toString(),S.toString(),u,A)}catch(e){throw console.error("encodeUniswapV2Router02AddLiquidity error",e),e}return yield c.execute(s?se._({id:"E6MqGy",message:"Add liquidity"}):se._({id:"L37FfW",message:"Create AMM V2 Position"}),{opcode:Pg.TX,to:v,data:b,value:j},{metadata:{[s?Sg.addLiquidityAMMV2Position:Sg.createAMMV2Position]:!0},successBack:l,submittedBack:d})}))})}function YI({lqAndDodoCompareText:t,baseToken:n,quoteToken:o,midPrice:r}){const a=r?Em({input:r}):"";return Yn.jsxs(i,{sx:{p:10,mb:12,backgroundColor:"background.paperDarkContrast",borderRadius:12},children:[Yn.jsxs(i,{sx:{typography:"body2",display:"flex",alignItems:"center",justifyContent:"center",color:"error.main",fontWeight:600,mb:10,textAlign:"center"},children:[Yn.jsx(i,{component:li.Alarm,sx:{mr:4}}),se._({id:"YUyuNp",message:"{lqAndDodoCompareText} Price Difference",values:{lqAndDodoCompareText:t}})]}),Yn.jsxs(i,{sx:{typography:"h6",color:"text.secondary",textAlign:"center"},children:[Yn.jsx(e,{id:"ZhEBp4",message:"Current liquidity pool token price"}),` 1 ${null==n?void 0:n.symbol} = ${a} ${null==o?void 0:o.symbol} ${se._({id:"wd1uHY",message:"differs from the price quoted by ZUNO by {lqAndDodoCompareText}",values:{lqAndDodoCompareText:t}})}`]})]})}function KI({chainId:t,baseTokenStatus:n,quoteTokenStatus:o,children:r}){const{runningRequests:a}=Ug(),{account:s,chainId:l}=dg();if(!s||t!==l)return Yn.jsx(cC,{chainId:t,fullWidth:!0});const d=a.some((e=>{var t,n;return(null===(t=e.metadata)||void 0===t?void 0:t[Sg.addLiquidity])||(null===(n=e.metadata)||void 0===n?void 0:n[Sg.removeLiquidity])})),u=[];n.needShowTokenStatusButton&&u.push(Yn.jsx(SI,{status:n})),o.needShowTokenStatusButton&&!n.isApproving&&u.push(Yn.jsx(SI,{status:o}));const p=u.length;return 2===p?Yn.jsx(i,{sx:{display:"flex","& > button":{flex:1,"&:last-child":{ml:8}}},children:u.map((e=>e))}):1===p?u[0]:d?Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:Yn.jsx(e,{id:"UbRKMZ",message:"Pending"})}):Yn.jsx(Yn.Fragment,{children:r})}function XI({pool:t,addPortion:n,midPrice:o,shareOfPool:r}){var s,d,c,u,p,h;const m=a(),[g,x]=z(!1);let y="";if(n&&o){const e=new Pe(1).div(n.plus(1)),i=new Pe(n).div(n.plus(1)),r=e.times(o),a=r.plus(i);y=n?`${Vm({input:r.div(a)})} ${null===(s=null==t?void 0:t.baseToken)||void 0===s?void 0:s.symbol} + ${Vm({input:i.div(a)})} ${null===(d=null==t?void 0:t.quoteToken)||void 0===d?void 0:d.symbol}`:""}const b=g?null===(c=null==t?void 0:t.quoteToken)||void 0===c?void 0:c.symbol:null===(u=null==t?void 0:t.baseToken)||void 0===u?void 0:u.symbol,j=g&&o?new Pe(1).div(o):o,C=g?null===(p=null==t?void 0:t.baseToken)||void 0===p?void 0:p.symbol:null===(h=null==t?void 0:t.quoteToken)||void 0===h?void 0:h.symbol;return Yn.jsxs(i,{sx:{mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[Yn.jsx(i,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"kNeEXg",message:"Current Price"})}),Yn.jsxs(v,{sx:{display:"flex",alignItems:"center",fontWeight:600,ml:8,overflow:"hidden"},loading:!t,loadingProps:{width:50},children:[Yn.jsx(l,{title:`1 ${b} = ${j?Em({input:j}):""} ${C}`,children:o?Yn.jsx(i,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${b} = ${j?Em({input:j}):""} ${C}`}):Yn.jsxs(i,{children:[`1 ${b} = `,Yn.jsx(v,{loading:!0,loadingProps:{width:30},component:"span",sx:{display:"inline-block"}}),` ${C}`]})}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,cursor:"pointer",backgroundColor:"background.paperDarkContrast",borderRadius:"50%","&:hover":{backgroundColor:T(m.palette.text.primary,.04)}},onClick:()=>x((e=>!e)),children:Yn.jsx(i,{component:li.Switch,sx:{width:18,height:18}})})]})]}),"AMMV2"===(null==t?void 0:t.type)?Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:m.spacing(1,0,0),borderColor:"border.main"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"NEQTCn",message:"Share Of Pool"})}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:r})]}):Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:m.spacing(1,0,0),borderColor:"border.main"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:[Yn.jsx(e,{id:"22Xs8M",message:"Deposit Ratio"}),Yn.jsx(f,{ml:4,title:Yn.jsx(e,{id:"I0yi1d",message:"Deposit ratio is determined by the current assets ratio in the pool. The ratio does not represent the exchange price"})})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:t&&ye.utils.singleSideLp(t.type)?Yn.jsx(e,{id:"Kb3KaW",message:"Any Ratio"}):Yn.jsx(Yn.Fragment,{children:Yn.jsx(l,{title:y,children:Yn.jsx(i,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y})})})})]})]})}function JI({baseToken:e,quoteToken:t}){const{toFiatPrice:n,fromFiatPrice:i}=Wg({fromToken:null!=e?e:null,toToken:null!=t?t:null});return function({fromToken:e,toToken:t,fromFiatPrice:n,toFiatPrice:i,reverse:o,showDecimals:r=1}){const a={comparePrice:null,comparePriceText:"",loading:!0};return e&&t&&n&&i?(o?(a.loading=!1,a.comparePrice=i.div(n),a.comparePriceText=`1 ${og(t)} = ${Em({input:a.comparePrice,showDecimals:r})} ${og(e)}`):(a.loading=!1,a.comparePrice=n.div(i),a.comparePriceText=`1 ${og(e)} = ${Em({input:a.comparePrice,showDecimals:r})} ${og(t)}`),a):a}({fromToken:e,toToken:t,fromFiatPrice:i?new Pe(i):void 0,toFiatPrice:n?new Pe(n):void 0})}const eS=(e,t,n)=>{const{comparePrice:i}=JI({baseToken:e,quoteToken:t}),o=$((()=>{if(!(n&&i&&i.toNumber()&&n.toNumber()))return 0;const e=i.minus(n);return Math.abs(e.div(i).toNumber())}),[n,i]),r=$((()=>`${Um(new Pe(o).times(100))}%`),[o]);return{lqAndDodoCompare:o,lqAndDodoCompareText:r,midPrice:n,isShowCompare:o>.01,isWarnCompare:o>.03}};function tS({pool:e,baseAmount:t,quoteAmount:n}){const[i,o,r,a,s,l]=H.useMemo((()=>{var t,n;const{baseToken:i,quoteToken:o}=e||{};let r=!1;if(!i||!o)return[void 0,void 0,void 0,void 0,void 0,r];const a=i.chainId,s=we[a],l=(null===(t=s.address)||void 0===t?void 0:t.toLowerCase())===i.address.toLowerCase(),d=(null===(n=s.address)||void 0===n?void 0:n.toLowerCase())===o.address.toLowerCase(),c=l?s.wrappedTokenAddress:i.address,u=d?s.wrappedTokenAddress:o.address,p=new Sn(i.chainId,c,i.decimals,i.symbol,i.name),h=new Sn(o.chainId,u,o.decimals,o.symbol,o.name);r=!p.sortsBefore(h);const[m,g]=r?[h,p]:[p,h];return[a,null==e?void 0:e.type,null==e?void 0:e.address,m,g,r]}),[e]),d=$m.getReserveLpQuery(i,r,o,null==a?void 0:a.decimals,null==s?void 0:s.decimals),c="AMMV2"===o,u=et(Object.assign(Object.assign({},d),{enabled:!!d.enabled&&c})),p=$m.getTotalBaseLpQuery(i,r,o,18),h=et(Object.assign(Object.assign({},p),{enabled:!!p.enabled&&c})),{account:m}=dg(),g=$m.getUserBaseLpQuery(i,r,o,18,m),f=et(Object.assign(Object.assign({},g),{enabled:!!g.enabled&&c})),x=H.useMemo((()=>u.isFetched&&!!u.data&&h.isFetched&&!!h.data),[u.isFetched,u.data,h.isFetched,h.data]),[y,v]=H.useMemo((()=>{var e;if(!a||!s||!1===x)return[null,null];const{baseReserve:t,quoteReserve:n}=null!==(e=u.data)&&void 0!==e?e:{baseReserve:0,quoteReserve:0},i=En.fromRawAmount(a,Pm(t,a.decimals).toString()),o=En.fromRawAmount(s,Pm(n,s.decimals).toString());let r=i,d=o;l&&(r=o,d=i);const c=new Ln(r,d);if(r.equalTo(0)||d.equalTo(0))return[c,null];const p=d.divide(r);return[c,new An(r.currency,d.currency,p.denominator,p.numerator)]}),[a,s,u.data,l]),[b,j]=H.useMemo((()=>x?v?[new Pe(v.toSignificant()),new Pe(v.invert().toSignificant())]:[void 0,void 0]:t&&n?[new Pe(n).div(t),new Pe(t).div(n)]:[void 0,void 0]),[v,x,t,n]),C=h.data,w=x?h.data&&a?Pm(h.data,18).toString():"":"0";let k,T;const I=l?s:a,S=l?a:s;if((null==y?void 0:y.liquidityToken)&&w&&C&&I&&S){const e=En.fromRawAmount(null==y?void 0:y.liquidityToken,w);if(void 0!==t&&void 0!==n){if(Number(t)&&Number(n)){const i=En.fromRawAmount(I,Pm(t,I.decimals).toString()),o=En.fromRawAmount(S,Pm(n,S.decimals).toString()),r=null==y?void 0:y.getLiquidityMinted(e,i,o);T=_m(r.quotient.toString(),18),k=T.div(C.plus(T)).times(100)}}else T=f.data||void 0,T&&(k=T.div(C).times(100))}else x||(k=new Pe(100));let E="-";return(null==e?void 0:e.baseToken)&&e.quoteToken&&(E=k?`${Em({input:k,showDecimals:2,roundingMode:Pe.ROUND_HALF_UP})}%`:"0%"),{isRearTokenA:l,pair:y,price:b,invertedPrice:j,reserveQuery:u,totalBaseLpQuery:h,liquidityMinted:T,poolTokenPercentage:k,shareOfPool:E,isExists:x}}function nS({pool:e,maxBaseAmount:t,maxQuoteAmount:n,isRemove:i}){var o,r,a;const[s,l]=H.useState(""),[d,c]=H.useState(""),u=!e||"AMMV2"!==e.type&&"AMMV3"!==e.type,p=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(o=null==e?void 0:e.baseToken)||void 0===o?void 0:o.decimals,null===(r=null==e?void 0:e.quoteToken)||void 0===r?void 0:r.decimals)),h=()=>{l(""),c("")},m=null==e?void 0:e.type,g=tS({pool:e,baseAmount:s,quoteAmount:d});let f=null===(a=p.data)||void 0===a?void 0:a.midPrice,x=new Pe(NaN),y=!1,v=!1;const b=p.data;if(e)if(b){const t=b.pmmParamsBG.i,n=b.pmmParamsBG.b,i=b.pmmParamsBG.q;v=("DSP"===e.type||"GSP"===e.type)&&(i.eq(0)||n.eq(0)),y="DVM"===e.type&&new Pe(i).eq(0),x=v?t:y?Pe(1):i.div(n)}else"AMMV2"===m&&(f=g.isRearTokenA?g.invertedPrice:g.price,x=f||new Pe(1));const j=H.useRef(x);if(!e||x.isNaN())return{baseAmount:s,quoteAmount:d,handleChangeBaseAmount:()=>{},handleChangeQuoteAmount:()=>{},reset:h};const C=!y&&!ye.utils.singleSideLp(e.type),w=e.baseToken.decimals,k=e.quoteToken.decimals,T=e=>{if(e){let o=x.multipliedBy(e).dp(k).toString();n&&i&&(n.lte(o)||(null==t?void 0:t.lte(0)))&&(o=n.toString()),c(o)}else c(e)};!C||j.current&&x.isEqualTo(j.current)||(j.current=x,T(s));let I=!1;I=!!e&&ye.utils.singleSideLp(e.type)?!s&&!d:y?!s:!s||!d;const S=u?p:g.reserveQuery;return{baseAmount:s,quoteAmount:d,handleChangeBaseAmount:e=>{let t=Rm(e,w);null===t&&(t=s),l(t),C&&T(t)},handleChangeQuoteAmount:e=>{let o=Rm(e,k);null===o&&(o=d),c(o),C&&(e=>{if(e){let o=new Pe(e).div(x).dp(w).toString();t&&i&&(t.lte(o)||(null==n?void 0:n.lte(0)))&&(o=t.toString()),l(o)}else l(e)})(o)},reset:h,addPortion:x,amountLoading:S.isLoading,amountError:S.isError,amountRefetch:S.refetch,amountCheckedDisabled:I,midPrice:f,uniV2Pair:g}}function iS({submittedBack:e,onlyShowSide:t,pool:n,balanceInfo:o}){var r,s,l,d,u,p;const h=a(),{isMobile:m}=Tg(),{account:g}=dg(),{baseAmount:f,quoteAmount:x,handleChangeBaseAmount:y,handleChangeQuoteAmount:b,addPortion:j,midPrice:C,amountLoading:w,amountCheckedDisabled:k,uniV2Pair:T,reset:I}=nS({pool:n}),S=et($m.getFeeRateQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,g)),E=null===(u=null===(s=null===(r=S.data)||void 0===r?void 0:r.mtFeeRate)||void 0===s?void 0:s.plus(null!==(d=null===(l=S.data)||void 0===l?void 0:l.lpFeeRate)&&void 0!==d?d:0))||void 0===u?void 0:u.toNumber(),A="AMMV2"===(null==n?void 0:n.type),[O,L]=H.useState(!1),{slipper:R,setSlipper:P,slipperValue:_,resetSlipper:M}=oC({address:null==n?void 0:n.address,type:null==n?void 0:n.type}),B=wC(n);H.useEffect((()=>{(null==n?void 0:n.address)!==(null==B?void 0:B.address)&&(I(),M())}),[n]);const D=ye.utils.canOperateLiquidity(null==n?void 0:n.type,void 0,null==n?void 0:n.creator,g),[N,F]=H.useState(!1),{isShowCompare:U,lqAndDodoCompareText:q,isWarnCompare:V}=eS(null==n?void 0:n.baseToken,null==n?void 0:n.quoteToken,C),W=A&&n.chainId?dt(n.chainId)||mt(n.chainId):void 0,$=lf(null==n?void 0:n.baseToken,{amount:f,contractAddress:W}),z=lf(null==n?void 0:n.quoteToken,{amount:x,contractAddress:W}),Z=$.insufficientBalance||z.insufficientBalance,{isSinglePool:G}=o,Q=!n||Z||!C||!!o.loading||!!o.error||k||S.isLoading;let Y=A?se._({id:"bwSQI0",message:"Supply"}):se._({id:"m16xKo",message:"Add"});Z&&(Y=se._({id:"znqB4T",message:"Insufficient balance"}));const K=()=>{I(),M(),e&&e()},{operateLiquidityMutation:X}=GI(n),J=()=>{A?L(!0):X.mutate({txTitle:se._({id:"OBdohg",message:"Add Liquidity"}),isRemove:!1,baseAmount:f,quoteAmount:x,slippageProtection:_,balanceInfo:o,SLIPPAGE_PROTECTION:iC,submittedBack:K})},ee=QI({baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,baseAmount:f,quoteAmount:x,fee:E,isExists:!0,slippage:_,submittedBack:()=>{K(),L(!1)}});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:20,pb:18,px:20},children:["quote"===t?"":Yn.jsx(hj,{amt:f,token:null==n?void 0:n.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:y,readOnly:o.loading||!D,sx:{backgroundColor:"background.cardInput",padding:h.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),t?"":Yn.jsx(uj,{}),"base"===t?"":Yn.jsx(hj,{amt:x,token:null==n?void 0:n.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:b,readOnly:o.loading||!D||G,sx:{backgroundColor:"background.cardInput",padding:h.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}),Yn.jsxs(v,{loading:o.loading||w,sx:{mt:8},children:[Yn.jsx(rC,{value:R,onChange:P,disabled:!D,type:null==n?void 0:n.type}),Yn.jsx(XI,{pool:n,addPortion:j,midPrice:C,shareOfPool:null==T?void 0:T.shareOfPool})]})]}),Yn.jsxs(i,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[U&&Yn.jsx(YI,{baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,lqAndDodoCompareText:q,midPrice:C}),n?Yn.jsx(KI,{chainId:n.chainId,baseTokenStatus:$,quoteTokenStatus:z,children:Yn.jsx(c,{fullWidth:!0,disabled:Q,danger:V,isLoading:X.isPending||ee.isPending,onClick:()=>{Q||(V?F(!0):J())},children:Y})}):Yn.jsx(c,{fullWidth:!0,disabled:!0,children:Y})]}),Yn.jsx(FI,{open:N,onClose:()=>F(!1),title:se._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:J,modal:!0,children:Yn.jsxs(i,{children:[Yn.jsx(i,{children:se._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:q}})}),Yn.jsx(i,{children:se._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),Yn.jsx(ub,{message:null===(p=X.error)||void 0===p?void 0:p.message,onClose:()=>X.reset(),isDialogModal:m}),A&&!!n&&Yn.jsx(WI,{open:O,onClose:()=>L(!1),slippage:_,baseToken:n.baseToken,baseAmount:f,quoteToken:n.quoteToken,quoteAmount:x,fee:E,price:null==T?void 0:T.price,lpAmount:null==T?void 0:T.liquidityMinted,shareOfPool:null==T?void 0:T.shareOfPool,pairAddress:n.address,createMutation:ee})]})}function oS({chainId:e,address:t,token:n,quoteToken:o,lpBalance:a,lpBalanceLoading:s,balanceNeedUpdateLoading:d,tokenBalanceList:c}){var u;const p=o?`${null==n?void 0:n.symbol}/${o.symbol}`:null!==(u=null==n?void 0:n.symbol)&&void 0!==u?u:"";return Yn.jsxs(i,{sx:{display:"flex"},children:[n?Yn.jsx(i,{sx:{position:"relative",top:2},children:o?Yn.jsx(kj,{tokens:[n,o],chainId:e,width:18,mr:4}):Yn.jsx(Df,{address:n.address,width:18,height:18,chainId:e,url:n.logoURI,marginRight:4,noShowChain:!0})}):Yn.jsx(j,{width:32,height:32,sx:{mr:4}}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",wordBreak:"break-all"},children:[Yn.jsx(v,{loading:s,loadingProps:{width:30},sx:{display:"flex",alignItems:"center",mr:2},children:d?Yn.jsx(L,{}):Em({input:a||"-"})}),`${p} LP`,!!(null==c?void 0:c.length)&&Yn.jsx(l,{title:Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:c.map((e=>Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",fontWeight:600,color:"text.primary"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{address:e.token.address,chainId:e.token.chainId,width:14,height:14,url:e.token.logoURI,marginRight:4,noShowChain:!0}),e.token.symbol]}),Yn.jsxs(v,{loading:e.loading,children:[!e.balance||e.balance.isZero()||e.balance.isNaN()?"":"~",e.balance?Em({input:e.balance}):""]})]},e.token.address)))}),sx:{padding:20,width:256},children:Yn.jsx(r,{component:li.DetailBorder,sx:{ml:4,width:16,height:16}})}),Yn.jsx(i,{component:"a",target:"_blank",rel:"noopener noreferrer",href:e?tg(e,t,"address"):"",sx:{display:"inline-flex",height:14},children:Yn.jsx(r,{component:li.ArrowTopRightBorder,sx:{ml:4,width:14,height:14}})})]})]},t)}function rS({loading:t,hidePoolInfo:n,pool:o,balanceInfo:r}){var s,c,u,p,h,m,g;const f=a(),x=t||!o,y=!!o&&ye.utils.singleSideLp(o.type),{isTokenLoading:b}=Mb(),{account:j}=dg(),C=et($m.getFeeRateQuery(null==o?void 0:o.chainId,null==o?void 0:o.address,null==o?void 0:o.type,j)),w=null===(c=null===(s=C.data)||void 0===s?void 0:s.lpFeeRate)||void 0===c?void 0:c.plus(null!==(p=null===(u=C.data)||void 0===u?void 0:u.mtFeeRate)&&void 0!==p?p:0);let k=!1,T=!1;o&&(r.userBaseLpBalance&&o.baseLpToken&&(k=b(o.baseLpToken.id,r.userBaseLpBalance)),r.userQuoteLpBalance&&o.quoteLpToken&&(T=b(o.quoteLpToken.id,r.userQuoteLpBalance)));const I="AMMV2"===(null==o?void 0:o.type);return Yn.jsxs(i,{sx:{mt:16,mx:20,border:"solid 1px",borderColor:"border.main",borderRadius:12},children:[n?"":Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:f.spacing(12,20),borderStyle:"solid",borderColor:"border.main",borderWidth:f.spacing(0,0,1)},children:[Yn.jsxs(i,{children:[Yn.jsxs(v,{loading:x,loadingSx:{width:100,mb:4},sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[null===(h=null==o?void 0:o.baseToken)||void 0===h?void 0:h.symbol,"/",null===(m=null==o?void 0:o.quoteToken)||void 0===m?void 0:m.symbol,"AMMV2"===(null==o?void 0:o.type)&&Yn.jsx(v,{loading:C.isLoading,loadingProps:{width:30},sx:{typography:"h6"},children:Yn.jsx(l,{title:Yn.jsxs(i,{sx:{typography:"h6","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",Yn.jsx("b",{children:Yn.jsx(e,{id:"e38JNU",message:"Tips:"})})," ",Yn.jsx(e,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vm({input:w})},components:{0:Yn.jsx("b",{})}})]}),sx:{maxWidth:240},children:Yn.jsx(i,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:f.palette.background.tag,color:"text.secondary",whiteSpace:"nowrap"},children:Vm({input:w})})})})]}),Yn.jsx(v,{loading:x,children:Yn.jsx(zb,{address:null!==(g=null==o?void 0:o.address)&&void 0!==g?g:"",truncate:!0,iconSize:14,iconSpace:4,customChainId:null==o?void 0:o.chainId,sx:{typography:"h6",color:"text.secondary"}})})]}),(null==o?void 0:o.address)&&!I?Yn.jsxs(i,{component:d,sx:{typography:"body2",display:"flex",alignItems:"center",color:"text.secondary"},onClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:o.chainId,address:o.address}})},children:[Yn.jsx(e,{id:"URmyfc",message:"Details"}),Yn.jsx(i,{component:li.ArrowRight,sx:{ml:4,position:"relative",top:1.2,width:16,height:16}})]}):""]}),Yn.jsxs(i,{sx:{p:f.spacing(12,20)},children:[Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),Yn.jsx(i,{sx:{mt:12},children:Yn.jsx(v,{loading:x,loadingSx:{width:100},children:y?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(oS,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,lpBalance:null==r?void 0:r.userBaseLpBalance,lpBalanceLoading:r.userLpBalanceLoading,balanceNeedUpdateLoading:k,tokenBalanceList:o?[{token:o.baseToken,balance:null==r?void 0:r.userBaseLpToTokenBalance,loading:r.userLpToTokenBalanceLoading}]:void 0}),Yn.jsx(oS,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.quoteToken,lpBalance:null==r?void 0:r.userQuoteLpBalance,lpBalanceLoading:r.userLpBalanceLoading,balanceNeedUpdateLoading:T,tokenBalanceList:o?[{token:o.quoteToken,balance:null==r?void 0:r.userQuoteLpToTokenBalance,loading:r.userLpToTokenBalanceLoading}]:void 0})]}):Yn.jsx(oS,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,quoteToken:null==o?void 0:o.quoteToken,lpBalance:r.userBaseLpBalance,lpBalanceLoading:r.userLpBalanceLoading,balanceNeedUpdateLoading:k,tokenBalanceList:o?[{token:o.baseToken,balance:r.userBaseLpToTokenBalance||new Pe(0),loading:r.userLpToTokenBalanceLoading},{token:o.quoteToken,balance:r.userQuoteLpToTokenBalance||new Pe(0),loading:r.userLpToTokenBalanceLoading}]:void 0})})})]})]})}const aS=({pool:e,isBase:t,baseAmount:n,quoteAmount:i})=>{var o,r;const a="CLASSICAL"===(null==e?void 0:e.type),s=t||void 0===t,l=null===(o=null==e?void 0:e.baseToken)||void 0===o?void 0:o.decimals,d=null===(r=null==e?void 0:e.quoteToken)||void 0===r?void 0:r.decimals,c=et(Object.assign(Object.assign({},$m.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,n&&void 0!==l?zt(new Pe(n).dp(l,Pe.ROUND_FLOOR).toString(),l).toString():"",l)),{enabled:!!e&&!!n&&a&&s})),u=et(Object.assign(Object.assign({},$m.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,i&&void 0!==d?zt(new Pe(i).dp(d,Pe.ROUND_FLOOR).toString(),d).toString():"",d)),{enabled:!!e&&!!i&&a&&!s}));let p,h="",m="",g="",f="",x="",y=!1,v=null;if(e){const t=rg(e.baseToken.decimals),o=rg(e.quoteToken.decimals);if(g=Em({input:n,showDecimals:t}),f=Em({input:i,showDecimals:o}),a)if(y=s?c.isLoading:u.isLoading,v=s?c.error:u.error,s){if(c.data){h=Em({input:c.data,showDecimals:t}),x=h;const e=new Pe(n).minus(c.data);g=e.gt(0)?Em({input:e,showDecimals:t}):"-",p=e}}else if(u.data){m=Em({input:u.data,showDecimals:o}),x=m;const e=new Pe(i).minus(u.data);g=e.gt(0)?Em({input:e,showDecimals:t}):"-",p=e}}let b=[];return e&&(a?t?b.push({amount:g||"0",symbol:e.baseToken.symbol}):b.push({amount:f||"0",symbol:e.quoteToken.symbol}):(b.push({amount:g||"0",symbol:e.baseToken.symbol}),b.push({amount:f||"0",symbol:e.quoteToken.symbol}))),{withdrawFee:x,baseWithdrawFee:h,quoteWithdrawFee:m,receiveBaseAmount:g,receiveQuoteAmount:f,receiveAmountBg:p,receiveList:b,loading:y,error:v}};var sS;!function(e){e[e.base=1]="base",e[e.quote=2]="quote"}(sS||(sS={}));const lS=e=>{const[t,n]=H.useState(sS.base);let i,o;return e&&ye.utils.singleSideLp(e.type)&&(i=t===sS.base,o=i?e.baseToken:e.quoteToken),{isBase:i,checkToken:o,checkTokenType:t,setCheckToken:n}};function dS({token:e,pool:t,sx:n,value:o,onChange:r,selectedValue:a,lpBalance:s,balanceMax:l,balanceInfo:d,loading:c}){var u;const p=null==t?void 0:t.chainId;return Yn.jsxs(i,{sx:n,children:[Yn.jsxs(i,{sx:{typography:"h5",display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:600},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[e?Yn.jsx(U,{checked:o===a,onChange:()=>r(o),sx:{mr:16}}):"",Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:e?Yn.jsx(Yn.Fragment,{children:Yn.jsx(Df,{address:e.address,width:24,height:24,chainId:e.chainId||p,url:e.logoURI,noShowChain:!0})}):t&&Yn.jsx(kj,{tokens:[t.baseToken,t.quoteToken],chainId:(null===(u=t.baseToken)||void 0===u?void 0:u.chainId)||p,width:24,height:24})})]}),Yn.jsxs(i,{sx:{textAlign:"right"},children:[e?`${e.symbol} LP `:t&&`${t.baseToken.symbol}\n ${t.quoteToken.symbol}\n LP `,c?Yn.jsx(i,{component:L,sx:{ml:4,position:"relative",top:3}}):s&&Em({input:s})||""]})]}),Yn.jsx(i,{sx:{typography:"body2",mt:5,color:"text.secondary",textAlign:"right"},children:e?Yn.jsxs(Yn.Fragment,{children:[c?Yn.jsx(i,{component:L,sx:{ml:4,position:"relative",top:3}}):`≈ ${l&&Em({input:l})||""}`,` ${e.symbol}`]}):t&&d&&d.userBaseLpToTokenBalance&&d.userQuoteLpToTokenBalance?Yn.jsxs(Yn.Fragment,{children:[c?Yn.jsx(i,{component:L,sx:{position:"relative",top:4}}):Em({input:d.userBaseLpToTokenBalance}),` ${null==t?void 0:t.baseToken.symbol} + `,c?Yn.jsx(i,{component:L,sx:{position:"relative",top:4}}):Em({input:d.userQuoteLpToTokenBalance}),` ${null==t?void 0:t.quoteToken.symbol}`]}):""})]})}function cS({pool:e,checkTokenType:t,setCheckToken:n,balanceInfo:i,baseTokenBalanceUpdateLoading:o,quoteBalanceUpdateLoading:r}){if(!e)return null;const a=ye.utils.singleSideLp(e.type);return Yn.jsx(Yn.Fragment,{children:a?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(dS,{token:e.baseToken,selectedValue:t,onChange:n,value:sS.base,lpBalance:i&&i.userBaseLpBalance,balanceMax:i&&i.userBaseLpToTokenBalance,loading:o}),Yn.jsx(dS,{selectedValue:t,onChange:n,sx:{mt:13},token:e.quoteToken,value:sS.quote,lpBalance:i&&i.userQuoteLpBalance,balanceMax:i&&i.userQuoteLpToTokenBalance,loading:r})]}):Yn.jsx(dS,{pool:e,value:t,onChange:n,lpBalance:i&&i.userBaseLpBalance,balanceInfo:i,loading:o||r})})}function uS({submittedBack:n,onlyShowSide:o,pool:r,balanceInfo:s}){var l,d,u,p,h,m,g,f,x,y;const b=a(),{isMobile:j}=Tg(),{account:C}=dg(),w=s.userBaseLpToTokenBalance,k=s.userQuoteLpToTokenBalance,T=s.loading,{slipper:I,setSlipper:S,slipperValue:E,resetSlipper:A}=oC({address:null==r?void 0:r.address}),{isBase:O,checkToken:L,checkTokenType:R,setCheckToken:P}=lS(r),{baseAmount:_,quoteAmount:M,handleChangeBaseAmount:B,handleChangeQuoteAmount:D,addPortion:N,midPrice:F,amountLoading:U,amountCheckedDisabled:V,uniV2Pair:W,reset:z}=nS({pool:r,maxBaseAmount:w,maxQuoteAmount:k}),[Z,G]=H.useState(""),[Q,Y]=H.useState("");H.useEffect((()=>{const e=setTimeout((()=>{G(_)}),80);return()=>clearTimeout(e)}),[_]),H.useEffect((()=>{const e=setTimeout((()=>{Y(M)}),80);return()=>clearTimeout(e)}),[M]);const K=e=>{B(e)},X=e=>{D(e)},J="AMMV2"===(null==r?void 0:r.type),ee=(null==r?void 0:r.chainId)?we[r.chainId]:void 0,te=null===(l=null==ee?void 0:ee.address)||void 0===l?void 0:l.toLowerCase(),ne=null===(d=null==ee?void 0:ee.wrappedTokenAddress)||void 0===d?void 0:d.toLowerCase(),ie=!!r&&[te,ne].includes(r.baseToken.address.toLowerCase()),oe=!!r&&[te,ne].includes(r.quoteToken.address.toLowerCase()),re=J&&r&&(ie||oe),[ae,le]=H.useState(!1),de=re&&ie&&!ae&&ee?r?Object.assign(Object.assign({},r.baseToken),{symbol:ee.symbol,address:ee.address}):void 0:null==r?void 0:r.baseToken,ce=re&&oe&&!ae&&ee?r?Object.assign(Object.assign({},r.quoteToken),{symbol:ee.symbol,address:ee.address}):void 0:null==r?void 0:r.quoteToken,ue=aS({pool:r?Object.assign(Object.assign({},r),{baseToken:de,quoteToken:ce}):r,isBase:O,baseAmount:Z,quoteAmount:Q}),{mode:pe,modeOptions:he,handleChangeMode:me,sliderPercentage:ge,handleChangeSliderPercentage:fe,resetPercentage:xe}=function({isBase:e,pool:t,baseOverride:n,quoteOverride:i,resetAmount:o,handleChangeBaseAmount:r,handleChangeQuoteAmount:a}){const[s,l]=H.useState(sC.percentage),[d,c]=H.useState(aC),u=H.useRef(null),p=()=>{u.current&&clearTimeout(u.current)},h=()=>{p(),c(aC)};return H.useEffect((()=>p),[]),{mode:s,modeOptions:[{key:sC.quantity,value:se._({id:"PIYEqF",message:"Quantity model"})},{key:sC.percentage,value:se._({id:"x4QVeW",message:"Percentage to remove"})}],handleChangeMode:e=>{l(e),o(),h()},sliderPercentage:d,handleChangeSliderPercentage:o=>{if(p(),o!==d&&c(o),!t)return;const s=100===o,l=()=>{if(t)if(e||void 0===e){if(n){let e=n.toString();s||(e=Lm(n.times(o/100),t.baseToken.decimals)),r(e)}}else if(i){let e=i.toString();s||(e=Lm(i.times(o/100),t.quoteToken.decimals)),a(e)}};s?l():u.current=setTimeout(l,100)},resetPercentage:h}}({isBase:O,pool:r,baseOverride:w,quoteOverride:k,resetAmount:z,handleChangeBaseAmount:K,handleChangeQuoteAmount:X});H.useEffect((()=>{z(),xe()}),[R]);const ve=wC(r);H.useEffect((()=>{(null==r?void 0:r.address)!==(null==ve?void 0:ve.address)&&(z(),A(),me(sC.percentage),fe(aC))}),[r]),H.useEffect((()=>{pe===sC.percentage&&fe(ge)}),[null==w?void 0:w.toString(),null==k?void 0:k.toString()]);const be=ye.utils.canOperateLiquidity(null==r?void 0:r.type,void 0,null==r?void 0:r.creator,C),[je,Ce]=H.useState(!1),{isShowCompare:ke,lqAndDodoCompareText:Ie,isWarnCompare:Se}=eS(null==r?void 0:r.baseToken,null==r?void 0:r.quoteToken,F),Ee=et($m.getFeeRateQuery(null==r?void 0:r.chainId,null==r?void 0:r.address,null==r?void 0:r.type,C)),Ae=null===(g=null===(p=null===(u=Ee.data)||void 0===u?void 0:u.mtFeeRate)||void 0===p?void 0:p.plus(null!==(m=null===(h=Ee.data)||void 0===h?void 0:h.lpFeeRate)&&void 0!==m?m:0))||void 0===g?void 0:g.toNumber(),{baseTokenStatus:Oe,quoteTokenStatus:Le}=function({pool:e,baseAmount:t,quoteAmount:n,balanceInfo:i}){var o,r,a,s,l;const{chainId:d,baseToken:c,quoteToken:u}=null!=e?e:{};let p="";const h="AMMV2"===(null==e?void 0:e.type);d&&(p=null!==(o=Te[d].DODO_V1_PAIR_PROXY)&&void 0!==o?o:"",h&&(p=dt(d)||mt(e.chainId)));const m=null!==(a=null===(r=null==e?void 0:e.baseLpToken)||void 0===r?void 0:r.id)&&void 0!==a?a:"",g=null!==(l=null===(s=null==e?void 0:e.quoteLpToken)||void 0===s?void 0:s.id)&&void 0!==l?l:"",f="CLASSICAL"===(null==e?void 0:e.type);return{baseTokenStatus:lf(c?Object.assign(Object.assign({},c),{symbol:f?c.symbol+" LP":`${c.symbol}/${null==u?void 0:u.symbol} LP`,address:m}):void 0,{amount:h&&i.userBaseLpToTokenBalance&&i.userBaseLpBalance?new Pe(t).div(i.userBaseLpToTokenBalance).times(i.userBaseLpBalance).toString():t,skipQuery:!p||!m||!f&&!h,contractAddress:p,overrideBalance:h?i.userBaseLpBalance:i.userBaseLpToTokenBalance}),quoteTokenStatus:lf(u?Object.assign(Object.assign({},u),{address:g}):void 0,{amount:n,skipQuery:!p||!g||!f,contractAddress:p,overrideBalance:i.userQuoteLpToTokenBalance})}}({pool:r,baseAmount:_,quoteAmount:M,balanceInfo:s}),Re=Oe.insufficientBalance||Le.insufficientBalance,{isSinglePool:_e}=s,Me=Re?se._({id:"znqB4T",message:"Insufficient balance"}):se._({id:"t/YqKh",message:"Remove"}),Be=()=>{z(),A(),n&&n()},De=null===(f=null==W?void 0:W.pair)||void 0===f?void 0:f.liquidityToken.decimals,Ne=null===(x=s.userBaseLpBalance)||void 0===x?void 0:x.times(ge/100),Fe=Ne&&void 0!==De?Pm(Ne,De).toString():"",{operateLiquidityMutation:Ue}=GI(r),qe=function({baseToken:e,quoteToken:n,baseAmount:i,quoteAmount:o,liquidityAmount:r,slippage:a,fee:s,submittedBack:l}){const d=Fg(),{account:c}=dg();t();const{deadLine:u}=Jn();return it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){if(!e||!n)throw new Error("token is undefined");if(!c)throw new Error("account is undefined");if(!s)throw new Error("fee is undefined");const t=e.chainId,p=we[t].address.toLowerCase(),h=dt(t),m=mt(t),g=!h,f=h||m;if(!f)throw new Error("AMMV2 contract address is not valid.");let x="";const y=e.address.toLowerCase()===p,v=n.address.toLowerCase()===p,b=Pm(new Pe(i).times(1-a),e.decimals),j=Pm(new Pe(o).times(1-a),n.decimals),C=Pm(s,4).toString(),w=Math.ceil(Date.now()/1e3)+(null!=u?u:600);try{if(y){const e=n.address,t=j.toString(),i=b.toString();x=g?vt(e,r,t,i,c,w):bt(e,C,r,t,i,c,w)}else if(v){const t=e.address,n=b.toString(),i=j.toString();x=g?vt(t,r,n,i,c,w):bt(t,C,r,n,i,c,w)}else x=g?jt(e.address,n.address,r,b.toString(),j.toString(),c,w):Ct(e.address,n.address,C,r,b.toString(),j.toString(),c,w)}catch(e){throw console.error("encodeUniswapV2Router02RemoveLiquidity error",e),e}return yield d.execute(se._({id:"cJtosk",message:"Remove liquidity"}),{opcode:Pg.TX,to:f,data:x,value:"0x0"},{metadata:{[Sg.removeLiqidityAMMV2Position]:!0},submittedBack:l})}))})}({baseToken:de,quoteToken:ce,baseAmount:_,quoteAmount:M,liquidityAmount:Fe,slippage:E,fee:Ae,submittedBack:Be}),Ve=()=>{if(J)return qe.mutate();Ue.mutate({txTitle:se._({id:"3XBvkd",message:"Remove Liquidity"}),isRemove:!0,baseAmount:_,quoteAmount:M,slippageProtection:E,balanceInfo:s,SLIPPAGE_PROTECTION:iC,submittedBack:Be})},We=$((()=>{var e;const t=new Pe(_),n=new Pe(M);return!r||Re||!F||!!s.loading||!!s.error||V||!!ue.error||ue.loading||!!(null===(e=ue.receiveAmountBg)||void 0===e?void 0:e.lte(0))||Ee.isLoading||(J?null==Ne||Ne.lte(0):!t.isFinite()||!n.isFinite()||t.lte(0)&&n.lte(0))}),[V,s.error,s.loading,_,Ee.isLoading,J,Re,Ne,F,r,M,ue.error,ue.loading,ue.receiveAmountBg]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:18,px:20},children:[!J&&Yn.jsxs(i,{sx:{mt:20,borderStyle:"solid",borderWidth:1,borderRadius:12,borderColor:"border.main"},children:[Yn.jsx(q,{value:pe,options:he,onChange:(e,t)=>me(t),popupOffset:0,sx:{px:20,py:12,width:"100%",backgroundColor:"transparent",color:"text.primary",typography:"body2"}}),!!r&&ye.utils.singleSideLp(r.type)&&Yn.jsx(i,{sx:{pt:20,pb:13,px:20,borderStyle:"solid",borderWidth:"1px 0 0"},children:Yn.jsx(cS,{pool:r,balanceInfo:s,checkTokenType:R,setCheckToken:P,baseTokenBalanceUpdateLoading:!1,quoteBalanceUpdateLoading:!1})})]}),Yn.jsx(i,{sx:{pt:20},children:pe===sC.percentage?Yn.jsx(Kj,{disabled:s.loading||!be,value:ge,onChange:fe}):L?Yn.jsx(hj,{amt:O?_:M,token:L,canClickBalance:!0,showPercentage:!0,onInputChange:O?K:X,readOnly:s.loading||!be,overrideBalance:O?w:k,overrideBalanceLoading:T,sx:{backgroundColor:"background.cardInput",padding:b.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(hj,{amt:_,token:null==r?void 0:r.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:K,readOnly:s.loading||!be,overrideBalance:w,overrideBalanceLoading:T,sx:{backgroundColor:"background.cardInput",padding:b.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),o?"":Yn.jsx(uj,{}),"base"===o?"":Yn.jsx(hj,{amt:M,token:null==r?void 0:r.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:X,readOnly:s.loading||!be||_e,overrideBalance:k,overrideBalanceLoading:T,sx:{backgroundColor:"background.cardInput",padding:b.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}})]})}),Yn.jsxs(v,{loading:s.loading||U,sx:{mt:8},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"flex-end",gap:8},children:[J&&re&&Yn.jsx(i,{sx:{px:12,py:4,borderRadius:20,borderWidth:1,backgroundColor:"transparent",color:"primary.main",cursor:"pointer",typography:"body2","&:hover":{backgroundColor:"hover.default"}},component:"button",onClick:()=>le((e=>!e)),children:Yn.jsx(e,{id:"/k7Ttv",message:"Receive {0}",values:{0:ae?null==ee?void 0:ee.symbol:null==ee?void 0:ee.wrappedTokenSymbol}})}),Yn.jsx(rC,{value:I,onChange:S,disabled:!be,type:null==r?void 0:r.type,sx:{margin:0}})]}),Yn.jsx(XI,{pool:r,addPortion:N,midPrice:F,shareOfPool:null==W?void 0:W.shareOfPool})]}),!!r&&Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",mt:20,mb:14},children:[Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary",position:"relative",top:2},children:Yn.jsx(e,{id:"lDgVWA",message:"Receive"})}),Yn.jsx(i,{sx:{textAlign:"right"},children:ue.receiveList.map(((e,t)=>Yn.jsxs(i,{sx:{mt:t>0?4:0},children:[Yn.jsxs(v,{component:"span",loading:ue.loading,loadingSx:{mr:8,width:100},sx:{display:"inline-block",typography:"h5",fontWeight:600,color:ue.receiveBaseAmount&&"0"!==ue.receiveBaseAmount?"primary.main":"text.primary"},children:[e.amount," "]}),Yn.jsx(i,{component:"span",sx:{typography:"body2"},children:e.symbol})]},e.symbol)))})]})]}),Yn.jsxs(i,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[ke&&Yn.jsx(YI,{baseToken:null==r?void 0:r.baseToken,quoteToken:null==r?void 0:r.quoteToken,lqAndDodoCompareText:Ie,midPrice:F}),r?Yn.jsx(KI,{chainId:r.chainId,baseTokenStatus:Oe,quoteTokenStatus:Le,children:Yn.jsx(c,{fullWidth:!0,disabled:We,danger:Se,isLoading:Ue.isPending||qe.isPending,onClick:()=>{We||(Se?Ce(!0):Ve())},children:Me})}):Yn.jsx(c,{fullWidth:!0,disabled:!0,children:Me})]}),Yn.jsx(FI,{open:je,onClose:()=>Ce(!1),title:se._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:Ve,modal:!0,children:Yn.jsxs(i,{children:[Yn.jsx(i,{children:se._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:Ie}})}),Yn.jsx(i,{children:se._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),Yn.jsx(ub,{message:null===(y=Ue.error)||void 0===y?void 0:y.message,onClose:()=>Ue.reset(),isDialogModal:j})]})}function pS({pool:e,operate:n,hidePoolInfo:i,errorRefetch:o,submittedBack:r}){var a,s,l,d,c,u;const{operateTab:p,operateTabs:h,handleChangeTab:m}=function(e=YT.Add){const{i18n:n}=t(),[i,o]=H.useState(e),r=H.useMemo((()=>[{key:YT.Add,value:n._({id:"m16xKo",message:"Add"})},{key:YT.Remove,value:n._({id:"t/YqKh",message:"Remove"})}]),[n._]);return H.useEffect((()=>{o(e)}),[e]),{operateTab:i,operateTabs:r,handleChangeTab:e=>{o(e)}}}(n),{account:g}=dg(),f=xI({account:g,pool:e?{chainId:e.chainId,address:e.address,type:e.type,baseTokenDecimals:e.baseToken.decimals,quoteTokenDecimals:e.quoteToken.decimals,baseLpTokenDecimals:null!==(s=null===(a=e.baseLpToken)||void 0===a?void 0:a.decimals)&&void 0!==s?s:18,quoteLpTokenDecimals:null!==(d=null===(l=e.quoteLpToken)||void 0===l?void 0:l.decimals)&&void 0!==d?d:18}:void 0}),x=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(c=null==e?void 0:e.baseToken)||void 0===c?void 0:c.decimals,null===(u=null==e?void 0:e.quoteToken)||void 0===u?void 0:u.decimals));return f.error||x.error||o?Yn.jsx(ai,{refresh:()=>{f.error&&f.refetch(),x.error&&x.refetch(),o&&o()},sx:{my:40,height:"100%"}}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(rS,{pool:e,balanceInfo:f,hidePoolInfo:i}),Yn.jsxs(S,{value:p,onChange:(e,t)=>{m(t)},children:[Yn.jsx(F,{tabs:h,variant:"inPaper",tabsListSx:{mt:16,mx:20}}),Yn.jsx(O,{value:YT.Add,children:Yn.jsx(iS,{pool:e,balanceInfo:f,submittedBack:r})}),Yn.jsx(O,{value:YT.Remove,children:Yn.jsx(uS,{pool:e,balanceInfo:f,submittedBack:r})})]})]})}function hS({onClose:e,pool:n,address:o,operate:r,chainId:a,hasMining:s,hidePoolInfo:l,sx:d}){var c,u,p,h,m,g,f,x,y;const{account:v}=dg(),b=a?Wu[a]:"",j=gg(),C=et(Object.assign(Object.assign({},j.getQuery(ye.graphql.fetchPoolList,{where:{id:null!==(c=null==o?void 0:o.toLocaleLowerCase())&&void 0!==c?c:"",chain:b}})),{enabled:!!o&&!!a})),w=null===(p=null===(u=C.data)||void 0===u?void 0:u.pairs)||void 0===p?void 0:p[0],k=w&&a?function(e,t){var n,i,o,r,a,s;if(e)return{address:e.id,chainId:t,baseToken:Zm(e.baseToken,t),quoteToken:Zm(e.quoteToken,t),type:e.type,creator:e.creator,baseLpToken:{id:null===(n=e.baseLpToken)||void 0===n?void 0:n.id,decimals:Number(null!==(o=null===(i=e.baseLpToken)||void 0===i?void 0:i.decimals)&&void 0!==o?o:18)},quoteLpToken:{id:null===(r=e.quoteLpToken)||void 0===r?void 0:r.id,decimals:Number(null!==(s=null===(a=e.quoteLpToken)||void 0===a?void 0:a.decimals)&&void 0!==s?s:18)}}}(w,a):void 0,I=o&&a?k:n,E=C.error?C.refetch:void 0,{poolOrMiningTab:A,poolOrMiningTabs:L,handleChangeTab:R}=function({hasMining:e}){const{i18n:n}=t(),[i,o]=H.useState(NI.Liquidity);return{poolOrMiningTab:i,poolOrMiningTabs:H.useMemo((()=>{const t=[{key:NI.Liquidity,value:n._({id:"6y2TB3",message:"Liquidity"})},{key:NI.Mining,value:n._({id:"Sti4vy",message:"Mining"})}];return e?t:t.slice(0,1)}),[n._,e]),handleChangeTab:e=>{o(e)}}}({hasMining:s}),P=xI({account:v,pool:I?{chainId:I.chainId,address:I.address,type:I.type,baseTokenDecimals:I.baseToken.decimals,quoteTokenDecimals:I.quoteToken.decimals,baseLpTokenDecimals:null!==(m=null===(h=I.baseLpToken)||void 0===h?void 0:h.decimals)&&void 0!==m?m:18,quoteLpTokenDecimals:null!==(f=null===(g=I.quoteLpToken)||void 0===g?void 0:g.decimals)&&void 0!==f?f:18}:void 0}),_=!!(null===(x=P.userBaseLpBalance)||void 0===x?void 0:x.gt(0))||!!(null===(y=P.userQuoteLpBalance)||void 0===y?void 0:y.gt(0)),M=null!=a?a:null==I?void 0:I.chainId,B=null!=o?o:null==I?void 0:I.address;return Yn.jsx(i,{sx:d,children:Yn.jsxs(S,{value:A,onChange:(e,t)=>{R(t)},sx:{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%"},children:[Yn.jsx(D,{tabs:L,tabsListSx:Object.assign({mx:20,justifyContent:"space-between"},s&&_?{"& button:last-child":{position:"relative","&::before":{content:`"${se._({id:"TY5fM3",message:"LP Tokens"})}"`,position:"absolute",top:16,right:20,px:8,py:2,borderRadius:12,transform:"scale(0.66667) translateX(100%)",transformOrigin:"right top",backgroundColor:T("#DABB1B",.2),color:"#DABB1B"}}}:{}),rightSlot:Yn.jsxs(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:12},children:["GSP"===(null==I?void 0:I.type)&&Yn.jsx(DI,{}),e?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"},cursor:"pointer"},children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16},onClick:()=>{e()}})}):void 0]})}),Yn.jsx(O,{value:NI.Liquidity,sx:{flex:1,overflowY:"auto"},children:Yn.jsx(pS,{pool:I,operate:r,hidePoolInfo:l,errorRefetch:E,submittedBack:()=>{s&&R(NI.Mining)}})}),Yn.jsx(O,{value:NI.Mining,sx:{flex:1,overflowY:"auto"},children:M&&B?Yn.jsx(BI,{chainId:M,account:v,poolAddress:B,goLpLink:()=>{R(NI.Liquidity)}}):""})]})})}function mS(e){var{modal:t}=e,n=qn(e,["modal"]);const{isMobile:i}=Tg();return Yn.jsx(Of,{open:!!n.pool||!!n.address,onClose:n.onClose,scope:!i,modal:t,id:"pool-operate",children:Yn.jsx(hS,{...n})})}function gS({address:t,chainId:n,hideName:o,sx:r}){const s=a(),c=gg(),{onlyChainId:u}=Jn(),p=et(Object.assign({},c.getQuery(Oe.graphql.fetchLiquidityLpPartnerRewards,{where:{chainId:u||void 0}})));if(!t)return null;const h=[];return("string"==typeof t?[t]:Array.from(new Set(t)).filter((e=>!!e))).forEach((e=>{var t,i,o;e&&(null===(o=null===(i=null===(t=p.data)||void 0===t?void 0:t.liquidity_getLpPartnerRewards)||void 0===i?void 0:i.partnerRewards)||void 0===o||o.some((t=>{var i,o,r,a,s,l,d,c,u,m,g,f,x,y;if((null==t?void 0:t.chainId)===n&&(null===(i=null==t?void 0:t.pool)||void 0===i?void 0:i.toLocaleLowerCase())===e.toLocaleLowerCase()){const e=null===(a=null===(r=null===(o=p.data)||void 0===o?void 0:o.liquidity_getLpPartnerRewards)||void 0===r?void 0:r.partnerInfos)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.partner)===t.partner));if(!e)return;h.push({partner:{name:null!==(s=null==e?void 0:e.partner)&&void 0!==s?s:"",logo:null!==(l=null==e?void 0:e.logo)&&void 0!==l?l:"",introduction:null!==(d=null==e?void 0:e.introduction)&&void 0!==d?d:"",link:null!==(c=null==e?void 0:e.link)&&void 0!==c?c:"",extra:null!==(u=null==e?void 0:e.extra)&&void 0!==u?u:{},background:(null===(m=null==e?void 0:e.theme)||void 0===m?void 0:m[0])||void 0,color:(null===(g=null==e?void 0:e.theme)||void 0===g?void 0:g[1])||void 0},reward:null!==(f=null==t?void 0:t.reward)&&void 0!==f?f:"",type:null!==(x=null==t?void 0:t.type)&&void 0!==x?x:"stakelp",sort:null!==(y=null==e?void 0:e.sort)&&void 0!==y?y:Number.MAX_SAFE_INTEGER})}})))})),(null==h?void 0:h.length)?(h.sort(((e,t)=>e.sort-t.sort)),Yn.jsx(i,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},r),children:h.map((t=>Yn.jsx(l,{leaveDelay:100,title:Yn.jsxs(i,{sx:{maxWidth:240,whiteSpace:"pre-wrap"},children:[t.partner.introduction,!!t.partner.link&&Yn.jsxs(i,{component:"a",target:"_blank",href:t.partner.link,rel:"noopener noreferrer",sx:{display:"flex",alignItems:"center",gap:4,color:"primary.main","&:hover":{opacity:.5}},children:[Yn.jsx(e,{id:"zwWKhA",message:"Learn more"})," ",Yn.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 2.91667V11.0833H11.0833V7H12.25V11.0833C12.25 11.725 11.725 12.25 11.0833 12.25H2.91667C2.26917 12.25 1.75 11.725 1.75 11.0833V2.91667C1.75 2.275 2.26917 1.75 2.91667 1.75H7V2.91667H2.91667ZM8.16667 2.91667V1.75H12.25V5.83333H11.0833V3.73917L5.34917 9.47333L4.52667 8.65083L10.2608 2.91667H8.16667Z",fill:"currentColor"})})]})]}),children:Yn.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,p:s.spacing(0,4),height:20,borderRadius:4,background:t.partner.background,color:t.partner.color,whiteSpace:"nowrap"},children:[Yn.jsx(i,{component:"img",src:t.partner.logo,alt:t.partner.name,sx:{width:14,height:14,borderRadius:"50%"}}),!o&&!!t.reward&&Yn.jsx(i,{sx:{fontSize:"10px",fontWeight:600},children:t.reward})]})},t.partner.name+t.reward)))})):null}var fS,xS;function yS(){return yS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},yS.apply(null,arguments)}const vS=e=>W.createElement("svg",yS({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),fS||(fS=W.createElement("circle",{cx:16,cy:16,r:16,fill:"#FFE804"})),xS||(xS=W.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.5 12.25H12.25V8.5H8.5V12.25ZM14.125 23.5H17.875V19.75H14.125V23.5ZM12.25 23.5H8.5V19.75H12.25V23.5ZM8.5 17.875H12.25V14.125H8.5V17.875ZM17.875 17.875H14.125V14.125H17.875V17.875ZM19.75 8.5V12.25H23.5V8.5H19.75ZM17.875 12.25H14.125V8.5H17.875V12.25ZM19.75 17.875H23.5V14.125H19.75V17.875ZM23.5 23.5H19.75V19.75H23.5V23.5Z",fill:"#1A1A1B"}))),bS="_default";function jS({value:e,onChange:t,placeholder:n,options:o,sx:r,readOnly:s,valueOnlyIcon:l}){const d=a();return Yn.jsx(q,{value:null!=e?e:bS,onChange:(n,i)=>{const o="number"==typeof e&&i?Number(i):i;t(o===bS?void 0:o)},disabled:s,sx:ne({padding:d.spacing(8,12),"& .MuiSelect-select.MuiSelect-select.MuiSelect-select":{display:"flex",alignItems:"center",gap:8,padding:d.spacing(8,12,8,12),minHeight:"auto",backgroundColor:"transparent",color:"text.primary",borderRadius:8,typography:"body2",fontWeight:600,borderStyle:"solid",borderWidth:1,borderColor:"divider","& svg, & img":{width:24,height:24},'&:hover, &[aria-expanded="true"]':{backgroundColor:"background.paper"},"&.Mui-readOnly":{color:"text.disabled"}},"& .MuiSelect-icon":{color:s?"text.disabled":"text.primary"},"& .MuiOutlinedInput-notchedOutline":{display:"none"}},r),renderValue:t=>{if(!(null==t?void 0:t.value)||t.value===bS)return Yn.jsx(i,{sx:{color:"text.secondary"},children:null!=n?n:""});const r=o.find((t=>t.key===e));return r?Yn.jsxs(Yn.Fragment,{children:[r.logo,l?"":r.value]}):null},options:[...o]})}function CS({isMobileStyle:e,chain:t,isLastItem:n,logoWidth:o,mobileLogoWidth:r,sx:s}){const l=a();return e?Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",py:18,borderTop:`1px solid ${l.palette.border.main}`,borderBottom:n?`1px solid ${l.palette.border.main}`:"none"},s),children:[Yn.jsx(i,{component:null==t?void 0:t.logo,sx:{width:r,height:r}}),Yn.jsx(i,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{component:null==t?void 0:t.logo,sx:{width:o,height:o}}),Yn.jsx(i,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]})}const wS=-1;function kS({chainId:n,setChainId:o,logoWidth:r=24,mobileLogoWidth:a=32,mainLogoWidth:s=24,mainMobileLogoWidth:l=18,notShowAllChain:c,valueOnlyIcon:u,sx:p}){const h=function(){const{chainId:e}=dg(),t=$((()=>{const t=new Map;let n;return ah.forEach(((i,o)=>{if(i.mainnet){if(e!==i.chainId)return;n=i.mainnet}t.set(o,Object.assign({},i))})),void 0!==n&&t.delete(n),Array.from(t.values())}),[e]);return t}(),[m,g]=H.useState(!1),{isMobile:f}=Tg(),{i18n:x}=t(),y=H.useCallback((()=>{const e=void 0===n?h[0]:h.find((e=>e.chainId===n));if(u){if(void 0===n||!e)return"";const t=f?a:s;return Yn.jsx(i,{component:null==e?void 0:e.logo,sx:{width:t,height:t}})}return void 0!==n||c?e?Yn.jsx(CS,{isMobileStyle:f,chain:e,logoWidth:s,mobileLogoWidth:l}):null:Yn.jsx(CS,{isMobileStyle:f,chain:{chainId:wS,logo:vS,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:s,mobileLogoWidth:l,sx:{border:"none"}})}),[n,h,c,u,f,x._]),v=H.useMemo((()=>{const e=[];return c||e.push({key:wS,value:Yn.jsx(CS,{isMobileStyle:f,chain:{chainId:wS,logo:vS,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:r,mobileLogoWidth:a})}),h.forEach(((t,n)=>{e.push({key:t.chainId,value:Yn.jsx(CS,{isLastItem:n===h.length-1,isMobileStyle:f,chain:t,logoWidth:r,mobileLogoWidth:a})})})),e}),[f,r,a,h,c]);return f?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,onClick:()=>g(!0),sx:Object.assign({display:"flex",alignItems:"center",backgroundColor:"background.tag",color:"text.primary",borderRadius:8,border:"none",px:8,height:32,fontWeight:600,typography:"body2"},p),children:[Yn.jsx(i,{sx:{pr:5},children:y()}),Yn.jsx(i,{component:li.CaretUp,sx:{width:12,height:12,transform:"rotate(180deg)"}})]}),Yn.jsx(Of,{open:m,title:Yn.jsx(e,{id:"lJvbHq",message:"Select Network"}),onClose:()=>g(!1),id:"select-chain",modal:!0,children:Yn.jsx(i,{sx:{mb:20},children:v.map((e=>Yn.jsxs(i,{onClick:()=>{const t=e.key;o(t===wS?void 0:Number(t)),g(!1)},sx:{position:"relative",px:20,"&:active":{backgroundColor:"hover.default"},"&:hover":{backgroundColor:"hover.default"},cursor:"pointer"},children:[e.value,(n?e.key===n:e.key===wS)&&Yn.jsx(i,{sx:{position:"absolute",left:0,top:24,height:20,width:2,backgroundColor:"text.primary"}})]},e.key)))})})]}):Yn.jsx(jS,{value:null!=n?n:wS,onChange:e=>{v.some((t=>String(t.key)===String(e)))&&o(e===wS?void 0:e)},placeholder:x._({id:"lJvbHq",message:"Select Network"}),options:v,valueOnlyIcon:u,sx:Object.assign({px:8,height:32,fontWeight:600,typography:"body2",backgroundColor:"background.tag",color:"text.primary"},p)})}function TS({lqList:e,onDeleteTag:t,sx:n}){var o;if(!(null==e?void 0:e.length))return null;if(!(null===(o=e[0])||void 0===o?void 0:o.pair))return null;const{pair:r}=e[0],a=Zm(r.baseToken,r.chainId),s=Zm(r.quoteToken,r.chainId);return a&&s?Yn.jsxs(i,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},n),children:[Yn.jsx(kj,{tokens:[a,s],chainId:a.chainId,width:20,mr:8}),a.symbol,"+",s.symbol,Yn.jsx(i,{component:li.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t()})]}):null}const IS=e=>{const{filterList:t,value:n,onChange:o}=e,r=a();return Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:t.map(((e,a)=>Yn.jsx(i,{sx:Object.assign(Object.assign({borderLeftWidth:1,borderRightWidth:a===t.length-1?1:0,borderTopWidth:1,borderBottomWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",typography:"body2",lineHeight:"30px",color:r.palette.text.secondary,px:20,cursor:"pointer",borderTopLeftRadius:0===a?8:0,borderBottomLeftRadius:0===a?8:0,borderTopRightRadius:a===t.length-1?8:0,borderBottomRightRadius:a===t.length-1?8:0},n===e.value?{backgroundColor:r.palette.border.disabled,color:r.palette.text.primary}:{}),{[r.breakpoints.down("tablet")]:{flexGrow:1,flexBasis:"25%",textAlign:"center"}}),onClick:()=>o(e.value),children:e.label},e.value)))})},SS=({sx:t,isRightTop:n,isReverseColor:o})=>{const r=a();return Yn.jsx(i,{sx:Object.assign(Object.assign(Object.assign({display:"inline-flex",padding:"2px 4px",alignItems:"center",gap:"4px",borderRadius:4,background:T(r.palette.warning.main,.1),color:r.palette.warning.main,fontSize:"10px",fontWeight:600,lineHeight:"14px"},n?{position:"absolute",top:-14,right:0,background:`linear-gradient(0deg, ${r.palette.warning.main}1A 0%, ${r.palette.warning.main}1A 100%), ${r.palette.background.paper}`}:void 0),o?{background:"light"===r.palette.mode?"linear-gradient(0deg, var(--label-warning, rgba(177, 86, 0, 0.10)) 0%, var(--label-warning, rgba(177, 86, 0, 0.10)) 100%), #FFF":"linear-gradient(0deg, #FFFFFF, #FFFFFF),linear-gradient(0deg, rgba(235, 141, 39, 0.1), rgba(235, 141, 39, 0.1))",zIndex:1}:void 0),t),children:Yn.jsx(e,{id:"y5rS9U",message:"Migrate"})})};function ES({chainId:t,baseToken:n,quoteToken:o,apy:a,hasQuote:s,hasMining:d,sx:c,children:u}){if(!n)return null;const p=s?[{token:n,transactionApy:null==a?void 0:a.transactionBaseApy,miningApy:null==a?void 0:a.miningBaseApy},{token:o,transactionApy:null==a?void 0:a.transactionQuoteApy,miningApy:null==a?void 0:a.miningQuoteApy}]:[{transactionApy:null==a?void 0:a.transactionBaseApy,miningApy:null==a?void 0:a.miningBaseApy,metromMiningApy:null==a?void 0:a.metromMiningApy}];return Yn.jsx(l,{children:null!=u?u:Yn.jsx(r,{component:li.QuestionBorder,sx:Object.assign({width:15,height:15},c)}),title:Yn.jsx(i,{sx:{minWidth:236},children:p.map(((r,a)=>{var s,l,c,u,p;return Yn.jsxs(i,{sx:{mt:0===a?0:20},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,typography:"body2",fontWeight:600,color:"text.primary"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:r.token?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Df,{width:14,height:14,marginRight:4,address:r.token.address,url:r.token.logoURI,chainId:t,noShowChain:!0}),r.token.symbol]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(kj,{tokens:[n,o],width:14,mr:4,chainId:t}),n.symbol,"/",null==o?void 0:o.symbol]})}),Yn.jsx(i,{children:Wm(new Pe(null!==(c=r.transactionApy)&&void 0!==c?c:0).plus(null!==(u=r.miningApy)&&void 0!==u?u:0).plus(null!==(p=r.metromMiningApy)&&void 0!==p?p:0))})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"OnDEky",message:"LP Fee"})}),Yn.jsx("span",{children:r.transactionApy?Wm(new Pe(r.transactionApy)):"-"})]}),d?Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"pSQ1lM",message:"MT Fee"})}),Yn.jsx("span",{children:r.miningApy?Wm(new Pe(r.miningApy)):"-"})]}):"",r.metromMiningApy&&Number(r.metromMiningApy)>0&&Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"Sti4vy",message:"Mining"})}),Yn.jsx("span",{children:r.metromMiningApy?Wm(new Pe(r.metromMiningApy)):"-"})]})]},null!==(l=null===(s=r.token)||void 0===s?void 0:s.address)&&void 0!==l?l:1)}))})})}function AS({list:t,onClick:n}){return Yn.jsx(Yn.Fragment,{children:null==t?void 0:t.map((t=>{var o,r,a,s;if(!(null==t?void 0:t.pair))return null;const l=t.pair,d=Zm(l.baseToken,l.chainId),c=Zm(l.quoteToken,l.chainId),u=l.apy?Wm(new Pe(null===(o=l.apy)||void 0===o?void 0:o.transactionBaseApy).plus(null!==(a=null===(r=l.apy)||void 0===r?void 0:r.miningBaseApy)&&void 0!==a?a:0)):void 0,p=ye.utils.singleSideLp(l.type)&&l.apy?Wm(new Pe(l.apy.transactionQuoteApy).plus(null!==(s=l.apy.miningQuoteApy)&&void 0!==s?s:0)):void 0;return d&&c?Yn.jsxs(i,{onClick:n,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(kj,{tokens:[d,c],chainId:l.chainId,width:24,mr:10}),Yn.jsxs(i,{sx:{typography:"h5"},children:[d.symbol,"/",c.symbol]})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{color:"custom.status.green.default",fontWeight:600},children:[u,p?`/${p}`:""]}),Yn.jsx(i,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]})]},l.id):null}))})}function OS(e){var t;const[n,i]=H.useState(null!==(t=null==e?void 0:e.tokens)&&void 0!==t?t:[]),[o,r]=H.useState([]);H.useEffect((()=>{e&&(i(e.tokens),r(e.lqList))}),[e]);const[a,s]=H.useMemo((()=>{const[e,t]=n;return[null==e?void 0:e.symbol,null==t?void 0:t.symbol]}),[n]);return{filterTokens:n,filterASymbol:a,filterBSymbol:s,filterAddressLqList:o,handleDeleteToken:t=>{i((n=>{const i=[...n],o=i.indexOf(t);return-1!==o&&i.splice(o,1),e&&e.onChangeFilterTokens(i),i}))},handleChangeFilterTokens:t=>{r([]),i(t),e&&(e.onChangeFilterTokens(t),e.onChangeFilterAddressLqList([]))},handleChangeFilterAddress:t=>{r(t),i([]),e&&(e.onChangeFilterTokens([]),e.onChangeFilterAddressLqList(t))}}}function LS({lqList:t,setOperatePool:n,getMigrationPairAndMining:o,supportAMM:r,timeRange:s}){const d=a(),{onSharePool:u}=Jn();return Yn.jsx(Yn.Fragment,{children:null==t?void 0:t.map((t=>{var a,p,h,m,g,f,x,y,v;if(!(null==t?void 0:t.pair))return null;const b=t.pair,j=Zm(b.baseToken,b.chainId),C=Zm(b.quoteToken,b.chainId),w=null===(a=b.apyList)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.timeRange)===`${s}D`)),k=w?Wm(new Pe(null==w?void 0:w.transactionBaseApy).plus(null!==(p=null==w?void 0:w.miningBaseApy)&&void 0!==p?p:0)):void 0,I=ye.utils.singleSideLp(b.type)&&w?Wm(new Pe(w.transactionQuoteApy).plus(null!==(h=w.miningQuoteApy)&&void 0!==h?h:0)):void 0,S=!!(null===(m=b.miningAddress)||void 0===m?void 0:m[0]),E=!!(null==w?void 0:w.metromMiningApy)&&Number(null==w?void 0:w.metromMiningApy)>0,A=b.type,O=Ym(A),L="AMMV2"===A,R="AMMV3"===A,P=null==o?void 0:o({address:b.id,chainId:b.chainId});return Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{r||Gj.getState().push({type:Zj.PoolDetail,params:{chainId:b.chainId,address:b.id}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[j&&C?Yn.jsx(kj,{tokens:[j,C],width:24,mr:6,chainId:b.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},children:[`${null==j?void 0:j.symbol}/${null==C?void 0:C.symbol}`,!!u&&Yn.jsx(i,{component:li.Share,sx:{ml:2,width:12,height:12},onClick:()=>u({chainId:b.chainId,baseToken:j,quoteToken:C,poolId:b.id,apy:w,isSingle:ye.utils.singleSideLp(b.type)})}),Yn.jsx(gS,{address:b.id,chainId:b.chainId})]}),!!P&&Yn.jsx(SS,{})]}),S||E?Yn.jsxs(i,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${T(d.palette.secondary.main,.3)} 0%, ${T(d.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",Yn.jsx(e,{id:"Sti4vy",message:"Mining"})]}):""]}),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[r&&Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[O,Yn.jsx(l,{title:Yn.jsx(e,{id:"O6RUgz",message:"Fee rate"}),children:Yn.jsx(i,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:R?null!==(f=null===(g=dT[b.lpFeeRate])||void 0===g?void 0:g.label)&&void 0!==f?f:"-":Vm({input:new Pe(null!==(x=b.lpFeeRate)&&void 0!==x?x:0).plus(b.mtFeeRate?_m(b.mtFeeRate,L?4:18):0)})})})]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5",color:"success.main"},children:[k,I?`/${I}`:""]}),Yn.jsxs(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[s,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"}),Yn.jsx(ES,{chainId:b.chainId,apy:w,baseToken:j,quoteToken:C,hasQuote:!!I,hasMining:S,sx:{width:14,height:14}})]})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",qm(new Pe(b.tvl))]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),r&&Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:["$",Em({input:null===(v=null===(y=b.volumeList)||void 0===y?void 0:y.find((e=>(null==e?void 0:e.timeRange)===`${s}D`)))||void 0===v?void 0:v.volume})]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"iuFFMB",message:"Volume ({timeRange}d)",values:{timeRange:s}})})]})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),n({pool:Gm(t),hasMining:S})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})}),r&&"PMM"===O&&Yn.jsx(zT,{chainId:b.chainId,address:b.id})]})]},b.id+b.chainId)}))})}function RS({lqList:t,loading:n,operatePool:o,setOperatePool:r,getMigrationPairAndMining:s,hasMore:d,loadMore:u,loadMoreLoading:p,supportAMM:h,timeRange:m}){const g=a(),{onSharePool:f}=Jn();return Yn.jsxs(ZT,{hasMore:d,loadMore:u,loadMoreLoading:p,empty:!(null==t?void 0:t.length),loading:n,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"AxdOHo",message:"Pair"})}),h&&Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})}),Yn.jsxs(i,{component:"th",children:[m,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"})]}),h&&Yn.jsxs("th",{children:[m,"d ",Yn.jsx(e,{id:"/cF7Rs",message:"Volume"})]}),Yn.jsx(i,{component:"th",sx:{width:80}})]})}),Yn.jsx(i,{component:"tbody",children:null==t?void 0:t.map((e=>{var t,n,a,d,u,p,x,y;if(!(null==e?void 0:e.pair))return null;const v=e.pair,b=Zm(v.baseToken,v.chainId),j=Zm(v.quoteToken,v.chainId),C=null===(t=v.apyList)||void 0===t?void 0:t.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)),w=C?Wm(new Pe(null==C?void 0:C.transactionBaseApy).plus(null!==(n=null==C?void 0:C.miningBaseApy)&&void 0!==n?n:0).plus(null!==(a=null==C?void 0:C.metromMiningApy)&&void 0!==a?a:0)):void 0,k=ye.utils.singleSideLp(v.type)&&C?Wm(new Pe(C.transactionQuoteApy).plus(null!==(d=C.miningQuoteApy)&&void 0!==d?d:0)):void 0;let T="";if((null===(u=null==o?void 0:o.pool)||void 0===u?void 0:u.address)===v.id||(null==o?void 0:o.address)===v.id)if(o.operate===YT.Remove)T=se._({id:"0+31GV",message:"Removing"});else T=se._({id:"1yHVE+",message:"Adding"});const I=!!(null===(p=v.miningAddress)||void 0===p?void 0:p[0]),S=!!(null==C?void 0:C.metromMiningApy)&&Number(null==C?void 0:C.metromMiningApy)>0,E=v.type,A=Ym(E),O="AMMV2"===E,L="AMMV3"===E,R=g.palette.hover.default,P=null==s?void 0:s({address:v.id,chainId:v.chainId});return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(T?", & td":"")]:{backgroundImage:`linear-gradient(${R}, ${R})`}},children:[Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[b&&j?Yn.jsx(kj,{tokens:[b,j],width:24,mr:8,chainId:v.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==b?void 0:b.symbol}/${null==j?void 0:j.symbol}`,Yn.jsx(gS,{address:v.id,chainId:v.chainId}),!!P&&Yn.jsx(SS,{})]}),Yn.jsx(zb,{address:v.id,customChainId:v.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,onShareClick:f?()=>f({chainId:v.chainId,baseToken:b,quoteToken:j,poolId:v.id,apy:C,isSingle:ye.utils.singleSideLp(v.type)}):void 0,sx:{typography:"h6",color:"text.secondary"},disabledAddress:h,onAddressClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:v.chainId,address:v.id}})}})]})]})}),h&&Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(cT,{poolType:A}),Yn.jsx(uT,{isAMMV2:O,isAMMV3:L,lpFeeRate:v.lpFeeRate,mtFeeRate:v.mtFeeRate})]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2"},title:v.tvl?`$${Em({input:v.tvl})}`:void 0,children:["$",qm(new Pe(v.tvl))]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[I||S?Yn.jsx(l,{title:se._({id:"Sti4vy",message:"Mining"}),children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",Yn.jsx(ES,{chainId:v.chainId,apy:C,baseToken:b,quoteToken:j,hasQuote:!!k,hasMining:I,children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[w,k?`/${k}`:""]})})]})}),h&&Yn.jsxs(i,{component:"td",sx:{typography:"body2"},children:["$",Em({input:null===(y=null===(x=v.volumeList)||void 0===x?void 0:x.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)))||void 0===y?void 0:y.volume})]}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[h&&"PMM"===A&&Yn.jsx(zT,{chainId:v.chainId,address:v.id}),T?Yn.jsx(HT,{text:T,onClick:()=>r(null)}):Yn.jsx(c,{size:c.Size.small,onClick:()=>{r({pool:Gm(e),hasMining:I})},sx:{py:0,height:32},children:se._({id:"m16xKo",message:"Add"})})]})})]},v.id+v.chainId)}))})]})}function PS({scrollParentRef:e,filterChainIds:t,activeChainId:n,handleChangeActiveChainId:o,operatePool:r,setOperatePool:s,tokenAndPoolFilter:l,getMigrationPairAndMining:d,children:c}){var u,p;const h=a(),{onlyChainId:m,supportAMMV2:g,supportAMMV3:f,notSupportPMM:x}=Jn(),{minDevice:y,isMobile:v}=Tg(),b=nt(),[j,C]=z("all"),[w,k]=z("1"),{filterTokens:T,filterASymbol:I,filterBSymbol:S,filterAddressLqList:E,handleDeleteToken:A,handleChangeFilterTokens:O,handleChangeFilterAddress:L}=OS(l),R=$((()=>{if(f&&"v3"===j)return["AMMV3"];if(g&&"v2"===j)return["AMMV2"];if(!x&&"pmm"===j)return["CLASSICAL","DVM","DSP","GSP"];let e=x?[]:["CLASSICAL","DVM","DSP","GSP"];return g&&e.push("AMMV2"),f&&e.push("AMMV3"),e}),[x,g,f,j]),P=$((()=>({chainIds:t,pageSize:v?4:8,filterState:{viewOnlyOwn:!1,filterTypes:R}})),[t,R,v]),_=gg(),M=_.getInfiniteQuery(ye.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},P),{filterState:Object.assign({filterASymbol:I,filterBSymbol:S},P.filterState)})}),B=at(Object.assign(Object.assign({},M),{initialPageParam:1,getNextPageParam:e=>{var t;const{currentPage:n,totalCount:i,pageSize:o}=null!==(t=e.liquidity_list)&&void 0!==t?t:{};if(!n||!i||!o)return null;let r=Math.floor(i/o);return i%o&&(r+=1),n>=r?null:n+1}}));let D=[];const N=!!(null==E?void 0:E.length);N?D=[...E]:null===(u=B.data)||void 0===u||u.pages.forEach((e=>{var t,n;null===(n=null===(t=e.liquidity_list)||void 0===t?void 0:t.lqList)||void 0===n||n.forEach((e=>{null==D||D.push(e)}))}));const F=B.hasNextPage&&!N;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[h.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[h.breakpoints.up("tablet")]:{mr:"auto"}},children:c}),!m&&Yn.jsx(kS,{chainId:n,setChainId:o}),(g||f)&&Yn.jsx(IS,{filterList:[{label:"All",value:"all"}].concat(x?[]:[{label:"PMM",value:"pmm"}]).concat(g?[{label:"V2",value:"v2"}]:[]).concat(f?[{label:"V3",value:"v3"}]:[]),value:j,onChange:e=>C(e)}),Yn.jsx(IS,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:w,onChange:e=>k(e)}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},v?{}:{"& > button":{flex:1}}),children:null!==(p=null==l?void 0:l.element)&&void 0!==p?p:Yn.jsx(QT,{value:T,onChange:O,searchAddress:(e,t)=>Vn(this,void 0,void 0,(function*(){var n;const i=_.getInfiniteQuery(ye.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},P),{filterState:Object.assign({address:e},P.filterState)})}),o=null===(n=(yield b.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?Yn.jsx(AS,{list:o,onClick:()=>{L(o),t()}}):null}))})}),(N||!!T.length)&&Yn.jsxs(i,{sx:{my:0},children:[N?Yn.jsx(TS,{lqList:E,onDeleteTag:()=>L([])}):"",Yn.jsx($T,{tags:T,onDeleteTag:A})]})]})]}),v?Yn.jsx(In,{hasMore:F,threshold:300,loadMore:ae((()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>e.current||null,loader:Yn.jsx(GT,{sx:{mt:20}},"loader"),children:Yn.jsxs(WT,{children:[B.isLoading?Yn.jsx(GT,{}):"",!B.isLoading&&!(null==D?void 0:D.length)&&!B.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!!(n&&!m||I||S)}),!!B.error&&Yn.jsx(ai,{refresh:B.refetch,sx:{mt:40}}),Yn.jsx(LS,{lqList:D,setOperatePool:s,supportAMM:g||f,getMigrationPairAndMining:d,timeRange:w})]})}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(RS,{lqList:D,loading:B.isLoading,operatePool:r,setOperatePool:s,hasMore:F,loadMoreLoading:B.isFetchingNextPage,loadMore:()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()},supportAMM:g||f,timeRange:w,getMigrationPairAndMining:d}),Yn.jsx(Tj,{loading:B.isLoading,refetch:B.error?B.refetch:void 0,empty:!(null==D?void 0:D.length),hasSearch:!!(n&&!m||I||S)})]})]})}function _S({onClick:e,title:t,desc:n}){const o=a();return Yn.jsx(i,{sx:{mx:20,px:0,py:14,borderTop:`1px solid ${o.palette.border.main}`,[o.breakpoints.up("tablet")]:{maxWidth:236,borderTop:"none",mx:0,px:16,py:8}},children:Yn.jsxs(d,{onClick:e,sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,p:0,borderRadius:8,textAlign:"left","&:hover":{backgroundColor:o.palette.background.tag},[o.breakpoints.up("tablet")]:{p:8}},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:o.palette.text.primary},children:t}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary},children:n})]})})}const MS=t=>{const n=a(),{isMobile:o}=Tg(),{supportAMMV2:r,supportAMMV3:s,notSupportPMM:d}=Jn(),[u,p]=H.useState(!1),h={[Zj.CreatePool]:!d,[Zj.createPoolAMMV2]:!!r,[Zj.createPoolAMMV3]:!!s},m=Object.entries(h).filter((([e,t])=>!0===t)),g=1===m.length?m[0][0]:void 0;if(!g){const t=Yn.jsxs(Yn.Fragment,{children:[!d&&Yn.jsx(_S,{onClick:()=>{Gj.getState().push({type:Zj.CreatePool})},title:Yn.jsx(e,{id:"Eif7f6",message:"PMM Pool"}),desc:Yn.jsx(e,{id:"LQ0J1B",message:"Flexible customization, take full control of liquidity"})}),r&&Yn.jsx(_S,{onClick:()=>{Gj.getState().push({type:Zj.createPoolAMMV2})},title:Yn.jsx(e,{id:"lNYomJ",message:"AMM V2 Position"}),desc:Yn.jsx(e,{id:"lLbR0m",message:"Simple, full-range liquidity"})}),s&&Yn.jsx(_S,{onClick:()=>{Gj.getState().push({type:Zj.createPoolAMMV3})},title:Yn.jsx(e,{id:"sVlqoo",message:"AMM V3 Position"}),desc:Yn.jsx(e,{id:"EkAv3P",message:"Concentrated liquidity, higher efficiency"})})]});return o?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{p(!0)},sx:{height:36},children:[Yn.jsx(i,{component:li.Plus,sx:{mr:4}}),Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"})]}),Yn.jsx(Of,{open:u,title:Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"}),onClose:()=>{p(!1)},modal:!0,children:Yn.jsx(i,{sx:{mb:0},children:t})})]}):Yn.jsx(l,{arrow:!1,leaveDelay:300,placement:o?"bottom":"bottom-end",sx:{p:0,backgroundColor:"background.paper"},title:Yn.jsx(i,{children:t}),children:Yn.jsxs(i,{sx:{width:o?"100%":"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,pl:8,pr:16,py:6,borderRadius:40,backgroundColor:n.palette.background.tag,typography:"body2",fontWeight:600,color:n.palette.text.link,cursor:"pointer","&:hover":{backgroundColor:T(n.palette.primary.main,.1)}},children:[Yn.jsx(i,{component:li.Plus}),Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"})]})})}return Yn.jsxs(c,{variant:c.Variant.outlined,fullWidth:o,onClick:()=>{Gj.getState().push({type:g})},sx:{height:40},children:[Yn.jsx(i,{component:li.Plus,sx:{mr:4}}),Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"})]})},BS="DODO_WIDGET_POOL_LIST_TOP_TAB",DS="DODO_WIDGET_POOL_LIST_TAB",NS="DODO_WIDGET_POOLS_LIST_FILTER_CHAIN";var FS,US,qS,VS;!function(e){e.ALM="ALM",e.NORMAL="NORMAL",e.MULTI_TOKEN="MULTI_TOKEN"}(FS||(FS={})),function(e){e.ALL="ALL",e.MY="MY"}(US||(US={})),function(e){e.addLiquidity="add-liquidity",e.myLiquidity="my-liquidity",e.myCreated="my-created"}(qS||(qS={})),function(e){e.ALL="ALL",e.MY="MY"}(VS||(VS={}));const WS=(e,t,n)=>{let i=se._({id:"TJBHlP",message:"Standard"}),o=n.palette.purple.main;switch(e){case"DSP":i=se._({id:"J7M/DA",message:"Pegged"}),o=n.palette.success.main;break;case"DPP":i=se._({id:"zwBp5t",message:"Private"}),o=n.palette.error.main}"DVM"===e&&(!t||t.isZero())&&(i=se._({id:"S8G1qk",message:"Single"}),o=n.palette.warning.main);return{typeLabel:i,typeColor:o,typeBgColor:T(o,.1)}};function HS({account:t,list:n,setOperatePool:o}){const r=a();return Yn.jsx(Yn.Fragment,{children:null==n?void 0:n.map((n=>{var a,s,l,u,p;if(!n)return null;const h=null!==(a=n.pairAddress)&&void 0!==a?a:"",m=n.chainId,g=n.poolType,f={chainId:m,address:null!==(s=n.baseAddress)&&void 0!==s?s:"",symbol:null!==(l=n.baseSymbol)&&void 0!==l?l:""},x={chainId:m,address:null!==(u=n.quoteAddress)&&void 0!==u?u:"",symbol:null!==(p=n.quoteSymbol)&&void 0!==p?p:""},{typeLabel:y,typeColor:v,typeBgColor:b}=WS(g,n.quoteReserve?new Pe(n.quoteReserve):null,r);return Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:m,address:h}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[f&&x?Yn.jsx(kj,{tokens:[f,x],width:24,mr:8,chainId:m,showChainLogo:!0}):"",Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},children:eg(h)}),"DPP"===g&&Yn.jsx(_,{sx:{ml:2},component:d,onClick:e=>{e.stopPropagation(),Gj.getState().push({type:Zj.ModifyPool,params:{chainId:m,address:h}})},children:Yn.jsx(i,{component:li.Edit,sx:{width:12,height:12,cursor:"pointer"}})})]}),Yn.jsx(i,{sx:{typography:"h6",width:"max-content",p:8,borderRadius:8,backgroundColor:b,color:v},children:y})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",mt:44},children:[Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",n.tvl?qm(new Pe(n.tvl)):"-"]}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),Yn.jsx(i,{sx:{display:"inline-block",mx:20,height:24,width:"1px",backgroundColor:"custom.border.default"}}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",n.totalFee?qm(new Pe(n.totalFee)):"-"]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"hCBYHP",message:"Total Fee Revenue"})})]})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",gap:"8px"},children:[!!t&&Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({address:h,operate:YT.Remove,chainId:m})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({address:h,operate:YT.Add,chainId:m})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})})]})]},h+m)}))})}function $S({account:t,list:n,loading:o,operatePool:r,setOperatePool:s}){const l=a(),d=Gj();return Yn.jsxs(ZT,{empty:!(null==n?void 0:n.length),loading:o,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"AxdOHo",message:"Pair"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"hCBYHP",message:"Total Fee Revenue"})}),Yn.jsx(i,{component:"th",sx:{width:160}})]})}),Yn.jsx(i,{component:"tbody",children:null==n?void 0:n.map((n=>{var o,a,u,p,h,m;if(!n)return null;const g="DPP"===n.poolType,f=null!==(o=n.pairAddress)&&void 0!==o?o:"",x=n.chainId,y=n.poolType,v={chainId:x,address:null!==(a=n.baseAddress)&&void 0!==a?a:"",symbol:null!==(u=n.baseSymbol)&&void 0!==u?u:""},b={chainId:x,address:null!==(p=n.quoteAddress)&&void 0!==p?p:"",symbol:null!==(h=n.quoteSymbol)&&void 0!==h?h:""},{typeLabel:j,typeColor:C,typeBgColor:w}=WS(y,n.quoteReserve?new Pe(n.quoteReserve):null,l);let k="";if((null===(m=null==r?void 0:r.pool)||void 0===m?void 0:m.address)===f||(null==r?void 0:r.address)===f)if((null==r?void 0:r.operate)===YT.Remove)k=se._({id:"0+31GV",message:"Removing"});else k=se._({id:"1yHVE+",message:"Adding"});const I=l.palette.hover.default;return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(k?", & td":"")]:{backgroundImage:`linear-gradient(${I}, ${I})`}},children:[Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[v&&b?Yn.jsx(kj,{tokens:[v,b],width:24,mr:10,chainId:x,showChainLogo:!0}):"",Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsxs(P,{lineSx:{bottom:-1},lineColor:"primary.main",hoverSx:{color:"primary.main","& svg":{display:"inline-block"}},className:"truncate-address-link",sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},onClick:()=>{d.push({type:Zj.PoolDetail,params:{chainId:x,address:f}})},children:eg(f)}),Yn.jsx(i,{component:li.ArrowRight,sx:{display:"none",width:14,height:14}})]}),g?Yn.jsx(i,{sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderColor:"text.primary",borderRadius:4,whiteSpace:"nowrap",cursor:"pointer","&:hover":{backgroundColor:T(l.palette.text.primary,.1)}},onClick:()=>{d.push({type:Zj.ModifyPool,params:{chainId:x,address:f}})},children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})}):""]}),Yn.jsx(i,{sx:{typography:"h6",width:"max-content",mt:2,px:8,py:2,borderRadius:12,backgroundColor:w,color:C},children:j})]})]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2"},title:n.tvl?`$${Em({input:n.tvl})}`:void 0,children:["$",n.tvl?qm(new Pe(n.tvl)):"-"]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{title:n.totalFee?`$${Em({input:n.totalFee})}`:"",sx:{typography:"body2",fontWeight:600},children:["$",n.totalFee?qm(new Pe(n.totalFee)):"-"]})}),Yn.jsx(i,{component:"td",children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:k?Yn.jsx(HT,{text:k,onClick:()=>s(null)}):Yn.jsxs(Yn.Fragment,{children:[!!t&&Yn.jsx(c,{variant:c.Variant.second,size:c.Size.small,onClick:e=>{e.stopPropagation(),s({operate:YT.Remove,chainId:x,address:f})},sx:{py:0,height:32},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{size:c.Size.small,onClick:()=>{s({chainId:x,address:f})},sx:{py:0,height:32},children:se._({id:"m16xKo",message:"Add"})})]})})})]},f+x)}))})]})}function zS({account:t,filterChainIds:n,activeChainId:o,handleChangeActiveChainId:r,operatePool:s,setOperatePool:l,children:d}){var c,u,p,h,m,g;const{isMobile:f}=Tg(),x=a(),{onlyChainId:y}=Jn(),v={limit:1e3,page:1,owner:t},b=gg().getQuery(ye.graphql.fetchDashboardPairList,{where:v}),j=et(Object.assign({},b)),C=null!==(g=n?null===(p=null===(u=null===(c=j.data)||void 0===c?void 0:c.dashboard_pairs_list)||void 0===u?void 0:u.list)||void 0===p?void 0:p.filter((e=>{var t;return n.includes(null!==(t=null==e?void 0:e.chainId)&&void 0!==t?t:0)})):null===(m=null===(h=j.data)||void 0===h?void 0:h.dashboard_pairs_list)||void 0===m?void 0:m.list)&&void 0!==g?g:[],[w,k]=H.useState(!1),T=w?C.filter((e=>!!Number(null==e?void 0:e.tvl))):C;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[x.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[x.breakpoints.up("tablet")]:{mr:"auto"}},children:d}),!y&&Yn.jsx(kS,{chainId:o,setChainId:r}),Yn.jsxs(i,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[Yn.jsx(I,{sx:{top:-1},size:16,checked:w,onChange:e=>{const{checked:t}=e.target;k(t)}}),Yn.jsx(e,{id:"eVZ7bY",message:"Hide TVL=0 pools"})]})]}),f?Yn.jsxs(WT,{children:[j.isLoading?Yn.jsx(GT,{}):"",!j.isLoading&&!(null==T?void 0:T.length)&&!j.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!!o&&!y}),!!j.error&&Yn.jsx(ai,{refresh:j.refetch,sx:{mt:40}}),Yn.jsx(HS,{account:t,list:T,setOperatePool:l})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx($S,{account:t,list:T,loading:j.isLoading,operatePool:s,setOperatePool:l}),Yn.jsx(Tj,{loading:j.isLoading,refetch:j.error?j.refetch:void 0,empty:!(null==T?void 0:T.length),hasSearch:!!o&&!y})]})]})}function ZS({account:t,lqList:n,setOperatePool:o,getMigrationPairAndMining:r,supportAMM:s,timeRange:d}){const u=a();return Yn.jsx(Yn.Fragment,{children:null==n?void 0:n.map((n=>{var a,p,h,m,g,f,x,y,v,b,j,C,w,k,I;if(!(null==n?void 0:n.pair))return null;const S=n.pair,E=Zm(S.baseToken,S.chainId),A=Zm(S.quoteToken,S.chainId),O=null===(a=S.apyList)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.timeRange)===`${d}D`)),L=ye.utils.singleSideLp(S.type),R=O?Wm(new Pe(null==O?void 0:O.transactionBaseApy).plus(null!==(p=null==O?void 0:O.miningBaseApy)&&void 0!==p?p:0).plus(null!==(h=null==O?void 0:O.metromMiningApy)&&void 0!==h?h:0)):void 0,P=L&&O?Wm(new Pe(O.transactionQuoteApy).plus(null!==(m=O.miningQuoteApy)&&void 0!==m?m:0)):void 0;let _,M;(null===(g=n.liquidityPositions)||void 0===g?void 0:g.length)&&n.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const a=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==a?void 0:a.length)){const t=a[1].toLocaleLowerCase();if((null===(i=null===(n=null==S?void 0:S.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(_=new Pe(e.liquidityTokenBalance));(null===(r=null===(o=null==S?void 0:S.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(M=new Pe(e.liquidityTokenBalance))}}}));const B=!!(null===(f=S.miningAddress)||void 0===f?void 0:f[0]),D=!!(null==O?void 0:O.metromMiningApy)&&Number(null==O?void 0:O.metromMiningApy)>0,N=null===(x=n.liquidityPositions)||void 0===x?void 0:x[0],F=S.type,U=Ym(F),q="AMMV2"===F,V="AMMV3"===F,W=null==r?void 0:r({address:S.id,chainId:S.chainId});return Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{s||Gj.getState().push({type:Zj.PoolDetail,params:{chainId:S.chainId,address:S.id}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[E&&A?Yn.jsx(kj,{tokens:[E,A],width:24,mr:6,chainId:S.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},children:[`${null==E?void 0:E.symbol}/${null==A?void 0:A.symbol}`,Yn.jsx(gS,{address:S.id,chainId:S.chainId})]}),!!W&&Yn.jsx(SS,{})]}),B||D?Yn.jsxs(i,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${T(u.palette.secondary.main,.3)} 0%, ${T(u.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",Yn.jsx(e,{id:"Sti4vy",message:"Mining"})]}):""]}),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[s&&Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[U,Yn.jsx(l,{title:Yn.jsx(e,{id:"O6RUgz",message:"Fee rate"}),children:Yn.jsx(i,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:V?null!==(v=null===(y=dT[S.lpFeeRate])||void 0===y?void 0:y.label)&&void 0!==v?v:"-":Vm({input:new Pe(null!==(b=S.lpFeeRate)&&void 0!==b?b:0).plus(S.mtFeeRate?_m(S.mtFeeRate,q?4:18):0)})})})]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5",color:"success.main"},children:[R||"-%",P?`/${P}`:""]}),Yn.jsxs(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[d,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"}),Yn.jsx(ES,{chainId:S.chainId,apy:O,baseToken:E,quoteToken:A,hasQuote:!!P,hasMining:B,sx:{width:14,height:14}})]})]}),V?null:Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",qm(new Pe(S.tvl||0))]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),"AMMV2"===F&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"h5"},children:Vm({input:null===(C=null===(j=n.liquidityPositions)||void 0===j?void 0:j[0])||void 0===C?void 0:C.poolShare})}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"h3PbRN",message:"My Pool Share"})})]}),Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"h5",display:"flex",alignItems:"center",fontWeight:"bold"},children:V?(null==N?void 0:N.liquidityUSD)?`$${Am({input:N.liquidityUSD,decimals:2})}`:"-":Yn.jsxs(Yn.Fragment,{children:[L?Yn.jsx(Df,{address:null==E?void 0:E.address,chainId:S.chainId,url:null==E?void 0:E.logoURI,width:18,height:18,sx:{mr:4}}):Yn.jsx(kj,{tokens:E&&A?[E,A]:[],width:18,mr:4,showChainLogo:!1,chainId:S.chainId}),_?Em({input:_}):"",L&&Yn.jsxs(Yn.Fragment,{children:[" / ",Yn.jsx(Df,{address:null==A?void 0:A.address,chainId:S.chainId,url:null==A?void 0:A.logoURI,width:18,height:18,sx:{mx:4}}),M?Em({input:M}):"0"]})]})}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})})]})]}),V&&Yn.jsxs(i,{sx:{mt:20},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[Yn.jsx(UT,{outOfRange:null!==(w=null==N?void 0:N.outOfRange)&&void 0!==w&&w}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(k=null==N?void 0:N.priceRange)||void 0===k?void 0:k.token0LowerPrice,atLimit:{},direction:dC.LOWER})," "]}),null==E?void 0:E.symbol]})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(I=null==N?void 0:N.priceRange)||void 0===I?void 0:I.token1LowerPrice,atLimit:{},direction:dC.UPPER})," "]}),null==E?void 0:E.symbol]})})]}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"YA4hwj",message:"Price Range"})})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[V?null:!!t&&Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({operate:YT.Remove,pool:Qm(n),hasMining:B})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({operate:YT.Add,pool:Qm(n),hasMining:B})},children:Yn.jsx(e,{id:"J/hVSQ",message:"{0}",values:{0:V?"Manage":"Add"}})}),s&&"PMM"===U&&Yn.jsx(zT,{chainId:S.chainId,address:S.id})]})]},V?null==N?void 0:N.id:S.id+S.chainId)}))})}function GS({account:t,lqList:n,loading:o,operatePool:r,setOperatePool:s,supportAMM:d,onlyV3:u,getMigrationPairAndMining:p,timeRange:h}){const m=a();return Yn.jsxs(ZT,{empty:!(null==n?void 0:n.length),loading:o,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"AxdOHo",message:"Pair"})}),d&&Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})}),u?null:Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})}),Yn.jsxs(i,{component:"th",children:[h,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"})]}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),u?Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"YA4hwj",message:"Price Range"})}):null,Yn.jsx(i,{component:"th",sx:{width:210}})]})}),Yn.jsx(i,{component:"tbody",children:null==n?void 0:n.map((n=>{var o,a,g,f,x,y,v,b,j,C,w,k,T,I,S;if(!(null==n?void 0:n.pair))return null;const E=n.pair,A=Zm(E.baseToken,E.chainId),O=Zm(E.quoteToken,E.chainId),L=ye.utils.singleSideLp(E.type),R=null===(o=E.apyList)||void 0===o?void 0:o.find((e=>(null==e?void 0:e.timeRange)===`${h}D`)),P=R?Wm(new Pe(null==R?void 0:R.transactionBaseApy).plus(null!==(a=null==R?void 0:R.miningBaseApy)&&void 0!==a?a:0)):void 0,_=L&&R?Wm(new Pe(R.transactionQuoteApy).plus(null!==(g=R.miningQuoteApy)&&void 0!==g?g:0)):void 0;let M,B;(null===(f=n.liquidityPositions)||void 0===f?void 0:f.length)&&n.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const a=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==a?void 0:a.length)){const t=a[1].toLocaleLowerCase();if((null===(i=null===(n=null==E?void 0:E.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(M=new Pe(e.liquidityTokenBalance));(null===(r=null===(o=null==E?void 0:E.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(B=new Pe(e.liquidityTokenBalance))}}}));const D=null===(x=n.liquidityPositions)||void 0===x?void 0:x[0],N=E.type,F=Ym(N),U="AMMV2"===N,q="AMMV3"===N;let V="";if(q)(null===(b=null===(v=null===(y=null==r?void 0:r.pool)||void 0===y?void 0:y.liquidityPositions)||void 0===v?void 0:v[0])||void 0===b?void 0:b.id)===(null==D?void 0:D.id)&&(V=se._({id:"p3607o",message:"Managing"}));else if((null===(j=null==r?void 0:r.pool)||void 0===j?void 0:j.address)===E.id||(null==r?void 0:r.address)===E.id)if(r.operate===YT.Remove)V=se._({id:"0+31GV",message:"Removing"});else V=se._({id:"1yHVE+",message:"Adding"});const W=!!(null===(C=E.miningAddress)||void 0===C?void 0:C[0]),H=!!(null==R?void 0:R.metromMiningApy)&&Number(null==R?void 0:R.metromMiningApy)>0,$=m.palette.hover.default,z=null==p?void 0:p({address:E.id,chainId:E.chainId});return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(V?", & td":"")]:{backgroundImage:`linear-gradient(${$}, ${$})`}},children:[Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[A&&O?Yn.jsx(kj,{tokens:[A,O],width:24,mr:8,chainId:E.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==A?void 0:A.symbol}/${null==O?void 0:O.symbol}`,Yn.jsx(gS,{address:E.id,chainId:E.chainId}),!!z&&Yn.jsx(SS,{})]}),Yn.jsx(zb,{address:E.id,customChainId:E.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,disabledAddress:d,onAddressClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:E.chainId,address:E.id}})},sx:{typography:"h6",color:"text.secondary"}})]})]})}),d&&Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(cT,{poolType:F}),Yn.jsx(uT,{isAMMV2:U,isAMMV3:q,lpFeeRate:E.lpFeeRate,mtFeeRate:E.mtFeeRate})]})}),q?null:Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2"},title:E.tvl?`$${Em({input:E.tvl||0})}`:void 0,children:["$",qm(new Pe(E.tvl||0))]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[W||H?Yn.jsx(l,{title:se._({id:"Sti4vy",message:"Mining"}),children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",Yn.jsx(ES,{chainId:E.chainId,apy:R,baseToken:A,quoteToken:O,hasQuote:!!_,hasMining:W,children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[P||"-%",_?`/${_}`:""]})})]})}),Yn.jsx(i,{component:"td",children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"body2"},children:q?(null==D?void 0:D.liquidityUSD)?`$${Am({input:D.liquidityUSD,decimals:2})}`:"-":Yn.jsxs(Yn.Fragment,{children:[L?Yn.jsx(Df,{address:null==A?void 0:A.address,chainId:E.chainId,url:null==A?void 0:A.logoURI,width:24,height:24,noShowChain:!0,sx:{mr:4}}):Yn.jsx(kj,{tokens:A&&O?[A,O]:[],width:24,mr:4,showChainLogo:!1,chainId:E.chainId}),M?Em({input:M}):"-",L&&Yn.jsxs(Yn.Fragment,{children:[" / ",Yn.jsx(Df,{address:null==O?void 0:O.address,chainId:E.chainId,url:null==O?void 0:O.logoURI,width:24,height:24,noShowChain:!0,sx:{mx:4}}),B?Em({input:B}):"0"]}),U&&Yn.jsx(l,{title:Yn.jsx(e,{id:"NXZdrO",message:"My pool share"}),children:Yn.jsx(i,{sx:{ml:4,px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Vm({input:null===(k=null===(w=n.liquidityPositions)||void 0===w?void 0:w[0])||void 0===k?void 0:k.poolShare})})})]})})}),u?Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[Yn.jsx(UT,{outOfRange:null!==(T=null==D?void 0:D.outOfRange)&&void 0!==T&&T}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(I=null==D?void 0:D.priceRange)||void 0===I?void 0:I.token0LowerPrice,atLimit:{},direction:dC.LOWER})," "]}),null==A?void 0:A.symbol]})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(S=null==D?void 0:D.priceRange)||void 0===S?void 0:S.token0UpperPrice,atLimit:{},direction:dC.UPPER})," "]}),null==A?void 0:A.symbol]})})]})}):null,Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[d&&"PMM"===F&&Yn.jsx(zT,{chainId:E.chainId,address:E.id}),V?Yn.jsx(HT,{text:V,onClick:()=>s(null)}):Yn.jsxs(Yn.Fragment,{children:[q?null:!!t&&Yn.jsxs(c,{variant:c.Variant.second,size:c.Size.small,onClick:e=>{e.stopPropagation(),s({operate:YT.Remove,pool:Qm(n),hasMining:W})},sx:{py:0,height:32},children:[Yn.jsx(e,{id:"t/YqKh",message:"Remove"}),!!z&&Yn.jsx(SS,{isRightTop:!0})]}),Yn.jsx(c,{size:c.Size.small,onClick:()=>{s({pool:Qm(n),hasMining:W})},sx:{py:0,height:32},children:q?se._({id:"wckWOP",message:"Manage"}):se._({id:"m16xKo",message:"Add"})})]})]})})]},q?null==D?void 0:D.id:E.id+E.chainId)}))})]})}function QS({account:e,filterChainIds:t,activeChainId:n,handleChangeActiveChainId:o,operatePool:r,setOperatePool:s,getMigrationPairAndMining:l,tokenAndPoolFilter:d,children:c}){var u,p,h,m,g,f,x,y;const v=a(),{minDevice:b,isMobile:j}=Tg(),C=nt(),{onlyChainId:w,supportAMMV2:k,supportAMMV3:T,notSupportPMM:I}=Jn(),[S,E]=H.useState("pmm&v2"),[A,O]=H.useState("1"),{filterTokens:L,filterASymbol:R,filterBSymbol:P,filterAddressLqList:_,handleDeleteToken:M,handleChangeFilterTokens:B,handleChangeFilterAddress:D}=OS(d);let N=I?[]:["CLASSICAL","DVM","DSP","GSP","DPP"];k&&N.push("AMMV2"),T&&"v3"===S&&(N=["AMMV3"]);const F={currentPage:1,pageSize:1e3,user:e,filterState:{viewOnlyOwn:!0,filterTypes:N}},U=gg(),q=U.getQuery(ye.graphql.fetchMyLiquidityList,{where:Object.assign(Object.assign({},F),{filterState:Object.assign({filterASymbol:R,filterBSymbol:P},F.filterState)})}),V=et(Object.assign({},q));let W=null!==(h=null===(p=null===(u=V.data)||void 0===u?void 0:u.liquidity_list)||void 0===p?void 0:p.lqList)&&void 0!==h?h:[];const $=!!(null==_?void 0:_.length);return $?W=[..._]:t&&(W=null!==(x=null===(f=null===(g=null===(m=V.data)||void 0===m?void 0:m.liquidity_list)||void 0===g?void 0:g.lqList)||void 0===f?void 0:f.filter((e=>{var n,i;return t.includes(null!==(i=null===(n=null==e?void 0:e.pair)||void 0===n?void 0:n.chainId)&&void 0!==i?i:0)})))&&void 0!==x?x:[]),Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[v.breakpoints.up("tablet")]:{py:16,flexDirection:"row",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[v.breakpoints.up("tablet")]:{mr:"auto"}},children:c}),!w&&Yn.jsx(kS,{chainId:n,setChainId:o}),T&&Yn.jsx(IS,{filterList:[{label:"V3",value:"v3"},{label:"V2 & PMM",value:"pmm&v2"}],value:S,onChange:e=>E(e)}),Yn.jsx(IS,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:A,onChange:e=>O(e)}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},j?{}:{"& > button":{flex:1}}),children:null!==(y=null==d?void 0:d.element)&&void 0!==y?y:Yn.jsx(QT,{value:L,onChange:B,searchAddress:(e,t)=>Vn(this,void 0,void 0,(function*(){var n;const i=U.getInfiniteQuery(ye.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},F),{filterState:Object.assign({address:e},F.filterState)})}),o=null===(n=(yield C.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?Yn.jsx(AS,{list:o,onClick:()=>{D(o),t()}}):null}))})}),($||!!L.length)&&Yn.jsxs(i,{sx:{my:0},children:[$?Yn.jsx(TS,{lqList:_,onDeleteTag:()=>D([])}):"",Yn.jsx($T,{tags:L,onDeleteTag:M})]})]})]}),j?Yn.jsxs(WT,{children:[V.isLoading?Yn.jsx(GT,{}):"",!V.isLoading&&!(null==W?void 0:W.length)&&!V.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!!(n&&!w||R||P)}),!!V.error&&Yn.jsx(ai,{refresh:V.refetch,sx:{mt:40}}),Yn.jsx(ZS,{account:e,lqList:W,setOperatePool:s,supportAMM:k||T,getMigrationPairAndMining:l,timeRange:A})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(GS,{account:e,lqList:W,loading:V.isLoading,operatePool:r,setOperatePool:s,supportAMM:k||T,onlyV3:"v3"===S,getMigrationPairAndMining:l,timeRange:A}),Yn.jsx(Tj,{loading:V.isLoading,refetch:V.error?V.refetch:void 0,empty:!(null==W?void 0:W.length),hasSearch:!!(n&&!w||R||P)})]})]})}function YS(e){var{sx:t}=e,n=qn(e,["sx"]);return Yn.jsx(O,{...n,sx:Object.assign(Object.assign({},t),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function KS({params:e,scrollRef:t,tokenAndPoolFilter:n,operatePool:o,onOperatePool:r,getMigrationPairAndMining:s}){var l,d,c;const{isMobile:u}=Tg();a();const p=Jn((e=>e.noDocumentLink)),h=H.useRef(null),{account:m}=dg(),{poolTopTab:g,normalPoolTab:f,almPoolTab:x,multiTokenPoolTab:y,normalTabs:v,almTabs:b,topTabs:j,multiTokenTabs:C,handleChangePoolTab:w}=function(){const[e,t]=z(FS.NORMAL),[n,i]=z(US.ALL),[o,r]=z(qS.addLiquidity),[a,s]=z(VS.ALL),{supportAMMV2:l,supportAMMV3:d,notSupportPMM:c,supportCurve:u}=Jn(),p=$((()=>{const e=[{key:FS.NORMAL,value:"Normal"}];return u&&e.push({key:FS.MULTI_TOKEN,value:"Multi-token"}),e}),[u]),h=$((()=>[{key:US.ALL,value:"All vauls"},{key:US.MY,value:"My liquidity"}]),[]),m=$((()=>{const e=[{key:qS.addLiquidity,value:"Add Liquidity"},{key:qS.myLiquidity,value:"My Liquidity"}];return c||e.push({key:qS.myCreated,value:l||d?"My Pools (PMM)":"My Pools"}),e}),[l,d,c]),g=$((()=>[{key:VS.ALL,value:"All pools"},{key:VS.MY,value:"My liquidity"}]),[]),f=G(!1);return Q((()=>{const e=sessionStorage.getItem(BS),n=sessionStorage.getItem(DS);e&&n&&!f.current&&(f.current=!0,t(e),e===FS.NORMAL?r(n):e===FS.ALM?i(n):e===FS.MULTI_TOKEN&&s(n))}),[]),{poolTopTab:e,normalPoolTab:o,almPoolTab:n,multiTokenPoolTab:a,topTabs:p,normalTabs:m,almTabs:h,multiTokenTabs:g,handleChangePoolTab:({topTab:e,poolTab:n})=>{t(e),e===FS.NORMAL?r(n):e===FS.ALM?i(n):e===FS.MULTI_TOKEN&&s(n),sessionStorage.setItem(BS,e),sessionStorage.setItem(DS,n)}}}(),{activeChainId:k,filterChainIds:T,handleChangeActiveChainId:I}=function(){const{chainId:e}=dg(),{onlyChainId:t,defaultChainId:n}=Jn(),[i,o]=H.useState(t),r=H.useMemo((()=>void 0!==i?[i]:sh(e)?void 0:Object.values(le).filter((e=>!!Number(e)))),[e,i]);return H.useEffect((()=>{const e=Number(sessionStorage.getItem(NS));e&&o(e)}),[]),H.useEffect((()=>{!sessionStorage.getItem(NS)&&n&&o(n)}),[n]),{activeChainId:i,filterChainIds:r,handleChangeActiveChainId:e=>{void 0===e?sessionStorage.removeItem(NS):sessionStorage.setItem(NS,String(e)),o(e)}}}(),[E,A]=H.useState(null),[L,R]=H.useState(o||null),P=e=>{if(r){if(r(e))return}R(e)};return H.useEffect((()=>{R(o||null)}),[o]),Yn.jsxs(zj,{sx:Object.assign({},u?{p:0}:{display:"flex",gap:12,flex:1}),ref:h,children:[Yn.jsxs(S,{value:g,onChange:(e,t)=>{t===FS.NORMAL?w({topTab:t,poolTab:f}):t===FS.ALM?w({topTab:t,poolTab:x}):t===FS.MULTI_TOKEN&&w({topTab:t,poolTab:y})},sx:u?{}:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%"},children:[Yn.jsxs(i,{sx:Object.assign({},u?void 0:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",pb:16,borderBottomWidth:1,borderBottomColor:"border.main",borderBottomStyle:"solid"}),children:[Yn.jsx(D,{tabs:j,variant:"default",tabsListSx:Object.assign({justifyContent:"space-between"},u?{mb:12,gap:32}:{borderBottomWidth:0}),tabSx:u?{mr:0,padding:"0px 0px 16px 0px",flexGrow:1,flexShrink:1,flexBasis:"93px",gap:32}:{mr:48,typography:"h5",lineHeight:"25px",minHeight:41,padding:"8px 0px 8px 0px"}}),g===FS.NORMAL&&Yn.jsx(MS,{})]}),Yn.jsx(YS,{value:FS.ALM,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:"ALM"}),Yn.jsx(YS,{value:FS.NORMAL,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsxs(S,{value:f,onChange:(e,t)=>{w({topTab:FS.NORMAL,poolTab:t})},children:[Yn.jsx(O,{value:qS.addLiquidity,children:Yn.jsx(PS,{account:m,filterChainIds:T,scrollParentRef:null!=t?t:h,activeChainId:k,handleChangeActiveChainId:I,operatePool:L,setOperatePool:P,tokenAndPoolFilter:n,getMigrationPairAndMining:s,children:Yn.jsx(F,{tabs:v,variant:"inPaperContrast"})})}),Yn.jsx(O,{value:qS.myLiquidity,children:Yn.jsx(QS,{account:m,filterChainIds:T,activeChainId:k,handleChangeActiveChainId:I,operatePool:L,setOperatePool:P,tokenAndPoolFilter:n,getMigrationPairAndMining:s,children:Yn.jsx(F,{tabs:v,variant:"inPaperContrast"})})}),Yn.jsx(O,{value:qS.myCreated,children:Yn.jsx(zS,{account:m,filterChainIds:T,activeChainId:k,handleChangeActiveChainId:I,operatePool:L,setOperatePool:P,children:Yn.jsx(F,{tabs:v,variant:"inPaperContrast"})})}),!p&&Yn.jsx(Qj,{title:"How does Liquidity Pools work?",descList:[{title:"Deposit Liquidity",desc:"Select a liquidity pool that suits your preferences and supply a pair of assets in our AMM pools or any supported assets in StableSwap pools. In return, you'll receive LP tokens, representing your share of the liquidity provided."},{title:"Earn Fees",desc:"As transactions occur within the pool, fees are collected and added to your LP tokens' value. This accrues daily, giving you real-time APY as your token holdings grow."},{title:"Delegate & Change Pool Fees",desc:"Boosted pool rewards are distributed every Sunday. If you've contributed liquidity to these pools, simply visit the rewards page, select the relevant week, and claim your earnings with ease."}],linkTo:"https://docs.dodoex.io/product/tutorial/how-to-provide-liquidity",sx:Object.assign({mt:16},u&&{mt:20})})]})}),Yn.jsx(YS,{value:FS.MULTI_TOKEN,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsxs(S,{value:y,onChange:(e,t)=>{w({topTab:FS.MULTI_TOKEN,poolTab:t})},children:[Yn.jsx(O,{value:VS.ALL,children:Yn.jsx(rI,{scrollParentRef:null!=t?t:h,activeChainId:k,operateCurvePool:E,setOperateCurvePool:A,account:m,children:Yn.jsx(F,{tabs:C,variant:"inPaperContrast"})})}),Yn.jsx(O,{value:VS.MY,children:Yn.jsx(rI,{scrollParentRef:null!=t?t:h,activeChainId:k,operateCurvePool:E,setOperateCurvePool:A,account:m,isMyPool:!0,children:Yn.jsx(F,{tabs:C,variant:"inPaperContrast"})})})]})})]}),g===FS.NORMAL&&L&&Yn.jsx(i,{sx:{position:"relative",width:u?"100%":375},children:"AMMV3"===(null===(l=null==L?void 0:L.pool)||void 0===l?void 0:l.type)&&L.pool.chainId?f===qS.myLiquidity&&(null===(c=null===(d=L.pool.liquidityPositions)||void 0===d?void 0:d[0])||void 0===c?void 0:c.tokenId)?Yn.jsx(FT,{baseToken:L.pool.baseToken,quoteToken:L.pool.quoteToken,feeAmount:Number(L.pool.lpFeeRate),tokenId:L.pool.liquidityPositions[0].tokenId,chainId:L.pool.chainId,onClose:()=>P(null)}):Yn.jsx(VT,{chainId:L.pool.chainId,baseToken:L.pool.baseToken,quoteToken:L.pool.quoteToken,feeAmount:Number(L.pool.lpFeeRate),onClose:()=>P(null),handleGoToAddLiquidityV3:e=>{Gj.getState().push({type:Zj.createPoolAMMV3,params:e})}}):Yn.jsx(Yn.Fragment,{children:u?Yn.jsx(mS,{account:m,onClose:()=>P(null),modal:u,...L}):Yn.jsx(hS,{account:m,onClose:()=>P(null),...L,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"}})})}),g===FS.MULTI_TOKEN&&E&&Yn.jsx(i,{sx:{position:"relative",width:u?"100%":375},children:Yn.jsx(hI,{operateCurvePool:E,setOperateCurvePool:A})})]})}function XS({sx:e,onClick:t}){const n=a();return Yn.jsx(r,{onClick:()=>{t?t():Gj.getState().back()},sx:ne({display:"inline-flex",alignItems:"center",cursor:"pointer"},e),children:Yn.jsx(i,{sx:{color:n.palette.text.secondary,width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",borderColor:n.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:8,backgroundColor:n.palette.background.paper},children:Yn.jsx(li.ArrowBack,{})})})}var JS,eE,tE,nE,iE,oE,rE,aE,sE,lE,dE,cE,uE;function pE(){return pE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},pE.apply(null,arguments)}const hE=e=>W.createElement("svg",pE({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),JS||(JS=W.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_5229_28889)"})),eE||(eE=W.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_5229_28889)"})),tE||(tE=W.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_5229_28889)"})),nE||(nE=W.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_5229_28889)"})),iE||(iE=W.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_5229_28889)"})),oE||(oE=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28889)"})),rE||(rE=W.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_5229_28889)"})),aE||(aE=W.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_5229_28889)"})),sE||(sE=W.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_5229_28889)"})),lE||(lE=W.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_5229_28889)"})),dE||(dE=W.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_5229_28889)"})),cE||(cE=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28889)"})),uE||(uE=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5229_28889",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_5229_28889",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_5229_28889",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_5229_28889",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_5229_28889",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_5229_28889",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_5229_28889",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_5229_28889",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_5229_28889",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_5229_28889",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_5229_28889",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5229_28889",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var mE,gE,fE,xE,yE,vE,bE,jE,CE,wE,kE,TE,IE;function SE(){return SE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},SE.apply(null,arguments)}const EE=e=>W.createElement("svg",SE({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),mE||(mE=W.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_3900_354238)"})),gE||(gE=W.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_3900_354238)"})),fE||(fE=W.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_3900_354238)"})),xE||(xE=W.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_3900_354238)"})),yE||(yE=W.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_3900_354238)"})),vE||(vE=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_3900_354238)"})),bE||(bE=W.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_3900_354238)"})),jE||(jE=W.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_3900_354238)"})),CE||(CE=W.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_3900_354238)"})),wE||(wE=W.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_3900_354238)"})),kE||(kE=W.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_3900_354238)"})),TE||(TE=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_3900_354238)"})),IE||(IE=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_3900_354238",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_3900_354238",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_3900_354238",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_3900_354238",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_3900_354238",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_3900_354238",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_3900_354238",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_3900_354238",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_3900_354238",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_3900_354238",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_3900_354238",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_3900_354238",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var AE,OE,LE,RE,PE,_E,ME,BE,DE,NE,FE,UE,qE,VE;function WE(){return WE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},WE.apply(null,arguments)}const HE=e=>W.createElement("svg",WE({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),AE||(AE=W.createElement("g",{clipPath:"url(#clip0_5057_344879)"},W.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344879)"}),W.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344879)"}),W.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344879)"}),W.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344879)"}),W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344879)"}),W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344879)"}),W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344879)"}),W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344879)"}),W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344879)"}),W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344879)"}))),OE||(OE=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344879)"})),LE||(LE=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344879)"})),RE||(RE=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344879)"})),PE||(PE=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344879)"})),_E||(_E=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344879)"})),ME||(ME=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344879)"})),BE||(BE=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344879)"})),DE||(DE=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344879)"})),NE||(NE=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344879)"})),FE||(FE=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344879)"})),UE||(UE=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344879)"})),qE||(qE=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344879)"})),VE||(VE=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5057_344879",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5057_344879",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint2_linear_5057_344879",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint3_linear_5057_344879",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint4_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint5_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint6_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint7_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint8_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint9_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint10_linear_5057_344879",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5057_344879",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint12_linear_5057_344879",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint13_linear_5057_344879",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint14_linear_5057_344879",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint15_linear_5057_344879",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint16_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint17_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint18_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint19_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint20_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint21_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("clipPath",{id:"clip0_5057_344879"},W.createElement("rect",{width:737,height:220,fill:"white"})))));var $E,zE,ZE,GE,QE,YE,KE,XE,JE,eA,tA,nA,iA,oA;function rA(){return rA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},rA.apply(null,arguments)}const aA=e=>W.createElement("svg",rA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),$E||($E=W.createElement("g",{clipPath:"url(#clip0_5057_344817)"},W.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344817)"}),W.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344817)"}),W.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344817)"}),W.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344817)"}),W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344817)"}),W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344817)"}),W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344817)"}),W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344817)"}),W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344817)"}),W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344817)"}))),zE||(zE=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344817)"})),ZE||(ZE=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344817)"})),GE||(GE=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344817)"})),QE||(QE=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344817)"})),YE||(YE=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344817)"})),KE||(KE=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344817)"})),XE||(XE=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344817)"})),JE||(JE=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344817)"})),eA||(eA=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344817)"})),tA||(tA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344817)"})),nA||(nA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344817)"})),iA||(iA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344817)"})),oA||(oA=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5057_344817",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5057_344817",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint2_linear_5057_344817",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint3_linear_5057_344817",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint4_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint5_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint6_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint7_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint8_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint9_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint10_linear_5057_344817",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5057_344817",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint12_linear_5057_344817",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint13_linear_5057_344817",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint14_linear_5057_344817",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint15_linear_5057_344817",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint16_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint17_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint18_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint19_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint20_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint21_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("clipPath",{id:"clip0_5057_344817"},W.createElement("rect",{width:737,height:220,fill:"white"})))));var sA,lA,dA,cA,uA,pA,hA,mA,gA,fA,xA,yA,vA;function bA(){return bA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bA.apply(null,arguments)}const jA=e=>W.createElement("svg",bA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),sA||(sA=W.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),lA||(lA=W.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),dA||(dA=W.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),cA||(cA=W.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),uA||(uA=W.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),pA||(pA=W.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),hA||(hA=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_5229_28865)"})),mA||(mA=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_5229_28865)"})),gA||(gA=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_5229_28865)"})),fA||(fA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_5229_28865)"})),xA||(xA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_5229_28865)"})),yA||(yA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_5229_28865)"})),vA||(vA=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5229_28865",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_5229_28865",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_5229_28865",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_5229_28865",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_5229_28865",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_5229_28865",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var CA,wA,kA,TA,IA,SA,EA,AA,OA,LA,RA,PA,_A;function MA(){return MA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MA.apply(null,arguments)}const BA=e=>W.createElement("svg",MA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),CA||(CA=W.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),wA||(wA=W.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),kA||(kA=W.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),TA||(TA=W.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),IA||(IA=W.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),SA||(SA=W.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),EA||(EA=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_3900_354262)"})),AA||(AA=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_3900_354262)"})),OA||(OA=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_3900_354262)"})),LA||(LA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_3900_354262)"})),RA||(RA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_3900_354262)"})),PA||(PA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_3900_354262)"})),_A||(_A=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_3900_354262",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_3900_354262",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_3900_354262",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_3900_354262",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_3900_354262",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_3900_354262",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var DA,NA,FA,UA,qA,VA,WA,HA,$A,zA,ZA,GA,QA;function YA(){return YA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},YA.apply(null,arguments)}const KA=e=>W.createElement("svg",YA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),DA||(DA=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_5229_28987)"})),NA||(NA=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_5229_28987)"})),FA||(FA=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_5229_28987)"})),UA||(UA=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_5229_28987)"})),qA||(qA=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_5229_28987)"})),VA||(VA=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28987)"})),WA||(WA=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_5229_28987)"})),HA||(HA=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_5229_28987)"})),$A||($A=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_5229_28987)"})),zA||(zA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_5229_28987)"})),ZA||(ZA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_5229_28987)"})),GA||(GA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28987)"})),QA||(QA=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5229_28987",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_5229_28987",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_5229_28987",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_5229_28987",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_5229_28987",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_5229_28987",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_5229_28987",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_5229_28987",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_5229_28987",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_5229_28987",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_5229_28987",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5229_28987",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var XA,JA,eO,tO,nO,iO,oO,rO,aO,sO,lO,dO,cO;function uO(){return uO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uO.apply(null,arguments)}const pO=e=>W.createElement("svg",uO({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),XA||(XA=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_4437_25449)"})),JA||(JA=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_4437_25449)"})),eO||(eO=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_4437_25449)"})),tO||(tO=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_4437_25449)"})),nO||(nO=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_4437_25449)"})),iO||(iO=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_4437_25449)"})),oO||(oO=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_4437_25449)"})),rO||(rO=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_4437_25449)"})),aO||(aO=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_4437_25449)"})),sO||(sO=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_4437_25449)"})),lO||(lO=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_4437_25449)"})),dO||(dO=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_4437_25449)"})),cO||(cO=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_4437_25449",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_4437_25449",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_4437_25449",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_4437_25449",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_4437_25449",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_4437_25449",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_4437_25449",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_4437_25449",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_4437_25449",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_4437_25449",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_4437_25449",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_4437_25449",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var hO,mO;function gO(){const e="https://docs.dodoex.io/product/tutorial/how-to-create-pools#learn-more-about-the-characteristics-of-different-pool-models",t=[{version:mO.standard,title:se._({id:"TJBHlP",message:"Standard"}),description:se._({id:"QNrpkx",message:"Classical AMM-like pool. Suitable for most assets."}),exampleImgUrl:pO,exampleDarkImgUrl:KA,docUrl:e,initPriceLabel:se._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:se._({id:"5OKrbq",message:"Since this pool uses the PMM algorithm, which is different from the normal AMM pool mechanism, the initial price calculation is also different from AMM."}),initPriceTipsLink:"https://docs.dodoex.io/en/product/dodo-v2-pools/dodo-vending-machine/dvm-initial-price-formula-explanation"},{version:mO.pegged,title:se._({id:"J7M/DA",message:"Pegged"}),description:se._({id:"RvYEUJ",message:"Suitable for synthetic assets. The liquidity is super concentrated at some price like Curve Finance."}),exampleImgUrl:EE,exampleDarkImgUrl:hE,docUrl:e,initPriceLabel:se._({id:"4ogEAw",message:"Pegged Exchange Rate"}),initPriceTips:se._({id:"M9dIDb",message:"The pegged exchange rate refers to the exchange rate between two token assets where one's value is pegged/fixed by the other. For example, the pegged exchange rate between the US Dollar and USDT is 1."})},{version:mO.singleToken,title:se._({id:"34w3mT",message:"Single-Token"}),description:se._({id:"a1AzKr",message:"For those who are looking to sell tokens and only need ask-side liquidity."}),exampleImgUrl:BA,exampleDarkImgUrl:jA,docUrl:e,initPriceLabel:se._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:se._({id:"HGf8fG",message:"You can set the minimum selling price for single-token pools."})},{version:mO.marketMakerPool,title:se._({id:"4vKwIV",message:"Private Pool"}),description:se._({id:"pKjCsP",message:"100% use your own funds and enjoy the maximum degree of flexibility."}),exampleImgUrl:aA,exampleDarkImgUrl:HE,docUrl:e,initPriceLabel:se._({id:"CeLrge",message:"Mid Price"}),initPriceTips:se._({id:"GGPOuT",message:"set current mid price"})}],n=t.reduce(((e,t)=>(e[t.version]=t,e)),{});return{versionList:t,versionMap:n,subPeggedVersionList:fO()}}function fO(){return[{version:hO.DSP,title:se._({id:"D1bhHv",message:"The pool’s market-making price is fixed"}),description:se._({id:"lgE483",message:"Once created, the price cannot be changed. This option applies to assets like ETH-WETH."})},{version:hO.GSP,title:se._({id:"LVzIav",message:"The pool’s market-making price can be adjusted"}),description:se._({id:"KkjUUb",message:"Once created, you can adjust the pool’s market-making price at any time. This option is suitable for assets with fluctuating pegged prices. Adjusting the pool’s market-making price allows for more competitive quotes."})}]}function xO(){return fO().reduce(((e,t)=>(e[t.version]=t,e)),{})}!function(e){e.DSP="dsp",e.GSP="gsp"}(hO||(hO={})),function(e){e.standard="standard",e.singleToken="single-token",e.pegged="pagged",e.marketMakerPool="market-maker-pool"}(mO||(mO={}));const yO="0.3",vO=0,bO=10,jO="1",CO="0.0000000000001",wO=1e8,kO="1",TO="0.0001",IO="0.1",SO=8;function EO({selectedVersion:e,quoteToken:t,initPrice:n,midPrice:i}){return e===mO.standard?!i||i.isZero()?null:Am({input:i,decimals:t.decimals}):Am({input:n,decimals:t.decimals})}function AO({initPrice:e}){const t=new Pe(e);if(!t.isFinite()||t.lte(0))return{base:null,quote:null};const n=new Pe(1),i=n.dividedBy(n.plus(t)).dp(SO,Pe.ROUND_DOWN);return{base:i,quote:n.minus(i).dp(SO,Pe.ROUND_DOWN)}}function OO({chainId:e,baseToken:t,quoteToken:n}){const i=we[e];return!(!t||!n)&&(!(!Xm(t.address,i.address)||!Xm(n.address,i.wrappedTokenAddress))||!(!Xm(t.address,i.wrappedTokenAddress)||!Xm(n.address,i.address)))}function LO({title:e,children:t,isWaiting:n}){const o=a();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:n?"-":t}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function RO({status:t,selectedVersion:n,baseToken:o,quoteToken:r,initPrice:a,slippageCoefficient:s,midPrice:l,sx:d}){var c;const{versionMap:u}=gO(),p="waiting"===t,{initPriceLabel:h}=u[n];return o&&r?Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:Object.assign({mt:0,display:"flex",alignItems:"stretch",gap:12,opacity:p?.5:1},d),children:[Yn.jsxs(LO,{title:Yn.jsx(e,{id:"fSFt4a",message:"Token Pair"}),isWaiting:p,children:[Yn.jsx(kj,{width:24,height:24,tokens:[o,r]}),o.symbol,"-",r.symbol]}),Yn.jsx(LO,{title:Yn.jsx(e,{id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:p,children:s}),Yn.jsxs(LO,{title:h,isWaiting:p,children:["1 ",o.symbol," = ",null!==(c=EO({midPrice:l,quoteToken:r,selectedVersion:n,initPrice:a}))&&void 0!==c?c:"-"," ",r.symbol]})]})}):null}var PO,_O;function MO(){return MO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MO.apply(null,arguments)}const BO=e=>W.createElement("svg",MO({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),PO||(PO=W.createElement("g",{clipPath:"url(#clip0_5251_29079)"},W.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_29079)"}),W.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#EC5A7D",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),W.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_29079)"}),W.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#2FBA90",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),_O||(_O=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5251_29079",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EC5A7D",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#EC5A7D",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5251_29079",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#2FBA90",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#2FBA90",stopOpacity:0})),W.createElement("clipPath",{id:"clip0_5251_29079"},W.createElement("rect",{width:54,height:32,fill:"white"})))));var DO,NO;function FO(){return FO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},FO.apply(null,arguments)}const UO=e=>W.createElement("svg",FO({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),DO||(DO=W.createElement("g",{clipPath:"url(#clip0_5251_28999)"},W.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_28999)"}),W.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#FF6187",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),W.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_28999)"}),W.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#55F9C7",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),NO||(NO=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5251_28999",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FF6187",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#FF6187",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5251_28999",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#55F9C7",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#55F9C7",stopOpacity:0})),W.createElement("clipPath",{id:"clip0_5251_28999"},W.createElement("rect",{width:54,height:32,fill:"white"})))));function qO({height:e,text:t}){return Yn.jsx(ti,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",height:e||261},emptyText:t||se._({id:"uiuMDr",message:"Enter parameters to view the yield curve"})})}const VO=H.lazy((()=>import("./index-CNqXq0K8.js"))),WO=H.lazy((()=>import("./index-r-jtP40I.js")));var HO,$O;function zO({baseToken:t,quoteToken:n,pmmParams:o,pmmModel:r,midPrice:s}){var l,d;const c=a(),{isMobile:u}=Tg(),[p,h]=H.useState(HO.depth),m=H.useRef(null),[g,f]=H.useState(0),x=null!==(l=null==t?void 0:t.symbol)&&void 0!==l?l:"",y=null!==(d=null==n?void 0:n.symbol)&&void 0!==d?d:"";H.useEffect((()=>{const e=()=>{m&&m.current&&f(m.current.offsetWidth)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[m,s]);const v=p===HO.depth;if(!s||s.isNaN())return Yn.jsx(qO,{height:u?261:v?665:494});const b=c.palette.success.main,j=c.palette.error.main,C=[{key:HO.liquidity,value:se._({id:"6y2TB3",message:"Liquidity"})},{key:HO.depth,value:se._({id:"n25Lml",message:"Depth"})}];return Yn.jsxs(i,{ref:m,sx:{mt:2,"& input":{backgroundColor:"background.cardInput",borderStyle:"solid",borderWidth:"1px",borderColor:"border.main",borderRadius:8,color:"text.primary",overflow:"hidden"},"& .operate-btn-wrapper button":{backgroundColor:"background.paperContrast",color:"text.primary"}},children:[Yn.jsxs(S,{value:p,onChange:(e,t)=>{h(t)},children:[Yn.jsx(F,{tabs:C,variant:"tag",tabsListSx:{ml:"auto"}}),Yn.jsx(i,{sx:Object.assign({typography:"h6",mt:8,mb:14,color:"text.secondary"},u?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:Yn.jsx(e,{id:"tyGEMJ",message:"Amounts"})}),Yn.jsx(O,{value:HO.depth,children:g&&Yn.jsx(H.Suspense,{children:Yn.jsx(VO,{width:g,height:u?261:364,chartId:"create-pool-depth-chart",baseTokenSymbol:x,quoteTokenSymbol:y,pmmModel:r,pmmParams:o,midPrice:s,colorMap:{grid:"light"===c.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===c.palette.mode?"#E4E4E4":void 0,leftBg:[0,T(b,.04),1,T(b,.3)],leftLine:b,rightBg:[0,T(j,.04),1,T(j,.3)],rightLine:j,tooltipBg:c.palette.background.paperContrast,tooltipColor:c.palette.text.primary},notShowAmountInput:u})})}),Yn.jsx(O,{value:HO.liquidity,children:Yn.jsx(H.Suspense,{children:Yn.jsx(WO,{width:g,height:u?261:364,baseTokenSymbol:x,quoteTokenSymbol:y,pmmModel:r,pmmParams:o,midPrice:s,notShowTipText:!0,colorMap:{grid:"light"===c.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===c.palette.mode?"#E4E4E4":void 0,leftBg:[0,T(b,.04),1,T(b,.3)],leftLine:b,rightBg:[0,T(j,.04),1,T(j,.3)],rightLine:j,tooltipBg:c.palette.background.paperContrast,tooltipColor:c.palette.text.primary,textColor:c.palette.text.secondary}})})})]}),Yn.jsx(i,{sx:Object.assign({typography:"h6",mt:6,color:"text.secondary"},u?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:Yn.jsx(e,{id:"DZULmp",message:"Swap Rate"})}),v?"":Yn.jsxs(i,{sx:{typography:"h6",mt:24,color:"text.secondary",textAlign:"center"},children:["* ",se._({id:"DuVAxN",message:"The area of the chart indicates the buy/sell volume of {baseSymbol} that can be carried by the market when the current price changes to the hover price.",values:{baseSymbol:x}})]})]})}!function(e){e[e.liquidity=1]="liquidity",e[e.depth=2]="depth"}(HO||(HO={})),function(e){e[e.standard=1]="standard",e[e.singleToken=2]="singleToken",e[e.pagged=3]="pagged",e[e.marketMaker=4]="marketMaker"}($O||($O={}));const ZO=({selectedVersion:e,baseAmount:t,quoteAmount:n,initPrice:i,slippageCoefficient:o})=>{const r=$((()=>{const r=[mO.standard,mO.singleToken].includes(e),a=e===mO.singleToken;if(!t||!a&&!n)return;const s=Number(i),l=Number(t),d=Number(n),c=Number(o);return{i:s,k:c,b:l,b0:l,q:d,q0:0!==c&&r?0:d,R:0!==c&&r?1:0}}),[t,i,n,e,o]),a=$((()=>{if(r)return Le(r)}),[r]),s=$((()=>{if(a)return a.getMidPrice()}),[a]);return{pmmParams:r,pmmModel:a,midPrice:s}};function GO({selectedVersion:e,baseToken:t,quoteToken:n,initPrice:o,slippageCoefficient:r,baseAmount:s,quoteAmount:l}){const c=a(),{isMobile:u}=Tg(),[p,h]=H.useState(!1),{pmmParams:m,pmmModel:g,midPrice:x}=ZO({selectedVersion:e,baseAmount:s,quoteAmount:l,initPrice:o,slippageCoefficient:r});if(!u)return null;const y=se._({id:"FQfStS",message:"Emulator"}),v=se._({id:"ihn3o9",message:"The liquidity of ZUNO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{mx:20,mb:8},children:Yn.jsxs(i,{sx:{width:"100%",px:20,py:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:c.palette.border.main,display:"flex",alignItems:"center",justifyContent:"space-between"},component:d,onClick:()=>h(!0),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:c.palette.text.secondary,typography:"body1",fontWeight:600},children:[y,Yn.jsx(f,{title:v,ml:4,sx:{width:14,height:14}})]}),!x||x.isNaN()?Yn.jsx(i,{sx:{py:5,typography:"body1"},children:"-"}):"light"===c.palette.mode?Yn.jsx(BO,{width:"52",height:"32"}):Yn.jsx(UO,{width:"52",height:"32"})]})}),Yn.jsx(Of,{open:p,onClose:()=>h(!1),modal:!0,title:Yn.jsxs(i,{children:[y,Yn.jsx(f,{title:v,ml:4})]}),children:Yn.jsx(i,{sx:{px:28,pb:20,maxHeight:"calc(80vh - 134px)",overflowY:"auto",overflowX:"hidden"},children:Yn.jsx(zO,{baseToken:t,quoteToken:n,pmmParams:m,pmmModel:g,midPrice:x})})})]})}function QO({color:e,backgroundColor:t,tagKey:n}){return Yn.jsx(i,{sx:{ml:8,px:8,py:2,borderRadius:4,backgroundColor:t,color:e,typography:"h6",fontWeight:500},children:n})}function YO({isWaiting:t,feeRate:n}){const o=a();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,width:"50%",opacity:t?.5:1},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:t?"-":Yn.jsxs(Yn.Fragment,{children:[n||"-","%",n===yO&&Yn.jsx(QO,{tagKey:se._({id:"/+c6tU",message:"99% Default"}),color:o.palette.purple.main,backgroundColor:T(o.palette.purple.main,.1)})]})}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"})})]})}function KO({isWaiting:t,selectedVersion:n,baseToken:o,quoteToken:r,initPrice:s,slippageCoefficient:l,baseAmount:d,quoteAmount:c,peggedBaseTokenRatio:u,peggedQuoteTokenRatio:p}){const h=a(),{pmmParams:m,pmmModel:g,midPrice:f}=ZO({selectedVersion:n,baseAmount:d,quoteAmount:c,initPrice:s,slippageCoefficient:l});return Yn.jsxs(Yn.Fragment,{children:[!t&&Yn.jsx(zO,{baseToken:o,quoteToken:r,pmmParams:m,pmmModel:g,midPrice:f}),Yn.jsxs(i,{sx:{mt:t?0:20,padding:16,borderRadius:8,backgroundColor:h.palette.background.paper,width:"50%",opacity:t?.5:1},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:t?"-":Yn.jsxs(Yn.Fragment,{children:[u,"% ",null==o?void 0:o.symbol," : ",p,"% ",null==r?void 0:r.symbol]})}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:h.palette.text.secondary,mt:8},children:Yn.jsx(e,{id:"eK0eiF",message:"Initial asset ratio"})})]})]})}function XO({title:e,children:t,isWaiting:n}){const o=a();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:n?"-":t}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function JO({status:e,selectedVersion:t,baseToken:n,quoteToken:o,initPrice:r,slippageCoefficient:a,baseAmount:s,quoteAmount:l}){var d;const{pmmParams:c,pmmModel:u,midPrice:p}=ZO({selectedVersion:t,baseAmount:s,quoteAmount:l,initPrice:r,slippageCoefficient:a}),{versionMap:h}=gO(),m="waiting"===e,{initPriceLabel:g}=h[t];return Yn.jsxs(Yn.Fragment,{children:["running"===e&&Yn.jsx(zO,{baseToken:n,quoteToken:o,pmmParams:c,pmmModel:u,midPrice:p}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"stretch",gap:12,opacity:m?.5:1},children:[Yn.jsx(XO,{title:se._({id:"fSFt4a",message:"Token Pair"}),isWaiting:m,children:n&&o?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(kj,{width:24,tokens:[n,o],chainId:n.chainId}),n.symbol,"-",o.symbol]}):""}),Yn.jsx(XO,{title:g,isWaiting:m,children:n&&o?Yn.jsxs(Yn.Fragment,{children:["1 ",n.symbol,"=",null!==(d=EO({midPrice:p,quoteToken:o,selectedVersion:t,initPrice:r}))&&void 0!==d?d:"-"," ",o.symbol]}):""}),Yn.jsx(XO,{title:se._({id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:m,children:a})]})]})}function eL({isWaiting:t,selectedSubPeggedVersion:n}){var o,r;const s=a(),l=xO();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:s.palette.background.paper,width:"50%",opacity:t?.5:1},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:t?"-":n&&null!==(r=null===(o=l[n])||void 0===o?void 0:o.title)&&void 0!==r?r:"-"}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:s.palette.text.secondary,mt:8},children:Yn.jsx(e,{id:"XPiFIY",message:"Can the pool price be adjusted?"})})]})}function tL({index:e,titleKey:t,status:n}){const o=a(),{isMobile:r}=Tg();return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:Object.assign({mt:28,mb:28,borderTopColor:"border.main",borderTopStyle:"solid",borderTopWidth:1},r?{mt:12,mb:12,display:1===e?"none":"block"}:{})}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",mb:20},children:[Yn.jsx(i,{sx:{display:"flex",width:"20px",height:"20px",justifyContent:"center",alignItems:"center",flexShrink:0,borderRadius:"50%",backgroundColor:"waiting"===n?o.palette.background.paperDarkContrast:o.palette.secondary.main,typography:"h6",fontWeight:600,textAlign:"center",color:"waiting"===n?o.palette.text.disabled:o.palette.secondary.contrastText},children:"completed"===n?Yn.jsx(Yn.Fragment,{children:Yn.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M12.7596 3.55566L5.92549 10.3897L3.23957 7.71418L1.77734 9.17641L5.92549 13.3246L14.2218 5.02826L12.7596 3.55566Z",fill:"currentColor"})})}):e}),Yn.jsx(i,{sx:{ml:8,typography:"body1",fontWeight:600,color:"waiting"===n?o.palette.text.disabled:o.palette.text.primary},children:t})]})]})}function nL({currentStep:e,isPeggedVersion:t}){const n=a(),{isMobile:o}=Tg();let r="",s="",l="";switch(e){case 0:r=se._({id:"hdIg7i",message:"Select Pool Version"}),l=se._({id:"fw3eYd",message:"ZUNO provides a variety of pool versions to suit your needs."});break;case 1:r=se._({id:"lsg9Mi",message:"Parameter Settings"});break;case 2:t?r=se._({id:"6lss/t",message:"Pricing Model"}):(r=se._({id:"Y7rVy0",message:"Fee Rate"}),s=se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}));break;case 3:if(!t)throw new Error("type is error");r=se._({id:"Y7rVy0",message:"Fee Rate"}),s=se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."});break;case 4:if(!t)throw new Error("type is error");r=se._({id:"3ggd2j",message:"Asset ratio within the pool"});break;default:throw new Error(`Invalid Step ${e}`)}return Yn.jsxs(i,{sx:Object.assign({position:"sticky",top:0,py:20,px:20,backgroundColor:n.palette.background.paper,zIndex:1},o?{}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"h5",color:n.palette.text.primary,fontWeight:600},children:r}),s&&Yn.jsx(f,{title:s,sx:{width:16,height:16}}),Yn.jsx(i,{sx:{marginLeft:"auto",display:"flex",alignItems:"center",gap:12},children:(t?[0,1,2,3,4]:[0,1,2]).map((t=>Yn.jsx(i,{sx:{width:12,height:12,borderRadius:12,background:e>=t?n.palette.secondary.main:T(n.palette.primary.main,.1)}},t)))})]}),l&&Yn.jsx(i,{sx:{mt:8,typography:"body2",color:n.palette.text.secondary},children:l})]})}function iL({versionItem:t,status:n}){const o=a(),{noDocumentLink:r}=Jn(),s="light"===o.palette.mode;return"completed"===n?Yn.jsxs(i,{sx:{backgroundColor:o.palette.background.paper,borderRadius:8,width:"50%",padding:16},children:[Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,color:o.palette.text.primary},children:t.title}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,mt:8,color:o.palette.text.secondary},children:t.description})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"h4",fontWeight:600},children:t.title}),!r&&Yn.jsxs(i,{sx:{ml:8,display:"flex",padding:"2px 8px",justifyContent:"center",alignItems:"center",gap:"2px",color:o.palette.text.disabled,backgroundColor:o.palette.background.paperDarkContrast,borderRadius:4,typography:"h6"},component:"a",href:t.docUrl,target:"_blank",rel:"noreferrer",children:[Yn.jsx(e,{id:"TGi+jm",message:"Doc"}),Yn.jsx("svg",{width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 3.41667V11.5833H11.0833V7.5H12.25V11.5833C12.25 12.225 11.725 12.75 11.0833 12.75H2.91667C2.26917 12.75 1.75 12.225 1.75 11.5833V3.41667C1.75 2.775 2.26917 2.25 2.91667 2.25H7V3.41667H2.91667ZM8.16667 3.41667V2.25H12.25V6.33333H11.0833V4.23917L5.34917 9.97333L4.52667 9.15083L10.2608 3.41667H8.16667Z",fill:"currentColor"})})]})]}),Yn.jsx(i,{sx:{position:"relative",width:"100%",minHeight:220},children:Yn.jsx(i,{component:s?t.exampleImgUrl:t.exampleDarkImgUrl,sx:{marginTop:20,width:"100%"}})})]})}function oL({side:e,tokenList:t,occupyToken:n,needFindToken:i,chainId:o}){var r,a;let s=null,l=null;const d=t.filter((t=>!(t.side&&t.side!==e||o&&t.chainId!==o)));return d.length&&(i&&(s=null!==(r=d.find((e=>e.address===(null==i?void 0:i.address)&&e.chainId===i.chainId)))&&void 0!==r?r:null,l=s),l||(n?l=null!==(a=d.find((e=>e.address!==n.address)))&&void 0!==a?a:null:[l]=d)),{findToken:s,defaultToken:l}}function rL(){const{account:e,chainId:t}=dg(),n=Gj((e=>{var t;return null===(t=e.page)||void 0===t?void 0:t.params}));return function({chainId:e,account:t,defaultBaseToken:n,defaultQuoteToken:i,tokenListInclude:o}={}){const{tokenList:r}=Th(),a=oL({side:"from",needFindToken:n,tokenList:r,chainId:e}),s=et(Object.assign({},ip.getFetchTokenQuery(o?void 0:e,null==n?void 0:n.address,t))),l=et(Object.assign({},ip.getFetchTokenQuery(o?void 0:e,null==i?void 0:i.address,t)));let d=null,c=!1;d=a.defaultToken,s.data&&(d=s.data,c=s.isLoading);let u=null,p=!1;return u=oL({side:"to",needFindToken:i,occupyToken:d,tokenList:r,chainId:e}).defaultToken,l.data&&(u=l.data,p=l.isLoading),{defaultBaseToken:d,defaultQuoteToken:u,defaultBaseTokenLoading:c,defaultQuoteTokenLoading:p}}({chainId:t,account:e,defaultBaseToken:(null==n?void 0:n.fromAddress)?{address:null==n?void 0:n.fromAddress,chainId:t}:void 0,defaultQuoteToken:(null==n?void 0:n.toAddress)?{address:null==n?void 0:n.toAddress,chainId:t}:void 0})}function aL({tokens:e}){const{apikey:t}=Jn(),n=Vg(Zu.fiatPrice);return et({enabled:!!e.length,queryKey:["fetch","fetchFiatPrice",e],queryFn:()=>Vn(this,void 0,void 0,(function*(){const i=yield Zt.post(n,{networks:e.map((e=>ig(e.chainId))),addresses:e.map((e=>e.address)),symbols:e.map((e=>e.symbol)),isCache:!0},t?{headers:{apikey:t}}:void 0),o=new Map;return i.data.data&&i.data.data.forEach((e=>{const t=Number(e.price);!Number.isNaN(t)&&t>0&&o.set(e.address,t)})),o}))})}const sL=({selectedVersion:e})=>e===mO.pegged?["0.0001","0.0005","0.002"]:["0.5","0.01","1"];var lL;function dL(e,t){return!e||null==t||e.isNaN()?"":e.dp(t,Pe.ROUND_DOWN).toString()}function cL({state:e,fixedRatioPrice:t}){const{selectedVersion:n,baseToken:i,quoteToken:o,baseAmount:r,isFixedRatio:a,leftTokenAddress:s}=e;if(!i||!o)throw new Error("token is required");const l=s===(null==i?void 0:i.address),d=n===mO.standard,c=n===mO.pegged,u=new Pe(t);let p=d?CO:l?t:!u.isNaN()&&u.gt(0)?new Pe(1).div(u).dp(l?o.decimals:i.decimals).toString():jO;if(d){const e=18-i.decimals+o.decimals;e<String(CO).split(".")[1].length&&(p=new Pe(1).div(10**e).toString())}if(c){const n=AO({initPrice:p}),i=n.base?n.base.multipliedBy(100).toString():"",o=n.quote?n.quote.multipliedBy(100).toString():"";return Object.assign(Object.assign({},e),{initPrice:p,fixedRatioPrice:t,peggedBaseTokenRatio:i,peggedQuoteTokenRatio:o})}if(d&&a){const n=new Pe(r);if(!n.isNaN()&&!u.isNaN()&&u.gt(0)){const r=l?n.multipliedBy(u):n.div(u);return Object.assign(Object.assign({},e),{initPrice:p,fixedRatioPrice:t,baseAmount:dL(n,i.decimals),quoteAmount:dL(r,o.decimals)})}}return Object.assign(Object.assign({},e),{initPrice:p,fixedRatioPrice:t})}function uL(e,t){var n;switch(t.type){case lL.SetCurrentStep:{const{payload:n}=t;return e.selectedVersion===mO.pegged?Object.assign(Object.assign({},e),{currentStep:n>=4?4:n<=0?0:n}):Object.assign(Object.assign({},e),{currentStep:n>=2?2:n<=0?0:n})}case lL.SelectNewVersion:{const{payload:i}=t;if(i===e.selectedVersion)return e;let o,r=kO;i===mO.pegged&&(r=TO,o=hO.DSP);let a=CO;i===mO.singleToken?a="":i!==mO.standard&&(a=jO);let s=!0;return i===mO.singleToken&&(s=!1),Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:"",isFixedRatio:s,initPrice:a,fixedRatioPrice:i===mO.singleToken?"":jO,slippageCoefficient:r,isSlippageCoefficientCustomized:!sL({selectedVersion:t.payload}).includes(r),selectedVersion:t.payload,selectedSubPeggedVersion:o,leftTokenAddress:null===(n=e.baseToken)||void 0===n?void 0:n.address})}case lL.SelectNewSubPeggedVersion:return Object.assign(Object.assign({},e),{selectedSubPeggedVersion:t.payload});case lL.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:n,baseAmount:"",leftTokenAddress:null==n?void 0:n.address})}case lL.UpdateQuoteToken:{const{baseToken:n}=e;return Object.assign(Object.assign({},e),{quoteToken:t.payload,quoteAmount:"",leftTokenAddress:null==n?void 0:n.address})}case lL.SwitchTokens:{const{selectedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=e;return t===mO.singleToken?Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,leftTokenAddress:null==i?void 0:i.address}):Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,baseAmount:r,quoteAmount:o,leftTokenAddress:null==i?void 0:i.address})}case lL.UpdateBaseAmount:{const n=t.payload,{selectedVersion:i,quoteToken:o,fixedRatioPrice:r,isFixedRatio:a,peggedBaseTokenRatio:s}=e;if(!o)throw new Error("token is required");const l=new Pe(n);if(i===mO.pegged){const t=new Pe(s).div(100).dp(SO,Pe.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:""});const i=l.div(t).minus(l);return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:dL(i,o.decimals)})}if(i===mO.standard&&a&&r){if(!n)return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:n});const t=function(e,t){const n=new Re;return n.B=new Pe(e.baseAmount),n.i=new Pe(e.initPrice),n.k=new Pe(e.slippageCoefficient),n.RStatus=1,n.getQuoteByMidPrice(t)}(Object.assign(Object.assign({},e),{baseAmount:n}),new Pe(r));return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:dL(t,o.decimals)})}return Object.assign(Object.assign({},e),{baseAmount:n})}case lL.UpdateQuoteAmount:{const n=t.payload,{selectedVersion:i,baseToken:o,fixedRatioPrice:r,isFixedRatio:a,leftTokenAddress:s,peggedQuoteTokenRatio:l}=e;if(!o)throw new Error("token is required");const d=s===(null==o?void 0:o.address),c=new Pe(n);if(i===mO.pegged){const t=new Pe(l).div(100).dp(SO,Pe.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:n});const i=c.div(t).minus(c);return Object.assign(Object.assign({},e),{baseAmount:dL(i,o.decimals),quoteAmount:n})}if(i===mO.standard&&a){const t=new Pe(r),i=t.gt(0)?d?c.div(t):c.multipliedBy(t):void 0;return Object.assign(Object.assign({},e),{baseAmount:dL(i,o.decimals),quoteAmount:n})}return Object.assign(Object.assign({},e),{quoteAmount:n})}case lL.UpdateIsFixedRatio:return Object.assign(Object.assign({},e),{isFixedRatio:t.payload});case lL.InitFixedRatioPrice:{const{leftTokenAddress:n,baseToken:i,quoteToken:o}=e;if(!i||!o)throw new Error("token is required");const r=n===(null==i?void 0:i.address),{baseTokenFiatPrice:a,quoteTokenFiatPrice:s}=t.payload,l=a&&s?new Pe(a).div(s):void 0,d=a&&s?new Pe(s).div(a):void 0,c=r?l:d,u=r?o.decimals:i.decimals;return c&&!c.isNaN()?cL({state:e,fixedRatioPrice:c.dp(u,Pe.ROUND_DOWN).toString()}):e}case lL.UpdateFixedRatioPrice:return cL({state:e,fixedRatioPrice:t.payload});case lL.ToggleLeftToken:{const{baseToken:t,quoteToken:n,fixedRatioPrice:i}=e;if(!t||!n)throw new Error("token is required");const o=e.leftTokenAddress===(null==t?void 0:t.address),r=o?null==n?void 0:n.address:null==t?void 0:t.address,a=new Pe(i);if(!a.isNaN()&&a.gt(0)){const i=new Pe(1).div(a).dp(o?t.decimals:n.decimals);return cL({state:Object.assign(Object.assign({},e),{leftTokenAddress:r}),fixedRatioPrice:i.toString()})}return Object.assign(Object.assign({},e),{leftTokenAddress:r})}case lL.UpdateSlippageCoefficient:return Object.assign(Object.assign({},e),{slippageCoefficient:t.payload});case lL.UpdateIsSlippageCoefficientCustomized:return Object.assign(Object.assign({},e),{isSlippageCoefficientCustomized:t.payload});case lL.UpdateFeeRate:return Object.assign(Object.assign({},e),{feeRate:t.payload});case lL.UpdateIsFeeRateCustomized:return Object.assign(Object.assign({},e),{isFeeRateCustomized:t.payload});case lL.InitEditParameters:return function(e,t){const{baseToken:n,quoteToken:i}=t;return n&&i?Object.assign(Object.assign({},e),{baseToken:n,quoteToken:i,leftTokenAddress:null==n?void 0:n.address,slippageCoefficient:"",initPrice:"",fixedRatioPrice:"",feeRate:"",isFixedRatio:!1}):e}(e,t.payload);case lL.UpdatePeggedBaseTokenRatio:{if(!e.quoteToken)throw new Error("token is required");const n=t.payload,i=new Pe(n).dp(SO-2,Pe.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:"",baseAmount:"",quoteAmount:""});const o=new Pe(100).minus(i).dp(SO-2,Pe.ROUND_DOWN),r=i.lte(0)?"0":e.baseAmount,a=new Pe(r),s=a.div(i.div(100)).minus(a);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:n,peggedQuoteTokenRatio:o.lt(0)?"0":o.toString(),baseAmount:r,quoteAmount:dL(s,e.quoteToken.decimals)})}case lL.UpdatePeggedQuoteTokenRatio:{if(!e.baseToken)throw new Error("token is required");const n=t.payload,i=new Pe(n).dp(SO-2,Pe.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:n,baseAmount:"",quoteAmount:""});const o=new Pe(100).minus(i).dp(SO-2,Pe.ROUND_DOWN),r=i.lte(0)?"0":e.quoteAmount,a=new Pe(r),s=a.div(i.div(100)).minus(a);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:o.lt(0)?"0":o.toString(),peggedQuoteTokenRatio:n,baseAmount:dL(s,e.baseToken.decimals),quoteAmount:r})}default:throw Error("Unknown action: "+t.type)}}function pL({isSingleTokenVersion:e,leftTokenAddress:t,baseToken:n,quoteToken:i,dispatch:o}){var r,a;const s=aL({tokens:$((()=>n&&i?[n,i]:[]),[n,i])}),l=t===(null==n?void 0:n.address),d=n?null===(r=s.data)||void 0===r?void 0:r.get(n.address):void 0,c=i?null===(a=s.data)||void 0===a?void 0:a.get(i.address):void 0,u=$((()=>{const e=d&&c?new Pe(d).div(c):void 0,t=d&&c?new Pe(c).div(d):void 0;return l?e:t}),[d,l,c]),p=!u||u.isNaN(),h=!s.isLoading&&!s.isPending&&p;return te((()=>{h&&o({type:lL.UpdateIsFixedRatio,payload:!1})}),[o,h]),te((()=>{e||d&&o({type:lL.InitFixedRatioPrice,payload:{baseTokenFiatPrice:d,quoteTokenFiatPrice:c}})}),[d,o,e,c]),{fiatPriceLoading:s.isLoading||s.isPending,currentPrice:u,isErrorPrice:h,isNullPrice:p}}function hL({label:e,value:t}){return Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",mb:16},children:[Yn.jsx(i,{sx:{color:"text.secondary",mr:8},children:e}),Yn.jsx(i,{sx:{textAlign:"right",wordBreak:"break-all"},children:t})]})}function mL({on:e,onClose:t,state:n,onConfirm:o,isModify:r,loading:a}){var s,l,d,u,p,h,m;const{chainId:g}=dg(),{versionMap:f}=gO(),{isMobile:x}=Tg(),{title:y,initPriceLabel:v}=f[n.selectedVersion],{midPrice:b}=ZO({selectedVersion:n.selectedVersion,baseAmount:n.baseAmount,quoteAmount:n.quoteAmount,initPrice:n.initPrice,slippageCoefficient:n.slippageCoefficient}),j=xO(),C=n.selectedVersion===mO.pegged;return Yn.jsx(Of,{open:e,onClose:t,modal:!0,title:r?se._({id:"dzV+zO",message:"Modify Confirmation"}):se._({id:"tnRI9r",message:"Pool Creation Confirmation"}),children:Yn.jsxs(i,{sx:{flex:1,px:20,pb:20,display:"flex",flexDirection:"column",justifyContent:"space-between",width:x?void 0:420},children:[Yn.jsxs(i,{sx:{pt:40,px:8},children:[Yn.jsx(hL,{label:se._({id:"eE0JZ4",message:"Version"}),value:y}),Yn.jsx(hL,{label:se._({id:"7m5+6j",message:"Initial Tokens"}),value:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[Yn.jsx(Df,{address:null===(s=n.baseToken)||void 0===s?void 0:s.address,chainId:g,marginRight:8,width:18,height:18}),n.baseAmount||"-"," ",null===(l=n.baseToken)||void 0===l?void 0:l.symbol]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",mt:4},children:[Yn.jsx(Df,{address:null===(d=n.quoteToken)||void 0===d?void 0:d.address,chainId:g,marginRight:8,width:18,height:18}),n.quoteAmount||"-"," ",null===(u=n.quoteToken)||void 0===u?void 0:u.symbol]})]})}),Yn.jsx(hL,{label:se._({id:"sjn3tj",message:"Slippage Coefficient"}),value:n.slippageCoefficient}),Yn.jsx(hL,{label:v,value:n.baseToken&&n.quoteToken?`1 ${n.baseToken.symbol} = ${EO({midPrice:b,quoteToken:n.quoteToken,selectedVersion:n.selectedVersion,initPrice:n.initPrice})} ${n.quoteToken.symbol}`:""}),C&&Yn.jsx(hL,{label:se._({id:"6lss/t",message:"Pricing Model"}),value:n.selectedSubPeggedVersion?null===(p=j[n.selectedSubPeggedVersion])||void 0===p?void 0:p.title:"-"}),Yn.jsx(hL,{label:se._({id:"Y7rVy0",message:"Fee Rate"}),value:`${n.feeRate}%`}),C&&Yn.jsx(hL,{label:se._({id:"eK0eiF",message:"Initial asset ratio"}),value:Yn.jsxs(Yn.Fragment,{children:[n.peggedBaseTokenRatio,"% ",null===(h=n.baseToken)||void 0===h?void 0:h.symbol," : ",n.peggedQuoteTokenRatio,"% ",null===(m=n.quoteToken)||void 0===m?void 0:m.symbol]})})]}),Yn.jsx(c,{fullWidth:!0,isLoading:a,sx:{mt:30},onClick:o,children:r?se._({id:"7VpPHA",message:"Confirm"}):se._({id:"hYgDIe",message:"Create"})})]})})}!function(e){e[e.SetCurrentStep=1]="SetCurrentStep",e[e.SelectNewVersion=2]="SelectNewVersion",e[e.SelectNewSubPeggedVersion=3]="SelectNewSubPeggedVersion",e[e.UpdateBaseToken=4]="UpdateBaseToken",e[e.UpdateQuoteToken=5]="UpdateQuoteToken",e[e.SwitchTokens=6]="SwitchTokens",e[e.UpdateBaseAmount=7]="UpdateBaseAmount",e[e.UpdateQuoteAmount=8]="UpdateQuoteAmount",e[e.UpdateIsFixedRatio=9]="UpdateIsFixedRatio",e[e.UpdateFixedRatioPrice=10]="UpdateFixedRatioPrice",e[e.InitFixedRatioPrice=11]="InitFixedRatioPrice",e[e.ToggleLeftToken=12]="ToggleLeftToken",e[e.UpdateSlippageCoefficient=13]="UpdateSlippageCoefficient",e[e.UpdateIsSlippageCoefficientCustomized=14]="UpdateIsSlippageCoefficientCustomized",e[e.UpdateFeeRate=15]="UpdateFeeRate",e[e.UpdateIsFeeRateCustomized=16]="UpdateIsFeeRateCustomized",e[e.InitEditParameters=17]="InitEditParameters",e[e.UpdatePeggedBaseTokenRatio=18]="UpdatePeggedBaseTokenRatio",e[e.UpdatePeggedQuoteTokenRatio=19]="UpdatePeggedQuoteTokenRatio"}(lL||(lL={}));const gL=({selectedVersion:e,selectedSubPeggedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r,feeRate:a,initPrice:s,slippageCoefficient:l})=>{const{chainId:d,account:c}=dg(),{deadLine:u}=Jn(),p=we[d];return{getCreateParams:()=>Vn(void 0,void 0,void 0,(function*(){if(!c||!n||!i)return null;let h="";const m=Number(n.decimals),g=Number(i.decimals),f=new Pe(a),x=e===mO.marketMakerPool,y=e===mO.standard,v=e===mO.pegged,b=e===mO.pegged&&t===hO.GSP,j={decimals:m,address:n.address},C={decimals:g,address:i.address},w=zt(o,m).toString(),k=zt(r||"0",g).toString(),T=x?f.times(100).toNumber():f.times(80).toNumber();let I=x&&y?new Pe(r).div(o).dp(g,Pe.ROUND_DOWN).toString():new Pe(s).toString();if(y){const e=18-n.decimals+i.decimals;e<String(CO).split(".")[1].length&&(I=new Pe(1).div(10**e).toString())}const S=Number(l||(v?"0.1":"1")),E=Math.ceil(Date.now()/1e3)+(null!=u?u:3600);let A;const O=[d,j,C,w,k,T,I,S,E];try{e===mO.standard||e===mO.singleToken?A=yield ye.encode.createDVMPoolABI(...O):x?A=yield ye.encode.createDPPPoolABI(...O):v?A=yield ye.encode.createDSPPoolABI(...O):b&&(A=yield ye.encode.createGSPPoolABI(d,c,j,C,w,k,T,I,S,E))}catch(e){throw console.error("2.0 CreatePool createPrams error",O,e),h=`2.0 CreatePool createPrams error; ERROR: ${e}`,new Error(h)}if(!A||!A.data)throw h="invalid data",new Error(h);try{const e=p.address.toLowerCase();return o&&n.address.toLowerCase()===e?A.value=AI(o):r&&i.address.toLowerCase()===e?A.value=AI(r):A.value=0,A}catch(e){throw console.error("2.0 sendTransaction error",e),h=`2.0 sendTransaction error; ERROR: ${e}`,new Error(h)}}))}},fL=({chainId:t,baseToken:n,quoteToken:o})=>{const r=a();return OO({chainId:t,baseToken:n,quoteToken:o})?Yn.jsx(i,{sx:{mb:12,py:8,px:12,borderRadius:8,backgroundColor:T(r.palette.error.main,.1),color:r.palette.error.main,textAlign:"center",typography:"h6",fontWeight:500},children:Yn.jsx(e,{id:"peTryP",message:"{0}-{1} is not supported. Please select another pair.",values:{0:null==n?void 0:n.symbol,1:null==o?void 0:o.symbol}})}):null};function xL({state:t,dispatch:n,openConfirm:i,isPeggedVersion:o,isStandardVersion:r,isSingleTokenVersion:a,fiatPriceLoading:s}){var l,d;const{currentStep:u,selectedVersion:p,baseToken:h,quoteToken:m,baseAmount:g,quoteAmount:f,initPrice:x,slippageCoefficient:y,feeRate:v}=t,b=new Pe(g||0),j=new Pe(f||0),C=lf(h,{amount:g}),w=lf(m,{amount:f}),k={variant:c.Variant.contained},T=OO({chainId:null!==(d=null===(l=t.baseToken)||void 0===l?void 0:l.chainId)&&void 0!==d?d:1,baseToken:h,quoteToken:m}),I=se._({id:"hXzOVo",message:"Next"}),S=Yn.jsx(c,{fullWidth:!0,disabled:!0,...k,children:I}),E=Yn.jsx(c,{variant:c.Variant.contained,fullWidth:!0,onClick:i,children:Yn.jsx(e,{id:"hYgDIe",message:"Create"})});if(0===u)return Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:1})},children:I});const A=!h||b.isNaN()||b.lte(0),O=!m||j.isNaN()||j.lte(0);if(1===u){if(T)return S;if(o){if(!h||!m)return S}else{if(A)return S;if(C.needShowTokenStatusButton||C.insufficientBalance)return Yn.jsx(SI,{status:C,buttonProps:k});if(!a){if(O)return S;if(w.needShowTokenStatusButton||w.insufficientBalance)return Yn.jsx(SI,{status:w,buttonProps:k})}if(!r){if(!m)return S;const e=new Pe(x),t=Math.min(m.decimals,16);if(!x||e.isNaN()||e.lt(`1e-${t}`)||e.gt(wO))return S;const n=new Pe(y);if(!y||n.isNaN()||n.lt(0)||n.gt(p===mO.pegged?IO:kO))return S}if(s)return S;if(OO({chainId:h.chainId,baseToken:h,quoteToken:m}))return S}return Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:2})},children:I})}const L=new Pe(v),R=!v||L.isNaN()||L.lt(vO)||L.gt(bO);return 2===u?o?Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:3})},children:I}):R?S:E:3===u?R?S:Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:4})},children:I}):4===u?A||O?S:C.needShowTokenStatusButton||C.insufficientBalance?Yn.jsx(SI,{status:C,buttonProps:k}):w.needShowTokenStatusButton||w.insufficientBalance?Yn.jsx(SI,{status:w,buttonProps:k}):E:null}function yL({state:t,dispatch:n,isPeggedVersion:o,isStandardVersion:r,isSingleTokenVersion:s,fiatPriceLoading:l}){const{currentStep:d}=t,u=a(),{isMobile:p}=Tg(),h=Fg(),{onlyChainId:m,chainId:g}=dg(),[f,x]=z(!1),{getCreateParams:y}=gL(t),v=it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){const e=yield y();if(!e)return;(yield h.execute(se._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Pg.TX,desc:"Create pool"},e),{early:!0,metadata:{[t.selectedVersion===mO.marketMakerPool?Sg.createDPPPool:t.selectedVersion===mO.pegged?t.selectedSubPeggedVersion===hO.DSP?Sg.createDSPPool:Sg.createGSPPool:Sg.createDVMPool]:"1"}}))===Eg.Submitted&&setTimeout((()=>{Gj.getState().push({type:Zj.Pool,params:{tab:qS.myCreated}})}),100)}))});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:u.palette.background.paperContrast,px:20,py:20},p?{}:{position:"static",backgroundColor:"transparent",py:0}),children:[1==d&&Yn.jsx(fL,{chainId:g,baseToken:t.baseToken,quoteToken:t.quoteToken}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[0===d&&p&&Yn.jsx(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{Gj.getState().back()},children:Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),d>0&&Yn.jsx(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{n({type:lL.SetCurrentStep,payload:d-1})},children:Yn.jsx(e,{id:"iH8pgl",message:"Back"})}),Yn.jsx(cC,{chainId:m,variant:c.Variant.contained,fullWidth:!0,includeButton:!0,children:Yn.jsx(xL,{state:t,dispatch:n,openConfirm:()=>{x(!0)},isPeggedVersion:o,isStandardVersion:r,isSingleTokenVersion:s,fiatPriceLoading:l})})]})]}),Yn.jsx(mL,{on:f,onClose:()=>x(!1),state:t,isModify:!1,onConfirm:v.mutate,loading:v.isPending})]})}function vL({selected:e}){const t=a();return Yn.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{marginLeft:"auto",flexShrink:0},children:[Yn.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:e?t.palette.success.main:t.palette.text.secondary}),e&&Yn.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:t.palette.success.main,stroke:t.palette.success.main})]})}function bL({title:e,subTitle:t,description:n,selected:o,onClick:r,children:s,sx:l,titleSx:c}){const u=a();u.palette.mode;return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",p:20,backgroundColor:u.palette.background.tag,borderWidth:1,borderColor:o?u.palette.primary.main:"transparent",borderStyle:"solid",borderRadius:12,flexWrap:"wrap",justifyContent:"flex-start",textAlign:"left","&:hover":{borderColor:u.palette.primary.main}},l),component:d,onClick:r,children:[Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between",typography:"caption",pr:2,color:u.palette.text.primary},c),children:[e,t,Yn.jsx(vL,{selected:o})]}),Yn.jsx(i,{sx:{mt:8,typography:"body2",width:"100%",textAlign:"left",color:o?u.palette.text.primary:u.palette.text.secondary},children:n}),s]})}function jL({errorMsg:e,isCustomized:t,onClick:n,value:o,onChange:r}){const s=a(),l=$((()=>!(!o||"0"===o||Number(o))),[o]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{py:12,px:20,backgroundColor:s.palette.background.paper,borderColor:t&&e||l?s.palette.error.main:t?s.palette.primary.main:s.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center"},onClick:n,children:Yn.jsx(Db,{value:t?o:"",onChange:r,suffix:Yn.jsx(vL,{selected:t}),placeholder:se._({id:"8Tg/JR",message:"Custom"}),sx:{backgroundColor:"transparent","& input":{typography:"body1",height:36,lineHeight:"36px",p:s.spacing(0),color:s.palette.text.primary,"&::placeholder":{color:s.palette.text.disabled,fontWeight:600,typography:"body1",lineHeight:1,position:"relative"}}}})}),e&&Yn.jsx(i,{sx:{typography:"h6",color:"error.main",mt:6},children:e})]})}const CL=()=>[{title:"0.01%",description:se._({id:"yzjPpo",message:"Fees will be the same as in most other pools."}),value:"0.01"},{title:"0.3%",description:se._({id:"OJOe+K",message:"Set the fee to the same as most other pools"}),value:yO,tag:"99% Default"},{title:"1%",description:"Most suitable for swapping exotic assets.",value:"1"}];function wL(){const e=a();return $((()=>CL().map((t=>t.value===yO?Object.assign(Object.assign({},t),{tagBackgroundColor:T(e.palette.purple.main,.1),tagColor:e.palette.purple.main}):t))),[e.palette.purple.main])}const kL=e=>{if(!e)return"";const t=new Pe(e);return t.isNaN()||!t.lt(vO)&&!t.gt(bO)?"":se._({id:"vWT429",message:"The fee rate must be between 0% to 10%"})},TL=(e,t)=>{if(!e)return"";const n=new Pe(e);if(!n.isNaN()&&(n.lt(0)||n.gt(t===mO.pegged?IO:kO)))switch(t){case mO.standard:case mO.singleToken:case mO.marketMakerPool:return se._({id:"3U+Oti",message:"he slippage coefficient needs to be greater than or equal to 0, and less than or equal to 1."});case mO.pegged:return se._({id:"LDprZB",message:"The slippage coefficient needs to be greater than 0, and less than 0.1."})}return""};function IL({dispatch:t,feeRate:n,isFeeRateCustomized:o}){const r=a(),s=wL(),l=$((()=>kL(n)||""),[n]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:[s.map((e=>{const i=!o&&n===e.value;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{t({type:lL.UpdateIsFeeRateCustomized,payload:!1}),t({type:lL.UpdateFeeRate,payload:e.value})},selected:i,subTitle:e.tag?Yn.jsx(QO,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:r.palette.background.paper,borderColor:i?r.palette.primary.main:r.palette.border.main}},e.value)})),Yn.jsx(i,{sx:{mt:8},children:Yn.jsx(jL,{errorMsg:l,isCustomized:o,onClick:()=>{t({type:lL.UpdateFeeRate,payload:""}),t({type:lL.UpdateIsFeeRateCustomized,payload:!0})},value:n,onChange:e=>{t({type:lL.UpdateFeeRate,payload:e})}})})]}),Yn.jsx(i,{sx:{typography:"body2",mt:20,color:"text.secondary",px:20},children:Yn.jsx(e,{id:"0b0AkA",message:"* Please note that the Fee Rate cannot be modified after the pool is created"})})]})}function SL({on:t,onClose:n,onConfirm:i}){return Yn.jsx(FI,{open:t,onClose:n,onConfirm:i,title:se._({id:"t+LmjM",message:"Initial Price Alert"}),modal:!0,children:Yn.jsx(e,{id:"yXm1vH",message:"The initial price is different from the current market price, which may cause your pool to be arbitraged"})})}const EL=({title:e,children:t,sx:n})=>{const o=a();return Yn.jsxs(i,{sx:Object.assign({mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},n),children:[Yn.jsx(i,{sx:{typography:"body2",color:o.palette.text.primary,fontWeight:500,display:"flex",alignItems:"center"},children:e}),t]})};function AL({selectedVersion:t,isStandardVersion:n,isSingleTokenVersion:o,isFixedRatio:s,leftTokenAddress:c,baseToken:u,quoteToken:p,fixedRatioPrice:h,dispatch:m,priceInfo:g}){const x=a(),[y,v]=z(!1),{versionMap:b}=gO(),{initPriceLabel:C,initPriceTips:w,initPriceTipsLink:k}=b[t],S=c===(null==u?void 0:u.address),E=S?null==u?void 0:u.symbol:null==p?void 0:p.symbol,A=S?null==p?void 0:p.symbol:null==u?void 0:u.symbol,{currentPrice:O,isErrorPrice:L,isNullPrice:R,fiatPriceLoading:P}=g,_=S?null==p?void 0:p.decimals:null==u?void 0:u.decimals,M=$((()=>{if(!p)return"";const e=function(e,t,n){if(!t)return"";const i=new Pe(t),o=Math.min(n,16),r=Number(`1e-${o}`);if(e!==mO.standard&&!i.isNaN()&&(i.lt(r)||i.gt(wO))){const t=r.toFixed(o);switch(e){case mO.pegged:case mO.singleToken:return se._({id:"P4iKEj",message:"The initial price needs to be greater than {min} and less than 100,000,000",values:{min:t}});case mO.marketMakerPool:return se._({id:"kdzjmC",message:"The mid price needs to be greater than {min} and less than 100,000,000",values:{min:t}})}}return""}(t,h,p.decimals);return e||""}),[h,p,t]),B=$((()=>!(!h||"0"===h||Number(h))),[h]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(EL,{title:Yn.jsxs(Yn.Fragment,{children:[C,w&&Yn.jsx(f,{title:Yn.jsxs(Yn.Fragment,{children:[w,k?Yn.jsxs(Yn.Fragment,{children:["\n",Yn.jsxs(i,{component:"a",href:k,target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[Yn.jsx(e,{id:"NgeSlx",message:"Learn More"}),">"]})]}):""]}),ml:4,sx:{width:14,height:14,alignItems:"center"}})]}),sx:{mt:20},children:Yn.jsxs(i,{sx:{pt:n?11:19,px:19,pb:11,borderWidth:1,borderStyle:"solid",borderColor:M||B?"error.main":x.palette.background.cardInput,borderRadius:8,backgroundColor:x.palette.background.cardInput,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20},children:[n?null:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{typography:"body2",color:x.palette.text.primary,display:"flex",alignItems:"center"},children:[Yn.jsxs(i,{sx:{fontWeight:600,color:x.palette.text.disabled,flexShrink:0},children:["1 ",null!=E?E:"-"," ="]}),Yn.jsx(Db,{value:h,onChange:e=>{m({type:lL.UpdateFixedRatioPrice,payload:e})},readOnly:s,sx:{backgroundColor:"background.cardInput",pl:0,pr:0,mt:0,flex:"1 1 auto","& input":{textAlign:"right",typography:"h5",height:25,py:0,px:8,color:x.palette.text.primary,"&::placeholder":{color:x.palette.text.disabled}}}}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:x.palette.text.disabled,flexShrink:0},children:null!=A?A:"-"}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},component:d,onClick:()=>{m({type:lL.ToggleLeftToken})},children:Yn.jsx(r,{weak:!0,component:li.Switch,sx:{marginLeft:8,p:x.spacing(2),color:x.palette.text.primary,backgroundColor:T(x.palette.primary.main,.1),borderRadius:"50%"}})})]}),M&&Yn.jsx(i,{sx:{typography:"h6",color:"error.main",mt:-14},children:M})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:n?"flex-start":"flex-end",typography:"h6",color:x.palette.text.primary,fontWeight:500},children:["=",Yn.jsx(e,{id:"pdZiL7",message:"Current Market Price:"})," ",P?Yn.jsx(j,{sx:{borderRadius:4},width:50,height:17}):R?Yn.jsx(l,{title:Yn.jsx(e,{id:"mObS+5",message:"Failed to get price of the token"}),children:Yn.jsx(i,{component:li.Warn,sx:{width:14,height:14,color:x.palette.error.main,typography:"h6"}})}):Am({input:O,decimals:_})," ",A,L||o?null:Yn.jsx(I,{checked:s,onChange:e=>{if(e.target.checked){if(m({type:lL.UpdateIsFixedRatio,payload:!0}),!_)throw new Error("currentTokenDecimals is undefined");O&&!O.isNaN()&&m({type:lL.UpdateFixedRatioPrice,payload:O.dp(_,Pe.ROUND_DOWN).toString()})}else v(!0)},sx:{ml:8}})]})]})}),Yn.jsx(SL,{on:y,onClose:()=>v(!1),onConfirm:()=>{m({type:lL.UpdateIsFixedRatio,payload:!1})}})]})}function OL({selectedVersion:e,selectedSubPeggedVersion:t,baseToken:n,quoteToken:o,initPrice:r,dispatch:s}){var l;const d=a(),{versionMap:c,subPeggedVersionList:u}=gO(),{initPriceLabel:p}=c[e];return n&&o?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{mt:8,display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",color:d.palette.text.secondary,fontWeight:500},children:p}),Yn.jsxs(i,{sx:{typography:"h5",color:d.palette.text.primary,fontWeight:600},children:["1 ",null==n?void 0:n.symbol,"=",null!==(l=EO({midPrice:void 0,quoteToken:o,selectedVersion:e,initPrice:r}))&&void 0!==l?l:"-"," ",o.symbol]})]}),Yn.jsx(i,{sx:{mt:20,display:"flex",flexDirection:"column",gap:12,px:20},children:u.map((e=>{const n=t===e.version;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{s({type:lL.SelectNewSubPeggedVersion,payload:e.version})},selected:n,subTitle:void 0,sx:{backgroundColor:d.palette.background.paper,borderColor:n?d.palette.primary.main:d.palette.border.main},titleSx:{typography:"body1",fontWeight:600}},e.version)}))})]}):null}function LL({title:e,value:t,onChange:n}){const o=a();return Yn.jsxs(i,{sx:{flexGrow:1,flexShrink:1,flexBasis:"50%",display:"flex",alignItems:"center",px:15,py:7,borderWidth:1,borderStyle:"solid",borderColor:o.palette.border.main,borderRadius:8,backgroundColor:o.palette.background.cardInput},children:[Yn.jsx(i,{sx:{color:o.palette.text.primary,typography:"body1",fontWeight:500,flexShrink:0},children:e}),Yn.jsx(Db,{value:t,onChange:n,suffix:"%",placeholder:"0",sx:{backgroundColor:"background.cardInput",mt:0,display:"flex",alignItems:"center",width:"100%",typography:"h5",lineHeight:"32px",color:o.palette.text.disabled,"& input":{textAlign:"right",py:0,px:8,color:o.palette.text.primary,"&::placeholder":{opacity:1,color:o.palette.text.disabled,fontWeight:600,typography:"h5",lineHeight:1,position:"relative"}}}})]})}const RL=({baseToken:t,quoteToken:n,initPrice:o,peggedBaseTokenRatio:r,peggedQuoteTokenRatio:s,baseAmount:l,quoteAmount:d,dispatch:u})=>{var p,h;const m=a(),[g,f]=$((()=>{const{base:e,quote:t}=AO({initPrice:o});return[e?e.multipliedBy(100).toString():null,t?t.multipliedBy(100).toString():null]}),[o]),x=""===r&&""===s,[y,v]=$((()=>{var e,i;const r=null!==(e=null==t?void 0:t.decimals)&&void 0!==e?e:0,a=null!==(i=null==n?void 0:n.decimals)&&void 0!==i?i:0,s=new Pe(l).dp(r,Pe.ROUND_DOWN).multipliedBy(`1e${r}`),c=new Pe(d).dp(a,Pe.ROUND_DOWN).multipliedBy(`1e${a}`),u=new Pe(o).multipliedBy(`1e${18-r+a}`).dp(0,Pe.ROUND_DOWN),p=c.lt(s.multipliedBy(u).div(1e18))?c.multipliedBy(1e18).div(u):s,h=new Pe(1001);if(h.gt(p))return[new Pe(1),"100%"];const m=h.dividedBy(p);return[m,Vm({input:m})]}),[l,null==t?void 0:t.decimals,o,d,null==n?void 0:n.decimals]),b=$((()=>!!y.lte("0.0000000001")||null!=g&&r===g&&null!=f&&s===f),[y,r,s,g,f]),j=`${null==t?void 0:t.symbol}:${null==n?void 0:n.symbol}=${g}%:${f}%`;return Yn.jsxs(EL,{title:Yn.jsx(e,{id:"OuSseo",message:"Ratio Settings"}),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(LL,{title:null!==(p=null==t?void 0:t.symbol)&&void 0!==p?p:"",value:r,onChange:e=>{u({type:lL.UpdatePeggedBaseTokenRatio,payload:e})}}),Yn.jsx(i,{sx:{color:m.palette.text.primary,typography:"body2",fontWeight:500,width:14,flexShrink:0,flexGrow:0,textAlign:"center"},children:":"}),Yn.jsx(LL,{title:null!==(h=null==n?void 0:n.symbol)&&void 0!==h?h:"",value:s,onChange:e=>{u({type:lL.UpdatePeggedQuoteTokenRatio,payload:e})}})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,px:19,pt:19,pb:11,borderRadius:16,borderWidth:1,borderColor:b||x?m.palette.border.main:"transparent",borderStyle:"solid",backgroundColor:b||x?m.palette.background.paper:T(m.palette.warning.main,.1)},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[x?null:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,color:b?m.palette.text.primary:m.palette.warning.main,typography:"body1",fontWeight:600},children:[b?null:Yn.jsx(li.Warn,{}),Yn.jsx(e,{id:"x3muNy",message:"Liquidity Burn Ratio"}),": ",v]}),Yn.jsx(i,{sx:{color:m.palette.text.secondary,typography:"h6",textAlign:"center","&>strong":{color:b?m.palette.text.primary:m.palette.warning.main}},children:x?Yn.jsx(e,{id:"pQJBKk",message:"The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{recommendRatioText:j}}):Yn.jsx(e,{id:"ZlQ83E",message:"<0>{lostRatio}</0> of the initial liquidity you provide will be burned. <1/>The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{lostRatio:v,recommendRatioText:j},components:{0:Yn.jsx("strong",{}),1:Yn.jsx("br",{})}})})]}),x||!b?Yn.jsx(c,{variant:c.Variant.outlined,fullWidth:!0,size:c.Size.small,onClick:()=>{u({type:lL.UpdatePeggedBaseTokenRatio,payload:null!=g?g:""})},sx:{border:`solid 1px ${m.palette.text.primary}`,color:m.palette.text.primary,"&:hover":{background:T(m.palette.text.primary,.1)}},children:Yn.jsx(e,{id:"NjdGps",message:"Use the recommended ratio"})}):null]})]})};function PL({open:e,onClose:t,afterClose:n,title:o,titleCenter:r,rightSlot:s,canBack:l=!0,children:d,width:c=420,height:u,testId:p}){const h=a(),{isMobile:m}=Tg();return Yn.jsx(V,{open:e,onClose:t,container:m?document.querySelector(`.${ib}`):void 0,disableEnforceFocus:!0,children:Yn.jsxs(i,{sx:Object.assign({backgroundColor:"background.paper",display:"flex",height:u,flexDirection:"column",justifyContent:"center",alignItems:"center",outline:0,overflow:"hidden","& > div":{width:"100%"}},m?{width:"100%",borderRadius:h.spacing(16,16,0,0)}:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:c,maxWidth:"95%",minHeight:200,maxHeight:"80%",borderRadius:16}),"data-testid":p,children:[o?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:r?"center":"space-between",p:20,width:"100%",boxSizing:"border-box"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:o}),s,!s&&l&&Yn.jsx(i,{component:li.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{t&&t(),null==n||n()}})]}):"",d]})})}var _L;function ML(){return ML=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ML.apply(null,arguments)}const BL=e=>W.createElement("svg",ML({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),_L||(_L=W.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},W.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function DL({dispatch:t,slippageCoefficient:n,selectedVersion:o,isCustomized:r,isStandardVersion:s}){const l=a(),[u,p]=z(!1),[h,m]=z(n),g=function({selectedVersion:e}){const t=a();return $((()=>{const n=t.palette.background.paperDarkContrast,i=t.palette.text.disabled,o=t.palette.purple.main,r=T(o,.1);return e===mO.pegged?[{tag:"",description:se._({id:"PPqGw9",message:"Applicable to pegged assets with a fixed price and no fluctuation"}),value:"0",title:"K=0",tagBackgroundColor:"transparent",tagColor:"transparent"},{tag:se._({id:"nTWWCZ",message:"Low"}),description:se._({id:"L4nQwl",message:"Suitable for stablecoins with price fluctuations within 0.5%"}),value:"0.0001",title:"K=0.0001",tagBackgroundColor:r,tagColor:o},{tag:se._({id:"agPptk",message:"Medium"}),description:se._({id:"FrP5tr",message:"Suitable for stablecoins with price fluctuations within 2%"}),value:"0.0005",title:"K=0.0005",tagBackgroundColor:n,tagColor:i},{tag:se._({id:"yx/fMc",message:"High"}),description:se._({id:"bC0iyq",message:"Suitable for stablecoins with price fluctuations within 10%"}),value:"0.002",title:"K=0.002",tagBackgroundColor:n,tagColor:i}]:[{tag:se._({id:"agPptk",message:"Medium"}),description:se._({id:"VXTSOE",message:"Suitable for most situations."}),value:"0.5",title:"K=0.5",tagBackgroundColor:n,tagColor:i},{tag:se._({id:"nTWWCZ",message:"Low"}),description:se._({id:"DPi/hO",message:"Results in a relatively fixed price."}),value:"0.01",title:"K=0.01",tagBackgroundColor:n,tagColor:i},{tag:se._({id:"yx/fMc",message:"High"}),description:se._({id:"fKYdE9",message:"Results in a more volatile price."}),value:"1",title:"K=1",tagBackgroundColor:r,tagColor:o}]}),[e,t.palette])}({selectedVersion:o}),[x,y]=z(n);x!==n&&(y(n),m(n));const v=$((()=>{const e=TL(h,o);return null!=e?e:""}),[o,h]),b=$((()=>!(!h||"0"===h||Number(h))),[h]),j=Boolean(v)||b||r&&!h;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(EL,{title:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"sjn3tj",message:"Slippage Coefficient"}),Yn.jsx(f,{title:se._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:4,sx:{width:14,height:14}})]}),sx:{mt:20},children:Yn.jsxs(i,{component:d,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:8,color:l.palette.text.primary,borderRadius:8,backgroundColor:l.palette.background.cardInput,"&:hover":{backgroundColor:l.palette.hover.default},"&[disabled]>svg":{color:l.palette.text.disabled}},disabled:s,onClick:s?void 0:()=>{p(!0)},children:[Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px"},children:n}),Yn.jsx(i,{component:BL,sx:{flexShrink:0,width:18,height:18}})]})}),Yn.jsx(PL,{open:u,onClose:()=>p(!1),title:Yn.jsxs(i,{children:[Yn.jsx(e,{id:"sjn3tj",message:"Slippage Coefficient"}),Yn.jsx(f,{title:se._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:8})]}),children:Yn.jsxs(i,{sx:{flex:1,overflowY:"auto"},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,p:l.spacing(8,28,28)},children:[g.map((e=>{const n=!r&&h===e.value;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{t({type:lL.UpdateIsSlippageCoefficientCustomized,payload:!1}),m(e.value)},selected:n,subTitle:e.tag?Yn.jsx(QO,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:l.palette.background.paper,borderColor:n?l.palette.primary.main:l.palette.border.main},titleSx:{typography:"body1"}},e.value)})),Yn.jsx(i,{sx:{mt:8},children:Yn.jsx(jL,{errorMsg:v,isCustomized:r,onClick:()=>{r||m(""),t({type:lL.UpdateIsSlippageCoefficientCustomized,payload:!0})},value:h,onChange:e=>{m(e)}})})]}),Yn.jsx(i,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:Yn.jsx(c,{fullWidth:!0,disabled:j,onClick:()=>{t({type:lL.UpdateSlippageCoefficient,payload:h}),p(!1)},children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function NL({token:t,oppositeTokenAddress:n,dispatch:o,tokenSelectOnChange:r}){var s;const l=a(),{chainId:c,account:u}=dg(),[p,h]=H.useState(!1),m=et(Object.assign({},ip.getFetchTokenQuery(c,null==t?void 0:t.address,u)));return t?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:{display:"flex",alignItems:"center",px:20,py:8,borderRadius:8,backgroundColor:l.palette.background.cardInput,"&:hover":{backgroundColor:l.palette.hover.default}},onClick:()=>{h(!0)},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:t.address,marginRight:0,width:24,height:24,chainId:t.chainId||c,noShowChain:!0,sx:{flexShrink:0}}),Yn.jsx(i,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600,lineHeight:"32px",flexShrink:0},children:t.symbol}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",fontWeight:500,color:l.palette.text.secondary,wordBreak:"break-all"},children:["(",Yn.jsx(e,{id:"fsBGk0",message:"Balance"}),": ",!t.address||m.isLoading?Yn.jsx(L,{}):Am({input:null===(s=m.data)||void 0===s?void 0:s.balance,decimals:t.decimals}),")"]})]}),Yn.jsx(i,{component:BL,sx:{flexShrink:0,ml:"auto",width:18,height:18,color:l.palette.text.secondary}})]}),Yn.jsx(Xb,{value:t,open:p,chainId:c,occupiedAddrs:[n],occupiedChainId:t.chainId,onClose:()=>{h(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return o({type:lL.SwitchTokens}),void h(!1);r(e),h(!1)}},modal:!0})]}):null}const FL=({baseToken:t,quoteToken:n,dispatch:i})=>{var o,r;return Yn.jsxs(EL,{title:Yn.jsx(e,{id:"dmiCGN",message:"Select Token Pair"}),children:[Yn.jsx(NL,{token:t,oppositeTokenAddress:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",dispatch:i,tokenSelectOnChange:e=>{i({type:lL.UpdateBaseToken,payload:e})}}),Yn.jsx(NL,{token:n,oppositeTokenAddress:null!==(r=null==t?void 0:t.address)&&void 0!==r?r:"",dispatch:i,tokenSelectOnChange:e=>{i({type:lL.UpdateQuoteToken,payload:e})}})]})};function UL({selectedVersion:e,dispatch:t}){const n=a(),{isMobile:o}=Tg(),{versionList:r}=gO(),s="light"===n.palette.mode;return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:r.map((n=>{const r=e===n.version;return Yn.jsx(bL,{title:n.title,description:n.description,onClick:()=>{t({type:lL.SelectNewVersion,payload:n.version})},selected:r,children:o&&r&&Yn.jsx(i,{component:s?n.exampleImgUrl:n.exampleDarkImgUrl,sx:{mt:28,width:"100%",height:88.1}})},n.version)}))})}function qL(){const t=a(),{defaultBaseToken:n,defaultQuoteToken:o}=rL(),{chainId:r}=dg(),[s,l]=H.useReducer(uL,{currentStep:0,selectedVersion:mO.standard,baseToken:n,quoteToken:o,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:CO,fixedRatioPrice:jO,leftTokenAddress:null==n?void 0:n.address,feeRate:yO,isFeeRateCustomized:!1,slippageCoefficient:kO,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});!n||s.baseToken&&s.baseToken.chainId===r||l({type:lL.UpdateBaseToken,payload:n}),!o||s.quoteToken&&s.quoteToken.chainId===r||l({type:lL.UpdateQuoteToken,payload:o});const{isMobile:d}=Tg(),{versionMap:c}=gO(),u=c[s.selectedVersion],p=s.selectedVersion===mO.singleToken,h=s.selectedVersion===mO.standard,m=s.selectedVersion===mO.pegged,g=p?s.quoteToken:s.baseToken,f=p?s.baseToken:s.quoteToken,x=pL({isSingleTokenVersion:p,leftTokenAddress:s.leftTokenAddress,baseToken:s.baseToken,quoteToken:s.quoteToken,dispatch:l}),y=new Pe(s.peggedBaseTokenRatio).div(100).dp(SO,Pe.ROUND_DOWN),v=new Pe(s.peggedQuoteTokenRatio).div(100).dp(SO,Pe.ROUND_DOWN),b=m&&y.lte(0),j=m&&v.lte(0),C=Yn.jsxs(i,{sx:{px:20},children:[Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:p?s.quoteAmount:s.baseAmount,onInputChange:p?void 0:e=>{l({type:p?lL.UpdateQuoteAmount:lL.UpdateBaseAmount,payload:e})},readOnly:p||b,sx:{backgroundColor:"background.cardInput",padding:t.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:b?se._({id:"t3d3/V",message:"ratio is 0"}):void 0,token:g,occupiedAddrs:f?[f.address]:void 0,occupiedChainId:r,chainId:r,onTokenChange:m?void 0:(e,t)=>{l(t?{type:lL.SwitchTokens}:{type:p?lL.UpdateQuoteToken:lL.UpdateBaseToken,payload:e})}}),Yn.jsx(uj,{}),Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:p?s.baseAmount:s.quoteAmount,onInputChange:e=>{l({type:p?lL.UpdateBaseAmount:lL.UpdateQuoteAmount,payload:e})},readOnly:h&&s.isFixedRatio&&!!s.fixedRatioPrice||j,sx:{backgroundColor:"background.cardInput",padding:t.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:j?se._({id:"t3d3/V",message:"ratio is 0"}):se._({id:"5QDjef",message:"The token amount is calculated by initial price."}),token:f,occupiedAddrs:g?[g.address]:void 0,occupiedChainId:r,chainId:r,onTokenChange:(e,t)=>{l(t?{type:lL.SwitchTokens}:{type:p?lL.UpdateBaseToken:lL.UpdateQuoteToken,payload:e})}})]});return Yn.jsx(zj,{children:Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"flex-start",height:"100%"},d?{}:{height:"auto",overflowX:"auto"}),children:[d?null:Yn.jsxs(i,{sx:{mr:12,flexGrow:1,display:"block",overflow:"hidden"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:20},children:[Yn.jsx(XS,{}),Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:Yn.jsx(e,{id:"pHQq+U",message:"Pool Setup"})}),Yn.jsx(cT,{poolType:"PMM"})]}),Yn.jsx(tL,{titleKey:se._({id:"hdIg7i",message:"Select Pool Version"}),index:1,status:0===s.currentStep?"running":"completed"}),Yn.jsx(iL,{versionItem:u,status:0===s.currentStep?"running":"completed"},u.version),Yn.jsx(tL,{titleKey:se._({id:"lsg9Mi",message:"Parameter Settings"}),index:2,status:0===s.currentStep?"waiting":1===s.currentStep?"running":"completed"}),m?Yn.jsx(RO,{status:0===s.currentStep?"waiting":1===s.currentStep?"running":"completed",baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,midPrice:void 0}):Yn.jsx(JO,{status:0===s.currentStep?"waiting":1===s.currentStep?"running":"completed",baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),m&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"6lss/t",message:"Pricing Model"}),index:3,status:s.currentStep>2?"completed":2===s.currentStep?"running":"waiting"}),Yn.jsx(eL,{isWaiting:s.currentStep<2,selectedSubPeggedVersion:s.selectedSubPeggedVersion})]}),m?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"Y7rVy0",message:"Fee Rate"}),index:4,status:s.currentStep>3?"completed":3===s.currentStep?"running":"waiting"}),Yn.jsx(YO,{isWaiting:s.currentStep<3,feeRate:s.feeRate})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"Y7rVy0",message:"Fee Rate"}),index:3,status:2===s.currentStep?"running":"waiting"}),Yn.jsx(YO,{isWaiting:s.currentStep<2,feeRate:s.feeRate})]}),m&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"3ggd2j",message:"Asset ratio within the pool"}),index:5,status:s.currentStep>4?"completed":4===s.currentStep?"running":"waiting"}),Yn.jsx(KO,{isWaiting:s.currentStep<4,baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount,peggedBaseTokenRatio:s.peggedBaseTokenRatio,peggedQuoteTokenRatio:s.peggedQuoteTokenRatio})]})]}),Yn.jsxs(i,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,borderRadius:0,backgroundColor:"background.paper",minHeight:"100%"},d?{}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto",height:"100%",position:"sticky",top:"0px",overflowY:"hidden"}),children:[Yn.jsx(nL,{currentStep:s.currentStep,isPeggedVersion:m}),0===s.currentStep&&Yn.jsx(UL,{selectedVersion:s.selectedVersion,dispatch:l}),1===s.currentStep&&Yn.jsxs(Yn.Fragment,{children:[m?Yn.jsx(Yn.Fragment,{children:Yn.jsx(FL,{baseToken:s.baseToken,quoteToken:s.quoteToken,dispatch:l})}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(GO,{baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),C]}),Yn.jsx(DL,{dispatch:l,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,isCustomized:s.isSlippageCoefficientCustomized,isStandardVersion:h}),Yn.jsx(AL,{selectedVersion:s.selectedVersion,isFixedRatio:s.isFixedRatio,leftTokenAddress:s.leftTokenAddress,baseToken:s.baseToken,quoteToken:s.quoteToken,fixedRatioPrice:s.fixedRatioPrice,dispatch:l,isStandardVersion:h,isSingleTokenVersion:p,priceInfo:x})]}),m&&2===s.currentStep&&Yn.jsx(OL,{selectedVersion:s.selectedVersion,selectedSubPeggedVersion:s.selectedSubPeggedVersion,baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,dispatch:l}),s.currentStep===(m?3:2)&&Yn.jsx(IL,{dispatch:l,feeRate:s.feeRate,isFeeRateCustomized:s.isFeeRateCustomized}),m&&4===s.currentStep&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(GO,{baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),Yn.jsx(RL,{dispatch:l,baseToken:s.baseToken,quoteToken:s.quoteToken,peggedBaseTokenRatio:s.peggedBaseTokenRatio,peggedQuoteTokenRatio:s.peggedQuoteTokenRatio,initPrice:s.initPrice,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),Yn.jsx(EL,{title:Yn.jsx(e,{id:"E4LM3N",message:"Add Initial Liquidity"}),sx:{mt:20},children:Yn.jsx(i,{sx:{mx:-20},children:C})})]}),Yn.jsx(i,{sx:Object.assign({pb:160},d?{}:{pb:28})}),Yn.jsx(yL,{state:s,dispatch:l,isPeggedVersion:m,isStandardVersion:h,isSingleTokenVersion:p,fiatPriceLoading:x.fiatPriceLoading})]})]})})}function VL({open:t,onClose:n,title:o,children:r,singleBtn:a,danger:s,singleBtnText:l,cancelText:d,confirmText:u,disabledConfirm:p,confirmLoading:h,isManualClose:m,onConfirm:g}){const f=PL;return Yn.jsx(f,{open:t,onClose:n,title:Yn.jsx(i,{sx:{textAlign:"center"},children:o}),canBack:!1,titleCenter:!0,children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1,width:"100%"},children:[Yn.jsx(i,{sx:{typography:"body2",color:o?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:r}),a?Yn.jsx(i,{sx:{px:20},children:Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,danger:s,sx:{mt:32,mb:20},onClick:()=>{n()},children:l||Yn.jsx(e,{id:"DPfwMq",message:"Done"})})}):Yn.jsxs(i,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{n()},children:d||Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),Yn.jsx(c,{sx:{ml:8},variant:c.Variant.outlined,danger:s,disabled:p,isLoading:h,onClick:()=>{g&&g(),m||n()},children:u||Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})]})]})})}function WL({sx:t,onClick:n}){const o=a();return Yn.jsxs(r,{onClick:()=>{n?n():Gj.getState().back()},sx:ne({display:"inline-flex",alignItems:"center",cursor:"pointer","& > svg":{mr:10}},t),children:[Yn.jsx(i,{sx:{color:o.palette.text.secondary,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderColor:o.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:"50%",backgroundColor:o.palette.background.paper,mr:6},children:Yn.jsx(li.ArrowBack,{})}),Yn.jsx(e,{id:"CKyk7Q",message:"Go back"})]})}function HL({open:t,onClose:n,alertContent:o,onConfirm:r}){const s=a(),[l,d]=H.useState(!1),u=se._({id:"LQU+Dm",message:"Risk Disclaimer"});return Yn.jsx(PL,{open:t,onClose:n,title:u,canBack:!1,titleCenter:!0,children:Yn.jsxs(i,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{mb:20,mx:20,maxHeight:275,overflowY:"auto",borderWidth:1,borderRadius:10,borderStyle:"solid",borderColor:"border.main",p:s.spacing(20),typography:"body2",backgroundColor:s.palette.background.input,color:s.palette.text.primary,textAlign:"left"},children:o}),Yn.jsxs(i,{sx:{padding:20,pt:12,backgroundColor:s.palette.background.paperContrast},children:[Yn.jsxs(i,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary",textAlign:"left","& a":{fontWeight:600,color:"primary.main","&:hover":{textDecoration:"underline"}}},children:[Yn.jsx(I,{sx:{top:-1},checked:l,onChange:e=>{const{checked:t}=e.target;d(t)}}),Yn.jsx(i,{children:Yn.jsx(e,{id:"dqWPbT",message:"I have read, understand, and agree to the <0>Terms of Service</0>.",components:{0:Yn.jsx("a",{href:"https://docs.dodoex.io/home/terms-of-service",target:"_blank",rel:"noopener noreferrer"})}})})]}),Yn.jsx(i,{sx:{mt:12,display:"flex",alignItems:"center"},children:Yn.jsx(c,{sx:{},disabled:!l,fullWidth:!0,onClick:()=>{d(!1),null==r||r()},children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})})]})]})})}function $L({id:e,chainId:t}){var n,i,o,r,a,s,l,d,c,u,p,h,m;const g=t?Wu[t]:"",f=gg().getQuery(ye.graphql.fetchPool,{id:e||"",where:{refreshNow:!1,chain:g},liquidityWhere:{chain:g,refreshNow:!1,filterState:{address:e}}}),x=et(Object.assign(Object.assign({},f),{enabled:!!e})),{pair:y,liquidity_list:v}=null!==(n=x.data)&&void 0!==n?n:{},b=null===(o=null===(i=null==v?void 0:v.lqList)||void 0===i?void 0:i[0])||void 0===o?void 0:o.pair;return Object.assign(Object.assign({},x),{poolDetail:y&&t?Object.assign(Object.assign({},y),{address:y.id,type:y.type,chainId:t,baseToken:Zm(y.baseToken,t),quoteToken:Zm(y.quoteToken,t),miningAddress:null!==(a=null===(r=null==b?void 0:b.miningAddress)||void 0===r?void 0:r[0])&&void 0!==a?a:"",apy:null==b?void 0:b.apy,baseApy:(null==b?void 0:b.apy)?Wm(new Pe(null!==(s=b.apy.transactionBaseApy)&&void 0!==s?s:0).plus(null!==(l=b.apy.miningBaseApy)&&void 0!==l?l:0)):void 0,quoteApy:Number(null===(d=null==b?void 0:b.apy)||void 0===d?void 0:d.transactionQuoteApy)||Number(null===(c=null==b?void 0:b.apy)||void 0===c?void 0:c.miningQuoteApy)?Wm(new Pe(null!==(p=null===(u=null==b?void 0:b.apy)||void 0===u?void 0:u.transactionQuoteApy)&&void 0!==p?p:0).plus(null!==(m=null===(h=null==b?void 0:b.apy)||void 0===h?void 0:h.miningQuoteApy)&&void 0!==m?m:0)):void 0,isCpPool:!1,cpAddress:void 0,cpLiquidator:void 0,cpCreator:void 0,cpCreatedAtTimestamp:void 0}):null})}function zL({disabled:t,chainId:n,baseStatus:i,quoteStatus:o,onClick:r}){const{account:a}=dg();return a?i.needShowTokenStatusButton||o.needShowTokenStatusButton?Yn.jsx(SI,{status:i.needShowTokenStatusButton?i:o,buttonProps:{variant:c.Variant.contained,fullWidth:!0}}):Yn.jsx(c,{variant:c.Variant.contained,fullWidth:!0,disabled:t,onClick:()=>r(),children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})}):Yn.jsx(cC,{chainId:n,variant:c.Variant.contained,fullWidth:!0,includeButton:!0})}function ZL({state:t,pool:n,loading:o}){var r,s;const{baseToken:l,quoteToken:d,baseAmount:u,quoteAmount:p,initPrice:h,slippageCoefficient:m,feeRate:g}=t,f=et($m.getPMMStateQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,null===(r=null==n?void 0:n.baseToken)||void 0===r?void 0:r.decimals,null===(s=null==n?void 0:n.quoteToken)||void 0===s?void 0:s.decimals)),x=a(),{isMobile:y}=Tg(),{account:v}=dg(),b=Gj(),[j,C]=H.useState(!1),w=f.data&&u?new Pe(u).minus(f.data.baseReserve):void 0,k=f.data&&p?new Pe(p).minus(f.data.quoteReserve):void 0,T=null==w?void 0:w.lt(0),I=lf(l,{amount:w}),S=lf(d,{amount:k});let E=!n||o||!u||Number(u)<0||!p||Number(p)<0;if(!E&&d){const e=new Pe(h),t=Math.min(d.decimals,16);(!h||e.isNaN()||e.lt(`1e-${t}`)||e.gt(wO))&&(E=!0);const n=new Pe(m);(!m||n.isNaN()||n.lt(0)||n.gt(kO))&&(E=!0);const i=new Pe(g);(!g||i.isNaN()||i.lt(0)||i.gt(bO))&&(E=!0)}const{modifyDPPMutation:A}=ZI({pool:n||void 0});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign(Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:x.palette.background.paperContrast,px:20,py:20},y?{}:{position:"static",backgroundColor:"transparent",py:0}),{display:"flex",alignItems:"center",gap:8}),children:[y&&!!v&&Yn.jsx(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{b.back()},children:Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),Yn.jsx(zL,{disabled:E,chainId:null==n?void 0:n.chainId,baseStatus:I,quoteStatus:S,onClick:()=>C(!0)})]}),Yn.jsx(mL,{on:j,onClose:()=>C(!1),state:t,isModify:!0,loading:A.isPending,onConfirm:()=>{var e,n;A.mutate({txTitle:se._({id:"KRnA5J",message:"Set pool parameters"}),baseAmount:null!==(e=null==w?void 0:w.toString())&&void 0!==e?e:"",quoteAmount:null!==(n=null==k?void 0:k.toString())&&void 0!==n?n:"",isRemove:T,feeRate:t.feeRate,initPrice:t.initPrice,slippageCoefficient:t.slippageCoefficient,submittedBack:()=>{C(!1),b.push({type:Zj.Pool,params:{tab:qS.myCreated}})}})}})]})}function GL({dispatch:t,feeRate:n,isCustomized:o}){const r=a(),[s,l]=H.useState(!1),[d,u]=H.useState(n),p=wL();!d&&n&&u(n);const h=kL(d),m=!(!d||"0"===d||Number(d)),g=Boolean(h)||m||o&&!d;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:20,px:20},children:[Yn.jsxs(i,{sx:{fontWeight:500,display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"}),Yn.jsx(f,{title:se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8,size:16})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",ml:12},children:[n,"%",Yn.jsx(c,{variant:c.Variant.tag,sx:{ml:12,fontSize:12},onClick:()=>l(!0),children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})})]})]}),Yn.jsx(PL,{open:s,onClose:()=>l(!1),title:Yn.jsxs(i,{children:[Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"}),Yn.jsx(f,{title:se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8})]}),children:Yn.jsxs(i,{sx:{flex:1,overflowY:"auto"},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,p:r.spacing(8,28,28)},children:[p.map((e=>{const n=!o&&d===e.value;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{t({type:lL.UpdateIsFeeRateCustomized,payload:!1}),u(e.value)},selected:n,subTitle:e.tag?Yn.jsx(QO,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:r.palette.background.paper,borderColor:n?r.palette.primary.main:r.palette.border.main}},e.value)})),Yn.jsx(i,{sx:{mt:8},children:Yn.jsx(jL,{errorMsg:h,isCustomized:o,onClick:()=>{o||u(""),t({type:lL.UpdateIsFeeRateCustomized,payload:!0})},value:d,onChange:e=>{u(e)}})})]}),Yn.jsx(i,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:Yn.jsx(c,{fullWidth:!0,disabled:g,onClick:()=>{t({type:lL.UpdateFeeRate,payload:d}),l(!1)},children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function QL({titleKey:e}){const t=a();return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{mt:28,mb:28,borderTopColor:"divider",borderTopStyle:"solid",borderTopWidth:1}}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",mb:20},children:Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:t.palette.text.primary},children:e})})]})}function YL({params:t}){var n,o,r,s;const l=a(),{isMobile:d}=Tg(),{chainId:c}=dg(),[u,p]=H.useState(!1),[h,m]=H.useReducer(uL,{currentStep:0,selectedVersion:mO.marketMakerPool,baseToken:null,quoteToken:null,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:jO,fixedRatioPrice:jO,leftTokenAddress:void 0,feeRate:yO,isFeeRateCustomized:!1,slippageCoefficient:kO,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});H.useEffect((()=>{p(!window.localStorage.getItem(hh.PoolEditPage))}),[]);const[g,f]=H.useState("inital"),x=$L({id:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),{poolDetail:y}=x,v=qn(x,["poolDetail"]);v.isPending||v.error||y||"inital"!==g||f("open"),!h.baseToken&&(null==y?void 0:y.baseToken)&&m({type:lL.InitEditParameters,payload:y});const b=et($m.getPMMStateQuery(null==y?void 0:y.chainId,null==y?void 0:y.address,null==y?void 0:y.type,null===(n=null==y?void 0:y.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==y?void 0:y.quoteToken)||void 0===o?void 0:o.decimals));if(!h.slippageCoefficient&&(null===(s=null===(r=b.data)||void 0===r?void 0:r.pmmParamsBG)||void 0===s?void 0:s.k)){const e=b.data.pmmParamsBG.k.toString(),t=!sL({selectedVersion:h.selectedVersion}).includes(e);m({type:lL.UpdateSlippageCoefficient,payload:e}),m({type:lL.UpdateIsSlippageCoefficientCustomized,payload:t})}!h.baseAmount&&b.data&&(m({type:lL.UpdateBaseAmount,payload:b.data.baseReserve.toString()}),m({type:lL.UpdateQuoteAmount,payload:b.data.quoteReserve.toString()})),!h.fixedRatioPrice&&b.data&&m({type:lL.UpdateFixedRatioPrice,payload:b.data.pmmParamsBG.i.toString()});const C=et($m.getLPFeeRateQuery(null==y?void 0:y.chainId,null==y?void 0:y.address,null==y?void 0:y.type));if(!h.feeRate&&C.data){const e=C.data.times(100).toString(),t=-1===CL().findIndex((t=>t.value===e));m({type:lL.UpdateFeeRate,payload:e}),m({type:lL.UpdateIsFeeRateCustomized,payload:t})}const w=h.selectedVersion===mO.singleToken,k=h.selectedVersion===mO.standard,T=pL({isSingleTokenVersion:w,leftTokenAddress:h.leftTokenAddress,baseToken:h.baseToken,quoteToken:h.quoteToken,dispatch:m}),{versionMap:I}=gO(),S=I[h.selectedVersion],E=!(null==y?void 0:y.baseToken),A=Yn.jsx(j,{variant:"rounded",width:210,height:60,sx:{padding:16,borderRadius:8}}),O=Yn.jsx(j,{variant:"rounded",height:167,sx:{mx:20,borderRadius:16}});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(zj,{children:Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"flex-start"},d?{height:"100%"}:{height:"auto"}),children:[d?null:Yn.jsxs(i,{sx:{mr:12,flexGrow:1,display:"block"},children:[Yn.jsx(WL,{}),Yn.jsx(i,{sx:{mt:28,typography:"h5",fontWeight:600,color:"text.primary"},children:Yn.jsx(e,{id:"pHQq+U",message:"Pool Setup"})}),Yn.jsx(QL,{titleKey:se._({id:"hdIg7i",message:"Select Pool Version"})}),Yn.jsx(iL,{versionItem:S,status:"completed"},S.version),Yn.jsx(QL,{titleKey:se._({id:"lsg9Mi",message:"Parameter Settings"})}),E?A:Yn.jsx(JO,{status:"running",baseToken:h.baseToken,quoteToken:h.quoteToken,initPrice:h.initPrice,slippageCoefficient:h.slippageCoefficient,selectedVersion:h.selectedVersion,baseAmount:h.baseAmount,quoteAmount:h.quoteAmount}),Yn.jsx(QL,{titleKey:se._({id:"Y7rVy0",message:"Fee Rate"})}),E?A:Yn.jsx(YO,{isWaiting:!1,feeRate:h.feeRate})]}),Yn.jsxs(i,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,backgroundColor:"background.paper"},d?{width:"100%",borderRadius:0,minHeight:"100%"}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto"}),children:[Yn.jsx(i,{sx:Object.assign({top:0,py:20,px:20,backgroundColor:l.palette.background.paper,zIndex:1},d?{position:"sticky"}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:Yn.jsx(i,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600},children:Yn.jsx(e,{id:"6XYkjc",message:"Edit Parameter Settings"})})})}),E?null:Yn.jsx(GO,{baseToken:h.baseToken,quoteToken:h.quoteToken,initPrice:h.initPrice,slippageCoefficient:h.slippageCoefficient,selectedVersion:h.selectedVersion,baseAmount:h.baseAmount,quoteAmount:h.quoteAmount}),E?O:Yn.jsxs(i,{sx:{px:20},children:[Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:h.baseAmount,onInputChange:e=>{m({type:lL.UpdateBaseAmount,payload:e})},readOnly:w,token:h.baseToken,occupiedAddrs:h.quoteToken?[h.quoteToken.address]:void 0,occupiedChainId:c,chainId:c}),Yn.jsx(pj,{}),Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:h.quoteAmount,onInputChange:e=>{m({type:lL.UpdateQuoteAmount,payload:e})},token:h.quoteToken,occupiedAddrs:h.baseToken?[h.baseToken.address]:void 0,occupiedChainId:c,chainId:c})]}),E?null:Yn.jsxs(Yn.Fragment,{children:[h.selectedVersion!==mO.standard&&Yn.jsx(DL,{dispatch:m,slippageCoefficient:h.slippageCoefficient,selectedVersion:h.selectedVersion,isCustomized:h.isSlippageCoefficientCustomized,isStandardVersion:k}),Yn.jsx(AL,{selectedVersion:h.selectedVersion,isFixedRatio:h.isFixedRatio,leftTokenAddress:h.leftTokenAddress,baseToken:h.baseToken,quoteToken:h.quoteToken,fixedRatioPrice:h.fixedRatioPrice,dispatch:m,isStandardVersion:k,isSingleTokenVersion:w,priceInfo:T}),Yn.jsx(GL,{dispatch:m,feeRate:h.feeRate,isCustomized:h.isFeeRateCustomized})]}),Yn.jsx(i,{sx:{pb:160,[l.breakpoints.up("tablet")]:{pb:28}}}),Yn.jsx(ZL,{state:h,pool:y,loading:E})]})]})}),Yn.jsx(VL,{singleBtn:!0,open:"open"===g,onClose:()=>f("close"),onConfirm:()=>f("close"),title:se._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),Yn.jsx(HL,{open:u,onClose:()=>{p(!1)},onConfirm:()=>{window.localStorage.setItem(hh.PoolEditPage,"1"),p(!1)},alertContent:Yn.jsx(e,{id:"Y9QDtD",message:"You are making changes to the liquidity of a private pool. This is a highly discretionary operation that may cause substantial inflows/outflows of funds and changes in market prices. Please make sure you are fully aware of the implications of each parameter modification."})})]})}function KL(e){return null==e?0:new Pe(e).dp(4,Pe.ROUND_DOWN).toNumber()}function XL({unit:t,data:n,masterKey:o,sumKey:r}){const s=a(),l=H.useRef(null),[d,c]=H.useState(null),[u,p]=H.useState(0);H.useEffect((()=>{const e=()=>{l&&l.current&&p(l.current.offsetWidth)};return setTimeout(e,100),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[l]);const h="light"===s.palette.mode?T(s.palette.success.main,.6):s.palette.primary.main,m="#ff9553",g=n[n.length-2],f="date";let x=[];if(null==n?void 0:n.length){let e=n[0][o];n.forEach((t=>{t[o]>e&&(e=t[o])})),x=e?[0,Math.ceil(e/3),Math.ceil(e/3*2),e]:[0]}let y=0;x.forEach((e=>{const t=Um(new Pe(e));let n=t.replace(".","").length;t.indexOf(".")>-1&&(n+=.11),n>y&&(y=n)}));const v=10*y+2;return Yn.jsxs(i,{ref:l,sx:{position:"relative"},children:[Yn.jsxs(i,{sx:{minHeight:62,mb:10},children:[Yn.jsxs(i,{sx:{typography:"caption",mb:8},children:[t||Yn.jsx("span",{children:" "}),Em({input:null==g?void 0:g[r]})]}),Yn.jsx(i,{sx:{color:"text.secondary"},children:an(null==g?void 0:g[f]).format("LL")})]}),Yn.jsxs(gn,{width:u,height:364,data:n,margin:{top:5,right:10,left:0,bottom:5},children:[Yn.jsx("defs",{children:n.map(((e,t)=>Yn.jsxs("linearGradient",{id:`colorBar${e.date}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[Yn.jsx("stop",{offset:"0%",stopColor:t===n.length-1?m:h}),Yn.jsx("stop",{offset:"100%",stopColor:T(t===n.length-1?m:h,.04)})]},e.date)))}),Yn.jsx(un,{hide:!0,dataKey:f,axisLine:!1,tickFormatter:e=>an(e).format("MM-DD")}),Yn.jsx(pn,{orientation:"right",axisLine:!1,ticks:x,width:v,tickFormatter:e=>Um(new Pe(e))}),Yn.jsx(fn,{isAnimationActive:!1,content:({active:t,payload:n,label:o})=>{if(!(t&&n&&n.length))return null;const r=an(o).format("YYYY-MM-DD")===an().format("YYYY-MM-DD");return Yn.jsxs(i,{sx:{px:10,py:12,maxWidth:240,borderRadius:8,backgroundColor:"background.paperContrast",typography:"h6",color:"text.secondary"},children:[Yn.jsx(i,{sx:{mr:8},children:an(o).format("MM-DD HH:mm")}),Yn.jsx(i,{children:n[0].value}),r?Yn.jsx(i,{children:Yn.jsx(e,{id:"ubzjDN",message:"Real Time"})}):""]})},cursor:!1,coordinate:{x:0,y:0}}),Yn.jsx(xn,{dataKey:o,onMouseMove:e=>{c(e[f])},onMouseLeave:()=>{c(null)},children:n.map((e=>Yn.jsx(yn,{fill:`url(#colorBar${e.date})`},e.date)))}),d&&Yn.jsx(vn,{x:d,stroke:h,strokeDasharray:"3 3"})]})]})}var JL,eR;function tR({poolDetail:e,chart24hDataFirst:t}){var n,o,r,s,l,d,c,u;const p=a(),[h,m]=H.useState(t?JL.volume:JL.depth),g={key:JL.depth,value:se._({id:"n25Lml",message:"Depth"})},f=[{key:JL.volume,value:se._({id:"/cF7Rs",message:"Volume"})},{key:JL.feeRevenue,value:se._({id:"9QjAGB",message:"FeeRevenue"})},{key:JL.traders,value:se._({id:"qDhDFK",message:"Traders"})}];t?f.push(g):f.splice(0,0,g);const x=function({address:e,chainId:t,day:n}){var i,o,r;const a=t?Wu[t]:"",s=gg().getQuery(ye.graphql.fetchPoolDayData,{where:{pair_address:null!=e?e:"",chain:a,day:n}}),l=et(Object.assign(Object.assign({},s),{enabled:!!e&&!!t})),d=null!==(r=null===(o=null===(i=l.data)||void 0===i?void 0:i.dashboard_pairs_day_data)||void 0===o?void 0:o.map((e=>{var t,n;return{volume:KL(null==e?void 0:e.volumeUsd),fee:KL(new Pe(null!==(t=null==e?void 0:e.feeUsd)&&void 0!==t?t:0).plus(null!==(n=null==e?void 0:e.mtFeeUsd)&&void 0!==n?n:0).toString()),traders:(null==e?void 0:e.addresses)?Number(e.addresses):0,date:(null==e?void 0:e.timestamp)?1e3*(null==e?void 0:e.timestamp):0,tvl:KL(null==e?void 0:e.tvlUsd)}})))&&void 0!==r?r:[];return Object.assign(Object.assign({},l),{dayDataList:d})}({chainId:null==e?void 0:e.chainId,address:null==e?void 0:e.address,day:30}),y=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(n=null==e?void 0:e.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==e?void 0:e.quoteToken)||void 0===o?void 0:o.decimals)),{pmmParamsBG:v}=null!==(r=y.data)&&void 0!==r?r:{},b=v?{i:v.i.toNumber(),k:v.k.toNumber(),b:v.b.toNumber(),b0:v.b0.toNumber(),q:v.q.toNumber(),q0:v.k.isEqualTo(0)?v.q.toNumber():v.q0.toNumber(),R:v.k.isEqualTo(0)?0:v.R}:void 0,j=b?Le(b):void 0,[C,w]=H.useState(!1),k=C&&(null===(s=y.data)||void 0===s?void 0:s.midPrice)?new Pe(1).div(null===(l=y.data)||void 0===l?void 0:l.midPrice):null===(d=y.data)||void 0===d?void 0:d.midPrice;return Yn.jsx(i,{sx:{mt:24,[p.breakpoints.up("tablet")]:{mt:20,pt:28,borderTop:`1px solid ${p.palette.border.main}`}},children:Yn.jsxs(S,{value:h,onChange:(e,t)=>m(t),children:[Yn.jsx(D,{tabs:f,variant:"rounded",tabsListSx:{borderWidth:0,gap:4,mb:24}}),h===JL.depth&&(null==e?void 0:e.baseToken)&&(null==e?void 0:e.quoteToken)?Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:Yn.jsx(nR,{baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,midPrice:k,isSwitchMidPrice:C,setIsSwitchMidPrice:w,showMidPrice:h===JL.depth})}):"",Yn.jsx(O,{value:JL.depth,children:Yn.jsx(zO,{baseToken:null!==(c=null==e?void 0:e.baseToken)&&void 0!==c?c:null,quoteToken:null!==(u=null==e?void 0:e.quoteToken)&&void 0!==u?u:null,pmmParams:b,pmmModel:j,midPrice:k})}),Yn.jsx(O,{value:JL.volume,children:Yn.jsx(XL,{data:x.dayDataList,masterKey:"volume",sumKey:"volume",unit:"$"})}),Yn.jsx(O,{value:JL.feeRevenue,children:Yn.jsx(XL,{data:x.dayDataList,masterKey:"fee",sumKey:"fee",unit:"$"})}),Yn.jsx(O,{value:JL.traders,children:Yn.jsx(XL,{data:x.dayDataList,masterKey:"traders",sumKey:"traders",unit:""})})]})})}function nR({baseToken:e,quoteToken:t,midPrice:n,isSwitchMidPrice:o,setIsSwitchMidPrice:a,showMidPrice:s}){const l=null==e?void 0:e.symbol,d=null==t?void 0:t.symbol,c=o?d:l,u=o?l:d;return Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:s?Yn.jsxs(i,{sx:{mt:4,typography:"body2",color:"text.secondary",wordBreak:"break-all",display:"flex"},children:[`1 ${c} = ${n?Em({input:n,showDecimals:16}):"-"} ${u}`,Yn.jsx(r,{weak:!0,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,position:"relative",top:1.5,ml:9,cursor:"pointer",borderRadius:"50%",backgroundColor:"background.paperDarkContrast",p:0},onClick:()=>a((e=>!e)),children:Yn.jsx(i,{component:li.Switch})})]}):""})}function iR({poolDetail:t}){var n,o,r;const{isMobile:s}=Tg(),l=a(),c=null==t?void 0:t.chainId;null===(r=et($m.getPMMStateQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,null===(n=null==t?void 0:t.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==t?void 0:t.quoteToken)||void 0===o?void 0:o.decimals)).data)||void 0===r||r.midPrice;const u=function({pool:e}){var t,n,i,o,r,a,s;const{chainId:l,address:d,type:c,baseToken:u,quoteToken:p}=e||{},h=null!=d?d:"",m=l?Wu[l]:"",g=null==u?void 0:u.decimals,f=null==p?void 0:p.decimals,x=et($m.getPMMStateQuery(l,d,c,null==u?void 0:u.decimals,null==p?void 0:p.decimals)),y=null===(t=x.data)||void 0===t?void 0:t.midPrice,v=et($m.getTotalBaseLpQuery(l,d,c,g)),b=et($m.getTotalQuoteLpQuery(l,d,c,f)),j=et($m.getReserveLpQuery(l,d,c,g,f)),C=et($m.getClassicalTargetQuery(l,d,c,g,f)),w=v.data;let k=b.data;k||b.isLoading||b.error||!w||(k=w);const{baseReserve:T,quoteReserve:I}=j.data||{},S=null===(n=C.data)||void 0===n?void 0:n.baseTarget,E=null===(i=C.data)||void 0===i?void 0:i.quoteTarget,A=aL({tokens:p?[p]:[]}),O=gg(),L=et(Object.assign(Object.assign({},O.getQuery(ye.graphql.fetchLiquidityPositions,{id:h,where:{pair:h,liquidityTokenBalance_not:"0",chain:m,refreshNow:!0},miningWhere:{pair:h,liquidityTokenInMining_not:"0",chain:m},first:1e3,orderBy:"liquidityTokenBalance",orderDirection:"desc"})),{enabled:!!d})),{balance:R,mining:P,pair:_}=null!==(o=L.data)&&void 0!==o?o:{};let M=[];const B=p?null===(r=A.data)||void 0===r?void 0:r.get(p.address):void 0;if(R&&P&&_){const{baseLpToken:e,quoteLpToken:t}=_,n=new Map,i=(null==e?void 0:e.id)===(null==t?void 0:t.id);for(const o of R){const{id:r,liquidityTokenBalance:a}=o,s=new Pe(null!=a?a:0),[l,u]=r.split("-");let p={id:l,baseSupplied:new Pe(0),quoteSupplied:new Pe(0)};n.has(p.id)?p=n.get(p.id):n.set(p.id,p);const[,h]=fI(s,w,T,S,d,c,g);h&&(i||u===(null==e?void 0:e.id))&&(p.baseSupplied=h);const[,m]=fI(s,k,I,E,d,c,f);m&&(i||u===(null==t?void 0:t.id))&&(p.quoteSupplied=m)}for(const o of P){const{id:r,liquidityTokenInMining:a}=o,s=new Pe(null!=a?a:0),[l,u]=r.split("-"),[,p]=fI(s,w,T,S,d,c,g),[,h]=fI(s,k,I,E,d,c,f);if(n.has(l)){const o=n.get(l);p&&(i||u===(null==e?void 0:e.id))&&(o.baseSupplied=p.plus(o.baseSupplied)),h&&(i||u===(null==t?void 0:t.id))&&(o.quoteSupplied=h.plus(o.quoteSupplied))}else{const o={id:l,baseSupplied:new Pe(0),quoteSupplied:new Pe(0)};p&&(i||u===(null==e?void 0:e.id))&&(o.baseSupplied=p),h&&(i||u===(null==t?void 0:t.id))&&(o.quoteSupplied=h),n.set(o.id,o)}}const o=(null!==(a=null==u?void 0:u.decimals)&&void 0!==a?a:0)>6?6:4,r=(null!==(s=null==p?void 0:p.decimals)&&void 0!==s?s:0)>6?6:4,l=B;n.forEach((e=>{var t,n;M.push({userId:e.id,baseSupplied:e.baseSupplied?Em({input:e.baseSupplied,showDecimals:o}):"0",quoteSupplied:e.quoteSupplied?Em({input:e.quoteSupplied,showDecimals:r}):"0",baseTokenAddress:null!==(t=null==u?void 0:u.address)&&void 0!==t?t:"",quoteTokenAddress:null!==(n=null==p?void 0:p.address)&&void 0!==n?n:"",baseTokenSymbol:Hm(u),quoteTokenSymbol:Hm(p),sharePercentage:y&&T?Em({input:y.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).div(y.multipliedBy(T).plus(null!=I?I:0)).multipliedBy(100),showDecimals:2}):"",dollarValue:null!=l&&y?`$${Em({input:y.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).multipliedBy(l),showDecimals:2})}`:"-",dollarValueBN:y?y.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0):Pe(0)})})),M.sort(((e,t)=>t.dollarValueBN.gt(e.dollarValueBN)?1:-1))}const D=[x,v,b,C,j,A,L],N=function(e){const t=[];if(e.forEach((e=>{e.error&&t.push(e.refetch)})),t.length)return()=>{t.forEach((e=>e()))}}(D),F=D.some((e=>e.isLoading));return Object.assign(Object.assign({},L),{isLoading:F,errorRefetch:N,list:M})}({pool:t}),[p,h]=H.useState(1),m=p*(s?4:8),g=u.list,f=m<g.length,x=g.slice(0,m);return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:u.error?u.refetch:void 0,loading:u.isLoading&&!(null==x?void 0:x.length),empty:!(null==x?void 0:x.length),children:!!(null==x?void 0:x.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"JlIjZf",message:"Liquidity Provider"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"C1qIFl",message:"Liquidity Supplied"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"me2dmq",message:"Value (USD)"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"Z8lGw6",message:"Share"})})]})}),Yn.jsx(i,{component:"tbody",children:null==x?void 0:x.map((e=>Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:Yn.jsx(zb,{address:e.userId,customChainId:c,truncate:!0})})}),Yn.jsxs("td",{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.baseTokenAddress,chainId:c,width:18,height:18}),`${e.baseSupplied} ${e.baseTokenSymbol}`]}),Yn.jsxs(i,{sx:{mt:4,display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.quoteTokenAddress,chainId:c,width:18,height:18}),`${e.quoteSupplied} ${e.quoteTokenSymbol}`]})]}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:e.dollarValue}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:`${e.sharePercentage}%`})]},e.userId)))})]})}),f&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>h((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function oR({address:e,chainId:t}){var n;const i=gg(),o=t?Wu[t]:"",r=i.getQuery(ye.graphql.fetchPoolDashboard,{where:{pair_address:null!=e?e:"",chain:o}}),a=et(Object.assign(Object.assign({},r),{enabled:!!e&&!!t})),s=null===(n=a.data)||void 0===n?void 0:n.dashboard_pairs_detail;return Object.assign(Object.assign({},a),{dashboard:s})}function rR(e,t){if(!e)return"";const n=an(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function aR({chainId:e,address:t,symbol:n,amount:o,sx:r}){return Yn.jsxs(i,{sx:ne({display:"flex",justifyContent:"flex-end",alignItems:"center"},r),children:[t&&Yn.jsx(i,{sx:{height:16,flexBasis:16,flexGrow:0,flexShrink:0,mr:4},children:Yn.jsx(Df,{width:16,height:16,address:t,chainId:e})}),Yn.jsxs(i,{sx:{textAlign:"right",display:"flex",alignItems:"center"},children:[o," ",Yn.jsx(i,{sx:{display:"inline-block",maxWidth:"6em",minWidth:"auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"},title:n,children:n})]})]})}function sR({chainId:e,baseToken:t,quoteToken:n,baseAmount:o,quoteAmount:r,vertical:a}){const{isMobile:s}=Tg();return Yn.jsxs(i,{sx:{mt:4,display:"flex",justifyContent:"flex-end",flexDirection:a?"column":"row",alignItems:a?"flex-end":"center",flexWrap:"wrap",typography:s?"h6":"body1"},children:[t?Yn.jsx(aR,{chainId:e,address:null==t?void 0:t.address,amount:o,symbol:null==t?void 0:t.symbol}):"-",a?"":Yn.jsx(i,{sx:{mx:10},children:"/"}),n?Yn.jsx(aR,{chainId:e,address:null==n?void 0:n.address,amount:r,symbol:null==n?void 0:n.symbol,sx:{mt:a?4:0}}):"-"]})}function lR({label:e,children:t,pairsStatLoading:n,poolDetailLoading:o}){const{isMobile:r}=Tg();return Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{color:"text.secondary",minWidth:"5em",typography:r?"h6":"body1"},children:e}),Yn.jsx(i,{sx:ne({textAlign:"right",overflow:"hidden","& .title":{typography:r?"body1":"caption",width:"100%"}},n&&!o||!n&&o?{ml:8,flex:1,display:"flex",flexDirection:"column",alignItems:"flex-end","& .title":{display:"flex",justifyContent:"flex-end"}}:{}),children:t})]})}function dR({sx:e}){return Yn.jsx(j,{sx:Object.assign({width:"100%",maxWidth:237,height:22},e)})}function cR({detail:e,lpFeeRate:t,mtFeeRate:n}){const{isMobile:o}=Tg();return"DPP"===(null==e?void 0:e.type)?null:e&&t&&n?Yn.jsxs(i,{sx:{color:"text.secondary",typography:o?"h6":"body1"},children:[Yn.jsx("span",{children:"LP "}),Yn.jsx("span",{children:Vm({input:t,showDecimals:6})}),Yn.jsxs("span",{children:[" / ",se._({id:"7C/BwI",message:"Community Treasury"})," "]}),Yn.jsx("span",{children:Vm({input:new Pe(null!=n?n:0).toNumber(),showDecimals:6})})]}):Yn.jsx(dR,{sx:{mt:4}})}function uR({detail:e}){var t,n,o,r,s,l,d,c,u,p,h,m,g,f,x,y,v,b,j,C,w,k,T,I,S,E,A;const O=a(),{isMobile:L}=Tg(),{baseToken:R,quoteToken:P}=null!=e?e:{},_="DPP"===(null==e?void 0:e.type),M="DSP"===(null==e?void 0:e.type)||"GSP"===(null==e?void 0:e.type),B="CLASSICAL"===(null==e?void 0:e.type),D=oR({address:null==e?void 0:e.address,chainId:null==e?void 0:e.chainId}),N=D.dashboard,F=D.isLoading,U=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(t=null==e?void 0:e.baseToken)||void 0===t?void 0:t.decimals,null===(n=null==e?void 0:e.quoteToken)||void 0===n?void 0:n.decimals)),q=F?Yn.jsx(dR,{}):null===(null==N?void 0:N.totalVolume)||void 0===(null==N?void 0:N.totalVolume)?"-":`$${Em({input:new Pe(null==N?void 0:N.totalVolume),showDecimals:2})}`,V=F?Yn.jsx(dR,{}):N&&(yj(N.totalFee)||yj(N.totalMtFee))?`$${Em({input:new Pe(N.totalFee||0).plus(N.totalMtFee||0),showDecimals:2})}`:"-",{account:W}=dg(),H=et($m.getFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,W)),$=null===(o=H.data)||void 0===o?void 0:o.mtFeeRate,z=null===(r=H.data)||void 0===r?void 0:r.lpFeeRate,Z=null==$?void 0:$.plus(null!=z?z:0),G=!e,Q=et($m.getClassicalTargetQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(s=null==e?void 0:e.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==e?void 0:e.quoteToken)||void 0===l?void 0:l.decimals));return Yn.jsxs(i,{sx:Object.assign({pb:30,position:"relative",overflow:"hidden"},L?{backgroundColor:"background.paper",p:20}:{mt:32}),children:[Yn.jsxs(i,{sx:{flex:"1 0 50%","& > div + div":{mt:10},"&::after":{content:'""',display:"block",my:20,width:"100%",height:"1px",backgroundColor:"border.main"}},children:[Yn.jsx(lR,{label:se._({id:"l4Za6X",message:"Total Swap Volume"}),pairsStatLoading:F,children:Yn.jsx("div",{className:"title",children:q})}),F||!e?Yn.jsx(dR,{sx:{mt:4}}):Yn.jsx(sR,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Em({input:null!==(d=null==N?void 0:N.baseVolumeCumulative)&&void 0!==d?d:0,showDecimals:2}),quoteAmount:Em({input:null!==(c=null==N?void 0:N.quoteVolumeCumulative)&&void 0!==c?c:0,showDecimals:2})}),Yn.jsx(lR,{label:se._({id:"Z033WN",message:"Total Swap Fee"}),pairsStatLoading:F,children:Yn.jsx("div",{className:"title",children:V})}),F||!e?Yn.jsx(dR,{sx:{mt:4}}):Yn.jsx(sR,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Em({input:new Pe(null!==(u=null==N?void 0:N.baseFee)&&void 0!==u?u:0).plus(null!==(p=null==N?void 0:N.baseMtFee)&&void 0!==p?p:0),showDecimals:2}),quoteAmount:Em({input:new Pe(null!==(h=null==N?void 0:N.quoteFee)&&void 0!==h?h:0).plus(null!==(m=null==N?void 0:N.quoteMtFee)&&void 0!==m?m:0),showDecimals:2})}),Yn.jsx(lR,{label:se._({id:"/BbUJ6",message:"Total Number of Traders"}),pairsStatLoading:F,children:F?Yn.jsx(dR,{sx:{mt:4}}):Em({input:null!==(g=null==N?void 0:N.txUsers)&&void 0!==g?g:0,showDecimals:0})})]}),Yn.jsxs(i,{sx:{flex:"1 0 50%",overflow:"hidden","& > div + div":{mt:10}},children:[Yn.jsx(lR,{label:se._({id:"UE2beD",message:"Creator"}),poolDetailLoading:!e,children:e?e.isCpPool?Yn.jsx(zb,{address:null!==(f=e.cpCreator)&&void 0!==f?f:"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}}):Yn.jsx(zb,{address:null!==(x=e.creator)&&void 0!==x?x:"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}}):Yn.jsx(dR,{})}),(null==e?void 0:e.isCpPool)||(null==e?void 0:e.owner)?Yn.jsx(lR,{label:se._({id:"LtI9AS",message:"Owner"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):(null==e?void 0:e.isCpPool)?Yn.jsx(zb,{address:null==e?void 0:e.cpCreator,truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}}):Yn.jsx(zb,{address:null!==(y=e.owner)&&void 0!==y?y:"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}})}):"",Yn.jsx(lR,{label:se._({id:"52uNwk",message:"Creation Time"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):rR(1e3*Number((null==e?void 0:e.isCpPool)?e.cpCreatedAtTimestamp||0:e.createdAtTimestamp||0))||"-"}),(null==e?void 0:e.isCpPool)?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(lR,{label:se._({id:"cDWXuq",message:"Settler"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):Yn.jsx(zb,{address:(null==e?void 0:e.cpLiquidator)||"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}})}),Yn.jsx(lR,{label:se._({id:"JuzN3b",message:"Related CrowdPooling"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):Yn.jsx(zb,{address:null==e?void 0:e.cpAddress,truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}})})]}):void 0,Yn.jsxs(lR,{label:se._({id:"Y7rVy0",message:"Fee Rate"}),poolDetailLoading:G,children:[Yn.jsx("div",{className:"detail-title",style:{textAlign:"right"},children:Vm({input:null==Z?void 0:Z.toNumber(),showDecimals:6})}),Yn.jsx(cR,{detail:e,lpFeeRate:z,mtFeeRate:$})]}),Yn.jsx(lR,{label:se._({id:"sjn3tj",message:"Slippage Coefficient"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):null===(b=null===(v=U.data)||void 0===v?void 0:v.pmmParamsBG)||void 0===b?void 0:b.k.toString()}),Yn.jsx(lR,{poolDetailLoading:G,label:B?se._({id:"d8YnVj",message:"Guide Price"}):_?se._({id:"CeLrge",message:"Mid Price"}):M?se._({id:"4ogEAw",message:"Pegged Exchange Rate"}):se._({id:"jjuKOj",message:"Min Price"}),children:G?Yn.jsx(dR,{}):null!==R&&(M?`1 ${null==R?void 0:R.symbol} = ${null===(w=null===(C=null===(j=U.data)||void 0===j?void 0:j.pmmParamsBG)||void 0===C?void 0:C.i)||void 0===w?void 0:w.toString()} ${null==P?void 0:P.symbol}`:null===(I=null===(T=null===(k=U.data)||void 0===k?void 0:k.pmmParamsBG)||void 0===T?void 0:T.i)||void 0===I?void 0:I.toString())||"-"}),B&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(lR,{label:se._({id:"JR7wWw",message:"Equilibrium target"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):Yn.jsx(Yn.Fragment,{children:null===(A=null===(E=null===(S=U.data)||void 0===S?void 0:S.pmmParamsBG)||void 0===E?void 0:E.k)||void 0===A?void 0:A.toString()})}),Q.data?Yn.jsx(sR,{vertical:!0,chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Em({input:Q.data.baseTarget,showDecimals:2}),quoteAmount:Em({input:Q.data.quoteTarget,showDecimals:2})}):""]})]})]})}function pR(e,t){if(!e)return"";const n=an(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function hR({amountOut:e,amountIn:t,fromTokenSymbol:n,toTokenSymbol:o}){const[r,a]=H.useState(!1),s=Em({input:t/e,showDecimals:2}),l=Em({input:e/t,showDecimals:2});return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:["1 ",r?o:n," = ",r?s:l," ",r?n:o,Yn.jsx(i,{sx:{ml:10,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backgroundColor:"background.paperContrast",borderRadius:"50%"},onClick:()=>a((e=>!e)),children:Yn.jsx(i,{component:li.Switch})})]})}function mR({poolDetail:t}){var n,o,r;const{isMobile:s}=Tg(),l=a(),{account:c,chainId:u}=dg(),p=et($m.getFeeRateQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,c)),h=null===(n=p.data)||void 0===n?void 0:n.mtFeeRate,m=null===(o=p.data)||void 0===o?void 0:o.lpFeeRate,g=null==h?void 0:h.plus(null!=m?m:0),f=function({chainId:e,address:t,first:n=50}){var i;const o=e?Wu[e]:"",r=gg().getQuery(ye.graphql.fetchPoolSwapList,{first:n,orderBy:"timestamp",orderDirection:"desc",where:{pair:t,chain:o}}),a=et(Object.assign(Object.assign({},r),{enabled:!!t})),s=null===(i=a.data)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},a),{swapList:s})}({address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),[x,y]=H.useState(1),v=x*(s?4:8),b=null!==(r=f.swapList)&&void 0!==r?r:[],j=v<b.length,C=b.slice(0,v);return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:f.error?f.refetch:void 0,loading:f.isLoading,empty:!(null==C?void 0:C.length),children:!!(null==C?void 0:C.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"LhMjLm",message:"Time"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"UPXmW+",message:"Trader"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"v4nCHK",message:"Paid"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"fZ5Vnu",message:"Received"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"a7u1N9",message:"Price"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"PLUB/s",message:"Fee"})})]})}),Yn.jsx(i,{component:"tbody",children:null==C?void 0:C.map((e=>Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:pR(1e3*e.timestamp)}),Yn.jsx("td",{children:Yn.jsx(zb,{address:e.from,truncate:!0})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.fromToken.id,chainId:u,width:18,height:18}),`${Em({input:e.amountIn,showDecimals:2})} ${e.fromToken.symbol}`]})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.toToken.id,chainId:u,width:18,height:18}),`${Em({input:e.amountOut,showDecimals:2})} ${e.toToken.symbol}`]})}),Yn.jsx("td",{children:Yn.jsx(hR,{amountOut:e.amountOut,amountIn:e.amountIn,fromTokenSymbol:e.fromToken.symbol,toTokenSymbol:e.toToken.symbol})}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:Vm({input:g})}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:`${Em({input:new Pe(e.amountOut).times(null!=g?g:0)})} ${e.toToken.symbol}`})]},e.id)))})]})}),j&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>y((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function gR({poolDetail:e}){const{isMobile:t}=Tg(),[n,o]=H.useState(eR.parameters),r=[{key:eR.parameters,value:se._({id:"F18WP3",message:"Parameters"})},{key:eR.swaps,value:se._({id:"EatqP4",message:"Swaps"})}];return e&&"DPP"!==(null==e?void 0:e.type)&&r.push({key:eR.liquidityProviders,value:se._({id:"juypHV",message:"Liquidity Providers"})}),Yn.jsx(i,{sx:Object.assign({mt:24,backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},t?{}:{mt:32,px:20}),children:Yn.jsxs(S,{value:n,onChange:(e,t)=>o(t),children:[Yn.jsx(D,{tabs:r}),Yn.jsx(O,{value:eR.parameters,children:Yn.jsx(uR,{detail:e})}),Yn.jsx(O,{value:eR.swaps,children:Yn.jsx(mR,{poolDetail:e})}),Yn.jsx(O,{value:eR.liquidityProviders,children:Yn.jsx(iR,{poolDetail:e})})]})})}function fR(){return Yn.jsx(j,{variant:"rounded",sx:{width:90}})}function xR({poolDetail:t}){var n,o;const r=a(),{isMobile:s}=Tg(),l=oR({address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),d=l.dashboard,c=[{description:se._({id:"Gr2anW",message:"Traders (24H)"}),text:l.isLoading?Yn.jsx(fR,{}):null===(null==d?void 0:d.txUserNear24h)||void 0===(null==d?void 0:d.txUserNear24h)?"-":Um(new Pe(null==d?void 0:d.txUserNear24h))},{description:se._({id:"sTnImq",message:"Total Liquidity"}),text:l.isLoading?Yn.jsx(fR,{}):null===(null==d?void 0:d.tvl)||void 0===(null==d?void 0:d.tvl)?"-":`$${Um(new Pe(null==d?void 0:d.tvl))}`},{description:se._({id:"p7/w10",message:"Volume (24H)"}),text:l.isLoading?Yn.jsx(fR,{}):null===(null==d?void 0:d.volume)||void 0===(null==d?void 0:d.volume)?"-":`$${Um(new Pe(null==d?void 0:d.volume))}`},{description:se._({id:"7X40pG",message:"Fees (24H)"}),text:l.isLoading?Yn.jsx(fR,{}):null!==!(null==d?void 0:d.feeNear24h)||(null==d?void 0:d.mtFeeNear24h)?`$${Um(new Pe(null!==(n=null==d?void 0:d.feeNear24h)&&void 0!==n?n:0).plus(null!==(o=null==d?void 0:d.mtFeeNear24h)&&void 0!==o?o:0))}`:"-",question:l.isLoading?void 0:Yn.jsxs(i,{sx:{width:198},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(e,{id:"OnDEky",message:"LP Fee"}),Yn.jsx(i,{children:(null==d?void 0:d.feeNear24h)?`$${Um(new Pe(null==d?void 0:d.feeNear24h))}`:"-"})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(e,{id:"pSQ1lM",message:"MT Fee"}),Yn.jsx(i,{children:(null==d?void 0:d.mtFeeNear24h)?`$${Um(new Pe(null==d?void 0:d.mtFeeNear24h))}`:"-"})]})]})}];return Yn.jsx(i,{sx:Object.assign({display:"grid",gap:12},s?{mt:24,gridTemplateColumns:"repeat(2, 1fr)"}:{mt:32,gridTemplateColumns:"repeat(4, 1fr)"}),children:c.map((e=>Yn.jsxs(i,{sx:{borderRadius:8,p:16,backgroundColor:"background.paper",border:`1px solid ${r.palette.border.main}`},children:[Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,lineHeight:"27px"},children:e.text}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary",gap:4},children:[e.description,e.question?Yn.jsx(lb,{title:e.question}):""]})]},e.description)))})}function yR({poolDetail:t,loading:n}){var o,r,s,c;const{address:u}=null!=t?t:{},p=a(),h=Gj(),{account:m}=dg(),{isMobile:g}=Tg(),f=m&&"DPP"===(null==t?void 0:t.type)&&(null===(o=null==t?void 0:t.owner)||void 0===o?void 0:o.toLocaleLowerCase())===m.toLocaleLowerCase(),{supportAMMV2:x,onSharePool:y}=Jn();return Yn.jsxs(i,{sx:Object.assign({},g?{pt:24}:{pt:20,display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[(null==t?void 0:t.baseToken)?Yn.jsx(kj,{tokens:[t.baseToken,t.quoteToken],chainId:t.chainId,width:36,mr:8}):Yn.jsx(j,{variant:"circular",sx:{width:36,height:36,mr:8}}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h4"},children:[(null==t?void 0:t.baseToken)?`${null===(r=t.baseToken)||void 0===r?void 0:r.symbol} / ${null===(s=t.quoteToken)||void 0===s?void 0:s.symbol}`:"-",x&&Yn.jsx(i,{component:"span",sx:{position:"relative",top:-4,ml:4,px:4,py:2,borderRadius:4,fontSize:10,lineHeight:1,fontWeight:600,backgroundColor:T(p.palette.purple.main,.1),color:p.palette.purple.main},children:"PMM"}),Yn.jsx(gS,{address:u,chainId:null==t?void 0:t.chainId,hideName:g,sx:{display:"inline-flex",ml:8}}),f&&!g?Yn.jsx(i,{component:d,sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderRadius:4,borderColor:"primary.main",color:"primary.main",whiteSpace:"nowrap","&:hover":{backgroundColor:"primary.main",color:"primary.contrastText"}},onClick:()=>{h.push({type:Zj.ModifyPool,params:{address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}})},children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})}):""]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",mr:12},children:Yn.jsx(zb,{address:null!=u?u:"",truncate:!0,showCopy:!0,iconDarkHover:!0,"data-key":"link",sx:{typography:"body2",color:"text.secondary"},iconSize:14,iconSpace:6,customChainId:null==t?void 0:t.chainId,onShareClick:y&&t?()=>y({chainId:t.chainId,baseToken:t.baseToken,quoteToken:t.quoteToken,poolId:u,apy:t.apy,isSingle:ye.utils.singleSideLp(t.type)}):void 0})})]})]}),Yn.jsxs(i,{sx:g?{display:"flex",alignItems:"center",mt:24}:{textAlign:"right"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"success.main",typography:"h4"},children:[(null==t?void 0:t.miningAddress)?Yn.jsx(l,{title:se._({id:"B3mhDR",message:"Add liquidity to obtain LP tokens for mining"}),children:Yn.jsx("span",{children:"✨ "})}):"",Yn.jsx(v,{loading:n,loadingSx:{width:100},children:null!==(c=null==t?void 0:t.baseApy)&&void 0!==c?c:"0%"}),(null==t?void 0:t.quoteApy)?`/${null==t?void 0:t.quoteApy}`:""]}),Yn.jsx(i,{sx:Object.assign({typography:"body2"},g?{ml:4}:{}),children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]})]})}function vR({chainId:e,shortNumber:t,pieSize:n="default",baseReserve:o=new Pe(1),baseAmount:r=new Pe(1),quoteAmount:s=new Pe(0),baseTokenSymbol:l="-",quoteTokenSymbol:d="-",quoteTokenDecimals:c=18,baseTokenDecimals:u=18,baseTokenAddress:p,quoteTokenAddress:h,baseTvlRate:m,quoteTvlRate:g,disabledAmount:f,disabledRate:x,disabledPercentage:y,loading:v,sx:b,pieRadius:C}){const w=a(),k="small"===n,T=k?6:16,I=C||(k?23:30),S=u>6?6:u>4?4:2,E=c>6?6:c>4?4:2,A=t?Um(new Pe(o)):Em({input:o,showDecimals:S}),O=t?Um(new Pe(s)):Em({input:s,showDecimals:E});let L=r.plus(s);L=L.lte(0)?new Pe(1):L;const R=m||r.div(L).multipliedBy(100).toFixed(2),P=g||s.div(L).multipliedBy(100).toFixed(2),_=r.lte(0)&&s.lte(0),M=w.palette.success.main,B=w.palette.error.main,D=[{name:"base",value:_?1:r.toNumber(),color:M},{name:"quote",value:_?1:s.toNumber(),color:B}];return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",flexDirection:"column"},b||{}),children:[Yn.jsx("div",{children:y?"":v?Yn.jsx(j,{width:46,height:46,variant:"circular"}):Yn.jsx(bn,{width:2*I,height:2*I,children:Yn.jsx(jn,{isAnimationActive:!1,dataKey:"value",data:D,labelLine:!1,label:!1,outerRadius:I,fill:B,children:D.map(((e,t)=>Yn.jsx(yn,{fill:e.color,strokeWidth:0},`cell-${t}`)))})})}),Yn.jsxs(i,{className:"symbol-wrapper",sx:{display:"flex",flexDirection:"column",justifyContent:"center",ml:0,mt:16,width:"100%","& > div":{paddingLeft:"12px",position:"relative","&::before":{content:'""',width:"8px",height:"8px",position:"absolute",left:"0",top:"50%",transform:"translateY(-50%)",backgroundColor:w.palette.purple.main,borderRadius:"50%"},"&:last-child::before":{backgroundColor:B},"&> span.symbol":{display:"inline-block",maxWidth:"6em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"}}},children:[v?Yn.jsx(j,{width:237,sx:{borderRadius:4}}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{className:"symbol",title:l,sx:{typography:"h6"},children:l}),p?Yn.jsx(zb,{address:p,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),Yn.jsxs(i,{sx:{textAlign:"right"},children:[f?"":`${A} `,y||x?"":Yn.jsxs(i,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${R}%)`]})]})]}),v?Yn.jsx(j,{width:237,sx:{borderRadius:4,marginTop:`${T}px`}}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:`${T}px`},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{className:"symbol",title:d,sx:{typography:"h6"},children:d}),h?Yn.jsx(zb,{address:h,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),Yn.jsxs(i,{sx:{textAlign:"right"},children:[f?"":`${O} `,y||x?"":Yn.jsxs(i,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${P}%)`]})]})]})]})]})}function bR({poolDetail:t}){var n,o,r,s,l,d,c,u,p;const h=a(),{isMobile:m}=Tg(),g=et($m.getPMMStateQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,null===(n=null==t?void 0:t.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==t?void 0:t.quoteToken)||void 0===o?void 0:o.decimals)),f=null===(r=g.data)||void 0===r?void 0:r.midPrice,x=et($m.getReserveLpQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,null===(s=null==t?void 0:t.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==t?void 0:t.quoteToken)||void 0===l?void 0:l.decimals)),{baseReserve:y,quoteReserve:v}=x.data||{},b=y&&f?null==f?void 0:f.multipliedBy(y):void 0,C=v&&f?new Pe(v):void 0;let w=b&&C?null==b?void 0:b.plus(C):void 0;w=!w||w.lte(0)?new Pe(1):w;const k=b&&b.div(w).multipliedBy(100).toFixed(2),T=C&&C.div(w).multipliedBy(100).toFixed(2);return Yn.jsxs(i,{sx:{mt:m?24:28},children:[Yn.jsx(i,{sx:{fontWeight:600},children:Yn.jsx(e,{id:"sTnImq",message:"Total Liquidity"})}),Yn.jsxs(i,{sx:{display:"flex",mt:16,backgroundColor:"background.paper",borderRadius:16,overflowX:"auto",border:`1px solid ${h.palette.border.main}`},children:[Yn.jsx(i,{sx:{flex:m?1:void 0,padding:m?h.spacing(20,30,20,20):h.spacing(20,30,16)},children:Yn.jsx(vR,{pieRadius:44,baseReserve:y,baseAmount:b,baseTokenDecimals:null===(d=null==t?void 0:t.baseToken)||void 0===d?void 0:d.decimals,quoteAmount:C,baseTvlRate:k,quoteTvlRate:T,chainId:null==t?void 0:t.chainId,quoteTokenDecimals:(null===(c=null==t?void 0:t.quoteToken)||void 0===c?void 0:c.decimals)||void 0,baseTokenSymbol:Hm(null==t?void 0:t.baseToken),quoteTokenSymbol:Hm(null==t?void 0:t.quoteToken),baseTokenAddress:m?null===(u=null==t?void 0:t.baseToken)||void 0===u?void 0:u.address:"",quoteTokenAddress:m?null===(p=null==t?void 0:t.quoteToken)||void 0===p?void 0:p.address:"",shortNumber:!0,disabledRate:!m,disabledAmount:!m,loading:g.isLoading||x.isLoading,sx:m?{typography:"body2",fontWeight:600}:{"& .symbol-wrapper":{display:"flex",alignItems:"center",flexDirection:"row","& > div, & > span":{mt:0,"&:last-child":{ml:16}},"& .MuiSkeleton-root":{width:"40px !important"}}}})}),m?"":Yn.jsxs(i,{component:"table",sx:{flex:1,fontWeight:600,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 0 1px","& thead":{typography:"h6",color:"text.secondary","& th":{textAlign:"right",px:20,py:16,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 1px","&:first-child":{textAlign:"left"}}},"& tbody":{typography:"body2",textAlign:"right","& td":{px:20,py:0,"&:first-child":{textAlign:"left"}}}},children:[Yn.jsx("thead",{children:Yn.jsxs("tr",{children:[Yn.jsx("th",{children:Yn.jsx(e,{id:"bUUVED",message:"Asset"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"hcNa1G",message:"Token Amount"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"iaocTt",message:"Ratio"})})]})}),Yn.jsxs("tbody",{children:[Yn.jsxs("tr",{children:[Yn.jsx("td",{children:t?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{address:t.baseToken.address,width:24,height:24,marginRight:4,chainId:t.chainId}),Yn.jsxs(i,{children:[t.baseToken.symbol,Yn.jsx(zb,{address:t.baseToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:t.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):Yn.jsx(j,{width:100,height:24})}),Yn.jsx("td",{children:t?Um(new Pe(t.baseReserve)):Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}})}),Yn.jsx("td",{children:g.isLoading?Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=k?k:"-"}%`})]}),Yn.jsxs("tr",{children:[Yn.jsx("td",{children:t?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{address:t.quoteToken.address,width:24,height:24,marginRight:4,chainId:t.chainId}),Yn.jsxs(i,{children:[t.quoteToken.symbol,Yn.jsx(zb,{address:t.quoteToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:t.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):Yn.jsx(j,{width:100,height:24})}),Yn.jsx("td",{children:t?Um(new Pe(t.quoteReserve)):Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}})}),Yn.jsx("td",{children:g.isLoading?Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=T?T:"-"}%`})]})]})]})]})]})}function jR({params:t}){var n,o,r,s,l,d,u;const p=Gj(),{isMobile:h}=Tg(),{account:m}=dg(),g=a(),f=$L({id:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),{poolDetail:x}=f,y=qn(f,["poolDetail"]),[v,b]=H.useState("inital");y.isPending||y.error||x||"inital"!==v||b("open");const j=x&&"DPP"===x.type&&m&&(null===(n=x.owner)||void 0===n?void 0:n.toLocaleLowerCase())===m.toLocaleLowerCase(),C=x&&"DPP"!==x.type||m&&(null==x?void 0:x.owner)&&x.owner.toLocaleLowerCase()===m.toLocaleLowerCase(),[w,k]=H.useState();x&&void 0===w&&!h&&k(YT.Add);const T=w&&x?Object.assign(Object.assign({},x),{baseLpToken:{id:null===(o=x.baseLpToken)||void 0===o?void 0:o.id,decimals:Number(null!==(s=null===(r=x.baseLpToken)||void 0===r?void 0:r.decimals)&&void 0!==s?s:18)},quoteLpToken:{id:null===(l=x.quoteLpToken)||void 0===l?void 0:l.id,decimals:Number(null!==(u=null===(d=x.quoteLpToken)||void 0===d?void 0:d.decimals)&&void 0!==u?u:18)}}):void 0,I=!!(null==x?void 0:x.miningAddress);return Yn.jsxs(zj,{sx:h?{p:g.spacing(28,0,C?108:0)}:{p:g.spacing(28,0,40)},children:[Yn.jsx(WL,{onClick:()=>{p.push({type:Zj.Pool})}}),Yn.jsxs(i,{sx:h?{}:{display:"flex",gap:12,overflow:"hidden"},children:[Yn.jsxs(i,{sx:{flex:1,overflow:"hidden"},children:[Yn.jsx(yR,{poolDetail:x,loading:y.isPending}),Yn.jsx(tR,{poolDetail:x,chart24hDataFirst:!0}),Yn.jsx(xR,{poolDetail:x}),Yn.jsx(bR,{poolDetail:x}),Yn.jsx(gR,{poolDetail:x})]}),h?Yn.jsx(mS,{account:m,pool:T,operate:w,hasMining:I,modal:!0,onClose:()=>{k(void 0)}}):Yn.jsx(hS,{account:m,operate:w,hasMining:I,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},pool:T,hidePoolInfo:!0})]}),Yn.jsx(VL,{singleBtn:!0,open:"open"===v,onClose:()=>b("close"),onConfirm:()=>b("close"),title:se._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),h&&C&&Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:j?"repeat(3, 1fr)":"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[j?Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{Gj.getState().push({type:Zj.ModifyPool,params:{chainId:x.chainId,address:x.address}})},children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})}):"",Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{k(YT.Remove)},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{onClick:()=>{k(YT.Add)},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})})]})})]})}function CR({statuses:t,children:n,buttonProps:o}){var r;if(!t.find((e=>e.needShowTokenStatusButton))&&n)return Yn.jsx(Yn.Fragment,{children:n});const a=t.find((e=>e.insufficientBalance));if(a)return Yn.jsx(c,{fullWidth:!0,disabled:!0,...o,children:Yn.jsx(e,{id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(r=a.token)||void 0===r?void 0:r.symbol}})});const s=t.some((e=>e.isApproving));return Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:4},children:t.map(((t,n)=>{var i,r;let a="";return t.isApproving?a=Yn.jsx(e,{id:"j2Uisd",message:"Approving"}):(t.needReset||t.needApprove)&&(a=t.approveTitle),a?Yn.jsx(c,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance||s,...o,children:a},null!==(r=null===(i=t.token)||void 0===i?void 0:i.symbol)&&void 0!==r?r:n):null}))})}function wR({token:t,chainId:n,showChainLogo:o,readonly:r,showChainName:s,logoSize:l=24,chainLogoSize:c=12,side:u,occupiedToken:p,defaultLoadBalance:h,notTokenPickerModal:m,border:g,px:f=20,py:x=8,highlightDefault:y,onTokenClick:v,onTokenChange:b}){var j,C;const{onlyChainId:w}=Jn(),k=n||w,T=a(),[I,S]=H.useState(!1),E=(null==t?void 0:t.chainId)?ah.get(t.chainId):null,A=s&&!!E;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:T.palette.text.primary,typography:A?"body2":"body1",fontWeight:600,px:f,py:x,"&:focus-visible":{opacity:.5}},!!g&&{border:`solid 1px ${T.palette.border.main}`,borderRadius:8,"&:hover":{backgroundColor:T.palette.hover.default}}),!(!y||t)&&{backgroundColor:T.palette.primary.main,color:T.palette.primary.contrastText,"&:hover":{opacity:.8}}),onClick:()=>{r||S(!0)},"data-testid":Ch,children:[!!(null==t?void 0:t.address)&&Yn.jsx(Df,{url:null==t?void 0:t.logoURI,address:null!==(j=null==t?void 0:t.address)&&void 0!==j?j:"",chainId:null==t?void 0:t.chainId,noShowChain:!o,width:l,height:l,chainSize:c,logoOffset:10,marginRight:0}),Yn.jsxs(i,{sx:{flex:1},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(null==t?void 0:t.address)?Yn.jsx(Yn.Fragment,{children:Yn.jsx(i,{children:null!==(C=null==t?void 0:t.symbol)&&void 0!==C?C:"-"})}):Yn.jsx(e,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&Yn.jsx(i,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{flexShrink:0},children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"})})]}),!!A&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[E.name,Yn.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]}),Yn.jsx(Xb,{value:t,open:I,side:u,chainId:k,occupiedAddrs:p?[p.address]:void 0,occupiedChainId:null==p?void 0:p.chainId,defaultLoadBalance:h,onClose:()=>{S(!1),v&&v()},onTokenChange:(e,t)=>{S(!1),setTimeout((()=>{!Array.isArray(e)&&b&&b(e,t)}),Sf)},modal:!m})]})}function kR({title:e,disabled:t,children:n}){return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,opacity:t?.3:void 0},children:[Yn.jsx(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:600},children:e}),n]})}!function(e){e[e.depth=1]="depth",e[e.volume=2]="volume",e[e.feeRevenue=3]="feeRevenue",e[e.traders=4]="traders"}(JL||(JL={})),function(e){e[e.parameters=1]="parameters",e[e.swaps=2]="swaps",e[e.liquidityProviders=3]="liquidityProviders"}(eR||(eR={}));const TR=1e-4;function IR({disabled:t,fee:n,onChange:o,feeList:r,hasCustom:s}){const l=a(),[c,u]=H.useState(!1),[p,h]=H.useState(!1),[m,g]=H.useState(""),{isMobile:f}=Tg(),x=!r.includes(n),y=x||p,v=!p&&x&&!!m&&new Pe(m).div(100).lt(TR),j=t||v;return Yn.jsxs(i,{sx:{opacity:t?.3:void 0,fontWeight:600},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main"},children:[Yn.jsx(e,{id:"tMMG40",message:"{0}% fee tier",values:{0:n?new Pe(n).times(100).toString():"-"}}),Yn.jsx(d,{sx:{px:16,py:7,border:`solid 1px ${l.palette.text.primary}`,borderRadius:8,fontWeight:600,color:"text.primary",cursor:j?"default":"pointer",opacity:v?.3:1},disabled:j,onClick:()=>{j||u((e=>!e))},children:c?Yn.jsx(e,{id:"vLyv1R",message:"Hide"}):Yn.jsx(e,{id:"ePK91l",message:"Edit"})})]}),c&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign({mt:12},f?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8,"& > label":{flex:1}}),children:[r.map((e=>{const t=n===e&&!y;return Yn.jsxs(i,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer"},t&&{color:l.palette.primary.main,borderColor:l.palette.primary.main}),children:[100*e,"%",Yn.jsx(U,{size:18,checked:t,onChange:(t,n)=>{n&&o(e)}})]},e)})),s&&Yn.jsxs(i,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer",color:v?l.palette.error.main:"text.primary"},y&&{color:l.palette.primary.main,borderColor:l.palette.primary.main}),onClick:()=>{h(!0),g("")},children:[p?Yn.jsx(b,{value:m,autoFocus:!0,onChange:e=>{const t=e.target.value;isNaN(Number(t))||g(t)},onBlur:()=>{const e=Number(m),t=e?new Pe(e).div(100).toNumber():e;t&&t<TR?o(0):m&&(e||0===e)&&o(t),h(!1)},sx:{p:0,flex:1,height:"100%",border:"none",backgroundColor:"none"},inputSx:{p:0}}):Yn.jsx(Yn.Fragment,{children:x?(new Pe(n).times(100).toNumber()||m)+"%":Yn.jsx(e,{id:"8Tg/JR",message:"Custom"})}),Yn.jsx(U,{size:18,checked:y,sx:{flexShrink:0}})]})]}),v&&Yn.jsxs(i,{sx:{mt:12,display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,typography:"h6",backgroundColor:T(l.palette.error.main,.1),color:l.palette.error.main},children:[Yn.jsx(i,{component:li.ErrorBorder,sx:{width:18,height:18}}),Yn.jsx(e,{id:"LHxwaD",message:"The fee tier should greater than {0}%",values:{0:100*TR}})]})]})]})}function SR({isExists:t,pair:n,pairAddress:o}){var a,s,d;const{isBalanceLoading:c,isDepositedLoading:u,balance:p,token0Deposited:h,token1Deposited:m,poolTokenPercentage:g}=function({pairAddress:e,pair:t}){var n;const{account:i}=dg(),o=null===(n=null==t?void 0:t.liquidityToken)||void 0===n?void 0:n.chainId,r=et(Object.assign(Object.assign({},kt(o,e,i)),{retry:!1})),a=et(Object.assign(Object.assign({},Tt(o,e)),{retry:!1})),[s,l,d]=H.useMemo((()=>{if(!t||!r.data||!a.data||a.data<r.data)return[void 0,void 0,void 0];const e=En.fromRawAmount(t.liquidityToken,a.data.toString()),n=En.fromRawAmount(t.liquidityToken,r.data.toString());return[new On(r.data.toString(),a.data.toString()),t.getLiquidityValue(t.token0,e,n,!1),t.getLiquidityValue(t.token1,e,n,!1)]}),[r.data,a.data,t]);return{isBalanceLoading:r.isLoading,isDepositedLoading:r.isLoading||a.isLoading,balance:r.data&&t?_m(r.data.toString(),t.liquidityToken.decimals):void 0,poolTokenPercentage:s?new Pe(s.toSignificant(6)):void 0,token0Deposited:l?new Pe(l.toSignificant()):void 0,token1Deposited:d?new Pe(d.toSignificant()):void 0}}({pairAddress:o,pair:n}),f=g?`${Em({input:g,showDecimals:2,roundingMode:Pe.ROUND_HALF_UP})}%`:void 0;return t&&n?Yn.jsxs(i,{sx:{px:20,py:12,borderWidth:1,borderRadius:8,borderStyle:"solid",borderColor:"border.main"},children:[Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),Yn.jsxs(i,{sx:{mt:12,display:"flex",alignItems:"center"},children:[Yn.jsx(kj,{width:18,height:18,tokens:[n.token0,n.token1],mr:4}),Yn.jsx(v,{loading:c,loadingProps:{width:50},sx:{mr:4},children:Am({input:p,decimals:null===(a=n.liquidityToken)||void 0===a?void 0:a.decimals})}),`${n.token0.symbol}/${n.token1.symbol} LP`,Yn.jsx(l,{title:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:10,typography:"body2",color:"text.primary"},children:[Yn.jsx(vI,{address:n.token0.address,chainId:n.token0.chainId,showName:null!==(s=n.token0.symbol)&&void 0!==s?s:"",size:14,offset:4,rightContent:Yn.jsx(v,{loading:u,loadingProps:{width:50},children:Am({input:h,decimals:n.token0.decimals})})}),Yn.jsx(vI,{address:n.token1.address,chainId:n.token1.chainId,showName:null!==(d=n.token1.symbol)&&void 0!==d?d:"",size:14,offset:4,rightContent:Yn.jsx(v,{loading:u,loadingProps:{width:50},children:Am({input:m,decimals:n.token1.decimals})})}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(e,{id:"c4miqE",message:"Pool share"}),Yn.jsx(v,{loading:u,loadingProps:{width:50},children:f})]})]}),sx:{padding:20,width:256},children:Yn.jsx(r,{component:li.DetailBorder,sx:{ml:4,width:16,height:16,cursor:"pointer"}})}),Yn.jsx(i,{component:"a",target:"_blank",rel:"noopener noreferrer",href:tg(n.liquidityToken.chainId,n.liquidityToken.address,"address"),sx:{ml:4,display:"inline-flex",height:16},children:Yn.jsx(r,{component:li.ArrowTopRightBorder,sx:{width:16,height:16}})})]})]}):null}function ER({sx:t,disabled:n,slippage:o,onChangeSlippage:r}){const s=a(),d=o===Jj,[c,u]=z(d?"":new Pe(o).times(100).toNumber());return Yn.jsx(l,{disabled:n,onlyClick:!0,title:Yn.jsxs(i,{sx:{backgroundColor:s.palette.background.paper,padding:s.spacing(16,20),borderRadius:16,width:375,maxWidth:"90vw",boxSizing:"border-box"},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.primary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"lqTDfd",message:"Slippage Tolerance"})}),Yn.jsxs("span",{children:[d?tC:o&&new Pe(o).times(100).toNumber(),"%"]})]}),Yn.jsxs(i,{sx:{mt:16,display:"flex",alignItems:"center",margin:s.spacing(16,0,0,0)},children:[Yn.jsx(Xj,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{u(""),r(Jj)},active:d}),Yn.jsx(b,{placeholder:String(tC),value:c,onChange:e=>{const{value:t}=e.target;u(t),r(t?new Pe(t).div(100).toNumber():Jj)},onBlur:()=>{(!d&&new Pe(o).gt(.1)||new Pe(o).lte(0))&&(u(10),r(.1))},suffix:Yn.jsx(i,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:Yn.jsx(_,{sx:Object.assign({width:"max-content",alignItems:"right",margin:s.spacing(0,0,0,"auto"),p:s.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast",cursor:"pointer"},t),children:Yn.jsx(i,{component:li.Setting,sx:{width:18,height:18,"& path:last-child":{fill:s.palette.text.primary}}})})})}function AR(){var t,n,o;const r=a(),[s,l]=H.useState(.003),[d,u]=H.useState(),[p,h]=H.useState(),[m,g]=H.useState(""),[f,x]=H.useState(""),[y,v]=H.useState(Jj),b=y===Jj?new Pe(tC).div(100).toNumber():y,{isMobile:j}=Tg(),{onlyChainId:C}=Jn(),w=H.useMemo((()=>C||(null==d?void 0:d.chainId)||(null==p?void 0:p.chainId)),[C,d,p]),{pairAddress:k,pair:T,price:I,isInvalidPair:S,invertedPrice:E,priceLoading:A,liquidityMinted:O,shareOfPool:L,isExists:R}=function({baseToken:e,quoteToken:t,baseAmount:n,quoteAmount:i,fee:o}){const[r,a,s]=H.useMemo((()=>{var n,i;if(!e||!t)return[null,null,!1];const o=we[e.chainId],r=(null===(n=o.address)||void 0===n?void 0:n.toLowerCase())===e.address.toLowerCase(),a=(null===(i=o.address)||void 0===i?void 0:i.toLowerCase())===t.address.toLowerCase(),s=r?o.wrappedTokenAddress:e.address,l=a?o.wrappedTokenAddress:t.address,d=s.toLowerCase()===l.toLowerCase();return d?[null,null,!0]:[new Sn(e.chainId,s,e.decimals,e.symbol,e.name),new Sn(t.chainId,l,t.decimals,t.symbol,t.name),d]}),[e,t]),l=H.useMemo((()=>{if(!r||!a||void 0===o)return;const e=r.chainId,t=e?lt(e)||wt(e):void 0;return t?ng({factoryAddress:t,tokenA:r,tokenB:a,fee:o}):void 0}),[r,a,o]),{pair:d,price:c,invertedPrice:u,reserveQuery:p,liquidityMinted:h,shareOfPool:m,isExists:g}=tS({pool:e&&t&&l?{baseToken:e,quoteToken:t,type:"AMMV2",address:l}:void 0,baseAmount:n,quoteAmount:i});return{pairAddress:l,pair:d,isInvalidPair:s,price:c,invertedPrice:u,priceLoading:p.isLoading,liquidityMinted:h,shareOfPool:m,isExists:g}}({baseToken:d,quoteToken:p,baseAmount:m,quoteAmount:f,fee:s}),P=wC(I);if(I&&m&&!I.isEqualTo(null!=P?P:0)&&R){const e=I.times(m).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18);e.isEqualTo(f)||x(e.toString())}const _=w?dt(w)||mt(w):void 0,M=lf(d,{amount:m,contractAddress:_}),B=lf(p,{amount:f,contractAddress:_}),[D,N]=H.useState(!1),F=!d||!p,U=QI({baseToken:d,quoteToken:p,baseAmount:m,quoteAmount:f,fee:s,isExists:R,slippage:b,successBack:()=>{Gj.getState().push({type:Zj.Pool,params:{tab:qS.myLiquidity}})}});return Q((()=>{console.error("createMutation.error",U.error)}),[U.error]),Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[r.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[Yn.jsx(XS,{onClick:()=>{Gj.getState().push({type:Zj.Pool})}}),Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:Yn.jsx(e,{id:"E6MqGy",message:"Add liquidity"})}),Yn.jsx(cT,{poolType:"AMM V2"})]}),Yn.jsxs(i,{sx:{pt:20,px:16,position:"relative",overflow:"hidden",backgroundColor:r.palette.background.paper,borderRadius:16,[r.breakpoints.up("tablet")]:{borderWidth:1,borderStyle:"solid",borderColor:"border.main",px:0,mx:"auto",width:600}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:20,[r.breakpoints.up("tablet")]:{pt:20,px:20,pb:20}},children:[Yn.jsx(SR,{pair:T,pairAddress:k,isExists:R}),Yn.jsxs(kR,{title:Yn.jsx(e,{id:"nxRg31",message:"Select pair"}),children:[Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:j?"repeat(1, 1fr)":"repeat(2, 1fr)",gap:12},children:[Yn.jsx(wR,{border:!0,highlightDefault:!0,chainId:w,token:d,onTokenChange:(e,t)=>{t?(u(p),h(d),g(""),x("")):(u(e),g(""))},occupiedToken:p}),Yn.jsx(wR,{border:!0,highlightDefault:!0,chainId:w,token:p,onTokenChange:(e,t)=>{t?(u(p),h(d)):(h(e),x(""))},occupiedToken:d})]}),(!w||Km(w))&&Yn.jsx(IR,{fee:s,onChange:l,feeList:[1e-4,5e-4,.003],hasCustom:!0,disabled:F})]}),Yn.jsx(kR,{title:Yn.jsx(e,{id:"MU9s7M",message:"Deposit amounts"}),disabled:F,children:Yn.jsxs(i,{children:[Yn.jsx(hj,{sx:{mb:4,pb:28,minHeight:"auto",backgroundColor:"background.cardInput",padding:r.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},token:d,amt:m,defaultLoadBalance:!0,onInputChange:e=>{var t;g(e);const n=Number(e);R&&I&&n&&x(I.times(e).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(n=null==p?void 0:p.address)&&void 0!==n?n:""],occupiedChainId:null==p?void 0:p.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:F}),Yn.jsx(uj,{}),Yn.jsx(hj,{sx:{pb:20,minHeight:"auto",backgroundColor:"background.cardInput",padding:r.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},token:p,amt:f,defaultLoadBalance:!0,onInputChange:e=>{var t;x(e);const n=Number(e);R&&E&&n&&g(E.times(e).dp(null!==(t=null==d?void 0:d.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(o=null==d?void 0:d.address)&&void 0!==o?o:""],occupiedChainId:null==d?void 0:d.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:F}),Yn.jsx(ER,{slippage:y,onChangeSlippage:v,disabled:F,sx:{mt:8}}),Yn.jsx(VI,{baseToken:d,quoteToken:p,loading:A,midPrice:I,shareOfPool:L}),!!R&&Yn.jsxs(i,{sx:{mt:20,p:20,borderRadius:16,backgroundColor:"background.paperContrast",typography:"h6",textAlign:"center","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",Yn.jsx("b",{children:Yn.jsx(e,{id:"e38JNU",message:"Tips:"})})," ",Yn.jsx(e,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vm({input:s})},components:{0:Yn.jsx("b",{})}})]})]})})]}),Yn.jsx(i,{sx:{mt:20,py:16,[r.breakpoints.up("tablet")]:{px:20}},children:Yn.jsx(cC,{fullWidth:!0,includeButton:!0,size:c.Size.big,disabled:F,chainId:w,children:Yn.jsx(CR,{statuses:[M,B],buttonProps:{size:c.Size.big},children:Yn.jsx(c,{fullWidth:!0,size:c.Size.big,disabled:!(d&&p&&m&&f&&!S&&s),onClick:()=>N(!0),children:S?Yn.jsx(e,{id:"R7D79P",message:"Invalid pair"}):Yn.jsx(e,{id:"bwSQI0",message:"Supply"})})})})}),Yn.jsx(WI,{open:D,onClose:()=>N(!1),slippage:b,baseToken:d,baseAmount:m,quoteToken:p,quoteAmount:f,fee:s,price:I,lpAmount:O,shareOfPool:L,pairAddress:k,createMutation:U})]})]})}const OR=({disabled:e,feeAmount:t,dispatch:n})=>{const o=a(),{isMobile:r}=Tg(),[s,l]=z(!1);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderStyle:"solid",borderColor:o.palette.border.main,borderRadius:12},e?{opacity:.3}:void 0),children:[Yn.jsx(i,{sx:{typography:"h5",color:o.palette.text.primary},children:t?`${dT[t].label} ${se._({id:"fxRyGG",message:"fee tier"})}`:se._({id:"EU3wU4",message:"Fee tier"})}),Yn.jsx(c,{size:c.Size.small,variant:c.Variant.outlined,disabled:e,onClick:()=>l((e=>!e)),sx:{color:o.palette.text.primary,border:`solid 1px ${o.palette.text.primary}`},children:s?se._({id:"vLyv1R",message:"Hide"}):se._({id:"ePK91l",message:"Edit"})})]}),s&&Yn.jsx(i,{sx:Object.assign({},r?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8}),children:[XC.LOWEST,XC.LOW,XC.MEDIUM,XC.HIGH].map((i=>{const r=t===i;return Yn.jsxs(c,{size:c.Size.middle,variant:c.Variant.outlined,disabled:e,onClick:()=>{n({type:ET.UpdateFeeAmount,payload:i})},sx:{flexBasis:"50%",flexShrink:1,flexGrow:1,justifyContent:"space-between",px:20,color:r?o.palette.primary.main:o.palette.text.primary,borderRadius:12,borderColor:r?o.palette.primary.main:o.palette.border.main,[o.breakpoints.up("tablet")]:{flexBasis:"25%"}},children:[dT[i].label,r?Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[Yn.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:o.palette.primary.main}),Yn.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:o.palette.primary.main,stroke:o.palette.primary.main})]}):Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Yn.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:o.palette.text.secondary})})]},i)}))})]})},LR={neutral1:"#222222",neutral2:"#7D7D7D",accent1:"#FC72FF",critical:"FF5F52",white:"#FFFFFF",surface3:"#22222212",opacity:{hover:.6,click:.4,disabled:.5,enabled:1}},RR=({series:e,xScale:t,yScale:n,xValue:o,yValue:r,fill:a})=>$((()=>{var s;return Yn.jsx(i,{component:"path",opacity:.5,stroke:null!=a?a:LR.accent1,fill:null!=a?a:LR.accent1,d:null!==(s=Rn().curve(Pn).x((e=>t(o(e)))).y1((e=>n(r(e)))).y0(n(0))(e.filter((e=>{const n=t(o(e));return n>0&&n<=window.innerWidth}))))&&void 0!==s?s:void 0})}),[a,e,t,o,n,r]),PR=({axisGenerator:e})=>Yn.jsx("g",{ref:t=>{t&&Mn(t).call(e).call((e=>e.select(".domain").remove()))}}),_R=({xScale:e,innerHeight:t,offset:n=0})=>$((()=>Yn.jsx(i,{component:"g",transform:`translate(0, ${t+n})`,sx:{"& line":{display:"none"},"& text":{color:LR.neutral2,transform:"translateY(5px)"}},children:Yn.jsx(PR,{axisGenerator:_n(e).ticks(6)})})),[t,n,e]),MR=e=>["M 0 0",`v ${e}`,"m 1 0","V 0","M 0 1","h 12","q 2 0, 2 2","v 22","q 0 2 -2 2","h -12","z"].join(" "),BR=()=>["m 5 7","v 14","M 0 0","m 9 7","v 14","z"].join(" "),DR=({color:e,size:t=10,margin:n=10})=>Yn.jsx("polygon",{points:`0 0, ${t} ${t}, 0 ${t}`,transform:` translate(${t+n}, ${n}) rotate(45) `,fill:e,stroke:e,strokeWidth:"4",strokeLinejoin:"round"});const NR=({color:e,d:t})=>Yn.jsx(i,{component:"path",cursor:"ew-resize",pointerEvents:"none",strokeWidth:3,stroke:e,fill:e,d:t}),FR=({d:e})=>Yn.jsx(i,{component:"path",cursor:"ew-resize",pointerEvents:"none",stroke:LR.white,opacity:LR.opacity.hover,d:e}),UR=({visible:e,transform:t,children:n})=>Yn.jsx(i,{component:"g",opacity:e?"1":"0",transform:t,sx:{transition:"opacity 300ms"},children:n}),qR=({y:e,x:t,height:n,width:o,rx:r})=>Yn.jsx(i,{component:"rect",fill:LR.surface3,y:e,x:t,height:n,width:o,rx:r}),VR=({y:e,transform:t,dominantBaseline:n,children:o})=>Yn.jsx(i,{component:"text",y:e,textAnchor:"middle",fontSize:"13px",fill:LR.neutral1,transform:t,dominantBaseline:n,children:o}),WR=(e,t,n)=>{const i=e.map((e=>n(e).toFixed(1))),o=t.map((e=>n(e).toFixed(1)));return i.every(((e,t)=>e===o[t]))},HR=({id:e,xScale:t,interactive:n,brushLabelValue:i,brushExtent:o,setBrushExtent:r,innerWidth:a,innerHeight:s,westHandleColor:l,eastHandleColor:d})=>{const c=G(null),u=G(null),[p,h]=z(o),[m,g]=z(!1),[f,x]=z(!1),y=function(e){const t=G();return Q((()=>{t.current=e}),[e]),t.current}(o),v=Z((e=>{const{type:n,selection:i,mode:a}=e;if(!i)return void h(null);const s=i.map(t.invert);"end"!==n||WR(o,s,t)||r(s,a),h(s)}),[t,o,r]);Q((()=>{h(o)}),[o]),Q((()=>{c.current&&(u.current=Bn().extent([[Math.max(2,t(0)),0],[a-2,s]]).handleSize(30).filter((()=>n)).on("brush end",v),u.current(Mn(c.current)),y&&WR(o,y,t)&&Mn(c.current).transition().call(u.current.move,o.map(t)),Mn(c.current).selectAll(".selection").attr("stroke","none").attr("fill-opacity","0.1").attr("fill",`url(#${e}-gradient-selection)`))}),[o,v,e,s,a,n,y,t]),Q((()=>{c.current&&u.current&&u.current.move(Mn(c.current),o.map(t))}),[o,t]),Q((()=>{g(!0);const e=setTimeout((()=>g(!1)),1500);return()=>clearTimeout(e)}),[p]);const b=p&&t(p[0])>20,j=p&&t(p[1])>a-20,C=p&&(t(p[0])<0||t(p[1])<0),w=p&&(t(p[0])>a||t(p[1])>a),k=p&&t(p[0])>=0&&t(p[0])<=a,T=p&&t(p[1])>=0&&t(p[1])<=a;return $((()=>Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("defs",{children:[Yn.jsxs("linearGradient",{id:`${e}-gradient-selection`,x1:"0%",y1:"100%",x2:"100%",y2:"100%",children:[Yn.jsx("stop",{stopColor:l}),Yn.jsx("stop",{stopColor:d,offset:"1"})]}),Yn.jsx("clipPath",{id:`${e}-brush-clip`,children:Yn.jsx("rect",{x:"0",y:"0",width:a,height:s})})]}),Yn.jsx("g",{ref:c,clipPath:`url(#${e}-brush-clip)`,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1)}),p&&Yn.jsxs(Yn.Fragment,{children:[k?Yn.jsxs("g",{transform:`translate(${Math.max(0,t(p[0]))}, 0), scale(${b?"-1":"1"}, 1)`,children:[Yn.jsxs("g",{children:[Yn.jsx(NR,{color:l,d:MR(s)}),Yn.jsx(FR,{d:BR()})]}),Yn.jsxs(UR,{transform:`translate(50,0), scale(${b?"1":"-1"}, 1)`,visible:m||f,children:[Yn.jsx(qR,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),Yn.jsx(VR,{transform:"scale(-1, 1)",y:"15",dominantBaseline:"middle",children:i("w",p[0])})]})]}):null,T?Yn.jsxs("g",{transform:`translate(${t(p[1])}, 0), scale(${j?"-1":"1"}, 1)`,children:[Yn.jsxs("g",{children:[Yn.jsx(NR,{color:d,d:MR(s)}),Yn.jsx(FR,{d:BR()})]}),Yn.jsxs(UR,{transform:`translate(50,0), scale(${j?"-1":"1"}, 1)`,visible:m||f,children:[Yn.jsx(qR,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),Yn.jsx(VR,{y:"15",dominantBaseline:"middle",children:i("e",p[1])})]})]}):null,C&&Yn.jsx(DR,{color:l}),w&&Yn.jsx("g",{transform:`translate(${a}, 0) scale(-1, 1)`,children:Yn.jsx(DR,{color:d})})]})]})),[i,d,T,j,b,f,e,s,a,p,w,m,C,l,k,t])},$R=({value:e,xScale:t,innerHeight:n})=>$((()=>Yn.jsx(i,{component:"line",x1:t(e),y1:"0",x2:t(e),y2:n,sx:{opacity:.5,strokeWidth:2,stroke:LR.neutral1,fill:"none"}})),[e,t,n]);function zR({svg:e,xScale:t,setZoom:n,width:o,height:r,resetBrush:a,showResetButton:s,zoomLevels:l}){const d=G(),[u,p,h,m]=$((()=>[()=>e&&d.current&&Mn(e).transition().call(d.current.scaleBy,2),()=>e&&d.current&&Mn(e).transition().call(d.current.scaleBy,.5),()=>e&&d.current&&Mn(e).transition().call(d.current.scaleTo,.5),()=>e&&d.current&&Mn(e).call(d.current.transform,Dn.translate(0,0).scale(1)).transition().call(d.current.scaleTo,.5)]),[e]);return Q((()=>{e&&(d.current=Nn().scaleExtent([l.min,l.max]).extent([[0,0],[o,r]]).on("zoom",(({transform:e})=>n(e))),Mn(e).call(d.current))}),[r,o,n,e,t,d,l,l.max,l.min]),Q((()=>{h()}),[h,l]),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:`repeat(${s?3:2}, 1fr)`,gridGap:"6px",position:"absolute",top:"-32px",right:0},children:[s&&Yn.jsx(c,{size:c.Size.small,sx:{borderRadius:16},onClick:()=>{a(),m()},disabled:!1,children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("polyline",{points:"1 4 1 10 7 10"}),Yn.jsx("polyline",{points:"23 20 23 14 17 14"}),Yn.jsx("path",{d:"M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"})]})}),Yn.jsx(c,{size:c.Size.small,sx:{borderRadius:16},onClick:u,disabled:!1,children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("circle",{cx:"11",cy:"11",r:"8"}),Yn.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Yn.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Yn.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),Yn.jsx(c,{size:c.Size.small,sx:{borderRadius:16},onClick:p,disabled:!1,children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("circle",{cx:"11",cy:"11",r:"8"}),Yn.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Yn.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]})}const ZR=e=>e.price0,GR=e=>e.activeLiquidity;function QR({id:e="liquidityChartRangeInput",data:{series:t,current:n},ticksAtLimit:o,styles:r,dimensions:{width:a,height:s},margins:l,interactive:d=!0,brushDomain:c,brushLabels:u,onBrushDomainChange:p,zoomLevels:h}){const m=G(null),[g,f]=z(null),[x,y]=$((()=>[s-l.top-l.bottom,a-l.left-l.right]),[a,s,l]),{xScale:v,yScale:b}=$((()=>{const e={xScale:Fn().domain([n*h.initialMin,n*h.initialMax]).range([0,y]),yScale:Fn().domain([0,Un(t,GR)]).range([x,0])};if(g){const t=g.rescaleX(e.xScale);e.xScale.domain(t.domain())}return e}),[n,h.initialMin,h.initialMax,y,t,x,g]);return Q((()=>{f(null)}),[h]),Q((()=>{c||p(v.domain(),void 0)}),[c,p,v]),Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(zR,{svg:m.current,xScale:v,setZoom:f,width:y,height:s,resetBrush:()=>{p([n*h.initialMin,n*h.initialMax],"reset")},showResetButton:Boolean(o[dC.LOWER]||o[dC.UPPER]),zoomLevels:h}),Yn.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${a} ${s}`,style:{overflow:"visible"},children:[Yn.jsxs("defs",{children:[Yn.jsx("clipPath",{id:`${e}-chart-clip`,children:Yn.jsx("rect",{x:"0",y:"0",width:y,height:s})}),c&&Yn.jsx("mask",{id:`${e}-chart-area-mask`,children:Yn.jsx("rect",{fill:"white",x:v(c[0]),y:"0",width:v(c[1])-v(c[0]),height:x})})]}),Yn.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[Yn.jsxs("g",{clipPath:`url(#${e}-chart-clip)`,children:[Yn.jsx(RR,{series:t,xScale:v,yScale:b,xValue:ZR,yValue:GR}),c&&Yn.jsx("g",{mask:`url(#${e}-chart-area-mask)`,children:Yn.jsx(RR,{series:t,xScale:v,yScale:b,xValue:ZR,yValue:GR,fill:r.area.selection})}),Yn.jsx($R,{value:n,xScale:v,innerHeight:x}),Yn.jsx(_R,{xScale:v,innerHeight:x})]}),Yn.jsx(i,{component:"rect",width:y,height:s,ref:m,sx:{fill:"transparent",cursor:"grab","&:active":{cursor:"grabbing"}}}),Yn.jsx(HR,{id:e,xScale:v,interactive:d,brushLabelValue:u,brushExtent:null!=c?c:v.domain(),innerWidth:y,innerHeight:x,setBrushExtent:p,westHandleColor:r.brush.handle.west,eastHandleColor:r.brush.handle.east})]})]})]})}const YR=8;function KR(e,t,n,i,o,r){var a,s,l,d,c;let u=Object.assign({},n),p=[];for(let n=o+(r?1:-1);r?n<i.length:n>=0;r?n++:n--){const o=Number(null===(a=i[n])||void 0===a?void 0:a.tickIdx),h=Dk(e,t,o),m={liquidityActive:u.liquidityActive,tick:o,liquidityNet:wn.BigInt(null!==(l=null===(s=i[n])||void 0===s?void 0:s.liquidityNet)&&void 0!==l?l:""),price0:h.toFixed(YR),sdkPrice:h};r?m.liquidityActive=wn.add(u.liquidityActive,wn.BigInt(null!==(c=null===(d=i[n])||void 0===d?void 0:d.liquidityNet)&&void 0!==c?c:0)):!r&&wn.notEqual(u.liquidityNet,wn.BigInt(0))&&(m.liquidityActive=wn.subtract(u.liquidityActive,u.liquidityNet)),p.push(m),u=m}return r||(p=p.reverse()),p}const XR=8,JR=(e,t)=>e&&t?Math.floor(e/JC[t])*JC[t]:void 0,eP=1e3;function tP(e,t,n,i){const[o,r]=z(0),[a,s]=z([]),{data:l,error:d,isLoading:c}=function(e,t,n,i=0,o){var r;const a=gg(),s=e&&t&&n?Vk.getAddress(null==e?void 0:e.wrapped,null==t?void 0:t.wrapped,n,void 0,o?SC[o]:void 0):void 0,l=a.getQuery(ve.graphql.AllV3TicksDocument,{skip:i,first:eP,where:{chain:o?Wu[o]:void 0,poolAddress:null!==(r=null==s?void 0:s.toLowerCase())&&void 0!==r?r:void 0,refreshNow:!0,schemaName:"ammv3"}});return et(Object.assign(Object.assign({},l),{enabled:!0}))}(e,t,n,o,i),u=null==l?void 0:l.ticks;return Q((()=>{(null==u?void 0:u.length)&&(s((e=>[...e,...u])),(null==u?void 0:u.length)===eP&&r((e=>e+eP)))}),[u]),{isLoading:c||(null==u?void 0:u.length)===eP,error:d,ticks:a}}function nP({currencyA:e,currencyB:t,feeAmount:n,chainId:i}){const{isLoading:o,error:r,data:a}=function(e,t,n,i){var o,r,a;const s=xT(e,t,n),l=null===(o=s[1])||void 0===o?void 0:o.liquidity,d=null===(r=s[1])||void 0===r?void 0:r.sqrtRatioX96,c=null===(a=s[1])||void 0===a?void 0:a.tickCurrent,u=$((()=>JR(c,n)),[c,n]),{isLoading:p,error:h,ticks:m}=tP(e,t,n,i);return $((()=>{var n,i,o,r,a;if(!e||!t||void 0===u||s[0]!==fT.EXISTS||!m||0===m.length||p)return{isLoading:p||s[0]===fT.LOADING,error:h,activeTick:u,data:void 0};const g=null==e?void 0:e.wrapped,f=null==t?void 0:t.wrapped,x=m.findIndex((e=>(null==e?void 0:e.tickIdx)&&e.tickIdx>u))-1;if(x<0)return console.log("usePoolTickData","usePoolActiveLiquidity","TickData pivot not found",{token0:g.address,token1:f.address,chainId:g.chainId}),{isLoading:p,error:h,activeTick:u,data:void 0};const y=Dk(g,f,u),v={liquidityActive:wn.BigInt(null!==(i=null===(n=s[1])||void 0===n?void 0:n.liquidity)&&void 0!==i?i:0),tick:u,liquidityNet:Number(null===(o=m[x])||void 0===o?void 0:o.tickIdx)===u?wn.BigInt(null!==(a=null===(r=m[x])||void 0===r?void 0:r.liquidityNet)&&void 0!==a?a:0):wn.BigInt(0),price0:y.toFixed(XR),sdkPrice:y},b=KR(g,f,v,m,x,!0),j=KR(g,f,v,m,x,!1).concat(v).concat(b);return{isLoading:p,error:h,currentTick:c,activeTick:u,liquidity:l,sqrtPriceX96:d,data:j}}),[e,t,u,s,m,p,h,c,l,d])}(e,t,n,i),s=Z((()=>{if(!(null==a?void 0:a.length))return;const e=[];for(let t=0;t<a.length;t++){const n=a[t],i={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};i.activeLiquidity>0&&e.push(i)}return e}),[a]);return $((()=>({isLoading:o,error:r,formattedData:o?void 0:s()})),[o,r,s])}const iP={initialMin:.999,initialMax:1.001,min:1e-5,max:1.5},oP={[XC.LOWEST]:iP,[XC.LOW_200]:iP,[XC.LOW_300]:iP,[XC.LOW_400]:iP,[XC.LOW]:iP,[XC.MEDIUM]:{initialMin:.5,initialMax:2,min:1e-5,max:20},[XC.HIGH]:{initialMin:.5,initialMax:2,min:1e-5,max:20}};function rP({message:e,icon:t}){return Yn.jsxs(gC,{style:{height:"100%",justifyContent:"center"},children:[t,e&&Yn.jsx(i,{sx:{mt:20,p:10,typography:"caption",textAlign:"center"},children:e})]})}function aP(){return Yn.jsx(v,{})}function sP({chainId:t,currencyA:n,currencyB:o,feeAmount:r,ticksAtLimit:a,price:s,priceLower:l,priceUpper:d,onLeftRangeInput:c,onRightRangeInput:u,interactive:p}){const h=n&&o&&(null==n?void 0:n.wrapped.sortsBefore(null==o?void 0:o.wrapped)),{isLoading:m,error:g,formattedData:f}=nP({currencyA:n,currencyB:o,feeAmount:r,chainId:t}),x=Z(((e,t)=>{let n=Number(e[0]);const i=Number(e[1]);n<=0&&(n=1/10**6),(!a[h?dC.LOWER:dC.UPPER]||"handle"===t||"reset"===t)&&n>0&&c(n.toFixed(6)),(!a[h?dC.UPPER:dC.LOWER]||"reset"===t)&&i>0&&i<1e35&&u(i.toFixed(6))}),[h,c,u,a]);p=p&&Boolean(null==f?void 0:f.length);const y=$((()=>{const e=h?l:null==d?void 0:d.invert(),t=h?d:null==l?void 0:l.invert();return e&&t?[parseFloat(null==e?void 0:e.toSignificant(6)),parseFloat(null==t?void 0:t.toSignificant(6))]:void 0}),[h,l,d]),v=Z(((e,t)=>{if(!s)return"";if("w"===e&&a[h?dC.LOWER:dC.UPPER])return"0";if("e"===e&&a[h?dC.UPPER:dC.LOWER])return"∞";const n=(t<s?-1:1)*((Math.max(t,s)-Math.min(t,s))/s)*100;return s?`${Am({input:n,decimals:2})}%`:""}),[h,s,a]),b=!n||!o||void 0===f&&!m&&!g;return Yn.jsx(fC,{gap:"md",style:{minHeight:"200px"},children:b?Yn.jsx(rP,{message:Yn.jsx(e,{id:"OZUH85",message:"Your position will appear here."}),icon:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:LR.neutral1,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),Yn.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]})}):m?Yn.jsx(aP,{}):g?Yn.jsx(rP,{message:Yn.jsx(e,{id:"79D0qY",message:"Liquidity data not available."}),icon:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:LR.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("path",{d:"M22.61 16.95A5 5 0 0 0 18 10h-1.26a8 8 0 0 0-7.05-6M5 5a8 8 0 0 0 4 15h9a5 5 0 0 0 1.7-.3"}),Yn.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}):f&&0!==f.length&&s?Yn.jsx(i,{sx:{position:"relative",width:"100%",maxHeight:"200px",justifyContent:"center",alignContent:"center"},children:Yn.jsx(QR,{data:{series:f,current:s},dimensions:{width:560,height:200},margins:{top:10,right:2,bottom:20,left:0},styles:{area:{selection:LR.accent1},brush:{handle:{west:LR.critical,east:LR.accent1}}},interactive:p,brushLabels:v,brushDomain:y,onBrushDomainChange:x,zoomLevels:oP[null!=r?r:XC.MEDIUM],ticksAtLimit:a})}):Yn.jsx(rP,{message:Yn.jsx(e,{id:"rH6vg9",message:"There is no liquidity data."}),icon:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:LR.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),Yn.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),Yn.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})})})}const lP=({value:t,decrement:n,increment:o,decrementDisabled:r=!1,incrementDisabled:s=!1,locked:l,onUserInput:d,title:u,tokenA:p,tokenB:h})=>{const m=a(),[g,f]=z(!1),[x,y]=z(""),[v,b]=z(!1),[j,C]=z(!1),w=Z((()=>{b(!1),f(!1),d(x)}),[x,d]),k=Z((()=>{b(!1),d(n())}),[n,d]),T=Z((()=>{b(!1),d(o())}),[o,d]);return Q((()=>{x===t||v||setTimeout((()=>{y(t),C(!0),setTimeout((function(){C(!1)}),1800)}),0)}),[x,v,t]),Yn.jsx(i,{onFocus:()=>{b(!0),f(!0)},onBlur:w,sx:{width:"100%",py:12,px:20,borderRadius:16,backgroundColor:m.palette.background.cardInput},children:Yn.jsxs(i,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:m.palette.text.primary},children:u}),Yn.jsx(i,{sx:{mt:4,typography:"h6",fontWeight:500,color:m.palette.text.secondary},children:Yn.jsx(e,{id:"1/LP4K",message:"{tokenB} per {tokenA}",values:{tokenB:h,tokenA:p}})}),Yn.jsx(Db,{sx:{mt:12,backgroundColor:m.palette.background.cardInput},value:x,onChange:e=>{y(e)},readOnly:l})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[!l&&Yn.jsx(c,{size:c.Size.small,onClick:T,disabled:s,sx:{px:4,backgroundColor:m.palette.background.paper,"&[disabled]":{cursor:"default"}},children:Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M14.25 9.75H9.75V14.25H8.25V9.75H3.75V8.25H8.25V3.75H9.75V8.25H14.25V9.75Z",fill:r?m.palette.text.disabled:m.palette.text.primary})})}),!l&&Yn.jsx(c,{size:c.Size.small,onClick:k,disabled:r,sx:{px:4,backgroundColor:m.palette.background.paper,"&[disabled]":{cursor:"default"}},children:Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("rect",{x:"3.75",y:"8.25",width:"10.5",height:"1.5",fill:r?m.palette.text.disabled:m.palette.text.primary})})})]})]})})},dP=({priceLower:t,priceUpper:n,onLeftRangeInput:o,onRightRangeInput:r,getDecrementLower:a,getIncrementLower:s,getDecrementUpper:l,getIncrementUpper:d,currencyA:c,currencyB:u,feeAmount:p,ticksAtLimit:h})=>{var m,g,f,x;const y=null===(m=null!=c?c:void 0)||void 0===m?void 0:m.wrapped,v=null===(g=null!=u?u:void 0)||void 0===g?void 0:g.wrapped,b=y&&v&&y.sortsBefore(v),j=b?t:null==n?void 0:n.invert(),C=b?n:null==t?void 0:t.invert();return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[Yn.jsx(lP,{value:h[b?dC.LOWER:dC.UPPER]?"0":null!==(f=null==j?void 0:j.toSignificant(8))&&void 0!==f?f:"",onUserInput:o,decrement:b?a:d,increment:b?s:l,decrementDisabled:void 0===j||h[b?dC.LOWER:dC.UPPER],incrementDisabled:void 0===j||h[b?dC.LOWER:dC.UPPER],feeAmount:p,label:j?`${null==u?void 0:u.symbol}`:"-",title:Yn.jsx(e,{id:"uEoBVI",message:"Low price"}),tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol}),Yn.jsx(lP,{value:h[b?dC.UPPER:dC.LOWER]?"∞":null!==(x=null==C?void 0:C.toSignificant(8))&&void 0!==x?x:"",onUserInput:r,decrement:b?l:s,increment:b?d:a,incrementDisabled:void 0===C||h[b?dC.UPPER:dC.LOWER],decrementDisabled:void 0===C||h[b?dC.UPPER:dC.LOWER],feeAmount:p,label:C?`${null==u?void 0:u.symbol}`:"-",tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol,title:Yn.jsx(e,{id:"kAC8rT",message:"High price"})})]})};var cP;function uP(){return uP=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uP.apply(null,arguments)}const pP=e=>W.createElement("svg",uP({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),cP||(cP=W.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},W.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function hP({chainId:e,token:t,oppositeTokenAddress:n,dispatch:o,tokenSelectOnChange:r}){const s=a(),[l,c]=z(!1);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:{flexBasis:"100%",flexGrow:1,flexShrink:1,display:"flex",alignItems:"center",px:20,py:8,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:t?s.palette.border.main:s.palette.primary.main,color:t?s.palette.text.primary:s.palette.primary.contrastText,backgroundColor:t?"transparent":s.palette.primary.main,"&:hover":{borderColor:t?s.palette.border.main:s.palette.primary.main,opacity:.8},[s.breakpoints.up("tablet")]:{flexBasis:"50%"}},onClick:()=>{c(!0)},children:[t?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:t.address,marginRight:0,width:24,height:24,chainId:t.chainId||e,noShowChain:!0,sx:{flexShrink:0}}),Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:t.symbol})]}):Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:se._({id:"0RrIzN",message:"Select token"})}),Yn.jsx(i,{component:pP,sx:{flexShrink:0,ml:"auto",width:18,height:18}})]}),Yn.jsx(Xb,{value:wT(t),open:l,chainId:e,occupiedAddrs:[n],occupiedChainId:null==t?void 0:t.chainId,onClose:()=>{c(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return o({type:ET.UpdateBaseTokenAndClearQuoteToken,payload:e}),void c(!1);r(e),c(!1)}},modal:!0})]})}const mP=({chainId:e,baseToken:t,quoteToken:n,dispatch:o})=>{var r,s;const l=a();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",[l.breakpoints.up("tablet")]:{flexWrap:"nowrap"}},children:[Yn.jsx(hP,{chainId:e,token:t,oppositeTokenAddress:null!==(r=null==n?void 0:n.address)&&void 0!==r?r:"",dispatch:o,tokenSelectOnChange:e=>{o({type:ET.UpdateBaseToken,payload:e})}}),Yn.jsx(hP,{chainId:e,token:n,oppositeTokenAddress:null!==(s=null==t?void 0:t.address)&&void 0!==s?s:"",dispatch:o,tokenSelectOnChange:e=>{o({type:ET.UpdateQuoteToken,payload:e})}})]})};const gP=[{value:.03,title:"Narrow"},{value:.08,title:"Standard"},{value:.15,title:"Wide"},{value:1,title:"Full"}],fP=e=>{const t=a(),[n,o]=z(null);return Yn.jsx(i,{sx:{borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:t.palette.border.main,overflow:"hidden",display:"flex",alignItems:"center",flexWrap:"wrap",alignSelf:"stretch"},children:gP.map(((r,a)=>Yn.jsxs(i,{component:d,onClick:()=>{o(r.value),e.onSelect(r.value)},sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",px:20,py:12,gap:8,flexBasis:"50%",flexGrow:1,borderRight:a%2==0?`1px solid ${t.palette.border.main}`:"none",borderBottom:a<=1?`1px solid ${t.palette.border.main}`:"none",[t.breakpoints.up("tablet")]:{flexBasis:"25%",borderRight:a===gP.length-1?"none":`1px solid ${t.palette.border.main}`,borderBottom:"none"},backgroundColor:n===r.value?T("#7BF179",.1):"transparent","&:hover":{backgroundColor:T("#7BF179",.1)}},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:t.palette.text.primary},children:r.title}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:600,color:t.palette.text.primary},children:1===r.value?"∞":`+-${100*r.value}%`})]},r.value)))})};function xP({params:t,handleGoBack:n,handleGoToPoolList:o}){var r,s,l,d,c,u,p,h,m,g;const{account:f,onlyChainId:x,defaultChainId:y}=dg(),v=null!=x?x:y,b=a(),j=Fg(),{isMobile:C}=Tg(),w=et(Object.assign({},ip.getFetchTokenQuery(v,null==t?void 0:t.from,f))),k=et(Object.assign({},ip.getFetchTokenQuery(v,null==t?void 0:t.to,f))),[I,S]=ee(AT,{baseToken:null,quoteToken:null,feeAmount:(null==t?void 0:t.fee)?Number(null==t?void 0:t.fee):void 0,independentField:lC.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""});Q((()=>{w.data&&S({type:ET.UpdateDefaultBaseToken,payload:w.data})}),[w]),Q((()=>{k.data&&S({type:ET.UpdateDefaultQuoteToken,payload:k.data})}),[k]);const{independentField:E,typedValue:A,startPriceTypedValue:O}=I,{pool:L,ticks:R,dependentField:P,price:_,pricesAtTicks:M,pricesAtLimit:B,parsedAmounts:D,currencyBalances:N,position:F,noLiquidity:U,currencies:q,errorMessage:V,invalidPool:W,invalidRange:H,outOfRange:G,depositADisabled:Y,depositBDisabled:K,invertPrice:X,ticksAtLimit:J,isTaxed:te}=ST({state:I,chainId:v}),ne=$((()=>{var e;return null===(e=X?null==_?void 0:_.invert():_)||void 0===e?void 0:e.toSignificant()}),[X,_]),{onFieldAInput:ie,onFieldBInput:oe,onLeftRangeInput:re,onRightRangeInput:ae,onStartPriceInput:le}=OT({noLiquidity:U,dispatch:S}),{slipper:de,setSlipper:ce,slipperValue:ue,resetSlipper:pe}=oC({address:void 0,type:"AMMV3"}),he=!V&&!H,[me,ge]=z(!1),fe={[E]:A,[P]:null!==(s=null===(r=D[P])||void 0===r?void 0:r.toSignificant(6))&&void 0!==s?s:""},xe=[lC.CURRENCY_A,lC.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:_T(N[t])})),{}),ye=lf(wT(null===(l=D[lC.CURRENCY_A])||void 0===l?void 0:l.currency),{contractAddress:EC[v],overrideBalance:N[lC.CURRENCY_A]?new Pe(N[lC.CURRENCY_A].toSignificant()):void 0,amount:D[lC.CURRENCY_A]?new Pe(D[lC.CURRENCY_A].toSignificant()):void 0}),ve=lf(wT(null===(d=D[lC.CURRENCY_B])||void 0===d?void 0:d.currency),{contractAddress:EC[v],overrideBalance:N[lC.CURRENCY_B]?new Pe(N[lC.CURRENCY_B].toSignificant()):void 0,amount:D[lC.CURRENCY_B]?new Pe(D[lC.CURRENCY_B].toSignificant()):void 0}),{[dC.LOWER]:be,[dC.UPPER]:je}=R,{[dC.LOWER]:Ce,[dC.UPPER]:we}=M,{getDecrementLower:ke,getIncrementLower:Te,getDecrementUpper:Ie,getIncrementUpper:Se,getSetFullRange:Ee}=function({tickLower:e,tickUpper:t,pool:n,state:i,dispatch:o}){const{baseToken:r,quoteToken:a,feeAmount:s}=i,l=$((()=>null==r?void 0:r.wrapped),[r]),d=$((()=>null==a?void 0:a.wrapped),[a]);return{getDecrementLower:Z((()=>l&&d&&"number"==typeof e&&s?Dk(l,d,e-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof e&&l&&d&&s&&n?Dk(l,d,n.tickCurrent-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,e,s,n]),getIncrementLower:Z((()=>l&&d&&"number"==typeof e&&s?Dk(l,d,e+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof e&&l&&d&&s&&n?Dk(l,d,n.tickCurrent+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,e,s,n]),getDecrementUpper:Z((()=>l&&d&&"number"==typeof t&&s?Dk(l,d,t-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof t&&l&&d&&s&&n?Dk(l,d,n.tickCurrent-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,t,s,n]),getIncrementUpper:Z((()=>l&&d&&"number"==typeof t&&s?Dk(l,d,t+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof t&&l&&d&&s&&n?Dk(l,d,n.tickCurrent+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,t,s,n]),getSetFullRange:Z((()=>{o({type:ET.setFullRange,payload:void 0})}),[o])}}({tickLower:be,tickUpper:je,pool:L,state:I,dispatch:S}),Ae=Z((e=>{if(Ee(),1!==e){if(ne){const t=new Pe(ne),n=t.multipliedBy(1-e),i=t.multipliedBy(1+e);re(n.dp(5,Pe.ROUND_DOWN).toString()),ae(i.dp(5,Pe.ROUND_DOWN).toString())}return}const t=B[dC.LOWER];t&&re(t.toSignificant(5));const n=B[dC.UPPER];n&&ae(n.toSignificant(5))}),[ne,Ee,re,ae,B]),{deadLine:Oe}=Jn(),Le=it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){if(!f||!v||!F)return;if(!I.baseToken||!I.quoteToken)return;const e=Math.ceil(Date.now()/1e3)+(null!=Oe?Oe:600),t=I.baseToken.isNative?I.baseToken:I.quoteToken.isNative?I.quoteToken:void 0;try{const{calldata:n,value:i}=eT.addCallParameters(F,{slippageTolerance:DT(100*ue),recipient:f,deadline:e.toString(),useNative:t,createPool:U});let r={to:EC[v],data:n,value:i};(yield j.execute(se._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Pg.TX},r),{early:!1,metadata:{[Sg.createAMMV3Pool]:"1"}}))===Eg.Success&&setTimeout((()=>{o()}),100)}catch(e){console.error("onAddMutation",e)}}))});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[b.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[Yn.jsx(XS,{}),Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:Yn.jsx(e,{id:"E6MqGy",message:"Add liquidity"})}),Yn.jsx(cT,{poolType:"AMM V3"})]}),Yn.jsxs(i,{sx:{px:16,display:"flex",flexDirection:"column",alignItems:"stretch",backgroundColor:b.palette.background.paper,borderRadius:16,[b.breakpoints.up("tablet")]:{borderColor:b.palette.border.main,borderWidth:1,borderStyle:"solid",px:0,mx:"auto",width:600}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,py:20,[b.breakpoints.up("tablet")]:{px:20}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"nxRg31",message:"Select pair"})}),Yn.jsx(mP,{chainId:v,baseToken:I.baseToken,quoteToken:I.quoteToken,dispatch:S}),Yn.jsx(OR,{disabled:!I.baseToken||!I.quoteToken,feeAmount:I.feeAmount,dispatch:S})]}),Yn.jsxs(bC,{disabled:!I.feeAmount||W,children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"5CZbyC",message:"Set price range"})}),Boolean(I.baseToken&&I.quoteToken)&&Yn.jsx(aT,{baseToken:I.baseToken,quoteToken:I.quoteToken,handleRateToggle:()=>{var e,t,n,i,o;J[dC.LOWER]||J[dC.UPPER]||(re(null!==(t=null===(e=X?Ce:null==we?void 0:we.invert())||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""),ae(null!==(i=null===(n=X?we:null==Ce?void 0:Ce.invert())||void 0===n?void 0:n.toSignificant(6))&&void 0!==i?i:""),ie(null!==(o=fe[lC.CURRENCY_B])&&void 0!==o?o:"")),S({type:ET.ToggleRate,payload:void 0})},sx:C?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0})]}),Yn.jsx(fP,{onSelect:Ae}),Yn.jsx(dP,{priceLower:Ce,priceUpper:we,getDecrementLower:ke,getIncrementLower:Te,getDecrementUpper:Ie,getIncrementUpper:Se,onLeftRangeInput:re,onRightRangeInput:ae,currencyA:I.baseToken,currencyB:I.quoteToken,feeAmount:I.feeAmount,ticksAtLimit:J}),G&&Yn.jsx(mC,{children:se._({id:"b+KjnH",message:"Your position will not earn fees or be used in trades until the market price moves into your range."})}),H&&Yn.jsx(mC,{children:se._({id:"Jh223O",message:"Invalid range selected. The min price must be lower than the max price."})})]}),U?Yn.jsxs(bC,{children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"zeSosD",message:"Starting price"})}),Yn.jsx(i,{sx:{p:8,borderRadius:8,backgroundColor:T(b.palette.primary.main,.1),typography:"h6",color:b.palette.primary.main},children:se._({id:"X6T02b",message:"This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."})}),Yn.jsx(i,{sx:{px:16,py:12,borderRadius:8,borderWidth:1,borderColor:b.palette.border.main,borderStyle:"solid"},children:Yn.jsx(Db,{sx:{backgroundColor:"transparent"},value:O,onChange:le})})]}):Yn.jsxs(bC,{disabled:!I.feeAmount||W,children:[Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:[se._({id:"DWd30U",message:"Current price"}),Yn.jsxs(i,{children:[ne," ",se._({id:"b2jAb+",message:"per"})," ",null!==(u=null===(c=I.baseToken)||void 0===c?void 0:c.symbol)&&void 0!==u?u:""]})]}),Yn.jsx(sP,{chainId:v,currencyA:null!==(p=I.baseToken)&&void 0!==p?p:void 0,currencyB:null!==(h=I.quoteToken)&&void 0!==h?h:void 0,feeAmount:I.feeAmount,ticksAtLimit:J,price:_?parseFloat((X?_.invert():_).toSignificant(8)):void 0,priceLower:Ce,priceUpper:we,onLeftRangeInput:re,onRightRangeInput:ae,interactive:!0})]}),Yn.jsxs(bC,{disabled:W||H||U&&!O,children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"MU9s7M",message:"Deposit amounts"})}),Yn.jsxs(i,{children:[Yn.jsx(IC,{value:fe[lC.CURRENCY_A],onUserInput:ie,maxAmount:xe[lC.CURRENCY_A],balance:N[lC.CURRENCY_A],currency:null!==(m=q[lC.CURRENCY_A])&&void 0!==m?m:null,locked:Y}),Yn.jsx(uj,{}),Yn.jsx(IC,{value:fe[lC.CURRENCY_B],onUserInput:oe,maxAmount:xe[lC.CURRENCY_B],balance:N[lC.CURRENCY_B],currency:null!==(g=q[lC.CURRENCY_B])&&void 0!==g?g:null,locked:K})]}),Yn.jsx(rC,{value:de,onChange:ce,disabled:!1,type:"AMMV3"})]})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",py:16,[b.breakpoints.up("tablet")]:{px:20,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:b.palette.background.paper}},children:Yn.jsx(jC,{chainId:v,approvalA:ye,approvalB:ve,parsedAmounts:D,isValid:he,depositADisabled:Y,depositBDisabled:K,errorMessage:V,setShowConfirm:ge})}),Yn.jsx(mT,{parsedAmounts:D,position:F,existingPosition:void 0,priceLower:Ce,priceUpper:we,outOfRange:G,ticksAtLimit:J,on:me,onClose:()=>{ge(!1)},onConfirm:Le.mutate,loading:Le.isPending})]})]})}const yP=["#154618","#ED4A25","#0E794D","#F7A33E","#582969","#DFCC28","#294369","#1D1D1D"],vP=({poolDetail:e,tokenBalances:t})=>{const n=a(),o=$((()=>{if(!e)return[];if(!t)return[];const n=t.reduce(((e,t)=>e.plus(t)),new _e(0));return e.coins.map(((e,i)=>({name:e.name,symbol:e.symbol,address:e.address,chainId:e.chainId,decimals:e.decimals,value:t[i].toNumber(),percentage:t[i].div(n).toNumber(),color:yP[i]})))}),[e,t]);return Yn.jsxs(i,{sx:{mt:16,display:"flex",flexDirection:"column",alignItems:"stretch",gap:28,p:20,backgroundColor:n.palette.background.paper,borderRadius:16,[n.breakpoints.up("tablet")]:{flexDirection:"row",alignItems:"center",border:`1px solid ${n.palette.border.main}`,p:0,gap:0}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",[n.breakpoints.up("tablet")]:{minWidth:364,flexDirection:"column",gap:16}},children:[Yn.jsx(bn,{width:88,height:88,children:Yn.jsx(jn,{isAnimationActive:!1,dataKey:"value",data:o,labelLine:!1,label:!1,outerRadius:44,children:o.map(((e,t)=>Yn.jsx(yn,{fill:e.color,strokeWidth:0},`cell-${t}`)))})}),Yn.jsx(i,{sx:{display:"none",[n.breakpoints.up("tablet")]:{display:"flex",alignItems:"center",justifyContent:"center",flexWrap:"wrap",gap:16,maxWidth:172}},children:o.map((e=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),Yn.jsx(i,{sx:{typography:"h6",color:n.palette.text.primary},children:e.symbol})]},e.address)))})]}),Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:16,[n.breakpoints.up("tablet")]:{display:"none"}},children:o.map((e=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary},children:e.symbol}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),Yn.jsxs(i,{sx:{ml:"auto",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary,textAlign:"right"},children:Am({input:e.value,decimals:e.decimals})}),Yn.jsxs(i,{sx:{typography:"h6",color:n.palette.text.secondary,textAlign:"right"},children:["(",Vm({input:new _e(e.percentage),showDecimals:2}),")"]})]})]},e.address)))}),Yn.jsxs(i,{sx:{display:"none",[n.breakpoints.up("tablet")]:{flexGrow:1,display:"block",borderLeft:`1px solid ${n.palette.border.main}`}},children:[Yn.jsxs(i,{sx:{borderBottom:`1px solid ${n.palette.border.main}`,typography:"h6",fontWeight:600,color:n.palette.text.secondary,height:48,display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:"Asset"}),Yn.jsx(i,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"Token Amount"}),Yn.jsx(i,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"ratio"})]}),o.map((e=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",height:56},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:[Yn.jsx(Df,{address:e.address,width:24,height:24,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary},children:e.symbol}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]})]}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Am({input:e.value,decimals:e.decimals})}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Vm({input:new _e(e.percentage),showDecimals:2})})]},e.address)))]})]})};function bP(e,t){if(!e)return"";const n=an(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function jP({chainId:t,address:n}){var o;const{isMobile:r}=Tg(),s=a(),l=function({chainId:e,address:t}){var n,i;const o=gg().getQuery(Se.graphql.curve_stableswap_ng_getPoolSwapInfo,{where:{chainId:null!=e?e:le.ZETACHAIN,poolAddress:null!=t?t:""}}),r=et(Object.assign(Object.assign({},o),{enabled:!!t&&!!e})),a=null===(i=null===(n=r.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolSwapInfo)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},r),{swapList:a})}({address:n,chainId:t}),[c,u]=H.useState(1),p=c*(r?4:8),h=null!==(o=l.swapList)&&void 0!==o?o:[],m=p<h.length,g=h.slice(0,p);return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:l.error?l.refetch:void 0,loading:l.isLoading,empty:!(null==g?void 0:g.length),children:!!(null==g?void 0:g.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"LhMjLm",message:"Time"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"UPXmW+",message:"Trader"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"v4nCHK",message:"Paid"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"fZ5Vnu",message:"Received"})})]})}),Yn.jsx(i,{component:"tbody",children:null==g?void 0:g.map((e=>Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:bP(1e3*e.time)}),Yn.jsx("td",{children:Yn.jsx(zb,{address:e.user,truncate:!0})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.paidToken.id,chainId:t,width:24,height:24,noBorder:!0,noShowChain:!0}),`${Am({input:e.paidAmount,decimals:e.paidToken.decimals})} ${e.paidToken.symbol}`]})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.receivedToken.id,chainId:t,width:18,height:18,noBorder:!0,noShowChain:!0}),`${Am({input:e.receivedAmount,decimals:e.receivedToken.decimals})} ${e.receivedToken.symbol}`]})})]},e.id)))})]})}),m&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:s.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>u((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}const CP=({chainId:t,address:n})=>{var o,r;const{isMobile:s}=Tg(),l=a(),c=function({chainId:e,address:t}){var n,i;const o=gg(),r=et(Object.assign(Object.assign({},o.getQuery(Se.graphql.curve_stableswap_ng_getPoolLiquidityHistory,{where:{chainId:null!=e?e:le.ZETACHAIN,poolAddress:null!=t?t:""}})),{enabled:!!t&&!!e}));return Object.assign(Object.assign({},r),{list:null===(i=null===(n=r.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolLiquidityHistory)||void 0===i?void 0:i.liquidityHistories})}({address:n,chainId:t}),[u,p]=H.useState(1),h=u*(s?4:8),m=c.list,g=h<(null!==(o=null==m?void 0:m.length)&&void 0!==o?o:0),f=null!==(r=null==m?void 0:m.slice(0,h))&&void 0!==r?r:[];return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:c.error?c.refetch:void 0,loading:c.isLoading&&!(null==f?void 0:f.length),empty:!(null==f?void 0:f.length),children:!!(null==f?void 0:f.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"LhMjLm",message:"Time"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"bwRvnp",message:"Action"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"GX8GKD",message:"Assets"})})]})}),Yn.jsx(i,{component:"tbody",children:null==f?void 0:f.map((e=>{var n;return Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:bP(1e3*e.time)}),Yn.jsx("td",{children:e.action}),Yn.jsx("td",{children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8},children:null===(n=e.assets)||void 0===n?void 0:n.map(((e,n)=>Yn.jsxs(J,{children:[n>0&&Yn.jsx(i,{sx:{width:"1px",height:"16px",backgroundColor:l.palette.border.main,margin:"0 8px"}}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2},children:[Yn.jsx(Df,{address:e.token.address,chainId:t,width:24,height:24,noBorder:!0,noShowChain:!0,marginRight:0}),Yn.jsxs(i,{sx:{typography:"body2"},children:[Am({input:e.amount,decimals:e.token.decimals})," ",e.token.symbol]})]})]},e.token.address)))})})]},e.id)}))})]})}),g&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>p((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})},wP=({title:e,children:t,tip:n,sx:o})=>Yn.jsxs(i,{sx:Object.assign({display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,py:8},o),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary"},children:e}),n&&Yn.jsx(lb,{title:n})]}),Yn.jsx(i,{sx:{typography:"body1",color:"text.primary"},children:t})]}),kP=({poolDetail:e})=>{var t;return Yn.jsxs(i,{sx:{mt:10,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[Yn.jsx(wP,{title:"Daily USD volume",children:(null==e?void 0:e.dailyVolumeUsd)?`$${qm(new Pe((null==e?void 0:e.dailyVolumeUsd)||"0"))}`:"-"}),Yn.jsx(wP,{title:"Liquidity utilization",tip:"24h Volume/Liquidity ratio",children:(null==e?void 0:e.liquidityUtilization)?`${Vm({input:new Pe((null==e?void 0:e.liquidityUtilization)||"0"),showDecimals:2})}`:"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Fee",children:(null==e?void 0:e.fee)?`${Vm({input:new Pe((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}`:"-"}),Yn.jsx(wP,{title:"DAO fee",children:(null==e?void 0:e.daoFee)?`${Vm({input:new Pe((null==e?void 0:e.daoFee)||"0"),showDecimals:2})}`:"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Virtual price",tip:"Measures pool growth; this is not a dollar value",children:(null==e?void 0:e.virtualPrice)?`${Am({input:new Pe((null==e?void 0:e.virtualPrice)||"0").div(1e18),decimals:18})}`:"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Pool/Token",children:(null==e?void 0:e.address)?Yn.jsx(zb,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body1",color:"text.primary"}}):"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Pool Type",children:"plain"===(null==e?void 0:e.poolType)?"Stableswap-NG":"meta"===(null==e?void 0:e.poolType)?"Plain pool":"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Coins",sx:{alignItems:"flex-start"},children:Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:e?e.coins.map((t=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(Df,{address:t.address,width:16,height:16,chainId:null==e?void 0:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsxs(i,{sx:{typography:"body1",fontWeight:500,color:"text.primary"},children:[t.symbol,"(Standard)"]})]},t.address))):"-"})}),Yn.jsx(wP,{title:"Pool Parameters:",sx:{alignItems:"flex-start"},children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsxs(i,{sx:{typography:"body1",color:"text.primary"},children:["A:",null!==(t=null==e?void 0:e.a)&&void 0!==t?t:"-"]}),Yn.jsx(lb,{title:"Amplification coefficient chosen from fluctuation of prices around 1."})]}),Yn.jsxs(i,{sx:{typography:"body1",color:"text.primary"},children:["Off Peg Multiplier:",(null==e?void 0:e.offpegFeeMultiplier)?new Pe(null==e?void 0:e.offpegFeeMultiplier).div(1e10).toString():"-"]})]})})]})},TP=({poolDetail:e})=>{var t;const n=a();return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,[n.breakpoints.up("tablet")]:{py:20,flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderBottom:`1px solid ${n.palette.border.main}`}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[e?Yn.jsx(XT,{pool:e,separate:!1,wrap:!0}):Yn.jsx(j,{width:72,height:52,sx:{borderRadius:8}}),Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"h4",fontWeight:600},children:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"-"}),(null==e?void 0:e.address)&&Yn.jsx(zb,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body2",color:"text.secondary"}})]})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"row",alignItems:"flex-end",gap:4,[n.breakpoints.up("tablet")]:{flexDirection:"column",gap:0}},children:[Yn.jsx(KT,{apy:null==e?void 0:e.apy,dailyApy:null==e?void 0:e.dailyApy,weeklyApy:null==e?void 0:e.weeklyApy,sx:{typography:"h4",[n.breakpoints.up("tablet")]:{typography:"h4"}}}),Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary"},children:"APY"})]})]})},IP=({poolDetail:e})=>{const t=a(),n=[{title:"Trader",value:qm(new Pe((null==e?void 0:e.traderCount)||"0"))},{title:"Total Liquidity",value:`$${qm(new Pe((null==e?void 0:e.tvl)||"0"))}`},{title:"Volume",value:`$${qm(new Pe((null==e?void 0:e.volume)||"0"))}`},{title:"Fees",value:Vm({input:new Pe((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}];return Yn.jsx(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gridTemplateRows:"repeat(2, 1fr)",gap:12,[t.breakpoints.up("tablet")]:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(1, 1fr)"}},children:n.map(((n,o)=>e?Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",p:16,borderRadius:8,backgroundColor:t.palette.background.paper,[t.breakpoints.up("tablet")]:{border:`1px solid ${t.palette.border.main}`}},children:[Yn.jsx(i,{sx:{typography:"caption",color:t.palette.text.primary},children:n.value}),Yn.jsx(i,{sx:{typography:"h6",color:t.palette.text.secondary},children:n.title})]},o):Yn.jsx(j,{width:"100%",height:77,sx:{borderRadius:8}},o)))})};const SP=({params:t})=>{const n=Gj(),{isMobile:o}=Tg(),{account:r}=dg(),s=a(),{poolDetail:l,isLoading:d,error:u}=function({address:e,chainId:t}){const n=gg(),i=Z((e=>{var n,i,o,r,a,s,l,d,c,u,p,h;const m=null==e?void 0:e.curve_stableswap_ng_getPoolInfo;if(!m)return;const g=((null===(n=m.coins)||void 0===n?void 0:n.map((e=>({chainId:null!=t?t:le.ZETACHAIN,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex));return{chainId:null!=t?t:le.ZETACHAIN,name:m.name||"",address:m.address||m.id||"",symbol:m.symbol,decimals:m.decimals,fee:(null===(i=m.fee)||void 0===i?void 0:i.toString())||"0",coins:g,apy:(null===(o=m.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(r=m.tvl)||void 0===r?void 0:r.toString())||null,volume:(null===(a=m.volume)||void 0===a?void 0:a.toString())||null,dailyVolumeUsd:(null===(s=m.dailyVolumeUsd)||void 0===s?void 0:s.toString())||null,traderCount:(null===(l=m.traderCount)||void 0===l?void 0:l.toString())||null,lpTokenBalance:null,liquidityUtilization:(null===(d=m.liquidityUtilization)||void 0===d?void 0:d.toString())||null,daoFee:(null===(c=m.daoFee)||void 0===c?void 0:c.toString())||null,virtualPrice:(null===(u=m.virtualPrice)||void 0===u?void 0:u.toString())||null,poolType:m.poolType||"plain",a:(null===(p=m.a)||void 0===p?void 0:p.toString())||null,offpegFeeMultiplier:(null===(h=m.offpegFeeMultiplier)||void 0===h?void 0:h.toString())||null}}),[t]),{data:o,isLoading:r,error:a}=et(Object.assign(Object.assign({},n.getQuery(Se.graphql.curve_stableswap_ng_getPoolInfo,{where:{chainId:null!=t?t:le.ZETACHAIN,poolAddress:null!=e?e:""}})),{enabled:!!e&&!!t,select:i}));return{poolDetail:o,isLoading:r,error:a}}({address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),{tokenBalances:p}=lI({pool:l,account:r}),[h,m]=z(null),[g,f]=z("parameters");Q((()=>{o||l&&m({pool:l,type:YT.Add})}),[l,o]);const x=$((()=>[{key:"parameters",value:"Parameters"},{key:"swaps",value:"Swaps"},{key:"liquidity",value:"Liquidity"}]),[]);return Yn.jsxs(zj,{sx:o?{p:s.spacing(28,0,108)}:{p:s.spacing(28,0,40)},children:[Yn.jsxs(i,{sx:{[s.breakpoints.up("tablet")]:{display:"flex",gap:12,overflow:"hidden"}},children:[Yn.jsxs(i,{sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",gap:24,[s.breakpoints.up("tablet")]:{gap:28}},children:[Yn.jsx(WL,{onClick:()=>{n.push({type:Zj.Pool})}}),Yn.jsx(TP,{poolDetail:l}),Yn.jsx(IP,{poolDetail:l}),l&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body1",color:s.palette.text.primary},children:"Currency reserves"}),Yn.jsx(vP,{poolDetail:l,tokenBalances:p})]}),Yn.jsx(i,{sx:{backgroundColor:s.palette.background.paper,borderRadius:16,overflow:"hidden",px:16,pb:16,[s.breakpoints.up("tablet")]:{px:20,pb:20}},children:Yn.jsxs(S,{value:g,onChange:(e,t)=>f(t),children:[Yn.jsx(D,{tabs:x}),Yn.jsx(O,{value:"parameters",children:Yn.jsx(kP,{poolDetail:l})}),Yn.jsx(O,{value:"swaps",children:Yn.jsx(jP,{chainId:null==t?void 0:t.chainId,address:null==t?void 0:t.address})}),Yn.jsx(O,{value:"liquidity",children:Yn.jsx(CP,{chainId:null==t?void 0:t.chainId,address:null==t?void 0:t.address})})]})})]}),Yn.jsx(i,{sx:{position:"relative",width:o?"100%":375},children:h?Yn.jsx(hI,{poolDetailBtnVisible:!1,operateCurvePool:h,setOperateCurvePool:o?m:void 0}):o?null:Yn.jsx(j,{width:375,height:403,sx:{borderRadius:16}})})]}),o&&Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[Yn.jsx(c,{variant:c.Variant.second,disabled:!l,onClick:()=>{l&&m({pool:l,type:YT.Remove})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{disabled:!l,onClick:()=>{l&&m({pool:l,type:YT.Add})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})})]})})]})};function EP(){const{routerPage:e}=Jn(),t=Gj((e=>e.page)),n=null!=e?e:t;switch(null==n?void 0:n.type){case Zj.Pool:return Yn.jsx(KS,{params:n.params});case Zj.CreatePool:return Yn.jsx(qL,{});case Zj.ModifyPool:return Yn.jsx(YL,{params:n.params});case Zj.PoolDetail:return Yn.jsx(jR,{params:n.params});case Zj.CurvePoolDetail:return Yn.jsx(SP,{params:n.params});case Zj.createPoolAMMV2:return Yn.jsx(AR,{});case Zj.createPoolAMMV3:return Yn.jsx(xP,{params:n.params,handleGoBack:()=>{Gj.getState().push({type:Zj.Pool})},handleGoToPoolList:()=>{Gj.getState().push({type:Zj.Pool})}});default:return Yn.jsx(KS,{params:null==n?void 0:n.params})}}export{AR as A,YL as B,SP as C,hS as D,ti as E,ai as F,mS as G,Zv as M,Zj as P,lj as S,hj as T,ab as U,sb as W,Vm as a,Rm as b,Hj as c,Df as d,ib as e,Um as f,$j as g,ah as h,Sg as i,Yn as j,$v as k,Gj as l,tg as m,Em as n,Am as o,EP as p,xP as q,Uu as r,Vu as s,FT as t,Dj as u,VT as v,xI as w,qL as x,jR as y,KS as z};
|
|
34
|
+
*/function cv(){if(Ky)return Yy;Ky=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Yy=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}()?Object.assign:function(i,o){for(var r,a,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(i),l=1;l<arguments.length;l++){for(var d in r=Object(arguments[l]))t.call(r,d)&&(s[d]=r[d]);if(e){a=e(r);for(var c=0;c<a.length;c++)n.call(r,a[c])&&(s[a[c]]=r[a[c]])}}return s},Yy}function uv(){if(Jy)return Xy;Jy=1;return Xy="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function pv(){return tv?ev:(tv=1,ev=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var hv=dv();$y.exports=function(){if(rv)return ov;rv=1;var e=dv(),t=cv(),n=uv(),i=pv(),o=function(){if(iv)return nv;iv=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=uv(),n={},i=pv();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,r,a,s,l){if("production"!==process.env.NODE_ENV)for(var d in o)if(i(o,d)){var c;try{if("function"!=typeof o[d]){var u=Error((s||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=o[d](r,d,s,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((s||"React class")+": type specification of "+a+" `"+d+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof c+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),c instanceof Error&&!(c.message in n)){n[c.message]=!0;var p=l?l():"";e("Failed "+a+" type: "+c.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},nv=o}(),r=function(){};function a(){return null}return"production"!==process.env.NODE_ENV&&(r=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),ov=function(s,l){var d="function"==typeof Symbol&&Symbol.iterator,c="@@iterator",u="<<anonymous>>",p={array:f("array"),bigint:f("bigint"),bool:f("boolean"),func:f("function"),number:f("number"),object:f("object"),string:f("string"),symbol:f("symbol"),any:g(a),arrayOf:function(e){return g((function(t,i,o,r,a){if("function"!=typeof e)return new m("Property `"+a+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[i];if(!Array.isArray(s))return new m("Invalid "+r+" `"+a+"` of type `"+v(s)+"` supplied to `"+o+"`, expected an array.");for(var l=0;l<s.length;l++){var d=e(s,l,o,r,a+"["+l+"]",n);if(d instanceof Error)return d}return null}))},element:g((function(e,t,n,i,o){var r=e[t];return s(r)?null:new m("Invalid "+i+" `"+o+"` of type `"+v(r)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:g((function(t,n,i,o,r){var a=t[n];return e.isValidElementType(a)?null:new m("Invalid "+o+" `"+r+"` of type `"+v(a)+"` supplied to `"+i+"`, expected a single ReactElement type.")})),instanceOf:function(e){return g((function(t,n,i,o,r){if(!(t[n]instanceof e)){var a=e.name||u;return new m("Invalid "+o+" `"+r+"` of type `"+((s=t[n]).constructor&&s.constructor.name?s.constructor.name:u)+"` supplied to `"+i+"`, expected instance of `"+a+"`.")}var s;return null}))},node:g((function(e,t,n,i,o){return y(e[t])?null:new m("Invalid "+i+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return g((function(t,o,r,a,s){if("function"!=typeof e)return new m("Property `"+s+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var l=t[o],d=v(l);if("object"!==d)return new m("Invalid "+a+" `"+s+"` of type `"+d+"` supplied to `"+r+"`, expected an object.");for(var c in l)if(i(l,c)){var u=e(l,c,r,a,s+"."+c,n);if(u instanceof Error)return u}return null}))},oneOf:function(e){return Array.isArray(e)?g((function(t,n,i,o,r){for(var a=t[n],s=0;s<e.length;s++)if(h(a,e[s]))return null;var l=JSON.stringify(e,(function(e,t){return"symbol"===b(t)?String(t):t}));return new m("Invalid "+o+" `"+r+"` of value `"+String(a)+"` supplied to `"+i+"`, expected one of "+l+".")})):("production"!==process.env.NODE_ENV&&r(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),a)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&r("Invalid argument supplied to oneOfType, expected an instance of array."),a;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+j(o)+" at index "+t+"."),a}return g((function(t,o,r,a,s){for(var l=[],d=0;d<e.length;d++){var c=(0,e[d])(t,o,r,a,s,n);if(null==c)return null;c.data&&i(c.data,"expectedType")&&l.push(c.data.expectedType)}return new m("Invalid "+a+" `"+s+"` supplied to `"+r+"`"+(l.length>0?", expected one of type ["+l.join(", ")+"]":"")+".")}))},shape:function(e){return g((function(t,i,o,r,a){var s=t[i],l=v(s);if("object"!==l)return new m("Invalid "+r+" `"+a+"` of type `"+l+"` supplied to `"+o+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return x(o,r,a,d,b(c));var u=c(s,d,o,r,a+"."+d,n);if(u)return u}return null}))},exact:function(e){return g((function(o,r,a,s,l){var d=o[r],c=v(d);if("object"!==c)return new m("Invalid "+s+" `"+l+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},o[r],e);for(var p in u){var h=e[p];if(i(e,p)&&"function"!=typeof h)return x(a,s,l,p,b(h));if(!h)return new m("Invalid "+s+" `"+l+"` key `"+p+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(o[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var g=h(d,p,a,s,l+"."+p,n);if(g)return g}return null}))}};function h(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function m(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function g(e){if("production"!==process.env.NODE_ENV)var t={},i=0;function o(o,a,s,d,c,p,h){if(d=d||u,p=p||s,h!==n){if(l){var g=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw g.name="Invariant Violation",g}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var f=d+":"+s;!t[f]&&i<3&&(r("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+d+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[f]=!0,i++)}}return null==a[s]?o?null===a[s]?new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `null`."):new m("The "+c+" `"+p+"` is marked as required in `"+d+"`, but its value is `undefined`."):null:e(a,s,d,c,p)}var a=o.bind(null,!1);return a.isRequired=o.bind(null,!0),a}function f(e){return g((function(t,n,i,o,r,a){var s=t[n];return v(s)!==e?new m("Invalid "+o+" `"+r+"` of type `"+b(s)+"` supplied to `"+i+"`, expected `"+e+"`.",{expectedType:e}):null}))}function x(e,t,n,i,o){return new m((e||"React class")+": "+t+" type `"+n+"."+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function y(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(y);if(null===e||s(e))return!0;var t=function(e){var t=e&&(d&&e[d]||e[c]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,i=t.call(e);if(t!==e.entries){for(;!(n=i.next()).done;)if(!y(n.value))return!1}else for(;!(n=i.next()).done;){var o=n.value;if(o&&!y(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function j(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return m.prototype=Error.prototype,p.checkPropTypes=o,p.resetWarningCache=o.resetWarningCache,p.PropTypes=p,p},ov}()(hv.isElement,!0)}else $y.exports=function(){if(sv)return av;sv=1;var e=uv();function t(){}function n(){}return n.resetWarningCache=t,av=function(){function i(t,n,i,o,r,a){if(a!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return i}i.isRequired=i;var r={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:o,element:i,elementType:i,instanceOf:o,node:i,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r}}()();var mv=Hn($y.exports);function gv(e,t){return"production"===process.env.NODE_ENV?()=>null:function(...n){return e(...n)||t(...n)}}function fv(e,t,n,i,o){const r=e[t],a=o||t;if(null==r||"undefined"==typeof window)return null;let s;const l=r.type;return"function"!=typeof l||function(e){const{prototype:t={}}=e;return Boolean(t.isReactComponent)}(l)||(s="Did you accidentally use a plain function component for an element instead?"),void 0!==s?new Error(`Invalid ${i} \`${a}\` supplied to \`${n}\`. Expected an element that can hold a ref. ${s} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const xv=gv(mv.element,fv);xv.isRequired=gv(mv.element.isRequired,fv);const yv="exact-prop: ";function vv(e){return e&&e.ownerDocument||document}const bv="undefined"!=typeof window?W.useLayoutEffect:W.useEffect;function jv(e){const t=W.useRef(e);return bv((()=>{t.current=e})),W.useRef(((...e)=>(0,t.current)(...e))).current}function Cv(...e){return W.useMemo((()=>e.every((e=>null==e))?null:t=>{e.forEach((e=>{!function(e,t){"function"==typeof e?e(t):e&&(e.current=t)}(e,t)}))}),e)}const wv={};const kv=[];class Tv{static create(){return new Tv}currentId=null;start(e,t){this.clear(),this.currentId=setTimeout((()=>{this.currentId=null,t()}),e)}clear=()=>{null!==this.currentId&&(clearTimeout(this.currentId),this.currentId=null)};disposeEffect=()=>this.clear}function Iv(){const e=function(e,t){const n=W.useRef(wv);return n.current===wv&&(n.current=e(t)),n}(Tv.create).current;var t;return t=e.disposeEffect,W.useEffect(t,kv),e}const Sv={active:"active",checked:"checked",completed:"completed",disabled:"disabled",error:"error",expanded:"expanded",focused:"focused",focusVisible:"focusVisible",open:"open",readOnly:"readOnly",required:"required",selected:"selected"};function Ev(e){var t,n,i="";if("string"==typeof e||"number"==typeof e)i+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=Ev(e[t]))&&(i&&(i+=" "),i+=n)}else for(n in e)e[n]&&(i&&(i+=" "),i+=n);return i}function Av(){for(var e,t,n=0,i="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=Ev(e))&&(i&&(i+=" "),i+=t);return i}function Ov(e,t=[]){if(void 0===e)return{};const n={};return Object.keys(e).filter((n=>n.match(/^on[A-Z]/)&&"function"==typeof e[n]&&!t.includes(n))).forEach((t=>{n[t]=e[t]})),n}function Lv(e){if(void 0===e)return{};const t={};return Object.keys(e).filter((t=>!(t.match(/^on[A-Z]/)&&"function"==typeof e[t]))).forEach((n=>{t[n]=e[n]})),t}function Rv(e){const{elementType:t,externalSlotProps:n,ownerState:i,skipResolvingSlotProps:o=!1,...r}=e,a=o?{}:function(e,t,n){return"function"==typeof e?e(t,n):e}(n,i),{props:s,internalRef:l}=function(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:i,externalForwardedProps:o,className:r}=e;if(!t){const e=Av(n?.className,r,o?.className,i?.className),t={...n?.style,...o?.style,...i?.style},a={...n,...o,...i};return e.length>0&&(a.className=e),Object.keys(t).length>0&&(a.style=t),{props:a,internalRef:void 0}}const a=Ov({...o,...i}),s=Lv(i),l=Lv(o),d=t(a),c=Av(d?.className,n?.className,r,o?.className,i?.className),u={...d?.style,...n?.style,...o?.style,...i?.style},p={...d,...n,...l,...s};return c.length>0&&(p.className=c),Object.keys(u).length>0&&(p.style=u),{props:p,internalRef:d.ref}}({...r,externalSlotProps:a}),d=function(e,t,n){return void 0===e||"string"==typeof e?t:{...t,ownerState:{...t.ownerState,...n}}}(t,{...s,ref:Cv(l,a?.ref,e.additionalProps?.ref)},i);return d}function Pv(e){return e.substring(2).toLowerCase()}function _v(e){const{children:t,disableReactTree:n=!1,mouseEvent:i="onClick",onClickAway:o,touchEvent:r="onTouchEnd"}=e,a=W.useRef(!1),s=W.useRef(null),l=W.useRef(!1),d=W.useRef(!1);W.useEffect((()=>(setTimeout((()=>{l.current=!0}),0),()=>{l.current=!1})),[]);const c=Cv((u=t)&&W.isValidElement(u)?u.props.propertyIsEnumerable("ref")?u.props.ref:u.ref:null,s);var u;const p=jv((e=>{const t=d.current;d.current=!1;const i=vv(s.current);if(!l.current||!s.current||"clientX"in e&&function(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}(e,i))return;if(a.current)return void(a.current=!1);let r;r=e.composedPath?e.composedPath().indexOf(s.current)>-1:!i.documentElement.contains(e.target)||s.current.contains(e.target),r||!n&&t||o(e)})),h=e=>n=>{d.current=!0;const i=t.props[e];i&&i(n)},m={ref:c};return!1!==r&&(m[r]=h(r)),W.useEffect((()=>{if(!1!==r){const e=Pv(r),t=vv(s.current),n=()=>{a.current=!0};return t.addEventListener(e,p),t.addEventListener("touchmove",n),()=>{t.removeEventListener(e,p),t.removeEventListener("touchmove",n)}}}),[p,r]),!1!==i&&(m[i]=h(i)),W.useEffect((()=>{if(!1!==i){const e=Pv(i),t=vv(s.current);return t.addEventListener(e,p),()=>{t.removeEventListener(e,p)}}}),[p,i]),Yn.jsx(W.Fragment,{children:W.cloneElement(t,m)})}"production"!==process.env.NODE_ENV&&(_v.propTypes={children:xv.isRequired,disableReactTree:mv.bool,mouseEvent:mv.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mv.func.isRequired,touchEvent:mv.oneOf(["onTouchEnd","onTouchStart",!1])}),"production"!==process.env.NODE_ENV&&(_v.propTypes=function(e){return"production"===process.env.NODE_ENV?e:{...e,[yv]:t=>{const n=Object.keys(t).filter((t=>!e.hasOwnProperty(t)));return n.length>0?new Error(`The following props are not supported: ${n.map((e=>`\`${e}\``)).join(", ")}. Please remove them.`):null}}}(_v.propTypes));const Mv="base";function Bv(e,t){const n=Sv[t];return n?`${Mv}--${n}`:function(e,t){return`${Mv}-${e}-${t}`}(e,t)}const Dv="Snackbar";function Nv(e){return Bv(Dv,e)}!function(e,t){const n={};t.forEach((t=>{n[t]=Bv(e,t)}))}(Dv,["root"]);const Fv={disableDefaultClasses:!1},Uv=W.createContext(Fv);"production"!==process.env.NODE_ENV&&(Uv.displayName="ClassNameConfiguratorContext");const qv=()=>function(e,t,n){const i={};for(const o in e){const r=e[o];let a="";for(let e=0;e<r.length;e+=1){const i=r[e];i&&(a+=t(i)+" ",n&&n[i]&&(a+=n[i]+" "))}i[o]=a}return i}({root:["root"]},function(e){const{disableDefaultClasses:t}=W.useContext(Uv);return n=>t?"":e(n)}(Nv)),Vv=W.forwardRef((function(e,t){const{autoHideDuration:n=null,children:i,disableWindowBlurListener:o=!1,exited:r=!0,onBlur:a,onClose:s,onFocus:l,onMouseEnter:d,onMouseLeave:c,open:u,resumeHideDuration:p,slotProps:h={},slots:m={},...g}=e,f=qv(),{getRootProps:x,onClickAway:y}=function(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:i,open:o,resumeHideDuration:r}=e,a=Iv();W.useEffect((()=>{if(o)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)};function e(e){e.defaultPrevented||"Escape"===e.key&&i?.(e,"escapeKeyDown")}}),[o,i]);const s=jv(((e,t)=>{i?.(e,t)})),l=jv((e=>{i&&null!=e&&a.start(e,(()=>{s(null,"timeout")}))}));W.useEffect((()=>(o&&l(t),a.clear)),[o,t,l,a]);const d=a.clear,c=W.useCallback((()=>{null!=t&&l(null!=r?r:.5*t)}),[t,r,l]),u=e=>t=>{const n=e.onFocus;n?.(t),d()},p=e=>t=>{const n=e.onMouseEnter;n?.(t),d()},h=e=>t=>{const n=e.onMouseLeave;n?.(t),c()};return W.useEffect((()=>{if(!n&&o)return window.addEventListener("focus",c),window.addEventListener("blur",d),()=>{window.removeEventListener("focus",c),window.removeEventListener("blur",d)}}),[n,o,c,d]),{getRootProps:(t={})=>{const n={...Ov(e),...Ov(t)};return{role:"presentation",...t,...n,onBlur:(i=n,e=>{const t=i.onBlur;t?.(e),c()}),onFocus:u(n),onMouseEnter:p(n),onMouseLeave:h(n)};var i},onClickAway:e=>{i?.(e,"clickaway")}}}({...e,autoHideDuration:n,disableWindowBlurListener:o,onClose:s,open:u,resumeHideDuration:p}),v=e,b=m.root||"div",j=Rv({elementType:b,getSlotProps:x,externalForwardedProps:g,externalSlotProps:h.root,additionalProps:{ref:t},ownerState:v,className:f.root}),C=Rv({elementType:_v,externalSlotProps:h.clickAwayListener,additionalProps:{onClickAway:y},ownerState:v});return delete C.ownerState,!u&&r?null:Yn.jsx(_v,{...C,children:Yn.jsx(b,{...j,children:i})})}));function Wv({size:e,color:t,time:n,strokeWidth:o=2,sx:r}){const[a,s]=z("0 1069"),l=e/2,d=l-1;return Q((()=>{s(2*Math.PI*d+" 0")}),[]),Yn.jsx(i,{width:e,height:e,component:"svg",sx:Object.assign({position:"absolute",top:`-${o}`,left:`-${o}`,transform:"rotate(-90deg)"},r),children:Yn.jsx(i,{component:"circle",cx:l,cy:l,r:d,strokeWidth:o,stroke:t,fill:"none",strokeDasharray:a,sx:{transition:`stroke-dasharray ${n}`}})})}"production"!==process.env.NODE_ENV&&(Vv.propTypes={autoHideDuration:mv.number,children:mv.node,disableWindowBlurListener:mv.bool,exited:mv.bool,onClose:mv.func,open:mv.bool,resumeHideDuration:mv.number,slotProps:mv.shape({clickAwayListener:mv.oneOfType([mv.func,mv.shape({children:mv.element.isRequired,disableReactTree:mv.bool,mouseEvent:mv.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:mv.func,touchEvent:mv.oneOf(["onTouchEnd","onTouchStart",!1])})]),root:mv.oneOfType([mv.func,mv.object])}),slots:mv.shape({root:mv.elementType})});var Hv=H.memo(Wv);const $v=st((e=>({notify:null,toast:t=>{e({notify:t})},close:()=>{e({notify:null})}}))),zv={entering:"translateX(0)",entered:"translateX(0)",exiting:"translateX(500px)",exited:"translateX(500px)",unmounted:"translateX(500px)"};function Zv(){const e=a(),{notify:t,close:n}=$v(),[o,r]=H.useState(!0),s=H.useRef(null),l=null==t?void 0:t.timeout,d=!!t;let c=Yn.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("circle",{cx:"18",cy:"18",r:"16.5",stroke:"#2FBA90",strokeWidth:"3"}),Yn.jsx("path",{d:"M25.1384 11.334L14.8873 21.5851L10.8584 17.5718L8.66504 19.7651L14.8873 25.9873L27.3317 13.5429L25.1384 11.334Z",fill:"#2FBA90"})]});switch(null==t?void 0:t.type){case"error":c=Yn.jsxs("svg",{width:"36",height:"37",viewBox:"0 0 36 37",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("circle",{cx:"18",cy:"18.5",r:"16.5",stroke:"#FF6187",strokeWidth:"3"}),Yn.jsx("path",{d:"M25.3331 13.0452L19.8782 18.5L25.3331 23.9548L23.5148 25.7731L18.06 20.3183L12.6051 25.7731L10.7869 23.9548L16.2417 18.5L10.7869 13.0452L12.6051 11.2269L18.06 16.6817L23.5148 11.2269L25.3331 13.0452Z",fill:"#FF6187"})]});break;case"warning":c=Yn.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.4065 3.6189L9.62438 3.59576L3.39812 9.78928L3.37498 18.5714L9.5685 24.7976L18.3506 24.8208L24.5769 18.6273L24.6 9.84516L18.4065 3.6189ZM26.9359 8.88481L19.3791 1.28812L8.66403 1.25988L1.06734 8.81663L1.0391 19.5317L8.59585 27.1284L19.311 27.1567L26.9076 19.5999L26.9359 8.88481Z",fill:"#B15600"}),Yn.jsx("path",{d:"M15.1664 7.58398H12.8331V16.9173H15.1664V7.58398Z",fill:"#B15600"}),Yn.jsx("path",{d:"M13.9998 21.6395C14.8896 21.6395 15.6109 20.9181 15.6109 20.0283C15.6109 19.1386 14.8896 18.4172 13.9998 18.4172C13.11 18.4172 12.3887 19.1386 12.3887 20.0283C12.3887 20.9181 13.11 21.6395 13.9998 21.6395Z",fill:"#B15600"})]})}return Yn.jsx(i,{component:Vv,open:d,autoHideDuration:l,onClose:(e,t)=>{"clickaway"!==t&&n()},exited:o,sx:{position:"fixed",top:20,left:20,right:20,zIndex:1,[e.breakpoints.up("tablet")]:{left:"auto"}},children:Yn.jsx(ln,{timeout:{enter:400,exit:400},in:d,appear:!0,unmountOnExit:!0,onEnter:()=>{r(!1)},onExited:()=>{r(!0)},nodeRef:s,children:o=>Yn.jsxs(i,{ref:s,sx:{display:"flex",justifyContent:"space-between",p:12,borderRadius:8,backgroundColor:"background.paper",color:"text.primary",border:"solid 1px",borderColor:"border.main",boxShadow:"0px 6px 12px 0px rgba(0, 0, 0, 0.10)",transform:zv[o],transition:"transform 300ms ease",[e.breakpoints.up("tablet")]:{p:20,width:"auto",maxWidth:328}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{mt:7,"& > svg":{width:28,height:28},[e.breakpoints.up("tablet")]:{"& > svg":{width:36,height:36}}},children:t?c:""}),Yn.jsxs(i,{sx:{ml:20},children:[Yn.jsx(i,{sx:{typography:"caption"},children:null==t?void 0:t.message}),(null==t?void 0:t.link)?Yn.jsxs(i,{component:"a",target:"_blank",rel:"noopener noreferrer",href:t.link.outerLink,sx:{display:"inline-flex",alignItems:"center",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},children:[t.link.text,Yn.jsx(i,{component:"svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{ml:4,width:18,height:18},children:Yn.jsx("path",{d:"M4.22703 13.2122L10.6811 6.75812L4.75206 6.75812L4.75736 5.25729H13.2426V13.7426H11.7471L11.7418 7.81878L5.28769 14.2729L4.22703 13.2122Z",fill:"currentColor"})})]}):"",(null==t?void 0:t.content)?Yn.jsx(i,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:t.content}):""]})]}),Yn.jsxs(i,{sx:{position:"relative",top:10,ml:12,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:12,borderStyle:"solid",borderWidth:l?"2.4px":0,borderColor:e.palette.border.main,backgroundColor:l?"transparent":e.palette.background.paperDarkContrast,cursor:"pointer",boxSizing:"border-box",[e.breakpoints.up("tablet")]:{ml:28}},onClick:n,children:[l?Yn.jsx(Hv,{size:24,strokeWidth:"2.4px",time:`${l}ms`,color:e.palette.text.disabled}):"",Yn.jsx(i,{component:"svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:16,height:16,border:"none",color:e.palette.text.disabled},children:Yn.jsx("g",{children:Yn.jsx("path",{d:"M12.8897 4.36345L9.25313 8L12.8897 11.6365L11.6775 12.8487L8.04095 9.21218L4.4044 12.8487L3.19221 11.6365L6.82876 8L3.19221 4.36345L4.4044 3.15127L8.04095 6.78782L11.6775 3.15127L12.8897 4.36345Z",fill:"currentColor"})})})]})]})})})}var Gv;function Qv(){return Qv=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Qv.apply(null,arguments)}const Yv=e=>W.createElement("svg",Qv({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Gv||(Gv=W.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},W.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},W.createElement("g",{transform:"translate(18.000000, 291.000000)"},W.createElement("g",{transform:"translate(40.000000, 83.000000)"},W.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"}))))))),Kv=6;function Xv(){var e;const t=a();return Yn.jsx(i,{sx:{mx:"auto",border:`${Kv}px solid ${null===(e=t.palette)||void 0===e?void 0:e.background.input}`,borderRadius:"50%",width:"64px",height:"64px",position:"relative",animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}},children:Yn.jsx(i,{component:Yv,sx:{position:"absolute",top:`-${Kv}px`,right:`-${Kv}px`,color:"primary.main"}})})}function Jv({showingDone:e,errorMessage:t}){return a(),t?Yn.jsx(i,{component:li.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?Yn.jsx(i,{component:li.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):Yn.jsx(Xv,{})}function eb({showingDone:e,showing:t}){return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[Yn.jsx(i,{sx:{mt:60},children:e?(null==t?void 0:t.brief)===Iy?se._({id:"EcVqOR",message:"{0} Submitted",values:{0:null==t?void 0:t.brief}}):se._({id:"4xbbt/",message:"{0} confirmed",values:{0:null==t?void 0:t.brief}}):se._({id:"/nzjSF",message:"{0} pending",values:{0:null==t?void 0:t.brief}})}),(null==t?void 0:t.subtitle)?Yn.jsx(i,{sx:{mt:20,typography:"body2"},children:null==t?void 0:t.subtitle}):""]})}function tb({isStarted:t,isEnded:n,tx:o,currentRequestChainId:a}){const[s,l]=z(0),{chainId:d}=dg(),c=$((()=>tg(a||d||1,o,"tx")),[a,d,o]),u=$((()=>{const e=Math.floor(s/60),t=s%60;return e?`${e}m ${t}s`:`${t}s`}),[s]),p=G();return Q((()=>(t&&(l(0),window.clearInterval(p.current),p.current=window.setInterval((()=>{l((e=>e+1))}),1e3)),()=>{window.clearInterval(p.current)})),[t]),Q((()=>{n&&window.clearInterval(p.current)}),[n]),Yn.jsxs(i,{sx:{mt:20,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.secondary",border:"solid 1px transparent",borderTopColor:"border.main"},children:[Yn.jsxs(i,{children:[Yn.jsx(e,{id:"+Jkdiu",message:"Transaction Time:"}),u]}),Yn.jsxs(r,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:c,target:"_blank",rel:"noopener noreferrer",children:[Yn.jsx(e,{id:"S3piC2",message:"Tx"}),Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function nb(t){var n,o,{children:r,executionStatus:a,showSubmitLoadingDialog:s}=t;const l=Mg(qn(t,["children","executionStatus","showSubmitLoadingDialog"])),{ctxVal:d,showing:u,closeShowing:p,setShowing:h,showingDone:m,errorMessage:g,transactionTx:f,requests:x}=Object.assign(Object.assign({},l),a),{isMobile:y}=Tg(),{noSubmissionDialog:v,submissionDialogModal:b}=Jn(),j=()=>{h((e=>{if(!e)return e;const t=Object.assign({},e);return delete t.submitState,t}))},C=m&&(null==u?void 0:u.brief)===Iy&&!g,w=null===(o=null===(n=null==x?void 0:x.get(f))||void 0===n?void 0:n[0].metadata)||void 0===o?void 0:o.chainId;return Yn.jsxs(Ng.Provider,{value:d,children:[r,s&&Yn.jsx(Of,{modal:!0,open:!!(null==u?void 0:u.submitState),onClose:j,children:!!u&&Yn.jsxs(i,{sx:{position:"relative",display:"flex",flexDirection:"column",alignItems:"center",gap:20,p:20,minHeight:208,width:y?"100%":340,textAlign:"center"},children:[Yn.jsxs(i,{sx:{textAlign:"center",color:"text.secondary"},children:[u.brief,Yn.jsx(i,{component:li.Error,sx:{position:"absolute",top:20,right:20,color:"text.secondary",cursor:"pointer"},onClick:j})]}),"submitted"===u.submitState?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.ArrowSubmit,sx:{width:64,height:64}}),Yn.jsxs("div",{children:[Yn.jsx("div",{children:se._({id:"EcVqOR",message:"{0} Submitted",values:{0:u.brief}})}),u.subtitle&&Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]}),Yn.jsx(c,{variant:c.Variant.outlined,fullWidth:!0,onClick:j,sx:{mt:4},children:Yn.jsx(e,{id:"zga9sT",message:"OK"})})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Xv,{}),Yn.jsxs("div",{children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"7y/8M6",message:"Please confirm in wallet"})}),u.subtitle&&Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",mt:8,color:"text.secondary",typography:"body2"},children:u.subtitle})]})]})]})}),Yn.jsx(Of,{open:!!u&&"loading"!==u.submitState&&!v,onClose:p,id:"submission",modal:!!y||b,children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",px:20,pb:20,flex:1,overflowY:"auto",width:y?void 0:b?340:void 0},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{textAlign:"center",pt:60},children:Yn.jsx(Jv,{showingDone:m,errorMessage:g})}),g?Yn.jsxs(i,{sx:{textAlign:"center",mt:60},children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"kf83Ld",message:"Something went wrong."})}),Yn.jsx(i,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:g})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(eb,{showingDone:m,showing:u}),Yn.jsx(tb,{isStarted:!!u,isEnded:m,tx:f,currentRequestChainId:w})]})]}),C&&Yn.jsx(c,{variant:c.Variant.outlined,fullWidth:!0,size:c.Size.big,onClick:()=>{yg(fg.Initial),p(),xg.setState({crossChainSubmittedCounter:1}),setTimeout((()=>{xg.setState({crossChainSubmittedCounter:0})}),300)},sx:{mt:y?20:"auto"},children:"Check in order list"}),Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:()=>{yg(fg.Initial),p()},sx:{mt:C?12:y?20:"auto"},children:g?Yn.jsx(e,{id:"1QfxQT",message:"Dismiss"}):Yn.jsx(e,{id:"yz7wBu",message:"Close"})})]})})]})}const ib="dodo-widget-container";function ob(e){return e.noLangProvider?Yn.jsx(Yn.Fragment,{children:e.children}):Yn.jsx(Vy,{locale:e.locale,children:Yn.jsx(nb,{...e,children:e.children})})}function rb(e){return Rf(e),wg(),function(){const{chainId:e,evmProvider:t}=dg();H.useEffect((()=>{const n=n=>{if(n===e){const e=ah.get(n);if(null==e?void 0:e.isEVMChain)return t}return null},i=new sn({multiCallAddressList:ct,getProvider:n,rpc:qu()});np.setGetConfigProvider(n),ut(i),Ie(i)}),[e,t])}(),e.noUI?Yn.jsx(ob,{...e,children:e.children}):null}function ab(e){var t;const n=G(null);return Yn.jsx(Xn,{...Object.assign(Object.assign({},e),{widgetRef:null!==(t=e.widgetRef)&&void 0!==t?t:n}),children:Yn.jsx(rb,{...e})})}function sb(e){const t=u({mode:e.colorMode,theme:e.theme,lang:e.locale||Ry});return e.apikey||e.apiServices||console.error("apikey and apiServices must have a."),Yn.jsxs(p,{theme:t,children:[Yn.jsx(h,{container:`.${ib}, .${m}, .${g}`}),Yn.jsx(rt,{client:Wy,children:Yn.jsxs(ab,{...e,children:[e.children,Yn.jsx(Zv,{})]})})]})}function lb(e){var{sx:t}=e,n=qn(e,["sx"]);const{width:i}=Jn(),o=$((()=>{let e="";return"number"==typeof i?e=`${i}px`:i&&(e=i),e?`calc(${e} - 40px)`:"auto"}),[i]);return Yn.jsx(f,{container:document.querySelector(`.${ib}`),maxWidth:o,sx:Object.assign({cursor:"help"},t),...n})}function db({route:t}){const n=a();ah.get(t.fromChainId);const o=ah.get(t.toChainId),[s,l]=z(!1),[c,u]=z(!1),p=df({fees:t.fees});return Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{py:20,borderStyle:"solid",borderWidth:n.spacing(1,0,0),borderColor:n.palette.border.main},children:Yn.jsx(x,{children:Yn.jsx(y,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[Yn.jsx(i,{component:li.DetailBorder,sx:{mr:6,width:18,height:18}}),Yn.jsx(e,{id:"rRDi3Y",message:"Detail"})]}),Yn.jsx(i,{component:li.CaretUp,sx:{width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]}),children:Yn.jsxs(i,{sx:{mt:16},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary",flexShrink:0},children:Yn.jsx(e,{id:"lt8yMa",message:"Send to:"})}),Yn.jsxs(i,{sx:{display:"flex",justifyContent:"flex-end",alignItems:"center"},children:[o?Yn.jsx(i,{component:o.logo,sx:{width:18,height:18}}):null,Yn.jsx(i,{sx:{display:"inline-block",mx:6,width:"1px",height:12,backgroundColor:"border.main"}}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},children:eg(t.toAddress)}),Yn.jsx(r,{component:"a",href:tg(t.toChainId,t.toAddress,"address"),target:"_blank",rel:"noopener noreferrer",sx:{ml:6,width:18,height:18,color:"text.secondary",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:18,height:18}})})]})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:Yn.jsx(e,{id:"sMMlTX",message:"Total fees"})}),Yn.jsxs(i,{component:d,onClick:()=>l(!s),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[Yn.jsx(i,{sx:{fontWeight:600,color:n.palette.text.primary},children:t.feeUSD?`~$${t.feeUSD}`:"-"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:s?Yn.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):Yn.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),s&&p.map((e=>Yn.jsxs(i,{sx:{mt:8,pl:22,pr:22,display:"flex",alignItems:"center",justifyContent:"space-between",color:"text.secondary",typography:"body2",position:"relative"},children:[Yn.jsx(i,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:"10",height:"25",viewBox:"0 0 10 25",fill:"none",sx:{width:10,height:25,position:"absolute",left:10,bottom:10},children:Yn.jsx("path",{d:"M9 24L2 24C1.44772 24 1 23.5523 1 23L1 1",stroke:"currentColor",strokeOpacity:"0.5",strokeLinecap:"round",strokeDasharray:"2 2"})}),Yn.jsx(i,{sx:{flex:1},children:e.title}),e.isFree?Yn.jsx(i,{sx:{color:n.palette.primary.main},children:"Free"}):null!==e.value?Yn.jsxs(i,{sx:{color:n.palette.text.primary},children:["~$",e.value]}):Yn.jsx(i,{sx:{color:n.palette.text.primary},children:"-"})]},e.title))),Yn.jsxs(i,{sx:{mt:8,mb:c?8:0,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"body2",fontWeight:600,color:"success.main",flexShrink:0},children:"Fee comparison"}),Yn.jsxs(i,{component:d,onClick:()=>u(!c),sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:4,typography:"body2",color:"text.primary"},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary},children:"ZUNO"}),Yn.jsx(i,{sx:{px:8,borderRadius:12,backgroundColor:n.palette.success.main,typography:"h6",fontWeight:600,color:n.palette.success.contrastText,textTransform:"uppercase"},children:"Cheapest"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:c?Yn.jsx("path",{d:"M3.75 11.2663L4.98375 12.5L9 8.4925L13.0162 12.5L14.25 11.2663L9 6.01625L3.75 11.2663Z",fill:"currentColor",fillOpacity:"0.5"}):Yn.jsx("path",{d:"M14.25 7.73375L13.0163 6.5L9 10.5075L4.98375 6.5L3.75 7.73375L9 12.9838L14.25 7.73375Z",fill:"currentColor",fillOpacity:"0.5"})})]})]}),c&&Yn.jsx(If,{feeUSD:t.feeUSD}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"body2",color:"text.secondary",flexShrink:0},children:[Yn.jsx(e,{id:"CMHmbm",message:"Slippage"}),Yn.jsx(lb,{onlyHover:!0,title:Yn.jsx(e,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:6})]}),Yn.jsxs(i,{sx:{typography:"body2"},children:[100*t.slippage,"%"]})]})]})})})}),Yn.jsx(i,{sx:{pt:0,pb:0,borderStyle:"solid",borderWidth:n.spacing(1,0,0),borderColor:n.palette.border.main},children:Yn.jsx(x,{children:Yn.jsx(y,{initialEntered:!0,sx:{"& button.active svg":{transform:"rotate(0)"}},header:Yn.jsxs(i,{sx:{py:20,display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.primary"},children:[Yn.jsx(i,{component:li.DetailBorder,sx:{mr:6,width:18,height:18}}),Yn.jsx(e,{id:"QNWt8A",message:"Estimated Time"})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:[t.executionDuration?hf({start:Date.now(),end:Date.now()+1e3*t.executionDuration}):"-",Yn.jsx(i,{component:li.CaretUp,sx:{ml:6,width:12,height:12,color:"text.secondary",transform:"rotate(180deg)",transition:"transform 0.2s linear"}})]})]}),children:Yn.jsx(hy,{route:t,isMobile:!0})})})})]})}function cb({open:t,onClose:n,route:o,bridgeOrderTxRequest:r,clearToAmt:s,clearFromAmt:l,isDialogModal:d}){const u=a(),{contractStatus:p}=xg(),h=Ey({route:o,bridgeOrderTxRequest:r});return Q((()=>{p!==fg.Pending&&n(),p===fg.TxSuccess&&(s(),l())}),[p]),Yn.jsx(Of,{title:Yn.jsx(e,{id:"tKE4Ak",message:"Cross Chain Summary"}),open:t,id:"cross-chain-summary",onClose:()=>{yg(fg.Initial),n()},modal:d,children:Yn.jsxs(Yn.Fragment,{children:[o?Yn.jsxs(i,{sx:{px:16,pb:20,flex:1,overflowY:"auto"},children:[Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"36% 28% 36%",py:20,borderStyle:"solid",borderWidth:u.spacing(1,0,0),borderColor:u.palette.border.main},children:[Yn.jsx(Ly,{token:o.fromToken,chainId:o.fromChainId,amount:o.fromAmount}),Yn.jsx(Oy,{children:Yn.jsx(i,{sx:{display:"flex",px:3,py:3,backgroundColor:u.palette.background.paperContrast,border:`1px solid ${u.palette.border.main}`,borderRadius:"50%",alignItems:"center",width:24,height:24,overflow:"hidden"},children:Yn.jsx(Ay,{size:"medium",toolDetails:o.step.toolDetails,nameMarginLeft:8})})}),Yn.jsx(Ly,{token:o.toToken,chainId:o.toChainId,amount:o.toTokenAmount})]}),Yn.jsx(db,{route:o})]}):"",Yn.jsx(i,{sx:{px:16,py:20},children:Yn.jsx(c,{fullWidth:!0,isLoading:p==fg.Pending,disabled:!o,onClick:()=>{h(),yg(fg.Pending)},children:p==fg.Pending?Yn.jsx(e,{id:"P+K/3O",message:"Confirming"}):Yn.jsx(e,{id:"PZqJog",message:"Confirm Cross Chain"})})})]})})}function ub({message:t,onClose:n,isDialogModal:o}){return Yn.jsx(Of,{open:!!t,onClose:n,id:"error-message",modal:o,children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{flex:1,textAlign:"center"},children:[Yn.jsx(i,{component:li.ErrorWarn,sx:{mt:60,width:64,height:64,color:"error.main"}}),t?Yn.jsxs(i,{sx:{textAlign:"center",mt:60},children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"kf83Ld",message:"Something went wrong."})}),Yn.jsx(i,{sx:{color:"text.secondary",mt:12,mx:20,typography:"body2",wordBreak:"break-all",overflow:"auto",height:"300px"},children:t})]}):""]}),Yn.jsx(i,{sx:{px:16,py:20},children:Yn.jsx(c,{onClick:n,fullWidth:!0,children:Yn.jsx(e,{id:"1QfxQT",message:"Dismiss"})})})]})})}function pb(){const[e,t]=z(!1);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(d,{sx:{mt:16,width:"100%",display:"flex",alignItems:"center",justifyContent:"center",gap:4,typography:"body2",fontWeight:600,color:"text.link","&:hover":{color:"text.primary"}},onClick:()=>t(!0),children:[Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"19",height:"19",viewBox:"0 0 19 19",fill:"none",children:Yn.jsx("path",{d:"M3.5 16.25V4.25C3.5 3.8375 3.64687 3.48438 3.94063 3.19063C4.23438 2.89687 4.5875 2.75 5 2.75H9.5C9.9125 2.75 10.2656 2.89687 10.5594 3.19063C10.8531 3.48438 11 3.8375 11 4.25V9.5H11.75C12.1625 9.5 12.5156 9.64688 12.8094 9.94063C13.1031 10.2344 13.25 10.5875 13.25 11V14.375C13.25 14.5875 13.3219 14.7656 13.4656 14.9094C13.6094 15.0531 13.7875 15.125 14 15.125C14.2125 15.125 14.3906 15.0531 14.5344 14.9094C14.6781 14.7656 14.75 14.5875 14.75 14.375V8.975C14.6375 9.0375 14.5188 9.07813 14.3938 9.09688C14.2688 9.11563 14.1375 9.125 14 9.125C13.475 9.125 13.0312 8.94375 12.6688 8.58125C12.3063 8.21875 12.125 7.775 12.125 7.25C12.125 6.85 12.2344 6.49063 12.4531 6.17188C12.6719 5.85313 12.9625 5.625 13.325 5.4875L11.75 3.9125L12.5375 3.125L15.3125 5.825C15.5 6.0125 15.6406 6.23125 15.7344 6.48125C15.8281 6.73125 15.875 6.9875 15.875 7.25V14.375C15.875 14.9 15.6938 15.3438 15.3313 15.7063C14.9688 16.0688 14.525 16.25 14 16.25C13.475 16.25 13.0312 16.0688 12.6688 15.7063C12.3063 15.3438 12.125 14.9 12.125 14.375V10.625H11V16.25H3.5ZM5 8H9.5V4.25H5V8ZM14 8C14.2125 8 14.3906 7.92813 14.5344 7.78438C14.6781 7.64062 14.75 7.4625 14.75 7.25C14.75 7.0375 14.6781 6.85938 14.5344 6.71563C14.3906 6.57188 14.2125 6.5 14 6.5C13.7875 6.5 13.6094 6.57188 13.4656 6.71563C13.3219 6.85938 13.25 7.0375 13.25 7.25C13.25 7.4625 13.3219 7.64062 13.4656 7.78438C13.6094 7.92813 13.7875 8 14 8Z",fill:"currentColor"})}),"Gas Refuel>"]}),Yn.jsx(Of,{open:e,onClose:()=>t(!1),title:"Gas refuel",modal:!0,children:Yn.jsxs(i,{sx:{maxWidth:540,minHeight:600,px:20,pb:24,display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[Yn.jsx(i,{sx:{pt:20,borderTopWidth:1,borderTopStyle:"solid",borderColor:"border.main",typography:"body2",color:"text.secondary"},children:"A solution for gas refueling that allows you to refill your wallet anonymously and gas-free."}),Yn.jsx(i,{component:"iframe",src:"https://smolrefuel.com/?partner=0x1271CAba4bf23f8Fb31F97448605d65EE302CA51",width:"100%",sx:{borderRadius:12,overflow:"hidden",flex:1,border:"none"}})]})})]})}function hb({open:t,execute:n,onClose:o,toToken:r,fromToken:s,fromAmount:l,toAmount:u,priceImpact:p,clearFromAmt:h,clearToAmt:m,baseFeeAmount:g,curToFiatPrice:f,curFromFiatPrice:x,pricePerFromToken:y,additionalFeeAmount:b,loading:j,slippage:C,isDialogModal:w}){var k,T;const I=a(),{contractStatus:S}=xg(),E=$((()=>new Pe(p).gt(mh)),[p]),[A,O]=z(!1),[L,R]=z(!1);return Q((()=>{S!==fg.Pending&&o(),S===fg.TxSuccess&&(m(),h())}),[S]),Q((()=>{O(!1)}),[f]),Yn.jsx(Of,{open:t,onClose:()=>{yg(fg.Initial),o()},id:"swap-summary",title:Yn.jsx(e,{id:"QR4/RH",message:"Swap summary"}),modal:w,children:Yn.jsxs(i,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${I.palette.border.main}`},children:[Yn.jsxs(i,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${I.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[Yn.jsx(Df,{width:16,height:16,url:null==s?void 0:s.logoURI,address:null!==(k=null==s?void 0:s.address)&&void 0!==k?k:"",marginRight:6}),Yn.jsx(i,{children:`${Am({input:l,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`})]}),Yn.jsx(i,{sx:{mt:4,typography:"h6",color:I.palette.text.secondary},children:x?`$${Em({input:x,showDecimals:1})}`:"-"})]}),Yn.jsx(i,{sx:{width:16,mx:16},component:li.DoubleRight}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex"},children:[Yn.jsx(Df,{width:16,height:16,marginRight:6,url:null==r?void 0:r.logoURI,address:null!==(T=null==r?void 0:r.address)&&void 0!==T?T:""}),Yn.jsx(v,{loading:j,loadingProps:{width:30},children:`${Am({input:u,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`})]}),Yn.jsx(v,{loading:j,loadingProps:{width:30},sx:{typography:"h6",mt:4,color:I.palette.text.secondary},children:f?`$${Em({input:f,showDecimals:1})}`:"-"})]})]}),Yn.jsxs(i,{sx:{mt:12,display:"flex",alignItems:"center",typography:"h6"},children:["1 ",null==s?void 0:s.symbol," = ",Yn.jsx(v,{loading:j,loadingProps:{width:30},children:Am({input:new Pe(u).dividedBy(new Pe(l)),decimals:null==r?void 0:r.decimals})})," ",null==r?void 0:r.symbol]})]}),Yn.jsxs(i,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${I.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:I.palette.text.secondary},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{width:16,mr:7},component:li.DetailBorder}),Yn.jsx(e,{id:"XeovX3",message:"Swap Detail"})]}),Yn.jsx(i,{component:d,children:Yn.jsx(i,{onClick:()=>R(!L),sx:{width:10,color:"text.secondary",transform:L?"rotateX(0deg)":"rotateX(180deg)"},component:li.CaretUp})})]}),Yn.jsxs(i,{sx:{mt:16,display:L?"initial":"none"},children:[Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"93m8jT",message:"Basic Fee"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"8Z29ZO",message:"Estimated service provider fees"}),ml:5})]}),Yn.jsx(v,{loading:j,loadingProps:{width:30},children:g?`${Am({input:g,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`:"0"})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"J39pAJ",message:"Additional Fee"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"ZXvy7b",message:"Additional routing fees set by the Widget user"}),ml:5})]}),Yn.jsx(v,{loading:j,loadingProps:{width:30},children:b?`${Am({input:b,decimals:null==r?void 0:r.decimals})} ${null==r?void 0:r.symbol}`:"0"})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"T+qgFw",message:"Price Impact"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),Yn.jsx(i,{children:`${p}%`})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"CMHmbm",message:"Slippage"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"GAypnX",message:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),Yn.jsxs(i,{children:[C,"%"]})]})]})]}),Yn.jsx(i,{sx:{flex:1}}),E&&Yn.jsxs(i,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>O(!A),children:[Yn.jsx(i,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:A?Yn.jsx(i,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:Yn.jsx(i,{component:li.Done,sx:{width:14,color:"secondary.contrastText"}})}):Yn.jsx(i,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${I.palette.text.secondary}`}})}),Yn.jsx(i,{children:Yn.jsx(e,{components:{0:Yn.jsx(i,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:p},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),Yn.jsx(c,{isLoading:S==fg.Pending,disabled:E&&!A,fullWidth:!0,onClick:()=>{n(),yg(fg.Pending)},children:S==fg.Pending?Yn.jsx(e,{id:"P+K/3O",message:"Confirming"}):Yn.jsx(e,{id:"lQ6r7x",message:"Confirm swap"})})]})})}function mb(e){var{sx:t,maxVal:n,decimals:i=2,onInputChange:o}=e,r=qn(e,["sx","maxVal","decimals","onInputChange"]);return Yn.jsx(b,{...r,onChange:e=>{const t=0===e.target.value.length?null:Rm(e.target.value,i),r=n&&t&&new _e(t).gt(n)?n.toString():t;o&&o(r)}})}function gb({open:t,onClose:n,isBridge:o,isDialogModal:r}){const s=a(),{slippage:l}=xg(),d=$((()=>Number(l)>=fh),[l]),{defaultSlippage:c}=Kg(o);return Yn.jsx(Of,{open:t,onClose:n,id:"swap-settings",title:Yn.jsx(e,{id:"Tz0i8g",message:"Settings"}),modal:r,children:Yn.jsx(i,{sx:{mx:20},children:Yn.jsxs(i,{sx:{py:20,borderTop:`1px solid ${s.palette.border.main}`},children:[Yn.jsxs(i,{sx:{mb:16,display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"lqTDfd",message:"Slippage Tolerance"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column"},children:[Yn.jsx(mb,{fullWidth:!0,maxVal:100,value:null!=l?l:"",placeholder:c.toString(),onInputChange:e=>{!function(e,t){null===t?localStorage.removeItem(e?ph:uh):localStorage.setItem(e?ph:uh,String(t))}(!!o,e),bg(e)},suffix:Yn.jsx(i,{sx:{color:"text.disabled"},children:"%"}),height:36,sx:{mt:12}}),d&&Yn.jsx(i,{sx:{typography:"h6",mt:6,color:"error.main"},children:Yn.jsx(e,{id:"Zm56FI",message:"Maximum slippage do not exceed 50%"})})]})]})})})}const fb="position-y-dot";function xb(){return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(j,{width:"100%",height:12}),Yn.jsx(j,{width:"100%",height:12})]})}function yb({data:e,loading:t}){var n,o;const r=a(),s=r.palette.primary.main,l=H.useRef(null),d=e.length;return Yn.jsx(i,{sx:{height:105,flex:1,[`& .${fb}`]:{}},ref:l,children:t?Yn.jsx(xb,{}):Yn.jsx(i,{component:dn,sx:{typography:"h6","& .recharts-cartesian-axis text":{fill:r.palette.background.paperContrast}},children:Yn.jsxs(cn,{data:e,margin:{top:0,right:0,left:0,bottom:0},children:[Yn.jsx(un,{dataKey:"forecastSlippage",axisLine:!1,tickLine:!1,interval:"preserveStartEnd",tickFormatter:e=>Vm({input:e}),type:"number",domain:[d&&null!==(n=e[0].forecastSlippage)&&void 0!==n?n:0,d&&null!==(o=e[d-1].forecastSlippage)&&void 0!==o?o:"auto"]}),Yn.jsx(pn,{dataKey:"confidenceRatio",axisLine:!1,tickLine:!1,hide:!0}),Yn.jsx("defs",{children:Yn.jsxs("linearGradient",{id:"count-linear",x1:"0",y1:"0",x2:"0",y2:"1",children:[Yn.jsx("stop",{offset:"0",stopColor:s,stopOpacity:.3}),Yn.jsx("stop",{offset:"100%",stopColor:s,stopOpacity:0})]})}),Yn.jsx(hn,{type:"monotone",dataKey:"confidenceRatio",stroke:s,strokeWidth:2,fill:"url(#count-linear)"}),e.map((e=>Yn.jsx(mn,{x:e.forecastSlippage,y:e.confidenceRatio,r:1,fill:r.palette.text.primary,stroke:"none",className:fb},e.confidenceRatio)))]})})})}var vb=H.memo(yb);const bb=C(w)((({theme:e})=>({height:2,padding:"15px 0",margin:0,"& .base-Slider-valueLabel":{fontSize:12,fontWeight:"normal",top:-6,backgroundColor:"unset",color:e.palette.text.primary,"&:before":{display:"none"},"& *":{background:"transparent",color:e.palette.text.primary}},"& .base-Slider-track":{display:"none"},"& .base-Slider-rail":{backgroundColor:e.palette.text.disabled,height:1,opacity:1},"& .base-Slider-mark":{display:"none",opacity:1,backgroundColor:e.palette.success.main,height:6,width:4,borderRadius:4},"& .base-Slider-markLabel":{display:"none",fontSize:"12px",lineHeight:"17px"}})));function jb(t){var{hidden:n,sx:o,value:r,color:a,min:s,max:l,formatValue:d,getSliderYPosition:c}=t,u=qn(t,["hidden","sx","value","color","min","max","formatValue","getSliderYPosition"]);const{children:p}=u,h=qn(u,["children"]),{isMobile:m}=k(),g=H.useRef(null),f=c(r),x=m?4:0,y=f?f-39-x:void 0,v=null!=a?a:"text.primary",b=r===s,j=r===l;return Yn.jsxs(i,{...h,ref:g,sx:Object.assign({position:"absolute","&&&":{display:n?"none":"block",backgroundColor:"transparent",boxShadow:"none",bottom:8+x,width:"auto",height:"auto",top:"auto",marginLeft:0,transform:"none"}},o),children:[p,Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[y?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:v,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),Yn.jsx(i,{sx:{height:y,width:"0",borderStyle:"dashed",borderWidth:1,borderColor:v}})]}):"",Yn.jsx(i,{sx:{width:16,height:16,borderRadius:"50%",backgroundColor:v,borderStyle:"solid",borderWidth:2,borderColor:"background.paperContrast",flexShrink:1}}),Yn.jsxs(i,{sx:Object.assign(Object.assign({typography:"h6",position:"absolute",bottom:-20,color:v,whiteSpace:"nowrap",backgroundColor:"background.paperContrast"},b?{left:0}:{}),j?{right:0}:{}),children:[j?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:"span",sx:{color:"success.main"},children:Yn.jsx(e,{id:"cOvZFM",message:"Dynamic"})}),Yn.jsx("span",{children:" • "})]}):"",d(r)]})]})]})}function Cb(e){var{hoverValue:t,formatValue:n,getSliderYPosition:i}=e,o=qn(e,["hoverValue","formatValue","getSliderYPosition"]);const{isMobile:r}=k(),a=r?"primary.main":void 0,s=r?void 0:"primary.main";return Yn.jsx(bb,{slots:{thumb:e=>{const l=o.value&&"number"==typeof o.value&&(o.min&&o.value<o.min||o.max&&o.value>o.max),d={value:o.value,min:o.min,max:o.max,hidden:!!l,color:a,formatValue:n,getSliderYPosition:i},c=Object.assign(Object.assign({},e),d);if(null!==t&&o.max&&o.min&&o.value!==t){const e=o.max-o.min,n=t-o.min,i=n?n/e*100:0;if(r){const e=!!t&&(!!o.min&&t<o.min||!!o.max&&t>o.max);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(jb,{...d,value:t,color:s,hidden:e,sx:{left:i+"%"}}),Yn.jsx(jb,{...c})]})}return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(jb,{...c}),Yn.jsx(jb,{...d,value:t,hidden:!1,color:s,sx:{left:i+"%"}})]})}return Yn.jsx(jb,{...c})}},...o})}const wb=(e,{time:t=100,wrapper:n=document,retryCount:i=50}={})=>new Promise((o=>{n.querySelector(e)?o(!0):setTimeout((()=>Vn(void 0,void 0,void 0,(function*(){if(n.querySelector(e))o(!0);else if(i){const r=yield wb(e,{time:t,wrapper:n,retryCount:i-1});o(r)}else o(!1)}))),t)}));function kb({data:t,activeSlippage:n,loading:o,sx:r,handleChangeCustomSlippage:a}){const s=H.useMemo((()=>{var e;return null!==(e=null==t?void 0:t.length)&&void 0!==e?e:0}),[t]),{isMobile:l}=k(),[d,c]=H.useState([]),u=H.useRef(null);H.useEffect((()=>{(()=>{Vn(this,void 0,void 0,(function*(){var e;if(u.current&&s){const t=`.${fb}`;yield wb(t,{wrapper:u.current});const n=u.current.querySelectorAll(t),{y:i,height:o}=u.current.getBoundingClientRect(),r=null!==(e=null==n?void 0:n.length)&&void 0!==e?e:0,a=[];for(let e=0;e<r;e++){const t=n[e];const r=(t.children[0]?t.children[0].getBoundingClientRect().y:t.getBoundingClientRect().y)-i-.5;a.push(o-r)}c(a)}}))})()}),[s]);const p=(({activeSlippage:e,data:t,yPositions:n})=>{const[i,o]=H.useState(0),r=H.useMemo((()=>1e6),[]),[a,s]=H.useMemo((()=>{var e,n;const i=null==t?void 0:t.length;return i?[new Pe(null!==(e=t[0].forecastSlippage)&&void 0!==e?e:0).times(null!=r?r:0).dp(0,1).toNumber(),new Pe(null!==(n=t[i-1].forecastSlippage)&&void 0!==n?n:0).times(null!=r?r:0).dp(0,1).toNumber()]:[0,0]}),[t,r]),l=H.useCallback((e=>{if(void 0===e)return"";const n=new Pe(e);if((null==t?void 0:t.length)&&r){const e=t.find((e=>{var t;return new Pe(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(r).dp(0,1).isEqualTo(n)}));if(null==e?void 0:e.forecastSlippage)return Vm({input:e.forecastSlippage,showDecimals:4})}return Vm({input:r?n.div(r):n,showDecimals:4})}),[r,t]),d=H.useCallback((e=>{let i=0;return e&&(null==t?void 0:t.length)&&r?(t.some(((o,a)=>{var s,l;const d=null!==(s=o.forecastSlippage)&&void 0!==s?s:0,c=new Pe(d).times(r).dp(0,1).toNumber();if(e===c)return i=n[a],!0;if(e<c){if(0===a)return i=0,!0;const o=d-(null!==(l=t[a-1].forecastSlippage)&&void 0!==l?l:0),s=n[a]-n[a-1],c=d-new Pe(e).div(r).toNumber();return i=n[a]-s/o*c,!0}})),i):i}),[n,t,r]),c=H.useCallback((e=>{o(e);const n=new Pe(e);let i,a=-1;if((null==t?void 0:t.length)&&r){a=t.findIndex((e=>{var t;return new Pe(null!==(t=e.forecastSlippage)&&void 0!==t?t:0).times(r).dp(0,1).isEqualTo(n)}));const e=-1!==a?t[a]:void 0;i=null==e?void 0:e.forecastSlippage}return i||(i=n.div(null!=r?r:0).toNumber()),i}),[t,r]);return H.useEffect((()=>{if(r&&e){const t=new Pe(e).times(r).dp(0,1);t.isEqualTo(i)||o(t.toNumber())}}),[e]),{min:a,max:s,value:i,decimalConversion:r,formatValue:l,getSliderYPosition:d,handleChangeValue:c}})({data:t,activeSlippage:n,yPositions:d}),{hoverValue:h,setHoverValue:m}=function(e,{slippageSlider:t}){const{isMobile:n}=k(),[i,o]=H.useState(null),r=H.useRef(!1);return H.useEffect((()=>{if(e.current&&t.max){const a=e.current;let{width:s,x:l}=a.getBoundingClientRect();const d=e=>{if(r.current)return;const n=e.pageX-l,a=t.max-t.min,d=new Pe(n/s*a).integerValue().plus(t.min).toNumber();d!==i&&o(d)},c=()=>{o(null)},u=()=>{r.current=!1},p=()=>{r.current=!0};return n||(a.addEventListener("mousemove",d),a.addEventListener("mouseleave",c),a.addEventListener("mouseup",u),a.addEventListener("mousedown",p)),()=>{n&&(a.removeEventListener("mousemove",d),a.removeEventListener("mouseleave",c),a.removeEventListener("mouseUp",u),a.removeEventListener("mouseDown",p))}}}),[e,n]),{hoverValue:i,setHoverValue:o}}(u,{slippageSlider:p}),{successRate:g,hoverSuccessRate:f}=function({data:e,activeSlippage:t,hoverValue:n,decimalConversion:i}){const o=H.useMemo((()=>{var n,i;let o="-";if(t&&(null==e?void 0:e.length)){const r=e.some(((n,i)=>{var r,a,s,l,d,c;const u=null!==(r=n.forecastSlippage)&&void 0!==r?r:0;if(t===u)return o=Vm({input:null!==(a=null==n?void 0:n.confidenceRatio)&&void 0!==a?a:0}),!0;if(t<u){if(0===i)o=`< ${Vm({input:null!==(s=null==n?void 0:n.confidenceRatio)&&void 0!==s?s:0})}`;else{const t=Vm({input:null!==(d=null===(l=e[i-1])||void 0===l?void 0:l.confidenceRatio)&&void 0!==d?d:0}),r=Vm({input:null!==(c=null==n?void 0:n.confidenceRatio)&&void 0!==c?c:0});o=`${t} - ${r}`}return!0}return!1}));r||(o=`> ${Vm({input:null!==(i=null===(n=e[e.length-1])||void 0===n?void 0:n.confidenceRatio)&&void 0!==i?i:0})}`)}return o}),[e,t]),r=H.useMemo((()=>{var t,o;let r="";if(n&&(null==e?void 0:e.length)&&i){const a=e.some(((t,o)=>{var a,s,l,d,c,u;const p=null!==(a=t.forecastSlippage)&&void 0!==a?a:0,h=new Pe(p).times(i).dp(0,1).toNumber();if(n===h)return r=Vm({input:null!==(s=null==t?void 0:t.confidenceRatio)&&void 0!==s?s:0}),!0;if(n<h){if(0===o)r=`< ${Vm({input:null!==(l=null==t?void 0:t.confidenceRatio)&&void 0!==l?l:0})}`;else{const n=Vm({input:null!==(c=null===(d=e[o-1])||void 0===d?void 0:d.confidenceRatio)&&void 0!==c?c:0}),i=Vm({input:null!==(u=null==t?void 0:t.confidenceRatio)&&void 0!==u?u:0});r=`${n} - ${i}`}return!0}return!1}));a||(r=`> ${Vm({input:null!==(o=null===(t=e[e.length-1])||void 0===t?void 0:t.confidenceRatio)&&void 0!==o?o:0})}`)}return r}),[n,i,e]);return{successRate:o,hoverSuccessRate:r}}({data:t,activeSlippage:n,hoverValue:h,decimalConversion:p.decimalConversion});return t?Yn.jsxs(i,{sx:Object.assign({p:12,pb:28,borderRadius:12,backgroundColor:"background.paperContrast"},r),children:[Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{typography:"h6",fontWeight:600,color:"text.secondary"},children:Yn.jsx(e,{id:"88dol0",message:"Success Rate"})}),Yn.jsx(v,{loading:o,loadingProps:{width:100},sx:{mt:4,typography:"caption",color:f?"primary.main":"text.primary"},children:f||g})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"flex-end",pr:4},children:[Yn.jsx(i,{sx:{pb:8,mr:16,typography:"h6",fontWeight:600},children:Yn.jsx(e,{id:"CMHmbm",message:"Slippage"})}),Yn.jsxs(i,{sx:{flex:1},ref:u,children:[Yn.jsx(vb,{data:t,loading:o}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:!o&&s?Yn.jsx(Cb,{value:l?h||-1:p.value,min:p.min,max:p.max,disabled:!l,marks:[{value:p.max,label:p.max}],formatValue:p.formatValue,getSliderYPosition:p.getSliderYPosition,hoverValue:l?p.value:h,onChange:(e,t)=>{if("number"==typeof t){if(l)return void m(t);const e=p.handleChangeValue(t);a(e)}},onChangeCommitted:()=>{m(null)}}):""})]})]})]}):null}var Tb,Ib=H.memo(kb);function Sb({title:t,desc:n,doNotChecked:o,onChangeDoNotChecked:r}){const s=a();if($((()=>o),[]))return null;const l=s.palette.warning.main;return Yn.jsxs(i,{sx:{backgroundColor:T(l,.1),borderRadius:8,padding:12},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,typography:"body2",color:l,fontWeight:700},children:[Yn.jsx(li.Warn,{}),t]}),Yn.jsx(i,{sx:{mt:8,typography:"body2",fontWeight:500,color:s.palette.text.secondary,textAlign:"center"},children:n}),!!r&&Yn.jsxs(i,{sx:{width:"100%",mt:20,color:s.palette.text.secondary,typography:"h6",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",gap:8,cursor:"pointer"},component:"label",children:[Yn.jsx(I,{checked:o,size:16,onChange:e=>{const{checked:t}=e.target;r(t)}}),Yn.jsx(e,{id:"3WdxUv",message:"Do not remind again"})]})]})}function Eb({fromToken:t,toToken:n}){var o,r;const s=a(),{slippageAdvanced:d,notRemindAgainSlippageHigher:c,notRemindAgainSlippageLower:u}=Gg(),{customSlippage:p,customSlippageNum:h,handleSlippageChange:m,forecastSlippage:g,forecastSlippageQuery:x,recommendSlippage:y}=tf({fromToken:t,toToken:n}),j=!!g,[C,w]=H.useState(!1),[k,L]=H.useState();!k&&t&&n&&L(p?Tb.custom:Tb.recommend);const R=k===Tb.custom,P=H.useRef(null),_=H.useMemo((()=>k===Tb.custom?h?new Pe(h).div(100).toNumber():void 0:new Pe(y).div(100).toNumber()),[k,y,h]),M=H.useCallback((e=>{R||L(Tb.custom),m({slippage:new Pe(e).times(100).toString(),disabled:!1,deleted:!1,recommend:String(y)})}),[R,y,m]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{mt:24,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[Yn.jsx(e,{id:"x6GJ4a",message:"Max Slippage"}),Yn.jsx(f,{title:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"qoii6e",message:"The dynamic slippage is provided by ZUNO team through analyzing historical transactions."}),Yn.jsx("br",{}),Yn.jsxs(i,{component:"a",href:se._({id:"zABfk1",message:"https://blog.dodoex.io/introducing-the-dodo-smart-slippage-3d32d13a4fef"}),target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[Yn.jsx(e,{id:"NgeSlx",message:"Learn More"}),">"]})]}),ml:7})]}),x.isLoading||(null===(o=x.slippageData.slippageList)||void 0===o?void 0:o.length)?Yn.jsxs(v,{loading:x.isLoading,loadingProps:{width:100},component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[Yn.jsx(e,{id:"sxkWRg",message:"Advanced"}),Yn.jsx(I,{sx:{top:-1},size:16,checked:d,onChange:e=>{const{checked:t}=e.target;Gg.setState({slippageAdvanced:t})}})]}):""]}),!!k&&Yn.jsxs(S,{value:k,onChange:(e,t)=>{L(t),t===Tb.custom&&w(!0)},children:[Yn.jsxs(E,{variant:"inPaper",sx:{mt:16,'&:not(:hover) [aria-selected="true"] .weak':{color:T(s.palette.secondary.contrastText,.5)}},children:[Yn.jsx(A,{value:Tb.recommend,variant:"inPaper",sx:{position:"relative"},children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:"span",sx:{position:"absolute",top:4,left:4,ml:4,typography:"h6",fontWeight:600,padding:s.spacing(0,8),borderRadius:4,backgroundColor:R?T(s.palette.purple.main,.1):"#FFF"},children:Yn.jsx(i,{component:"span",sx:{background:R?`linear-gradient(90deg, ${s.palette.purple.main} -1.33%, ${"dark"===s.palette.mode?"#E6D9FF":"#BFAFF3"} 98.67%)`:`linear-gradient(90deg, ${s.palette.purple.main} -1.33%, #BFAFF3 98.67%)`,backgroundClip:"text",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"New"})}),Yn.jsxs(i,{sx:{textAlign:"center"},children:[j?Yn.jsxs(i,{sx:{flexGrow:1,typography:"body2",fontWeight:600},children:[y.toString()||"-","%"]}):Yn.jsx(l,{title:Yn.jsx(e,{id:"wSpNR+",message:"This trading pair does not have enough historical data and has used the default dynamic slippage."}),sx:{ml:0,maxWidth:240},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"body2",fontWeight:600,color:s.palette.warning.main,gap:4},children:[Yn.jsx(i,{component:li.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),Yn.jsxs("span",{children:[y.toString()||"-","%"]})]})}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:600},className:"weak",children:Yn.jsx(e,{id:"cOvZFM",message:"Dynamic"})})]})]})}),Yn.jsx(A,{value:Tb.custom,variant:"inPaper",sx:{position:"relative",p:0},children:Yn.jsxs(i,{sx:{px:16,py:12,typography:"body2",fontWeight:600,textAlign:"center"},onClick:()=>{setTimeout((()=>{w(!0)}))},children:[C?Yn.jsx(b,{ref:P,placeholder:"-",sx:{backgroundColor:"transparent",borderWidth:0,"& input":{textAlign:"center",typography:"body2",p:0,boxSizing:"border-box",height:19,color:R?s.palette.secondary.contrastText:s.palette.text.secondary,"&::placeholder":{color:"custom.input.placeholder",opacity:1}}},inputMode:"decimal",value:p||"",autoFocus:!0,onChange:e=>{const t=e.target.value;m({slippage:t,disabled:!1,recommend:String(y)})},onBlur:()=>{setTimeout((()=>{if(w(!1),!h)return void L(Tb.recommend);const e=!h||h<0;e&&p&&m({slippage:p,disabled:e,deleted:e,recommend:String(y)})}),10)},onKeyDown:e=>{var t;"Enter"===e.code&&(e.preventDefault(),null===(t=P.current)||void 0===t||t.blur())}}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,color:p&&R?s.palette.warning.main:void 0},children:[p&&Yn.jsx(i,{component:li.Alarm,sx:{position:"relative",top:-2,width:18,height:18}}),p||"-","%"]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",typography:"h6",fontWeight:600},className:"weak",children:Yn.jsx(e,{id:"8Tg/JR",message:"Custom"})})]})})]}),Yn.jsx(O,{value:Tb.recommend,children:(null===(r=x.slippageData.slippageList)||void 0===r?void 0:r.length)&&d?Yn.jsx(Ib,{data:x.slippageData.slippageList,activeSlippage:_,loading:x.isLoading,handleChangeCustomSlippage:M,sx:{mt:8}}):""}),Yn.jsxs(O,{value:Tb.custom,children:[Yn.jsx(i,{sx:{mt:8}}),h>y&&Yn.jsx(Sb,{title:se._({id:"8XNsbx",message:"Higher than dynamic slippage"}),desc:se._({id:"iLj1a9",message:"Dynamic slippage is {recommendSlippage}%,the current slippage setting is higher than the dynamic slippage, which means you are willing to accept a worse final execution price.",values:{recommendSlippage:y}}),doNotChecked:c,onChangeDoNotChecked:e=>Gg.setState({notRemindAgainSlippageHigher:e})}),!!h&&h<y&&Yn.jsx(Sb,{title:se._({id:"TTlkRL",message:"Lower than dynamic slippage"}),desc:se._({id:"yq+Q9s",message:"Dynamic slippage is {recommendSlippage}% , the current slippage setting may increase the failure rate of transactions.",values:{recommendSlippage:y}}),doNotChecked:u,onChangeDoNotChecked:e=>Gg.setState({notRemindAgainSlippageLower:e})})]})]})]})}function Ab({checked:t,onChange:n,sx:o,disabled:r}){const s=a();let l=s.palette.background.tag;return t&&(l=s.palette.secondary.main),Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",position:"relative",borderRadius:8,backgroundColor:s.palette.background.input,opacity:r?.5:1},o),component:d,disabled:r,onClick:()=>{r||n(!t)},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:s.palette.text.primary,whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"az8lvo",message:"Off"})}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:t?s.palette.secondary.contrastText:s.palette.text.primary,whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"Z5HWHd",message:"On"})}),Yn.jsx(i,{sx:{borderRadius:6,backgroundColor:l,zIndex:0,position:"absolute",top:2,bottom:2,width:"calc(50% - 2px - 2px)",left:t?"calc(50% + 2px)":"2px",transition:"left 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"}})]})}function Ob({show:t,onClick:n}){const o=a();return Yn.jsxs(r,{weak:!0,sx:{display:t?"flex":"none",alignItems:"center",position:"absolute",bottom:28,left:"50%",transform:"translateX(-50%)",p:o.spacing(8,20),fontWeight:600,borderRadius:20,border:`solid 1px ${o.palette.border.main}`,backgroundColor:"background.paperContrast",boxShadow:`0px 8px 16px 0px ${T("light"===o.palette.mode?"#FFF":"#000",.1)}`,cursor:"pointer",whiteSpace:"nowrap",gap:4},onClick:n,children:[Yn.jsx(e,{id:"F8yRdq",message:"More trade settings"}),Yn.jsx(i,{component:"svg",width:25,height:24,viewBox:"0 0 25 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:Yn.jsx("path",{d:"M12.5 19L6.5 13L7.9 11.6L12.5 16.175L17.1 11.6L18.5 13L12.5 19ZM12.5 13L6.5 6.99998L7.9 5.59998L12.5 10.175L17.1 5.59998L18.5 6.99998L12.5 13Z",fill:"currentColor"})})]})}function Lb({selected:e,name:t,logo:n,onClick:o}){const r=a();return Yn.jsxs(i,{component:d,onClick:o,sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,py:19,mt:16,mx:8,width:"calc(33.33% - 8px - 8px)",borderRadius:8,backgroundColor:r.palette.background.paperContrast,borderColor:e?r.palette.secondary.main:r.palette.background.paperContrast,borderWidth:1,borderStyle:"solid","&:hover":{borderColor:r.palette.secondary.main},position:"relative",overflow:"hidden"},children:[Yn.jsx("img",{src:n,alt:t,style:{height:40,width:40}}),Yn.jsx(i,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:600},children:t}),e&&Yn.jsx(i,{sx:{right:0,top:0,position:"absolute",width:32,height:24,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:r.palette.secondary.main,borderRadius:"0px 0px 0px 8px"},children:Yn.jsx("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M11.8709 3.16663L5.03682 10.0007L2.35089 7.32514L0.888672 8.78737L5.03682 12.9355L13.3331 4.63922L11.8709 3.16663Z",fill:r.palette.secondary.contrastText})})})]})}function Rb({privacySwapSupplierEndpoints:e,endpointStatusMap:t,refetchEndpointStatus:n,setIsSelectSupplierMode:o}){var r,s;const l=a(),[d,u]=z(null!==(s=null===(r=null==e?void 0:e[0])||void 0===r?void 0:r.key)&&void 0!==s?s:null),[p,h]=z(t);p!==t&&(h(t),Array.from(t.entries()).forEach((([e,t])=>{t&&u(e)})));const m=d?null==e?void 0:e.find((e=>e.key===d)):void 0,g=!d||t.get(d),f=Z((()=>{n(),o(!1)}),[n,o]),{switchTo:x}=function({chainId:e,successCallback:t,selectedSupplier:n}){return{switchTo:Z((()=>Vn(this,void 0,void 0,(function*(){if(n)try{yield window.ethereum.request({method:"wallet_addEthereumChain",params:[n.addChainParameters]}),t()}catch(e){console.error(e)}}))),[n,t])}}({successCallback:f,selectedSupplier:m});return Yn.jsxs(i,{sx:{display:"flex",alignItems:"stretch",flexDirection:"column",minHeight:"100%"},children:[Yn.jsx(i,{sx:{mt:20,pt:12,display:"flex",alignItems:"flex-start",flexWrap:"wrap",mx:-8},children:null==e?void 0:e.map(((e,t)=>{const n=d===e.key;return Yn.jsx(Lb,{selected:n,name:e.name,logo:e.logo,onClick:()=>u(e.key)},t)}))}),Yn.jsx(i,{sx:{mt:24,width:"100%",height:"1px",flexShrink:0,flexGrow:0,backgroundColor:l.palette.border.main}}),Yn.jsxs(i,{sx:{mt:24,mb:24,typography:"body2",fontWeight:500,color:l.palette.text.secondary},children:[Yn.jsx(i,{children:"*Choose your privacy transaction server. Later, a new network will be added to your wallet, and transactions submitted under this network can only be seen by the privacy transaction server. The server will protect you from the impact of MEV. You can also disable the privacy transaction by switching back to the original network."}),m&&Yn.jsx(i,{sx:{color:l.palette.primary.main},component:"a",href:null==m?void 0:m.docUrl,target:"_blank",rel:"noopener noreferrer",children:"Learn more>"})]}),Yn.jsx(c,{size:c.Size.big,variant:c.Variant.contained,fullWidth:!0,sx:{marginTop:"auto",flexShrink:0,flexGrow:0},disabled:g,onClick:x,children:"Enable Privacy Swap"}),Yn.jsx(i,{sx:{height:28,width:"100%"}})]})}function Pb({open:t,onClose:n,fromToken:o,toToken:r,privacySwapEnableAble:s,privacySwapEnable:l,privacySwapSupplierEndpoints:d,endpointStatusMap:c,refetchEndpointStatus:u,isDialogModal:p}){const h=a(),{ddl:m,expertMode:g,disableIndirectRouting:f}=Gg(),[x,y]=z(!1),v=H.useRef(null),[j,C]=H.useState(!1);return H.useEffect((()=>{const e=v.current,t=new ResizeObserver((()=>{e&&C(e.scrollHeight!==e.offsetHeight)})),n=re((()=>{if(!e)return;const t=e.scrollTop+e.clientHeight<e.scrollHeight-2;C(t)}),50);return e&&(C(e.scrollHeight!==e.clientHeight),t.observe(e),e.addEventListener("scroll",n)),()=>{e&&(t.unobserve(e),e.removeEventListener("scroll",n))}}),[null==v?void 0:v.current]),Yn.jsx(Of,{open:t,onClose:x?()=>y(!1):n,id:"swap-settings",title:x?"Select A Supplier":Yn.jsx(e,{id:"Tz0i8g",message:"Settings"}),modal:p,children:Yn.jsx(i,{sx:{px:20,pb:34,overflowY:"auto"},ref:v,children:x?Yn.jsx(Rb,{privacySwapSupplierEndpoints:d,endpointStatusMap:c,refetchEndpointStatus:u,setIsSelectSupplierMode:y,privacySwapEnable:l,privacySwapEnableAble:s}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Eb,{fromToken:o,toToken:r}),Yn.jsxs(i,{sx:{mt:24,pt:14,borderTop:`solid 1px ${h.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[Yn.jsx(e,{id:"zSMRJ/",message:"Transaction Deadline"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"wmCrk7",message:"You may modify the transaction deadline, the maximum time allowed for a trade to be processed on-chain. However, please note that this may lead to your trade executing at a subpar price, as the market price may change during that time."}),ml:7})]}),Yn.jsxs(i,{sx:{mt:16,display:"flex",alignItems:"center",gap:8,typography:"body2"},children:[Yn.jsx(b,{sx:{width:80,height:34,lineHeight:1,typography:"body2","& input":{px:16,py:6}},placeholder:String(xh),value:m,onChange:e=>{Gg.setState({ddl:e.target.value})}}),Yn.jsx(e,{id:"H9HlDe",message:"minutes"})]})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,mt:24,pt:14,borderTop:`solid 1px ${h.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{fontWeight:600},children:[Yn.jsx(e,{id:"MXQodB",message:"Disable Indirect Routing"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"Y0Knz4",message:"Checking this option means that the routing algorithm will only route to liquidity pools between the two tokens in the trading pair and will ignore routes with any intermediary tokens."}),ml:7})]}),Yn.jsx(Ab,{checked:f,onChange:e=>{Gg.setState({disableIndirectRouting:e})}})]}),s&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{fontWeight:600},children:[Yn.jsx(e,{id:"U1Bq/+",message:"Privacy Swap"}),Yn.jsx(lb,{title:Yn.jsx(e,{id:"fsEEap",message:"Privacy Swap can effectively protect users from sandwich attacks that could come about due to the differences between the slippage settings and the current price in the liquidity pool. This feature is free for a limited time."}),ml:7})]}),Yn.jsx(Ab,{checked:l,disabled:l,onChange:e=>{e&&y(!0)}})]})]}),Yn.jsx(Ob,{show:j,onClick:()=>{var e,t;null===(e=v.current)||void 0===e||e.scrollTo({top:null===(t=v.current)||void 0===t?void 0:t.scrollHeight,behavior:"smooth"})}})]})})})}function _b({onClick:e,disabled:t,plus:n}){const o=a(),r=t||n||!e;return Yn.jsx(i,{sx:{width:"100%",position:"relative"},children:Yn.jsx(i,{component:d,sx:Object.assign({width:44,height:44,borderRadius:"50%",backgroundColor:o.palette.background.paper,border:"4px solid #E4E1D4",display:"flex",alignItems:"center",justifyContent:"center",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%) rotate(-90deg)",color:"text.secondary"},r?{cursor:"inherit"}:{"&:hover":{color:"text.primary"},"&:focus-visible":{"&::before":{content:'""',position:"absolute",display:"block",left:"50%",top:"50%",transform:"translate(-50%, -50%)",borderRadius:"50%",width:36,height:36,border:"solid 1px",borderColor:"text.secondary"}}}),disabled:r,onClick:()=>{r||e&&e()},children:n?Yn.jsx(i,{component:li.Plus,sx:{width:24,height:24}}):Yn.jsx(i,{component:li.ArrowBack,sx:{width:24,height:24}})})})}!function(e){e.recommend="recommend",e.custom="custom"}(Tb||(Tb={}));const Mb=()=>{const{requests:e,updateText:t}=Fg(),n=H.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if((n===Ig.Running||n===Ig.Success)&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&(!e.doneTime||Math.ceil(Date.now()/1e3)-e.doneTime<300)){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),i=H.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var i,o;if(n===Ig.Success&&(null===(i=e.metadata)||void 0===i?void 0:i.logBalance)&&e.doneTime&&Math.ceil(Date.now()/1e3)-e.doneTime<300){const n=null===(o=e.metadata)||void 0===o?void 0:o.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),o=H.useCallback(((e,n,i)=>{const o=e[n];if(!o)return!1;return!!(Pe.isBigNumber(i)?i:new Pe(i)).isEqualTo(o)||(t((e=>{var t;const i=Object.assign({},e.metadata);return(null===(t=null==i?void 0:i.logBalance)||void 0===t?void 0:t[n])?(delete i.logBalance[n],Object.keys(i.logBalance).length||delete i.logBalance,{brief:e.brief,spec:e.spec,metadata:i}):null})),!1)}),[t]),r=H.useCallback(((e,t)=>o(n,e,t)),[n,o]),a=H.useCallback(((e,t)=>o(i,e,t)),[i,o]);return{balanceData:n,balanceDataDone:i,isTokenLoading:r,isTokenLoadingDone:a}};function Bb({onClick:t,balance:n,decimals:o,address:r,showMaxBtn:s,canClickBalance:l,loading:c,balanceText:u}){const{palette:p}=a(),h=l&&(null==n?void 0:n.gt(0))&&t;return Yn.jsxs(i,{sx:Object.assign({typography:"body2",alignItems:"center",color:p.text.secondary,wordBreak:"break-word",textAlign:"right"},h?{"&:hover":{color:p.text.primary,cursor:"pointer"}}:{}),onClick:h?()=>t(n?n.toString():""):void 0,children:[null!=u?u:Yn.jsx(e,{id:"0QDjxt",message:"Balance:"})," ",c?Yn.jsx(L,{sx:{position:"relative",top:-2,verticalAlign:"middle"}}):Yn.jsxs(Yn.Fragment,{children:[r?Am({input:n,decimals:Math.min(o||4,4)}):"-",s&&n&&n.gt(0)&&t&&Yn.jsx(i,{component:d,sx:{ml:6,color:(null==n?void 0:n.gt(0))?p.primary.main:p.text.disabled,cursor:r?"pointer":"unset",typography:"body2"},onClick:()=>t&&t(n?n.toString():""),children:Yn.jsx(e,{id:"CK1KXz",message:"Max"})})]})]})}const Db=X((function({readOnly:e,sx:t,value:n,decimals:o,onChange:r,suffix:s,suffixGap:l=0,withClear:c,onFocus:u,placeholder:p,readonlyShowSuffix:h,typography:m},g){const f=a(),x=$((()=>s||(c&&n&&r?Yn.jsx(i,{component:d,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{r&&r("")},children:Yn.jsx(i,{component:li.Error,sx:{width:12}})}):void 0)),[r,s,f.palette.text.primary,n,c]);return Yn.jsx(b,{fullWidth:!0,value:n,readOnly:e,placeholder:p||"0.00",onFocus:u,onChange:e=>{const t=e.target.value,n=0===t.length?"":Rm(t,o);r&&r(n)},"data-testid":"number-input-wrapper",suffix:(!e||h)&&x,suffixGap:l,ref:g,sx:Object.assign({border:"none","& input":{fontSize:24,typography:m,border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:m,color:"text.disabled"}}},t)})}));function Nb({token:t,onClick:n,showChainLogo:o,readonly:r,showChainName:s}){var l,c;const u=a(),p=(null==t?void 0:t.chainId)?ah.get(t.chainId):null,h=s&&!!p;return Yn.jsxs(i,{component:d,sx:{display:"flex",alignItems:"center",gap:8,color:u.palette.text.primary,typography:h?"body2":"body1",fontWeight:600,"&:focus-visible":{opacity:.5}},onClick:e=>{r||n&&n(e)},"data-testid":jh,children:[!!(null==t?void 0:t.address)&&Yn.jsx(Df,{url:null==t?void 0:t.logoURI,address:null!==(l=null==t?void 0:t.address)&&void 0!==l?l:"",chainId:null==t?void 0:t.chainId,noShowChain:!o,width:32,height:32,chainSize:16,logoOffset:6,marginRight:0}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[(null==t?void 0:t.address)?Yn.jsx(Yn.Fragment,{children:Yn.jsx(i,{children:null!==(c=null==t?void 0:t.symbol)&&void 0!==c?c:"-"})}):Yn.jsx(e,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&Yn.jsx("svg",{width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 11.75L12 7.25H6L9 11.75Z",fill:"currentColor"})})]}),!!h&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[p.name,Yn.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]})}function Fb({chain:e,active:t,onClick:n}){return Yn.jsx(l,{title:e.name,placement:"top",onlyHover:!0,children:Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,cursor:"pointer",border:"1px solid"},t?{backgroundColor:"tabActive.main",borderColor:"tabActive.main",color:"primary.main"}:{borderColor:"border.main","&:hover":{backgroundColor:"hover.default"}}),onClick:n,children:[Yn.jsx(i,{component:e.logo,sx:{width:24,height:24}}),t&&Yn.jsx(i,{sx:{typography:"body2",color:"primary.main"},children:e.name})]})},e.chainId)}var Ub=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],i=0;i<e.rangeCount;i++)n.push(e.getRangeAt(i));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||n.forEach((function(t){e.addRange(t)})),t&&t.focus()}},qb={"text/plain":"Text","text/html":"Url",default:"Text"};var Vb=function(e,t){var n,i,o,r,a,s,l=!1;t||(t={}),n=t.debug||!1;try{if(o=Ub(),r=document.createRange(),a=document.getSelection(),(s=document.createElement("span")).textContent=e,s.ariaHidden="true",s.style.all="unset",s.style.position="fixed",s.style.top=0,s.style.clip="rect(0, 0, 0, 0)",s.style.whiteSpace="pre",s.style.webkitUserSelect="text",s.style.MozUserSelect="text",s.style.msUserSelect="text",s.style.userSelect="text",s.addEventListener("copy",(function(i){if(i.stopPropagation(),t.format)if(i.preventDefault(),void 0===i.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var o=qb[t.format]||qb.default;window.clipboardData.setData(o,e)}else i.clipboardData.clearData(),i.clipboardData.setData(t.format,e);t.onCopy&&(i.preventDefault(),t.onCopy(i.clipboardData))})),document.body.appendChild(s),r.selectNodeContents(s),a.addRange(r),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");l=!0}catch(o){n&&console.error("unable to copy using execCommand: ",o),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),l=!0}catch(o){n&&console.error("unable to copy using clipboardData: ",o),n&&console.error("falling back to prompt"),i=function(e){var t=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C";return e.replace(/#{\s*key\s*}/g,t)}("message"in t?t.message:"Copy to clipboard: #{key}, Enter"),window.prompt(i,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(r):a.removeAllRanges()),s&&document.body.removeChild(s),o()}return l},Wb=Hn(Vb);function Hb({copyText:e,size:t,sx:n,componentProps:o,onClick:r,children:a}){var s;const[l,c]=H.useState(!1);return Yn.jsx(R,{title:se._({id:"6V3Ea3",message:"Copied"}),open:l,onClose:()=>c(!1),arrow:!1,children:Yn.jsxs(i,{...o,component:null!==(s=null==o?void 0:o.component)&&void 0!==s?s:d,onClick:t=>{if(null==o?void 0:o.onClick)return o.onClick(t);t.stopPropagation(),e&&(Wb(e),c(!0)),r&&r()},sx:Object.assign({cursor:"pointer"},null==o?void 0:o.sx),children:[Yn.jsx(i,{component:li.Copy,sx:Object.assign({width:t||"auto",height:t||"auto"},n)}),a]})})}function $b({truncate:e,address:t,disabledAddress:n,sx:o,handleOpen:r,addressHoverColor:a,addressHoverShowIcon:s}){return n?Yn.jsx(i,{children:e?eg(t):t}):Yn.jsx(P,{lineSx:{bottom:-1},lineColor:null!=a?a:(null==o?void 0:o.color)||"",hoverSx:{color:"addressHoverColor","& svg":{display:"inline-block"}},className:"truncate-address-link",children:Yn.jsxs(i,{onClick:e=>{null==r||r(e,"address")},sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[e?eg(t):t,s?Yn.jsx(i,{component:li.ArrowRight,sx:{display:"none",width:14,height:14}}):""]})})}function zb({address:e,truncate:t,showCopy:n,size:o="medium",iconSize:s,iconSpace:l,sx:d,iconDarkHover:c,disabledAddress:u,addressHoverColor:p,addressHoverShowIcon:h,customChainId:m,handleOpen:g,onAddressClick:f,onShareClick:x}){const y=a(),{chainId:v}=dg(),b=null!=m?m:v,j="medium"===o,C=c?_:r,w=e=>{let t=e?12:8;return l&&(t=l),c&&(t-=3),t},k="big"===o?"h5":j?"body1":"body2",T=(t,n)=>{g?g(t,n):b&&(t.stopPropagation(),window.open(tg(b,e,"address")))},I=s||(j?16:14);return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",typography:k,color:y.palette.text.primary,lineHeight:"normal"},d||{}),children:[Yn.jsx($b,{truncate:t,address:e,disabledAddress:u,sx:d,typography:k,handleOpen:null!=f?f:T,addressHoverColor:p,addressHoverShowIcon:h}),Yn.jsx(C,{sx:{display:"inline-flex",ml:w(j),cursor:"pointer"},onClick:e=>{T(e,"icon")},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:I,height:I}})}),n?Yn.jsx(Hb,{size:I,copyText:e,componentProps:{component:C,sx:{ml:w(j),display:"inline-flex",alignItems:"center",justifyContent:"center"}}}):null,!!x&&Yn.jsx(C,{sx:{display:"inline-flex",ml:w(j),cursor:"pointer"},onClick:e=>{x(e)},children:Yn.jsx(i,{component:li.Share,sx:{width:I,height:I,ml:w(j)}})})]})}function Zb({token:e,disabled:t,style:n,balance:o,onSelect:r}){const s=a(),l=$((()=>o?Am({input:o,decimals:e.decimals}):""),[o,e.decimals]);return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",px:8,py:8,borderRadius:8,cursor:t?"auto":"pointer",opacity:t?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:n,onClick:()=>{t||r(e)},"data-testid":kh,children:[Yn.jsx(Df,{token:e,width:32,height:32,noShowChain:!0,noBorder:!0}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:2},children:[Yn.jsx(i,{sx:{textAlign:"left",color:"text.primary",typography:"body2",fontWeight:600},children:e.symbol}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:{color:"text.secondary",typography:"h6",fontWeight:500,maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:e.name,children:e.name}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,showCopy:!0,truncate:!0,iconSpace:2,iconSize:12,size:"small",sx:{typography:"h6",color:"text.disabled"}})]})]}),Yn.jsx(i,{sx:{ml:"auto",typography:"body1",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"flex-end"},children:(null==o?void 0:o.gte(0))?l:Yn.jsx(i,{component:li.Loading,width:18,sx:{"& path":{fill:s.palette.text.disabled},animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}}})})]})}function Gb(){return Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between"},children:[Yn.jsx(j,{variant:"circular",width:32,sx:{mt:8}}),Yn.jsxs(i,{sx:{ml:8,flex:"1 0 auto"},children:[Yn.jsx(j,{sx:{borderRadius:4},height:24}),Yn.jsx(j,{sx:{mt:4,borderRadius:4},height:19,width:137})]})]})}function Qb({data:e,index:t,style:n}){const i=e.tokenList[t],o=e.getIsDisabled(i),r=e.getBalance(i);return Yn.jsx(Zb,{token:i,disabled:o,style:n,onSelect:e.onSelectToken,balance:r},i.address+i.chainId)}function Yb({fixedSizeHeight:e,tokenList:t,onSelectToken:n,getIsDisabled:i,getBalance:o}){const r=$((()=>({onSelectToken:n,tokenList:t,getIsDisabled:i,getBalance:o})),[n,t,i,o]);return Yn.jsx(Cn,{height:e,width:"100%",itemSize:56,itemData:r,itemCount:t.length,children:Qb})}function Kb({chainId:e,value:t,onChange:n,occupiedAddrs:o,occupiedChainId:r,hiddenAddrs:a,showAddrs:s,visible:l,side:d,defaultLoadBalance:c,multiple:u,searchPlaceholder:p,searchOtherAddress:h,sx:m,filterBySupportTargetChain:g}){const{chainList:f,selectChainId:x,setSelectChainId:y}=function(e){const{crossChain:t,defaultChainId:n,IS_TEST_ENV:i}=Jn(),[o,r]=z(e?Array.isArray(e)?e[0]?e[0].chainId:n:e.chainId:n),a=$((()=>t?i?Array.from(ah.values()):Array.from(ah.values()).filter((e=>!e.isTestNet)):[]),[i,t]);return{chainList:a,selectChainId:o,setSelectChainId:r}}(t),{showTokenList:v,filter:b,setFilter:j,onSelectToken:C,popularTokenList:w,tokenInfoMap:k}=function({value:e,onChange:t,occupiedAddrs:n,occupiedChainId:i,hiddenAddrs:o,showAddrs:r,side:a,chainId:s,visible:l,defaultLoadBalance:d,multiple:c,filterBySupportTargetChain:u}){const[p,h]=z(""),m=Lg(),g=null!=s?s:m,{tokenList:f,popularTokenList:x}=Th(),y=$((()=>new Set(o?o.map((e=>e.toLowerCase())):void 0)),[o]),v=$((()=>r?new Set(r.map((e=>e.toLowerCase()))):void 0),[r]),b=Z((e=>{const t=new Set;return e.filter((e=>{if(e.chainId!==g)return!1;let n=!0;if(n=v?v.has(e.address.toLowerCase()):!y.has(e.address.toLowerCase()),n)if(a)n=!e.side||e.side===a;else{const i=`${e.chainId}-${e.address}`;n=!t.has(i),t.add(i)}return n}))}),[g,v,y,a]),j=Z((e=>{var t;if(e.chainId!==g)return!1;if(!u)return!0;if(null==i||i===g)return!0;if(!e.supportTargetChain)return!1;if(i!==le.SOLANA)return!0;if(g!==le.ZETACHAIN)return!1;const o=null===(t=null==n?void 0:n[0])||void 0===t?void 0:t.toLowerCase(),r=e.address.toLowerCase();if(!o)return!0;const a=we[i];switch(o){case a.address.toLowerCase():case a.wrappedTokenAddress.toLowerCase():return r==="0x4bC32034caCcc9B7e02536945eDbC286bACbA073".toLowerCase();case"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v".toLowerCase():return r==="0x8344d6f84d26f998fa070BbEA6D2E15E359e2641".toLowerCase();case"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB".toLowerCase():return r==="0xEe9CC614D03e7Dbe994b514079f4914a605B4719".toLowerCase();default:return!0}}),[g,u,n,i]),C=$((()=>b(f.filter(j))),[j,b,f]),w=$((()=>b(x.filter(j))),[j,b,x]),k=Z((o=>{const r=o.address.toLowerCase(),a=!(i&&o.chainId!==i||!(null==n?void 0:n.some((e=>e.toLowerCase()===r))));if(Array.isArray(e)||c&&!e){const n=[...e],i=n.findIndex((e=>e.address.toLocaleLowerCase()===r));-1!==i?n.splice(i,1):n.push(o),t(n,a)}else t(o,a)}),[t,n,i]),T=Pf({chainId:g,tokenList:C,popularTokenList:w,value:e,visible:l,defaultLoadBalance:d}),I=Z((t=>{if(null===t)return null;const i=[];p?t.forEach((e=>{const t=Bf(e,p,{matchAddress:!0});t&&i.push({sort:t,token:e})})):t.forEach((e=>{i.push({sort:0,token:e})}));const o=[];return i.sort(((t,i)=>{var o,r;const a=t.token,s=i.token;if(e)if(Array.isArray(e)){const t=e.map((e=>e.address)),n=t.indexOf(a.address),i=t.indexOf(s.address),o=-1!==n,r=-1!==i;if(o||r)return o&&n<i||!r?-1:1}else{if(a.address===e.address)return-1;if(s.address===e.address)return 1}if(null==n?void 0:n.includes(a.address))return-1;if(null==n?void 0:n.includes(s.address))return 1;const l=(null===(o=T.get(`${a.chainId}-${a.address}`))||void 0===o?void 0:o.balance)||new Pe(0),d=(null===(r=T.get(`${s.chainId}-${s.address}`))||void 0===r?void 0:r.balance)||new Pe(0),c=w.map((e=>e.address));return(null==c?void 0:c.includes(a.address))?-1:(null==c?void 0:c.includes(s.address))?1:l.eq(d)?t.sort!==i.sort?t.sort>i.sort?1:-1:a.symbol.localeCompare(s.symbol):l.gt(d)?-1:1})).some((e=>!!(p&&o.length>21)||(o.push(e.token),!1))),o}),[p,T,n,e,w]),S=$((()=>I(C)||[]),[I,C]);return{filter:p,setFilter:h,showTokenList:S,onSelectToken:k,popularTokenList:w,tokenInfoMap:T}}({value:t,onChange:n,occupiedAddrs:o,occupiedChainId:r,hiddenAddrs:a,showAddrs:s,side:d,chainId:null!=e?e:x,visible:l,defaultLoadBalance:c,multiple:u,filterBySupportTargetChain:g}),T=G(null),I=G(null),[S,E]=z(329);Q((()=>{if(T.current){const e=new ResizeObserver((e=>{for(const t of e)if(t.target===T.current){const e=t.contentRect.height-1;e>0&&E(e)}}));return e.observe(T.current),()=>{e.disconnect()}}}),[]);const A=et({queryKey:["token-picker-searchOtherAddress",b],queryFn:()=>h?h(b):null,enabled:Jm(b)&&!!h}),O=Z((e=>!!t&&(Array.isArray(t)?t.some((t=>t.address===e.address&&t.chainId===e.chainId)):t.address===e.address&&t.chainId===e.chainId)),[t]),L=Z((e=>{var t;return null===(t=k.get(`${e.chainId}-${e.address}`))||void 0===t?void 0:t.balance}),[k]);return Yn.jsxs(i,{sx:Object.assign({display:"flex",flexDirection:"column",px:16,flexGrow:1,overflow:"hidden"},m),children:[Yn.jsx(M,{fullWidth:!0,height:48,value:b,onChange:e=>j(e.target.value),clearValue:()=>j(""),placeholder:null!=p?p:se._({id:"72/M0o",message:"Enter the token symbol or address"}),sx:{mb:16}}),void 0===e&&f.length>0&&Yn.jsx(i,{ref:I,sx:{position:"relative",display:"flex",gap:8,flexWrap:"wrap",pb:32,"&::after":{content:'""',position:"absolute",bottom:16,left:0,right:0,height:"1px",backgroundColor:"border.main"}},children:f.map((e=>Yn.jsx(Fb,{chain:e,active:e.chainId===x,onClick:()=>{y(e.chainId)}},e.chainId)))}),Yn.jsx(i,{sx:{pb:15,flexGrow:1},ref:T,children:v.length?Yn.jsx(Yb,{fixedSizeHeight:S,tokenList:v,onSelectToken:C,getIsDisabled:O,getBalance:L}):Yn.jsx(i,{sx:{height:S,overflowY:"auto"},children:A.isLoading?Yn.jsx(Gb,{}):A.data?A.data:Yn.jsx(ti,{hasSearch:!0,sx:{mt:80}})})})]})}function Xb(t){const{height:n,TokenPickerDialog:i}=Jn(),{isMobile:o}=Tg();if(i)return Yn.jsx(i,{...t});const{open:r,title:a,value:s,onClose:l,occupiedAddrs:d,hiddenAddrs:c,showAddrs:u,occupiedChainId:p,onTokenChange:h,side:m,defaultLoadBalance:g,multiple:f,searchPlaceholder:x,searchOtherAddress:y,chainId:v,modal:b,filterBySupportTargetChain:j}=t;return Yn.jsx(Of,{height:b?"80vh":n,open:r,onClose:l,title:null!=a?a:Yn.jsx(e,{id:"T0Y2+3",message:"Select a token"}),id:"select-token",testId:wh,modal:b,children:Yn.jsx(Kb,{value:s,visible:r,onChange:h,occupiedAddrs:d,occupiedChainId:p,hiddenAddrs:c,showAddrs:u,side:m,defaultLoadBalance:g,multiple:f,searchPlaceholder:x,searchOtherAddress:y,chainId:v,sx:b?{width:o?"100%":420,borderRadius:16}:void 0,filterBySupportTargetChain:j})})}const Jb=/^ST[0-9A-HJ-NP-Z]{39}$/,ej=/^0x[a-fA-F0-9]{64}$/,tj=/^[A-Za-z0-9_-]{48}$/;const nj=({chainId:e,open:t,onClose:n,inputToAddress:o,setInputToAddress:r})=>{const s=a(),[l,u]=z(o||""),p=function(e,t){return $((()=>{if(!e)return!1;const n=ah.get(t);if(!n)return!1;try{if(n.isEVMChain)return!!sm(e);if(n.isSolanaChain)return new Fe(e),!0;if(n.isBTCChain){if(Jb.test(e))return!0;try{return t===le.BTC_SIGNET?en.address.toOutputScript(e,by):en.address.toOutputScript(e,en.networks.bitcoin),!0}catch(e){return!1}}else{if(n.isSUIChain)return ej.test(e);if(n.isTONChain)return tj.test(e)}return!1}catch(e){return!1}}),[e,t])}(l,e),h=$((()=>ah.get(e)),[e]);return Yn.jsx(Of,{open:t,onClose:n,title:"Receive address",modal:!0,children:Yn.jsxs(i,{sx:{minWidth:420,p:20,borderTop:`1px solid ${s.palette.border.main}`,display:"flex",flexDirection:"column",gap:20},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(b,{fullWidth:!0,value:l,placeholder:`Enter ${null==h?void 0:h.name} address`,onChange:e=>{u(e.target.value)},height:48,suffix:l?Yn.jsx(i,{component:d,sx:{ml:5,width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center",flexShrink:0,color:"text.secondary","&:focus-visible":{border:"solid 1px",borderColor:"text.primary"}},onClick:()=>{u("")},children:Yn.jsx(i,{component:li.Error,sx:{width:12}})}):null}),!p&&l&&Yn.jsx(i,{sx:{typography:"h6",color:"error.main"},children:"Invalid address"})]}),Yn.jsx(c,{fullWidth:!0,variant:c.Variant.contained,size:c.Size.middle,disabled:!l||!p,onClick:()=>{r(l),n()},children:"Confirm"})]})})},ij=({token:e,enterAddressEnabled:t=!1,inputToAddress:n,setInputToAddress:o,account:r})=>{var a,s,l,d,c,u;const p=e.chainId,{open:h,disconnect:m,suiConnectModalOpen:g,setSuiConnectModalOpen:f}=dg(),[x,y]=z(!1),v=$((()=>ah.get(p)),[p]),b=Yn.jsxs("svg",{width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("path",{d:"M12.001 6.3667C12.7373 6.3667 13.3339 6.9634 13.334 7.69971V9.03369H10.1338C9.54481 9.03383 9.06738 9.51108 9.06738 10.1001C9.06751 10.689 9.54488 11.1664 10.1338 11.1665H13.334V12.4995C13.334 13.2359 12.7374 13.8335 12.001 13.8335H4.00098C3.2646 13.8335 2.66797 13.2359 2.66797 12.4995V7.69971C2.66806 6.9634 3.26465 6.3667 4.00098 6.3667H12.001Z",fill:"currentColor"}),Yn.jsx("ellipse",{cx:"10.1349",cy:"10.1002",rx:"0.533334",ry:"0.533333",fill:"currentColor"}),Yn.jsx("path",{d:"M8.54243 3.63688C9.14948 3.36708 9.86253 3.5853 10.2146 4.14863L10.9341 5.29984H4.80078L8.54243 3.63688Z",fill:"currentColor"})]});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(B,{triggerChildren:(null===(a=null==r?void 0:r.appKitAccount)||void 0===a?void 0:a.isConnected)?Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:[b,eg(null===(s=null==r?void 0:r.appKitAccount)||void 0===s?void 0:s.address),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:Yn.jsx("path",{d:"M12.667 6.93016L11.5703 5.8335L8.00033 9.39572L4.43033 5.8335L3.33366 6.93016L8.00033 11.5968L12.667 6.93016Z",fill:"currentColor",fillOpacity:"0.5"})})]}):Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:4,px:4,py:2,borderRadius:4,backgroundColor:"background.tag",typography:"h6",lineHeight:"16px"},children:["Wallet address:",eg(null===(l=null==r?void 0:r.appKitAccount)||void 0===l?void 0:l.address),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"17",viewBox:"0 0 16 17",fill:"none",children:Yn.jsx("path",{d:"M3.33301 10.0698L4.42967 11.1665L7.99967 7.60428L11.5697 11.1665L12.6663 10.0698L7.99967 5.40317L3.33301 10.0698Z",fill:"currentColor",fillOpacity:"0.5"})})]}),titleSx:{display:"flex",flexDirection:"column",gap:8},children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsxs(i,{sx:{typography:"h6",lineHeight:"16px",color:"text.secondary"},children:["Connected(",lg(p),")"]}),(null===(d=null==r?void 0:r.appKitAccount)||void 0===d?void 0:d.isConnected)?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,px:8,py:8,color:"text.primary",borderRadius:8,backgroundColor:"background.paperContrast",typography:"body2",lineHeight:"19px"},children:[n?b:v&&Yn.jsx(i,{component:v.logo,sx:{width:16,height:16}}),eg(null===(c=null==r?void 0:r.appKitAccount)||void 0===c?void 0:c.address),Yn.jsx(i,{sx:{ml:"auto",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},onClick:()=>{n?o(null):m({namespace:null==r?void 0:r.namespace})},children:Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.25 2.25H9.75V9.75H8.25V2.25ZM12.3075 4.94244L13.3725 3.87744C14.8275 5.11494 15.75 6.94494 15.75 8.99994C15.75 12.7274 12.7275 15.7499 9 15.7499C5.2725 15.7499 2.25 12.7274 2.25 8.99994C2.25 6.94494 3.1725 5.11494 4.6275 3.87744L5.685 4.93494C4.5075 5.89494 3.75 7.35744 3.75 8.99994C3.75 11.9024 6.0975 14.2499 9 14.2499C11.9025 14.2499 14.25 11.9024 14.25 8.99994C14.25 7.35744 13.4925 5.89494 12.3075 4.94244Z",fill:"#ED4A25"})})})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),"sui"===(null==r?void 0:r.namespace)?Yn.jsx(Pt,{trigger:Yn.jsx(i,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},children:"Connect a new wallet"}),open:g,onOpenChange:e=>{console.log("walletconnectbtn isOpen",e),f(e)}}):Yn.jsx(i,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{h({namespace:null==r?void 0:r.namespace})},children:"Connect a new wallet"})]}),t&&Yn.jsxs(Yn.Fragment,{children:[(null===(u=null==r?void 0:r.appKitAccount)||void 0===u?void 0:u.isConnected)&&Yn.jsx(i,{sx:{height:"1px",width:"100%",backgroundColor:"border.main"}}),Yn.jsx(i,{sx:{p:8,cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.primary","&:hover":{borderRadius:8,backgroundColor:"background.paperContrast"}},onClick:()=>{y(!0)},children:"Enter receive address"})]})]})}),x&&Yn.jsx(nj,{open:x,onClose:()=>y(!1),chainId:p,inputToAddress:n,setInputToAddress:o})]})};function oj({sx:t,amt:n,token:o,readOnly:r,showMaxBtn:s,canClickBalance:l,onMaxClick:d,fiatPriceTxt:u,failedReason:p,occupiedAddrs:h,occupiedChainId:m,showAddrs:g,onInputFocus:f,onTokenClick:x,onInputChange:y,onTokenChange:v,side:b,showChainLogo:j,showChainName:C,defaultLoadBalance:w,overrideBalance:k,overrideBalanceLoading:T,balanceText:I,showPercentage:S,inputReadonlyTooltip:E,inputTypography:A,hideToken:O,checkLogBalance:L,notTokenPickerModal:P,enterAddressEnabled:_,inputToAddress:M,setInputToAddress:B,account:D,tokenQuery:N,filterBySupportTargetChain:F}){var U,q;const V=a(),[W,H]=z(!1),$=null!==(q=null!=k?k:null===(U=N.data)||void 0===U?void 0:U.balance)&&void 0!==q?q:null,{isTokenLoading:Z}=Mb();let Y=null!=T?T:N.isLoading;!Y&&$&&(L?Y=Object.entries(L).some((([e,t])=>Z(e,t))):o&&(Y=Z(o.address,$))),Cg({tokenList:o?[o]:[]});const[K,X]=z(0),J=G("");Q((()=>{n!==J.current&&X(0)}),[n]);const{gotoBuyToken:ee}=Jn();let te=ee&&$&&n&&$.lt(n);const ne=!!y||!!E,ie={"& input":{typography:"h2",height:"44px",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{typography:"h2",height:"44px",color:"text.disabled"}},backgroundColor:"background.paper"};return Yn.jsxs(i,{sx:Object.assign({minHeight:ne?133:"auto",padding:V.spacing(20,20,24),overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",borderRadius:12,backgroundColor:V.palette.background.paper},t),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[O?Yn.jsx(i,{}):Yn.jsx(Nb,{token:o,showChainLogo:j,showChainName:C,onClick:()=>H(!0),readonly:!v}),o&&Yn.jsx(ij,{token:o,enterAddressEnabled:_,inputToAddress:M,setInputToAddress:B,account:D})]}),ne&&(r&&E?Yn.jsx(R,{title:E,arrow:!1,children:Yn.jsx(i,{children:Yn.jsx(Db,{value:n,readOnly:!0,withClear:!0,sx:Object.assign({mt:16},ie)})})}):Yn.jsx(Db,{value:n,onFocus:f,onChange:y?e=>{y(e),X(0)}:void 0,readOnly:r,withClear:!0,suffix:te?Yn.jsx(c,{variant:c.Variant.tag,backgroundColor:V.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{var t;e.stopPropagation(),(null===(t=null==D?void 0:D.appKitAccount)||void 0===t?void 0:t.address)&&(null==ee||ee({token:o,account:D.appKitAccount.address}))},children:Yn.jsx(e,{id:"qiOIiY",message:"Buy"})}):void 0,typography:A,sx:Object.assign({mt:16},ie)})),p&&Yn.jsx(i,{sx:{mt:4,typography:"h6",lineHeight:"16px",fontWeight:500,color:V.palette.error.main},children:p}),Yn.jsxs(i,{sx:{mt:S?9:4,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{typography:"h6",color:V.palette.text.secondary},children:u}),Yn.jsx(Bb,{balance:$,balanceText:I,onClick:r||!d&&!y?void 0:e=>{d?d(e):y&&y(e),0!==K&&1!==K&&(X(1),J.current=e)},showMaxBtn:s,canClickBalance:l,address:null==o?void 0:o.address,decimals:null==o?void 0:o.decimals,loading:Y})]}),Yn.jsx(Xb,{value:o,open:W,side:b,chainId:void 0,showAddrs:g,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:w,onClose:()=>{H(!1),x&&x()},onTokenChange:(e,t)=>{H(!1),setTimeout((()=>{!Array.isArray(e)&&v&&v(e,t)}),Sf)},modal:!P,filterBySupportTargetChain:F})]})}function rj({rawRouteData:e,chainId:t}){const n=H.useMemo((()=>{if(!e)return[];try{const n=JSON.parse(e);return n.subRoute[0].midPath.map((e=>{const{fromToken:n,toToken:i,oneSplitTotalPart:o}=e,r=new Map;return e.poolDetails.forEach((e=>{var t;const n={poolPart:Vm({input:new Pe(e.poolPart).div(o)}),poolAddress:e.pool||null};r.has(e.poolName)?null===(t=r.get(e.poolName))||void 0===t||t.push(n):r.set(e.poolName,[n])})),{fromToken:n,toToken:i,chainId:t,poolDetails:r}}))}catch(e){console.error(e)}return[]}),[t,e]);return{routeData:n}}const aj=({routeInfo:t,toToken:n,fromToken:o})=>{const[r,s]=z(!1),l=a(),{isMobile:d}=Tg(),c=$((()=>{const e=[{key:"from",logo:Yn.jsx(Df,{token:o,noShowChain:!0,height:14,width:14,marginRight:0})}];return e.push({key:"to",logo:Yn.jsx(Df,{token:n,noShowChain:!0,height:14,width:14,marginRight:0})}),e}),[o,n]),{routeData:u}=rj({rawRouteData:t,chainId:null==o?void 0:o.chainId});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{py:4,pl:8,pr:4,display:"flex",alignItems:"center",gap:4,borderRadius:12,backgroundColor:l.palette.background.tag,cursor:"pointer",typography:"h6",fontWeight:500,color:l.palette.text.secondary,"&:hover":{color:l.palette.text.primary}},onClick:()=>{s(!0)},children:[Yn.jsx(i,{sx:{color:l.palette.text.primary},children:"Route:"}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:0},children:c.map(((e,t)=>Yn.jsx(J,{children:e.logo},e.key)))}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:Yn.jsx("path",{d:"M2.91699 11.0833V7.58332H4.08366V9.91666H6.41699V11.0833H2.91699ZM9.91699 6.41666V4.08332H7.58366V2.91666H11.0837V6.41666H9.91699Z",fill:"currentColor"})})]}),Yn.jsx(Of,{open:r,title:Yn.jsx(e,{id:"rT8e1f",message:"Route"}),onClose:()=>s(!1),modal:!0,children:Yn.jsx(i,{sx:{minWidth:d?"100%":800,py:20,px:20,borderTop:`1px solid ${l.palette.border.main}`},children:d?Yn.jsx($f,{routeData:u,fromTokenRaw:o,toTokenRaw:n}):Yn.jsx(zf,{routeData:u,fromTokenRaw:o,toTokenRaw:n})})})]})};function sj({toToken:t,fromToken:n,priceStatus:o,pricePerToToken:r,pricePerFromToken:s,routeInfo:l}){const c=a(),[u,p]=z("-"),[h,m]=z(null),[g,f]=z("-"),[x,y]=z(null);Q((()=>{p(null==n?void 0:n.symbol),f(null==t?void 0:t.symbol),m(r),y(s)}),[n,t,r,s]);const v=Z((()=>{p(g),f(u),m(x),y(h)}),[u,h,g,x]);return Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:{[Qg.Initial]:"-",[Qg.Loading]:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(L,{sx:{mr:5}}),Yn.jsx(e,{id:"JdNn1Y",message:"Fetching best price..."})]}),[Qg.Failed]:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.Warn,sx:{width:15,mr:5,color:"warning.main"}}),Yn.jsx(e,{id:"NVAuTg",message:"Quote not available"})]}),[Qg.Success]:Yn.jsxs(i,{sx:{width:"100%",mt:16,px:11,py:7,borderRadius:12,border:`solid 1px ${c.palette.border.main}`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"flex-start",gap:6},children:[Yn.jsxs(i,{sx:{typography:"body2",lineHeight:"18px",color:c.palette.text.primary},children:["1 ",u," ",Yn.jsx("span",{style:{color:c.palette.text.secondary},children:"="})," ",Em({input:x,showDecimals:4})," ",g]}),Yn.jsx(i,{component:d,sx:{width:18,height:18,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:Yn.jsx(i,{sx:{width:16,color:"text.secondary"},onClick:v,component:li.Switch})})]}),n&&t&&Yn.jsx(aj,{routeInfo:l,fromToken:n,toToken:t})]})}[o]})}function lj({getAutoSlippage:t,onPayTokenChange:n,onReceiveTokenChange:o}={}){var r,s,u,p,h,m;const g=a(),{isInflight:f}=Ug(),{noPowerBy:x,onlyChainId:y}=Jn(),{isMobile:v}=Tg(),{open:b,disconnect:j,suiConnectModalOpen:C,setSuiConnectModalOpen:w,getAppKitAccountByChainId:k,chainId:T,appKitActiveNetwork:I}=dg(),[S,E]=z(!1),[A,O]=z(""),[R,P]=z(""),[_,M]=z(""),[B,D]=z(""),[N,F]=z(null),[U,q]=z(null),[V,W]=z(!1),[H,G]=z(!1),[Y,K]=z(!1),[X,J]=z(null),ee=$((()=>k(null==N?void 0:N.chainId)),[null==N?void 0:N.chainId,k]),te=$((()=>{const e=k(null==U?void 0:U.chainId);if(e)return X?Object.assign(Object.assign({},e),{appKitAccount:Object.assign(Object.assign({},e.appKitAccount),{isConnected:!0,address:X})}):e}),[k,null==U?void 0:U.chainId,X]),ne=$((()=>ae((e=>M(e)),300)),[]),ie=$((()=>ae((e=>D(e)),300)),[]),oe=$((()=>{if(N&&U)return!(!(null==N?void 0:N.chainId)||!(null==U?void 0:U.chainId)||N.chainId===U.chainId)}),[N,U]),{toFiatPrice:re,fromFiatPrice:de}=Wg({toToken:U,fromToken:N}),{marginAmount:ce}=function({token:e,fiatPrice:t}){return{marginAmount:$((()=>{var n;const i=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,o=null!=t?new Pe(500).div(t):new Pe(0),r=Pm(o,i);return(r.lt(new Pe(1).times(new Pe(10).pow(i-3)))?new Pe(0):r).toString(10)}),[null==e?void 0:e.decimals,t])}}({token:S?U:N,fiatPrice:S?re:de});kg({fromToken:N,toToken:U,getAutoSlippage:t});const{slippage:ue,slippageLoading:pe}=tf({fromToken:N,toToken:U}),{slippage:he}=function(){const{defaultSlippage:e}=Kg(!0);return{slippage:xg((t=>t.slippage||e))}}(),{privacySwapSupplierEndpoints:me,privacySwapEnable:ge,privacySwapEnableAble:fe,endpointStatusMap:xe,refetchEndpointStatus:ye}=ef({chainId:null==N?void 0:N.chainId,account:null==ee?void 0:ee.appKitAccount.address}),ve=function(e){var t,n;const{getAppKitAccountByChainId:i}=dg(),{latestBlockNumber:o}=xg(),r=ip.getFetchTokenQuery(e&&(null===(t=ah.get(e))||void 0===t?void 0:t.isEVMChain)?e:void 0,e?we[e].address:void 0,null===(n=i(e))||void 0===n?void 0:n.appKitAccount.address);return et(Object.assign(Object.assign({},r),{queryKey:[...r.queryKey,o]}))}(null==N?void 0:N.chainId),{sendRouteLoading:be,sendRouteError:je,setSendRouteError:ke,bridgeOrderTxRequest:Te,handleClickSend:Ie}=function(){const e=gg(),{evmProvider:t}=dg(),[n,i]=z(),[o,r]=z(!1),[a,s]=z(""),l=Z((n=>Vn(this,[n],void 0,(function*({selectedRoute:n,fromEtherTokenBalance:o,goNext:a}){var l,d;if(!n)return;const{encodeParams:c}=n;if(c&&c.interfaceParams){s(""),r(!0);try{const u=yield e.getData(Ce.graphql.cross_chain_swap_zetachain_transactionEncode.toString(),{data:{interfaceParams:c.interfaceParams}});if(!u||!u.cross_chain_swap_zetachain_transactionEncode)throw new Error("cross_chain_swap_transactionEncode is null");const{data:p,to:h,value:m,from:g,chainId:f}=u.cross_chain_swap_zetachain_transactionEncode;if(!(p&&h&&m&&g&&f))throw new Error("cross_chain_swap_transactionEncode is null");const x=ah.get(f);if(null==x?void 0:x.isEVMChain){if(!o)throw new Error("fromEtherTokenBalance is null");const{fromToken:e,fromAmount:i}=n,a=we[f],c=_m(m,18),u=a&&e.address.toLowerCase()===a.address.toLowerCase(),x=c.minus(u?i:0);if(!c.isNaN()&&c.gt(0)&&o.lt(c))return s(se._({id:"F9xwHA",message:"Insufficient cross-chain fees, need at least {0} {1}",values:{0:Am({input:x,decimals:null!==(l=null==a?void 0:a.decimals)&&void 0!==l?l:18}),1:null!==(d=null==a?void 0:a.symbol)&&void 0!==d?d:"-"}})),void r(!1);if(!t||!(yield ug({from:g,to:h,value:m,data:p},t)))throw new Error("failed to estimate gas")}i({data:p,to:h,value:m,from:g,chainId:f}),a()}catch(e){console.error("[failed to construct transaction request]: ",e);const{message:t}=e;s(t)}r(!1)}}))),[e,t]);return{sendRouteLoading:o,sendRouteError:a,setSendRouteError:s,bridgeOrderTxRequest:n,handleClickSend:l}}(),{bridgeRouteList:Se,status:Ee,failedReason:Ae}=function({fromAccount:e,toAccount:t,fromToken:n,toToken:i,fromAmount:o,enabled:r,slippage:a}){var s,l,d,c;const{tokenList:u}=Th(),{GRAPHQL_URL:p}=Jn(),h=$((()=>n&&o?new Pe(o).multipliedBy(new Pe(10).pow(n.decimals)).dp(0,Pe.ROUND_DOWN):null),[o,n]),m=null!==(l=null===(s=null==e?void 0:e.appKitAccount)||void 0===s?void 0:s.address)&&void 0!==l?l:rh(null==n?void 0:n.chainId),g=null!==(c=null===(d=null==t?void 0:t.appKitAccount)||void 0===d?void 0:d.address)&&void 0!==c?c:rh(null==i?void 0:i.chainId),{data:f,error:x,isLoading:y,refetch:v}=et({retry:!1,queryKey:["graphql","cross_chain_swap_zetachain_routes",null==n?void 0:n.chainId,null==n?void 0:n.address,null==i?void 0:i.chainId,null==i?void 0:i.address,m,g,null==h?void 0:h.toString(),a],queryFn:()=>Vn(this,void 0,void 0,(function*(){const e=yield fetch(`${p}?opname=Cross_chain_swap_zetachain_routes`,{headers:{"content-type":"application/json"},body:`{"query":"\\n query Cross_chain_swap_zetachain_routes($where: Cross_chain_swap_zetachainrouteParams) {\\n cross_chain_swap_zetachain_routes(where: $where) {\\n routeId\\n fromChainId\\n fromTokenAddress\\n fromAmount\\n fromAmountWithOutDecimals\\n fromAmountUSD\\n toChainId\\n toTokenAddress\\n toAmount\\n toAmountWithOutDecimals\\n toAmountUSD\\n fromAddress\\n toAddress\\n slippage\\n approveTarget\\n fees\\n omniPlan\\n encodeParams\\n }\\n}\\n ","variables":{"where":{"fromChainId":${null==n?void 0:n.chainId},"fromTokenAddress":"${null==n?void 0:n.address}","toChainId":${null==i?void 0:i.chainId},"toTokenAddress":"${null==i?void 0:i.address}","fromAddress":"${m}","toAddress":"${g}","fromAmount":"${null==h?void 0:h.toString()}","slippage":${a?Number(a)/100:null}}},"operationName":"Cross_chain_swap_zetachain_routes"}`,method:"POST"}),t=yield e.json();if(t.errors)throw new Error(t.errors[0].message);return t.data})),refetchInterval:15e3,enabled:!!n&&!!i&&!!h&&h.isFinite()&&h.gt(0)&&n.chainId!==i.chainId&&r}),{status:b,failedReason:j,bridgeRouteList:C}=$((()=>{if(y)return{status:Eh.Loading,bridgeRouteList:[]};if(x){let e;if(console.error("error:",x),x.message.includes("NOT_ROUTE_MIN_AMOUNT:min-")){const t=x.message.split("min-")[1];t&&(e=`(Enter min amount: ${t})`)}return{status:Eh.Failed,failedReason:e,bridgeRouteList:[]}}if(f&&f.cross_chain_swap_zetachain_routes){const e=[],{routeId:t,fromChainId:n,fromTokenAddress:i,fromAmount:o,fromAmountWithOutDecimals:r,fromAmountUSD:a,toChainId:s,toTokenAddress:l,toAmount:d,fromAddress:c,toAddress:p,slippage:h,approveTarget:m,fees:g,omniPlan:x,encodeParams:y}=f.cross_chain_swap_zetachain_routes,v=ah.get(n);if(t&&n&&i&&r&&s&&l&&d&&c&&p&&h&&(!(null==v?void 0:v.isEVMChain)||m)&&g&&x&&x.length>0&&y){const o=u.find((e=>e.address.toLowerCase()===i.toLowerCase()&&e.chainId===n)),a=u.find((e=>e.address.toLowerCase()===l.toLowerCase()&&e.chainId===s)),v=new Pe(d);if(o&&a&&v.isFinite()&&v.gt(0)){const i=Sh({omniPlan:x,tokenList:u});if(i.includedSteps.length>0){const l=g.reduce(((e,t)=>{var n;return e.plus(null!==(n=t.amountUSD)&&void 0!==n?n:0)}),new Pe(0)).dp(4,Pe.ROUND_DOWN).toString(),d={key:t,id:t,fromChainId:n,toChainId:s,fromToken:o,toToken:a,fromAmount:r,toTokenAmount:v.div(`1e${a.decimals}`),fromAddress:c,toAddress:p,product:"zetachain",slippage:h,roundedRouteCostTime:0,spenderContractAddress:null!=m?m:null,feeUSD:l,fees:g,executionDuration:null,step:i,encodeParams:y,productParams:null,sourceRoute:f.cross_chain_swap_zetachain_routes};e.push(d)}}}return e.length>0?{status:Eh.Success,bridgeRouteList:e}:{status:Eh.Failed,bridgeRouteList:[]}}return{status:Eh.Initial,bridgeRouteList:[]}}),[y,x,f,u]);return{status:b,failedReason:j,refetch:v,bridgeRouteList:C}}({toToken:U,fromToken:N,fromAmount:_,fromAccount:ee,toAccount:te,enabled:!Y&&!be,slippage:he}),Oe=$((()=>{if(Se&&Se.length>0)return Se[0]}),[Se]),{isApproving:Le,isGetApproveLoading:Re,needApprove:_e,insufficientBalance:Me,submitApprove:Be,getMaxBalance:De,tokenQuery:Ne}=lf(N,{amount:_,contractAddress:null!==(r=null==Oe?void 0:Oe.spenderContractAddress)&&void 0!==r?r:void 0,account:null==ee?void 0:ee.appKitAccount.address}),{tokenQuery:Fe}=lf(U,{account:null==te?void 0:te.appKitAccount.address}),Ue=Z((()=>{Je(De())}),[De]),qe=$((()=>!(!(null==ee?void 0:ee.appKitAccount.address)||Me||Le||Re||_e)),[null==ee?void 0:ee.appKitAccount.address,Me,Le,Re,_e]),{status:Ve,rawBrief:We,executeSwap:He}=Yg({toToken:U,fromToken:N,marginAmount:ce,fromAmount:_,toAmount:B,estimateGas:qe,isReverseRouting:S,slippage:ue,slippageLoading:pe}),{resAmount:$e,priceImpact:ze,baseFeeAmount:Ze,additionalFeeAmount:Ge,resPricePerToToken:Qe,resPricePerFromToken:Ye,routeInfo:Ke}=$((()=>We||{resAmount:null,priceImpact:null,baseFeeAmount:null,additionalFeeAmount:null,resPricePerToToken:null,resPricePerFromToken:null,routeInfo:null}),[We]),Xe=jg(oe),Je=Z((e=>{const t=e.toString();O(t),ne(t)}),[O,ne]),tt=Z((e=>{const t=e.toString();P(t),ie(t)}),[P,ie]),nt=Z((e=>F((t=>{var i;const o="function"==typeof e?e(t):e;return T||xg.setState({fromTokenChainId:null!==(i=null==o?void 0:o.chainId)&&void 0!==i?i:void 0}),n&&o&&o!==t&&n(o),o}))),[n,T]),it=Z((e=>q((t=>{const n="function"==typeof e?e(t):e;return o&&n&&n!==t&&o(n),n}))),[o]);!function({fromToken:e,toToken:t,setFromToken:n,setToToken:i,updateFromAmt:o,updateToAmt:r,setIsReverseRouting:a}){const{tokenList:s}=Th(),{crossChain:l,defaultFromToken:d,defaultToToken:c,onlyChainId:u}=Jn(),{chainId:p}=dg(),h=Z((()=>{let h,m=null;const g=l?void 0:null!=u?u:p;if(!e){const e=Xg({side:"from",defaultToken:d,tokenList:s,chainId:g});m=e.findToken,h=e.setDefaultAmount,m&&(n(m),void 0!==h&&(a(!1),o(h)))}if(!t){const{findToken:e,setDefaultAmount:t}=Xg({side:"to",defaultToken:c,tokenList:s,occupyToken:m,chainId:g});e&&(i(e),void 0===h&&void 0!==t&&(a(!0),r(t)))}}),[p,l,d,c,e,u,n,a,i,t,s,o,r]);Q((()=>{const e=setTimeout((()=>{h()}),10);return()=>clearTimeout(e)}),[h])}({fromToken:N,toToken:U,setFromToken:nt,setToToken:it,updateFromAmt:Je,updateToAmt:tt,setIsReverseRouting:E});const ot=Z((()=>{Je(""),tt(""),nt(U),it(N),ch("from",U),ch("to",N)}),[nt,U,it,N,Je,tt]),rt=Z(((e,t)=>{if(t)return ot();Je(""),tt(""),nt(e),ch("from",e)}),[ot,Je,tt,nt,ch]),at=Z(((e,t)=>{if(t)return ot();Je(""),tt(""),it(e),ch("to",e)}),[ot,Je,tt,nt,ch]),st=Z((()=>{S&&Je(""),E(!1)}),[S,Je]),lt=Z((()=>{S||tt(""),E(!0)}),[S,tt]),dt=(e=>{const{defaultSlippage:t}=Kg(void 0===e),n=xg((e=>e.slippage||t));return $((()=>(void 0===e?Number(n):e)>5),[n,e])})(oe?void 0:ue),ct=$((()=>(100*Number(ze)).toFixed(2)),[ze]),ut=$((()=>{const e=S?$e:_;return e&&de?new Pe(de).multipliedBy(e):null}),[de,_,S,$e]),pt=$((()=>{var e;if(!re||void 0===oe)return null;if(oe)return(null===(e=null==Oe?void 0:Oe.toTokenAmount)||void 0===e?void 0:e.gt(0))?Oe.toTokenAmount.multipliedBy(re):null;const t=S?B:$e;return t?new Pe(re).multipliedBy(t):null}),[re,B,S,$e,Oe,oe]),ht=$((()=>Yn.jsxs(i,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[Yn.jsx(lb,{title:Yn.jsx(e,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),Yn.jsxs(i,{sx:{display:"flex"},children:[Yn.jsx(e,{id:"6+mYrD",message:"Current price impact"}),Yn.jsxs(i,{sx:{color:g.palette.error.main,ml:4},children:[ct,"%"]})]})]})),[ct,g.palette.error.main]),mt=$((()=>Yn.jsx(sj,{toToken:U,fromToken:N,priceStatus:Ve,pricePerToToken:Qe,pricePerFromToken:Ye,routeInfo:Ke})),[U,N,Ve,Qe,Ye,Ke]),gt=$((()=>!le[(null==N?void 0:N.chainId)||1]),[null==N?void 0:N.chainId]),ft=$((()=>{if(!N)return!1;const e=k(N.chainId);return!!e&&(!!e.chain.isEVMChain&&(!!T&&!!(null==N?void 0:N.chainId)&&(null==N?void 0:N.chainId)!==T))}),[T,N,k]),xt=function({fromToken:e,toToken:t}){const n=Th(Ih);return $((()=>!(!e||n.some((t=>t.chainId===e.chainId&&t.address===e.address&&(!t.side||"to"===t.side))))||!(!t||n.some((e=>e.chainId===t.chainId&&e.address===t.address&&(!e.side||"from"===e.side))))),[e,t,n])}({fromToken:N,toToken:U}),yt=$((()=>Yn.jsx(l,{open:Xe.showSwitchSlippage,title:oe?Yn.jsx(e,{id:"qLkska",message:"The setting has been switched to cross chain mode"}):Yn.jsx(e,{id:"NSCBTb",message:"The setting has been switched to swap mode"}),placement:"bottom-end",onClose:()=>Xe.setShowSwitchSlippage(!1),onlyClick:!0,children:Yn.jsx(i,{component:d,onClick:()=>G(!0),sx:{p:4,backgroundColor:g.palette.background.paper,borderRadius:4,height:28,width:28,display:"flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.Setting,sx:{width:20,height:20,color:"text.primary",cursor:"pointer"}})})})),[oe,Xe,g.palette.background.paper]),vt=$((()=>dt&&new Pe(S?B:_).gt(0)&&!Me&&(oe?Ee===Qg.Success:Ve===Qg.Success)?Yn.jsxs(i,{sx:{textAlign:"center",mb:8},children:[Yn.jsx(i,{component:li.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),se._({id:"//95jS",message:"The current slippage protection coefficient set exceeds {maxSlippageWarning}%, which may result in losses.",values:{maxSlippageWarning:5}})]}):null),[dt,S,B,_,Me,oe,Ee,Ve]),bt=$((()=>ft?Yn.jsxs(i,{sx:{textAlign:"center"},children:[Yn.jsx(i,{component:li.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),Yn.jsx(e,{id:"54ffaC",message:"The current network is inconsistent with the wallet - please switch in wallet"})]}):oe&&Ee===Qg.Initial?"-":Ve===Qg.Loading||oe&&Ee===Qg.Loading?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(L,{sx:{mr:5}}),Yn.jsx(e,{id:"JdNn1Y",message:"Fetching best price..."})]})}):gt?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.Warn,sx:{mr:6,width:16,color:"warning.main"}}),Yn.jsx(e,{id:"udsWDJ",message:"Unsupported network - switch to trade"})]}):oe&&Se.length?Yn.jsxs(Yn.Fragment,{children:[vt,Yn.jsx(gy,{route:Oe})]}):oe&&(Ee===Qg.Success&&!Se.length||Ee===Qg.Failed)&&A?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{component:li.Warn,sx:{width:15,mr:5,color:"warning.main"}}),Yn.jsx(e,{id:"NVAuTg",message:"Quote not available"})]}):Yn.jsxs(Yn.Fragment,{children:[!oe&&A&&new Pe(ct).gt(mh)&&ht,vt,mt]})),[Ve,mt,A,ht,ct,gt,oe,Ee,Se,Oe,ft,vt]),jt=$((()=>S?new Pe(R).gt(0)?Am({input:$e,decimals:null==N?void 0:N.decimals}):"-":A),[A,R,$e,N,S]),Ct=$((()=>{var e;return S?R:oe?(null===(e=null==Oe?void 0:Oe.toTokenAmount)||void 0===e?void 0:e.gt(0))&&Ee!==Qg.Loading?Am({input:Oe.toTokenAmount,decimals:null==U?void 0:U.decimals}):"-":new Pe(A).gt(0)?Am({input:$e,decimals:null==U?void 0:U.decimals}):"-"}),[A,R,$e,U,S,Oe,oe,Ee]),wt=$((()=>{var t,n,o,r;if(!(null===(t=null==ee?void 0:ee.appKitAccount)||void 0===t?void 0:t.isConnected)){const e=`Connect to ${lg(null==N?void 0:N.chainId)} wallet`,t=Yn.jsx(c,{fullWidth:!0,disabled:!0,children:e});if(!(null==N?void 0:N.chainId))return t;const i=null===(n=ah.get(N.chainId))||void 0===n?void 0:n.caipNetwork;if(!i)return t;const o=sg.getChainNamespace(i);return"sui"===o?Yn.jsx(Pt,{trigger:Yn.jsx(c,{fullWidth:!0,children:e}),open:C,onOpenChange:e=>{console.log("swap from button isOpen",e),w(e)}}):Yn.jsx(c,{fullWidth:!0,onClick:()=>{b({namespace:o})},children:e})}if(ee.chain.isEVMChain&&ee.chain.chainId!==T)return Yn.jsx(c,{fullWidth:!0,onClick:()=>{I.switchNetwork(ee.chain.caipNetwork)},children:Yn.jsx(e,{id:"1+P9RR",message:"Switch to {0}",values:{0:ee.chain.name}})});if(ee.chain.isSolanaChain&&ee.chain.chainId!==T)return Yn.jsx(c,{fullWidth:!0,onClick:()=>{I.switchNetwork(ee.chain.caipNetwork)},children:Yn.jsx(e,{id:"1+P9RR",message:"Switch to {0}",values:{0:ee.chain.name}})});if(!(null===(o=null==te?void 0:te.appKitAccount)||void 0===o?void 0:o.isConnected)){const e=`Connect to ${lg(null==U?void 0:U.chainId)} wallet`,t=Yn.jsx(c,{fullWidth:!0,disabled:!0,children:e});if(!(null==U?void 0:U.chainId))return t;const n=null===(r=ah.get(U.chainId))||void 0===r?void 0:r.caipNetwork;if(!n)return t;const i=sg.getChainNamespace(n);return"sui"===i?Yn.jsx(Pt,{trigger:Yn.jsx(c,{fullWidth:!0,children:e}),open:C,onOpenChange:e=>{console.log("swap to button isOpen",e),w(e)}}):Yn.jsx(c,{fullWidth:!0,onClick:()=>{b({namespace:i})},children:e})}if(f)return Yn.jsx(c,{fullWidth:!0,isLoading:!0,disabled:!0,children:Yn.jsx(e,{id:"FRBvjQ",message:"Transaction Pending"})});if(!N||!U)return Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:Yn.jsx(e,{id:"KlvBGJ",message:"Select Tokens"})});if(!new Pe(S?B:_).gt(0))return Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:Yn.jsx(e,{id:"iPMIoT",message:"Enter an amount"})});if(oe?Ee===Qg.Loading||Re:Ve===Qg.Loading)return Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:Yn.jsx(e,{id:"OauUE6",message:"Fetching Price..."})});let a=!1;return a=oe?!Se.length||Ee===Qg.Failed:!$e||Ve===Qg.Failed,a?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:Yn.jsx(e,{id:"NVAuTg",message:"Quote not available"})}):Me?Yn.jsx(c,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:Yn.jsx(e,{id:"znqB4T",message:"Insufficient balance"})}):_e?Yn.jsx(c,{fullWidth:!0,disabled:Le,onClick:()=>Be(),children:Le?Yn.jsx(e,{id:"j2Uisd",message:"Approving"}):Yn.jsx(e,{id:"Z7ZXbT",message:"Approve"})}):oe?Yn.jsx(c,{fullWidth:!0,onClick:()=>{var e,t;return Ie({selectedRoute:Oe,fromEtherTokenBalance:null!==(t=null===(e=ve.data)||void 0===e?void 0:e.balance)&&void 0!==t?t:null,goNext:()=>K(!0)})},"data-testid":bh,disabled:!Oe,isLoading:be,children:Yn.jsx(e,{id:"SXnevP",message:"Review Cross Chain"})}):ge?Yn.jsxs(c,{fullWidth:!0,onClick:()=>W(!0),"data-testid":bh,children:[Yn.jsx(l,{placement:"top",onlyHover:!0,maxWidth:240,title:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:500,color:"text.primary"},children:"Privacy Swap is Enabled"}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:"text.secondary"},children:"Your transactions on the Ethereum network will be protected from sandwich attacks."})]}),children:Yn.jsx(i,{sx:{mr:8},children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"30",viewBox:"0 0 25 30",fill:"none",children:[Yn.jsx("path",{d:"M12.5 4L3.5 8V14C3.5 19.55 7.34 24.74 12.5 26C17.66 24.74 21.5 19.55 21.5 14V8L12.5 4Z",fill:"white"}),Yn.jsx("path",{d:"M23 14C23 20.1791 18.7457 26.0187 12.8555 27.457L12.5 27.5439L12.1445 27.457C6.25427 26.0187 2 20.1791 2 14V7.02539L2.89062 6.62891L11.8906 2.62891L12.5 2.3584L13.1094 2.62891L22.1094 6.62891L23 7.02539V14Z",stroke:"white",strokeOpacity:"0.5",strokeWidth:"3"}),Yn.jsx("path",{d:"M16.3937 11.3638L10.8021 16.9553L8.60457 14.7662L7.4082 15.9626L10.8021 19.3565L17.59 12.5686L16.3937 11.3638Z",fill:"#154618"})]})})}),Yn.jsx(e,{id:"K/Ay/d",message:"Review Swap"})]}):Yn.jsx(c,{fullWidth:!0,onClick:()=>W(!0),"data-testid":bh,children:Yn.jsx(e,{id:"K/Ay/d",message:"Review Swap"})})}),[null===(s=null==ee?void 0:ee.appKitAccount)||void 0===s?void 0:s.isConnected,null==ee?void 0:ee.chain.isEVMChain,null==ee?void 0:ee.chain.chainId,null==ee?void 0:ee.chain.isSolanaChain,null==ee?void 0:ee.chain.name,null==ee?void 0:ee.chain.caipNetwork,T,null===(u=null==te?void 0:te.appKitAccount)||void 0===u?void 0:u.isConnected,f,N,U,S,B,_,oe,Ee,Re,Ve,Me,_e,ge,C,w,b,I,Se.length,$e,Le,Be,Oe,be,Ie,null===(p=ve.data)||void 0===p?void 0:p.balance]),kt=$((()=>N&&U?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{token:N,width:16,height:16,marginRight:6,chainId:N.chainId,noShowChain:!!y}),`${Am({input:S?$e:_,decimals:null==N?void 0:N.decimals})} ${null==N?void 0:N.symbol}`,Yn.jsx(i,{component:li.DoubleRight,sx:{width:12,height:12,mx:16}}),Yn.jsx(Df,{token:U,width:16,height:16,marginRight:6,chainId:U.chainId,noShowChain:!!y}),`${Am({input:S?B:$e,decimals:null==U?void 0:U.decimals})} ${null==U?void 0:U.symbol}`]}):Yn.jsx(i,{})),[N,U,_,B,$e,S,y]);return Yn.jsxs(i,{sx:{width:"100%",overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",borderRadius:16,backgroundColor:g.palette.background.skeleton,[g.breakpoints.up("laptop")]:{width:450,backgroundColor:g.palette.background.skeleton,backdropFilter:"blur(4px)"}},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",px:16,py:20},children:[Yn.jsx(i,{sx:{typography:"caption",color:g.palette.text.primary},children:"Universal Swap"}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",borderRadius:4,p:1,backgroundColor:g.palette.background.tag},children:[Yn.jsxs(i,{sx:{color:g.palette.text.secondary,typography:"h6",px:6,py:4},children:[oe?(null==Oe?void 0:Oe.slippage)?100*Oe.slippage:null!=he?he:"-":ue,"%"]}),yt]})]}),Yn.jsxs(i,{sx:{flex:1,px:16,pb:20,overflowY:"auto"},children:[Yn.jsxs(i,{children:[Yn.jsx(oj,{sx:{mb:4},token:N,side:"from",amt:jt,defaultLoadBalance:!0,onMaxClick:Ue,onInputChange:Je,onInputFocus:oe?void 0:st,showMaxBtn:!S&&!A,occupiedAddrs:[null!==(h=null==U?void 0:U.address)&&void 0!==h?h:""],occupiedChainId:null==U?void 0:U.chainId,fiatPriceTxt:ut?`$${Am({input:ut,decimals:2})}`:"$-",onTokenChange:rt,readOnly:S,showChainLogo:!y,showChainName:!y,notTokenPickerModal:!v,enterAddressEnabled:!1,inputToAddress:X,setInputToAddress:J,account:ee,failedReason:Ae,tokenQuery:Ne}),Yn.jsx(_b,{onClick:ot,disabled:xt}),Yn.jsx(oj,{token:U,side:"to",amt:Ct,onInputChange:tt,onInputFocus:oe?void 0:lt,occupiedAddrs:[null!==(m=null==N?void 0:N.address)&&void 0!==m?m:""],occupiedChainId:null==N?void 0:N.chainId,fiatPriceTxt:pt?Yn.jsxs(Yn.Fragment,{children:["$",Am({input:pt,decimals:2})]}):"$-",onTokenChange:at,readOnly:oe||!S,showChainLogo:!y,showChainName:!y,notTokenPickerModal:!v,enterAddressEnabled:oe,inputToAddress:X,setInputToAddress:J,account:te,sx:{padding:g.spacing(24,20,20)},tokenQuery:Fe,filterBySupportTargetChain:!1}),Yn.jsx(i,{sx:{py:16,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:bt})]}),wt,Yn.jsx(pb,{}),x?"":Yn.jsxs(i,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:g.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[Yn.jsx(i,{sx:{width:18,height:18,transform:"translate(1px, 2px)","& path":{fill:g.palette.text.disabled}},component:li.Dodo}),Yn.jsx(e,{id:"QIsI8+",message:"Powered by ZUNO protocol"})]})]}),Yn.jsx(hb,{toToken:U,fromToken:N,fromAmount:S?$e:_,toAmount:S?B:$e,open:V,baseFeeAmount:Ze,priceImpact:ct,additionalFeeAmount:Ge,curToFiatPrice:pt,execute:()=>He(kt),clearFromAmt:()=>Je(""),clearToAmt:()=>tt(""),curFromFiatPrice:ut,pricePerFromToken:Ye,onClose:()=>W(!1),loading:Ve===Qg.Loading,slippage:ue,isDialogModal:v}),oe?Yn.jsx(gb,{open:H,onClose:()=>G(!1),isBridge:!0,isDialogModal:v}):Yn.jsx(Pb,{open:H,onClose:()=>G(!1),fromToken:N,toToken:U,privacySwapEnableAble:fe,privacySwapEnable:ge,privacySwapSupplierEndpoints:me,endpointStatusMap:xe,refetchEndpointStatus:ye,isDialogModal:v}),Yn.jsx(cb,{open:Y,onClose:()=>K(!1),route:Oe,bridgeOrderTxRequest:Te,clearFromAmt:()=>Je(""),clearToAmt:()=>tt(""),isDialogModal:v}),Yn.jsx(ub,{message:je,onClose:()=>ke(""),isDialogModal:v})]})}const dj=[.25,.5,.75,1];function cj({value:e,onChange:t,sx:n}){const o=a(),r="light"===o.palette.mode,{isMobile:s}=Tg();return Yn.jsx(i,{sx:Object.assign({display:"grid",gap:s?10:14,gridTemplateColumns:`repeat(${dj.length}, 1fr)`},n),children:dj.map((n=>{const i=n===e;return Yn.jsxs(d,{disabled:!t,sx:{typography:"h6",borderRadius:4,padding:o.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:disabled":{color:"text.disabled"},"&:not(:disabled)&:hover":{color:o.palette.text.primary,backgroundColor:T(o.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?o.palette.primary.main:T(o.palette.text.primary,.4)}},onClick:()=>{!i&&t&&t(n)},className:i?"selected":void 0,children:[100*n,"%"]},n)}))})}function uj(){return a(),Yn.jsx(i,{sx:{height:4,position:"relative",color:"text.secondary"},children:Yn.jsx(i,{sx:{width:44,height:44,backgroundColor:"background.input",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",borderWidth:4,borderStyle:"solid",borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",color:"text.secondary"},children:Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"24",viewBox:"0 0 25 24",fill:"none",children:Yn.jsx("path",{d:"M19.0142 13H13.0142V19H11.0142V13H5.01416V11H11.0142V5H13.0142V11H19.0142V13Z",fill:"currentColor"})})})})}function pj(){return Yn.jsx(i,{sx:{position:"relative",height:4},children:Yn.jsx(i,{sx:{width:44,height:44,borderRadius:22,backgroundColor:"background.input",borderWidth:4,borderColor:"background.paper",position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%) rotate(90deg)",display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:Yn.jsx(i,{component:li.Plus})})})}function hj({sx:t,inputSx:n,amt:o,token:r,readOnly:s,showMaxBtn:l,canClickBalance:d,onMaxClick:u,fiatPriceTxt:p,occupiedAddrs:h,occupiedChainId:m,onInputFocus:g,onTokenClick:f,onInputChange:x,onTokenChange:y,side:v,showChainLogo:b,showChainName:j,defaultLoadBalance:C,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:I,inputReadonlyTooltip:S,inputTypography:E,chainId:A,hideToken:O,checkLogBalance:L,notTokenPickerModal:P}){var _,M;const{account:B}=dg(),D=a(),[N,F]=z(!1),U=et(ip.getFetchTokenQuery(null==r?void 0:r.chainId,null==r?void 0:r.address,B)),q=null!==(M=null!=w?w:null===(_=U.data)||void 0===_?void 0:_.balance)&&void 0!==M?M:null,{isTokenLoading:V}=Mb();let W=null!=k?k:U.isLoading;!W&&q&&(L?W=Object.entries(L).some((([e,t])=>V(e,t))):r&&(W=V(r.address,q))),Cg({tokenList:r?[r]:[]});const[H,$]=z(0),Z=G("");Q((()=>{o!==Z.current&&$(0)}),[o]);const{gotoBuyToken:Y}=Jn();let K=Y&&q&&o&&q.lt(o);const X=!!x||!!S;return Yn.jsxs(i,{sx:Object.assign({minHeight:X?133:"auto",padding:D.spacing(20,20,24),borderRadius:16,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:D.palette.background.input},t),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[O?Yn.jsx(i,{}):Yn.jsx(Nb,{token:r,showChainLogo:b,showChainName:j,onClick:()=>F(!0),readonly:!y}),Yn.jsx(Bb,{balance:q,balanceText:T,onClick:s||!u&&!x?void 0:e=>{u?u(e):x&&x(e),0!==H&&1!==H&&($(1),Z.current=e)},showMaxBtn:l,canClickBalance:d,address:null==r?void 0:r.address,decimals:null==r?void 0:r.decimals,loading:W})]}),X&&(s&&S?Yn.jsx(R,{title:S,arrow:!1,children:Yn.jsx(i,{children:Yn.jsx(Db,{value:o,readOnly:!0,withClear:!0,sx:Object.assign({mt:12},n)})})}):Yn.jsx(Db,{value:o,onFocus:g,onChange:x?e=>{x(e),$(0)}:void 0,readOnly:s,withClear:!0,suffix:K?Yn.jsx(c,{variant:c.Variant.tag,backgroundColor:D.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{e.stopPropagation(),null==Y||Y({token:r,account:B})},children:Yn.jsx(e,{id:"qiOIiY",message:"Buy"})}):void 0,typography:E,sx:Object.assign({mt:12},n)})),!s&&I?Yn.jsx(cj,{sx:{mt:16},value:H,onChange:q&&void 0!==(null==r?void 0:r.decimals)?e=>{if(q&&(null==r?void 0:r.decimals))if($(e),1===e){const e=q.toString();u?u(e):x&&x(e),Z.current=e}else if(x){const t=q.multipliedBy(e).dp(r.decimals).toString();x(t),Z.current=t}}:void 0}):"",void 0!==p?Yn.jsx(i,{sx:{mt:I?9:0,typography:"h6",color:D.palette.text.secondary},children:p}):"",Yn.jsx(Xb,{value:r,open:N,side:v,chainId:A,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:C,onClose:()=>{F(!1),f&&f()},onTokenChange:(e,t)=>{F(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),Sf)},modal:!P})]})}var mj;function gj(){return gj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},gj.apply(null,arguments)}const fj=e=>W.createElement("svg",gj({width:12,height:12,viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),mj||(mj=W.createElement("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"}))),xj=e=>Object.keys(new Array(e+1).join(","));function yj(e){return null!=e&&""!==e}var vj;function bj(){return bj=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bj.apply(null,arguments)}const jj=e=>W.createElement("svg",bj({height:355,viewBox:"0 0 397 355",width:397,xmlns:"http://www.w3.org/2000/svg"},e),vj||(vj=W.createElement("g",{fill:"none",fillRule:"evenodd",transform:"translate(-1 -1)"},W.createElement("path",{d:"m114.622644 327.195472 52.004717 13.810198v-18.05949l4.245283-4.249292h29.716982v21.246459 14.872523h-31.839624l-39.268868-16.997169z",fill:"#cdbdb2"}),W.createElement("path",{d:"m199.528305 327.195472 50.943397 13.810198v-18.05949l4.245283-4.249292h29.716981v21.246459 14.872523h-31.839623l-39.268868-16.997169z",fill:"#cdbdb2",transform:"matrix(-1 0 0 1 483.96227 0)"}),W.createElement("path",{d:"m170.872644 287.889523-4.245283 35.056657 5.306604-4.249292h55.18868l6.367925 4.249292-4.245284-35.056657-8.490565-5.311615-42.452832 1.062323z",fill:"#393939"}),W.createElement("path",{d:"m142.216984 50.9915022 25.471698 59.4900858 11.674528 173.158643h41.391511l12.735849-173.158643 23.349056-59.4900858z",fill:"#f89c35"}),W.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),W.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),W.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),W.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),W.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 56.25-39.305949z",fill:"#eb8f35"}),W.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),W.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),W.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),W.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),W.createElement("path",{d:"m114.622644 327.195472 56.25-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3"}),W.createElement("path",{d:"m229.245286 327.195472 55.18868-39.305949-4.245283 33.994334v19.121813l-38.207548-7.43626z",fill:"#dfcec3",transform:"matrix(-1 0 0 1 513.679252 0)"}),W.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),W.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),W.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"}),W.createElement("g",{transform:"matrix(-1 0 0 1 399.056611 0)"},W.createElement("path",{d:"m30.7783023 181.657226-29.71698153 86.048161 74.29245393-4.249293h47.7594343v-37.181303l-2.122641-76.487253-10.613208 8.498583z",fill:"#f89d35"}),W.createElement("path",{d:"m87.0283032 191.218134 87.0283028 2.124646-9.551886 44.617563-41.391511-10.623229z",fill:"#d87c30"}),W.createElement("path",{d:"m87.0283032 192.280457 36.0849058 33.994334v33.994334z",fill:"#ea8d3a"}),W.createElement("path",{d:"m123.113209 227.337114 42.452831 10.623229 13.79717 45.679888-9.551886 5.311615-46.698115-27.620398z",fill:"#f89d35"}),W.createElement("path",{d:"m123.113209 261.331448-8.490565 65.864024 55.18868-38.243626z",fill:"#eb8f35"}),W.createElement("path",{d:"m174.056606 193.34278 5.306604 90.297451-15.919812-46.211049z",fill:"#ea8e3a"}),W.createElement("path",{d:"m74.2924539 262.393771 48.8207551-1.062323-8.490565 65.864024z",fill:"#d87c30"}),W.createElement("path",{d:"m24.4103777 355.878193 90.2122663-28.682721-40.3301901-64.801701-73.23113313 5.311616z",fill:"#eb8f35"}),W.createElement("path",{d:"m167.688682 110.481588-45.636793 38.243627-35.0235858 42.492919 87.0283028 3.186969z",fill:"#e8821e"}),W.createElement("path",{d:"m132.665096 212.464593-11.674528 24.433427 41.39151-10.623229z",fill:"#393939",transform:"matrix(-1 0 0 1 283.372646 0)"}),W.createElement("path",{d:"m23.349057 1.06232296 144.339625 109.41926504-24.410378-59.4900858z",fill:"#e88f35"}),W.createElement("path",{d:"m23.349057 1.06232296-19.10377392 58.42776294 10.61320772 63.7393781-7.42924541 4.249292 10.61320771 9.560906-8.49056617 7.436261 11.67452847 10.623229-7.4292454 6.373938 16.9811323 21.246459 79.5990577-24.433428c38.915096-31.161473 58.018869-47.096318 57.311322-47.804533-.707548-.708215-48.820756-37.1813036-144.339625-109.41926504z",fill:"#8e5a30"})))));function Cj(e){const{switchNetwork:t}=Nt();return $((()=>{var n;if(!e)return;const i=null===(n=ah.get(e))||void 0===n?void 0:n.caipNetwork;return i?()=>t(i):void 0}),[e,t])}function wj({token:e,size:t="small",sx:n,children:o}){const[r,a]=z(!1),{evmProvider:s,chainId:l}=dg(),d=Cj(e.chainId);return Yn.jsxs(i,{sx:ne({margin:"0",border:"none",padding:"0",background:"none",cursor:"pointer","&:focus":{outline:"none"},"&:active":{outline:"none"},display:"inline-flex",alignItems:"center",justifyContent:"center"},n),onClick:t=>Vn(this,void 0,void 0,(function*(){if(t.stopPropagation(),void 0!==e.chainId&&e.chainId!==l&&d)return void(null==d||d());if(r)return;if(!s)return;a(!0);const{result:n,failMsg:i}=yield function(e,t){return Vn(this,void 0,void 0,(function*(){if(!e)return{result:!1};try{return{result:yield e.send("wallet_watchAsset",{type:"ERC20",options:{address:t.address,symbol:t.symbol,decimals:t.decimals,image:t.logoURI}})}}catch(e){return console.error(e),{result:!1,failMsg:null==e?void 0:e.message}}}))}(s,e);n?$v.getState().toast({message:se._({id:"DupCvC",message:"Added successful"}),type:"success",timeout:3e3}):$v.getState().toast({message:`${se._({id:"v4wgrk",message:"Failed to add"})}${i?`: ${i}`:""}`,type:"error"}),a(!1)})),component:"button",children:[Yn.jsx(i,{component:jj,sx:Object.assign({},"medium"===t?{width:16,height:16}:{width:14,height:14})}),o]})}function kj({tokens:e,width:t=24,height:n=24,gap:o=-4,cross:r,mr:s,chainId:l,showChainLogo:d,sx:c}){var u;const p=a(),{onlyChainId:h}=Jn(),m=d&&!h,g=t/2;return!e||e.length<=0?Yn.jsx(i,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:s,position:"relative",zIndex:0},c),children:Yn.jsx(i,{component:"svg",xmlns:"http://www.w3.org/2000/svg",width:52,height:24,viewBox:"0 0 52 24",fill:"none",sx:{height:t,width:"auto",color:T(p.palette.text.primary,"light"===p.palette.mode?.11:.13),animation:"pulseKeyframe 2s ease-in-out 0.5s infinite","@keyframes pulseKeyframe":{"0%":{opacity:1},"50%":{opacity:.4},"100%":{opacity:1}}},children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M21.3746 4.50813C19.1755 1.76008 15.7933 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24C15.7933 24 19.1755 22.2399 21.3746 19.4919C19.8788 17.3743 19 14.7898 19 12C19 9.21023 19.8788 6.62571 21.3746 4.50813ZM22 5.36441C24.1498 2.13102 27.8261 0 32 0C38.3911 0 43.6152 4.99623 43.9797 11.296C41.0986 12.163 39 14.8364 39 18C39 19.1371 39.2711 20.2108 39.7523 21.1602C37.6611 22.9317 34.9553 24 32 24C27.8261 24 24.1498 21.869 22 18.6356C20.7363 16.735 20 14.4535 20 12C20 9.54653 20.7363 7.26502 22 5.36441ZM52 18C52 21.3137 49.3137 24 46 24C43.5588 24 41.458 22.542 40.5211 20.4493C40.5042 20.4116 40.4876 20.3736 40.4715 20.3355C40.1679 19.6176 40 18.8284 40 18C40 15.3894 41.6673 13.1682 43.9952 12.3431C44.6221 12.1209 45.2969 12 46 12C49.3137 12 52 14.6863 52 18Z",fill:"currentColor"})})}):Yn.jsxs(i,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:s,position:"relative",zIndex:0},c),children:[e.map(((e,n)=>Yn.jsx(i,{sx:{display:"inline-flex",width:t,height:t,ml:n>0?o:0,borderRadius:"50%",backgroundColor:p.palette.background.default},children:"object"==typeof e?Yn.jsx(Df,{address:e.address,width:t,height:t,chainId:l,url:e.logoURI,cross:r,noShowChain:!0,noBorder:!0,marginRight:0}):Yn.jsx(i,{component:"img",height:t,src:e})},n))),m&&ah.has(l)?Yn.jsx(i,{component:null===(u=ah.get(l))||void 0===u?void 0:u.logo,sx:{position:"absolute",bottom:0,right:0,zIndex:e.length+1,transform:"translateX(50%)",width:g,height:g}}):""]})}function Tj({loading:e,empty:t,hasSearch:n,children:o,refetch:r}){return e?Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",gap:24,px:24,height:320},children:xj(4).map(((e,t)=>Yn.jsx(j,{width:"100%",height:45},t)))}):r?Yn.jsx(ai,{refresh:r,sx:{height:320}}):t?Yn.jsx(ti,{hasSearch:n,sx:{height:320}}):Yn.jsx(Yn.Fragment,{children:o})}function Ij({show:e,onClick:t,sx:n}){return Yn.jsx(i,{component:d,sx:Object.assign({p:3,transform:e?"rotate(180deg)":"none",transition:"all 100ms",color:"text.primary",display:"flex",alignItems:"center",justifyContent:"center"},n),onClick:t,children:Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.58398 11.376C8.78189 11.6728 9.21811 11.6728 9.41603 11.376L12.4818 6.77735C12.7033 6.44507 12.4651 6 12.0657 6H5.93426C5.53491 6 5.29672 6.44507 5.51823 6.77735L8.58398 11.376Z",fill:"currentColor"})})})}function Sj({isMobile:e,statusText:t,statusColor:n,time:o,alphaColor:r,sx:s,children:l}){const d=a(),c=T(n,.1),u=r?T(n,r):n;return Yn.jsxs(i,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:e?"center":"flex-start",gap:2,typography:"h6",color:"text.secondary"},s),children:[Yn.jsxs(i,{sx:{padding:d.spacing(4,16),borderRadius:4,backgroundColor:c,color:u,textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center"},children:[t,l]}),o]})}function Ej({token:e,amount:t,canAddMetamask:n,title:o,linkVisible:r=!0}){var a,s;return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2},children:[Yn.jsxs(i,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:[o,": ",Am({input:t,decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),n&&e&&Yn.jsx(wj,{token:e})]}),Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:4,typography:"h6",fontWeight:500,color:"text.secondary"},children:[e&&null!==(s=null===(a=ah.get(e.chainId))||void 0===a?void 0:a.name)&&void 0!==s?s:"-",r&&Yn.jsx(fj,{})]})]})}function Aj({token:e,amount:t,showChain:n,hideLogo:o,canAddMetamask:r,sx:a}){var s,l;let d="";n&&(d=null!==(l=null===(s=ah.get(e.chainId))||void 0===s?void 0:s.name)&&void 0!==l?l:"");const c=Am({input:t,decimals:e.decimals});return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:[!o&&Yn.jsx(Df,{address:e.address,chainId:e.chainId,width:20,height:20}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:2},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,wordBreak:"break-word",typography:"body1",fontWeight:600},children:[`${c} ${e.symbol}`,r&&Yn.jsx(wj,{token:e})]}),!!d&&Yn.jsxs(i,{sx:{display:"inline-flex",alignItems:"center",gap:2,typography:"h6",fontWeight:500,color:"text.secondary"},children:[d,Yn.jsx(fj,{})]})]})]})}function Oj({height:t=64,sx:n,onClick:o,hasMore:r,loading:s}){return a(),r?Yn.jsx(d,{sx:Object.assign({display:"flex",justifyContent:"center",alignItems:"center",height:t,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},n),onClick:o,children:s?Yn.jsx(L,{}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})}):null}function Lj(e){var{sx:t,children:n,hasMore:o,loadMore:r,loadMoreLoading:a}=e,s=qn(e,["sx","children","hasMore","loadMore","loadMoreLoading"]);return Yn.jsxs(i,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",pt:12,px:20,pb:20},t),...s,children:[Yn.jsx(i,{component:"table",sx:{width:"100%",borderCollapse:"separate",borderSpacing:"0 4px","& th":{py:12,px:24,typography:"body2",textAlign:"left",color:"text.secondary",backgroundColor:"background.paper"},"& th:first-of-type":{borderTopLeftRadius:"8px",borderBottomLeftRadius:"8px"},"& th:last-of-type":{borderTopRightRadius:"8px",borderBottomRightRadius:"8px"},"& td":{px:24,py:20,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,"&::after":{content:'""',display:"table-row",height:"0"}}},children:n}),!!r&&Yn.jsx(Oj,{loading:a,hasMore:o,onClick:r})]})}function Rj({fromToken:e,toToken:t,fromTokenPrice:n,toTokenPrice:o,sx:r,children:s}){const l=a(),[c,u]=z(!1),p=$((()=>new Pe(n&&o?c?o:n:0)),[n,o,c]);return Yn.jsxs(i,{component:d,sx:Object.assign({display:"flex",alignItems:"center",gap:8,color:"text.primary",typography:"body1",fontWeight:600,"&:hover>svg>path":{fill:l.palette.text.primary}},r),onClick:()=>u((e=>!e)),children:[Yn.jsxs(i,{children:[s,"1 ",c?t.symbol:e.symbol," = ",p&&p.isFinite()?Am({input:p,decimals:c?e.decimals:t.decimals}):"-"," ",c?e.symbol:t.symbol]}),Yn.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[Yn.jsx("circle",{cx:"9",cy:"9",r:"9",fill:l.palette.border.main}),Yn.jsx("path",{d:"M9.5 6.5H4.5V8H13.5L9.5 4.25V6.5ZM8.25 13.75V11.5H13.5V10H4.5L8.25 13.75Z",fill:l.palette.text.secondary})]})]})}function Pj({showFold:e,isMobile:t,data:n}){const o=a(),r=$((()=>{var e,t,i,o,r,a,s,l,d,c,u,p,h,m;const g=[{title:"Total time spent",value:null!==(i=hf({start:null!==(e=n.startTime)&&void 0!==e?e:void 0,end:null!==(t=n.endTime)&&void 0!==t?t:void 0}))&&void 0!==i?i:"-"},{title:"Pay",value:Yn.jsx(zb,{address:null!==(o=n.fromAddress)&&void 0!==o?o:"",customChainId:null!==(r=n.routeData.fromChainId)&&void 0!==r?r:le.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:"Receive",value:Yn.jsx(zb,{address:null!==(a=n.toAddress)&&void 0!==a?a:"",customChainId:null!==(s=n.routeData.toChainId)&&void 0!==s?s:le.ZETACHAIN,showCopy:!0,truncate:!0,iconSpace:4,iconSize:14,size:"small"})},{title:Yn.jsxs(Yn.Fragment,{children:["Fill Gas (Destination gas)",Yn.jsx(lb,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(c=null===(d=null===(l=n.fees)||void 0===l?void 0:l.find((e=>"destinationFee"===e.type)))||void 0===d?void 0:d.amountUSD)&&void 0!==c?c:"-"}`},{title:Yn.jsxs(Yn.Fragment,{children:["Bridge Fee",Yn.jsx(lb,{onlyHover:!0,title:"-",ml:0})]}),value:`$${null!==(h=null===(p=null===(u=n.fees)||void 0===u?void 0:u.find((e=>"platformFee"===e.type)))||void 0===p?void 0:p.amountUSD)&&void 0!==h?h:"-"}`}],f=null===(m=n.fees)||void 0===m?void 0:m.find((e=>"svmRentFee"===e.type));return f&&g.push({title:Yn.jsxs(Yn.Fragment,{children:["Rent",Yn.jsx(lb,{onlyHover:!0,title:"Rent (only first transaction of SPL token)",ml:0})]}),value:`$${f.amountUSD}`}),g}),[n.endTime,n.fees,n.fromAddress,n.routeData.fromChainId,n.routeData.toChainId,n.startTime,n.toAddress]);return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:16,p:e?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${o.palette.background.skeleton} 0%, ${o.palette.background.skeleton} 100%), ${o.palette.background.paper}`,maxHeight:e?"auto":0,transition:"all 300ms",overflow:"hidden",[o.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px",gap:24}},children:[Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:8,[o.breakpoints.up("tablet")]:{alignItems:"center",flexDirection:"row",gap:20}},children:r.map(((e,t)=>Yn.jsxs(i,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",[o.breakpoints.up("tablet")]:{flexBasis:"20%",flexGrow:1,flexShrink:1,flexDirection:"column",alignItems:"flex-start",justifyContent:"flex-start",gap:4}},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.secondary",typography:"h6"},children:e.title}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.primary",typography:"body2"},children:e.value})]},t)))}),null!=n.routeData.fromChainId&&null!=n.routeData.toChainId&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{height:"1px",width:"100%",backgroundColor:"border.disabled"}}),Yn.jsx(hy,{route:{fromChainId:n.routeData.fromChainId,toChainId:n.routeData.toChainId,step:n.routeData.step},isMobile:t})]})]})}function _j({data:e}){const t=a(),n="refund_success"===e.subStatus,{isMobile:o}=Tg();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2,[t.breakpoints.up("tablet")]:{gap:8}},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",width:16,height:16,color:n?t.palette.success.main:t.palette.text.disabled,borderRadius:"50%",backgroundColor:n?T(t.palette.success.main,.1):t.palette.background.tag,[t.breakpoints.up("tablet")]:{width:24,height:24}},children:n?Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:o?"12":"16",height:o?"12":"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{d:"M12.7601 3.55554L5.92598 10.3896L3.24005 7.71406L1.77783 9.17628L5.92598 13.3244L14.2223 5.02813L12.7601 3.55554Z",fill:"currentColor"})}):Yn.jsx(L,{sx:{width:12,color:t.palette.text.disabled,[t.breakpoints.up("tablet")]:{width:16}}})}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2,[t.breakpoints.up("tablet")]:{flexDirection:"column",alignItems:"flex-start"}},children:[e.refundChainId&&e.refundHash?Yn.jsx(zb,{address:e.refundHash,customChainId:e.refundChainId,showCopy:!1,truncate:!0,iconSpace:o?2:8,sx:{typography:"h6",[t.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},handleOpen:t=>{t.stopPropagation(),window.open(tg(e.refundChainId,e.refundHash,"tx"))}}):Yn.jsx(i,{sx:{typography:"h6",[t.breakpoints.up("tablet")]:{typography:"body1",fontWeight:600}},children:"-"}),Yn.jsx(i,{sx:{display:"none",[t.breakpoints.up("tablet")]:{display:"block",typography:"h6",color:t.palette.text.secondary}},children:n?"Refunded to this address.":"Refund in progress."}),n?null:Yn.jsx(i,{sx:{typography:"h6",color:t.palette.text.secondary,[t.breakpoints.up("tablet")]:{display:"none"}},children:"(Refund in progress.)"})]})]})}function Mj({data:e,isMobile:t,isErrorRefund:n}){var o,r,s,d,c,u,p,h,m,g;const f=a(),{statusText:x,statusColor:y,statusAlphaColor:v}=$((()=>{let t="Loading",n=f.palette.text.primary;switch(e.status){case"pending":t="Pending",n=f.palette.text.secondary;break;case"success":t="Succeeded",n=f.palette.success.main;break;case"failure_revert":t="Swap failed",n=f.palette.error.main;break;case"abort":t="Aborted",n=f.palette.error.main}return{statusText:t,statusColor:n,statusAlphaColor:undefined}}),[e.status,f.palette.error.main,f.palette.success.main,f.palette.text.primary,f.palette.text.secondary]),[b,j]=H.useState(!1),C=e.createdAt?gf(new Date(e.createdAt)):"-";return t?Yn.jsxs(i,{sx:{backgroundColor:f.palette.background.paper,borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{width:24,height:24,address:null===(o=e.fromToken)||void 0===o?void 0:o.address,chainId:null===(r=e.fromToken)||void 0===r?void 0:r.chainId}),Yn.jsx(i,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:Yn.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),Yn.jsx(Df,{width:24,height:24,address:null===(s=e.toToken)||void 0===s?void 0:s.address,chainId:null===(d=e.toToken)||void 0===d?void 0:d.chainId})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8},children:Yn.jsx(Sj,{isMobile:!1,statusText:x,statusColor:y,alphaColor:v,children:"success"!==e.status&&Yn.jsx(lb,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:y}})})})]}),Yn.jsx(i,{sx:{typography:"h6",color:f.palette.text.secondary},children:C})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(Ej,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay",linkVisible:!1}),Yn.jsx(Ej,{token:e.toToken,amount:e.toAmount,canAddMetamask:e.fromToken&&null!==(u=null===(c=ah.get(e.fromToken.chainId))||void 0===c?void 0:c.isEVMChain)&&void 0!==u&&u,title:"Receive",linkVisible:!1}),n&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2},children:[Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:"text.primary"},children:"Refunds TX:"}),Yn.jsx(_j,{data:e})]})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${f.palette.border.main}`},children:Yn.jsx(Ij,{show:b,onClick:()=>j((e=>!e)),sx:{color:"text.secondary"}})})]})]}),Yn.jsx(Pj,{showFold:b,data:e,isMobile:t})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("tr",{children:[Yn.jsx(i,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:b?0:8},children:e.fromToken&&Yn.jsx(Aj,{token:e.fromToken,amount:null!==(p=e.fromAmount)&&void 0!==p?p:"",showChain:!0})}),Yn.jsx("td",{children:e.toToken&&Yn.jsx(Aj,{token:e.toToken,amount:null!==(h=e.toAmount)&&void 0!==h?h:"",showChain:!0,canAddMetamask:null!==(g=null===(m=ah.get(e.toToken.chainId))||void 0===m?void 0:m.isEVMChain)&&void 0!==g&&g})}),Yn.jsx("td",{children:Yn.jsx(Sj,{isMobile:t,statusText:x,statusColor:y,alphaColor:v,time:C,children:"success"!==e.status&&Yn.jsx(lb,{onlyHover:!0,title:e.subStatus,ml:4,sx:{color:y}})})}),n?Yn.jsx("td",{children:Yn.jsx(_j,{data:e})}):Yn.jsx("td",{children:e.fromToken&&e.toToken&&Yn.jsx(Rj,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),Yn.jsx(i,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:b?0:8},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[!n&&"refund_success"===e.subStatus&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(l,{title:"refund TX",placement:"top",onlyHover:!0,children:Yn.jsx(i,{component:"a",href:e.refundChainId&&e.refundHash?tg(e.refundChainId,e.refundHash,"tx"):void 0,target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:18,height:18}})})}),Yn.jsx(i,{sx:{height:16,width:"1px",backgroundColor:"border.main"}})]}),Yn.jsx(Ij,{show:b,onClick:()=>j((e=>!e))})]})})]}),Yn.jsx("tr",{children:Yn.jsx(i,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:Yn.jsx(Pj,{showFold:b,data:e})})})]})}function Bj({account:t,type:n}){const{isMobile:o}=Tg(),r=function({account:e,limit:t=5,type:n}){var i;const{tokenList:o}=Th(),r=gg().getInfiniteQuery(Ce.graphql.cross_chain_swap_zetachain_orderList,"page",{where:{user:e,pageSize:t,type:n}}),a=at(Object.assign(Object.assign({},r),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_orderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),s=$((()=>{var e,t,n,i;return null!==(i=null===(n=null===(t=null===(e=a.data)||void 0===e?void 0:e.pages)||void 0===t?void 0:t.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_orderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===n?void 0:n.map((e=>{const t=o.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.fromTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.fromChainId)})),n=o.find((t=>{var n;return t.address.toLowerCase()===(null===(n=null==e?void 0:e.toTokenAddress)||void 0===n?void 0:n.toLowerCase())&&t.chainId===(null==e?void 0:e.toChainId)})),i=(null==e?void 0:e.fromAmount)&&t?new Pe(e.fromAmount).div(10**t.decimals).dp(t.decimals,Pe.ROUND_DOWN):null,r=(null==e?void 0:e.toAmount)&&n?new Pe(e.toAmount).div(10**n.decimals).dp(n.decimals,Pe.ROUND_DOWN):null;return{hash:null==e?void 0:e.fromHash,refundHash:null==e?void 0:e.refundHash,externalId:null==e?void 0:e.externalId,refundCridgeContract:void 0,refundChainId:(null==e?void 0:e.refundChainId)?Number(e.refundChainId):void 0,fromToken:t,toToken:n,fromAmount:i,toAmount:r,startTime:(null==e?void 0:e.startTime)?1e3*e.startTime:void 0,endTime:(null==e?void 0:e.endTime)?1e3*e.endTime:void 0,createdAt:null==e?void 0:e.createdAt,fromAddress:null==e?void 0:e.fromAddress,toAddress:null==e?void 0:e.toAddress,routeData:{fromChainId:null==e?void 0:e.fromChainId,toChainId:null==e?void 0:e.toChainId,step:Sh({omniPlan:null==e?void 0:e.omniPlan,tokenList:o})},fees:null==e?void 0:e.fees,status:null==e?void 0:e.status,subStatus:null==e?void 0:e.subStatus,transactionHash:null==e?void 0:e.fromHash,fromTokenPrice:i&&r&&t?r.div(i).dp(t.decimals,Pe.ROUND_DOWN).toString():null,toTokenPrice:i&&r&&n?i.div(r).dp(n.decimals,Pe.ROUND_DOWN).toString():null}})))&&void 0!==i?i:[]}),[null===(i=a.data)||void 0===i?void 0:i.pages,o]);return Object.assign(Object.assign({},a),{orderList:s})}({account:t,limit:o?10:5,type:n}),a="error_refund"===n;return Yn.jsx(Tj,{isMobile:o,empty:!r.orderList.length,loading:r.isLoading,children:o?Yn.jsxs(i,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[r.orderList.map((e=>Yn.jsx(Mj,{data:e,isMobile:o,isErrorRefund:a},e.hash))),Yn.jsx(Oj,{loading:r.isFetchingNextPage,onClick:r.fetchNextPage,hasMore:r.hasNextPage,height:68})]}):Yn.jsx(Yn.Fragment,{children:Yn.jsxs(Lj,{loadMoreLoading:r.isFetchingNextPage,loadMore:r.fetchNextPage,hasMore:r.hasNextPage,children:[Yn.jsx("thead",{children:Yn.jsxs("tr",{children:[Yn.jsx("th",{children:Yn.jsx(e,{id:"4fL/V7",message:"Pay"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"lDgVWA",message:"Receive"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"uAQUqI",message:"Status"})}),a?Yn.jsx("th",{children:Yn.jsx(e,{id:"VmAUk7",message:"Refunds TX"})}):Yn.jsx("th",{children:Yn.jsx(e,{id:"fqDzSu",message:"Rate"})}),Yn.jsx(i,{component:"th",sx:{width:a?110:140,textAlign:"right !important"},children:Yn.jsx(e,{id:"URmyfc",message:"Details"})})]})}),Yn.jsx("tbody",{children:r.orderList.map((e=>Yn.jsx(Mj,{data:e,isMobile:o,isErrorRefund:a},e.hash)))})]})})})}function Dj({account:e,limit:t=5}){var n,i,o,r;const a=void 0,s=gg().getInfiniteQuery(Ce.graphql.cross_chain_swap_zetachain_swapOrderList,"page",{where:{userAddress:null==e?void 0:e.toLowerCase(),pageSize:t}}),l=at(Object.assign(Object.assign({},s),{enabled:!!e,initialPageParam:1,getNextPageParam:e=>{var n;const{page:i,count:o}=null!==(n=e.cross_chain_swap_zetachain_swapOrderList)&&void 0!==n?n:{page:0,count:0};return i&&o?i*t>=o?null:i+1:null}})),d=null!==(r=null===(o=null===(i=null===(n=l.data)||void 0===n?void 0:n.pages)||void 0===i?void 0:i.reduce(((e,t)=>{var n,i;return[...e,...null!==(i=null===(n=t.cross_chain_swap_zetachain_swapOrderList)||void 0===n?void 0:n.list)&&void 0!==i?i:[]]}),[]))||void 0===o?void 0:o.map((t=>{var n,i,o,r,s,l,d,c,u,p,h,m,g,f,x,y,v,b,j;let C="";const w=null!==(i=null===(n=null==t?void 0:t.extra)||void 0===n?void 0:n.safeTxHash)&&void 0!==i?i:void 0;return w&&a&&e&&(C=a(w,null==t?void 0:t.chainId,e)),{hash:null!==(o=null==t?void 0:t.hash)&&void 0!==o?o:"",fromToken:ag({address:null!==(r=null==t?void 0:t.fromTokenAddress)&&void 0!==r?r:"",decimals:null==t?void 0:t.fromTokenDecimals,symbol:null!==(s=null==t?void 0:t.fromTokenSymbol)&&void 0!==s?s:"",name:null!==(l=null==t?void 0:t.fromTokenSymbol)&&void 0!==l?l:""},null==t?void 0:t.chainId),toToken:ag({address:null!==(d=null==t?void 0:t.toTokenAddress)&&void 0!==d?d:"",decimals:null==t?void 0:t.toTokenDecimals,symbol:null!==(c=null==t?void 0:t.toTokenSymbol)&&void 0!==c?c:"",name:null!==(u=null==t?void 0:t.toTokenSymbol)&&void 0!==u?u:""},null==t?void 0:t.chainId),fromAmount:null!==(p=null==t?void 0:t.fromAmount)&&void 0!==p?p:"",toAmount:null!==(h=null==t?void 0:t.toAmount)&&void 0!==h?h:"",minAmount:null!==(m=null==t?void 0:t.minAmount)&&void 0!==m?m:"",fromTokenPrice:null!==(g=null==t?void 0:t.fromTokenPrice)&&void 0!==g?g:"",toTokenPrice:null!==(f=null==t?void 0:t.toTokenPrice)&&void 0!==f?f:"",createdAt:null!==(x=null==t?void 0:t.createdAt)&&void 0!==x?x:"",routeData:null!==(v=null===(y=null==t?void 0:t.extra)||void 0===y?void 0:y.routeData)&&void 0!==v?v:"",safeTxHash:w,safeTxUrl:C,status:null!==(b=null==t?void 0:t.status)&&void 0!==b?b:"",transactionHash:null===(j=null==t?void 0:t.extra)||void 0===j?void 0:j.transactionHash}})))&&void 0!==r?r:[];return Object.assign(Object.assign({},l),{orderList:d})}var Nj,Fj;function Uj({showFold:t,isMobile:n,data:o}){const r=a(),{routeData:s}=rj({rawRouteData:o.routeData,chainId:o.fromToken.chainId}),l=$((()=>o.fromTokenPrice?new Pe(o.fromTokenPrice):new Pe(0)),[o.fromTokenPrice]);return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:24,p:t?16:0,borderBottomLeftRadius:8,borderBottomRightRadius:8,background:`linear-gradient(0deg, ${r.palette.background.skeleton} 0%, ${r.palette.background.skeleton} 100%), ${r.palette.background.paper}`,maxHeight:t?400:0,transition:"all 300ms",overflow:"hidden",[r.breakpoints.up("tablet")]:{marginTop:"-4px",marginBottom:"4px"}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"h6",color:r.palette.text.secondary},children:[Yn.jsx(e,{id:"URmyfc",message:"Details"}),n&&Yn.jsxs(i,{children:["Rate: 1 ",o.fromToken.symbol,"=",l&&l.isFinite()?Am({input:l,decimals:o.toToken.decimals}):"-"," ",o.toToken.symbol]})]}),n?Yn.jsx($f,{routeData:s,fromTokenRaw:o.fromToken,toTokenRaw:o.toToken}):Yn.jsx(zf,{routeData:s,fromTokenRaw:o.fromToken,toTokenRaw:o.toToken})]})}function qj({data:e,isMobile:t}){var n,o,r,s,l,d;const c=a(),[u,p]=H.useState(!1),{statusText:h,statusColor:m,statusAlphaColor:g}=function({status:e,stateTextMap:t}){let n=t?t[e]:e;const i=a();let o,r=se._({id:"yQE2r9",message:"Loading"}),s=i.palette.text.primary;switch(e){case Nj.Warning:r=se._({id:"GGWsTU",message:"Canceled"}),o=.1;break;case Nj.Failed:r=se._({id:"7Bj3x9",message:"Failed"}),s=i.palette.error.main;break;case Nj.Success:r=se._({id:"KAbcm2",message:"Succeeded"}),s=i.palette.success.main}return{state:n,statusText:r,statusColor:s,statusAlphaColor:o}}({status:e.status}),f=gf(new Date(e.createdAt));return t?Yn.jsxs(i,{sx:{backgroundColor:c.palette.background.paper,borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",p:16,gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},onClick:()=>window.open(tg(e.fromToken.chainId,e.hash,"tx"),"_blank"),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{width:24,height:24,address:e.fromToken.address,chainId:e.fromToken.chainId}),Yn.jsx(i,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{color:"text.secondary"},children:Yn.jsx("path",{d:"M7.575 8.625L4.5 11.7L5.625 12.75L9.75 8.625L5.625 4.5L4.5 5.55L7.575 8.625ZM12.15 8.625L9.075 11.7L10.125 12.75L14.25 8.625L10.125 4.5L9.075 5.55L12.15 8.625Z",fill:"currentColor"})}),Yn.jsx(Df,{width:24,height:24,address:e.toToken.address,chainId:e.toToken.chainId})]}),Yn.jsx(Sj,{isMobile:!1,statusText:h,statusColor:m,alphaColor:g})]}),Yn.jsx(i,{sx:{typography:"h6",color:c.palette.text.secondary},children:f})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[Yn.jsx(Ej,{token:e.fromToken,amount:e.fromAmount,canAddMetamask:!1,title:"Pay"}),Yn.jsx(Ej,{token:e.toToken,amount:e.toAmount,canAddMetamask:null!==(o=null===(n=ah.get(e.fromToken.chainId))||void 0===n?void 0:n.isEVMChain)&&void 0!==o&&o,title:"Receive"})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",p:2,borderRadius:8,border:`1px solid ${c.palette.border.main}`},children:Yn.jsx(Ij,{show:u,onClick:()=>p((e=>!e)),sx:{color:"text.secondary"}})})]})]}),Yn.jsx(Uj,{showFold:u,data:e,isMobile:!0})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("tr",{children:[Yn.jsx(i,{component:"td",sx:{borderTopLeftRadius:8,borderBottomLeftRadius:u?0:8},children:Yn.jsx(Aj,{token:e.fromToken,amount:null!==(r=e.fromAmount)&&void 0!==r?r:"",showChain:!0})}),Yn.jsx("td",{children:Yn.jsx(Aj,{token:e.toToken,amount:null!==(s=e.toAmount)&&void 0!==s?s:"",showChain:!0,canAddMetamask:null!==(d=null===(l=ah.get(e.toToken.chainId))||void 0===l?void 0:l.isEVMChain)&&void 0!==d&&d})}),Yn.jsx("td",{children:Yn.jsx(Sj,{isMobile:t,statusText:h,statusColor:m,alphaColor:g,time:f})}),Yn.jsx("td",{children:Yn.jsx(Rj,{fromToken:e.fromToken,toToken:e.toToken,fromTokenPrice:e.fromTokenPrice,toTokenPrice:e.toTokenPrice})}),Yn.jsx(i,{component:"td",sx:{borderTopRightRadius:8,borderBottomRightRadius:u?0:8},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{component:"a",href:tg(e.fromToken.chainId,e.hash,"tx"),target:"_blank",rel:"noopener noreferrer",sx:{p:3,color:"primary.main",display:"flex",alignItems:"center",justifyContent:"center"},children:Yn.jsx(i,{component:li.ArrowTopRightBorder,sx:{width:18,height:18}})}),Yn.jsx(i,{sx:{height:16,width:"1px",backgroundColor:"border.main"}}),Yn.jsx(Ij,{show:u,onClick:()=>p((e=>!e))})]})})]}),Yn.jsx("tr",{children:Yn.jsx(i,{component:"td",colSpan:5,sx:{p:"0 !important",backgroundColor:"transparent !important"},children:Yn.jsx(Uj,{showFold:u,data:e})})})]})}function Vj({account:t}){const{isMobile:n}=Tg(),o=Dj({account:t,limit:n?10:5});return Yn.jsx(Tj,{isMobile:n,empty:!o.orderList.length,loading:o.isLoading,children:n?Yn.jsxs(i,{sx:{pt:12,px:16,display:"flex",flexDirection:"column",gap:8},children:[o.orderList.map((e=>Yn.jsx(qj,{data:e,isMobile:n},e.hash))),Yn.jsx(Oj,{loading:o.isFetchingNextPage,onClick:o.fetchNextPage,hasMore:o.hasNextPage,height:68})]}):Yn.jsx(Yn.Fragment,{children:Yn.jsxs(Lj,{loadMoreLoading:o.isFetchingNextPage,loadMore:o.fetchNextPage,hasMore:o.hasNextPage,children:[Yn.jsx("thead",{children:Yn.jsxs("tr",{children:[Yn.jsx("th",{children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8},children:Yn.jsx(e,{id:"4fL/V7",message:"Pay"})})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"lDgVWA",message:"Receive"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"uAQUqI",message:"Status"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"fqDzSu",message:"Rate"})}),Yn.jsx(i,{component:"th",sx:{width:140},children:Yn.jsx(e,{id:"URmyfc",message:"Details"})})]})}),Yn.jsx("tbody",{children:o.orderList.map((e=>Yn.jsx(qj,{data:e,isMobile:n},e.hash)))})]})})})}function Wj(e){var{sx:t}=e,n=qn(e,["sx"]);return Yn.jsx(O,{...n,sx:Object.assign(Object.assign({},t),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function Hj(){const e=a(),{isMobile:t}=Tg(),n=G(null),o=G(null),{crossChainSubmittedCounter:r}=xg(),s=nt(),l=G(),d=G(s),{evmAccount:c,solanaAccount:u,bitcoinAccount:p,suiAccount:h,tonAccount:m,currentAccount:g}=dg(),[f,x]=z(Fj.sameChain),[y,v]=z(),b=$((()=>[{key:Fj.sameChain,value:"Same chain Swaps"},{key:Fj.crossChain,value:"Cross Chain Swaps"},{key:Fj.errorRefunds,value:"Error Refunds"}]),[]),j=$((()=>{var e,t,n,i,o;const r=[];if(c.isConnected&&c.address){const t=null===(e=ah.entries().find((([e,t])=>t.isEVMChain)))||void 0===e?void 0:e[1];t&&r.push({account:sm(c.address),firstChain:t})}if(u.isConnected&&u.address){const e=null===(t=ah.entries().find((([e,t])=>t.isSolanaChain)))||void 0===t?void 0:t[1];e&&r.push({account:u.address,firstChain:e})}if(p.isConnected&&p.address){const e=null===(n=ah.entries().find((([e,t])=>t.isBTCChain)))||void 0===n?void 0:n[1];e&&r.push({account:p.address,firstChain:e})}if(h.isConnected&&h.address){const e=null===(i=ah.entries().find((([e,t])=>t.isSUIChain)))||void 0===i?void 0:i[1];e&&r.push({account:h.address,firstChain:e})}if(m.isConnected&&m.address){const e=null===(o=ah.entries().find((([e,t])=>t.isTONChain)))||void 0===o?void 0:o[1];e&&r.push({account:m.address,firstChain:e})}return r}),[p.address,p.isConnected,c.address,c.isConnected,u.address,u.isConnected,h.address,h.isConnected,m.address,m.isConnected]);Q((()=>{v((()=>{if(j.length>0)return j[0].account}))}),[j]);const C=Z(((e,t,i)=>{v(e),n.current&&(t?n.current.scrollTo({left:n.current.scrollWidth,behavior:"smooth"}):i&&n.current.scrollTo({left:0,behavior:"smooth"}))}),[]);return Q((()=>{const e=null==g?void 0:g.address;if(!e)return;const t=j.find((t=>t.account.toLowerCase()===e.toLowerCase()));t&&(l.current=t.account)}),[j,null==g?void 0:g.address]),Q((()=>{d.current=s}),[s]),Q((()=>{0!==r&&setTimeout((()=>{var e;null===(e=o.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"}),x(Fj.crossChain),l.current&&(v(l.current),d.current.invalidateQueries({queryKey:["graphql","getInfiniteQuery","page",Ce.graphql.cross_chain_swap_zetachain_orderList]}))}),300)}),[r]),Yn.jsxs(S,{value:f,onChange:(e,t)=>{x(t)},sx:{width:"100%",display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%",borderRadius:16,backgroundColor:"background.skeleton",backdropFilter:"blur(4px)",[e.breakpoints.up("laptop")]:{}},className:t?void 0:"gradient-card-border",children:[Yn.jsx(i,{ref:o,sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",px:16,pt:20,[e.breakpoints.up("laptop")]:{px:24}},children:Yn.jsx(D,{tabs:b,variant:"default",tabsListSx:{justifyContent:"space-between",borderBottomWidth:0},tabSx:{mr:28,typography:"body2",lineHeight:"19px",minHeight:39,padding:"0px 0px 20px 0px",[e.breakpoints.up("laptop")]:{typography:"body1",lineHeight:"22px",minHeight:42}}})}),Yn.jsx(i,{ref:n,sx:{px:16,py:12,display:"flex",alignItems:"center",gap:12,overflowX:"auto",borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",[e.breakpoints.up("laptop")]:{px:24},"&::-webkit-scrollbar":{display:"none"},msOverflowStyle:"none",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",userSelect:"none"},children:j.map(((t,n)=>{const o=y===t.account,r=n===j.length-1,a=0===n;return Yn.jsxs(i,{sx:Object.assign(Object.assign({display:"flex",alignItems:"center",gap:4,pl:8,py:8,pr:10,borderRadius:4,backgroundColor:"transparent",cursor:"pointer",typography:"body2",lineHeight:"19px",color:"text.secondary",flexShrink:0},o&&{backgroundColor:T(e.palette.success.main,.1),color:"success.main"}),{"&:hover":{backgroundColor:o?T(e.palette.success.main,.1):e.palette.background.paperDarkContrast}}),onClick:()=>C(t.account,r,a),children:[t.firstChain&&Yn.jsx(i,{component:t.firstChain.logo,sx:{width:16,height:16}}),"(",lg(t.firstChain.chainId),")",eg(t.account)]},t.account)}))}),y?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Wj,{value:Fj.sameChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsx(Vj,{account:y})}),Yn.jsx(Wj,{value:Fj.crossChain,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsx(Bj,{account:y})}),Yn.jsx(Wj,{value:Fj.errorRefunds,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsx(Bj,{account:y,type:"error_refund"})})]}):Yn.jsx(Tj,{isMobile:t,empty:!0,loading:!1})]})}!function(e){e.Running="pending",e.Success="success",e.Failed="failed",e.Warning="reset"}(Nj||(Nj={})),function(e){e.sameChain="same-chain",e.crossChain="cross-chain",e.errorRefunds="error-refunds"}(Fj||(Fj={}));const $j="widget-module-container",zj=H.forwardRef((function(e,t){var{sx:n}=e,o=qn(e,["sx"]);const{isMobile:r}=Tg();return Yn.jsx(i,{className:$j,ref:t,sx:Object.assign(Object.assign({flex:1,backgroundColor:"transparent"},r?{padding:0,height:"100%",width:"100%",overflowX:"hidden"}:{padding:0,height:"auto"}),n),...o})}));var Zj;!function(e){e.Pool="pool",e.PoolDetail="poolDetail",e.CurvePoolDetail="curvePoolDetail",e.CreatePool="createPool",e.ModifyPool="modifyPool",e.MiningList="miningList",e.MiningDetail="miningDetail",e.createPoolAMMV2="createPoolAMMV2",e.createPoolAMMV3="createPoolAMMV3"}(Zj||(Zj={}));const Gj=st(((e,t)=>({page:void 0,historyList:[],push:t=>{e((e=>{var n;const i=[...e.historyList,null!==(n=e.page)&&void 0!==n?n:{type:Zj.Pool}];return{page:t,historyList:i}}))},back:()=>{e((e=>{const t=e.historyList.length;if(!t)return"undefined"!=typeof window&&window.history&&history.back(),e;const n=[...e.historyList];return{page:n.splice(t-1,1)[0],historyList:n}}))}})));function Qj({title:e,descList:t,linkTo:n,sx:o}){const r=a();return Yn.jsxs(i,{sx:Object.assign({backgroundColor:r.palette.background.paper,backdropFilter:"blur(4px)",borderRadius:12,padding:24,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24},o),children:[Yn.jsx(i,{sx:{color:r.palette.text.primary,typography:"body1",fontWeight:500,lineHeight:"24px"},children:e}),Yn.jsx(i,{sx:{display:"flex",alignItems:"stretch",gap:24},children:t.map(((e,t)=>Yn.jsxs(i,{sx:{flex:1,padding:16,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:8,borderWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:{color:r.palette.primary.contrastText,typography:"h6",fontWeight:600,lineHeight:"20px",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:r.palette.primary.main},children:t+1}),Yn.jsx(i,{sx:{color:r.palette.text.primary,typography:"body2",fontWeight:500,lineHeight:"24px"},children:e.title})]}),Yn.jsx(i,{sx:{color:r.palette.text.secondary,typography:"h6",fontWeight:500,lineHeight:"18px"},children:e.desc})]},t)))}),Yn.jsx(i,{component:"a",href:n,target:"_blank",rel:"noopener noreferrer",sx:{px:24,py:12,borderRadius:8,backgroundColor:r.palette.background.tag,color:r.palette.text.primary,typography:"body2",fontWeight:700,lineHeight:"21px",textDecoration:"none"},children:"Read Docs"})]})}const Yj=[{value:0,label:"0%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:75,label:"75%"},{value:100,label:"100%"}];function Kj({disabled:e,value:t,onChange:n,sx:o}){return Yn.jsxs(i,{sx:Object.assign({p:20,backgroundColor:"background.cardInput",borderRadius:12},o),children:[Yn.jsx(Db,{value:String(t),onChange:e=>n(+e),readOnly:!0,readonlyShowSuffix:!0,suffix:Yn.jsx(i,{sx:{typography:"h2"},children:"%"}),sx:{mt:12,backgroundColor:"background.cardInput","& input":{pl:0,typography:"h1"}}}),Yn.jsx(i,{sx:{mt:20},children:Yn.jsx(w,{marks:Yj,step:1,disabled:e,value:t,onChange:(e,t)=>n(t)})})]})}function Xj({active:t,sx:n,onClick:o}){const r=a(),s="light"===r.palette.mode;let l=r.palette.primary.main,c="transparent";return t&&(l=r.palette.primary.contrastText,c=T(r.palette.primary.main,.8)),Yn.jsx(i,{component:d,sx:Object.assign({typography:"body2",p:t?r.spacing(8,20,9):r.spacing(7,19,8),minWidth:79,border:t?void 0:`1px solid ${l}`,color:l,backgroundColor:c,borderRadius:8,fontWeight:600,"&:hover":{color:t?r.palette.primary.contrastText:r.palette.primary.main,backgroundColor:t?r.palette.primary.main:s?"rgba(26, 26, 27, 0.04)":"rgba(241, 249, 2, 0.08)"}},n),onClick:o,children:Yn.jsx(e,{id:"R9Khdg",message:"Auto"})})}const Jj="auto",eC="0.1",tC="0.5",nC="0.5",iC=.01,oC=({address:e,type:t})=>{const[n,i]=z(Jj),o=$((()=>n===Jj?"AMMV3"===t?new Pe(nC).div(100).toNumber():"AMMV2"===t?new Pe(tC).div(100).toNumber():new Pe(eC).div(100).toNumber():n),[n,t]);return{slipper:n,setSlipper:i,slipperValue:o,resetSlipper:()=>{i(Jj)}}};function rC({type:t,disabled:n,value:o,onChange:r,sx:s}){const d=a(),c=o===Jj,[u,p]=z(c?"":new Pe(o).times(100).toNumber()),h="AMMV3"==t?nC:"AMMV2"==t?tC:eC;return Yn.jsx(l,{disabled:n,onlyClick:!0,title:Yn.jsxs(i,{sx:{backgroundColor:d.palette.background.paper,padding:d.spacing(12,20),borderRadius:8,width:318,maxWidth:"90vw",boxSizing:"border-box"},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"lqTDfd",message:"Slippage Tolerance"})}),Yn.jsxs("span",{children:[c?h:o&&new Pe(o).times(100).toNumber(),"%"]})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",margin:d.spacing(16,0,0,0)},children:[Yn.jsx(Xj,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{p(""),r(Jj)},active:c}),Yn.jsx(b,{placeholder:String(h),value:u,onChange:e=>{const{value:t}=e.target;p(t),r(t?new Pe(t).div(100).toNumber():Jj)},onBlur:()=>{(!c&&new Pe(o).gt(.1)||new Pe(o).lte(0))&&(p(10),r(.1))},suffix:Yn.jsx(i,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:Yn.jsx(_,{sx:Object.assign({width:"max-content",alignItems:"right",margin:d.spacing(0,0,0,"auto"),p:d.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast"},s),children:Yn.jsx(i,{component:li.Setting,sx:{width:18,height:18,"& path:last-child":{fill:d.palette.text.primary}}})})})}const aC=50;var sC,lC,dC;function cC(t){var n,i,o,{chainId:r,includeButton:a}=t,s=qn(t,["chainId","includeButton"]);const{chainId:l,getAppKitAccountByChainId:d,open:u}=dg(),[p,h]=H.useState(!1),m=Cj(r),g=void 0!==l&&void 0!==r&&l!==r,f=d(r);return!(null==f?void 0:f.appKitAccount.address)||p||void 0===l||r&&r!==l?Yn.jsx(Yn.Fragment,{children:Yn.jsx(c,{...s,isLoading:p,onClick:()=>Vn(this,void 0,void 0,(function*(){if(g)return m?(h(!0),yield m(),void h(!1)):void 0;h(!0),u({namespace:null==f?void 0:f.namespace}),h(!1)})),children:p?Yn.jsx(e,{id:"J28zul",message:"Connecting..."}):g&&r?se._({id:"1+P9RR",message:"Switch to {0}",values:{0:null!==(o=null===(i=ah.get(r))||void 0===i?void 0:i.name)&&void 0!==o?o:"unknown"}}):Yn.jsx(e,{id:"r7ScnQ",message:"Connect to a wallet"})})}):a?Yn.jsx(Yn.Fragment,{children:null!==(n=s.children)&&void 0!==n?n:null}):Yn.jsx(c,{...s})}!function(e){e[e.quantity=1]="quantity",e[e.percentage=2]="percentage"}(sC||(sC={})),function(e){e.CURRENCY_A="CURRENCY_A",e.CURRENCY_B="CURRENCY_B"}(lC||(lC={})),function(e){e.LOWER="LOWER",e.UPPER="UPPER"}(dC||(dC={}));const uC={xs:"4px",sm:"8px",md:"12px",lg:"24px",xl:"32px"},pC=({children:e,sx:t})=>(a(),Yn.jsx(i,{sx:Object.assign({display:"flex",flexDirection:"column",gap:20,px:20,py:20,borderRadius:12},t),children:e})),hC=({children:e,sx:t})=>{const n=a();return Yn.jsx(pC,{sx:Object.assign(Object.assign({},t),{backgroundColor:n.palette.background.paperContrast}),children:e})},mC=({children:e})=>{const t=a();return Yn.jsxs(i,{sx:{p:8,borderRadius:8,backgroundColor:T(t.palette.warning.main,.1),display:"flex",alignItems:"center",gap:8},children:[Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.75 16.125L9 1.875L17.25 16.125H0.75ZM14.6475 14.625L8.99998 4.86749L3.35247 14.625H14.6475ZM9.75004 12.375H8.25003V13.875H9.75004V12.375ZM8.25003 7.875H9.75004V10.875H8.25003V7.875Z",fill:t.palette.warning.main})}),Yn.jsx(i,{sx:{typography:"h6",color:t.palette.warning.main,textAlign:"left"},children:e})]})};function gC({gap:e,flex:t,children:n,style:o}){return Yn.jsx(i,{sx:Object.assign(Object.assign(Object.assign({display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:e&&uC[e]||e},t&&{flex:t}),{width:"100%",alignItems:"center"}),o),children:n})}function fC({gap:e,justify:t,grow:n,children:o,style:r}){return Yn.jsx(i,{sx:Object.assign({display:"grid",gridAutoRows:"auto",gridRowGap:e&&uC[e]||e,justifyItems:t,flexGrow:n&&1},r),children:o})}function xC({gap:e,children:t,sx:n}){return Yn.jsx(i,{sx:Object.assign({width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"flex-start",gap:e&&uC[e]||e},n),children:t})}function yC({children:e,style:t}){return Yn.jsx(xC,{sx:Object.assign({justifyContent:"space-between"},t),children:e})}function vC({gap:e,justify:t,children:n,sx:i}){return Yn.jsx(xC,{sx:Object.assign({position:"relative",width:"fit-content",margin:`-${e}`},i),children:n})}function bC({children:e,disabled:t,sx:n}){return Yn.jsx(xC,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:"stretch",gap:12,opacity:t?.2:1,pointerEvents:t?"none":"auto"},n),children:e})}const jC=({chainId:t,approvalA:n,approvalB:o,parsedAmounts:r,isValid:a,depositADisabled:s,depositBDisabled:l,errorMessage:d,setShowConfirm:u})=>{var p,h;const m=n.needApprove&&!!r[lC.CURRENCY_A]||n.isApproving,g=o.needApprove&&!!r[lC.CURRENCY_B]||o.isApproving;return Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:t,children:Yn.jsxs(fC,{gap:"md",style:{width:"100%"},children:[(m||g)&&a&&Yn.jsxs(i,{sx:{width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"space-between",gap:8},children:[m&&Yn.jsx(c,{size:c.Size.big,isLoading:n.isApproving,onClick:n.submitApprove,disabled:n.insufficientBalance,width:g?"50%":"100%",children:n.isApproving?Yn.jsx(e,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(p=n.token)||void 0===p?void 0:p.symbol}}):n.approveTitle}),g&&Yn.jsx(c,{size:c.Size.big,isLoading:o.isApproving,onClick:o.submitApprove,disabled:o.insufficientBalance,width:m?"50%":"100%",children:o.isApproving?Yn.jsx(e,{id:"DTFrUE",message:"Approving {0}...",values:{0:null===(h=o.token)||void 0===h?void 0:h.symbol}}):o.approveTitle})]}),Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:()=>{u(!0)},disabled:!a||n.needApprove&&!s||o.needApprove&&!l,danger:!a&&!!r[lC.CURRENCY_A]&&!!r[lC.CURRENCY_B],children:d||se._({id:"rdUucN",message:"Preview"})})]})})},CC=({chainId:e,disabled:t,isLoading:n,onConfirm:i})=>Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:e,children:Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:i,disabled:t,isLoading:n,children:se._({id:"h5pjuM",message:"Collect fees"})})});function wC(e){const t=G();return Q((()=>{t.current=e})),t.current}const kC=[.25,.5,.75,1];function TC({currentValue:e,onClick:t,sx:n}){const o=a(),r="light"===o.palette.mode,{isMobile:s}=Tg(),[l,c]=z(null),u=G(0);Q((()=>{e?(u.current+=1,u.current>=2&&(c(null),u.current=0)):c(null)}),[e]);const p=wC(e);return Q((()=>{p===e&&1===l&&(u.current=1)}),[e,p,l]),Yn.jsx(i,{sx:Object.assign({display:"grid",gap:s?10:14,gridTemplateColumns:`repeat(${kC.length}, 1fr)`},n),children:kC.map((e=>{const n=e===l;return Yn.jsxs(d,{sx:{typography:"h6",borderRadius:4,padding:o.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:hover":{color:o.palette.text.primary,backgroundColor:T(o.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?o.palette.primary.main:T(o.palette.text.primary,.4)}},onClick:()=>{n||(u.current=0,c(e),t(e))},className:n?"selected":void 0,children:[100*e,"%"]},e)}))})}const IC=({value:t,onUserInput:n,maxAmount:o,balance:r,currency:s,locked:l})=>{var c,u;const p=a(),h=Z((e=>{if(!o||!s)return;const t=o.toExact().multipliedBy(e).dp(s.decimals).toString();n(t)}),[s,o,n]),m=$((()=>r?Am({input:r.toExact(),decimals:null==s?void 0:s.decimals}):"-"),[null==s?void 0:s.decimals,r]);return Yn.jsxs(i,{sx:{pt:20,pb:20,px:20,borderRadius:16,backgroundColor:p.palette.background.cardInput},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,color:p.palette.text.primary,typography:"h5"},children:[(null==s?void 0:s.address)&&Yn.jsx(Df,{address:null!==(c=null==s?void 0:s.address)&&void 0!==c?c:"",chainId:null==s?void 0:s.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:(null==s?void 0:s.address)?Yn.jsx(i,{children:null!==(u=null==s?void 0:s.symbol)&&void 0!==u?u:"-"}):Yn.jsx(e,{id:"sIPJGT",message:"SELECT TOKEN"})})]}),Yn.jsxs(i,{component:d,sx:{color:p.palette.text.secondary,"&:hover":{color:p.palette.text.primary},cursor:"pointer",display:"flex",flexWrap:"wrap",justifyContent:"flex-end",typography:"body2"},onClick:()=>{h(1)},children:[Yn.jsxs(i,{sx:{wordBreak:"keep-all"},children:[se._({id:"fsBGk0",message:"Balance"}),": "]}),Yn.jsx(i,{sx:{wordBreak:"break-all",textAlign:"right",display:"flex",alignItems:"center"},children:m})]})]}),Yn.jsx(Db,{sx:{mt:4,backgroundColor:p.palette.background.cardInput},suffix:void 0,value:t,onChange:n,readOnly:l,withClear:!l}),l?null:Yn.jsx(TC,{sx:{mt:20,mb:0},onClick:h,currentValue:t})]})},SC={},EC={};var AC,OC;Object.values(le).filter((e=>"number"==typeof e)).map((e=>{const t=pt(e),n=ht(e);t&&(SC[e]=t),n&&(EC[e]=n)})),le.MAINNET,le.ARBITRUM_ONE,le.SEPOLIA,le.TAIKO,function(e){e[e.EXACT_INPUT=0]="EXACT_INPUT",e[e.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(AC||(AC={})),function(e){e[e.ROUND_DOWN=0]="ROUND_DOWN",e[e.ROUND_HALF_UP=1]="ROUND_HALF_UP",e[e.ROUND_UP=2]="ROUND_UP"}(OC||(OC={}));const LC=wn.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),RC={[OC.ROUND_DOWN]:Pe.ROUND_DOWN,[OC.ROUND_HALF_UP]:Pe.ROUND_HALF_UP,[OC.ROUND_UP]:Pe.ROUND_UP},PC={[OC.ROUND_DOWN]:Pe.ROUND_DOWN,[OC.ROUND_HALF_UP]:Pe.ROUND_HALF_UP,[OC.ROUND_UP]:Pe.ROUND_UP};class _C{constructor(e,t=wn.BigInt(1)){this.numerator=wn.BigInt(e),this.denominator=wn.BigInt(t)}static tryParseFraction(e){if(e instanceof wn||"number"==typeof e||"string"==typeof e)return new _C(e);if("numerator"in e&&"denominator"in e)return e;throw new Error("Could not parse fraction")}get quotient(){return wn.divide(this.numerator,this.denominator)}get remainder(){return new _C(wn.remainder(this.numerator,this.denominator),this.denominator)}invert(){return new _C(this.denominator,this.numerator)}add(e){const t=_C.tryParseFraction(e);return wn.equal(this.denominator,t.denominator)?new _C(wn.add(this.numerator,t.numerator),this.denominator):new _C(wn.add(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator)),wn.multiply(this.denominator,t.denominator))}subtract(e){const t=_C.tryParseFraction(e);return wn.equal(this.denominator,t.denominator)?new _C(wn.subtract(this.numerator,t.numerator),this.denominator):new _C(wn.subtract(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator)),wn.multiply(this.denominator,t.denominator))}lessThan(e){const t=_C.tryParseFraction(e);return wn.lessThan(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator))}equalTo(e){const t=_C.tryParseFraction(e);return wn.equal(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator))}greaterThan(e){const t=_C.tryParseFraction(e);return wn.greaterThan(wn.multiply(this.numerator,t.denominator),wn.multiply(t.numerator,this.denominator))}multiply(e){const t=_C.tryParseFraction(e);return new _C(wn.multiply(this.numerator,t.numerator),wn.multiply(this.denominator,t.denominator))}divide(e){const t=_C.tryParseFraction(e);return new _C(wn.multiply(this.numerator,t.denominator),wn.multiply(this.denominator,t.numerator))}toSignificant(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=OC.ROUND_HALF_UP){kn(Number.isInteger(e),`${e} is not an integer.`),kn(e>0,`${e} is not positive.`);const i=RC[n],o=new Pe(this.numerator.toString()).div(this.denominator.toString()).precision(e,i);return o.toFormat(o.decimalPlaces(),i,t)}toFixed(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=OC.ROUND_HALF_UP){kn(Number.isInteger(e),`${e} is not an integer.`),kn(e>=0,`${e} is negative.`);const i=PC[n];return new Pe(this.numerator.toString()).decimalPlaces(e,i).div(this.denominator.toString()).toFormat(e,i,t)}get asFraction(){return new _C(this.numerator,this.denominator)}}class MC extends _C{static fromRawAmount(e,t){return new MC(e,t)}static fromFractionalAmount(e,t,n){return new MC(e,t,n)}constructor(e,t,n){super(t,n),kn(wn.lessThanOrEqual(this.quotient,LC),"AMOUNT"),this.currency=e,this.decimalScale=wn.exponentiate(wn.BigInt(10),wn.BigInt(e.decimals))}add(e){kn(this.currency.equals(e.currency),"CURRENCY");const t=super.add(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}subtract(e){kn(this.currency.equals(e.currency),"CURRENCY");const t=super.subtract(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}multiply(e){const t=super.multiply(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}divide(e){const t=super.divide(e);return MC.fromFractionalAmount(this.currency,t.numerator,t.denominator)}toSignificant(e=6,t,n=OC.ROUND_DOWN){return super.divide(this.decimalScale).toSignificant(e,t,n)}toFixed(e=this.currency.decimals,t,n=OC.ROUND_DOWN){return kn(e<=this.currency.decimals,"DECIMALS"),super.divide(this.decimalScale).toFixed(e,t,n)}toExact(){return new Pe(this.quotient.toString()).div(this.decimalScale.toString())}get wrapped(){return this.currency.isToken?this:MC.fromFractionalAmount(this.currency.wrapped,this.numerator,this.denominator)}}const BC=new _C(wn.BigInt(100));function DC(e){return new NC(e.numerator,e.denominator)}class NC extends _C{constructor(){super(...arguments),this.isPercent=!0}add(e){return DC(super.add(e))}subtract(e){return DC(super.subtract(e))}multiply(e){return DC(super.multiply(e))}divide(e){return DC(super.divide(e))}toSignificant(e=5,t,n){return super.multiply(BC).toSignificant(e,t,n)}toFixed(e=2,t,n){return super.multiply(BC).toFixed(e,t,n)}}class FC extends _C{constructor(...e){let t,n,i,o;if(4===e.length)[t,n,i,o]=e;else{const r=e[0].quoteAmount.divide(e[0].baseAmount);[t,n,i,o]=[e[0].baseAmount.currency,e[0].quoteAmount.currency,r.denominator,r.numerator]}super(o,i),this.baseCurrency=t,this.quoteCurrency=n,this.scalar=new _C(wn.exponentiate(wn.BigInt(10),wn.BigInt(t.decimals)),wn.exponentiate(wn.BigInt(10),wn.BigInt(n.decimals)))}invert(){return new FC(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)}multiply(e){kn(this.quoteCurrency.equals(e.baseCurrency),"TOKEN");const t=super.multiply(e);return new FC(this.baseCurrency,e.quoteCurrency,t.denominator,t.numerator)}quote(e){kn(e.currency.equals(this.baseCurrency),"TOKEN");const t=super.multiply(e);return MC.fromFractionalAmount(this.quoteCurrency,t.numerator,t.denominator)}get adjustedForDecimals(){return super.multiply(this.scalar)}toSignificant(e=6,t,n){return this.adjustedForDecimals.toSignificant(e,t,n)}toFixed(e=4,t,n){return this.adjustedForDecimals.toFixed(e,t,n)}}class UC{constructor(e,t,n,i){kn(Number.isSafeInteger(e),"CHAIN_ID"),kn(t>=0&&t<255&&Number.isInteger(t),"DECIMALS"),this.chainId=e,this.decimals=t,this.symbol=n,this.name=i}}function qC(e){try{return sm(e)}catch(t){throw new Error(`${e} is not a valid address.`)}}const VC=/^0x[0-9a-fA-F]{40}$/;class WC extends UC{constructor(e,t,n,i,o,r,a,s){super(e,n,i,o),this.isNative=!1,this.isToken=!0,this.address=r?function(e){if(VC.test(e))return e;throw new Error(`${e} is not a valid address.`)}(t):qC(t),a&&kn(a.gte($t.from(0)),"NON-NEGATIVE FOT FEES"),s&&kn(s.gte($t.from(0)),"NON-NEGATIVE FOT FEES"),this.buyFeeBps=a,this.sellFeeBps=s}equals(e){return e.isToken&&this.chainId===e.chainId&&this.address.toLowerCase()===e.address.toLowerCase()}sortsBefore(e){return kn(this.chainId===e.chainId,"CHAIN_IDS"),kn(this.address.toLowerCase()!==e.address.toLowerCase(),"ADDRESSES"),this.address.toLowerCase()<e.address.toLowerCase()}get wrapped(){return this}}const HC=wn.BigInt(Number.MAX_SAFE_INTEGER),$C=wn.BigInt(0),zC=wn.BigInt(1),ZC=wn.BigInt(2);const GC=wn.BigInt(0),QC=1e4;new NC(wn.BigInt(1),QC),new NC(1,100),new NC(3,100),new NC(5,100),new NC(10,100),new NC(15,100);const YC=new NC(0);new NC(1);const KC="0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";var XC;!function(e){e[e.LOWEST=100]="LOWEST",e[e.LOW_200=200]="LOW_200",e[e.LOW_300=300]="LOW_300",e[e.LOW_400=400]="LOW_400",e[e.LOW=500]="LOW",e[e.MEDIUM=3e3]="MEDIUM",e[e.HIGH=1e4]="HIGH"}(XC||(XC={}));const JC={[XC.LOWEST]:1,[XC.LOW_200]:4,[XC.LOW_300]:6,[XC.LOW_400]:8,[XC.LOW]:10,[XC.MEDIUM]:60,[XC.HIGH]:200},ew=wn.BigInt(-1),tw=wn.BigInt(0),nw=wn.BigInt(1),iw=wn.exponentiate(wn.BigInt(2),wn.BigInt(96)),ow=wn.exponentiate(iw,wn.BigInt(2)),rw=new Nh("properties/5.8.0");function aw(e,t,n){Object.defineProperty(e,t,{enumerable:!0,value:n,writable:!1})}function sw(e,t){for(let n=0;n<32;n++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null}const lw={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function dw(e){if(null==e||lw[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const t=Object.keys(e);for(let n=0;n<t.length;n++){let i=null;try{i=e[t[n]]}catch(e){continue}if(!dw(i))return!1}return!0}return rw.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function cw(e){if(dw(e))return e;if(Array.isArray(e))return Object.freeze(e.map((e=>uw(e))));if("object"==typeof e){const t={};for(const n in e){const i=e[n];void 0!==i&&aw(t,n,uw(i))}return t}return rw.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}function uw(e){return cw(e)}class pw{constructor(e){for(const t in e)this[t]=uw(e[t])}}const hw="abi/5.8.0",mw=new Nh(hw),gw={};let fw={calldata:!0,memory:!0,storage:!0},xw={calldata:!0,memory:!0};function yw(e,t){if("bytes"===e||"string"===e){if(fw[t])return!0}else if("address"===e){if("payable"===t)return!0}else if((e.indexOf("[")>=0||"tuple"===e)&&xw[t])return!0;return(fw[t]||"payable"===t)&&mw.throwArgumentError("invalid modifier","name",t),!1}function vw(e,t){for(let n in t)aw(e,n,t[n])}const bw=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),jw=new RegExp(/^(.*)\[([0-9]*)\]$/);class Cw{constructor(e,t){e!==gw&&mw.throwError("use fromString",Nh.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),vw(this,t);let n=this.type.match(jw);vw(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:Cw.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json){let t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map((t=>JSON.parse(t.format(e))))),JSON.stringify(t)}let t="";return"array"===this.baseType?(t+=this.arrayChildren.format(e),t+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==bw.sighash&&(t+=this.type),t+="("+this.components.map((t=>t.format(e))).join(e===bw.full?", ":",")+")"):t+=this.type,e!==bw.sighash&&(!0===this.indexed&&(t+=" indexed"),e===bw.full&&this.name&&(t+=" "+this.name)),t}static from(e,t){return"string"==typeof e?Cw.fromString(e,t):Cw.fromObject(e)}static fromObject(e){return Cw.isParamType(e)?e:new Cw(gw,{name:e.name||null,type:Pw(e.type),indexed:null==e.indexed?null:!!e.indexed,components:e.components?e.components.map(Cw.fromObject):null})}static fromString(e,t){return n=function(e,t){let n=e;function i(t){mw.throwArgumentError(`unexpected character at position ${t}`,"param",e)}function o(e){let n={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(n.indexed=!1),n}e=e.replace(/\s/g," ");let r={type:"",name:"",state:{allowType:!0}},a=r;for(let n=0;n<e.length;n++){let r=e[n];switch(r){case"(":a.state.allowType&&""===a.type?a.type="tuple":a.state.allowParams||i(n),a.state.allowType=!1,a.type=Pw(a.type),a.components=[o(a)],a=a.components[0];break;case")":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),yw(a.type,a.name)&&(a.name=""),a.type=Pw(a.type);let e=a;a=a.parent,a||i(n),delete e.parent,a.state.allowParams=!1,a.state.allowName=!0,a.state.allowArray=!0;break;case",":delete a.state,"indexed"===a.name&&(t||i(n),a.indexed=!0,a.name=""),yw(a.type,a.name)&&(a.name=""),a.type=Pw(a.type);let s=o(a.parent);a.parent.components.push(s),delete a.parent,a=s;break;case" ":a.state.allowType&&""!==a.type&&(a.type=Pw(a.type),delete a.state.allowType,a.state.allowName=!0,a.state.allowParams=!0),a.state.allowName&&""!==a.name&&("indexed"===a.name?(t||i(n),a.indexed&&i(n),a.indexed=!0,a.name=""):yw(a.type,a.name)?a.name="":a.state.allowName=!1);break;case"[":a.state.allowArray||i(n),a.type+=r,a.state.allowArray=!1,a.state.allowName=!1,a.state.readArray=!0;break;case"]":a.state.readArray||i(n),a.type+=r,a.state.readArray=!1,a.state.allowArray=!0,a.state.allowName=!0;break;default:a.state.allowType?(a.type+=r,a.state.allowParams=!0,a.state.allowArray=!0):a.state.allowName?(a.name+=r,delete a.state.allowArray):a.state.readArray?a.type+=r:i(n)}}return a.parent&&mw.throwArgumentError("unexpected eof","param",e),delete r.state,"indexed"===a.name?(t||i(n.length-7),a.indexed&&i(n.length-7),a.indexed=!0,a.name=""):yw(a.type,a.name)&&(a.name=""),r.type=Pw(r.type),r}(e,!!t),Cw.fromObject({name:n.name,type:n.type,indexed:n.indexed,components:n.components});var n}static isParamType(e){return!(null==e||!e._isParamType)}}function ww(e,t){return function(e){e=e.trim();let t=[],n="",i=0;for(let o=0;o<e.length;o++){let r=e[o];","===r&&0===i?(t.push(n),n=""):(n+=r,"("===r?i++:")"===r&&(i--,-1===i&&mw.throwArgumentError("unbalanced parenthesis","value",e)))}n&&t.push(n);return t}(e).map((e=>Cw.fromString(e,t)))}class kw{constructor(e,t){e!==gw&&mw.throwError("use a static from method",Nh.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),vw(this,t),this._isFragment=!0,Object.freeze(this)}static from(e){return kw.isFragment(e)?e:"string"==typeof e?kw.fromString(e):kw.fromObject(e)}static fromObject(e){if(kw.isFragment(e))return e;switch(e.type){case"function":return Ow.fromObject(e);case"event":return Tw.fromObject(e);case"constructor":return Aw.fromObject(e);case"error":return Rw.fromObject(e);case"fallback":case"receive":return null}return mw.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return"event"===(e=(e=(e=e.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0]?Tw.fromString(e.substring(5).trim()):"function"===e.split(" ")[0]?Ow.fromString(e.substring(8).trim()):"constructor"===e.split("(")[0].trim()?Aw.fromString(e.trim()):"error"===e.split(" ")[0]?Rw.fromString(e.substring(5).trim()):mw.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return!(!e||!e._isFragment)}}class Tw extends kw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==bw.sighash&&(t+="event "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ",e!==bw.sighash&&this.anonymous&&(t+="anonymous "),t.trim()}static from(e){return"string"==typeof e?Tw.fromString(e):Tw.fromObject(e)}static fromObject(e){if(Tw.isEventFragment(e))return e;"event"!==e.type&&mw.throwArgumentError("invalid event object","value",e);const t={name:Mw(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(Cw.fromObject):[],type:"event"};return new Tw(gw,t)}static fromString(e){let t=e.match(Bw);t||mw.throwArgumentError("invalid event string","value",e);let n=!1;return t[3].split(" ").forEach((e=>{switch(e.trim()){case"anonymous":n=!0;break;case"":break;default:mw.warn("unknown modifier: "+e)}})),Tw.fromObject({name:t[1].trim(),anonymous:n,inputs:ww(t[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&"event"===e.type}}function Iw(e,t){t.gas=null;let n=e.split("@");return 1!==n.length?(n.length>2&&mw.throwArgumentError("invalid human-readable ABI signature","value",e),n[1].match(/^[0-9]+$/)||mw.throwArgumentError("invalid human-readable ABI signature gas","value",e),t.gas=$t.from(n[1]),n[0]):e}function Sw(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach((e=>{switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"nonpayable":t.payable=!1,t.stateMutability="nonpayable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}}))}function Ew(e){let t={constant:!1,payable:!0,stateMutability:"payable"};return null!=e.stateMutability?(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant&&mw.throwArgumentError("cannot have constant function with mutability "+t.stateMutability,"value",e),t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable&&mw.throwArgumentError("cannot have payable function with mutability "+t.stateMutability,"value",e)):null!=e.payable?(t.payable=!!e.payable,null!=e.constant||t.payable||"constructor"===e.type||mw.throwArgumentError("unable to determine stateMutability","value",e),t.constant=!!e.constant,t.constant?t.stateMutability="view":t.stateMutability=t.payable?"payable":"nonpayable",t.payable&&t.constant&&mw.throwArgumentError("cannot have constant payable function","value",e)):null!=e.constant?(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable"):"constructor"!==e.type&&mw.throwArgumentError("unable to determine stateMutability","value",e),t}class Aw extends kw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});e===bw.sighash&&mw.throwError("cannot format a constructor for sighash",Nh.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let t="constructor("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()}static from(e){return"string"==typeof e?Aw.fromString(e):Aw.fromObject(e)}static fromObject(e){if(Aw.isConstructorFragment(e))return e;"constructor"!==e.type&&mw.throwArgumentError("invalid constructor object","value",e);let t=Ew(e);t.constant&&mw.throwArgumentError("constructor cannot be constant","value",e);const n={name:null,type:e.type,inputs:e.inputs?e.inputs.map(Cw.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?$t.from(e.gas):null};return new Aw(gw,n)}static fromString(e){let t={type:"constructor"},n=(e=Iw(e,t)).match(Bw);return n&&"constructor"===n[1].trim()||mw.throwArgumentError("invalid constructor string","value",e),t.inputs=ww(n[2].trim(),!1),Sw(n[3].trim(),t),Aw.fromObject(t)}static isConstructorFragment(e){return e&&e._isFragment&&"constructor"===e.type}}class Ow extends Aw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map((t=>JSON.parse(t.format(e)))),outputs:this.outputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==bw.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ",e!==bw.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map((t=>t.format(e))).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()}static from(e){return"string"==typeof e?Ow.fromString(e):Ow.fromObject(e)}static fromObject(e){if(Ow.isFunctionFragment(e))return e;"function"!==e.type&&mw.throwArgumentError("invalid function object","value",e);let t=Ew(e);const n={type:e.type,name:Mw(e.name),constant:t.constant,inputs:e.inputs?e.inputs.map(Cw.fromObject):[],outputs:e.outputs?e.outputs.map(Cw.fromObject):[],payable:t.payable,stateMutability:t.stateMutability,gas:e.gas?$t.from(e.gas):null};return new Ow(gw,n)}static fromString(e){let t={type:"function"},n=(e=Iw(e,t)).split(" returns ");n.length>2&&mw.throwArgumentError("invalid function string","value",e);let i=n[0].match(Bw);if(i||mw.throwArgumentError("invalid function signature","value",e),t.name=i[1].trim(),t.name&&Mw(t.name),t.inputs=ww(i[2],!1),Sw(i[3].trim(),t),n.length>1){let i=n[1].match(Bw);""==i[1].trim()&&""==i[3].trim()||mw.throwArgumentError("unexpected tokens","value",e),t.outputs=ww(i[2],!1)}else t.outputs=[];return Ow.fromObject(t)}static isFunctionFragment(e){return e&&e._isFragment&&"function"===e.type}}function Lw(e){const t=e.format();return"Error(string)"!==t&&"Panic(uint256)"!==t||mw.throwArgumentError(`cannot specify user defined ${t} error`,"fragment",e),e}class Rw extends kw{format(e){if(e||(e=bw.sighash),bw[e]||mw.throwArgumentError("invalid format type","format",e),e===bw.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((t=>JSON.parse(t.format(e))))});let t="";return e!==bw.sighash&&(t+="error "),t+=this.name+"("+this.inputs.map((t=>t.format(e))).join(e===bw.full?", ":",")+") ",t.trim()}static from(e){return"string"==typeof e?Rw.fromString(e):Rw.fromObject(e)}static fromObject(e){if(Rw.isErrorFragment(e))return e;"error"!==e.type&&mw.throwArgumentError("invalid error object","value",e);const t={type:e.type,name:Mw(e.name),inputs:e.inputs?e.inputs.map(Cw.fromObject):[]};return Lw(new Rw(gw,t))}static fromString(e){let t={type:"error"},n=e.match(Bw);return n||mw.throwArgumentError("invalid error signature","value",e),t.name=n[1].trim(),t.name&&Mw(t.name),t.inputs=ww(n[2],!1),Lw(Rw.fromObject(t))}static isErrorFragment(e){return e&&e._isFragment&&"error"===e.type}}function Pw(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}const _w=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function Mw(e){return e&&e.match(_w)||mw.throwArgumentError(`invalid identifier "${e}"`,"value",e),e}const Bw=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Dw=new Nh(hw);class Nw{constructor(e,t,n,i){this.name=e,this.type=t,this.localName=n,this.dynamic=i}_throwError(e,t){Dw.throwArgumentError(e,this.localName,t)}}class Fw{constructor(e){aw(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e)}get data(){return function(e){let t="0x";return e.forEach((e=>{t+=Qh(e).substring(2)})),t}(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData($h(e._data))}writeBytes(e){let t=Hh(e);const n=t.length%this.wordSize;return n&&(t=$h([t,this._padding.slice(n)])),this._writeData(t)}_getValue(e){let t=Hh($t.from(e));return t.length>this.wordSize&&Dw.throwError("value out-of-bounds",Nh.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=$h([this._padding.slice(t.length%this.wordSize),t])),t}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){const e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,t=>{this._data[e]=this._getValue(t)}}}class Uw{constructor(e,t,n,i){aw(this,"_data",Hh(e)),aw(this,"wordSize",t||32),aw(this,"_coerceFunc",n),aw(this,"allowLoose",i),this._offset=0}get data(){return Qh(this._data)}get consumed(){return this._offset}static coerce(e,t){let n=e.match("^u?int([0-9]+)$");return n&&parseInt(n[1])<=48&&(t=t.toNumber()),t}coerce(e,t){return this._coerceFunc?this._coerceFunc(e,t):Uw.coerce(e,t)}_peekBytes(e,t,n){let i=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+i>this._data.length&&(this.allowLoose&&n&&this._offset+t<=this._data.length?i=t:Dw.throwError("data out-of-bounds",Nh.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+i})),this._data.slice(this._offset,this._offset+i)}subReader(e){return new Uw(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,t){let n=this._peekBytes(0,e,!!t);return this._offset+=n.length,n.slice(0,e)}readValue(){return $t.from(this.readBytes(this.wordSize))}}class qw extends Nw{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){try{t=sm(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)}decode(e){return sm(Xh(e.readValue().toHexString(),20))}}class Vw extends Nw{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,t){return this.coder.encode(e,t)}decode(e){return this.coder.decode(e)}}const Ww=new Nh(hw);function Hw(e,t,n){let i=null;if(Array.isArray(n))i=n;else if(n&&"object"==typeof n){let e={};i=t.map((t=>{const i=t.localName;return i||Ww.throwError("cannot encode object for signature with missing names",Nh.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]&&Ww.throwError("cannot encode object for signature with duplicate names",Nh.errors.INVALID_ARGUMENT,{argument:"values",coder:t,value:n}),e[i]=!0,n[i]}))}else Ww.throwArgumentError("invalid tuple value","tuple",n);t.length!==i.length&&Ww.throwArgumentError("types/value length mismatch","tuple",n);let o=new Fw(e.wordSize),r=new Fw(e.wordSize),a=[];t.forEach(((e,t)=>{let n=i[t];if(e.dynamic){let t=r.length;e.encode(r,n);let i=o.writeUpdatableValue();a.push((e=>{i(e+t)}))}else e.encode(o,n)})),a.forEach((e=>{e(o.length)}));let s=e.appendWriter(o);return s+=e.appendWriter(r),s}function $w(e,t){let n=[],i=e.subReader(0);t.forEach((t=>{let o=null;if(t.dynamic){let n=e.readValue(),r=i.subReader(n.toNumber());try{o=t.decode(r)}catch(e){if(e.code===Nh.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}}else try{o=t.decode(e)}catch(e){if(e.code===Nh.errors.BUFFER_OVERRUN)throw e;o=e,o.baseType=t.name,o.name=t.localName,o.type=t.type}null!=o&&n.push(o)}));const o=t.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});t.forEach(((e,t)=>{let i=e.localName;if(!i||1!==o[i])return;if("length"===i&&(i="_length"),null!=n[i])return;const r=n[t];r instanceof Error?Object.defineProperty(n,i,{enumerable:!0,get:()=>{throw r}}):n[i]=r}));for(let e=0;e<n.length;e++){const t=n[e];t instanceof Error&&Object.defineProperty(n,e,{enumerable:!0,get:()=>{throw t}})}return Object.freeze(n)}class zw extends Nw{constructor(e,t,n){super("array",e.type+"["+(t>=0?t:"")+"]",n,-1===t||e.dynamic),this.coder=e,this.length=t}defaultValue(){const e=this.coder.defaultValue(),t=[];for(let n=0;n<this.length;n++)t.push(e);return t}encode(e,t){Array.isArray(t)||this._throwError("expected array value",t);let n=this.length;-1===n&&(n=t.length,e.writeValue(t.length)),Ww.checkArgumentCount(t.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let e=0;e<t.length;e++)i.push(this.coder);return Hw(e,i,t)}decode(e){let t=this.length;-1===t&&(t=e.readValue().toNumber(),32*t>e._data.length&&Ww.throwError("insufficient data length",Nh.errors.BUFFER_OVERRUN,{length:e._data.length,count:t}));let n=[];for(let e=0;e<t;e++)n.push(new Vw(this.coder));return e.coerce(this.name,$w(e,n))}}class Zw extends Nw{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){return e.writeValue(t?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}}class Gw extends Nw{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Hh(t);let n=e.writeValue(t.length);return n+=e.writeBytes(t),n}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}}class Qw extends Gw{constructor(e){super("bytes",e)}decode(e){return e.coerce(this.name,Qh(super.decode(e)))}}class Yw extends Nw{constructor(e,t){let n="bytes"+String(e);super(n,n,t,!1),this.size=e}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(e,t){let n=Hh(t);return n.length!==this.size&&this._throwError("incorrect data length",t),e.writeBytes(n)}decode(e){return e.coerce(this.name,Qh(e.readBytes(this.size)))}}class Kw extends Nw{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return null!=t&&this._throwError("not null",t),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}}class Xw extends Nw{constructor(e,t,n){const i=(t?"int":"uint")+8*e;super(i,i,n,!1),this.size=e,this.signed=t}defaultValue(){return 0}encode(e,t){let n=$t.from(t),i=pm.mask(8*e.wordSize);if(this.signed){let e=i.mask(8*this.size-1);(n.gt(e)||n.lt(e.add(um).mul(dm)))&&this._throwError("value out-of-bounds",t)}else(n.lt(cm)||n.gt(i.mask(8*this.size)))&&this._throwError("value out-of-bounds",t);return n=n.toTwos(8*this.size).mask(8*this.size),this.signed&&(n=n.fromTwos(8*this.size).toTwos(8*e.wordSize)),e.writeValue(n)}decode(e){let t=e.readValue().mask(8*this.size);return this.signed&&(t=t.fromTwos(8*this.size)),e.coerce(this.name,t)}}class Jw extends Gw{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,ym(t))}decode(e){return vm(super.decode(e))}}class ek extends Nw{constructor(e,t){let n=!1;const i=[];e.forEach((e=>{e.dynamic&&(n=!0),i.push(e.type)}));super("tuple","tuple("+i.join(",")+")",t,n),this.coders=e}defaultValue(){const e=[];this.coders.forEach((t=>{e.push(t.defaultValue())}));const t=this.coders.reduce(((e,t)=>{const n=t.localName;return n&&(e[n]||(e[n]=0),e[n]++),e}),{});return this.coders.forEach(((n,i)=>{let o=n.localName;o&&1===t[o]&&("length"===o&&(o="_length"),null==e[o]&&(e[o]=e[i]))})),Object.freeze(e)}encode(e,t){return Hw(e,this.coders,t)}decode(e){return e.coerce(this.name,$w(e,this.coders))}}const tk=new Nh(hw),nk=new RegExp(/^bytes([0-9]*)$/),ik=new RegExp(/^(u?int)([0-9]*)$/);const ok=new class{constructor(e){aw(this,"coerceFunc",e||null)}_getCoder(e){switch(e.baseType){case"address":return new qw(e.name);case"bool":return new Zw(e.name);case"string":return new Jw(e.name);case"bytes":return new Qw(e.name);case"array":return new zw(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new ek((e.components||[]).map((e=>this._getCoder(e))),e.name);case"":return new Kw(e.name)}let t=e.type.match(ik);if(t){let n=parseInt(t[2]||"256");return(0===n||n>256||n%8!=0)&&tk.throwArgumentError("invalid "+t[1]+" bit length","param",e),new Xw(n/8,"int"===t[1],e.name)}if(t=e.type.match(nk),t){let n=parseInt(t[1]);return(0===n||n>32)&&tk.throwArgumentError("invalid bytes length","param",e),new Yw(n,e.name)}return tk.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,t){return new Uw(e,this._getWordSize(),this.coerceFunc,t)}_getWriter(){return new Fw(this._getWordSize())}getDefaultValue(e){const t=e.map((e=>this._getCoder(Cw.from(e))));return new ek(t,"_").defaultValue()}encode(e,t){e.length!==t.length&&tk.throwError("types/values length mismatch",Nh.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});const n=e.map((e=>this._getCoder(Cw.from(e)))),i=new ek(n,"_"),o=this._getWriter();return i.encode(o,t),o.data}decode(e,t,n){const i=e.map((e=>this._getCoder(Cw.from(e))));return new ek(i,"_").decode(this._getReader(Hh(t),n))}};function rk(e){return tm(ym(e))}const ak=new Nh(hw);class sk extends pw{}class lk extends pw{}class dk extends pw{}class ck extends pw{static isIndexed(e){return!(!e||!e._isIndexed)}}const uk={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function pk(e,t){const n=new Error(`deferred error during ABI decoding triggered accessing ${e}`);return n.error=t,n}class hk{constructor(e){let t=[];t="string"==typeof e?JSON.parse(e):e,aw(this,"fragments",t.map((e=>kw.from(e))).filter((e=>null!=e))),aw(this,"_abiCoder",sw(new.target,"getAbiCoder")()),aw(this,"functions",{}),aw(this,"errors",{}),aw(this,"events",{}),aw(this,"structs",{}),this.fragments.forEach((e=>{let t=null;switch(e.type){case"constructor":return this.deploy?void ak.warn("duplicate definition - constructor"):void aw(this,"deploy",e);case"function":t=this.functions;break;case"event":t=this.events;break;case"error":t=this.errors;break;default:return}let n=e.format();t[n]?ak.warn("duplicate definition - "+n):t[n]=e})),this.deploy||aw(this,"deploy",Aw.from({payable:!1,type:"constructor"})),aw(this,"_isInterface",!0)}format(e){e||(e=bw.full),e===bw.sighash&&ak.throwArgumentError("interface does not support formatting sighash","format",e);const t=this.fragments.map((t=>t.format(e)));return e===bw.json?JSON.stringify(t.map((e=>JSON.parse(e)))):t}static getAbiCoder(){return ok}static getAddress(e){return sm(e)}static getSighash(e){return Kh(rk(e.format()),0,4)}static getEventTopic(e){return rk(e.format())}getFunction(e){if(Zh(e)){for(const t in this.functions)if(e===this.getSighash(t))return this.functions[t];ak.throwArgumentError("no matching function","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.functions).filter((e=>e.split("(")[0]===t));return 0===n.length?ak.throwArgumentError("no matching function","name",t):n.length>1&&ak.throwArgumentError("multiple matching functions","name",t),this.functions[n[0]]}const t=this.functions[Ow.fromString(e).format()];return t||ak.throwArgumentError("no matching function","signature",e),t}getEvent(e){if(Zh(e)){const t=e.toLowerCase();for(const e in this.events)if(t===this.getEventTopic(e))return this.events[e];ak.throwArgumentError("no matching event","topichash",t)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.events).filter((e=>e.split("(")[0]===t));return 0===n.length?ak.throwArgumentError("no matching event","name",t):n.length>1&&ak.throwArgumentError("multiple matching events","name",t),this.events[n[0]]}const t=this.events[Tw.fromString(e).format()];return t||ak.throwArgumentError("no matching event","signature",e),t}getError(e){if(Zh(e)){const t=sw(this.constructor,"getSighash");for(const n in this.errors){if(e===t(this.errors[n]))return this.errors[n]}ak.throwArgumentError("no matching error","sighash",e)}if(-1===e.indexOf("(")){const t=e.trim(),n=Object.keys(this.errors).filter((e=>e.split("(")[0]===t));return 0===n.length?ak.throwArgumentError("no matching error","name",t):n.length>1&&ak.throwArgumentError("multiple matching errors","name",t),this.errors[n[0]]}const t=this.errors[Ow.fromString(e).format()];return t||ak.throwArgumentError("no matching error","signature",e),t}getSighash(e){if("string"==typeof e)try{e=this.getFunction(e)}catch(t){try{e=this.getError(e)}catch(e){throw t}}return sw(this.constructor,"getSighash")(e)}getEventTopic(e){return"string"==typeof e&&(e=this.getEvent(e)),sw(this.constructor,"getEventTopic")(e)}_decodeParams(e,t){return this._abiCoder.decode(e,t)}_encodeParams(e,t){return this._abiCoder.encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){"string"==typeof e&&(e=this.getError(e));const n=Hh(t);return Qh(n.slice(0,4))!==this.getSighash(e)&&ak.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Qh(n)),this._decodeParams(e.inputs,n.slice(4))}encodeErrorResult(e,t){return"string"==typeof e&&(e=this.getError(e)),Qh($h([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionData(e,t){"string"==typeof e&&(e=this.getFunction(e));const n=Hh(t);return Qh(n.slice(0,4))!==this.getSighash(e)&&ak.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Qh(n)),this._decodeParams(e.inputs,n.slice(4))}encodeFunctionData(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Qh($h([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))}decodeFunctionResult(e,t){"string"==typeof e&&(e=this.getFunction(e));let n=Hh(t),i=null,o="",r=null,a=null,s=null;switch(n.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,n)}catch(e){}break;case 4:{const e=Qh(n.slice(0,4)),t=uk[e];if(t)r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.signature,t.reason&&(i=r[0]),"Error"===a?o=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(r[0])}`:"Panic"===a&&(o=`; VM Exception while processing transaction: reverted with panic code ${r[0]}`);else try{const t=this.getError(e);r=this._abiCoder.decode(t.inputs,n.slice(4)),a=t.name,s=t.format()}catch(e){}break}}return ak.throwError("call revert exception"+o,Nh.errors.CALL_EXCEPTION,{method:e.format(),data:Qh(t),errorArgs:r,errorName:a,errorSignature:s,reason:i})}encodeFunctionResult(e,t){return"string"==typeof e&&(e=this.getFunction(e)),Qh(this._abiCoder.encode(e.outputs,t||[]))}encodeFilterTopics(e,t){"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&ak.throwError("too many arguments for "+e.format(),Nh.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});let n=[];e.anonymous||n.push(this.getEventTopic(e));const i=(e,t)=>"string"===e.type?rk(t):"bytes"===e.type?tm(Qh(t)):("bool"===e.type&&"boolean"==typeof t&&(t=t?"0x01":"0x00"),e.type.match(/^u?int/)&&(t=$t.from(t).toHexString()),"address"===e.type&&this._abiCoder.encode(["address"],[t]),Xh(Qh(t),32));for(t.forEach(((t,o)=>{let r=e.inputs[o];r.indexed?null==t?n.push(null):"array"===r.baseType||"tuple"===r.baseType?ak.throwArgumentError("filtering with tuples or arrays not supported","contract."+r.name,t):Array.isArray(t)?n.push(t.map((e=>i(r,e)))):n.push(i(r,t)):null!=t&&ak.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+r.name,t)}));n.length&&null===n[n.length-1];)n.pop();return n}encodeEventLog(e,t){"string"==typeof e&&(e=this.getEvent(e));const n=[],i=[],o=[];return e.anonymous||n.push(this.getEventTopic(e)),t.length!==e.inputs.length&&ak.throwArgumentError("event arguments/values mismatch","values",t),e.inputs.forEach(((e,r)=>{const a=t[r];if(e.indexed)if("string"===e.type)n.push(rk(a));else if("bytes"===e.type)n.push(tm(a));else{if("tuple"===e.baseType||"array"===e.baseType)throw new Error("not implemented");n.push(this._abiCoder.encode([e.type],[a]))}else i.push(e),o.push(a)})),{data:this._abiCoder.encode(i,o),topics:n}}decodeEventLog(e,t,n){if("string"==typeof e&&(e=this.getEvent(e)),null!=n&&!e.anonymous){let t=this.getEventTopic(e);Zh(n[0],32)&&n[0].toLowerCase()===t||ak.throwError("fragment/topic mismatch",Nh.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:t,value:n[0]}),n=n.slice(1)}let i=[],o=[],r=[];e.inputs.forEach(((e,t)=>{e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(Cw.fromObject({type:"bytes32",name:e.name})),r.push(!0)):(i.push(e),r.push(!1)):(o.push(e),r.push(!1))}));let a=null!=n?this._abiCoder.decode(i,$h(n)):null,s=this._abiCoder.decode(o,t,!0),l=[],d=0,c=0;e.inputs.forEach(((e,t)=>{if(e.indexed)if(null==a)l[t]=new ck({_isIndexed:!0,hash:null});else if(r[t])l[t]=new ck({_isIndexed:!0,hash:a[c++]});else try{l[t]=a[c++]}catch(e){l[t]=e}else try{l[t]=s[d++]}catch(e){l[t]=e}if(e.name&&null==l[e.name]){const n=l[t];n instanceof Error?Object.defineProperty(l,e.name,{enumerable:!0,get:()=>{throw pk(`property ${JSON.stringify(e.name)}`,n)}}):l[e.name]=n}}));for(let e=0;e<l.length;e++){const t=l[e];t instanceof Error&&Object.defineProperty(l,e,{enumerable:!0,get:()=>{throw pk(`index ${e}`,t)}})}return Object.freeze(l)}parseTransaction(e){let t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new lk({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:$t.from(e.value||"0")}):null}parseLog(e){let t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new sk({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),args:this.decodeEventLog(t,e.data,e.topics)})}parseError(e){const t=Qh(e);let n=this.getError(t.substring(0,10).toLowerCase());return n?new dk({args:this._abiCoder.decode(n.inputs,"0x"+t.substring(10)),errorFragment:n,name:n.name,signature:n.format(),sighash:this.getSighash(n)}):null}static isInterface(e){return!(!e||!e._isInterface)}}function mk({factoryAddress:e,tokenA:t,tokenB:n,fee:i,initCodeHashManualOverride:o,chainId:r}){const[a,s]=t.sortsBefore(n)?[t,n]:[n,t],l=Sm(["bytes"],[ok.encode(["address","address","uint24"],[a.address,s.address,i])]),d=null!=o?o:function(e){switch(e){case le.TAIKO:case le.ZETACHAIN:case le.ZETACHAIN_TESTNET:return"0x5ccd5621c1bb9e44ce98cef8b90d31eb2423dec3793b6239232cefae976936ea";case le.SEPOLIA:return"0x4509fa1e2d1989ac1632a56fe87c53e8d1e9d05847694e00f62b23e28cec98c4";default:return KC}}(r);return lm(e,l,d)}const gk=wn.BigInt(2),fk=[128,64,32,16,8,4,2,1].map((e=>[e,wn.exponentiate(gk,wn.BigInt(e))]));function xk(e,t){return wn.signedRightShift(wn.multiply(e,wn.BigInt(t)),wn.BigInt(128))}const yk=wn.exponentiate(wn.BigInt(2),wn.BigInt(32));class vk{constructor(){}static getSqrtRatioAtTick(e){kn(e>=vk.MIN_TICK&&e<=vk.MAX_TICK&&Number.isInteger(e),"TICK");const t=e<0?-1*e:e;let n=1&t?wn.BigInt("0xfffcb933bd6fad37aa2d162d1a594001"):wn.BigInt("0x100000000000000000000000000000000");return 2&t&&(n=xk(n,"0xfff97272373d413259a46990580e213a")),4&t&&(n=xk(n,"0xfff2e50f5f656932ef12357cf3c7fdcc")),8&t&&(n=xk(n,"0xffe5caca7e10e4e61c3624eaa0941cd0")),16&t&&(n=xk(n,"0xffcb9843d60f6159c9db58835c926644")),32&t&&(n=xk(n,"0xff973b41fa98c081472e6896dfb254c0")),64&t&&(n=xk(n,"0xff2ea16466c96a3843ec78b326b52861")),128&t&&(n=xk(n,"0xfe5dee046a99a2a811c461f1969c3053")),256&t&&(n=xk(n,"0xfcbe86c7900a88aedcffc83b479aa3a4")),512&t&&(n=xk(n,"0xf987a7253ac413176f2b074cf7815e54")),1024&t&&(n=xk(n,"0xf3392b0822b70005940c7a398e4b70f3")),2048&t&&(n=xk(n,"0xe7159475a2c29b7443b29c7fa6e889d9")),4096&t&&(n=xk(n,"0xd097f3bdfd2022b8845ad8f792aa5825")),8192&t&&(n=xk(n,"0xa9f746462d870fdf8a65dc1f90e061e5")),16384&t&&(n=xk(n,"0x70d869a156d2a1b890bb3df62baf32f7")),32768&t&&(n=xk(n,"0x31be135f97d08fd981231505542fcfa6")),65536&t&&(n=xk(n,"0x9aa508b5b7a84e1c677de54f3e99bc9")),131072&t&&(n=xk(n,"0x5d6af8dedb81196699c329225ee604")),262144&t&&(n=xk(n,"0x2216e584f5fa1ea926041bedfe98")),524288&t&&(n=xk(n,"0x48a170391f7dc42444e8fa2")),e>0&&(n=wn.divide(LC,n)),wn.greaterThan(wn.remainder(n,yk),tw)?wn.add(wn.divide(n,yk),nw):wn.divide(n,yk)}static getTickAtSqrtRatio(e){kn(wn.greaterThanOrEqual(e,vk.MIN_SQRT_RATIO)&&wn.lessThan(e,vk.MAX_SQRT_RATIO),"SQRT_RATIO");const t=wn.leftShift(e,wn.BigInt(32)),n=function(e){kn(wn.greaterThan(e,tw),"ZERO"),kn(wn.lessThanOrEqual(e,LC),"MAX");let t=0;for(const[n,i]of fk)wn.greaterThanOrEqual(e,i)&&(e=wn.signedRightShift(e,wn.BigInt(n)),t+=n);return t}(t);let i;i=wn.greaterThanOrEqual(wn.BigInt(n),wn.BigInt(128))?wn.signedRightShift(t,wn.BigInt(n-127)):wn.leftShift(t,wn.BigInt(127-n));let o=wn.leftShift(wn.subtract(wn.BigInt(n),wn.BigInt(128)),wn.BigInt(64));for(let e=0;e<14;e++){i=wn.signedRightShift(wn.multiply(i,i),wn.BigInt(127));const t=wn.signedRightShift(i,wn.BigInt(128));o=wn.bitwiseOr(o,wn.leftShift(t,wn.BigInt(63-e))),i=wn.signedRightShift(i,t)}const r=wn.multiply(o,wn.BigInt("255738958999603826347141")),a=wn.toNumber(wn.signedRightShift(wn.subtract(r,wn.BigInt("3402992956809132418596140100660247210")),wn.BigInt(128))),s=wn.toNumber(wn.signedRightShift(wn.add(r,wn.BigInt("291339464771989622907027621153398088495")),wn.BigInt(128)));return a===s?a:wn.lessThanOrEqual(vk.getSqrtRatioAtTick(s),e)?s:a}}vk.MIN_TICK=-887272,vk.MAX_TICK=-vk.MIN_TICK,vk.MIN_SQRT_RATIO=wn.BigInt("4295128739"),vk.MAX_SQRT_RATIO=wn.BigInt("1461446703485210103287273052203988822378723970342");class bk{constructor(){}static mulDivRoundingUp(e,t,n){const i=wn.multiply(e,t);let o=wn.divide(i,n);return wn.notEqual(wn.remainder(i,n),tw)&&(o=wn.add(o,nw)),o}}const jk=wn.subtract(wn.exponentiate(wn.BigInt(2),wn.BigInt(160)),nw);function Ck(e,t){const n=wn.multiply(e,t);return wn.bitwiseAnd(n,LC)}class wk{constructor(){}static getAmount0Delta(e,t,n,i){wn.greaterThan(e,t)&&([e,t]=[t,e]);const o=wn.leftShift(n,wn.BigInt(96)),r=wn.subtract(t,e);return i?bk.mulDivRoundingUp(bk.mulDivRoundingUp(o,r,t),nw,e):wn.divide(wn.divide(wn.multiply(o,r),t),e)}static getAmount1Delta(e,t,n,i){return wn.greaterThan(e,t)&&([e,t]=[t,e]),i?bk.mulDivRoundingUp(n,wn.subtract(t,e),iw):wn.divide(wn.multiply(n,wn.subtract(t,e)),iw)}static getNextSqrtPriceFromInput(e,t,n,i){return kn(wn.greaterThan(e,tw)),kn(wn.greaterThan(t,tw)),i?this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!0):this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!0)}static getNextSqrtPriceFromOutput(e,t,n,i){return kn(wn.greaterThan(e,tw)),kn(wn.greaterThan(t,tw)),i?this.getNextSqrtPriceFromAmount1RoundingDown(e,t,n,!1):this.getNextSqrtPriceFromAmount0RoundingUp(e,t,n,!1)}static getNextSqrtPriceFromAmount0RoundingUp(e,t,n,i){if(wn.equal(n,tw))return e;const o=wn.leftShift(t,wn.BigInt(96));if(i){let t=Ck(n,e);if(wn.equal(wn.divide(t,n),e)){const n=function(e,t){const n=wn.add(e,t);return wn.bitwiseAnd(n,LC)}(o,t);if(wn.greaterThanOrEqual(n,o))return bk.mulDivRoundingUp(o,e,n)}return bk.mulDivRoundingUp(o,nw,wn.add(wn.divide(o,e),n))}{let t=Ck(n,e);kn(wn.equal(wn.divide(t,n),e)),kn(wn.greaterThan(o,t));const i=wn.subtract(o,t);return bk.mulDivRoundingUp(o,e,i)}}static getNextSqrtPriceFromAmount1RoundingDown(e,t,n,i){if(i){const i=wn.lessThanOrEqual(n,jk)?wn.divide(wn.leftShift(n,wn.BigInt(96)),t):wn.divide(wn.multiply(n,iw),t);return wn.add(e,i)}{const i=bk.mulDivRoundingUp(n,iw,t);return kn(wn.greaterThan(e,i)),wn.subtract(e,i)}}}const kk=wn.exponentiate(wn.BigInt(10),wn.BigInt(6));class Tk{constructor(){}static computeSwapStep(e,t,n,i,o){const r={};o=wn.BigInt(o);const a=wn.greaterThanOrEqual(e,t),s=wn.greaterThanOrEqual(i,tw);if(s){const s=wn.divide(wn.multiply(i,wn.subtract(kk,o)),kk);r.amountIn=a?wk.getAmount0Delta(t,e,n,!0):wk.getAmount1Delta(e,t,n,!0),wn.greaterThanOrEqual(s,r.amountIn)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=wk.getNextSqrtPriceFromInput(e,n,s,a)}else r.amountOut=a?wk.getAmount1Delta(t,e,n,!1):wk.getAmount0Delta(e,t,n,!1),wn.greaterThanOrEqual(wn.multiply(i,ew),r.amountOut)?r.sqrtRatioNextX96=t:r.sqrtRatioNextX96=wk.getNextSqrtPriceFromOutput(e,n,wn.multiply(i,ew),a);const l=wn.equal(t,r.sqrtRatioNextX96);return a?(r.amountIn=l&&s?r.amountIn:wk.getAmount0Delta(r.sqrtRatioNextX96,e,n,!0),r.amountOut=l&&!s?r.amountOut:wk.getAmount1Delta(r.sqrtRatioNextX96,e,n,!1)):(r.amountIn=l&&s?r.amountIn:wk.getAmount1Delta(e,r.sqrtRatioNextX96,n,!0),r.amountOut=l&&!s?r.amountOut:wk.getAmount0Delta(e,r.sqrtRatioNextX96,n,!1)),!s&&wn.greaterThan(r.amountOut,wn.multiply(i,ew))&&(r.amountOut=wn.multiply(i,ew)),s&&wn.notEqual(r.sqrtRatioNextX96,t)?r.feeAmount=wn.subtract(i,r.amountIn):r.feeAmount=bk.mulDivRoundingUp(r.amountIn,o,wn.subtract(kk,o)),[r.sqrtRatioNextX96,r.amountIn,r.amountOut,r.feeAmount]}}class Ik{constructor(){}static addDelta(e,t){return wn.lessThan(t,tw)?wn.subtract(e,wn.multiply(t,ew)):wn.add(e,t)}}class Sk{getTick(e){return Vn(this,void 0,void 0,(function*(){throw new Error(Sk.ERROR_MESSAGE)}))}nextInitializedTickWithinOneWord(e,t,n){return Vn(this,void 0,void 0,(function*(){throw new Error(Sk.ERROR_MESSAGE)}))}}function Ek(e,t){return e.index-t.index}Sk.ERROR_MESSAGE="No tick data provider was given";class Ak{constructor(){}static validateList(e,t){kn(t>0,"TICK_SPACING_NONZERO"),kn(e.every((({index:e})=>e%t==0)),"TICK_SPACING"),kn(wn.equal(e.reduce(((e,{liquidityNet:t})=>wn.add(e,t)),tw),tw),"ZERO_NET"),kn(function(e,t){for(let n=0;n<e.length-1;n++)if(t(e[n],e[n+1])>0)return!1;return!0}(e,Ek),"SORTED")}static isBelowSmallest(e,t){return kn(e.length>0,"LENGTH"),t<e[0].index}static isAtOrAboveLargest(e,t){return kn(e.length>0,"LENGTH"),t>=e[e.length-1].index}static getTick(e,t){const n=e[this.binarySearch(e,t)];return kn(n.index===t,"NOT_CONTAINED"),n}static binarySearch(e,t){kn(!this.isBelowSmallest(e,t),"BELOW_SMALLEST");let n,i=0,o=e.length-1;for(;;){if(n=Math.floor((i+o)/2),e[n].index<=t&&(n===e.length-1||e[n+1].index>t))return n;e[n].index<t?i=n+1:o=n-1}}static nextInitializedTick(e,t,n){if(n){if(kn(!Ak.isBelowSmallest(e,t),"BELOW_SMALLEST"),Ak.isAtOrAboveLargest(e,t))return e[e.length-1];return e[this.binarySearch(e,t)]}if(kn(!this.isAtOrAboveLargest(e,t),"AT_OR_ABOVE_LARGEST"),this.isBelowSmallest(e,t))return e[0];return e[this.binarySearch(e,t)+1]}static nextInitializedTickWithinOneWord(e,t,n,i){const o=Math.floor(t/i);if(n){const r=(o>>8<<8)*i;if(Ak.isBelowSmallest(e,t))return[r,!1];const a=Ak.nextInitializedTick(e,t,n).index,s=Math.max(r,a);return[s,s===a]}{const r=(((o+1>>8)+1<<8)-1)*i;if(this.isAtOrAboveLargest(e,t))return[r,!1];const a=this.nextInitializedTick(e,t,n).index,s=Math.min(r,a);return[s,s===a]}}}function Ok(e){let t=wn.BigInt(e).toString(16);return t.length%2!=0&&(t=`0${t}`),`0x${t}`}function Lk(e,t){const n=wn.leftShift(wn.BigInt(e),wn.BigInt(192)),i=wn.BigInt(t);return function(e){if(kn(wn.greaterThanOrEqual(e,$C),"NEGATIVE"),wn.lessThan(e,HC))return wn.BigInt(Math.floor(Math.sqrt(wn.toNumber(e))));let t,n;for(t=e,n=wn.add(wn.divide(e,ZC),zC);wn.lessThan(n,t);)t=n,n=wn.divide(wn.add(wn.divide(e,n),n),ZC);return t}(wn.divide(n,i))}function Rk(e,t,n){wn.greaterThan(e,t)&&([e,t]=[t,e]);const i=wn.divide(wn.multiply(e,t),iw);return wn.divide(wn.multiply(wn.BigInt(n),i),wn.subtract(t,e))}function Pk(e,t,n){wn.greaterThan(e,t)&&([e,t]=[t,e]);const i=wn.multiply(wn.multiply(wn.BigInt(n),e),t),o=wn.multiply(iw,wn.subtract(t,e));return wn.divide(i,o)}function _k(e,t,n){return wn.greaterThan(e,t)&&([e,t]=[t,e]),wn.divide(wn.multiply(wn.BigInt(n),iw),wn.subtract(t,e))}function Mk(e,t,n,i,o,r){wn.greaterThan(t,n)&&([t,n]=[n,t]);const a=r?Pk:Rk;if(wn.lessThanOrEqual(e,t))return a(t,n,i);if(wn.lessThan(e,n)){const r=a(e,n,i),s=_k(t,e,o);return wn.lessThan(r,s)?r:s}return _k(t,n,o)}function Bk(e,t){kn(Number.isInteger(e)&&Number.isInteger(t),"INTEGERS"),kn(t>0,"TICK_SPACING"),kn(e>=vk.MIN_TICK&&e<=vk.MAX_TICK,"TICK_BOUND");const n=Math.round(e/t)*t;return n<vk.MIN_TICK?n+t:n>vk.MAX_TICK?n-t:n}function Dk(e,t,n){const i=vk.getSqrtRatioAtTick(n),o=wn.multiply(i,i);return e.sortsBefore(t)?new FC(e,t,ow,o):new FC(e,t,o,ow)}function Nk(e){const t=e.baseCurrency.sortsBefore(e.quoteCurrency),n=t?Lk(e.numerator,e.denominator):Lk(e.denominator,e.numerator);let i=vk.getTickAtSqrtRatio(n);const o=Dk(e.baseCurrency,e.quoteCurrency,i+1);return t?e.lessThan(o)||i++:e.greaterThan(o)||i++,i}wn.exponentiate(wn.BigInt(2),wn.BigInt(128)),wn.exponentiate(wn.BigInt(2),wn.BigInt(256));class Fk{constructor({index:e,liquidityGross:t,liquidityNet:n}){kn(e>=vk.MIN_TICK&&e<=vk.MAX_TICK,"TICK"),this.index=e,this.liquidityGross=wn.BigInt(t),this.liquidityNet=wn.BigInt(n)}}class Uk{constructor(e,t){const n=e.map((e=>e instanceof Fk?e:new Fk(e)));Ak.validateList(n,t),this.ticks=n}getTick(e){return Vn(this,void 0,void 0,(function*(){return Ak.getTick(this.ticks,e)}))}nextInitializedTickWithinOneWord(e,t,n){return Vn(this,void 0,void 0,(function*(){return Ak.nextInitializedTickWithinOneWord(this.ticks,e,t,n)}))}}const qk=new Sk;let Vk=class e{static getAddress(e,t,n,i,o){return mk({factoryAddress:null!=o?o:"0x78172691DD3B8ADa7aEbd9bFfB487FB11D735DB2",fee:n,tokenA:e,tokenB:t,initCodeHashManualOverride:i})}constructor(e,t,n,i,o,r,a=qk){kn(Number.isInteger(n)&&n<1e6,"FEE");const s=vk.getSqrtRatioAtTick(r),l=vk.getSqrtRatioAtTick(r+1);kn(wn.greaterThanOrEqual(wn.BigInt(i),s)&&wn.lessThanOrEqual(wn.BigInt(i),l),"PRICE_BOUNDS"),[this.token0,this.token1]=e.sortsBefore(t)?[e,t]:[t,e],this.fee=n,this.sqrtRatioX96=wn.BigInt(i),this.liquidity=wn.BigInt(o),this.tickCurrent=r,this.tickDataProvider=Array.isArray(a)?new Uk(a,JC[n]):a}involvesToken(e){return e.equals(this.token0)||e.equals(this.token1)}get token0Price(){var e;return null!==(e=this._token0Price)&&void 0!==e?e:this._token0Price=new FC(this.token0,this.token1,ow,wn.multiply(this.sqrtRatioX96,this.sqrtRatioX96))}get token1Price(){var e;return null!==(e=this._token1Price)&&void 0!==e?e:this._token1Price=new FC(this.token1,this.token0,wn.multiply(this.sqrtRatioX96,this.sqrtRatioX96),ow)}priceOf(e){return kn(this.involvesToken(e),"TOKEN"),e.equals(this.token0)?this.token0Price:this.token1Price}get chainId(){return this.token0.chainId}getOutputAmount(t,n){return Vn(this,void 0,void 0,(function*(){kn(this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token0),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,t.quotient,n),l=i?this.token1:this.token0;return[MC.fromRawAmount(l,wn.multiply(o,ew)),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}getInputAmount(t,n){return Vn(this,void 0,void 0,(function*(){kn(t.currency.isToken&&this.involvesToken(t.currency),"TOKEN");const i=t.currency.equals(this.token1),{amountCalculated:o,sqrtRatioX96:r,liquidity:a,tickCurrent:s}=yield this.swap(i,wn.multiply(t.quotient,ew),n),l=i?this.token0:this.token1;return[MC.fromRawAmount(l,o),new e(this.token0,this.token1,this.fee,r,a,s,this.tickDataProvider)]}))}swap(e,t,n){return Vn(this,void 0,void 0,(function*(){return function(e,t,n,i,o,r,a,s,l){return Vn(this,void 0,void 0,(function*(){l||(l=a?wn.add(vk.MIN_SQRT_RATIO,nw):wn.subtract(vk.MAX_SQRT_RATIO,nw)),a?(kn(wn.greaterThan(l,vk.MIN_SQRT_RATIO),"RATIO_MIN"),kn(wn.lessThan(l,t),"RATIO_CURRENT")):(kn(wn.lessThan(l,vk.MAX_SQRT_RATIO),"RATIO_MAX"),kn(wn.greaterThan(l,t),"RATIO_CURRENT"));const d=wn.greaterThanOrEqual(s,tw),c={amountSpecifiedRemaining:s,amountCalculated:tw,sqrtPriceX96:t,tick:n,liquidity:i};for(;wn.notEqual(c.amountSpecifiedRemaining,tw)&&c.sqrtPriceX96!==l;){let t={};if(t.sqrtPriceStartX96=c.sqrtPriceX96,[t.tickNext,t.initialized]=yield r.nextInitializedTickWithinOneWord(c.tick,a,o),t.tickNext<vk.MIN_TICK?t.tickNext=vk.MIN_TICK:t.tickNext>vk.MAX_TICK&&(t.tickNext=vk.MAX_TICK),t.sqrtPriceNextX96=vk.getSqrtRatioAtTick(t.tickNext),[c.sqrtPriceX96,t.amountIn,t.amountOut,t.feeAmount]=Tk.computeSwapStep(c.sqrtPriceX96,(a?wn.lessThan(t.sqrtPriceNextX96,l):wn.greaterThan(t.sqrtPriceNextX96,l))?l:t.sqrtPriceNextX96,c.liquidity,c.amountSpecifiedRemaining,e),d?(c.amountSpecifiedRemaining=wn.subtract(c.amountSpecifiedRemaining,wn.add(t.amountIn,t.feeAmount)),c.amountCalculated=wn.subtract(c.amountCalculated,t.amountOut)):(c.amountSpecifiedRemaining=wn.add(c.amountSpecifiedRemaining,t.amountOut),c.amountCalculated=wn.add(c.amountCalculated,wn.add(t.amountIn,t.feeAmount))),wn.equal(c.sqrtPriceX96,t.sqrtPriceNextX96)){if(t.initialized){let e=wn.BigInt((yield r.getTick(t.tickNext)).liquidityNet);a&&(e=wn.multiply(e,ew)),c.liquidity=Ik.addDelta(c.liquidity,e)}c.tick=a?t.tickNext-1:t.tickNext}else wn.notEqual(c.sqrtPriceX96,t.sqrtPriceStartX96)&&(c.tick=vk.getTickAtSqrtRatio(c.sqrtPriceX96))}return{amountCalculated:c.amountCalculated,sqrtRatioX96:c.sqrtPriceX96,liquidity:c.liquidity,tickCurrent:c.tick}}))}(wn.BigInt(this.fee),this.sqrtRatioX96,this.tickCurrent,this.liquidity,this.tickSpacing,this.tickDataProvider,e,t,n)}))}get tickSpacing(){return JC[this.fee]}};class Wk{constructor({pool:e,liquidity:t,tickLower:n,tickUpper:i}){this._token0Amount=null,this._token1Amount=null,this._mintAmounts=null,kn(n<i,"TICK_ORDER"),kn(n>=vk.MIN_TICK&&n%e.tickSpacing==0,"TICK_LOWER"),kn(i<=vk.MAX_TICK&&i%e.tickSpacing==0,"TICK_UPPER"),this.pool=e,this.tickLower=n,this.tickUpper=i,this.liquidity=wn.BigInt(t)}get token0PriceLower(){return Dk(this.pool.token0,this.pool.token1,this.tickLower)}get token0PriceUpper(){return Dk(this.pool.token0,this.pool.token1,this.tickUpper)}get amount0(){return null===this._token0Amount&&(this.pool.tickCurrent<this.tickLower?this._token0Amount=MC.fromRawAmount(this.pool.token0,wk.getAmount0Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this.pool.tickCurrent<this.tickUpper?this._token0Amount=MC.fromRawAmount(this.pool.token0,wk.getAmount0Delta(this.pool.sqrtRatioX96,vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1)):this._token0Amount=MC.fromRawAmount(this.pool.token0,tw)),this._token0Amount}get amount1(){return null===this._token1Amount&&(this.pool.tickCurrent<this.tickLower?this._token1Amount=MC.fromRawAmount(this.pool.token1,tw):this.pool.tickCurrent<this.tickUpper?this._token1Amount=MC.fromRawAmount(this.pool.token1,wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!1)):this._token1Amount=MC.fromRawAmount(this.pool.token1,wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!1))),this._token1Amount}ratiosAfterSlippage(e){const t=this.pool.token0Price.asFraction.multiply(new NC(1).subtract(e)),n=this.pool.token0Price.asFraction.multiply(e.add(1));let i=Lk(t.numerator,t.denominator);wn.lessThanOrEqual(i,vk.MIN_SQRT_RATIO)&&(i=wn.add(vk.MIN_SQRT_RATIO,wn.BigInt(1)));let o=Lk(n.numerator,n.denominator);return wn.greaterThanOrEqual(o,vk.MAX_SQRT_RATIO)&&(o=wn.subtract(vk.MAX_SQRT_RATIO,wn.BigInt(1))),{sqrtRatioX96Lower:i,sqrtRatioX96Upper:o}}mintAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,n,0,vk.getTickAtSqrtRatio(n)),o=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,t,0,vk.getTickAtSqrtRatio(t)),r=Wk.fromAmounts(Object.assign(Object.assign({pool:this.pool,tickLower:this.tickLower,tickUpper:this.tickUpper},this.mintAmounts),{useFullPrecision:!1})),{amount0:a}=new Wk({pool:o,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts,{amount1:s}=new Wk({pool:i,liquidity:r.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).mintAmounts;return{amount0:a,amount1:s}}burnAmountsWithSlippage(e){const{sqrtRatioX96Upper:t,sqrtRatioX96Lower:n}=this.ratiosAfterSlippage(e),i=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,n,0,vk.getTickAtSqrtRatio(n)),o=new Vk(this.pool.token0,this.pool.token1,this.pool.fee,t,0,vk.getTickAtSqrtRatio(t)),r=new Wk({pool:o,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount0,a=new Wk({pool:i,liquidity:this.liquidity,tickLower:this.tickLower,tickUpper:this.tickUpper}).amount1;return{amount0:r.quotient,amount1:a.quotient}}get mintAmounts(){return null===this._mintAmounts?this.pool.tickCurrent<this.tickLower?{amount0:wk.getAmount0Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:tw}:this.pool.tickCurrent<this.tickUpper?{amount0:wk.getAmount0Delta(this.pool.sqrtRatioX96,vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0),amount1:wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),this.pool.sqrtRatioX96,this.liquidity,!0)}:{amount0:tw,amount1:wk.getAmount1Delta(vk.getSqrtRatioAtTick(this.tickLower),vk.getSqrtRatioAtTick(this.tickUpper),this.liquidity,!0)}:this._mintAmounts}static fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:o,useFullPrecision:r}){const a=vk.getSqrtRatioAtTick(t),s=vk.getSqrtRatioAtTick(n);return new Wk({pool:e,tickLower:t,tickUpper:n,liquidity:Mk(e.sqrtRatioX96,a,s,i,o,r)})}static fromAmount0({pool:e,tickLower:t,tickUpper:n,amount0:i,useFullPrecision:o}){return Wk.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:i,amount1:LC,useFullPrecision:o})}static fromAmount1({pool:e,tickLower:t,tickUpper:n,amount1:i}){return Wk.fromAmounts({pool:e,tickLower:t,tickUpper:n,amount0:LC,amount1:i,useFullPrecision:!0})}}var Hk=[{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"}];class $k{constructor(){}static encodeMulticall(e){return Array.isArray(e)||(e=[e]),1===e.length?e[0]:$k.INTERFACE.encodeFunctionData("multicall",[e])}static decodeMulticall(e){return $k.INTERFACE.decodeFunctionData("multicall",e).data}}$k.INTERFACE=new hk(Hk);var zk=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"},{internalType:"address",name:"_tokenDescriptor_",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"address",name:"recipient",type:"address"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"Collect",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"DecreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"},{indexed:!1,internalType:"uint256",name:"amount0",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amount1",type:"uint256"}],name:"IncreaseLiquidity",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[],name:"DOMAIN_SEPARATOR",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"PERMIT_TYPEHASH",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"burn",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint128",name:"amount0Max",type:"uint128"},{internalType:"uint128",name:"amount1Max",type:"uint128"}],internalType:"struct INonfungiblePositionManager.CollectParams",name:"params",type:"tuple"}],name:"collect",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceX96",type:"uint160"}],name:"createAndInitializePoolIfNecessary",outputs:[{internalType:"address",name:"pool",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.DecreaseLiquidityParams",name:"params",type:"tuple"}],name:"decreaseLiquidity",outputs:[{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.IncreaseLiquidityParams",name:"params",type:"tuple"}],name:"increaseLiquidity",outputs:[{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint256",name:"amount0Desired",type:"uint256"},{internalType:"uint256",name:"amount1Desired",type:"uint256"},{internalType:"uint256",name:"amount0Min",type:"uint256"},{internalType:"uint256",name:"amount1Min",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"}],internalType:"struct INonfungiblePositionManager.MintParams",name:"params",type:"tuple"}],name:"mint",outputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"amount0",type:"uint256"},{internalType:"uint256",name:"amount1",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"permit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"positions",outputs:[{internalType:"uint96",name:"nonce",type:"uint96"},{internalType:"address",name:"operator",type:"address"},{internalType:"address",name:"token0",type:"address"},{internalType:"address",name:"token1",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"},{internalType:"uint128",name:"liquidity",type:"uint128"},{internalType:"uint256",name:"feeGrowthInside0LastX128",type:"uint256"},{internalType:"uint256",name:"feeGrowthInside1LastX128",type:"uint256"},{internalType:"uint128",name:"tokensOwed0",type:"uint128"},{internalType:"uint128",name:"tokensOwed1",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint256",name:"index",type:"uint256"}],name:"tokenOfOwnerByIndex",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amount0Owed",type:"uint256"},{internalType:"uint256",name:"amount1Owed",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"uniswapV3MintCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}],Zk=[{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"}];class Gk{constructor(){}static encodeFeeBips(e){return Ok(e.multiply(1e4).quotient)}static encodeUnwrapWETH9(e,t,n){if(t=qC(t),n){const i=this.encodeFeeBips(n.fee),o=qC(n.recipient);return Gk.INTERFACE.encodeFunctionData("unwrapWETH9WithFee",[Ok(e),t,i,o])}return Gk.INTERFACE.encodeFunctionData("unwrapWETH9",[Ok(e),t])}static encodeSweepToken(e,t,n,i){if(n=qC(n),i){const o=this.encodeFeeBips(i.fee),r=qC(i.recipient);return Gk.INTERFACE.encodeFunctionData("sweepTokenWithFee",[e.address,Ok(t),n,o,r])}return Gk.INTERFACE.encodeFunctionData("sweepToken",[e.address,Ok(t),n])}static encodeRefundETH(){return Gk.INTERFACE.encodeFunctionData("refundETH")}}Gk.INTERFACE=new hk(Zk);var Qk=[{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"}];class Yk{constructor(){}static encodePermit(e,t){return"nonce"in t?Yk.INTERFACE.encodeFunctionData("selfPermitAllowed",[e.address,Ok(t.nonce),Ok(t.expiry),t.v,t.r,t.s]):Yk.INTERFACE.encodeFunctionData("selfPermit",[e.address,Ok(t.amount),Ok(t.deadline),t.v,t.r,t.s])}}Yk.INTERFACE=new hk(Qk);const Kk=Ok(wn.subtract(wn.exponentiate(wn.BigInt(2),wn.BigInt(128)),wn.BigInt(1)));function Xk(e){return Object.keys(e).some((e=>"recipient"===e))}const Jk={Permit:[{name:"spender",type:"address"},{name:"tokenId",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};class eT{constructor(){}static encodeCreate(e){return eT.INTERFACE.encodeFunctionData("createAndInitializePoolIfNecessary",[e.token0.address,e.token1.address,e.fee,Ok(e.sqrtRatioX96)])}static createCallParameters(e){return{calldata:this.encodeCreate(e),value:Ok(0)}}static addCallParameters(e,t){kn(wn.greaterThan(e.liquidity,tw),"ZERO_LIQUIDITY");const n=[],{amount0:i,amount1:o}=e.mintAmounts,r=e.mintAmountsWithSlippage(t.slippageTolerance),a=Ok(r.amount0),s=Ok(r.amount1),l=Ok(t.deadline);if(Xk(t)&&t.createPool&&n.push(this.encodeCreate(e.pool)),t.token0Permit&&n.push(Yk.encodePermit(e.pool.token0,t.token0Permit)),t.token1Permit&&n.push(Yk.encodePermit(e.pool.token1,t.token1Permit)),Xk(t)){const r=qC(t.recipient);n.push(eT.INTERFACE.encodeFunctionData("mint",[{token0:e.pool.token0.address,token1:e.pool.token1.address,fee:e.pool.fee,tickLower:e.tickLower,tickUpper:e.tickUpper,amount0Desired:Ok(i),amount1Desired:Ok(o),amount0Min:a,amount1Min:s,recipient:r,deadline:l}]))}else n.push(eT.INTERFACE.encodeFunctionData("increaseLiquidity",[{tokenId:Ok(t.tokenId),amount0Desired:Ok(i),amount1Desired:Ok(o),amount0Min:a,amount1Min:s,deadline:l}]));let d=Ok(0);if(t.useNative){const r=t.useNative.wrapped;kn(e.pool.token0.equals(r)||e.pool.token1.equals(r),"NO_WETH");const a=e.pool.token0.equals(r)?i:o;wn.greaterThan(a,tw)&&n.push(Gk.encodeRefundETH()),d=Ok(a)}return{calldata:$k.encodeMulticall(n),value:d}}static encodeCollect(e){const t=[],n=Ok(e.tokenId),i=e.expectedCurrencyOwed0.currency.isNative||e.expectedCurrencyOwed1.currency.isNative,o=qC(e.recipient);if(t.push(eT.INTERFACE.encodeFunctionData("collect",[{tokenId:n,recipient:i?"0x0000000000000000000000000000000000000000":o,amount0Max:Kk,amount1Max:Kk}])),i){const n=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed0.quotient:e.expectedCurrencyOwed1.quotient,i=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.currency:e.expectedCurrencyOwed0.currency,r=e.expectedCurrencyOwed0.currency.isNative?e.expectedCurrencyOwed1.quotient:e.expectedCurrencyOwed0.quotient;t.push(Gk.encodeUnwrapWETH9(n,o)),t.push(Gk.encodeSweepToken(i,r,o))}return t}static collectCallParameters(e){const t=eT.encodeCollect(e);return{calldata:$k.encodeMulticall(t),value:Ok(0)}}static removeCallParameters(e,t){const n=[],i=Ok(t.deadline),o=Ok(t.tokenId),r=new Wk({pool:e.pool,liquidity:t.liquidityPercentage.multiply(e.liquidity).quotient,tickLower:e.tickLower,tickUpper:e.tickUpper});kn(wn.greaterThan(r.liquidity,tw),"ZERO_LIQUIDITY");const{amount0:a,amount1:s}=r.burnAmountsWithSlippage(t.slippageTolerance);t.permit&&n.push(eT.INTERFACE.encodeFunctionData("permit",[qC(t.permit.spender),o,Ok(t.permit.deadline),t.permit.v,t.permit.r,t.permit.s])),n.push(eT.INTERFACE.encodeFunctionData("decreaseLiquidity",[{tokenId:o,liquidity:Ok(r.liquidity),amount0Min:Ok(a),amount1Min:Ok(s),deadline:i}]));const l=t.collectOptions,{expectedCurrencyOwed0:d,expectedCurrencyOwed1:c}=l,u=qn(l,["expectedCurrencyOwed0","expectedCurrencyOwed1"]);return n.push(...eT.encodeCollect(Object.assign({tokenId:Ok(t.tokenId),expectedCurrencyOwed0:d.add(MC.fromRawAmount(d.currency,a)),expectedCurrencyOwed1:c.add(MC.fromRawAmount(c.currency,s))},u))),t.liquidityPercentage.equalTo(nw)?t.burnToken&&n.push(eT.INTERFACE.encodeFunctionData("burn",[o])):kn(!0!==t.burnToken,"CANNOT_BURN"),{calldata:$k.encodeMulticall(n),value:Ok(0)}}static safeTransferFromParameters(e){const t=qC(e.recipient),n=qC(e.sender);let i;return i=e.data?eT.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256,bytes)",[n,t,Ok(e.tokenId),e.data]):eT.INTERFACE.encodeFunctionData("safeTransferFrom(address,address,uint256)",[n,t,Ok(e.tokenId)]),{calldata:i,value:Ok(0)}}static getPermitData(e,t,n){return{domain:{name:"Uniswap V3 Positions NFT-V1",chainId:n,version:"1",verifyingContract:t},types:Jk,values:e}}}eT.INTERFACE=new hk(zk);var tT=[{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactInputSingleParams",name:"params",type:"tuple"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160[]",name:"sqrtPriceX96AfterList",type:"uint160[]"},{internalType:"uint32[]",name:"initializedTicksCrossedList",type:"uint32[]"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct IQuoterV2.QuoteExactOutputSingleParams",name:"params",type:"tuple"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceX96After",type:"uint160"},{internalType:"uint32",name:"initializedTicksCrossed",type:"uint32"},{internalType:"uint256",name:"gasEstimate",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}];new hk([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountIn",type:"uint256"}],name:"quoteExactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"uint256",name:"amountOut",type:"uint256"}],name:"quoteExactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],name:"quoteExactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"path",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"view",type:"function"}]),new hk(tT);new hk([{inputs:[{internalType:"contract IUniswapV3Factory",name:"_factory",type:"address"},{internalType:"contract INonfungiblePositionManager",name:"_nonfungiblePositionManager",type:"address"},{internalType:"uint256",name:"_maxIncentiveStartLeadTime",type:"uint256"},{internalType:"uint256",name:"_maxIncentiveDuration",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"oldOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"DepositTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{indexed:!0,internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{indexed:!1,internalType:"uint256",name:"startTime",type:"uint256"},{indexed:!1,internalType:"uint256",name:"endTime",type:"uint256"},{indexed:!1,internalType:"address",name:"refundee",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"IncentiveCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"refund",type:"uint256"}],name:"IncentiveEnded",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"reward",type:"uint256"}],name:"RewardClaimed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"},{indexed:!1,internalType:"uint128",name:"liquidity",type:"uint128"}],name:"TokenStaked",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"TokenUnstaked",type:"event"},{inputs:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountRequested",type:"uint256"}],name:"claimReward",outputs:[{internalType:"uint256",name:"reward",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"reward",type:"uint256"}],name:"createIncentive",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"deposits",outputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"uint48",name:"numberOfStakes",type:"uint48"},{internalType:"int24",name:"tickLower",type:"int24"},{internalType:"int24",name:"tickUpper",type:"int24"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"}],name:"endIncentive",outputs:[{internalType:"uint256",name:"refund",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"contract IUniswapV3Factory",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getRewardInfo",outputs:[{internalType:"uint256",name:"reward",type:"uint256"},{internalType:"uint160",name:"secondsInsideX128",type:"uint160"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"incentives",outputs:[{internalType:"uint256",name:"totalRewardUnclaimed",type:"uint256"},{internalType:"uint160",name:"totalSecondsClaimedX128",type:"uint160"},{internalType:"uint96",name:"numberOfStakes",type:"uint96"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxIncentiveStartLeadTime",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"nonfungiblePositionManager",outputs:[{internalType:"contract INonfungiblePositionManager",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"from",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract IERC20Minimal",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"rewards",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"stakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"incentiveId",type:"bytes32"}],name:"stakes",outputs:[{internalType:"uint160",name:"secondsPerLiquidityInsideInitialX128",type:"uint160"},{internalType:"uint128",name:"liquidity",type:"uint128"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"}],name:"transferDeposit",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IERC20Minimal",name:"rewardToken",type:"address"},{internalType:"contract IUniswapV3Pool",name:"pool",type:"address"},{internalType:"uint256",name:"startTime",type:"uint256"},{internalType:"uint256",name:"endTime",type:"uint256"},{internalType:"address",name:"refundee",type:"address"}],internalType:"struct IUniswapV3Staker.IncentiveKey",name:"key",type:"tuple"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"unstakeToken",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"to",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"withdrawToken",outputs:[],stateMutability:"nonpayable",type:"function"}]);function nT({removed:e,inRange:t}){const n=a(),o={py:4,px:8,color:n.palette.success.main,borderRadius:4,backgroundColor:T(n.palette.success.main,.1),typography:"h6"};return e?Yn.jsx(l,{title:se._({id:"MZPP7t",message:"Your position has 0 liquidity, and is not earning fees."}),maxWidth:240,children:Yn.jsx(i,{sx:Object.assign(Object.assign({},o),{color:n.palette.warning.main,backgroundColor:T(n.palette.warning.main,.1)}),children:se._({id:"D87pha",message:"Closed"})})}):t?Yn.jsx(l,{title:se._({id:"aIvv/z",message:"The price of this pool is within your selected range. Your position is currently earning fees."}),maxWidth:240,children:Yn.jsx(i,{sx:o,children:se._({id:"vOyUlD",message:"In range"})})}):Yn.jsx(l,{title:se._({id:"IwiTcw",message:"The price of this pool is outside of your selected range. Your position is not currently earning fees."}),maxWidth:240,children:Yn.jsx(i,{sx:Object.assign(Object.assign({},o),{color:n.palette.error.main,backgroundColor:T(n.palette.error.main,.1)}),children:se._({id:"i3Z+/Z",message:"Out of range"})})})}new hk([{inputs:[{internalType:"address",name:"_factory",type:"address"},{internalType:"address",name:"_WETH9",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"WETH9",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"}],internalType:"struct ISwapRouter.ExactInputParams",name:"params",type:"tuple"}],name:"exactInput",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountIn",type:"uint256"},{internalType:"uint256",name:"amountOutMinimum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactInputSingleParams",name:"params",type:"tuple"}],name:"exactInputSingle",outputs:[{internalType:"uint256",name:"amountOut",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"bytes",name:"path",type:"bytes"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"}],internalType:"struct ISwapRouter.ExactOutputParams",name:"params",type:"tuple"}],name:"exactOutput",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{components:[{internalType:"address",name:"tokenIn",type:"address"},{internalType:"address",name:"tokenOut",type:"address"},{internalType:"uint24",name:"fee",type:"uint24"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256",name:"amountOut",type:"uint256"},{internalType:"uint256",name:"amountInMaximum",type:"uint256"},{internalType:"uint160",name:"sqrtPriceLimitX96",type:"uint160"}],internalType:"struct ISwapRouter.ExactOutputSingleParams",name:"params",type:"tuple"}],name:"exactOutputSingle",outputs:[{internalType:"uint256",name:"amountIn",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[],name:"factory",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes[]",name:"data",type:"bytes[]"}],name:"multicall",outputs:[{internalType:"bytes[]",name:"results",type:"bytes[]"}],stateMutability:"payable",type:"function"},{inputs:[],name:"refundETH",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowed",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"nonce",type:"uint256"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitAllowedIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"value",type:"uint256"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"selfPermitIfNecessary",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"sweepToken",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"token",type:"address"},{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"sweepTokenWithFee",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"int256",name:"amount0Delta",type:"int256"},{internalType:"int256",name:"amount1Delta",type:"int256"},{internalType:"bytes",name:"_data",type:"bytes"}],name:"uniswapV3SwapCallback",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"}],name:"unwrapWETH9",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"amountMinimum",type:"uint256"},{internalType:"address",name:"recipient",type:"address"},{internalType:"uint256",name:"feeBips",type:"uint256"},{internalType:"address",name:"feeRecipient",type:"address"}],name:"unwrapWETH9WithFee",outputs:[],stateMutability:"payable",type:"function"},{stateMutability:"payable",type:"receive"}]);const iT=({token:e,amount:t})=>{var n;const o=a();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(Df,{address:null!==(n=null==e?void 0:e.address)&&void 0!==n?n:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:18,height:18,marginRight:0}),Yn.jsxs(i,{sx:{typography:"body1",color:o.palette.text.primary},children:[Am({input:t.toSignificant(),decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),Yn.jsx(d,{sx:{display:"flex",alignItems:"center",color:o.palette.text.secondary,"&:hover":{color:o.palette.text.primary}},onClick:()=>{window.open(tg(e.chainId,null==e?void 0:e.address,"address"))},children:Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{opacity:"0.5",fillRule:"evenodd",clipRule:"evenodd",d:"M3.33333 3.33333V12.6667H12.6667V8H14V12.6667C14 13.4 13.4 14 12.6667 14H3.33333C2.59333 14 2 13.4 2 12.6667V3.33333C2 2.6 2.59333 2 3.33333 2H8V3.33333H3.33333ZM9.33333 3.33333V2H14V6.66667H12.6667V4.27333L6.11333 10.8267L5.17333 9.88667L11.7267 3.33333H9.33333Z",fill:"currentColor"})})})]})},oT=({position:t,inRange:n})=>{var o;const r=a(),s=t.pool.token0,l=t.pool.token1,c=t.pool.chainId,u=(null==t?void 0:t.liquidity)&&wn.equal(null==t?void 0:t.liquidity,wn.BigInt(0)),p=$((()=>Vk.getAddress(t.pool.token0,t.pool.token1,t.pool.fee,void 0,c?SC[c]:void 0)),[c,t.pool.fee,t.pool.token0,t.pool.token1]);return Yn.jsxs(i,{sx:{border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:r.spacing(12,20),borderBottomStyle:"solid",borderBottomColor:"border.main",borderBottomWidth:1},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[Yn.jsxs(i,{sx:{typography:"body2",color:r.palette.text.primary},children:[se._({id:"PVa3KL",message:"Position on"})," ",null==s?void 0:s.symbol,"/",null==l?void 0:l.symbol]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(nT,{removed:u,inRange:n}),Yn.jsx(i,{sx:{py:4,px:8,color:r.palette.text.secondary,borderRadius:4,backgroundColor:r.palette.background.tag,typography:"h6"},children:Vm({input:(null===(o=null==t?void 0:t.pool)||void 0===o?void 0:o.fee)/1e6})})]})]}),Yn.jsxs(d,{sx:{display:"flex",alignItems:"center",gap:0,typography:"body2",color:r.palette.text.secondary,"&:hover":{color:r.palette.text.primary}},onClick:()=>{window.open(tg(c,p,"address"))},children:[se._({id:"URmyfc",message:"Details"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M7.5 5L6.4425 6.0575L9.8775 9.5L6.4425 12.9425L7.5 14L12 9.5L7.5 5Z",fill:"currentColor"})})]})]}),Yn.jsxs(i,{sx:{p:r.spacing(12,20)},children:[Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),Yn.jsxs(i,{sx:{mt:12},children:[Yn.jsx(iT,{token:s,amount:t.amount0}),Yn.jsx(iT,{token:l,amount:t.amount1})]})]})]})};function rT({price:e,atLimit:t,direction:n}){return t[n]?n===dC.LOWER?"0":"∞":"string"==typeof e&&"∞"===e?"∞":Am({input:"string"==typeof e?e:null==e?void 0:e.toSignificant()})}const aT=({baseToken:e,quoteToken:t,handleRateToggle:n,sx:o})=>{const r=a(),s=null==e?void 0:e.wrapped,l=null==t?void 0:t.wrapped,c=s&&l&&s.sortsBefore(l);return Yn.jsx(i,{component:d,onClick:n,sx:Object.assign({display:"flex",alignItems:"center",p:1,borderRadius:8,backgroundColor:r.palette.border.main},o),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",width:"100%",[r.breakpoints.up("tablet")]:{width:"auto"}},children:[Yn.jsx(i,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},c?{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}:{color:r.palette.text.secondary,backgroundColor:"transparent"}),children:c?e.symbol:null==t?void 0:t.symbol}),Yn.jsx(i,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},c?{color:r.palette.text.secondary,backgroundColor:"transparent"}:{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}),children:c?t.symbol:null==e?void 0:e.symbol})]})})},sT=({position:t,title:n,baseCurrencyDefault:o,ticksAtLimit:r})=>{const s=t.pool.token0,l=t.pool.token1,d=a(),[c,u]=z(o?o===s?s:o===l?l:s:s),p=c===s,h=p?l:s,m=p?t.pool.priceOf(t.pool.token0):t.pool.priceOf(t.pool.token1),g=p?t.token0PriceLower:t.token0PriceUpper.invert(),f=p?t.token0PriceUpper:t.token0PriceLower.invert(),x=Z((()=>{u(h)}),[h]);return Yn.jsxs(fC,{gap:"md",children:[Yn.jsxs(yC,{children:[n?Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:d.palette.text.secondary},children:n}):Yn.jsx("div",{}),Yn.jsx(aT,{baseToken:p?s:l,quoteToken:p?l:s,handleRateToggle:x})]}),Yn.jsxs(yC,{children:[Yn.jsxs(hC,{sx:{width:"48%",py:12,gap:12},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:[Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"body2"},children:Yn.jsx(e,{id:"EQs1sJ",message:"Min price"})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"caption"},children:rT({price:g,atLimit:r,direction:dC.LOWER})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==c?void 0:c.symbol}})})]}),Yn.jsxs(hC,{sx:{width:"48%",py:12,gap:12},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:[Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"body2"},children:Yn.jsx(e,{id:"5etEUX",message:"Max price"})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"caption"},children:rT({price:f,atLimit:r,direction:dC.UPPER})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==h?void 0:h.symbol}})})]})]}),Yn.jsxs(hC,{sx:{py:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(fC,{gap:"4px",justify:"flex-start",children:[Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"body2"},children:Yn.jsx(e,{id:"DWd30U",message:"Current price"})}),Yn.jsx(i,{sx:{color:d.palette.text.secondary,typography:"h6"},children:Yn.jsx(e,{id:"7Z4WfS",message:"{0} per {1}",values:{0:h.symbol,1:c.symbol}})})]}),Yn.jsx(i,{sx:{color:d.palette.text.primary,typography:"caption"},children:`${Am({input:m.toSignificant()})} `})]})]})},lT=({chainId:e,disabled:t,removed:n,isLoading:i,error:o,onConfirm:r})=>Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:e,children:Yn.jsx(c,{fullWidth:!0,size:c.Size.big,onClick:r,disabled:t,isLoading:i,children:n?se._({id:"D87pha",message:"Closed"}):null!=o?o:se._({id:"t/YqKh",message:"Remove"})})}),dT={[XC.LOWEST]:{label:"0.01%"},[XC.LOW_200]:{label:"0.02%"},[XC.LOW_300]:{label:"0.03%"},[XC.LOW_400]:{label:"0.04%"},[XC.LOW]:{label:"0.05%"},[XC.MEDIUM]:{label:"0.30%"},[XC.HIGH]:{label:"1.00%"}},cT=({poolType:e})=>{const t="AMM V2"===e?N.error.main:"AMM V3"===e?N.purple.main:N.success.main;return Yn.jsx(i,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:T(t,.1),color:t,whiteSpace:"nowrap"},children:e})},uT=({isAMMV2:t,isAMMV3:n,lpFeeRate:o,mtFeeRate:r})=>{var a,s;return Yn.jsx(l,{title:Yn.jsx(e,{id:"O6RUgz",message:"Fee rate"}),children:Yn.jsx(i,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:n?null!==(s=null===(a=dT[o])||void 0===a?void 0:a.label)&&void 0!==s?s:"-":Vm({input:new Pe(null!=o?o:0).plus(r?_m(r,t?4:18):0)})})})},pT=({sx:e})=>Yn.jsx(cT,{poolType:"AMM V3"}),hT=({position:t,title:n,inRange:o,baseCurrencyDefault:r,ticksAtLimit:a})=>{var s,l,d;const c=t.pool.token0,u=t.pool.token1,p=(null==t?void 0:t.liquidity)&&wn.equal(null==t?void 0:t.liquidity,wn.BigInt(0));return Yn.jsxs(fC,{gap:"md",style:{marginTop:"0.5rem"},children:[Yn.jsxs(yC,{style:{gap:4},children:[Yn.jsxs(vC,{children:[Yn.jsx(kj,{tokens:[{address:c.address},{address:u.address}],mr:8,chainId:c.chainId}),Yn.jsxs(i,{sx:{typography:"h5"},children:[null==c?void 0:c.symbol," / ",null==u?void 0:u.symbol]})]}),Yn.jsx(pT,{sx:{ml:"auto"}}),Yn.jsx(nT,{removed:p,inRange:o})]}),Yn.jsxs(hC,{children:[Yn.jsxs(fC,{gap:"md",children:[Yn.jsxs(yC,{children:[Yn.jsxs(vC,{children:[Yn.jsx(Df,{address:null!==(s=null==c?void 0:c.address)&&void 0!==s?s:"",chainId:null==c?void 0:c.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),Yn.jsx(i,{sx:{ml:8},children:null==c?void 0:c.symbol})]}),Yn.jsx(vC,{children:Yn.jsx(i,{sx:{mr:8},children:Am({input:t.amount0.toSignificant(),decimals:null==c?void 0:c.decimals})})})]}),Yn.jsxs(yC,{children:[Yn.jsxs(vC,{children:[Yn.jsx(Df,{address:null!==(l=null==u?void 0:u.address)&&void 0!==l?l:"",chainId:null==u?void 0:u.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),Yn.jsx(i,{ml:"8px",children:null==u?void 0:u.symbol})]}),Yn.jsx(vC,{children:Yn.jsx(i,{mr:"8px",children:Am({input:t.amount1.toSignificant(),decimals:null==u?void 0:u.decimals})})})]})]}),Yn.jsxs(yC,{children:[Yn.jsx(i,{children:Yn.jsx(e,{id:"EU3wU4",message:"Fee tier"})}),Yn.jsx(i,{children:Vm({input:(null===(d=null==t?void 0:t.pool)||void 0===d?void 0:d.fee)/1e6})})]})]}),Yn.jsx(sT,{position:t,title:n,baseCurrencyDefault:r,ticksAtLimit:a})]})},mT=({on:e,onClose:t,position:n,outOfRange:o,ticksAtLimit:r,onConfirm:a,loading:s})=>{const{isMobile:l}=Tg();return Yn.jsx(Of,{open:e,onClose:t,modal:!0,title:se._({id:"E6MqGy",message:"Add liquidity"}),height:683,children:Yn.jsxs(i,{sx:{flex:1,px:20,pb:24,display:"flex",flexDirection:"column",justifyContent:"space-between",width:l?void 0:420},children:[Yn.jsx(i,{sx:{pt:0,px:0},children:n?Yn.jsx(hT,{position:n,inRange:!o,ticksAtLimit:r,title:se._({id:"3VUfrF",message:"Selected Range"})}):null}),Yn.jsx(c,{size:c.Size.big,fullWidth:!0,isLoading:s,sx:{mt:20},onClick:a,children:se._({id:"m16xKo",message:"Add"})})]})})};class gT{static getPoolAddress(e,t,n,i,o){this.addresses.length>this.MAX_ENTRIES&&(this.addresses=this.addresses.slice(0,this.MAX_ENTRIES/2));const{address:r}=t,{address:a}=n,s=`${e}:${r}:${a}:${i.toString()}`,l=this.addresses.find((e=>e.key===s));if(l)return l.address;const d={key:s,address:mk({factoryAddress:e,tokenA:t,tokenB:n,fee:i,chainId:o})};return this.addresses.unshift(d),d.address}static getPool(e,t,n,i,o,r){this.pools.length>this.MAX_ENTRIES&&(this.pools=this.pools.slice(0,this.MAX_ENTRIES/2));const a=this.pools.find((a=>a.token0===e&&a.token1===t&&a.fee===n&&wn.EQ(a.sqrtRatioX96,i)&&wn.EQ(a.liquidity,o)&&a.tickCurrent===r));if(a)return a;const s=new Vk(e,t,n,i,o,r);return this.pools.unshift(s),s}}var fT;function xT(e,t,n){const i=$((()=>[[e,t,n]]),[e,t,n]);return function(e,t){const n=$((()=>e?t.map((([e,t,n])=>{if(e&&t&&n){const i=e.wrapped,o=t.wrapped;if(i.equals(o))return;return i.sortsBefore(o)?[i,o,n]:[o,i,n]}})):new Array(t.length)),[e,t]),i=$((()=>{const t=e&&SC[e];return t?n.map((n=>n&&gT.getPoolAddress(t,...n,e))):new Array(n.length)}),[e,n]),{data:o}=tt({queries:i.map((t=>zm.getV3PoolSlot0(e,t))),combine:e=>({data:e.map((e=>e.data))})}),{data:r}=tt({queries:i.map((t=>zm.getV3PoolLiquidity(e,t))),combine:e=>({data:e.map((e=>e.data))})});return $((()=>t.map(((e,t)=>{const i=n[t];if(!i)return[fT.INVALID,null];const[a,s,l]=i;if(!o[t])return[fT.NOT_EXISTS,null];const d=o[t];if(!r[t])return[fT.NOT_EXISTS,null];const c=r[t];if(!d||!c)return[fT.NOT_EXISTS,null];if(!d.sqrtPriceX96||d.sqrtPriceX96.eq(0))return[fT.NOT_EXISTS,null];try{const e=gT.getPool(a,s,l,d.sqrtPriceX96,c[0],d.tick);return[fT.EXISTS,e]}catch(e){return console.error(e,{tags:{file:"usePools",function:"usePools"},extra:{token0:a.address,token1:s.address,chainId:a.chainId,fee:l}}),[fT.NOT_EXISTS,null]}}))),[r,t,o,n])}(null==e?void 0:e.chainId,i)[0]}gT.MAX_ENTRIES=128,gT.pools=[],gT.addresses=[],function(e){e[e.LOADING=0]="LOADING",e[e.NOT_EXISTS=1]="NOT_EXISTS",e[e.EXISTS=2]="EXISTS",e[e.INVALID=3]="INVALID"}(fT||(fT={}));class yT{constructor(e){const t=we[e];this.chainId=e,this.decimals=t.decimals,this.name=t.name,this.symbol=t.symbol,this.isNative=!0,this.isToken=!1,this.address=vT(this.chainId)}equals(e){return e.isNative&&e.chainId===this.chainId}get wrapped(){const e=we[this.chainId];return new WC(this.chainId,e.wrappedTokenAddress,e.decimals,e.wrappedTokenSymbol,e.name)}static onChain(e){var t;return null!==(t=this._cachedNativeCurrency[e])&&void 0!==t?t:this._cachedNativeCurrency[e]=new yT(e)}}function vT(e){return we[e].address}function bT(e,t){const n=null==e?void 0:e.toLowerCase(),i=null==t?void 0:t.toLowerCase();return null!==n&&null!==i&&n===i}yT._cachedNativeCurrency={};const jT=(e,t)=>!t||bT(t,vT(e));function CT(e){if(!e)return;const{name:t,chainId:n,address:i,decimals:o,symbol:r}=e;return function(e,t){return!jT(e,t)}(n,i)?new WC(n,i,o,null!=r?r:void 0,null!=t?t:void 0):new yT(n)}function wT(e){var t,n;if(e)return{chainId:e.chainId,address:e.address,decimals:e.decimals,symbol:null!==(t=e.symbol)&&void 0!==t?t:"",name:null!==(n=e.name)&&void 0!==n?n:""}}function kT(e,t,n){if(e&&t&&"number"==typeof n)return Dk(e,t,n)}function TT(e,t){if(e&&t&&!isNaN(parseFloat(e)))try{const n=Tn(function(e,t){const n=e.split(/[.,]/),i=e.includes(".")?".":",";return n.length>1&&n[1].length>t?n[0]+i+n[1].slice(0,t):e}(e,t.decimals),t.decimals).toString();if("0"!==n)return MC.fromRawAmount(t,wn.BigInt(n))}catch(t){console.error("tryParseCurrencyAmount","tryParseCurrencyAmount",`Failed to parse input amount: "${e}"`,t)}}function IT(e,t,n,i){if(!(e&&t&&n&&i))return;const o=function(e,t,n){var i;if(!e||!t||!n)return;if(!n.match(/^\d*\.?\d+$/))return;const[o,r]=n.split("."),a=null!==(i=null==r?void 0:r.length)&&void 0!==i?i:0,s=wn.BigInt((null!=o?o:"")+(null!=r?r:""));return new FC(e,t,wn.multiply(wn.BigInt(10**a),wn.BigInt(10**e.decimals)),wn.multiply(s,wn.BigInt(10**t.decimals)))}(e,t,i);if(!o)return;let r;const a=Lk(o.numerator,o.denominator);return r=wn.greaterThanOrEqual(a,vk.MAX_SQRT_RATIO)?vk.MAX_TICK:wn.lessThanOrEqual(a,vk.MIN_SQRT_RATIO)?vk.MIN_TICK:Nk(o),Bk(r,JC[n])}function ST({state:e,existingPosition:t,chainId:n}){var i,o,r,a,s,l,d,c,u,p,h,m,g;const{account:f}=dg(),{feeAmount:x,independentField:y,typedValue:v,leftRangeTypedValue:b,rightRangeTypedValue:j,startPriceTypedValue:C}=e,w=null!==(i=e.baseToken)&&void 0!==i?i:void 0,k=null!==(o=e.baseToken)&&void 0!==o?o:void 0,T=null!==(r=e.quoteToken)&&void 0!==r?r:void 0,I=y===lC.CURRENCY_A?lC.CURRENCY_B:lC.CURRENCY_A,S=$((()=>({[lC.CURRENCY_A]:w,[lC.CURRENCY_B]:T})),[w,T]),[E,A,O]=$((()=>[null==w?void 0:w.wrapped,null==T?void 0:T.wrapped,null==k?void 0:k.wrapped]),[w,T,k]),[L,R]=$((()=>E&&A?E.sortsBefore(A)?[E,A]:[A,E]:[void 0,void 0]),[E,A]),P=et(ip.getFetchTokenQuery(null===(a=S[lC.CURRENCY_A])||void 0===a?void 0:a.chainId,null===(s=S[lC.CURRENCY_A])||void 0===s?void 0:s.address,f)),_=et(ip.getFetchTokenQuery(null===(l=S[lC.CURRENCY_B])||void 0===l?void 0:l.chainId,null===(d=S[lC.CURRENCY_B])||void 0===d?void 0:d.address,f)),M=$((()=>{var e,t,n,i,o,r;return{[lC.CURRENCY_A]:S[lC.CURRENCY_A]?(null===(e=P.data)||void 0===e?void 0:e.balance)?MC.fromRawAmount(S[lC.CURRENCY_A],wn.BigInt(null===(t=P.data)||void 0===t?void 0:t.balance.multipliedBy(Math.pow(10,null!==(n=S[lC.CURRENCY_A].decimals)&&void 0!==n?n:18)).toString())):MC.fromRawAmount(S[lC.CURRENCY_A],0):void 0,[lC.CURRENCY_B]:S[lC.CURRENCY_B]?(null===(i=_.data)||void 0===i?void 0:i.balance)?MC.fromRawAmount(S[lC.CURRENCY_B],wn.BigInt(null===(o=_.data)||void 0===o?void 0:o.balance.multipliedBy(Math.pow(10,null!==(r=S[lC.CURRENCY_B].decimals)&&void 0!==r?r:18)).toString())):MC.fromRawAmount(S[lC.CURRENCY_B],0):void 0}}),[S,null===(c=P.data)||void 0===c?void 0:c.balance,null===(u=_.data)||void 0===u?void 0:u.balance]),[B,D]=xT(S[lC.CURRENCY_A],S[lC.CURRENCY_B],x),N=B===fT.NOT_EXISTS,F=Boolean(O&&L&&!O.equals(L)),U=$((()=>{var e;if(!N)return D&&L?D.priceOf(L):void 0;{const t=TT(C,F?L:R);if(t&&L&&R){const n=TT("1",F?R:L),i=n&&t?new FC(n.currency,t.currency,n.quotient,t.quotient):void 0;return null!==(e=F?null==i?void 0:i.invert():i)&&void 0!==e?e:void 0}}}),[N,C,F,R,L,D]),q=$((()=>{const e=U?Lk(U.numerator,U.denominator):void 0;return U&&e&&!(wn.greaterThanOrEqual(e,vk.MIN_SQRT_RATIO)&&wn.lessThan(e,vk.MAX_SQRT_RATIO))}),[U]),V=$((()=>{if(E&&A&&x&&U&&!q){const e=Nk(U),t=vk.getSqrtRatioAtTick(e);return new Vk(E,A,x,t,wn.BigInt(0),e,[])}}),[x,q,U,E,A]),W=null!=D?D:V,H=$((()=>({[dC.LOWER]:x?Bk(vk.MIN_TICK,JC[x]):void 0,[dC.UPPER]:x?Bk(vk.MAX_TICK,JC[x]):void 0})),[x]),Z=$((()=>({[dC.LOWER]:"number"==typeof(null==t?void 0:t.tickLower)?t.tickLower:F&&"boolean"==typeof j||!F&&"boolean"==typeof b?H[dC.LOWER]:F?IT(R,L,x,j.toString()):IT(L,R,x,b.toString()),[dC.UPPER]:"number"==typeof(null==t?void 0:t.tickUpper)?t.tickUpper:!F&&"boolean"==typeof j||F&&"boolean"==typeof b?H[dC.UPPER]:F?IT(R,L,x,b.toString()):IT(L,R,x,j.toString())})),[t,x,F,b,j,H,L,R]),{[dC.LOWER]:G,[dC.UPPER]:Q}=Z||{},Y=$((()=>({[dC.LOWER]:x&&G===H.LOWER,[dC.UPPER]:x&&Q===H.UPPER})),[H,G,Q,x]),K=Boolean("number"==typeof G&&"number"==typeof Q&&G>=Q),X=$((()=>({[dC.LOWER]:kT(L,R,H.LOWER),[dC.UPPER]:kT(L,R,H.UPPER)})),[L,R,H.LOWER,H.UPPER]),J=$((()=>({[dC.LOWER]:kT(L,R,Z[dC.LOWER]),[dC.UPPER]:kT(L,R,Z[dC.UPPER])})),[L,R,Z]),{[dC.LOWER]:ee,[dC.UPPER]:te}=J,ne=Boolean(!K&&U&&ee&&te&&(U.lessThan(ee)||U.greaterThan(te))),ie=TT(v,S[y]),oe=$((()=>{const e=null==ie?void 0:ie.wrapped,t=I===lC.CURRENCY_B?T:w;if(ie&&e&&"number"==typeof G&&"number"==typeof Q&&W){if(ne||K)return;const n=e.currency.equals(W.token0)?Wk.fromAmount0({pool:W,tickLower:G,tickUpper:Q,amount0:ie.quotient,useFullPrecision:!0}):Wk.fromAmount1({pool:W,tickLower:G,tickUpper:Q,amount1:ie.quotient}),i=e.currency.equals(W.token0)?n.amount1:n.amount0;return t&&MC.fromRawAmount(t,i.quotient)}}),[ie,ne,I,T,w,G,Q,W,K]),re=$((()=>({[lC.CURRENCY_A]:y===lC.CURRENCY_A?ie:oe,[lC.CURRENCY_B]:y===lC.CURRENCY_A?oe:ie})),[oe,ie,y]),ae=Boolean("number"==typeof Q&&W&&W.tickCurrent>=Q),le=Boolean("number"==typeof G&&W&&W.tickCurrent<=G),de=K||Boolean(ae&&W&&E&&W.token0.equals(E)||le&&W&&E&&W.token1.equals(E)),ce=K||Boolean(ae&&W&&A&&W.token0.equals(A)||le&&W&&A&&W.token1.equals(A)),{inputTax:ue,outputTax:pe}=function(e,t,n){const[{inputTax:i,outputTax:o},r]=z({inputTax:YC,outputTax:YC});return{inputTax:i,outputTax:o}}((null==w?void 0:w.isToken)&&w.address,(null==T?void 0:T.isToken)&&T.address),he=$((()=>{var e,t;if(!W||!E||!A||"number"!=typeof G||"number"!=typeof Q||K)return;const n=ae?GC:null===(e=null==re?void 0:re[E.equals(W.token0)?lC.CURRENCY_A:lC.CURRENCY_B])||void 0===e?void 0:e.quotient,i=le?GC:null===(t=null==re?void 0:re[E.equals(W.token0)?lC.CURRENCY_B:lC.CURRENCY_A])||void 0===t?void 0:t.quotient;return void 0!==n&&void 0!==i?Wk.fromAmounts({pool:W,tickLower:G,tickUpper:Q,amount0:n,amount1:i,useFullPrecision:!0}):void 0}),[re,W,E,A,ae,le,K,G,Q]);let me;f||(me=se._({id:"r7ScnQ",message:"Connect to a wallet"})),B===fT.INVALID&&(me=null!=me?me:se._({id:"R7D79P",message:"Invalid pair"})),q&&(me=null!=me?me:se._({id:"HXBqgG",message:"Invalid price input"})),(re[lC.CURRENCY_A]||de)&&(re[lC.CURRENCY_B]||ce)||(me=null!=me?me:se._({id:"iPMIoT",message:"Enter an amount"}));const{[lC.CURRENCY_A]:ge,[lC.CURRENCY_B]:fe}=re;ge&&(null===(p=null==M?void 0:M[lC.CURRENCY_A])||void 0===p?void 0:p.lessThan(ge))&&(me=se._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(h=S[lC.CURRENCY_A])||void 0===h?void 0:h.symbol}})),fe&&(null===(m=null==M?void 0:M[lC.CURRENCY_B])||void 0===m?void 0:m.lessThan(fe))&&(me=se._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(g=S[lC.CURRENCY_B])||void 0===g?void 0:g.symbol}}));const xe=ue.greaterThan(0)||pe.greaterThan(0),ye=B===fT.INVALID||xe;return{dependentField:I,currencies:S,pool:D,poolState:B,currencyBalances:M,parsedAmounts:re,ticks:Z,price:U,pricesAtTicks:J,pricesAtLimit:X,position:he,noLiquidity:N,errorMessage:me,invalidPool:ye,invalidRange:K,outOfRange:ne,depositADisabled:de,depositBDisabled:ce,invertPrice:F,ticksAtLimit:Y,isTaxed:xe}}var ET;function AT(e,t){switch(t.type){case ET.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:CT(n)})}case ET.UpdateDefaultBaseToken:{const n=t.payload;return e.baseToken?e:Object.assign(Object.assign({},e),{baseToken:CT(n)})}case ET.UpdateQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{quoteToken:CT(n)})}case ET.UpdateDefaultQuoteToken:{const n=t.payload;return e.quoteToken?e:Object.assign(Object.assign({},e),{quoteToken:CT(n)})}case ET.UpdateBaseTokenAndClearQuoteToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:CT(n),quoteToken:null})}case ET.UpdateFeeAmount:return Object.assign(Object.assign({},e),{feeAmount:t.payload});case ET.ToggleRate:{const{baseToken:t,quoteToken:n}=e;return Object.assign(Object.assign({},e),{baseToken:n,quoteToken:t})}case ET.setFullRange:return Object.assign(Object.assign({},e),{leftRangeTypedValue:!0,rightRangeTypedValue:!0});case ET.typeStartPriceInput:return Object.assign(Object.assign({},e),{startPriceTypedValue:t.payload.typedValue});case ET.typeLeftRangeInput:return Object.assign(Object.assign({},e),{leftRangeTypedValue:t.payload.typedValue});case ET.typeRightRangeInput:return Object.assign(Object.assign({},e),{rightRangeTypedValue:t.payload.typedValue});case ET.typeInput:{const{payload:{field:n,typedValue:i,noLiquidity:o}}=t;return o?(e.independentField,Object.assign(Object.assign({},e),{independentField:n,typedValue:i})):Object.assign(Object.assign({},e),{independentField:n,typedValue:i})}default:throw Error("Unknown action: "+t.type)}}function OT({noLiquidity:e,dispatch:t}){return{onFieldAInput:Z((n=>{t({type:ET.typeInput,payload:{field:lC.CURRENCY_A,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onFieldBInput:Z((n=>{t({type:ET.typeInput,payload:{field:lC.CURRENCY_B,typedValue:n,noLiquidity:!0===e}})}),[t,e]),onLeftRangeInput:Z((e=>{t({type:ET.typeLeftRangeInput,payload:{typedValue:e}})}),[t]),onRightRangeInput:Z((e=>{t({type:ET.typeRightRangeInput,payload:{typedValue:e}})}),[t]),onStartPriceInput:Z((e=>{t({type:ET.typeStartPriceInput,payload:{typedValue:e}})}),[t])}}function LT(e){return e?EC[e]:void 0}function RT(e,t){const n=LT(t),i=$((()=>e?e.map((e=>[e])):[]),[e]),o=et(zm.getPositions(t,n,i)),r=o.isLoading,a=o.error,s=$((()=>{var t;if(!r&&!a&&e)return null===(t=o.data)||void 0===t?void 0:t.map(((t,n)=>({tokenId:e[n],fee:t.fee,feeGrowthInside0LastX128:t.feeGrowthInside0LastX128.toString(),feeGrowthInside1LastX128:t.feeGrowthInside1LastX128.toString(),liquidity:t.liquidity.toString(),nonce:t.nonce.toString(),operator:t.operator,tickLower:t.tickLower,tickUpper:t.tickUpper,token0:t.token0,token1:t.token1,tokensOwed0:t.tokensOwed0.toString(),tokensOwed1:t.tokensOwed1.toString()})))}),[r,a,o,e]);return{loading:r,positions:null==s?void 0:s.map(((e,t)=>Object.assign(Object.assign({},e),{tokenId:i[t][0]})))}}!function(e){e[e.UpdateBaseToken=0]="UpdateBaseToken",e[e.UpdateDefaultBaseToken=1]="UpdateDefaultBaseToken",e[e.UpdateQuoteToken=2]="UpdateQuoteToken",e[e.UpdateDefaultQuoteToken=3]="UpdateDefaultQuoteToken",e[e.UpdateBaseTokenAndClearQuoteToken=4]="UpdateBaseTokenAndClearQuoteToken",e[e.UpdateFeeAmount=5]="UpdateFeeAmount",e[e.ToggleRate=6]="ToggleRate",e[e.setFullRange=7]="setFullRange",e[e.typeStartPriceInput=8]="typeStartPriceInput",e[e.typeLeftRangeInput=9]="typeLeftRangeInput",e[e.typeRightRangeInput=10]="typeRightRangeInput",e[e.typeInput=11]="typeInput"}(ET||(ET={}));const PT=wn.exponentiate(wn.BigInt(10),wn.BigInt(16));function _T(e){if(e)return e.currency.isNative?wn.greaterThan(e.quotient,PT)?MC.fromRawAmount(e.currency,wn.subtract(e.quotient,PT)):MC.fromRawAmount(e.currency,wn.BigInt(0)):e}const MT=1e4,BT=100*MT;function DT(e){const t=Math.floor(Number(e)*MT);return new NC(t,BT)}const NT=({token:e,amount:t})=>{var n;const o=a();return Yn.jsxs(i,{sx:{py:8,display:"flex",alignItems:"center",gap:6,typography:"h5",color:o.palette.text.primary},children:[Yn.jsx(Df,{address:null!==(n=null==e?void 0:e.address)&&void 0!==n?n:"",chainId:null==e?void 0:e.chainId,noShowChain:!0,width:24,height:24,marginRight:0}),Yn.jsx(i,{children:null==e?void 0:e.symbol}),Yn.jsx(i,{sx:{ml:"auto"},children:Am({input:null==t?void 0:t.toSignificant(),decimals:null==e?void 0:e.decimals})})]})},FT=({chainId:e,baseToken:t,quoteToken:n,feeAmount:o,tokenId:r,onClose:s})=>{var l,d;const{isMobile:c}=Tg(),u=a(),p=Fg(),h=nt(),{account:m}=dg(),{position:g,loading:f}=function(e,t){var n;const i=RT(e?[e]:void 0,t);return{loading:i.loading,position:null===(n=i.positions)||void 0===n?void 0:n[0]}}(r,e),x=!!g&&!f,{position:y}=function(e,t,n){const i=$((()=>t?CT(t):void 0),[t]),o=$((()=>n?CT(n):void 0),[n]),[,r]=xT(null!=i?i:void 0,null!=o?o:void 0,null==e?void 0:e.fee);let a;return r&&e&&(a=new Wk({pool:r,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})),{position:a,pool:null!=r?r:void 0}}(g,t,n),[v,b]=z("stake"),[j,C]=z(!1),[w,k]=z(aC),[T,I]=ee(AT,{baseToken:CT(t),quoteToken:CT(n),feeAmount:o,independentField:lC.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""}),{independentField:E,typedValue:A,startPriceTypedValue:L}=T,{pool:R,ticks:P,dependentField:_,price:M,pricesAtTicks:B,pricesAtLimit:D,parsedAmounts:N,currencyBalances:U,position:q,noLiquidity:V,currencies:W,errorMessage:H,invalidPool:Z,invalidRange:G,outOfRange:Q,depositADisabled:Y,depositBDisabled:K,invertPrice:X,ticksAtLimit:J,isTaxed:te}=ST({state:T,existingPosition:y,chainId:e}),{position:ne,liquidityPercentage:ie,liquidityValue0:oe,liquidityValue1:re,feeValue0:ae,feeValue1:le,error:de}=function({percent:e,position:t,asWETH:n,baseToken:i,quoteToken:o}){const{account:r}=dg(),[a,s]=$((()=>[null==i?void 0:i.wrapped,null==o?void 0:o.wrapped]),[i,o]),[l,d]=$((()=>a&&s?a.sortsBefore(s)?[a,s]:[s,a]:[void 0,void 0]),[a,s]),[,c]=xT(null!=l?l:void 0,null!=d?d:void 0,null==t?void 0:t.fee),u=$((()=>c&&(null==t?void 0:t.liquidity)&&"number"==typeof(null==t?void 0:t.tickLower)&&"number"==typeof(null==t?void 0:t.tickUpper)?new Wk({pool:c,liquidity:t.liquidity.toString(),tickLower:t.tickLower,tickUpper:t.tickUpper}):void 0),[c,t]),p=new NC(e,100),h=u?p.multiply(u.amount0.quotient).quotient:void 0,m=u?p.multiply(u.amount1.quotient).quotient:void 0,g=l&&h?MC.fromRawAmount(l,h):void 0,f=d&&m?MC.fromRawAmount(d,m):void 0,x=!(!c||!t)&&(c.tickCurrent<t.tickLower||c.tickCurrent>t.tickUpper);let y;return r||(y=se._({id:"r7ScnQ",message:"Connect to a wallet"})),0===e&&(y=null!=y?y:se._({id:"Sta9CR",message:"Enter a percent"})),{position:u,liquidityPercentage:p,liquidityValue0:g,liquidityValue1:f,feeValue0:void 0,feeValue1:void 0,outOfRange:x,error:y}}({position:g,asWETH:void 0,percent:w,baseToken:T.baseToken,quoteToken:T.quoteToken}),ce="0"===(null==g?void 0:g.liquidity),[ue,pe]=function({chainId:e,pool:t,tokenId:n,asWETH:i}){var o;const r=LT(e),a=null===(o=$t.from(n))||void 0===o?void 0:o.toHexString(),s=et(zm.getOwner(e,r,n)),l=et(zm.getCollect(e,r,a,s.data&&Array.isArray(s.data)?s.data[0]:void 0));return t&&l&&l.data&&l.data.amount0&&l.data.amount1?[MC.fromRawAmount(t.token0,l.data.amount0.toString()),MC.fromRawAmount(t.token1,l.data.amount1.toString())]:[void 0,void 0]}({pool:null!=R?R:void 0,tokenId:r,asWETH:!1,chainId:e}),he=pe,me=ue;$((()=>{var e;return null===(e=X?null==M?void 0:M.invert():M)||void 0===e?void 0:e.toSignificant()}),[X,M]);const{onFieldAInput:ge,onFieldBInput:fe,onLeftRangeInput:xe,onRightRangeInput:ye,onStartPriceInput:ve}=OT({noLiquidity:V,dispatch:I}),{slipper:be,setSlipper:je,slipperValue:Ce,resetSlipper:we}=oC({address:void 0,type:"AMMV3"}),Te=!H&&!G,Ie=$((()=>{var e,t;return{[E]:A,[_]:null!==(t=null===(e=N[_])||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""}}),[_,E,N,A]),Se=$((()=>[lC.CURRENCY_A,lC.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:_T(U[t])})),{})),[U]),Ee=lf(wT(null===(l=N[lC.CURRENCY_A])||void 0===l?void 0:l.currency),{contractAddress:EC[e],overrideBalance:U[lC.CURRENCY_A]?new Pe(U[lC.CURRENCY_A].toSignificant()):void 0,amount:N[lC.CURRENCY_A]?new Pe(N[lC.CURRENCY_A].toSignificant()):void 0}),Ae=lf(wT(null===(d=N[lC.CURRENCY_B])||void 0===d?void 0:d.currency),{contractAddress:EC[e],overrideBalance:U[lC.CURRENCY_B]?new Pe(U[lC.CURRENCY_B].toSignificant()):void 0,amount:N[lC.CURRENCY_B]?new Pe(N[lC.CURRENCY_B].toSignificant()):void 0}),{[dC.LOWER]:Oe,[dC.UPPER]:Le}=P,{[dC.LOWER]:Re,[dC.UPPER]:_e}=B,{deadLine:Me}=Jn(),Be=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(!m||!e||!q)return;if(!T.baseToken||!T.quoteToken)return;const t=Math.ceil(Date.now()/1e3)+(null!=Me?Me:600),n=T.baseToken.isNative?T.baseToken:T.quoteToken.isNative?T.quoteToken:void 0;try{const{calldata:i,value:o}=eT.addCallParameters(q,{tokenId:r,slippageTolerance:DT(100*Ce),deadline:t.toString(),useNative:n});let a={to:EC[e],data:i,value:o};(yield p.execute(se._({id:"OBdohg",message:"Add Liquidity"}),Object.assign({opcode:Pg.TX},a),{early:!1,metadata:{[Sg.addAMMV3Pool]:"1"}}))===Eg.Success&&(C(!1),setTimeout((()=>{null==s||s()}),100)),h.invalidateQueries({queryKey:[ke,"ammv3"],refetchType:"all"})}catch(e){console.error("onAddMutation",e)}}))}),De=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(!(m&&e&&ne&&ie&&oe&&re))return;const t=Math.ceil(Date.now()/1e3)+(null!=Me?Me:600);try{const{calldata:n,value:i}=eT.removeCallParameters(ne,{tokenId:r.toString(),liquidityPercentage:ie,slippageTolerance:DT(100*Ce),deadline:t.toString(),collectOptions:{expectedCurrencyOwed0:null!=ae?ae:MC.fromRawAmount(oe.currency,0),expectedCurrencyOwed1:null!=le?le:MC.fromRawAmount(re.currency,0),recipient:m}});let o={to:EC[e],data:n,value:i};(yield p.execute(se._({id:"3XBvkd",message:"Remove Liquidity"}),Object.assign({opcode:Pg.TX},o),{early:!1,metadata:{[Sg.removeAMMV3Pool]:"1"}}))===Eg.Success&&setTimeout((()=>{null==s||s()}),100),h.invalidateQueries({queryKey:[ke,"ammv3"],refetchType:"all"})}catch(e){console.error("onRemoveMutation",e)}}))}),Ne=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(m&&e&&R)try{const{calldata:t,value:n}=eT.collectCallParameters({tokenId:r.toString(),expectedCurrencyOwed0:null!=ue?ue:MC.fromRawAmount(R.token0,0),expectedCurrencyOwed1:null!=pe?pe:MC.fromRawAmount(R.token1,0),recipient:m});let i={to:EC[e],data:t,value:n};(yield p.execute(se._({id:"zXCpR0",message:"Claim Rewards"}),Object.assign({opcode:Pg.TX},i),{early:!1,metadata:{[Sg.claimAMMV3Pool]:"1"}}))===Eg.Success&&setTimeout((()=>{null==s||s()}),100),h.invalidateQueries({queryKey:[ke,"ammv3"],refetchType:"all"})}catch(e){console.error("onClaimMutation",e)}}))}),Fe=$((()=>{var t,n,o,r;const a=[{key:"stake",value:se._({id:"m16xKo",message:"Add"})},{key:"unstake",value:se._({id:"t/YqKh",message:"Remove"})},{key:"claim",value:se._({id:"hom7qf",message:"Claim"})}];return Yn.jsxs(i,{sx:{borderRadius:16,backgroundColor:u.palette.background.paper},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:u.palette.background.paper},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:se._({id:"E6MqGy",message:"Add liquidity"})}),s?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16},onClick:()=>{s()}})}):void 0]}),x&&y&&Yn.jsx(i,{sx:{mx:20,mb:16},children:Yn.jsx(oT,{position:y,inRange:!Q})}),Yn.jsxs(S,{value:v,onChange:(e,t)=>{b(t)},children:[Yn.jsx(F,{tabs:a,variant:"inPaper",tabsListSx:{mx:20}}),Yn.jsxs(O,{value:"stake",children:[x&&y&&Yn.jsx(i,{sx:{mt:16,mx:20},children:Yn.jsx(sT,{position:y,title:se._({id:"3VUfrF",message:"Selected Range"}),ticksAtLimit:J})}),Yn.jsxs(i,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.secondary,textAlign:"left"},children:se._({id:"BRi+RY",message:"Add more liquidity"})}),Yn.jsxs(i,{children:[Yn.jsx(IC,{value:Ie[lC.CURRENCY_A],onUserInput:ge,maxAmount:Se[lC.CURRENCY_A],balance:U[lC.CURRENCY_A],currency:null!==(t=W[lC.CURRENCY_A])&&void 0!==t?t:null,locked:Y}),Yn.jsx(uj,{}),Yn.jsx(IC,{value:Ie[lC.CURRENCY_B],onUserInput:fe,maxAmount:Se[lC.CURRENCY_B],balance:U[lC.CURRENCY_B],currency:null!==(n=W[lC.CURRENCY_B])&&void 0!==n?n:null,locked:K})]}),Yn.jsx(rC,{value:be,onChange:je,disabled:!1,type:"AMMV3"})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:u.palette.background.paper},children:Yn.jsx(jC,{chainId:e,approvalA:Ee,approvalB:Ae,parsedAmounts:N,isValid:Te,depositADisabled:Y,depositBDisabled:K,errorMessage:H,setShowConfirm:C})}),Yn.jsx(mT,{parsedAmounts:N,position:q,existingPosition:void 0,priceLower:Re,priceUpper:_e,outOfRange:Q,ticksAtLimit:J,on:j,onClose:()=>{C(!1)},onConfirm:Be.mutate,loading:Be.isPending})]}),Yn.jsxs(O,{value:"unstake",children:[Yn.jsxs(i,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[Yn.jsx(Kj,{disabled:!1,value:w,onChange:e=>k(e)}),Yn.jsx(rC,{value:be,onChange:je,disabled:!1,type:"AMMV3"})]}),Yn.jsxs(i,{sx:{mt:16,mx:20,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{typography:"body2",color:u.palette.text.secondary},children:"Receive"}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:[Yn.jsx(i,{component:"span",sx:{color:u.palette.primary.main},children:oe?Am({input:oe.toExact(),decimals:oe.currency.decimals}):"-"})," ",null===(o=null==oe?void 0:oe.currency)||void 0===o?void 0:o.symbol]}),Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:u.palette.text.primary},children:[Yn.jsx(i,{component:"span",sx:{color:u.palette.primary.main},children:re?Am({input:re.toExact(),decimals:re.currency.decimals}):"-"})," ",null===(r=null==re?void 0:re.currency)||void 0===r?void 0:r.symbol]})]})]}),Yn.jsx(i,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:u.palette.background.paper},children:Yn.jsx(lT,{chainId:e,disabled:ce||0===w||!oe,removed:ce,error:de,onConfirm:De.mutate,isLoading:De.isPending})})]}),Yn.jsxs(O,{value:"claim",children:[Yn.jsxs(i,{sx:{mx:20,mt:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:u.palette.border.main},children:[Yn.jsx(i,{sx:{py:12,px:20,typography:"body1",color:u.palette.text.primary,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:u.palette.border.main},children:se._({id:"tu/fxg",message:"Claim fees"})}),Yn.jsxs(i,{sx:{p:20},children:[Yn.jsx(NT,{token:null==he?void 0:he.currency,amount:he}),Yn.jsx(NT,{token:null==me?void 0:me.currency,amount:me})]})]}),Yn.jsx(i,{sx:{mx:20,mt:16,typography:"h6",color:u.palette.text.secondary},children:se._({id:"Joa5Dk",message:"*Collecting fees will withdraw currently available fees for you."})}),Yn.jsx(i,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:u.palette.background.paper},children:Yn.jsx(CC,{chainId:e,disabled:Ne.isPending,onConfirm:Ne.mutate,isLoading:Ne.isPending})})]})]})]})}),[Ee,Ae,e,W,U,Y,K,de,H,y,me,he,Ie,x,Te,oe,re,Se,Be.isPending,Be.mutate,Ne.isPending,Ne.mutate,s,ge,fe,De.isPending,De.mutate,v,Q,N,q,Re,_e,ce,je,j,w,be,u.palette.background.paper,u.palette.border.main,u.palette.primary.main,u.palette.text.primary,u.palette.text.secondary,J]);return c?Yn.jsx(Of,{open:null!=t&&null!=n,onClose:s,scope:!c,modal:c,id:"pool-operate",children:Fe}):Fe};const UT=({outOfRange:e})=>{const t=a();return Yn.jsx(l,{title:e?se._({id:"i3Z+/Z",message:"Out of range"}):se._({id:"vOyUlD",message:"In range"}),children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:e?Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.583252 12.5416L6.99992 1.45825L13.4166 12.5416H0.583252ZM11.3924 11.3749L6.9999 3.78575L2.6074 11.3749H11.3924ZM7.58328 9.62492H6.41661V10.7916H7.58328V9.62492ZM6.41661 6.12492H7.58328V8.45825H6.41661V6.12492Z",fill:t.palette.warning.main})}):Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:Yn.jsx("circle",{cx:"4",cy:"4",r:"4",fill:t.palette.success.main})})})})},qT=({p:e,currency0:t,currency1:n,onClickManage:o})=>{const r=a(),[,s]=xT(null!=t?t:void 0,null!=n?n:void 0,e.fee),l=$((()=>{if(s)return new Wk({pool:s,liquidity:e.liquidity.toString(),tickLower:e.tickLower,tickUpper:e.tickUpper})}),[e.liquidity,e.tickLower,e.tickUpper,s]),d=(u=e.fee,p=e.tickLower,h=e.tickUpper,$((()=>({[dC.LOWER]:u&&p?p===Bk(vk.MIN_TICK,JC[u]):void 0,[dC.UPPER]:u&&h?h===Bk(vk.MAX_TICK,JC[u]):void 0})),[u,p,h]));var u,p,h;const m=null==l?void 0:l.token0PriceLower,g=null==l?void 0:l.token0PriceUpper,f=null==l?void 0:l.amount1.currency,x=null==l?void 0:l.amount0.currency,y=!!s&&(s.tickCurrent<e.tickLower||s.tickCurrent>=e.tickUpper),v=t==t?null==l?void 0:l.pool.priceOf(null==l?void 0:l.pool.token0):null==l?void 0:l.pool.priceOf(null==l?void 0:l.pool.token1);return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,px:20,py:20,pb:12,borderRadius:12,backgroundColor:r.palette.background.paperContrast},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h5",color:r.palette.text.primary},children:[Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:m,atLimit:d,direction:dC.LOWER})," "]}),null==f?void 0:f.symbol]})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:g,atLimit:d,direction:dC.UPPER})," "]}),null==f?void 0:f.symbol]})})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(UT,{outOfRange:y}),Yn.jsxs(i,{sx:{typography:"h6",color:r.palette.text.secondary},children:[se._({id:"DWd30U",message:"Current price"}),": ",`${Am({input:null==v?void 0:v.toSignificant()})}`," ",null==f?void 0:f.symbol," per ",null==x?void 0:x.symbol]})]})]}),Yn.jsx(c,{variant:c.Variant.outlined,size:c.Size.small,fullWidth:!0,onClick:o,children:se._({id:"wckWOP",message:"Manage"})})]})},VT=({chainId:e,baseToken:t,quoteToken:n,feeAmount:o,onClose:r,handleGoToAddLiquidityV3:s})=>{const{isMobile:l}=Tg(),d=a(),{account:u}=dg(),{positions:p,loading:h}=function(e,t){const n=LT(t),{isLoading:i,data:o}=et(zm.getBalanceOf(t,n,null!=e?e:void 0)),r=$((()=>{if(e&&o&&o.isFinite()){const t=[];for(let n=0;n<o.toNumber();n++)t.push([e,n]);return t}return[]}),[e,o]),a=et(zm.getTokenOfOwnerByIndex(t,n,r)),s=a.isLoading,l=$((()=>e&&a.data?a.data.map((e=>{if(Array.isArray(e)&&e.length>0)return e[0].toString()})):[]),[e,a]),{positions:d,loading:c}=RT(l,t);return{loading:s||i||c,positions:d}}(u,e),m=$((()=>t?CT(t):void 0),[t]),g=$((()=>n?CT(n):void 0),[n]),[f,x]=$((()=>[null==m?void 0:m.wrapped,null==g?void 0:g.wrapped]),[m,g]),[y,v]=$((()=>f&&x?f.sortsBefore(x)?[f,x]:[x,f]:[void 0,void 0]),[f,x]),b=$((()=>{if(void 0!==p)return p.filter((e=>bT(null==y?void 0:y.address,e.token0)&&bT(null==v?void 0:v.address,e.token1)&&e.fee===o))}),[o,p,null==y?void 0:y.address,null==v?void 0:v.address]),[j,C]=z(null),w=$((()=>{var e;return Yn.jsxs(i,{sx:{p:20,display:"flex",flexDirection:"column",gap:16,borderRadius:16,backgroundColor:d.palette.background.paper,minHeight:480},children:[Yn.jsxs(i,{sx:{pb:16,borderBottomColor:d.palette.border.main,borderBottomStyle:"solid",borderBottomWidth:1,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:d.palette.text.primary},children:[se._({id:"Gs02OK",message:"My Positions"})," (",null!==(e=null==b?void 0:b.length)&&void 0!==e?e:0,")"]}),r?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16},onClick:()=>{r()}})}):void 0]}),b&&b.length>0?Yn.jsxs(Yn.Fragment,{children:[null==b?void 0:b.map((e=>Yn.jsx(qT,{p:e,currency0:m,currency1:g,onClickManage:()=>{C(e)}},e.tokenId))),Yn.jsxs(c,{size:c.Size.big,variant:c.Variant.second,onClick:()=>{s({from:t.address,to:n.address,fee:String(o)})},sx:{gap:8},children:[Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:Yn.jsx("path",{d:"M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z",fill:"currentColor"})}),se._({id:"FQ4aT9",message:"Add Position"})]})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{mt:100,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[Yn.jsx(ei,{sx:{width:60,height:60,borderRadius:24/105*60}}),Yn.jsx(i,{sx:{typography:"body1",color:d.palette.text.secondary},children:se._({id:"/6L4mj",message:"Your position is empty"})})]}),Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:void 0!==b&&0===b.length?Yn.jsx(c,{size:c.Size.small,onClick:()=>{s({from:t.address,to:n.address,fee:String(o)})},children:se._({id:"FQ4aT9",message:"Add Position"})}):Yn.jsx(cC,{size:c.Size.small})})]})]})}),[d.palette.background.paper,d.palette.border.main,d.palette.text.primary,d.palette.text.secondary,b,r,m,g,s,t.address,n.address,o]);return null!==j?Yn.jsx(FT,{baseToken:t,quoteToken:n,feeAmount:o,tokenId:j.tokenId,chainId:e,onClose:()=>{C(null)}}):l?Yn.jsx(Of,{open:null!=t&&null!=n,onClose:r,scope:!l,modal:l,id:"pool-operate",children:w}):w};function WT({children:e,sx:t,gap:n=20,repeatBaseForLargeScreen:o=3}){const{isMobile:r,minDevice:a}=Tg();let s={};if(r)s={display:"flex",flexDirection:"column",gap:n};else{let e=2;[1418,1761,2104].some(((t,n)=>{if(a(t))return e=o+n,!0})),s={display:"grid",gap:n,gridTemplateColumns:`repeat(${e}, 1fr)`}}return Yn.jsx(i,{sx:Object.assign(Object.assign({},s),t),children:e})}function HT({text:e,onClick:t}){const n=a();return Yn.jsxs(i,{sx:{typography:"body2",display:"inline-flex",alignItems:"center",p:n.spacing(0,4,0,8),width:"max-content",height:32,backgroundColor:"hover.default",color:"primary.main",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:t,children:[e,Yn.jsx(i,{component:li.ArrowBack,sx:{ml:2,width:16,height:16,transform:"rotate(180deg)"}})]})}function $T({tags:e,onDeleteTag:t,sx:n}){return e.length?Yn.jsx(i,{sx:Object.assign({display:"inline-flex",alignItems:"center"},n),children:e.map((e=>Yn.jsxs(i,{sx:{typography:"body2",display:"flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},children:[Yn.jsx(Df,{address:e.address,width:20,height:20,chainId:e.chainId,url:e.logoURI,noShowChain:!0,marginRight:8}),e.symbol,Yn.jsx(i,{component:li.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t(e)})]},e.address)))}):null}function zT({chainId:e,address:t,type:n=Zj.PoolDetail}){const{isMobile:o}=Tg();return Yn.jsx(i,{component:"button",onClick:i=>{i.stopPropagation(),Gj.getState().push({type:n,params:{chainId:e,address:t}})},sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,cursor:"pointer",flexShrink:0,color:"text.primary","&:hover":{opacity:.5}},o?{width:64,height:36,backgroundColor:"background.tag"}:{width:40,height:32,backgroundColor:"transparent",borderWidth:1,borderStyle:"solid",borderColor:"border.main"}),children:Yn.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.83333 14.1667H7.5V8.33333H5.83333V14.1667ZM9.16667 14.1667H10.8333V5.83333H9.16667V14.1667ZM12.5 14.1667H14.1667V10.8333H12.5V14.1667ZM4.16667 17.5C3.70833 17.5 3.31597 17.3368 2.98958 17.0104C2.66319 16.684 2.5 16.2917 2.5 15.8333V4.16667C2.5 3.70833 2.66319 3.31597 2.98958 2.98958C3.31597 2.66319 3.70833 2.5 4.16667 2.5H15.8333C16.2917 2.5 16.684 2.66319 17.0104 2.98958C17.3368 3.31597 17.5 3.70833 17.5 4.16667V15.8333C17.5 16.2917 17.3368 16.684 17.0104 17.0104C16.684 17.3368 16.2917 17.5 15.8333 17.5H4.16667ZM4.16667 15.8333H15.8333V4.16667H4.16667V15.8333Z",fill:"currentColor"})})})}function ZT(t){var{sx:n,children:o,empty:r,loading:s,hasMore:l,loadMore:c,loadMoreLoading:u}=t,p=qn(t,["sx","children","empty","loading","hasMore","loadMore","loadMoreLoading"]);const h=a();return Yn.jsxs(i,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto",borderRadius:16},n),...p,children:[Yn.jsx(i,{component:"table",sx:Object.assign({width:"100%",borderCollapse:"collapse","& th":{px:24,py:12,typography:"h6",lineHeight:"20px",textAlign:"left",color:"text.secondary"},"& td":{px:24,py:12,backgroundColor:"background.paper"},"& thead":{position:"sticky",top:0,zIndex:2,backgroundColor:"background.tag"},"& tbody tr":{borderWidth:"1px 0px 1px 0px",borderStyle:"solid",borderColor:"border.main"}},!r&&!s&&{"& th:last-child, & td:last-child":{position:"sticky",right:0,zIndex:1,"&::before":{content:'""',position:"absolute",top:0,bottom:0,left:1,width:"1px",boxShadow:`${"dark"===h.palette.mode?"#1A1A1B":T("#1A1A1B",.1)} -2px 0px 4px 0px`}}}),children:o}),l&&Yn.jsx(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:c,children:u?Yn.jsx(L,{}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})})]})}function GT({sx:t}){const{supportAMMV2:n,supportAMMV3:o}=Jn(),r=n||o;return Yn.jsxs(i,{sx:Object.assign({px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},t),children:[Yn.jsx(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(kj,{width:24,tokens:[],mr:6,showChainLogo:!0}),Yn.jsx(j,{variant:"rounded",height:20,width:88})]})}),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[r&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:Yn.jsx(j,{variant:"rounded",height:24,width:100})}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})})]}),Yn.jsxs(i,{children:[Yn.jsx(j,{variant:"rounded",height:24,width:100}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]}),Yn.jsxs(i,{children:[Yn.jsx(j,{variant:"rounded",height:24,width:100}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),r&&Yn.jsxs(i,{children:[Yn.jsx(j,{variant:"rounded",height:24,width:100}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"Q8W3SC",message:"Volume (1D)"})})]})]}),Yn.jsx(j,{variant:"rounded",height:32,sx:{mt:20}})]})}function QT({sx:t,value:n,onChange:o,searchAddress:r}){const[a,s]=H.useState(!1),{isMobile:l}=Tg();return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:Object.assign(Object.assign({typography:"body2",display:"flex",alignItems:"center",justifyContent:"flex-start",px:12,height:32,backgroundColor:"background.tag",color:"text.secondary",borderRadius:8,fontWeight:600},l?{width:"100%"}:{minWidth:220}),t),onClick:()=>s(!0),children:[Yn.jsx(i,{component:li.Search,sx:{width:16,height:16,mr:8,flexShrink:0}}),Yn.jsx(e,{id:"A1taO8",message:"Search"})]}),Yn.jsx(Xb,{value:n,open:a,multiple:!0,title:Yn.jsx(e,{id:"o8aMNm",message:"Select a liquidity pool"}),searchPlaceholder:se._({id:"4nzwq3",message:"Search by token or pool address"}),onClose:()=>{s(!1)},onTokenChange:e=>{if(Array.isArray(e)){if(e.length>2){const t=[e[0],e[2]];o(t)}else o(e);s(!1)}},searchOtherAddress:e=>r(e,(()=>s(!1))),modal:!0})]})}var YT;function KT({apy:e,dailyApy:t,weeklyApy:n,sx:o}){const r=a();return Yn.jsx(l,{title:Yn.jsxs(i,{sx:{maxWidth:216,typography:"h6",fontWeight:500,color:"text.secondary"},children:[Yn.jsx(i,{sx:{fontWeight:700},children:"Base vAPY (annualized)"}),Yn.jsxs(i,{component:"ul",sx:{pl:16,my:0,listStyleType:"disc"},children:[Yn.jsxs("li",{children:["Daily: ",Vm({input:t,showDecimals:2})]}),Yn.jsxs("li",{children:["Weekly: ",Vm({input:n,showDecimals:2})]})]}),Yn.jsx("br",{}),"*Variable APY based on today’s trading activity"]}),children:Yn.jsx(i,{component:"span",sx:Object.assign({fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto",typography:"h5",[r.breakpoints.up("tablet")]:{typography:"body2"}},o),children:Vm({input:e,showDecimals:2})})})}!function(e){e[e.Add=1]="Add",e[e.Remove=2]="Remove"}(YT||(YT={}));const XT=({pool:e,separate:t,wrap:n})=>{const o=a();if(!e)return null;const r=e.coins.slice(0,8),s=r.length,d=t?s>=6&&n?18:24:s>3?24:36,c=(u=s,n?u<=3?{rows:1,cols:u,itemsPerRow:[u]}:4===u?{rows:2,cols:2,itemsPerRow:[2,2]}:5===u?{rows:2,cols:3,itemsPerRow:[3,2]}:6===u?{rows:2,cols:3,itemsPerRow:[3,3]}:7===u?{rows:2,cols:4,itemsPerRow:[4,3]}:8===u?{rows:2,cols:4,itemsPerRow:[4,4]}:{rows:1,cols:u,itemsPerRow:[u]}:{rows:1,cols:u,itemsPerRow:[u]});var u;return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:4},children:Array.from({length:c.rows},((n,a)=>Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:t?2:0,[o.breakpoints.up("tablet")]:{gap:t?4:0}},children:r.slice(c.itemsPerRow.slice(0,a).reduce(((e,t)=>e+t),0),c.itemsPerRow.slice(0,a+1).reduce(((e,t)=>e+t),0)).map(((n,o)=>Yn.jsx(l,{title:n.symbol,placement:"top",onlyHover:!0,leaveDelay:100,sx:{maxWidth:240},children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",zIndex:o,position:"relative",marginLeft:t?0:o>0?"-8px":0},children:Yn.jsx(Df,{address:n.address,width:d,height:d,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0})})},n.address)))},a)))})};function JT({lqList:e,onDeleteTag:t,sx:n}){if(!(null==e?void 0:e.length))return null;const{name:o}=e[0];return Yn.jsxs(i,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},n),children:[o,Yn.jsx(i,{component:li.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t()})]})}function eI({list:e,onClick:t}){return Yn.jsx(Yn.Fragment,{children:null==e?void 0:e.map((e=>Yn.jsxs(i,{onClick:t,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(XT,{pool:e,separate:!1,wrap:!1}),Yn.jsx(i,{sx:{typography:"h5"},children:e.name})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{color:"custom.status.green.default",fontWeight:600},children:["$",e.tvl?qm(new Pe(e.tvl)):"-"]}),Yn.jsx(i,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:"TVL"})]})]},e.address)))})}const tI=new Se({contractRequests:np});function nI(e,t){var n,i,o,r,a,s,l,d,c,u,p,h,m,g;if(!e||!t)return[];const f=[];for(const x of e){if(!(null==x?void 0:x.pool))continue;const e=x.pool,y=((null===(n=e.coins)||void 0===n?void 0:n.map((e=>({chainId:t,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex)),v={chainId:t,name:e.name||"",address:e.address||e.id||"",symbol:e.symbol,decimals:e.decimals,fee:(null===(i=e.fee)||void 0===i?void 0:i.toString())||"0",coins:y,apy:(null===(o=e.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(r=e.tvl)||void 0===r?void 0:r.toString())||null,volume:(null===(a=e.volume)||void 0===a?void 0:a.toString())||null,dailyVolumeUsd:(null===(s=e.dailyVolumeUsd)||void 0===s?void 0:s.toString())||null,traderCount:(null===(l=e.traderCount)||void 0===l?void 0:l.toString())||null,liquidityUtilization:(null===(d=e.liquidityUtilization)||void 0===d?void 0:d.toString())||null,lpTokenBalance:(null===(u=null===(c=x.liquidityPositions)||void 0===c?void 0:c[0])||void 0===u?void 0:u.liquidityTokenBalance)||null,daoFee:(null===(p=e.daoFee)||void 0===p?void 0:p.toString())||null,virtualPrice:(null===(h=e.virtualPrice)||void 0===h?void 0:h.toString())||null,poolType:e.poolType||"plain",a:(null===(m=e.a)||void 0===m?void 0:m.toString())||null,offpegFeeMultiplier:(null===(g=e.offpegFeeMultiplier)||void 0===g?void 0:g.toString())||null};f.push(v)}return f}function iI({poolList:t,isMyPool:n,setOperateCurvePool:o}){const r=a();return Yn.jsx(Yn.Fragment,{children:t.map((t=>Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",border:`1px solid ${r.palette.border.main}`,borderRadius:16},className:"gradient-card-border",onClick:()=>{Gj.getState().push({type:Zj.CurvePoolDetail,params:{chainId:t.chainId,address:t.address}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600},children:t.name}),Yn.jsx(i,{sx:{maxWidth:146,wordBreak:"break-word",typography:"body2",color:r.palette.text.secondary},children:t.coins.map(((e,n)=>Yn.jsxs(i,{component:"span",children:[e.symbol,n!==t.coins.length-1&&"/"]},e.address)))})]}),Yn.jsx(XT,{pool:t,separate:!0,wrap:!0})]}),Yn.jsxs(i,{sx:{mt:40},children:[Yn.jsx(KT,{apy:t.apy,dailyApy:t.dailyApy,weeklyApy:t.weeklyApy}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:20},children:[Yn.jsxs(i,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",t.tvl?qm(new Pe(t.tvl)):"-"]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),Yn.jsx(i,{sx:{flexShrink:0,flexGrow:0,width:"1px",height:24,backgroundColor:r.palette.border.main}}),Yn.jsxs(i,{sx:{flexBasis:"100%",flexGrow:1,flexShrink:1},children:[Yn.jsx(i,{sx:{typography:"h5"},children:n?t.lpTokenBalance?Am({input:t.lpTokenBalance,decimals:t.decimals}):"-":Yn.jsxs(Yn.Fragment,{children:["$",t.volume?qm(new Pe(t.volume)):"-"]})}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:n?"My LP tokens":"Volume"})]})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[n&&Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({pool:t,type:YT.Remove})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({pool:t,type:YT.Add})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})}),Yn.jsx(zT,{chainId:t.chainId,address:t.address,type:Zj.CurvePoolDetail})]})]},`${t.chainId}-${t.address}`)))})}function oI({poolList:e,isMyPool:t,loading:n,operateCurvePool:o,setOperateCurvePool:r,hasMore:s,loadMore:l,loadMoreLoading:d}){const u=a();return Yn.jsxs(ZT,{hasMore:s,loadMore:l,loadMoreLoading:d,empty:!(null==e?void 0:e.length),loading:n,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:"Pool"}),Yn.jsx(i,{component:"th",children:"Assets"}),Yn.jsx(i,{component:"th",children:"APY"}),Yn.jsx(i,{component:"th",children:"TVL"}),Yn.jsx(i,{component:"th",children:t?"My LP tokens":"Volume"}),Yn.jsx(i,{component:"th",sx:{width:t?249:155}})]})}),Yn.jsx(i,{component:"tbody",children:e.map((e=>{var n;let a="";if((null===(n=null==o?void 0:o.pool)||void 0===n?void 0:n.address.toLowerCase())===e.address.toLowerCase())if(o.type===YT.Remove)a=se._({id:"0+31GV",message:"Removing"});else a=se._({id:"1yHVE+",message:"Adding"});const s=u.palette.hover.default;return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(a?", & td":"")]:{backgroundImage:`linear-gradient(${s}, ${s})`}},children:[Yn.jsxs(i,{component:"td",children:[Yn.jsx(i,{sx:{typography:"body2",lineHeight:"19px",fontWeight:600},children:e.name}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),Yn.jsx(i,{component:"td",children:Yn.jsx(XT,{pool:e,separate:!0,wrap:!1})}),Yn.jsx(i,{component:"td",children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:Yn.jsx(KT,{apy:e.apy,dailyApy:e.dailyApy,weeklyApy:e.weeklyApy})})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},title:`$${Am({input:e.tvl,decimals:2})}`,children:["$",e.tvl?qm(new Pe(e.tvl)):"-"]})}),Yn.jsx(i,{component:"td",children:t?Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},title:`$${Am({input:e.lpTokenBalance,decimals:2})}`,children:e.lpTokenBalance?Am({input:e.lpTokenBalance,decimals:e.decimals}):"-"}):Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},title:`$${Am({input:e.volume,decimals:2})}`,children:["$",e.volume?qm(new Pe(e.volume)):"-"]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[Yn.jsx(zT,{chainId:e.chainId,address:e.address,type:Zj.CurvePoolDetail}),a?Yn.jsx(HT,{text:a,onClick:()=>r(null)}):Yn.jsxs(Yn.Fragment,{children:[t&&Yn.jsx(c,{variant:c.Variant.second,size:c.Size.small,onClick:()=>{r({pool:e,type:YT.Remove})},sx:{py:0,height:32},children:se._({id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{size:c.Size.small,onClick:()=>{r({pool:e,type:YT.Add})},sx:{py:0,height:32},children:se._({id:"m16xKo",message:"Add"})})]})]})})]},`${e.chainId}-${e.address}`)}))})]})}const rI=({account:e,scrollParentRef:t,activeChainId:n,operateCurvePool:o,setOperateCurvePool:r,children:s,isMyPool:l=!1})=>{var d,c;const u=a(),{isMobile:p}=Tg(),h=gg(),m=nt(),{onlyChainId:g}=Jn(),{filterTokens:f,filterAddressLqList:x,handleDeleteToken:y,handleChangeFilterTokens:v,handleChangeFilterAddress:b}=function(){const[e,t]=H.useState([]),[n,i]=H.useState([]);return{filterTokens:e,filterAddressLqList:n,handleDeleteToken:e=>{t((t=>{const n=[...t],i=n.indexOf(e);return-1!==i&&n.splice(i,1),n}))},handleChangeFilterTokens:e=>{i([]),e.length>0?t([e[e.length-1]]):t([])},handleChangeFilterAddress:e=>{i(e),t([])}}}(),j=$((()=>{var t,i;return{chainId:n,pageSize:p?4:8,order:{orderBy:"tvl",orderDirection:"desc"},user:l?null==e?void 0:e.toLowerCase():null,filterState:{tokenAddress:null!==(i=null===(t=f[0])||void 0===t?void 0:t.address.toLowerCase())&&void 0!==i?i:null}}}),[n,p,l,e,f]),C=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign({},j)}),w=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign({},j)}),k=at(Object.assign(Object.assign({},C),{enabled:!l,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getAllPools)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getAllPools;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),T=at(Object.assign(Object.assign({},w),{enabled:l&&null!=e,initialPageParam:1,getNextPageParam:e=>{if(!e.curve_stableswap_ng_getMyLiquidity)return null;const{currentPage:t,totalCount:n,pageSize:i}=e.curve_stableswap_ng_getMyLiquidity;if(!t||!n||!i)return null;let o=Math.floor(n/i);return n%i&&(o+=1),t>=o?null:t+1}})),I=!!(null==x?void 0:x.length),S=$((()=>{var e,t;let i=[];return I?i=[...x]:l?null===(t=T.data)||void 0===t||t.pages.forEach((e=>{var t;const o=nI(null===(t=e.curve_stableswap_ng_getMyLiquidity)||void 0===t?void 0:t.lqList,n);i=[...i,...o]})):null===(e=k.data)||void 0===e||e.pages.forEach((e=>{var t;const o=nI(null===(t=e.curve_stableswap_ng_getAllPools)||void 0===t?void 0:t.lqList,n);i=[...i,...o]})),i}),[I,l,x,null===(d=k.data)||void 0===d?void 0:d.pages,n,null===(c=T.data)||void 0===c?void 0:c.pages]),E=(l?T.hasNextPage:k.hasNextPage)&&!I,A=l?T:k;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:20,display:"flex",flexDirection:"column",gap:12,[u.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[u.breakpoints.up("tablet")]:{mr:"auto"}},children:s}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},p?{}:{"& > button":{flex:1}}),children:Yn.jsx(QT,{value:f,onChange:v,searchAddress:(e,t)=>Vn(void 0,void 0,void 0,(function*(){var i,o;const r=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getAllPools,"currentPage",{where:Object.assign(Object.assign({},j),{filterState:{poolAddress:e.toLowerCase()}})}),a=h.getInfiniteQuery(Se.graphql.curve_stableswap_ng_getMyLiquidity,"currentPage",{where:Object.assign(Object.assign({},j),{filterState:{poolAddress:e.toLowerCase()}})}),s=nI(l?null===(i=(yield m.fetchQuery(a)).curve_stableswap_ng_getMyLiquidity)||void 0===i?void 0:i.lqList:null===(o=(yield m.fetchQuery(r)).curve_stableswap_ng_getAllPools)||void 0===o?void 0:o.lqList,n);return(null==s?void 0:s.length)?Yn.jsx(eI,{list:s,onClick:()=>{b(s),t()}}):null}))})}),(I||!!f.length)&&Yn.jsxs(i,{sx:{my:0},children:[I?Yn.jsx(JT,{lqList:x,onDeleteTag:()=>b([])}):null,Yn.jsx($T,{tags:f,onDeleteTag:y})]})]})]}),p?Yn.jsx(In,{hasMore:E,threshold:300,loadMore:ae((()=>{A.hasNextPage&&!A.isFetching&&A.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>t.current||null,loader:Yn.jsx(GT,{sx:{mt:20}},"loader"),children:Yn.jsxs(WT,{children:[A.isLoading?Yn.jsx(GT,{}):"",!A.isLoading&&!(null==S?void 0:S.length)&&!A.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!(!n||g)}),!!A.error&&Yn.jsx(ai,{refresh:A.refetch,sx:{mt:40}}),Yn.jsx(iI,{isMyPool:l,poolList:S,setOperateCurvePool:r})]})}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(oI,{isMyPool:l,poolList:S,loading:A.isLoading,operateCurvePool:o,setOperateCurvePool:r,hasMore:E,loadMoreLoading:A.isFetchingNextPage,loadMore:()=>{A.hasNextPage&&!A.isFetching&&A.fetchNextPage()}}),Yn.jsx(Tj,{loading:A.isLoading,refetch:A.error?A.refetch:void 0,empty:!(null==S?void 0:S.length),hasSearch:!(!n||g)})]})]})};function aI({children:e}){const t=a();return Yn.jsx(i,{sx:{px:20,py:16,boxShadow:"0px -1px 0px 0px rgba(55, 55, 57, 0.10)",backgroundColor:"background.paper",borderBottomLeftRadius:16,borderBottomRightRadius:16,position:"fixed",bottom:0,left:0,right:0,[t.breakpoints.up("tablet")]:{position:"static"}},children:e})}const sI=e=>{const t=a();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,px:12,height:36,borderRadius:8,border:`1px solid ${t.palette.border.main}`},children:[Yn.jsxs(i,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px",color:t.palette.text.secondary,textTransform:"capitalize"},children:["Slippage Bonus (incl. pricing)",Yn.jsx(lb,{title:"Bonus comes as an advantage from current coin prices which usually appears for coins which are low in balance"})]}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:t.palette.success.main},children:"-"})]})};function lI({pool:e,account:t}){var n;const i=et(tI.getBalanceOf(null==e?void 0:e.chainId,null==e?void 0:e.address,t)),o=et(tI.getBalances(null==e?void 0:e.chainId,null==e?void 0:e.address,null!==(n=null==e?void 0:e.coins)&&void 0!==n?n:[])),r=et(tI.getTotalSupply(null==e?void 0:e.chainId,null==e?void 0:e.address)),a=$((()=>r.data?null==(null==e?void 0:e.decimals)?null:r.data.div(10**e.decimals).dp(e.decimals,Pe.ROUND_DOWN):null),[r.data,null==e?void 0:e.decimals]),s=$((()=>i.data?null==(null==e?void 0:e.decimals)?null:i.data.div(10**e.decimals).dp(e.decimals,Pe.ROUND_DOWN):null),[i.data,null==e?void 0:e.decimals]),l=$((()=>o.data?null==(null==e?void 0:e.coins)?null:o.data.map(((t,n)=>{const i=e.coins[n];return t.div(10**i.decimals).dp(i.decimals,Pe.ROUND_DOWN)})):null),[o.data,null==e?void 0:e.coins]),d=$((()=>l&&s&&a?null==(null==e?void 0:e.coins)?null:l.map(((t,n)=>{const i=e.coins[n];return t.multipliedBy(s).div(a).dp(i.decimals,Pe.ROUND_DOWN)})):null),[l,s,a,null==e?void 0:e.coins]);return{lpTokenTotalSupply:a,tokenBalances:l,lpTokenBalance:s,userTokenBalances:d,lpTokenBalanceLoading:i.isLoading||o.isLoading||r.isLoading}}const dI=({operateCurvePool:e})=>{const t=a(),{account:n,chainId:o}=dg(),r=Fg(),s=nt(),[l,u]=z(!1),[p,h]=z({}),m=G(p);m.current=p;const{slipper:g,setSlipper:f,slipperValue:x,resetSlipper:y}=oC({address:e.pool.address}),{lpTokenTotalSupply:v,tokenBalances:b,lpTokenBalance:j,userTokenBalances:C}=lI({pool:e.pool,account:n}),w=Z((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),h(t)}),[e.pool.coins]);Q((()=>{w()}),[w]);const k=(t,n)=>{h((i=>{const o=Object.assign(Object.assign({},i),{[t]:n});if(l&&b){const i=e.pool.coins.findIndex((e=>e.address===t));if(-1!==i){const r=b[i],a=new Pe(n||"0");a.isZero()||""===n?e.pool.coins.forEach((e=>{e.address!==t&&(o[e.address]="0")})):r&&r.gt(0)&&a.gt(0)&&e.pool.coins.forEach(((e,t)=>{if(t!==i){const n=b[t];if(n&&n.gt(0)){const t=n.div(r),i=a.multipliedBy(t).dp(e.decimals,Pe.ROUND_DOWN).toString();o[e.address]=i}else o[e.address]="0"}}))}}return o}))},T=tt({queries:e.pool.coins.map((t=>{const i=ip.getFetchTokenQuery(t.chainId,t.address,n,e.pool.address);return{queryKey:i.queryKey,enabled:i.enabled&&null!=t.chainId&&null!=t.address&&null!=n&&null!=e.pool.address,queryFn:i.queryFn}})),combine:e=>({data:e.map((e=>{var t,n,i,o;return{address:null===(t=e.data)||void 0===t?void 0:t.address,symbol:null===(n=e.data)||void 0===n?void 0:n.symbol,balance:null===(i=e.data)||void 0===i?void 0:i.balance,allowance:null===(o=e.data)||void 0===o?void 0:o.allowance}})),loading:e.some((e=>e.isLoading))})}),{getApprovalState:I,getBalanceState:S,getPendingRest:E,submitApprove:A}=(({account:e,chainId:t,offset:n,contractAddress:i})=>{var o,r;const a=Fg(),s=nt(),{runningRequests:l}=Ug(),{updateBlockNumber:d}=wg(),c=H.useMemo((()=>null!=i?i:Te[t].DODO_APPROVE),[t,i]),u=H.useMemo((()=>{var e;return t?null===(e=we[t])||void 0===e?void 0:e.address:null}),[t]),p=it({mutationFn:n=>Vn(void 0,[n],void 0,(function*({token:n,isReset:i,submittedBack:o,canceledCallback:r,successBack:l,failedCallback:u}){if(!c||!e||!n)return;const p=og(n),h=i?new Pe(0):void 0,m=i?se._({id:"OfhWJH",message:"Reset"}):se._({id:"Z7ZXbT",message:"Approve"}),g=yield a.execute(`${m} ${p}`,{opcode:Pg.Approval,token:n,contract:c,amt:h},{submittedBack:o,metadata:{[Sg.approve]:!0}});if(g===Eg.Canceled&&(null==r||r()),g===Eg.Success&&l&&l(),g===Eg.Failed&&(null==u||u()),g!==Eg.Success)return g;yield d(),s.invalidateQueries({queryKey:ip.getFetchTokenQuery(t,null==n?void 0:n.address,e,c).queryKey,refetchType:"all"})}))}),h=Z(((t,i,o,r)=>{var a,s;if(!t)return of.Loading;const d=l.some((e=>{var n,i,o;return(null===(n=e.spec)||void 0===n?void 0:n.opcode)===Pg.Approval&&(null===(i=e.spec)||void 0===i?void 0:i.token.address)===(null==t?void 0:t.address)&&(null===(o=e.spec)||void 0===o?void 0:o.contract)===c})),h=(null===(s=null===(a=p.variables)||void 0===a?void 0:a.token)||void 0===s?void 0:s.address)===(null==t?void 0:t.address)&&p.isPending,m=new Pe(null!=i?i:0);return e?!o||m.minus(null!=n?n:0).gt(o)||m.isZero()?of.Unchecked:t&&t.address===u?of.Sufficient:d||h?of.Approving:r?m.minus(null!=n?n:0).gt(r)?of.Insufficient:of.Sufficient:of.Loading:of.Unchecked}),[e,u,c,n,l,p.isPending,null===(r=null===(o=p.variables)||void 0===o?void 0:o.token)||void 0===r?void 0:r.address]);return{getApprovalState:h,getPendingRest:Z(((e,t)=>("USDT"===(null==e?void 0:e.symbol)||(null==e?void 0:e.address.toLowerCase())==="0x6426e6017968377529487E0ef0aA4E7759724e05".toLowerCase())&&null!==t&&t.gt(0)),[]),getBalanceState:Z(((t,i,o)=>e?o?t.minus(null!=n?n:0).gt(o)?rf.Insufficient:rf.Sufficient:rf.Loading:rf.Unchecked),[e,n]),submitApprove:Z(((e,t,n,i,o,r)=>Vn(void 0,void 0,void 0,(function*(){p.mutate({token:e,isReset:t,submittedBack:n,canceledCallback:i,successBack:o,failedCallback:r})}))),[p]),getMaxBalance:Z(((e,n)=>{const i=new Pe(0);return e&&void 0!==t&&n||i}),[t])}})({account:n,chainId:e.pool.chainId,contractAddress:e.pool.address}),O=Z(((t,n,i)=>{var o;if(!b)return{};const r={},a=n||p,s=i||T.data,l=b.findIndex((e=>e&&e.gt(0)));if(-1!==l){const n=b[l],i=e.pool.coins[l];let d;if(void 0!==t)d=t;else{const e=Object.values(a).find((e=>e&&"0"!==e&&""!==e));if(e)d=e;else{const e=null===(o=null==s?void 0:s.find((e=>{var t,n;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(n=i.address)||void 0===n?void 0:n.toLowerCase())})))||void 0===o?void 0:o.balance;d=e&&e.gt(0)?e.dp(i.decimals,Pe.ROUND_DOWN).toString():"1"}}const c=new Pe(d);r[i.address]=d,e.pool.coins.forEach(((e,t)=>{if(t!==l){const i=b[t];if(i&&i.gt(0)&&n.gt(0)){const t=i.div(n),o=c.multipliedBy(t).dp(e.decimals,Pe.ROUND_DOWN).toString();r[e.address]=o}else r[e.address]="0"}}))}return r}),[e.pool.coins,b,p,T.data]),L=et(tI.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=p[e.address]||"0",n=new Pe(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,Pe.ROUND_DOWN).toString():"0"})),!0)),R=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n&&L.data)try{const t=new hk([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_min_mint_amount",type:"uint256"}],name:"add_liquidity",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=p[e.address]||"0",n=new Pe(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,Pe.ROUND_DOWN).toString():"0"})),i=L.data.multipliedBy(1-x).dp(0,Pe.ROUND_DOWN).toString(),o=t.encodeFunctionData("add_liquidity",[n,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("add_liquidity",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveAddLiquidity]:!0},submittedBack:()=>{a()},successBack:()=>{a(),w()}})}catch(e){console.error("curve add_liquidity",e)}}))}),P=$((()=>{var t,i;if(!n||e.pool.chainId!==o)return Yn.jsx(cC,{chainId:e.pool.chainId,fullWidth:!0});if(T.loading)return Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!Object.values(p).some((e=>e&&"0"!==e)))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const n of e.pool.coins){const e=p[n.address];if(!e||"0"===e)continue;const o=new Pe(e);if(!o.isFinite())return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"});const r=T.data.find((e=>{var t,i;return(null===(t=e.address)||void 0===t?void 0:t.toLowerCase())===(null===(i=n.address)||void 0===i?void 0:i.toLowerCase())})),a=null!==(t=null==r?void 0:r.balance)&&void 0!==t?t:null,s=null!==(i=null==r?void 0:r.allowance)&&void 0!==i?i:null,l=S(o,n,a),d=E(n,s),u=I(n,o,a,s);if(l===rf.Loading||u===of.Loading)return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Loading..."});if(l===rf.Insufficient)return Yn.jsxs(c,{fullWidth:!0,disabled:!0,children:["Insufficient ",n.symbol," balance"]});if(u===of.Approving)return Yn.jsxs(c,{fullWidth:!0,disabled:!0,children:[n.symbol," Approval Pending"]});if(u===of.Insufficient)return Yn.jsxs(c,{fullWidth:!0,onClick:()=>{A(n,d)},children:["Approve ",n.symbol]})}return L.isLoading||!L.data?Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):L.data.lte(0)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"}):Yn.jsx(c,{fullWidth:!0,disabled:R.isPending,isLoading:R.isPending,onClick:()=>{R.mutate()},children:"Add"})}),[n,o,I,S,E,L.data,L.isLoading,R,e.pool.chainId,e.pool.coins,A,p,T.data,T.loading]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[t.breakpoints.up("tablet")]:{pb:20}},children:[Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:4},children:e.pool.coins.map((e=>{var n;const o=null===(n=T.data.find((t=>{var n,i;return(null===(n=t.address)||void 0===n?void 0:n.toLowerCase())===(null===(i=e.address)||void 0===i?void 0:i.toLowerCase())})))||void 0===n?void 0:n.balance;return Yn.jsxs(i,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:t.palette.background.cardInput},children:[Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(Df,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:e.symbol})]}),Yn.jsxs(i,{component:d,onClick:()=>{o&&((e,t,n)=>{if(!t)return;const i=t.dp(n,Pe.ROUND_DOWN).toString();k(e,i)})(e.address,o,e.decimals)},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:t.palette.text.secondary,"&:hover":{color:t.palette.text.primary}},children:["Balance: ",o?Am({input:o,decimals:e.decimals}):"-"]})]}),Yn.jsx(Db,{value:p[e.address]||"",onChange:t=>{k(e.address,t)},decimals:e.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]},e.symbol)}))}),Yn.jsxs(i,{sx:{mt:-8,display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8},children:[Yn.jsxs(i,{component:d,onClick:()=>{const e=!l;if(u(e),e&&b){const e=O(void 0,m.current,T.data);h(e)}},sx:{px:11,py:3,borderRadius:20,border:`1px solid ${l?t.palette.primary.main:t.palette.border.main}`,typography:"body2",fontWeight:500,lineHeight:"19px",color:l?t.palette.primary.contrastText:t.palette.text.primary,backgroundColor:l?t.palette.primary.main:"transparent","&:hover":{opacity:.8}},children:["Balanced proportion: ",l?"ON":"OFF"]}),Yn.jsx(rC,{value:g,onChange:f,sx:{width:"auto",display:"inline-flex",ml:0}})]}),Yn.jsx(sI,{})]}),Yn.jsx(aI,{children:P})]})};function cI({disabled:e,selected:t,onClick:n,children:o,iconVisible:r}){const s=a(),l=t?s.palette.success.main:s.palette.text.secondary;return Yn.jsxs(i,{component:d,disabled:e,onClick:n,sx:{flexGrow:1,flexShrink:1,flexBasis:"100%",display:"flex",alignItems:"center",gap:8},children:[r&&Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:t?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:l}),Yn.jsx("rect",{x:"4.5",y:"5",width:"9",height:"9",rx:"4.5",fill:l,stroke:l})]}):Yn.jsx("rect",{x:"0.5",y:"1",width:"17",height:"17",rx:"8.5",stroke:l})}),Yn.jsx(i,{sx:{flexGrow:1,display:"flex",alignItems:"center",gap:8,typography:"body2",fontWeight:500,lineHeight:"19px",color:s.palette.text.primary},children:o})]})}const uI=({operateCurvePool:e})=>{const t=a(),{account:n,chainId:o}=dg(),r=Fg(),s=nt(),[l,u]=z(""),[p,h]=z("oneCoin"),[m,g]=z(0),[f,x]=z({}),{slipper:y,setSlipper:v,slipperValue:b,resetSlipper:j}=oC({address:e.pool.address}),{lpTokenBalance:C,userTokenBalances:w,lpTokenBalanceLoading:k}=lI({pool:e.pool,account:n}),T=Z((()=>{const t={};e.pool.coins.forEach((e=>{t[e.address]=""})),x(t)}),[e.pool.coins]);Q((()=>{T()}),[T]);const I=$((()=>{const e=new _e(l);return e.isFinite()?e:null}),[l]),S=et(tI.calcWithdrawOneCoin(e.pool.chainId,e.pool.address,I?I.multipliedBy(10**e.pool.decimals).dp(0,_e.ROUND_DOWN).toString():"0",m)),E=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n&&S.data)try{const t=new hk([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"i",type:"int128"},{name:"_min_received",type:"uint256"}],name:"remove_liquidity_one_coin",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,_e.ROUND_DOWN).toString():"0",i=S.data.multipliedBy(1-b).dp(0,_e.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_one_coin",[n,m,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("remove_liquidity_one_coin",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveRemoveLiquidityOneCoin]:!0},submittedBack:()=>{a()},successBack:()=>{a(),u("")}})}catch(e){console.error("curve remove_liquidity_one_coin",e)}}))}),A=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n)try{const t=new hk([{inputs:[{name:"_burn_amount",type:"uint256"},{name:"_min_amounts",type:"uint256[]"}],name:"remove_liquidity",outputs:[{name:"",type:"uint256[]"}],stateMutability:"nonpayable",type:"function"}]),n=I?I.multipliedBy(10**e.pool.decimals).dp(0,_e.ROUND_DOWN).toString():"0",i=e.pool.coins.map(((e,t)=>(null==w?void 0:w[t])&&I&&C&&C.gt(0)?w[t].multipliedBy(I).div(C).multipliedBy(10**e.decimals).multipliedBy(1-b).dp(0,_e.ROUND_DOWN).toString():"0")),o=t.encodeFunctionData("remove_liquidity",[n,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("remove_liquidity",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveRemoveLiquidity]:!0},submittedBack:()=>{a()},successBack:()=>{a(),u("")}})}catch(e){console.error("curve remove_liquidity",e)}}))}),O=et(Object.assign({},tI.calcTokenAmount(e.pool.chainId,e.pool.address,e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new _e(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,_e.ROUND_DOWN).toString():"0"})),!1)));Q((()=>{if("custom"===p&&O.isSuccess&&O.data){const t=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,_e.ROUND_DOWN);u(t.toString())}}),[O.isSuccess,O.data,p,e.pool.decimals]);const L=it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){if(n&&O.data)try{const t=new hk([{inputs:[{name:"_amounts",type:"uint256[]"},{name:"_max_burn_amount",type:"uint256"}],name:"remove_liquidity_imbalance",outputs:[{name:"",type:"uint256"}],stateMutability:"nonpayable",type:"function"}]),n=e.pool.coins.map((e=>{const t=f[e.address]||"0",n=new _e(t);return n.isFinite()?n.multipliedBy(10**e.decimals).dp(0,_e.ROUND_DOWN).toString():"0"})),i=O.data.multipliedBy(1+b).dp(0,_e.ROUND_DOWN).toString(),o=t.encodeFunctionData("remove_liquidity_imbalance",[n,i]),a=()=>{s.invalidateQueries({queryKey:[ke,"curve"],refetchType:"all"}),s.invalidateQueries({queryKey:[ke,"token","getFetchTokenQuery"],refetchType:"all"})};return yield r.execute("remove_liquidity_imbalance",{opcode:Pg.TX,data:o,to:e.pool.address,value:"0x0"},{metadata:{[Sg.curveRemoveLiquidityImBalance]:!0},submittedBack:()=>{a()},successBack:()=>{a(),u(""),T()}})}catch(e){console.error("curve remove_liquidity_imbalance",e)}}))}),R=$((()=>{if(!n||e.pool.chainId!==o)return Yn.jsx(cC,{chainId:e.pool.chainId,fullWidth:!0});if(!l||"0"===l)return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Please enter amount"});const t=new _e(l);if(!t.isFinite())return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"});if(k)return Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Loading..."});if(!C||C.lte(0))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"No LP token balance"});if(t.gt(C))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"});if("oneCoin"===p)return S.isLoading||!S.data?Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."}):S.data.lte(0)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"}):Yn.jsx(c,{fullWidth:!0,disabled:E.isPending,isLoading:E.isPending,onClick:()=>{E.mutate()},children:"Remove"});if("balanced"===p)return Yn.jsx(c,{fullWidth:!0,disabled:A.isPending,isLoading:A.isPending,onClick:()=>{A.mutate()},children:"Remove"});if("custom"===p){if(!Object.values(f).some((e=>e&&"0"!==e)))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Please enter amount"});for(const t of e.pool.coins){const e=f[t.address];if(!e||"0"===e)continue;if(!new _e(e).isFinite())return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"})}if(O.isLoading||!O.data)return Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:"Calculating..."});if(O.data.lte(0))return Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Invalid input"});const n=O.data.dividedBy(10**e.pool.decimals).dp(e.pool.decimals,_e.ROUND_DOWN);return n.gt(t)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Insufficient input amount"}):n.gt(C)?Yn.jsx(c,{fullWidth:!0,disabled:!0,children:"Insufficient LP token balance"}):Yn.jsx(c,{fullWidth:!0,disabled:L.isPending,isLoading:L.isPending,onClick:()=>{L.mutate()},children:"Remove"})}return null}),[n,e.pool.chainId,e.pool.decimals,e.pool.coins,o,l,k,C,p,S.isLoading,S.data,E,A,f,O.isLoading,O.data,L]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:100,px:20,pt:16,display:"flex",flexDirection:"column",gap:16,[t.breakpoints.up("tablet")]:{pb:20}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[Yn.jsxs(i,{sx:{px:20,py:12,display:"flex",alignItems:"center",gap:16,borderRadius:16,backgroundColor:t.palette.background.cardInput},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:"LP Tokens"}),Yn.jsxs(i,{component:d,onClick:()=>{C&&u(C.dp(e.pool.decimals,_e.ROUND_DOWN).toString())},sx:{mt:4,typography:"h6",fontWeight:500,lineHeight:"16px",color:t.palette.text.secondary,"&:hover":{color:t.palette.text.primary}},children:["Balance: ",C?Am({input:C,decimals:e.pool.decimals}):"-"]})]}),Yn.jsx(Db,{value:l,onChange:e=>{u(e)},decimals:e.pool.decimals,typography:"h4",sx:{mt:0,"& input":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,textAlign:"right",border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:"h4",lineHeight:"33px",fontWeight:600,color:"text.disabled"}}}})]}),Yn.jsxs(i,{sx:{p:12,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,borderRadius:8,border:`1px solid ${t.palette.border.main}`},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(cI,{iconVisible:!0,disabled:!1,selected:"oneCoin"===p,onClick:()=>{h("oneCoin")},children:"One coin"}),Yn.jsx(cI,{iconVisible:!0,disabled:!1,selected:"balanced"===p,onClick:()=>{h("balanced")},children:"Balanced"}),Yn.jsx(cI,{iconVisible:!0,disabled:!1,selected:"custom"===p,onClick:()=>{h("custom")},children:"Custom"})]}),Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:12},children:e.pool.coins.map(((e,n)=>{var o;return Yn.jsxs(cI,{iconVisible:"oneCoin"===p||"balanced"===p,disabled:!1,selected:"oneCoin"!==p||m===n,onClick:()=>{"oneCoin"===p&&g(n)},children:[Yn.jsx(Df,{width:24,height:24,address:e.address,chainId:e.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:e.symbol}),"oneCoin"===p&&Yn.jsx(i,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:m===n?Am({input:null===(o=S.data)||void 0===o?void 0:o.div(10**e.decimals),decimals:e.decimals}):"0"}),"balanced"===p&&Yn.jsx(i,{sx:{ml:"auto",typography:"body1",fontWeight:600,lineHeight:"22px",color:t.palette.text.primary},children:(null==w?void 0:w[n])&&I&&C&&C.gt(0)?Am({input:w[n].multipliedBy(I).div(C),decimals:e.decimals}):"-"}),"custom"===p&&Yn.jsx(i,{sx:{ml:"auto"},children:Yn.jsx(Db,{value:f[e.address]||"",onChange:t=>{var n,i;n=e.address,i=t,x((e=>Object.assign(Object.assign({},e),{[n]:i})))},decimals:e.decimals,sx:{mt:0,"& input":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,textAlign:"right",border:`1px solid ${t.palette.border.main}`,borderRadius:8,outline:"none",padding:0,color:"text.primary",height:38,width:160,px:12,"&::placeholder":{fontSize:16,typography:"body1",lineHeight:"22px",fontWeight:600,color:"text.disabled"}}}})})]},e.address)}))})]}),Yn.jsx(rC,{value:y,onChange:v,sx:{}})]}),Yn.jsx(sI,{})]}),Yn.jsx(aI,{children:R})]})},pI=({onClose:e,poolDetailBtnVisible:t=!0,operateCurvePool:n})=>{const o=a(),{account:r}=dg(),[s,c]=z(n.type),[u,p]=z(n.type);u!==n.type&&(p(n.type),c(n.type));const{lpTokenBalance:h,userTokenBalances:m}=lI({pool:n.pool,account:r});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{position:"relative",display:"flex",flexDirection:"column",gap:16,px:20,pt:20},children:[e&&Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid",borderColor:o.palette.border.main},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,lineHeight:"22px",pb:17},children:"Liquidity"}),Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:e,component:d,children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16}})})]}),Yn.jsxs(i,{children:[t&&Yn.jsxs(i,{sx:{px:20,py:12,borderTopLeftRadius:8,borderTopRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,borderBottom:"none",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,lineHeight:"19px",color:"text.primary"},children:n.pool.name}),Yn.jsx(zb,{address:n.pool.address,customChainId:n.pool.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),Yn.jsxs(i,{component:d,onClick:()=>{Gj.getState().push({type:Zj.CurvePoolDetail,params:{address:n.pool.address,chainId:n.pool.chainId}})},sx:{display:"flex",alignItems:"center",color:"text.secondary","&:hover":{color:"text.primary"}},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:500,lineHeight:"19px"},children:"details"}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M7.49988 5L6.44238 6.0575L9.87738 9.5L6.44238 12.9425L7.49988 14L11.9999 9.5L7.49988 5Z",fill:"currentColor"})})]})]}),Yn.jsxs(i,{sx:{px:20,py:12,borderTopLeftRadius:t?0:8,borderTopRightRadius:t?0:8,borderBottomLeftRadius:8,borderBottomRightRadius:8,borderStyle:"solid",borderColor:"border.main",borderWidth:1,display:"flex",flexDirection:"column",alignItems:"flex-start",gap:12},children:[Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,lineHeight:"16px",color:"text.secondary"},children:"My LP tokens"}),Yn.jsx(l,{title:Yn.jsx(i,{sx:{m:8,display:"flex",flexDirection:"column",gap:20,minWidth:216},children:null==m?void 0:m.map(((e,t)=>{const o=n.pool.coins[t];return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600,lineHeight:"14px"},children:[Yn.jsx(Df,{width:14,height:14,address:o.address,chainId:o.chainId,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsx(i,{children:o.symbol}),Yn.jsx(i,{sx:{ml:"auto"},children:Am({input:e,decimals:o.decimals})})]},t)}))}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:500,lineHeight:"22px",color:o.palette.text.primary},children:Am({input:h,decimals:n.pool.decimals})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.00016 1.33325C4.32016 1.33325 1.3335 4.31992 1.3335 7.99992C1.3335 11.6799 4.32016 14.6666 8.00016 14.6666C11.6802 14.6666 14.6668 11.6799 14.6668 7.99992C14.6668 4.31992 11.6802 1.33325 8.00016 1.33325ZM7.3335 4.66658V5.99992H8.66683V4.66658H7.3335ZM7.3335 7.33325V11.3333H8.66683V7.33325H7.3335ZM2.66683 7.99992C2.66683 10.9399 5.06016 13.3333 8.00016 13.3333C10.9402 13.3333 13.3335 10.9399 13.3335 7.99992C13.3335 5.05992 10.9402 2.66659 8.00016 2.66659C5.06016 2.66659 2.66683 5.05992 2.66683 7.99992Z",fill:o.palette.text.secondary})})]})})]})]})]}),Yn.jsxs(S,{value:s,onChange:(e,t)=>{c(t)},children:[Yn.jsx(F,{tabs:[{key:YT.Add,value:"Add"},{key:YT.Remove,value:"Remove"}],variant:"inPaper",tabsListSx:{mt:16,mx:20}}),Yn.jsx(O,{value:YT.Add,children:Yn.jsx(dI,{operateCurvePool:n})}),Yn.jsx(O,{value:YT.Remove,children:Yn.jsx(uI,{operateCurvePool:n})})]})]})},hI=({poolDetailBtnVisible:e,operateCurvePool:t,setOperateCurvePool:n})=>{const{isMobile:o}=Tg(),r=$((()=>{if(n)return()=>{n(null)}}),[n]);return o?Yn.jsx(Of,{open:!0,onClose:r,scope:!o,modal:o,id:"curve-pool-operate",children:Yn.jsx(pI,{onClose:r,operateCurvePool:t,poolDetailBtnVisible:e})}):Yn.jsx(i,{sx:{borderRadius:16,backgroundColor:"background.paper"},children:Yn.jsx(pI,{onClose:r,operateCurvePool:t,poolDetailBtnVisible:e})})};function mI(e,t,n,i){return"CLASSICAL"===i&&e&&t&&e.isEqualTo(t)?e.times(`1e${n}`).minus(1).div(`1e${n}`):e}function gI(e,t){return e.lte(0)?new _e(0):t.div(e)}function fI(e,t,n,i,o,r,a){const s=o&&function(e){return-1!==["0x9D9793e1E18CDEe6cf63818315D55244f73EC006","0x0D04146B2Fe5d267629a7eb341Fb4388DcdBD22f","0x3D9d765b0fbAf594F90F07bc42889473e6613C7A","0x3854BdcB1a7cBA4b1A5f9a7C8719e247Df4c42c6","0xA46F5eC3219f956d14C6816Ef9cf6CaBf13bdD77","0xB16f2Ff8E8499E31B257d2A02D25e8956Ae6aFe7"].findIndex((t=>t.toLowerCase()===e.toLowerCase()))}(o);let l,d;const c="CLASSICAL"===r?i:n;if(e&&t&&c&&void 0!==a){if(d=gI(t,c),l=e.times(d),"CLASSICAL"===r&&s){if(!i)return[void 0,void 0];l.gt(i)&&n&&(d=gI(t,_e.min(i,n)),l=l.times(d))}return[d,l.dp(Number(a),_e.ROUND_DOWN)]}return[void 0,void 0]}function xI({account:e,pool:t}){var n,i;const{chainId:o,address:r,type:a,baseTokenDecimals:s,quoteTokenDecimals:l,baseLpTokenDecimals:d,quoteLpTokenDecimals:c}=null!=t?t:{},u=et($m.getTotalBaseLpQuery(o,r,a,d)),p=et($m.getTotalQuoteLpQuery(o,r,a,c)),h=et($m.getUserBaseLpQuery(o,r,a,d,e)),m=et($m.getUserQuoteLpQuery(o,r,a,c,e)),g=et($m.getReserveLpQuery(o,r,a,s,l)),f=et($m.getClassicalTargetQuery(o,r,a,s,l)),x=u.data,y=p.data,{baseReserve:v,quoteReserve:b}=g.data||{},j=null===(n=f.data)||void 0===n?void 0:n.baseTarget,C=null===(i=f.data)||void 0===i?void 0:i.quoteTarget,w="DPP"===a,k=w?v:mI(h.data,x,d,a),T=w?b:mI(m.data,y,c,a),[I,S]=w?[new _e(1),v]:fI(k,x,v,j,r,a,s);let E,A;if(b){let e=p.data;e||p.isLoading||p.error||!x||(e=x);const t=m.isFetched&&!m.error&&null===T?k:T;w?(E=new _e(1),A=b):m.isLoading||m.error||f.error||t?[E,A]=fI(t,e,b,C,r,a,l):A=new _e(0)}const O=h.isLoading||m.isLoading,L=h.isError||m.isError,R=()=>{h.refetch(),m.refetch(),u.refetch(),p.refetch(),g.refetch(),f.refetch()},P=O||u.isLoading||p.isLoading||g.isLoading||f.isLoading,_=L||u.isError||p.isError||g.isError||f.isError,M="DVM"===(null==t?void 0:t.type)&&(!b||b.isZero());return{totalBaseLpBalance:x,totalQuoteLpBalance:y,baseReserve:v,quoteReserve:b,classicalBaseTarget:j,classicalQuoteTarget:C,userBaseLpBalance:k,userQuoteLpBalance:T,userBaseLpToTokenBalance:S,userQuoteLpToTokenBalance:A,baseLpToTokenProportion:I,quoteLpToTokenProportion:E,isSinglePool:M,userLpBalanceLoading:O,userLpToTokenBalanceLoading:P,userLpBalanceError:L,userLpToTokenBalanceError:_,userLpToTokenBalanceRefetch:R,error:_,loading:P,refetch:R}}const yI=new Ee({contractRequests:np});function vI({chainId:e,address:t,showName:n,size:o,offset:r,rightContent:a}){const s=Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:r},children:[Yn.jsx(Df,{chainId:e,address:t,width:o,height:o,noShowChain:!0,marginRight:0}),n]});return a?Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s,a]}):s}function bI({miningItem:e}){var t,n;const{account:i}=dg(),o=null!==(t=null==e?void 0:e.rewardTokenInfos)&&void 0!==t?t:[],r=[],a=[];if(e){const t=e.version,s=null!==(n=e.miningContractAddress)&&void 0!==n?n:"";o.forEach((n=>{var o,l,d,c,u,p,h,m,g;const f={address:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",decimals:null==n?void 0:n.decimals,symbol:null!==(l=null==n?void 0:n.symbol)&&void 0!==l?l:"",usdPrice:null!==(d=null==n?void 0:n.price)&&void 0!==d?d:""};if("3"===t)r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,f.address,f.decimals,t));else switch(e.type){case"classical":r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,null!==(u=null===(c=e.baseLpToken)||void 0===c?void 0:c.address)&&void 0!==u?u:"",f.decimals,"2")),r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,null!==(h=null===(p=e.quoteLpToken)||void 0===p?void 0:p.address)&&void 0!==h?h:"",f.decimals,"2"));break;case"vdodo":case"single":r.push(f),a.push(yI.getPendingRewardQuery(e.chainId,s,i,null!==(g=null===(m=e.baseToken)||void 0===m?void 0:m.address)&&void 0!==g?g:"",f.decimals,"2"));break;default:throw new Error(`type: ${e.type} is not valid.`)}}))}return tt({queries:a,combine:e=>{let t=new Pe(0),n=new Pe(0);return{data:e.map(((e,i)=>{const o=r[i],a=e.data;if(a){t=a.plus(t);const e=null==o?void 0:o.usdPrice;e&&(n=n.plus(a.times(e)))}return Object.assign(Object.assign({},o),{amount:a})})),pending:e.some((e=>e.isPending)),error:e.some((e=>e.isError)),totalReward:t,totalRewardUSD:n,refetch:()=>{e.forEach((e=>e.refetch()))}}}})}function jI({value:e,label:t,tokenList:n,loading:o}){const r=a();return Yn.jsxs(i,{sx:{flexGrow:0,flexShrink:1,width:"30%"},children:[Yn.jsx(i,{sx:{typography:"h6",color:r.palette.text.secondary},children:t}),Yn.jsxs(i,{sx:{mt:8,typography:"body1",fontWeight:600,color:r.palette.text.primary,display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(v,{loading:o,loadingProps:{width:30},children:e?`$${Am({input:e,decimals:2})}`:"-"}),Yn.jsx(l,{placement:"top",title:Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:8,width:190,color:"text.primary",fontWeight:600},children:n.map((e=>{var t;return Yn.jsx(vI,{chainId:e.chainId,address:e.address,showName:null!==(t=e.symbolEle)&&void 0!==t?t:e.symbol,rightContent:e.amount,size:20,offset:6},e.address+e.chainId)}))}),children:Yn.jsx(i,{component:d,sx:{display:"flex",alignItems:"center",color:r.palette.text.secondary,width:16,height:16,"&:hover":{color:"text.primary"}},children:Yn.jsx(li.DetailBorder,{})})})]})]})}function CI({chainId:t,loading:n,miningItem:o,miningContractAddress:r,stakedTokenUSD:s,stakedTokenUSDLoading:l,miningTitle:d,associatedMineSectionShort:c,stakedTokenList:u,isEnded:p}){var h,m;const g=a(),f=bI({miningItem:o});return Yn.jsxs(i,{sx:{backgroundColor:g.palette.background.paper,borderRadius:8,borderColor:g.palette.border.main,borderStyle:"solid",borderWidth:1,mb:20},children:[c?null:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{py:12,px:20,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(v,{loading:n,loadingProps:{width:100},children:Yn.jsx(kj,{width:24,tokens:u,gap:-6,chainId:t,mr:4,showChainLogo:!1})}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{color:g.palette.text.primary,typography:"body2",fontWeight:600,display:"flex",alignItems:"center"},children:null!=d?d:"-"}),p&&Yn.jsx(i,{sx:{backgroundColor:g.palette.border.disabled,borderRadius:4,typography:"h6",fontWeight:500,px:8,color:g.palette.text.disabled},children:Yn.jsx(e,{id:"237hSL",message:"Ended"})})]}),Yn.jsx(zb,{size:"small",truncate:!0,address:null!=r?r:"",iconSpace:4,sx:{color:g.palette.text.secondary,typography:"h6"},customChainId:t})]})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:g.palette.text.secondary,typography:"h6",cursor:"pointer"},onClick:()=>{Gj.getState().push({type:Zj.MiningDetail,params:{address:r,chainId:t}})},children:[Yn.jsx(e,{id:"URmyfc",message:"Details"}),Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Yn.jsx("path",{d:"M7.5 4.5L6.4425 5.5575L9.8775 9L6.4425 12.4425L7.5 13.5L12 9L7.5 4.5Z",fill:"currentColor"})})]})]}),Yn.jsx(i,{sx:{width:"100%",height:"1px",backgroundColor:g.palette.border.main}})]}),Yn.jsxs(i,{sx:{py:12,px:20,display:"flex",alignItems:"center",gap:20},children:[Yn.jsx(jI,{value:s,label:se._({id:"luOvdJ",message:"My Staked"}),tokenList:u,loading:n||l}),Yn.jsx(i,{sx:{width:"1px",height:30,backgroundColor:g.palette.border.main,flexGrow:0,flexShrink:0}}),Yn.jsx(jI,{value:f.totalRewardUSD,label:se._({id:"4cJ0hF",message:"Rewards"}),tokenList:null!==(m=null===(h=f.data)||void 0===h?void 0:h.map((e=>Object.assign(Object.assign({chainId:t},e),{name:e.symbol,amount:Am({input:e.amount,decimals:e.decimals})}))))&&void 0!==m?m:[],loading:f.pending||n})]})]})}const wI=({miningItem:e,successBack:t})=>{const{account:n}=dg(),i=Fg();return it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){const o=yield Vn(void 0,void 0,void 0,(function*(){if(!n||!(null==e?void 0:e.miningContractAddress))return null;let t="";const i=yield Ee.encode.claimAllMining(e.miningContractAddress);if(i&&i.data)return i.value=0,i;throw t="invalid data",new Error(t)}));if(!o)return;return yield i.execute(se._({id:"hom7qf",message:"Claim"}),Object.assign({opcode:Pg.TX},o),{metadata:{[Sg.claimMining]:"1"},successBack:t})}))})};function kI({miningItem:t}){const n=bI({miningItem:t}),i=wI({miningItem:t,successBack:()=>{n.refetch()}});return Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:null==t?void 0:t.chainId,children:Yn.jsx(c,{fullWidth:!0,isLoading:i.isPending,disabled:n.totalReward.isZero(),onClick:()=>{i.mutate()},children:i.isPending?Yn.jsx(e,{id:"KvG1xW",message:"Claiming"}):Yn.jsx(e,{id:"dUdltF",message:"One-Click Claim"})})})}function TI({tokenSymbol:e,goLpLink:t}){const n=a();return Yn.jsxs(P,{sx:{color:n.palette.text.secondary,typography:"h6",display:"flex",alignItems:"center"},component:d,onClick:t,children:[se._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:e}}),Yn.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.83324 3.88867L5.01074 4.71117L7.68241 7.38867L5.01074 10.0662L5.83324 10.8887L9.33324 7.38867L5.83324 3.88867Z",fill:"currentColor"})})]})}function II({miningItem:t,loading:n,sx:o}){const r=a(),s=bI({miningItem:t});return Yn.jsxs(i,{sx:Object.assign({borderWidth:1,borderRadius:12},o),children:[Yn.jsxs(i,{sx:{typography:"body1",color:r.palette.text.secondary,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12},children:[Yn.jsx(e,{id:"4cJ0hF",message:"Rewards"}),":",Yn.jsx(v,{loading:n||s.pending,loadingProps:{width:100},sx:{color:r.palette.text.primary,fontWeight:600},children:s.pending||s.error?"-":`$${Am({input:s.totalRewardUSD,decimals:2})}`})]}),Yn.jsxs(i,{sx:{borderTopWidth:1,px:20,pt:4,pb:8},children:[(n||s.pending)&&Yn.jsx(v,{loading:n,loadingProps:{width:150}}),!n&&!s.pending&&!!t&&s.data.map((e=>Yn.jsxs(i,{sx:{mt:16,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.address&&e.symbol&&Yn.jsx(vI,{chainId:t.chainId,address:e.address,showName:e.symbol,size:24,offset:6}),Yn.jsxs(i,{sx:{ml:"auto"},children:[Yn.jsx(i,{sx:{typography:"h5",textAlign:"right"},children:Am({input:e.amount,decimals:e.decimals})}),Yn.jsx(i,{sx:{mt:2,typography:"body2",color:r.palette.text.secondary,textAlign:"right"},children:e.usdPrice&&e.amount?`≈ $${Am({input:new Pe(e.amount).multipliedBy(e.usdPrice).dp(4,Pe.ROUND_DOWN),decimals:4})}`:"-"})]})]},e.address)))]})]})}function SI({status:t,children:n,buttonProps:i}){return!t.needShowTokenStatusButton&&n?Yn.jsx(Yn.Fragment,{children:n}):t.insufficientBalance?Yn.jsx(c,{fullWidth:!0,disabled:!0,...i,children:Yn.jsx(e,{id:"znqB4T",message:"Insufficient balance"})}):Yn.jsx(c,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance,...i,children:t.isApproving?Yn.jsx(e,{id:"j2Uisd",message:"Approving"}):t.approveTitle})}function EI(e){if(!e&&"number"!=typeof e)return e;let t="";return t=Pe.isBigNumber(e)?e.toString(16):new Pe(e).toString(16),t.length%2?"0x0"+t:"0x"+t}function AI(e){return EI(Pm(e,18))}const OI=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:o})=>{const{chainId:r,account:a}=dg(),s=Fg(),l=we[r];return it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){const r=yield Vn(void 0,void 0,void 0,(function*(){var n,i;if(!(a&&e&&e.baseToken&&e.miningContractAddress))return null;let o="";const r=new Pe(t),s=Number(e.baseToken.decimals),d=yield Ee.encode.depositMining(e.miningContractAddress,r,s);if(!d||!d.data)throw o="invalid data",new Error(o);try{return t&&(null===(i=null===(n=e.baseLpToken)||void 0===n?void 0:n.address)||void 0===i?void 0:i.toLocaleLowerCase())===l.address.toLocaleLowerCase()?d.value=AI(r):d.value=0,d}catch(e){throw console.error("2.0 sendTransaction error",e),o=`2.0 sendTransaction error; ERROR: ${e}`,new Error(o)}}));if(!r)return;return yield s.execute(se._({id:"JYKRJS",message:"Stake"}),Object.assign({opcode:Pg.TX},r),{metadata:{[Sg.stakeMining]:"1",logBalance:o},submittedBack:n,successBack:i})}))})};function LI({goLpLink:t,amount:n,miningItem:i,balanceInfo:o,submittedBack:r,successBack:a,logBalance:s}){var l,d,u,p;const h=OI({miningItem:i,amount:n,submittedBack:r,successBack:a,logBalance:s}),m=i?`${null===(l=i.baseToken)||void 0===l?void 0:l.symbol}-${null===(d=i.quoteToken)||void 0===d?void 0:d.symbol} LP`:"",g=lf(i?ag(Object.assign(Object.assign({},i.baseLpToken),{symbol:m}),i.chainId):null,{contractAddress:null!==(u=null==i?void 0:i.miningContractAddress)&&void 0!==u?u:"",overrideBalance:o.userBaseLpBalance,amount:n});return t&&m&&(null===(p=o.userBaseLpBalance)||void 0===p?void 0:p.isZero())?Yn.jsx(c,{fullWidth:!0,onClick:()=>t(),children:se._({id:"dJqd5x",message:"Get {tokenSymbol}",values:{tokenSymbol:m}})}):Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:null==i?void 0:i.chainId,children:Yn.jsx(SI,{status:g,children:Yn.jsx(c,{fullWidth:!0,isLoading:h.isPending,disabled:!Number(n),onClick:()=>{h.mutate()},children:h.isPending?Yn.jsx(e,{id:"KsqhWn",message:"Staking"}):Yn.jsx(e,{id:"JYKRJS",message:"Stake"})})})})}const RI=({miningItem:e,amount:t,submittedBack:n,successBack:i,logBalance:o})=>{const{account:r}=dg(),a=Fg();return it({mutationFn:()=>Vn(void 0,void 0,void 0,(function*(){const s=yield Vn(void 0,void 0,void 0,(function*(){if(!(r&&e&&e.baseToken&&e.miningContractAddress))return null;let n="";const i=new Pe(t),o=Number(e.baseToken.decimals),a=yield Ee.encode.withdrawMining(e.miningContractAddress,i,o);if(a&&a.data)return a.value=0,a;throw n="invalid data",new Error(n)}));if(!s)return;return yield a.execute(se._({id:"OFjZGo",message:"Unstake"}),Object.assign({opcode:Pg.TX},s),{metadata:{[Sg.unstakeMining]:"1",logBalance:o},submittedBack:n,successBack:i})}))})};function PI({amount:t,miningItem:n,overrideBalance:i,submittedBack:o,successBack:r,logBalance:a}){var s,l;const d=RI({miningItem:n,amount:t,submittedBack:o,successBack:r,logBalance:a}),u=n?`${null===(s=n.baseToken)||void 0===s?void 0:s.symbol}-${null===(l=n.quoteToken)||void 0===l?void 0:l.symbol} LP`:"",p=lf(n?ag(Object.assign(Object.assign({},n.baseLpToken),{symbol:u}),n.chainId):null,{overrideBalance:i,amount:t,skipQuery:!0});return Yn.jsx(cC,{includeButton:!0,fullWidth:!0,chainId:null==n?void 0:n.chainId,children:Yn.jsx(SI,{status:p,children:Yn.jsx(c,{fullWidth:!0,isLoading:d.isPending,disabled:!Number(t),onClick:()=>{d.mutate()},children:d.isPending?Yn.jsx(e,{id:"1gWStS",message:"Unstaking"}):Yn.jsx(e,{id:"OFjZGo",message:"Unstake"})})})})}function _I(e){var{sx:t}=e,n=qn(e,["sx"]);const o=a();return Yn.jsx(i,{sx:Object.assign({paddingTop:20,backgroundColor:o.palette.background.paper,position:"sticky",bottom:0},t),...n})}function MI({chainId:e,poolAddress:t,status:n,loading:o,operateType:r,setOperateType:s,miningItem:l,associatedMineSectionVisible:d,goLpLink:c}){var u,p,h,m,g,f,x,y,v,b,j,C,w,k,T,I,E;const A=a(),{account:L}=dg(),{miningContractAddress:R}=null!=l?l:{},P=ag(null==l?void 0:l.baseToken,e),_=ag(null==l?void 0:l.quoteToken,e),[M,B]=H.useState(""),[D,N]=H.useState(""),U=[{key:"stake",value:se._({id:"JYKRJS",message:"Stake"})},{key:"unstake",value:se._({id:"OFjZGo",message:"Unstake"})},{key:"claim",value:se._({id:"hom7qf",message:"Claim"})}],q=l&&P&&_&&["classical","lptoken"].includes(null!==(u=l.type)&&void 0!==u?u:"")?{chainId:e,address:t,type:"lptoken"===l.type?"DSP":"CLASSICAL",baseToken:P,quoteToken:_}:void 0,V=xI({account:L,pool:l&&P&&_&&l.baseLpToken&&l.quoteLpToken&&["classical","lptoken"].includes(null!==(p=l.type)&&void 0!==p?p:"")?{chainId:e,address:t,type:"lptoken"===l.type?"DSP":"CLASSICAL",baseTokenDecimals:P.decimals,quoteTokenDecimals:_.decimals,baseLpTokenDecimals:null!==(h=l.baseLpToken.decimals)&&void 0!==h?h:18,quoteLpTokenDecimals:null!==(m=l.quoteLpToken.decimals)&&void 0!==m?m:18}:void 0}),W=et($m.getPMMStateQuery(null==q?void 0:q.chainId,null==q?void 0:q.address,null==q?void 0:q.type,null===(g=null==q?void 0:q.baseToken)||void 0===g?void 0:g.decimals,null===(f=null==q?void 0:q.quoteToken)||void 0===f?void 0:f.decimals)),$=et(yI.getLpStakedBalance(null==l?void 0:l.chainId,(null==l?void 0:l.miningContractAddress)||void 0,L,null!==(y=null===(x=null==l?void 0:l.baseLpToken)||void 0===x?void 0:x.address)&&void 0!==y?y:"",null===(v=null==l?void 0:l.baseToken)||void 0===v?void 0:v.decimals,null==l?void 0:l.version)),z=$.isLoading||W.isLoading;let Z,G,Q;if($.data&&V.baseLpToTokenProportion&&V.quoteLpToTokenProportion&&!W.isLoading){const e=null===(b=null==l?void 0:l.baseToken)||void 0===b?void 0:b.price,t=null===(j=null==l?void 0:l.quoteToken)||void 0===j?void 0:j.price,n=null===(C=W.data)||void 0===C?void 0:C.midPrice;G=$.data.times(V.baseLpToTokenProportion),Q=$.data.times(V.quoteLpToTokenProportion),n?t?Z=G.times(n).plus(Q).times(t):e&&(Z=Q.times(n).plus(G).times(e)):e&&t&&(Z=G.times(e).plus(Q.times(t)))}const Y=P&&_?[Object.assign(Object.assign({},P),{amount:Am({input:G,decimals:P.decimals})}),Object.assign(Object.assign({},_),{amount:Am({input:Q,decimals:_.decimals})})]:[],K=P&&_?`${P.symbol}-${_.symbol} LP`:"- LP",X=n===Ae.ended,J=(null===(w=null==l?void 0:l.baseLpToken)||void 0===w?void 0:w.address)&&V.userBaseLpBalance?{[null===(k=null==l?void 0:l.baseLpToken)||void 0===k?void 0:k.address]:V.userBaseLpBalance.toString()}:{},ee=()=>{V.refetch(),W.refetch(),$.refetch()};return Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:{paddingTop:20,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:A.palette.background.paper,px:20,paddingBottom:0,borderBottomLeftRadius:0,borderBottomRightRadius:0},children:[d&&Yn.jsx(CI,{chainId:e,miningContractAddress:null!=R?R:"",loading:o,miningItem:l,stakedTokenUSD:Z,stakedTokenUSDLoading:z,miningTitle:null!==(T=null==l?void 0:l.title)&&void 0!==T?T:"",stakedTokenList:Y}),Yn.jsxs(S,{value:r,onChange:(e,t)=>{s(t)},children:[Yn.jsx(F,{tabs:U,variant:"inPaper",tabsListSx:{mt:16}}),Yn.jsxs(O,{value:"stake",children:[Yn.jsxs(i,{sx:{mt:20,borderColor:A.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:16},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(kj,{width:Y.length>1?20:28,tokens:Y,chainId:e}),Yn.jsx(i,{sx:{ml:8,typography:"body1",color:A.palette.text.primary,fontWeight:600},children:K})]}),!!c&&Yn.jsx(TI,{tokenSymbol:K,goLpLink:c})]}),Yn.jsx(hj,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:se._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:V.userBaseLpBalance||new Pe("-"),overrideBalanceLoading:V.loading,amt:M,canClickBalance:!0,onInputChange:e=>{B(e)},readOnly:X||o,token:P,checkLogBalance:J,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),Yn.jsx(_I,{children:Yn.jsx(LI,{miningItem:l,balanceInfo:V,amount:M,goLpLink:c,submittedBack:()=>B(""),successBack:ee,logBalance:J})})]}),Yn.jsxs(O,{value:"unstake",children:[Yn.jsx(hj,{showPercentage:!0,hideToken:!0,inputTypography:"h1",balanceText:se._({id:"RxHSET",message:"LP Balance:"}),overrideBalance:$.data||new Pe("-"),overrideBalanceLoading:$.isLoading,amt:X?null!==(E=null===(I=$.data)||void 0===I?void 0:I.toString())&&void 0!==E?E:"":D,onInputChange:e=>{N(e)},canClickBalance:!0,readOnly:X||o,token:P,checkLogBalance:J,occupiedChainId:e,chainId:e,sx:{mt:20,borderWidth:1}}),Yn.jsx(_I,{children:Yn.jsx(PI,{miningItem:l,overrideBalance:$.data,amount:D,submittedBack:()=>N(""),successBack:ee,logBalance:J})})]}),Yn.jsxs(O,{value:"claim",children:[Yn.jsx(II,{miningItem:l,loading:o,sx:{mt:20}}),Yn.jsx(_I,{children:Yn.jsx(kI,{miningItem:l})})]})]})]})})}function BI({chainId:e,account:t,poolAddress:n,goLpLink:i}){var o,r,a;const s=gg().getQuery(Ee.graphql.fetchMiningList,{where:{chainIds:[e],user:t,filterState:{address:n}}}),l=et(Object.assign(Object.assign({},s),{enabled:!!n})),d=null===(a=null===(r=null===(o=l.data)||void 0===o?void 0:o.mining_list)||void 0===r?void 0:r.list)||void 0===a?void 0:a[0],{status:c}=function({miningItem:e}){var t,n;let i=Ae.active,o=[];if(null==e?void 0:e.rewardTokenInfos)if("classical"!==e.type){const r=Ee.utils.getMiningStatusByTimestamp({startTime:null!==(t=e.startTime)&&void 0!==t?t:"",endTime:null!==(n=e.endTime)&&void 0!==n?n:"",rewardTokenInfoList:e.rewardTokenInfos.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))});i=r.status,o.push(r)}else if(e.rewardQuoteTokenInfos){o=[e.rewardTokenInfos,e.rewardQuoteTokenInfos].map((t=>{var n,i;return Ee.utils.getMiningStatusByTimestamp({startTime:null!==(n=e.startTime)&&void 0!==n?n:"",endTime:null!==(i=e.endTime)&&void 0!==i?i:"",rewardTokenInfoList:t.map((e=>{var t,n;return{startTime:null!==(t=null==e?void 0:e.startTime)&&void 0!==t?t:"",endTime:null!==(n=null==e?void 0:e.endTime)&&void 0!==n?n:""}}))})}));const[{status:t},{status:n}]=o;Ae.active,(t===Ae.upcoming&&n===Ae.upcoming||t===Ae.upcoming&&n===Ae.ended||t===Ae.ended&&n===Ae.upcoming)&&Ae.upcoming,t===Ae.ended&&n===Ae.ended&&Ae.ended}return{status:i,miningStatusList:o}}({miningItem:d}),[u,p]=H.useState(c===Ae.ended?"unstake":"stake");return Yn.jsx(MI,{chainId:e,loading:l.isLoading||l.isPending,operateType:u,setOperateType:p,associatedMineSectionVisible:!0,miningItem:d,status:c,goLpLink:i,poolAddress:n})}const DI=()=>{const t=a();return Yn.jsx(l,{placement:"top-end",leaveDelay:100,title:Yn.jsx(i,{sx:{maxWidth:240,color:t.palette.warning.main,typography:"h6",fontWeight:500,"&>a":{textDecoration:"underline",color:t.palette.warning.main},"&>a:hover":{color:T(t.palette.warning.main,.5)}},children:Yn.jsx(e,{id:"QtgfjM",message:"The creator of the liquidity pool can adjust the liquidity distribution by modifying the market-making price parameters. <0>Learn more</0>",components:{0:Yn.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://docs.dodoex.io/en/product/pmm-algorithm"})}})}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2,py:4,px:8,borderRadius:8,backgroundColor:T(t.palette.warning.main,.1),color:t.palette.warning.main,typography:"h6",fontWeight:500,lineHeight:"16px",cursor:"help"},children:[Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:Yn.jsx("path",{d:"M8.00008 10.6666C8.18897 10.6666 8.3473 10.6027 8.47508 10.4749C8.60286 10.3471 8.66675 10.1888 8.66675 9.99992C8.66675 9.81103 8.60286 9.6527 8.47508 9.52492C8.3473 9.39714 8.18897 9.33325 8.00008 9.33325C7.81119 9.33325 7.65286 9.39714 7.52508 9.52492C7.3973 9.6527 7.33341 9.81103 7.33341 9.99992C7.33341 10.1888 7.3973 10.3471 7.52508 10.4749C7.65286 10.6027 7.81119 10.6666 8.00008 10.6666ZM7.33341 7.99992H8.66675V4.66659H7.33341V7.99992ZM8.00008 14.6666C6.45564 14.2777 5.18064 13.3916 4.17508 12.0083C3.16953 10.6249 2.66675 9.08881 2.66675 7.39992V3.33325L8.00008 1.33325L13.3334 3.33325V7.39992C13.3334 9.08881 12.8306 10.6249 11.8251 12.0083C10.8195 13.3916 9.54453 14.2777 8.00008 14.6666ZM8.00008 13.2666C9.15564 12.8999 10.1112 12.1666 10.8667 11.0666C11.6223 9.96659 12.0001 8.74436 12.0001 7.39992V4.24992L8.00008 2.74992L4.00008 4.24992V7.39992C4.00008 8.74436 4.37786 9.96659 5.13341 11.0666C5.88897 12.1666 6.84453 12.8999 8.00008 13.2666Z",fill:"currentColor"})}),Yn.jsx(e,{id:"iDGO1l",message:"Disclaimer"})]})})};var NI;function FI(t){const{ConfirmComponent:n}=Jn();if(n)return Yn.jsx(n,{...t});const{open:o,onClose:r,title:a,children:s,singleBtn:l,danger:d,singleBtnText:u,cancelText:p,confirmText:h,disabledConfirm:m,confirmLoading:g,isManualClose:f,onConfirm:x,modal:y}=t;return Yn.jsx(Of,{open:o,onClose:r,title:a,modal:y,children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1},children:[Yn.jsx(i,{sx:{typography:"body2",color:a?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:s}),l?Yn.jsx(i,{sx:{px:20},children:Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,danger:d,sx:{mt:32,mb:20},onClick:()=>{r()},children:u||Yn.jsx(e,{id:"DPfwMq",message:"Done"})})}):Yn.jsxs(i,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{r()},children:p||Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),Yn.jsx(c,{sx:{ml:8},variant:c.Variant.outlined,danger:d,disabled:m,isLoading:g,onClick:()=>{x&&x(),f||r()},children:h||Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})]})]})})}function UI(e){var{sx:t,label:n,children:o}=e,r=qn(e,["sx","label","children"]);return Yn.jsxs(i,{sx:Object.assign({display:"flex",justifyContent:"space-between"},t),...r,children:[Yn.jsx(i,{children:n}),Yn.jsx(i,{sx:{textAlign:"right",fontWeight:600},children:o})]})}function qI({baseToken:e,quoteToken:t,midPrice:n,loading:o,disabled:r}){const s=a(),[d,c]=z(!1),u=d?null==t?void 0:t.symbol:null==e?void 0:e.symbol,p=d&&n?new Pe(1).div(n):n,h=d?null==e?void 0:e.symbol:null==t?void 0:t.symbol;return Yn.jsxs(v,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:o,loadingProps:{width:50},children:[e&&t?Yn.jsx(l,{title:`1 ${u} = ${p?Em({input:p}):""} ${h}`,children:n?Yn.jsx(i,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${u} = ${p?Em({input:p}):""} ${h}`}):Yn.jsxs(i,{children:[`1 ${u} = `,Yn.jsx(v,{loading:o,loadingProps:{width:30},component:"span",sx:{display:"inline-block"},children:"-"}),` ${h}`]})}):"-",Yn.jsx(i,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,backgroundColor:"background.paperDarkContrast",borderRadius:"50%"},!r&&{cursor:"pointer","&:hover":{backgroundColor:T(s.palette.text.primary,.04)}}),onClick:()=>{r||c((e=>!e))},children:Yn.jsx(i,{component:li.Switch,sx:{width:18,height:18}})})]})}function VI({baseToken:t,quoteToken:n,loading:o,midPrice:r,shareOfPool:s,sx:l}){const d=a(),c=!t||!n;return Yn.jsxs(i,{sx:Object.assign({mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},l),children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[Yn.jsx(i,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"kNeEXg",message:"Current Price"})}),Yn.jsx(qI,{baseToken:t,quoteToken:n,loading:o,disabled:c,midPrice:r})]}),Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:d.spacing(1,0,0),borderColor:"border.main"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"SbBMxj",message:"Share of pool"})}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:Yn.jsx(v,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:o,loadingProps:{width:50},children:s||"-%"})})]})]})}function WI({open:t,onClose:n,slippage:o,baseToken:r,quoteToken:s,baseAmount:l,quoteAmount:d,lpAmount:u,fee:p,price:h,shareOfPool:m,pairAddress:g,createMutation:f}){const x=a(),{isMobile:y}=Tg();return Yn.jsx(Of,{modal:!0,open:t,onClose:n,title:u?Yn.jsx(e,{id:"AeZIvT",message:"You will receive"}):Yn.jsx(e,{id:"aM1tos",message:"You are creating a pool"}),children:Yn.jsxs(i,{sx:{px:20,py:24,borderTopWidth:1,width:y?"100%":420},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h3"},children:[Yn.jsx(kj,{width:24,height:24,tokens:r&&s?[r,s]:[],chainId:null==r?void 0:r.chainId}),u?Am({input:u,decimals:18}):""]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:x.palette.text.secondary,gap:4,fontWeight:600},children:[Yn.jsx(e,{id:"syToc5",message:"{0}/{1} Pool Tokens",values:{0:null==r?void 0:r.symbol,1:null==s?void 0:s.symbol}}),Yn.jsx(cT,{poolType:"AMM V2"})]})]}),Yn.jsx(i,{sx:{mt:16,typography:"h6",color:"text.secondary",textAlign:"center"},children:Yn.jsx(e,{id:"rQ9c+8",message:"Output is estimated. If the price changes by more than {0} your transaction will revert.",values:{0:Vm({input:o})}})}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,mt:20,p:20,typography:"body2",borderRadius:12,backgroundColor:x.palette.background.paperContrast},children:[Yn.jsx(UI,{label:Yn.jsx(e,{id:"YG004A",message:"{0} deposited",values:{0:null==r?void 0:r.symbol}}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[Yn.jsx(Df,{width:18,height:18,marginRight:4,token:r}),Am({input:l,decimals:null==r?void 0:r.decimals})]})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"YG004A",message:"{0} deposited",values:{0:null==s?void 0:s.symbol}}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{width:18,height:18,marginRight:4,token:s}),Am({input:d,decimals:null==s?void 0:s.decimals})]})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"EU3wU4",message:"Fee tier"}),children:Vm({input:p})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"fqDzSu",message:"Rate"}),children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{width:18,height:18,marginRight:4,token:r}),Yn.jsx(qI,{baseToken:r,quoteToken:s,midPrice:h})]})}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"SbBMxj",message:"Share of pool"}),children:m}),Yn.jsx(UI,{label:Yn.jsx(e,{id:"ESQO1L",message:"Pool address"}),children:Yn.jsx(zb,{showCopy:!1,address:null!=g?g:"",customChainId:null==r?void 0:r.chainId,truncate:!0,iconSpace:4,sx:{typography:"body2"}})})]}),Yn.jsx(c,{fullWidth:!0,size:c.Size.big,sx:{mt:20},isLoading:f.isPending,onClick:()=>{f.mutate()},children:f.isPending?Yn.jsx(e,{id:"pwUZo2",message:"Confirming..."}):Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})]})})}function HI(e,t,n){const i=new Pe(e),o=new Pe(t),r=i.minus(o),a=i.gt(o),s=i.lt(o);return{now:o,target:i,isChange:a||s,change:r,changeText:(s?"":"+")+Em({input:r,showDecimals:n>6?6:4,showPrecisionDecimals:2}),isAdd:a,isRemove:s}}!function(e){e[e.Liquidity=1]="Liquidity",e[e.Mining=2]="Mining"}(NI||(NI={}));const $I=e=>Vn(void 0,[e],void 0,(function*({chainId:e,account:t,srcPool:n,baseToken:i,quoteToken:o,baseAmount:r,quoteAmount:a,feeRate:s,initPrice:l,slippageCoefficient:d,ddl:c,SLIPPAGE_PROTECTION:u}){const p=e?we[e]:void 0,h=function({srcPool:e,newPool:t}){if(!e)return null;const{baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=t,{baseReserve:a,quoteReserve:s}=e;return{baseAmount:HI(o,a,n.decimals),quoteAmount:HI(r,s,i.decimals),feeRate:HI(new Pe(t.feeRate).div(100),e.feeRate,6),initPrice:HI(t.initPrice,e.i,10),slippageCoefficient:HI(t.slippageCoefficient||"1",e.k,4)}}({srcPool:n,newPool:{baseToken:i,quoteToken:o,baseAmount:r,quoteAmount:a,feeRate:s,initPrice:l,slippageCoefficient:d}});if(!(t&&e&&h&&n))return null;const m=Number(i.decimals),g=Number(o.decimals);let f;const x=h.slippageCoefficient.target;try{const t=i.symbol===(null==p?void 0:p.symbol),r=o.symbol===(null==p?void 0:p.symbol);if(h.baseAmount.isRemove&&h.quoteAmount.isRemove){const t=[yield $m.getDPPOwnerProxyAddressQuery(e,n.address).queryFn(),h.feeRate.target.multipliedBy(1e4).toNumber(),h.initPrice.target.toNumber(),x.toNumber(),zt(h.baseAmount.change.abs().dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),zt(h.quoteAmount.change.abs().dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),zt(h.baseAmount.now.multipliedBy(1-u).dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),zt(h.quoteAmount.now.multipliedBy(1-u).dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),m,g];f=yield ye.encode.removeDPPPoolABI(...t)}else{const t=[e,n.address,h.feeRate.target.multipliedBy(1e4).toNumber(),h.initPrice.target.toNumber(),x.toNumber(),h.baseAmount.isAdd?zt(h.baseAmount.change.abs().dp(m,Pe.ROUND_FLOOR).toString(),m).toString():"0",h.quoteAmount.isAdd?zt(h.quoteAmount.change.abs().dp(g,Pe.ROUND_FLOOR).toString(),g).toString():"0",h.baseAmount.isAdd?"0":zt(h.baseAmount.change.abs().dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),h.quoteAmount.isAdd?"0":zt(h.quoteAmount.change.abs().dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),zt(h.baseAmount.now.multipliedBy(1-u).dp(m,Pe.ROUND_FLOOR).toString(),m).toString(),zt(h.quoteAmount.now.multipliedBy(1-u).dp(g,Pe.ROUND_FLOOR).toString(),g).toString(),0,m,g,Math.ceil(Date.now()/1e3)+(null!=c?c:600)];f=yield ye.encode.resetDPPPoolABI(...t)}return t&&h.baseAmount.isAdd&&(f.value=AI(h.baseAmount.change)),r&&h.quoteAmount.isAdd&&(f.value=AI(h.quoteAmount.change)),f}catch(e){throw console.error("2.0 resetDPPPool error",e),new Error(`2.0 resetDPPPool error;ERROR:${e}`)}})),zI=(e,t,n)=>t?e&&"0"!==e?n?t.minus(e).toString():t.plus(e).toString():t.toString():e;function ZI({pool:e}){var t,n;const{account:i}=dg(),o=Fg(),r=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(t=null==e?void 0:e.baseToken)||void 0===t?void 0:t.decimals,null===(n=null==e?void 0:e.quoteToken)||void 0===n?void 0:n.decimals)),a=et($m.getLPFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type)),{deadLine:s}=Jn(),l=it({mutationFn:t=>Vn(this,[t],void 0,(function*({baseAmount:t,quoteAmount:n,isRemove:l=!1,feeRate:d,initPrice:c,slippageCoefficient:u,txTitle:p,submittedBack:h}){var m;if(!e)throw new Error("pool is undefined");const g=a.data;if(!g)throw new Error("lpFeeRate is undefined");if(!r.data)throw new Error("pmmStateQuery.data is undefined");const{pmmParamsBG:f,baseReserve:x,quoteReserve:y}=r.data,v=f.i.toNumber(),b=f.k.toNumber(),j=yield $I({account:i,chainId:null==e?void 0:e.chainId,SLIPPAGE_PROTECTION:iC,srcPool:Object.assign(Object.assign({},e),{baseReserve:x,quoteReserve:y,i:v,k:b,feeRate:g.times(100).toString()}),baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,baseAmount:zI(t,x?new Pe(x):void 0,l),quoteAmount:zI(n,y?new Pe(y):void 0,l),feeRate:null!=d?d:g.times(100).toString(),initPrice:null!=c?c:String(v),slippageCoefficient:null!=u?u:String(b),ddl:s});if(!j)throw new Error(`modify pool failed: ${e.address}`);return o.execute(p,Object.assign(Object.assign({opcode:Pg.TX},j),{value:null!==(m=j.value)&&void 0!==m?m:0}),{metadata:{[l?Sg.removeLiquidity:Sg.addLiquidity]:!0},submittedBack:h})}))});return{modifyDPPMutation:l}}const GI=e=>{const{account:t,chainId:n}=dg(),i=Fg(),o=nt(),{deadLine:r}=Jn(),{modifyDPPMutation:a}=ZI({pool:e}),s=it({mutationFn:a=>Vn(void 0,void 0,void 0,(function*(){var s,l,d,c,u;if(!e||!t||!a.balanceInfo)return;const{isRemove:p,baseAmount:h,quoteAmount:m,slippageProtection:g,balanceInfo:f,SLIPPAGE_PROTECTION:x,submittedBack:y,successBack:v,txTitle:b,withdrawInfo:j}=a,C=!p,{address:w,type:k,baseToken:T,quoteToken:I}=e,S=T.address.toLowerCase(),E=I.address.toLowerCase(),A=we[n].address.toLowerCase(),O=A===S,L=A===E,R="DSP"===k||"GSP"===k,P="CLASSICAL"===k,_=w.toLocaleLowerCase(),M=new Pe(h),B=new Pe(m),D=M.isNaN(),N=B.isNaN(),F=+T.decimals,U=+I.decimals,q=T.symbol,V=I.symbol,W=g;let H,$=D?"0":zt(M.multipliedBy(1-W).dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),z=N?"0":zt(B.multipliedBy(1-W).dp(U,Pe.ROUND_FLOOR).toString(),U).toString();try{if(C)if(P){const e=!D&&(null==f?void 0:f.classicalBaseTarget)&&f.classicalBaseTarget.gt(0)&&f.totalBaseLpBalance?zt(M.multipliedBy(f.totalBaseLpBalance).multipliedBy(1-x).div(f.classicalBaseTarget).dp(F,Pe.ROUND_FLOOR).toString(),F).toString():"0",t=!N&&(null==f?void 0:f.classicalBaseTarget)&&f.totalQuoteLpBalance&&f.classicalQuoteTarget&&f.classicalQuoteTarget.gt(0)?zt(B.multipliedBy(f.totalQuoteLpBalance).multipliedBy(1-x).div(f.classicalQuoteTarget).dp(U,Pe.ROUND_FLOOR).toString(),U).toString():"0",i=[n,_,D?"0":zt(M.dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),N?"0":zt(B.dp(U,Pe.ROUND_FLOOR).toString(),U).toString(),e,t,O?1:L?2:0,Math.ceil(Date.now()/1e3)+(null!=r?r:600)];H=yield ye.encode.addClassicalLiquidityABI(...i)}else{const e=[n,_,D?"0":zt(M.dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),N?"0":zt(B.dp(U,Pe.ROUND_FLOOR).toString(),U).toString(),$,z,O?1:L?2:0,Math.ceil(Date.now()/1e3)+(null!=r?r:600)];H=R?yield ye.encode.addDSPLiquidityABI(...e):yield ye.encode.addDVMLiquidityABI(...e)}else if(P){if("base"===(D?"quote":"base")){const e=M.dp(F,Pe.ROUND_FLOOR).toString(),t=j&&j.receiveAmountBg?zt(j.receiveAmountBg.multipliedBy(1-W).dp(F,Pe.ROUND_FLOOR).toString(),F).toString():$,i=[n,_,zt(e,F).toString(),t];H=yield ye.encode.removeClassicalBaseABI(...i)}else{const e=B.dp(U,Pe.ROUND_FLOOR).toString(),t=j&&j.receiveAmountBg?zt(j.receiveAmountBg.multipliedBy(1-W).dp(U,Pe.ROUND_FLOOR).toString(),U).toString():z,i=[n,_,zt(e,U).toString(),t];H=yield ye.encode.removeClassicalQuoteABI(...i)}}else{if(!((null==f?void 0:f.baseReserve)&&f.quoteReserve&&f.totalBaseLpBalance&&f.userBaseLpBalance&&f.userBaseLpToTokenBalance))return;let e=new Pe(0);if(null===(s=f.totalBaseLpBalance)||void 0===s?void 0:s.lte(0))e=f.userBaseLpBalance||new Pe(0);else if(f.baseReserve.gt(0)&&f.quoteReserve.eq(0)){let t=M;M.gte(f.userBaseLpToTokenBalance)&&(t=f.userBaseLpToTokenBalance),e=t.multipliedBy(f.totalBaseLpBalance).div(f.baseReserve)}else if(f.baseReserve.gt(0)&&f.quoteReserve.gt(0)){let t=M;M.gte(f.userBaseLpToTokenBalance)&&(t=f.userBaseLpToTokenBalance);let n,i=B;if(f.userQuoteLpToTokenBalance&&B.gte(f.userQuoteLpToTokenBalance)&&(i=f.userQuoteLpToTokenBalance),i.gt(0)&&(null===(l=f.userQuoteLpToTokenBalance)||void 0===l?void 0:l.gt(0))&&(n=i.div(f.userQuoteLpToTokenBalance)),t.gt(0)&&f.userBaseLpToTokenBalance.gt(0)&&(n=t.div(f.userBaseLpToTokenBalance)),(null==n?void 0:n.gte(1))&&(n=new Pe(1)),!n)return;e=n.multipliedBy(f.userBaseLpBalance);const o=e.dp(F,Pe.ROUND_FLOOR).div(f.totalBaseLpBalance);t=o.multipliedBy(f.baseReserve).dp(F,Pe.ROUND_FLOOR),i=o.multipliedBy(f.quoteReserve).dp(U,Pe.ROUND_FLOOR),$=zt(t.multipliedBy(1-W).dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),z=zt(i.multipliedBy(1-W).dp(U,Pe.ROUND_FLOOR).toString(),U).toString()}const i=O||L,o=[n,_,t,e.isNaN()?"0":zt(e.dp(F,Pe.ROUND_FLOOR).toString(),F).toString(),$,z,i,Math.ceil(Date.now()/1e3)+(null!=r?r:600)];H=R?yield ye.encode.removeDSPLiquidityABI(...o):yield ye.encode.removeDVMLiquidityABI(...o)}}catch(e){throw new Error(`v2 addDVMLiquidity or removeDVMLiquidity or removeDSPLiquidity error: ${e}`)}if(H&&H.data){const r={};if(h){const i=null===(d=o.getQueryData(ip.getFetchTokenQuery(n,T.address,t).queryKey))||void 0===d?void 0:d.balance;i&&(r[T.address]=i.toString()),e.baseLpToken&&(null==f?void 0:f.userBaseLpBalance)&&(r[e.baseLpToken.id]=f.userBaseLpBalance.toString())}if(m){const i=null===(c=o.getQueryData(ip.getFetchTokenQuery(n,I.address,t).queryKey))||void 0===c?void 0:c.balance;i&&(r[I.address]=i.toString()),e.quoteLpToken&&(null==f?void 0:f.userQuoteLpBalance)&&(r[e.quoteLpToken.id]=f.userQuoteLpBalance.toString())}try{let e;C&&O&&(H.value=AI(D?"0":M)),C&&L&&(H.value=AI(N?"0":B)),D||(e=`${M.toString()}${q}`),N||(e=D?`${B.toString()}${V}`:`${e} & ${B.toString()}${V}`);(yield i.execute(b,Object.assign(Object.assign({opcode:Pg.TX},H),{value:null!==(u=H.value)&&void 0!==u?u:0}),{subtitle:e,metadata:{[C?Sg.addLiquidity:Sg.removeLiquidity]:!0,logBalance:r},submittedBack:y}))===Eg.Success&&v&&v()}catch(e){throw Error(`v2 sendTransaction error: ${e}`)}}}))}),l="DPP"===(null==e?void 0:e.type)?a:s;return H.useEffect((()=>{l.reset()}),[e]),{operateLiquidityMutation:l}};function QI({baseToken:e,quoteToken:n,baseAmount:i,quoteAmount:o,slippage:r,fee:a,isExists:s,successBack:l,submittedBack:d}){const c=Fg(),{account:u}=dg();t();const{deadLine:p}=Jn();return it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){var t,h;if(!e||!n)throw new Error("token is undefined");if(!u)throw new Error("account is undefined");if(!a)throw new Error("fee is undefined");const m=e.chainId,g=we[m].address.toLowerCase(),f=dt(m),x=mt(m),y=!f,v=f||x;if(!v)throw new Error("AMMV2 contract address is not valid.");let b="",j="0x0";const C=e.address.toLowerCase()===g,w=n.address.toLowerCase()===g,k=Pm(i,e.decimals),T=Pm(o,n.decimals),I=k.times(1-r).dp(0,Pe.ROUND_FLOOR),S=T.times(1-r).dp(0,Pe.ROUND_FLOOR),E=Pm(a,4).toString(),A=Math.ceil(Date.now()/1e3)+(null!=p?p:600);try{if(C){const e=n.address,i=T.toString(),o=S.toString(),r=I.toString();j=null!==(t=EI(k))&&void 0!==t?t:"",b=y?gt(e,i,o,r,u,A):ft(e,E,i,o,r,u,A)}else if(w){const t=e.address,n=k.toString(),i=I.toString(),o=S.toString();j=null!==(h=EI(T))&&void 0!==h?h:"",b=y?gt(t,n,i,o,u,A):ft(t,E,n,i,o,u,A)}else b=y?xt(e.address,n.address,k.toString(),T.toString(),I.toString(),S.toString(),u,A):yt(e.address,n.address,E,k.toString(),T.toString(),I.toString(),S.toString(),u,A)}catch(e){throw console.error("encodeUniswapV2Router02AddLiquidity error",e),e}return yield c.execute(s?se._({id:"E6MqGy",message:"Add liquidity"}):se._({id:"L37FfW",message:"Create AMM V2 Position"}),{opcode:Pg.TX,to:v,data:b,value:j},{metadata:{[s?Sg.addLiquidityAMMV2Position:Sg.createAMMV2Position]:!0},successBack:l,submittedBack:d})}))})}function YI({lqAndDodoCompareText:t,baseToken:n,quoteToken:o,midPrice:r}){const a=r?Em({input:r}):"";return Yn.jsxs(i,{sx:{p:10,mb:12,backgroundColor:"background.paperDarkContrast",borderRadius:12},children:[Yn.jsxs(i,{sx:{typography:"body2",display:"flex",alignItems:"center",justifyContent:"center",color:"error.main",fontWeight:600,mb:10,textAlign:"center"},children:[Yn.jsx(i,{component:li.Alarm,sx:{mr:4}}),se._({id:"YUyuNp",message:"{lqAndDodoCompareText} Price Difference",values:{lqAndDodoCompareText:t}})]}),Yn.jsxs(i,{sx:{typography:"h6",color:"text.secondary",textAlign:"center"},children:[Yn.jsx(e,{id:"ZhEBp4",message:"Current liquidity pool token price"}),` 1 ${null==n?void 0:n.symbol} = ${a} ${null==o?void 0:o.symbol} ${se._({id:"wd1uHY",message:"differs from the price quoted by ZUNO by {lqAndDodoCompareText}",values:{lqAndDodoCompareText:t}})}`]})]})}function KI({chainId:t,baseTokenStatus:n,quoteTokenStatus:o,children:r}){const{runningRequests:a}=Ug(),{account:s,chainId:l}=dg();if(!s||t!==l)return Yn.jsx(cC,{chainId:t,fullWidth:!0});const d=a.some((e=>{var t,n;return(null===(t=e.metadata)||void 0===t?void 0:t[Sg.addLiquidity])||(null===(n=e.metadata)||void 0===n?void 0:n[Sg.removeLiquidity])})),u=[];n.needShowTokenStatusButton&&u.push(Yn.jsx(SI,{status:n})),o.needShowTokenStatusButton&&!n.isApproving&&u.push(Yn.jsx(SI,{status:o}));const p=u.length;return 2===p?Yn.jsx(i,{sx:{display:"flex","& > button":{flex:1,"&:last-child":{ml:8}}},children:u.map((e=>e))}):1===p?u[0]:d?Yn.jsx(c,{fullWidth:!0,disabled:!0,isLoading:!0,children:Yn.jsx(e,{id:"UbRKMZ",message:"Pending"})}):Yn.jsx(Yn.Fragment,{children:r})}function XI({pool:t,addPortion:n,midPrice:o,shareOfPool:r}){var s,d,c,u,p,h;const m=a(),[g,x]=z(!1);let y="";if(n&&o){const e=new Pe(1).div(n.plus(1)),i=new Pe(n).div(n.plus(1)),r=e.times(o),a=r.plus(i);y=n?`${Vm({input:r.div(a)})} ${null===(s=null==t?void 0:t.baseToken)||void 0===s?void 0:s.symbol} + ${Vm({input:i.div(a)})} ${null===(d=null==t?void 0:t.quoteToken)||void 0===d?void 0:d.symbol}`:""}const b=g?null===(c=null==t?void 0:t.quoteToken)||void 0===c?void 0:c.symbol:null===(u=null==t?void 0:t.baseToken)||void 0===u?void 0:u.symbol,j=g&&o?new Pe(1).div(o):o,C=g?null===(p=null==t?void 0:t.baseToken)||void 0===p?void 0:p.symbol:null===(h=null==t?void 0:t.quoteToken)||void 0===h?void 0:h.symbol;return Yn.jsxs(i,{sx:{mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[Yn.jsx(i,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"kNeEXg",message:"Current Price"})}),Yn.jsxs(v,{sx:{display:"flex",alignItems:"center",fontWeight:600,ml:8,overflow:"hidden"},loading:!t,loadingProps:{width:50},children:[Yn.jsx(l,{title:`1 ${b} = ${j?Em({input:j}):""} ${C}`,children:o?Yn.jsx(i,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${b} = ${j?Em({input:j}):""} ${C}`}):Yn.jsxs(i,{children:[`1 ${b} = `,Yn.jsx(v,{loading:!0,loadingProps:{width:30},component:"span",sx:{display:"inline-block"}}),` ${C}`]})}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,cursor:"pointer",backgroundColor:"background.paperDarkContrast",borderRadius:"50%","&:hover":{backgroundColor:T(m.palette.text.primary,.04)}},onClick:()=>x((e=>!e)),children:Yn.jsx(i,{component:li.Switch,sx:{width:18,height:18}})})]})]}),"AMMV2"===(null==t?void 0:t.type)?Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:m.spacing(1,0,0),borderColor:"border.main"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:Yn.jsx(e,{id:"NEQTCn",message:"Share Of Pool"})}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:r})]}):Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,minHeight:36,typography:"body2",borderStyle:"solid",borderWidth:m.spacing(1,0,0),borderColor:"border.main"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:[Yn.jsx(e,{id:"22Xs8M",message:"Deposit Ratio"}),Yn.jsx(f,{ml:4,title:Yn.jsx(e,{id:"I0yi1d",message:"Deposit ratio is determined by the current assets ratio in the pool. The ratio does not represent the exchange price"})})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:t&&ye.utils.singleSideLp(t.type)?Yn.jsx(e,{id:"Kb3KaW",message:"Any Ratio"}):Yn.jsx(Yn.Fragment,{children:Yn.jsx(l,{title:y,children:Yn.jsx(i,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y})})})})]})]})}function JI({baseToken:e,quoteToken:t}){const{toFiatPrice:n,fromFiatPrice:i}=Wg({fromToken:null!=e?e:null,toToken:null!=t?t:null});return function({fromToken:e,toToken:t,fromFiatPrice:n,toFiatPrice:i,reverse:o,showDecimals:r=1}){const a={comparePrice:null,comparePriceText:"",loading:!0};return e&&t&&n&&i?(o?(a.loading=!1,a.comparePrice=i.div(n),a.comparePriceText=`1 ${og(t)} = ${Em({input:a.comparePrice,showDecimals:r})} ${og(e)}`):(a.loading=!1,a.comparePrice=n.div(i),a.comparePriceText=`1 ${og(e)} = ${Em({input:a.comparePrice,showDecimals:r})} ${og(t)}`),a):a}({fromToken:e,toToken:t,fromFiatPrice:i?new Pe(i):void 0,toFiatPrice:n?new Pe(n):void 0})}const eS=(e,t,n)=>{const{comparePrice:i}=JI({baseToken:e,quoteToken:t}),o=$((()=>{if(!(n&&i&&i.toNumber()&&n.toNumber()))return 0;const e=i.minus(n);return Math.abs(e.div(i).toNumber())}),[n,i]),r=$((()=>`${Um(new Pe(o).times(100))}%`),[o]);return{lqAndDodoCompare:o,lqAndDodoCompareText:r,midPrice:n,isShowCompare:o>.01,isWarnCompare:o>.03}};function tS({pool:e,baseAmount:t,quoteAmount:n}){const[i,o,r,a,s,l]=H.useMemo((()=>{var t,n;const{baseToken:i,quoteToken:o}=e||{};let r=!1;if(!i||!o)return[void 0,void 0,void 0,void 0,void 0,r];const a=i.chainId,s=we[a],l=(null===(t=s.address)||void 0===t?void 0:t.toLowerCase())===i.address.toLowerCase(),d=(null===(n=s.address)||void 0===n?void 0:n.toLowerCase())===o.address.toLowerCase(),c=l?s.wrappedTokenAddress:i.address,u=d?s.wrappedTokenAddress:o.address,p=new Sn(i.chainId,c,i.decimals,i.symbol,i.name),h=new Sn(o.chainId,u,o.decimals,o.symbol,o.name);r=!p.sortsBefore(h);const[m,g]=r?[h,p]:[p,h];return[a,null==e?void 0:e.type,null==e?void 0:e.address,m,g,r]}),[e]),d=$m.getReserveLpQuery(i,r,o,null==a?void 0:a.decimals,null==s?void 0:s.decimals),c="AMMV2"===o,u=et(Object.assign(Object.assign({},d),{enabled:!!d.enabled&&c})),p=$m.getTotalBaseLpQuery(i,r,o,18),h=et(Object.assign(Object.assign({},p),{enabled:!!p.enabled&&c})),{account:m}=dg(),g=$m.getUserBaseLpQuery(i,r,o,18,m),f=et(Object.assign(Object.assign({},g),{enabled:!!g.enabled&&c})),x=H.useMemo((()=>u.isFetched&&!!u.data&&h.isFetched&&!!h.data),[u.isFetched,u.data,h.isFetched,h.data]),[y,v]=H.useMemo((()=>{var e;if(!a||!s||!1===x)return[null,null];const{baseReserve:t,quoteReserve:n}=null!==(e=u.data)&&void 0!==e?e:{baseReserve:0,quoteReserve:0},i=En.fromRawAmount(a,Pm(t,a.decimals).toString()),o=En.fromRawAmount(s,Pm(n,s.decimals).toString());let r=i,d=o;l&&(r=o,d=i);const c=new Ln(r,d);if(r.equalTo(0)||d.equalTo(0))return[c,null];const p=d.divide(r);return[c,new An(r.currency,d.currency,p.denominator,p.numerator)]}),[a,s,u.data,l]),[b,j]=H.useMemo((()=>x?v?[new Pe(v.toSignificant()),new Pe(v.invert().toSignificant())]:[void 0,void 0]:t&&n?[new Pe(n).div(t),new Pe(t).div(n)]:[void 0,void 0]),[v,x,t,n]),C=h.data,w=x?h.data&&a?Pm(h.data,18).toString():"":"0";let k,T;const I=l?s:a,S=l?a:s;if((null==y?void 0:y.liquidityToken)&&w&&C&&I&&S){const e=En.fromRawAmount(null==y?void 0:y.liquidityToken,w);if(void 0!==t&&void 0!==n){if(Number(t)&&Number(n)){const i=En.fromRawAmount(I,Pm(t,I.decimals).toString()),o=En.fromRawAmount(S,Pm(n,S.decimals).toString()),r=null==y?void 0:y.getLiquidityMinted(e,i,o);T=_m(r.quotient.toString(),18),k=T.div(C.plus(T)).times(100)}}else T=f.data||void 0,T&&(k=T.div(C).times(100))}else x||(k=new Pe(100));let E="-";return(null==e?void 0:e.baseToken)&&e.quoteToken&&(E=k?`${Em({input:k,showDecimals:2,roundingMode:Pe.ROUND_HALF_UP})}%`:"0%"),{isRearTokenA:l,pair:y,price:b,invertedPrice:j,reserveQuery:u,totalBaseLpQuery:h,liquidityMinted:T,poolTokenPercentage:k,shareOfPool:E,isExists:x}}function nS({pool:e,maxBaseAmount:t,maxQuoteAmount:n,isRemove:i}){var o,r,a;const[s,l]=H.useState(""),[d,c]=H.useState(""),u=!e||"AMMV2"!==e.type&&"AMMV3"!==e.type,p=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(o=null==e?void 0:e.baseToken)||void 0===o?void 0:o.decimals,null===(r=null==e?void 0:e.quoteToken)||void 0===r?void 0:r.decimals)),h=()=>{l(""),c("")},m=null==e?void 0:e.type,g=tS({pool:e,baseAmount:s,quoteAmount:d});let f=null===(a=p.data)||void 0===a?void 0:a.midPrice,x=new Pe(NaN),y=!1,v=!1;const b=p.data;if(e)if(b){const t=b.pmmParamsBG.i,n=b.pmmParamsBG.b,i=b.pmmParamsBG.q;v=("DSP"===e.type||"GSP"===e.type)&&(i.eq(0)||n.eq(0)),y="DVM"===e.type&&new Pe(i).eq(0),x=v?t:y?Pe(1):i.div(n)}else"AMMV2"===m&&(f=g.isRearTokenA?g.invertedPrice:g.price,x=f||new Pe(1));const j=H.useRef(x);if(!e||x.isNaN())return{baseAmount:s,quoteAmount:d,handleChangeBaseAmount:()=>{},handleChangeQuoteAmount:()=>{},reset:h};const C=!y&&!ye.utils.singleSideLp(e.type),w=e.baseToken.decimals,k=e.quoteToken.decimals,T=e=>{if(e){let o=x.multipliedBy(e).dp(k).toString();n&&i&&(n.lte(o)||(null==t?void 0:t.lte(0)))&&(o=n.toString()),c(o)}else c(e)};!C||j.current&&x.isEqualTo(j.current)||(j.current=x,T(s));let I=!1;I=!!e&&ye.utils.singleSideLp(e.type)?!s&&!d:y?!s:!s||!d;const S=u?p:g.reserveQuery;return{baseAmount:s,quoteAmount:d,handleChangeBaseAmount:e=>{let t=Rm(e,w);null===t&&(t=s),l(t),C&&T(t)},handleChangeQuoteAmount:e=>{let o=Rm(e,k);null===o&&(o=d),c(o),C&&(e=>{if(e){let o=new Pe(e).div(x).dp(w).toString();t&&i&&(t.lte(o)||(null==n?void 0:n.lte(0)))&&(o=t.toString()),l(o)}else l(e)})(o)},reset:h,addPortion:x,amountLoading:S.isLoading,amountError:S.isError,amountRefetch:S.refetch,amountCheckedDisabled:I,midPrice:f,uniV2Pair:g}}function iS({submittedBack:e,onlyShowSide:t,pool:n,balanceInfo:o}){var r,s,l,d,u,p;const h=a(),{isMobile:m}=Tg(),{account:g}=dg(),{baseAmount:f,quoteAmount:x,handleChangeBaseAmount:y,handleChangeQuoteAmount:b,addPortion:j,midPrice:C,amountLoading:w,amountCheckedDisabled:k,uniV2Pair:T,reset:I}=nS({pool:n}),S=et($m.getFeeRateQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,g)),E=null===(u=null===(s=null===(r=S.data)||void 0===r?void 0:r.mtFeeRate)||void 0===s?void 0:s.plus(null!==(d=null===(l=S.data)||void 0===l?void 0:l.lpFeeRate)&&void 0!==d?d:0))||void 0===u?void 0:u.toNumber(),A="AMMV2"===(null==n?void 0:n.type),[O,L]=H.useState(!1),{slipper:R,setSlipper:P,slipperValue:_,resetSlipper:M}=oC({address:null==n?void 0:n.address,type:null==n?void 0:n.type}),B=wC(n);H.useEffect((()=>{(null==n?void 0:n.address)!==(null==B?void 0:B.address)&&(I(),M())}),[n]);const D=ye.utils.canOperateLiquidity(null==n?void 0:n.type,void 0,null==n?void 0:n.creator,g),[N,F]=H.useState(!1),{isShowCompare:U,lqAndDodoCompareText:q,isWarnCompare:V}=eS(null==n?void 0:n.baseToken,null==n?void 0:n.quoteToken,C),W=A&&n.chainId?dt(n.chainId)||mt(n.chainId):void 0,$=lf(null==n?void 0:n.baseToken,{amount:f,contractAddress:W}),z=lf(null==n?void 0:n.quoteToken,{amount:x,contractAddress:W}),Z=$.insufficientBalance||z.insufficientBalance,{isSinglePool:G}=o,Q=!n||Z||!C||!!o.loading||!!o.error||k||S.isLoading;let Y=A?se._({id:"bwSQI0",message:"Supply"}):se._({id:"m16xKo",message:"Add"});Z&&(Y=se._({id:"znqB4T",message:"Insufficient balance"}));const K=()=>{I(),M(),e&&e()},{operateLiquidityMutation:X}=GI(n),J=()=>{A?L(!0):X.mutate({txTitle:se._({id:"OBdohg",message:"Add Liquidity"}),isRemove:!1,baseAmount:f,quoteAmount:x,slippageProtection:_,balanceInfo:o,SLIPPAGE_PROTECTION:iC,submittedBack:K})},ee=QI({baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,baseAmount:f,quoteAmount:x,fee:E,isExists:!0,slippage:_,submittedBack:()=>{K(),L(!1)}});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:20,pb:18,px:20},children:["quote"===t?"":Yn.jsx(hj,{amt:f,token:null==n?void 0:n.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:y,readOnly:o.loading||!D,sx:{backgroundColor:"background.cardInput",padding:h.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),t?"":Yn.jsx(uj,{}),"base"===t?"":Yn.jsx(hj,{amt:x,token:null==n?void 0:n.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:b,readOnly:o.loading||!D||G,sx:{backgroundColor:"background.cardInput",padding:h.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}),Yn.jsxs(v,{loading:o.loading||w,sx:{mt:8},children:[Yn.jsx(rC,{value:R,onChange:P,disabled:!D,type:null==n?void 0:n.type}),Yn.jsx(XI,{pool:n,addPortion:j,midPrice:C,shareOfPool:null==T?void 0:T.shareOfPool})]})]}),Yn.jsxs(i,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[U&&Yn.jsx(YI,{baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,lqAndDodoCompareText:q,midPrice:C}),n?Yn.jsx(KI,{chainId:n.chainId,baseTokenStatus:$,quoteTokenStatus:z,children:Yn.jsx(c,{fullWidth:!0,disabled:Q,danger:V,isLoading:X.isPending||ee.isPending,onClick:()=>{Q||(V?F(!0):J())},children:Y})}):Yn.jsx(c,{fullWidth:!0,disabled:!0,children:Y})]}),Yn.jsx(FI,{open:N,onClose:()=>F(!1),title:se._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:J,modal:!0,children:Yn.jsxs(i,{children:[Yn.jsx(i,{children:se._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:q}})}),Yn.jsx(i,{children:se._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),Yn.jsx(ub,{message:null===(p=X.error)||void 0===p?void 0:p.message,onClose:()=>X.reset(),isDialogModal:m}),A&&!!n&&Yn.jsx(WI,{open:O,onClose:()=>L(!1),slippage:_,baseToken:n.baseToken,baseAmount:f,quoteToken:n.quoteToken,quoteAmount:x,fee:E,price:null==T?void 0:T.price,lpAmount:null==T?void 0:T.liquidityMinted,shareOfPool:null==T?void 0:T.shareOfPool,pairAddress:n.address,createMutation:ee})]})}function oS({chainId:e,address:t,token:n,quoteToken:o,lpBalance:a,lpBalanceLoading:s,balanceNeedUpdateLoading:d,tokenBalanceList:c}){var u;const p=o?`${null==n?void 0:n.symbol}/${o.symbol}`:null!==(u=null==n?void 0:n.symbol)&&void 0!==u?u:"";return Yn.jsxs(i,{sx:{display:"flex"},children:[n?Yn.jsx(i,{sx:{position:"relative",top:2},children:o?Yn.jsx(kj,{tokens:[n,o],chainId:e,width:18,mr:4}):Yn.jsx(Df,{address:n.address,width:18,height:18,chainId:e,url:n.logoURI,marginRight:4,noShowChain:!0})}):Yn.jsx(j,{width:32,height:32,sx:{mr:4}}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",flexWrap:"wrap",wordBreak:"break-all"},children:[Yn.jsx(v,{loading:s,loadingProps:{width:30},sx:{display:"flex",alignItems:"center",mr:2},children:d?Yn.jsx(L,{}):Em({input:a||"-"})}),`${p} LP`,!!(null==c?void 0:c.length)&&Yn.jsx(l,{title:Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:c.map((e=>Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",fontWeight:600,color:"text.primary"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{address:e.token.address,chainId:e.token.chainId,width:14,height:14,url:e.token.logoURI,marginRight:4,noShowChain:!0}),e.token.symbol]}),Yn.jsxs(v,{loading:e.loading,children:[!e.balance||e.balance.isZero()||e.balance.isNaN()?"":"~",e.balance?Em({input:e.balance}):""]})]},e.token.address)))}),sx:{padding:20,width:256},children:Yn.jsx(r,{component:li.DetailBorder,sx:{ml:4,width:16,height:16}})}),Yn.jsx(i,{component:"a",target:"_blank",rel:"noopener noreferrer",href:e?tg(e,t,"address"):"",sx:{display:"inline-flex",height:14},children:Yn.jsx(r,{component:li.ArrowTopRightBorder,sx:{ml:4,width:14,height:14}})})]})]},t)}function rS({loading:t,hidePoolInfo:n,pool:o,balanceInfo:r}){var s,c,u,p,h,m,g;const f=a(),x=t||!o,y=!!o&&ye.utils.singleSideLp(o.type),{isTokenLoading:b}=Mb(),{account:j}=dg(),C=et($m.getFeeRateQuery(null==o?void 0:o.chainId,null==o?void 0:o.address,null==o?void 0:o.type,j)),w=null===(c=null===(s=C.data)||void 0===s?void 0:s.lpFeeRate)||void 0===c?void 0:c.plus(null!==(p=null===(u=C.data)||void 0===u?void 0:u.mtFeeRate)&&void 0!==p?p:0);let k=!1,T=!1;o&&(r.userBaseLpBalance&&o.baseLpToken&&(k=b(o.baseLpToken.id,r.userBaseLpBalance)),r.userQuoteLpBalance&&o.quoteLpToken&&(T=b(o.quoteLpToken.id,r.userQuoteLpBalance)));const I="AMMV2"===(null==o?void 0:o.type);return Yn.jsxs(i,{sx:{mt:16,mx:20,border:"solid 1px",borderColor:"border.main",borderRadius:12},children:[n?"":Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:f.spacing(12,20),borderStyle:"solid",borderColor:"border.main",borderWidth:f.spacing(0,0,1)},children:[Yn.jsxs(i,{children:[Yn.jsxs(v,{loading:x,loadingSx:{width:100,mb:4},sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[null===(h=null==o?void 0:o.baseToken)||void 0===h?void 0:h.symbol,"/",null===(m=null==o?void 0:o.quoteToken)||void 0===m?void 0:m.symbol,"AMMV2"===(null==o?void 0:o.type)&&Yn.jsx(v,{loading:C.isLoading,loadingProps:{width:30},sx:{typography:"h6"},children:Yn.jsx(l,{title:Yn.jsxs(i,{sx:{typography:"h6","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",Yn.jsx("b",{children:Yn.jsx(e,{id:"e38JNU",message:"Tips:"})})," ",Yn.jsx(e,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vm({input:w})},components:{0:Yn.jsx("b",{})}})]}),sx:{maxWidth:240},children:Yn.jsx(i,{sx:{px:8,height:24,typography:"h6",lineHeight:"24px",borderRadius:4,background:f.palette.background.tag,color:"text.secondary",whiteSpace:"nowrap"},children:Vm({input:w})})})})]}),Yn.jsx(v,{loading:x,children:Yn.jsx(zb,{address:null!==(g=null==o?void 0:o.address)&&void 0!==g?g:"",truncate:!0,iconSize:14,iconSpace:4,customChainId:null==o?void 0:o.chainId,sx:{typography:"h6",color:"text.secondary"}})})]}),(null==o?void 0:o.address)&&!I?Yn.jsxs(i,{component:d,sx:{typography:"body2",display:"flex",alignItems:"center",color:"text.secondary"},onClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:o.chainId,address:o.address}})},children:[Yn.jsx(e,{id:"URmyfc",message:"Details"}),Yn.jsx(i,{component:li.ArrowRight,sx:{ml:4,position:"relative",top:1.2,width:16,height:16}})]}):""]}),Yn.jsxs(i,{sx:{p:f.spacing(12,20)},children:[Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),Yn.jsx(i,{sx:{mt:12},children:Yn.jsx(v,{loading:x,loadingSx:{width:100},children:y?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(oS,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,lpBalance:null==r?void 0:r.userBaseLpBalance,lpBalanceLoading:r.userLpBalanceLoading,balanceNeedUpdateLoading:k,tokenBalanceList:o?[{token:o.baseToken,balance:null==r?void 0:r.userBaseLpToTokenBalance,loading:r.userLpToTokenBalanceLoading}]:void 0}),Yn.jsx(oS,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.quoteToken,lpBalance:null==r?void 0:r.userQuoteLpBalance,lpBalanceLoading:r.userLpBalanceLoading,balanceNeedUpdateLoading:T,tokenBalanceList:o?[{token:o.quoteToken,balance:null==r?void 0:r.userQuoteLpToTokenBalance,loading:r.userLpToTokenBalanceLoading}]:void 0})]}):Yn.jsx(oS,{chainId:null==o?void 0:o.chainId,address:null==o?void 0:o.address,token:null==o?void 0:o.baseToken,quoteToken:null==o?void 0:o.quoteToken,lpBalance:r.userBaseLpBalance,lpBalanceLoading:r.userLpBalanceLoading,balanceNeedUpdateLoading:k,tokenBalanceList:o?[{token:o.baseToken,balance:r.userBaseLpToTokenBalance||new Pe(0),loading:r.userLpToTokenBalanceLoading},{token:o.quoteToken,balance:r.userQuoteLpToTokenBalance||new Pe(0),loading:r.userLpToTokenBalanceLoading}]:void 0})})})]})]})}const aS=({pool:e,isBase:t,baseAmount:n,quoteAmount:i})=>{var o,r;const a="CLASSICAL"===(null==e?void 0:e.type),s=t||void 0===t,l=null===(o=null==e?void 0:e.baseToken)||void 0===o?void 0:o.decimals,d=null===(r=null==e?void 0:e.quoteToken)||void 0===r?void 0:r.decimals,c=et(Object.assign(Object.assign({},$m.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,n&&void 0!==l?zt(new Pe(n).dp(l,Pe.ROUND_FLOOR).toString(),l).toString():"",l)),{enabled:!!e&&!!n&&a&&s})),u=et(Object.assign(Object.assign({},$m.getWithdrawBasePenaltyQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,i&&void 0!==d?zt(new Pe(i).dp(d,Pe.ROUND_FLOOR).toString(),d).toString():"",d)),{enabled:!!e&&!!i&&a&&!s}));let p,h="",m="",g="",f="",x="",y=!1,v=null;if(e){const t=rg(e.baseToken.decimals),o=rg(e.quoteToken.decimals);if(g=Em({input:n,showDecimals:t}),f=Em({input:i,showDecimals:o}),a)if(y=s?c.isLoading:u.isLoading,v=s?c.error:u.error,s){if(c.data){h=Em({input:c.data,showDecimals:t}),x=h;const e=new Pe(n).minus(c.data);g=e.gt(0)?Em({input:e,showDecimals:t}):"-",p=e}}else if(u.data){m=Em({input:u.data,showDecimals:o}),x=m;const e=new Pe(i).minus(u.data);g=e.gt(0)?Em({input:e,showDecimals:t}):"-",p=e}}let b=[];return e&&(a?t?b.push({amount:g||"0",symbol:e.baseToken.symbol}):b.push({amount:f||"0",symbol:e.quoteToken.symbol}):(b.push({amount:g||"0",symbol:e.baseToken.symbol}),b.push({amount:f||"0",symbol:e.quoteToken.symbol}))),{withdrawFee:x,baseWithdrawFee:h,quoteWithdrawFee:m,receiveBaseAmount:g,receiveQuoteAmount:f,receiveAmountBg:p,receiveList:b,loading:y,error:v}};var sS;!function(e){e[e.base=1]="base",e[e.quote=2]="quote"}(sS||(sS={}));const lS=e=>{const[t,n]=H.useState(sS.base);let i,o;return e&&ye.utils.singleSideLp(e.type)&&(i=t===sS.base,o=i?e.baseToken:e.quoteToken),{isBase:i,checkToken:o,checkTokenType:t,setCheckToken:n}};function dS({token:e,pool:t,sx:n,value:o,onChange:r,selectedValue:a,lpBalance:s,balanceMax:l,balanceInfo:d,loading:c}){var u;const p=null==t?void 0:t.chainId;return Yn.jsxs(i,{sx:n,children:[Yn.jsxs(i,{sx:{typography:"h5",display:"flex",alignItems:"center",justifyContent:"space-between",fontWeight:600},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[e?Yn.jsx(U,{checked:o===a,onChange:()=>r(o),sx:{mr:16}}):"",Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:e?Yn.jsx(Yn.Fragment,{children:Yn.jsx(Df,{address:e.address,width:24,height:24,chainId:e.chainId||p,url:e.logoURI,noShowChain:!0})}):t&&Yn.jsx(kj,{tokens:[t.baseToken,t.quoteToken],chainId:(null===(u=t.baseToken)||void 0===u?void 0:u.chainId)||p,width:24,height:24})})]}),Yn.jsxs(i,{sx:{textAlign:"right"},children:[e?`${e.symbol} LP `:t&&`${t.baseToken.symbol}\n ${t.quoteToken.symbol}\n LP `,c?Yn.jsx(i,{component:L,sx:{ml:4,position:"relative",top:3}}):s&&Em({input:s})||""]})]}),Yn.jsx(i,{sx:{typography:"body2",mt:5,color:"text.secondary",textAlign:"right"},children:e?Yn.jsxs(Yn.Fragment,{children:[c?Yn.jsx(i,{component:L,sx:{ml:4,position:"relative",top:3}}):`≈ ${l&&Em({input:l})||""}`,` ${e.symbol}`]}):t&&d&&d.userBaseLpToTokenBalance&&d.userQuoteLpToTokenBalance?Yn.jsxs(Yn.Fragment,{children:[c?Yn.jsx(i,{component:L,sx:{position:"relative",top:4}}):Em({input:d.userBaseLpToTokenBalance}),` ${null==t?void 0:t.baseToken.symbol} + `,c?Yn.jsx(i,{component:L,sx:{position:"relative",top:4}}):Em({input:d.userQuoteLpToTokenBalance}),` ${null==t?void 0:t.quoteToken.symbol}`]}):""})]})}function cS({pool:e,checkTokenType:t,setCheckToken:n,balanceInfo:i,baseTokenBalanceUpdateLoading:o,quoteBalanceUpdateLoading:r}){if(!e)return null;const a=ye.utils.singleSideLp(e.type);return Yn.jsx(Yn.Fragment,{children:a?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(dS,{token:e.baseToken,selectedValue:t,onChange:n,value:sS.base,lpBalance:i&&i.userBaseLpBalance,balanceMax:i&&i.userBaseLpToTokenBalance,loading:o}),Yn.jsx(dS,{selectedValue:t,onChange:n,sx:{mt:13},token:e.quoteToken,value:sS.quote,lpBalance:i&&i.userQuoteLpBalance,balanceMax:i&&i.userQuoteLpToTokenBalance,loading:r})]}):Yn.jsx(dS,{pool:e,value:t,onChange:n,lpBalance:i&&i.userBaseLpBalance,balanceInfo:i,loading:o||r})})}function uS({submittedBack:n,onlyShowSide:o,pool:r,balanceInfo:s}){var l,d,u,p,h,m,g,f,x,y;const b=a(),{isMobile:j}=Tg(),{account:C}=dg(),w=s.userBaseLpToTokenBalance,k=s.userQuoteLpToTokenBalance,T=s.loading,{slipper:I,setSlipper:S,slipperValue:E,resetSlipper:A}=oC({address:null==r?void 0:r.address}),{isBase:O,checkToken:L,checkTokenType:R,setCheckToken:P}=lS(r),{baseAmount:_,quoteAmount:M,handleChangeBaseAmount:B,handleChangeQuoteAmount:D,addPortion:N,midPrice:F,amountLoading:U,amountCheckedDisabled:V,uniV2Pair:W,reset:z}=nS({pool:r,maxBaseAmount:w,maxQuoteAmount:k}),[Z,G]=H.useState(""),[Q,Y]=H.useState("");H.useEffect((()=>{const e=setTimeout((()=>{G(_)}),80);return()=>clearTimeout(e)}),[_]),H.useEffect((()=>{const e=setTimeout((()=>{Y(M)}),80);return()=>clearTimeout(e)}),[M]);const K=e=>{B(e)},X=e=>{D(e)},J="AMMV2"===(null==r?void 0:r.type),ee=(null==r?void 0:r.chainId)?we[r.chainId]:void 0,te=null===(l=null==ee?void 0:ee.address)||void 0===l?void 0:l.toLowerCase(),ne=null===(d=null==ee?void 0:ee.wrappedTokenAddress)||void 0===d?void 0:d.toLowerCase(),ie=!!r&&[te,ne].includes(r.baseToken.address.toLowerCase()),oe=!!r&&[te,ne].includes(r.quoteToken.address.toLowerCase()),re=J&&r&&(ie||oe),[ae,le]=H.useState(!1),de=re&&ie&&!ae&&ee?r?Object.assign(Object.assign({},r.baseToken),{symbol:ee.symbol,address:ee.address}):void 0:null==r?void 0:r.baseToken,ce=re&&oe&&!ae&&ee?r?Object.assign(Object.assign({},r.quoteToken),{symbol:ee.symbol,address:ee.address}):void 0:null==r?void 0:r.quoteToken,ue=aS({pool:r?Object.assign(Object.assign({},r),{baseToken:de,quoteToken:ce}):r,isBase:O,baseAmount:Z,quoteAmount:Q}),{mode:pe,modeOptions:he,handleChangeMode:me,sliderPercentage:ge,handleChangeSliderPercentage:fe,resetPercentage:xe}=function({isBase:e,pool:t,baseOverride:n,quoteOverride:i,resetAmount:o,handleChangeBaseAmount:r,handleChangeQuoteAmount:a}){const[s,l]=H.useState(sC.percentage),[d,c]=H.useState(aC),u=H.useRef(null),p=()=>{u.current&&clearTimeout(u.current)},h=()=>{p(),c(aC)};return H.useEffect((()=>p),[]),{mode:s,modeOptions:[{key:sC.quantity,value:se._({id:"PIYEqF",message:"Quantity model"})},{key:sC.percentage,value:se._({id:"x4QVeW",message:"Percentage to remove"})}],handleChangeMode:e=>{l(e),o(),h()},sliderPercentage:d,handleChangeSliderPercentage:o=>{if(p(),o!==d&&c(o),!t)return;const s=100===o,l=()=>{if(t)if(e||void 0===e){if(n){let e=n.toString();s||(e=Lm(n.times(o/100),t.baseToken.decimals)),r(e)}}else if(i){let e=i.toString();s||(e=Lm(i.times(o/100),t.quoteToken.decimals)),a(e)}};s?l():u.current=setTimeout(l,100)},resetPercentage:h}}({isBase:O,pool:r,baseOverride:w,quoteOverride:k,resetAmount:z,handleChangeBaseAmount:K,handleChangeQuoteAmount:X});H.useEffect((()=>{z(),xe()}),[R]);const ve=wC(r);H.useEffect((()=>{(null==r?void 0:r.address)!==(null==ve?void 0:ve.address)&&(z(),A(),me(sC.percentage),fe(aC))}),[r]),H.useEffect((()=>{pe===sC.percentage&&fe(ge)}),[null==w?void 0:w.toString(),null==k?void 0:k.toString()]);const be=ye.utils.canOperateLiquidity(null==r?void 0:r.type,void 0,null==r?void 0:r.creator,C),[je,Ce]=H.useState(!1),{isShowCompare:ke,lqAndDodoCompareText:Ie,isWarnCompare:Se}=eS(null==r?void 0:r.baseToken,null==r?void 0:r.quoteToken,F),Ee=et($m.getFeeRateQuery(null==r?void 0:r.chainId,null==r?void 0:r.address,null==r?void 0:r.type,C)),Ae=null===(g=null===(p=null===(u=Ee.data)||void 0===u?void 0:u.mtFeeRate)||void 0===p?void 0:p.plus(null!==(m=null===(h=Ee.data)||void 0===h?void 0:h.lpFeeRate)&&void 0!==m?m:0))||void 0===g?void 0:g.toNumber(),{baseTokenStatus:Oe,quoteTokenStatus:Le}=function({pool:e,baseAmount:t,quoteAmount:n,balanceInfo:i}){var o,r,a,s,l;const{chainId:d,baseToken:c,quoteToken:u}=null!=e?e:{};let p="";const h="AMMV2"===(null==e?void 0:e.type);d&&(p=null!==(o=Te[d].DODO_V1_PAIR_PROXY)&&void 0!==o?o:"",h&&(p=dt(d)||mt(e.chainId)));const m=null!==(a=null===(r=null==e?void 0:e.baseLpToken)||void 0===r?void 0:r.id)&&void 0!==a?a:"",g=null!==(l=null===(s=null==e?void 0:e.quoteLpToken)||void 0===s?void 0:s.id)&&void 0!==l?l:"",f="CLASSICAL"===(null==e?void 0:e.type);return{baseTokenStatus:lf(c?Object.assign(Object.assign({},c),{symbol:f?c.symbol+" LP":`${c.symbol}/${null==u?void 0:u.symbol} LP`,address:m}):void 0,{amount:h&&i.userBaseLpToTokenBalance&&i.userBaseLpBalance?new Pe(t).div(i.userBaseLpToTokenBalance).times(i.userBaseLpBalance).toString():t,skipQuery:!p||!m||!f&&!h,contractAddress:p,overrideBalance:h?i.userBaseLpBalance:i.userBaseLpToTokenBalance}),quoteTokenStatus:lf(u?Object.assign(Object.assign({},u),{address:g}):void 0,{amount:n,skipQuery:!p||!g||!f,contractAddress:p,overrideBalance:i.userQuoteLpToTokenBalance})}}({pool:r,baseAmount:_,quoteAmount:M,balanceInfo:s}),Re=Oe.insufficientBalance||Le.insufficientBalance,{isSinglePool:_e}=s,Me=Re?se._({id:"znqB4T",message:"Insufficient balance"}):se._({id:"t/YqKh",message:"Remove"}),Be=()=>{z(),A(),n&&n()},De=null===(f=null==W?void 0:W.pair)||void 0===f?void 0:f.liquidityToken.decimals,Ne=null===(x=s.userBaseLpBalance)||void 0===x?void 0:x.times(ge/100),Fe=Ne&&void 0!==De?Pm(Ne,De).toString():"",{operateLiquidityMutation:Ue}=GI(r),qe=function({baseToken:e,quoteToken:n,baseAmount:i,quoteAmount:o,liquidityAmount:r,slippage:a,fee:s,submittedBack:l}){const d=Fg(),{account:c}=dg();t();const{deadLine:u}=Jn();return it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){if(!e||!n)throw new Error("token is undefined");if(!c)throw new Error("account is undefined");if(!s)throw new Error("fee is undefined");const t=e.chainId,p=we[t].address.toLowerCase(),h=dt(t),m=mt(t),g=!h,f=h||m;if(!f)throw new Error("AMMV2 contract address is not valid.");let x="";const y=e.address.toLowerCase()===p,v=n.address.toLowerCase()===p,b=Pm(new Pe(i).times(1-a),e.decimals),j=Pm(new Pe(o).times(1-a),n.decimals),C=Pm(s,4).toString(),w=Math.ceil(Date.now()/1e3)+(null!=u?u:600);try{if(y){const e=n.address,t=j.toString(),i=b.toString();x=g?vt(e,r,t,i,c,w):bt(e,C,r,t,i,c,w)}else if(v){const t=e.address,n=b.toString(),i=j.toString();x=g?vt(t,r,n,i,c,w):bt(t,C,r,n,i,c,w)}else x=g?jt(e.address,n.address,r,b.toString(),j.toString(),c,w):Ct(e.address,n.address,C,r,b.toString(),j.toString(),c,w)}catch(e){throw console.error("encodeUniswapV2Router02RemoveLiquidity error",e),e}return yield d.execute(se._({id:"cJtosk",message:"Remove liquidity"}),{opcode:Pg.TX,to:f,data:x,value:"0x0"},{metadata:{[Sg.removeLiqidityAMMV2Position]:!0},submittedBack:l})}))})}({baseToken:de,quoteToken:ce,baseAmount:_,quoteAmount:M,liquidityAmount:Fe,slippage:E,fee:Ae,submittedBack:Be}),Ve=()=>{if(J)return qe.mutate();Ue.mutate({txTitle:se._({id:"3XBvkd",message:"Remove Liquidity"}),isRemove:!0,baseAmount:_,quoteAmount:M,slippageProtection:E,balanceInfo:s,SLIPPAGE_PROTECTION:iC,submittedBack:Be})},We=$((()=>{var e;const t=new Pe(_),n=new Pe(M);return!r||Re||!F||!!s.loading||!!s.error||V||!!ue.error||ue.loading||!!(null===(e=ue.receiveAmountBg)||void 0===e?void 0:e.lte(0))||Ee.isLoading||(J?null==Ne||Ne.lte(0):!t.isFinite()||!n.isFinite()||t.lte(0)&&n.lte(0))}),[V,s.error,s.loading,_,Ee.isLoading,J,Re,Ne,F,r,M,ue.error,ue.loading,ue.receiveAmountBg]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pb:18,px:20},children:[!J&&Yn.jsxs(i,{sx:{mt:20,borderStyle:"solid",borderWidth:1,borderRadius:12,borderColor:"border.main"},children:[Yn.jsx(q,{value:pe,options:he,onChange:(e,t)=>me(t),popupOffset:0,sx:{px:20,py:12,width:"100%",backgroundColor:"transparent",color:"text.primary",typography:"body2"}}),!!r&&ye.utils.singleSideLp(r.type)&&Yn.jsx(i,{sx:{pt:20,pb:13,px:20,borderStyle:"solid",borderWidth:"1px 0 0"},children:Yn.jsx(cS,{pool:r,balanceInfo:s,checkTokenType:R,setCheckToken:P,baseTokenBalanceUpdateLoading:!1,quoteBalanceUpdateLoading:!1})})]}),Yn.jsx(i,{sx:{pt:20},children:pe===sC.percentage?Yn.jsx(Kj,{disabled:s.loading||!be,value:ge,onChange:fe}):L?Yn.jsx(hj,{amt:O?_:M,token:L,canClickBalance:!0,showPercentage:!0,onInputChange:O?K:X,readOnly:s.loading||!be,overrideBalance:O?w:k,overrideBalanceLoading:T,sx:{backgroundColor:"background.cardInput",padding:b.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(hj,{amt:_,token:null==r?void 0:r.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:K,readOnly:s.loading||!be,overrideBalance:w,overrideBalanceLoading:T,sx:{backgroundColor:"background.cardInput",padding:b.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"}}),o?"":Yn.jsx(uj,{}),"base"===o?"":Yn.jsx(hj,{amt:M,token:null==r?void 0:r.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:X,readOnly:s.loading||!be||_e,overrideBalance:k,overrideBalanceLoading:T,sx:{backgroundColor:"background.cardInput",padding:b.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"}})]})}),Yn.jsxs(v,{loading:s.loading||U,sx:{mt:8},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"flex-end",gap:8},children:[J&&re&&Yn.jsx(i,{sx:{px:12,py:4,borderRadius:20,borderWidth:1,backgroundColor:"transparent",color:"primary.main",cursor:"pointer",typography:"body2","&:hover":{backgroundColor:"hover.default"}},component:"button",onClick:()=>le((e=>!e)),children:Yn.jsx(e,{id:"/k7Ttv",message:"Receive {0}",values:{0:ae?null==ee?void 0:ee.symbol:null==ee?void 0:ee.wrappedTokenSymbol}})}),Yn.jsx(rC,{value:I,onChange:S,disabled:!be,type:null==r?void 0:r.type,sx:{margin:0}})]}),Yn.jsx(XI,{pool:r,addPortion:N,midPrice:F,shareOfPool:null==W?void 0:W.shareOfPool})]}),!!r&&Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",mt:20,mb:14},children:[Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary",position:"relative",top:2},children:Yn.jsx(e,{id:"lDgVWA",message:"Receive"})}),Yn.jsx(i,{sx:{textAlign:"right"},children:ue.receiveList.map(((e,t)=>Yn.jsxs(i,{sx:{mt:t>0?4:0},children:[Yn.jsxs(v,{component:"span",loading:ue.loading,loadingSx:{mr:8,width:100},sx:{display:"inline-block",typography:"h5",fontWeight:600,color:ue.receiveBaseAmount&&"0"!==ue.receiveBaseAmount?"primary.main":"text.primary"},children:[e.amount," "]}),Yn.jsx(i,{component:"span",sx:{typography:"body2"},children:e.symbol})]},e.symbol)))})]})]}),Yn.jsxs(i,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:[ke&&Yn.jsx(YI,{baseToken:null==r?void 0:r.baseToken,quoteToken:null==r?void 0:r.quoteToken,lqAndDodoCompareText:Ie,midPrice:F}),r?Yn.jsx(KI,{chainId:r.chainId,baseTokenStatus:Oe,quoteTokenStatus:Le,children:Yn.jsx(c,{fullWidth:!0,disabled:We,danger:Se,isLoading:Ue.isPending||qe.isPending,onClick:()=>{We||(Se?Ce(!0):Ve())},children:Me})}):Yn.jsx(c,{fullWidth:!0,disabled:!0,children:Me})]}),Yn.jsx(FI,{open:je,onClose:()=>Ce(!1),title:se._({id:"bEsfUQ",message:"Confirm submission"}),onConfirm:Ve,modal:!0,children:Yn.jsxs(i,{children:[Yn.jsx(i,{children:se._({id:"tecieV",message:"Price discrepancy {lqAndDodoCompareText} between liquidity pool and the quote price on ZUNO.",values:{lqAndDodoCompareText:Ie}})}),Yn.jsx(i,{children:se._({id:"vXvgFK",message:"There is risk of being arbitraged if adding this liquidity."})})]})}),Yn.jsx(ub,{message:null===(y=Ue.error)||void 0===y?void 0:y.message,onClose:()=>Ue.reset(),isDialogModal:j})]})}function pS({pool:e,operate:n,hidePoolInfo:i,errorRefetch:o,submittedBack:r}){var a,s,l,d,c,u;const{operateTab:p,operateTabs:h,handleChangeTab:m}=function(e=YT.Add){const{i18n:n}=t(),[i,o]=H.useState(e),r=H.useMemo((()=>[{key:YT.Add,value:n._({id:"m16xKo",message:"Add"})},{key:YT.Remove,value:n._({id:"t/YqKh",message:"Remove"})}]),[n._]);return H.useEffect((()=>{o(e)}),[e]),{operateTab:i,operateTabs:r,handleChangeTab:e=>{o(e)}}}(n),{account:g}=dg(),f=xI({account:g,pool:e?{chainId:e.chainId,address:e.address,type:e.type,baseTokenDecimals:e.baseToken.decimals,quoteTokenDecimals:e.quoteToken.decimals,baseLpTokenDecimals:null!==(s=null===(a=e.baseLpToken)||void 0===a?void 0:a.decimals)&&void 0!==s?s:18,quoteLpTokenDecimals:null!==(d=null===(l=e.quoteLpToken)||void 0===l?void 0:l.decimals)&&void 0!==d?d:18}:void 0}),x=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(c=null==e?void 0:e.baseToken)||void 0===c?void 0:c.decimals,null===(u=null==e?void 0:e.quoteToken)||void 0===u?void 0:u.decimals));return f.error||x.error||o?Yn.jsx(ai,{refresh:()=>{f.error&&f.refetch(),x.error&&x.refetch(),o&&o()},sx:{my:40,height:"100%"}}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(rS,{pool:e,balanceInfo:f,hidePoolInfo:i}),Yn.jsxs(S,{value:p,onChange:(e,t)=>{m(t)},children:[Yn.jsx(F,{tabs:h,variant:"inPaper",tabsListSx:{mt:16,mx:20}}),Yn.jsx(O,{value:YT.Add,children:Yn.jsx(iS,{pool:e,balanceInfo:f,submittedBack:r})}),Yn.jsx(O,{value:YT.Remove,children:Yn.jsx(uS,{pool:e,balanceInfo:f,submittedBack:r})})]})]})}function hS({onClose:e,pool:n,address:o,operate:r,chainId:a,hasMining:s,hidePoolInfo:l,sx:d}){var c,u,p,h,m,g,f,x,y;const{account:v}=dg(),b=a?Wu[a]:"",j=gg(),C=et(Object.assign(Object.assign({},j.getQuery(ye.graphql.fetchPoolList,{where:{id:null!==(c=null==o?void 0:o.toLocaleLowerCase())&&void 0!==c?c:"",chain:b}})),{enabled:!!o&&!!a})),w=null===(p=null===(u=C.data)||void 0===u?void 0:u.pairs)||void 0===p?void 0:p[0],k=w&&a?function(e,t){var n,i,o,r,a,s;if(e)return{address:e.id,chainId:t,baseToken:Zm(e.baseToken,t),quoteToken:Zm(e.quoteToken,t),type:e.type,creator:e.creator,baseLpToken:{id:null===(n=e.baseLpToken)||void 0===n?void 0:n.id,decimals:Number(null!==(o=null===(i=e.baseLpToken)||void 0===i?void 0:i.decimals)&&void 0!==o?o:18)},quoteLpToken:{id:null===(r=e.quoteLpToken)||void 0===r?void 0:r.id,decimals:Number(null!==(s=null===(a=e.quoteLpToken)||void 0===a?void 0:a.decimals)&&void 0!==s?s:18)}}}(w,a):void 0,I=o&&a?k:n,E=C.error?C.refetch:void 0,{poolOrMiningTab:A,poolOrMiningTabs:L,handleChangeTab:R}=function({hasMining:e}){const{i18n:n}=t(),[i,o]=H.useState(NI.Liquidity);return{poolOrMiningTab:i,poolOrMiningTabs:H.useMemo((()=>{const t=[{key:NI.Liquidity,value:n._({id:"6y2TB3",message:"Liquidity"})},{key:NI.Mining,value:n._({id:"Sti4vy",message:"Mining"})}];return e?t:t.slice(0,1)}),[n._,e]),handleChangeTab:e=>{o(e)}}}({hasMining:s}),P=xI({account:v,pool:I?{chainId:I.chainId,address:I.address,type:I.type,baseTokenDecimals:I.baseToken.decimals,quoteTokenDecimals:I.quoteToken.decimals,baseLpTokenDecimals:null!==(m=null===(h=I.baseLpToken)||void 0===h?void 0:h.decimals)&&void 0!==m?m:18,quoteLpTokenDecimals:null!==(f=null===(g=I.quoteLpToken)||void 0===g?void 0:g.decimals)&&void 0!==f?f:18}:void 0}),_=!!(null===(x=P.userBaseLpBalance)||void 0===x?void 0:x.gt(0))||!!(null===(y=P.userQuoteLpBalance)||void 0===y?void 0:y.gt(0)),M=null!=a?a:null==I?void 0:I.chainId,B=null!=o?o:null==I?void 0:I.address;return Yn.jsx(i,{sx:d,children:Yn.jsxs(S,{value:A,onChange:(e,t)=>{R(t)},sx:{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%"},children:[Yn.jsx(D,{tabs:L,tabsListSx:Object.assign({mx:20,justifyContent:"space-between"},s&&_?{"& button:last-child":{position:"relative","&::before":{content:`"${se._({id:"TY5fM3",message:"LP Tokens"})}"`,position:"absolute",top:16,right:20,px:8,py:2,borderRadius:12,transform:"scale(0.66667) translateX(100%)",transformOrigin:"right top",backgroundColor:T("#DABB1B",.2),color:"#DABB1B"}}}:{}),rightSlot:Yn.jsxs(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:12},children:["GSP"===(null==I?void 0:I.type)&&Yn.jsx(DI,{}),e?Yn.jsx(i,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,borderStyle:"solid",borderColor:"border.main",color:"text.secondary","&:hover":{color:"text.primary"},cursor:"pointer"},children:Yn.jsx(i,{component:li.Error,sx:{width:16,height:16},onClick:()=>{e()}})}):void 0]})}),Yn.jsx(O,{value:NI.Liquidity,sx:{flex:1,overflowY:"auto"},children:Yn.jsx(pS,{pool:I,operate:r,hidePoolInfo:l,errorRefetch:E,submittedBack:()=>{s&&R(NI.Mining)}})}),Yn.jsx(O,{value:NI.Mining,sx:{flex:1,overflowY:"auto"},children:M&&B?Yn.jsx(BI,{chainId:M,account:v,poolAddress:B,goLpLink:()=>{R(NI.Liquidity)}}):""})]})})}function mS(e){var{modal:t}=e,n=qn(e,["modal"]);const{isMobile:i}=Tg();return Yn.jsx(Of,{open:!!n.pool||!!n.address,onClose:n.onClose,scope:!i,modal:t,id:"pool-operate",children:Yn.jsx(hS,{...n})})}function gS({address:t,chainId:n,hideName:o,sx:r}){const s=a(),c=gg(),{onlyChainId:u}=Jn(),p=et(Object.assign({},c.getQuery(Oe.graphql.fetchLiquidityLpPartnerRewards,{where:{chainId:u||void 0}})));if(!t)return null;const h=[];return("string"==typeof t?[t]:Array.from(new Set(t)).filter((e=>!!e))).forEach((e=>{var t,i,o;e&&(null===(o=null===(i=null===(t=p.data)||void 0===t?void 0:t.liquidity_getLpPartnerRewards)||void 0===i?void 0:i.partnerRewards)||void 0===o||o.some((t=>{var i,o,r,a,s,l,d,c,u,m,g,f,x,y;if((null==t?void 0:t.chainId)===n&&(null===(i=null==t?void 0:t.pool)||void 0===i?void 0:i.toLocaleLowerCase())===e.toLocaleLowerCase()){const e=null===(a=null===(r=null===(o=p.data)||void 0===o?void 0:o.liquidity_getLpPartnerRewards)||void 0===r?void 0:r.partnerInfos)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.partner)===t.partner));if(!e)return;h.push({partner:{name:null!==(s=null==e?void 0:e.partner)&&void 0!==s?s:"",logo:null!==(l=null==e?void 0:e.logo)&&void 0!==l?l:"",introduction:null!==(d=null==e?void 0:e.introduction)&&void 0!==d?d:"",link:null!==(c=null==e?void 0:e.link)&&void 0!==c?c:"",extra:null!==(u=null==e?void 0:e.extra)&&void 0!==u?u:{},background:(null===(m=null==e?void 0:e.theme)||void 0===m?void 0:m[0])||void 0,color:(null===(g=null==e?void 0:e.theme)||void 0===g?void 0:g[1])||void 0},reward:null!==(f=null==t?void 0:t.reward)&&void 0!==f?f:"",type:null!==(x=null==t?void 0:t.type)&&void 0!==x?x:"stakelp",sort:null!==(y=null==e?void 0:e.sort)&&void 0!==y?y:Number.MAX_SAFE_INTEGER})}})))})),(null==h?void 0:h.length)?(h.sort(((e,t)=>e.sort-t.sort)),Yn.jsx(i,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},r),children:h.map((t=>Yn.jsx(l,{leaveDelay:100,title:Yn.jsxs(i,{sx:{maxWidth:240,whiteSpace:"pre-wrap"},children:[t.partner.introduction,!!t.partner.link&&Yn.jsxs(i,{component:"a",target:"_blank",href:t.partner.link,rel:"noopener noreferrer",sx:{display:"flex",alignItems:"center",gap:4,color:"primary.main","&:hover":{opacity:.5}},children:[Yn.jsx(e,{id:"zwWKhA",message:"Learn more"})," ",Yn.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 2.91667V11.0833H11.0833V7H12.25V11.0833C12.25 11.725 11.725 12.25 11.0833 12.25H2.91667C2.26917 12.25 1.75 11.725 1.75 11.0833V2.91667C1.75 2.275 2.26917 1.75 2.91667 1.75H7V2.91667H2.91667ZM8.16667 2.91667V1.75H12.25V5.83333H11.0833V3.73917L5.34917 9.47333L4.52667 8.65083L10.2608 2.91667H8.16667Z",fill:"currentColor"})})]})]}),children:Yn.jsxs(d,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,p:s.spacing(0,4),height:20,borderRadius:4,background:t.partner.background,color:t.partner.color,whiteSpace:"nowrap"},children:[Yn.jsx(i,{component:"img",src:t.partner.logo,alt:t.partner.name,sx:{width:14,height:14,borderRadius:"50%"}}),!o&&!!t.reward&&Yn.jsx(i,{sx:{fontSize:"10px",fontWeight:600},children:t.reward})]})},t.partner.name+t.reward)))})):null}var fS,xS;function yS(){return yS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},yS.apply(null,arguments)}const vS=e=>W.createElement("svg",yS({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),fS||(fS=W.createElement("circle",{cx:16,cy:16,r:16,fill:"#FFE804"})),xS||(xS=W.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.5 12.25H12.25V8.5H8.5V12.25ZM14.125 23.5H17.875V19.75H14.125V23.5ZM12.25 23.5H8.5V19.75H12.25V23.5ZM8.5 17.875H12.25V14.125H8.5V17.875ZM17.875 17.875H14.125V14.125H17.875V17.875ZM19.75 8.5V12.25H23.5V8.5H19.75ZM17.875 12.25H14.125V8.5H17.875V12.25ZM19.75 17.875H23.5V14.125H19.75V17.875ZM23.5 23.5H19.75V19.75H23.5V23.5Z",fill:"#1A1A1B"}))),bS="_default";function jS({value:e,onChange:t,placeholder:n,options:o,sx:r,readOnly:s,valueOnlyIcon:l}){const d=a();return Yn.jsx(q,{value:null!=e?e:bS,onChange:(n,i)=>{const o="number"==typeof e&&i?Number(i):i;t(o===bS?void 0:o)},disabled:s,sx:ne({padding:d.spacing(8,12),"& .MuiSelect-select.MuiSelect-select.MuiSelect-select":{display:"flex",alignItems:"center",gap:8,padding:d.spacing(8,12,8,12),minHeight:"auto",backgroundColor:"transparent",color:"text.primary",borderRadius:8,typography:"body2",fontWeight:600,borderStyle:"solid",borderWidth:1,borderColor:"divider","& svg, & img":{width:24,height:24},'&:hover, &[aria-expanded="true"]':{backgroundColor:"background.paper"},"&.Mui-readOnly":{color:"text.disabled"}},"& .MuiSelect-icon":{color:s?"text.disabled":"text.primary"},"& .MuiOutlinedInput-notchedOutline":{display:"none"}},r),renderValue:t=>{if(!(null==t?void 0:t.value)||t.value===bS)return Yn.jsx(i,{sx:{color:"text.secondary"},children:null!=n?n:""});const r=o.find((t=>t.key===e));return r?Yn.jsxs(Yn.Fragment,{children:[r.logo,l?"":r.value]}):null},options:[...o]})}function CS({isMobileStyle:e,chain:t,isLastItem:n,logoWidth:o,mobileLogoWidth:r,sx:s}){const l=a();return e?Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",py:18,borderTop:`1px solid ${l.palette.border.main}`,borderBottom:n?`1px solid ${l.palette.border.main}`:"none"},s),children:[Yn.jsx(i,{component:null==t?void 0:t.logo,sx:{width:r,height:r}}),Yn.jsx(i,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{component:null==t?void 0:t.logo,sx:{width:o,height:o}}),Yn.jsx(i,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]})}const wS=-1;function kS({chainId:n,setChainId:o,logoWidth:r=24,mobileLogoWidth:a=32,mainLogoWidth:s=24,mainMobileLogoWidth:l=18,notShowAllChain:c,valueOnlyIcon:u,sx:p}){const h=function(){const{chainId:e}=dg(),t=$((()=>{const t=new Map;let n;return ah.forEach(((i,o)=>{if(i.mainnet){if(e!==i.chainId)return;n=i.mainnet}t.set(o,Object.assign({},i))})),void 0!==n&&t.delete(n),Array.from(t.values())}),[e]);return t}(),[m,g]=H.useState(!1),{isMobile:f}=Tg(),{i18n:x}=t(),y=H.useCallback((()=>{const e=void 0===n?h[0]:h.find((e=>e.chainId===n));if(u){if(void 0===n||!e)return"";const t=f?a:s;return Yn.jsx(i,{component:null==e?void 0:e.logo,sx:{width:t,height:t}})}return void 0!==n||c?e?Yn.jsx(CS,{isMobileStyle:f,chain:e,logoWidth:s,mobileLogoWidth:l}):null:Yn.jsx(CS,{isMobileStyle:f,chain:{chainId:wS,logo:vS,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:s,mobileLogoWidth:l,sx:{border:"none"}})}),[n,h,c,u,f,x._]),v=H.useMemo((()=>{const e=[];return c||e.push({key:wS,value:Yn.jsx(CS,{isMobileStyle:f,chain:{chainId:wS,logo:vS,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:r,mobileLogoWidth:a})}),h.forEach(((t,n)=>{e.push({key:t.chainId,value:Yn.jsx(CS,{isLastItem:n===h.length-1,isMobileStyle:f,chain:t,logoWidth:r,mobileLogoWidth:a})})})),e}),[f,r,a,h,c]);return f?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,onClick:()=>g(!0),sx:Object.assign({display:"flex",alignItems:"center",backgroundColor:"background.tag",color:"text.primary",borderRadius:8,border:"none",px:8,height:32,fontWeight:600,typography:"body2"},p),children:[Yn.jsx(i,{sx:{pr:5},children:y()}),Yn.jsx(i,{component:li.CaretUp,sx:{width:12,height:12,transform:"rotate(180deg)"}})]}),Yn.jsx(Of,{open:m,title:Yn.jsx(e,{id:"lJvbHq",message:"Select Network"}),onClose:()=>g(!1),id:"select-chain",modal:!0,children:Yn.jsx(i,{sx:{mb:20},children:v.map((e=>Yn.jsxs(i,{onClick:()=>{const t=e.key;o(t===wS?void 0:Number(t)),g(!1)},sx:{position:"relative",px:20,"&:active":{backgroundColor:"hover.default"},"&:hover":{backgroundColor:"hover.default"},cursor:"pointer"},children:[e.value,(n?e.key===n:e.key===wS)&&Yn.jsx(i,{sx:{position:"absolute",left:0,top:24,height:20,width:2,backgroundColor:"text.primary"}})]},e.key)))})})]}):Yn.jsx(jS,{value:null!=n?n:wS,onChange:e=>{v.some((t=>String(t.key)===String(e)))&&o(e===wS?void 0:e)},placeholder:x._({id:"lJvbHq",message:"Select Network"}),options:v,valueOnlyIcon:u,sx:Object.assign({px:8,height:32,fontWeight:600,typography:"body2",backgroundColor:"background.tag",color:"text.primary"},p)})}function TS({lqList:e,onDeleteTag:t,sx:n}){var o;if(!(null==e?void 0:e.length))return null;if(!(null===(o=e[0])||void 0===o?void 0:o.pair))return null;const{pair:r}=e[0],a=Zm(r.baseToken,r.chainId),s=Zm(r.quoteToken,r.chainId);return a&&s?Yn.jsxs(i,{sx:Object.assign({typography:"body2",display:"inline-flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},n),children:[Yn.jsx(kj,{tokens:[a,s],chainId:a.chainId,width:20,mr:8}),a.symbol,"+",s.symbol,Yn.jsx(i,{component:li.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t()})]}):null}const IS=e=>{const{filterList:t,value:n,onChange:o}=e,r=a();return Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:t.map(((e,a)=>Yn.jsx(i,{sx:Object.assign(Object.assign({borderLeftWidth:1,borderRightWidth:a===t.length-1?1:0,borderTopWidth:1,borderBottomWidth:1,borderColor:r.palette.border.main,borderStyle:"solid",typography:"body2",lineHeight:"30px",color:r.palette.text.secondary,px:20,cursor:"pointer",borderTopLeftRadius:0===a?8:0,borderBottomLeftRadius:0===a?8:0,borderTopRightRadius:a===t.length-1?8:0,borderBottomRightRadius:a===t.length-1?8:0},n===e.value?{backgroundColor:r.palette.border.disabled,color:r.palette.text.primary}:{}),{[r.breakpoints.down("tablet")]:{flexGrow:1,flexBasis:"25%",textAlign:"center"}}),onClick:()=>o(e.value),children:e.label},e.value)))})},SS=({sx:t,isRightTop:n,isReverseColor:o})=>{const r=a();return Yn.jsx(i,{sx:Object.assign(Object.assign(Object.assign({display:"inline-flex",padding:"2px 4px",alignItems:"center",gap:"4px",borderRadius:4,background:T(r.palette.warning.main,.1),color:r.palette.warning.main,fontSize:"10px",fontWeight:600,lineHeight:"14px"},n?{position:"absolute",top:-14,right:0,background:`linear-gradient(0deg, ${r.palette.warning.main}1A 0%, ${r.palette.warning.main}1A 100%), ${r.palette.background.paper}`}:void 0),o?{background:"light"===r.palette.mode?"linear-gradient(0deg, var(--label-warning, rgba(177, 86, 0, 0.10)) 0%, var(--label-warning, rgba(177, 86, 0, 0.10)) 100%), #FFF":"linear-gradient(0deg, #FFFFFF, #FFFFFF),linear-gradient(0deg, rgba(235, 141, 39, 0.1), rgba(235, 141, 39, 0.1))",zIndex:1}:void 0),t),children:Yn.jsx(e,{id:"y5rS9U",message:"Migrate"})})};function ES({chainId:t,baseToken:n,quoteToken:o,apy:a,hasQuote:s,hasMining:d,sx:c,children:u}){if(!n)return null;const p=s?[{token:n,transactionApy:null==a?void 0:a.transactionBaseApy,miningApy:null==a?void 0:a.miningBaseApy},{token:o,transactionApy:null==a?void 0:a.transactionQuoteApy,miningApy:null==a?void 0:a.miningQuoteApy}]:[{transactionApy:null==a?void 0:a.transactionBaseApy,miningApy:null==a?void 0:a.miningBaseApy,metromMiningApy:null==a?void 0:a.metromMiningApy}];return Yn.jsx(l,{children:null!=u?u:Yn.jsx(r,{component:li.QuestionBorder,sx:Object.assign({width:15,height:15},c)}),title:Yn.jsx(i,{sx:{minWidth:236},children:p.map(((r,a)=>{var s,l,c,u,p;return Yn.jsxs(i,{sx:{mt:0===a?0:20},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,typography:"body2",fontWeight:600,color:"text.primary"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:r.token?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(Df,{width:14,height:14,marginRight:4,address:r.token.address,url:r.token.logoURI,chainId:t,noShowChain:!0}),r.token.symbol]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(kj,{tokens:[n,o],width:14,mr:4,chainId:t}),n.symbol,"/",null==o?void 0:o.symbol]})}),Yn.jsx(i,{children:Wm(new Pe(null!==(c=r.transactionApy)&&void 0!==c?c:0).plus(null!==(u=r.miningApy)&&void 0!==u?u:0).plus(null!==(p=r.metromMiningApy)&&void 0!==p?p:0))})]}),Yn.jsxs(i,{sx:{mt:8,display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"OnDEky",message:"LP Fee"})}),Yn.jsx("span",{children:r.transactionApy?Wm(new Pe(r.transactionApy)):"-"})]}),d?Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"pSQ1lM",message:"MT Fee"})}),Yn.jsx("span",{children:r.miningApy?Wm(new Pe(r.miningApy)):"-"})]}):"",r.metromMiningApy&&Number(r.metromMiningApy)>0&&Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"Sti4vy",message:"Mining"})}),Yn.jsx("span",{children:r.metromMiningApy?Wm(new Pe(r.metromMiningApy)):"-"})]})]},null!==(l=null===(s=r.token)||void 0===s?void 0:s.address)&&void 0!==l?l:1)}))})})}function AS({list:t,onClick:n}){return Yn.jsx(Yn.Fragment,{children:null==t?void 0:t.map((t=>{var o,r,a,s;if(!(null==t?void 0:t.pair))return null;const l=t.pair,d=Zm(l.baseToken,l.chainId),c=Zm(l.quoteToken,l.chainId),u=l.apy?Wm(new Pe(null===(o=l.apy)||void 0===o?void 0:o.transactionBaseApy).plus(null!==(a=null===(r=l.apy)||void 0===r?void 0:r.miningBaseApy)&&void 0!==a?a:0)):void 0,p=ye.utils.singleSideLp(l.type)&&l.apy?Wm(new Pe(l.apy.transactionQuoteApy).plus(null!==(s=l.apy.miningQuoteApy)&&void 0!==s?s:0)):void 0;return d&&c?Yn.jsxs(i,{onClick:n,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(kj,{tokens:[d,c],chainId:l.chainId,width:24,mr:10}),Yn.jsxs(i,{sx:{typography:"h5"},children:[d.symbol,"/",c.symbol]})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{color:"custom.status.green.default",fontWeight:600},children:[u,p?`/${p}`:""]}),Yn.jsx(i,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]})]},l.id):null}))})}function OS(e){var t;const[n,i]=H.useState(null!==(t=null==e?void 0:e.tokens)&&void 0!==t?t:[]),[o,r]=H.useState([]);H.useEffect((()=>{e&&(i(e.tokens),r(e.lqList))}),[e]);const[a,s]=H.useMemo((()=>{const[e,t]=n;return[null==e?void 0:e.symbol,null==t?void 0:t.symbol]}),[n]);return{filterTokens:n,filterASymbol:a,filterBSymbol:s,filterAddressLqList:o,handleDeleteToken:t=>{i((n=>{const i=[...n],o=i.indexOf(t);return-1!==o&&i.splice(o,1),e&&e.onChangeFilterTokens(i),i}))},handleChangeFilterTokens:t=>{r([]),i(t),e&&(e.onChangeFilterTokens(t),e.onChangeFilterAddressLqList([]))},handleChangeFilterAddress:t=>{r(t),i([]),e&&(e.onChangeFilterTokens([]),e.onChangeFilterAddressLqList(t))}}}function LS({lqList:t,setOperatePool:n,getMigrationPairAndMining:o,supportAMM:r,timeRange:s}){const d=a(),{onSharePool:u}=Jn();return Yn.jsx(Yn.Fragment,{children:null==t?void 0:t.map((t=>{var a,p,h,m,g,f,x,y,v;if(!(null==t?void 0:t.pair))return null;const b=t.pair,j=Zm(b.baseToken,b.chainId),C=Zm(b.quoteToken,b.chainId),w=null===(a=b.apyList)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.timeRange)===`${s}D`)),k=w?Wm(new Pe(null==w?void 0:w.transactionBaseApy).plus(null!==(p=null==w?void 0:w.miningBaseApy)&&void 0!==p?p:0)):void 0,I=ye.utils.singleSideLp(b.type)&&w?Wm(new Pe(w.transactionQuoteApy).plus(null!==(h=w.miningQuoteApy)&&void 0!==h?h:0)):void 0,S=!!(null===(m=b.miningAddress)||void 0===m?void 0:m[0]),E=!!(null==w?void 0:w.metromMiningApy)&&Number(null==w?void 0:w.metromMiningApy)>0,A=b.type,O=Ym(A),L="AMMV2"===A,R="AMMV3"===A,P=null==o?void 0:o({address:b.id,chainId:b.chainId});return Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{r||Gj.getState().push({type:Zj.PoolDetail,params:{chainId:b.chainId,address:b.id}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[j&&C?Yn.jsx(kj,{tokens:[j,C],width:24,mr:6,chainId:b.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},children:[`${null==j?void 0:j.symbol}/${null==C?void 0:C.symbol}`,!!u&&Yn.jsx(i,{component:li.Share,sx:{ml:2,width:12,height:12},onClick:()=>u({chainId:b.chainId,baseToken:j,quoteToken:C,poolId:b.id,apy:w,isSingle:ye.utils.singleSideLp(b.type)})}),Yn.jsx(gS,{address:b.id,chainId:b.chainId})]}),!!P&&Yn.jsx(SS,{})]}),S||E?Yn.jsxs(i,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${T(d.palette.secondary.main,.3)} 0%, ${T(d.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",Yn.jsx(e,{id:"Sti4vy",message:"Mining"})]}):""]}),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[r&&Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[O,Yn.jsx(l,{title:Yn.jsx(e,{id:"O6RUgz",message:"Fee rate"}),children:Yn.jsx(i,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:R?null!==(f=null===(g=dT[b.lpFeeRate])||void 0===g?void 0:g.label)&&void 0!==f?f:"-":Vm({input:new Pe(null!==(x=b.lpFeeRate)&&void 0!==x?x:0).plus(b.mtFeeRate?_m(b.mtFeeRate,L?4:18):0)})})})]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5",color:"success.main"},children:[k,I?`/${I}`:""]}),Yn.jsxs(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[s,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"}),Yn.jsx(ES,{chainId:b.chainId,apy:w,baseToken:j,quoteToken:C,hasQuote:!!I,hasMining:S,sx:{width:14,height:14}})]})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",qm(new Pe(b.tvl))]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),r&&Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:["$",Em({input:null===(v=null===(y=b.volumeList)||void 0===y?void 0:y.find((e=>(null==e?void 0:e.timeRange)===`${s}D`)))||void 0===v?void 0:v.volume})]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"iuFFMB",message:"Volume ({timeRange}d)",values:{timeRange:s}})})]})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),n({pool:Gm(t),hasMining:S})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})}),r&&"PMM"===O&&Yn.jsx(zT,{chainId:b.chainId,address:b.id})]})]},b.id+b.chainId)}))})}function RS({lqList:t,loading:n,operatePool:o,setOperatePool:r,getMigrationPairAndMining:s,hasMore:d,loadMore:u,loadMoreLoading:p,supportAMM:h,timeRange:m}){const g=a(),{onSharePool:f}=Jn();return Yn.jsxs(ZT,{hasMore:d,loadMore:u,loadMoreLoading:p,empty:!(null==t?void 0:t.length),loading:n,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"AxdOHo",message:"Pair"})}),h&&Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})}),Yn.jsxs(i,{component:"th",children:[m,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"})]}),h&&Yn.jsxs("th",{children:[m,"d ",Yn.jsx(e,{id:"/cF7Rs",message:"Volume"})]}),Yn.jsx(i,{component:"th",sx:{width:80}})]})}),Yn.jsx(i,{component:"tbody",children:null==t?void 0:t.map((e=>{var t,n,a,d,u,p,x,y;if(!(null==e?void 0:e.pair))return null;const v=e.pair,b=Zm(v.baseToken,v.chainId),j=Zm(v.quoteToken,v.chainId),C=null===(t=v.apyList)||void 0===t?void 0:t.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)),w=C?Wm(new Pe(null==C?void 0:C.transactionBaseApy).plus(null!==(n=null==C?void 0:C.miningBaseApy)&&void 0!==n?n:0).plus(null!==(a=null==C?void 0:C.metromMiningApy)&&void 0!==a?a:0)):void 0,k=ye.utils.singleSideLp(v.type)&&C?Wm(new Pe(C.transactionQuoteApy).plus(null!==(d=C.miningQuoteApy)&&void 0!==d?d:0)):void 0;let T="";if((null===(u=null==o?void 0:o.pool)||void 0===u?void 0:u.address)===v.id||(null==o?void 0:o.address)===v.id)if(o.operate===YT.Remove)T=se._({id:"0+31GV",message:"Removing"});else T=se._({id:"1yHVE+",message:"Adding"});const I=!!(null===(p=v.miningAddress)||void 0===p?void 0:p[0]),S=!!(null==C?void 0:C.metromMiningApy)&&Number(null==C?void 0:C.metromMiningApy)>0,E=v.type,A=Ym(E),O="AMMV2"===E,L="AMMV3"===E,R=g.palette.hover.default,P=null==s?void 0:s({address:v.id,chainId:v.chainId});return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(T?", & td":"")]:{backgroundImage:`linear-gradient(${R}, ${R})`}},children:[Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[b&&j?Yn.jsx(kj,{tokens:[b,j],width:24,mr:8,chainId:v.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==b?void 0:b.symbol}/${null==j?void 0:j.symbol}`,Yn.jsx(gS,{address:v.id,chainId:v.chainId}),!!P&&Yn.jsx(SS,{})]}),Yn.jsx(zb,{address:v.id,customChainId:v.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,onShareClick:f?()=>f({chainId:v.chainId,baseToken:b,quoteToken:j,poolId:v.id,apy:C,isSingle:ye.utils.singleSideLp(v.type)}):void 0,sx:{typography:"h6",color:"text.secondary"},disabledAddress:h,onAddressClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:v.chainId,address:v.id}})}})]})]})}),h&&Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(cT,{poolType:A}),Yn.jsx(uT,{isAMMV2:O,isAMMV3:L,lpFeeRate:v.lpFeeRate,mtFeeRate:v.mtFeeRate})]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2"},title:v.tvl?`$${Em({input:v.tvl})}`:void 0,children:["$",qm(new Pe(v.tvl))]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[I||S?Yn.jsx(l,{title:se._({id:"Sti4vy",message:"Mining"}),children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",Yn.jsx(ES,{chainId:v.chainId,apy:C,baseToken:b,quoteToken:j,hasQuote:!!k,hasMining:I,children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[w,k?`/${k}`:""]})})]})}),h&&Yn.jsxs(i,{component:"td",sx:{typography:"body2"},children:["$",Em({input:null===(y=null===(x=v.volumeList)||void 0===x?void 0:x.find((e=>(null==e?void 0:e.timeRange)===`${m}D`)))||void 0===y?void 0:y.volume})]}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[h&&"PMM"===A&&Yn.jsx(zT,{chainId:v.chainId,address:v.id}),T?Yn.jsx(HT,{text:T,onClick:()=>r(null)}):Yn.jsx(c,{size:c.Size.small,onClick:()=>{r({pool:Gm(e),hasMining:I})},sx:{py:0,height:32},children:se._({id:"m16xKo",message:"Add"})})]})})]},v.id+v.chainId)}))})]})}function PS({scrollParentRef:e,filterChainIds:t,activeChainId:n,handleChangeActiveChainId:o,operatePool:r,setOperatePool:s,tokenAndPoolFilter:l,getMigrationPairAndMining:d,children:c}){var u,p;const h=a(),{onlyChainId:m,supportAMMV2:g,supportAMMV3:f,notSupportPMM:x}=Jn(),{minDevice:y,isMobile:v}=Tg(),b=nt(),[j,C]=z("all"),[w,k]=z("1"),{filterTokens:T,filterASymbol:I,filterBSymbol:S,filterAddressLqList:E,handleDeleteToken:A,handleChangeFilterTokens:O,handleChangeFilterAddress:L}=OS(l),R=$((()=>{if(f&&"v3"===j)return["AMMV3"];if(g&&"v2"===j)return["AMMV2"];if(!x&&"pmm"===j)return["CLASSICAL","DVM","DSP","GSP"];let e=x?[]:["CLASSICAL","DVM","DSP","GSP"];return g&&e.push("AMMV2"),f&&e.push("AMMV3"),e}),[x,g,f,j]),P=$((()=>({chainIds:t,pageSize:v?4:8,filterState:{viewOnlyOwn:!1,filterTypes:R}})),[t,R,v]),_=gg(),M=_.getInfiniteQuery(ye.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},P),{filterState:Object.assign({filterASymbol:I,filterBSymbol:S},P.filterState)})}),B=at(Object.assign(Object.assign({},M),{initialPageParam:1,getNextPageParam:e=>{var t;const{currentPage:n,totalCount:i,pageSize:o}=null!==(t=e.liquidity_list)&&void 0!==t?t:{};if(!n||!i||!o)return null;let r=Math.floor(i/o);return i%o&&(r+=1),n>=r?null:n+1}}));let D=[];const N=!!(null==E?void 0:E.length);N?D=[...E]:null===(u=B.data)||void 0===u||u.pages.forEach((e=>{var t,n;null===(n=null===(t=e.liquidity_list)||void 0===t?void 0:t.lqList)||void 0===n||n.forEach((e=>{null==D||D.push(e)}))}));const F=B.hasNextPage&&!N;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[h.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[h.breakpoints.up("tablet")]:{mr:"auto"}},children:c}),!m&&Yn.jsx(kS,{chainId:n,setChainId:o}),(g||f)&&Yn.jsx(IS,{filterList:[{label:"All",value:"all"}].concat(x?[]:[{label:"PMM",value:"pmm"}]).concat(g?[{label:"V2",value:"v2"}]:[]).concat(f?[{label:"V3",value:"v3"}]:[]),value:j,onChange:e=>C(e)}),Yn.jsx(IS,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:w,onChange:e=>k(e)}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},v?{}:{"& > button":{flex:1}}),children:null!==(p=null==l?void 0:l.element)&&void 0!==p?p:Yn.jsx(QT,{value:T,onChange:O,searchAddress:(e,t)=>Vn(this,void 0,void 0,(function*(){var n;const i=_.getInfiniteQuery(ye.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},P),{filterState:Object.assign({address:e},P.filterState)})}),o=null===(n=(yield b.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?Yn.jsx(AS,{list:o,onClick:()=>{L(o),t()}}):null}))})}),(N||!!T.length)&&Yn.jsxs(i,{sx:{my:0},children:[N?Yn.jsx(TS,{lqList:E,onDeleteTag:()=>L([])}):"",Yn.jsx($T,{tags:T,onDeleteTag:A})]})]})]}),v?Yn.jsx(In,{hasMore:F,threshold:300,loadMore:ae((()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>e.current||null,loader:Yn.jsx(GT,{sx:{mt:20}},"loader"),children:Yn.jsxs(WT,{children:[B.isLoading?Yn.jsx(GT,{}):"",!B.isLoading&&!(null==D?void 0:D.length)&&!B.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!!(n&&!m||I||S)}),!!B.error&&Yn.jsx(ai,{refresh:B.refetch,sx:{mt:40}}),Yn.jsx(LS,{lqList:D,setOperatePool:s,supportAMM:g||f,getMigrationPairAndMining:d,timeRange:w})]})}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(RS,{lqList:D,loading:B.isLoading,operatePool:r,setOperatePool:s,hasMore:F,loadMoreLoading:B.isFetchingNextPage,loadMore:()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()},supportAMM:g||f,timeRange:w,getMigrationPairAndMining:d}),Yn.jsx(Tj,{loading:B.isLoading,refetch:B.error?B.refetch:void 0,empty:!(null==D?void 0:D.length),hasSearch:!!(n&&!m||I||S)})]})]})}function _S({onClick:e,title:t,desc:n}){const o=a();return Yn.jsx(i,{sx:{mx:20,px:0,py:14,borderTop:`1px solid ${o.palette.border.main}`,[o.breakpoints.up("tablet")]:{maxWidth:236,borderTop:"none",mx:0,px:16,py:8}},children:Yn.jsxs(d,{onClick:e,sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:0,p:0,borderRadius:8,textAlign:"left","&:hover":{backgroundColor:o.palette.background.tag},[o.breakpoints.up("tablet")]:{p:8}},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:o.palette.text.primary},children:t}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary},children:n})]})})}const MS=t=>{const n=a(),{isMobile:o}=Tg(),{supportAMMV2:r,supportAMMV3:s,notSupportPMM:d}=Jn(),[u,p]=H.useState(!1),h={[Zj.CreatePool]:!d,[Zj.createPoolAMMV2]:!!r,[Zj.createPoolAMMV3]:!!s},m=Object.entries(h).filter((([e,t])=>!0===t)),g=1===m.length?m[0][0]:void 0;if(!g){const t=Yn.jsxs(Yn.Fragment,{children:[!d&&Yn.jsx(_S,{onClick:()=>{Gj.getState().push({type:Zj.CreatePool})},title:Yn.jsx(e,{id:"Eif7f6",message:"PMM Pool"}),desc:Yn.jsx(e,{id:"LQ0J1B",message:"Flexible customization, take full control of liquidity"})}),r&&Yn.jsx(_S,{onClick:()=>{Gj.getState().push({type:Zj.createPoolAMMV2})},title:Yn.jsx(e,{id:"lNYomJ",message:"AMM V2 Position"}),desc:Yn.jsx(e,{id:"lLbR0m",message:"Simple, full-range liquidity"})}),s&&Yn.jsx(_S,{onClick:()=>{Gj.getState().push({type:Zj.createPoolAMMV3})},title:Yn.jsx(e,{id:"sVlqoo",message:"AMM V3 Position"}),desc:Yn.jsx(e,{id:"EkAv3P",message:"Concentrated liquidity, higher efficiency"})})]});return o?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{p(!0)},sx:{height:36},children:[Yn.jsx(i,{component:li.Plus,sx:{mr:4}}),Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"})]}),Yn.jsx(Of,{open:u,title:Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"}),onClose:()=>{p(!1)},modal:!0,children:Yn.jsx(i,{sx:{mb:0},children:t})})]}):Yn.jsx(l,{arrow:!1,leaveDelay:300,placement:o?"bottom":"bottom-end",sx:{p:0,backgroundColor:"background.paper"},title:Yn.jsx(i,{children:t}),children:Yn.jsxs(i,{sx:{width:o?"100%":"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,pl:8,pr:16,py:6,borderRadius:40,backgroundColor:n.palette.background.tag,typography:"body2",fontWeight:600,color:n.palette.text.link,cursor:"pointer","&:hover":{backgroundColor:T(n.palette.primary.main,.1)}},children:[Yn.jsx(i,{component:li.Plus}),Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"})]})})}return Yn.jsxs(c,{variant:c.Variant.outlined,fullWidth:o,onClick:()=>{Gj.getState().push({type:g})},sx:{height:40},children:[Yn.jsx(i,{component:li.Plus,sx:{mr:4}}),Yn.jsx(e,{id:"p2jbcE",message:"Create Pool"})]})},BS="DODO_WIDGET_POOL_LIST_TOP_TAB",DS="DODO_WIDGET_POOL_LIST_TAB",NS="DODO_WIDGET_POOLS_LIST_FILTER_CHAIN";var FS,US,qS,VS;!function(e){e.ALM="ALM",e.NORMAL="NORMAL",e.MULTI_TOKEN="MULTI_TOKEN"}(FS||(FS={})),function(e){e.ALL="ALL",e.MY="MY"}(US||(US={})),function(e){e.addLiquidity="add-liquidity",e.myLiquidity="my-liquidity",e.myCreated="my-created"}(qS||(qS={})),function(e){e.ALL="ALL",e.MY="MY"}(VS||(VS={}));const WS=(e,t,n)=>{let i=se._({id:"TJBHlP",message:"Standard"}),o=n.palette.purple.main;switch(e){case"DSP":i=se._({id:"J7M/DA",message:"Pegged"}),o=n.palette.success.main;break;case"DPP":i=se._({id:"zwBp5t",message:"Private"}),o=n.palette.error.main}"DVM"===e&&(!t||t.isZero())&&(i=se._({id:"S8G1qk",message:"Single"}),o=n.palette.warning.main);return{typeLabel:i,typeColor:o,typeBgColor:T(o,.1)}};function HS({account:t,list:n,setOperatePool:o}){const r=a();return Yn.jsx(Yn.Fragment,{children:null==n?void 0:n.map((n=>{var a,s,l,u,p;if(!n)return null;const h=null!==(a=n.pairAddress)&&void 0!==a?a:"",m=n.chainId,g=n.poolType,f={chainId:m,address:null!==(s=n.baseAddress)&&void 0!==s?s:"",symbol:null!==(l=n.baseSymbol)&&void 0!==l?l:""},x={chainId:m,address:null!==(u=n.quoteAddress)&&void 0!==u?u:"",symbol:null!==(p=n.quoteSymbol)&&void 0!==p?p:""},{typeLabel:y,typeColor:v,typeBgColor:b}=WS(g,n.quoteReserve?new Pe(n.quoteReserve):null,r);return Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:m,address:h}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[f&&x?Yn.jsx(kj,{tokens:[f,x],width:24,mr:8,chainId:m,showChainLogo:!0}):"",Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},children:eg(h)}),"DPP"===g&&Yn.jsx(_,{sx:{ml:2},component:d,onClick:e=>{e.stopPropagation(),Gj.getState().push({type:Zj.ModifyPool,params:{chainId:m,address:h}})},children:Yn.jsx(i,{component:li.Edit,sx:{width:12,height:12,cursor:"pointer"}})})]}),Yn.jsx(i,{sx:{typography:"h6",width:"max-content",p:8,borderRadius:8,backgroundColor:b,color:v},children:y})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",mt:44},children:[Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",n.tvl?qm(new Pe(n.tvl)):"-"]}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),Yn.jsx(i,{sx:{display:"inline-block",mx:20,height:24,width:"1px",backgroundColor:"custom.border.default"}}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",n.totalFee?qm(new Pe(n.totalFee)):"-"]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"hCBYHP",message:"Total Fee Revenue"})})]})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",gap:"8px"},children:[!!t&&Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({address:h,operate:YT.Remove,chainId:m})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({address:h,operate:YT.Add,chainId:m})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})})]})]},h+m)}))})}function $S({account:t,list:n,loading:o,operatePool:r,setOperatePool:s}){const l=a(),d=Gj();return Yn.jsxs(ZT,{empty:!(null==n?void 0:n.length),loading:o,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"AxdOHo",message:"Pair"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"hCBYHP",message:"Total Fee Revenue"})}),Yn.jsx(i,{component:"th",sx:{width:160}})]})}),Yn.jsx(i,{component:"tbody",children:null==n?void 0:n.map((n=>{var o,a,u,p,h,m;if(!n)return null;const g="DPP"===n.poolType,f=null!==(o=n.pairAddress)&&void 0!==o?o:"",x=n.chainId,y=n.poolType,v={chainId:x,address:null!==(a=n.baseAddress)&&void 0!==a?a:"",symbol:null!==(u=n.baseSymbol)&&void 0!==u?u:""},b={chainId:x,address:null!==(p=n.quoteAddress)&&void 0!==p?p:"",symbol:null!==(h=n.quoteSymbol)&&void 0!==h?h:""},{typeLabel:j,typeColor:C,typeBgColor:w}=WS(y,n.quoteReserve?new Pe(n.quoteReserve):null,l);let k="";if((null===(m=null==r?void 0:r.pool)||void 0===m?void 0:m.address)===f||(null==r?void 0:r.address)===f)if((null==r?void 0:r.operate)===YT.Remove)k=se._({id:"0+31GV",message:"Removing"});else k=se._({id:"1yHVE+",message:"Adding"});const I=l.palette.hover.default;return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(k?", & td":"")]:{backgroundImage:`linear-gradient(${I}, ${I})`}},children:[Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[v&&b?Yn.jsx(kj,{tokens:[v,b],width:24,mr:10,chainId:x,showChainLogo:!0}):"",Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsxs(P,{lineSx:{bottom:-1},lineColor:"primary.main",hoverSx:{color:"primary.main","& svg":{display:"inline-block"}},className:"truncate-address-link",sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600},onClick:()=>{d.push({type:Zj.PoolDetail,params:{chainId:x,address:f}})},children:eg(f)}),Yn.jsx(i,{component:li.ArrowRight,sx:{display:"none",width:14,height:14}})]}),g?Yn.jsx(i,{sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderColor:"text.primary",borderRadius:4,whiteSpace:"nowrap",cursor:"pointer","&:hover":{backgroundColor:T(l.palette.text.primary,.1)}},onClick:()=>{d.push({type:Zj.ModifyPool,params:{chainId:x,address:f}})},children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})}):""]}),Yn.jsx(i,{sx:{typography:"h6",width:"max-content",mt:2,px:8,py:2,borderRadius:12,backgroundColor:w,color:C},children:j})]})]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2"},title:n.tvl?`$${Em({input:n.tvl})}`:void 0,children:["$",n.tvl?qm(new Pe(n.tvl)):"-"]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{title:n.totalFee?`$${Em({input:n.totalFee})}`:"",sx:{typography:"body2",fontWeight:600},children:["$",n.totalFee?qm(new Pe(n.totalFee)):"-"]})}),Yn.jsx(i,{component:"td",children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:k?Yn.jsx(HT,{text:k,onClick:()=>s(null)}):Yn.jsxs(Yn.Fragment,{children:[!!t&&Yn.jsx(c,{variant:c.Variant.second,size:c.Size.small,onClick:e=>{e.stopPropagation(),s({operate:YT.Remove,chainId:x,address:f})},sx:{py:0,height:32},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{size:c.Size.small,onClick:()=>{s({chainId:x,address:f})},sx:{py:0,height:32},children:se._({id:"m16xKo",message:"Add"})})]})})})]},f+x)}))})]})}function zS({account:t,filterChainIds:n,activeChainId:o,handleChangeActiveChainId:r,operatePool:s,setOperatePool:l,children:d}){var c,u,p,h,m,g;const{isMobile:f}=Tg(),x=a(),{onlyChainId:y}=Jn(),v={limit:1e3,page:1,owner:t},b=gg().getQuery(ye.graphql.fetchDashboardPairList,{where:v}),j=et(Object.assign({},b)),C=null!==(g=n?null===(p=null===(u=null===(c=j.data)||void 0===c?void 0:c.dashboard_pairs_list)||void 0===u?void 0:u.list)||void 0===p?void 0:p.filter((e=>{var t;return n.includes(null!==(t=null==e?void 0:e.chainId)&&void 0!==t?t:0)})):null===(m=null===(h=j.data)||void 0===h?void 0:h.dashboard_pairs_list)||void 0===m?void 0:m.list)&&void 0!==g?g:[],[w,k]=H.useState(!1),T=w?C.filter((e=>!!Number(null==e?void 0:e.tvl))):C;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[x.breakpoints.up("tablet")]:{py:16,flexDirection:"row",alignItems:"center",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[x.breakpoints.up("tablet")]:{mr:"auto"}},children:d}),!y&&Yn.jsx(kS,{chainId:o,setChainId:r}),Yn.jsxs(i,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary"},children:[Yn.jsx(I,{sx:{top:-1},size:16,checked:w,onChange:e=>{const{checked:t}=e.target;k(t)}}),Yn.jsx(e,{id:"eVZ7bY",message:"Hide TVL=0 pools"})]})]}),f?Yn.jsxs(WT,{children:[j.isLoading?Yn.jsx(GT,{}):"",!j.isLoading&&!(null==T?void 0:T.length)&&!j.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!!o&&!y}),!!j.error&&Yn.jsx(ai,{refresh:j.refetch,sx:{mt:40}}),Yn.jsx(HS,{account:t,list:T,setOperatePool:l})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx($S,{account:t,list:T,loading:j.isLoading,operatePool:s,setOperatePool:l}),Yn.jsx(Tj,{loading:j.isLoading,refetch:j.error?j.refetch:void 0,empty:!(null==T?void 0:T.length),hasSearch:!!o&&!y})]})]})}function ZS({account:t,lqList:n,setOperatePool:o,getMigrationPairAndMining:r,supportAMM:s,timeRange:d}){const u=a();return Yn.jsx(Yn.Fragment,{children:null==n?void 0:n.map((n=>{var a,p,h,m,g,f,x,y,v,b,j,C,w,k,I;if(!(null==n?void 0:n.pair))return null;const S=n.pair,E=Zm(S.baseToken,S.chainId),A=Zm(S.quoteToken,S.chainId),O=null===(a=S.apyList)||void 0===a?void 0:a.find((e=>(null==e?void 0:e.timeRange)===`${d}D`)),L=ye.utils.singleSideLp(S.type),R=O?Wm(new Pe(null==O?void 0:O.transactionBaseApy).plus(null!==(p=null==O?void 0:O.miningBaseApy)&&void 0!==p?p:0).plus(null!==(h=null==O?void 0:O.metromMiningApy)&&void 0!==h?h:0)):void 0,P=L&&O?Wm(new Pe(O.transactionQuoteApy).plus(null!==(m=O.miningQuoteApy)&&void 0!==m?m:0)):void 0;let _,M;(null===(g=n.liquidityPositions)||void 0===g?void 0:g.length)&&n.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const a=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==a?void 0:a.length)){const t=a[1].toLocaleLowerCase();if((null===(i=null===(n=null==S?void 0:S.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(_=new Pe(e.liquidityTokenBalance));(null===(r=null===(o=null==S?void 0:S.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(M=new Pe(e.liquidityTokenBalance))}}}));const B=!!(null===(f=S.miningAddress)||void 0===f?void 0:f[0]),D=!!(null==O?void 0:O.metromMiningApy)&&Number(null==O?void 0:O.metromMiningApy)>0,N=null===(x=n.liquidityPositions)||void 0===x?void 0:x[0],F=S.type,U=Ym(F),q="AMMV2"===F,V="AMMV3"===F,W=null==r?void 0:r({address:S.id,chainId:S.chainId});return Yn.jsxs(i,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16},className:"gradient-card-border",onClick:()=>{s||Gj.getState().push({type:Zj.PoolDetail,params:{chainId:S.chainId,address:S.id}})},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[E&&A?Yn.jsx(kj,{tokens:[E,A],width:24,mr:6,chainId:S.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{sx:{typography:"body2",fontWeight:600},children:[`${null==E?void 0:E.symbol}/${null==A?void 0:A.symbol}`,Yn.jsx(gS,{address:S.id,chainId:S.chainId})]}),!!W&&Yn.jsx(SS,{})]}),B||D?Yn.jsxs(i,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${T(u.palette.secondary.main,.3)} 0%, ${T(u.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",Yn.jsx(e,{id:"Sti4vy",message:"Mining"})]}):""]}),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",rowGap:20,mt:44,"& > div:nth-child(odd)":{pr:20},"& > div:nth-child(even)":{position:"relative",pl:20,"&::before":{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",display:"inline-block",content:'""',height:24,width:"1px",backgroundColor:"border.main"}}},children:[s&&Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[U,Yn.jsx(l,{title:Yn.jsx(e,{id:"O6RUgz",message:"Fee rate"}),children:Yn.jsx(i,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:V?null!==(v=null===(y=dT[S.lpFeeRate])||void 0===y?void 0:y.label)&&void 0!==v?v:"-":Vm({input:new Pe(null!==(b=S.lpFeeRate)&&void 0!==b?b:0).plus(S.mtFeeRate?_m(S.mtFeeRate,q?4:18):0)})})})]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})})]}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5",color:"success.main"},children:[R||"-%",P?`/${P}`:""]}),Yn.jsxs(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[d,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"}),Yn.jsx(ES,{chainId:S.chainId,apy:O,baseToken:E,quoteToken:A,hasQuote:!!P,hasMining:B,sx:{width:14,height:14}})]})]}),V?null:Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h5"},children:["$",qm(new Pe(S.tvl||0))]}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})})]}),"AMMV2"===F&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"h5"},children:Vm({input:null===(C=null===(j=n.liquidityPositions)||void 0===j?void 0:j[0])||void 0===C?void 0:C.poolShare})}),Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"h3PbRN",message:"My Pool Share"})})]}),Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"h5",display:"flex",alignItems:"center",fontWeight:"bold"},children:V?(null==N?void 0:N.liquidityUSD)?`$${Am({input:N.liquidityUSD,decimals:2})}`:"-":Yn.jsxs(Yn.Fragment,{children:[L?Yn.jsx(Df,{address:null==E?void 0:E.address,chainId:S.chainId,url:null==E?void 0:E.logoURI,width:18,height:18,sx:{mr:4}}):Yn.jsx(kj,{tokens:E&&A?[E,A]:[],width:18,mr:4,showChainLogo:!1,chainId:S.chainId}),_?Em({input:_}):"",L&&Yn.jsxs(Yn.Fragment,{children:[" / ",Yn.jsx(Df,{address:null==A?void 0:A.address,chainId:S.chainId,url:null==A?void 0:A.logoURI,width:18,height:18,sx:{mx:4}}),M?Em({input:M}):"0"]})]})}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})})]})]}),V&&Yn.jsxs(i,{sx:{mt:20},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[Yn.jsx(UT,{outOfRange:null!==(w=null==N?void 0:N.outOfRange)&&void 0!==w&&w}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(k=null==N?void 0:N.priceRange)||void 0===k?void 0:k.token0LowerPrice,atLimit:{},direction:dC.LOWER})," "]}),null==E?void 0:E.symbol]})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(I=null==N?void 0:N.priceRange)||void 0===I?void 0:I.token1LowerPrice,atLimit:{},direction:dC.UPPER})," "]}),null==E?void 0:E.symbol]})})]}),Yn.jsx(i,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:Yn.jsx(e,{id:"YA4hwj",message:"Price Range"})})]}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"center",gap:"8px"},children:[V?null:!!t&&Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({operate:YT.Remove,pool:Qm(n),hasMining:B})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{fullWidth:!0,size:c.Size.small,onClick:e=>{e.stopPropagation(),o({operate:YT.Add,pool:Qm(n),hasMining:B})},children:Yn.jsx(e,{id:"J/hVSQ",message:"{0}",values:{0:V?"Manage":"Add"}})}),s&&"PMM"===U&&Yn.jsx(zT,{chainId:S.chainId,address:S.id})]})]},V?null==N?void 0:N.id:S.id+S.chainId)}))})}function GS({account:t,lqList:n,loading:o,operatePool:r,setOperatePool:s,supportAMM:d,onlyV3:u,getMigrationPairAndMining:p,timeRange:h}){const m=a();return Yn.jsxs(ZT,{empty:!(null==n?void 0:n.length),loading:o,children:[Yn.jsx(i,{component:"thead",children:Yn.jsxs(i,{component:"tr",children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"AxdOHo",message:"Pair"})}),d&&Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"1Qz63U",message:"Pool Type"})}),u?null:Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"FHKsZF",message:"TVL"})}),Yn.jsxs(i,{component:"th",children:[h,"d ",Yn.jsx(e,{id:"rSayea",message:"APY"})]}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),u?Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"YA4hwj",message:"Price Range"})}):null,Yn.jsx(i,{component:"th",sx:{width:210}})]})}),Yn.jsx(i,{component:"tbody",children:null==n?void 0:n.map((n=>{var o,a,g,f,x,y,v,b,j,C,w,k,T,I,S;if(!(null==n?void 0:n.pair))return null;const E=n.pair,A=Zm(E.baseToken,E.chainId),O=Zm(E.quoteToken,E.chainId),L=ye.utils.singleSideLp(E.type),R=null===(o=E.apyList)||void 0===o?void 0:o.find((e=>(null==e?void 0:e.timeRange)===`${h}D`)),P=R?Wm(new Pe(null==R?void 0:R.transactionBaseApy).plus(null!==(a=null==R?void 0:R.miningBaseApy)&&void 0!==a?a:0)):void 0,_=L&&R?Wm(new Pe(R.transactionQuoteApy).plus(null!==(g=R.miningQuoteApy)&&void 0!==g?g:0)):void 0;let M,B;(null===(f=n.liquidityPositions)||void 0===f?void 0:f.length)&&n.liquidityPositions.forEach((e=>{var t,n,i,o,r;if(null==e?void 0:e.liquidityTokenBalance){const a=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==a?void 0:a.length)){const t=a[1].toLocaleLowerCase();if((null===(i=null===(n=null==E?void 0:E.baseLpToken)||void 0===n?void 0:n.id)||void 0===i?void 0:i.toLocaleLowerCase())===t)return void(M=new Pe(e.liquidityTokenBalance));(null===(r=null===(o=null==E?void 0:E.quoteLpToken)||void 0===o?void 0:o.id)||void 0===r?void 0:r.toLocaleLowerCase())===t&&(B=new Pe(e.liquidityTokenBalance))}}}));const D=null===(x=n.liquidityPositions)||void 0===x?void 0:x[0],N=E.type,F=Ym(N),U="AMMV2"===N,q="AMMV3"===N;let V="";if(q)(null===(b=null===(v=null===(y=null==r?void 0:r.pool)||void 0===y?void 0:y.liquidityPositions)||void 0===v?void 0:v[0])||void 0===b?void 0:b.id)===(null==D?void 0:D.id)&&(V=se._({id:"p3607o",message:"Managing"}));else if((null===(j=null==r?void 0:r.pool)||void 0===j?void 0:j.address)===E.id||(null==r?void 0:r.address)===E.id)if(r.operate===YT.Remove)V=se._({id:"0+31GV",message:"Removing"});else V=se._({id:"1yHVE+",message:"Adding"});const W=!!(null===(C=E.miningAddress)||void 0===C?void 0:C[0]),H=!!(null==R?void 0:R.metromMiningApy)&&Number(null==R?void 0:R.metromMiningApy)>0,$=m.palette.hover.default,z=null==p?void 0:p({address:E.id,chainId:E.chainId});return Yn.jsxs(i,{component:"tr",sx:{["&:hover td"+(V?", & td":"")]:{backgroundImage:`linear-gradient(${$}, ${$})`}},children:[Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[A&&O?Yn.jsx(kj,{tokens:[A,O],width:24,mr:8,chainId:E.chainId,showChainLogo:!0}):"",Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==A?void 0:A.symbol}/${null==O?void 0:O.symbol}`,Yn.jsx(gS,{address:E.id,chainId:E.chainId}),!!z&&Yn.jsx(SS,{})]}),Yn.jsx(zb,{address:E.id,customChainId:E.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,disabledAddress:d,onAddressClick:()=>{Gj.getState().push({type:Zj.PoolDetail,params:{chainId:E.chainId,address:E.id}})},sx:{typography:"h6",color:"text.secondary"}})]})]})}),d&&Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(cT,{poolType:F}),Yn.jsx(uT,{isAMMV2:U,isAMMV3:q,lpFeeRate:E.lpFeeRate,mtFeeRate:E.mtFeeRate})]})}),q?null:Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{typography:"body2"},title:E.tvl?`$${Em({input:E.tvl||0})}`:void 0,children:["$",qm(new Pe(E.tvl||0))]})}),Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[W||H?Yn.jsx(l,{title:se._({id:"Sti4vy",message:"Mining"}),children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",Yn.jsx(ES,{chainId:E.chainId,apy:R,baseToken:A,quoteToken:O,hasQuote:!!_,hasMining:W,children:Yn.jsxs(i,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[P||"-%",_?`/${_}`:""]})})]})}),Yn.jsx(i,{component:"td",children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"body2"},children:q?(null==D?void 0:D.liquidityUSD)?`$${Am({input:D.liquidityUSD,decimals:2})}`:"-":Yn.jsxs(Yn.Fragment,{children:[L?Yn.jsx(Df,{address:null==A?void 0:A.address,chainId:E.chainId,url:null==A?void 0:A.logoURI,width:24,height:24,noShowChain:!0,sx:{mr:4}}):Yn.jsx(kj,{tokens:A&&O?[A,O]:[],width:24,mr:4,showChainLogo:!1,chainId:E.chainId}),M?Em({input:M}):"-",L&&Yn.jsxs(Yn.Fragment,{children:[" / ",Yn.jsx(Df,{address:null==O?void 0:O.address,chainId:E.chainId,url:null==O?void 0:O.logoURI,width:24,height:24,noShowChain:!0,sx:{mx:4}}),B?Em({input:B}):"0"]}),U&&Yn.jsx(l,{title:Yn.jsx(e,{id:"NXZdrO",message:"My pool share"}),children:Yn.jsx(i,{sx:{ml:4,px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Vm({input:null===(k=null===(w=n.liquidityPositions)||void 0===w?void 0:w[0])||void 0===k?void 0:k.poolShare})})})]})})}),u?Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[Yn.jsx(UT,{outOfRange:null!==(T=null==D?void 0:D.outOfRange)&&void 0!==T&&T}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(I=null==D?void 0:D.priceRange)||void 0===I?void 0:I.token0LowerPrice,atLimit:{},direction:dC.LOWER})," "]}),null==A?void 0:A.symbol]})}),Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:Yn.jsx("path",{d:"M15.75 9.50293L12.75 12.5029L11.7 11.4529L12.8813 10.2529L5.11875 10.2529L6.3 11.4529L5.25 12.5029L2.25 9.50293L5.25 6.50293L6.31875 7.55293L5.11875 8.75293L12.8813 8.75293L11.7 7.55293L12.75 6.50293L15.75 9.50293Z",fill:"currentColor",fillOpacity:"0.5"})}),Yn.jsx(i,{children:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("span",{children:[rT({price:null===(S=null==D?void 0:D.priceRange)||void 0===S?void 0:S.token0UpperPrice,atLimit:{},direction:dC.UPPER})," "]}),null==A?void 0:A.symbol]})})]})}):null,Yn.jsx(i,{component:"td",children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[d&&"PMM"===F&&Yn.jsx(zT,{chainId:E.chainId,address:E.id}),V?Yn.jsx(HT,{text:V,onClick:()=>s(null)}):Yn.jsxs(Yn.Fragment,{children:[q?null:!!t&&Yn.jsxs(c,{variant:c.Variant.second,size:c.Size.small,onClick:e=>{e.stopPropagation(),s({operate:YT.Remove,pool:Qm(n),hasMining:W})},sx:{py:0,height:32},children:[Yn.jsx(e,{id:"t/YqKh",message:"Remove"}),!!z&&Yn.jsx(SS,{isRightTop:!0})]}),Yn.jsx(c,{size:c.Size.small,onClick:()=>{s({pool:Qm(n),hasMining:W})},sx:{py:0,height:32},children:q?se._({id:"wckWOP",message:"Manage"}):se._({id:"m16xKo",message:"Add"})})]})]})})]},q?null==D?void 0:D.id:E.id+E.chainId)}))})]})}function QS({account:e,filterChainIds:t,activeChainId:n,handleChangeActiveChainId:o,operatePool:r,setOperatePool:s,getMigrationPairAndMining:l,tokenAndPoolFilter:d,children:c}){var u,p,h,m,g,f,x,y;const v=a(),{minDevice:b,isMobile:j}=Tg(),C=nt(),{onlyChainId:w,supportAMMV2:k,supportAMMV3:T,notSupportPMM:I}=Jn(),[S,E]=H.useState("pmm&v2"),[A,O]=H.useState("1"),{filterTokens:L,filterASymbol:R,filterBSymbol:P,filterAddressLqList:_,handleDeleteToken:M,handleChangeFilterTokens:B,handleChangeFilterAddress:D}=OS(d);let N=I?[]:["CLASSICAL","DVM","DSP","GSP","DPP"];k&&N.push("AMMV2"),T&&"v3"===S&&(N=["AMMV3"]);const F={currentPage:1,pageSize:1e3,user:e,filterState:{viewOnlyOwn:!0,filterTypes:N}},U=gg(),q=U.getQuery(ye.graphql.fetchMyLiquidityList,{where:Object.assign(Object.assign({},F),{filterState:Object.assign({filterASymbol:R,filterBSymbol:P},F.filterState)})}),V=et(Object.assign({},q));let W=null!==(h=null===(p=null===(u=V.data)||void 0===u?void 0:u.liquidity_list)||void 0===p?void 0:p.lqList)&&void 0!==h?h:[];const $=!!(null==_?void 0:_.length);return $?W=[..._]:t&&(W=null!==(x=null===(f=null===(g=null===(m=V.data)||void 0===m?void 0:m.liquidity_list)||void 0===g?void 0:g.lqList)||void 0===f?void 0:f.filter((e=>{var n,i;return t.includes(null!==(i=null===(n=null==e?void 0:e.pair)||void 0===n?void 0:n.chainId)&&void 0!==i?i:0)})))&&void 0!==x?x:[]),Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{pt:12,pb:20,display:"flex",flexDirection:"column",gap:12,[v.breakpoints.up("tablet")]:{py:16,flexDirection:"row",gap:8,px:0,justifyContent:"space-between"}},children:[Yn.jsx(i,{sx:{[v.breakpoints.up("tablet")]:{mr:"auto"}},children:c}),!w&&Yn.jsx(kS,{chainId:n,setChainId:o}),T&&Yn.jsx(IS,{filterList:[{label:"V3",value:"v3"},{label:"V2 & PMM",value:"pmm&v2"}],value:S,onChange:e=>E(e)}),Yn.jsx(IS,{filterList:[{label:"1d",value:"1"},{label:"7d",value:"7"},{label:"14d",value:"14"},{label:"30d",value:"30"}],value:A,onChange:e=>O(e)}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:Object.assign({flex:1,display:"flex",alignItems:"center",gap:8},j?{}:{"& > button":{flex:1}}),children:null!==(y=null==d?void 0:d.element)&&void 0!==y?y:Yn.jsx(QT,{value:L,onChange:B,searchAddress:(e,t)=>Vn(this,void 0,void 0,(function*(){var n;const i=U.getInfiniteQuery(ye.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},F),{filterState:Object.assign({address:e},F.filterState)})}),o=null===(n=(yield C.fetchQuery(i)).liquidity_list)||void 0===n?void 0:n.lqList;return(null==o?void 0:o.length)?Yn.jsx(AS,{list:o,onClick:()=>{D(o),t()}}):null}))})}),($||!!L.length)&&Yn.jsxs(i,{sx:{my:0},children:[$?Yn.jsx(TS,{lqList:_,onDeleteTag:()=>D([])}):"",Yn.jsx($T,{tags:L,onDeleteTag:M})]})]})]}),j?Yn.jsxs(WT,{children:[V.isLoading?Yn.jsx(GT,{}):"",!V.isLoading&&!(null==W?void 0:W.length)&&!V.error&&Yn.jsx(ti,{sx:{mt:40},hasSearch:!!(n&&!w||R||P)}),!!V.error&&Yn.jsx(ai,{refresh:V.refetch,sx:{mt:40}}),Yn.jsx(ZS,{account:e,lqList:W,setOperatePool:s,supportAMM:k||T,getMigrationPairAndMining:l,timeRange:A})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(GS,{account:e,lqList:W,loading:V.isLoading,operatePool:r,setOperatePool:s,supportAMM:k||T,onlyV3:"v3"===S,getMigrationPairAndMining:l,timeRange:A}),Yn.jsx(Tj,{loading:V.isLoading,refetch:V.error?V.refetch:void 0,empty:!(null==W?void 0:W.length),hasSearch:!!(n&&!w||R||P)})]})]})}function YS(e){var{sx:t}=e,n=qn(e,["sx"]);return Yn.jsx(O,{...n,sx:Object.assign(Object.assign({},t),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function KS({params:e,scrollRef:t,tokenAndPoolFilter:n,operatePool:o,onOperatePool:r,getMigrationPairAndMining:s}){var l,d,c;const{isMobile:u}=Tg();a();const p=Jn((e=>e.noDocumentLink)),h=H.useRef(null),{account:m}=dg(),{poolTopTab:g,normalPoolTab:f,almPoolTab:x,multiTokenPoolTab:y,normalTabs:v,almTabs:b,topTabs:j,multiTokenTabs:C,handleChangePoolTab:w}=function(){const[e,t]=z(FS.NORMAL),[n,i]=z(US.ALL),[o,r]=z(qS.addLiquidity),[a,s]=z(VS.ALL),{supportAMMV2:l,supportAMMV3:d,notSupportPMM:c,supportCurve:u}=Jn(),p=$((()=>{const e=[{key:FS.NORMAL,value:"Normal"}];return u&&e.push({key:FS.MULTI_TOKEN,value:"Multi-token"}),e}),[u]),h=$((()=>[{key:US.ALL,value:"All vauls"},{key:US.MY,value:"My liquidity"}]),[]),m=$((()=>{const e=[{key:qS.addLiquidity,value:"Add Liquidity"},{key:qS.myLiquidity,value:"My Liquidity"}];return c||e.push({key:qS.myCreated,value:l||d?"My Pools (PMM)":"My Pools"}),e}),[l,d,c]),g=$((()=>[{key:VS.ALL,value:"All pools"},{key:VS.MY,value:"My liquidity"}]),[]),f=G(!1);return Q((()=>{const e=sessionStorage.getItem(BS),n=sessionStorage.getItem(DS);e&&n&&!f.current&&(f.current=!0,t(e),e===FS.NORMAL?r(n):e===FS.ALM?i(n):e===FS.MULTI_TOKEN&&s(n))}),[]),{poolTopTab:e,normalPoolTab:o,almPoolTab:n,multiTokenPoolTab:a,topTabs:p,normalTabs:m,almTabs:h,multiTokenTabs:g,handleChangePoolTab:({topTab:e,poolTab:n})=>{t(e),e===FS.NORMAL?r(n):e===FS.ALM?i(n):e===FS.MULTI_TOKEN&&s(n),sessionStorage.setItem(BS,e),sessionStorage.setItem(DS,n)}}}(),{activeChainId:k,filterChainIds:T,handleChangeActiveChainId:I}=function(){const{chainId:e}=dg(),{onlyChainId:t,defaultChainId:n}=Jn(),[i,o]=H.useState(t),r=H.useMemo((()=>void 0!==i?[i]:sh(e)?void 0:Object.values(le).filter((e=>!!Number(e)))),[e,i]);return H.useEffect((()=>{const e=Number(sessionStorage.getItem(NS));e&&o(e)}),[]),H.useEffect((()=>{!sessionStorage.getItem(NS)&&n&&o(n)}),[n]),{activeChainId:i,filterChainIds:r,handleChangeActiveChainId:e=>{void 0===e?sessionStorage.removeItem(NS):sessionStorage.setItem(NS,String(e)),o(e)}}}(),[E,A]=H.useState(null),[L,R]=H.useState(o||null),P=e=>{if(r){if(r(e))return}R(e)};return H.useEffect((()=>{R(o||null)}),[o]),Yn.jsxs(zj,{sx:Object.assign({},u?{p:0}:{display:"flex",gap:12,flex:1}),ref:h,children:[Yn.jsxs(S,{value:g,onChange:(e,t)=>{t===FS.NORMAL?w({topTab:t,poolTab:f}):t===FS.ALM?w({topTab:t,poolTab:x}):t===FS.MULTI_TOKEN&&w({topTab:t,poolTab:y})},sx:u?{}:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%"},children:[Yn.jsxs(i,{sx:Object.assign({},u?void 0:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",pb:16,borderBottomWidth:1,borderBottomColor:"border.main",borderBottomStyle:"solid"}),children:[Yn.jsx(D,{tabs:j,variant:"default",tabsListSx:Object.assign({justifyContent:"space-between"},u?{mb:12,gap:32}:{borderBottomWidth:0}),tabSx:u?{mr:0,padding:"0px 0px 16px 0px",flexGrow:1,flexShrink:1,flexBasis:"93px",gap:32}:{mr:48,typography:"h5",lineHeight:"25px",minHeight:41,padding:"8px 0px 8px 0px"}}),g===FS.NORMAL&&Yn.jsx(MS,{})]}),Yn.jsx(YS,{value:FS.ALM,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:"ALM"}),Yn.jsx(YS,{value:FS.NORMAL,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsxs(S,{value:f,onChange:(e,t)=>{w({topTab:FS.NORMAL,poolTab:t})},children:[Yn.jsx(O,{value:qS.addLiquidity,children:Yn.jsx(PS,{account:m,filterChainIds:T,scrollParentRef:null!=t?t:h,activeChainId:k,handleChangeActiveChainId:I,operatePool:L,setOperatePool:P,tokenAndPoolFilter:n,getMigrationPairAndMining:s,children:Yn.jsx(F,{tabs:v,variant:"inPaperContrast"})})}),Yn.jsx(O,{value:qS.myLiquidity,children:Yn.jsx(QS,{account:m,filterChainIds:T,activeChainId:k,handleChangeActiveChainId:I,operatePool:L,setOperatePool:P,tokenAndPoolFilter:n,getMigrationPairAndMining:s,children:Yn.jsx(F,{tabs:v,variant:"inPaperContrast"})})}),Yn.jsx(O,{value:qS.myCreated,children:Yn.jsx(zS,{account:m,filterChainIds:T,activeChainId:k,handleChangeActiveChainId:I,operatePool:L,setOperatePool:P,children:Yn.jsx(F,{tabs:v,variant:"inPaperContrast"})})}),!p&&Yn.jsx(Qj,{title:"How does Liquidity Pools work?",descList:[{title:"Deposit Liquidity",desc:"Select a liquidity pool that suits your preferences and supply a pair of assets in our AMM pools or any supported assets in StableSwap pools. In return, you'll receive LP tokens, representing your share of the liquidity provided."},{title:"Earn Fees",desc:"As transactions occur within the pool, fees are collected and added to your LP tokens' value. This accrues daily, giving you real-time APY as your token holdings grow."},{title:"Delegate & Change Pool Fees",desc:"Boosted pool rewards are distributed every Sunday. If you've contributed liquidity to these pools, simply visit the rewards page, select the relevant week, and claim your earnings with ease."}],linkTo:"https://docs.dodoex.io/product/tutorial/how-to-provide-liquidity",sx:Object.assign({mt:16},u&&{mt:20})})]})}),Yn.jsx(YS,{value:FS.MULTI_TOKEN,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:Yn.jsxs(S,{value:y,onChange:(e,t)=>{w({topTab:FS.MULTI_TOKEN,poolTab:t})},children:[Yn.jsx(O,{value:VS.ALL,children:Yn.jsx(rI,{scrollParentRef:null!=t?t:h,activeChainId:k,operateCurvePool:E,setOperateCurvePool:A,account:m,children:Yn.jsx(F,{tabs:C,variant:"inPaperContrast"})})}),Yn.jsx(O,{value:VS.MY,children:Yn.jsx(rI,{scrollParentRef:null!=t?t:h,activeChainId:k,operateCurvePool:E,setOperateCurvePool:A,account:m,isMyPool:!0,children:Yn.jsx(F,{tabs:C,variant:"inPaperContrast"})})})]})})]}),g===FS.NORMAL&&L&&Yn.jsx(i,{sx:{position:"relative",width:u?"100%":375},children:"AMMV3"===(null===(l=null==L?void 0:L.pool)||void 0===l?void 0:l.type)&&L.pool.chainId?f===qS.myLiquidity&&(null===(c=null===(d=L.pool.liquidityPositions)||void 0===d?void 0:d[0])||void 0===c?void 0:c.tokenId)?Yn.jsx(FT,{baseToken:L.pool.baseToken,quoteToken:L.pool.quoteToken,feeAmount:Number(L.pool.lpFeeRate),tokenId:L.pool.liquidityPositions[0].tokenId,chainId:L.pool.chainId,onClose:()=>P(null)}):Yn.jsx(VT,{chainId:L.pool.chainId,baseToken:L.pool.baseToken,quoteToken:L.pool.quoteToken,feeAmount:Number(L.pool.lpFeeRate),onClose:()=>P(null),handleGoToAddLiquidityV3:e=>{Gj.getState().push({type:Zj.createPoolAMMV3,params:e})}}):Yn.jsx(Yn.Fragment,{children:u?Yn.jsx(mS,{account:m,onClose:()=>P(null),modal:u,...L}):Yn.jsx(hS,{account:m,onClose:()=>P(null),...L,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"}})})}),g===FS.MULTI_TOKEN&&E&&Yn.jsx(i,{sx:{position:"relative",width:u?"100%":375},children:Yn.jsx(hI,{operateCurvePool:E,setOperateCurvePool:A})})]})}function XS({sx:e,onClick:t}){const n=a();return Yn.jsx(r,{onClick:()=>{t?t():Gj.getState().back()},sx:ne({display:"inline-flex",alignItems:"center",cursor:"pointer"},e),children:Yn.jsx(i,{sx:{color:n.palette.text.secondary,width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",borderColor:n.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:8,backgroundColor:n.palette.background.paper},children:Yn.jsx(li.ArrowBack,{})})})}var JS,eE,tE,nE,iE,oE,rE,aE,sE,lE,dE,cE,uE;function pE(){return pE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},pE.apply(null,arguments)}const hE=e=>W.createElement("svg",pE({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),JS||(JS=W.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_5229_28889)"})),eE||(eE=W.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_5229_28889)"})),tE||(tE=W.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_5229_28889)"})),nE||(nE=W.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_5229_28889)"})),iE||(iE=W.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_5229_28889)"})),oE||(oE=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28889)"})),rE||(rE=W.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_5229_28889)"})),aE||(aE=W.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_5229_28889)"})),sE||(sE=W.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_5229_28889)"})),lE||(lE=W.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_5229_28889)"})),dE||(dE=W.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_5229_28889)"})),cE||(cE=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28889)"})),uE||(uE=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5229_28889",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_5229_28889",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_5229_28889",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_5229_28889",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_5229_28889",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_5229_28889",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_5229_28889",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_5229_28889",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_5229_28889",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_5229_28889",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_5229_28889",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5229_28889",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var mE,gE,fE,xE,yE,vE,bE,jE,CE,wE,kE,TE,IE;function SE(){return SE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},SE.apply(null,arguments)}const EE=e=>W.createElement("svg",SE({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),mE||(mE=W.createElement("rect",{x:28.5,y:214,width:40,height:6,fill:"url(#paint0_linear_3900_354238)"})),gE||(gE=W.createElement("rect",{x:88.5,y:208,width:40,height:12,fill:"url(#paint1_linear_3900_354238)"})),fE||(fE=W.createElement("rect",{x:148.5,y:201,width:40,height:19,fill:"url(#paint2_linear_3900_354238)"})),xE||(xE=W.createElement("rect",{x:208.5,y:188,width:40,height:32,fill:"url(#paint3_linear_3900_354238)"})),yE||(yE=W.createElement("rect",{x:268.5,y:170,width:40,height:50,fill:"url(#paint4_linear_3900_354238)"})),vE||(vE=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_3900_354238)"})),bE||(bE=W.createElement("rect",{width:40,height:6,transform:"matrix(-1 0 0 1 708.5 214)",fill:"url(#paint6_linear_3900_354238)"})),jE||(jE=W.createElement("rect",{width:40,height:12,transform:"matrix(-1 0 0 1 648.5 208)",fill:"url(#paint7_linear_3900_354238)"})),CE||(CE=W.createElement("rect",{width:40,height:19,transform:"matrix(-1 0 0 1 588.5 201)",fill:"url(#paint8_linear_3900_354238)"})),wE||(wE=W.createElement("rect",{width:40,height:32,transform:"matrix(-1 0 0 1 528.5 188)",fill:"url(#paint9_linear_3900_354238)"})),kE||(kE=W.createElement("rect",{width:40,height:50,transform:"matrix(-1 0 0 1 468.5 170)",fill:"url(#paint10_linear_3900_354238)"})),TE||(TE=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_3900_354238)"})),IE||(IE=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_3900_354238",x1:48.5,y1:214,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_3900_354238",x1:108.5,y1:208,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_3900_354238",x1:168.5,y1:201,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_3900_354238",x1:228.5,y1:188,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_3900_354238",x1:288.5,y1:170,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_3900_354238",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_3900_354238",x1:20,y1:0,x2:20,y2:6,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_3900_354238",x1:20,y1:0,x2:20,y2:12,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_3900_354238",x1:20,y1:0,x2:20,y2:19,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_3900_354238",x1:20,y1:0,x2:20,y2:32,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_3900_354238",x1:20,y1:0,x2:20,y2:50,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_3900_354238",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var AE,OE,LE,RE,PE,_E,ME,BE,DE,NE,FE,UE,qE,VE;function WE(){return WE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},WE.apply(null,arguments)}const HE=e=>W.createElement("svg",WE({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),AE||(AE=W.createElement("g",{clipPath:"url(#clip0_5057_344879)"},W.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344879)"}),W.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344879)"}),W.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344879)"}),W.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344879)"}),W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344879)"}),W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344879)"}),W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344879)"}),W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344879)"}),W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344879)"}),W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344879)"}))),OE||(OE=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344879)"})),LE||(LE=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344879)"})),RE||(RE=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344879)"})),PE||(PE=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344879)"})),_E||(_E=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344879)"})),ME||(ME=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344879)"})),BE||(BE=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344879)"})),DE||(DE=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344879)"})),NE||(NE=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344879)"})),FE||(FE=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344879)"})),UE||(UE=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344879)"})),qE||(qE=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344879)"})),VE||(VE=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5057_344879",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5057_344879",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint2_linear_5057_344879",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint3_linear_5057_344879",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint4_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint5_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint6_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint7_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint8_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint9_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"white",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"white",stopOpacity:0})),W.createElement("linearGradient",{id:"paint10_linear_5057_344879",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5057_344879",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint12_linear_5057_344879",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint13_linear_5057_344879",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint14_linear_5057_344879",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint15_linear_5057_344879",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#D0BCFF",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#D0BCFF",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint16_linear_5057_344879",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint17_linear_5057_344879",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint18_linear_5057_344879",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint19_linear_5057_344879",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint20_linear_5057_344879",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint21_linear_5057_344879",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("clipPath",{id:"clip0_5057_344879"},W.createElement("rect",{width:737,height:220,fill:"white"})))));var $E,zE,ZE,GE,QE,YE,KE,XE,JE,eA,tA,nA,iA,oA;function rA(){return rA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},rA.apply(null,arguments)}const aA=e=>W.createElement("svg",rA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),$E||($E=W.createElement("g",{clipPath:"url(#clip0_5057_344817)"},W.createElement("rect",{x:-10.5,y:160,width:40,height:60,fill:"url(#paint0_linear_5057_344817)"}),W.createElement("rect",{x:49.5,y:120,width:40,height:100,fill:"url(#paint1_linear_5057_344817)"}),W.createElement("rect",{x:109.5,y:60,width:40,height:160,fill:"url(#paint2_linear_5057_344817)"}),W.createElement("rect",{x:169.5,width:40,height:220,fill:"url(#paint3_linear_5057_344817)"}),W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 549.5 200)",fill:"url(#paint4_linear_5057_344817)"}),W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 489.5 180)",fill:"url(#paint5_linear_5057_344817)"}),W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 429.5 160)",fill:"url(#paint6_linear_5057_344817)"}),W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 369.5 120)",fill:"url(#paint7_linear_5057_344817)"}),W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 309.5 60)",fill:"url(#paint8_linear_5057_344817)"}),W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 249.5 0)",fill:"url(#paint9_linear_5057_344817)"}))),zE||(zE=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint10_linear_5057_344817)"})),ZE||(ZE=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint11_linear_5057_344817)"})),GE||(GE=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint12_linear_5057_344817)"})),QE||(QE=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint13_linear_5057_344817)"})),YE||(YE=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint14_linear_5057_344817)"})),KE||(KE=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint15_linear_5057_344817)"})),XE||(XE=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint16_linear_5057_344817)"})),JE||(JE=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint17_linear_5057_344817)"})),eA||(eA=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint18_linear_5057_344817)"})),tA||(tA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint19_linear_5057_344817)"})),nA||(nA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint20_linear_5057_344817)"})),iA||(iA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint21_linear_5057_344817)"})),oA||(oA=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5057_344817",x1:9.5,y1:160,x2:9.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5057_344817",x1:69.5,y1:120,x2:69.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint2_linear_5057_344817",x1:129.5,y1:60,x2:129.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint3_linear_5057_344817",x1:189.5,y1:0,x2:189.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint4_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint5_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint6_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint7_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint8_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint9_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#1A1A1B",stopOpacity:.1}),W.createElement("stop",{offset:1,stopColor:"#1A1A1B",stopOpacity:0})),W.createElement("linearGradient",{id:"paint10_linear_5057_344817",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5057_344817",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint12_linear_5057_344817",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint13_linear_5057_344817",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint14_linear_5057_344817",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint15_linear_5057_344817",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint16_linear_5057_344817",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint17_linear_5057_344817",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint18_linear_5057_344817",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint19_linear_5057_344817",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint20_linear_5057_344817",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint21_linear_5057_344817",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("clipPath",{id:"clip0_5057_344817"},W.createElement("rect",{width:737,height:220,fill:"white"})))));var sA,lA,dA,cA,uA,pA,hA,mA,gA,fA,xA,yA,vA;function bA(){return bA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},bA.apply(null,arguments)}const jA=e=>W.createElement("svg",bA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),sA||(sA=W.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),lA||(lA=W.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),dA||(dA=W.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),cA||(cA=W.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),uA||(uA=W.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),pA||(pA=W.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"white",fillOpacity:.1})),hA||(hA=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_5229_28865)"})),mA||(mA=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_5229_28865)"})),gA||(gA=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_5229_28865)"})),fA||(fA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_5229_28865)"})),xA||(xA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_5229_28865)"})),yA||(yA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_5229_28865)"})),vA||(vA=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5229_28865",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_5229_28865",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_5229_28865",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_5229_28865",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_5229_28865",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_5229_28865",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var CA,wA,kA,TA,IA,SA,EA,AA,OA,LA,RA,PA,_A;function MA(){return MA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MA.apply(null,arguments)}const BA=e=>W.createElement("svg",MA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),CA||(CA=W.createElement("rect",{x:28.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),wA||(wA=W.createElement("rect",{x:88.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),kA||(kA=W.createElement("rect",{x:148.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),TA||(TA=W.createElement("rect",{x:208.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),IA||(IA=W.createElement("rect",{x:268.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),SA||(SA=W.createElement("rect",{x:328.5,y:216,width:40,height:4,fill:"#1A1A1B",fillOpacity:.1})),EA||(EA=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint0_linear_3900_354262)"})),AA||(AA=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint1_linear_3900_354262)"})),OA||(OA=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint2_linear_3900_354262)"})),LA||(LA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint3_linear_3900_354262)"})),RA||(RA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint4_linear_3900_354262)"})),PA||(PA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint5_linear_3900_354262)"})),_A||(_A=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_3900_354262",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_3900_354262",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_3900_354262",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_3900_354262",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_3900_354262",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_3900_354262",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var DA,NA,FA,UA,qA,VA,WA,HA,$A,zA,ZA,GA,QA;function YA(){return YA=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},YA.apply(null,arguments)}const KA=e=>W.createElement("svg",YA({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),DA||(DA=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_5229_28987)"})),NA||(NA=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_5229_28987)"})),FA||(FA=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_5229_28987)"})),UA||(UA=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_5229_28987)"})),qA||(qA=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_5229_28987)"})),VA||(VA=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_5229_28987)"})),WA||(WA=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_5229_28987)"})),HA||(HA=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_5229_28987)"})),$A||($A=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_5229_28987)"})),zA||(zA=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_5229_28987)"})),ZA||(ZA=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_5229_28987)"})),GA||(GA=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_5229_28987)"})),QA||(QA=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5229_28987",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_5229_28987",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_5229_28987",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_5229_28987",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_5229_28987",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_5229_28987",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#B786FD",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#B786FD",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_5229_28987",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_5229_28987",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_5229_28987",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_5229_28987",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_5229_28987",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_5229_28987",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FFE804",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#FFE804",stopOpacity:.04})))));var XA,JA,eO,tO,nO,iO,oO,rO,aO,sO,lO,dO,cO;function uO(){return uO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uO.apply(null,arguments)}const pO=e=>W.createElement("svg",uO({width:737,height:220,viewBox:"0 0 737 220",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),XA||(XA=W.createElement("rect",{x:28.5,y:200,width:40,height:20,fill:"url(#paint0_linear_4437_25449)"})),JA||(JA=W.createElement("rect",{x:88.5,y:180,width:40,height:40,fill:"url(#paint1_linear_4437_25449)"})),eO||(eO=W.createElement("rect",{x:148.5,y:160,width:40,height:60,fill:"url(#paint2_linear_4437_25449)"})),tO||(tO=W.createElement("rect",{x:208.5,y:120,width:40,height:100,fill:"url(#paint3_linear_4437_25449)"})),nO||(nO=W.createElement("rect",{x:268.5,y:60,width:40,height:160,fill:"url(#paint4_linear_4437_25449)"})),iO||(iO=W.createElement("rect",{x:328.5,width:40,height:220,fill:"url(#paint5_linear_4437_25449)"})),oO||(oO=W.createElement("rect",{width:40,height:20,transform:"matrix(-1 0 0 1 708.5 200)",fill:"url(#paint6_linear_4437_25449)"})),rO||(rO=W.createElement("rect",{width:40,height:40,transform:"matrix(-1 0 0 1 648.5 180)",fill:"url(#paint7_linear_4437_25449)"})),aO||(aO=W.createElement("rect",{width:40,height:60,transform:"matrix(-1 0 0 1 588.5 160)",fill:"url(#paint8_linear_4437_25449)"})),sO||(sO=W.createElement("rect",{width:40,height:100,transform:"matrix(-1 0 0 1 528.5 120)",fill:"url(#paint9_linear_4437_25449)"})),lO||(lO=W.createElement("rect",{width:40,height:160,transform:"matrix(-1 0 0 1 468.5 60)",fill:"url(#paint10_linear_4437_25449)"})),dO||(dO=W.createElement("rect",{width:40,height:220,transform:"matrix(-1 0 0 1 408.5 0)",fill:"url(#paint11_linear_4437_25449)"})),cO||(cO=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_4437_25449",x1:48.5,y1:200,x2:48.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint1_linear_4437_25449",x1:108.5,y1:180,x2:108.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint2_linear_4437_25449",x1:168.5,y1:160,x2:168.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint3_linear_4437_25449",x1:228.5,y1:120,x2:228.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint4_linear_4437_25449",x1:288.5,y1:60,x2:288.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint5_linear_4437_25449",x1:348.5,y1:0,x2:348.5,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#6851B4",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#6851B4",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint6_linear_4437_25449",x1:20,y1:0,x2:20,y2:20,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint7_linear_4437_25449",x1:20,y1:0,x2:20,y2:40,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint8_linear_4437_25449",x1:20,y1:0,x2:20,y2:60,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint9_linear_4437_25449",x1:20,y1:0,x2:20,y2:100,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint10_linear_4437_25449",x1:20,y1:0,x2:20,y2:160,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})),W.createElement("linearGradient",{id:"paint11_linear_4437_25449",x1:20,y1:0,x2:20,y2:220,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EB8D27",stopOpacity:.6}),W.createElement("stop",{offset:1,stopColor:"#EB8D27",stopOpacity:.04})))));var hO,mO;function gO(){const e="https://docs.dodoex.io/product/tutorial/how-to-create-pools#learn-more-about-the-characteristics-of-different-pool-models",t=[{version:mO.standard,title:se._({id:"TJBHlP",message:"Standard"}),description:se._({id:"QNrpkx",message:"Classical AMM-like pool. Suitable for most assets."}),exampleImgUrl:pO,exampleDarkImgUrl:KA,docUrl:e,initPriceLabel:se._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:se._({id:"5OKrbq",message:"Since this pool uses the PMM algorithm, which is different from the normal AMM pool mechanism, the initial price calculation is also different from AMM."}),initPriceTipsLink:"https://docs.dodoex.io/en/product/dodo-v2-pools/dodo-vending-machine/dvm-initial-price-formula-explanation"},{version:mO.pegged,title:se._({id:"J7M/DA",message:"Pegged"}),description:se._({id:"RvYEUJ",message:"Suitable for synthetic assets. The liquidity is super concentrated at some price like Curve Finance."}),exampleImgUrl:EE,exampleDarkImgUrl:hE,docUrl:e,initPriceLabel:se._({id:"4ogEAw",message:"Pegged Exchange Rate"}),initPriceTips:se._({id:"M9dIDb",message:"The pegged exchange rate refers to the exchange rate between two token assets where one's value is pegged/fixed by the other. For example, the pegged exchange rate between the US Dollar and USDT is 1."})},{version:mO.singleToken,title:se._({id:"34w3mT",message:"Single-Token"}),description:se._({id:"a1AzKr",message:"For those who are looking to sell tokens and only need ask-side liquidity."}),exampleImgUrl:BA,exampleDarkImgUrl:jA,docUrl:e,initPriceLabel:se._({id:"d2CZvA",message:"Initial Price"}),initPriceTips:se._({id:"HGf8fG",message:"You can set the minimum selling price for single-token pools."})},{version:mO.marketMakerPool,title:se._({id:"4vKwIV",message:"Private Pool"}),description:se._({id:"pKjCsP",message:"100% use your own funds and enjoy the maximum degree of flexibility."}),exampleImgUrl:aA,exampleDarkImgUrl:HE,docUrl:e,initPriceLabel:se._({id:"CeLrge",message:"Mid Price"}),initPriceTips:se._({id:"GGPOuT",message:"set current mid price"})}],n=t.reduce(((e,t)=>(e[t.version]=t,e)),{});return{versionList:t,versionMap:n,subPeggedVersionList:fO()}}function fO(){return[{version:hO.DSP,title:se._({id:"D1bhHv",message:"The pool’s market-making price is fixed"}),description:se._({id:"lgE483",message:"Once created, the price cannot be changed. This option applies to assets like ETH-WETH."})},{version:hO.GSP,title:se._({id:"LVzIav",message:"The pool’s market-making price can be adjusted"}),description:se._({id:"KkjUUb",message:"Once created, you can adjust the pool’s market-making price at any time. This option is suitable for assets with fluctuating pegged prices. Adjusting the pool’s market-making price allows for more competitive quotes."})}]}function xO(){return fO().reduce(((e,t)=>(e[t.version]=t,e)),{})}!function(e){e.DSP="dsp",e.GSP="gsp"}(hO||(hO={})),function(e){e.standard="standard",e.singleToken="single-token",e.pegged="pagged",e.marketMakerPool="market-maker-pool"}(mO||(mO={}));const yO="0.3",vO=0,bO=10,jO="1",CO="0.0000000000001",wO=1e8,kO="1",TO="0.0001",IO="0.1",SO=8;function EO({selectedVersion:e,quoteToken:t,initPrice:n,midPrice:i}){return e===mO.standard?!i||i.isZero()?null:Am({input:i,decimals:t.decimals}):Am({input:n,decimals:t.decimals})}function AO({initPrice:e}){const t=new Pe(e);if(!t.isFinite()||t.lte(0))return{base:null,quote:null};const n=new Pe(1),i=n.dividedBy(n.plus(t)).dp(SO,Pe.ROUND_DOWN);return{base:i,quote:n.minus(i).dp(SO,Pe.ROUND_DOWN)}}function OO({chainId:e,baseToken:t,quoteToken:n}){const i=we[e];return!(!t||!n)&&(!(!Xm(t.address,i.address)||!Xm(n.address,i.wrappedTokenAddress))||!(!Xm(t.address,i.wrappedTokenAddress)||!Xm(n.address,i.address)))}function LO({title:e,children:t,isWaiting:n}){const o=a();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:n?"-":t}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function RO({status:t,selectedVersion:n,baseToken:o,quoteToken:r,initPrice:a,slippageCoefficient:s,midPrice:l,sx:d}){var c;const{versionMap:u}=gO(),p="waiting"===t,{initPriceLabel:h}=u[n];return o&&r?Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:Object.assign({mt:0,display:"flex",alignItems:"stretch",gap:12,opacity:p?.5:1},d),children:[Yn.jsxs(LO,{title:Yn.jsx(e,{id:"fSFt4a",message:"Token Pair"}),isWaiting:p,children:[Yn.jsx(kj,{width:24,height:24,tokens:[o,r]}),o.symbol,"-",r.symbol]}),Yn.jsx(LO,{title:Yn.jsx(e,{id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:p,children:s}),Yn.jsxs(LO,{title:h,isWaiting:p,children:["1 ",o.symbol," = ",null!==(c=EO({midPrice:l,quoteToken:r,selectedVersion:n,initPrice:a}))&&void 0!==c?c:"-"," ",r.symbol]})]})}):null}var PO,_O;function MO(){return MO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},MO.apply(null,arguments)}const BO=e=>W.createElement("svg",MO({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),PO||(PO=W.createElement("g",{clipPath:"url(#clip0_5251_29079)"},W.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_29079)"}),W.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#EC5A7D",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),W.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_29079)"}),W.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#2FBA90",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),_O||(_O=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5251_29079",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#EC5A7D",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#EC5A7D",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5251_29079",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#2FBA90",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#2FBA90",stopOpacity:0})),W.createElement("clipPath",{id:"clip0_5251_29079"},W.createElement("rect",{width:54,height:32,fill:"white"})))));var DO,NO;function FO(){return FO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},FO.apply(null,arguments)}const UO=e=>W.createElement("svg",FO({width:54,height:32,viewBox:"0 0 54 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),DO||(DO=W.createElement("g",{clipPath:"url(#clip0_5251_28999)"},W.createElement("path",{d:"M41.2736 0.409826C33.3354 1.31458 28.4933 23.304 27.1777 32H54.0001V0.0303594C53.1946 0.0303459 46.2675 -0.159361 41.2736 0.409826Z",fill:"url(#paint0_linear_5251_28999)"}),W.createElement("path",{d:"M27 31.7932C28.3204 23.1499 33.2469 1.97641 41.3084 0.583249C43.491 0.206055 53.1916 0.206014 54 0.206056",stroke:"#FF6187",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}),W.createElement("path",{d:"M12.7264 0.409826C20.6646 1.31458 25.5067 23.304 26.8223 32H-0.000102997V0.0303594C0.805374 0.0303459 7.73247 -0.159361 12.7264 0.409826Z",fill:"url(#paint1_linear_5251_28999)"}),W.createElement("path",{d:"M27 31.7932C25.6796 23.1499 20.7531 1.97641 12.6916 0.583249C10.509 0.206055 0.808383 0.206014 2.38419e-07 0.206056",stroke:"#55F9C7",strokeWidth:.206452,strokeLinecap:"square",strokeLinejoin:"round"}))),NO||(NO=W.createElement("defs",null,W.createElement("linearGradient",{id:"paint0_linear_5251_28999",x1:54.0001,y1:5.72231,x2:54.0001,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#FF6187",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#FF6187",stopOpacity:0})),W.createElement("linearGradient",{id:"paint1_linear_5251_28999",x1:-10303e-8,y1:5.72231,x2:-10372e-8,y2:31.0514,gradientUnits:"userSpaceOnUse"},W.createElement("stop",{stopColor:"#55F9C7",stopOpacity:.3}),W.createElement("stop",{offset:1,stopColor:"#55F9C7",stopOpacity:0})),W.createElement("clipPath",{id:"clip0_5251_28999"},W.createElement("rect",{width:54,height:32,fill:"white"})))));function qO({height:e,text:t}){return Yn.jsx(ti,{sx:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",height:e||261},emptyText:t||se._({id:"uiuMDr",message:"Enter parameters to view the yield curve"})})}const VO=H.lazy((()=>import("./index-BrbFWPgV.js"))),WO=H.lazy((()=>import("./index-D9d6DgUD.js")));var HO,$O;function zO({baseToken:t,quoteToken:n,pmmParams:o,pmmModel:r,midPrice:s}){var l,d;const c=a(),{isMobile:u}=Tg(),[p,h]=H.useState(HO.depth),m=H.useRef(null),[g,f]=H.useState(0),x=null!==(l=null==t?void 0:t.symbol)&&void 0!==l?l:"",y=null!==(d=null==n?void 0:n.symbol)&&void 0!==d?d:"";H.useEffect((()=>{const e=()=>{m&&m.current&&f(m.current.offsetWidth)};return e(),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[m,s]);const v=p===HO.depth;if(!s||s.isNaN())return Yn.jsx(qO,{height:u?261:v?665:494});const b=c.palette.success.main,j=c.palette.error.main,C=[{key:HO.liquidity,value:se._({id:"6y2TB3",message:"Liquidity"})},{key:HO.depth,value:se._({id:"n25Lml",message:"Depth"})}];return Yn.jsxs(i,{ref:m,sx:{mt:2,"& input":{backgroundColor:"background.cardInput",borderStyle:"solid",borderWidth:"1px",borderColor:"border.main",borderRadius:8,color:"text.primary",overflow:"hidden"},"& .operate-btn-wrapper button":{backgroundColor:"background.paperContrast",color:"text.primary"}},children:[Yn.jsxs(S,{value:p,onChange:(e,t)=>{h(t)},children:[Yn.jsx(F,{tabs:C,variant:"tag",tabsListSx:{ml:"auto"}}),Yn.jsx(i,{sx:Object.assign({typography:"h6",mt:8,mb:14,color:"text.secondary"},u?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:Yn.jsx(e,{id:"tyGEMJ",message:"Amounts"})}),Yn.jsx(O,{value:HO.depth,children:g&&Yn.jsx(H.Suspense,{children:Yn.jsx(VO,{width:g,height:u?261:364,chartId:"create-pool-depth-chart",baseTokenSymbol:x,quoteTokenSymbol:y,pmmModel:r,pmmParams:o,midPrice:s,colorMap:{grid:"light"===c.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===c.palette.mode?"#E4E4E4":void 0,leftBg:[0,T(b,.04),1,T(b,.3)],leftLine:b,rightBg:[0,T(j,.04),1,T(j,.3)],rightLine:j,tooltipBg:c.palette.background.paperContrast,tooltipColor:c.palette.text.primary},notShowAmountInput:u})})}),Yn.jsx(O,{value:HO.liquidity,children:Yn.jsx(H.Suspense,{children:Yn.jsx(WO,{width:g,height:u?261:364,baseTokenSymbol:x,quoteTokenSymbol:y,pmmModel:r,pmmParams:o,midPrice:s,notShowTipText:!0,colorMap:{grid:"light"===c.palette.mode?"#E4E4E4":void 0,midPriceLine:"light"===c.palette.mode?"#E4E4E4":void 0,leftBg:[0,T(b,.04),1,T(b,.3)],leftLine:b,rightBg:[0,T(j,.04),1,T(j,.3)],rightLine:j,tooltipBg:c.palette.background.paperContrast,tooltipColor:c.palette.text.primary,textColor:c.palette.text.secondary}})})})]}),Yn.jsx(i,{sx:Object.assign({typography:"h6",mt:6,color:"text.secondary"},u?{transform:"scale(0.66667)",transformOrigin:"top left"}:{}),children:Yn.jsx(e,{id:"DZULmp",message:"Swap Rate"})}),v?"":Yn.jsxs(i,{sx:{typography:"h6",mt:24,color:"text.secondary",textAlign:"center"},children:["* ",se._({id:"DuVAxN",message:"The area of the chart indicates the buy/sell volume of {baseSymbol} that can be carried by the market when the current price changes to the hover price.",values:{baseSymbol:x}})]})]})}!function(e){e[e.liquidity=1]="liquidity",e[e.depth=2]="depth"}(HO||(HO={})),function(e){e[e.standard=1]="standard",e[e.singleToken=2]="singleToken",e[e.pagged=3]="pagged",e[e.marketMaker=4]="marketMaker"}($O||($O={}));const ZO=({selectedVersion:e,baseAmount:t,quoteAmount:n,initPrice:i,slippageCoefficient:o})=>{const r=$((()=>{const r=[mO.standard,mO.singleToken].includes(e),a=e===mO.singleToken;if(!t||!a&&!n)return;const s=Number(i),l=Number(t),d=Number(n),c=Number(o);return{i:s,k:c,b:l,b0:l,q:d,q0:0!==c&&r?0:d,R:0!==c&&r?1:0}}),[t,i,n,e,o]),a=$((()=>{if(r)return Le(r)}),[r]),s=$((()=>{if(a)return a.getMidPrice()}),[a]);return{pmmParams:r,pmmModel:a,midPrice:s}};function GO({selectedVersion:e,baseToken:t,quoteToken:n,initPrice:o,slippageCoefficient:r,baseAmount:s,quoteAmount:l}){const c=a(),{isMobile:u}=Tg(),[p,h]=H.useState(!1),{pmmParams:m,pmmModel:g,midPrice:x}=ZO({selectedVersion:e,baseAmount:s,quoteAmount:l,initPrice:o,slippageCoefficient:r});if(!u)return null;const y=se._({id:"FQfStS",message:"Emulator"}),v=se._({id:"ihn3o9",message:"The liquidity of ZUNO is continuous, which is different from the discrete liquidity of UniV3. The ticks shown in the illustration are for demonstration purposes only."});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{mx:20,mb:8},children:Yn.jsxs(i,{sx:{width:"100%",px:20,py:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:c.palette.border.main,display:"flex",alignItems:"center",justifyContent:"space-between"},component:d,onClick:()=>h(!0),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:c.palette.text.secondary,typography:"body1",fontWeight:600},children:[y,Yn.jsx(f,{title:v,ml:4,sx:{width:14,height:14}})]}),!x||x.isNaN()?Yn.jsx(i,{sx:{py:5,typography:"body1"},children:"-"}):"light"===c.palette.mode?Yn.jsx(BO,{width:"52",height:"32"}):Yn.jsx(UO,{width:"52",height:"32"})]})}),Yn.jsx(Of,{open:p,onClose:()=>h(!1),modal:!0,title:Yn.jsxs(i,{children:[y,Yn.jsx(f,{title:v,ml:4})]}),children:Yn.jsx(i,{sx:{px:28,pb:20,maxHeight:"calc(80vh - 134px)",overflowY:"auto",overflowX:"hidden"},children:Yn.jsx(zO,{baseToken:t,quoteToken:n,pmmParams:m,pmmModel:g,midPrice:x})})})]})}function QO({color:e,backgroundColor:t,tagKey:n}){return Yn.jsx(i,{sx:{ml:8,px:8,py:2,borderRadius:4,backgroundColor:t,color:e,typography:"h6",fontWeight:500},children:n})}function YO({isWaiting:t,feeRate:n}){const o=a();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,width:"50%",opacity:t?.5:1},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:t?"-":Yn.jsxs(Yn.Fragment,{children:[n||"-","%",n===yO&&Yn.jsx(QO,{tagKey:se._({id:"/+c6tU",message:"99% Default"}),color:o.palette.purple.main,backgroundColor:T(o.palette.purple.main,.1)})]})}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"})})]})}function KO({isWaiting:t,selectedVersion:n,baseToken:o,quoteToken:r,initPrice:s,slippageCoefficient:l,baseAmount:d,quoteAmount:c,peggedBaseTokenRatio:u,peggedQuoteTokenRatio:p}){const h=a(),{pmmParams:m,pmmModel:g,midPrice:f}=ZO({selectedVersion:n,baseAmount:d,quoteAmount:c,initPrice:s,slippageCoefficient:l});return Yn.jsxs(Yn.Fragment,{children:[!t&&Yn.jsx(zO,{baseToken:o,quoteToken:r,pmmParams:m,pmmModel:g,midPrice:f}),Yn.jsxs(i,{sx:{mt:t?0:20,padding:16,borderRadius:8,backgroundColor:h.palette.background.paper,width:"50%",opacity:t?.5:1},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:t?"-":Yn.jsxs(Yn.Fragment,{children:[u,"% ",null==o?void 0:o.symbol," : ",p,"% ",null==r?void 0:r.symbol]})}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:h.palette.text.secondary,mt:8},children:Yn.jsx(e,{id:"eK0eiF",message:"Initial asset ratio"})})]})]})}function XO({title:e,children:t,isWaiting:n}){const o=a();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:o.palette.background.paper,flexGrow:1,flexBasis:"100%"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8,typography:"h5"},children:n?"-":t}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:o.palette.text.secondary,mt:8},children:e})]})}function JO({status:e,selectedVersion:t,baseToken:n,quoteToken:o,initPrice:r,slippageCoefficient:a,baseAmount:s,quoteAmount:l}){var d;const{pmmParams:c,pmmModel:u,midPrice:p}=ZO({selectedVersion:t,baseAmount:s,quoteAmount:l,initPrice:r,slippageCoefficient:a}),{versionMap:h}=gO(),m="waiting"===e,{initPriceLabel:g}=h[t];return Yn.jsxs(Yn.Fragment,{children:["running"===e&&Yn.jsx(zO,{baseToken:n,quoteToken:o,pmmParams:c,pmmModel:u,midPrice:p}),Yn.jsxs(i,{sx:{mt:20,display:"flex",alignItems:"stretch",gap:12,opacity:m?.5:1},children:[Yn.jsx(XO,{title:se._({id:"fSFt4a",message:"Token Pair"}),isWaiting:m,children:n&&o?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(kj,{width:24,tokens:[n,o],chainId:n.chainId}),n.symbol,"-",o.symbol]}):""}),Yn.jsx(XO,{title:g,isWaiting:m,children:n&&o?Yn.jsxs(Yn.Fragment,{children:["1 ",n.symbol,"=",null!==(d=EO({midPrice:p,quoteToken:o,selectedVersion:t,initPrice:r}))&&void 0!==d?d:"-"," ",o.symbol]}):""}),Yn.jsx(XO,{title:se._({id:"sjn3tj",message:"Slippage Coefficient"}),isWaiting:m,children:a})]})]})}function eL({isWaiting:t,selectedSubPeggedVersion:n}){var o,r;const s=a(),l=xO();return Yn.jsxs(i,{sx:{padding:16,borderRadius:8,backgroundColor:s.palette.background.paper,width:"50%",opacity:t?.5:1},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"h5",fontWeight:600},children:t?"-":n&&null!==(r=null===(o=l[n])||void 0===o?void 0:o.title)&&void 0!==r?r:"-"}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,color:s.palette.text.secondary,mt:8},children:Yn.jsx(e,{id:"XPiFIY",message:"Can the pool price be adjusted?"})})]})}function tL({index:e,titleKey:t,status:n}){const o=a(),{isMobile:r}=Tg();return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:Object.assign({mt:28,mb:28,borderTopColor:"border.main",borderTopStyle:"solid",borderTopWidth:1},r?{mt:12,mb:12,display:1===e?"none":"block"}:{})}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",mb:20},children:[Yn.jsx(i,{sx:{display:"flex",width:"20px",height:"20px",justifyContent:"center",alignItems:"center",flexShrink:0,borderRadius:"50%",backgroundColor:"waiting"===n?o.palette.background.paperDarkContrast:o.palette.secondary.main,typography:"h6",fontWeight:600,textAlign:"center",color:"waiting"===n?o.palette.text.disabled:o.palette.secondary.contrastText},children:"completed"===n?Yn.jsx(Yn.Fragment,{children:Yn.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M12.7596 3.55566L5.92549 10.3897L3.23957 7.71418L1.77734 9.17641L5.92549 13.3246L14.2218 5.02826L12.7596 3.55566Z",fill:"currentColor"})})}):e}),Yn.jsx(i,{sx:{ml:8,typography:"body1",fontWeight:600,color:"waiting"===n?o.palette.text.disabled:o.palette.text.primary},children:t})]})]})}function nL({currentStep:e,isPeggedVersion:t}){const n=a(),{isMobile:o}=Tg();let r="",s="",l="";switch(e){case 0:r=se._({id:"hdIg7i",message:"Select Pool Version"}),l=se._({id:"fw3eYd",message:"ZUNO provides a variety of pool versions to suit your needs."});break;case 1:r=se._({id:"lsg9Mi",message:"Parameter Settings"});break;case 2:t?r=se._({id:"6lss/t",message:"Pricing Model"}):(r=se._({id:"Y7rVy0",message:"Fee Rate"}),s=se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}));break;case 3:if(!t)throw new Error("type is error");r=se._({id:"Y7rVy0",message:"Fee Rate"}),s=se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."});break;case 4:if(!t)throw new Error("type is error");r=se._({id:"3ggd2j",message:"Asset ratio within the pool"});break;default:throw new Error(`Invalid Step ${e}`)}return Yn.jsxs(i,{sx:Object.assign({position:"sticky",top:0,py:20,px:20,backgroundColor:n.palette.background.paper,zIndex:1},o?{}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"h5",color:n.palette.text.primary,fontWeight:600},children:r}),s&&Yn.jsx(f,{title:s,sx:{width:16,height:16}}),Yn.jsx(i,{sx:{marginLeft:"auto",display:"flex",alignItems:"center",gap:12},children:(t?[0,1,2,3,4]:[0,1,2]).map((t=>Yn.jsx(i,{sx:{width:12,height:12,borderRadius:12,background:e>=t?n.palette.secondary.main:T(n.palette.primary.main,.1)}},t)))})]}),l&&Yn.jsx(i,{sx:{mt:8,typography:"body2",color:n.palette.text.secondary},children:l})]})}function iL({versionItem:t,status:n}){const o=a(),{noDocumentLink:r}=Jn(),s="light"===o.palette.mode;return"completed"===n?Yn.jsxs(i,{sx:{backgroundColor:o.palette.background.paper,borderRadius:8,width:"50%",padding:16},children:[Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,color:o.palette.text.primary},children:t.title}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:500,mt:8,color:o.palette.text.secondary},children:t.description})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{typography:"h4",fontWeight:600},children:t.title}),!r&&Yn.jsxs(i,{sx:{ml:8,display:"flex",padding:"2px 8px",justifyContent:"center",alignItems:"center",gap:"2px",color:o.palette.text.disabled,backgroundColor:o.palette.background.paperDarkContrast,borderRadius:4,typography:"h6"},component:"a",href:t.docUrl,target:"_blank",rel:"noreferrer",children:[Yn.jsx(e,{id:"TGi+jm",message:"Doc"}),Yn.jsx("svg",{width:"14",height:"15",viewBox:"0 0 14 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.91667 3.41667V11.5833H11.0833V7.5H12.25V11.5833C12.25 12.225 11.725 12.75 11.0833 12.75H2.91667C2.26917 12.75 1.75 12.225 1.75 11.5833V3.41667C1.75 2.775 2.26917 2.25 2.91667 2.25H7V3.41667H2.91667ZM8.16667 3.41667V2.25H12.25V6.33333H11.0833V4.23917L5.34917 9.97333L4.52667 9.15083L10.2608 3.41667H8.16667Z",fill:"currentColor"})})]})]}),Yn.jsx(i,{sx:{position:"relative",width:"100%",minHeight:220},children:Yn.jsx(i,{component:s?t.exampleImgUrl:t.exampleDarkImgUrl,sx:{marginTop:20,width:"100%"}})})]})}function oL({side:e,tokenList:t,occupyToken:n,needFindToken:i,chainId:o}){var r,a;let s=null,l=null;const d=t.filter((t=>!(t.side&&t.side!==e||o&&t.chainId!==o)));return d.length&&(i&&(s=null!==(r=d.find((e=>e.address===(null==i?void 0:i.address)&&e.chainId===i.chainId)))&&void 0!==r?r:null,l=s),l||(n?l=null!==(a=d.find((e=>e.address!==n.address)))&&void 0!==a?a:null:[l]=d)),{findToken:s,defaultToken:l}}function rL(){const{account:e,chainId:t}=dg(),n=Gj((e=>{var t;return null===(t=e.page)||void 0===t?void 0:t.params}));return function({chainId:e,account:t,defaultBaseToken:n,defaultQuoteToken:i,tokenListInclude:o}={}){const{tokenList:r}=Th(),a=oL({side:"from",needFindToken:n,tokenList:r,chainId:e}),s=et(Object.assign({},ip.getFetchTokenQuery(o?void 0:e,null==n?void 0:n.address,t))),l=et(Object.assign({},ip.getFetchTokenQuery(o?void 0:e,null==i?void 0:i.address,t)));let d=null,c=!1;d=a.defaultToken,s.data&&(d=s.data,c=s.isLoading);let u=null,p=!1;return u=oL({side:"to",needFindToken:i,occupyToken:d,tokenList:r,chainId:e}).defaultToken,l.data&&(u=l.data,p=l.isLoading),{defaultBaseToken:d,defaultQuoteToken:u,defaultBaseTokenLoading:c,defaultQuoteTokenLoading:p}}({chainId:t,account:e,defaultBaseToken:(null==n?void 0:n.fromAddress)?{address:null==n?void 0:n.fromAddress,chainId:t}:void 0,defaultQuoteToken:(null==n?void 0:n.toAddress)?{address:null==n?void 0:n.toAddress,chainId:t}:void 0})}function aL({tokens:e}){const{apikey:t}=Jn(),n=Vg(Zu.fiatPrice);return et({enabled:!!e.length,queryKey:["fetch","fetchFiatPrice",e],queryFn:()=>Vn(this,void 0,void 0,(function*(){const i=yield Zt.post(n,{networks:e.map((e=>ig(e.chainId))),addresses:e.map((e=>e.address)),symbols:e.map((e=>e.symbol)),isCache:!0},t?{headers:{apikey:t}}:void 0),o=new Map;return i.data.data&&i.data.data.forEach((e=>{const t=Number(e.price);!Number.isNaN(t)&&t>0&&o.set(e.address,t)})),o}))})}const sL=({selectedVersion:e})=>e===mO.pegged?["0.0001","0.0005","0.002"]:["0.5","0.01","1"];var lL;function dL(e,t){return!e||null==t||e.isNaN()?"":e.dp(t,Pe.ROUND_DOWN).toString()}function cL({state:e,fixedRatioPrice:t}){const{selectedVersion:n,baseToken:i,quoteToken:o,baseAmount:r,isFixedRatio:a,leftTokenAddress:s}=e;if(!i||!o)throw new Error("token is required");const l=s===(null==i?void 0:i.address),d=n===mO.standard,c=n===mO.pegged,u=new Pe(t);let p=d?CO:l?t:!u.isNaN()&&u.gt(0)?new Pe(1).div(u).dp(l?o.decimals:i.decimals).toString():jO;if(d){const e=18-i.decimals+o.decimals;e<String(CO).split(".")[1].length&&(p=new Pe(1).div(10**e).toString())}if(c){const n=AO({initPrice:p}),i=n.base?n.base.multipliedBy(100).toString():"",o=n.quote?n.quote.multipliedBy(100).toString():"";return Object.assign(Object.assign({},e),{initPrice:p,fixedRatioPrice:t,peggedBaseTokenRatio:i,peggedQuoteTokenRatio:o})}if(d&&a){const n=new Pe(r);if(!n.isNaN()&&!u.isNaN()&&u.gt(0)){const r=l?n.multipliedBy(u):n.div(u);return Object.assign(Object.assign({},e),{initPrice:p,fixedRatioPrice:t,baseAmount:dL(n,i.decimals),quoteAmount:dL(r,o.decimals)})}}return Object.assign(Object.assign({},e),{initPrice:p,fixedRatioPrice:t})}function uL(e,t){var n;switch(t.type){case lL.SetCurrentStep:{const{payload:n}=t;return e.selectedVersion===mO.pegged?Object.assign(Object.assign({},e),{currentStep:n>=4?4:n<=0?0:n}):Object.assign(Object.assign({},e),{currentStep:n>=2?2:n<=0?0:n})}case lL.SelectNewVersion:{const{payload:i}=t;if(i===e.selectedVersion)return e;let o,r=kO;i===mO.pegged&&(r=TO,o=hO.DSP);let a=CO;i===mO.singleToken?a="":i!==mO.standard&&(a=jO);let s=!0;return i===mO.singleToken&&(s=!1),Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:"",isFixedRatio:s,initPrice:a,fixedRatioPrice:i===mO.singleToken?"":jO,slippageCoefficient:r,isSlippageCoefficientCustomized:!sL({selectedVersion:t.payload}).includes(r),selectedVersion:t.payload,selectedSubPeggedVersion:o,leftTokenAddress:null===(n=e.baseToken)||void 0===n?void 0:n.address})}case lL.SelectNewSubPeggedVersion:return Object.assign(Object.assign({},e),{selectedSubPeggedVersion:t.payload});case lL.UpdateBaseToken:{const n=t.payload;return Object.assign(Object.assign({},e),{baseToken:n,baseAmount:"",leftTokenAddress:null==n?void 0:n.address})}case lL.UpdateQuoteToken:{const{baseToken:n}=e;return Object.assign(Object.assign({},e),{quoteToken:t.payload,quoteAmount:"",leftTokenAddress:null==n?void 0:n.address})}case lL.SwitchTokens:{const{selectedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r}=e;return t===mO.singleToken?Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,leftTokenAddress:null==i?void 0:i.address}):Object.assign(Object.assign({},e),{baseToken:i,quoteToken:n,baseAmount:r,quoteAmount:o,leftTokenAddress:null==i?void 0:i.address})}case lL.UpdateBaseAmount:{const n=t.payload,{selectedVersion:i,quoteToken:o,fixedRatioPrice:r,isFixedRatio:a,peggedBaseTokenRatio:s}=e;if(!o)throw new Error("token is required");const l=new Pe(n);if(i===mO.pegged){const t=new Pe(s).div(100).dp(SO,Pe.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:""});const i=l.div(t).minus(l);return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:dL(i,o.decimals)})}if(i===mO.standard&&a&&r){if(!n)return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:n});const t=function(e,t){const n=new Re;return n.B=new Pe(e.baseAmount),n.i=new Pe(e.initPrice),n.k=new Pe(e.slippageCoefficient),n.RStatus=1,n.getQuoteByMidPrice(t)}(Object.assign(Object.assign({},e),{baseAmount:n}),new Pe(r));return Object.assign(Object.assign({},e),{baseAmount:n,quoteAmount:dL(t,o.decimals)})}return Object.assign(Object.assign({},e),{baseAmount:n})}case lL.UpdateQuoteAmount:{const n=t.payload,{selectedVersion:i,baseToken:o,fixedRatioPrice:r,isFixedRatio:a,leftTokenAddress:s,peggedQuoteTokenRatio:l}=e;if(!o)throw new Error("token is required");const d=s===(null==o?void 0:o.address),c=new Pe(n);if(i===mO.pegged){const t=new Pe(l).div(100).dp(SO,Pe.ROUND_DOWN);if(!t.isFinite()||t.lt(0))return Object.assign(Object.assign({},e),{baseAmount:"",quoteAmount:n});const i=c.div(t).minus(c);return Object.assign(Object.assign({},e),{baseAmount:dL(i,o.decimals),quoteAmount:n})}if(i===mO.standard&&a){const t=new Pe(r),i=t.gt(0)?d?c.div(t):c.multipliedBy(t):void 0;return Object.assign(Object.assign({},e),{baseAmount:dL(i,o.decimals),quoteAmount:n})}return Object.assign(Object.assign({},e),{quoteAmount:n})}case lL.UpdateIsFixedRatio:return Object.assign(Object.assign({},e),{isFixedRatio:t.payload});case lL.InitFixedRatioPrice:{const{leftTokenAddress:n,baseToken:i,quoteToken:o}=e;if(!i||!o)throw new Error("token is required");const r=n===(null==i?void 0:i.address),{baseTokenFiatPrice:a,quoteTokenFiatPrice:s}=t.payload,l=a&&s?new Pe(a).div(s):void 0,d=a&&s?new Pe(s).div(a):void 0,c=r?l:d,u=r?o.decimals:i.decimals;return c&&!c.isNaN()?cL({state:e,fixedRatioPrice:c.dp(u,Pe.ROUND_DOWN).toString()}):e}case lL.UpdateFixedRatioPrice:return cL({state:e,fixedRatioPrice:t.payload});case lL.ToggleLeftToken:{const{baseToken:t,quoteToken:n,fixedRatioPrice:i}=e;if(!t||!n)throw new Error("token is required");const o=e.leftTokenAddress===(null==t?void 0:t.address),r=o?null==n?void 0:n.address:null==t?void 0:t.address,a=new Pe(i);if(!a.isNaN()&&a.gt(0)){const i=new Pe(1).div(a).dp(o?t.decimals:n.decimals);return cL({state:Object.assign(Object.assign({},e),{leftTokenAddress:r}),fixedRatioPrice:i.toString()})}return Object.assign(Object.assign({},e),{leftTokenAddress:r})}case lL.UpdateSlippageCoefficient:return Object.assign(Object.assign({},e),{slippageCoefficient:t.payload});case lL.UpdateIsSlippageCoefficientCustomized:return Object.assign(Object.assign({},e),{isSlippageCoefficientCustomized:t.payload});case lL.UpdateFeeRate:return Object.assign(Object.assign({},e),{feeRate:t.payload});case lL.UpdateIsFeeRateCustomized:return Object.assign(Object.assign({},e),{isFeeRateCustomized:t.payload});case lL.InitEditParameters:return function(e,t){const{baseToken:n,quoteToken:i}=t;return n&&i?Object.assign(Object.assign({},e),{baseToken:n,quoteToken:i,leftTokenAddress:null==n?void 0:n.address,slippageCoefficient:"",initPrice:"",fixedRatioPrice:"",feeRate:"",isFixedRatio:!1}):e}(e,t.payload);case lL.UpdatePeggedBaseTokenRatio:{if(!e.quoteToken)throw new Error("token is required");const n=t.payload,i=new Pe(n).dp(SO-2,Pe.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:"",baseAmount:"",quoteAmount:""});const o=new Pe(100).minus(i).dp(SO-2,Pe.ROUND_DOWN),r=i.lte(0)?"0":e.baseAmount,a=new Pe(r),s=a.div(i.div(100)).minus(a);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:n,peggedQuoteTokenRatio:o.lt(0)?"0":o.toString(),baseAmount:r,quoteAmount:dL(s,e.quoteToken.decimals)})}case lL.UpdatePeggedQuoteTokenRatio:{if(!e.baseToken)throw new Error("token is required");const n=t.payload,i=new Pe(n).dp(SO-2,Pe.ROUND_DOWN);if(!i.isFinite()||i.lt(0))return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:"",peggedQuoteTokenRatio:n,baseAmount:"",quoteAmount:""});const o=new Pe(100).minus(i).dp(SO-2,Pe.ROUND_DOWN),r=i.lte(0)?"0":e.quoteAmount,a=new Pe(r),s=a.div(i.div(100)).minus(a);return Object.assign(Object.assign({},e),{peggedBaseTokenRatio:o.lt(0)?"0":o.toString(),peggedQuoteTokenRatio:n,baseAmount:dL(s,e.baseToken.decimals),quoteAmount:r})}default:throw Error("Unknown action: "+t.type)}}function pL({isSingleTokenVersion:e,leftTokenAddress:t,baseToken:n,quoteToken:i,dispatch:o}){var r,a;const s=aL({tokens:$((()=>n&&i?[n,i]:[]),[n,i])}),l=t===(null==n?void 0:n.address),d=n?null===(r=s.data)||void 0===r?void 0:r.get(n.address):void 0,c=i?null===(a=s.data)||void 0===a?void 0:a.get(i.address):void 0,u=$((()=>{const e=d&&c?new Pe(d).div(c):void 0,t=d&&c?new Pe(c).div(d):void 0;return l?e:t}),[d,l,c]),p=!u||u.isNaN(),h=!s.isLoading&&!s.isPending&&p;return te((()=>{h&&o({type:lL.UpdateIsFixedRatio,payload:!1})}),[o,h]),te((()=>{e||d&&o({type:lL.InitFixedRatioPrice,payload:{baseTokenFiatPrice:d,quoteTokenFiatPrice:c}})}),[d,o,e,c]),{fiatPriceLoading:s.isLoading||s.isPending,currentPrice:u,isErrorPrice:h,isNullPrice:p}}function hL({label:e,value:t}){return Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",mb:16},children:[Yn.jsx(i,{sx:{color:"text.secondary",mr:8},children:e}),Yn.jsx(i,{sx:{textAlign:"right",wordBreak:"break-all"},children:t})]})}function mL({on:e,onClose:t,state:n,onConfirm:o,isModify:r,loading:a}){var s,l,d,u,p,h,m;const{chainId:g}=dg(),{versionMap:f}=gO(),{isMobile:x}=Tg(),{title:y,initPriceLabel:v}=f[n.selectedVersion],{midPrice:b}=ZO({selectedVersion:n.selectedVersion,baseAmount:n.baseAmount,quoteAmount:n.quoteAmount,initPrice:n.initPrice,slippageCoefficient:n.slippageCoefficient}),j=xO(),C=n.selectedVersion===mO.pegged;return Yn.jsx(Of,{open:e,onClose:t,modal:!0,title:r?se._({id:"dzV+zO",message:"Modify Confirmation"}):se._({id:"tnRI9r",message:"Pool Creation Confirmation"}),children:Yn.jsxs(i,{sx:{flex:1,px:20,pb:20,display:"flex",flexDirection:"column",justifyContent:"space-between",width:x?void 0:420},children:[Yn.jsxs(i,{sx:{pt:40,px:8},children:[Yn.jsx(hL,{label:se._({id:"eE0JZ4",message:"Version"}),value:y}),Yn.jsx(hL,{label:se._({id:"7m5+6j",message:"Initial Tokens"}),value:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end"},children:[Yn.jsx(Df,{address:null===(s=n.baseToken)||void 0===s?void 0:s.address,chainId:g,marginRight:8,width:18,height:18}),n.baseAmount||"-"," ",null===(l=n.baseToken)||void 0===l?void 0:l.symbol]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",mt:4},children:[Yn.jsx(Df,{address:null===(d=n.quoteToken)||void 0===d?void 0:d.address,chainId:g,marginRight:8,width:18,height:18}),n.quoteAmount||"-"," ",null===(u=n.quoteToken)||void 0===u?void 0:u.symbol]})]})}),Yn.jsx(hL,{label:se._({id:"sjn3tj",message:"Slippage Coefficient"}),value:n.slippageCoefficient}),Yn.jsx(hL,{label:v,value:n.baseToken&&n.quoteToken?`1 ${n.baseToken.symbol} = ${EO({midPrice:b,quoteToken:n.quoteToken,selectedVersion:n.selectedVersion,initPrice:n.initPrice})} ${n.quoteToken.symbol}`:""}),C&&Yn.jsx(hL,{label:se._({id:"6lss/t",message:"Pricing Model"}),value:n.selectedSubPeggedVersion?null===(p=j[n.selectedSubPeggedVersion])||void 0===p?void 0:p.title:"-"}),Yn.jsx(hL,{label:se._({id:"Y7rVy0",message:"Fee Rate"}),value:`${n.feeRate}%`}),C&&Yn.jsx(hL,{label:se._({id:"eK0eiF",message:"Initial asset ratio"}),value:Yn.jsxs(Yn.Fragment,{children:[n.peggedBaseTokenRatio,"% ",null===(h=n.baseToken)||void 0===h?void 0:h.symbol," : ",n.peggedQuoteTokenRatio,"% ",null===(m=n.quoteToken)||void 0===m?void 0:m.symbol]})})]}),Yn.jsx(c,{fullWidth:!0,isLoading:a,sx:{mt:30},onClick:o,children:r?se._({id:"7VpPHA",message:"Confirm"}):se._({id:"hYgDIe",message:"Create"})})]})})}!function(e){e[e.SetCurrentStep=1]="SetCurrentStep",e[e.SelectNewVersion=2]="SelectNewVersion",e[e.SelectNewSubPeggedVersion=3]="SelectNewSubPeggedVersion",e[e.UpdateBaseToken=4]="UpdateBaseToken",e[e.UpdateQuoteToken=5]="UpdateQuoteToken",e[e.SwitchTokens=6]="SwitchTokens",e[e.UpdateBaseAmount=7]="UpdateBaseAmount",e[e.UpdateQuoteAmount=8]="UpdateQuoteAmount",e[e.UpdateIsFixedRatio=9]="UpdateIsFixedRatio",e[e.UpdateFixedRatioPrice=10]="UpdateFixedRatioPrice",e[e.InitFixedRatioPrice=11]="InitFixedRatioPrice",e[e.ToggleLeftToken=12]="ToggleLeftToken",e[e.UpdateSlippageCoefficient=13]="UpdateSlippageCoefficient",e[e.UpdateIsSlippageCoefficientCustomized=14]="UpdateIsSlippageCoefficientCustomized",e[e.UpdateFeeRate=15]="UpdateFeeRate",e[e.UpdateIsFeeRateCustomized=16]="UpdateIsFeeRateCustomized",e[e.InitEditParameters=17]="InitEditParameters",e[e.UpdatePeggedBaseTokenRatio=18]="UpdatePeggedBaseTokenRatio",e[e.UpdatePeggedQuoteTokenRatio=19]="UpdatePeggedQuoteTokenRatio"}(lL||(lL={}));const gL=({selectedVersion:e,selectedSubPeggedVersion:t,baseToken:n,quoteToken:i,baseAmount:o,quoteAmount:r,feeRate:a,initPrice:s,slippageCoefficient:l})=>{const{chainId:d,account:c}=dg(),{deadLine:u}=Jn(),p=we[d];return{getCreateParams:()=>Vn(void 0,void 0,void 0,(function*(){if(!c||!n||!i)return null;let h="";const m=Number(n.decimals),g=Number(i.decimals),f=new Pe(a),x=e===mO.marketMakerPool,y=e===mO.standard,v=e===mO.pegged,b=e===mO.pegged&&t===hO.GSP,j={decimals:m,address:n.address},C={decimals:g,address:i.address},w=zt(o,m).toString(),k=zt(r||"0",g).toString(),T=x?f.times(100).toNumber():f.times(80).toNumber();let I=x&&y?new Pe(r).div(o).dp(g,Pe.ROUND_DOWN).toString():new Pe(s).toString();if(y){const e=18-n.decimals+i.decimals;e<String(CO).split(".")[1].length&&(I=new Pe(1).div(10**e).toString())}const S=Number(l||(v?"0.1":"1")),E=Math.ceil(Date.now()/1e3)+(null!=u?u:3600);let A;const O=[d,j,C,w,k,T,I,S,E];try{e===mO.standard||e===mO.singleToken?A=yield ye.encode.createDVMPoolABI(...O):x?A=yield ye.encode.createDPPPoolABI(...O):v?A=yield ye.encode.createDSPPoolABI(...O):b&&(A=yield ye.encode.createGSPPoolABI(d,c,j,C,w,k,T,I,S,E))}catch(e){throw console.error("2.0 CreatePool createPrams error",O,e),h=`2.0 CreatePool createPrams error; ERROR: ${e}`,new Error(h)}if(!A||!A.data)throw h="invalid data",new Error(h);try{const e=p.address.toLowerCase();return o&&n.address.toLowerCase()===e?A.value=AI(o):r&&i.address.toLowerCase()===e?A.value=AI(r):A.value=0,A}catch(e){throw console.error("2.0 sendTransaction error",e),h=`2.0 sendTransaction error; ERROR: ${e}`,new Error(h)}}))}},fL=({chainId:t,baseToken:n,quoteToken:o})=>{const r=a();return OO({chainId:t,baseToken:n,quoteToken:o})?Yn.jsx(i,{sx:{mb:12,py:8,px:12,borderRadius:8,backgroundColor:T(r.palette.error.main,.1),color:r.palette.error.main,textAlign:"center",typography:"h6",fontWeight:500},children:Yn.jsx(e,{id:"peTryP",message:"{0}-{1} is not supported. Please select another pair.",values:{0:null==n?void 0:n.symbol,1:null==o?void 0:o.symbol}})}):null};function xL({state:t,dispatch:n,openConfirm:i,isPeggedVersion:o,isStandardVersion:r,isSingleTokenVersion:a,fiatPriceLoading:s}){var l,d;const{currentStep:u,selectedVersion:p,baseToken:h,quoteToken:m,baseAmount:g,quoteAmount:f,initPrice:x,slippageCoefficient:y,feeRate:v}=t,b=new Pe(g||0),j=new Pe(f||0),C=lf(h,{amount:g}),w=lf(m,{amount:f}),k={variant:c.Variant.contained},T=OO({chainId:null!==(d=null===(l=t.baseToken)||void 0===l?void 0:l.chainId)&&void 0!==d?d:1,baseToken:h,quoteToken:m}),I=se._({id:"hXzOVo",message:"Next"}),S=Yn.jsx(c,{fullWidth:!0,disabled:!0,...k,children:I}),E=Yn.jsx(c,{variant:c.Variant.contained,fullWidth:!0,onClick:i,children:Yn.jsx(e,{id:"hYgDIe",message:"Create"})});if(0===u)return Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:1})},children:I});const A=!h||b.isNaN()||b.lte(0),O=!m||j.isNaN()||j.lte(0);if(1===u){if(T)return S;if(o){if(!h||!m)return S}else{if(A)return S;if(C.needShowTokenStatusButton||C.insufficientBalance)return Yn.jsx(SI,{status:C,buttonProps:k});if(!a){if(O)return S;if(w.needShowTokenStatusButton||w.insufficientBalance)return Yn.jsx(SI,{status:w,buttonProps:k})}if(!r){if(!m)return S;const e=new Pe(x),t=Math.min(m.decimals,16);if(!x||e.isNaN()||e.lt(`1e-${t}`)||e.gt(wO))return S;const n=new Pe(y);if(!y||n.isNaN()||n.lt(0)||n.gt(p===mO.pegged?IO:kO))return S}if(s)return S;if(OO({chainId:h.chainId,baseToken:h,quoteToken:m}))return S}return Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:2})},children:I})}const L=new Pe(v),R=!v||L.isNaN()||L.lt(vO)||L.gt(bO);return 2===u?o?Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:3})},children:I}):R?S:E:3===u?R?S:Yn.jsx(c,{fullWidth:!0,...k,onClick:()=>{n({type:lL.SetCurrentStep,payload:4})},children:I}):4===u?A||O?S:C.needShowTokenStatusButton||C.insufficientBalance?Yn.jsx(SI,{status:C,buttonProps:k}):w.needShowTokenStatusButton||w.insufficientBalance?Yn.jsx(SI,{status:w,buttonProps:k}):E:null}function yL({state:t,dispatch:n,isPeggedVersion:o,isStandardVersion:r,isSingleTokenVersion:s,fiatPriceLoading:l}){const{currentStep:d}=t,u=a(),{isMobile:p}=Tg(),h=Fg(),{onlyChainId:m,chainId:g}=dg(),[f,x]=z(!1),{getCreateParams:y}=gL(t),v=it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){const e=yield y();if(!e)return;(yield h.execute(se._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Pg.TX,desc:"Create pool"},e),{early:!0,metadata:{[t.selectedVersion===mO.marketMakerPool?Sg.createDPPPool:t.selectedVersion===mO.pegged?t.selectedSubPeggedVersion===hO.DSP?Sg.createDSPPool:Sg.createGSPPool:Sg.createDVMPool]:"1"}}))===Eg.Submitted&&setTimeout((()=>{Gj.getState().push({type:Zj.Pool,params:{tab:qS.myCreated}})}),100)}))});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:u.palette.background.paperContrast,px:20,py:20},p?{}:{position:"static",backgroundColor:"transparent",py:0}),children:[1==d&&Yn.jsx(fL,{chainId:g,baseToken:t.baseToken,quoteToken:t.quoteToken}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[0===d&&p&&Yn.jsx(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{Gj.getState().back()},children:Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),d>0&&Yn.jsx(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{n({type:lL.SetCurrentStep,payload:d-1})},children:Yn.jsx(e,{id:"iH8pgl",message:"Back"})}),Yn.jsx(cC,{chainId:m,variant:c.Variant.contained,fullWidth:!0,includeButton:!0,children:Yn.jsx(xL,{state:t,dispatch:n,openConfirm:()=>{x(!0)},isPeggedVersion:o,isStandardVersion:r,isSingleTokenVersion:s,fiatPriceLoading:l})})]})]}),Yn.jsx(mL,{on:f,onClose:()=>x(!1),state:t,isModify:!1,onConfirm:v.mutate,loading:v.isPending})]})}function vL({selected:e}){const t=a();return Yn.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{marginLeft:"auto",flexShrink:0},children:[Yn.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:e?t.palette.success.main:t.palette.text.secondary}),e&&Yn.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:t.palette.success.main,stroke:t.palette.success.main})]})}function bL({title:e,subTitle:t,description:n,selected:o,onClick:r,children:s,sx:l,titleSx:c}){const u=a();u.palette.mode;return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",p:20,backgroundColor:u.palette.background.tag,borderWidth:1,borderColor:o?u.palette.primary.main:"transparent",borderStyle:"solid",borderRadius:12,flexWrap:"wrap",justifyContent:"flex-start",textAlign:"left","&:hover":{borderColor:u.palette.primary.main}},l),component:d,onClick:r,children:[Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between",typography:"caption",pr:2,color:u.palette.text.primary},c),children:[e,t,Yn.jsx(vL,{selected:o})]}),Yn.jsx(i,{sx:{mt:8,typography:"body2",width:"100%",textAlign:"left",color:o?u.palette.text.primary:u.palette.text.secondary},children:n}),s]})}function jL({errorMsg:e,isCustomized:t,onClick:n,value:o,onChange:r}){const s=a(),l=$((()=>!(!o||"0"===o||Number(o))),[o]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{py:12,px:20,backgroundColor:s.palette.background.paper,borderColor:t&&e||l?s.palette.error.main:t?s.palette.primary.main:s.palette.border.main,borderWidth:1,borderStyle:"solid",borderRadius:12,display:"flex",alignItems:"center"},onClick:n,children:Yn.jsx(Db,{value:t?o:"",onChange:r,suffix:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:16},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,ml:8},children:"%"}),Yn.jsx(vL,{selected:t})]}),placeholder:se._({id:"8Tg/JR",message:"Custom"}),sx:{backgroundColor:"transparent","& input":{typography:"body1",height:36,lineHeight:"36px",p:s.spacing(0),color:s.palette.text.primary,"&::placeholder":{color:s.palette.text.disabled,fontWeight:600,typography:"body1",lineHeight:1,position:"relative"}}}})}),e&&Yn.jsx(i,{sx:{typography:"h6",color:"error.main",mt:6},children:e})]})}const CL=()=>[{title:"0.01%",description:se._({id:"yzjPpo",message:"Fees will be the same as in most other pools."}),value:"0.01"},{title:"0.3%",description:se._({id:"OJOe+K",message:"Set the fee to the same as most other pools"}),value:yO,tag:"99% Default"},{title:"1%",description:"Most suitable for swapping exotic assets.",value:"1"}];function wL(){const e=a();return $((()=>CL().map((t=>t.value===yO?Object.assign(Object.assign({},t),{tagBackgroundColor:T(e.palette.purple.main,.1),tagColor:e.palette.purple.main}):t))),[e.palette.purple.main])}const kL=e=>{if(!e)return"";const t=new Pe(e);return t.isNaN()||!t.lt(vO)&&!t.gt(bO)?"":se._({id:"vWT429",message:"The fee rate must be between 0% to 10%"})},TL=(e,t)=>{if(!e)return"";const n=new Pe(e);if(!n.isNaN()&&(n.lt(0)||n.gt(t===mO.pegged?IO:kO)))switch(t){case mO.standard:case mO.singleToken:case mO.marketMakerPool:return se._({id:"3U+Oti",message:"he slippage coefficient needs to be greater than or equal to 0, and less than or equal to 1."});case mO.pegged:return se._({id:"LDprZB",message:"The slippage coefficient needs to be greater than 0, and less than 0.1."})}return""};function IL({dispatch:t,feeRate:n,isFeeRateCustomized:o}){const r=a(),s=wL(),l=$((()=>kL(n)||""),[n]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:[s.map((e=>{const i=!o&&n===e.value;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{t({type:lL.UpdateIsFeeRateCustomized,payload:!1}),t({type:lL.UpdateFeeRate,payload:e.value})},selected:i,subTitle:e.tag?Yn.jsx(QO,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:r.palette.background.paper,borderColor:i?r.palette.primary.main:r.palette.border.main}},e.value)})),Yn.jsx(i,{sx:{mt:8},children:Yn.jsx(jL,{errorMsg:l,isCustomized:o,onClick:()=>{t({type:lL.UpdateFeeRate,payload:""}),t({type:lL.UpdateIsFeeRateCustomized,payload:!0})},value:n,onChange:e=>{t({type:lL.UpdateFeeRate,payload:e})}})})]}),Yn.jsx(i,{sx:{typography:"body2",mt:20,color:"text.secondary",px:20},children:Yn.jsx(e,{id:"0b0AkA",message:"* Please note that the Fee Rate cannot be modified after the pool is created"})})]})}function SL({on:t,onClose:n,onConfirm:i}){return Yn.jsx(FI,{open:t,onClose:n,onConfirm:i,title:se._({id:"t+LmjM",message:"Initial Price Alert"}),modal:!0,children:Yn.jsx(e,{id:"yXm1vH",message:"The initial price is different from the current market price, which may cause your pool to be arbitraged"})})}const EL=({title:e,children:t,sx:n})=>{const o=a();return Yn.jsxs(i,{sx:Object.assign({mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},n),children:[Yn.jsx(i,{sx:{typography:"body2",color:o.palette.text.primary,fontWeight:500,display:"flex",alignItems:"center"},children:e}),t]})};function AL({selectedVersion:t,isStandardVersion:n,isSingleTokenVersion:o,isFixedRatio:s,leftTokenAddress:c,baseToken:u,quoteToken:p,fixedRatioPrice:h,dispatch:m,priceInfo:g}){const x=a(),[y,v]=z(!1),{versionMap:b}=gO(),{initPriceLabel:C,initPriceTips:w,initPriceTipsLink:k}=b[t],S=c===(null==u?void 0:u.address),E=S?null==u?void 0:u.symbol:null==p?void 0:p.symbol,A=S?null==p?void 0:p.symbol:null==u?void 0:u.symbol,{currentPrice:O,isErrorPrice:L,isNullPrice:R,fiatPriceLoading:P}=g,_=S?null==p?void 0:p.decimals:null==u?void 0:u.decimals,M=$((()=>{if(!p)return"";const e=function(e,t,n){if(!t)return"";const i=new Pe(t),o=Math.min(n,16),r=Number(`1e-${o}`);if(e!==mO.standard&&!i.isNaN()&&(i.lt(r)||i.gt(wO))){const t=r.toFixed(o);switch(e){case mO.pegged:case mO.singleToken:return se._({id:"P4iKEj",message:"The initial price needs to be greater than {min} and less than 100,000,000",values:{min:t}});case mO.marketMakerPool:return se._({id:"kdzjmC",message:"The mid price needs to be greater than {min} and less than 100,000,000",values:{min:t}})}}return""}(t,h,p.decimals);return e||""}),[h,p,t]),B=$((()=>!(!h||"0"===h||Number(h))),[h]);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(EL,{title:Yn.jsxs(Yn.Fragment,{children:[C,w&&Yn.jsx(f,{title:Yn.jsxs(Yn.Fragment,{children:[w,k?Yn.jsxs(Yn.Fragment,{children:["\n",Yn.jsxs(i,{component:"a",href:k,target:"_blank",rel:"noopener noreferrer",sx:{color:"primary.main",textDecoration:"underline"},onClick:e=>{e.stopPropagation()},children:[Yn.jsx(e,{id:"NgeSlx",message:"Learn More"}),">"]})]}):""]}),ml:4,sx:{width:14,height:14,alignItems:"center"}})]}),sx:{mt:20},children:Yn.jsxs(i,{sx:{pt:n?11:19,px:19,pb:11,borderWidth:1,borderStyle:"solid",borderColor:M||B?"error.main":x.palette.background.cardInput,borderRadius:8,backgroundColor:x.palette.background.cardInput,display:"flex",flexDirection:"column",alignItems:"stretch",gap:20},children:[n?null:Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{typography:"body2",color:x.palette.text.primary,display:"flex",alignItems:"center"},children:[Yn.jsxs(i,{sx:{fontWeight:600,color:x.palette.text.disabled,flexShrink:0},children:["1 ",null!=E?E:"-"," ="]}),Yn.jsx(Db,{value:h,onChange:e=>{m({type:lL.UpdateFixedRatioPrice,payload:e})},readOnly:s,sx:{backgroundColor:"background.cardInput",pl:0,pr:0,mt:0,flex:"1 1 auto","& input":{textAlign:"right",typography:"h5",height:25,py:0,px:8,color:x.palette.text.primary,"&::placeholder":{color:x.palette.text.disabled}}}}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:x.palette.text.disabled,flexShrink:0},children:null!=A?A:"-"}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},component:d,onClick:()=>{m({type:lL.ToggleLeftToken})},children:Yn.jsx(r,{weak:!0,component:li.Switch,sx:{marginLeft:8,p:x.spacing(2),color:x.palette.text.primary,backgroundColor:T(x.palette.primary.main,.1),borderRadius:"50%"}})})]}),M&&Yn.jsx(i,{sx:{typography:"h6",color:"error.main",mt:-14},children:M})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:n?"flex-start":"flex-end",typography:"h6",color:x.palette.text.primary,fontWeight:500},children:["=",Yn.jsx(e,{id:"pdZiL7",message:"Current Market Price:"})," ",P?Yn.jsx(j,{sx:{borderRadius:4},width:50,height:17}):R?Yn.jsx(l,{title:Yn.jsx(e,{id:"mObS+5",message:"Failed to get price of the token"}),children:Yn.jsx(i,{component:li.Warn,sx:{width:14,height:14,color:x.palette.error.main,typography:"h6"}})}):Am({input:O,decimals:_})," ",A,L||o?null:Yn.jsx(I,{checked:s,onChange:e=>{if(e.target.checked){if(m({type:lL.UpdateIsFixedRatio,payload:!0}),!_)throw new Error("currentTokenDecimals is undefined");O&&!O.isNaN()&&m({type:lL.UpdateFixedRatioPrice,payload:O.dp(_,Pe.ROUND_DOWN).toString()})}else v(!0)},sx:{ml:8}})]})]})}),Yn.jsx(SL,{on:y,onClose:()=>v(!1),onConfirm:()=>{m({type:lL.UpdateIsFixedRatio,payload:!1})}})]})}function OL({selectedVersion:e,selectedSubPeggedVersion:t,baseToken:n,quoteToken:o,initPrice:r,dispatch:s}){var l;const d=a(),{versionMap:c,subPeggedVersionList:u}=gO(),{initPriceLabel:p}=c[e];return n&&o?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{mt:8,display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",color:d.palette.text.secondary,fontWeight:500},children:p}),Yn.jsxs(i,{sx:{typography:"h5",color:d.palette.text.primary,fontWeight:600},children:["1 ",null==n?void 0:n.symbol,"=",null!==(l=EO({midPrice:void 0,quoteToken:o,selectedVersion:e,initPrice:r}))&&void 0!==l?l:"-"," ",o.symbol]})]}),Yn.jsx(i,{sx:{mt:20,display:"flex",flexDirection:"column",gap:12,px:20},children:u.map((e=>{const n=t===e.version;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{s({type:lL.SelectNewSubPeggedVersion,payload:e.version})},selected:n,subTitle:void 0,sx:{backgroundColor:d.palette.background.paper,borderColor:n?d.palette.primary.main:d.palette.border.main},titleSx:{typography:"body1",fontWeight:600}},e.version)}))})]}):null}function LL({title:e,value:t,onChange:n}){const o=a();return Yn.jsxs(i,{sx:{flexGrow:1,flexShrink:1,flexBasis:"50%",display:"flex",alignItems:"center",px:15,py:7,borderWidth:1,borderStyle:"solid",borderColor:o.palette.border.main,borderRadius:8,backgroundColor:o.palette.background.cardInput},children:[Yn.jsx(i,{sx:{color:o.palette.text.primary,typography:"body1",fontWeight:500,flexShrink:0},children:e}),Yn.jsx(Db,{value:t,onChange:n,suffix:"%",placeholder:"0",sx:{backgroundColor:"background.cardInput",mt:0,display:"flex",alignItems:"center",width:"100%",typography:"h5",lineHeight:"32px",color:o.palette.text.disabled,"& input":{textAlign:"right",py:0,px:8,color:o.palette.text.primary,"&::placeholder":{opacity:1,color:o.palette.text.disabled,fontWeight:600,typography:"h5",lineHeight:1,position:"relative"}}}})]})}const RL=({baseToken:t,quoteToken:n,initPrice:o,peggedBaseTokenRatio:r,peggedQuoteTokenRatio:s,baseAmount:l,quoteAmount:d,dispatch:u})=>{var p,h;const m=a(),[g,f]=$((()=>{const{base:e,quote:t}=AO({initPrice:o});return[e?e.multipliedBy(100).toString():null,t?t.multipliedBy(100).toString():null]}),[o]),x=""===r&&""===s,[y,v]=$((()=>{var e,i;const r=null!==(e=null==t?void 0:t.decimals)&&void 0!==e?e:0,a=null!==(i=null==n?void 0:n.decimals)&&void 0!==i?i:0,s=new Pe(l).dp(r,Pe.ROUND_DOWN).multipliedBy(`1e${r}`),c=new Pe(d).dp(a,Pe.ROUND_DOWN).multipliedBy(`1e${a}`),u=new Pe(o).multipliedBy(`1e${18-r+a}`).dp(0,Pe.ROUND_DOWN),p=c.lt(s.multipliedBy(u).div(1e18))?c.multipliedBy(1e18).div(u):s,h=new Pe(1001);if(h.gt(p))return[new Pe(1),"100%"];const m=h.dividedBy(p);return[m,Vm({input:m})]}),[l,null==t?void 0:t.decimals,o,d,null==n?void 0:n.decimals]),b=$((()=>!!y.lte("0.0000000001")||null!=g&&r===g&&null!=f&&s===f),[y,r,s,g,f]),j=`${null==t?void 0:t.symbol}:${null==n?void 0:n.symbol}=${g}%:${f}%`;return Yn.jsxs(EL,{title:Yn.jsx(e,{id:"OuSseo",message:"Ratio Settings"}),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(LL,{title:null!==(p=null==t?void 0:t.symbol)&&void 0!==p?p:"",value:r,onChange:e=>{u({type:lL.UpdatePeggedBaseTokenRatio,payload:e})}}),Yn.jsx(i,{sx:{color:m.palette.text.primary,typography:"body2",fontWeight:500,width:14,flexShrink:0,flexGrow:0,textAlign:"center"},children:":"}),Yn.jsx(LL,{title:null!==(h=null==n?void 0:n.symbol)&&void 0!==h?h:"",value:s,onChange:e=>{u({type:lL.UpdatePeggedQuoteTokenRatio,payload:e})}})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:20,px:19,pt:19,pb:11,borderRadius:16,borderWidth:1,borderColor:b||x?m.palette.border.main:"transparent",borderStyle:"solid",backgroundColor:b||x?m.palette.background.paper:T(m.palette.warning.main,.1)},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[x?null:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,color:b?m.palette.text.primary:m.palette.warning.main,typography:"body1",fontWeight:600},children:[b?null:Yn.jsx(li.Warn,{}),Yn.jsx(e,{id:"x3muNy",message:"Liquidity Burn Ratio"}),": ",v]}),Yn.jsx(i,{sx:{color:m.palette.text.secondary,typography:"h6",textAlign:"center","&>strong":{color:b?m.palette.text.primary:m.palette.warning.main}},children:x?Yn.jsx(e,{id:"pQJBKk",message:"The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{recommendRatioText:j}}):Yn.jsx(e,{id:"ZlQ83E",message:"<0>{lostRatio}</0> of the initial liquidity you provide will be burned. <1/>The closer the provided asset ratio is to the recommended ratio ({recommendRatioText}), the smaller the portion burned.",values:{lostRatio:v,recommendRatioText:j},components:{0:Yn.jsx("strong",{}),1:Yn.jsx("br",{})}})})]}),x||!b?Yn.jsx(c,{variant:c.Variant.outlined,fullWidth:!0,size:c.Size.small,onClick:()=>{u({type:lL.UpdatePeggedBaseTokenRatio,payload:null!=g?g:""})},sx:{border:`solid 1px ${m.palette.text.primary}`,color:m.palette.text.primary,"&:hover":{background:T(m.palette.text.primary,.1)}},children:Yn.jsx(e,{id:"NjdGps",message:"Use the recommended ratio"})}):null]})]})};function PL({open:e,onClose:t,afterClose:n,title:o,titleCenter:r,rightSlot:s,canBack:l=!0,children:d,width:c=420,height:u,testId:p}){const h=a(),{isMobile:m}=Tg();return Yn.jsx(V,{open:e,onClose:t,container:m?document.querySelector(`.${ib}`):void 0,disableEnforceFocus:!0,children:Yn.jsxs(i,{sx:Object.assign({backgroundColor:"background.paper",display:"flex",height:u,flexDirection:"column",justifyContent:"center",alignItems:"center",outline:0,overflow:"hidden","& > div":{width:"100%"}},m?{width:"100%",borderRadius:h.spacing(16,16,0,0)}:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:c,maxWidth:"95%",minHeight:200,maxHeight:"80%",borderRadius:16}),"data-testid":p,children:[o?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:r?"center":"space-between",p:20,width:"100%",boxSizing:"border-box"},children:[Yn.jsx(i,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:o}),s,!s&&l&&Yn.jsx(i,{component:li.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{t&&t(),null==n||n()}})]}):"",d]})})}var _L;function ML(){return ML=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},ML.apply(null,arguments)}const BL=e=>W.createElement("svg",ML({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),_L||(_L=W.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},W.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function DL({dispatch:t,slippageCoefficient:n,selectedVersion:o,isCustomized:r,isStandardVersion:s}){const l=a(),[u,p]=z(!1),[h,m]=z(n),g=function({selectedVersion:e}){const t=a();return $((()=>{const n=t.palette.background.paperDarkContrast,i=t.palette.text.disabled,o=t.palette.purple.main,r=T(o,.1);return e===mO.pegged?[{tag:"",description:se._({id:"PPqGw9",message:"Applicable to pegged assets with a fixed price and no fluctuation"}),value:"0",title:"K=0",tagBackgroundColor:"transparent",tagColor:"transparent"},{tag:se._({id:"nTWWCZ",message:"Low"}),description:se._({id:"L4nQwl",message:"Suitable for stablecoins with price fluctuations within 0.5%"}),value:"0.0001",title:"K=0.0001",tagBackgroundColor:r,tagColor:o},{tag:se._({id:"agPptk",message:"Medium"}),description:se._({id:"FrP5tr",message:"Suitable for stablecoins with price fluctuations within 2%"}),value:"0.0005",title:"K=0.0005",tagBackgroundColor:n,tagColor:i},{tag:se._({id:"yx/fMc",message:"High"}),description:se._({id:"bC0iyq",message:"Suitable for stablecoins with price fluctuations within 10%"}),value:"0.002",title:"K=0.002",tagBackgroundColor:n,tagColor:i}]:[{tag:se._({id:"agPptk",message:"Medium"}),description:se._({id:"VXTSOE",message:"Suitable for most situations."}),value:"0.5",title:"K=0.5",tagBackgroundColor:n,tagColor:i},{tag:se._({id:"nTWWCZ",message:"Low"}),description:se._({id:"DPi/hO",message:"Results in a relatively fixed price."}),value:"0.01",title:"K=0.01",tagBackgroundColor:n,tagColor:i},{tag:se._({id:"yx/fMc",message:"High"}),description:se._({id:"fKYdE9",message:"Results in a more volatile price."}),value:"1",title:"K=1",tagBackgroundColor:r,tagColor:o}]}),[e,t.palette])}({selectedVersion:o}),[x,y]=z(n);x!==n&&(y(n),m(n));const v=$((()=>{const e=TL(h,o);return null!=e?e:""}),[o,h]),b=$((()=>!(!h||"0"===h||Number(h))),[h]),j=Boolean(v)||b||r&&!h;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(EL,{title:Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(e,{id:"sjn3tj",message:"Slippage Coefficient"}),Yn.jsx(f,{title:se._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:4,sx:{width:14,height:14}})]}),sx:{mt:20},children:Yn.jsxs(i,{component:d,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:8,color:l.palette.text.primary,borderRadius:8,backgroundColor:l.palette.background.cardInput,"&:hover":{backgroundColor:l.palette.hover.default},"&[disabled]>svg":{color:l.palette.text.disabled}},disabled:s,onClick:s?void 0:()=>{p(!0)},children:[Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px"},children:n}),Yn.jsx(i,{component:BL,sx:{flexShrink:0,width:18,height:18}})]})}),Yn.jsx(PL,{open:u,onClose:()=>p(!1),title:Yn.jsxs(i,{children:[Yn.jsx(e,{id:"sjn3tj",message:"Slippage Coefficient"}),Yn.jsx(f,{title:se._({id:"+/wf6Z",message:"The smaller the slippage coefficient, the lower the slippage for traders, and the deeper the market depth."}),ml:8})]}),children:Yn.jsxs(i,{sx:{flex:1,overflowY:"auto"},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,p:l.spacing(8,28,28)},children:[g.map((e=>{const n=!r&&h===e.value;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{t({type:lL.UpdateIsSlippageCoefficientCustomized,payload:!1}),m(e.value)},selected:n,subTitle:e.tag?Yn.jsx(QO,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:l.palette.background.paper,borderColor:n?l.palette.primary.main:l.palette.border.main},titleSx:{typography:"body1"}},e.value)})),Yn.jsx(i,{sx:{mt:8},children:Yn.jsx(jL,{errorMsg:v,isCustomized:r,onClick:()=>{r||m(""),t({type:lL.UpdateIsSlippageCoefficientCustomized,payload:!0})},value:h,onChange:e=>{m(e)}})})]}),Yn.jsx(i,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:Yn.jsx(c,{fullWidth:!0,disabled:j,onClick:()=>{t({type:lL.UpdateSlippageCoefficient,payload:h}),p(!1)},children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function NL({token:t,oppositeTokenAddress:n,dispatch:o,tokenSelectOnChange:r}){var s;const l=a(),{chainId:c,account:u}=dg(),[p,h]=H.useState(!1),m=et(Object.assign({},ip.getFetchTokenQuery(c,null==t?void 0:t.address,u)));return t?Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:{display:"flex",alignItems:"center",px:20,py:8,borderRadius:8,backgroundColor:l.palette.background.cardInput,"&:hover":{backgroundColor:l.palette.hover.default}},onClick:()=>{h(!0)},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:t.address,marginRight:0,width:24,height:24,chainId:t.chainId||c,noShowChain:!0,sx:{flexShrink:0}}),Yn.jsx(i,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600,lineHeight:"32px",flexShrink:0},children:t.symbol}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",fontWeight:500,color:l.palette.text.secondary,wordBreak:"break-all"},children:["(",Yn.jsx(e,{id:"fsBGk0",message:"Balance"}),": ",!t.address||m.isLoading?Yn.jsx(L,{}):Am({input:null===(s=m.data)||void 0===s?void 0:s.balance,decimals:t.decimals}),")"]})]}),Yn.jsx(i,{component:BL,sx:{flexShrink:0,ml:"auto",width:18,height:18,color:l.palette.text.secondary}})]}),Yn.jsx(Xb,{value:t,open:p,chainId:c,occupiedAddrs:[n],occupiedChainId:t.chainId,onClose:()=>{h(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return o({type:lL.SwitchTokens}),void h(!1);r(e),h(!1)}},modal:!0})]}):null}const FL=({baseToken:t,quoteToken:n,dispatch:i})=>{var o,r;return Yn.jsxs(EL,{title:Yn.jsx(e,{id:"dmiCGN",message:"Select Token Pair"}),children:[Yn.jsx(NL,{token:t,oppositeTokenAddress:null!==(o=null==n?void 0:n.address)&&void 0!==o?o:"",dispatch:i,tokenSelectOnChange:e=>{i({type:lL.UpdateBaseToken,payload:e})}}),Yn.jsx(NL,{token:n,oppositeTokenAddress:null!==(r=null==t?void 0:t.address)&&void 0!==r?r:"",dispatch:i,tokenSelectOnChange:e=>{i({type:lL.UpdateQuoteToken,payload:e})}})]})};function UL({selectedVersion:e,dispatch:t}){const n=a(),{isMobile:o}=Tg(),{versionList:r}=gO(),s="light"===n.palette.mode;return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:12,px:20},children:r.map((n=>{const r=e===n.version;return Yn.jsx(bL,{title:n.title,description:n.description,onClick:()=>{t({type:lL.SelectNewVersion,payload:n.version})},selected:r,children:o&&r&&Yn.jsx(i,{component:s?n.exampleImgUrl:n.exampleDarkImgUrl,sx:{mt:28,width:"100%",height:88.1}})},n.version)}))})}function qL(){const t=a(),{defaultBaseToken:n,defaultQuoteToken:o}=rL(),{chainId:r}=dg(),[s,l]=H.useReducer(uL,{currentStep:0,selectedVersion:mO.standard,baseToken:n,quoteToken:o,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:CO,fixedRatioPrice:jO,leftTokenAddress:null==n?void 0:n.address,feeRate:yO,isFeeRateCustomized:!1,slippageCoefficient:kO,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});!n||s.baseToken&&s.baseToken.chainId===r||l({type:lL.UpdateBaseToken,payload:n}),!o||s.quoteToken&&s.quoteToken.chainId===r||l({type:lL.UpdateQuoteToken,payload:o});const{isMobile:d}=Tg(),{versionMap:c}=gO(),u=c[s.selectedVersion],p=s.selectedVersion===mO.singleToken,h=s.selectedVersion===mO.standard,m=s.selectedVersion===mO.pegged,g=p?s.quoteToken:s.baseToken,f=p?s.baseToken:s.quoteToken,x=pL({isSingleTokenVersion:p,leftTokenAddress:s.leftTokenAddress,baseToken:s.baseToken,quoteToken:s.quoteToken,dispatch:l}),y=new Pe(s.peggedBaseTokenRatio).div(100).dp(SO,Pe.ROUND_DOWN),v=new Pe(s.peggedQuoteTokenRatio).div(100).dp(SO,Pe.ROUND_DOWN),b=m&&y.lte(0),j=m&&v.lte(0),C=Yn.jsxs(i,{sx:{px:20},children:[Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:p?s.quoteAmount:s.baseAmount,onInputChange:p?void 0:e=>{l({type:p?lL.UpdateQuoteAmount:lL.UpdateBaseAmount,payload:e})},readOnly:p||b,sx:{backgroundColor:"background.cardInput",padding:t.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:b?se._({id:"t3d3/V",message:"ratio is 0"}):void 0,token:g,occupiedAddrs:f?[f.address]:void 0,occupiedChainId:r,chainId:r,onTokenChange:m?void 0:(e,t)=>{l(t?{type:lL.SwitchTokens}:{type:p?lL.UpdateQuoteToken:lL.UpdateBaseToken,payload:e})}}),Yn.jsx(uj,{}),Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:p?s.baseAmount:s.quoteAmount,onInputChange:e=>{l({type:p?lL.UpdateBaseAmount:lL.UpdateQuoteAmount,payload:e})},readOnly:h&&s.isFixedRatio&&!!s.fixedRatioPrice||j,sx:{backgroundColor:"background.cardInput",padding:t.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},inputReadonlyTooltip:j?se._({id:"t3d3/V",message:"ratio is 0"}):se._({id:"5QDjef",message:"The token amount is calculated by initial price."}),token:f,occupiedAddrs:g?[g.address]:void 0,occupiedChainId:r,chainId:r,onTokenChange:(e,t)=>{l(t?{type:lL.SwitchTokens}:{type:p?lL.UpdateBaseToken:lL.UpdateQuoteToken,payload:e})}})]});return Yn.jsx(zj,{children:Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"flex-start",height:"100%"},d?{}:{height:"auto",overflowX:"auto"}),children:[d?null:Yn.jsxs(i,{sx:{mr:12,flexGrow:1,display:"block",overflow:"hidden"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:20},children:[Yn.jsx(XS,{}),Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:Yn.jsx(e,{id:"pHQq+U",message:"Pool Setup"})}),Yn.jsx(cT,{poolType:"PMM"})]}),Yn.jsx(tL,{titleKey:se._({id:"hdIg7i",message:"Select Pool Version"}),index:1,status:0===s.currentStep?"running":"completed"}),Yn.jsx(iL,{versionItem:u,status:0===s.currentStep?"running":"completed"},u.version),Yn.jsx(tL,{titleKey:se._({id:"lsg9Mi",message:"Parameter Settings"}),index:2,status:0===s.currentStep?"waiting":1===s.currentStep?"running":"completed"}),m?Yn.jsx(RO,{status:0===s.currentStep?"waiting":1===s.currentStep?"running":"completed",baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,midPrice:void 0}):Yn.jsx(JO,{status:0===s.currentStep?"waiting":1===s.currentStep?"running":"completed",baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),m&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"6lss/t",message:"Pricing Model"}),index:3,status:s.currentStep>2?"completed":2===s.currentStep?"running":"waiting"}),Yn.jsx(eL,{isWaiting:s.currentStep<2,selectedSubPeggedVersion:s.selectedSubPeggedVersion})]}),m?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"Y7rVy0",message:"Fee Rate"}),index:4,status:s.currentStep>3?"completed":3===s.currentStep?"running":"waiting"}),Yn.jsx(YO,{isWaiting:s.currentStep<3,feeRate:s.feeRate})]}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"Y7rVy0",message:"Fee Rate"}),index:3,status:2===s.currentStep?"running":"waiting"}),Yn.jsx(YO,{isWaiting:s.currentStep<2,feeRate:s.feeRate})]}),m&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(tL,{titleKey:se._({id:"3ggd2j",message:"Asset ratio within the pool"}),index:5,status:s.currentStep>4?"completed":4===s.currentStep?"running":"waiting"}),Yn.jsx(KO,{isWaiting:s.currentStep<4,baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount,peggedBaseTokenRatio:s.peggedBaseTokenRatio,peggedQuoteTokenRatio:s.peggedQuoteTokenRatio})]})]}),Yn.jsxs(i,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,borderRadius:0,backgroundColor:"background.paper",minHeight:"100%"},d?{}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto",height:"100%",position:"sticky",top:"0px",overflowY:"hidden"}),children:[Yn.jsx(nL,{currentStep:s.currentStep,isPeggedVersion:m}),0===s.currentStep&&Yn.jsx(UL,{selectedVersion:s.selectedVersion,dispatch:l}),1===s.currentStep&&Yn.jsxs(Yn.Fragment,{children:[m?Yn.jsx(Yn.Fragment,{children:Yn.jsx(FL,{baseToken:s.baseToken,quoteToken:s.quoteToken,dispatch:l})}):Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(GO,{baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),C]}),Yn.jsx(DL,{dispatch:l,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,isCustomized:s.isSlippageCoefficientCustomized,isStandardVersion:h}),Yn.jsx(AL,{selectedVersion:s.selectedVersion,isFixedRatio:s.isFixedRatio,leftTokenAddress:s.leftTokenAddress,baseToken:s.baseToken,quoteToken:s.quoteToken,fixedRatioPrice:s.fixedRatioPrice,dispatch:l,isStandardVersion:h,isSingleTokenVersion:p,priceInfo:x})]}),m&&2===s.currentStep&&Yn.jsx(OL,{selectedVersion:s.selectedVersion,selectedSubPeggedVersion:s.selectedSubPeggedVersion,baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,dispatch:l}),s.currentStep===(m?3:2)&&Yn.jsx(IL,{dispatch:l,feeRate:s.feeRate,isFeeRateCustomized:s.isFeeRateCustomized}),m&&4===s.currentStep&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(GO,{baseToken:s.baseToken,quoteToken:s.quoteToken,initPrice:s.initPrice,slippageCoefficient:s.slippageCoefficient,selectedVersion:s.selectedVersion,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),Yn.jsx(RL,{dispatch:l,baseToken:s.baseToken,quoteToken:s.quoteToken,peggedBaseTokenRatio:s.peggedBaseTokenRatio,peggedQuoteTokenRatio:s.peggedQuoteTokenRatio,initPrice:s.initPrice,baseAmount:s.baseAmount,quoteAmount:s.quoteAmount}),Yn.jsx(EL,{title:Yn.jsx(e,{id:"E4LM3N",message:"Add Initial Liquidity"}),sx:{mt:20},children:Yn.jsx(i,{sx:{mx:-20},children:C})})]}),Yn.jsx(i,{sx:Object.assign({pb:160},d?{}:{pb:28})}),Yn.jsx(yL,{state:s,dispatch:l,isPeggedVersion:m,isStandardVersion:h,isSingleTokenVersion:p,fiatPriceLoading:x.fiatPriceLoading})]})]})})}function VL({open:t,onClose:n,title:o,children:r,singleBtn:a,danger:s,singleBtnText:l,cancelText:d,confirmText:u,disabledConfirm:p,confirmLoading:h,isManualClose:m,onConfirm:g}){const f=PL;return Yn.jsx(f,{open:t,onClose:n,title:Yn.jsx(i,{sx:{textAlign:"center"},children:o}),canBack:!1,titleCenter:!0,children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",flex:1,width:"100%"},children:[Yn.jsx(i,{sx:{typography:"body2",color:o?"text.secondary":"text.primary",textAlign:"center",wordBreak:"break-all",mt:20,px:36},children:r}),a?Yn.jsx(i,{sx:{px:20},children:Yn.jsx(c,{fullWidth:!0,variant:c.Variant.outlined,danger:s,sx:{mt:32,mb:20},onClick:()=>{n()},children:l||Yn.jsx(e,{id:"DPfwMq",message:"Done"})})}):Yn.jsxs(i,{sx:{mt:24,mb:20,mx:20,display:"flex",alignItems:"center","& > button":{flex:1}},children:[Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{n()},children:d||Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),Yn.jsx(c,{sx:{ml:8},variant:c.Variant.outlined,danger:s,disabled:p,isLoading:h,onClick:()=>{g&&g(),m||n()},children:u||Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})]})]})})}function WL({sx:t,onClick:n}){const o=a();return Yn.jsxs(r,{onClick:()=>{n?n():Gj.getState().back()},sx:ne({display:"inline-flex",alignItems:"center",cursor:"pointer","& > svg":{mr:10}},t),children:[Yn.jsx(i,{sx:{color:o.palette.text.secondary,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderColor:o.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:"50%",backgroundColor:o.palette.background.paper,mr:6},children:Yn.jsx(li.ArrowBack,{})}),Yn.jsx(e,{id:"CKyk7Q",message:"Go back"})]})}function HL({open:t,onClose:n,alertContent:o,onConfirm:r}){const s=a(),[l,d]=H.useState(!1),u=se._({id:"LQU+Dm",message:"Risk Disclaimer"});return Yn.jsx(PL,{open:t,onClose:n,title:u,canBack:!1,titleCenter:!0,children:Yn.jsxs(i,{sx:{flex:1,display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{mb:20,mx:20,maxHeight:275,overflowY:"auto",borderWidth:1,borderRadius:10,borderStyle:"solid",borderColor:"border.main",p:s.spacing(20),typography:"body2",backgroundColor:s.palette.background.input,color:s.palette.text.primary,textAlign:"left"},children:o}),Yn.jsxs(i,{sx:{padding:20,pt:12,backgroundColor:s.palette.background.paperContrast},children:[Yn.jsxs(i,{component:"label",sx:{display:"flex",alignItems:"center",gap:8,typography:"body2",cursor:"pointer",color:"text.secondary",textAlign:"left","& a":{fontWeight:600,color:"primary.main","&:hover":{textDecoration:"underline"}}},children:[Yn.jsx(I,{sx:{top:-1},checked:l,onChange:e=>{const{checked:t}=e.target;d(t)}}),Yn.jsx(i,{children:Yn.jsx(e,{id:"dqWPbT",message:"I have read, understand, and agree to the <0>Terms of Service</0>.",components:{0:Yn.jsx("a",{href:"https://docs.dodoex.io/home/terms-of-service",target:"_blank",rel:"noopener noreferrer"})}})})]}),Yn.jsx(i,{sx:{mt:12,display:"flex",alignItems:"center"},children:Yn.jsx(c,{sx:{},disabled:!l,fullWidth:!0,onClick:()=>{d(!1),null==r||r()},children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})})]})]})})}function $L({id:e,chainId:t}){var n,i,o,r,a,s,l,d,c,u,p,h,m;const g=t?Wu[t]:"",f=gg().getQuery(ye.graphql.fetchPool,{id:e||"",where:{refreshNow:!1,chain:g},liquidityWhere:{chain:g,refreshNow:!1,filterState:{address:e}}}),x=et(Object.assign(Object.assign({},f),{enabled:!!e})),{pair:y,liquidity_list:v}=null!==(n=x.data)&&void 0!==n?n:{},b=null===(o=null===(i=null==v?void 0:v.lqList)||void 0===i?void 0:i[0])||void 0===o?void 0:o.pair;return Object.assign(Object.assign({},x),{poolDetail:y&&t?Object.assign(Object.assign({},y),{address:y.id,type:y.type,chainId:t,baseToken:Zm(y.baseToken,t),quoteToken:Zm(y.quoteToken,t),miningAddress:null!==(a=null===(r=null==b?void 0:b.miningAddress)||void 0===r?void 0:r[0])&&void 0!==a?a:"",apy:null==b?void 0:b.apy,baseApy:(null==b?void 0:b.apy)?Wm(new Pe(null!==(s=b.apy.transactionBaseApy)&&void 0!==s?s:0).plus(null!==(l=b.apy.miningBaseApy)&&void 0!==l?l:0)):void 0,quoteApy:Number(null===(d=null==b?void 0:b.apy)||void 0===d?void 0:d.transactionQuoteApy)||Number(null===(c=null==b?void 0:b.apy)||void 0===c?void 0:c.miningQuoteApy)?Wm(new Pe(null!==(p=null===(u=null==b?void 0:b.apy)||void 0===u?void 0:u.transactionQuoteApy)&&void 0!==p?p:0).plus(null!==(m=null===(h=null==b?void 0:b.apy)||void 0===h?void 0:h.miningQuoteApy)&&void 0!==m?m:0)):void 0,isCpPool:!1,cpAddress:void 0,cpLiquidator:void 0,cpCreator:void 0,cpCreatedAtTimestamp:void 0}):null})}function zL({disabled:t,chainId:n,baseStatus:i,quoteStatus:o,onClick:r}){const{account:a}=dg();return a?i.needShowTokenStatusButton||o.needShowTokenStatusButton?Yn.jsx(SI,{status:i.needShowTokenStatusButton?i:o,buttonProps:{variant:c.Variant.contained,fullWidth:!0}}):Yn.jsx(c,{variant:c.Variant.contained,fullWidth:!0,disabled:t,onClick:()=>r(),children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})}):Yn.jsx(cC,{chainId:n,variant:c.Variant.contained,fullWidth:!0,includeButton:!0})}function ZL({state:t,pool:n,loading:o}){var r,s;const{baseToken:l,quoteToken:d,baseAmount:u,quoteAmount:p,initPrice:h,slippageCoefficient:m,feeRate:g}=t,f=et($m.getPMMStateQuery(null==n?void 0:n.chainId,null==n?void 0:n.address,null==n?void 0:n.type,null===(r=null==n?void 0:n.baseToken)||void 0===r?void 0:r.decimals,null===(s=null==n?void 0:n.quoteToken)||void 0===s?void 0:s.decimals)),x=a(),{isMobile:y}=Tg(),{account:v}=dg(),b=Gj(),[j,C]=H.useState(!1),w=f.data&&u?new Pe(u).minus(f.data.baseReserve):void 0,k=f.data&&p?new Pe(p).minus(f.data.quoteReserve):void 0,T=null==w?void 0:w.lt(0),I=lf(l,{amount:w}),S=lf(d,{amount:k});let E=!n||o||!u||Number(u)<0||!p||Number(p)<0;if(!E&&d){const e=new Pe(h),t=Math.min(d.decimals,16);(!h||e.isNaN()||e.lt(`1e-${t}`)||e.gt(wO))&&(E=!0);const n=new Pe(m);(!m||n.isNaN()||n.lt(0)||n.gt(kO))&&(E=!0);const i=new Pe(g);(!g||i.isNaN()||i.lt(0)||i.gt(bO))&&(E=!0)}const{modifyDPPMutation:A}=ZI({pool:n||void 0});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign(Object.assign({position:"sticky",left:0,right:0,bottom:0,backgroundColor:x.palette.background.paperContrast,px:20,py:20},y?{}:{position:"static",backgroundColor:"transparent",py:0}),{display:"flex",alignItems:"center",gap:8}),children:[y&&!!v&&Yn.jsx(c,{variant:c.Variant.second,fullWidth:!0,onClick:()=>{b.back()},children:Yn.jsx(e,{id:"dEgA5A",message:"Cancel"})}),Yn.jsx(zL,{disabled:E,chainId:null==n?void 0:n.chainId,baseStatus:I,quoteStatus:S,onClick:()=>C(!0)})]}),Yn.jsx(mL,{on:j,onClose:()=>C(!1),state:t,isModify:!0,loading:A.isPending,onConfirm:()=>{var e,n;A.mutate({txTitle:se._({id:"KRnA5J",message:"Set pool parameters"}),baseAmount:null!==(e=null==w?void 0:w.toString())&&void 0!==e?e:"",quoteAmount:null!==(n=null==k?void 0:k.toString())&&void 0!==n?n:"",isRemove:T,feeRate:t.feeRate,initPrice:t.initPrice,slippageCoefficient:t.slippageCoefficient,submittedBack:()=>{C(!1),b.push({type:Zj.Pool,params:{tab:qS.myCreated}})}})}})]})}function GL({dispatch:t,feeRate:n,isCustomized:o}){const r=a(),[s,l]=H.useState(!1),[d,u]=H.useState(n),p=wL();!d&&n&&u(n);const h=kL(d),m=!(!d||"0"===d||Number(d)),g=Boolean(h)||m||o&&!d;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",mt:20,px:20},children:[Yn.jsxs(i,{sx:{fontWeight:500,display:"flex",alignItems:"center"},children:[Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"}),Yn.jsx(f,{title:se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8,size:16})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",ml:12},children:[n,"%",Yn.jsx(c,{variant:c.Variant.tag,sx:{ml:12,fontSize:12},onClick:()=>l(!0),children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})})]})]}),Yn.jsx(PL,{open:s,onClose:()=>l(!1),title:Yn.jsxs(i,{children:[Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"}),Yn.jsx(f,{title:se._({id:"2vjOqX",message:"Pools with lower transaction fees will attract more traders."}),ml:8})]}),children:Yn.jsxs(i,{sx:{flex:1,overflowY:"auto"},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,p:r.spacing(8,28,28)},children:[p.map((e=>{const n=!o&&d===e.value;return Yn.jsx(bL,{title:e.title,description:e.description,onClick:()=>{t({type:lL.UpdateIsFeeRateCustomized,payload:!1}),u(e.value)},selected:n,subTitle:e.tag?Yn.jsx(QO,{color:e.tagColor,backgroundColor:e.tagBackgroundColor,tagKey:e.tag}):void 0,sx:{backgroundColor:r.palette.background.paper,borderColor:n?r.palette.primary.main:r.palette.border.main}},e.value)})),Yn.jsx(i,{sx:{mt:8},children:Yn.jsx(jL,{errorMsg:h,isCustomized:o,onClick:()=>{o||u(""),t({type:lL.UpdateIsFeeRateCustomized,payload:!0})},value:d,onChange:e=>{u(e)}})})]}),Yn.jsx(i,{sx:{position:"sticky",bottom:0,px:20,py:16,backgroundColor:"background.paperContrast"},children:Yn.jsx(c,{fullWidth:!0,disabled:g,onClick:()=>{t({type:lL.UpdateFeeRate,payload:d}),l(!1)},children:Yn.jsx(e,{id:"7VpPHA",message:"Confirm"})})})]})})]})}function QL({titleKey:e}){const t=a();return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(i,{sx:{mt:28,mb:28,borderTopColor:"divider",borderTopStyle:"solid",borderTopWidth:1}}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",mb:20},children:Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:t.palette.text.primary},children:e})})]})}function YL({params:t}){var n,o,r,s;const l=a(),{isMobile:d}=Tg(),{chainId:c}=dg(),[u,p]=H.useState(!1),[h,m]=H.useReducer(uL,{currentStep:0,selectedVersion:mO.marketMakerPool,baseToken:null,quoteToken:null,baseAmount:"",quoteAmount:"",isFixedRatio:!0,initPrice:jO,fixedRatioPrice:jO,leftTokenAddress:void 0,feeRate:yO,isFeeRateCustomized:!1,slippageCoefficient:kO,isSlippageCoefficientCustomized:!1,peggedBaseTokenRatio:"",peggedQuoteTokenRatio:""});H.useEffect((()=>{p(!window.localStorage.getItem(hh.PoolEditPage))}),[]);const[g,f]=H.useState("inital"),x=$L({id:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),{poolDetail:y}=x,v=qn(x,["poolDetail"]);v.isPending||v.error||y||"inital"!==g||f("open"),!h.baseToken&&(null==y?void 0:y.baseToken)&&m({type:lL.InitEditParameters,payload:y});const b=et($m.getPMMStateQuery(null==y?void 0:y.chainId,null==y?void 0:y.address,null==y?void 0:y.type,null===(n=null==y?void 0:y.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==y?void 0:y.quoteToken)||void 0===o?void 0:o.decimals));if(!h.slippageCoefficient&&(null===(s=null===(r=b.data)||void 0===r?void 0:r.pmmParamsBG)||void 0===s?void 0:s.k)){const e=b.data.pmmParamsBG.k.toString(),t=!sL({selectedVersion:h.selectedVersion}).includes(e);m({type:lL.UpdateSlippageCoefficient,payload:e}),m({type:lL.UpdateIsSlippageCoefficientCustomized,payload:t})}!h.baseAmount&&b.data&&(m({type:lL.UpdateBaseAmount,payload:b.data.baseReserve.toString()}),m({type:lL.UpdateQuoteAmount,payload:b.data.quoteReserve.toString()})),!h.fixedRatioPrice&&b.data&&m({type:lL.UpdateFixedRatioPrice,payload:b.data.pmmParamsBG.i.toString()});const C=et($m.getLPFeeRateQuery(null==y?void 0:y.chainId,null==y?void 0:y.address,null==y?void 0:y.type));if(!h.feeRate&&C.data){const e=C.data.times(100).toString(),t=-1===CL().findIndex((t=>t.value===e));m({type:lL.UpdateFeeRate,payload:e}),m({type:lL.UpdateIsFeeRateCustomized,payload:t})}const w=h.selectedVersion===mO.singleToken,k=h.selectedVersion===mO.standard,T=pL({isSingleTokenVersion:w,leftTokenAddress:h.leftTokenAddress,baseToken:h.baseToken,quoteToken:h.quoteToken,dispatch:m}),{versionMap:I}=gO(),S=I[h.selectedVersion],E=!(null==y?void 0:y.baseToken),A=Yn.jsx(j,{variant:"rounded",width:210,height:60,sx:{padding:16,borderRadius:8}}),O=Yn.jsx(j,{variant:"rounded",height:167,sx:{mx:20,borderRadius:16}});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(zj,{children:Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"flex-start"},d?{height:"100%"}:{height:"auto"}),children:[d?null:Yn.jsxs(i,{sx:{mr:12,flexGrow:1,display:"block"},children:[Yn.jsx(WL,{}),Yn.jsx(i,{sx:{mt:28,typography:"h5",fontWeight:600,color:"text.primary"},children:Yn.jsx(e,{id:"pHQq+U",message:"Pool Setup"})}),Yn.jsx(QL,{titleKey:se._({id:"hdIg7i",message:"Select Pool Version"})}),Yn.jsx(iL,{versionItem:S,status:"completed"},S.version),Yn.jsx(QL,{titleKey:se._({id:"lsg9Mi",message:"Parameter Settings"})}),E?A:Yn.jsx(JO,{status:"running",baseToken:h.baseToken,quoteToken:h.quoteToken,initPrice:h.initPrice,slippageCoefficient:h.slippageCoefficient,selectedVersion:h.selectedVersion,baseAmount:h.baseAmount,quoteAmount:h.quoteAmount}),Yn.jsx(QL,{titleKey:se._({id:"Y7rVy0",message:"Fee Rate"})}),E?A:Yn.jsx(YO,{isWaiting:!1,feeRate:h.feeRate})]}),Yn.jsxs(i,{sx:Object.assign({flexGrow:1,flexShrink:0,flexBasis:375,backgroundColor:"background.paper"},d?{width:"100%",borderRadius:0,minHeight:"100%"}:{pb:20,borderRadius:16,flexGrow:0,minHeight:"auto"}),children:[Yn.jsx(i,{sx:Object.assign({top:0,py:20,px:20,backgroundColor:l.palette.background.paper,zIndex:1},d?{position:"sticky"}:{position:"static",borderTopLeftRadius:16,borderTopRightRadius:16}),children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:Yn.jsx(i,{sx:{typography:"h5",color:l.palette.text.primary,fontWeight:600},children:Yn.jsx(e,{id:"6XYkjc",message:"Edit Parameter Settings"})})})}),E?null:Yn.jsx(GO,{baseToken:h.baseToken,quoteToken:h.quoteToken,initPrice:h.initPrice,slippageCoefficient:h.slippageCoefficient,selectedVersion:h.selectedVersion,baseAmount:h.baseAmount,quoteAmount:h.quoteAmount}),E?O:Yn.jsxs(i,{sx:{px:20},children:[Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:h.baseAmount,onInputChange:e=>{m({type:lL.UpdateBaseAmount,payload:e})},readOnly:w,token:h.baseToken,occupiedAddrs:h.quoteToken?[h.quoteToken.address]:void 0,occupiedChainId:c,chainId:c}),Yn.jsx(pj,{}),Yn.jsx(hj,{canClickBalance:!0,showPercentage:!0,amt:h.quoteAmount,onInputChange:e=>{m({type:lL.UpdateQuoteAmount,payload:e})},token:h.quoteToken,occupiedAddrs:h.baseToken?[h.baseToken.address]:void 0,occupiedChainId:c,chainId:c})]}),E?null:Yn.jsxs(Yn.Fragment,{children:[h.selectedVersion!==mO.standard&&Yn.jsx(DL,{dispatch:m,slippageCoefficient:h.slippageCoefficient,selectedVersion:h.selectedVersion,isCustomized:h.isSlippageCoefficientCustomized,isStandardVersion:k}),Yn.jsx(AL,{selectedVersion:h.selectedVersion,isFixedRatio:h.isFixedRatio,leftTokenAddress:h.leftTokenAddress,baseToken:h.baseToken,quoteToken:h.quoteToken,fixedRatioPrice:h.fixedRatioPrice,dispatch:m,isStandardVersion:k,isSingleTokenVersion:w,priceInfo:T}),Yn.jsx(GL,{dispatch:m,feeRate:h.feeRate,isCustomized:h.isFeeRateCustomized})]}),Yn.jsx(i,{sx:{pb:160,[l.breakpoints.up("tablet")]:{pb:28}}}),Yn.jsx(ZL,{state:h,pool:y,loading:E})]})]})}),Yn.jsx(VL,{singleBtn:!0,open:"open"===g,onClose:()=>f("close"),onConfirm:()=>f("close"),title:se._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),Yn.jsx(HL,{open:u,onClose:()=>{p(!1)},onConfirm:()=>{window.localStorage.setItem(hh.PoolEditPage,"1"),p(!1)},alertContent:Yn.jsx(e,{id:"Y9QDtD",message:"You are making changes to the liquidity of a private pool. This is a highly discretionary operation that may cause substantial inflows/outflows of funds and changes in market prices. Please make sure you are fully aware of the implications of each parameter modification."})})]})}function KL(e){return null==e?0:new Pe(e).dp(4,Pe.ROUND_DOWN).toNumber()}function XL({unit:t,data:n,masterKey:o,sumKey:r}){const s=a(),l=H.useRef(null),[d,c]=H.useState(null),[u,p]=H.useState(0);H.useEffect((()=>{const e=()=>{l&&l.current&&p(l.current.offsetWidth)};return setTimeout(e,100),window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}}),[l]);const h="light"===s.palette.mode?T(s.palette.success.main,.6):s.palette.primary.main,m="#ff9553",g=n[n.length-2],f="date";let x=[];if(null==n?void 0:n.length){let e=n[0][o];n.forEach((t=>{t[o]>e&&(e=t[o])})),x=e?[0,Math.ceil(e/3),Math.ceil(e/3*2),e]:[0]}let y=0;x.forEach((e=>{const t=Um(new Pe(e));let n=t.replace(".","").length;t.indexOf(".")>-1&&(n+=.11),n>y&&(y=n)}));const v=10*y+2;return Yn.jsxs(i,{ref:l,sx:{position:"relative"},children:[Yn.jsxs(i,{sx:{minHeight:62,mb:10},children:[Yn.jsxs(i,{sx:{typography:"caption",mb:8},children:[t||Yn.jsx("span",{children:" "}),Em({input:null==g?void 0:g[r]})]}),Yn.jsx(i,{sx:{color:"text.secondary"},children:an(null==g?void 0:g[f]).format("LL")})]}),Yn.jsxs(gn,{width:u,height:364,data:n,margin:{top:5,right:10,left:0,bottom:5},children:[Yn.jsx("defs",{children:n.map(((e,t)=>Yn.jsxs("linearGradient",{id:`colorBar${e.date}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[Yn.jsx("stop",{offset:"0%",stopColor:t===n.length-1?m:h}),Yn.jsx("stop",{offset:"100%",stopColor:T(t===n.length-1?m:h,.04)})]},e.date)))}),Yn.jsx(un,{hide:!0,dataKey:f,axisLine:!1,tickFormatter:e=>an(e).format("MM-DD")}),Yn.jsx(pn,{orientation:"right",axisLine:!1,ticks:x,width:v,tickFormatter:e=>Um(new Pe(e))}),Yn.jsx(fn,{isAnimationActive:!1,content:({active:t,payload:n,label:o})=>{if(!(t&&n&&n.length))return null;const r=an(o).format("YYYY-MM-DD")===an().format("YYYY-MM-DD");return Yn.jsxs(i,{sx:{px:10,py:12,maxWidth:240,borderRadius:8,backgroundColor:"background.paperContrast",typography:"h6",color:"text.secondary"},children:[Yn.jsx(i,{sx:{mr:8},children:an(o).format("MM-DD HH:mm")}),Yn.jsx(i,{children:n[0].value}),r?Yn.jsx(i,{children:Yn.jsx(e,{id:"ubzjDN",message:"Real Time"})}):""]})},cursor:!1,coordinate:{x:0,y:0}}),Yn.jsx(xn,{dataKey:o,onMouseMove:e=>{c(e[f])},onMouseLeave:()=>{c(null)},children:n.map((e=>Yn.jsx(yn,{fill:`url(#colorBar${e.date})`},e.date)))}),d&&Yn.jsx(vn,{x:d,stroke:h,strokeDasharray:"3 3"})]})]})}var JL,eR;function tR({poolDetail:e,chart24hDataFirst:t}){var n,o,r,s,l,d,c,u;const p=a(),[h,m]=H.useState(t?JL.volume:JL.depth),g={key:JL.depth,value:se._({id:"n25Lml",message:"Depth"})},f=[{key:JL.volume,value:se._({id:"/cF7Rs",message:"Volume"})},{key:JL.feeRevenue,value:se._({id:"9QjAGB",message:"FeeRevenue"})},{key:JL.traders,value:se._({id:"qDhDFK",message:"Traders"})}];t?f.push(g):f.splice(0,0,g);const x=function({address:e,chainId:t,day:n}){var i,o,r;const a=t?Wu[t]:"",s=gg().getQuery(ye.graphql.fetchPoolDayData,{where:{pair_address:null!=e?e:"",chain:a,day:n}}),l=et(Object.assign(Object.assign({},s),{enabled:!!e&&!!t})),d=null!==(r=null===(o=null===(i=l.data)||void 0===i?void 0:i.dashboard_pairs_day_data)||void 0===o?void 0:o.map((e=>{var t,n;return{volume:KL(null==e?void 0:e.volumeUsd),fee:KL(new Pe(null!==(t=null==e?void 0:e.feeUsd)&&void 0!==t?t:0).plus(null!==(n=null==e?void 0:e.mtFeeUsd)&&void 0!==n?n:0).toString()),traders:(null==e?void 0:e.addresses)?Number(e.addresses):0,date:(null==e?void 0:e.timestamp)?1e3*(null==e?void 0:e.timestamp):0,tvl:KL(null==e?void 0:e.tvlUsd)}})))&&void 0!==r?r:[];return Object.assign(Object.assign({},l),{dayDataList:d})}({chainId:null==e?void 0:e.chainId,address:null==e?void 0:e.address,day:30}),y=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(n=null==e?void 0:e.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==e?void 0:e.quoteToken)||void 0===o?void 0:o.decimals)),{pmmParamsBG:v}=null!==(r=y.data)&&void 0!==r?r:{},b=v?{i:v.i.toNumber(),k:v.k.toNumber(),b:v.b.toNumber(),b0:v.b0.toNumber(),q:v.q.toNumber(),q0:v.k.isEqualTo(0)?v.q.toNumber():v.q0.toNumber(),R:v.k.isEqualTo(0)?0:v.R}:void 0,j=b?Le(b):void 0,[C,w]=H.useState(!1),k=C&&(null===(s=y.data)||void 0===s?void 0:s.midPrice)?new Pe(1).div(null===(l=y.data)||void 0===l?void 0:l.midPrice):null===(d=y.data)||void 0===d?void 0:d.midPrice;return Yn.jsx(i,{sx:{mt:24,[p.breakpoints.up("tablet")]:{mt:20,pt:28,borderTop:`1px solid ${p.palette.border.main}`}},children:Yn.jsxs(S,{value:h,onChange:(e,t)=>m(t),children:[Yn.jsx(D,{tabs:f,variant:"rounded",tabsListSx:{borderWidth:0,gap:4,mb:24}}),h===JL.depth&&(null==e?void 0:e.baseToken)&&(null==e?void 0:e.quoteToken)?Yn.jsx(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:Yn.jsx(nR,{baseToken:null==e?void 0:e.baseToken,quoteToken:null==e?void 0:e.quoteToken,midPrice:k,isSwitchMidPrice:C,setIsSwitchMidPrice:w,showMidPrice:h===JL.depth})}):"",Yn.jsx(O,{value:JL.depth,children:Yn.jsx(zO,{baseToken:null!==(c=null==e?void 0:e.baseToken)&&void 0!==c?c:null,quoteToken:null!==(u=null==e?void 0:e.quoteToken)&&void 0!==u?u:null,pmmParams:b,pmmModel:j,midPrice:k})}),Yn.jsx(O,{value:JL.volume,children:Yn.jsx(XL,{data:x.dayDataList,masterKey:"volume",sumKey:"volume",unit:"$"})}),Yn.jsx(O,{value:JL.feeRevenue,children:Yn.jsx(XL,{data:x.dayDataList,masterKey:"fee",sumKey:"fee",unit:"$"})}),Yn.jsx(O,{value:JL.traders,children:Yn.jsx(XL,{data:x.dayDataList,masterKey:"traders",sumKey:"traders",unit:""})})]})})}function nR({baseToken:e,quoteToken:t,midPrice:n,isSwitchMidPrice:o,setIsSwitchMidPrice:a,showMidPrice:s}){const l=null==e?void 0:e.symbol,d=null==t?void 0:t.symbol,c=o?d:l,u=o?l:d;return Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:s?Yn.jsxs(i,{sx:{mt:4,typography:"body2",color:"text.secondary",wordBreak:"break-all",display:"flex"},children:[`1 ${c} = ${n?Em({input:n,showDecimals:16}):"-"} ${u}`,Yn.jsx(r,{weak:!0,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,position:"relative",top:1.5,ml:9,cursor:"pointer",borderRadius:"50%",backgroundColor:"background.paperDarkContrast",p:0},onClick:()=>a((e=>!e)),children:Yn.jsx(i,{component:li.Switch})})]}):""})}function iR({poolDetail:t}){var n,o,r;const{isMobile:s}=Tg(),l=a(),c=null==t?void 0:t.chainId;null===(r=et($m.getPMMStateQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,null===(n=null==t?void 0:t.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==t?void 0:t.quoteToken)||void 0===o?void 0:o.decimals)).data)||void 0===r||r.midPrice;const u=function({pool:e}){var t,n,i,o,r,a,s;const{chainId:l,address:d,type:c,baseToken:u,quoteToken:p}=e||{},h=null!=d?d:"",m=l?Wu[l]:"",g=null==u?void 0:u.decimals,f=null==p?void 0:p.decimals,x=et($m.getPMMStateQuery(l,d,c,null==u?void 0:u.decimals,null==p?void 0:p.decimals)),y=null===(t=x.data)||void 0===t?void 0:t.midPrice,v=et($m.getTotalBaseLpQuery(l,d,c,g)),b=et($m.getTotalQuoteLpQuery(l,d,c,f)),j=et($m.getReserveLpQuery(l,d,c,g,f)),C=et($m.getClassicalTargetQuery(l,d,c,g,f)),w=v.data;let k=b.data;k||b.isLoading||b.error||!w||(k=w);const{baseReserve:T,quoteReserve:I}=j.data||{},S=null===(n=C.data)||void 0===n?void 0:n.baseTarget,E=null===(i=C.data)||void 0===i?void 0:i.quoteTarget,A=aL({tokens:p?[p]:[]}),O=gg(),L=et(Object.assign(Object.assign({},O.getQuery(ye.graphql.fetchLiquidityPositions,{id:h,where:{pair:h,liquidityTokenBalance_not:"0",chain:m,refreshNow:!0},miningWhere:{pair:h,liquidityTokenInMining_not:"0",chain:m},first:1e3,orderBy:"liquidityTokenBalance",orderDirection:"desc"})),{enabled:!!d})),{balance:R,mining:P,pair:_}=null!==(o=L.data)&&void 0!==o?o:{};let M=[];const B=p?null===(r=A.data)||void 0===r?void 0:r.get(p.address):void 0;if(R&&P&&_){const{baseLpToken:e,quoteLpToken:t}=_,n=new Map,i=(null==e?void 0:e.id)===(null==t?void 0:t.id);for(const o of R){const{id:r,liquidityTokenBalance:a}=o,s=new Pe(null!=a?a:0),[l,u]=r.split("-");let p={id:l,baseSupplied:new Pe(0),quoteSupplied:new Pe(0)};n.has(p.id)?p=n.get(p.id):n.set(p.id,p);const[,h]=fI(s,w,T,S,d,c,g);h&&(i||u===(null==e?void 0:e.id))&&(p.baseSupplied=h);const[,m]=fI(s,k,I,E,d,c,f);m&&(i||u===(null==t?void 0:t.id))&&(p.quoteSupplied=m)}for(const o of P){const{id:r,liquidityTokenInMining:a}=o,s=new Pe(null!=a?a:0),[l,u]=r.split("-"),[,p]=fI(s,w,T,S,d,c,g),[,h]=fI(s,k,I,E,d,c,f);if(n.has(l)){const o=n.get(l);p&&(i||u===(null==e?void 0:e.id))&&(o.baseSupplied=p.plus(o.baseSupplied)),h&&(i||u===(null==t?void 0:t.id))&&(o.quoteSupplied=h.plus(o.quoteSupplied))}else{const o={id:l,baseSupplied:new Pe(0),quoteSupplied:new Pe(0)};p&&(i||u===(null==e?void 0:e.id))&&(o.baseSupplied=p),h&&(i||u===(null==t?void 0:t.id))&&(o.quoteSupplied=h),n.set(o.id,o)}}const o=(null!==(a=null==u?void 0:u.decimals)&&void 0!==a?a:0)>6?6:4,r=(null!==(s=null==p?void 0:p.decimals)&&void 0!==s?s:0)>6?6:4,l=B;n.forEach((e=>{var t,n;M.push({userId:e.id,baseSupplied:e.baseSupplied?Em({input:e.baseSupplied,showDecimals:o}):"0",quoteSupplied:e.quoteSupplied?Em({input:e.quoteSupplied,showDecimals:r}):"0",baseTokenAddress:null!==(t=null==u?void 0:u.address)&&void 0!==t?t:"",quoteTokenAddress:null!==(n=null==p?void 0:p.address)&&void 0!==n?n:"",baseTokenSymbol:Hm(u),quoteTokenSymbol:Hm(p),sharePercentage:y&&T?Em({input:y.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).div(y.multipliedBy(T).plus(null!=I?I:0)).multipliedBy(100),showDecimals:2}):"",dollarValue:null!=l&&y?`$${Em({input:y.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0).multipliedBy(l),showDecimals:2})}`:"-",dollarValueBN:y?y.multipliedBy(e.baseSupplied||0).plus(e.quoteSupplied||0):Pe(0)})})),M.sort(((e,t)=>t.dollarValueBN.gt(e.dollarValueBN)?1:-1))}const D=[x,v,b,C,j,A,L],N=function(e){const t=[];if(e.forEach((e=>{e.error&&t.push(e.refetch)})),t.length)return()=>{t.forEach((e=>e()))}}(D),F=D.some((e=>e.isLoading));return Object.assign(Object.assign({},L),{isLoading:F,errorRefetch:N,list:M})}({pool:t}),[p,h]=H.useState(1),m=p*(s?4:8),g=u.list,f=m<g.length,x=g.slice(0,m);return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:u.error?u.refetch:void 0,loading:u.isLoading&&!(null==x?void 0:x.length),empty:!(null==x?void 0:x.length),children:!!(null==x?void 0:x.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"JlIjZf",message:"Liquidity Provider"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"C1qIFl",message:"Liquidity Supplied"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"me2dmq",message:"Value (USD)"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"Z8lGw6",message:"Share"})})]})}),Yn.jsx(i,{component:"tbody",children:null==x?void 0:x.map((e=>Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center"},children:Yn.jsx(zb,{address:e.userId,customChainId:c,truncate:!0})})}),Yn.jsxs("td",{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.baseTokenAddress,chainId:c,width:18,height:18}),`${e.baseSupplied} ${e.baseTokenSymbol}`]}),Yn.jsxs(i,{sx:{mt:4,display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.quoteTokenAddress,chainId:c,width:18,height:18}),`${e.quoteSupplied} ${e.quoteTokenSymbol}`]})]}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:e.dollarValue}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:`${e.sharePercentage}%`})]},e.userId)))})]})}),f&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>h((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function oR({address:e,chainId:t}){var n;const i=gg(),o=t?Wu[t]:"",r=i.getQuery(ye.graphql.fetchPoolDashboard,{where:{pair_address:null!=e?e:"",chain:o}}),a=et(Object.assign(Object.assign({},r),{enabled:!!e&&!!t})),s=null===(n=a.data)||void 0===n?void 0:n.dashboard_pairs_detail;return Object.assign(Object.assign({},a),{dashboard:s})}function rR(e,t){if(!e)return"";const n=an(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function aR({chainId:e,address:t,symbol:n,amount:o,sx:r}){return Yn.jsxs(i,{sx:ne({display:"flex",justifyContent:"flex-end",alignItems:"center"},r),children:[t&&Yn.jsx(i,{sx:{height:16,flexBasis:16,flexGrow:0,flexShrink:0,mr:4},children:Yn.jsx(Df,{width:16,height:16,address:t,chainId:e})}),Yn.jsxs(i,{sx:{textAlign:"right",display:"flex",alignItems:"center"},children:[o," ",Yn.jsx(i,{sx:{display:"inline-block",maxWidth:"6em",minWidth:"auto",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"},title:n,children:n})]})]})}function sR({chainId:e,baseToken:t,quoteToken:n,baseAmount:o,quoteAmount:r,vertical:a}){const{isMobile:s}=Tg();return Yn.jsxs(i,{sx:{mt:4,display:"flex",justifyContent:"flex-end",flexDirection:a?"column":"row",alignItems:a?"flex-end":"center",flexWrap:"wrap",typography:s?"h6":"body1"},children:[t?Yn.jsx(aR,{chainId:e,address:null==t?void 0:t.address,amount:o,symbol:null==t?void 0:t.symbol}):"-",a?"":Yn.jsx(i,{sx:{mx:10},children:"/"}),n?Yn.jsx(aR,{chainId:e,address:null==n?void 0:n.address,amount:r,symbol:null==n?void 0:n.symbol,sx:{mt:a?4:0}}):"-"]})}function lR({label:e,children:t,pairsStatLoading:n,poolDetailLoading:o}){const{isMobile:r}=Tg();return Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between"},children:[Yn.jsx(i,{sx:{color:"text.secondary",minWidth:"5em",typography:r?"h6":"body1"},children:e}),Yn.jsx(i,{sx:ne({textAlign:"right",overflow:"hidden","& .title":{typography:r?"body1":"caption",width:"100%"}},n&&!o||!n&&o?{ml:8,flex:1,display:"flex",flexDirection:"column",alignItems:"flex-end","& .title":{display:"flex",justifyContent:"flex-end"}}:{}),children:t})]})}function dR({sx:e}){return Yn.jsx(j,{sx:Object.assign({width:"100%",maxWidth:237,height:22},e)})}function cR({detail:e,lpFeeRate:t,mtFeeRate:n}){const{isMobile:o}=Tg();return"DPP"===(null==e?void 0:e.type)?null:e&&t&&n?Yn.jsxs(i,{sx:{color:"text.secondary",typography:o?"h6":"body1"},children:[Yn.jsx("span",{children:"LP "}),Yn.jsx("span",{children:Vm({input:t,showDecimals:6})}),Yn.jsxs("span",{children:[" / ",se._({id:"7C/BwI",message:"Community Treasury"})," "]}),Yn.jsx("span",{children:Vm({input:new Pe(null!=n?n:0).toNumber(),showDecimals:6})})]}):Yn.jsx(dR,{sx:{mt:4}})}function uR({detail:e}){var t,n,o,r,s,l,d,c,u,p,h,m,g,f,x,y,v,b,j,C,w,k,T,I,S,E,A;const O=a(),{isMobile:L}=Tg(),{baseToken:R,quoteToken:P}=null!=e?e:{},_="DPP"===(null==e?void 0:e.type),M="DSP"===(null==e?void 0:e.type)||"GSP"===(null==e?void 0:e.type),B="CLASSICAL"===(null==e?void 0:e.type),D=oR({address:null==e?void 0:e.address,chainId:null==e?void 0:e.chainId}),N=D.dashboard,F=D.isLoading,U=et($m.getPMMStateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(t=null==e?void 0:e.baseToken)||void 0===t?void 0:t.decimals,null===(n=null==e?void 0:e.quoteToken)||void 0===n?void 0:n.decimals)),q=F?Yn.jsx(dR,{}):null===(null==N?void 0:N.totalVolume)||void 0===(null==N?void 0:N.totalVolume)?"-":`$${Em({input:new Pe(null==N?void 0:N.totalVolume),showDecimals:2})}`,V=F?Yn.jsx(dR,{}):N&&(yj(N.totalFee)||yj(N.totalMtFee))?`$${Em({input:new Pe(N.totalFee||0).plus(N.totalMtFee||0),showDecimals:2})}`:"-",{account:W}=dg(),H=et($m.getFeeRateQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,W)),$=null===(o=H.data)||void 0===o?void 0:o.mtFeeRate,z=null===(r=H.data)||void 0===r?void 0:r.lpFeeRate,Z=null==$?void 0:$.plus(null!=z?z:0),G=!e,Q=et($m.getClassicalTargetQuery(null==e?void 0:e.chainId,null==e?void 0:e.address,null==e?void 0:e.type,null===(s=null==e?void 0:e.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==e?void 0:e.quoteToken)||void 0===l?void 0:l.decimals));return Yn.jsxs(i,{sx:Object.assign({pb:30,position:"relative",overflow:"hidden"},L?{backgroundColor:"background.paper",p:20}:{mt:32}),children:[Yn.jsxs(i,{sx:{flex:"1 0 50%","& > div + div":{mt:10},"&::after":{content:'""',display:"block",my:20,width:"100%",height:"1px",backgroundColor:"border.main"}},children:[Yn.jsx(lR,{label:se._({id:"l4Za6X",message:"Total Swap Volume"}),pairsStatLoading:F,children:Yn.jsx("div",{className:"title",children:q})}),F||!e?Yn.jsx(dR,{sx:{mt:4}}):Yn.jsx(sR,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Em({input:null!==(d=null==N?void 0:N.baseVolumeCumulative)&&void 0!==d?d:0,showDecimals:2}),quoteAmount:Em({input:null!==(c=null==N?void 0:N.quoteVolumeCumulative)&&void 0!==c?c:0,showDecimals:2})}),Yn.jsx(lR,{label:se._({id:"Z033WN",message:"Total Swap Fee"}),pairsStatLoading:F,children:Yn.jsx("div",{className:"title",children:V})}),F||!e?Yn.jsx(dR,{sx:{mt:4}}):Yn.jsx(sR,{chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Em({input:new Pe(null!==(u=null==N?void 0:N.baseFee)&&void 0!==u?u:0).plus(null!==(p=null==N?void 0:N.baseMtFee)&&void 0!==p?p:0),showDecimals:2}),quoteAmount:Em({input:new Pe(null!==(h=null==N?void 0:N.quoteFee)&&void 0!==h?h:0).plus(null!==(m=null==N?void 0:N.quoteMtFee)&&void 0!==m?m:0),showDecimals:2})}),Yn.jsx(lR,{label:se._({id:"/BbUJ6",message:"Total Number of Traders"}),pairsStatLoading:F,children:F?Yn.jsx(dR,{sx:{mt:4}}):Em({input:null!==(g=null==N?void 0:N.txUsers)&&void 0!==g?g:0,showDecimals:0})})]}),Yn.jsxs(i,{sx:{flex:"1 0 50%",overflow:"hidden","& > div + div":{mt:10}},children:[Yn.jsx(lR,{label:se._({id:"UE2beD",message:"Creator"}),poolDetailLoading:!e,children:e?e.isCpPool?Yn.jsx(zb,{address:null!==(f=e.cpCreator)&&void 0!==f?f:"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}}):Yn.jsx(zb,{address:null!==(x=e.creator)&&void 0!==x?x:"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}}):Yn.jsx(dR,{})}),(null==e?void 0:e.isCpPool)||(null==e?void 0:e.owner)?Yn.jsx(lR,{label:se._({id:"LtI9AS",message:"Owner"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):(null==e?void 0:e.isCpPool)?Yn.jsx(zb,{address:null==e?void 0:e.cpCreator,truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}}):Yn.jsx(zb,{address:null!==(y=e.owner)&&void 0!==y?y:"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}})}):"",Yn.jsx(lR,{label:se._({id:"52uNwk",message:"Creation Time"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):rR(1e3*Number((null==e?void 0:e.isCpPool)?e.cpCreatedAtTimestamp||0:e.createdAtTimestamp||0))||"-"}),(null==e?void 0:e.isCpPool)?Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(lR,{label:se._({id:"cDWXuq",message:"Settler"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):Yn.jsx(zb,{address:(null==e?void 0:e.cpLiquidator)||"",truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}})}),Yn.jsx(lR,{label:se._({id:"JuzN3b",message:"Related CrowdPooling"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):Yn.jsx(zb,{address:null==e?void 0:e.cpAddress,truncate:!0,"data-key":"link",sx:{color:O.palette.text.primary}})})]}):void 0,Yn.jsxs(lR,{label:se._({id:"Y7rVy0",message:"Fee Rate"}),poolDetailLoading:G,children:[Yn.jsx("div",{className:"detail-title",style:{textAlign:"right"},children:Vm({input:null==Z?void 0:Z.toNumber(),showDecimals:6})}),Yn.jsx(cR,{detail:e,lpFeeRate:z,mtFeeRate:$})]}),Yn.jsx(lR,{label:se._({id:"sjn3tj",message:"Slippage Coefficient"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):null===(b=null===(v=U.data)||void 0===v?void 0:v.pmmParamsBG)||void 0===b?void 0:b.k.toString()}),Yn.jsx(lR,{poolDetailLoading:G,label:B?se._({id:"d8YnVj",message:"Guide Price"}):_?se._({id:"CeLrge",message:"Mid Price"}):M?se._({id:"4ogEAw",message:"Pegged Exchange Rate"}):se._({id:"jjuKOj",message:"Min Price"}),children:G?Yn.jsx(dR,{}):null!==R&&(M?`1 ${null==R?void 0:R.symbol} = ${null===(w=null===(C=null===(j=U.data)||void 0===j?void 0:j.pmmParamsBG)||void 0===C?void 0:C.i)||void 0===w?void 0:w.toString()} ${null==P?void 0:P.symbol}`:null===(I=null===(T=null===(k=U.data)||void 0===k?void 0:k.pmmParamsBG)||void 0===T?void 0:T.i)||void 0===I?void 0:I.toString())||"-"}),B&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(lR,{label:se._({id:"JR7wWw",message:"Equilibrium target"}),poolDetailLoading:G,children:G?Yn.jsx(dR,{}):Yn.jsx(Yn.Fragment,{children:null===(A=null===(E=null===(S=U.data)||void 0===S?void 0:S.pmmParamsBG)||void 0===E?void 0:E.k)||void 0===A?void 0:A.toString()})}),Q.data?Yn.jsx(sR,{vertical:!0,chainId:e.chainId,baseToken:e.baseToken,quoteToken:e.quoteToken,baseAmount:Em({input:Q.data.baseTarget,showDecimals:2}),quoteAmount:Em({input:Q.data.quoteTarget,showDecimals:2})}):""]})]})]})}function pR(e,t){if(!e)return"";const n=an(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function hR({amountOut:e,amountIn:t,fromTokenSymbol:n,toTokenSymbol:o}){const[r,a]=H.useState(!1),s=Em({input:t/e,showDecimals:2}),l=Em({input:e/t,showDecimals:2});return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:["1 ",r?o:n," = ",r?s:l," ",r?n:o,Yn.jsx(i,{sx:{ml:10,width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",backgroundColor:"background.paperContrast",borderRadius:"50%"},onClick:()=>a((e=>!e)),children:Yn.jsx(i,{component:li.Switch})})]})}function mR({poolDetail:t}){var n,o,r;const{isMobile:s}=Tg(),l=a(),{account:c,chainId:u}=dg(),p=et($m.getFeeRateQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,c)),h=null===(n=p.data)||void 0===n?void 0:n.mtFeeRate,m=null===(o=p.data)||void 0===o?void 0:o.lpFeeRate,g=null==h?void 0:h.plus(null!=m?m:0),f=function({chainId:e,address:t,first:n=50}){var i;const o=e?Wu[e]:"",r=gg().getQuery(ye.graphql.fetchPoolSwapList,{first:n,orderBy:"timestamp",orderDirection:"desc",where:{pair:t,chain:o}}),a=et(Object.assign(Object.assign({},r),{enabled:!!t})),s=null===(i=a.data)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},a),{swapList:s})}({address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),[x,y]=H.useState(1),v=x*(s?4:8),b=null!==(r=f.swapList)&&void 0!==r?r:[],j=v<b.length,C=b.slice(0,v);return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:f.error?f.refetch:void 0,loading:f.isLoading,empty:!(null==C?void 0:C.length),children:!!(null==C?void 0:C.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"LhMjLm",message:"Time"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"UPXmW+",message:"Trader"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"v4nCHK",message:"Paid"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"fZ5Vnu",message:"Received"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"a7u1N9",message:"Price"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"Y7rVy0",message:"Fee Rate"})}),Yn.jsx(i,{component:"th",sx:{"&&":{textAlign:"right"}},children:Yn.jsx(e,{id:"PLUB/s",message:"Fee"})})]})}),Yn.jsx(i,{component:"tbody",children:null==C?void 0:C.map((e=>Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:pR(1e3*e.timestamp)}),Yn.jsx("td",{children:Yn.jsx(zb,{address:e.from,truncate:!0})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.fromToken.id,chainId:u,width:18,height:18}),`${Em({input:e.amountIn,showDecimals:2})} ${e.fromToken.symbol}`]})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.toToken.id,chainId:u,width:18,height:18}),`${Em({input:e.amountOut,showDecimals:2})} ${e.toToken.symbol}`]})}),Yn.jsx("td",{children:Yn.jsx(hR,{amountOut:e.amountOut,amountIn:e.amountIn,fromTokenSymbol:e.fromToken.symbol,toTokenSymbol:e.toToken.symbol})}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:Vm({input:g})}),Yn.jsx(i,{component:"td",sx:{textAlign:"right"},children:`${Em({input:new Pe(e.amountOut).times(null!=g?g:0)})} ${e.toToken.symbol}`})]},e.id)))})]})}),j&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>y((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}function gR({poolDetail:e}){const{isMobile:t}=Tg(),[n,o]=H.useState(eR.parameters),r=[{key:eR.parameters,value:se._({id:"F18WP3",message:"Parameters"})},{key:eR.swaps,value:se._({id:"EatqP4",message:"Swaps"})}];return e&&"DPP"!==(null==e?void 0:e.type)&&r.push({key:eR.liquidityProviders,value:se._({id:"juypHV",message:"Liquidity Providers"})}),Yn.jsx(i,{sx:Object.assign({mt:24,backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},t?{}:{mt:32,px:20}),children:Yn.jsxs(S,{value:n,onChange:(e,t)=>o(t),children:[Yn.jsx(D,{tabs:r}),Yn.jsx(O,{value:eR.parameters,children:Yn.jsx(uR,{detail:e})}),Yn.jsx(O,{value:eR.swaps,children:Yn.jsx(mR,{poolDetail:e})}),Yn.jsx(O,{value:eR.liquidityProviders,children:Yn.jsx(iR,{poolDetail:e})})]})})}function fR(){return Yn.jsx(j,{variant:"rounded",sx:{width:90}})}function xR({poolDetail:t}){var n,o;const r=a(),{isMobile:s}=Tg(),l=oR({address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),d=l.dashboard,c=[{description:se._({id:"Gr2anW",message:"Traders (24H)"}),text:l.isLoading?Yn.jsx(fR,{}):null===(null==d?void 0:d.txUserNear24h)||void 0===(null==d?void 0:d.txUserNear24h)?"-":Um(new Pe(null==d?void 0:d.txUserNear24h))},{description:se._({id:"sTnImq",message:"Total Liquidity"}),text:l.isLoading?Yn.jsx(fR,{}):null===(null==d?void 0:d.tvl)||void 0===(null==d?void 0:d.tvl)?"-":`$${Um(new Pe(null==d?void 0:d.tvl))}`},{description:se._({id:"p7/w10",message:"Volume (24H)"}),text:l.isLoading?Yn.jsx(fR,{}):null===(null==d?void 0:d.volume)||void 0===(null==d?void 0:d.volume)?"-":`$${Um(new Pe(null==d?void 0:d.volume))}`},{description:se._({id:"7X40pG",message:"Fees (24H)"}),text:l.isLoading?Yn.jsx(fR,{}):null!==!(null==d?void 0:d.feeNear24h)||(null==d?void 0:d.mtFeeNear24h)?`$${Um(new Pe(null!==(n=null==d?void 0:d.feeNear24h)&&void 0!==n?n:0).plus(null!==(o=null==d?void 0:d.mtFeeNear24h)&&void 0!==o?o:0))}`:"-",question:l.isLoading?void 0:Yn.jsxs(i,{sx:{width:198},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(e,{id:"OnDEky",message:"LP Fee"}),Yn.jsx(i,{children:(null==d?void 0:d.feeNear24h)?`$${Um(new Pe(null==d?void 0:d.feeNear24h))}`:"-"})]}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(e,{id:"pSQ1lM",message:"MT Fee"}),Yn.jsx(i,{children:(null==d?void 0:d.mtFeeNear24h)?`$${Um(new Pe(null==d?void 0:d.mtFeeNear24h))}`:"-"})]})]})}];return Yn.jsx(i,{sx:Object.assign({display:"grid",gap:12},s?{mt:24,gridTemplateColumns:"repeat(2, 1fr)"}:{mt:32,gridTemplateColumns:"repeat(4, 1fr)"}),children:c.map((e=>Yn.jsxs(i,{sx:{borderRadius:8,p:16,backgroundColor:"background.paper",border:`1px solid ${r.palette.border.main}`},children:[Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,lineHeight:"27px"},children:e.text}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary",gap:4},children:[e.description,e.question?Yn.jsx(lb,{title:e.question}):""]})]},e.description)))})}function yR({poolDetail:t,loading:n}){var o,r,s,c;const{address:u}=null!=t?t:{},p=a(),h=Gj(),{account:m}=dg(),{isMobile:g}=Tg(),f=m&&"DPP"===(null==t?void 0:t.type)&&(null===(o=null==t?void 0:t.owner)||void 0===o?void 0:o.toLocaleLowerCase())===m.toLocaleLowerCase(),{supportAMMV2:x,onSharePool:y}=Jn();return Yn.jsxs(i,{sx:Object.assign({},g?{pt:24}:{pt:20,display:"flex",alignItems:"center",justifyContent:"space-between"}),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[(null==t?void 0:t.baseToken)?Yn.jsx(kj,{tokens:[t.baseToken,t.quoteToken],chainId:t.chainId,width:36,mr:8}):Yn.jsx(j,{variant:"circular",sx:{width:36,height:36,mr:8}}),Yn.jsxs(i,{children:[Yn.jsxs(i,{sx:{typography:"h4"},children:[(null==t?void 0:t.baseToken)?`${null===(r=t.baseToken)||void 0===r?void 0:r.symbol} / ${null===(s=t.quoteToken)||void 0===s?void 0:s.symbol}`:"-",x&&Yn.jsx(i,{component:"span",sx:{position:"relative",top:-4,ml:4,px:4,py:2,borderRadius:4,fontSize:10,lineHeight:1,fontWeight:600,backgroundColor:T(p.palette.purple.main,.1),color:p.palette.purple.main},children:"PMM"}),Yn.jsx(gS,{address:u,chainId:null==t?void 0:t.chainId,hideName:g,sx:{display:"inline-flex",ml:8}}),f&&!g?Yn.jsx(i,{component:d,sx:{typography:"h6",px:8,py:2,ml:8,borderStyle:"solid",borderWidth:1,borderRadius:4,borderColor:"primary.main",color:"primary.main",whiteSpace:"nowrap","&:hover":{backgroundColor:"primary.main",color:"primary.contrastText"}},onClick:()=>{h.push({type:Zj.ModifyPool,params:{address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}})},children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})}):""]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",mr:12},children:Yn.jsx(zb,{address:null!=u?u:"",truncate:!0,showCopy:!0,iconDarkHover:!0,"data-key":"link",sx:{typography:"body2",color:"text.secondary"},iconSize:14,iconSpace:6,customChainId:null==t?void 0:t.chainId,onShareClick:y&&t?()=>y({chainId:t.chainId,baseToken:t.baseToken,quoteToken:t.quoteToken,poolId:u,apy:t.apy,isSingle:ye.utils.singleSideLp(t.type)}):void 0})})]})]}),Yn.jsxs(i,{sx:g?{display:"flex",alignItems:"center",mt:24}:{textAlign:"right"},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",color:"success.main",typography:"h4"},children:[(null==t?void 0:t.miningAddress)?Yn.jsx(l,{title:se._({id:"B3mhDR",message:"Add liquidity to obtain LP tokens for mining"}),children:Yn.jsx("span",{children:"✨ "})}):"",Yn.jsx(v,{loading:n,loadingSx:{width:100},children:null!==(c=null==t?void 0:t.baseApy)&&void 0!==c?c:"0%"}),(null==t?void 0:t.quoteApy)?`/${null==t?void 0:t.quoteApy}`:""]}),Yn.jsx(i,{sx:Object.assign({typography:"body2"},g?{ml:4}:{}),children:Yn.jsx(e,{id:"rSayea",message:"APY"})})]})]})}function vR({chainId:e,shortNumber:t,pieSize:n="default",baseReserve:o=new Pe(1),baseAmount:r=new Pe(1),quoteAmount:s=new Pe(0),baseTokenSymbol:l="-",quoteTokenSymbol:d="-",quoteTokenDecimals:c=18,baseTokenDecimals:u=18,baseTokenAddress:p,quoteTokenAddress:h,baseTvlRate:m,quoteTvlRate:g,disabledAmount:f,disabledRate:x,disabledPercentage:y,loading:v,sx:b,pieRadius:C}){const w=a(),k="small"===n,T=k?6:16,I=C||(k?23:30),S=u>6?6:u>4?4:2,E=c>6?6:c>4?4:2,A=t?Um(new Pe(o)):Em({input:o,showDecimals:S}),O=t?Um(new Pe(s)):Em({input:s,showDecimals:E});let L=r.plus(s);L=L.lte(0)?new Pe(1):L;const R=m||r.div(L).multipliedBy(100).toFixed(2),P=g||s.div(L).multipliedBy(100).toFixed(2),_=r.lte(0)&&s.lte(0),M=w.palette.success.main,B=w.palette.error.main,D=[{name:"base",value:_?1:r.toNumber(),color:M},{name:"quote",value:_?1:s.toNumber(),color:B}];return Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",flexDirection:"column"},b||{}),children:[Yn.jsx("div",{children:y?"":v?Yn.jsx(j,{width:46,height:46,variant:"circular"}):Yn.jsx(bn,{width:2*I,height:2*I,children:Yn.jsx(jn,{isAnimationActive:!1,dataKey:"value",data:D,labelLine:!1,label:!1,outerRadius:I,fill:B,children:D.map(((e,t)=>Yn.jsx(yn,{fill:e.color,strokeWidth:0},`cell-${t}`)))})})}),Yn.jsxs(i,{className:"symbol-wrapper",sx:{display:"flex",flexDirection:"column",justifyContent:"center",ml:0,mt:16,width:"100%","& > div":{paddingLeft:"12px",position:"relative","&::before":{content:'""',width:"8px",height:"8px",position:"absolute",left:"0",top:"50%",transform:"translateY(-50%)",backgroundColor:w.palette.purple.main,borderRadius:"50%"},"&:last-child::before":{backgroundColor:B},"&> span.symbol":{display:"inline-block",maxWidth:"6em",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",verticalAlign:"text-bottom"}}},children:[v?Yn.jsx(j,{width:237,sx:{borderRadius:4}}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{className:"symbol",title:l,sx:{typography:"h6"},children:l}),p?Yn.jsx(zb,{address:p,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),Yn.jsxs(i,{sx:{textAlign:"right"},children:[f?"":`${A} `,y||x?"":Yn.jsxs(i,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${R}%)`]})]})]}),v?Yn.jsx(j,{width:237,sx:{borderRadius:4,marginTop:`${T}px`}}):Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:`${T}px`},children:[Yn.jsxs(i,{children:[Yn.jsx(i,{className:"symbol",title:d,sx:{typography:"h6"},children:d}),h?Yn.jsx(zb,{address:h,customChainId:e,truncate:!0,showCopy:!0,size:"small",iconSpace:4,sx:{typography:"h6",color:"text.secondary"}}):""]}),Yn.jsxs(i,{sx:{textAlign:"right"},children:[f?"":`${O} `,y||x?"":Yn.jsxs(i,{sx:{color:"text.secondary",typography:"h6",fontWeight:600},children:[" ",`(${P}%)`]})]})]})]})]})}function bR({poolDetail:t}){var n,o,r,s,l,d,c,u,p;const h=a(),{isMobile:m}=Tg(),g=et($m.getPMMStateQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,null===(n=null==t?void 0:t.baseToken)||void 0===n?void 0:n.decimals,null===(o=null==t?void 0:t.quoteToken)||void 0===o?void 0:o.decimals)),f=null===(r=g.data)||void 0===r?void 0:r.midPrice,x=et($m.getReserveLpQuery(null==t?void 0:t.chainId,null==t?void 0:t.address,null==t?void 0:t.type,null===(s=null==t?void 0:t.baseToken)||void 0===s?void 0:s.decimals,null===(l=null==t?void 0:t.quoteToken)||void 0===l?void 0:l.decimals)),{baseReserve:y,quoteReserve:v}=x.data||{},b=y&&f?null==f?void 0:f.multipliedBy(y):void 0,C=v&&f?new Pe(v):void 0;let w=b&&C?null==b?void 0:b.plus(C):void 0;w=!w||w.lte(0)?new Pe(1):w;const k=b&&b.div(w).multipliedBy(100).toFixed(2),T=C&&C.div(w).multipliedBy(100).toFixed(2);return Yn.jsxs(i,{sx:{mt:m?24:28},children:[Yn.jsx(i,{sx:{fontWeight:600},children:Yn.jsx(e,{id:"sTnImq",message:"Total Liquidity"})}),Yn.jsxs(i,{sx:{display:"flex",mt:16,backgroundColor:"background.paper",borderRadius:16,overflowX:"auto",border:`1px solid ${h.palette.border.main}`},children:[Yn.jsx(i,{sx:{flex:m?1:void 0,padding:m?h.spacing(20,30,20,20):h.spacing(20,30,16)},children:Yn.jsx(vR,{pieRadius:44,baseReserve:y,baseAmount:b,baseTokenDecimals:null===(d=null==t?void 0:t.baseToken)||void 0===d?void 0:d.decimals,quoteAmount:C,baseTvlRate:k,quoteTvlRate:T,chainId:null==t?void 0:t.chainId,quoteTokenDecimals:(null===(c=null==t?void 0:t.quoteToken)||void 0===c?void 0:c.decimals)||void 0,baseTokenSymbol:Hm(null==t?void 0:t.baseToken),quoteTokenSymbol:Hm(null==t?void 0:t.quoteToken),baseTokenAddress:m?null===(u=null==t?void 0:t.baseToken)||void 0===u?void 0:u.address:"",quoteTokenAddress:m?null===(p=null==t?void 0:t.quoteToken)||void 0===p?void 0:p.address:"",shortNumber:!0,disabledRate:!m,disabledAmount:!m,loading:g.isLoading||x.isLoading,sx:m?{typography:"body2",fontWeight:600}:{"& .symbol-wrapper":{display:"flex",alignItems:"center",flexDirection:"row","& > div, & > span":{mt:0,"&:last-child":{ml:16}},"& .MuiSkeleton-root":{width:"40px !important"}}}})}),m?"":Yn.jsxs(i,{component:"table",sx:{flex:1,fontWeight:600,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 0 1px","& thead":{typography:"h6",color:"text.secondary","& th":{textAlign:"right",px:20,py:16,borderStyle:"solid",borderColor:"border.main",borderWidth:"0 0 1px","&:first-child":{textAlign:"left"}}},"& tbody":{typography:"body2",textAlign:"right","& td":{px:20,py:0,"&:first-child":{textAlign:"left"}}}},children:[Yn.jsx("thead",{children:Yn.jsxs("tr",{children:[Yn.jsx("th",{children:Yn.jsx(e,{id:"bUUVED",message:"Asset"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"hcNa1G",message:"Token Amount"})}),Yn.jsx("th",{children:Yn.jsx(e,{id:"iaocTt",message:"Ratio"})})]})}),Yn.jsxs("tbody",{children:[Yn.jsxs("tr",{children:[Yn.jsx("td",{children:t?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{address:t.baseToken.address,width:24,height:24,marginRight:4,chainId:t.chainId}),Yn.jsxs(i,{children:[t.baseToken.symbol,Yn.jsx(zb,{address:t.baseToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:t.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):Yn.jsx(j,{width:100,height:24})}),Yn.jsx("td",{children:t?Um(new Pe(t.baseReserve)):Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}})}),Yn.jsx("td",{children:g.isLoading?Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=k?k:"-"}%`})]}),Yn.jsxs("tr",{children:[Yn.jsx("td",{children:t?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center"},children:[Yn.jsx(Df,{address:t.quoteToken.address,width:24,height:24,marginRight:4,chainId:t.chainId}),Yn.jsxs(i,{children:[t.quoteToken.symbol,Yn.jsx(zb,{address:t.quoteToken.address,truncate:!0,showCopy:!0,size:"small",iconSpace:4,customChainId:t.chainId,sx:{typography:"h6",color:"text.secondary"}})]})]}):Yn.jsx(j,{width:100,height:24})}),Yn.jsx("td",{children:t?Um(new Pe(t.quoteReserve)):Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}})}),Yn.jsx("td",{children:g.isLoading?Yn.jsx(j,{width:50,height:24,sx:{display:"inline-block"}}):`${null!=T?T:"-"}%`})]})]})]})]})]})}function jR({params:t}){var n,o,r,s,l,d,u;const p=Gj(),{isMobile:h}=Tg(),{account:m}=dg(),g=a(),f=$L({id:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),{poolDetail:x}=f,y=qn(f,["poolDetail"]),[v,b]=H.useState("inital");y.isPending||y.error||x||"inital"!==v||b("open");const j=x&&"DPP"===x.type&&m&&(null===(n=x.owner)||void 0===n?void 0:n.toLocaleLowerCase())===m.toLocaleLowerCase(),C=x&&"DPP"!==x.type||m&&(null==x?void 0:x.owner)&&x.owner.toLocaleLowerCase()===m.toLocaleLowerCase(),[w,k]=H.useState();x&&void 0===w&&!h&&k(YT.Add);const T=w&&x?Object.assign(Object.assign({},x),{baseLpToken:{id:null===(o=x.baseLpToken)||void 0===o?void 0:o.id,decimals:Number(null!==(s=null===(r=x.baseLpToken)||void 0===r?void 0:r.decimals)&&void 0!==s?s:18)},quoteLpToken:{id:null===(l=x.quoteLpToken)||void 0===l?void 0:l.id,decimals:Number(null!==(u=null===(d=x.quoteLpToken)||void 0===d?void 0:d.decimals)&&void 0!==u?u:18)}}):void 0,I=!!(null==x?void 0:x.miningAddress);return Yn.jsxs(zj,{sx:h?{p:g.spacing(28,0,C?108:0)}:{p:g.spacing(28,0,40)},children:[Yn.jsx(WL,{onClick:()=>{p.push({type:Zj.Pool})}}),Yn.jsxs(i,{sx:h?{}:{display:"flex",gap:12,overflow:"hidden"},children:[Yn.jsxs(i,{sx:{flex:1,overflow:"hidden"},children:[Yn.jsx(yR,{poolDetail:x,loading:y.isPending}),Yn.jsx(tR,{poolDetail:x,chart24hDataFirst:!0}),Yn.jsx(xR,{poolDetail:x}),Yn.jsx(bR,{poolDetail:x}),Yn.jsx(gR,{poolDetail:x})]}),h?Yn.jsx(mS,{account:m,pool:T,operate:w,hasMining:I,modal:!0,onClose:()=>{k(void 0)}}):Yn.jsx(hS,{account:m,operate:w,hasMining:I,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"},pool:T,hidePoolInfo:!0})]}),Yn.jsx(VL,{singleBtn:!0,open:"open"===v,onClose:()=>b("close"),onConfirm:()=>b("close"),title:se._({id:"Da1+Da",message:"Pool not found. Please switch to another network and retry."})}),h&&C&&Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:j?"repeat(3, 1fr)":"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[j?Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{Gj.getState().push({type:Zj.ModifyPool,params:{chainId:x.chainId,address:x.address}})},children:Yn.jsx(e,{id:"ePK91l",message:"Edit"})}):"",Yn.jsx(c,{variant:c.Variant.second,onClick:()=>{k(YT.Remove)},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{onClick:()=>{k(YT.Add)},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})})]})})]})}function CR({statuses:t,children:n,buttonProps:o}){var r;if(!t.find((e=>e.needShowTokenStatusButton))&&n)return Yn.jsx(Yn.Fragment,{children:n});const a=t.find((e=>e.insufficientBalance));if(a)return Yn.jsx(c,{fullWidth:!0,disabled:!0,...o,children:Yn.jsx(e,{id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(r=a.token)||void 0===r?void 0:r.symbol}})});const s=t.some((e=>e.isApproving));return Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:4},children:t.map(((t,n)=>{var i,r;let a="";return t.isApproving?a=Yn.jsx(e,{id:"j2Uisd",message:"Approving"}):(t.needReset||t.needApprove)&&(a=t.approveTitle),a?Yn.jsx(c,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance||s,...o,children:a},null!==(r=null===(i=t.token)||void 0===i?void 0:i.symbol)&&void 0!==r?r:n):null}))})}function wR({token:t,chainId:n,showChainLogo:o,readonly:r,showChainName:s,logoSize:l=24,chainLogoSize:c=12,side:u,occupiedToken:p,defaultLoadBalance:h,notTokenPickerModal:m,border:g,px:f=20,py:x=8,highlightDefault:y,onTokenClick:v,onTokenChange:b}){var j,C;const{onlyChainId:w}=Jn(),k=n||w,T=a(),[I,S]=H.useState(!1),E=(null==t?void 0:t.chainId)?ah.get(t.chainId):null,A=s&&!!E;return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:T.palette.text.primary,typography:A?"body2":"body1",fontWeight:600,px:f,py:x,"&:focus-visible":{opacity:.5}},!!g&&{border:`solid 1px ${T.palette.border.main}`,borderRadius:8,"&:hover":{backgroundColor:T.palette.hover.default}}),!(!y||t)&&{backgroundColor:T.palette.primary.main,color:T.palette.primary.contrastText,"&:hover":{opacity:.8}}),onClick:()=>{r||S(!0)},"data-testid":Ch,children:[!!(null==t?void 0:t.address)&&Yn.jsx(Df,{url:null==t?void 0:t.logoURI,address:null!==(j=null==t?void 0:t.address)&&void 0!==j?j:"",chainId:null==t?void 0:t.chainId,noShowChain:!o,width:l,height:l,chainSize:c,logoOffset:10,marginRight:0}),Yn.jsxs(i,{sx:{flex:1},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(null==t?void 0:t.address)?Yn.jsx(Yn.Fragment,{children:Yn.jsx(i,{children:null!==(C=null==t?void 0:t.symbol)&&void 0!==C?C:"-"})}):Yn.jsx(e,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&Yn.jsx(i,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{flexShrink:0},children:Yn.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"})})]}),!!A&&Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[E.name,Yn.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M5.6036 4.12761C5.50037 4.20906 5.3708 4.24967 5.23958 4.24169C5.10836 4.23372 4.98466 4.17773 4.89203 4.08438C4.7994 3.99103 4.74433 3.86685 4.7373 3.73549C4.73026 3.60413 4.77177 3.47477 4.8539 3.37205L5.96239 2.25211C6.46737 1.76405 7.14372 1.494 7.84575 1.5001C8.54779 1.50621 9.21934 1.78798 9.71577 2.28474C10.2122 2.78151 10.4938 3.4535 10.4999 4.156C10.506 4.85851 10.2361 5.5353 9.74839 6.04062L8.60241 7.16592C8.55441 7.22201 8.49533 7.26757 8.4289 7.29974C8.36246 7.3319 8.29009 7.34997 8.21635 7.35282C8.1426 7.35567 8.06906 7.34324 8.00034 7.3163C7.93162 7.28936 7.86921 7.2485 7.81702 7.19627C7.76483 7.14405 7.724 7.0816 7.69707 7.01284C7.67015 6.94407 7.65772 6.87048 7.66057 6.79668C7.66342 6.72289 7.68148 6.65047 7.71363 6.58399C7.74577 6.51751 7.7913 6.4584 7.84736 6.41036L8.97191 5.28506C9.25568 4.98032 9.41017 4.57725 9.40283 4.16078C9.39549 3.74431 9.22689 3.34695 8.93255 3.05242C8.63821 2.75788 8.24111 2.58917 7.82491 2.58182C7.40872 2.57447 7.00592 2.72906 6.70138 3.01302L5.6036 4.12761ZM6.34259 7.93755C6.38819 7.87582 6.44652 7.82461 6.51361 7.7874C6.58071 7.75018 6.65501 7.72783 6.73149 7.72185C6.80798 7.71586 6.88485 7.7264 6.95691 7.75273C7.02897 7.77906 7.09453 7.82058 7.14917 7.87447C7.2038 7.92836 7.24622 7.99337 7.27356 8.06509C7.3009 8.13682 7.31252 8.21358 7.30764 8.29019C7.30275 8.3668 7.28148 8.44147 7.24525 8.50913C7.20902 8.5768 7.15869 8.63589 7.09765 8.68239L5.96774 9.81305C5.45894 10.2708 4.7943 10.5163 4.11029 10.4992C3.42627 10.482 2.77479 10.2034 2.2896 9.72061C1.80441 9.23784 1.52232 8.58752 1.50127 7.90316C1.48021 7.2188 1.72179 6.55234 2.17638 6.04062L3.30629 4.93139C3.3504 4.86735 3.4079 4.81369 3.47482 4.77413C3.54174 4.73456 3.61646 4.71005 3.69379 4.70229C3.77113 4.69453 3.84922 4.70371 3.92266 4.72919C3.99609 4.75466 4.0631 4.79583 4.11904 4.84983C4.17497 4.90384 4.21849 4.96937 4.24657 5.0419C4.27464 5.11442 4.28661 5.19219 4.28163 5.2698C4.27665 5.34742 4.25484 5.42302 4.21773 5.49135C4.18062 5.55969 4.12908 5.61912 4.06671 5.66552L2.93144 6.79618C2.64767 7.10092 2.49318 7.50398 2.50052 7.92045C2.50786 8.33692 2.67647 8.73428 2.97081 9.02882C3.26515 9.32335 3.66224 9.49207 4.07844 9.49942C4.49463 9.50676 4.89743 9.35217 5.20197 9.06821L6.34259 7.93755ZM5.00919 7.76072C4.96119 7.81681 4.90211 7.86237 4.83567 7.89454C4.76924 7.9267 4.69687 7.94477 4.62312 7.94763C4.54937 7.95048 4.47583 7.93804 4.40711 7.9111C4.33839 7.88416 4.27598 7.8433 4.2238 7.79108C4.17161 7.73885 4.13077 7.6764 4.10385 7.60764C4.07693 7.53887 4.0645 7.46528 4.06735 7.39149C4.0702 7.31769 4.08826 7.24528 4.1204 7.17879C4.15255 7.11231 4.19808 7.0532 4.25413 7.00516L6.90487 4.35267C7.00731 4.26488 7.13909 4.21901 7.27386 4.22422C7.40863 4.22943 7.53648 4.28533 7.63185 4.38077C7.72722 4.4762 7.78309 4.60413 7.7883 4.73899C7.7935 4.87385 7.74766 5.00572 7.65993 5.10823L5.00919 7.76072Z",fill:"currentColor"})})]})]})]}),Yn.jsx(Xb,{value:t,open:I,side:u,chainId:k,occupiedAddrs:p?[p.address]:void 0,occupiedChainId:null==p?void 0:p.chainId,defaultLoadBalance:h,onClose:()=>{S(!1),v&&v()},onTokenChange:(e,t)=>{S(!1),setTimeout((()=>{!Array.isArray(e)&&b&&b(e,t)}),Sf)},modal:!m})]})}function kR({title:e,disabled:t,children:n}){return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:12,opacity:t?.3:void 0},children:[Yn.jsx(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:600},children:e}),n]})}!function(e){e[e.depth=1]="depth",e[e.volume=2]="volume",e[e.feeRevenue=3]="feeRevenue",e[e.traders=4]="traders"}(JL||(JL={})),function(e){e[e.parameters=1]="parameters",e[e.swaps=2]="swaps",e[e.liquidityProviders=3]="liquidityProviders"}(eR||(eR={}));const TR=1e-4;function IR({disabled:t,fee:n,onChange:o,feeList:r,hasCustom:s}){const l=a(),[c,u]=H.useState(!1),[p,h]=H.useState(!1),[m,g]=H.useState(""),{isMobile:f}=Tg(),x=!r.includes(n),y=x||p,v=!p&&x&&!!m&&new Pe(m).div(100).lt(TR),j=t||v;return Yn.jsxs(i,{sx:{opacity:t?.3:void 0,fontWeight:600},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main"},children:[Yn.jsx(e,{id:"tMMG40",message:"{0}% fee tier",values:{0:n?new Pe(n).times(100).toString():"-"}}),Yn.jsx(d,{sx:{px:16,py:7,border:`solid 1px ${l.palette.text.primary}`,borderRadius:8,fontWeight:600,color:"text.primary",cursor:j?"default":"pointer",opacity:v?.3:1},disabled:j,onClick:()=>{j||u((e=>!e))},children:c?Yn.jsx(e,{id:"vLyv1R",message:"Hide"}):Yn.jsx(e,{id:"ePK91l",message:"Edit"})})]}),c&&Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign({mt:12},f?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8,"& > label":{flex:1}}),children:[r.map((e=>{const t=n===e&&!y;return Yn.jsxs(i,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer"},t&&{color:l.palette.primary.main,borderColor:l.palette.primary.main}),children:[100*e,"%",Yn.jsx(U,{size:18,checked:t,onChange:(t,n)=>{n&&o(e)}})]},e)})),s&&Yn.jsxs(i,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,borderStyle:"solid",borderColor:"border.main",cursor:"pointer",color:v?l.palette.error.main:"text.primary"},y&&{color:l.palette.primary.main,borderColor:l.palette.primary.main}),onClick:()=>{h(!0),g("")},children:[p?Yn.jsx(b,{value:m,autoFocus:!0,onChange:e=>{const t=e.target.value;isNaN(Number(t))||g(t)},onBlur:()=>{const e=Number(m),t=e?new Pe(e).div(100).toNumber():e;t&&t<TR?o(0):m&&(e||0===e)&&o(t),h(!1)},sx:{p:0,flex:1,height:"100%",border:"none",backgroundColor:"none"},inputSx:{p:0}}):Yn.jsx(Yn.Fragment,{children:x?(new Pe(n).times(100).toNumber()||m)+"%":Yn.jsx(e,{id:"8Tg/JR",message:"Custom"})}),Yn.jsx(U,{size:18,checked:y,sx:{flexShrink:0}})]})]}),v&&Yn.jsxs(i,{sx:{mt:12,display:"flex",alignItems:"center",gap:8,p:8,borderRadius:8,typography:"h6",backgroundColor:T(l.palette.error.main,.1),color:l.palette.error.main},children:[Yn.jsx(i,{component:li.ErrorBorder,sx:{width:18,height:18}}),Yn.jsx(e,{id:"LHxwaD",message:"The fee tier should greater than {0}%",values:{0:100*TR}})]})]})]})}function SR({isExists:t,pair:n,pairAddress:o}){var a,s,d;const{isBalanceLoading:c,isDepositedLoading:u,balance:p,token0Deposited:h,token1Deposited:m,poolTokenPercentage:g}=function({pairAddress:e,pair:t}){var n;const{account:i}=dg(),o=null===(n=null==t?void 0:t.liquidityToken)||void 0===n?void 0:n.chainId,r=et(Object.assign(Object.assign({},kt(o,e,i)),{retry:!1})),a=et(Object.assign(Object.assign({},Tt(o,e)),{retry:!1})),[s,l,d]=H.useMemo((()=>{if(!t||!r.data||!a.data||a.data<r.data)return[void 0,void 0,void 0];const e=En.fromRawAmount(t.liquidityToken,a.data.toString()),n=En.fromRawAmount(t.liquidityToken,r.data.toString());return[new On(r.data.toString(),a.data.toString()),t.getLiquidityValue(t.token0,e,n,!1),t.getLiquidityValue(t.token1,e,n,!1)]}),[r.data,a.data,t]);return{isBalanceLoading:r.isLoading,isDepositedLoading:r.isLoading||a.isLoading,balance:r.data&&t?_m(r.data.toString(),t.liquidityToken.decimals):void 0,poolTokenPercentage:s?new Pe(s.toSignificant(6)):void 0,token0Deposited:l?new Pe(l.toSignificant()):void 0,token1Deposited:d?new Pe(d.toSignificant()):void 0}}({pairAddress:o,pair:n}),f=g?`${Em({input:g,showDecimals:2,roundingMode:Pe.ROUND_HALF_UP})}%`:void 0;return t&&n?Yn.jsxs(i,{sx:{px:20,py:12,borderWidth:1,borderRadius:8,borderStyle:"solid",borderColor:"border.main"},children:[Yn.jsx(i,{sx:{typography:"h6",color:"text.secondary"},children:Yn.jsx(e,{id:"YHc3B+",message:"My Liquidity"})}),Yn.jsxs(i,{sx:{mt:12,display:"flex",alignItems:"center"},children:[Yn.jsx(kj,{width:18,height:18,tokens:[n.token0,n.token1],mr:4}),Yn.jsx(v,{loading:c,loadingProps:{width:50},sx:{mr:4},children:Am({input:p,decimals:null===(a=n.liquidityToken)||void 0===a?void 0:a.decimals})}),`${n.token0.symbol}/${n.token1.symbol} LP`,Yn.jsx(l,{title:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:10,typography:"body2",color:"text.primary"},children:[Yn.jsx(vI,{address:n.token0.address,chainId:n.token0.chainId,showName:null!==(s=n.token0.symbol)&&void 0!==s?s:"",size:14,offset:4,rightContent:Yn.jsx(v,{loading:u,loadingProps:{width:50},children:Am({input:h,decimals:n.token0.decimals})})}),Yn.jsx(vI,{address:n.token1.address,chainId:n.token1.chainId,showName:null!==(d=n.token1.symbol)&&void 0!==d?d:"",size:14,offset:4,rightContent:Yn.jsx(v,{loading:u,loadingProps:{width:50},children:Am({input:m,decimals:n.token1.decimals})})}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsx(e,{id:"c4miqE",message:"Pool share"}),Yn.jsx(v,{loading:u,loadingProps:{width:50},children:f})]})]}),sx:{padding:20,width:256},children:Yn.jsx(r,{component:li.DetailBorder,sx:{ml:4,width:16,height:16,cursor:"pointer"}})}),Yn.jsx(i,{component:"a",target:"_blank",rel:"noopener noreferrer",href:tg(n.liquidityToken.chainId,n.liquidityToken.address,"address"),sx:{ml:4,display:"inline-flex",height:16},children:Yn.jsx(r,{component:li.ArrowTopRightBorder,sx:{width:16,height:16}})})]})]}):null}function ER({sx:t,disabled:n,slippage:o,onChangeSlippage:r}){const s=a(),d=o===Jj,[c,u]=z(d?"":new Pe(o).times(100).toNumber());return Yn.jsx(l,{disabled:n,onlyClick:!0,title:Yn.jsxs(i,{sx:{backgroundColor:s.palette.background.paper,padding:s.spacing(16,20),borderRadius:16,width:375,maxWidth:"90vw",boxSizing:"border-box"},children:[Yn.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.primary"},children:[Yn.jsx("span",{children:Yn.jsx(e,{id:"lqTDfd",message:"Slippage Tolerance"})}),Yn.jsxs("span",{children:[d?tC:o&&new Pe(o).times(100).toNumber(),"%"]})]}),Yn.jsxs(i,{sx:{mt:16,display:"flex",alignItems:"center",margin:s.spacing(16,0,0,0)},children:[Yn.jsx(Xj,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{u(""),r(Jj)},active:d}),Yn.jsx(b,{placeholder:String(tC),value:c,onChange:e=>{const{value:t}=e.target;u(t),r(t?new Pe(t).div(100).toNumber():Jj)},onBlur:()=>{(!d&&new Pe(o).gt(.1)||new Pe(o).lte(0))&&(u(10),r(.1))},suffix:Yn.jsx(i,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:Yn.jsx(_,{sx:Object.assign({width:"max-content",alignItems:"right",margin:s.spacing(0,0,0,"auto"),p:s.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast",cursor:"pointer"},t),children:Yn.jsx(i,{component:li.Setting,sx:{width:18,height:18,"& path:last-child":{fill:s.palette.text.primary}}})})})}function AR(){var t,n,o;const r=a(),[s,l]=H.useState(.003),[d,u]=H.useState(),[p,h]=H.useState(),[m,g]=H.useState(""),[f,x]=H.useState(""),[y,v]=H.useState(Jj),b=y===Jj?new Pe(tC).div(100).toNumber():y,{isMobile:j}=Tg(),{onlyChainId:C}=Jn(),w=H.useMemo((()=>C||(null==d?void 0:d.chainId)||(null==p?void 0:p.chainId)),[C,d,p]),{pairAddress:k,pair:T,price:I,isInvalidPair:S,invertedPrice:E,priceLoading:A,liquidityMinted:O,shareOfPool:L,isExists:R}=function({baseToken:e,quoteToken:t,baseAmount:n,quoteAmount:i,fee:o}){const[r,a,s]=H.useMemo((()=>{var n,i;if(!e||!t)return[null,null,!1];const o=we[e.chainId],r=(null===(n=o.address)||void 0===n?void 0:n.toLowerCase())===e.address.toLowerCase(),a=(null===(i=o.address)||void 0===i?void 0:i.toLowerCase())===t.address.toLowerCase(),s=r?o.wrappedTokenAddress:e.address,l=a?o.wrappedTokenAddress:t.address,d=s.toLowerCase()===l.toLowerCase();return d?[null,null,!0]:[new Sn(e.chainId,s,e.decimals,e.symbol,e.name),new Sn(t.chainId,l,t.decimals,t.symbol,t.name),d]}),[e,t]),l=H.useMemo((()=>{if(!r||!a||void 0===o)return;const e=r.chainId,t=e?lt(e)||wt(e):void 0;return t?ng({factoryAddress:t,tokenA:r,tokenB:a,fee:o}):void 0}),[r,a,o]),{pair:d,price:c,invertedPrice:u,reserveQuery:p,liquidityMinted:h,shareOfPool:m,isExists:g}=tS({pool:e&&t&&l?{baseToken:e,quoteToken:t,type:"AMMV2",address:l}:void 0,baseAmount:n,quoteAmount:i});return{pairAddress:l,pair:d,isInvalidPair:s,price:c,invertedPrice:u,priceLoading:p.isLoading,liquidityMinted:h,shareOfPool:m,isExists:g}}({baseToken:d,quoteToken:p,baseAmount:m,quoteAmount:f,fee:s}),P=wC(I);if(I&&m&&!I.isEqualTo(null!=P?P:0)&&R){const e=I.times(m).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18);e.isEqualTo(f)||x(e.toString())}const _=w?dt(w)||mt(w):void 0,M=lf(d,{amount:m,contractAddress:_}),B=lf(p,{amount:f,contractAddress:_}),[D,N]=H.useState(!1),F=!d||!p,U=QI({baseToken:d,quoteToken:p,baseAmount:m,quoteAmount:f,fee:s,isExists:R,slippage:b,successBack:()=>{Gj.getState().push({type:Zj.Pool,params:{tab:qS.myLiquidity}})}});return Q((()=>{console.error("createMutation.error",U.error)}),[U.error]),Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[r.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[Yn.jsx(XS,{onClick:()=>{Gj.getState().push({type:Zj.Pool})}}),Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:Yn.jsx(e,{id:"E6MqGy",message:"Add liquidity"})}),Yn.jsx(cT,{poolType:"AMM V2"})]}),Yn.jsxs(i,{sx:{pt:20,px:16,position:"relative",overflow:"hidden",backgroundColor:r.palette.background.paper,borderRadius:16,[r.breakpoints.up("tablet")]:{borderWidth:1,borderStyle:"solid",borderColor:"border.main",px:0,mx:"auto",width:600}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:20,[r.breakpoints.up("tablet")]:{pt:20,px:20,pb:20}},children:[Yn.jsx(SR,{pair:T,pairAddress:k,isExists:R}),Yn.jsxs(kR,{title:Yn.jsx(e,{id:"nxRg31",message:"Select pair"}),children:[Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:j?"repeat(1, 1fr)":"repeat(2, 1fr)",gap:12},children:[Yn.jsx(wR,{border:!0,highlightDefault:!0,chainId:w,token:d,onTokenChange:(e,t)=>{t?(u(p),h(d),g(""),x("")):(u(e),g(""))},occupiedToken:p}),Yn.jsx(wR,{border:!0,highlightDefault:!0,chainId:w,token:p,onTokenChange:(e,t)=>{t?(u(p),h(d)):(h(e),x(""))},occupiedToken:d})]}),(!w||Km(w))&&Yn.jsx(IR,{fee:s,onChange:l,feeList:[1e-4,5e-4,.003],hasCustom:!0,disabled:F})]}),Yn.jsx(kR,{title:Yn.jsx(e,{id:"MU9s7M",message:"Deposit amounts"}),disabled:F,children:Yn.jsxs(i,{children:[Yn.jsx(hj,{sx:{mb:4,pb:28,minHeight:"auto",backgroundColor:"background.cardInput",padding:r.spacing(20,20,28)},inputSx:{backgroundColor:"background.cardInput"},token:d,amt:m,defaultLoadBalance:!0,onInputChange:e=>{var t;g(e);const n=Number(e);R&&I&&n&&x(I.times(e).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(n=null==p?void 0:p.address)&&void 0!==n?n:""],occupiedChainId:null==p?void 0:p.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:F}),Yn.jsx(uj,{}),Yn.jsx(hj,{sx:{pb:20,minHeight:"auto",backgroundColor:"background.cardInput",padding:r.spacing(20,20,20)},inputSx:{backgroundColor:"background.cardInput"},token:p,amt:f,defaultLoadBalance:!0,onInputChange:e=>{var t;x(e);const n=Number(e);R&&E&&n&&g(E.times(e).dp(null!==(t=null==d?void 0:d.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(o=null==d?void 0:d.address)&&void 0!==o?o:""],occupiedChainId:null==d?void 0:d.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:F}),Yn.jsx(ER,{slippage:y,onChangeSlippage:v,disabled:F,sx:{mt:8}}),Yn.jsx(VI,{baseToken:d,quoteToken:p,loading:A,midPrice:I,shareOfPool:L}),!!R&&Yn.jsxs(i,{sx:{mt:20,p:20,borderRadius:16,backgroundColor:"background.paperContrast",typography:"h6",textAlign:"center","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",Yn.jsx("b",{children:Yn.jsx(e,{id:"e38JNU",message:"Tips:"})})," ",Yn.jsx(e,{id:"1ABiXc",message:"By adding liquidity you’ll earn <0>{0}</0> of all trades on this pair proportional to your share of the pool. Fees are added to the pool, accrue in real time and can be claimed by withdrawing your liquidity.",values:{0:Vm({input:s})},components:{0:Yn.jsx("b",{})}})]})]})})]}),Yn.jsx(i,{sx:{mt:20,py:16,[r.breakpoints.up("tablet")]:{px:20}},children:Yn.jsx(cC,{fullWidth:!0,includeButton:!0,size:c.Size.big,disabled:F,chainId:w,children:Yn.jsx(CR,{statuses:[M,B],buttonProps:{size:c.Size.big},children:Yn.jsx(c,{fullWidth:!0,size:c.Size.big,disabled:!(d&&p&&m&&f&&!S&&s),onClick:()=>N(!0),children:S?Yn.jsx(e,{id:"R7D79P",message:"Invalid pair"}):Yn.jsx(e,{id:"bwSQI0",message:"Supply"})})})})}),Yn.jsx(WI,{open:D,onClose:()=>N(!1),slippage:b,baseToken:d,baseAmount:m,quoteToken:p,quoteAmount:f,fee:s,price:I,lpAmount:O,shareOfPool:L,pairAddress:k,createMutation:U})]})]})}const OR=({disabled:e,feeAmount:t,dispatch:n})=>{const o=a(),{isMobile:r}=Tg(),[s,l]=z(!1);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderStyle:"solid",borderColor:o.palette.border.main,borderRadius:12},e?{opacity:.3}:void 0),children:[Yn.jsx(i,{sx:{typography:"h5",color:o.palette.text.primary},children:t?`${dT[t].label} ${se._({id:"fxRyGG",message:"fee tier"})}`:se._({id:"EU3wU4",message:"Fee tier"})}),Yn.jsx(c,{size:c.Size.small,variant:c.Variant.outlined,disabled:e,onClick:()=>l((e=>!e)),sx:{color:o.palette.text.primary,border:`solid 1px ${o.palette.text.primary}`},children:s?se._({id:"vLyv1R",message:"Hide"}):se._({id:"ePK91l",message:"Edit"})})]}),s&&Yn.jsx(i,{sx:Object.assign({},r?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8}),children:[XC.LOWEST,XC.LOW,XC.MEDIUM,XC.HIGH].map((i=>{const r=t===i;return Yn.jsxs(c,{size:c.Size.middle,variant:c.Variant.outlined,disabled:e,onClick:()=>{n({type:ET.UpdateFeeAmount,payload:i})},sx:{flexBasis:"50%",flexShrink:1,flexGrow:1,justifyContent:"space-between",px:20,color:r?o.palette.primary.main:o.palette.text.primary,borderRadius:12,borderColor:r?o.palette.primary.main:o.palette.border.main,[o.breakpoints.up("tablet")]:{flexBasis:"25%"}},children:[dT[i].label,r?Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[Yn.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:o.palette.primary.main}),Yn.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:o.palette.primary.main,stroke:o.palette.primary.main})]}):Yn.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:Yn.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:o.palette.text.secondary})})]},i)}))})]})},LR={neutral1:"#222222",neutral2:"#7D7D7D",accent1:"#FC72FF",critical:"FF5F52",white:"#FFFFFF",surface3:"#22222212",opacity:{hover:.6,click:.4,disabled:.5,enabled:1}},RR=({series:e,xScale:t,yScale:n,xValue:o,yValue:r,fill:a})=>$((()=>{var s;return Yn.jsx(i,{component:"path",opacity:.5,stroke:null!=a?a:LR.accent1,fill:null!=a?a:LR.accent1,d:null!==(s=Rn().curve(Pn).x((e=>t(o(e)))).y1((e=>n(r(e)))).y0(n(0))(e.filter((e=>{const n=t(o(e));return n>0&&n<=window.innerWidth}))))&&void 0!==s?s:void 0})}),[a,e,t,o,n,r]),PR=({axisGenerator:e})=>Yn.jsx("g",{ref:t=>{t&&Mn(t).call(e).call((e=>e.select(".domain").remove()))}}),_R=({xScale:e,innerHeight:t,offset:n=0})=>$((()=>Yn.jsx(i,{component:"g",transform:`translate(0, ${t+n})`,sx:{"& line":{display:"none"},"& text":{color:LR.neutral2,transform:"translateY(5px)"}},children:Yn.jsx(PR,{axisGenerator:_n(e).ticks(6)})})),[t,n,e]),MR=e=>["M 0 0",`v ${e}`,"m 1 0","V 0","M 0 1","h 12","q 2 0, 2 2","v 22","q 0 2 -2 2","h -12","z"].join(" "),BR=()=>["m 5 7","v 14","M 0 0","m 9 7","v 14","z"].join(" "),DR=({color:e,size:t=10,margin:n=10})=>Yn.jsx("polygon",{points:`0 0, ${t} ${t}, 0 ${t}`,transform:` translate(${t+n}, ${n}) rotate(45) `,fill:e,stroke:e,strokeWidth:"4",strokeLinejoin:"round"});const NR=({color:e,d:t})=>Yn.jsx(i,{component:"path",cursor:"ew-resize",pointerEvents:"none",strokeWidth:3,stroke:e,fill:e,d:t}),FR=({d:e})=>Yn.jsx(i,{component:"path",cursor:"ew-resize",pointerEvents:"none",stroke:LR.white,opacity:LR.opacity.hover,d:e}),UR=({visible:e,transform:t,children:n})=>Yn.jsx(i,{component:"g",opacity:e?"1":"0",transform:t,sx:{transition:"opacity 300ms"},children:n}),qR=({y:e,x:t,height:n,width:o,rx:r})=>Yn.jsx(i,{component:"rect",fill:LR.surface3,y:e,x:t,height:n,width:o,rx:r}),VR=({y:e,transform:t,dominantBaseline:n,children:o})=>Yn.jsx(i,{component:"text",y:e,textAnchor:"middle",fontSize:"13px",fill:LR.neutral1,transform:t,dominantBaseline:n,children:o}),WR=(e,t,n)=>{const i=e.map((e=>n(e).toFixed(1))),o=t.map((e=>n(e).toFixed(1)));return i.every(((e,t)=>e===o[t]))},HR=({id:e,xScale:t,interactive:n,brushLabelValue:i,brushExtent:o,setBrushExtent:r,innerWidth:a,innerHeight:s,westHandleColor:l,eastHandleColor:d})=>{const c=G(null),u=G(null),[p,h]=z(o),[m,g]=z(!1),[f,x]=z(!1),y=function(e){const t=G();return Q((()=>{t.current=e}),[e]),t.current}(o),v=Z((e=>{const{type:n,selection:i,mode:a}=e;if(!i)return void h(null);const s=i.map(t.invert);"end"!==n||WR(o,s,t)||r(s,a),h(s)}),[t,o,r]);Q((()=>{h(o)}),[o]),Q((()=>{c.current&&(u.current=Bn().extent([[Math.max(2,t(0)),0],[a-2,s]]).handleSize(30).filter((()=>n)).on("brush end",v),u.current(Mn(c.current)),y&&WR(o,y,t)&&Mn(c.current).transition().call(u.current.move,o.map(t)),Mn(c.current).selectAll(".selection").attr("stroke","none").attr("fill-opacity","0.1").attr("fill",`url(#${e}-gradient-selection)`))}),[o,v,e,s,a,n,y,t]),Q((()=>{c.current&&u.current&&u.current.move(Mn(c.current),o.map(t))}),[o,t]),Q((()=>{g(!0);const e=setTimeout((()=>g(!1)),1500);return()=>clearTimeout(e)}),[p]);const b=p&&t(p[0])>20,j=p&&t(p[1])>a-20,C=p&&(t(p[0])<0||t(p[1])<0),w=p&&(t(p[0])>a||t(p[1])>a),k=p&&t(p[0])>=0&&t(p[0])<=a,T=p&&t(p[1])>=0&&t(p[1])<=a;return $((()=>Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs("defs",{children:[Yn.jsxs("linearGradient",{id:`${e}-gradient-selection`,x1:"0%",y1:"100%",x2:"100%",y2:"100%",children:[Yn.jsx("stop",{stopColor:l}),Yn.jsx("stop",{stopColor:d,offset:"1"})]}),Yn.jsx("clipPath",{id:`${e}-brush-clip`,children:Yn.jsx("rect",{x:"0",y:"0",width:a,height:s})})]}),Yn.jsx("g",{ref:c,clipPath:`url(#${e}-brush-clip)`,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1)}),p&&Yn.jsxs(Yn.Fragment,{children:[k?Yn.jsxs("g",{transform:`translate(${Math.max(0,t(p[0]))}, 0), scale(${b?"-1":"1"}, 1)`,children:[Yn.jsxs("g",{children:[Yn.jsx(NR,{color:l,d:MR(s)}),Yn.jsx(FR,{d:BR()})]}),Yn.jsxs(UR,{transform:`translate(50,0), scale(${b?"1":"-1"}, 1)`,visible:m||f,children:[Yn.jsx(qR,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),Yn.jsx(VR,{transform:"scale(-1, 1)",y:"15",dominantBaseline:"middle",children:i("w",p[0])})]})]}):null,T?Yn.jsxs("g",{transform:`translate(${t(p[1])}, 0), scale(${j?"-1":"1"}, 1)`,children:[Yn.jsxs("g",{children:[Yn.jsx(NR,{color:d,d:MR(s)}),Yn.jsx(FR,{d:BR()})]}),Yn.jsxs(UR,{transform:`translate(50,0), scale(${j?"-1":"1"}, 1)`,visible:m||f,children:[Yn.jsx(qR,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),Yn.jsx(VR,{y:"15",dominantBaseline:"middle",children:i("e",p[1])})]})]}):null,C&&Yn.jsx(DR,{color:l}),w&&Yn.jsx("g",{transform:`translate(${a}, 0) scale(-1, 1)`,children:Yn.jsx(DR,{color:d})})]})]})),[i,d,T,j,b,f,e,s,a,p,w,m,C,l,k,t])},$R=({value:e,xScale:t,innerHeight:n})=>$((()=>Yn.jsx(i,{component:"line",x1:t(e),y1:"0",x2:t(e),y2:n,sx:{opacity:.5,strokeWidth:2,stroke:LR.neutral1,fill:"none"}})),[e,t,n]);function zR({svg:e,xScale:t,setZoom:n,width:o,height:r,resetBrush:a,showResetButton:s,zoomLevels:l}){const d=G(),[u,p,h,m]=$((()=>[()=>e&&d.current&&Mn(e).transition().call(d.current.scaleBy,2),()=>e&&d.current&&Mn(e).transition().call(d.current.scaleBy,.5),()=>e&&d.current&&Mn(e).transition().call(d.current.scaleTo,.5),()=>e&&d.current&&Mn(e).call(d.current.transform,Dn.translate(0,0).scale(1)).transition().call(d.current.scaleTo,.5)]),[e]);return Q((()=>{e&&(d.current=Nn().scaleExtent([l.min,l.max]).extent([[0,0],[o,r]]).on("zoom",(({transform:e})=>n(e))),Mn(e).call(d.current))}),[r,o,n,e,t,d,l,l.max,l.min]),Q((()=>{h()}),[h,l]),Yn.jsxs(i,{sx:{display:"grid",gridTemplateColumns:`repeat(${s?3:2}, 1fr)`,gridGap:"6px",position:"absolute",top:"-32px",right:0},children:[s&&Yn.jsx(c,{size:c.Size.small,sx:{borderRadius:16},onClick:()=>{a(),m()},disabled:!1,children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("polyline",{points:"1 4 1 10 7 10"}),Yn.jsx("polyline",{points:"23 20 23 14 17 14"}),Yn.jsx("path",{d:"M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"})]})}),Yn.jsx(c,{size:c.Size.small,sx:{borderRadius:16},onClick:u,disabled:!1,children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("circle",{cx:"11",cy:"11",r:"8"}),Yn.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Yn.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),Yn.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),Yn.jsx(c,{size:c.Size.small,sx:{borderRadius:16},onClick:p,disabled:!1,children:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("circle",{cx:"11",cy:"11",r:"8"}),Yn.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),Yn.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]})}const ZR=e=>e.price0,GR=e=>e.activeLiquidity;function QR({id:e="liquidityChartRangeInput",data:{series:t,current:n},ticksAtLimit:o,styles:r,dimensions:{width:a,height:s},margins:l,interactive:d=!0,brushDomain:c,brushLabels:u,onBrushDomainChange:p,zoomLevels:h}){const m=G(null),[g,f]=z(null),[x,y]=$((()=>[s-l.top-l.bottom,a-l.left-l.right]),[a,s,l]),{xScale:v,yScale:b}=$((()=>{const e={xScale:Fn().domain([n*h.initialMin,n*h.initialMax]).range([0,y]),yScale:Fn().domain([0,Un(t,GR)]).range([x,0])};if(g){const t=g.rescaleX(e.xScale);e.xScale.domain(t.domain())}return e}),[n,h.initialMin,h.initialMax,y,t,x,g]);return Q((()=>{f(null)}),[h]),Q((()=>{c||p(v.domain(),void 0)}),[c,p,v]),Yn.jsxs(Yn.Fragment,{children:[Yn.jsx(zR,{svg:m.current,xScale:v,setZoom:f,width:y,height:s,resetBrush:()=>{p([n*h.initialMin,n*h.initialMax],"reset")},showResetButton:Boolean(o[dC.LOWER]||o[dC.UPPER]),zoomLevels:h}),Yn.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${a} ${s}`,style:{overflow:"visible"},children:[Yn.jsxs("defs",{children:[Yn.jsx("clipPath",{id:`${e}-chart-clip`,children:Yn.jsx("rect",{x:"0",y:"0",width:y,height:s})}),c&&Yn.jsx("mask",{id:`${e}-chart-area-mask`,children:Yn.jsx("rect",{fill:"white",x:v(c[0]),y:"0",width:v(c[1])-v(c[0]),height:x})})]}),Yn.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[Yn.jsxs("g",{clipPath:`url(#${e}-chart-clip)`,children:[Yn.jsx(RR,{series:t,xScale:v,yScale:b,xValue:ZR,yValue:GR}),c&&Yn.jsx("g",{mask:`url(#${e}-chart-area-mask)`,children:Yn.jsx(RR,{series:t,xScale:v,yScale:b,xValue:ZR,yValue:GR,fill:r.area.selection})}),Yn.jsx($R,{value:n,xScale:v,innerHeight:x}),Yn.jsx(_R,{xScale:v,innerHeight:x})]}),Yn.jsx(i,{component:"rect",width:y,height:s,ref:m,sx:{fill:"transparent",cursor:"grab","&:active":{cursor:"grabbing"}}}),Yn.jsx(HR,{id:e,xScale:v,interactive:d,brushLabelValue:u,brushExtent:null!=c?c:v.domain(),innerWidth:y,innerHeight:x,setBrushExtent:p,westHandleColor:r.brush.handle.west,eastHandleColor:r.brush.handle.east})]})]})]})}const YR=8;function KR(e,t,n,i,o,r){var a,s,l,d,c;let u=Object.assign({},n),p=[];for(let n=o+(r?1:-1);r?n<i.length:n>=0;r?n++:n--){const o=Number(null===(a=i[n])||void 0===a?void 0:a.tickIdx),h=Dk(e,t,o),m={liquidityActive:u.liquidityActive,tick:o,liquidityNet:wn.BigInt(null!==(l=null===(s=i[n])||void 0===s?void 0:s.liquidityNet)&&void 0!==l?l:""),price0:h.toFixed(YR),sdkPrice:h};r?m.liquidityActive=wn.add(u.liquidityActive,wn.BigInt(null!==(c=null===(d=i[n])||void 0===d?void 0:d.liquidityNet)&&void 0!==c?c:0)):!r&&wn.notEqual(u.liquidityNet,wn.BigInt(0))&&(m.liquidityActive=wn.subtract(u.liquidityActive,u.liquidityNet)),p.push(m),u=m}return r||(p=p.reverse()),p}const XR=8,JR=(e,t)=>e&&t?Math.floor(e/JC[t])*JC[t]:void 0,eP=1e3;function tP(e,t,n,i){const[o,r]=z(0),[a,s]=z([]),{data:l,error:d,isLoading:c}=function(e,t,n,i=0,o){var r;const a=gg(),s=e&&t&&n?Vk.getAddress(null==e?void 0:e.wrapped,null==t?void 0:t.wrapped,n,void 0,o?SC[o]:void 0):void 0,l=a.getQuery(ve.graphql.AllV3TicksDocument,{skip:i,first:eP,where:{chain:o?Wu[o]:void 0,poolAddress:null!==(r=null==s?void 0:s.toLowerCase())&&void 0!==r?r:void 0,refreshNow:!0,schemaName:"ammv3"}});return et(Object.assign(Object.assign({},l),{enabled:!0}))}(e,t,n,o,i),u=null==l?void 0:l.ticks;return Q((()=>{(null==u?void 0:u.length)&&(s((e=>[...e,...u])),(null==u?void 0:u.length)===eP&&r((e=>e+eP)))}),[u]),{isLoading:c||(null==u?void 0:u.length)===eP,error:d,ticks:a}}function nP({currencyA:e,currencyB:t,feeAmount:n,chainId:i}){const{isLoading:o,error:r,data:a}=function(e,t,n,i){var o,r,a;const s=xT(e,t,n),l=null===(o=s[1])||void 0===o?void 0:o.liquidity,d=null===(r=s[1])||void 0===r?void 0:r.sqrtRatioX96,c=null===(a=s[1])||void 0===a?void 0:a.tickCurrent,u=$((()=>JR(c,n)),[c,n]),{isLoading:p,error:h,ticks:m}=tP(e,t,n,i);return $((()=>{var n,i,o,r,a;if(!e||!t||void 0===u||s[0]!==fT.EXISTS||!m||0===m.length||p)return{isLoading:p||s[0]===fT.LOADING,error:h,activeTick:u,data:void 0};const g=null==e?void 0:e.wrapped,f=null==t?void 0:t.wrapped,x=m.findIndex((e=>(null==e?void 0:e.tickIdx)&&e.tickIdx>u))-1;if(x<0)return console.log("usePoolTickData","usePoolActiveLiquidity","TickData pivot not found",{token0:g.address,token1:f.address,chainId:g.chainId}),{isLoading:p,error:h,activeTick:u,data:void 0};const y=Dk(g,f,u),v={liquidityActive:wn.BigInt(null!==(i=null===(n=s[1])||void 0===n?void 0:n.liquidity)&&void 0!==i?i:0),tick:u,liquidityNet:Number(null===(o=m[x])||void 0===o?void 0:o.tickIdx)===u?wn.BigInt(null!==(a=null===(r=m[x])||void 0===r?void 0:r.liquidityNet)&&void 0!==a?a:0):wn.BigInt(0),price0:y.toFixed(XR),sdkPrice:y},b=KR(g,f,v,m,x,!0),j=KR(g,f,v,m,x,!1).concat(v).concat(b);return{isLoading:p,error:h,currentTick:c,activeTick:u,liquidity:l,sqrtPriceX96:d,data:j}}),[e,t,u,s,m,p,h,c,l,d])}(e,t,n,i),s=Z((()=>{if(!(null==a?void 0:a.length))return;const e=[];for(let t=0;t<a.length;t++){const n=a[t],i={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};i.activeLiquidity>0&&e.push(i)}return e}),[a]);return $((()=>({isLoading:o,error:r,formattedData:o?void 0:s()})),[o,r,s])}const iP={initialMin:.999,initialMax:1.001,min:1e-5,max:1.5},oP={[XC.LOWEST]:iP,[XC.LOW_200]:iP,[XC.LOW_300]:iP,[XC.LOW_400]:iP,[XC.LOW]:iP,[XC.MEDIUM]:{initialMin:.5,initialMax:2,min:1e-5,max:20},[XC.HIGH]:{initialMin:.5,initialMax:2,min:1e-5,max:20}};function rP({message:e,icon:t}){return Yn.jsxs(gC,{style:{height:"100%",justifyContent:"center"},children:[t,e&&Yn.jsx(i,{sx:{mt:20,p:10,typography:"caption",textAlign:"center"},children:e})]})}function aP(){return Yn.jsx(v,{})}function sP({chainId:t,currencyA:n,currencyB:o,feeAmount:r,ticksAtLimit:a,price:s,priceLower:l,priceUpper:d,onLeftRangeInput:c,onRightRangeInput:u,interactive:p}){const h=n&&o&&(null==n?void 0:n.wrapped.sortsBefore(null==o?void 0:o.wrapped)),{isLoading:m,error:g,formattedData:f}=nP({currencyA:n,currencyB:o,feeAmount:r,chainId:t}),x=Z(((e,t)=>{let n=Number(e[0]);const i=Number(e[1]);n<=0&&(n=1/10**6),(!a[h?dC.LOWER:dC.UPPER]||"handle"===t||"reset"===t)&&n>0&&c(n.toFixed(6)),(!a[h?dC.UPPER:dC.LOWER]||"reset"===t)&&i>0&&i<1e35&&u(i.toFixed(6))}),[h,c,u,a]);p=p&&Boolean(null==f?void 0:f.length);const y=$((()=>{const e=h?l:null==d?void 0:d.invert(),t=h?d:null==l?void 0:l.invert();return e&&t?[parseFloat(null==e?void 0:e.toSignificant(6)),parseFloat(null==t?void 0:t.toSignificant(6))]:void 0}),[h,l,d]),v=Z(((e,t)=>{if(!s)return"";if("w"===e&&a[h?dC.LOWER:dC.UPPER])return"0";if("e"===e&&a[h?dC.UPPER:dC.LOWER])return"∞";const n=(t<s?-1:1)*((Math.max(t,s)-Math.min(t,s))/s)*100;return s?`${Am({input:n,decimals:2})}%`:""}),[h,s,a]),b=!n||!o||void 0===f&&!m&&!g;return Yn.jsx(fC,{gap:"md",style:{minHeight:"200px"},children:b?Yn.jsx(rP,{message:Yn.jsx(e,{id:"OZUH85",message:"Your position will appear here."}),icon:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:LR.neutral1,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),Yn.jsx("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]})}):m?Yn.jsx(aP,{}):g?Yn.jsx(rP,{message:Yn.jsx(e,{id:"79D0qY",message:"Liquidity data not available."}),icon:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:LR.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("path",{d:"M22.61 16.95A5 5 0 0 0 18 10h-1.26a8 8 0 0 0-7.05-6M5 5a8 8 0 0 0 4 15h9a5 5 0 0 0 1.7-.3"}),Yn.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}):f&&0!==f.length&&s?Yn.jsx(i,{sx:{position:"relative",width:"100%",maxHeight:"200px",justifyContent:"center",alignContent:"center"},children:Yn.jsx(QR,{data:{series:f,current:s},dimensions:{width:560,height:200},margins:{top:10,right:2,bottom:20,left:0},styles:{area:{selection:LR.accent1},brush:{handle:{west:LR.critical,east:LR.accent1}}},interactive:p,brushLabels:v,brushDomain:y,onBrushDomainChange:x,zoomLevels:oP[null!=r?r:XC.MEDIUM],ticksAtLimit:a})}):Yn.jsx(rP,{message:Yn.jsx(e,{id:"rH6vg9",message:"There is no liquidity data."}),icon:Yn.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:LR.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[Yn.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),Yn.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),Yn.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})})})}const lP=({value:t,decrement:n,increment:o,decrementDisabled:r=!1,incrementDisabled:s=!1,locked:l,onUserInput:d,title:u,tokenA:p,tokenB:h})=>{const m=a(),[g,f]=z(!1),[x,y]=z(""),[v,b]=z(!1),[j,C]=z(!1),w=Z((()=>{b(!1),f(!1),d(x)}),[x,d]),k=Z((()=>{b(!1),d(n())}),[n,d]),T=Z((()=>{b(!1),d(o())}),[o,d]);return Q((()=>{x===t||v||setTimeout((()=>{y(t),C(!0),setTimeout((function(){C(!1)}),1800)}),0)}),[x,v,t]),Yn.jsx(i,{onFocus:()=>{b(!0),f(!0)},onBlur:w,sx:{width:"100%",py:12,px:20,borderRadius:16,backgroundColor:m.palette.background.cardInput},children:Yn.jsxs(i,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:m.palette.text.primary},children:u}),Yn.jsx(i,{sx:{mt:4,typography:"h6",fontWeight:500,color:m.palette.text.secondary},children:Yn.jsx(e,{id:"1/LP4K",message:"{tokenB} per {tokenA}",values:{tokenB:h,tokenA:p}})}),Yn.jsx(Db,{sx:{mt:12,backgroundColor:m.palette.background.cardInput},value:x,onChange:e=>{y(e)},readOnly:l})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",gap:8},children:[!l&&Yn.jsx(c,{size:c.Size.small,onClick:T,disabled:s,sx:{px:4,backgroundColor:m.palette.background.paper,"&[disabled]":{cursor:"default"}},children:Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("path",{d:"M14.25 9.75H9.75V14.25H8.25V9.75H3.75V8.25H8.25V3.75H9.75V8.25H14.25V9.75Z",fill:r?m.palette.text.disabled:m.palette.text.primary})})}),!l&&Yn.jsx(c,{size:c.Size.small,onClick:k,disabled:r,sx:{px:4,backgroundColor:m.palette.background.paper,"&[disabled]":{cursor:"default"}},children:Yn.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:Yn.jsx("rect",{x:"3.75",y:"8.25",width:"10.5",height:"1.5",fill:r?m.palette.text.disabled:m.palette.text.primary})})})]})]})})},dP=({priceLower:t,priceUpper:n,onLeftRangeInput:o,onRightRangeInput:r,getDecrementLower:a,getIncrementLower:s,getDecrementUpper:l,getIncrementUpper:d,currencyA:c,currencyB:u,feeAmount:p,ticksAtLimit:h})=>{var m,g,f,x;const y=null===(m=null!=c?c:void 0)||void 0===m?void 0:m.wrapped,v=null===(g=null!=u?u:void 0)||void 0===g?void 0:g.wrapped,b=y&&v&&y.sortsBefore(v),j=b?t:null==n?void 0:n.invert(),C=b?n:null==t?void 0:t.invert();return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[Yn.jsx(lP,{value:h[b?dC.LOWER:dC.UPPER]?"0":null!==(f=null==j?void 0:j.toSignificant(8))&&void 0!==f?f:"",onUserInput:o,decrement:b?a:d,increment:b?s:l,decrementDisabled:void 0===j||h[b?dC.LOWER:dC.UPPER],incrementDisabled:void 0===j||h[b?dC.LOWER:dC.UPPER],feeAmount:p,label:j?`${null==u?void 0:u.symbol}`:"-",title:Yn.jsx(e,{id:"uEoBVI",message:"Low price"}),tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol}),Yn.jsx(lP,{value:h[b?dC.UPPER:dC.LOWER]?"∞":null!==(x=null==C?void 0:C.toSignificant(8))&&void 0!==x?x:"",onUserInput:r,decrement:b?l:s,increment:b?d:a,incrementDisabled:void 0===C||h[b?dC.UPPER:dC.LOWER],decrementDisabled:void 0===C||h[b?dC.UPPER:dC.LOWER],feeAmount:p,label:C?`${null==u?void 0:u.symbol}`:"-",tokenA:null==c?void 0:c.symbol,tokenB:null==u?void 0:u.symbol,title:Yn.jsx(e,{id:"kAC8rT",message:"High price"})})]})};var cP;function uP(){return uP=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},uP.apply(null,arguments)}const pP=e=>W.createElement("svg",uP({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),cP||(cP=W.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},W.createElement("path",{id:"\\xE4\\xB8\\x89\\xE8\\xA7\\x92\\xE5\\xBD\\xA2",fillRule:"evenodd",clipRule:"evenodd",d:"M6.58398 12.376C6.78189 12.6728 7.21811 12.6728 7.41603 12.376L10.4818 7.77735C10.7033 7.44507 10.4651 7 10.0657 7H3.93426C3.53491 7 3.29672 7.44507 3.51823 7.77735L6.58398 12.376Z",fill:"currentColor"}))));function hP({chainId:e,token:t,oppositeTokenAddress:n,dispatch:o,tokenSelectOnChange:r}){const s=a(),[l,c]=z(!1);return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{component:d,sx:{flexBasis:"100%",flexGrow:1,flexShrink:1,display:"flex",alignItems:"center",px:20,py:8,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:t?s.palette.border.main:s.palette.primary.main,color:t?s.palette.text.primary:s.palette.primary.contrastText,backgroundColor:t?"transparent":s.palette.primary.main,"&:hover":{borderColor:t?s.palette.border.main:s.palette.primary.main,opacity:.8},[s.breakpoints.up("tablet")]:{flexBasis:"50%"}},onClick:()=>{c(!0)},children:[t?Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:t.address,marginRight:0,width:24,height:24,chainId:t.chainId||e,noShowChain:!0,sx:{flexShrink:0}}),Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:t.symbol})]}):Yn.jsx(i,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:se._({id:"0RrIzN",message:"Select token"})}),Yn.jsx(i,{component:pP,sx:{flexShrink:0,ml:"auto",width:18,height:18}})]}),Yn.jsx(Xb,{value:wT(t),open:l,chainId:e,occupiedAddrs:[n],occupiedChainId:null==t?void 0:t.chainId,onClose:()=>{c(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return o({type:ET.UpdateBaseTokenAndClearQuoteToken,payload:e}),void c(!1);r(e),c(!1)}},modal:!0})]})}const mP=({chainId:e,baseToken:t,quoteToken:n,dispatch:o})=>{var r,s;const l=a();return Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",[l.breakpoints.up("tablet")]:{flexWrap:"nowrap"}},children:[Yn.jsx(hP,{chainId:e,token:t,oppositeTokenAddress:null!==(r=null==n?void 0:n.address)&&void 0!==r?r:"",dispatch:o,tokenSelectOnChange:e=>{o({type:ET.UpdateBaseToken,payload:e})}}),Yn.jsx(hP,{chainId:e,token:n,oppositeTokenAddress:null!==(s=null==t?void 0:t.address)&&void 0!==s?s:"",dispatch:o,tokenSelectOnChange:e=>{o({type:ET.UpdateQuoteToken,payload:e})}})]})};const gP=[{value:.03,title:"Narrow"},{value:.08,title:"Standard"},{value:.15,title:"Wide"},{value:1,title:"Full"}],fP=e=>{const t=a(),[n,o]=z(null);return Yn.jsx(i,{sx:{borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:t.palette.border.main,overflow:"hidden",display:"flex",alignItems:"center",flexWrap:"wrap",alignSelf:"stretch"},children:gP.map(((r,a)=>Yn.jsxs(i,{component:d,onClick:()=>{o(r.value),e.onSelect(r.value)},sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",px:20,py:12,gap:8,flexBasis:"50%",flexGrow:1,borderRight:a%2==0?`1px solid ${t.palette.border.main}`:"none",borderBottom:a<=1?`1px solid ${t.palette.border.main}`:"none",[t.breakpoints.up("tablet")]:{flexBasis:"25%",borderRight:a===gP.length-1?"none":`1px solid ${t.palette.border.main}`,borderBottom:"none"},backgroundColor:n===r.value?T("#7BF179",.1):"transparent","&:hover":{backgroundColor:T("#7BF179",.1)}},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:t.palette.text.primary},children:r.title}),Yn.jsx(i,{sx:{typography:"h6",fontWeight:600,color:t.palette.text.primary},children:1===r.value?"∞":`+-${100*r.value}%`})]},r.value)))})};function xP({params:t,handleGoBack:n,handleGoToPoolList:o}){var r,s,l,d,c,u,p,h,m,g;const{account:f,onlyChainId:x,defaultChainId:y}=dg(),v=null!=x?x:y,b=a(),j=Fg(),{isMobile:C}=Tg(),w=et(Object.assign({},ip.getFetchTokenQuery(v,null==t?void 0:t.from,f))),k=et(Object.assign({},ip.getFetchTokenQuery(v,null==t?void 0:t.to,f))),[I,S]=ee(AT,{baseToken:null,quoteToken:null,feeAmount:(null==t?void 0:t.fee)?Number(null==t?void 0:t.fee):void 0,independentField:lC.CURRENCY_A,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""});Q((()=>{w.data&&S({type:ET.UpdateDefaultBaseToken,payload:w.data})}),[w]),Q((()=>{k.data&&S({type:ET.UpdateDefaultQuoteToken,payload:k.data})}),[k]);const{independentField:E,typedValue:A,startPriceTypedValue:O}=I,{pool:L,ticks:R,dependentField:P,price:_,pricesAtTicks:M,pricesAtLimit:B,parsedAmounts:D,currencyBalances:N,position:F,noLiquidity:U,currencies:q,errorMessage:V,invalidPool:W,invalidRange:H,outOfRange:G,depositADisabled:Y,depositBDisabled:K,invertPrice:X,ticksAtLimit:J,isTaxed:te}=ST({state:I,chainId:v}),ne=$((()=>{var e;return null===(e=X?null==_?void 0:_.invert():_)||void 0===e?void 0:e.toSignificant()}),[X,_]),{onFieldAInput:ie,onFieldBInput:oe,onLeftRangeInput:re,onRightRangeInput:ae,onStartPriceInput:le}=OT({noLiquidity:U,dispatch:S}),{slipper:de,setSlipper:ce,slipperValue:ue,resetSlipper:pe}=oC({address:void 0,type:"AMMV3"}),he=!V&&!H,[me,ge]=z(!1),fe={[E]:A,[P]:null!==(s=null===(r=D[P])||void 0===r?void 0:r.toSignificant(6))&&void 0!==s?s:""},xe=[lC.CURRENCY_A,lC.CURRENCY_B].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:_T(N[t])})),{}),ye=lf(wT(null===(l=D[lC.CURRENCY_A])||void 0===l?void 0:l.currency),{contractAddress:EC[v],overrideBalance:N[lC.CURRENCY_A]?new Pe(N[lC.CURRENCY_A].toSignificant()):void 0,amount:D[lC.CURRENCY_A]?new Pe(D[lC.CURRENCY_A].toSignificant()):void 0}),ve=lf(wT(null===(d=D[lC.CURRENCY_B])||void 0===d?void 0:d.currency),{contractAddress:EC[v],overrideBalance:N[lC.CURRENCY_B]?new Pe(N[lC.CURRENCY_B].toSignificant()):void 0,amount:D[lC.CURRENCY_B]?new Pe(D[lC.CURRENCY_B].toSignificant()):void 0}),{[dC.LOWER]:be,[dC.UPPER]:je}=R,{[dC.LOWER]:Ce,[dC.UPPER]:we}=M,{getDecrementLower:ke,getIncrementLower:Te,getDecrementUpper:Ie,getIncrementUpper:Se,getSetFullRange:Ee}=function({tickLower:e,tickUpper:t,pool:n,state:i,dispatch:o}){const{baseToken:r,quoteToken:a,feeAmount:s}=i,l=$((()=>null==r?void 0:r.wrapped),[r]),d=$((()=>null==a?void 0:a.wrapped),[a]);return{getDecrementLower:Z((()=>l&&d&&"number"==typeof e&&s?Dk(l,d,e-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof e&&l&&d&&s&&n?Dk(l,d,n.tickCurrent-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,e,s,n]),getIncrementLower:Z((()=>l&&d&&"number"==typeof e&&s?Dk(l,d,e+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof e&&l&&d&&s&&n?Dk(l,d,n.tickCurrent+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,e,s,n]),getDecrementUpper:Z((()=>l&&d&&"number"==typeof t&&s?Dk(l,d,t-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof t&&l&&d&&s&&n?Dk(l,d,n.tickCurrent-JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,t,s,n]),getIncrementUpper:Z((()=>l&&d&&"number"==typeof t&&s?Dk(l,d,t+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):"number"!=typeof t&&l&&d&&s&&n?Dk(l,d,n.tickCurrent+JC[s]).toSignificant(5,void 0,OC.ROUND_UP):""),[l,d,t,s,n]),getSetFullRange:Z((()=>{o({type:ET.setFullRange,payload:void 0})}),[o])}}({tickLower:be,tickUpper:je,pool:L,state:I,dispatch:S}),Ae=Z((e=>{if(Ee(),1!==e){if(ne){const t=new Pe(ne),n=t.multipliedBy(1-e),i=t.multipliedBy(1+e);re(n.dp(5,Pe.ROUND_DOWN).toString()),ae(i.dp(5,Pe.ROUND_DOWN).toString())}return}const t=B[dC.LOWER];t&&re(t.toSignificant(5));const n=B[dC.UPPER];n&&ae(n.toSignificant(5))}),[ne,Ee,re,ae,B]),{deadLine:Oe}=Jn(),Le=it({mutationFn:()=>Vn(this,void 0,void 0,(function*(){if(!f||!v||!F)return;if(!I.baseToken||!I.quoteToken)return;const e=Math.ceil(Date.now()/1e3)+(null!=Oe?Oe:600),t=I.baseToken.isNative?I.baseToken:I.quoteToken.isNative?I.quoteToken:void 0;try{const{calldata:n,value:i}=eT.addCallParameters(F,{slippageTolerance:DT(100*ue),recipient:f,deadline:e.toString(),useNative:t,createPool:U});let r={to:EC[v],data:n,value:i};(yield j.execute(se._({id:"8OiU8L",message:"Pool Creation"}),Object.assign({opcode:Pg.TX},r),{early:!1,metadata:{[Sg.createAMMV3Pool]:"1"}}))===Eg.Success&&setTimeout((()=>{o()}),100)}catch(e){console.error("onAddMutation",e)}}))});return Yn.jsxs(Yn.Fragment,{children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:20,mx:16,pb:20,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:"border.main",mb:20,[b.breakpoints.up("tablet")]:{width:600,mx:"auto"}},children:[Yn.jsx(XS,{}),Yn.jsx(i,{sx:{typography:"caption",fontWeight:600,color:"text.primary",mr:"auto"},children:Yn.jsx(e,{id:"E6MqGy",message:"Add liquidity"})}),Yn.jsx(cT,{poolType:"AMM V3"})]}),Yn.jsxs(i,{sx:{px:16,display:"flex",flexDirection:"column",alignItems:"stretch",backgroundColor:b.palette.background.paper,borderRadius:16,[b.breakpoints.up("tablet")]:{borderColor:b.palette.border.main,borderWidth:1,borderStyle:"solid",px:0,mx:"auto",width:600}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,py:20,[b.breakpoints.up("tablet")]:{px:20}},children:[Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"nxRg31",message:"Select pair"})}),Yn.jsx(mP,{chainId:v,baseToken:I.baseToken,quoteToken:I.quoteToken,dispatch:S}),Yn.jsx(OR,{disabled:!I.baseToken||!I.quoteToken,feeAmount:I.feeAmount,dispatch:S})]}),Yn.jsxs(bC,{disabled:!I.feeAmount||W,children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"5CZbyC",message:"Set price range"})}),Boolean(I.baseToken&&I.quoteToken)&&Yn.jsx(aT,{baseToken:I.baseToken,quoteToken:I.quoteToken,handleRateToggle:()=>{var e,t,n,i,o;J[dC.LOWER]||J[dC.UPPER]||(re(null!==(t=null===(e=X?Ce:null==we?void 0:we.invert())||void 0===e?void 0:e.toSignificant(6))&&void 0!==t?t:""),ae(null!==(i=null===(n=X?we:null==Ce?void 0:Ce.invert())||void 0===n?void 0:n.toSignificant(6))&&void 0!==i?i:""),ie(null!==(o=fe[lC.CURRENCY_B])&&void 0!==o?o:"")),S({type:ET.ToggleRate,payload:void 0})},sx:C?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0})]}),Yn.jsx(fP,{onSelect:Ae}),Yn.jsx(dP,{priceLower:Ce,priceUpper:we,getDecrementLower:ke,getIncrementLower:Te,getDecrementUpper:Ie,getIncrementUpper:Se,onLeftRangeInput:re,onRightRangeInput:ae,currencyA:I.baseToken,currencyB:I.quoteToken,feeAmount:I.feeAmount,ticksAtLimit:J}),G&&Yn.jsx(mC,{children:se._({id:"b+KjnH",message:"Your position will not earn fees or be used in trades until the market price moves into your range."})}),H&&Yn.jsx(mC,{children:se._({id:"Jh223O",message:"Invalid range selected. The min price must be lower than the max price."})})]}),U?Yn.jsxs(bC,{children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"zeSosD",message:"Starting price"})}),Yn.jsx(i,{sx:{p:8,borderRadius:8,backgroundColor:T(b.palette.primary.main,.1),typography:"h6",color:b.palette.primary.main},children:se._({id:"X6T02b",message:"This pool must be initialized before you can add liquidity. To initialize, select a starting price for the pool. Then, enter your liquidity price range and deposit amount. Gas fees will be higher than usual due to the initialization transaction."})}),Yn.jsx(i,{sx:{px:16,py:12,borderRadius:8,borderWidth:1,borderColor:b.palette.border.main,borderStyle:"solid"},children:Yn.jsx(Db,{sx:{backgroundColor:"transparent"},value:O,onChange:le})})]}):Yn.jsxs(bC,{disabled:!I.feeAmount||W,children:[Yn.jsxs(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:[se._({id:"DWd30U",message:"Current price"}),Yn.jsxs(i,{children:[ne," ",se._({id:"b2jAb+",message:"per"})," ",null!==(u=null===(c=I.baseToken)||void 0===c?void 0:c.symbol)&&void 0!==u?u:""]})]}),Yn.jsx(sP,{chainId:v,currencyA:null!==(p=I.baseToken)&&void 0!==p?p:void 0,currencyB:null!==(h=I.quoteToken)&&void 0!==h?h:void 0,feeAmount:I.feeAmount,ticksAtLimit:J,price:_?parseFloat((X?_.invert():_).toSignificant(8)):void 0,priceLower:Ce,priceUpper:we,onLeftRangeInput:re,onRightRangeInput:ae,interactive:!0})]}),Yn.jsxs(bC,{disabled:W||H||U&&!O,children:[Yn.jsx(i,{sx:{typography:"body1",fontWeight:600,color:b.palette.text.primary,textAlign:"left"},children:se._({id:"MU9s7M",message:"Deposit amounts"})}),Yn.jsxs(i,{children:[Yn.jsx(IC,{value:fe[lC.CURRENCY_A],onUserInput:ie,maxAmount:xe[lC.CURRENCY_A],balance:N[lC.CURRENCY_A],currency:null!==(m=q[lC.CURRENCY_A])&&void 0!==m?m:null,locked:Y}),Yn.jsx(uj,{}),Yn.jsx(IC,{value:fe[lC.CURRENCY_B],onUserInput:oe,maxAmount:xe[lC.CURRENCY_B],balance:N[lC.CURRENCY_B],currency:null!==(g=q[lC.CURRENCY_B])&&void 0!==g?g:null,locked:K})]}),Yn.jsx(rC,{value:de,onChange:ce,disabled:!1,type:"AMMV3"})]})]}),Yn.jsx(i,{sx:{display:"flex",alignItems:"center",py:16,[b.breakpoints.up("tablet")]:{px:20,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:b.palette.background.paper}},children:Yn.jsx(jC,{chainId:v,approvalA:ye,approvalB:ve,parsedAmounts:D,isValid:he,depositADisabled:Y,depositBDisabled:K,errorMessage:V,setShowConfirm:ge})}),Yn.jsx(mT,{parsedAmounts:D,position:F,existingPosition:void 0,priceLower:Ce,priceUpper:we,outOfRange:G,ticksAtLimit:J,on:me,onClose:()=>{ge(!1)},onConfirm:Le.mutate,loading:Le.isPending})]})]})}const yP=["#154618","#ED4A25","#0E794D","#F7A33E","#582969","#DFCC28","#294369","#1D1D1D"],vP=({poolDetail:e,tokenBalances:t})=>{const n=a(),o=$((()=>{if(!e)return[];if(!t)return[];const n=t.reduce(((e,t)=>e.plus(t)),new _e(0));return e.coins.map(((e,i)=>({name:e.name,symbol:e.symbol,address:e.address,chainId:e.chainId,decimals:e.decimals,value:t[i].toNumber(),percentage:t[i].div(n).toNumber(),color:yP[i]})))}),[e,t]);return Yn.jsxs(i,{sx:{mt:16,display:"flex",flexDirection:"column",alignItems:"stretch",gap:28,p:20,backgroundColor:n.palette.background.paper,borderRadius:16,[n.breakpoints.up("tablet")]:{flexDirection:"row",alignItems:"center",border:`1px solid ${n.palette.border.main}`,p:0,gap:0}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",justifyContent:"center",[n.breakpoints.up("tablet")]:{minWidth:364,flexDirection:"column",gap:16}},children:[Yn.jsx(bn,{width:88,height:88,children:Yn.jsx(jn,{isAnimationActive:!1,dataKey:"value",data:o,labelLine:!1,label:!1,outerRadius:44,children:o.map(((e,t)=>Yn.jsx(yn,{fill:e.color,strokeWidth:0},`cell-${t}`)))})}),Yn.jsx(i,{sx:{display:"none",[n.breakpoints.up("tablet")]:{display:"flex",alignItems:"center",justifyContent:"center",flexWrap:"wrap",gap:16,maxWidth:172}},children:o.map((e=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),Yn.jsx(i,{sx:{typography:"h6",color:n.palette.text.primary},children:e.symbol})]},e.address)))})]}),Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",gap:16,[n.breakpoints.up("tablet")]:{display:"none"}},children:o.map((e=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(i,{sx:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color}}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary},children:e.symbol}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]}),Yn.jsxs(i,{sx:{ml:"auto",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary,textAlign:"right"},children:Am({input:e.value,decimals:e.decimals})}),Yn.jsxs(i,{sx:{typography:"h6",color:n.palette.text.secondary,textAlign:"right"},children:["(",Vm({input:new _e(e.percentage),showDecimals:2}),")"]})]})]},e.address)))}),Yn.jsxs(i,{sx:{display:"none",[n.breakpoints.up("tablet")]:{flexGrow:1,display:"block",borderLeft:`1px solid ${n.palette.border.main}`}},children:[Yn.jsxs(i,{sx:{borderBottom:`1px solid ${n.palette.border.main}`,typography:"h6",fontWeight:600,color:n.palette.text.secondary,height:48,display:"flex",alignItems:"center"},children:[Yn.jsx(i,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:"Asset"}),Yn.jsx(i,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"Token Amount"}),Yn.jsx(i,{sx:{flexBasis:"150px",flexGrow:1,flexShrink:1,px:20,textAlign:"right"},children:"ratio"})]}),o.map((e=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",height:56},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8,flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:[Yn.jsx(Df,{address:e.address,width:24,height:24,chainId:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary},children:e.symbol}),Yn.jsx(zb,{address:e.address,customChainId:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:12,iconSpace:4,sx:{typography:"h6",color:"text.secondary"}})]})]}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Am({input:e.value,decimals:e.decimals})}),Yn.jsx(i,{sx:{typography:"body2",fontWeight:600,color:n.palette.text.primary,textAlign:"right",flexBasis:"150px",flexGrow:1,flexShrink:1,px:20},children:Vm({input:new _e(e.percentage),showDecimals:2})})]},e.address)))]})]})};function bP(e,t){if(!e)return"";const n=an(e);return n.isValid()?n.format("YYYY/MM/DD HH:mm:ss"):""}function jP({chainId:t,address:n}){var o;const{isMobile:r}=Tg(),s=a(),l=function({chainId:e,address:t}){var n,i;const o=gg().getQuery(Se.graphql.curve_stableswap_ng_getPoolSwapInfo,{where:{chainId:null!=e?e:le.ZETACHAIN,poolAddress:null!=t?t:""}}),r=et(Object.assign(Object.assign({},o),{enabled:!!t&&!!e})),a=null===(i=null===(n=r.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolSwapInfo)||void 0===i?void 0:i.swaps;return Object.assign(Object.assign({},r),{swapList:a})}({address:n,chainId:t}),[c,u]=H.useState(1),p=c*(r?4:8),h=null!==(o=l.swapList)&&void 0!==o?o:[],m=p<h.length,g=h.slice(0,p);return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:l.error?l.refetch:void 0,loading:l.isLoading,empty:!(null==g?void 0:g.length),children:!!(null==g?void 0:g.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"LhMjLm",message:"Time"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"UPXmW+",message:"Trader"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"v4nCHK",message:"Paid"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"fZ5Vnu",message:"Received"})})]})}),Yn.jsx(i,{component:"tbody",children:null==g?void 0:g.map((e=>Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:bP(1e3*e.time)}),Yn.jsx("td",{children:Yn.jsx(zb,{address:e.user,truncate:!0})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.paidToken.id,chainId:t,width:24,height:24,noBorder:!0,noShowChain:!0}),`${Am({input:e.paidAmount,decimals:e.paidToken.decimals})} ${e.paidToken.symbol}`]})}),Yn.jsx("td",{children:Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[Yn.jsx(Df,{address:e.receivedToken.id,chainId:t,width:18,height:18,noBorder:!0,noShowChain:!0}),`${Am({input:e.receivedAmount,decimals:e.receivedToken.decimals})} ${e.receivedToken.symbol}`]})})]},e.id)))})]})}),m&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:s.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>u((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})}const CP=({chainId:t,address:n})=>{var o,r;const{isMobile:s}=Tg(),l=a(),c=function({chainId:e,address:t}){var n,i;const o=gg(),r=et(Object.assign(Object.assign({},o.getQuery(Se.graphql.curve_stableswap_ng_getPoolLiquidityHistory,{where:{chainId:null!=e?e:le.ZETACHAIN,poolAddress:null!=t?t:""}})),{enabled:!!t&&!!e}));return Object.assign(Object.assign({},r),{list:null===(i=null===(n=r.data)||void 0===n?void 0:n.curve_stableswap_ng_getPoolLiquidityHistory)||void 0===i?void 0:i.liquidityHistories})}({address:n,chainId:t}),[u,p]=H.useState(1),h=u*(s?4:8),m=c.list,g=h<(null!==(o=null==m?void 0:m.length)&&void 0!==o?o:0),f=null!==(r=null==m?void 0:m.slice(0,h))&&void 0!==r?r:[];return Yn.jsx(i,{sx:{display:"flex",flexDirection:"column"},children:Yn.jsx(Tj,{refetch:c.error?c.refetch:void 0,loading:c.isLoading&&!(null==f?void 0:f.length),empty:!(null==f?void 0:f.length),children:!!(null==f?void 0:f.length)&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{overflowX:"auto",minHeight:244},children:Yn.jsxs(i,{component:"table",sx:{minWidth:"100%"},children:[Yn.jsx(i,{component:"thead",sx:{position:"sticky",top:0},children:Yn.jsxs(i,{component:"tr",sx:{"& th":{p:24,borderBottomWidth:1,typography:"body1",lineHeight:1,textAlign:"left",whiteSpace:"nowrap"}},children:[Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"LhMjLm",message:"Time"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"bwRvnp",message:"Action"})}),Yn.jsx(i,{component:"th",children:Yn.jsx(e,{id:"GX8GKD",message:"Assets"})})]})}),Yn.jsx(i,{component:"tbody",children:null==f?void 0:f.map((e=>{var n;return Yn.jsxs(i,{component:"tr",sx:{"& td":{px:24,py:20,whiteSpace:"nowrap"}},children:[Yn.jsx("td",{children:bP(1e3*e.time)}),Yn.jsx("td",{children:e.action}),Yn.jsx("td",{children:Yn.jsx(i,{sx:{display:"flex",alignItems:"center",gap:8},children:null===(n=e.assets)||void 0===n?void 0:n.map(((e,n)=>Yn.jsxs(J,{children:[n>0&&Yn.jsx(i,{sx:{width:"1px",height:"16px",backgroundColor:l.palette.border.main,margin:"0 8px"}}),Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:2},children:[Yn.jsx(Df,{address:e.token.address,chainId:t,width:24,height:24,noBorder:!0,noShowChain:!0,marginRight:0}),Yn.jsxs(i,{sx:{typography:"body2"},children:[Am({input:e.amount,decimals:e.token.decimals})," ",e.token.symbol]})]})]},e.token.address)))})})]},e.id)}))})]})}),g&&Yn.jsxs(d,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:l.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:()=>p((e=>e+1)),children:[Yn.jsx(e,{id:"yQ2kGp",message:"Load more"}),Yn.jsx(i,{component:li.ArrowRight,sx:{transform:"rotate(90deg)"}})]})]})})})},wP=({title:e,children:t,tip:n,sx:o})=>Yn.jsxs(i,{sx:Object.assign({display:"flex",justifyContent:"space-between",alignItems:"center",gap:16,py:8},o),children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary"},children:e}),n&&Yn.jsx(lb,{title:n})]}),Yn.jsx(i,{sx:{typography:"body1",color:"text.primary"},children:t})]}),kP=({poolDetail:e})=>{var t;return Yn.jsxs(i,{sx:{mt:10,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[Yn.jsx(wP,{title:"Daily USD volume",children:(null==e?void 0:e.dailyVolumeUsd)?`$${qm(new Pe((null==e?void 0:e.dailyVolumeUsd)||"0"))}`:"-"}),Yn.jsx(wP,{title:"Liquidity utilization",tip:"24h Volume/Liquidity ratio",children:(null==e?void 0:e.liquidityUtilization)?`${Vm({input:new Pe((null==e?void 0:e.liquidityUtilization)||"0"),showDecimals:2})}`:"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Fee",children:(null==e?void 0:e.fee)?`${Vm({input:new Pe((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}`:"-"}),Yn.jsx(wP,{title:"DAO fee",children:(null==e?void 0:e.daoFee)?`${Vm({input:new Pe((null==e?void 0:e.daoFee)||"0"),showDecimals:2})}`:"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Virtual price",tip:"Measures pool growth; this is not a dollar value",children:(null==e?void 0:e.virtualPrice)?`${Am({input:new Pe((null==e?void 0:e.virtualPrice)||"0").div(1e18),decimals:18})}`:"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Pool/Token",children:(null==e?void 0:e.address)?Yn.jsx(zb,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body1",color:"text.primary"}}):"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Pool Type",children:"plain"===(null==e?void 0:e.poolType)?"Stableswap-NG":"meta"===(null==e?void 0:e.poolType)?"Plain pool":"-"}),Yn.jsx(i,{sx:{my:10,width:"100%",height:"1px",backgroundColor:"border.main"}}),Yn.jsx(wP,{title:"Coins",sx:{alignItems:"flex-start"},children:Yn.jsx(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:e?e.coins.map((t=>Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsx(Df,{address:t.address,width:16,height:16,chainId:null==e?void 0:e.chainId,url:void 0,cross:!1,noShowChain:!0,noBorder:!0,marginRight:0}),Yn.jsxs(i,{sx:{typography:"body1",fontWeight:500,color:"text.primary"},children:[t.symbol,"(Standard)"]})]},t.address))):"-"})}),Yn.jsx(wP,{title:"Pool Parameters:",sx:{alignItems:"flex-start"},children:Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:12},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:4},children:[Yn.jsxs(i,{sx:{typography:"body1",color:"text.primary"},children:["A:",null!==(t=null==e?void 0:e.a)&&void 0!==t?t:"-"]}),Yn.jsx(lb,{title:"Amplification coefficient chosen from fluctuation of prices around 1."})]}),Yn.jsxs(i,{sx:{typography:"body1",color:"text.primary"},children:["Off Peg Multiplier:",(null==e?void 0:e.offpegFeeMultiplier)?new Pe(null==e?void 0:e.offpegFeeMultiplier).div(1e10).toString():"-"]})]})})]})},TP=({poolDetail:e})=>{var t;const n=a();return Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,[n.breakpoints.up("tablet")]:{py:20,flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderBottom:`1px solid ${n.palette.border.main}`}},children:[Yn.jsxs(i,{sx:{display:"flex",alignItems:"center",gap:8},children:[e?Yn.jsx(XT,{pool:e,separate:!1,wrap:!0}):Yn.jsx(j,{width:72,height:52,sx:{borderRadius:8}}),Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"h4",fontWeight:600},children:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"-"}),(null==e?void 0:e.address)&&Yn.jsx(zb,{address:null==e?void 0:e.address,customChainId:null==e?void 0:e.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"body2",color:"text.secondary"}})]})]}),Yn.jsxs(i,{sx:{display:"flex",flexDirection:"row",alignItems:"flex-end",gap:4,[n.breakpoints.up("tablet")]:{flexDirection:"column",gap:0}},children:[Yn.jsx(KT,{apy:null==e?void 0:e.apy,dailyApy:null==e?void 0:e.dailyApy,weeklyApy:null==e?void 0:e.weeklyApy,sx:{typography:"h4",[n.breakpoints.up("tablet")]:{typography:"h4"}}}),Yn.jsx(i,{sx:{typography:"body2",color:"text.secondary"},children:"APY"})]})]})},IP=({poolDetail:e})=>{const t=a(),n=[{title:"Trader",value:qm(new Pe((null==e?void 0:e.traderCount)||"0"))},{title:"Total Liquidity",value:`$${qm(new Pe((null==e?void 0:e.tvl)||"0"))}`},{title:"Volume",value:`$${qm(new Pe((null==e?void 0:e.volume)||"0"))}`},{title:"Fees",value:Vm({input:new Pe((null==e?void 0:e.fee)||"0").div(1e10),showDecimals:2})}];return Yn.jsx(i,{sx:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gridTemplateRows:"repeat(2, 1fr)",gap:12,[t.breakpoints.up("tablet")]:{gridTemplateColumns:"repeat(4, 1fr)",gridTemplateRows:"repeat(1, 1fr)"}},children:n.map(((n,o)=>e?Yn.jsxs(i,{sx:{display:"flex",flexDirection:"column",p:16,borderRadius:8,backgroundColor:t.palette.background.paper,[t.breakpoints.up("tablet")]:{border:`1px solid ${t.palette.border.main}`}},children:[Yn.jsx(i,{sx:{typography:"caption",color:t.palette.text.primary},children:n.value}),Yn.jsx(i,{sx:{typography:"h6",color:t.palette.text.secondary},children:n.title})]},o):Yn.jsx(j,{width:"100%",height:77,sx:{borderRadius:8}},o)))})};const SP=({params:t})=>{const n=Gj(),{isMobile:o}=Tg(),{account:r}=dg(),s=a(),{poolDetail:l,isLoading:d,error:u}=function({address:e,chainId:t}){const n=gg(),i=Z((e=>{var n,i,o,r,a,s,l,d,c,u,p,h;const m=null==e?void 0:e.curve_stableswap_ng_getPoolInfo;if(!m)return;const g=((null===(n=m.coins)||void 0===n?void 0:n.map((e=>({chainId:null!=t?t:le.ZETACHAIN,address:e.address||e.id||"",name:e.name||e.symbol||"",decimals:e.decimals,symbol:e.symbol||"",tokenIndex:e.tokenIndex||0}))))||[]).sort(((e,t)=>e.tokenIndex-t.tokenIndex));return{chainId:null!=t?t:le.ZETACHAIN,name:m.name||"",address:m.address||m.id||"",symbol:m.symbol,decimals:m.decimals,fee:(null===(i=m.fee)||void 0===i?void 0:i.toString())||"0",coins:g,apy:(null===(o=m.apy)||void 0===o?void 0:o.toString())||null,dailyApy:null,weeklyApy:null,tvl:(null===(r=m.tvl)||void 0===r?void 0:r.toString())||null,volume:(null===(a=m.volume)||void 0===a?void 0:a.toString())||null,dailyVolumeUsd:(null===(s=m.dailyVolumeUsd)||void 0===s?void 0:s.toString())||null,traderCount:(null===(l=m.traderCount)||void 0===l?void 0:l.toString())||null,lpTokenBalance:null,liquidityUtilization:(null===(d=m.liquidityUtilization)||void 0===d?void 0:d.toString())||null,daoFee:(null===(c=m.daoFee)||void 0===c?void 0:c.toString())||null,virtualPrice:(null===(u=m.virtualPrice)||void 0===u?void 0:u.toString())||null,poolType:m.poolType||"plain",a:(null===(p=m.a)||void 0===p?void 0:p.toString())||null,offpegFeeMultiplier:(null===(h=m.offpegFeeMultiplier)||void 0===h?void 0:h.toString())||null}}),[t]),{data:o,isLoading:r,error:a}=et(Object.assign(Object.assign({},n.getQuery(Se.graphql.curve_stableswap_ng_getPoolInfo,{where:{chainId:null!=t?t:le.ZETACHAIN,poolAddress:null!=e?e:""}})),{enabled:!!e&&!!t,select:i}));return{poolDetail:o,isLoading:r,error:a}}({address:null==t?void 0:t.address,chainId:null==t?void 0:t.chainId}),{tokenBalances:p}=lI({pool:l,account:r}),[h,m]=z(null),[g,f]=z("parameters");Q((()=>{o||l&&m({pool:l,type:YT.Add})}),[l,o]);const x=$((()=>[{key:"parameters",value:"Parameters"},{key:"swaps",value:"Swaps"},{key:"liquidity",value:"Liquidity"}]),[]);return Yn.jsxs(zj,{sx:o?{p:s.spacing(28,0,108)}:{p:s.spacing(28,0,40)},children:[Yn.jsxs(i,{sx:{[s.breakpoints.up("tablet")]:{display:"flex",gap:12,overflow:"hidden"}},children:[Yn.jsxs(i,{sx:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",gap:24,[s.breakpoints.up("tablet")]:{gap:28}},children:[Yn.jsx(WL,{onClick:()=>{n.push({type:Zj.Pool})}}),Yn.jsx(TP,{poolDetail:l}),Yn.jsx(IP,{poolDetail:l}),l&&Yn.jsxs(i,{children:[Yn.jsx(i,{sx:{typography:"body1",color:s.palette.text.primary},children:"Currency reserves"}),Yn.jsx(vP,{poolDetail:l,tokenBalances:p})]}),Yn.jsx(i,{sx:{backgroundColor:s.palette.background.paper,borderRadius:16,overflow:"hidden",px:16,pb:16,[s.breakpoints.up("tablet")]:{px:20,pb:20}},children:Yn.jsxs(S,{value:g,onChange:(e,t)=>f(t),children:[Yn.jsx(D,{tabs:x}),Yn.jsx(O,{value:"parameters",children:Yn.jsx(kP,{poolDetail:l})}),Yn.jsx(O,{value:"swaps",children:Yn.jsx(jP,{chainId:null==t?void 0:t.chainId,address:null==t?void 0:t.address})}),Yn.jsx(O,{value:"liquidity",children:Yn.jsx(CP,{chainId:null==t?void 0:t.chainId,address:null==t?void 0:t.address})})]})})]}),Yn.jsx(i,{sx:{position:"relative",width:o?"100%":375},children:h?Yn.jsx(hI,{poolDetailBtnVisible:!1,operateCurvePool:h,setOperateCurvePool:o?m:void 0}):o?null:Yn.jsx(j,{width:375,height:403,sx:{borderRadius:16}})})]}),o&&Yn.jsx(Yn.Fragment,{children:Yn.jsxs(i,{sx:{position:"fixed",bottom:0,left:0,right:0,p:20,display:"grid",gap:"8px",gridTemplateColumns:"repeat(2, 1fr)",backgroundColor:"background.paperContrast"},children:[Yn.jsx(c,{variant:c.Variant.second,disabled:!l,onClick:()=>{l&&m({pool:l,type:YT.Remove})},children:Yn.jsx(e,{id:"t/YqKh",message:"Remove"})}),Yn.jsx(c,{disabled:!l,onClick:()=>{l&&m({pool:l,type:YT.Add})},children:Yn.jsx(e,{id:"m16xKo",message:"Add"})})]})})]})};function EP(){const{routerPage:e}=Jn(),t=Gj((e=>e.page)),n=null!=e?e:t;switch(null==n?void 0:n.type){case Zj.Pool:return Yn.jsx(KS,{params:n.params});case Zj.CreatePool:return Yn.jsx(qL,{});case Zj.ModifyPool:return Yn.jsx(YL,{params:n.params});case Zj.PoolDetail:return Yn.jsx(jR,{params:n.params});case Zj.CurvePoolDetail:return Yn.jsx(SP,{params:n.params});case Zj.createPoolAMMV2:return Yn.jsx(AR,{});case Zj.createPoolAMMV3:return Yn.jsx(xP,{params:n.params,handleGoBack:()=>{Gj.getState().push({type:Zj.Pool})},handleGoToPoolList:()=>{Gj.getState().push({type:Zj.Pool})}});default:return Yn.jsx(KS,{params:null==n?void 0:n.params})}}export{AR as A,YL as B,SP as C,hS as D,ti as E,ai as F,mS as G,Zv as M,Zj as P,lj as S,hj as T,ab as U,sb as W,Vm as a,Rm as b,Hj as c,Df as d,ib as e,Um as f,$j as g,ah as h,Sg as i,Yn as j,$v as k,Gj as l,tg as m,Em as n,Am as o,EP as p,xP as q,Uu as r,Vu as s,FT as t,Dj as u,VT as v,xI as w,qL as x,jR as y,KS as z};
|