@dodoex/widgets 3.0.1-solana.12 → 3.0.1-solana.13

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/index.cjs CHANGED
@@ -20,4 +20,4 @@
20
20
  object-assign
21
21
  (c) Sindre Sorhus
22
22
  @license MIT
23
- */function vl(){if(al)return rl;al=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return rl=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 o={};return"abcdefghijklmnopqrst".split("").forEach((function(e){o[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(o,i){for(var r,a,l=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(o),s=1;s<arguments.length;s++){for(var d in r=Object(arguments[s]))t.call(r,d)&&(l[d]=r[d]);if(e){a=e(r);for(var c=0;c<a.length;c++)n.call(r,a[c])&&(l[a[c]]=r[a[c]])}}return l},rl}function bl(){if(sl)return ll;sl=1;return ll="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function jl(){return cl?dl:(cl=1,dl=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var Cl=yl();el.exports=function(){if(ml)return hl;ml=1;var e=yl(),t=vl(),n=bl(),o=jl(),i=function(){if(pl)return ul;pl=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=bl(),n={},o=jl();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function i(i,r,a,l,s){if("production"!==process.env.NODE_ENV)for(var d in i)if(o(i,d)){var c;try{if("function"!=typeof i[d]){var u=Error((l||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=i[d](r,d,l,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((l||"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=s?s():"";e("Failed "+a+" type: "+c.message+(null!=p?p:""))}}}return i.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},ul=i}(),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){}}),hl=function(l,s){var d="function"==typeof Symbol&&Symbol.iterator,c="@@iterator",u="<<anonymous>>",p={array:x("array"),bigint:x("bigint"),bool:x("boolean"),func:x("function"),number:x("number"),object:x("object"),string:x("string"),symbol:x("symbol"),any:f(a),arrayOf:function(e){return f((function(t,o,i,r,a){if("function"!=typeof e)return new m("Property `"+a+"` of component `"+i+"` has invalid PropType notation inside arrayOf.");var l=t[o];if(!Array.isArray(l))return new m("Invalid "+r+" `"+a+"` of type `"+v(l)+"` supplied to `"+i+"`, expected an array.");for(var s=0;s<l.length;s++){var d=e(l,s,i,r,a+"["+s+"]",n);if(d instanceof Error)return d}return null}))},element:f((function(e,t,n,o,i){var r=e[t];return l(r)?null:new m("Invalid "+o+" `"+i+"` of type `"+v(r)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:f((function(t,n,o,i,r){var a=t[n];return e.isValidElementType(a)?null:new m("Invalid "+i+" `"+r+"` of type `"+v(a)+"` supplied to `"+o+"`, expected a single ReactElement type.")})),instanceOf:function(e){return f((function(t,n,o,i,r){if(!(t[n]instanceof e)){var a=e.name||u;return new m("Invalid "+i+" `"+r+"` of type `"+((l=t[n]).constructor&&l.constructor.name?l.constructor.name:u)+"` supplied to `"+o+"`, expected instance of `"+a+"`.")}var l;return null}))},node:f((function(e,t,n,o,i){return y(e[t])?null:new m("Invalid "+o+" `"+i+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return f((function(t,i,r,a,l){if("function"!=typeof e)return new m("Property `"+l+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var s=t[i],d=v(s);if("object"!==d)return new m("Invalid "+a+" `"+l+"` of type `"+d+"` supplied to `"+r+"`, expected an object.");for(var c in s)if(o(s,c)){var u=e(s,c,r,a,l+"."+c,n);if(u instanceof Error)return u}return null}))},oneOf:function(e){return Array.isArray(e)?f((function(t,n,o,i,r){for(var a=t[n],l=0;l<e.length;l++)if(h(a,e[l]))return null;var s=JSON.stringify(e,(function(e,t){return"symbol"===b(t)?String(t):t}));return new m("Invalid "+i+" `"+r+"` of value `"+String(a)+"` supplied to `"+o+"`, expected one of "+s+".")})):("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 i=e[t];if("function"!=typeof i)return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+j(i)+" at index "+t+"."),a}return f((function(t,i,r,a,l){for(var s=[],d=0;d<e.length;d++){var c=(0,e[d])(t,i,r,a,l,n);if(null==c)return null;c.data&&o(c.data,"expectedType")&&s.push(c.data.expectedType)}return new m("Invalid "+a+" `"+l+"` supplied to `"+r+"`"+(s.length>0?", expected one of type ["+s.join(", ")+"]":"")+".")}))},shape:function(e){return f((function(t,o,i,r,a){var l=t[o],s=v(l);if("object"!==s)return new m("Invalid "+r+" `"+a+"` of type `"+s+"` supplied to `"+i+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return g(i,r,a,d,b(c));var u=c(l,d,i,r,a+"."+d,n);if(u)return u}return null}))},exact:function(e){return f((function(i,r,a,l,s){var d=i[r],c=v(d);if("object"!==c)return new m("Invalid "+l+" `"+s+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},i[r],e);for(var p in u){var h=e[p];if(o(e,p)&&"function"!=typeof h)return g(a,l,s,p,b(h));if(!h)return new m("Invalid "+l+" `"+s+"` key `"+p+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(i[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var f=h(d,p,a,l,s+"."+p,n);if(f)return f}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 f(e){if("production"!==process.env.NODE_ENV)var t={},o=0;function i(i,a,l,d,c,p,h){if(d=d||u,p=p||l,h!==n){if(s){var f=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 f.name="Invariant Violation",f}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var x=d+":"+l;!t[x]&&o<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[x]=!0,o++)}}return null==a[l]?i?null===a[l]?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,l,d,c,p)}var a=i.bind(null,!1);return a.isRequired=i.bind(null,!0),a}function x(e){return f((function(t,n,o,i,r,a){var l=t[n];return v(l)!==e?new m("Invalid "+i+" `"+r+"` of type `"+b(l)+"` supplied to `"+o+"`, expected `"+e+"`.",{expectedType:e}):null}))}function g(e,t,n,o,i){return new m((e||"React class")+": "+t+" type `"+n+"."+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+i+"`.")}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||l(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,o=t.call(e);if(t!==e.entries){for(;!(n=o.next()).done;)if(!y(n.value))return!1}else for(;!(n=o.next()).done;){var i=n.value;if(i&&!y(i[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=i,p.resetWarningCache=i.resetWarningCache,p.PropTypes=p,p},hl}()(Cl.isElement,!0)}else el.exports=function(){if(xl)return fl;xl=1;var e=bl();function t(){}function n(){}return n.resetWarningCache=t,fl=function(){function o(t,n,o,i,r,a){if(a!==e){var l=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 l.name="Invariant Violation",l}}function i(){return o}o.isRequired=o;var r={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:i,element:o,elementType:o,instanceOf:i,node:o,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r}}()();var wl=W(el.exports);function kl(e,t){return"production"===process.env.NODE_ENV?()=>null:function(...n){return e(...n)||t(...n)}}function Tl(e,t,n,o,i){const r=e[t],a=i||t;if(null==r||"undefined"==typeof window)return null;let l;const s=r.type;return"function"!=typeof s||function(e){const{prototype:t={}}=e;return Boolean(t.isReactComponent)}(s)||(l="Did you accidentally use a plain function component for an element instead?"),void 0!==l?new Error(`Invalid ${o} \`${a}\` supplied to \`${n}\`. Expected an element that can hold a ref. ${l} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const Rl=kl(wl.element,Tl);Rl.isRequired=kl(wl.element.isRequired,Tl);const Sl="exact-prop: ​";function Il(e){return e&&e.ownerDocument||document}const Bl="undefined"!=typeof window?O.useLayoutEffect:O.useEffect;function Ml(e){const t=O.useRef(e);return Bl((()=>{t.current=e})),O.useRef(((...e)=>(0,t.current)(...e))).current}function El(...e){return O.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 Ll={};const Ol=[];class Wl{static create(){return new Wl}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 Vl(){const e=function(e,t){const n=O.useRef(Ll);return n.current===Ll&&(n.current=e(t)),n}(Wl.create).current;var t;return t=e.disposeEffect,O.useEffect(t,Ol),e}const Al={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 Fl(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Fl(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Pl(){for(var e,t,n=0,o="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Fl(e))&&(o&&(o+=" "),o+=t);return o}function Zl(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 Nl(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 Ul(e){const{elementType:t,externalSlotProps:n,ownerState:o,skipResolvingSlotProps:i=!1,...r}=e,a=i?{}:function(e,t,n){return"function"==typeof e?e(t,n):e}(n,o),{props:l,internalRef:s}=function(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:o,externalForwardedProps:i,className:r}=e;if(!t){const e=Pl(n?.className,r,i?.className,o?.className),t={...n?.style,...i?.style,...o?.style},a={...n,...i,...o};return e.length>0&&(a.className=e),Object.keys(t).length>0&&(a.style=t),{props:a,internalRef:void 0}}const a=Zl({...i,...o}),l=Nl(o),s=Nl(i),d=t(a),c=Pl(d?.className,n?.className,r,i?.className,o?.className),u={...d?.style,...n?.style,...i?.style,...o?.style},p={...d,...n,...s,...l};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,{...l,ref:El(s,a?.ref,e.additionalProps?.ref)},o);return d}function Hl(e){return e.substring(2).toLowerCase()}function Dl(e){const{children:t,disableReactTree:n=!1,mouseEvent:o="onClick",onClickAway:i,touchEvent:r="onTouchEnd"}=e,a=O.useRef(!1),l=O.useRef(null),s=O.useRef(!1),d=O.useRef(!1);O.useEffect((()=>(setTimeout((()=>{s.current=!0}),0),()=>{s.current=!1})),[]);const c=El((u=t)&&O.isValidElement(u)?u.props.propertyIsEnumerable("ref")?u.props.ref:u.ref:null,l);var u;const p=Ml((e=>{const t=d.current;d.current=!1;const o=Il(l.current);if(!s.current||!l.current||"clientX"in e&&function(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}(e,o))return;if(a.current)return void(a.current=!1);let r;r=e.composedPath?e.composedPath().indexOf(l.current)>-1:!o.documentElement.contains(e.target)||l.current.contains(e.target),r||!n&&t||i(e)})),h=e=>n=>{d.current=!0;const o=t.props[e];o&&o(n)},m={ref:c};return!1!==r&&(m[r]=h(r)),O.useEffect((()=>{if(!1!==r){const e=Hl(r),t=Il(l.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!==o&&(m[o]=h(o)),O.useEffect((()=>{if(!1!==o){const e=Hl(o),t=Il(l.current);return t.addEventListener(e,p),()=>{t.removeEventListener(e,p)}}}),[p,o]),G.jsx(O.Fragment,{children:O.cloneElement(t,m)})}"production"!==process.env.NODE_ENV&&(Dl.propTypes={children:Rl.isRequired,disableReactTree:wl.bool,mouseEvent:wl.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:wl.func.isRequired,touchEvent:wl.oneOf(["onTouchEnd","onTouchStart",!1])}),"production"!==process.env.NODE_ENV&&(Dl.propTypes=function(e){return"production"===process.env.NODE_ENV?e:{...e,[Sl]: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}}}(Dl.propTypes));const Yl="base";function zl(e,t){const n=Al[t];return n?`${Yl}--${n}`:function(e,t){return`${Yl}-${e}-${t}`}(e,t)}const ql="Snackbar";function Xl(e){return zl(ql,e)}!function(e,t){const n={};t.forEach((t=>{n[t]=zl(e,t)}))}(ql,["root"]);const Gl={disableDefaultClasses:!1},_l=O.createContext(Gl);"production"!==process.env.NODE_ENV&&(_l.displayName="ClassNameConfiguratorContext");const Jl=()=>function(e,t,n){const o={};for(const i in e){const r=e[i];let a="";for(let e=0;e<r.length;e+=1){const o=r[e];o&&(a+=t(o)+" ",n&&n[o]&&(a+=n[o]+" "))}o[i]=a}return o}({root:["root"]},function(e){const{disableDefaultClasses:t}=O.useContext(_l);return n=>t?"":e(n)}(Xl)),Ql=O.forwardRef((function(e,t){const{autoHideDuration:n=null,children:o,disableWindowBlurListener:i=!1,exited:r=!0,onBlur:a,onClose:l,onFocus:s,onMouseEnter:d,onMouseLeave:c,open:u,resumeHideDuration:p,slotProps:h={},slots:m={},...f}=e,x=Jl(),{getRootProps:g,onClickAway:y}=function(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:o,open:i,resumeHideDuration:r}=e,a=Vl();O.useEffect((()=>{if(i)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)};function e(e){e.defaultPrevented||"Escape"===e.key&&o?.(e,"escapeKeyDown")}}),[i,o]);const l=Ml(((e,t)=>{o?.(e,t)})),s=Ml((e=>{o&&null!=e&&a.start(e,(()=>{l(null,"timeout")}))}));O.useEffect((()=>(i&&s(t),a.clear)),[i,t,s,a]);const d=a.clear,c=O.useCallback((()=>{null!=t&&s(null!=r?r:.5*t)}),[t,r,s]),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 O.useEffect((()=>{if(!n&&i)return window.addEventListener("focus",c),window.addEventListener("blur",d),()=>{window.removeEventListener("focus",c),window.removeEventListener("blur",d)}}),[n,i,c,d]),{getRootProps:(t={})=>{const n={...Zl(e),...Zl(t)};return{role:"presentation",...t,...n,onBlur:(o=n,e=>{const t=o.onBlur;t?.(e),c()}),onFocus:u(n),onMouseEnter:p(n),onMouseLeave:h(n)};var o},onClickAway:e=>{o?.(e,"clickaway")}}}({...e,autoHideDuration:n,disableWindowBlurListener:i,onClose:l,open:u,resumeHideDuration:p}),v=e,b=m.root||"div",j=Ul({elementType:b,getSlotProps:g,externalForwardedProps:f,externalSlotProps:h.root,additionalProps:{ref:t},ownerState:v,className:x.root}),C=Ul({elementType:Dl,externalSlotProps:h.clickAwayListener,additionalProps:{onClickAway:y},ownerState:v});return delete C.ownerState,!u&&r?null:G.jsx(Dl,{...C,children:G.jsx(b,{...j,children:o})})}));function Kl({size:e,color:t,time:n,strokeWidth:r=2,sx:a}){const[l,s]=i.useState("0 1069"),d=e/2,c=d-1;return i.useEffect((()=>{s(2*Math.PI*c+" 0")}),[]),G.jsx(o.Box,{width:e,height:e,component:"svg",sx:Object.assign({position:"absolute",top:`-${r}`,left:`-${r}`,transform:"rotate(-90deg)"},a),children:G.jsx(o.Box,{component:"circle",cx:d,cy:d,r:c,strokeWidth:r,stroke:t,fill:"none",strokeDasharray:l,sx:{transition:`stroke-dasharray ${n}`}})})}"production"!==process.env.NODE_ENV&&(Ql.propTypes={autoHideDuration:wl.number,children:wl.node,disableWindowBlurListener:wl.bool,exited:wl.bool,onClose:wl.func,open:wl.bool,resumeHideDuration:wl.number,slotProps:wl.shape({clickAwayListener:wl.oneOfType([wl.func,wl.shape({children:wl.element.isRequired,disableReactTree:wl.bool,mouseEvent:wl.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:wl.func,touchEvent:wl.oneOf(["onTouchEnd","onTouchStart",!1])})]),root:wl.oneOfType([wl.func,wl.object])}),slots:wl.shape({root:wl.elementType})});var $l=i.memo(Kl);const es=f.create((e=>({notify:null,toast:t=>{e({notify:t})},close:()=>{e({notify:null})}}))),ts={entering:"translateX(0)",entered:"translateX(0)",exiting:"translateX(500px)",exited:"translateX(500px)",unmounted:"translateX(500px)"};function ns(){const e=o.useTheme(),{notify:t,close:n}=es(),[r,a]=i.useState(!0),l=i.useRef(null),s=null==t?void 0:t.timeout,d=!!t;let c=G.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18",r:"16.5",stroke:"#2FBA90",strokeWidth:"3"}),G.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=G.jsxs("svg",{width:"36",height:"37",viewBox:"0 0 36 37",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18.5",r:"16.5",stroke:"#FF6187",strokeWidth:"3"}),G.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=G.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.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"}),G.jsx("path",{d:"M15.1664 7.58398H12.8331V16.9173H15.1664V7.58398Z",fill:"#B15600"}),G.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 G.jsx(o.Box,{component:Ql,open:d,autoHideDuration:s,onClose:(e,t)=>{"clickaway"!==t&&n()},exited:r,sx:{position:"fixed",top:20,left:20,right:20,zIndex:1,[e.breakpoints.up("tablet")]:{left:"auto"}},children:G.jsx(C.Transition,{timeout:{enter:400,exit:400},in:d,appear:!0,unmountOnExit:!0,onEnter:()=>{a(!1)},onExited:()=>{a(!0)},nodeRef:l,children:i=>G.jsxs(o.Box,{ref:l,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:ts[i],transition:"transform 300ms ease",[e.breakpoints.up("tablet")]:{p:20,width:"auto",maxWidth:328}},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{sx:{mt:7,"& > svg":{width:28,height:28},[e.breakpoints.up("tablet")]:{"& > svg":{width:36,height:36}}},children:t?c:""}),G.jsxs(o.Box,{sx:{ml:20},children:[G.jsx(o.Box,{sx:{typography:"caption"},children:null==t?void 0:t.message}),(null==t?void 0:t.link)?G.jsxs(o.Box,{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,G.jsx(o.Box,{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:G.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)?G.jsx(o.Box,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:t.content}):""]})]}),G.jsxs(o.Box,{sx:{position:"relative",top:10,ml:12,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:12,borderStyle:"solid",borderWidth:s?"2.4px":0,borderColor:e.palette.border.main,backgroundColor:s?"transparent":e.palette.background.paperDarkContrast,cursor:"pointer",boxSizing:"border-box",[e.breakpoints.up("tablet")]:{ml:28}},onClick:n,children:[s?G.jsx($l,{size:24,strokeWidth:"2.4px",time:`${s}ms`,color:e.palette.text.disabled}):"",G.jsx(o.Box,{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:G.jsx("g",{children:G.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 os;function is(){return is=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},is.apply(null,arguments)}const rs=e=>O.createElement("svg",is({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),os||(os=O.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},O.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},O.createElement("g",{transform:"translate(18.000000, 291.000000)"},O.createElement("g",{transform:"translate(40.000000, 83.000000)"},O.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"}))))))),as=300;function ls({open:e,onClose:t,afterClose:n,title:i,rightSlot:r,canBack:a=!0,children:l,height:s,testId:d}){return G.jsxs(o.Box,{sx:{position:"absolute",top:e?0:"100%",transition:`all ${as}ms`,zIndex:20,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",backgroundColor:"background.paper",borderRadius:16,height:s},"data-testid":d,"data-active":e?"1":"0",children:[i?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:i}),r,!r&&a&&G.jsx(o.Box,{component:A.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{t&&t(),setTimeout((()=>n&&n()),as)}})]}):"",e?l:""]})}function ss({open:e,onClose:t,afterClose:n,title:i,rightSlot:r,canBack:a=!0,children:l,height:s,testId:d}){return G.jsx(o.Modal,{open:e,onClose:t,"data-testid":d,"data-active":e?"1":"0",children:G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:s},children:[i?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:i}),r,!r&&a&&G.jsx(o.Box,{component:A.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{t&&t(),setTimeout((()=>n&&n()),as)}})]}):"",e?l:""]})})}function ds(e){var{scope:t,modal:n}=e,o=Oo(e,["scope","modal"]);const{widgetRef:i,DialogComponent:r}=Fo();if(r)return G.jsx(r,{scope:t,...o});const a=n?ss:ls;return(null==i?void 0:i.current)&&!t?w.createPortal(G.jsx(a,{...o}),i.current):G.jsx(a,{...o})}const cs=6;function us({showingDone:e,errorMessage:t}){var n;const i=o.useTheme();return t?G.jsx(o.Box,{component:A.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?G.jsx(o.Box,{component:A.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):G.jsx(o.Box,{sx:{mx:"auto",border:`${cs}px solid ${null===(n=i.palette)||void 0===n?void 0:n.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:G.jsx(o.Box,{component:rs,sx:{position:"absolute",top:`-${cs}px`,right:`-${cs}px`,color:"primary.main"}})})}function ps({showingDone:e,showing:n}){return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[G.jsx(o.Box,{sx:{mt:60},children:e?t.i18n._({id:"4xbbt/",message:"{0} confirmed",values:{0:null==n?void 0:n.brief}}):t.i18n._({id:"/nzjSF",message:"{0} pending",values:{0:null==n?void 0:n.brief}})}),(null==n?void 0:n.subtitle)?G.jsx(o.Box,{sx:{mt:20,typography:"body2"},children:null==n?void 0:n.subtitle}):""]})}function hs({isStarted:t,isEnded:n,tx:r}){const[a,l]=i.useState(0),{chainId:s}=Zo(),d=i.useMemo((()=>`https://${yo[s||1]}/tx/${r}`),[r,s]),c=i.useMemo((()=>{const e=Math.floor(a/60),t=a%60;return e?`${e}m ${t}s`:`${t}s`}),[a]),u=i.useRef();return i.useEffect((()=>(t&&(l(0),window.clearInterval(u.current),u.current=window.setInterval((()=>{l((e=>e+1))}),1e3)),()=>{window.clearInterval(u.current)})),[t]),i.useEffect((()=>{n&&window.clearInterval(u.current)}),[n]),G.jsxs(o.Box,{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:[G.jsxs(o.Box,{children:[G.jsx(e.Trans,{id:"+Jkdiu",message:"Transaction Time:"}),c]}),G.jsxs(o.HoverOpacity,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:d,target:"_blank",rel:"noopener noreferrer",children:[G.jsx(e.Trans,{id:"S3piC2",message:"Tx"}),G.jsx(o.Box,{component:A.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function ms(t){var{children:n,executionStatus:i}=t;const r=Ti(Oo(t,["children","executionStatus"])),{ctxVal:a,showing:s,closeShowing:d,showingDone:c,errorMessage:u,transactionTx:p}=Object.assign(Object.assign({},r),i),h=l.useDispatch(),m=Fo((e=>e.noSubmissionDialog));return G.jsxs(Ri.Provider,{value:a,children:[n,G.jsx(ds,{open:!!s&&!m,onClose:d,id:"submission",children:G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",px:20,pb:20,flex:1,overflowY:"auto"},children:[G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{textAlign:"center",pt:60},children:G.jsx(us,{showingDone:c,errorMessage:u})}),u?G.jsxs(o.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(o.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(o.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:u})]}):G.jsxs(G.Fragment,{children:[G.jsx(ps,{showingDone:c,showing:s}),G.jsx(hs,{isStarted:!!s,isEnded:c,tx:p})]})]}),G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:()=>{h(Yo(Xo.Initial)),d()},sx:{mt:20},children:u?G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"}):G.jsx(e.Trans,{id:"yz7wBu",message:"Close"})})]})})]})}const fs="dodo-widget-container";function xs(e){return e.noLangProvider?G.jsx(G.Fragment,{children:e.children}):G.jsx(Ja,{locale:e.locale,children:G.jsx(ms,{...e,children:e.children})})}function gs(e){!function({tokenList:e,popularTokenList:t}){const n=l.useDispatch();i.useEffect((()=>{(()=>{Wo(this,void 0,void 0,(function*(){let o=[];o=a.isArray(e)?e:a.unionBy(t,pr,(e=>e.address.toLowerCase()+e.chainId+e.side)),n(hr(o))}))})()}),[e,n,t]),i.useEffect((()=>{n(mr(null!=t?t:[]))}),[t,n])}(e),Ci();const t=e.width||375,n=e.height||494,{widgetRef:r}=Fo();return e.noUI?G.jsx(xs,{...e,children:e.children}):G.jsx(xs,{...e,children:G.jsx(o.Box,{sx:{width:t,height:n,overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",minWidth:335,minHeight:494,borderRadius:16,backgroundColor:"background.paper"},className:fs,ref:r,children:e.children})})}function ys(e){var t,n;const o=i.useRef(null);return G.jsx(l.Provider,{store:Di,children:G.jsx(Ao,{...Object.assign(Object.assign({},e),{widgetRef:null!==(t=e.widgetRef)&&void 0!==t?t:o,apiDomain:null!==(n=e.apiDomain)&&void 0!==n?n:"dodoex.io"}),children:G.jsx(Ka,{children:G.jsx(Na,{children:G.jsx(gs,{...e})})})})})}function vs(e){var{sx:t}=e,n=Oo(e,["sx"]);const{width:r}=Fo(),a=i.useMemo((()=>{let e="";return"number"==typeof r?e=`${r}px`:r&&(e=r),e?`calc(${e} - 40px)`:"auto"}),[r]);return G.jsx(o.QuestionTooltip,{container:document.querySelector(`.${fs}`),maxWidth:a,sx:Object.assign({cursor:"help"},t),...n})}function bs(t){var n,{chainId:r,includeButton:a}=t,l=Oo(t,["chainId","includeButton"]);const{account:s,chainId:d}=Zo(),{onConnectWalletClick:c}=Fo(),[u,p]=i.useState(!1),{setVisible:h}=j.useWalletModal();return!s||u||void 0===d||r&&r!==d?G.jsx(G.Fragment,{children:G.jsx(o.Button,{...l,isLoading:u,onClick:()=>Wo(this,void 0,void 0,(function*(){if(c){p(!0);const e=yield c();if(p(!1),e)return}h(!0)})),children:u?G.jsx(e.Trans,{id:"J28zul",message:"Connecting..."}):G.jsx(e.Trans,{id:"r7ScnQ",message:"Connect to a wallet"})})}):a?G.jsx(G.Fragment,{children:null!==(n=l.children)&&void 0!==n?n:null}):G.jsx(o.Button,{...l})}function js({needSwitchChain:e}){return G.jsx(G.Fragment,{children:G.jsx(bs,{size:o.Button.Size.middle,fullWidth:!0,"data-testid":Io,chainId:e})})}function Cs({open:t,execute:n,onClose:a,toToken:s,fromToken:d,fromAmount:c,toAmount:u,priceImpact:p,clearFromAmt:h,clearToAmt:m,baseFeeAmount:f,curToFiatPrice:x,curFromFiatPrice:g,additionalFeeAmount:y,loading:v,slippage:b}){var j,C;const w=o.useTheme(),k=l.useDispatch(),T=l.useSelector(Yi),R=i.useMemo((()=>!!p&&new r(p).gt(wo)),[p]),[S,I]=i.useState(!1),[B,M]=i.useState(!1);return i.useEffect((()=>{T!==Xo.Pending&&a(),T===Xo.TxSuccess&&(m(),h())}),[T]),i.useEffect((()=>{I(!1)}),[x]),G.jsx(ds,{open:t,onClose:()=>{k(Yo(Xo.Initial)),a()},id:"swap-summary",title:G.jsx(e.Trans,{id:"QR4/RH",message:"Swap summary"}),children:G.jsxs(o.Box,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${w.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${w.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[G.jsx(Wa,{width:16,height:16,url:null==d?void 0:d.logoURI,address:null!==(j=null==d?void 0:d.address)&&void 0!==j?j:"",marginRight:6}),G.jsx(o.Box,{children:`${Ko({input:c,decimals:null==d?void 0:d.decimals})} ${null==d?void 0:d.symbol}`})]}),null!==g&&G.jsx(o.Box,{sx:{mt:4,typography:"h6",color:w.palette.text.secondary},children:g?`$${Qo({input:g,showDecimals:1})}`:"-"})]}),G.jsx(o.Box,{sx:{width:16,mx:16},component:A.DoubleRight}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex"},children:[G.jsx(Wa,{width:16,height:16,marginRight:6,url:null==s?void 0:s.logoURI,address:null!==(C=null==s?void 0:s.address)&&void 0!==C?C:""}),G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:`${Ko({input:u,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`})]}),null!==g&&G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},sx:{typography:"h6",mt:4,color:w.palette.text.secondary},children:x?`$${Qo({input:x,showDecimals:1})}(${p}%)`:"-"})]})]}),G.jsxs(o.Box,{sx:{mt:12,display:"flex",alignItems:"center",typography:"h6"},children:["1",null==d?void 0:d.symbol," = ",G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:Ko({input:new r(u).dividedBy(new r(c)),decimals:null==s?void 0:s.decimals})})," ",null==s?void 0:s.symbol]})]}),G.jsxs(o.Box,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${w.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:w.palette.text.secondary},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{sx:{width:16,mr:7},component:A.DetailBorder}),G.jsx(e.Trans,{id:"XeovX3",message:"Swap Detail"})]}),G.jsx(o.Box,{component:o.ButtonBase,children:G.jsx(o.Box,{onClick:()=>M(!B),sx:{width:10,color:"text.secondary",transform:B?"rotateX(0deg)":"rotateX(180deg)"},component:A.CaretUp})})]}),G.jsxs(o.Box,{sx:{mt:16,display:B?"initial":"none"},children:[G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"93m8jT",message:"Basic Fee"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"8Z29ZO",message:"Estimated service provider fees"}),ml:5})]}),G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:f?`${Ko({input:f,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"J39pAJ",message:"Additional Fee"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"ZXvy7b",message:"Additional routing fees set by the Widget user"}),ml:5})]}),G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:y?`${Ko({input:y,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),!!p&&G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"T+qgFw",message:"Price Impact"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),G.jsx(o.Box,{children:`${p}%`})]}),G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"GAypnX",message:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),G.jsxs(o.Box,{children:[b,"%"]})]})]})]}),G.jsx(o.Box,{sx:{flex:1}}),R&&G.jsxs(o.Box,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>I(!S),children:[G.jsx(o.Box,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:S?G.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:G.jsx(o.Box,{component:A.Done,sx:{width:14,color:"#1a1a1b"}})}):G.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${w.palette.text.secondary}`}})}),G.jsx(o.Box,{children:G.jsx(e.Trans,{components:{0:G.jsx(o.Box,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:p},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),G.jsx(o.Button,{isLoading:T==Xo.Pending,disabled:R&&!S,fullWidth:!0,onClick:()=>{n(),k(Yo(Xo.Pending))},children:T==Xo.Pending?G.jsx(e.Trans,{id:"P+K/3O",message:"Confirming"}):G.jsx(e.Trans,{id:"lQ6r7x",message:"Confirm swap"})})]})})}var ws;function ks({fromToken:t,toToken:n}){const a=o.useTheme(),{onlySolana:l}=Fo();or();const{customSlippage:s,customSlippageNum:d,handleSlippageChange:c,forecastSlippage:u,forecastSlippageQuery:p,recommendSlippage:h}=ar({fromToken:t,toToken:n}),[m,f]=i.useState(!1),[x,g]=i.useState();!x&&t&&n&&g(s?ws.custom:ws.recommend);const y=x===ws.custom;return i.useRef(null),i.useMemo((()=>x===ws.custom?d?new r(d).div(100).toNumber():void 0:new r(h).div(100).toNumber()),[x,h,d]),i.useCallback((e=>{y||g(ws.custom),c({slippage:new r(e).times(100).toString(),disabled:!1,deleted:!1,recommend:String(h)})}),[y,h,c]),l?G.jsxs(o.Box,{sx:{pt:20,borderTop:`1px solid ${a.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"}),G.jsx(o.QuestionTooltip,{title:G.jsx(e.Trans,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column"},children:[G.jsx(o.Input,{placeholder:String(h),fullWidth:!0,sx:{height:36,"& input":{boxSizing:"border-box","&::placeholder":{color:"custom.input.placeholder",opacity:1}}},inputMode:"decimal",suffix:G.jsx(o.Box,{sx:{color:"text.disabled"},children:"%"}),value:s||"",onChange:e=>{const t=e.target.value;c({slippage:t,disabled:!1,recommend:String(h)})},onBlur:()=>{setTimeout((()=>{if(f(!1),!d)return void g(ws.recommend);const e=!d||d<0;e&&s&&c({slippage:s,disabled:e,deleted:e,recommend:String(h)})}),10)}}),Number(s)>=To&&G.jsx(o.Box,{sx:{typography:"h6",mt:6,color:"error.main"},children:G.jsx(e.Trans,{id:"Zm56FI",message:"Maximum slippage do not exceed 50%"})})]})]}):null}function Ts({checked:t,onChange:n,sx:i,disabled:r}){const a=o.useTheme();let l=a.palette.background.paper;return t&&(l=a.palette.secondary.main),G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",position:"relative",borderRadius:8,backgroundColor:a.palette.background.input,opacity:r?.5:1},i),component:o.ButtonBase,disabled:r,onClick:()=>{r||n(!t)},children:[G.jsx(o.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"az8lvo",message:"Off"})}),G.jsx(o.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:t?a.palette.secondary.contrastText:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"Z5HWHd",message:"On"})}),G.jsx(o.Box,{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 Rs({show:t,onClick:n}){const i=o.useTheme();return G.jsxs(o.HoverOpacity,{weak:!0,sx:{display:t?"flex":"none",alignItems:"center",position:"absolute",bottom:28,left:"50%",transform:"translateX(-50%)",p:i.spacing(8,20),fontWeight:600,borderRadius:20,border:`solid 1px ${i.palette.border.main}`,backgroundColor:"background.paperContrast",boxShadow:`0px 8px 16px 0px ${o.alpha("light"===i.palette.mode?"#FFF":"#000",.1)}`,cursor:"pointer",whiteSpace:"nowrap",gap:4},onClick:n,children:[G.jsx(e.Trans,{id:"F8yRdq",message:"More trade settings"}),G.jsx(o.Box,{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:G.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 Ss({open:t,onClose:n,fromToken:r,toToken:l}){const s=o.useTheme(),{ddl:d,disableIndirectRouting:c}=or(),{onlySolana:u}=Fo(),p=i.useRef(null),[h,m]=i.useState(!1);return i.useEffect((()=>{const e=p.current,t=new ResizeObserver((()=>{e&&m(e.scrollHeight!==e.offsetHeight)})),n=a.throttle((()=>{if(!e)return;const t=e.scrollTop+e.clientHeight<e.scrollHeight-2;m(t)}),50);return e&&(m(e.scrollHeight!==e.clientHeight),t.observe(e),e.addEventListener("scroll",n)),()=>{e&&(t.unobserve(e),e.removeEventListener("scroll",n))}}),[null==p?void 0:p.current]),G.jsx(ds,{open:t,onClose:n,id:"swap-settings",title:G.jsx(e.Trans,{id:"Tz0i8g",message:"Settings"}),children:G.jsxs(o.Box,{sx:{px:20,pb:34,overflowY:"auto"},ref:p,children:[G.jsx(ks,{fromToken:r,toToken:l}),!u&&G.jsxs(o.Box,{sx:{mt:24,pt:14,borderTop:`solid 1px ${s.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[G.jsx(e.Trans,{id:"zSMRJ/",message:"Transaction Deadline"}),G.jsx(vs,{title:G.jsx(e.Trans,{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})]}),G.jsxs(o.Box,{sx:{mt:16,display:"flex",alignItems:"center",gap:8,typography:"body2"},children:[G.jsx(o.Input,{sx:{width:80,height:34,lineHeight:1,typography:"body2","& input":{px:16,py:6}},placeholder:String(Ro),value:d,onChange:e=>{or.setState({ddl:e.target.value})}}),G.jsx(e.Trans,{id:"H9HlDe",message:"minutes"})]})]}),!u&&G.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:24,pt:14,borderTop:`solid 1px ${s.palette.border.main}`},children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(o.Box,{sx:{fontWeight:600},children:[G.jsx(e.Trans,{id:"MXQodB",message:"Disable Indirect Routing"}),G.jsx(vs,{title:G.jsx(e.Trans,{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})]}),G.jsx(Ts,{checked:c,onChange:e=>{or.setState({disableIndirectRouting:e})}})]})}),G.jsx(Rs,{show:h,onClick:()=>{var e,t;null===(e=p.current)||void 0===e||e.scrollTo({top:null===(t=p.current)||void 0===t?void 0:t.scrollHeight,behavior:"smooth"})}})]})})}function Is({onClick:e,disabled:t,plus:n}){const i=o.useTheme(),r=t||n||!e;return G.jsx(o.Box,{sx:{width:"100%",position:"relative"},children:G.jsx(o.Box,{component:o.ButtonBase,sx:Object.assign({width:36,height:36,borderRadius:"50%",backgroundColor:i.palette.background.input,border:`4px solid ${i.palette.background.paper}`,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:28,height:28,border:"solid 1px",borderColor:"text.primary"}}}),disabled:r,onClick:()=>{r||e&&e()},children:n?G.jsx(o.Box,{component:A.Plus,sx:{width:18,height:18}}):G.jsx(o.Box,{component:A.ArrowBack,sx:{width:18,height:18}})})})}!function(e){e.recommend="recommend",e.custom="custom"}(ws||(ws={}));const Bs=()=>{const{requests:e,updateText:t}=Si(),n=i.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var o,i;if((n===No.Running||n===No.Success)&&(null===(o=e.metadata)||void 0===o?void 0:o.logBalance)&&(!e.doneTime||Math.ceil(Date.now()/1e3)-e.doneTime<300)){const n=null===(i=e.metadata)||void 0===i?void 0:i.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),o=i.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var o,i;if(n===No.Success&&(null===(o=e.metadata)||void 0===o?void 0:o.logBalance)&&e.doneTime&&Math.ceil(Date.now()/1e3)-e.doneTime<300){const n=null===(i=e.metadata)||void 0===i?void 0:i.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),a=i.useCallback(((e,n,o)=>{const i=e[n];if(!i)return!1;return!!(r.isBigNumber(o)?o:new r(o)).isEqualTo(i)||(t((e=>{var t;const o=Object.assign({},e.metadata);return(null===(t=null==o?void 0:o.logBalance)||void 0===t?void 0:t[n])?(delete o.logBalance[n],Object.keys(o.logBalance).length||delete o.logBalance,{brief:e.brief,spec:e.spec,metadata:o}):null})),!1)}),[t]),l=i.useCallback(((e,t)=>a(n,e,t)),[n,a]),s=i.useCallback(((e,t)=>a(o,e,t)),[o,a]);return{balanceData:n,balanceDataDone:o,isTokenLoading:l,isTokenLoadingDone:s}};function Ms({onClick:t,balance:n,decimals:i,address:r,showMaxBtn:a,canClickBalance:l,loading:s,balanceText:d}){const{palette:c}=o.useTheme(),u=l&&(null==n?void 0:n.gt(0))&&t;return G.jsxs(o.Box,{sx:Object.assign({typography:"body2",alignItems:"center",color:c.text.secondary,wordBreak:"break-word",textAlign:"right"},u?{"&:hover":{color:c.text.primary,cursor:"pointer"}}:{}),onClick:u?()=>t(n?n.toString():""):void 0,children:[null!=d?d:G.jsx(e.Trans,{id:"0QDjxt",message:"Balance:"})," ",s?G.jsx(o.RotatingIcon,{sx:{position:"relative",top:-2,verticalAlign:"middle"}}):G.jsxs(G.Fragment,{children:[r?Ko({input:n,decimals:Math.min(i||4,4)}):"-",a&&n&&n.gt(0)&&t&&G.jsx(o.Box,{component:o.ButtonBase,sx:{ml:6,color:(null==n?void 0:n.gt(0))?c.primary.main:c.text.disabled,cursor:r?"pointer":"unset",typography:"body2"},onClick:()=>t&&t(n?n.toString():""),children:G.jsx(e.Trans,{id:"CK1KXz",message:"Max"})})]})]})}const Es=i.forwardRef((function({readOnly:e,sx:t,value:n,decimals:r,onChange:a,suffix:l,suffixGap:s=0,withClear:d,onFocus:c,placeholder:u,readonlyShowSuffix:p,typography:h},m){const f=o.useTheme(),x=i.useMemo((()=>l||(d&&n&&a?G.jsx(o.Box,{component:o.ButtonBase,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:()=>{a&&a("")},children:G.jsx(o.Box,{component:A.Error,sx:{width:12}})}):void 0)),[a,l,f.palette.text.primary,n,d]);return G.jsx(o.Input,{fullWidth:!0,value:n,readOnly:e,placeholder:u||"0.00",onFocus:c,onChange:e=>{const t=e.target.value,n=0===t.length?"":ti(t,r);a&&a(n)},"data-testid":"number-input-wrapper",suffix:(!e||p)&&x,suffixGap:s,ref:m,sx:Object.assign({border:"none","& input":{fontSize:24,typography:h,border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:h,color:"text.disabled"}}},t)})}));function Ls(){const e=o.useTheme(),t=Fo((e=>e.width)),[n,r]=i.useState(null!=t?t:"undefined"==typeof window?375:document.body.clientWidth);i.useEffect((()=>{const e=()=>{r("undefined"==typeof window?375:document.body.clientWidth)};return"number"!=typeof t?(e(),window.addEventListener("resize",e)):r(t),()=>{window.removeEventListener("resize",e)}}),[t]);return{isMobile:i.useMemo((()=>"number"==typeof n&&n<e.breakpoints.values.tablet),[n,e.breakpoints.values]),isTablet:i.useMemo((()=>"number"==typeof n&&n<e.breakpoints.values.tablet),[n,e.breakpoints.values]),minDevice:i.useCallback((e=>"number"==typeof n&&n>e),[n]),maxDevice:i.useCallback((e=>"number"==typeof n&&n<e),[n])}}const Os=[.25,.5,.75,1];function Ws({value:e,onChange:t,sx:n}){const i=o.useTheme(),r="light"===i.palette.mode,{isMobile:a}=Ls();return G.jsx(o.Box,{sx:Object.assign({display:"grid",gap:a?10:14,gridTemplateColumns:`repeat(${Os.length}, 1fr)`},n),children:Os.map((n=>{const a=n===e;return G.jsxs(o.ButtonBase,{disabled:!t,sx:{typography:"h6",borderRadius:4,padding:i.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:disabled":{color:"text.disabled"},"&:not(:disabled)&:hover":{color:i.palette.text.primary,backgroundColor:o.alpha(i.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?i.palette.primary.main:o.alpha(i.palette.text.primary,.4)}},onClick:()=>{!a&&t&&t(n)},className:a?"selected":void 0,children:[100*n,"%"]},n)}))})}function Vs({token:t,onClick:n,showChainLogo:i,readonly:r,showChainName:a}){var l,s;const d=o.useTheme(),c=(null==t?void 0:t.chainId)?La.get(t.chainId):null,u=a&&!!c;return G.jsxs(o.Box,{component:o.ButtonBase,sx:{display:"flex",alignItems:"center",gap:8,color:d.palette.text.primary,typography:u?"body2":"body1",fontWeight:600,"&:focus-visible":{opacity:.5}},onClick:e=>{r||n&&n(e)},"data-testid":Bo,children:[!!(null==t?void 0:t.address)&&G.jsx(Wa,{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:!i,width:30,height:30,chainSize:16,logoOffset:10,marginRight:0}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[(null==t?void 0:t.address)?G.jsx(G.Fragment,{children:G.jsx(o.Box,{children:null!==(s=null==t?void 0:t.symbol)&&void 0!==s?s:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&G.jsx("svg",{width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 11.75L12 7.25H6L9 11.75Z",fill:"currentColor"})})]}),!!u&&G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[c.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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 As({token:e,disabled:t,style:n,balance:i,onClick:r}){const a=o.useTheme(),{account:l}=Zo(),s=i?Qo({input:i}):"";return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2",px:6,py:5,borderRadius:8,cursor:t?"auto":"pointer",opacity:t?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:n,onClick:()=>{t||r()},"data-testid":Lo,children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{token:e}),G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{fontWeight:600,textAlign:"left"},children:e.symbol}),l&&G.jsx(o.Box,{sx:{mt:4,textAlign:"left"},children:(null==i?void 0:i.gte(0))?s:G.jsx(o.Box,{component:A.Loading,width:18,sx:{"& path":{fill:a.palette.text.disabled},animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}}})})]})]}),G.jsx(o.Box,{sx:{color:"text.secondary",textAlign:"right"},children:e.name})]})}function Fs({chain:t,active:n,onClick:i}){return G.jsx(o.Tooltip,{title:t.name,placement:"top",onlyHover:!0,children:G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",p:8,borderRadius:8,cursor:"pointer"},n?{backgroundColor:"secondary.main",color:"secondary.contrastText"}:{border:"1px solid",borderColor:"border.main","&:hover":{backgroundColor:"hover.default"}}),onClick:i,children:[G.jsx(o.Box,{component:t.logo,sx:{width:24,height:24}}),n?G.jsxs(o.Box,{sx:{ml:8},children:[G.jsx(e.Trans,{id:"Fdp03t",message:"on"}),` ${t.name}`]}):""]})},t.chainId)}function Ps(e){try{return new u.PublicKey(e),!0}catch(e){return!1}}function Zs(e){if(e.length<=10)return e;try{return new u.PublicKey(e),`${e.slice(0,4)}...${e.slice(-4)}`}catch(t){return`${e.slice(0,6)}...${e.slice(-4)}`}}function Ns(e,t,n="address"){return`https://${yo[e]}${t?`/${n}/${t}`:""}`}function Us(){return G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[G.jsx(o.Skeleton,{variant:"circular",width:32,sx:{mt:8}}),G.jsxs(o.Box,{sx:{ml:8,flex:"1 0 auto"},children:[G.jsx(o.Skeleton,{sx:{borderRadius:4},height:24}),G.jsx(o.Skeleton,{sx:{mt:4,borderRadius:4},height:19,width:137})]})]})}function Hs({chainId:e,value:n,onChange:r,occupiedAddrs:a,occupiedChainId:s,hiddenAddrs:c,showAddrs:u,visible:p,side:h,defaultLoadBalance:m,multiple:f,searchPlaceholder:x,searchOtherAddress:g,sx:y}){const{chainList:v,selectChainId:b,setSelectChainId:j}=function(e){const{chainId:t}=Zo(),n=l.useSelector(Gi),{crossChain:o,onlyChainId:r}=Fo(),a=i.useMemo((()=>{const t=new Set;return n.forEach((n=>{n.side&&e&&n.side!==e||t.add(n.chainId)})),t}),[n,e]),s=i.useMemo((()=>{if(!o||r)return[];const e=new Map;let n;return La.forEach(((o,i)=>{if(a.has(o.chainId)){if(o.mainnet){if(t!==o.chainId)return;n=o.mainnet}e.set(i,Object.assign({},o))}})),void 0!==n&&e.delete(n),Array.from(e.values())}),[t,n,o,r]),d=i.useMemo((()=>!s.length||t&&a.has(t)?t:s[0].chainId),[t,a]),[c,u]=i.useState(d);i.useEffect((()=>{void 0===c&&u(d)}),[d]);const p=i.useMemo((()=>null!=c?c:d),[c,d]);return{chainList:s,selectChainId:p,setSelectChainId:u}}(h),{showTokenList:C,filter:w,setFilter:T,onSelectToken:R,popularTokenList:S,tokenInfoMap:I}=br({value:n,onChange:r,occupiedAddrs:a,occupiedChainId:s,hiddenAddrs:c,showAddrs:u,side:h,chainId:null!=e?e:b,visible:p,defaultLoadBalance:m,multiple:f}),B=i.useRef(null),[M,E]=i.useState(0);i.useEffect((()=>{if(p&&n)if(Array.isArray(n)){const[e]=n;e&&e.chainId!==b&&j(e.chainId)}else j(n.chainId)}),[n,p]),i.useEffect((()=>{let e;return p&&(e=window.setTimeout((()=>{B.current&&E(B.current.offsetHeight-16)}),300)),()=>clearTimeout(e)}),[B,p,b]);const L=d.useQuery({queryKey:["token-picker-searchOtherAddress",w],queryFn:()=>g?g(w):null,enabled:Ps(w)&&!!g}),O=i.useCallback((({index:e,style:t})=>{var o;const i=C[e];if(!i)return null;let r=!1;return n&&(r=Array.isArray(n)?n.some((e=>e.address===i.address&&e.chainId===i.chainId)):n.address===i.address&&n.chainId===i.chainId),G.jsx(As,{token:i,disabled:r,style:t,onClick:()=>R(i),balance:null===(o=I.get(`${i.chainId}-${i.address}`))||void 0===o?void 0:o.balance},i.address+i.chainId)}),[C,S,n]);return G.jsxs(o.Box,{sx:Object.assign({display:"flex",flexDirection:"column",px:20,flex:1,overflow:"hidden"},y),children:[G.jsx(o.SearchInput,{fullWidth:!0,height:48,value:w,onChange:e=>T(e.target.value),clearValue:()=>T(""),placeholder:null!=x?x:t.i18n._({id:"72/M0o",message:"Enter the token symbol or address"}),sx:{mb:16}}),void 0===e&&v.length?G.jsx(o.Box,{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:v.map((e=>G.jsx(Fs,{chain:e,active:e.chainId===b,onClick:()=>{j(e.chainId)}},e.chainId)))}):"",G.jsx(o.Box,{sx:{pb:16,flex:1,minHeight:64},ref:B,children:C.length?G.jsx(k.FixedSizeList,{height:M,itemCount:C.length,itemSize:52,width:"100%",className:"token-list",children:O}):G.jsxs(o.Box,{sx:{height:M,overflowY:"auto"},children:[L.isLoading?G.jsx(Us,{}):"",L.data?L.data:""]})})]})}function Ds({open:t,title:n,value:o,onClose:i,occupiedAddrs:r,hiddenAddrs:a,occupiedChainId:l,onTokenChange:s,side:d,defaultLoadBalance:c,multiple:u,searchPlaceholder:p,searchOtherAddress:h,chainId:m,modal:f}){const{height:x}=Fo(),{isMobile:g}=Ls();return G.jsx(ds,{height:f?"80vh":x,open:t,onClose:i,title:null!=n?n:G.jsx(e.Trans,{id:"T0Y2+3",message:"Select a token"}),id:"select-token",testId:Eo,modal:f,children:G.jsx(Hs,{value:o,visible:t,onChange:s,occupiedAddrs:r,occupiedChainId:l,hiddenAddrs:a,side:d,defaultLoadBalance:c,multiple:u,searchPlaceholder:p,searchOtherAddress:h,chainId:m,sx:f?{width:g?"100%":420,borderRadius:16}:void 0})})}function Ys(){return G.jsx(o.Box,{sx:{position:"relative",height:4},children:G.jsx(o.Box,{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:G.jsx(o.Box,{component:A.Plus})})})}function zs({sx:t,inputSx:n,amt:r,token:a,readOnly:l,showMaxBtn:s,canClickBalance:c,onMaxClick:u,fiatPriceTxt:p,occupiedAddrs:h,occupiedChainId:m,onInputFocus:f,onTokenClick:x,onInputChange:g,onTokenChange:y,side:v,showChainLogo:b,showChainName:j,defaultLoadBalance:C,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:R,inputReadonlyTooltip:S,inputTypography:I,chainId:B,hideToken:M,checkLogBalance:E,notTokenPickerModal:L}){var O,W;const{account:V,isSolana:A}=Zo(),F=o.useTheme(),{gotoBuyToken:P}=Fo(),[Z,N]=i.useState(!1),{fetchTokenBalance:U}=yi(),H=d.useQuery({queryKey:["token","getFetchTokenQuery",B,null==V?void 0:V.toLocaleLowerCase(),void 0,null==a?void 0:a.address],queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!a)return;const e=yield U(a.address);return Object.assign(Object.assign({},a),{balance:e.amount,allowance:Jo})})),enabled:!!V&&A&&!!a}),D=null!==(W=null!=w?w:null===(O=H.data)||void 0===O?void 0:O.balance)&&void 0!==W?W:null,{isTokenLoading:Y}=Bs();let z=null!=k?k:H.isLoading;!z&&D&&(E?z=Object.entries(E).some((([e,t])=>Y(e,t))):a&&(z=Y(a.address,D))),vi({tokenList:a?[a]:[],chainId:null==a?void 0:a.chainId});const[q,X]=i.useState(0),_=i.useRef("");i.useEffect((()=>{r!==_.current&&X(0)}),[r]);let J=P&&D&&r&&D.lt(r);const Q=!!g||!!S;return G.jsxs(o.Box,{sx:Object.assign({minHeight:Q?133:"auto",padding:F.spacing(20,20,24),borderRadius:12,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:F.palette.background.input},t),children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[M?G.jsx(o.Box,{}):G.jsx(Vs,{token:a,showChainLogo:b,showChainName:j,onClick:()=>N(!0),readonly:!y}),G.jsx(Ms,{balance:D,balanceText:T,onClick:l||!u&&!g?void 0:e=>{u?u(e):g&&g(e),0!==q&&1!==q&&(X(1),_.current=e)},showMaxBtn:s,canClickBalance:c,address:null==a?void 0:a.address,decimals:null==a?void 0:a.decimals,loading:z})]}),Q&&(l&&S?G.jsx(o.TooltipToast,{title:S,arrow:!1,children:G.jsx(o.Box,{children:G.jsx(Es,{value:r,readOnly:!0,withClear:!0,sx:Object.assign({mt:12},n)})})}):G.jsx(Es,{value:r,onFocus:f,onChange:g?e=>{g(e),X(0)}:void 0,readOnly:l,withClear:!0,suffix:J?G.jsx(o.Button,{variant:o.Button.Variant.tag,backgroundColor:F.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{e.stopPropagation(),null==P||P({token:a,account:V})},children:G.jsx(e.Trans,{id:"qiOIiY",message:"Buy"})}):void 0,typography:I,sx:{mt:12}})),!l&&R?G.jsx(Ws,{sx:{mt:16},value:q,onChange:D&&void 0!==(null==a?void 0:a.decimals)?e=>{if(D&&(null==a?void 0:a.decimals))if(X(e),1===e){const e=D.toString();u?u(e):g&&g(e),_.current=e}else if(g){const t=D.multipliedBy(e).dp(a.decimals).toString();g(t),_.current=t}}:void 0}):"",void 0!==p?G.jsx(o.Box,{sx:{mt:R?9:0,typography:"h6",color:F.palette.text.secondary},children:p}):"",G.jsx(Ds,{value:a,open:Z,side:v,chainId:B,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:C,onClose:()=>{N(!1),x&&x()},onTokenChange:(e,t)=>{N(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),as)},modal:!L})]})}function qs({toToken:t,fromToken:n,priceStatus:r,pricePerToToken:a,pricePerFromToken:l}){const[s,d]=i.useState("-"),[c,u]=i.useState(null),[p,h]=i.useState("-"),[m,f]=i.useState(null);i.useEffect((()=>{d(null==n?void 0:n.symbol),h(null==t?void 0:t.symbol),u(a),f(l)}),[n,t,a,l]);const x=i.useCallback((()=>{d(p),h(s),u(m),f(c)}),[s,c,p,m]);return G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:{[Oi.Initial]:"-",[Oi.Loading]:G.jsxs(G.Fragment,{children:[G.jsx(o.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]}),[Oi.Failed]:G.jsxs(G.Fragment,{children:[G.jsx(o.Box,{component:A.Warn,sx:{width:15,mr:5,color:"warning.main"}}),G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})]}),[Oi.Success]:G.jsxs(G.Fragment,{children:[G.jsx(o.Box,{sx:{typography:"body2"},children:`1 ${s} = ${Qo({input:m,showDecimals:4})} ${p}`}),G.jsx(o.Box,{component:o.ButtonBase,sx:{width:18,height:18,ml:6,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsx(o.Box,{sx:{width:16,color:"text.secondary"},onClick:x,component:A.Switch})})]})}[r]})}var Xs;exports.PageType=void 0,(Xs=exports.PageType||(exports.PageType={})).Pool="pool",Xs.PoolDetail="poolDetail",Xs.CreatePool="createPool",Xs.ModifyPool="modifyPool",Xs.MiningList="miningList",Xs.MiningDetail="miningDetail",Xs.createPoolAMMV2="createPoolAMMV2",Xs.createPoolAMMV3="createPoolAMMV3";const Gs=f.create(((e,t)=>({page:void 0,historyList:[],push:t=>{e((e=>{var n;const o=[...e.historyList,null!==(n=e.page)&&void 0!==n?n:{type:exports.PageType.Pool}];return{page:t,historyList:o}}))},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 _s({sx:t,onClick:n}){const i=o.useTheme();return G.jsxs(o.HoverOpacity,{onClick:()=>{n?n():Gs.getState().back()},sx:a.merge({display:"inline-flex",alignItems:"center",cursor:"pointer","& > svg":{mr:10}},t),children:[G.jsx(o.Box,{sx:{color:i.palette.text.secondary,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderColor:i.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:"50%",backgroundColor:i.palette.background.paper,mr:6},children:G.jsx(A.ArrowBack,{})}),G.jsx(e.Trans,{id:"CKyk7Q",message:"Go back"})]})}function Js({statuses:t,children:n,buttonProps:i}){var r;if(!t.find((e=>e.needShowTokenStatusButton))&&n)return G.jsx(G.Fragment,{children:n});const a=t.find((e=>e.insufficientBalance));if(a)return G.jsx(o.Button,{fullWidth:!0,disabled:!0,...i,children:G.jsx(e.Trans,{id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(r=a.token)||void 0===r?void 0:r.symbol}})});const l=t.some((e=>e.isApproving));return G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:t.map(((t,n)=>{var r,a;let s="";return t.isApproving?s=G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):(t.needReset||t.needApprove)&&(s=t.approveTitle),s?G.jsx(o.Button,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance||l,...i,children:s},null!==(a=null===(r=t.token)||void 0===r?void 0:r.symbol)&&void 0!==a?a:n):null}))})}function Qs({token:t,chainId:n,showChainLogo:r,readonly:a,showChainName:l,logoSize:s=24,chainLogoSize:d=12,side:c,occupiedToken:u,defaultLoadBalance:p,notTokenPickerModal:h,border:m,px:f=20,py:x=8,highlightDefault:g,onTokenClick:y,onTokenChange:v}){var b,j;const{onlyChainId:C}=Fo(),w=n||C,k=o.useTheme(),[T,R]=i.useState(!1),S=(null==t?void 0:t.chainId)?La.get(t.chainId):null,I=l&&!!S;return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:k.palette.text.primary,typography:I?"body2":"body1",fontWeight:600,px:f,py:x,"&:focus-visible":{opacity:.5}},!!m&&{border:`solid 1px ${k.palette.border.main}`,borderRadius:8,"&:hover":{backgroundColor:k.palette.hover.default}}),!(!g||t)&&{backgroundColor:k.palette.primary.main,color:k.palette.primary.contrastText,"&:hover":{opacity:.8}}),onClick:()=>{a||R(!0)},"data-testid":Mo,children:[!!(null==t?void 0:t.address)&&G.jsx(Wa,{url:null==t?void 0:t.logoURI,address:null!==(b=null==t?void 0:t.address)&&void 0!==b?b:"",chainId:null==t?void 0:t.chainId,noShowChain:!r,width:s,height:s,chainSize:d,logoOffset:10,marginRight:0}),G.jsxs(o.Box,{sx:{flex:1},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(null==t?void 0:t.address)?G.jsx(G.Fragment,{children:G.jsx(o.Box,{children:null!==(j=null==t?void 0:t.symbol)&&void 0!==j?j:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!a&&G.jsx(o.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{flexShrink:0},children:G.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"})})]}),!!I&&G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[S.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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"})})]})]})]}),G.jsx(Ds,{value:t,open:T,side:c,chainId:w,occupiedAddrs:u?[u.address]:void 0,occupiedChainId:null==u?void 0:u.chainId,defaultLoadBalance:p,onClose:()=>{R(!1),y&&y()},onTokenChange:(e,t)=>{R(!1),setTimeout((()=>{!Array.isArray(e)&&v&&v(e,t)}),as)},modal:!h})]})}const Ks=i.forwardRef((function(e,t){var{sx:n}=e,i=Oo(e,["sx"]);const{isMobile:r}=Ls(),a=o.useTheme();return G.jsx(o.Box,{className:"widget-module-container",ref:t,sx:Object.assign(Object.assign({flex:1,overflowY:"auto",backgroundColor:"background.default"},r?{padding:0,height:"100%",width:"100%",overflowX:"hidden"}:{padding:a.spacing(28,20,40,40),height:"auto"}),n),...i})})),$s="auto",ed="0.1",td="0.5",nd="0.5";function od(e){const t=i.useRef();return i.useEffect((()=>{t.current=e})),t.current}function id({baseToken:n,quoteToken:o,pairMintAAmount:i,pairMintBAmount:r,slippage:a,isExists:l,poolInfo:s,poolKeys:c,successBack:u,submittedBack:p}){const h=Si(),{account:m}=Zo(),f=Ua();return e.useLingui(),d.useMutation({mutationFn:()=>Wo(this,void 0,void 0,(function*(){if(!n||!o)throw new Error("token is undefined");if(!m)throw new Error("account is undefined");if(!s||!i||!r)throw new Error("poolInfo is undefined");if(!f)throw new Error("raydium is undefined");const e=new T(new R(i).mul(10**s.mintA.decimals).toFixed(0,R.ROUND_DOWN)),d=new y.Percent(100*a*100,1e4),{execute:x}=l?yield f.cpmm.addLiquidity({poolInfo:s,poolKeys:c,inputAmount:e,slippage:d,baseIn:!0,txVersion:y.TxVersion.LEGACY}):yield f.cpmm.createPool({programId:ui,poolFeeAccount:pi,mintA:s.mintA,mintB:s.mintB,mintAAmount:e,mintBAmount:new T(new R(r).mul(10**s.mintB.decimals).toFixed(0,R.ROUND_DOWN)),startTime:new T(0),feeConfig:hi[0],associatedOnly:!1,ownerInfo:{useSOLBalance:!0},txVersion:Aa});return yield h.executeCustom({brief:l?t.i18n._({id:"E6MqGy",message:"Add liquidity"}):t.i18n._({id:"L37FfW",message:"Create AMM V2 Position"}),metadata:{[l?exports.MetadataFlag.addLiquidityAMMV2Position:exports.MetadataFlag.createAMMV2Position]:!0},handler:e=>Wo(this,void 0,void 0,(function*(){const{txId:t}=yield x({sendAndConfirm:!0});e.onSuccess(t)})),successBack:u,submittedBack:p})})),onError:e=>{console.error(e)}})}function rd({pool:e,baseAmount:t,quoteAmount:n,slippage:o}){var a,l,s,c,p,h,m,f,x,g,v,b,j,C;const{account:w}=Zo(),k=Ua(),[R,S,I,B,M]=i.useMemo((()=>{if(!(null==e?void 0:e.baseToken)||!e.quoteToken)return[void 0,void 0,void 0,void 0,!0];const{baseToken:o,quoteToken:i}=e,r=new T(new u.PublicKey(o.address).toBuffer()).lte(new T(new u.PublicKey(i.address).toBuffer())),[a,l]=r?[o,i]:[i,o],[s,d]=r?[t,n]:[n,t];return[a,l,s,d,r]}),[t,e,n]),E=d.useQuery({queryKey:["cpmm","poolInfo",null==e?void 0:e.address],enabled:null!=(null==e?void 0:e.address),queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!(null==e?void 0:e.address)||!k)return null;const{poolInfo:t,poolKeys:n,rpcData:o}=yield k.cpmm.getPoolInfoFromRpc(e.address);if(!o)return{baseReserve:0,quoteReserve:0,lpAmount:0};const[i,r]=t.mintA.address.toLowerCase()===e.baseToken.address.toLowerCase()?[e.baseToken.symbol,e.quoteToken.symbol]:[e.quoteToken.symbol,e.baseToken.symbol],a=oi(t.lpAmount,t.lpMint.decimals);return{baseReserve:oi(o.baseReserve.toNumber(),n.mintA.decimals),quoteReserve:oi(o.quoteReserve.toNumber(),n.mintB.decimals),lpAmount:a,lpMint:t.lpMint,poolKeys:Object.assign(Object.assign({},n),{mintA:Object.assign(Object.assign({},n.mintA),{symbol:i}),mintB:Object.assign(Object.assign({},n.mintB),{symbol:r})}),poolInfo:Object.assign(Object.assign({},t),{lpAmount:a.toNumber(),mintA:Object.assign(Object.assign({},t.mintA),{symbol:i}),mintB:Object.assign(Object.assign({},t.mintB),{symbol:r})}),rpcData:o}}))}),L=d.useQuery({queryKey:["cpmm","lpBalance",null===(l=null===(a=E.data)||void 0===a?void 0:a.lpMint)||void 0===l?void 0:l.address],enabled:!!(w&&E.data&&(null===(s=E.data)||void 0===s?void 0:s.lpMint)&&(null===(p=null===(c=E.data)||void 0===c?void 0:c.lpMint)||void 0===p?void 0:p.address)&&(null===(m=null===(h=E.data)||void 0===h?void 0:h.lpMint)||void 0===m?void 0:m.decimals)),queryFn:()=>Wo(this,void 0,void 0,(function*(){var e,t,n,o,i;if(!(w&&E.data&&(null===(e=E.data)||void 0===e?void 0:e.lpMint)&&(null===(n=null===(t=E.data)||void 0===t?void 0:t.lpMint)||void 0===n?void 0:n.address)&&(null===(i=null===(o=E.data)||void 0===o?void 0:o.lpMint)||void 0===i?void 0:i.decimals)&&k))return null;yield k.account.fetchWalletTokenAccounts();const r=E.data.lpMint.address,a=k.account.tokenAccounts.find((e=>e.mint.toBase58()===r));if(!a)throw new Error(`you do not have balance in pool: ${r}`);return oi(a.amount.toNumber(),E.data.lpMint.decimals)}))}),O=d.useQuery({queryKey:["cpmm","pairAmount",I,null===(f=E.data)||void 0===f?void 0:f.poolInfo],enabled:!(!E.data||!(null===(x=E.data)||void 0===x?void 0:x.poolInfo)||!I),queryFn:()=>Wo(this,void 0,void 0,(function*(){var e;if(!(E.data&&(null===(e=E.data)||void 0===e?void 0:e.poolInfo)&&I&&k))return null;const t=E.data.poolInfo,n=yield k.cpmm.computePairAmount({baseReserve:E.data.rpcData.baseReserve,quoteReserve:E.data.rpcData.quoteReserve,poolInfo:t,amount:I,slippage:new y.Percent(100*o*100,1e4),baseIn:!0,epochInfo:yield k.fetchEpochInfo()});return{pairMintAAmount:I,pairMintBAmount:oi(n.anotherAmount.amount.toString(),t.mintB.decimals).toString(),liquidityMinted:oi(n.liquidity.toString(),t.lpMint.decimals)}}))}),[W,V,A,F]=i.useMemo((()=>{if(!E.data||!L.data)return[void 0,void 0,void 0,void 0];const{baseReserve:e,quoteReserve:t,lpAmount:n}=E.data,o=L.data,i=o.div(n),r=o.multipliedBy(e).div(n),a=o.multipliedBy(t).div(n);return[o,i,r,a]}),[E.data,L.data]),P=i.useMemo((()=>E.isFetched&&null!=E.data),[E.isFetched,E.data]),[Z,N]=i.useMemo((()=>{var e,o;if(P){if(null!=(null===(o=null===(e=E.data)||void 0===e?void 0:e.poolInfo)||void 0===o?void 0:o.price)){const e=new r(E.data.poolInfo.price);return[e,new r(1).div(e)]}return[void 0,void 0]}return t&&n?[new r(n).div(t),new r(t).div(n)]:[void 0,void 0]}),[t,P,null===(v=null===(g=E.data)||void 0===g?void 0:g.poolInfo)||void 0===v?void 0:v.price,n]);return{isFront:M,poolInfoQuery:E,lpBalanceQuery:L,lpBalance:W,lpBalancePercentage:V,lpToAmountA:A,lpToAmountB:F,price:Z,invertedPrice:N,liquidityMinted:null===(b=O.data)||void 0===b?void 0:b.liquidityMinted,pairMintAAmount:null===(j=O.data)||void 0===j?void 0:j.pairMintAAmount,pairMintBAmount:null===(C=O.data)||void 0===C?void 0:C.pairMintBAmount,isExists:P}}const ad="DODO_WIDGET_POOL_LIST_TAB",ld="DODO_WIDGET_POOLS_LIST_FILTER_CHAIN";var sd;!function(e){e.addLiquidity="add-liquidity",e.myLiquidity="my-liquidity",e.myCreated="my-created"}(sd||(sd={}));var dd=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],o=0;o<e.rangeCount;o++)n.push(e.getRangeAt(o));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()}},cd={"text/plain":"Text","text/html":"Url",default:"Text"};var ud=function(e,t){var n,o,i,r,a,l,s=!1;t||(t={}),n=t.debug||!1;try{if(i=dd(),r=document.createRange(),a=document.getSelection(),(l=document.createElement("span")).textContent=e,l.ariaHidden="true",l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",(function(o){if(o.stopPropagation(),t.format)if(o.preventDefault(),void 0===o.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var i=cd[t.format]||cd.default;window.clipboardData.setData(i,e)}else o.clipboardData.clearData(),o.clipboardData.setData(t.format,e);t.onCopy&&(o.preventDefault(),t.onCopy(o.clipboardData))})),document.body.appendChild(l),r.selectNodeContents(l),a.addRange(r),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");s=!0}catch(i){n&&console.error("unable to copy using execCommand: ",i),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),s=!0}catch(i){n&&console.error("unable to copy using clipboardData: ",i),n&&console.error("falling back to prompt"),o=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(o,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(r):a.removeAllRanges()),l&&document.body.removeChild(l),i()}return s},pd=W(ud);function hd({copyText:e,size:n,sx:r,componentProps:a,onClick:l,children:s}){var d;const[c,u]=i.useState(!1);return G.jsx(o.TooltipToast,{title:t.i18n._({id:"6V3Ea3",message:"Copied"}),open:c,onClose:()=>u(!1),arrow:!1,children:G.jsxs(o.Box,{...a,component:null!==(d=null==a?void 0:a.component)&&void 0!==d?d:o.ButtonBase,onClick:t=>{if(null==a?void 0:a.onClick)return a.onClick(t);t.stopPropagation(),e&&(pd(e),u(!0)),l&&l()},sx:Object.assign({cursor:"pointer"},null==a?void 0:a.sx),children:[G.jsx(o.Box,{component:A.Copy,sx:Object.assign({width:n||"auto",height:n||"auto"},r)}),s]})})}function md({truncate:e,address:t,disabledAddress:n,sx:i,handleOpen:r,addressHoverColor:a,addressHoverShowIcon:l}){return n?G.jsx(o.Box,{children:e?Zs(t):t}):G.jsx(o.HoverAddUnderLine,{lineSx:{bottom:-1},lineColor:null!=a?a:(null==i?void 0:i.color)||"",hoverSx:{color:"addressHoverColor","& svg":{display:"inline-block"}},className:"truncate-address-link",children:G.jsxs(o.Box,{onClick:e=>{null==r||r(e,"address")},sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[e?Zs(t):t,l?G.jsx(o.Box,{component:A.ArrowRight,sx:{display:"none",width:14,height:14}}):""]})})}function fd({address:e,truncate:t,showCopy:n,size:i="medium",iconSize:r,iconSpace:a,sx:l,iconDarkHover:s,disabledAddress:d,addressHoverColor:c,addressHoverShowIcon:u,customChainId:p,handleOpen:h,onAddressClick:m}){const f=o.useTheme(),x="big"===i,g="medium"===i,y=s?o.HoverAddBackground:o.HoverOpacity,v=e=>{let t=e?12:8;return a&&(t=a),s&&(t-=3),t},b=x?"h5":g?"body1":"body2",{chainId:j}=Zo(),C=null!=p?p:j,w=(t,n)=>{h?h(t,n):C&&(t.stopPropagation(),window.open(Ns(C,e,"address")))};return G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",typography:b,color:f.palette.text.primary,lineHeight:"normal"},l||{}),children:[G.jsx(md,{truncate:t,address:e,disabledAddress:d,sx:l,typography:b,handleOpen:null!=m?m:w,addressHoverColor:c,addressHoverShowIcon:u}),G.jsx(y,{sx:{display:"inline-flex",ml:v(g),cursor:"pointer"},onClick:e=>{w(e,"icon")},children:G.jsx(o.Box,{component:A.ArrowTopRightBorder,sx:{width:r||(g?16:14),height:r||(g?16:14)}})}),n?G.jsx(hd,{size:r||(g?16:14),copyText:e,componentProps:{component:y,sx:{ml:v(g)}}}):null]})}function xd(e){var{sx:t,label:n,children:i}=e,r=Oo(e,["sx","label","children"]);return G.jsxs(o.Box,{sx:Object.assign({display:"flex",justifyContent:"space-between"},t),...r,children:[G.jsx(o.Box,{children:n}),G.jsx(o.Box,{sx:{textAlign:"right",fontWeight:600},children:i})]})}function gd({tokens:e,width:t=24,height:n=24,gap:i=-4,cross:r,mr:a,chainId:l,showChainLogo:s,sx:d}){var c;const u=o.useTheme(),{onlyChainId:p}=Fo(),h=s&&!p;if(!e||e.length<=0)return null;const m=t/2;return G.jsxs(o.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:a,position:"relative",zIndex:0},d),children:[e.map(((e,n)=>G.jsx(o.Box,{sx:{display:"inline-flex",width:t,height:t,ml:n>0?i:0,borderRadius:"50%",backgroundColor:u.palette.background.default},children:"object"==typeof e?G.jsx(Wa,{address:e.address,width:t,height:t,chainId:l,url:e.logoURI,cross:r,noShowChain:!0,noBorder:!0,marginRight:0}):G.jsx(o.Box,{component:"img",height:t,src:e})},n))),h&&La.has(l)?G.jsx(o.Box,{component:null===(c=La.get(l))||void 0===c?void 0:c.logo,sx:{position:"absolute",bottom:0,right:0,zIndex:e.length+1,transform:"translateX(50%)",width:m,height:m}}):""]})}function yd({baseToken:e,quoteToken:t,midPrice:n,loading:a,disabled:l}){const s=o.useTheme(),[d,c]=i.useState(!1),u=d?null==t?void 0:t.symbol:null==e?void 0:e.symbol,p=d&&n?new r(1).div(n):n,h=d?null==e?void 0:e.symbol:null==t?void 0:t.symbol;return G.jsxs(o.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:a,loadingProps:{width:50},children:[e&&t?G.jsx(o.Tooltip,{title:`1 ${u} = ${p?Qo({input:p}):""} ${h}`,children:n?G.jsx(o.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${u} = ${p?Qo({input:p}):""} ${h}`}):G.jsxs(o.Box,{children:[`1 ${u} = `,G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:30},component:"span",sx:{display:"inline-block"},children:"-"}),` ${h}`]})}):"-",G.jsx(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,backgroundColor:"background.paperDarkContrast",borderRadius:"50%"},!l&&{cursor:"pointer","&:hover":{backgroundColor:o.alpha(s.palette.text.primary,.04)}}),onClick:()=>{l||c((e=>!e))},children:G.jsx(o.Box,{component:A.Switch,sx:{width:18,height:18}})})]})}function vd({baseToken:t,quoteToken:n,loading:i,midPrice:a,lpBalancePercentage:l,sx:s}){const d=o.useTheme(),c=!t||!n;return G.jsxs(o.Box,{sx:Object.assign({mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},s),children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[G.jsx(o.Box,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"kNeEXg",message:"Current Price"})}),G.jsx(yd,{baseToken:t,quoteToken:n,loading:i,disabled:c,midPrice:a})]}),G.jsxs(o.Box,{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:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"})}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:G.jsx(o.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:i,loadingProps:{width:50},children:l?`${di({input:l,roundingMode:r.ROUND_DOWN})}`:"-%"})})]})]})}function bd({open:t,onClose:n,slippage:i,baseToken:r,quoteToken:a,pairMintAAmount:l,pairMintBAmount:s,lpAmount:d,feeRate:c,price:u,lpBalancePercentage:p,pairAddress:h,createMutation:m}){const f=o.useTheme(),{isMobile:x}=Ls();return G.jsx(ds,{modal:!0,open:t,onClose:n,title:d?G.jsx(e.Trans,{id:"AeZIvT",message:"You will receive"}):G.jsx(e.Trans,{id:"aM1tos",message:"You are creating a pool"}),children:G.jsxs(o.Box,{sx:{px:20,py:24,borderTopWidth:1,width:x?"100%":420},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h3"},children:[G.jsx(gd,{width:24,height:24,tokens:r&&a?[r,a]:[]}),d?Ko({input:d,decimals:null==r?void 0:r.decimals}):""]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,fontWeight:600},children:[G.jsx(e.Trans,{id:"syToc5",message:"{0}/{1} Pool Tokens",values:{0:null==r?void 0:r.symbol,1:null==a?void 0:a.symbol}}),G.jsx(o.Box,{sx:{px:4,py:2,fontSize:10,lineHeight:1,backgroundColor:o.alpha(f.palette.purple.main,.1),color:f.palette.purple.main,borderRadius:4},children:G.jsx(e.Trans,{id:"rbsyJM",message:"AMM V2"})})]})]}),G.jsx(o.Box,{sx:{mt:16,typography:"h6",color:"text.secondary",textAlign:"center"},children:G.jsx(e.Trans,{id:"rQ9c+8",message:"Output is estimated. If the price changes by more than {0} your transaction will revert.",values:{0:di({input:i})}})}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:20,p:20,typography:"body2",borderRadius:12,backgroundColor:f.palette.background.paperContrast},children:[G.jsx(xd,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==r?void 0:r.symbol}}),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[G.jsx(Wa,{width:18,height:18,marginRight:4,token:r}),Ko({input:l,decimals:null==r?void 0:r.decimals})]})}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==a?void 0:a.symbol}}),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{width:18,height:18,marginRight:4,token:a}),Ko({input:s,decimals:null==a?void 0:a.decimals})]})}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"}),children:null!=c?Number(c)/1e4+"%":"-"}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"}),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{width:18,height:18,marginRight:4,token:r}),G.jsx(yd,{baseToken:r,quoteToken:a,midPrice:u})]})}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"}),children:p?`${di({input:p})}`:"-%"}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"ESQO1L",message:"Pool address"}),children:G.jsx(fd,{showCopy:!1,address:null!=h?h:"",customChainId:null==r?void 0:r.chainId,truncate:!0,iconSpace:4,sx:{typography:"body2"}})})]}),G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,sx:{mt:20},isLoading:m.isPending,onClick:()=>{m.mutate()},children:m.isPending?G.jsx(e.Trans,{id:"pwUZo2",message:"Confirming..."}):G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})})}function jd({title:e,disabled:t,children:n}){return G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:12,opacity:t?.3:void 0},children:[G.jsx(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:600},children:e}),n]})}function Cd({disabled:t,feeIndex:n,onChange:a,feeList:l}){const s=o.useTheme(),[d,c]=i.useState(!1),{isMobile:u}=Ls(),p=t,h=l[n];return G.jsxs(o.Box,{sx:{opacity:t?.3:void 0,fontWeight:600},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:12,borderWidth:1,borderRadius:12},children:[G.jsx(e.Trans,{id:"tMMG40",message:"{0}% fee tier",values:{0:h?new r(h.tradeFeeRate).div(1e4).toString():"-"}}),G.jsx(o.ButtonBase,{sx:{px:16,py:7,border:`solid 1px ${s.palette.text.primary}`,borderRadius:8,fontWeight:600,color:"text.primary",cursor:p?"default":"pointer"},disabled:p,onClick:()=>{p||c((e=>!e))},children:d?G.jsx(e.Trans,{id:"vLyv1R",message:"Hide"}):G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})})]}),d&&G.jsx(G.Fragment,{children:G.jsx(o.Box,{sx:Object.assign({mt:12},u?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8,"& > label":{flex:1}}),children:l.map(((e,t)=>{const i=n===t;return G.jsxs(o.Box,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,cursor:"pointer"},i&&{borderColor:s.palette.primary.main}),children:[e.tradeFeeRate/1e4,"%",G.jsx(o.Radio,{size:18,checked:i,onChange:(e,n)=>{n&&a(t)}})]},e.id)}))})})]})}function wd({chainId:e,address:t,showName:n,size:i,offset:r,rightContent:a}){const l=G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:r},children:[G.jsx(Wa,{chainId:e,address:t,width:i,height:i,noShowChain:!0,marginRight:0}),n]});return a?G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l,a]}):l}function kd({isExists:t,poolInfo:i,poolInfoLoading:a,lpBalanceLoading:l,lpBalance:s,lpBalancePercentage:d,lpToAmountA:c,lpToAmountB:u,sx:p}){var h,m;const f=d?`${di({input:d,roundingMode:r.ROUND_DOWN})}`:void 0;return t&&i?G.jsxs(o.Box,{sx:Object.assign({px:20,py:12,borderWidth:1,borderRadius:8},p),children:[G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(o.Box,{sx:{mt:12,display:"flex",alignItems:"center",flexWrap:"wrap"},children:[G.jsx(gd,{width:18,height:18,tokens:[i.mintA,i.mintB],mr:4}),G.jsx(o.LoadingSkeleton,{loading:l,loadingProps:{width:50},sx:{mr:4},children:Ko({input:s,decimals:i.lpMint.decimals})}),`${i.mintA.symbol}/${i.mintB.symbol} LP`,G.jsx(o.Tooltip,{title:G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:10,typography:"body2",color:"text.primary"},children:[G.jsx(wd,{address:i.mintA.address,chainId:i.mintA.chainId,showName:null!==(h=i.mintA.symbol)&&void 0!==h?h:"",size:14,offset:4,rightContent:G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:50},children:Ko({input:c,decimals:i.mintA.decimals})})}),G.jsx(wd,{address:i.mintB.address,chainId:i.mintB.chainId,showName:null!==(m=i.mintB.symbol)&&void 0!==m?m:"",size:14,offset:4,rightContent:G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:50},children:Ko({input:u,decimals:i.mintB.decimals})})}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"c4miqE",message:"Pool share"}),G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:50},children:f})]})]}),sx:{padding:20,width:256},children:G.jsx(o.HoverOpacity,{component:A.DetailBorder,sx:{ml:4,width:16,height:16,cursor:"pointer"}})}),G.jsx(o.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:Ns(n.ChainId.SOON_TESTNET,i.lpMint.address,"address"),sx:{ml:4,display:"inline-flex",height:16},children:G.jsx(o.HoverOpacity,{component:A.ArrowTopRightBorder,sx:{width:16,height:16}})})]})]}):null}function Td({active:t,sx:n,onClick:i}){const r=o.useTheme(),a="light"===r.palette.mode;let l=r.palette.primary.main,s="transparent";return t&&(l=r.palette.primary.contrastText,s=o.alpha(r.palette.primary.main,.8)),G.jsx(o.Box,{component:o.ButtonBase,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:s,borderRadius:8,fontWeight:600,"&:hover":{color:t?r.palette.primary.contrastText:r.palette.primary.main,backgroundColor:t?r.palette.primary.main:a?"rgba(26, 26, 27, 0.04)":"rgba(241, 249, 2, 0.08)"}},n),onClick:i,children:G.jsx(e.Trans,{id:"R9Khdg",message:"Auto"})})}function Rd({sx:t,disabled:n,slippage:a,onChangeSlippage:l}){const s=o.useTheme(),d=a===$s,[c,u]=i.useState(d?"":new r(a).times(100).toNumber());return G.jsx(o.Tooltip,{disabled:n,onlyClick:!0,title:G.jsxs(o.Box,{sx:{backgroundColor:s.palette.background.paper,padding:s.spacing(16,20),borderRadius:16,width:375,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.primary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[d?td:a&&new r(a).times(100).toNumber(),"%"]})]}),G.jsxs(o.Box,{sx:{mt:16,display:"flex",alignItems:"center",margin:s.spacing(16,0,0,0)},children:[G.jsx(Td,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{u(""),l($s)},active:d}),G.jsx(o.Input,{placeholder:String(td),value:c,onChange:e=>{const{value:t}=e.target;u(t),l(t?new r(t).div(100).toNumber():$s)},onBlur:()=>{(!d&&new r(a).gt(.1)||new r(a).lte(0))&&(u(10),l(.1))},suffix:G.jsx(o.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(o.HoverAddBackground,{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:G.jsx(o.Box,{component:A.Setting,sx:{width:18,height:18,"& path:last-child":{fill:s.palette.text.primary}}})})})}function Sd(){var t,n,a;const[l,s]=i.useState(0),[d,c]=i.useState(),[p,h]=i.useState(),[m,f]=i.useState(""),[x,g]=i.useState(""),[v,b]=i.useState($s),j=v===$s?new r(td).div(100).toNumber():v,{isMobile:C}=Ls(),{onlyChainId:w}=Fo(),k=i.useMemo((()=>w||(null==d?void 0:d.chainId)||(null==p?void 0:p.chainId)),[w,d,p]),{poolKeys:R,poolInfo:S,pairAddress:I,price:B,isInvalidPair:M,invertedPrice:E,poolInfoLoading:L,lpBalanceLoading:O,lpBalance:W,lpBalancePercentage:V,lpToAmountA:F,lpToAmountB:P,liquidityMinted:Z,pairMintAAmount:N,pairMintBAmount:U,isExists:H}=function({baseToken:e,quoteToken:t,baseAmount:n,quoteAmount:o,feeIndex:r,slippage:a}){var l,s,d;const[c,p]=i.useMemo((()=>{if(!e||!t||null==r)return[void 0,!0];const n=new T(new u.PublicKey(e.address).toBuffer()).lte(new T(new u.PublicKey(t.address).toBuffer())),[o,i]=n?[e,t]:[t,e],[a,l]=[new u.PublicKey(o.address),new u.PublicKey(i.address)];return[y.getCreatePoolKeys({poolId:void 0,programId:ui,configId:new u.PublicKey(hi[r].id),mintA:a,mintB:l}),a.toBase58()===l.toBase58()]}),[r,e,t]),{price:h,invertedPrice:m,poolInfoQuery:f,lpBalanceQuery:x,lpBalance:g,lpBalancePercentage:v,lpToAmountA:b,lpToAmountB:j,liquidityMinted:C,pairMintAAmount:w,pairMintBAmount:k,isExists:R}=rd({pool:e&&t&&c?{baseToken:e,quoteToken:t,address:c.poolId.toBase58()}:void 0,baseAmount:n,quoteAmount:o,slippage:a});return{poolKeys:null===(l=f.data)||void 0===l?void 0:l.poolKeys,poolInfo:null===(s=f.data)||void 0===s?void 0:s.poolInfo,pairAddress:null===(d=null==c?void 0:c.poolId)||void 0===d?void 0:d.toBase58(),isInvalidPair:p,price:h,invertedPrice:m,poolInfoLoading:f.isLoading,lpBalanceLoading:x.isLoading,lpBalance:g,lpBalancePercentage:v,lpToAmountA:b,lpToAmountB:j,liquidityMinted:C,pairMintAAmount:w,pairMintBAmount:k,isExists:R}}({baseToken:d,quoteToken:p,baseAmount:m,quoteAmount:x,feeIndex:l,slippage:j}),D=od(B);if(B&&m&&!B.isEqualTo(null!=D?D:0)&&H){const e=B.times(m).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18);e.isEqualTo(x)||g(e.toString())}const Y=ur(d,{amount:m}),z=ur(p,{amount:x}),[q,X]=i.useState(!1),_=!d||!p,J=()=>{Gs.getState().push({type:exports.PageType.Pool})},Q=id({baseToken:d,quoteToken:p,pairMintAAmount:N,pairMintBAmount:U,isExists:H,poolKeys:R,poolInfo:S,slippage:j,successBack:()=>{Gs.getState().push({type:exports.PageType.Pool,params:{tab:sd.myLiquidity}})}});return G.jsxs(Ks,{children:[G.jsxs(o.Box,{sx:{mx:"auto",borderRadius:C?0:16,backgroundColor:"background.paper",width:C?"100%":600,position:"relative",overflow:"hidden"},children:[C?G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20,pb:0},children:G.jsx(_s,{onClick:J})}):G.jsxs(o.Box,{sx:{position:"relative",display:"flex",justifyContent:"center",alignItems:"center",px:20,py:24,typography:"caption"},children:[G.jsx(o.Box,{component:A.ArrowBack,sx:{position:"absolute",left:20,cursor:"pointer"},onClick:J}),G.jsx(e.Trans,{id:"E6MqGy",message:"Add liquidity"})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:20,pt:24,px:20,pb:20},children:[G.jsx(kd,{isExists:H,poolInfo:S,poolInfoLoading:L,lpBalanceLoading:O,lpBalance:W,lpBalancePercentage:V,lpToAmountA:F,lpToAmountB:P}),G.jsxs(jd,{title:G.jsx(e.Trans,{id:"nxRg31",message:"Select pair"}),children:[G.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:C?"repeat(1, 1fr)":"repeat(2, 1fr)",gap:12},children:[G.jsx(Qs,{border:!0,highlightDefault:!0,chainId:k,token:d,onTokenChange:(e,t)=>{t?(c(p),h(d),f(""),g("")):(c(e),f(""))},occupiedToken:p}),G.jsx(Qs,{border:!0,highlightDefault:!0,chainId:k,token:p,onTokenChange:(e,t)=>{t?(c(p),h(d)):(h(e),g(""))},occupiedToken:d})]}),G.jsx(Cd,{feeIndex:l,onChange:s,feeList:hi,disabled:_})]}),G.jsx(jd,{title:G.jsx(e.Trans,{id:"MU9s7M",message:"Deposit amounts"}),disabled:_,children:G.jsxs(o.Box,{children:[G.jsx(zs,{sx:{mb:4,pb:28,minHeight:"auto"},token:d,amt:m,defaultLoadBalance:!0,onInputChange:e=>{var t;f(e);const n=Number(e);H&&B&&n&&g(B.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:_}),G.jsx(Is,{plus:!0}),G.jsx(zs,{sx:{pb:20,minHeight:"auto"},token:p,amt:x,defaultLoadBalance:!0,onInputChange:e=>{var t;g(e);const n=Number(e);H&&E&&n&&f(E.times(e).dp(null!==(t=null==d?void 0:d.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(a=null==d?void 0:d.address)&&void 0!==a?a:""],occupiedChainId:null==d?void 0:d.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:_}),G.jsx(Rd,{slippage:v,onChangeSlippage:b,disabled:_,sx:{mt:8}}),G.jsx(vd,{baseToken:d,quoteToken:p,loading:L,midPrice:B,lpBalancePercentage:H?V:100}),!!H&&G.jsxs(o.Box,{sx:{mt:20,p:20,borderRadius:16,backgroundColor:"background.paperContrast",typography:"h6",textAlign:"center","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"XoymfI",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:di({input:hi[l].tradeFeeRate/1e4})},components:{0:G.jsx("b",{})}})]})]})})]}),G.jsx(o.Box,{sx:{py:16,px:20,borderTopWidth:1},children:G.jsx(bs,{fullWidth:!0,includeButton:!0,size:o.Button.Size.big,disabled:_,chainId:k,children:G.jsx(Js,{statuses:[Y,z],buttonProps:{size:o.Button.Size.big},children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,disabled:!(d&&p&&m&&x&&!M&&null!=l),onClick:()=>X(!0),children:M?G.jsx(e.Trans,{id:"R7D79P",message:"Invalid pair"}):G.jsx(e.Trans,{id:"bwSQI0",message:"Supply"})})})})})]}),G.jsx(bd,{open:q,onClose:()=>X(!1),slippage:j,baseToken:d,pairMintAAmount:N,quoteToken:p,pairMintBAmount:U,feeRate:hi[l].tradeFeeRate,price:B,lpAmount:Z,lpBalancePercentage:H?V:100,pairAddress:I,createMutation:Q})]})}const Id=({type:e})=>{const[t,o]=i.useState($s),a=i.useMemo((()=>t===$s?e===n.CLMM?new r(nd).div(100).toNumber():e===n.CPMM?new r(td).div(100).toNumber():new r(ed).div(100).toNumber():t),[t,e]);return{slipper:t,setSlipper:o,slipperValue:a,resetSlipper:()=>{o($s)}}};function Bd({type:t,disabled:a,value:l,onChange:s,sx:d}){const c=o.useTheme(),u=l===$s,[p,h]=i.useState(u?"":new r(l).times(100).toNumber()),m=t===n.CLMM?nd:t===n.CPMM?td:ed;return G.jsx(o.Tooltip,{disabled:a,onlyClick:!0,title:G.jsxs(o.Box,{sx:{backgroundColor:c.palette.background.paper,padding:c.spacing(12,20),borderRadius:8,width:318,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[u?m:l&&new r(l).times(100).toNumber(),"%"]})]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",margin:c.spacing(16,0,0,0)},children:[G.jsx(Td,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{h(""),s($s)},active:u}),G.jsx(o.Input,{placeholder:String(m),value:p,onChange:e=>{const{value:t}=e.target;h(t),s(t?new r(t).div(100).toNumber():$s)},onBlur:()=>{(!u&&new r(l).gt(.1)||new r(l).lte(0))&&(h(10),s(.1))},suffix:G.jsx(o.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(o.HoverAddBackground,{sx:Object.assign({width:"max-content",alignItems:"right",margin:c.spacing(0,0,0,"auto"),p:c.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast"},d),children:G.jsx(o.Box,{component:A.Setting,sx:{width:18,height:18,"& path:last-child":{fill:c.palette.text.primary}}})})})}const Md=({chainId:e,isValid:n,errorMessage:i,setShowConfirm:r})=>G.jsx(bs,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:()=>{r(!0)},disabled:!n,danger:!n,children:i||t.i18n._({id:"rdUucN",message:"Preview"})})}),Ed=[.25,.5,.75,1];function Ld({currentValue:e,onClick:t,sx:n}){const r=o.useTheme(),a="light"===r.palette.mode,{isMobile:l}=Ls(),[s,d]=i.useState(null),c=i.useRef(0);i.useEffect((()=>{e?(c.current+=1,c.current>=2&&(d(null),c.current=0)):d(null)}),[e]);const u=od(e);return i.useEffect((()=>{u===e&&1===s&&(c.current=1)}),[e,u,s]),G.jsx(o.Box,{sx:Object.assign({display:"grid",gap:l?10:14,gridTemplateColumns:`repeat(${Ed.length}, 1fr)`},n),children:Ed.map((e=>{const n=e===s;return G.jsxs(o.ButtonBase,{sx:{typography:"h6",borderRadius:4,padding:r.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:hover":{color:r.palette.text.primary,backgroundColor:o.alpha(r.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:a?r.palette.primary.main:o.alpha(r.palette.text.primary,.4)}},onClick:()=>{n||(c.current=0,d(e),t(e))},className:n?"selected":void 0,children:[100*e,"%"]},e)}))})}const Od=({value:n,onUserInput:r,maxAmount:a,balance:l,mint:s,locked:d})=>{var c,u;const p=o.useTheme(),h=i.useCallback((e=>{if(!a||!s)return;const t=a.multipliedBy(e).dp(s.decimals).toString();r(t)}),[s,a,r]),m=i.useMemo((()=>l?Ko({input:l,decimals:null==s?void 0:s.decimals}):"-"),[null==s?void 0:s.decimals,l]);return G.jsxs(o.Box,{sx:{pt:12,pb:20,px:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",borderRadius:12,backgroundColor:p.palette.background.input},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:p.palette.text.primary,typography:"h5"},children:[(null==s?void 0:s.address)&&G.jsx(Wa,{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}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:(null==s?void 0:s.address)?G.jsx(o.Box,{children:null!==(u=null==s?void 0:s.symbol)&&void 0!==u?u:"-"}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"})})]}),G.jsxs(o.Box,{component:o.ButtonBase,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:[G.jsxs(o.Box,{sx:{wordBreak:"keep-all"},children:[t.i18n._({id:"fsBGk0",message:"Balance"}),": "]}),G.jsx(o.Box,{sx:{wordBreak:"break-all",textAlign:"right",display:"flex",alignItems:"center"},children:m})]})]}),G.jsx(Es,{sx:{mt:4},suffix:void 0,value:n,onChange:r,readOnly:d,withClear:!d}),d?null:G.jsx(Ld,{sx:{mt:20,mb:0},onClick:h,currentValue:n})]})};var Wd,Vd;function Ad(e,t){switch(t.type){case Wd.UpdateMint1:{const n=t.payload;return Object.assign(Object.assign({},e),{mint1:n})}case Wd.UpdateDefaultMint1:{const n=t.payload;return e.mint1?e:Object.assign(Object.assign({},e),{mint1:n})}case Wd.UpdateMint2:{const n=t.payload;return Object.assign(Object.assign({},e),{mint2:n})}case Wd.UpdateDefaultMint2:{const n=t.payload;return e.mint2?e:Object.assign(Object.assign({},e),{mint2:n})}case Wd.UpdateMint1AndClearMint2:{const n=t.payload;return Object.assign(Object.assign({},e),{mint1:n,mint2:void 0})}case Wd.UpdateFeeAmount:return Object.assign(Object.assign({},e),{feeAmount:t.payload});case Wd.UpdateSelectedMintIndex:return Object.assign(Object.assign({},e),{selectedMintIndex:t.payload});case Wd.setFullRange:return Object.assign(Object.assign({},e),{leftRangeTypedValue:!0,rightRangeTypedValue:!0});case Wd.typeStartPriceInput:return Object.assign(Object.assign({},e),{startPriceTypedValue:t.payload.typedValue});case Wd.typeLeftRangeInput:return Object.assign(Object.assign({},e),{leftRangeTypedValue:t.payload.typedValue});case Wd.typeRightRangeInput:return Object.assign(Object.assign({},e),{rightRangeTypedValue:t.payload.typedValue});case Wd.typeInput:{const{payload:{field:n,typedValue:o}}=t;return Object.assign(Object.assign({},e),{independentField:n,typedValue:o})}default:throw Error("Unknown action: "+t.type)}}!function(e){e[e.UpdateMint1=0]="UpdateMint1",e[e.UpdateMint2=1]="UpdateMint2",e[e.UpdateDefaultMint1=2]="UpdateDefaultMint1",e[e.UpdateDefaultMint2=3]="UpdateDefaultMint2",e[e.UpdateMint1AndClearMint2=4]="UpdateMint1AndClearMint2",e[e.UpdateFeeAmount=5]="UpdateFeeAmount",e[e.UpdateSelectedMintIndex=6]="UpdateSelectedMintIndex",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"}(Wd||(Wd={})),function(e){e[e.LOW=1e3]="LOW"}(Vd||(Vd={}));const Fd={[Vd.LOW]:20},Pd={[Vd.LOW]:{label:"0.1%"}},Zd=({disabled:e,feeAmount:n,dispatch:r})=>{const a=o.useTheme(),{isMobile:l}=Ls(),[s,d]=i.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderStyle:"solid",borderColor:a.palette.border.main,borderRadius:12},e?{opacity:.3}:void 0),children:[G.jsx(o.Box,{sx:{typography:"h5",color:a.palette.text.primary},children:n?`${Pd[n].label} ${t.i18n._({id:"fxRyGG",message:"fee tier"})}`:t.i18n._({id:"EU3wU4",message:"Fee tier"})}),G.jsx(o.Button,{size:o.Button.Size.small,variant:o.Button.Variant.outlined,disabled:e,onClick:()=>d((e=>!e)),sx:{color:a.palette.text.primary,border:`solid 1px ${a.palette.text.primary}`},children:s?t.i18n._({id:"vLyv1R",message:"Hide"}):t.i18n._({id:"ePK91l",message:"Edit"})})]}),s&&G.jsx(o.Box,{sx:Object.assign({},l?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8}),children:[Vd.LOW].map((t=>{const i=n===t;return G.jsxs(o.Button,{size:o.Button.Size.middle,variant:o.Button.Variant.outlined,disabled:e,onClick:()=>{r({type:Wd.UpdateFeeAmount,payload:t})},sx:{flexBasis:"50%",flexShrink:1,flexGrow:1,justifyContent:"space-between",px:20,color:a.palette.text.primary,borderRadius:12,borderColor:i?a.palette.primary.main:a.palette.border.main,[a.breakpoints.up("tablet")]:{flexBasis:"25%"}},children:[Pd[t].label,i?G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.primary.main}),G.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:a.palette.primary.main,stroke:a.palette.primary.main})]}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.text.secondary})})]},t)}))})]})};var Nd,Ud,Hd;!function(e){e.DEPOSIT_1="DEPOSIT_1",e.DEPOSIT_2="DEPOSIT_2"}(Nd||(Nd={})),function(e){e.LOWER="LOWER",e.UPPER="UPPER"}(Ud||(Ud={})),function(e){e.TOKEN0="TOKEN0",e.TOKEN1="TOKEN1"}(Hd||(Hd={}));const Dd={xs:"4px",sm:"8px",md:"12px",lg:"24px",xl:"32px"},Yd=({children:e,sx:t})=>(o.useTheme(),G.jsx(o.Box,{sx:Object.assign({display:"flex",flexDirection:"column",gap:20,px:20,py:20,borderRadius:12},t),children:e})),zd=({children:e,sx:t})=>{const n=o.useTheme();return G.jsx(Yd,{sx:Object.assign(Object.assign({},t),{backgroundColor:n.palette.background.paperContrast}),children:e})},qd=({children:e})=>{const t=o.useTheme();return G.jsxs(o.Box,{sx:{p:8,borderRadius:8,backgroundColor:o.alpha(t.palette.warning.main,.1),display:"flex",alignItems:"center",gap:8},children:[G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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})}),G.jsx(o.Box,{sx:{typography:"h6",color:t.palette.warning.main,textAlign:"left"},children:e})]})};function Xd({gap:e,flex:t,children:n,style:i}){return G.jsx(o.Box,{sx:Object.assign(Object.assign(Object.assign({display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:e&&Dd[e]||e},t&&{flex:t}),{width:"100%",alignItems:"center"}),i),children:n})}function Gd({gap:e,justify:t,grow:n,children:i,style:r}){return G.jsx(o.Box,{sx:Object.assign({display:"grid",gridAutoRows:"auto",gridRowGap:e&&Dd[e]||e,justifyItems:t,flexGrow:n&&1},r),children:i})}function _d({gap:e,children:t,sx:n}){return G.jsx(o.Box,{sx:Object.assign({width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"flex-start",gap:e&&Dd[e]||e},n),children:t})}function Jd({children:e,style:t}){return G.jsx(_d,{sx:Object.assign({justifyContent:"space-between"},t),children:e})}function Qd({gap:e,justify:t,children:n,sx:o}){return G.jsx(_d,{sx:Object.assign({position:"relative",width:"fit-content",margin:`-${e}`},o),children:n})}function Kd({children:e,disabled:t,sx:n}){return G.jsx(_d,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:"stretch",gap:12,opacity:t?.2:1,pointerEvents:t?"none":"auto"},n),children:e})}const $d={neutral1:"#222222",neutral2:"#7D7D7D",accent1:"#FC72FF",critical:"FF5F52",white:"#FFFFFF",surface3:"#22222212",opacity:{hover:.6,click:.4,disabled:.5,enabled:1}},ec=({series:e,xScale:t,yScale:n,xValue:r,yValue:a,fill:l})=>i.useMemo((()=>{var i;return G.jsx(o.Box,{component:"path",opacity:.5,stroke:null!=l?l:$d.accent1,fill:null!=l?l:$d.accent1,d:null!==(i=I.area().curve(I.curveStepAfter).x((e=>t(r(e)))).y1((e=>n(a(e)))).y0(n(0))(e.filter((e=>{const n=t(r(e));return n>0&&n<=window.innerWidth}))))&&void 0!==i?i:void 0})}),[l,e,t,r,n,a]),tc=({axisGenerator:e})=>G.jsx("g",{ref:t=>{t&&I.select(t).call(e).call((e=>e.select(".domain").remove()))}}),nc=({xScale:e,innerHeight:t,offset:n=0})=>i.useMemo((()=>G.jsx(o.Box,{component:"g",transform:`translate(0, ${t+n})`,sx:{"& line":{display:"none"},"& text":{color:$d.neutral2,transform:"translateY(5px)"}},children:G.jsx(tc,{axisGenerator:I.axisBottom(e).ticks(6)})})),[t,n,e]),oc=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(" "),ic=()=>["m 5 7","v 14","M 0 0","m 9 7","v 14","z"].join(" "),rc=({color:e,size:t=10,margin:n=10})=>G.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 ac=({color:e,d:t})=>G.jsx(o.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",strokeWidth:3,stroke:e,fill:e,d:t}),lc=({d:e})=>G.jsx(o.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",stroke:$d.white,opacity:$d.opacity.hover,d:e}),sc=({visible:e,transform:t,children:n})=>G.jsx(o.Box,{component:"g",opacity:e?"1":"0",transform:t,sx:{transition:"opacity 300ms"},children:n}),dc=({y:e,x:t,height:n,width:i,rx:r})=>G.jsx(o.Box,{component:"rect",fill:$d.surface3,y:e,x:t,height:n,width:i,rx:r}),cc=({y:e,transform:t,dominantBaseline:n,children:i})=>G.jsx(o.Box,{component:"text",y:e,textAnchor:"middle",fontSize:"13px",fill:$d.neutral1,transform:t,dominantBaseline:n,children:i}),uc=(e,t,n)=>{const o=e.map((e=>n(e).toFixed(1))),i=t.map((e=>n(e).toFixed(1)));return o.every(((e,t)=>e===i[t]))},pc=({id:e,xScale:t,interactive:n,brushLabelValue:o,brushExtent:r,setBrushExtent:a,innerWidth:l,innerHeight:s,westHandleColor:d,eastHandleColor:c})=>{const u=i.useRef(null),p=i.useRef(null),[h,m]=i.useState(r),[f,x]=i.useState(!1),[g,y]=i.useState(!1),v=function(e){const t=i.useRef();return i.useEffect((()=>{t.current=e}),[e]),t.current}(r),b=i.useCallback((e=>{const{type:n,selection:o,mode:i}=e;if(!o)return void m(null);const l=o.map(t.invert);"end"!==n||uc(r,l,t)||a(l,i),m(l)}),[t,r,a]);i.useEffect((()=>{m(r)}),[r]),i.useEffect((()=>{u.current&&(p.current=I.brushX().extent([[Math.max(2,t(0)),0],[l-2,s]]).handleSize(30).filter((()=>n)).on("brush end",b),p.current(I.select(u.current)),v&&uc(r,v,t)&&I.select(u.current).transition().call(p.current.move,r.map(t)),I.select(u.current).selectAll(".selection").attr("stroke","none").attr("fill-opacity","0.1").attr("fill",`url(#${e}-gradient-selection)`))}),[r,b,e,s,l,n,v,t]),i.useEffect((()=>{u.current&&p.current&&p.current.move(I.select(u.current),r.map(t))}),[r,t]),i.useEffect((()=>{x(!0);const e=setTimeout((()=>x(!1)),1500);return()=>clearTimeout(e)}),[h]);const j=h&&t(h[0])>20,C=h&&t(h[1])>l-20,w=h&&(t(h[0])<0||t(h[1])<0),k=h&&(t(h[0])>l||t(h[1])>l),T=h&&t(h[0])>=0&&t(h[0])<=l,R=h&&t(h[1])>=0&&t(h[1])<=l;return i.useMemo((()=>G.jsxs(G.Fragment,{children:[G.jsxs("defs",{children:[G.jsxs("linearGradient",{id:`${e}-gradient-selection`,x1:"0%",y1:"100%",x2:"100%",y2:"100%",children:[G.jsx("stop",{stopColor:d}),G.jsx("stop",{stopColor:c,offset:"1"})]}),G.jsx("clipPath",{id:`${e}-brush-clip`,children:G.jsx("rect",{x:"0",y:"0",width:l,height:s})})]}),G.jsx("g",{ref:u,clipPath:`url(#${e}-brush-clip)`,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)}),h&&G.jsxs(G.Fragment,{children:[T?G.jsxs("g",{transform:`translate(${Math.max(0,t(h[0]))}, 0), scale(${j?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(ac,{color:d,d:oc(s)}),G.jsx(lc,{d:ic()})]}),G.jsxs(sc,{transform:`translate(50,0), scale(${j?"1":"-1"}, 1)`,visible:f||g,children:[G.jsx(dc,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(cc,{transform:"scale(-1, 1)",y:"15",dominantBaseline:"middle",children:o("w",h[0])})]})]}):null,R?G.jsxs("g",{transform:`translate(${t(h[1])}, 0), scale(${C?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(ac,{color:c,d:oc(s)}),G.jsx(lc,{d:ic()})]}),G.jsxs(sc,{transform:`translate(50,0), scale(${C?"-1":"1"}, 1)`,visible:f||g,children:[G.jsx(dc,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(cc,{y:"15",dominantBaseline:"middle",children:o("e",h[1])})]})]}):null,w&&G.jsx(rc,{color:d}),k&&G.jsx("g",{transform:`translate(${l}, 0) scale(-1, 1)`,children:G.jsx(rc,{color:c})})]})]})),[o,c,R,C,j,g,e,s,l,h,k,f,w,d,T,t])},hc=({value:e,xScale:t,innerHeight:n})=>i.useMemo((()=>G.jsx(o.Box,{component:"line",x1:t(e),y1:"0",x2:t(e),y2:n,sx:{opacity:.5,strokeWidth:2,stroke:$d.neutral1,fill:"none"}})),[e,t,n]);function mc({svg:e,xScale:t,setZoom:n,width:r,height:a,resetBrush:l,showResetButton:s,zoomLevels:d}){const c=i.useRef(),[u,p,h,m]=i.useMemo((()=>[()=>e&&c.current&&I.select(e).transition().call(c.current.scaleBy,2),()=>e&&c.current&&I.select(e).transition().call(c.current.scaleBy,.5),()=>e&&c.current&&I.select(e).transition().call(c.current.scaleTo,.5),()=>e&&c.current&&I.select(e).call(c.current.transform,I.zoomIdentity.translate(0,0).scale(1)).transition().call(c.current.scaleTo,.5)]),[e]);return i.useEffect((()=>{e&&(c.current=I.zoom().scaleExtent([d.min,d.max]).extent([[0,0],[r,a]]).on("zoom",(({transform:e})=>n(e))),I.select(e).call(c.current))}),[a,r,n,e,t,c,d,d.max,d.min]),i.useEffect((()=>{h()}),[h,d]),G.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:`repeat(${s?3:2}, 1fr)`,gridGap:"6px",position:"absolute",top:"-32px",right:0},children:[s&&G.jsx(o.Button,{size:o.Button.Size.small,sx:{borderRadius:16},onClick:()=>{l(),m()},disabled:!1,children:G.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:[G.jsx("polyline",{points:"1 4 1 10 7 10"}),G.jsx("polyline",{points:"23 20 23 14 17 14"}),G.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"})]})}),G.jsx(o.Button,{size:o.Button.Size.small,sx:{borderRadius:16},onClick:u,disabled:!1,children:G.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:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),G.jsx(o.Button,{size:o.Button.Size.small,sx:{borderRadius:16},onClick:p,disabled:!1,children:G.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:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]})}const fc=e=>e.price0,xc=e=>e.activeLiquidity;function gc({id:e="liquidityChartRangeInput",data:{series:t,current:n},ticksAtLimit:r,styles:a,dimensions:{width:l,height:s},margins:d,interactive:c=!0,brushDomain:u,brushLabels:p,onBrushDomainChange:h,zoomLevels:m}){const f=i.useRef(null),[x,g]=i.useState(null),[y,v]=i.useMemo((()=>[s-d.top-d.bottom,l-d.left-d.right]),[l,s,d]),{xScale:b,yScale:j}=i.useMemo((()=>{const e={xScale:I.scaleLinear().domain([n*m.initialMin,n*m.initialMax]).range([0,v]),yScale:I.scaleLinear().domain([0,I.max(t,xc)]).range([y,0])};if(x){const t=x.rescaleX(e.xScale);e.xScale.domain(t.domain())}return e}),[n,m.initialMin,m.initialMax,v,t,y,x]);return i.useEffect((()=>{g(null)}),[m]),i.useEffect((()=>{u||h(b.domain(),void 0)}),[u,h,b]),G.jsxs(G.Fragment,{children:[G.jsx(mc,{svg:f.current,xScale:b,setZoom:g,width:v,height:s,resetBrush:()=>{h([n*m.initialMin,n*m.initialMax],"reset")},showResetButton:Boolean(r[Ud.LOWER]||r[Ud.UPPER]),zoomLevels:m}),G.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${l} ${s}`,style:{overflow:"visible"},children:[G.jsxs("defs",{children:[G.jsx("clipPath",{id:`${e}-chart-clip`,children:G.jsx("rect",{x:"0",y:"0",width:v,height:s})}),u&&G.jsx("mask",{id:`${e}-chart-area-mask`,children:G.jsx("rect",{fill:"white",x:b(u[0]),y:"0",width:b(u[1])-b(u[0]),height:y})})]}),G.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[G.jsxs("g",{clipPath:`url(#${e}-chart-clip)`,children:[G.jsx(ec,{series:t,xScale:b,yScale:j,xValue:fc,yValue:xc}),u&&G.jsx("g",{mask:`url(#${e}-chart-area-mask)`,children:G.jsx(ec,{series:t,xScale:b,yScale:j,xValue:fc,yValue:xc,fill:a.area.selection})}),G.jsx(hc,{value:n,xScale:b,innerHeight:y}),G.jsx(nc,{xScale:b,innerHeight:y})]}),G.jsx(o.Box,{component:"rect",width:v,height:s,ref:f,sx:{fill:"transparent",cursor:"grab","&:active":{cursor:"grabbing"}}}),G.jsx(pc,{id:e,xScale:b,interactive:c,brushLabelValue:p,brushExtent:null!=u?u:b.domain(),innerWidth:v,innerHeight:y,setBrushExtent:h,westHandleColor:a.brush.handle.west,eastHandleColor:a.brush.handle.east})]})]})]})}function yc({tick:e,decimalsA:t,decimalsB:n}){if(!t||!n||"number"!=typeof e)return;const o=y.SqrtPriceMath.getSqrtPriceX64FromTick(e);return new r(y.SqrtPriceMath.sqrtPriceX64ToPrice(o,t,n).toString())}var vc;function bc(e){const t=Ua(),n=d.useQuery({queryKey:["clmm","getPoolInfoFromRpc",e],enabled:null!=e&&null!=t,queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!t||!e)return null;try{const{poolInfo:n,poolKeys:o,computePoolInfo:i,tickData:r}=yield t.clmm.getPoolInfoFromRpc(e);return{poolInfo:n,poolKeys:o,computePoolInfo:i,tickData:r}}catch(e){return console.error("getPoolInfoFromRpc error",e),null}}))});return n.isLoading?[vc.LOADING,null,e]:n.isError?[vc.INVALID,null,e]:n.data?[vc.EXISTS,n.data,e]:[vc.NOT_EXISTS,null,e]}function jc(e,t,n,o){return bc(i.useMemo((()=>{if(!e||!t||!n)return null;const i=function({chainId:e,feeAmount:t,mint1Address:n,mint2Address:o}){const[i,r]=new T(new u.PublicKey(n).toBuffer()).gt(new T(new u.PublicKey(o).toBuffer()))?[o,n]:[n,o],[a,l]=[new u.PublicKey(i),new u.PublicKey(r)],s=gi[e];if(!s)throw new Error("Invalid config");const d=s.config.find((e=>e.tradeFeeRate===t));if(!d)throw new Error("Invalid fee");const{publicKey:c}=y.getPdaPoolId(s.programId,new u.PublicKey(d.id),a,l);return c}({mint1Address:e,mint2Address:t,feeAmount:n,chainId:o}).toBase58();return i}),[o,n,e,t]))}!function(e){e[e.LOADING=0]="LOADING",e[e.NOT_EXISTS=1]="NOT_EXISTS",e[e.EXISTS=2]="EXISTS",e[e.INVALID=3]="INVALID"}(vc||(vc={}));const Cc=8,wc=(e,t)=>e&&t?Math.floor(e/Fd[t])*Fd[t]:void 0,kc=1e3;function Tc(e,t){const[o,r]=i.useState(0),[a,l]=i.useState([]),{data:s,error:c,isLoading:u}=function(e,t=0,o){const i=rr().getQuery(n.AMMV3Api.graphql.AllV3TicksDocument,{skip:t,first:kc,where:{chain:o?n.chainIdToShortName[o]:n.chainIdShortNameEnum.SOON_TESTNET,poolAddress:null!=e?e:"",pairType:n.CLMM}});return d.useQuery(Object.assign(Object.assign({},i),{enabled:!!e}))}(e,o,t),p=null==s?void 0:s.amm_getTicksData.ticks;return i.useEffect((()=>{(null==p?void 0:p.length)&&(l((e=>[...e,...p])),(null==p?void 0:p.length)===kc&&r((e=>e+kc)))}),[p]),{isLoading:u||(null==p?void 0:p.length)===kc,error:c,ticks:a}}function Rc({mint1:e,mint2:t,feeAmount:n}){const{isLoading:o,error:r,data:a}=function(e,t,n,o){var r,a;const{chainId:l}=Zo(),[s,d,c]=jc(null==e?void 0:e.address,null==t?void 0:t.address,n,l),u=null===(r=null==d?void 0:d.computePoolInfo)||void 0===r?void 0:r.tickCurrent,p=i.useMemo((()=>wc(u,n)),[u,n]),{isLoading:h,error:m,ticks:f}=Tc(c,l);return i.useMemo((()=>{var n,o,i,r,a,l;if(!e||!t||void 0===p||s!==vc.EXISTS||!f||0===f.length||h)return{isLoading:h||s===vc.LOADING,error:m,activeTick:p,data:void 0};const c=f.findIndex((e=>(null==e?void 0:e.tickIdx)&&e.tickIdx>p))-1;if(c<0)return console.log("usePoolTickData","usePoolActiveLiquidity","TickData pivot not found",{mint1:e.address,mint2:t.address,chainId:e.chainId}),{isLoading:h,error:m,activeTick:p,data:void 0};const u=yc({decimalsA:e.decimals,decimalsB:t.decimals,tick:p}),x={liquidityActive:null!==(o=null===(n=null==d?void 0:d.computePoolInfo)||void 0===n?void 0:n.liquidity.toNumber())&&void 0!==o?o:0,tick:p,liquidityNet:Number(null===(i=f[c])||void 0===i?void 0:i.tickIdx)===p?Number(null!==(a=null===(r=f[c])||void 0===r?void 0:r.liquidityNet)&&void 0!==a?a:0):0,price0:null!==(l=null==u?void 0:u.toFixed(Cc))&&void 0!==l?l:"",sdkPrice:u},g=[].concat(x).concat([]);return{isLoading:h,error:m,data:g}}),[p,m,h,e,t,null===(a=null==d?void 0:d.computePoolInfo)||void 0===a?void 0:a.liquidity,s,f])}(e,t,n),l=i.useCallback((()=>{if(!(null==a?void 0:a.length))return;const e=[];for(let t=0;t<a.length;t++){const n=a[t],o={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};o.activeLiquidity>0&&e.push(o)}return e}),[a]);return i.useMemo((()=>({isLoading:o,error:r,formattedData:o?void 0:l()})),[o,r,l])}const Sc={[Vd.LOW]:{initialMin:.999,initialMax:1.001,min:1e-5,max:1.5}};function Ic({message:e,icon:t}){return G.jsxs(Xd,{style:{height:"100%",justifyContent:"center"},children:[t,e&&G.jsx(o.Box,{sx:{mt:20,p:10,typography:"caption",textAlign:"center"},children:e})]})}function Bc(){return G.jsx(o.LoadingSkeleton,{})}function Mc({mint1:t,mint2:n,feeAmount:r,ticksAtLimit:a,price:s,priceLower:d,priceUpper:c,onLeftRangeInput:u,onRightRangeInput:p,interactive:h}){const m=!0,{isLoading:f,error:x,formattedData:g}=Rc({mint1:t,mint2:n,feeAmount:r}),y=i.useCallback(((e,t)=>{let n=Number(e[0]);const o=Number(e[1]);n<=0&&(n=1/10**6),l.batch((()=>{(!a[Ud.LOWER]||"handle"===t||"reset"===t)&&n>0&&u(n.toFixed(6)),(!a[Ud.UPPER]||"reset"===t)&&o>0&&o<1e35&&p(o.toFixed(6))}))}),[m,u,p,a]);h=h&&Boolean(null==g?void 0:g.length);const v=i.useMemo((()=>{const e=d,t=c;return e&&t?[parseFloat(null==e?void 0:e.toString()),parseFloat(null==t?void 0:t.toString())]:void 0}),[d,c]),b=i.useCallback(((e,t)=>{if(!s)return"";if("w"===e&&a[Ud.LOWER])return"0";if("e"===e&&a[Ud.UPPER])return"∞";const n=(t<s?-1:1)*((Math.max(t,s)-Math.min(t,s))/s)*100;return s?`${Ko({input:n,decimals:2})}%`:""}),[m,s,a]),j=!t||!n||void 0===g&&!f&&!x;return G.jsx(Gd,{gap:"md",style:{minHeight:"200px"},children:j?G.jsx(Ic,{message:G.jsx(e.Trans,{id:"OZUH85",message:"Your position will appear here."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:$d.neutral1,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),G.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"})]})}):f?G.jsx(Bc,{}):x?G.jsx(Ic,{message:G.jsx(e.Trans,{id:"79D0qY",message:"Liquidity data not available."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:$d.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.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"}),G.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}):g&&0!==g.length&&s?G.jsx(o.Box,{sx:{position:"relative",width:"100%",maxHeight:"200px",justifyContent:"center",alignContent:"center"},children:G.jsx(gc,{data:{series:g,current:s},dimensions:{width:560,height:200},margins:{top:10,right:2,bottom:20,left:0},styles:{area:{selection:$d.accent1},brush:{handle:{west:$d.critical,east:$d.accent1}}},interactive:h,brushLabels:b,brushDomain:v,onBrushDomainChange:y,zoomLevels:Sc[null!=r?r:Vd.LOW],ticksAtLimit:a})}):G.jsx(Ic,{message:G.jsx(e.Trans,{id:"rH6vg9",message:"There is no liquidity data."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:$d.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),G.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),G.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})})})}const Ec=({value:e,decrement:t,increment:n,decrementDisabled:r=!1,incrementDisabled:a=!1,locked:l,onUserInput:s,title:d,perPriceText:c})=>{const u=o.useTheme(),[p,h]=i.useState(""),[m,f]=i.useState(!1),x=i.useCallback((()=>{f(!1),s(p)}),[p,s]),g=i.useCallback((()=>{f(!1),s(t())}),[t,s]),y=i.useCallback((()=>{f(!1),s(n())}),[n,s]);return i.useEffect((()=>{p===e||m||setTimeout((()=>{h(e)}),0)}),[p,m,e]),G.jsx(o.Box,{onFocus:()=>{f(!0)},onBlur:x,sx:{width:"100%",py:12,px:20,borderRadius:16,backgroundColor:u.palette.background.input},children:G.jsxs(o.Box,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsx(o.Box,{sx:{typography:"body2",fontWeight:600,color:u.palette.text.primary},children:d}),G.jsx(o.Box,{sx:{mt:4,typography:"h6",fontWeight:500,color:u.palette.text.secondary},children:c}),G.jsx(Es,{sx:{mt:12},value:p,onChange:e=>{h(e)},readOnly:l})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[!l&&G.jsx(o.Button,{size:o.Button.Size.small,onClick:y,disabled:a,sx:{px:4,backgroundColor:u.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M14.25 9.75H9.75V14.25H8.25V9.75H3.75V8.25H8.25V3.75H9.75V8.25H14.25V9.75Z",fill:r?u.palette.text.disabled:u.palette.text.primary})})}),!l&&G.jsx(o.Button,{size:o.Button.Size.small,onClick:g,disabled:r,sx:{px:4,backgroundColor:u.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("rect",{x:"3.75",y:"8.25",width:"10.5",height:"1.5",fill:r?u.palette.text.disabled:u.palette.text.primary})})})]})]})})},Lc=({priceLower:t,priceUpper:n,onLeftRangeInput:i,onRightRangeInput:r,getDecrementLower:a,getIncrementLower:l,getDecrementUpper:s,getIncrementUpper:d,perPriceText:c,ticksAtLimit:u})=>{var p,h;const m=t,f=n;return G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[G.jsx(Ec,{value:u[Ud.LOWER]?"0":null!==(p=null==m?void 0:m.dp(8).toString())&&void 0!==p?p:"",onUserInput:i,decrement:a,increment:l,decrementDisabled:void 0===m||u[Ud.LOWER],incrementDisabled:void 0===m||u[Ud.LOWER],title:G.jsx(e.Trans,{id:"uEoBVI",message:"Low price"}),perPriceText:c}),G.jsx(Ec,{value:u[Ud.UPPER]?"∞":null!==(h=null==f?void 0:f.dp(8).toString())&&void 0!==h?h:"",onUserInput:r,decrement:s,increment:d,incrementDisabled:void 0===f||u[Ud.UPPER],decrementDisabled:void 0===f||u[Ud.UPPER],title:G.jsx(e.Trans,{id:"kAC8rT",message:"High price"}),perPriceText:c})]})},Oc=({mintA:e,mintB:t,selectedMintIndex:n,handleRateToggle:i,sx:r})=>{const a=o.useTheme();return G.jsx(o.Box,{component:o.ButtonBase,onClick:i,sx:Object.assign({display:"flex",alignItems:"center",p:1,borderRadius:8,backgroundColor:a.palette.border.main},r),children:G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",width:"100%",[a.breakpoints.up("tablet")]:{width:"auto"}},children:[e,t].map(((e,t)=>{const i=n===t;return G.jsx(o.Box,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},i?{color:a.palette.text.primary,backgroundColor:a.palette.background.paper}:{color:a.palette.text.secondary,backgroundColor:"transparent"}),children:e.symbol},e.address)}))})})};function Wc(e,t){var n;return e?{chainId:t,address:e.id,name:e.name,decimals:Number(e.decimals),symbol:e.symbol,logoURI:null!==(n=e.logoImg)&&void 0!==n?n:""}:e}function Vc(e){var t,n,o,i;const r=null==e?void 0:e.pair;if(r)return{address:r.id,chainId:r.chainId,baseToken:Wc(r.baseToken,r.chainId),quoteToken:Wc(r.quoteToken,r.chainId),type:r.type,creator:r.creator,baseLpToken:{id:null===(t=r.baseLpToken)||void 0===t?void 0:t.id},quoteLpToken:{id:null===(n=r.quoteLpToken)||void 0===n?void 0:n.id},lpFeeRate:null===(o=null==e?void 0:e.pair)||void 0===o?void 0:o.lpFeeRate,mtFeeRate:null===(i=null==e?void 0:e.pair)||void 0===i?void 0:i.mtFeeRate}}function Ac(e){const t=Vc(e);if(t)return Object.assign(Object.assign({},t),{liquidityPositions:null==e?void 0:e.liquidityPositions})}function Fc(e){switch(e){case"SVM_AMMV2":return"AMM V2";case"SVM_AMMV3":return"AMM V3";default:return"PMM"}}function Pc({type:e,lpFeeRate:t,mtFeeRate:n}){var o,i;return"SVM_AMMV3"===e?null!==(i=null===(o=Pd[t])||void 0===o?void 0:o.label)&&void 0!==i?i:"-":`${Ko({input:new r(null!=t?t:0).plus(null!=n?n:0).div(1e4),decimals:4})}%`}new n.PoolApi,new n.AMMV3Api;const Zc=({sx:e})=>{const n=o.useTheme();return G.jsx(o.Box,{sx:Object.assign({py:4,px:8,color:n.palette.primary.main,borderRadius:4,backgroundColor:o.alpha(n.palette.primary.main,.1),typography:"h6"},e),children:t.i18n._({id:"m8r/Yx",message:"AMM V3"})})};function Nc({removed:e,inRange:n}){const i=o.useTheme(),r={py:4,px:8,color:i.palette.success.main,borderRadius:4,backgroundColor:o.alpha(i.palette.success.main,.1),typography:"h6"};return e?G.jsx(o.Tooltip,{title:t.i18n._({id:"MZPP7t",message:"Your position has 0 liquidity, and is not earning fees."}),children:G.jsx(o.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.warning.main,backgroundColor:o.alpha(i.palette.warning.main,.1)}),children:t.i18n._({id:"D87pha",message:"Closed"})})}):n?G.jsx(o.Tooltip,{title:t.i18n._({id:"aIvv/z",message:"The price of this pool is within your selected range. Your position is currently earning fees."}),children:G.jsx(o.Box,{sx:r,children:t.i18n._({id:"vOyUlD",message:"In range"})})}):G.jsx(o.Tooltip,{title:t.i18n._({id:"IwiTcw",message:"The price of this pool is outside of your selected range. Your position is not currently earning fees."}),children:G.jsx(o.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.error.main,backgroundColor:o.alpha(i.palette.error.main,.1)}),children:t.i18n._({id:"i3Z+/Z",message:"Out of range"})})})}function Uc({price:e,atLimit:t,direction:n}){return t[n]?n===Ud.LOWER?"0":"∞":"string"==typeof e&&"∞"===e?"∞":Ko({input:e})}const Hc=({position:t,title:n,ticksAtLimit:r})=>{const{poolInfo:{mintA:a,mintB:l,feeRate:s,price:d},liquidity:c,amountA:u,amountB:p,tickLowerPrice:h,tickUpperPrice:m}=t,f=o.useTheme(),[x,g]=i.useState(a),y=i.useMemo((()=>x.address===a.address?l:a),[x.address,a,l]),v=i.useCallback((()=>{g(y)}),[y]);return G.jsxs(Gd,{gap:"md",children:[G.jsxs(Jd,{children:[n?G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:f.palette.text.secondary},children:n}):G.jsx("div",{}),G.jsx(Oc,{mintA:a,mintB:l,selectedMintIndex:0,handleRateToggle:v})]}),G.jsxs(Jd,{children:[G.jsxs(zd,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"EQs1sJ",message:"Min price"})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:y.symbol,1:x.symbol}})})]}),G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"caption"},children:Uc({price:h,atLimit:r,direction:Ud.LOWER})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==x?void 0:x.symbol}})})]}),G.jsxs(zd,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"5etEUX",message:"Max price"})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:y.symbol,1:x.symbol}})})]}),G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"caption"},children:Uc({price:m,atLimit:r,direction:Ud.UPPER})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==y?void 0:y.symbol}})})]})]}),G.jsxs(zd,{sx:{py:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(Gd,{gap:"4px",justify:"flex-start",children:[G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"DWd30U",message:"Current price"})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:y.symbol,1:x.symbol}})})]}),G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"caption"},children:Ko({input:d})})]})]})},Dc=({position:t,title:i,inRange:r,ticksAtLimit:a})=>{Zo();const{poolInfo:{mintA:l,mintB:s,feeRate:d},liquidity:c,amountA:u,amountB:p}=t,h=c.isZero();return G.jsxs(Gd,{gap:"md",style:{marginTop:"0.5rem"},children:[G.jsxs(Jd,{style:{gap:4},children:[G.jsxs(Qd,{children:[G.jsx(gd,{tokens:[{address:l.address},{address:s.address}],mr:8}),G.jsxs(o.Box,{sx:{typography:"h5"},children:[l.symbol," / ",s.symbol]})]}),G.jsx(Zc,{sx:{ml:"auto"}}),G.jsx(Nc,{removed:h,inRange:r})]}),G.jsxs(zd,{children:[G.jsxs(Gd,{gap:"md",children:[G.jsxs(Jd,{children:[G.jsxs(Qd,{children:[G.jsx(Wa,{address:l.address,chainId:l.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(o.Box,{sx:{ml:8},children:l.symbol})]}),G.jsx(Qd,{children:G.jsx(o.Box,{sx:{mr:8},children:Ko({input:u,decimals:l.decimals})})})]}),G.jsxs(Jd,{children:[G.jsxs(Qd,{children:[G.jsx(Wa,{address:s.address,chainId:s.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(o.Box,{ml:"8px",children:s.symbol})]}),G.jsx(Qd,{children:G.jsx(o.Box,{mr:"8px",children:Ko({input:p,decimals:s.decimals})})})]})]}),G.jsxs(Jd,{children:[G.jsx(o.Box,{children:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"})}),G.jsx(o.Box,{children:Pc({type:n.CLMM,lpFeeRate:d,mtFeeRate:0})})]})]}),G.jsx(Hc,{position:t,title:i,ticksAtLimit:a})]})},Yc=({position:e,outOfRange:n,ticksAtLimit:i,on:r,onClose:a,onConfirm:l,loading:s})=>{const{isMobile:d}=Ls();return G.jsx(ds,{open:r,onClose:a,modal:!0,title:t.i18n._({id:"E6MqGy",message:"Add liquidity"}),height:683,children:G.jsxs(o.Box,{sx:{flex:1,px:20,pb:24,display:"flex",flexDirection:"column",justifyContent:"space-between",width:d?void 0:420},children:[G.jsx(o.Box,{sx:{pt:0,px:0},children:e?G.jsx(Dc,{position:e,inRange:!n,ticksAtLimit:i,title:t.i18n._({id:"3VUfrF",message:"Selected Range"})}):null}),G.jsx(o.Button,{size:o.Button.Size.big,fullWidth:!0,isLoading:s,sx:{mt:20},onClick:l,children:t.i18n._({id:"m16xKo",message:"Add"})})]})})};var zc;function qc(){return qc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},qc.apply(null,arguments)}const Xc=e=>O.createElement("svg",qc({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),zc||(zc=O.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},O.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 Gc({token:e,oppositeTokenAddress:n,dispatch:r,tokenSelectOnChange:a}){const l=o.useTheme(),{chainId:s}=Zo(),[d,c]=i.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,sx:{flexBasis:"100%",flexGrow:1,flexShrink:1,display:"flex",alignItems:"center",px:20,py:8,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:e?l.palette.border.main:l.palette.primary.main,color:e?l.palette.text.primary:l.palette.primary.contrastText,backgroundColor:e?"transparent":l.palette.primary.main,"&:hover":{borderColor:e?l.palette.border.main:l.palette.primary.main},[l.breakpoints.up("tablet")]:{flexBasis:"50%"}},onClick:()=>{c(!0)},children:[e?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Wa,{address:e.address,marginRight:0,width:24,height:24,chainId:e.chainId||s,noShowChain:!0,sx:{flexShrink:0}}),G.jsx(o.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:e.symbol})]}):G.jsx(o.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:t.i18n._({id:"0RrIzN",message:"Select token"})}),G.jsx(o.Box,{component:Xc,sx:{flexShrink:0,ml:"auto",width:18,height:18}})]}),G.jsx(Ds,{value:e,open:d,chainId:s,occupiedAddrs:[n],occupiedChainId:null==e?void 0:e.chainId,onClose:()=>{c(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return r({type:Wd.UpdateMint1AndClearMint2,payload:e}),void c(!1);a(e),c(!1)}},modal:!0})]})}const _c=({mint1:e,mint2:t,dispatch:n})=>{var i,r;const a=o.useTheme();return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",[a.breakpoints.up("tablet")]:{flexWrap:"nowrap"}},children:[G.jsx(Gc,{token:e,oppositeTokenAddress:null!==(i=null==t?void 0:t.address)&&void 0!==i?i:"",dispatch:n,tokenSelectOnChange:e=>{n({type:Wd.UpdateMint1,payload:e})}}),G.jsx(Gc,{token:t,oppositeTokenAddress:null!==(r=null==e?void 0:e.address)&&void 0!==r?r:"",dispatch:n,tokenSelectOnChange:e=>{n({type:Wd.UpdateMint2,payload:e})}})]})};function Jc({mint:e,chainId:t,symbol:n}){const{fetchTokenInfo:o}=yi();return d.useQuery({queryKey:["token","info",t,e],queryFn:()=>Wo(this,void 0,void 0,(function*(){return yield o({mint:e,chainId:t,symbol:n})})),enabled:!!e}).data}function Qc(e,t){B(Number.isInteger(e)&&Number.isInteger(t),"INTEGERS"),B(t>0,"TICK_SPACING"),B(e>=y.MIN_TICK&&e<=y.MAX_TICK,"TICK_BOUND");const n=Math.round(e/t)*t;return n<y.MIN_TICK?n+t:n>y.MAX_TICK?n-t:n}function Kc({price:e,feeAmount:t,mintDecimalsA:n,mintDecimalsB:o,baseIn:i}){const r=new S(e.toString()),a=i?r:new S(1).div(r),l=y.TickMath.getTickWithPriceAndTickspacing(a,Fd[t],n,o),s=y.SqrtPriceMath.getSqrtPriceX64FromTick(l),d=y.SqrtPriceMath.sqrtPriceX64ToPrice(s,n,o);return i?{tick:l,price:d}:{tick:l,price:new S(1).div(d)}}const $c=[n.ChainId.MAINNET,n.ChainId.ARBITRUM_ONE,n.ChainId.SEPOLIA,n.ChainId.TAIKO],eu={v3CoreFactoryAddress:"0x3d2A7Bac4E8439ABe86B58324695e921a5FC0987",nonfungiblePositionManagerAddress:"0x483E5c0f309577f79b0a19cE65E332DD388aD7A8"},tu=Object.assign({},eu),nu=Object.assign({},eu),ou={v3CoreFactoryAddress:"0x3d2A7Bac4E8439ABe86B58324695e921a5FC0987",nonfungiblePositionManagerAddress:"0x483E5c0f309577f79b0a19cE65E332DD388aD7A8"},iu={[n.ChainId.MAINNET]:tu,[n.ChainId.ARBITRUM_ONE]:nu,[n.ChainId.SEPOLIA]:ou,[n.ChainId.TAIKO]:ou};var ru,au;Object.assign({},$c.reduce(((e,t)=>(e[t]=iu[t].v3CoreFactoryAddress,e)),{})),Object.assign({},$c.reduce(((e,t)=>{const n=iu[t].nonfungiblePositionManagerAddress;return n&&(e[t]=n),e}),{})),function(e){e[e.EXACT_INPUT=0]="EXACT_INPUT",e[e.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(ru||(ru={})),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"}(au||(au={})),M.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const lu={[au.ROUND_DOWN]:r.ROUND_DOWN,[au.ROUND_HALF_UP]:r.ROUND_HALF_UP,[au.ROUND_UP]:r.ROUND_UP},su={[au.ROUND_DOWN]:r.ROUND_DOWN,[au.ROUND_HALF_UP]:r.ROUND_HALF_UP,[au.ROUND_UP]:r.ROUND_UP};class du{constructor(e,t=M.BigInt(1)){this.numerator=M.BigInt(e),this.denominator=M.BigInt(t)}static tryParseFraction(e){if(e instanceof M||"number"==typeof e||"string"==typeof e)return new du(e);if("numerator"in e&&"denominator"in e)return e;throw new Error("Could not parse fraction")}get quotient(){return M.divide(this.numerator,this.denominator)}get remainder(){return new du(M.remainder(this.numerator,this.denominator),this.denominator)}invert(){return new du(this.denominator,this.numerator)}add(e){const t=du.tryParseFraction(e);return M.equal(this.denominator,t.denominator)?new du(M.add(this.numerator,t.numerator),this.denominator):new du(M.add(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator)),M.multiply(this.denominator,t.denominator))}subtract(e){const t=du.tryParseFraction(e);return M.equal(this.denominator,t.denominator)?new du(M.subtract(this.numerator,t.numerator),this.denominator):new du(M.subtract(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator)),M.multiply(this.denominator,t.denominator))}lessThan(e){const t=du.tryParseFraction(e);return M.lessThan(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator))}equalTo(e){const t=du.tryParseFraction(e);return M.equal(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator))}greaterThan(e){const t=du.tryParseFraction(e);return M.greaterThan(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator))}multiply(e){const t=du.tryParseFraction(e);return new du(M.multiply(this.numerator,t.numerator),M.multiply(this.denominator,t.denominator))}divide(e){const t=du.tryParseFraction(e);return new du(M.multiply(this.numerator,t.denominator),M.multiply(this.denominator,t.numerator))}toSignificant(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=au.ROUND_HALF_UP){B(Number.isInteger(e),`${e} is not an integer.`),B(e>0,`${e} is not positive.`);const o=lu[n],i=new r(this.numerator.toString()).div(this.denominator.toString()).precision(e,o);return i.toFormat(i.decimalPlaces(),o,t)}toFixed(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=au.ROUND_HALF_UP){B(Number.isInteger(e),`${e} is not an integer.`),B(e>=0,`${e} is negative.`);const o=su[n];return new r(this.numerator.toString()).decimalPlaces(e,o).div(this.denominator.toString()).toFormat(e,o,t)}get asFraction(){return new du(this.numerator,this.denominator)}}const cu=new du(M.BigInt(100));function uu(e){return new pu(e.numerator,e.denominator)}class pu extends du{constructor(){super(...arguments),this.isPercent=!0}add(e){return uu(super.add(e))}subtract(e){return uu(super.subtract(e))}multiply(e){return uu(super.multiply(e))}divide(e){return uu(super.divide(e))}toSignificant(e=5,t,n){return super.multiply(cu).toSignificant(e,t,n)}toFixed(e=2,t,n){return super.multiply(cu).toFixed(e,t,n)}}function hu(e){const t=new r(e);if(t.isFinite())return t}M.BigInt(Number.MAX_SAFE_INTEGER),M.BigInt(0),M.BigInt(1),M.BigInt(2),M.BigInt(0);new pu(M.BigInt(1),1e4),new pu(1,100),new pu(3,100),new pu(5,100),new pu(10,100),new pu(15,100);const mu=new pu(0);function fu({mint:e,chainId:t}){const{account:n}=Zo(),{fetchTokenBalance:o}=yi();return d.useQuery({queryKey:["token","balance",t,n,e],queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!e)return;return(yield o(e.toString())).amount})),enabled:!!n&&!!e}).data}function xu({state:e,existingPosition:n,slipperValue:o}){const{account:a,chainId:l}=Zo(),s=Ua(),{feeAmount:d,selectedMintIndex:p,independentField:h,typedValue:m,leftRangeTypedValue:f,rightRangeTypedValue:x,startPriceTypedValue:g}=e,{mint1:v,mint2:b}=e,[j,C]=i.useMemo((()=>v&&b?new T(new u.PublicKey(v.address).toBuffer()).gt(new T(new u.PublicKey(b.address).toBuffer()))?[b,v]:[v,b]:[void 0,void 0]),[v,b]),w=h===Nd.DEPOSIT_1?Nd.DEPOSIT_2:Nd.DEPOSIT_1,[k,R]=i.useMemo((()=>j&&C?0==p?[j,C]:[C,j]:[void 0,void 0]),[j,C,p]),I=fu({mint:null==k?void 0:k.address,chainId:null==k?void 0:k.chainId}),B=fu({mint:null==R?void 0:R.address,chainId:null==R?void 0:R.chainId}),M=i.useMemo((()=>({[Nd.DEPOSIT_1]:I,[Nd.DEPOSIT_2]:B})),[I,B]),[E,L,O]=jc(null==v?void 0:v.address,null==b?void 0:b.address,d,l),W=E===vc.NOT_EXISTS,V=i.useMemo((()=>{if(!C)return;if(W){const e=hu(g);if(!e)return;return 0===p?e:new r(1).div(e).dp(C.decimals,r.ROUND_UP)}if(!L||null==L.poolInfo.price)return;return new r(L.poolInfo.price)}),[C,W,L,g,p]),A=i.useMemo((()=>{if(!V||null==(null==j?void 0:j.decimals)||null==(null==C?void 0:C.decimals))return!0;const e=y.SqrtPriceMath.priceToSqrtPriceX64(new S(V.toString()),null==j?void 0:j.decimals,null==C?void 0:C.decimals);return!(e&&!e.gt(y.MAX_SQRT_PRICE_X64)&&!e.lt(y.MIN_SQRT_PRICE_X64))}),[V,j,C]),F=i.useMemo((()=>{if(j&&C){if(L){return Object.assign(Object.assign({},L.poolInfo),{mintA:Object.assign(Object.assign({},L.poolInfo.mintA),{chainId:j.chainId,symbol:j.symbol}),mintB:Object.assign(Object.assign({},L.poolInfo.mintB),{chainId:C.chainId,symbol:C.symbol}),tickCurrent:L.computePoolInfo.tickCurrent})}if(d&&V&&!A&&O){const e=gi[l];if(!e)throw new Error("Invalid config");const t=e.config.find((e=>e.tradeFeeRate===d));if(!t)throw new Error("Invalid fee");const{tick:n}=Kc({mintDecimalsA:j.decimals,mintDecimalsB:C.decimals,feeAmount:d,price:V,baseIn:0===p});if(null==n)throw new Error("Invalid tick");return{type:"Concentrated",config:t,programId:e.programId.toBase58(),id:O,mintA:Object.assign(Object.assign({},y.toApiV3Token({address:j.address,decimals:j.decimals,programId:c.TOKEN_PROGRAM_ID.toBase58(),extensions:{feeConfig:void 0}})),{chainId:j.chainId,symbol:j.symbol}),mintB:Object.assign(Object.assign({},y.toApiV3Token({address:C.address,decimals:C.decimals,programId:c.TOKEN_PROGRAM_ID.toBase58(),extensions:{feeConfig:void 0}})),{chainId:C.chainId,symbol:C.symbol}),rewardDefaultInfos:[],rewardDefaultPoolInfos:"Clmm",price:V.toNumber(),tickCurrent:n,mintAmountA:0,mintAmountB:0,feeRate:t.tradeFeeRate,openTime:"",tvl:0,day:{volume:0,volumeQuote:0,volumeFee:0,feeApr:0,rewardApr:[0],apr:0,priceMax:0,priceMin:0},week:{volume:0,volumeQuote:0,volumeFee:0,feeApr:0,rewardApr:[0],apr:0,priceMax:0,priceMin:0},month:{volume:0,volumeQuote:0,volumeFee:0,feeApr:0,rewardApr:[0],apr:0,priceMax:0,priceMin:0},pooltype:[],farmUpcomingCount:0,farmOngoingCount:0,farmFinishedCount:0,burnPercent:0}}}}),[l,d,A,j,C,L,O,V,p]),P=i.useMemo((()=>({[Ud.LOWER]:d?Qc(y.MIN_TICK,Fd[d]):void 0,[Ud.UPPER]:d?Qc(y.MAX_TICK,Fd[d]):void 0})),[d]),Z=i.useMemo((()=>{if(n&&n.tickLower&&"number"==typeof(null==n?void 0:n.tickLower)&&n.tickUpper&&"number"==typeof(null==n?void 0:n.tickUpper))return{[Ud.LOWER]:n.tickLower,[Ud.UPPER]:n.tickUpper};if(!j||!C||!d)return{[Ud.LOWER]:void 0,[Ud.UPPER]:void 0};const e="boolean"==typeof f?void 0:hu(f),t="boolean"==typeof x?void 0:hu(x),o=0===p;return{[Ud.LOWER]:"boolean"==typeof f?P[Ud.LOWER]:e?Kc({mintDecimalsA:j.decimals,mintDecimalsB:C.decimals,feeAmount:d,price:e,baseIn:o}).tick:void 0,[Ud.UPPER]:"boolean"==typeof x?P[Ud.UPPER]:t?Kc({mintDecimalsA:j.decimals,mintDecimalsB:C.decimals,feeAmount:d,price:t,baseIn:o}).tick:void 0}}),[n,d,f,j,C,x,p,P]),{[Ud.LOWER]:N,[Ud.UPPER]:U}=Z,H=i.useMemo((()=>({[Ud.LOWER]:d&&N===P.LOWER,[Ud.UPPER]:d&&U===P.UPPER})),[P,N,U,d]),D=Boolean("number"==typeof N&&"number"==typeof U&&N>=U),Y=i.useMemo((()=>({[Ud.LOWER]:yc({tick:P.LOWER,decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals}),[Ud.UPPER]:yc({tick:P.UPPER,decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals})})),[null==j?void 0:j.decimals,null==C?void 0:C.decimals,P.LOWER,P.UPPER]),z=i.useMemo((()=>({[Ud.LOWER]:yc({tick:Z[Ud.LOWER],decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals}),[Ud.UPPER]:yc({tick:Z[Ud.UPPER],decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals})})),[null==j?void 0:j.decimals,null==C?void 0:C.decimals,Z]),{[Ud.LOWER]:q,[Ud.UPPER]:X}=z,G=Boolean(!D&&V&&q&&X&&(V.lt(q)||V.gt(X))),_=i.useMemo((()=>hu(m)),[m]),[J,Q]=i.useState(void 0);i.useEffect((()=>{let e=!0;return function(){Wo(this,void 0,void 0,(function*(){try{if(!s||!F||null==N||null==U)return;const t=yield s.fetchEpochInfo(),n=yield y.PoolUtils.getLiquidityAmountOutFromAmountIn({poolInfo:F,slippage:o,inputA:!0,tickLower:Math.min(N,U),tickUpper:Math.max(N,U),amount:new T(new S(m||"0").mul(10**F.mintA.decimals).toFixed(0)),add:!0,amountHasFee:!0,epochInfo:t});if(e){if(!n.amountSlippageB.amount)return;Q(new r(n.amountSlippageB.amount.toString()).div(new r(10**F.mintB.decimals)).dp(F.mintB.decimals,r.ROUND_UP))}}catch(e){console.error("error",e)}}))}(),()=>{e=!1}}),[F,s,o,N,U,m]);const K=i.useMemo((()=>({[Nd.DEPOSIT_1]:h===Nd.DEPOSIT_1?_:J,[Nd.DEPOSIT_2]:h===Nd.DEPOSIT_1?J:_})),[J,_,h]),$=Boolean("number"==typeof U&&(null==F?void 0:F.tickCurrent)&&F.tickCurrent>=U),ee=Boolean("number"==typeof N&&(null==F?void 0:F.tickCurrent)&&F.tickCurrent<=N),te=D||Boolean($&&F&&v&&new u.PublicKey(F.mintA.address).equals(new u.PublicKey(v.address))||ee&&F&&b&&new u.PublicKey(F.mintA.address).equals(new u.PublicKey(b.address))),ne=D||Boolean($&&F&&b&&new u.PublicKey(F.mintA.address).equals(new u.PublicKey(b.address))||ee&&F&&v&&new u.PublicKey(F.mintB.address).equals(new u.PublicKey(v.address))),{inputTax:oe,outputTax:ie}=function(){const[{inputTax:e,outputTax:t},n]=i.useState({inputTax:mu,outputTax:mu});return{inputTax:e,outputTax:t}}(),[re,ae]=i.useState();let le;i.useEffect((()=>{let e=!0;return function(){Wo(this,void 0,void 0,(function*(){try{if(!s||!F||null==N||null==U)return;const t=yield s.fetchEpochInfo(),n=yield y.PoolUtils.getLiquidityAmountOutFromAmountIn({poolInfo:F,slippage:o,inputA:!0,tickLower:Math.min(N,U),tickUpper:Math.max(N,U),amount:new T(new S(m||"0").mul(10**F.mintA.decimals).toFixed(0)),add:!0,amountHasFee:!0,epochInfo:t});e&&ae({poolInfo:F,tickLower:N,tickUpper:U,tickLowerPrice:q,tickUpperPrice:X,liquidity:new r(n.liquidity.toString()),amountA:new r(n.amountSlippageA.amount.toString()).div(new r(10**F.mintA.decimals)).dp(F.mintA.decimals,r.ROUND_UP),amountB:new r(n.amountSlippageB.amount.toString()).div(new r(10**F.mintB.decimals)).dp(F.mintB.decimals,r.ROUND_UP)})}catch(e){console.error("error",e)}}))}(),()=>{e=!1}}),[q,F,z,s,o,N,U,m,X]),a||(le=t.i18n._({id:"r7ScnQ",message:"Connect to a wallet"})),E===vc.INVALID&&(le=null!=le?le:t.i18n._({id:"R7D79P",message:"Invalid pair"})),A&&(le=null!=le?le:t.i18n._({id:"HXBqgG",message:"Invalid price input"})),(K[Nd.DEPOSIT_1]||te)&&(K[Nd.DEPOSIT_2]||ne)||(le=null!=le?le:t.i18n._({id:"iPMIoT",message:"Enter an amount"}));const{[Nd.DEPOSIT_1]:se,[Nd.DEPOSIT_2]:de}=K;se&&(null==I?void 0:I.lt(se))&&(le=t.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null==k?void 0:k.symbol}})),de&&(null==B?void 0:B.lt(de))&&(le=t.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null==R?void 0:R.symbol}}));const ce=oe.greaterThan(0)||ie.greaterThan(0),ue=E===vc.INVALID||ce;return{mintA:j,mintB:C,dependentField:w,mints:{[Nd.DEPOSIT_1]:k,[Nd.DEPOSIT_2]:R},poolInfo:F,poolState:E,depositBalances:M,parsedAmounts:K,ticks:Z,price:V,pricesAtTicks:z,pricesAtLimit:Y,position:re,poolIsNoExisted:W,errorMessage:le,invalidPool:ue,invalidRange:D,outOfRange:G,depositADisabled:te,depositBDisabled:ne,ticksAtLimit:H,isTaxed:ce,poolKeys:W||null==L?void 0:L.poolKeys}}function gu({dispatch:e}){return{onField1Input:i.useCallback((t=>{e({type:Wd.typeInput,payload:{field:Nd.DEPOSIT_1,typedValue:t}})}),[e]),onField2Input:i.useCallback((t=>{e({type:Wd.typeInput,payload:{field:Nd.DEPOSIT_2,typedValue:t}})}),[e]),onLeftRangeInput:i.useCallback((t=>{e({type:Wd.typeLeftRangeInput,payload:{typedValue:t}})}),[e]),onRightRangeInput:i.useCallback((t=>{e({type:Wd.typeRightRangeInput,payload:{typedValue:t}})}),[e]),onStartPriceInput:i.useCallback((t=>{e({type:Wd.typeStartPriceInput,payload:{typedValue:t}})}),[e])}}new pu(1);const yu=new r(.01);function vu(e){if(e)return e.gt(yu)?e.minus(yu):new r(0)}const bu=Buffer.from("support_mint","utf8");function ju(e,t){return y.findProgramAddress([bu,t.toBuffer()],e)}function Cu({params:e,handleGoBack:a,handleGoToPoolList:l}){var s,p,h,m,f,x;const{chainId:g,account:v}=Zo(),b=Ua(),j=o.useTheme(),C=Si(),{isMobile:w}=Ls(),k=Jc({mint:null==e?void 0:e.mint1,chainId:g}),R=Jc({mint:null==e?void 0:e.mint2,chainId:g}),[I,B]=i.useReducer(Ad,{mint1:k,mint2:R,feeAmount:(null==e?void 0:e.fee)?Number(null==e?void 0:e.fee):void 0,selectedMintIndex:0,independentField:Nd.DEPOSIT_1,typedValue:"",startPriceTypedValue:"1",leftRangeTypedValue:"",rightRangeTypedValue:""});i.useEffect((()=>{k&&B({type:Wd.UpdateDefaultMint1,payload:k})}),[k]),i.useEffect((()=>{R&&B({type:Wd.UpdateDefaultMint2,payload:R})}),[R]);const{independentField:M,typedValue:E,startPriceTypedValue:L}=I,{slipper:O,setSlipper:W,slipperValue:V,resetSlipper:A}=Id({type:n.CLMM}),{mintA:F,mintB:P,poolInfo:Z,poolKeys:N,ticks:U,dependentField:H,price:D,pricesAtTicks:Y,pricesAtLimit:z,parsedAmounts:q,depositBalances:X,position:_,poolIsNoExisted:J,mints:Q,errorMessage:K,invalidPool:$,invalidRange:ee,outOfRange:te,depositADisabled:ne,depositBDisabled:oe,ticksAtLimit:ie}=xu({state:I,slipperValue:V,existingPosition:void 0}),{onField1Input:re,onField2Input:ae,onLeftRangeInput:le,onRightRangeInput:se,onStartPriceInput:de}=gu({dispatch:B}),ce=!K&&!ee,[ue,pe]=i.useState(!1),he={[M]:E,[H]:null!==(p=null===(s=q[H])||void 0===s?void 0:s.toString())&&void 0!==p?p:""},me=[Nd.DEPOSIT_1,Nd.DEPOSIT_2].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:vu(X[t])})),{}),{[Ud.LOWER]:fe,[Ud.UPPER]:xe}=U,{[Ud.LOWER]:ge,[Ud.UPPER]:ye}=Y,{getDecrementLower:ve,getIncrementLower:be,getDecrementUpper:je,getIncrementUpper:Ce,getSetFullRange:we}=function({tickLower:e,tickUpper:t,poolInfo:n,state:o,dispatch:a}){var l,s;const{feeAmount:d}=o,c=null===(l=null==n?void 0:n.mintA)||void 0===l?void 0:l.decimals,u=null===(s=null==n?void 0:n.mintB)||void 0===s?void 0:s.decimals;return{getDecrementLower:i.useCallback((()=>{if(!d)return"";const t="number"==typeof e?e:null==n?void 0:n.tickCurrent;if(!t)return"";const o=yc({decimalsA:c,decimalsB:u,tick:t-Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,e]),getIncrementLower:i.useCallback((()=>{if(!d)return"";const t="number"==typeof e?e:null==n?void 0:n.tickCurrent;if(!t)return"";const o=yc({decimalsA:c,decimalsB:u,tick:t+Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,e]),getDecrementUpper:i.useCallback((()=>{if(!d)return"";const e="number"==typeof t?t:null==n?void 0:n.tickCurrent;if(!e)return"";const o=yc({decimalsA:c,decimalsB:u,tick:e-Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,t]),getIncrementUpper:i.useCallback((()=>{if(!d)return"";const e="number"==typeof t?t:null==n?void 0:n.tickCurrent;if(!e)return"";const o=yc({decimalsA:c,decimalsB:u,tick:e+Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,t]),getSetFullRange:i.useCallback((()=>{a({type:Wd.setFullRange,payload:void 0})}),[a])}}({tickLower:fe,tickUpper:xe,poolInfo:Z,state:I,dispatch:B}),ke=i.useCallback((()=>{we()}),[we,le,se,z]),Te=d.useMutation({mutationFn:()=>Wo(this,void 0,void 0,(function*(){if(!v||!g)return;if(!Z)throw new Error("poolInfo is undefined");if(!D)throw new Error("price is undefined");if(!b)throw new Error("raydium is undefined");const e=gi[g];if(!e)throw new Error("Invalid config");const n=b.clmm;b.clmm.scope.checkOwner();const o=new y.TxBuilder({connection:n.scope.connection,feePayer:n.scope.ownerPubKey,cluster:n.scope.cluster,owner:n.scope.owner,blockhashCommitment:n.scope.blockhashCommitment,loopMultiTxStatus:n.scope.loopMultiTxStatus,api:n.scope.api,signAllTransactions:n.scope.signAllTransactions}),i=J?yield function(e){return Wo(this,void 0,void 0,(function*(){var t;const{programId:n,mint1:o,mint2:i,ammConfig:r,initialPrice:a,computeBudgetConfig:l,forerunCreate:s,getObserveState:d,txVersion:p,txTipConfig:h,feePayer:m,clmm:f,txBuilder:x}=e,g=(null===(t=f.scope.owner)||void 0===t?void 0:t.publicKey)||u.PublicKey.default,[v,b,j]=new T(new u.PublicKey(o.address).toBuffer()).gt(new T(new u.PublicKey(i.address).toBuffer()))?[i,o,new S(1).div(a)]:[o,i,a],C=y.SqrtPriceMath.priceToSqrtPriceX64(j,v.decimals,b.decimals),w=[],k=[];v.programId===c.TOKEN_2022_PROGRAM_ID.toBase58()&&k.push(ju(n,new u.PublicKey(v.address)).publicKey),b.programId===c.TOKEN_2022_PROGRAM_ID.toBase58()&&k.push(ju(n,new u.PublicKey(b.address)).publicKey),(yield f.scope.connection.getMultipleAccountsInfo(k)).forEach(((e,t)=>{e&&w.push(k[t])}));const R=yield y.ClmmInstrument.createPoolInstructions({connection:f.scope.connection,programId:n,owner:g,mintA:v,mintB:b,ammConfigId:r.id,initialPriceX64:C,forerunCreate:!d&&s,extendMintAccount:w});return x.addInstruction(R),{address:Object.assign(Object.assign({},R.address),{observationId:R.address.observationId.toBase58(),exBitmapAccount:R.address.exBitmapAccount.toBase58(),programId:n.toString(),id:R.address.poolId.toString(),mintA:v,mintB:b,openTime:"0",vault:{A:R.address.mintAVault.toString(),B:R.address.mintBVault.toString()},rewardInfos:[],config:{id:r.id.toString(),index:r.index,protocolFeeRate:r.protocolFeeRate,tradeFeeRate:r.tradeFeeRate,tickSpacing:r.tickSpacing,fundFeeRate:r.fundFeeRate,description:r.description,defaultRange:0,defaultRangePoint:[]}}),mockPoolInfo:Object.assign({type:"Concentrated",rewardDefaultPoolInfos:"Clmm",id:R.address.poolId.toString(),mintA:v,mintB:b,feeRate:r.tradeFeeRate,openTime:"0",programId:n.toString(),price:j.toNumber(),config:{id:r.id.toString(),index:r.index,protocolFeeRate:r.protocolFeeRate,tradeFeeRate:r.tradeFeeRate,tickSpacing:r.tickSpacing,fundFeeRate:r.fundFeeRate,description:r.description,defaultRange:0,defaultRangePoint:[]},burnPercent:0},y.mockV3CreatePoolInfo),forerunCreate:s}}))}({programId:e.programId,mint1:Z.mintA,mint2:Z.mintB,ammConfig:Object.assign(Object.assign({},Z.config),{id:new u.PublicKey(Z.config.id),fundOwner:"",description:""}),initialPrice:new S(D.toString()),clmm:n,txBuilder:o}):void 0;if(!_)throw new Error("position is undefined");const l=yield function(e){return Wo(this,arguments,void 0,(function*({poolInfo:e,poolKeys:t,ownerInfo:n,tickLower:o,tickUpper:i,base:r,baseAmount:a,otherAmountMax:l,nft2022:s,associatedOnly:d=!0,checkCreateATAOwner:c=!1,withMetadata:p="create",getEphemeralSigners:h,computeBudgetConfig:m,txTipConfig:f,txVersion:x,feePayer:g,clmm:v,txBuilder:b}){!1===v.scope.availability.addConcentratedPosition&&v.logAndCreateError("add position feature disabled in your region");let j=null,C=null;const w=n.useSOLBalance&&e.mintA.address===y.WSOLMint.toString(),k=n.useSOLBalance&&e.mintB.address===y.WSOLMint.toString(),[T,R]="MintA"===r?[a,l]:[l,a],{account:S,instructionParams:I}=yield v.scope.account.getOrCreateTokenAccount({tokenProgram:e.mintA.programId,mint:new u.PublicKey(e.mintA.address),owner:v.scope.ownerPubKey,createInfo:w||T.isZero()?{payer:v.scope.ownerPubKey,amount:T}:void 0,skipCloseAccount:!w,notUseTokenAccount:w,associatedOnly:!w&&d,checkCreateATAOwner:c});S&&(j=S),b.addInstruction(I||{});const{account:B,instructionParams:M}=yield v.scope.account.getOrCreateTokenAccount({tokenProgram:e.mintB.programId,mint:new u.PublicKey(e.mintB.address),owner:v.scope.ownerPubKey,createInfo:k||R.isZero()?{payer:v.scope.ownerPubKey,amount:R}:void 0,skipCloseAccount:!k,notUseTokenAccount:k,associatedOnly:!k&&d,checkCreateATAOwner:c});B&&(C=B),b.addInstruction(M||{}),j&&C||v.logAndCreateError("cannot found target token accounts","tokenAccounts",{ownerTokenAccountA:null==j?void 0:j.toBase58(),ownerTokenAccountB:null==C?void 0:C.toBase58()});const E=t||(yield v.getClmmPoolKeys(e.id)),L=yield y.ClmmInstrument.openPositionFromBaseInstructions({poolInfo:e,poolKeys:E,ownerInfo:Object.assign(Object.assign({},n),{feePayer:v.scope.ownerPubKey,wallet:v.scope.ownerPubKey,tokenAccountA:j,tokenAccountB:C}),tickLower:o,tickUpper:i,base:r,baseAmount:a,otherAmountMax:l,withMetadata:p,getEphemeralSigners:h,nft2022:s});return b.addInstruction(L),Object.assign({},L.address)}))}({poolInfo:Z,poolKeys:null!=N?N:null==i?void 0:i.address,tickUpper:Math.max(_.tickLower,_.tickUpper),tickLower:Math.min(_.tickLower,_.tickUpper),base:"MintA",ownerInfo:{useSOLBalance:!0},baseAmount:new T(new S(E||"0").mul(10**Z.mintA.decimals).toFixed(0)),otherAmountMax:new T(_.amountB.multipliedBy(new r(10**Z.mintB.decimals)).toFixed(0)),clmm:n,txBuilder:o});o.addCustomComputeBudget({units:6e5,microLamports:1e3});const{transaction:s,signers:d}=yield o.versionBuild({txVersion:y.TxVersion.LEGACY,extInfo:l});const p=yield C.executeCustom({brief:J?t.i18n._({id:"8OiU8L",message:"Pool Creation"}):t.i18n._({id:"OBdohg",message:"Add Liquidity"}),metadata:{[J?exports.MetadataFlag.createAMMV3Pool:exports.MetadataFlag.addAMMV3Pool]:!0},handler:e=>Wo(this,void 0,void 0,(function*(){const{txId:t}=yield function(){return Wo(this,void 0,void 0,(function*(){var e,t,o;if(!b)throw new Error("raydium is undefined");const i=yield y.getRecentBlockHash(b.connection,b.blockhashCommitment);s.recentBlockhash=i,d.length&&s.sign(...d),y.printSimulate([s]);const r=yield null===(t=(e=n.scope).signAllTransactions)||void 0===t?void 0:t.call(e,[s]);if(d.length)for(const e of r);const a=null===(o=null==r?void 0:r[0])||void 0===o?void 0:o.serialize();if(!a)throw new Error("rawTransaction is undefined");return{txId:yield n.scope.connection.sendRawTransaction(a,{skipPreflight:!0}),signedTx:null==r?void 0:r[0]}}))}();e.onSuccess(t)})),successBack:()=>{a()},submittedBack:()=>{a()}});return p})),onError:e=>{console.error(e)}}),Re=F&&P?0===I.selectedMintIndex?`${null==P?void 0:P.symbol} per ${null==F?void 0:F.symbol}`:`${null==F?void 0:F.symbol} per ${null==P?void 0:P.symbol}`:"-";return G.jsx(Ks,{children:G.jsxs(o.Box,{sx:{mx:"auto",borderRadius:w?0:16,backgroundColor:"background.paper",width:w?"100%":600,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:j.palette.background.paper},children:[G.jsx(o.Box,{component:o.ButtonBase,onClick:a,sx:{flexGrow:0,flexShrink:0,display:"flex",alignItems:"center",color:j.palette.text.primary,width:24,height:24},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",children:G.jsx("path",{d:"M20 11.5H7.83L13.42 5.91L12 4.5L4 12.5L12 20.5L13.41 19.09L7.83 13.5H20V11.5Z",fill:"currentColor"})})}),G.jsx(o.Box,{sx:{flexGrow:1,textAlign:"center",typography:"caption",color:j.palette.text.primary},children:t.i18n._({id:"E6MqGy",message:"Add liquidity"})}),G.jsx(o.Box,{sx:{flexGrow:0,flexShrink:0,width:24,height:24}})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,p:20},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"nxRg31",message:"Select pair"})}),G.jsx(_c,{mint1:I.mint1,mint2:I.mint2,dispatch:B}),G.jsx(Zd,{disabled:!I.mint1||!I.mint2,feeAmount:I.feeAmount,dispatch:B})]}),G.jsxs(Kd,{disabled:!I.feeAmount||$,children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"5CZbyC",message:"Set price range"})}),F&&P&&G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8,width:"100%",[j.breakpoints.up("tablet")]:{ml:"auto",width:"auto"}},children:[G.jsx(o.Button,{size:o.Button.Size.small,variant:o.Button.Variant.outlined,onClick:ke,sx:Object.assign({py:4,px:12,height:26,typography:"h6",fontWeight:600},w?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0),children:t.i18n._({id:"5IHTSS",message:"Full range"})}),G.jsx(Oc,{mintA:F,mintB:P,selectedMintIndex:I.selectedMintIndex,handleRateToggle:()=>{B({type:Wd.UpdateSelectedMintIndex,payload:0===I.selectedMintIndex?1:0})},sx:w?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0})]})]}),G.jsx(Lc,{priceLower:ge,priceUpper:ye,getDecrementLower:ve,getIncrementLower:be,getDecrementUpper:je,getIncrementUpper:Ce,onLeftRangeInput:le,onRightRangeInput:se,ticksAtLimit:ie,perPriceText:Re}),te&&G.jsx(qd,{children:t.i18n._({id:"b+KjnH",message:"Your position will not earn fees or be used in trades until the market price moves into your range."})}),ee&&G.jsx(qd,{children:t.i18n._({id:"Jh223O",message:"Invalid range selected. The min price must be lower than the max price."})})]}),J?G.jsxs(Kd,{children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"zeSosD",message:"Starting price"})}),G.jsx(o.Box,{sx:{p:8,borderRadius:8,backgroundColor:o.alpha(j.palette.primary.main,.1),typography:"h6",color:j.palette.primary.main},children:t.i18n._({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."})}),G.jsx(o.Box,{sx:{px:16,py:12,borderRadius:8,borderWidth:1,borderColor:j.palette.border.main,borderStyle:"solid"},children:G.jsx(Es,{sx:{backgroundColor:"transparent"},value:L,onChange:de,suffix:G.jsx(o.Box,{sx:{typography:"h6",color:j.palette.text.secondary},children:Re})})})]}):G.jsxs(Kd,{disabled:!I.feeAmount||$,children:[G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:[t.i18n._({id:"DWd30U",message:"Current price"}),G.jsxs(o.Box,{children:[Ko({input:D,decimals:9})," ",t.i18n._({id:"b2jAb+",message:"per"})," ",null!==(m=null===(h=I.mint1)||void 0===h?void 0:h.symbol)&&void 0!==m?m:""]})]}),G.jsx(Mc,{mint1:I.mint1,mint2:I.mint2,feeAmount:I.feeAmount,ticksAtLimit:ie,price:D?D.toNumber():void 0,priceLower:ge,priceUpper:ye,onLeftRangeInput:le,onRightRangeInput:se,interactive:!0})]}),G.jsxs(Kd,{disabled:$||ee||J&&!L,children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"MU9s7M",message:"Deposit amounts"})}),G.jsxs(o.Box,{children:[G.jsx(Od,{value:he[Nd.DEPOSIT_1],onUserInput:re,maxAmount:me[Nd.DEPOSIT_1],balance:X[Nd.DEPOSIT_1],mint:null!==(f=Q[Nd.DEPOSIT_1])&&void 0!==f?f:null,locked:ne}),G.jsx(Ys,{}),G.jsx(Od,{value:he[Nd.DEPOSIT_2],onUserInput:ae,maxAmount:me[Nd.DEPOSIT_2],balance:X[Nd.DEPOSIT_2],mint:null!==(x=Q[Nd.DEPOSIT_2])&&void 0!==x?x:null,locked:oe})]}),G.jsx(Bd,{value:O,onChange:W,disabled:!1,type:n.CLMM})]})]}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:j.palette.background.paper},children:G.jsx(Md,{chainId:g,isValid:ce,errorMessage:K,setShowConfirm:pe})}),G.jsx(Yc,{position:_,outOfRange:te,ticksAtLimit:ie,on:ue,onClose:()=>{pe(!1)},onConfirm:Te.mutate,loading:Te.isPending})]})})}function wu({title:t,desc:n,linkTo:i,LeftImage:r,sx:a}){const l=o.useTheme(),s="light"===l.palette.mode;return G.jsxs(o.Box,{sx:Object.assign({backgroundColor:l.palette.background.paper,borderRadius:16,padding:20},a),children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[G.jsx(o.Box,{sx:{backgroundColor:o.alpha(l.palette.secondary.main,.3),color:s?"#EB8D27":l.palette.secondary.main,borderRadius:6,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.55558 0.888672C3.87558 0.888672 0.888916 3.87534 0.888916 7.55534C0.888916 11.2353 3.87558 14.222 7.55558 14.222C11.2356 14.222 14.2222 11.2353 14.2222 7.55534C14.2222 3.87534 11.2356 0.888672 7.55558 0.888672ZM8.22225 11.5553V10.222H6.88892V11.5553H8.22225ZM4.88892 6.22201C4.88892 4.74867 6.08225 3.55534 7.55558 3.55534C9.02892 3.55534 10.2222 4.74867 10.2222 6.22201C10.2222 7.07728 9.69557 7.53755 9.18276 7.9857C8.69626 8.41085 8.22225 8.82509 8.22225 9.55534H6.88892C6.88892 8.34116 7.51699 7.85973 8.06921 7.43646C8.50241 7.10441 8.88892 6.80815 8.88892 6.22201C8.88892 5.48867 8.28892 4.88867 7.55558 4.88867C6.82225 4.88867 6.22225 5.48867 6.22225 6.22201H4.88892Z",fill:"currentColor"})})}),G.jsx(o.Box,{sx:{color:l.palette.text.primary,typography:"body1",fontWeight:600,ml:4},children:G.jsx(e.Trans,{id:"cmUrtC",message:"SEE HOW IT WORKS"})})]}),G.jsxs(o.Box,{sx:{mt:20,borderTopWidth:1,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{component:r,sx:{width:64,height:64,flexShrink:0}}),G.jsxs(o.Box,{sx:{ml:16,color:l.palette.text.primary,typography:"body1",fontWeight:600},children:[t,G.jsx(o.Box,{sx:{mt:4,color:l.palette.text.secondary,typography:"body2",fontWeight:500},children:n})]})]}),G.jsx(o.Box,{component:"a",href:i,target:"_blank",rel:"noopener noreferrer",sx:{pl:16,flexShrink:0},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("path",{d:"M7.23375 3.75L6 4.98375L10.0075 9L6 13.0162L7.23375 14.25L12.4838 9L7.23375 3.75Z",fill:l.palette.text.primary})})})]})]})}const ku=[{value:0,label:"0%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:75,label:"75%"},{value:100,label:"100%"}];function Tu({disabled:e,value:t,onChange:n,sx:i}){return G.jsxs(o.Box,{sx:Object.assign({p:20,backgroundColor:"background.input",borderRadius:12},i),children:[G.jsx(Es,{value:String(t),onChange:e=>n(+e),readOnly:!0,readonlyShowSuffix:!0,suffix:G.jsx(o.Box,{sx:{typography:"h2"},children:"%"}),sx:{mt:12,"& input":{pl:0,typography:"h1"}}}),G.jsx(o.Box,{sx:{mt:20},children:G.jsx(o.Slider,{marks:ku,step:1,disabled:e,value:t,onChange:(e,t)=>n(t)})})]})}const Ru=50;var Su;!function(e){e[e.quantity=1]="quantity",e[e.percentage=2]="percentage"}(Su||(Su={}));const Iu=({chainId:e,disabled:n,isLoading:i,onConfirm:r})=>G.jsx(bs,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:r,disabled:n,isLoading:i,children:t.i18n._({id:"h5pjuM",message:"Collect fees"})})}),Bu=({mint:e,pooledAmount:t})=>{var n;const i=o.useTheme();return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Wa,{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}),G.jsxs(o.Box,{sx:{typography:"body1",color:i.palette.text.primary},children:[Ko({input:t,decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),G.jsx(o.ButtonBase,{sx:{display:"flex",alignItems:"center",color:i.palette.text.secondary,"&:hover":{color:i.palette.text.primary}},onClick:()=>{e&&window.open(Ns(e.chainId,e.address,"address"))},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.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"})})})]})},Mu=({mintA:i,mintB:r,feeAmount:a,existingPosition:l,positionInfo:s,inRange:d,removed:c})=>{const u=o.useTheme();return G.jsxs(o.Box,{sx:{border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:u.spacing(12,20),borderBottomStyle:"solid",borderBottomColor:"border.main",borderBottomWidth:1},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(o.Box,{sx:{typography:"body2",color:u.palette.text.primary},children:[t.i18n._({id:"PVa3KL",message:"Position on"})," ",null==i?void 0:i.symbol,"/",null==r?void 0:r.symbol]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nc,{removed:c,inRange:d}),G.jsx(o.Box,{sx:{py:4,px:8,color:u.palette.primary.main,borderRadius:4,backgroundColor:o.alpha(u.palette.primary.main,.1),typography:"h6"},children:Pc({type:n.CLMM,lpFeeRate:a,mtFeeRate:0})})]})]}),G.jsxs(o.ButtonBase,{sx:{display:"flex",alignItems:"center",gap:0,typography:"body2",color:u.palette.text.secondary,"&:hover":{color:u.palette.text.primary}},onClick:()=>{(null==i?void 0:i.chainId)&&window.open(Ns(i.chainId,null==l?void 0:l.poolId.toBase58(),"address"))},children:[t.i18n._({id:"URmyfc",message:"Details"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M7.5 5L6.4425 6.0575L9.8775 9.5L6.4425 12.9425L7.5 14L12 9.5L7.5 5Z",fill:"currentColor"})})]})]}),G.jsxs(o.Box,{sx:{p:u.spacing(12,20)},children:[G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(o.Box,{sx:{mt:12},children:[G.jsx(Bu,{mint:i,pooledAmount:null==s?void 0:s.pooledAmountA}),G.jsx(Bu,{mint:r,pooledAmount:null==s?void 0:s.pooledAmountB})]})]})]})},Eu=({chainId:e,disabled:n,removed:i,isLoading:r,onConfirm:a})=>G.jsx(bs,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:a,disabled:n,isLoading:r,children:i?t.i18n._({id:"D87pha",message:"Closed"}):t.i18n._({id:"t/YqKh",message:"Remove"})})});function Lu({position:e}){const t=Ua(),[,n]=bc(e?e.poolId.toBase58():null),{data:o}=d.useQuery({queryKey:["clmm","getPositionInfo",e,null==n?void 0:n.poolInfo],enabled:!!e&&!!(null==n?void 0:n.poolInfo),queryFn:()=>Wo(this,void 0,void 0,(function*(){const o=null==n?void 0:n.poolInfo;if(!o||!t||!e)return null;const i=y.TickUtils.getTickPrice({poolInfo:o,tick:e.tickLower,baseIn:!0}),a=y.TickUtils.getTickPrice({poolInfo:o,tick:e.tickUpper,baseIn:!0}),l=yield t.connection.getEpochInfo(),{amountA:s,amountB:d}=y.PositionUtils.getAmountsFromLiquidity({poolInfo:o,ownerPosition:e,liquidity:e.liquidity,slippage:0,add:!1,epochInfo:l}),[c,u]=[new r(s.amount.toString()).div(10**o.mintA.decimals),new r(d.amount.toString()).div(10**o.mintB.decimals)];return{pooledAmountA:c,pooledAmountB:u,priceLower:new r(i.price.toString()),priceUpper:new r(a.price.toString())}}))});return{pool:n,positionInfo:null!=o?o:null}}function Ou(e){var t;const n=Ua(),o=d.useQuery({queryKey:["clmm","getOwnerPositionInfo",e,null==n?void 0:n.owner],enabled:null!=e&&null!=n&&null!=n.owner,queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!n||!n.owner||!e)return null;const t=gi[e];if(!t)throw new Error("Invalid config");try{const e=yield n.clmm.getOwnerPositionInfo({programId:t.programId});return e.forEach((e=>{console.log("getOwnerPositionInfo p",e.poolId.toBase58(),e.nftMint.toBase58(),e.liquidity.toString(),e.tickLower,e.tickUpper)})),{allPosition:e}}catch(e){return console.error("getOwnerPositionInfo error",e),null}}))});return{loading:o.isLoading,positions:null===(t=o.data)||void 0===t?void 0:t.allPosition}}const Wu=({mint:e,rewardAmountOwed:t})=>{var n;const i=o.useTheme();return G.jsxs(o.Box,{sx:{py:8,display:"flex",alignItems:"center",gap:6,typography:"h5",color:i.palette.text.primary},children:[G.jsx(Wa,{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}),G.jsx(o.Box,{children:null==e?void 0:e.symbol}),G.jsx(o.Box,{sx:{ml:"auto"},children:Ko({input:null==t?void 0:t.toString(),decimals:null==e?void 0:e.decimals})})]})},Vu=({mint1Address:e,mint2Address:a,feeAmount:l,poolId:s,nftMint:c,onClose:p})=>{const{isMobile:h}=Ls(),m=o.useTheme(),f=Si(),x=d.useQueryClient(),{account:g,chainId:v}=Zo(),b=Ua(),{position:j}=function({chainId:e,nftMint:t,poolId:n}){const o=Ou(e);return{position:i.useMemo((()=>{if(o.positions)return o.positions.find((e=>e.nftMint.equals(new u.PublicKey(t))&&e.poolId.equals(new u.PublicKey(n))))}),[o,t,n]),loading:o.loading}}({chainId:v,nftMint:c,poolId:s}),{positionInfo:C,pool:w}=Lu({position:j}),[k,R]=i.useState("stake"),[I,B]=i.useState(!1),[M,E]=i.useState(Ru),L=Jc({mint:e,chainId:v}),O=Jc({mint:a,chainId:v}),[W,V]=i.useReducer(Ad,{mint1:L,mint2:O,feeAmount:l,selectedMintIndex:0,independentField:Nd.DEPOSIT_1,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""});i.useEffect((()=>{L&&V({type:Wd.UpdateDefaultMint1,payload:L})}),[L]),i.useEffect((()=>{O&&V({type:Wd.UpdateDefaultMint2,payload:O})}),[O]);const{independentField:F,typedValue:P}=W,{slipper:Z,setSlipper:N,slipperValue:U}=Id({type:n.CLMM}),{mintA:H,mintB:D,dependentField:Y,parsedAmounts:z,depositBalances:q,position:X,mints:_,errorMessage:J,invalidRange:Q,outOfRange:K,depositADisabled:$,depositBDisabled:ee,ticksAtLimit:te}=xu({state:W,existingPosition:j,slipperValue:U}),ne=(null==j?void 0:j.liquidity)&&j.liquidity.eq(new T(0)),{onField1Input:oe,onField2Input:ie}=gu({dispatch:V}),re=!J&&!Q,ae=i.useMemo((()=>{var e,t;return{[F]:P,[Y]:null!==(t=null===(e=z[Y])||void 0===e?void 0:e.toString())&&void 0!==t?t:""}}),[Y,F,z,P]),le=[Nd.DEPOSIT_1,Nd.DEPOSIT_2].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:vu(q[t])})),{}),se=d.useMutation({mutationFn:()=>Wo(void 0,void 0,void 0,(function*(){if(!g)throw new Error("account is undefined");if(!b)throw new Error("raydium is undefined");if(!j)throw new Error("existingPosition is undefined");if(!(null==w?void 0:w.poolInfo))throw new Error("poolInfo is undefined");if(!X)throw new Error("position is undefined");const{execute:e}=yield b.clmm.increasePositionFromLiquidity({poolInfo:w.poolInfo,poolKeys:w.poolKeys,ownerPosition:j,ownerInfo:{useSOLBalance:!0},liquidity:new T(new S(X.liquidity.toString()).mul(1-U).toFixed(0)),amountMaxA:new T(new S(P||"0").mul(10**w.poolInfo.mintA.decimals).toFixed(0)),amountMaxB:new T(X.amountB.multipliedBy(1+U).multipliedBy(new r(10**w.poolInfo.mintB.decimals)).toFixed(0)),checkCreateATAOwner:!0,txVersion:y.TxVersion.LEGACY});(yield f.executeCustom({brief:t.i18n._({id:"OBdohg",message:"Add Liquidity"}),metadata:{[exports.MetadataFlag.addAMMV3Pool]:!0},handler:t=>Wo(void 0,void 0,void 0,(function*(){const{txId:n}=yield e({sendAndConfirm:!0});t.onSuccess(n)}))}))===Ho.Success&&(B(!1),setTimeout((()=>{null==p||p()}),100)),x.invalidateQueries({queryKey:["clmm"],refetchType:"all"})})),onError:e=>{console.error(e)}}),de=d.useMutation({mutationFn:()=>Wo(void 0,void 0,void 0,(function*(){if(!g)throw new Error("account is undefined");if(!b)throw new Error("raydium is undefined");if(!j)throw new Error("existingPosition is undefined");if(!(null==w?void 0:w.poolInfo))throw new Error("poolInfo is undefined");const e=new T(new S(j.liquidity.toString()).mul(1-M/100).toFixed(0)),{execute:n}=yield b.clmm.decreaseLiquidity({poolInfo:w.poolInfo,poolKeys:w.poolKeys,ownerPosition:j,ownerInfo:{useSOLBalance:!0,closePosition:!1},liquidity:e,amountMinA:new T(0),amountMinB:new T(0),txVersion:y.TxVersion.LEGACY});(yield f.executeCustom({brief:t.i18n._({id:"3XBvkd",message:"Remove Liquidity"}),metadata:{[exports.MetadataFlag.removeAMMV3Pool]:!0},handler:e=>Wo(void 0,void 0,void 0,(function*(){const{txId:t}=yield n({sendAndConfirm:!0});e.onSuccess(t)}))}))===Ho.Success&&setTimeout((()=>{null==p||p()}),100),x.invalidateQueries({queryKey:["clmm"],refetchType:"all"})})),onError:e=>{console.error("onRemoveMutation",e)}}),ce=d.useMutation({mutationFn:()=>Wo(void 0,void 0,void 0,(function*(){if(!b)throw new Error("raydium is undefined");if(!(null==w?void 0:w.poolInfo))throw new Error("poolInfo is undefined");const{execute:e}=yield b.clmm.collectRewards({poolInfo:w.poolInfo,ownerInfo:{useSOLBalance:!0},rewardMints:w.poolInfo.rewardDefaultInfos.map((e=>new u.PublicKey(e.mint.address))),associatedOnly:!0,checkCreateATAOwner:!0,computeBudgetConfig:void 0,txTipConfig:void 0});(yield f.executeCustom({brief:t.i18n._({id:"zXCpR0",message:"Claim Rewards"}),metadata:{[exports.MetadataFlag.claimAMMV3Pool]:!0},handler:t=>Wo(void 0,void 0,void 0,(function*(){const{txId:n}=yield e();t.onSuccess(n)}))}))===Ho.Success&&setTimeout((()=>{null==p||p()}),100),x.invalidateQueries({queryKey:["clmm"],refetchType:"all"})})),onError:e=>{console.error("onClaimMutation",e)}}),ue=i.useMemo((()=>{var e,i;const r=[{key:"stake",value:t.i18n._({id:"JYKRJS",message:"Stake"})},{key:"unstake",value:t.i18n._({id:"OFjZGo",message:"Unstake"})},{key:"claim",value:t.i18n._({id:"hom7qf",message:"Claim"})}];return G.jsxs(o.Box,{sx:{borderRadius:16,backgroundColor:m.palette.background.paper},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:m.palette.background.paper},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.primary},children:t.i18n._({id:"E6MqGy",message:"Add liquidity"})}),p?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(o.Box,{component:A.Error,sx:{width:16,height:16},onClick:()=>{p()}})}):void 0]}),G.jsx(o.Box,{sx:{mx:20,mb:16},children:G.jsx(Mu,{existingPosition:j,positionInfo:C,inRange:!K,removed:ne,mintA:H,mintB:D,feeAmount:l})}),G.jsxs(o.Tabs,{value:k,onChange:(e,t)=>{R(t)},children:[G.jsx(o.TabsButtonGroup,{tabs:r,variant:"inPaper",tabsListSx:{mx:20}}),G.jsxs(o.TabPanel,{value:"stake",children:[X&&G.jsx(o.Box,{sx:{mt:16,mx:20},children:G.jsx(Hc,{position:X,title:t.i18n._({id:"3VUfrF",message:"Selected Range"}),ticksAtLimit:te})}),G.jsxs(o.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.secondary,textAlign:"left"},children:t.i18n._({id:"BRi+RY",message:"Add more liquidity"})}),G.jsxs(o.Box,{children:[G.jsx(Od,{value:ae[Nd.DEPOSIT_1],onUserInput:oe,maxAmount:le[Nd.DEPOSIT_1],balance:q[Nd.DEPOSIT_1],mint:null!==(e=_[Nd.DEPOSIT_1])&&void 0!==e?e:null,locked:$}),G.jsx(Ys,{}),G.jsx(Od,{value:ae[Nd.DEPOSIT_2],onUserInput:ie,maxAmount:le[Nd.DEPOSIT_2],balance:q[Nd.DEPOSIT_2],mint:null!==(i=_[Nd.DEPOSIT_2])&&void 0!==i?i:null,locked:ee})]}),G.jsx(Bd,{value:Z,onChange:N,disabled:!1,type:n.CLMM})]}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:m.palette.background.paper},children:G.jsx(Md,{chainId:v,isValid:re,errorMessage:J,setShowConfirm:B})}),G.jsx(Yc,{position:X,outOfRange:K,ticksAtLimit:te,on:I,onClose:()=>{B(!1)},onConfirm:se.mutate,loading:se.isPending})]}),G.jsxs(o.TabPanel,{value:"unstake",children:[G.jsxs(o.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(Tu,{disabled:!1,value:M,onChange:e=>E(e)}),G.jsx(Bd,{value:Z,onChange:N,disabled:!1,type:n.CLMM})]}),G.jsxs(o.Box,{sx:{mt:16,mx:20,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[G.jsx(o.Box,{sx:{typography:"body2",color:m.palette.text.secondary},children:"Receive"}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.primary},children:[G.jsx(o.Box,{component:"span",sx:{color:m.palette.primary.main},children:(null==C?void 0:C.pooledAmountA)?Ko({input:C.pooledAmountA.multipliedBy(M/100),decimals:null==H?void 0:H.decimals}):"-"})," ",null==H?void 0:H.symbol]}),G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.primary},children:[G.jsx(o.Box,{component:"span",sx:{color:m.palette.primary.main},children:(null==C?void 0:C.pooledAmountB)?Ko({input:C.pooledAmountB.multipliedBy(M/100),decimals:null==D?void 0:D.decimals}):"-"})," ",null==D?void 0:D.symbol]})]})]}),G.jsx(o.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:m.palette.background.paper},children:G.jsx(Eu,{chainId:v,disabled:ne||0===M,removed:ne,onConfirm:de.mutate,isLoading:de.isPending})})]}),G.jsxs(o.TabPanel,{value:"claim",children:[G.jsxs(o.Box,{sx:{mx:20,mt:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:m.palette.border.main},children:[G.jsx(o.Box,{sx:{py:12,px:20,typography:"body1",color:m.palette.text.primary,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:m.palette.border.main},children:t.i18n._({id:"tu/fxg",message:"Claim fees"})}),G.jsx(o.Box,{sx:{p:20},children:null==w?void 0:w.poolInfo.rewardDefaultInfos.map(((e,t)=>{const n=null==j?void 0:j.rewardInfos[t].rewardAmountOwed;return G.jsx(Wu,{mint:e.mint,rewardAmountOwed:n},e.mint.address)}))})]}),G.jsx(o.Box,{sx:{mx:20,mt:16,typography:"h6",color:m.palette.text.secondary},children:t.i18n._({id:"Joa5Dk",message:"*Collecting fees will withdraw currently available fees for you."})}),G.jsx(o.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:m.palette.background.paper},children:G.jsx(Iu,{chainId:v,disabled:ce.isPending||!(null==w?void 0:w.poolInfo)||0===(null==w?void 0:w.poolInfo.rewardDefaultInfos.length),onConfirm:ce.mutate,isLoading:ce.isPending})})]})]})]})}),[v,$,ee,q,J,j,l,ae,re,le,H,D,_,se.isPending,se.mutate,ce.isPending,ce.mutate,p,oe,ie,de.isPending,de.mutate,k,K,null==w?void 0:w.poolInfo,X,C,ne,N,I,M,Z,m.palette.background.paper,m.palette.border.main,m.palette.primary.main,m.palette.text.primary,m.palette.text.secondary,te]);return h?G.jsx(ds,{open:null!=H&&null!=D,onClose:p,scope:!h,modal:void 0,id:"pool-operate",children:ue}):ue};const Au=({outOfRange:e})=>{const n=o.useTheme();return G.jsx(o.Tooltip,{title:e?t.i18n._({id:"i3Z+/Z",message:"Out of range"}):t.i18n._({id:"vOyUlD",message:"In range"}),children:G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:e?G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:G.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:n.palette.warning.main})}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:G.jsx("circle",{cx:"4",cy:"4",r:"4",fill:n.palette.success.main})})})})},Fu=({position:e,mintA:n,mintB:r,feeAmount:a,onClickManage:l})=>{const s=o.useTheme(),{positionInfo:d,pool:c}=Lu({position:e}),u=function(e,t,n){return i.useMemo((()=>({[Ud.LOWER]:e&&t?t===Qc(y.MIN_TICK,Fd[e]):void 0,[Ud.UPPER]:e&&n?n===Qc(y.MAX_TICK,Fd[e]):void 0})),[e,t,n])}(a,e.tickLower,e.tickUpper),p=null==d?void 0:d.priceLower,h=null==d?void 0:d.priceUpper,m=!!(null==c?void 0:c.computePoolInfo)&&(c.computePoolInfo.tickCurrent<e.tickLower||c.computePoolInfo.tickCurrent>=e.tickUpper),f=null==c?void 0:c.poolInfo.price;return G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,px:20,py:20,pb:12,borderRadius:12,backgroundColor:s.palette.background.paperContrast},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h5",color:s.palette.text.primary},children:[G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:p,atLimit:u,direction:Ud.LOWER})," "]}),null==r?void 0:r.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.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"})}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:h,atLimit:u,direction:Ud.UPPER})," "]}),null==r?void 0:r.symbol]})})]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Au,{outOfRange:m}),G.jsxs(o.Box,{sx:{typography:"h6",color:s.palette.text.secondary},children:["Current price: ",Ko({input:f})," ",null==r?void 0:r.symbol," per ",null==n?void 0:n.symbol]})]})]}),G.jsx(o.Button,{variant:o.Button.Variant.outlined,size:o.Button.Size.small,fullWidth:!0,onClick:l,children:t.i18n._({id:"wckWOP",message:"Manage"})})]})};const Pu=({mint1Address:e,mint2Address:n,feeAmount:r,poolId:a,onClose:l,handleGoToAddLiquidityV3:s})=>{const{isMobile:d}=Ls(),c=o.useTheme(),{chainId:p,account:h}=Zo(),{positions:m,loading:f}=Ou(p),{mintA:x,mintB:g}=function({mint1Address:e,mint2Address:t}){const{chainId:n}=Zo(),o=Jc({mint:e,chainId:n}),r=Jc({mint:t,chainId:n}),[a,l]=i.useMemo((()=>o&&r?new T(new u.PublicKey(o.address).toBuffer()).gt(new T(new u.PublicKey(r.address).toBuffer()))?[r,o]:[o,r]:[void 0,void 0]),[o,r]);return{mintA:a,mintB:l}}({mint1Address:e,mint2Address:n}),y=i.useMemo((()=>{if(void 0!==m)return m.filter((e=>e.poolId.equals(new u.PublicKey(a))))}),[m,a]),[v,b]=i.useState(null),j=i.useMemo((()=>{var e;return G.jsxs(o.Box,{sx:{p:20,display:"flex",flexDirection:"column",gap:16,borderRadius:16,backgroundColor:c.palette.background.paper,minHeight:480},children:[G.jsxs(o.Box,{sx:{pb:16,borderBottomColor:c.palette.border.main,borderBottomStyle:"solid",borderBottomWidth:1,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:c.palette.text.primary},children:[t.i18n._({id:"Gs02OK",message:"My Positions"})," (",null!==(e=null==y?void 0:y.length)&&void 0!==e?e:0,")"]}),l?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(o.Box,{component:A.Error,sx:{width:16,height:16},onClick:()=>{l()}})}):void 0]}),f||!y?G.jsx(G.Fragment,{children:G.jsx(o.Box,{sx:{mt:100,display:"flex",justifyContent:"center"},children:G.jsx(_a,{})})}):y.length>0?G.jsxs(G.Fragment,{children:[null==y?void 0:y.map((e=>G.jsx(Fu,{position:e,mintA:x,mintB:g,feeAmount:r,onClickManage:()=>{b(e)}},e.nftMint.toBase58()))),G.jsxs(o.Button,{size:o.Button.Size.big,variant:o.Button.Variant.second,onClick:()=>{s({mint1:null==x?void 0:x.address,mint2:null==g?void 0:g.address,fee:String(r)})},sx:{gap:8},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:G.jsx("path",{d:"M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z",fill:"currentColor"})}),t.i18n._({id:"FQ4aT9",message:"Add Position"})]})]}):G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{mt:100,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[G.jsx(o.EmptyDataIcon,{sx:{width:60,height:60,borderRadius:24/105*60}}),G.jsx(o.Box,{sx:{typography:"body1",color:c.palette.text.secondary},children:t.i18n._({id:"/6L4mj",message:"Your position is empty"})})]}),G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsx(bs,{size:o.Button.Size.small,includeButton:!0,children:G.jsx(o.Button,{size:o.Button.Size.small,onClick:()=>{s({mint1:null==x?void 0:x.address,mint2:null==g?void 0:g.address,fee:String(r)})},children:t.i18n._({id:"FQ4aT9",message:"Add Position"})})})})]})]})}),[y,r,s,f,x,g,l,c.palette.background.paper,c.palette.border.main,c.palette.text.primary,c.palette.text.secondary]);return null!==v?G.jsx(Vu,{mint1Address:e,mint2Address:n,feeAmount:r,poolId:v.poolId.toBase58(),nftMint:v.nftMint.toBase58(),onClose:()=>{b(null)}}):d?G.jsx(ds,{open:null!=x&&null!=g,onClose:l,scope:!d,modal:void 0,id:"pool-operate",children:j}):j};var Zu,Nu;function Uu({message:t,onClose:n}){return G.jsx(ds,{open:!!t,onClose:n,id:"error-message",children:G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{flex:1,textAlign:"center"},children:[G.jsx(o.Box,{component:A.ErrorWarn,sx:{mt:60,width:64,height:64,color:"error.main"}}),t?G.jsxs(o.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(o.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(o.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:t})]}):""]}),G.jsx(o.Box,{sx:{px:16,py:20},children:G.jsx(o.Button,{onClick:n,fullWidth:!0,children:G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"})})})]})})}function Hu({status:t,children:n,buttonProps:i}){return!t.needShowTokenStatusButton&&n?G.jsx(G.Fragment,{children:n}):t.insufficientBalance?G.jsx(o.Button,{fullWidth:!0,disabled:!0,...i,children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):G.jsx(o.Button,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance,...i,children:t.isApproving?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):t.approveTitle})}function Du({chainId:t,baseTokenStatus:n,quoteTokenStatus:i,children:r}){const{runningRequests:a}=Ii(),{account:l,chainId:s}=Zo();if(!l||t!==s)return G.jsx(bs,{chainId:t,fullWidth:!0});const d=a.some((e=>{var t,n;return(null===(t=e.metadata)||void 0===t?void 0:t[exports.MetadataFlag.addLiquidity])||(null===(n=e.metadata)||void 0===n?void 0:n[exports.MetadataFlag.removeLiquidity])})),c=[];n.needShowTokenStatusButton&&c.push(G.jsx(Hu,{status:n})),i.needShowTokenStatusButton&&!n.isApproving&&c.push(G.jsx(Hu,{status:i}));const u=c.length;return 2===u?G.jsx(o.Box,{sx:{display:"flex","& > button":{flex:1,"&:last-child":{ml:8}}},children:c.map((e=>e))}):1===u?c[0]:d?G.jsx(o.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:G.jsx(e.Trans,{id:"UbRKMZ",message:"Pending"})}):G.jsx(G.Fragment,{children:r})}function Yu({pool:e,maxBaseAmount:t,maxQuoteAmount:n,isRemove:o}){const[a,l]=i.useState(""),[s,d]=i.useState(""),[c,u]=i.useState(Co),p=c===Co?new r(td).div(100).toNumber():c,h=()=>{l(""),d("")},m=rd({pool:(null==e?void 0:e.baseToken)&&e.quoteToken?{baseToken:e.baseToken,quoteToken:e.quoteToken,address:e.address}:void 0,baseAmount:a,quoteAmount:s,slippage:p}),f=m.isFront?m.price:m.invertedPrice,x=f||new r(1),g=i.useRef(x);if(!e||x.isNaN())return{baseAmount:a,quoteAmount:s,handleChangeBaseAmount:()=>{},handleChangeQuoteAmount:()=>{},reset:h,uniV2Pair:m,slippage:c,slippageNumber:p,setSlippage:u};const y=e.baseToken.decimals,v=e.quoteToken.decimals,b=e=>{if(e){let i=x.multipliedBy(e).dp(v).toString();n&&o&&(n.lte(i)||(null==t?void 0:t.lte(0)))&&(i=n.toString()),d(i)}else d(e)};g.current&&x.isEqualTo(g.current)||(g.current=x,b(a));return{baseAmount:a,quoteAmount:s,handleChangeBaseAmount:e=>{let t=ti(e,y);null===t&&(t=a),l(t),b(t)},handleChangeQuoteAmount:e=>{let i=ti(e,v);null===i&&(i=s),d(i),(e=>{if(e){let i=new r(e).div(x).dp(y).toString();t&&o&&(t.lte(i)||(null==n?void 0:n.lte(0)))&&(i=t.toString()),l(i)}else l(e)})(i)},reset:h,midPrice:f,addPortion:x,amountCheckedDisabled:!a||!s,uniV2Pair:m,slippage:c,slippageNumber:p,setSlippage:u}}function zu({submittedBack:e,pool:n}){var r,a,l;const s="SVM_AMMV2"===(null==n?void 0:n.type),[d,c]=i.useState(!1),{baseAmount:u,quoteAmount:p,midPrice:h,amountCheckedDisabled:m,uniV2Pair:f,handleChangeBaseAmount:x,handleChangeQuoteAmount:g,reset:y,slippage:v,slippageNumber:b,setSlippage:j}=Yu({pool:n});i.useEffect((()=>{y()}),[n]);const C=ur(null==n?void 0:n.baseToken,{amount:u}),w=ur(null==n?void 0:n.quoteToken,{amount:p}),k=C.insufficientBalance||w.insufficientBalance,T=!n||k||!h||!!f.poolInfoQuery.isLoading||!!f.poolInfoQuery.error||m||f.poolInfoQuery.isLoading;let R=s?t.i18n._({id:"bwSQI0",message:"Supply"}):t.i18n._({id:"m16xKo",message:"Add"});k&&(R=t.i18n._({id:"znqB4T",message:"Insufficient balance"}));const S=id({baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,pairMintAAmount:f.pairMintAAmount,pairMintBAmount:f.pairMintBAmount,isExists:f.isExists,poolKeys:null===(r=f.poolInfoQuery.data)||void 0===r?void 0:r.poolKeys,poolInfo:null===(a=f.poolInfoQuery.data)||void 0===a?void 0:a.poolInfo,slippage:b,submittedBack:()=>{y(),e&&e(),c(!1)}}),I=!(null==n?void 0:n.baseToken)||!(null==n?void 0:n.quoteToken);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{pt:20,pb:18,px:20},children:[G.jsx(zs,{sx:{mb:4,pb:28,minHeight:"auto"},amt:u,token:null==n?void 0:n.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:x,readOnly:f.poolInfoQuery.isLoading}),G.jsx(Is,{plus:!0}),G.jsx(zs,{sx:{pb:20,minHeight:"auto"},amt:p,token:null==n?void 0:n.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:g,readOnly:f.poolInfoQuery.isLoading}),G.jsx(Rd,{slippage:v,onChangeSlippage:j,disabled:I,sx:{mt:8}}),G.jsx(vd,{baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,loading:f.poolInfoQuery.isLoading,midPrice:h,lpBalancePercentage:f.isExists?f.lpBalancePercentage:100})]}),G.jsx(o.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:n?G.jsx(Du,{chainId:n.chainId,baseTokenStatus:C,quoteTokenStatus:w,children:G.jsx(o.Button,{fullWidth:!0,disabled:T,isLoading:S.isPending,onClick:()=>{T||c(!0)},children:R})}):G.jsx(o.Button,{fullWidth:!0,disabled:!0,children:R})}),G.jsx(Uu,{message:null===(l=S.error)||void 0===l?void 0:l.message,onClose:()=>S.reset()}),s&&!!n&&G.jsx(bd,{open:d,onClose:()=>c(!1),slippage:b,baseToken:n.baseToken,quoteToken:n.quoteToken,pairMintAAmount:f.pairMintAAmount,pairMintBAmount:f.pairMintBAmount,feeRate:n.lpFeeRate,price:null==f?void 0:f.price,lpAmount:null==f?void 0:f.liquidityMinted,lpBalancePercentage:f.isExists?f.lpBalancePercentage:100,pairAddress:n.address,createMutation:S})]})}function qu({hidePoolInfo:t,pool:n,children:i}){var r,a,l,s,d;const c=o.useTheme(),u=!n,p="SVM_AMMV2"===(null==n?void 0:n.type),h=n?Pc({type:n.type,lpFeeRate:null!==(r=n.lpFeeRate)&&void 0!==r?r:"0",mtFeeRate:null!==(a=n.mtFeeRate)&&void 0!==a?a:"0"}):"-";return G.jsxs(o.Box,{sx:{mt:16,mx:20,border:"solid 1px",borderColor:"border.main",borderRadius:12},children:[t?"":G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:c.spacing(12,20),borderStyle:"solid",borderColor:"border.main",borderWidth:c.spacing(0,0,1)},children:[G.jsxs(o.Box,{children:[G.jsxs(o.LoadingSkeleton,{loading:u,loadingSx:{width:100,mb:4},sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[null===(l=null==n?void 0:n.baseToken)||void 0===l?void 0:l.symbol,"/",null===(s=null==n?void 0:n.quoteToken)||void 0===s?void 0:s.symbol,p&&G.jsx(o.Tooltip,{title:G.jsxs(o.Box,{sx:{typography:"h6","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"ipqmyu",message:"By adding liquidity you’ll earn <0>{feeRate}</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:{feeRate:h},components:{0:G.jsx("b",{})}})]}),sx:{maxWidth:240},children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.disabled"},children:h})})]}),G.jsx(o.LoadingSkeleton,{loading:u,children:G.jsx(fd,{address:null!==(d=null==n?void 0:n.address)&&void 0!==d?d:"",truncate:!0,iconSize:14,iconSpace:4,customChainId:null==n?void 0:n.chainId,sx:{typography:"h6",color:"text.secondary"}})})]}),(null==n?void 0:n.address)&&!p?G.jsxs(o.Box,{component:o.ButtonBase,sx:{typography:"body2",display:"flex",alignItems:"center",color:"text.secondary"},onClick:()=>{Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:n.chainId,address:n.address}})},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),G.jsx(o.Box,{component:A.ArrowRight,sx:{ml:4,position:"relative",top:1.2,width:16,height:16}})]}):""]}),G.jsx(o.Box,{sx:{p:c.spacing(12,20)},children:i})]})}function Xu({submittedBack:n,pool:a}){var l,s,c;const[u,p]=i.useState(""),[h,m]=i.useState(""),[f,x]=i.useState(Co),g=f===Co?new r(td).div(100).toNumber():f,{isFront:v,price:b,invertedPrice:j,poolInfoQuery:C,lpBalanceQuery:w,lpBalance:k,lpBalancePercentage:R,lpToAmountA:I,lpToAmountB:B,liquidityMinted:M,pairMintAAmount:E,pairMintBAmount:L,isExists:O}=rd({pool:(null==a?void 0:a.baseToken)&&a.quoteToken?{baseToken:a.baseToken,quoteToken:a.quoteToken,address:a.address}:void 0,baseAmount:void 0,quoteAmount:void 0,slippage:0}),{mode:W,modeOptions:V,handleChangeMode:A,sliderPercentage:F,handleChangeSliderPercentage:P,resetPercentage:Z}=function({isBase:e,pool:n,baseOverride:o,quoteOverride:r,resetAmount:a,handleChangeBaseAmount:l,handleChangeQuoteAmount:s}){const[d,c]=i.useState(Su.percentage),[u,p]=i.useState(Ru),h=i.useRef(null),m=()=>{h.current&&clearTimeout(h.current)},f=()=>{m(),p(Ru)};return i.useEffect((()=>m),[]),{mode:d,modeOptions:[{key:Su.percentage,value:t.i18n._({id:"x4QVeW",message:"Percentage to remove"})}],handleChangeMode:e=>{c(e),null==a||a(),f()},sliderPercentage:u,handleChangeSliderPercentage:t=>{if(m(),t!==u&&p(t),!n)return;const i=100===t,a=()=>{if(n)if(e||void 0===e){if(o){let e=o.toString();i||(e=ei(o.times(t/100),n.baseToken.decimals)),null==l||l(e)}}else if(r){let e=r.toString();i||(e=ei(r.times(t/100),n.quoteToken.decimals)),null==s||s(e)}};i?a():h.current=setTimeout(a,100)},resetPercentage:f}}({isBase:!0,pool:a,baseOverride:I,quoteOverride:B}),N=ur(null==a?void 0:a.baseToken,{amount:u}),U=ur(null==a?void 0:a.quoteToken,{amount:h}),H=!a||!!C.isLoading||!!C.error||!!w.error||w.isLoading,D=t.i18n._({id:"t/YqKh",message:"Remove"}),Y=function({liquidityAmount:n,slippage:o,poolInfo:i,poolKeys:r,submittedBack:a}){const l=Si(),s=Ua();return e.useLingui(),d.useMutation({mutationFn:()=>Wo(this,void 0,void 0,(function*(){if(!s)throw new Error("raydium is undefined");if(!i||!r)throw new Error("poolInfo or poolKeys is undefined");if(!n)throw new Error("liquidityAmount is undefined");const e=new T(new S(n.toString()).mul(10**i.lpMint.decimals).toFixed(0,S.ROUND_DOWN)),d=new y.Percent(100*o*100,1e4),{execute:c}=yield s.cpmm.withdrawLiquidity({poolInfo:i,poolKeys:r,lpAmount:e,txVersion:y.TxVersion.LEGACY,slippage:d});return yield l.executeCustom({brief:t.i18n._({id:"cJtosk",message:"Remove liquidity"}),metadata:{[exports.MetadataFlag.removeLiqidityAMMV2Position]:!0},handler:e=>Wo(this,void 0,void 0,(function*(){const{txId:t}=yield c({sendAndConfirm:!0});e.onSuccess(t)})),submittedBack:a})}))})}({liquidityAmount:null==k?void 0:k.times(F/100),slippage:g,poolKeys:null===(l=C.data)||void 0===l?void 0:l.poolKeys,poolInfo:null===(s=C.data)||void 0===s?void 0:s.poolInfo,submittedBack:()=>{n&&n()}}),z=!(null==a?void 0:a.baseToken)||!(null==a?void 0:a.quoteToken);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{pb:18,px:20},children:[G.jsx(o.Box,{sx:{pt:20},children:W===Su.percentage?G.jsx(Tu,{disabled:C.isLoading||!k||k.lte(0),value:F,onChange:P}):G.jsx(G.Fragment,{})}),G.jsx(Rd,{slippage:f,onChangeSlippage:x,disabled:z,sx:{mt:8}}),G.jsx(vd,{baseToken:null==a?void 0:a.baseToken,quoteToken:null==a?void 0:a.quoteToken,loading:C.isLoading,midPrice:v?b:j,lpBalancePercentage:O?R:100})]}),G.jsx(o.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:a?G.jsx(Du,{chainId:a.chainId,baseTokenStatus:N,quoteTokenStatus:U,children:G.jsx(o.Button,{fullWidth:!0,disabled:H,isLoading:Y.isPending,onClick:()=>{H||Y.mutate()},children:D})}):G.jsx(o.Button,{fullWidth:!0,disabled:!0,children:D})}),G.jsx(Uu,{message:null===(c=Y.error)||void 0===c?void 0:c.message,onClose:()=>Y.reset()})]})}function Gu({pool:t,operate:n,hidePoolInfo:r,submittedBack:a}){var l;const{operateTab:s,operateTabs:d,handleChangeTab:c}=function(t=Nu.Add){const{i18n:n}=e.useLingui(),[o,r]=i.useState(t),a=i.useMemo((()=>[{key:Nu.Add,value:n._({id:"m16xKo",message:"Add"})},{key:Nu.Remove,value:n._({id:"t/YqKh",message:"Remove"})}]),[n._]);return i.useEffect((()=>{r(t)}),[t]),{operateTab:o,operateTabs:a,handleChangeTab:e=>{r(e)}}}(n);Zo();const{price:u,invertedPrice:p,poolInfoQuery:h,lpBalanceQuery:m,lpBalance:f,lpBalancePercentage:x,lpToAmountA:g,lpToAmountB:y,liquidityMinted:v,pairMintAAmount:b,pairMintBAmount:j,isExists:C}=rd({pool:(null==t?void 0:t.baseToken)&&t.quoteToken?{baseToken:t.baseToken,quoteToken:t.quoteToken,address:t.address}:void 0,baseAmount:void 0,quoteAmount:void 0,slippage:0});return G.jsxs(G.Fragment,{children:[G.jsx(qu,{pool:t,hidePoolInfo:r,children:G.jsx(kd,{isExists:C,poolInfo:null===(l=h.data)||void 0===l?void 0:l.poolInfo,poolInfoLoading:h.isLoading,lpBalanceLoading:m.isLoading,lpBalance:f,lpBalancePercentage:x,lpToAmountA:g,lpToAmountB:y,sx:{px:0,py:0,border:"none"}})}),G.jsxs(o.Tabs,{value:s,onChange:(e,t)=>{c(t)},children:[G.jsx(o.TabsButtonGroup,{tabs:d,variant:"inPaper",tabsListSx:{mt:16,mx:20}}),G.jsx(o.TabPanel,{value:Nu.Add,children:G.jsx(zu,{pool:t,submittedBack:a})}),G.jsx(o.TabPanel,{value:Nu.Remove,children:G.jsx(Xu,{pool:t,submittedBack:a})})]})]})}function _u({onClose:t,pool:n,operate:r,hasMining:a,hidePoolInfo:l,sx:s}){const{poolOrMiningTab:d,poolOrMiningTabs:c,handleChangeTab:u}=function({hasMining:t}){const{i18n:n}=e.useLingui(),[o,r]=i.useState(Zu.Liquidity);return{poolOrMiningTab:o,poolOrMiningTabs:i.useMemo((()=>{const e=[{key:Zu.Liquidity,value:n._({id:"6y2TB3",message:"Liquidity"})},{key:Zu.Mining,value:n._({id:"Sti4vy",message:"Mining"})}];return t?e:e.slice(0,1)}),[n._,t]),handleChangeTab:e=>{r(e)}}}({hasMining:a});return G.jsx(o.Box,{sx:s,children:G.jsxs(o.Tabs,{value:d,onChange:(e,t)=>{u(t)},sx:{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%"},children:[G.jsx(o.TabsGroup,{tabs:c,tabsListSx:Object.assign({mx:20,justifyContent:t?"space-between":"flex-start"},{}),rightSlot:G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:12},children:t?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(o.Box,{component:A.Error,sx:{width:16,height:16},onClick:()=>{t()}})}):void 0})}),G.jsx(o.TabPanel,{value:Zu.Liquidity,sx:{flex:1,overflowY:"auto"},children:G.jsx(Gu,{pool:n,operate:r,hidePoolInfo:l,submittedBack:()=>{a&&u(Zu.Mining)}})})]})})}function Ju(e){var{modal:t}=e,n=Oo(e,["modal"]);const{isMobile:o}=Ls();return G.jsx(ds,{open:!!n.pool,onClose:n.onClose,scope:!o,modal:t,id:"pool-operate",children:G.jsx(_u,{...n})})}!function(e){e[e.Liquidity=1]="Liquidity",e[e.Mining=2]="Mining"}(Zu||(Zu={})),function(e){e[e.Add=1]="Add",e[e.Remove=2]="Remove"}(Nu||(Nu={}));const Qu=e=>Object.keys(new Array(e+1).join(","));var Ku,$u,ep;function tp({sx:t,hasSearch:n,emptyText:i}){return G.jsxs(o.Box,{sx:Object.assign({display:"flex",flexDirection:"column",gap:12,justifyContent:"center",alignItems:"center",typography:"body2",fontWeight:500,color:"text.secondary",textAlign:"center"},t),children:[G.jsx(o.EmptyDataIcon,{hasSearch:n,sx:{width:60,height:60,borderRadius:12}}),G.jsx(o.Box,{children:null!=i?i:G.jsx(e.Trans,{id:"AxPAXW",message:"No results found"})})]})}function np(){return np=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},np.apply(null,arguments)}!function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success",e[e.Warning=2]="Warning"}(Ku||(Ku={}));const op=e=>O.createElement("svg",np({width:60,height:60,viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),O.createElement("g",{opacity:.5},O.createElement("mask",{id:"mask0_3521_179418",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:60,height:60},$u||($u=O.createElement("rect",{width:60,height:60,rx:16,fill:"white"}))),ep||(ep=O.createElement("g",{mask:"url(#mask0_3521_179418)"},O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 30.0352H60V16.0352C60 7.1986 52.8366 0.0351562 44 0.0351562H16C7.16344 0.0351562 0 7.1986 0 16.0352V30.0352Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{d:"M29.4643 4H16C9.37258 4 4 9.37258 4 16V27H27.1154L31.7914 18.7271L23.1831 13.6634L29.4643 4Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{d:"M31.7101 27H56V16C56 9.37258 50.6274 4 44 4H34.0384L34.1766 4.08987L28.8164 12.3364L37.2081 17.2727L31.7101 27Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 44C0 52.8366 7.16344 60 16 60H44C52.8366 60 60 52.8366 60 44V30H0V44Z",fill:"#ABABAB",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M59.4395 44.8861C59.4395 53.0965 52.7625 59.7526 44.5257 59.7526C36.2891 59.7526 29.6118 53.0965 29.6118 44.8861C29.6118 36.6756 36.2891 30.0195 44.5257 30.0195C52.7625 30.0195 59.4395 36.6756 59.4395 44.8861Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M29.8277 44.8665C29.8277 53.077 23.1507 59.7331 14.9139 59.7331C6.67727 59.7331 0 53.077 0 44.8665C0 36.6561 6.67727 30 14.9139 30C23.1507 30 29.8277 36.6561 29.8277 44.8665Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.9177 44.8883C51.9177 48.958 48.6082 52.257 44.5255 52.257C40.4431 52.257 37.1333 48.958 37.1333 44.8883C37.1333 40.8186 40.4431 37.5195 44.5255 37.5195C48.6082 37.5195 51.9177 40.8186 51.9177 44.8883Z",fill:"#444446"})))));function ip({sx:t,refresh:n}){return G.jsxs(o.Box,{sx:a.merge({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},t),children:[G.jsx(o.Box,{component:op,sx:{display:"inline-block",width:60,height:60,mb:12}}),G.jsx(o.Box,{sx:{typography:"body2",width:252,textAlign:"center"},children:G.jsx(o.Box,{component:"span",sx:{color:"text.secondary"},children:G.jsx(e.Trans,{id:"Vmw6BM",message:"Something went wrong…<0>Refresh again</0>",components:{0:G.jsx(o.HoverOpacity,{component:"span",color:"primary.main",weak:!0,sx:{cursor:"pointer"},onClick:()=>{n()}})}})})})]})}function rp({loading:e,empty:t,hasSearch:n,children:i,refetch:r}){return e?G.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",gap:24,px:24,height:320},children:Qu(4).map(((e,t)=>G.jsx(o.Skeleton,{width:"100%",height:45},t)))}):r?G.jsx(ip,{refresh:r,sx:{height:320}}):t?G.jsx(tp,{hasSearch:n,sx:{height:320}}):G.jsx(G.Fragment,{children:i})}function ap({children:e,sx:t,gap:n=20,repeatBaseForLargeScreen:i=3}){const{isMobile:r,minDevice:a}=Ls();let l={};if(r)l={display:"flex",flexDirection:"column",gap:n};else{let e=2;[1418,1761,2104].some(((t,n)=>{if(a(t))return e=i+n,!0})),l={display:"grid",gap:n,gridTemplateColumns:`repeat(${e}, 1fr)`}}return G.jsx(o.Box,{sx:Object.assign(Object.assign({},l),t),children:e})}function lp({address:t,chainId:i,hideName:r,sx:a}){const l=o.useTheme(),s=rr(),{onlyChainId:c}=Fo(),u=d.useQuery(Object.assign({},s.getQuery(n.SystemApi.graphql.fetchLiquidityLpPartnerRewards,{where:{chainId:c||void 0}})));if(!t)return null;const p=[];return("string"==typeof t?[t]:Array.from(new Set(t)).filter((e=>!!e))).forEach((e=>{var t,n,o;e&&(null===(o=null===(n=null===(t=u.data)||void 0===t?void 0:t.liquidity_getLpPartnerRewards)||void 0===n?void 0:n.partnerRewards)||void 0===o||o.some((t=>{var n,o,r,a,l,s,d,c,h,m,f,x,g,y;if((null==t?void 0:t.chainId)===i&&(null===(n=null==t?void 0:t.pool)||void 0===n?void 0:n.toLocaleLowerCase())===e.toLocaleLowerCase()){const e=null===(a=null===(r=null===(o=u.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;p.push({partner:{name:null!==(l=null==e?void 0:e.partner)&&void 0!==l?l:"",logo:null!==(s=null==e?void 0:e.logo)&&void 0!==s?s:"",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!==(h=null==e?void 0:e.extra)&&void 0!==h?h:{},background:(null===(m=null==e?void 0:e.theme)||void 0===m?void 0:m[0])||void 0,color:(null===(f=null==e?void 0:e.theme)||void 0===f?void 0:f[1])||void 0},reward:null!==(x=null==t?void 0:t.reward)&&void 0!==x?x:"",type:null!==(g=null==t?void 0:t.type)&&void 0!==g?g:"stakelp",sort:null!==(y=null==e?void 0:e.sort)&&void 0!==y?y:Number.MAX_SAFE_INTEGER})}})))})),(null==p?void 0:p.length)?(p.sort(((e,t)=>e.sort-t.sort)),G.jsx(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:p.map((t=>G.jsx(o.Tooltip,{leaveDelay:100,title:G.jsxs(o.Box,{sx:{maxWidth:240,whiteSpace:"pre-wrap"},children:[t.partner.introduction,!!t.partner.link&&G.jsxs(o.Box,{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:[G.jsx(e.Trans,{id:"zwWKhA",message:"Learn more"})," ",G.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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:G.jsxs(o.ButtonBase,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,p:l.spacing(0,4),height:20,borderRadius:4,background:t.partner.background,color:t.partner.color,whiteSpace:"nowrap"},children:[G.jsx(o.Box,{component:"img",src:t.partner.logo,alt:t.partner.name,sx:{width:14,height:14,borderRadius:"50%"}}),!r&&!!t.reward&&G.jsx(o.Box,{sx:{fontSize:"10px",fontWeight:600},children:t.reward})]})},t.partner.name+t.reward)))})):null}var sp,dp;function cp(){return cp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},cp.apply(null,arguments)}const up=e=>O.createElement("svg",cp({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),sp||(sp=O.createElement("circle",{cx:16,cy:16,r:16,fill:"#FFE804"})),dp||(dp=O.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"}))),pp="_default";function hp({value:e,onChange:t,placeholder:n,options:i,sx:r,readOnly:l,valueOnlyIcon:s}){const d=o.useTheme();return G.jsx(o.Select,{value:null!=e?e:pp,onChange:(n,o)=>{const i="number"==typeof e?Number(o):o;t(i===pp?void 0:i)},disabled:l,sx:a.merge({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:l?"text.disabled":"text.primary"},"& .MuiOutlinedInput-notchedOutline":{display:"none"}},r),renderValue:t=>{if(!(null==t?void 0:t.value)||t.value===pp)return G.jsx(o.Box,{sx:{color:"text.secondary"},children:null!=n?n:""});const r=i.find((t=>t.key===e));return r?G.jsxs(G.Fragment,{children:[r.logo,s?"":r.value]}):null},options:[...i]})}function mp({isMobileStyle:e,chain:t,isLastItem:n,logoWidth:i,mobileLogoWidth:r,sx:a}){const l=o.useTheme();return e?G.jsxs(o.Box,{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"},a),children:[G.jsx(o.Box,{component:null==t?void 0:t.logo,sx:{width:r,height:r}}),G.jsx(o.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]}):G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{component:null==t?void 0:t.logo,sx:{width:i,height:i}}),G.jsx(o.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]})}const fp=-1;function xp({chainId:t,setChainId:n,logoWidth:r=24,mobileLogoWidth:a=32,mainLogoWidth:l=24,mainMobileLogoWidth:s=18,notShowAllChain:d,valueOnlyIcon:c,sx:u}){const p=function(){const{chainId:e}=g.useWeb3React();return i.useMemo((()=>{const t=new Map;let n;return La.forEach(((o,i)=>{if(o.mainnet){if(e!==o.chainId)return;n=o.mainnet}t.set(i,Object.assign({},o))})),void 0!==n&&t.delete(n),Array.from(t.values())}),[e])}(),[h,m]=i.useState(!1),{isMobile:f}=Ls(),{i18n:x}=e.useLingui(),y=i.useCallback((()=>{const e=void 0===t?p[0]:p.find((e=>e.chainId===t));if(c){if(void 0===t||!e)return"";const n=f?a:l;return G.jsx(o.Box,{component:null==e?void 0:e.logo,sx:{width:n,height:n}})}return void 0!==t||d?e?G.jsx(mp,{isMobileStyle:f,chain:e,logoWidth:l,mobileLogoWidth:s}):null:G.jsx(mp,{isMobileStyle:f,chain:{chainId:fp,logo:up,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:l,mobileLogoWidth:s,sx:{border:"none"}})}),[t,p,d,c,f,x._]),v=i.useMemo((()=>{const e=[];return d||e.push({key:fp,value:G.jsx(mp,{isMobileStyle:f,chain:{chainId:fp,logo:up,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:r,mobileLogoWidth:a})}),p.forEach(((t,n)=>{e.push({key:t.chainId,value:G.jsx(mp,{isLastItem:n===p.length-1,isMobileStyle:f,chain:t,logoWidth:r,mobileLogoWidth:a})})})),e}),[f,r,a,p,d]);return f?G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,onClick:()=>m(!0),sx:Object.assign({display:"flex",alignItems:"center",backgroundColor:"background.tag",borderRadius:8,border:"none",px:8,height:32,fontWeight:600,typography:"body2"},u),children:[G.jsx(o.Box,{sx:{pr:5},children:y()}),G.jsx(o.Box,{component:A.CaretUp,sx:{width:12,height:12,transform:"rotate(180deg)"}})]}),G.jsx(ds,{open:h,title:G.jsx(e.Trans,{id:"lJvbHq",message:"Select Network"}),onClose:()=>m(!1),id:"select-chain",modal:!0,children:G.jsx(o.Box,{sx:{mb:20},children:v.map((e=>G.jsxs(o.Box,{onClick:()=>{const t=e.key;n(t===fp?void 0:Number(t)),m(!1)},sx:{position:"relative",px:20,"&:active":{backgroundColor:"hover.default"},"&:hover":{backgroundColor:"hover.default"},cursor:"pointer"},children:[e.value,(t?e.key===t:e.key===fp)&&G.jsx(o.Box,{sx:{position:"absolute",left:0,top:24,height:20,width:2,backgroundColor:"text.primary"}})]},e.key)))})})]}):G.jsx(hp,{value:null!=t?t:fp,onChange:e=>{n(e===fp?void 0:e)},placeholder:x._({id:"lJvbHq",message:"Select Network"}),options:v,valueOnlyIcon:c,sx:Object.assign({height:32,fontWeight:600,typography:"body2"},u)})}function gp({text:e,onClick:t}){const n=o.useTheme();return G.jsxs(o.Box,{sx:{typography:"body2",display:"inline-flex",alignItems:"center",p:n.spacing(0,4,0,8),width:"max-content",height:32,backgroundColor:"hover.default",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:t,children:[e,G.jsx(o.Box,{component:A.ArrowBack,sx:{ml:2,width:16,height:16,transform:"rotate(180deg)"}})]})}function yp({lqList:e,onDeleteTag:t,sx:n}){var i;if(!(null==e?void 0:e.length))return null;if(!(null===(i=e[0])||void 0===i?void 0:i.pair))return null;const{pair:r}=e[0],a=Wc(r.baseToken,r.chainId),l=Wc(r.quoteToken,r.chainId);return a&&l?G.jsxs(o.Box,{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:[G.jsx(gd,{tokens:[a,l],chainId:a.chainId,width:20,mr:8}),a.symbol,"+",l.symbol,G.jsx(o.Box,{component:A.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t()})]}):null}function vp({tags:e,onDeleteTag:t,sx:n}){return e.length?G.jsx(o.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center"},n),children:e.map((e=>G.jsxs(o.Box,{sx:{typography:"body2",display:"flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},children:[G.jsx(Wa,{address:e.address,width:20,height:20,chainId:e.chainId,url:e.logoURI,noShowChain:!0,marginRight:8}),e.symbol,G.jsx(o.Box,{component:A.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 bp({chainId:e,address:t}){const{isMobile:n}=Ls();return G.jsx(o.Box,{component:"button",onClick:n=>{n.stopPropagation(),Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:e,address:t}})},sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,cursor:"pointer",flexShrink:0,height:36,"&:hover":{opacity:.5}},n?{width:64,backgroundColor:"background.tag"}:{width:40,backgroundColor:"transparent",borderWidth:1}),children:G.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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:"#1A1A1B"})})})}function jp(t){var{sx:n,children:i,hasMore:r,loadMore:a,loadMoreLoading:l}=t,s=Oo(t,["sx","children","hasMore","loadMore","loadMoreLoading"]);const d=o.useTheme();return G.jsxs(o.Box,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto"},n),...s,children:[G.jsx(o.Box,{component:"table",sx:{width:"100%",borderCollapse:"collapse","& th":{p:24,typography:"body1",textAlign:"left",color:"text.secondary"},"& td":{px:24,py:20},"& thead":{position:"sticky",top:0,zIndex:2,backgroundColor:"background.paper"},"& th:last-child, & td:last-child":{position:"sticky",right:0,zIndex:1,backgroundColor:"background.paper","&::before":{content:'""',position:"absolute",top:0,bottom:0,left:1,width:"1px",boxShadow:`${o.alpha(d.palette.text.primary,.1)} -2px 0px 4px 0px`}}},children:i}),r&&G.jsx(o.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:d.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:a,children:l?G.jsx(o.RotatingIcon,{}):G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(o.Box,{component:A.ArrowRight,sx:{transform:"rotate(90deg)"}})]})})]})}function Cp({sx:t}){return G.jsxs(o.Box,{sx:Object.assign({px:20,pt:20,pb:12,backgroundColor:"background.paperContrast",borderRadius:16,display:"flex",flexDirection:"column"},t),children:[G.jsx(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Skeleton,{variant:"circular",width:48}),G.jsx(o.Skeleton,{variant:"rounded",height:28,width:100,sx:{ml:8}})]})}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mt:44},children:[G.jsxs(o.Box,{children:[G.jsx(o.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]}),G.jsx(o.Box,{sx:{display:"inline-block",mx:20,height:24,width:"1px",backgroundColor:"custom.border.default"}}),G.jsxs(o.Box,{children:[G.jsx(o.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]})]}),G.jsx(o.Skeleton,{variant:"rounded",height:32})]})}function wp({chainId:t,baseToken:n,quoteToken:i,apy:a,hasQuote:l,hasMining:s,sx:d,children:c}){if(!n)return null;const u=l?[{token:n,transactionApy:null==a?void 0:a.transactionBaseApy,miningApy:null==a?void 0:a.miningBaseApy},{token:i,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}];return G.jsx(o.Tooltip,{children:null!=c?c:G.jsx(o.HoverOpacity,{component:A.QuestionBorder,sx:Object.assign({width:15,height:15},d)}),title:G.jsx(o.Box,{sx:{width:236},children:u.map(((a,l)=>{var d,c,u,p;return G.jsxs(o.Box,{sx:{mt:0===l?0:20},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2",fontWeight:600,color:"text.primary"},children:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:a.token?G.jsxs(G.Fragment,{children:[G.jsx(Wa,{width:14,height:14,marginRight:4,address:a.token.address,url:a.token.logoURI,chainId:t,noShowChain:!0}),a.token.symbol]}):G.jsxs(G.Fragment,{children:[G.jsx(gd,{tokens:[n,i],width:14,mr:4,chainId:t}),n.symbol,"/",null==i?void 0:i.symbol]})}),G.jsx(o.Box,{children:ci(new r(null!==(u=a.transactionApy)&&void 0!==u?u:0).plus(null!==(p=a.miningApy)&&void 0!==p?p:0))})]}),G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"OnDEky",message:"LP Fee"})}),G.jsx("span",{children:a.transactionApy?ci(new r(a.transactionApy)):"-"})]}),s?G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"pSQ1lM",message:"MT Fee"})}),G.jsx("span",{children:a.miningApy?ci(new r(a.miningApy)):"-"})]}):""]},null!==(c=null===(d=a.token)||void 0===d?void 0:d.address)&&void 0!==c?c:1)}))})})}function kp({sx:n,value:r,onChange:a,searchAddress:l}){const[s,d]=i.useState(!1),{isMobile:c}=Ls();return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,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},c?{}:{minWidth:220}),n),onClick:()=>d(!0),children:[G.jsx(o.Box,{component:A.Search,sx:{width:16,height:16,mr:8,flexShrink:0}}),G.jsx(e.Trans,{id:"A1taO8",message:"Search"})]}),G.jsx(Ds,{value:r,open:s,multiple:!0,title:G.jsx(e.Trans,{id:"o8aMNm",message:"Select a liquidity pool"}),searchPlaceholder:t.i18n._({id:"4nzwq3",message:"Search by token or pool address"}),onClose:()=>{d(!1)},onTokenChange:e=>{if(Array.isArray(e)){if(e.length>2){const t=[e[0],e[2]];a(t)}else a(e);d(!1)}},searchOtherAddress:e=>l(e,(()=>d(!1))),modal:!0})]})}function Tp({list:t,onClick:i}){return G.jsx(G.Fragment,{children:null==t?void 0:t.map((t=>{var a,l,s,d;if(!(null==t?void 0:t.pair))return null;const c=t.pair,u=Wc(c.baseToken,c.chainId),p=Wc(c.quoteToken,c.chainId),h=c.apy?ci(new r(null===(a=c.apy)||void 0===a?void 0:a.transactionBaseApy).plus(null!==(s=null===(l=c.apy)||void 0===l?void 0:l.miningBaseApy)&&void 0!==s?s:0)):void 0,m=n.PoolApi.utils.singleSideLp(c.type)&&c.apy?ci(new r(c.apy.transactionQuoteApy).plus(null!==(d=c.apy.miningQuoteApy)&&void 0!==d?d:0)):void 0;return u&&p?G.jsxs(o.Box,{onClick:i,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(gd,{tokens:[u,p],chainId:c.chainId,width:24,mr:10}),G.jsxs(o.Box,{sx:{typography:"h5"},children:[u.symbol,"/",p.symbol]})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{color:"custom.status.green.default",fontWeight:600},children:[h,m?`/${m}`:""]}),G.jsx(o.Box,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]})]},c.id):null}))})}function Rp(){const[e,t]=i.useState([]),[n,o]=i.useState([]),[r,a]=i.useMemo((()=>{const[t,n]=e;return[null==t?void 0:t.symbol,null==n?void 0:n.symbol]}),[e]);return{filterTokens:e,filterASymbol:r,filterBSymbol:a,filterAddressLqList:n,handleDeleteToken:e=>{t((t=>{const n=[...t],o=n.indexOf(e);return-1!==o&&n.splice(o,1),n}))},handleChangeFilterTokens:e=>{o([]),t(e)},handleChangeFilterAddress:e=>{o(e),t([])}}}function Sp({lqList:t,setOperatePool:i,supportAMM:a}){const l=o.useTheme();return G.jsx(G.Fragment,{children:null==t?void 0:t.map((t=>{var s,d,c,u,p,h,m;if(!(null==t?void 0:t.pair))return null;const f=t.pair,x=Wc(f.baseToken,f.chainId),g=Wc(f.quoteToken,f.chainId),y=f.apy?ci(new r(null===(s=f.apy)||void 0===s?void 0:s.transactionBaseApy).plus(null!==(c=null===(d=f.apy)||void 0===d?void 0:d.miningBaseApy)&&void 0!==c?c:0)):void 0,v=n.PoolApi.utils.singleSideLp(f.type)&&f.apy?ci(new r(f.apy.transactionQuoteApy).plus(null!==(u=f.apy.miningQuoteApy)&&void 0!==u?u:0)):void 0,b=!!(null===(p=f.miningAddress)||void 0===p?void 0:p[0]),j=Fc(f.type);return G.jsx(o.Box,{sx:{p:8,borderRadius:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"border.disabled",backdropFilter:"blur(5px)"},children:G.jsxs(o.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:"border.main"},className:"gradient-card-border",onClick:()=>{a||Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:f.chainId,address:f.id}})},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[x&&g?G.jsx(gd,{tokens:[x,g],width:24,mr:6,chainId:f.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==x?void 0:x.symbol}/${null==g?void 0:g.symbol}`,G.jsx(lp,{address:f.id,chainId:f.chainId})]})]}),b?G.jsxs(o.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${o.alpha(l.palette.secondary.main,.3)} 0%, ${o.alpha(l.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(o.Box,{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:[a&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[j,G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:f.type,lpFeeRate:null!==(h=f.lpFeeRate)&&void 0!==h?h:0,mtFeeRate:null!==(m=f.mtFeeRate)&&void 0!==m?m:0})})})]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5",color:"success.main"},children:[y,v?`/${v}`:""]}),G.jsxs(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(wp,{chainId:f.chainId,apy:f.apy,baseToken:x,quoteToken:g,hasQuote:!!v,hasMining:b,sx:{width:14,height:14}})]})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5"},children:["$",si(new r(f.tvl))]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),a&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:["$",Qo({input:f.volume24H||0})]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"Q8W3SC",message:"Volume (1D)"})})]})]}),G.jsxs(o.Box,{sx:{mt:20,display:"flex",gap:"8px"},children:[G.jsx(bs,{fullWidth:!0,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),i({pool:Vc(t),hasMining:b})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})}),a&&"PMM"===j&&G.jsx(bp,{chainId:f.chainId,address:f.id})]})]})},f.id+f.chainId)}))})}function Ip({lqList:i,operatePool:a,setOperatePool:l,hasMore:s,loadMore:d,loadMoreLoading:c,supportAMM:u}){const p=o.useTheme();return G.jsxs(jp,{hasMore:s,loadMore:d,loadMoreLoading:c,children:[G.jsx(o.Box,{component:"thead",children:G.jsxs(o.Box,{component:"tr",children:[G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),u&&G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})}),G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})}),u&&G.jsx("th",{children:G.jsx(e.Trans,{id:"Q8W3SC",message:"Volume (1D)"})}),G.jsx(o.Box,{component:"th",sx:{width:80}})]})}),G.jsx(o.Box,{component:"tbody",children:null==i?void 0:i.map((i=>{var s,d,c,h,m,f,x,g;if(!(null==i?void 0:i.pair))return null;const y=i.pair,v=Wc(y.baseToken,y.chainId),b=Wc(y.quoteToken,y.chainId),j=y.apy?ci(new r(null===(s=y.apy)||void 0===s?void 0:s.transactionBaseApy).plus(null!==(c=null===(d=y.apy)||void 0===d?void 0:d.miningBaseApy)&&void 0!==c?c:0)):void 0,C=n.PoolApi.utils.singleSideLp(y.type)&&y.apy?ci(new r(y.apy.transactionQuoteApy).plus(null!==(h=y.apy.miningQuoteApy)&&void 0!==h?h:0)):void 0;let w="";if((null===(m=null==a?void 0:a.pool)||void 0===m?void 0:m.address)===y.id||(null==a?void 0:a.address)===y.id)if(a.operate===Nu.Remove)w=t.i18n._({id:"0+31GV",message:"Removing"});else w=t.i18n._({id:"1yHVE+",message:"Adding"});const k=!!(null===(f=y.miningAddress)||void 0===f?void 0:f[0]),T=Fc(y.type),R=p.palette.background.tag;return G.jsxs(o.Box,{component:"tr",sx:{["&:hover td"+(w?", & td":"")]:{backgroundImage:`linear-gradient(${R}, ${R})`}},children:[G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v&&b?G.jsx(gd,{tokens:[v,b],width:24,mr:10,chainId:y.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==v?void 0:v.symbol}/${null==b?void 0:b.symbol}`,G.jsx(lp,{address:y.id,chainId:y.chainId})]}),G.jsx(fd,{address:y.id,customChainId:y.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"},disabledAddress:u,onAddressClick:()=>{Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:y.chainId,address:y.id}})}})]})]})}),u&&G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:T}),G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:y.type,lpFeeRate:null!==(x=y.lpFeeRate)&&void 0!==x?x:0,mtFeeRate:null!==(g=y.mtFeeRate)&&void 0!==g?g:0})})})]})}),G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{typography:"body2"},title:y.tvl?`$${Qo({input:y.tvl})}`:void 0,children:["$",si(new r(y.tvl))]})}),G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[k?G.jsx(o.Tooltip,{title:t.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(wp,{chainId:y.chainId,apy:y.apy,baseToken:v,quoteToken:b,hasQuote:!!C,hasMining:k,children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[j,C?`/${C}`:""]})})]})}),u&&G.jsxs(o.Box,{component:"td",children:["$",Qo({input:y.volume24H||0})]}),G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[u&&"PMM"===T&&G.jsx(bp,{chainId:y.chainId,address:y.id}),w?G.jsx(gp,{text:w,onClick:()=>l(null)}):G.jsx(o.Button,{size:o.Button.Size.small,onClick:()=>{l({pool:Vc(i),hasMining:k})},children:t.i18n._({id:"m16xKo",message:"Add"})})]})})]},y.id+y.chainId)}))})]})}function Bp({scrollParentRef:e,filterChainIds:t,activeChainId:i,handleChangeActiveChainId:r,operatePool:l,setOperatePool:s}){var c;const{onlyChainId:u,supportAMMV2:p,supportAMMV3:h,notSupportPMM:m}=Fo(),{minDevice:f,isMobile:x}=Ls(),g=d.useQueryClient(),{filterTokens:y,filterASymbol:v,filterBSymbol:b,filterAddressLqList:j,handleDeleteToken:C,handleChangeFilterTokens:w,handleChangeFilterAddress:k}=Rp(),T=[];p&&T.push("SVM_AMMV2"),h&&T.push("SVM_AMMV3");const R={chainIds:t,pageSize:x?4:8,filterState:{viewOnlyOwn:!1,filterTypes:T}},S=rr(),I=S.getInfiniteQuery(n.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},R),{filterState:Object.assign({filterASymbol:v,filterBSymbol:b},R.filterState)})}),B=d.useInfiniteQuery(Object.assign(Object.assign({},I),{initialPageParam:1,getNextPageParam:e=>{var t;const{currentPage:n,totalCount:o,pageSize:i}=null!==(t=e.liquidity_list)&&void 0!==t?t:{};if(!n||!o||!i)return null;let r=Math.floor(o/i);return o%i&&(r+=1),n>=r?null:n+1}}));let M=[];const L=!!(null==j?void 0:j.length);L?M=[...j]:null===(c=B.data)||void 0===c||c.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==M||M.push(e)}))}));const O=B.hasNextPage&&!L;return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:Object.assign(Object.assign({py:16,display:"flex",gap:8},f(475)?{}:{flexDirection:"column"}),x?{}:{px:20,borderBottomWidth:1}),children:[G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:8},f(475)?{}:{"& > button":{flex:1}}),children:[!u&&G.jsx(xp,{chainId:i,setChainId:r}),G.jsx(kp,{value:y,onChange:w,searchAddress:(e,t)=>Wo(this,void 0,void 0,(function*(){var o;const i=S.getInfiniteQuery(n.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},R),{filterState:Object.assign({address:e},R.filterState)})}),r=null===(o=(yield g.fetchQuery(i)).liquidity_list)||void 0===o?void 0:o.lqList;return(null==r?void 0:r.length)?G.jsx(Tp,{list:r,onClick:()=>{k(r),t()}}):null}))})]}),(L||!!y.length)&&G.jsxs(o.Box,{sx:{my:0},children:[L?G.jsx(yp,{lqList:j,onDeleteTag:()=>k([])}):"",G.jsx(vp,{tags:y,onDeleteTag:C})]})]}),x?G.jsx(E,{hasMore:O,threshold:300,loadMore:a.debounce((()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>e.current||null,loader:G.jsx(Cp,{sx:{mt:20}},"loader"),children:G.jsxs(ap,{gap:12,children:[B.isLoading?G.jsx(Cp,{}):"",!B.isLoading&&!(null==M?void 0:M.length)&&!B.error&&G.jsx(tp,{sx:{mt:40},hasSearch:!!(i&&!u||v||b)}),!!B.error&&G.jsx(ip,{refresh:B.refetch,sx:{mt:40}}),G.jsx(Sp,{lqList:M,setOperatePool:s,supportAMM:p||h})]})}):G.jsxs(G.Fragment,{children:[G.jsx(Ip,{lqList:M,operatePool:l,setOperatePool:s,hasMore:O,loadMoreLoading:B.isFetchingNextPage,loadMore:()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()},supportAMM:p||h}),G.jsx(rp,{loading:B.isLoading,refetch:B.error?B.refetch:void 0,empty:!(null==M?void 0:M.length),hasSearch:!!(i&&!u||v||b)})]})]})}function Mp({onClick:e,title:t,desc:n}){const i=o.useTheme();return G.jsx(o.Box,{sx:{mx:20,px:0,py:14,borderTop:`1px solid ${i.palette.border.main}`,[i.breakpoints.up("tablet")]:{borderTop:"none",mx:0,px:16,py:8}},children:G.jsxs(o.ButtonBase,{onClick:e,sx:{width:"100%",display:"flex",flexDirection:"column",gap:0,p:0,borderRadius:8,"&:hover":{backgroundColor:i.palette.background.tag},[i.breakpoints.up("tablet")]:{p:8}},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:i.palette.text.primary,textAlign:"left"},children:t}),G.jsx(o.Box,{sx:{typography:"h6",fontWeight:500,color:i.palette.text.secondary,textAlign:"left"},children:n})]})})}const Ep=t=>{const n=o.useTheme(),{isMobile:r}=Ls(),{supportAMMV2:a,supportAMMV3:l,notSupportPMM:s}=Fo(),[d,c]=i.useState(!1),u={[exports.PageType.CreatePool]:!s,[exports.PageType.createPoolAMMV2]:!!a,[exports.PageType.createPoolAMMV3]:!!l},p=Object.entries(u).filter((([e,t])=>!0===t)),h=1===p.length?p[0][0]:void 0;if(!h){const t=G.jsxs(G.Fragment,{children:[!s&&G.jsx(Mp,{onClick:()=>{Gs.getState().push({type:exports.PageType.CreatePool})},title:G.jsx(e.Trans,{id:"Eif7f6",message:"PMM Pool"}),desc:G.jsx(e.Trans,{id:"ukTFO0",message:"Description of this type of pool"})}),a&&G.jsx(Mp,{onClick:()=>{Gs.getState().push({type:exports.PageType.createPoolAMMV2})},title:G.jsx(e.Trans,{id:"lNYomJ",message:"AMM V2 Position"}),desc:G.jsx(e.Trans,{id:"ukTFO0",message:"Description of this type of pool"})}),l&&G.jsx(Mp,{onClick:()=>{Gs.getState().push({type:exports.PageType.createPoolAMMV3})},title:G.jsx(e.Trans,{id:"sVlqoo",message:"AMM V3 Position"}),desc:G.jsx(e.Trans,{id:"ukTFO0",message:"Description of this type of pool"})})]});return r?G.jsxs(G.Fragment,{children:[G.jsxs(o.Button,{variant:o.Button.Variant.outlined,fullWidth:r,onClick:()=>{c(!0)},sx:{height:40},children:[G.jsx(o.Box,{component:A.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]}),G.jsx(ds,{open:d,title:G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"}),onClose:()=>{c(!1)},modal:!0,children:G.jsx(o.Box,{sx:{mb:0},children:t})})]}):G.jsx(o.Tooltip,{arrow:!1,leaveDelay:300,placement:r?"bottom":"bottom-end",sx:{p:0,backgroundColor:"background.paper"},title:G.jsx(o.Box,{children:t}),children:G.jsxs(o.Box,{sx:{width:r?"100%":"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:10,pl:8,pr:16,py:7,borderRadius:8,borderWidth:1,borderColor:n.palette.text.primary,typography:"body1",fontWeight:600,color:n.palette.text.primary,cursor:"pointer","&:hover":{backgroundColor:n.palette.background.tag}},children:[G.jsx(o.Box,{component:A.Plus}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})})}return G.jsxs(o.Button,{variant:o.Button.Variant.outlined,fullWidth:r,onClick:()=>{Gs.getState().push({type:h})},sx:{height:40},children:[G.jsx(o.Box,{component:A.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})};const Lp=({onlyV3:e,setOnlyV3:n,sx:i})=>{const r=o.useTheme(),{notSupportPMM:a}=Fo();return G.jsx(o.Box,{component:o.ButtonBase,onClick:()=>n(!e),sx:Object.assign({display:"flex",alignItems:"center",p:2,borderRadius:8,backgroundColor:r.palette.border.main},i),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",width:"100%",[r.breakpoints.up("tablet")]:{width:194}},children:[G.jsx(o.Box,{sx:Object.assign({flex:1,width:0,pt:4,pb:5,borderRadius:6,textAlign:"center",typography:"body2",whiteSpace:"nowrap"},e?{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}:{color:r.palette.text.secondary,backgroundColor:"transparent"}),children:t.i18n._({id:"yoR+O6",message:"V3"})}),G.jsx(o.Box,{sx:Object.assign({flex:1,width:0,pt:4,pb:5,borderRadius:6,textAlign:"center",typography:"body2",whiteSpace:"nowrap"},e?{color:r.palette.text.secondary,backgroundColor:"transparent"}:{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}),children:a?"V2":t.i18n._({id:"eK6I8d",message:"V2 & PMM"})})]})})};function Op({account:t,lqList:i,setOperatePool:a,supportAMM:l}){const s=o.useTheme();return G.jsx(G.Fragment,{children:null==i?void 0:i.map((i=>{var d,c,u,p,h,m,f,x,g,y,v,b,j,C;if(!(null==i?void 0:i.pair))return null;const w=i.pair,k=Wc(w.baseToken,w.chainId),T=Wc(w.quoteToken,w.chainId),R=n.PoolApi.utils.singleSideLp(w.type),S=w.apy?ci(new r(null===(d=w.apy)||void 0===d?void 0:d.transactionBaseApy).plus(null!==(u=null===(c=w.apy)||void 0===c?void 0:c.miningBaseApy)&&void 0!==u?u:0)):"0%",I=R&&w.apy?ci(new r(w.apy.transactionQuoteApy).plus(null!==(p=w.apy.miningQuoteApy)&&void 0!==p?p:0)):void 0;let B,M;(null===(h=i.liquidityPositions)||void 0===h?void 0:h.length)&&i.liquidityPositions.forEach((e=>{var t,n,o,i,a;if(null==e?void 0:e.liquidityTokenBalance){const l=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==l?void 0:l.length)){const t=l[1].toLocaleLowerCase();if((null===(o=null===(n=null==w?void 0:w.baseLpToken)||void 0===n?void 0:n.id)||void 0===o?void 0:o.toLocaleLowerCase())===t)return void(B=new r(e.liquidityTokenBalance));(null===(a=null===(i=null==w?void 0:w.quoteLpToken)||void 0===i?void 0:i.id)||void 0===a?void 0:a.toLocaleLowerCase())===t&&(M=new r(e.liquidityTokenBalance))}}}));const E=!!(null===(m=w.miningAddress)||void 0===m?void 0:m[0]),L=null===(f=i.liquidityPositions)||void 0===f?void 0:f[0],O=w.type,W=Fc(O),V="SVM_AMMV2"===O,A="SVM_AMMV3"===O;return G.jsx(o.Box,{sx:{p:8,borderRadius:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"border.disabled",backdropFilter:"blur(5px)"},children:G.jsxs(o.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:"border.main"},className:"gradient-card-border",onClick:()=>{l||Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:w.chainId,address:w.id}})},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[k&&T?G.jsx(gd,{tokens:[k,T],width:24,mr:6,chainId:w.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==k?void 0:k.symbol}/${null==T?void 0:T.symbol}`,G.jsx(lp,{address:w.id,chainId:w.chainId})]})]}),E?G.jsxs(o.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${o.alpha(s.palette.secondary.main,.3)} 0%, ${o.alpha(s.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(o.Box,{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:[l&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[W,G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:w.type,lpFeeRate:null!==(x=w.lpFeeRate)&&void 0!==x?x:0,mtFeeRate:null!==(g=w.mtFeeRate)&&void 0!==g?g:0})})})]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),A?null:G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5",color:"success.main"},children:[S,I?`/${I}`:""]}),G.jsxs(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(wp,{chainId:w.chainId,apy:w.apy,baseToken:k,quoteToken:T,hasQuote:!!I,hasMining:E,sx:{width:14,height:14}})]})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5"},children:["$",si(new r(w.tvl||0))]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]})]}),V&&G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{typography:"h5"},children:di({input:null===(v=null===(y=i.liquidityPositions)||void 0===y?void 0:y[0])||void 0===v?void 0:v.poolShare})}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"h3PbRN",message:"My Pool Share"})})]}),G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{typography:"h5",display:"flex",alignItems:"center",fontWeight:"bold"},children:A?(null==L?void 0:L.liquidityUSD)?`$${Ko({input:L.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[R?G.jsx(Wa,{address:null==k?void 0:k.address,chainId:w.chainId,url:null==k?void 0:k.logoURI,width:18,height:18,sx:{mr:4}}):G.jsx(gd,{tokens:k&&T?[k,T]:[],width:18,mr:4,showChainLogo:!1,chainId:w.chainId}),B?Qo({input:B}):"",R&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Wa,{address:null==T?void 0:T.address,chainId:w.chainId,url:null==T?void 0:T.logoURI,width:18,height:18,sx:{mx:4}}),M?Qo({input:M}):"0"]})]})}),G.jsx(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})})]}),A&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Au,{outOfRange:null!==(b=null==L?void 0:L.outOfRange)&&void 0!==b&&b}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(j=null==L?void 0:L.priceRange)||void 0===j?void 0:j.token0LowerPrice,atLimit:{},direction:Ud.LOWER})," "]}),null==k?void 0:k.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.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"})}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(C=null==L?void 0:L.priceRange)||void 0===C?void 0:C.token1LowerPrice,atLimit:{},direction:Ud.UPPER})," "]}),null==k?void 0:k.symbol]})})]}),G.jsx(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})})]})]}),G.jsxs(o.Box,{sx:{mt:20,display:"flex",gap:"8px"},children:[A?null:!!t&&G.jsx(bs,{fullWidth:!0,variant:o.Button.Variant.outlined,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),a({operate:Nu.Remove,pool:Ac(i),hasMining:E})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(bs,{fullWidth:!0,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),a({operate:Nu.Add,pool:Ac(i),hasMining:E})},children:G.jsx(e.Trans,{id:"J/hVSQ",message:"{0}",values:{0:A?"Manage":"Add"}})}),l&&"PMM"===W&&G.jsx(bp,{chainId:w.chainId,address:w.id})]})]})},A?null==L?void 0:L.id:w.id+w.chainId)}))})}function Wp({account:i,lqList:a,operatePool:l,setOperatePool:s,supportAMM:d,onlyV3:c}){const u=o.useTheme();return G.jsxs(jp,{children:[G.jsx(o.Box,{component:"thead",children:G.jsxs(o.Box,{component:"tr",children:[G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),d&&G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),c?null:G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})}),c?null:G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})}),G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),c?G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})}):null,G.jsx(o.Box,{component:"th",sx:{width:210}})]})}),G.jsx(o.Box,{component:"tbody",children:null==a?void 0:a.map((a=>{var p,h,m,f,x,g,y,v,b,j,C,w,k,T,R,S,I,B;if(!(null==a?void 0:a.pair))return null;const M=a.pair,E=Wc(M.baseToken,M.chainId),L=Wc(M.quoteToken,M.chainId),O=n.PoolApi.utils.singleSideLp(M.type),W=M.apy?ci(new r(null===(p=M.apy)||void 0===p?void 0:p.transactionBaseApy).plus(null!==(m=null===(h=M.apy)||void 0===h?void 0:h.miningBaseApy)&&void 0!==m?m:0)):void 0,V=O&&M.apy?ci(new r(M.apy.transactionQuoteApy).plus(null!==(f=M.apy.miningQuoteApy)&&void 0!==f?f:0)):void 0;let A,F;(null===(x=a.liquidityPositions)||void 0===x?void 0:x.length)&&a.liquidityPositions.forEach((e=>{var t,n,o,i,a;if(null==e?void 0:e.liquidityTokenBalance){const l=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==l?void 0:l.length)){const t=l[1].toLocaleLowerCase();if((null===(o=null===(n=null==M?void 0:M.baseLpToken)||void 0===n?void 0:n.id)||void 0===o?void 0:o.toLocaleLowerCase())===t)return void(A=new r(e.liquidityTokenBalance));(null===(a=null===(i=null==M?void 0:M.quoteLpToken)||void 0===i?void 0:i.id)||void 0===a?void 0:a.toLocaleLowerCase())===t&&(F=new r(e.liquidityTokenBalance))}}}));const P=null===(g=a.liquidityPositions)||void 0===g?void 0:g[0],Z=M.type,N=Fc(Z),U="SVM_AMMV2"===Z,H="SVM_AMMV3"===Z;let D="";if(H)(null===(b=null===(v=null===(y=null==l?void 0:l.pool)||void 0===y?void 0:y.liquidityPositions)||void 0===v?void 0:v[0])||void 0===b?void 0:b.id)===(null==P?void 0:P.id)&&(D=t.i18n._({id:"p3607o",message:"Managing"}));else if((null===(j=null==l?void 0:l.pool)||void 0===j?void 0:j.address)===M.id||(null==l?void 0:l.address)===M.id)if(l.operate===Nu.Remove)D=t.i18n._({id:"0+31GV",message:"Removing"});else D=t.i18n._({id:"1yHVE+",message:"Adding"});const Y=!!(null===(C=M.miningAddress)||void 0===C?void 0:C[0]),z=u.palette.background.tag;return G.jsxs(o.Box,{component:"tr",sx:{["&:hover td"+(D?", & td":"")]:{backgroundImage:`linear-gradient(${z}, ${z})`}},children:[G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E&&L?G.jsx(gd,{tokens:[E,L],width:24,mr:10,chainId:M.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==E?void 0:E.symbol}/${null==L?void 0:L.symbol}`,G.jsx(lp,{address:M.id,chainId:M.chainId})]}),G.jsx(fd,{address:M.id,customChainId:M.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,disabledAddress:d,onAddressClick:()=>{Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:M.chainId,address:M.id}})},sx:{typography:"h6",color:"text.secondary"}})]})]})}),d&&G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:N}),G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:M.type,lpFeeRate:null!==(w=M.lpFeeRate)&&void 0!==w?w:0,mtFeeRate:null!==(k=M.mtFeeRate)&&void 0!==k?k:0})})})]})}),H?null:G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{typography:"body2"},title:M.tvl?`$${Qo({input:M.tvl||0})}`:void 0,children:["$",si(new r(M.tvl||0))]})}),H?null:G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[Y?G.jsx(o.Tooltip,{title:t.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(wp,{chainId:M.chainId,apy:M.apy,baseToken:E,quoteToken:L,hasQuote:!!V,hasMining:Y,children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[W||"0%",V?`/${V}`:""]})})]})}),G.jsx(o.Box,{component:"td",children:G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:H?(null==P?void 0:P.liquidityUSD)?`$${Ko({input:P.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[O?G.jsx(Wa,{address:null==E?void 0:E.address,chainId:M.chainId,url:null==E?void 0:E.logoURI,width:24,height:24,noShowChain:!0,sx:{mr:4}}):G.jsx(gd,{tokens:E&&L?[E,L]:[],width:24,mr:4,showChainLogo:!1,chainId:M.chainId}),A?Qo({input:A}):"-",O&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Wa,{address:null==L?void 0:L.address,chainId:M.chainId,url:null==L?void 0:L.logoURI,width:24,height:24,noShowChain:!0,sx:{mx:4}}),F?Qo({input:F}):"0"]}),U&&G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"NXZdrO",message:"My pool share"}),children:G.jsx(o.Box,{sx:{ml:4,px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:di({input:null===(R=null===(T=a.liquidityPositions)||void 0===T?void 0:T[0])||void 0===R?void 0:R.poolShare})})})]})})}),c?G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Au,{outOfRange:null!==(S=null==P?void 0:P.outOfRange)&&void 0!==S&&S}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(I=null==P?void 0:P.priceRange)||void 0===I?void 0:I.token0LowerPrice,atLimit:{},direction:Ud.LOWER})," "]}),null==E?void 0:E.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.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"})}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(B=null==P?void 0:P.priceRange)||void 0===B?void 0:B.token0UpperPrice,atLimit:{},direction:Ud.UPPER})," "]}),null==E?void 0:E.symbol]})})]})}):null,G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[d&&"PMM"===N&&G.jsx(bp,{chainId:M.chainId,address:M.id}),D?G.jsx(gp,{text:D,onClick:()=>s(null)}):G.jsxs(G.Fragment,{children:[H?null:!!i&&G.jsx(bs,{variant:o.Button.Variant.outlined,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),s({operate:Nu.Remove,pool:Ac(a),hasMining:Y})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(bs,{size:o.Button.Size.small,onClick:()=>{s({pool:Ac(a),hasMining:Y})},children:H?t.i18n._({id:"wckWOP",message:"Manage"}):t.i18n._({id:"m16xKo",message:"Add"})})]})]})})]},H?null==P?void 0:P.id:M.id+M.chainId)}))})]})}function Vp({account:e,filterChainIds:t,activeChainId:r,handleChangeActiveChainId:a,operatePool:l,setOperatePool:s}){var c,u,p,h,m,f,x;o.useTheme();const{minDevice:g,isMobile:y}=Ls(),v=d.useQueryClient(),{onlyChainId:b,supportAMMV2:j,supportAMMV3:C,notSupportPMM:w}=Fo(),[k,T]=i.useState(!1),{filterTokens:R,filterASymbol:S,filterBSymbol:I,filterAddressLqList:B,handleDeleteToken:M,handleChangeFilterTokens:E,handleChangeFilterAddress:L}=Rp();let O=[];j&&O.push("SVM_AMMV2"),C&&k&&(O=["SVM_AMMV3"]);const W={currentPage:1,pageSize:1e3,user:e,filterState:{viewOnlyOwn:!0,filterTypes:O}},V=rr(),A=V.getQuery(n.PoolApi.graphql.fetchMyLiquidityList,{where:Object.assign(Object.assign({},W),{filterState:Object.assign({filterASymbol:S,filterBSymbol:I},W.filterState)})}),F=d.useQuery(Object.assign({},A));let P=null!==(p=null===(u=null===(c=F.data)||void 0===c?void 0:c.liquidity_list)||void 0===u?void 0:u.lqList)&&void 0!==p?p:[];const Z=!!(null==B?void 0:B.length);Z?P=[...B]:t&&(P=null!==(x=null===(f=null===(m=null===(h=F.data)||void 0===h?void 0:h.liquidity_list)||void 0===m?void 0:m.lqList)||void 0===f?void 0:f.filter((e=>{var n,o;return t.includes(null!==(o=null===(n=null==e?void 0:e.pair)||void 0===n?void 0:n.chainId)&&void 0!==o?o:0)})))&&void 0!==x?x:[]);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:Object.assign(Object.assign({py:16,display:"flex",gap:8},g(475)?{}:{flexDirection:"column"}),y?{}:{px:20,borderBottomWidth:1}),children:[G.jsxs(o.Box,{sx:Object.assign(Object.assign({display:"flex",alignItems:"center",gap:8},g(475)?{}:{"& > button":{flex:1,flexBasis:"100%"}}),y?{flexWrap:"wrap"}:{}),children:[!b&&G.jsx(xp,{chainId:r,setChainId:a}),C&&G.jsx(Lp,{onlyV3:k,setOnlyV3:T,sx:y?{flexGrow:1,flexBasis:"100%"}:void 0}),G.jsx(kp,{value:R,onChange:E,searchAddress:(e,t)=>Wo(this,void 0,void 0,(function*(){var o;const i=V.getInfiniteQuery(n.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},W),{filterState:Object.assign({address:e},W.filterState)})}),r=null===(o=(yield v.fetchQuery(i)).liquidity_list)||void 0===o?void 0:o.lqList;return(null==r?void 0:r.length)?G.jsx(Tp,{list:r,onClick:()=>{L(r),t()}}):null}))})]}),(Z||!!R.length)&&G.jsxs(o.Box,{sx:{my:0},children:[Z?G.jsx(yp,{lqList:B,onDeleteTag:()=>L([])}):"",G.jsx(vp,{tags:R,onDeleteTag:M})]})]}),y?G.jsxs(ap,{gap:12,children:[F.isLoading?G.jsx(Cp,{}):"",!F.isLoading&&!(null==P?void 0:P.length)&&!F.error&&G.jsx(tp,{sx:{mt:40},hasSearch:!!(r&&!b||S||I)}),!!F.error&&G.jsx(ip,{refresh:F.refetch,sx:{mt:40}}),G.jsx(Op,{account:e,lqList:P,setOperatePool:s,supportAMM:j||C})]}):G.jsxs(G.Fragment,{children:[G.jsx(Wp,{account:e,lqList:P,operatePool:l,setOperatePool:s,supportAMM:j||C,onlyV3:k}),G.jsx(rp,{loading:F.isLoading,refetch:F.error?F.refetch:void 0,empty:!(null==P?void 0:P.length),hasSearch:!!(r&&!b||S||I)})]})]})}var Ap,Fp;function Pp(){return Pp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Pp.apply(null,arguments)}const Zp=e=>O.createElement("svg",Pp({width:66,height:64,viewBox:"0 0 66 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Ap||(Ap=O.createElement("rect",{width:64,height:60.1342,fill:"url(#pattern0)"})),Fp||(Fp=O.createElement("defs",null,O.createElement("pattern",{id:"pattern0",patternContentUnits:"objectBoundingBox",width:1,height:1},O.createElement("use",{xlinkHref:"#image0_2465_53170",transform:"matrix(0.00671141 0 0 0.00714286 -0.503356 -0.9)"})),O.createElement("image",{id:"image0_2465_53170",width:300,height:300,xlinkHref:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAADWuSURBVHgB7Z0JeFRVtu9XhYQwJRQzhulE5gYliPNEofc16rtXQvu10O1rCfdrW/F9V+Daer3dtyXwerDt9gLv2TYOLYFuVOhWwBm7NYUDICIEARkCphCCMicECAkk9fZ/n9qVk0pVxqqkEv6/79uc+dSpJOfPWmuvvbYIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGkrdJOCCFO5qs2UrUNQgghcc7JQCOEkLgmQzV/oHmExB0JQggxePCP2+0OrpP4goJFSBXjMzIyBE0xSUjcQcEipAoPxCozMxPrUC23EEJIHAKV8q9cudJfUFBg4ljZQgghcYalWoFlWX7DrFmzjGjNEkIIiQM8qi1Q7STECpaV4eTJk37lHhrRyhXb2vIIIYQ0E4hJzVRtpdi5Vn7VI+hXMatqYuVk8eLFfo/HY4QrVMAsIYSQGODMsfLDosrJydGWVH1AbCuMcM0UQgiJEVnisK7Q4PZlZWVFtLCys7O1FSY1rSuPkGbHJYQ0HktsN8sszb66gGAUq1bkaL7AsrmAxTVebOHJVBaX5ObmCpaGsWPHSl5eHla9qi1RbVUzPyMhpAFAhPBiZ4kdnF6s2hZxWCh1tQEp4k9Nrt+5gVYgthWDz4LL5Qk8QyyxJNBLaFxERy9hlpC4gRYWcWKJLRCwPDLEIRRKdKRre5Hv9BQZmCLSP1Vtq31KkILHsI31+nDgVGBZUrXEPrM8WFJ1LAAsG5g7a8W2ePIkutaOR7XcBQsWyLRp06Rbt27Yl6PadCFxQ6KQix2P2EmTGIpiYQdE57o0kev72eI0SonUgFSJKuZ+td33VJnI9mO2cO04Km617ll/SD/vnMApXrFFBSLmk6bhRVu1apVnzJgxZt8SIXEFBevixCO2SE1Tze0UqNvToy9OjQXPhWfSjKjav65Q5N2v9NKz43gw+O0VW7xWS+Mtr7Ver9fjiGN5hcQVdAkvLjxiWyceiMFtSpymKCEY3bP+rly8Aevri3YiT3+gfMT9epdPbKGZKw23ujxix88kcI8JQuIKCtbFgSV2EFsL1X2Xi/xkTOsVqVBcyk/ocZntPi54W/lxH+rdsLLQUTBXGgY6FNyB67KFxBUUrLYPetqyUxLF/ci1SqzGSJvEiFZiZ2VWHVVf+G9B4fKJbSn56nmrHLFdZVzjFRJXULDaNnD/sm/pI/LfN4v06S2tAlhKO45V9SQa4LqidxLLcLRTFmPPsbZ4gRwVip/7qhYwn9qcLHbPYl14xK7rPlZI3EHBartosXpwqAhatwEiCXHcxYJY1PNKTpbvtnsHawOpFAjGP3xVzQ6ClEtFOqdVbcPamvB/gqLVEEuLxCEUrLaJpVrBpP4iv1LxqqQOKl51icQtsKjuWiVSJsnyne98R/r37y+9evWS1NTqanT06FE5deqU7Nu3T7788kstXC/eUd3iat9VpPtl1e8P0Rr7mApqnWUgvbXDab7aJlmq3fZ/xymhShJJ7qJEq6PELTPeEzlSkSpTp06V4cOHS/fu3SU5uWaPQOfOnfWxwYMHa2HbkPelfFNSIZlDQ87rV33breJaZedVQGqnFvKFqp0T0iphieS2SUaaEqh+AZGKZ1cQpLZXglJWplt9gaUFUUOGvZN2HcKfn2FVrQpptTBx9CKg8oLENfNuUi7hyjJZtmyZdgdNgyA5LS24hGgHDx7UDS4h4lhOknsIacNQsNooh0pFPjsucpV6gS/EuQME4dl4rwq471Jt50FZv+FgrecjK/++G0WmjqiZS9ahe/hrVm4S0gagYLVhfv6FyOJrlGuo1iuUldUuzn/byLqfEhiCg0A8egvNAGi4fkhpGJgSOeG1y8DwLuHCd0SWrBXSBqBgtVFSVLC9RAWap39qi1bS0fjuKQwlUq5VJJCDBcEKBWI1a6ltxYVUfyCtEAbd2ygp6r+ixdfa6xCtv+4VKT0pbRKIVWgqQ9FZkdlLbbG67VIVJ7tRSBuAgtWGGZFqixZ6C/9LuYc3rhT5cJ+0KYxYGVcQQoXs9vR/E3nxA1uoFt/edsZNXuzQJWzjQKwgWqtUHPuZfBUjetd2jx6+2i4l05pfZKdYoVLD6k324GeIFgLzC2+Nn1I5JDpQsC4SMvvbDcL1lwLlKr0v8niyLVooM4OhLq1JvJDRXqTiXM+8JeL90m6pge9z9whHHS3SpqBgXWQY4dp1SuTPPpGP9tvpBAAvuSnkF481sjAYet0hkQ2H7YYhNwDPPDdCmgNpW1CwLlIQ38I4Q4B8rc9O2MunPrMbMNURRvWoWq8trSBaQJiKy+2KDTuUKO04XpXmAEzxwVmXt363ljQMChbRyaVoEhiTB+GCBQYRgxWDcsROIBBGuPQkFO3tdT0ZRUA8uravLiQQG4iQobjM3ncwzCQUTtDbCXG98xKRy/qITBjGuNTFDAWLiBvxKyUGJcrNOlukxEtsAftRetU5ELBDKphdWGo3ZNKXqPbRCTvfq6SRw3+M4PVRf4njlBD9S18RjIOESKWqfWmdqs7FIO4uFKuLGgoWkfOBoTu9Bldtl50WKS0WOaeWZWdsARlRD7GAqIUjUYlQF0cyaKiVdLxACKkTChaRM8fthrpZHVXvWxdlXSWq9V4OgcEA6vJz9vLUYbuBzj2qD64e3LVq/XxZ1ThGXZOridZRvFedILGHfwIkCCwrNCNGEIjkziIdutgClpRsL+GayWH7WL9Rtd9zz4dCSNSgYJGIwHKCW4gWDriKX220hSzS9YREEwpW2yRPBcWnFap4Ur9OElPg8jVX+ZqmuIQm10zqNxEFiVM4lrBtkqNaEcYPEjtVYoUtWDnS+FmhSRzAmu5tE9g8h5WVlQkr69a+0uKgFldySuTjpfWQEcTS2rWXBoGE03veUHG5cj1bznShYLVqKFhtF7g+rt0l4sH4QcxNiAkpWoqoCFZqw4oQPv+FPWbyqJ1qMUs1lvFr5VCw2jZe1faXXJDMv/jsHUjKbAnhioZg4fr6CNa6QqVOH4gs3a46Bir0Lp/Y1hVp5VCwWh7M4vKtxA5YWh7VLAy1+eCwnbWuM8mbUbiiYmF1VUHXWv5ijVBhLGRpck8ZOHCgHDt2DIdgXW0V0uqhYLUslmo7VUPiwAaJHftVyxo6dKi0T+0h63wnBBYXxgwCjNeLtXhFQ7A6KcFyhfzFQqSeV1L0wN9F/rzDFqqJEyfKfffdJ2+99ZacPXvWJ7Su2gxMa2hZzBx5k1RbILHDi7Z//37PlClT5IorrpBvvvlGtm/fLv/1xQl9wlXdA4Og1XJ4asvGuyLSrqrEzHolVO8U2AOoO3XqJAPTB8r/njxZRoywZ7H46KOPjHWVLaTNwKnqW5Yc1aaJ3XOVLrHtwbJUKxg7dqwWLMPp06dFCZn4fD759tsqzxSiBfHqFxiI3FQR00NzapkEI9xYQoxL3FliL+HO5p+tqubQoUMH/T0wA/S4ceO0aDl5+OGHIVg+sX+upI1AwWpZtliWlQGxUEwQ2xKKJQvat28/E1aWWtY4WF5eLsePH9fWF9rJkyerzcZsSr1gRh4TvHfOMI39qQ6b3Vlp4Swy/rpVbaPUjHMarz1f28J06kKgMkRp9Wfr27dvsMGKSktLkz59+kg4YF298MILWG2OnylpRihYLYelWsGCBQskOztbioqKFoodHI4lbnymimW5b7755npdYETsxIkTUlJSohussjNnzjRoavl6PZzbXaNBoLCEReVkwIABkpgYPqIRsK5WqdXJQtoUjGG1HB78M378eN1Wr14N1zDWggWXc2F+fv4cuIYpKeGj4AkJCXqKeAgSLLFLLrlEt3BAwCBqaEAFucXlcul7tGvXTi8hLFiiGSBCZgkxChWk2ujSpUtEsVq1apWJXc0W0uaghdVyFCh30CooKBCv1ysTJsB70S9ZLIPvQFtZSoDcd9xxR42DEBlYNUZcKisr5cKFC+L3+2uci2NGlEAkEakvuJ9T1CIRybqCUP3mN7/BMkfYM9gmYVpD8wPB+KNqHriDGRkZonRL1q5di8D3bYFzkDMUqyHFuG9H5dZ5YDWFWlkdO3aUzp07B7dhLUGUIBDOBgErLS3VYgahwXZFRYVeN9tm3TRzPwDrzVhm586d0w37cF1SUuToPqyrSJbhsmXLZNcuPWgQriCH4LRBKFjNA0TqftWeCLRr58+fLw888EDwhMzMTN1Lt3XrVo/afExsl3Gs2AJTJNEVMCSTPqBEqwNys5xAMCIJghNjWaHhGggX2vnz53UzYuRsOA5XE0CcIHDmXhBBuJ9oRtTCgUB7OCsM1lUg0J6j2hKJLeb3iV8gfkc+oUA2C3QJY4cldkxqvATyrWBJTZo0SWbNmqXXw4EewyVLlmg3Ec0BNqJpOeDZ5sMtDI1P9e/fv1bRqA1jXYVzIUPjWA0Fca5IsbTnn39ePv74Y6wijcEnDQciNFPs3xsSeRdEuA+O5ypLz7rhhht0B8Qnn3yC/dmqzRUSUxh0jx2ZYr8AGo/HI1lZWTrAHkmsAILQgwYN0udgXfUeVjss0ROsHNXmbNmyxR0qAgicO93ChtAUQaoLuIPhgHUVECsIhk8ajqVa7pgxYyzVZN++fRAhdIJMDnO/3IkTJ1oPPvhg8HmQAjJjxoxsdEBITesuW+zEYPzuvGLH1nxCGgUtrNiSEWiTAksLOyFeixcvriFcCxcuNCkO2MQ/6JpfG1g2Vag8Yovo+MBzuJ0HTW8gxHLYsGHayoo3IgXbEbt677338PMx7llDyRk8ePC05557LrjjmWeekVdffbXGieiQwOc5gUjv3r27motvGDJkiBhxw/3WrFnjCzwnXchGQAsrtuQFWk5gWwuYcvWQVmDl5ubqoDuYO3euFiux/xeeK9FLeJyjWpZqVkoXtwwfnKHaGL00lJwult37tqi2VT788EPd8FwQVpN+0NKY9IhwwCIUWwB80jgGYfyhk+9+97taYF566aXgvl/84hfSp29/Wbdhk1x/7ZXB/XCDA728Mm/ePC1Se/fulccff1z/XiFy4NFHH0Wc0lJxyiyJfW9wm4SC1bwYAfMqKyp39uzZWrQQtwqIVTSTHT2qLVbNunKMRx64d44WKYhWbRz61ifLXlsguetWi+nFjAfhiqWrqShCLMpJQYFPevW+RIqK7f1nS8+Ju0eanC69oHtHIwFLCh0DcBNNZn7ocQmxbkn9oWC1DD7VpitLKxeB9cDQHBCtZMf5qs1K62vJvEcWCwSrvuCaRx5cIPd8b5a8/l6OLFo6Vz/f1KlTa7x8zUmMBWvha6+9lonvh0A6rKOVq9+UTind5be/X6hPSEpKluuUVXX3XZOkUyc7yfXgwUKdBtKjR/dgJ4Ny+SQvL08H4wO9voK4GMA24mMKzsLYSBjDajl0AqfqMXQjeXT16tWwvMZK08A9V6rmued7M5VVlV3Dojp02Ceb8rxquT+4L6WzchWHjAlrgcHi+vFPJ+glUi+MC9vc1KOH0CdNG+iMXlPTS6iB0MAiQi/gLbf+D/n5zx7T+8+eLZU33/67vJ/7kUz70RTtHuLZMBBbqscb3er6TIigipGJEkWIVjR+zxcttLBaDvxR5ykLyxOwsPKkaUBpclXLmPfoYrnzu1nBAyWni5Sbt1ByP1ml4lS1fwyuu3PitKBVBotr+aIt8uOHJ+hhL6ClRCvGLAg0S7Ut06ZNc9977736ACyj+++/X1tLZ0vPy4pXV0v/fmny8KwHZNhQe7ps5JIFgEnmNRvK0spSVpepyLFVGLtqErSwWhadCxVYRw/eamk8sKwyQ8Xq9TU58rtnZkvJmSJtPd353WlKuFbD0spz9+w7u2vXnrmD+veS8rLSaiVmcA/EvSBYBojWpq1enZ5RW2pGLEDAHe4XXC6kMCDQjpIyKDGDtIZdu3b5JDqlZCzVCpTFWy2N4sknn5Td+T5JbN9Zjh0+KMntq786yM4/ePAgVtFhki0kJlCwWhZLquIZjU14BOgJzH7kwfk69gRgVUGoEIeCUMFFxDGs35TZDccXWiMyFiRKQsGY0UPF3dV+ORF72bx5s+Tn50taH8Sz5suEGzKD94Ro7S/cpbvwmzMQ/8UXX8i7774rSYnt5X/elikDB1iybXuevLVmlTnFJ9ERLHypk88++6zu7TP88te/kwOFR2TIP98oXaxeNS7qkZoqO99fJx8uWY7NLIl9tv1FCYfmtCxwE7LEftl+K43DUm2ViVkBIyzrNr0rE67PlBeeypUbrrpNWQUddCxq8Sv6o55VFpYvQVyz+vbuoWJEdn0s5GOlp6freuj5+3bJ6nfx3rm0i4jrcZ/X3v6TfP21r9lcQwSxV65cKSOGj5K3Xs2Ve6ZkyU3Xe+SfbrlNzpWVyabNuro0hAYZ6hhM2JRhTLjWs3PnTuuqq67SO15++WXZnLdDRmR6ZMT3bpHUS3rXaNaQwTLKc52cLPxGCnfme6Txv09SC5xIteVBz2BThnTkwm0zYgUgVohVwaWbP29ltUA6gu4BfJFuiLwiiBFcP1hRi5ZmK0vNNhhMzyPcxw0bYlmG3gZJtLCsYFFBrLAEzzy/UC67Kl3++Hy1kBDc65NiW62I5+EgzMOGKut01Zu36p577tFDqZYuXVp0wLdLWVa9I15wodIeFzn4Gl3NlWkLMYJB95ZnlTSeLNWsR2bMD4oS3EAjVk4RMyBJNECdmdYQK4hWTg7iYLOCCadwEWFxISUDwtaQWlYNBZ+BSg6wEhMq7e/42OOztVDBNXzwvplyo7K24B5+fdAnX2zfinVLrVvbduR5xDE8SuyODZ/YwW+vBDo+wnwszkE+nCVVw6GYihAHULBaN3MgHibGhAA7kj7t4HpW2AtKTp80q/UaGgLRQg7WokWLZPbjk+XtZfZ7C0GEJQcrC4mlsQDWFdxBfFbv7pYcK1R+7IsLtVj958Nz5LGfZgfPvWx0hm4QMUPxqSJbyA4oIduRp9a3ZigRy1D7cdIcx0flSPhxiGbbEhIX0CVsvWSpZiF2ZUCSp6JIxbCKICaIV0UDJFRClOBOBj5DW1hoECxYQLHAVKsw4ovv86elC2TksAx56CfZdV7fNdWtra8fqpjXE/MWyA+nZgX3z1CW2WMPZxuBwwEo8TRpJJWVfiGxh4LVepkG98zkS8G6CsSn0E04Vq37pjwwVudeRQMzPAcWHIL6AJYPxMqRqR9VUIwPYmVSK5BLhu/41OMr5fABpTA7RL7xqaDVEZGzp1QcqTzyvWBpPTgzS3UmWPLxP7Zoofp4vVfeerfazydHAqWrQ0lO7iSnC4/J8V2+sO2bHXulcFu+nNz/jSQmtRcSG+gStk4s0dnss4I7ApaPT6q60ycoYVk5e87kjHmP5uj8q4aAYnuhg41vu+02eeWVV7RwQKwglkh9gJVl5gOMFhBBiOGEGyYF90F89Wc6csPOnbGbASN42ndUAqPCau2S7CUmX/3hv07WAfuXXlwpy1YskSd+n63jX3AtwbLlOfLSCv2jw/jLatUUOnToYvW3hsnelR/JXvlI6mKgNVK+yudE07GAgtU60X7MlWPG641AIihWsx3nYAdKCOQ+/mRWRlqfQaFjCsccLfR1c3frJUePHpHSsyXVPgBVQ5GY6Rw/CFFCgB1WFgQL3DlRBeVXPKHFJZrBd2O1maoSu/fm6e8YriPBCSoxh4oYrE/EsX798xzZvdunxeqJefOVW1gl+HAdBylB+81Tcy2xrdRssQPuGefOnV58ofyU/Mejj0pd5G3dKjmLXxQSGyhYrZNJTksj95OVZv/akPNgJWjR0pbWI4u1dRRg1ZmSIkEr/Do/4geZnkKTJHrttdfq2BIy3u041nid9oAM+Whmv+N+6Dww33HTF/ZXw5jHhgLrE8J3x4Rpcsc96ZJ5e5ZM+ZdZ2o3slCpazJRQ6WUAqDFMUgsbGFOI0jD1Gfxd8NVeKTunqzngWp+QqELBap1kOOtZoRSM2N30vjDnQrQmK/dwixItt67GMGOBfvERxF7057l6Of2W+ZLeq7oYHCn2yYr183SZGfQUwsIyorRp69pg4B3CgnhTNAULFpvzO5oOBOe++mAss3n35miRxfpP7pkjxcdFtyMnfPL9H4+VisoLulKDqYvVp08fCwKFbHcMXK4vuAeG9Jw+fRq9IZxqLMpQsFofeGPdxh3ECxkIgq+t47oiJVZuDGQOJpKOsXv7UI3hrU0L5ff3fi6dO1TlPI4aMF6uHjpJHl9+ix74bGrRw/XDy28yAxDHCinl3GRwv/R+Vc+CsZD4nIZiLDNjCYbGwLL+bYJ07NRBMBQnUgnmhoB7YND0M888A7cSOV4cohNF2EvY+rDwj3npHGVittRyTTaue+H3udI52S0n9/rl2M5KOV9albl+5JRP3ty8sMaFOP8/Jr0mCf4Owcx2WB7Oqg/Dh2QEB01HCwhWtQz9RqZobNqaG3QtUVHV5KzZx2yLC+5eNMTKcNdddxlLLUcanmVPaoGC1fqw8I+xNhzCsb+Wa8bjRcVLe2CdLVSJHV1yaGOllJ7wB127HQfCG2m9u1oyYfS9QcFCPAtWnUlviIWFFYrTKmoIyOwPBu7VzwrZ+gZ0VkCoTIG9aII67gFXEgFGS0hUoGC1PrTZYawPx9jAvFrOtzAIuqTQL8kpLul9mUvclr2EtQUgaBCsM+fCC096rwwdV4IwmQA83DSAHkgQzQTScJUgzOc1BCOq4Th0uKBB8amGACFEfXdljVpij2vk+MIoQMFqfbgbGMvR5kVa30FSViLSoUfVgY7dXcrCstfNPc+Uh3/Brd62lQLXz4hJqJsW7Yx3p9jASsK2Q6AbdI9wwgXrK5Zln9PS0uSpp56CeFliW1qkiVCwWh+N/p+68nzkYylduuplJAurc4eu0pxASA4eLAg+s3Hl0MnQEIwlapZO4cJ3Dp18IpqgbDJK1Pzyl7/EpkeqijWSRkLBan34Guga+fAPXtTOvUXOHq4a8wYXsUN3ex0BadA71Qp7k6PF+ja6hzDW8SoAK+7Qt/t1nA0xN1NvPpDCUW/QIWAsQViR1WrZd+lmJoWICUePHtWjBTBlGGJaYiekNnq8IqFgtUqqWQmdgwaXFeF0n2pFyJvq3MelLZYj2yqlyIeeQr90H2IXnd291+5k/OnScfLbVd+TNz9fKNsPeKXgSJ62ugqO2oIGt8/0CJpAeMkZu2RNNDPdYWGdKSuSz79cq0VLirvqcYUYnlNbXCoUCB3cSFxzZYanWu/mlZeP198Fk4DA0kLZZXw/NAxNQl2wplBeXi7Hjx/XPxfU1goE97OENBoKVuvDh39MLMfRexbJVdQnoFQyXtq0qxN07OqCslr6XuHS67BAYLmgp/Daa8dLsX+/LM79d5mz/FYtYPc+3UMWf/Dv+mYYS4gkUf3ZgbgX7ouXMpqCZcYm7lCiiWc9ss0vw5Pu1J+FzPXzpfW7j3El0SM44fpJ1QQPHQ2w2v7whz9oYYFFdPjwYd0KCwvlwIEDsn//fr2OfTgO6xKCVl8xO3XqlD43NTXVpDp4hDQaJo62PvTbpl+6PuJMpkRUPDTA41FtpXop3eZFR432lH4u1apOQkIljiMfK2g1qW1YIyZ9AQFqxHzwgqNIoDNHCrNGR7u+O8QPSaqf5a+WKdfbCapIZP3ncTP1WMZupZfLhFHTJLGjSFJH0UukaiSphvWERHu/ycSHYM+fa8e9zeBt7MfP4/Enp+tcrB49ekjPnj31OVhiLKXZZ7ZBcbFtUaInsFu3bnXOmQihI9GBgtX60KK0e+9WscvLjDf7sZLjOE9PTIEYzvzslcFJUc3MORAmCNErbzwjW/ZslGlTHq2W64Tzwk3Aanrq7hyTFdyHWFMsJqSAlYXyyNsPrJXRA+zveff1j8vGvavl6Xf+VbuqELALQWvLH2hVQLj+edxD8vLaecFKrPg5oAoEfn5wM0f1Hy+LlyxQ931ddu/+BJcZn7Pal4JgDRgwQD/X8OHD9RJuH2Z6rk20YGFB+GI8GexFAX+CrQ+fICb1hVdvOIQlM3DcEjvvJxvF/ZDdDiEylhisqTunD5cH5/yL/K+Hb5J3PlohyR06St6eT2Vj4J61YeprGTEzllgspv0y5ZdXrKsqeY/M+7l3vy9W7zHabZ3x3GBZ/Om/yxs7npId33rl0Kk91e5ReUHk9stnSid13f97Vn33a2bKzVdP0tVSX19jj5pJrnRLr66W6SH1iV1eppvYs0phJh4MIJ+uYlwLd+/e7V29enURpv2CVYZZoo3FFQkE3jG5BwWr6XDWnNbJSCUUGffcNUtvoOdr01YvAkhwCxcpEbN++/OXBccx0w2YPWcyEi9hnV2XkNCuOLFjR5/fX+k7c7p4RPfubqnwV8jaT9+RXt3TJL3/8IgfvOjP2eI7sNt2LZVYrvtsjazxviI33nhj1K0svOho6ze/r4VqWNq1ej/GO04cc7/u0Tx25oCUuook/9insvXQ3+XT/a/JP/Y8L19+u1b2HN0gR0771Hc7r8Xik+2vii/fJ/ff/KKyjMrk6eWztbX10ru/lbyCNXK+QueRQR3fdTwGVMwntmWL/VA5zIizVgmYZ+PGje7rrrtOUlJSatQPM+CzcQwTsWJORWnapCMXNRSs1olbiU+mGcgL1yYwddcIuDy//fkrujvfgHpQgVlvfqBaXmVlhffksW9WF5048qkSrFnDhqTLqJHDpPz8ecld/45YSrD6hUlORXD+VwtnBGaHztL7Fr/yhBw+vl8X94sF/fv317WxvHnL9RCh9N5V3wvrnu/cKxfOXZB3NyxSwfDTq7p06fafyjA6fLr82LmjZ3zur45v7gAhO3G+UNzde8uRswWybu9fJWPIRLlt7APi8ifIkeL9TrF6op6P5lNt7fnz5x9AvhUsTEz0Gg70OKIXEtYYpr0XClajoY3aOoFfplMVgDPeBDFxBsRBoBqpVxxTqAfw4T4nTpxQFkA7GZLeX7p07ih/UFbUkePf1PhQuJP6MyZWpRLhGWI9CzRK2yDNAXErNKRaACxfzJ2t9+G7nD1dMn3fnrxV+3ZvnrV315YJe3du6XbhXKVy7SonuFyVs1yudgs7dursLU88U/Tmjv+Wv2x+TNblr5CzZUVmfshsaRh6Fp6vv/46ZnXtSXUYdG+d6OmpVG+Zx1T+tGex8crjv5uup8QymIoEUj0g7yRPCZYHKxCtUSMvlc/zdskf/jJH5s58LngSrCtYaWagNDB15P9p4r0SSxDHQhFBBOBz85ZI7o6wFVtQaqJGgpbPl4d9XgkR6/7WEE95WZm7rKzUJ5HHYdaHvGPHjlmwokjsoUvYetlfXn4uK61Punb/7F6/Yh1PSuubHqxQgC78bTs34KX9QYT7jFXuyrUul0sPJYFoIeaye99uGTX0SundI02fNOX+sXrwMcTQWHCIi0lChdxxxx2C62MJYkDolbvssst0OgGedejQodrdQq6TYobUc+oycKrohIrfnUJCWVPr4tyuYncZ119/fZ0xPMSwPvvsM6zSJWwkdAlbL14046YBWFkQLkx6aoaj2IX2arUg9CwPmzdvli1b7Gz3/mm9tHCtePtZvQ2X0q6nPieY+mCsK5RMjrVYOUGcaNy4cbohmRPJnWJbjz5pIZSFVa/zIFjSNGvuooeC1bqZC9Ewddph+SA5EqkGZl7CwFCUSNVI4U9at956q96AaL399ttSUlIifXp1F9/BPVqsIIqw4pwTQOicLtUzdvnll0tzAWvK7/cLYkZLly6VHTt2mEMtabHAJdTPVBtLliwxAfcFQhpN8/3XSGIFMtkzUfo4aP28l6OztzHOMDBQerrUjGHh5FwlVhZKH//sZz+Tbdu2SXJyspSVlcklaf2ltLRcik4e0fc1+VzAiFhmZqaMHj1akpKSpF27dtLYOA6uxT0wU09FRUXYcyBUe/bs0WkBsKrMc4otVtnScsAPRNAwA2MF0TmARFLDmTNndO9gwLpq6Wdt9VCwWh5L7D9605xxGJMDVFtsBtcUqJiVe/mzVVWSjWgFwP/qoRMi5Kg27YUXXtAv2JEjR+Shhx7SQ1C6d+8edA9Npnxw9hrlYsJ6GzVqlEyYMEGfj5gSrC1kdEO0IDqRxAvHSkvt1HSMr+vcuXPwGAQIPZZO0PuG6ep37typx/V17dpVfzasq+LiYpiPYyU+yBLbvbak5rhOPCfMYK+QJkHBal4ssf+oERH3SP1L5+peQdXw33RBYOl1HPeolouUhnmPLg7uhEuICSYC8Sz8ky1V7mHBD37wA/nhD38YPB+z47z//vvBbWTKww0MVjfF/ZRYlZw9Lnfffbf07t1bWzqwkJDJDSsJwXFsR0qihGBBHAF6/3CeETjj8mGAMQZYo6GaAkQLQ2IwIw2WmBAjPz8fP5Oxwqm0LiooWLEHbzsSlzIlMFIfLzp6u7CEdYMlLA1jbeCFxksKKwIWBwLNiJGgDApcjABGxJCTtTZw/zkQGJPqYID7hpQER4VQXOu+8sortcWCe8IdNPdG2oKZ2dlgxMpUiYB1hIqayMGCG4TWmGoNECeIklkiSdTU28K90TOIBjEEn3/+uXzwwQdYzRLOSHPRQcGKHRAqzE03C+vI2EY3POa5w4uO7brK8yI7etOmTfrFNcmZRlxMg4gF8AU+040p7DF0JhT07KGMjCMYr9GzyvSx9EBqlFwJHfSMKp96aI+yrBCgx3OhGYExQLDQtW+W+ofg6Oo3QoSlKdNiEi5xjRE+832xD1ZXIFalx+w995zODcsROy5HLjIoWLEB1g4Uw4Ibc80118jIkSP1AVMAz0ztbgb4RgJuEXqhMFYvFIgGrA0EqxHj+fTTT4PHIEDImaptthlYSwjMh2bGO0EPJNIkEKNCvhXiVbCuYJkZjIXkbEaMQjPAIWBOUUODSEXKYUJRPbiJAGKlRMsn9mBkn8Qvltg13CGqTGOIIhSs6AOhmoXeM8SH4PqFAy85eo8Qw6lNtHAeRAvuW+jceRAGBKRxPV54uJKwuv7xj3/I9u3b9TmIaznzp+oLguvoDcRy0KBBcvPNN+s4Feo/RXMOv9qAEKN8C0BKwLp167CaJfHvCuaIHQbwii2uJEpQsKIHTAT8r+oJDWZHAhYSBAcCANEJR6goOTl48KAWvXBiBvF66aWXgkF0e8DytLA1rgywuHI/Xq3cxlUm4VRbVkhfMOVREHOLFFCPJrCqYF0BhyuInrZZEt9YqhUkpaTK+RKdgQ/B8gqJChSs6AGxykROk0nErA9GdBBYDhfTqk2wanMXAdyx9957T5YvX26Gr2gwbAcWl7P3T7dAQB3WITLYER+D4CGNANsAwuXMM4oViFshfoXvgCTRgCuIXsF6D79pIXJUmzZx1fvywY8mQ7Rag8i2Gjj4OTqgWy7zxz/+cYPECiD4DtFB8Lqhc+RBzExJ33DgnnANIVZw6SBsEKGvvvpKjhbvlR35dnoBeilHjh4s466+TD/PLbfcoq9BjlZCQjvdWwm3EOP34KLB4nHGsKINrCuTxwU3MFAgD5ZKvIuVpdq09MlTpNvI0dLn6hvk4PvvwDXMlvh/9lYBBavpWKpl33nnnTJpkh6WF6x/hGZePLhsiFOFi/9AJCAszlmVDWbevNDrTOA+kmBBrF577TVZv369DpaPHTtWPwumnIp0DY5jOnqIxLJlyyQxqb30GzhMCr/eIx9++KFMmTJFnwdXLdaCBZDKgTQGsTPEfRL/ePDP6H97RG8My/oJBAu/0CzhkJyoQMFqOtmwUCBYEBC4eBCTSJneZnIFpzUF9wdWDEbyw4JB6gIG9gKTiImgc3p6ulx66aU6eRLDU3CvcOIDsUL8CmIFi2/GjBn62SCKaOFiXuazkHaBYTrHj5+QAekjJUmJVmrXHnLiWFV9rFiXUjGC5SBHWgdzel99vXTuN0BvmPUzhQfwPxkFKwpQsJqGpdo0BNjRo4WcKQAxMkNWTIDambtksriNBQEXDcD9SkpK1pZNQju78k/l2XKprER2+HFt/Rh69eold911lxY2Z0wpVKwQUwMmhQLPiJgYRCtcz+Sbb76pZ3m5pP+lWqxagjCC1RpAr4mV/r2p1XamT54q25/+nUdqDrsijYCC1TSQb6WzsBE4h0jBQgknBBAvNIjZihUrdINl1bFTivTs3V86p7jrJRBl50ql9GyJEr9iWbRokd4HYULPJGJhf/3rX7UIIg5lxMpgUiggWEa0nD1+b769RvK277Ofp4tbWopWKlj6bwFWlZPe16jtp/VqltDKajIUrKYxHu4gBv06s9Fr4+WXX9YWEISq38BBatmwnCbMcIOG+uTnz5drVw09eRisDNcR1tFNN92kY1awtkKfCWKKHkkIFo5DYM1zrfjr38QaPFrfuyVp6ozLLcR498hRQXfQAAELpDiMEdJkKFhNw0LWN156BM7rAtUGIFawXuBy1YnLXySVKtic4PJhTHC1Q+K3khKT3H0uGZTRLiFBTpw4qsci/vrXv9bJqnA5zbCZUNFCYB/Pi3gbLL433nhDPxficAMGDZE1f/cKaTAZ6BUMR6C30COkyVCwmoa7X79+tYoVAtQQBrSNGzfqfT371CJuECm/a6GyM7x7d+Z5pXY8YqdUeJA7BRfQxLPMVO8QLbh9oc8IEUM87fnnn9fDe+BW3nfffVJaek4+/HiDXrYUrdAltFRzdwqxrgyd+g8w55AmQsFqIrVlfSOmBEsHogWrRgfhk9pHjlW5ZNWFUv90n29LXcFZj9gxkWko74JewHD5XxAt9A5CtMznO58b4w+NWJl4V8eOHeTmG6+lldUI2ivXr479DLw3EQpW0yhylHupBkTCCAWsGSyPHz8uF1Tc6VTxcZ0qEMLcvTs3Z0tk8MeOwC4SET1w/xBYR0InWiRgeaFn0IxHNCBm9frrr1cTK8P4m66jYDUMLULlJafqdR5pPBSsprF227ZtNQYBwv0zmevGNQMQB4gE0hjQ0wfRQvBdOUA5+3bVECtL7K5yqFFmYN2NXCwMk0GSKkTLCCOsOOdnGcxsMwiywwXEMyGDffXq1TpmNX369GANKlNdQZd66dNTvj1cv8kVYk3ffoPHd0hJEd+uPJ/EJ7oybOE/3rGGT/tJjYNHNupB2z4hTYaC1TRWKQtrJiokmKoMJnkUFlU4AVm4cKE8+eSTOp5VWGyXA05IaBcs7hfAcl4DkYLQ3H777br3z4kJqJtYlen1c2LKuCD14k9/+pPO5/r+978vmJoqMHW6dhdN2Rfki40aOTRuBEv1iuYkSoIMGTHOC3GvkIq1cSheC5Uwzf/0sYdkmBItDM05f+qUbHv6d0awWGwwClCwmgZqHRUp98ptBAvCAdGKVH0Bca2rr75aJ30iBQHW1pEjR9wnT550o1QwcrlMJVIIFZYIQsNCijSdllO0IDjhOgE6deoky//2phwq/Fp+9KMfycCBA7Ww4lxcHxqLgyu5ZetOOXEynrwYv0f9BDwQr8EjrlDCVTk3joQLOVbugpXL56gWeswrnHwiKlCwmgbe5oXKwppjrCwzIDlSfSsIFo4NHjxYN1MFwVRtwHa4ayEqOG5EJtxxfLZxRZ0CBIsK9dqTO6ZK956XyIVKl3Yhw1WAcHLVlRlxG8tSwpWlhCsrzoQrW+xhRBiK0y2wzyssLxM1OC9h08H/rD7EhUwMqDYRgLsVbhyfGVuIOFM4IFIQQgiSGRAdinFBIWwAHQJ4rl/96ldS6U+QlECgf8eXe1Wg3qpzpuIhg9Ml3gkIV8GQEVfMkfjAJ3bdruxA8wqJGhSsplPUOcU9F67dH//4R72jtoqckQQLFhEExNQ9D0eoIIVi3EGIHjLfMW0XguvIXO83cGgwneJs6TkpKi6pcb2pP2UYMtiS7t3cOhWjOWlkpnv2kJFXzBfSpqFLGAUu6XephSEyyGmqLX5VF7CgIEbhyswA0+OHiguRXEOUMM7JydHjCU15mHDDf5AcetnokcHEVlOuxgBRxf0HK9E6HJiWK+7xy6yhI65w5+/azAkq2igUrCiB2BBALSm86AhshwNWUOjEDAa4hXD5TC9jOCBqOIbzQmNlSJnAEBu4gngeWFaoABGOwkPfamsP4mfcWDw3RBHbZm7A0rNntGWW2EKVGxqK6kXMGjL8iq17d2/mQOM2CAUrGrhU8N1fJVqoxOD1evW4vtBywrUJlhlCY3oaIwXuYWUhGRTnYR2DnyFUqOOOvK5Bg0fXWfkBQ2/Wrd8gqSldItbHQgdBWfkF2f5lvh5wjVpdKJHcXJgJKBoB4lkUrDYIY1hRwF/h8pl1iFbvSwbpdACUTEbvnCnGB0ycKlIRPGPlwLqJhCnct3LlSpk6dar+jJLTpdr9c8aq6qK83O4pjBRzw2eMHWu7twkJiTpTvznJz8+vfShTJFziHjq0kX45iWtoYUWBivIKb2LHBFhZ2o8zGeym9AsastzRUC0UIGYULgYFsYqUwgBXD1N4Yf5BpFEAu0zNsAaXqQGwzuqarbl3L7uiKUQDn4sZdJoD1HGHu5pScwhTvfC3k5Yr6EViBgUrCvh8eUWqWx1d2cGudbzgfZSlBYsLwrX2w4+0cGE4DSZzwMSq1113nd6G22imqQcInKOnDOKE8jWoTAqBOhIIficmJdcZowril9mudpVevz8h1wiqobS0VNZ+tF72feWTwsJvgxUaund3S7+0vjJ61AgdmAcQxMKv83VOl8kdixUobIiZfmBdGTe7obgqOG6vLcJpvqKEZWW4E5NdueJyRXRFzpQUq0B3kZSfK1Uv5VmpLxAlWFIQjfpWJvWL3+cS//S9u+wSNYNHXFHgilDiZED/NOnatYuKZ6Xo7aPHjqueweNy6lSJTmsw2e4QXjRM+4WhPbEA7jIGZsONbqzliO++b9eW+E8iIw2GghVFrBEZVqLftbI20TKgTjvKHVdWVEiFWr9wvix4DAKV0C5RkpM7SpKewLSd1JtAPa0L5yoXwPIzu5UFWKPI1NDBltw20SMdkpPD3mr7l7vlk/Wfa+EyGNFCLM7j8TQ6hSMUdDLAekMrLz8vfdIGNaFMc+UEI9SkbUHBigFDhmfM8rtcM13isqS5iCBUQAupJBQ49yUnt5eHHqw7XWnvXp+sfGNNtX0ozYypv1AqxwzyhnA1dF5FiJSZlANjJbENSxKdFk2YAGPu3l21lukhrRgKVgwZPCIjy+VKmIRBu0pMoh4Ehuuj7rva5apcVZtFEU6wQOadE7WVFYlzKpb07pq1kr+vIOxx1PUqKT6hS+UAXZZGiZapDoFtZ1DfDF2C2wehMiVtjMuLmFxjXMAgKl7H/Ku2DQWrmRgyIsPjcsmYysqEdJfLP0b5Z1a9LTBlPaGmu8vlyvNXyn5xVeZViHjrO+BXx9c6KsHy1+w5w/CboUMs6dWzhxIX2zUsLi6RAwe/kc1btmnRqgu4t6VnTqugfYl2c2GBOV1cJ6HuLtw+5Hg1yO0NAcKdkOCfnP9lXp6QNg0Fq4WBmEgHcSeGBMQvmIJvyiAJdfEaA9xUcSU061g7CBlK5hgwq09ThKkGepIO11xaVRcPFKyLCLiGSS6Z5Pe7MrW1VY/OgfjE71VW6qrzpbIkGmJOWg8UrIscY+FV26msOuxTtpBHua3T1J+JR1oavx8VDFfr2YTYA3jRQsEidQJRa9dePMql9CD+1iwCpgRK9bSqmFTl2opzsoqWFAEULNIohn4nI6Pyguo4SEjIUB0CblvIdLUES3UuuOvqFdWJrZgcNjBJrPpD3O+XShU8l7zzZzGumwJFCGkBEDsTQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQQgghhBBCCCGEEEIIIQ3l/wMvNv557ac0YgAAAABJRU5ErkJggg=="}))));function Np(e){var{sx:t}=e,n=Oo(e,["sx"]);return G.jsx(o.TabPanel,{...n,sx:Object.assign(Object.assign({},t),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function Up({params:r}){var a,l,s;const{isMobile:d}=Ls(),c=Fo((e=>e.noDocumentLink)),u=i.useRef(null),{account:p}=Zo(),{poolTab:h,tabs:m,handleChangePoolTab:f}=function({account:t,paramsTab:n}){const{i18n:o}=e.useLingui(),[r,a]=i.useState(sd.addLiquidity),{supportAMMV2:l,supportAMMV3:s,notSupportPMM:d}=Fo(),c=i.useMemo((()=>{const e=[{key:sd.addLiquidity,value:o._({id:"OBdohg",message:"Add Liquidity"})},{key:sd.myLiquidity,value:o._({id:"YHc3B+",message:"My Liquidity"})}];return d||e.push({key:sd.myCreated,value:l||s?o._({id:"zcVtwU",message:"My Pools (PMM)"}):o._({id:"fZFkP1",message:"My Pools"})}),e}),[o._,l,s,d]),u=i.useRef(!1);i.useEffect((()=>{const e=sessionStorage.getItem(ad);t&&e&&!u.current&&(u.current=!0,a(e))}),[t]);const p=e=>{a(e),sessionStorage.setItem(ad,e)};return i.useEffect((()=>{n&&p(n)}),[n]),{poolTab:r,tabs:c,handleChangePoolTab:p}}({account:p,paramsTab:null==r?void 0:r.tab}),{activeChainId:x,filterChainIds:g,handleChangeActiveChainId:y}=function(){const{chainId:e}=Zo(),{onlyChainId:t}=Fo(),[o,r]=i.useState(t),a=i.useMemo((()=>void 0!==o?[o]:Oa(e)?void 0:Object.values(n.ChainId).filter((e=>!!Number(e)))),[e,o]);return i.useEffect((()=>{const e=sessionStorage.getItem(ld);e&&r(Number(e))}),[]),{activeChainId:o,filterChainIds:a,handleChangeActiveChainId:e=>{void 0===e?sessionStorage.removeItem(ld):sessionStorage.setItem(ld,String(e)),r(e)}}}(),[v,b]=i.useState(null);return G.jsxs(Ks,{sx:Object.assign({},d?{p:20}:{display:"flex",gap:12,flex:1}),ref:u,children:[G.jsx(o.Box,{sx:d?{}:{p:8,borderRadius:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"border.disabled",backdropFilter:"blur(5px)",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%"},children:G.jsxs(o.Tabs,{value:h,onChange:(e,t)=>{f(t)},sx:d?{}:{display:"flex",flexDirection:"column",borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"background.paper"},className:d?void 0:"gradient-card-border",children:[G.jsxs(o.Box,{sx:d?{}:{display:"flex",justifyContent:"space-between",p:20,borderBottomWidth:1},children:[G.jsx(o.TabsGroup,{tabs:m,variant:"rounded",tabsListSx:Object.assign({},d?{mb:16}:{borderBottomWidth:0,justifyContent:"space-between"}),tabSx:d?void 0:{mb:0}}),G.jsx(Ep,{})]}),G.jsx(Np,{value:sd.addLiquidity,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(Bp,{account:p,filterChainIds:g,scrollParentRef:u,activeChainId:x,handleChangeActiveChainId:y,operatePool:v,setOperatePool:b})}),G.jsx(Np,{value:sd.myLiquidity,children:G.jsx(Vp,{account:p,filterChainIds:g,activeChainId:x,handleChangeActiveChainId:y,operatePool:v,setOperatePool:b})})]})}),G.jsxs(o.Box,{sx:{position:"relative",width:c&&!v?"auto":375},children:[!c&&G.jsx(wu,{title:t.i18n._({id:"6y2TB3",message:"Liquidity"}),desc:t.i18n._({id:"QNrpkx",message:"Classical AMM-like pool. Suitable for most assets."}),linkTo:"https://docs.dodoex.io/product/tutorial/how-to-provide-liquidity",LeftImage:Zp}),"SVM_AMMV3"===(null===(a=null==v?void 0:v.pool)||void 0===a?void 0:a.type)&&v.pool.chainId?h===sd.myLiquidity&&(null===(s=null===(l=v.pool.liquidityPositions)||void 0===l?void 0:l[0])||void 0===s?void 0:s.tokenId)?G.jsx(Vu,{mint1Address:v.pool.baseToken.address,mint2Address:v.pool.quoteToken.address,feeAmount:Number(v.pool.lpFeeRate),poolId:v.pool.address,nftMint:v.pool.liquidityPositions[0].tokenId,onClose:()=>b(null)}):G.jsx(Pu,{mint1Address:v.pool.baseToken.address,mint2Address:v.pool.quoteToken.address,feeAmount:Number(v.pool.lpFeeRate),poolId:v.pool.address,onClose:()=>b(null),handleGoToAddLiquidityV3:e=>{Gs.getState().push({type:exports.PageType.createPoolAMMV3,params:e})}}):d?G.jsx(Ju,{account:p,onClose:()=>b(null),modal:d,pool:null==v?void 0:v.pool,operate:null==v?void 0:v.operate,hasMining:!1,hidePoolInfo:!1}):!!v&&G.jsx(_u,{account:p,onClose:()=>b(null),pool:null==v?void 0:v.pool,operate:null==v?void 0:v.operate,hasMining:!1,hidePoolInfo:!1,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"}})]})]})}exports.AMMV2Create=Sd,exports.AMMV3PositionManage=Vu,exports.AMMV3PositionsView=Pu,exports.AddLiquidityV3=Cu,exports.Pool=function(){const{routerPage:e}=Fo(),t=Gs((e=>e.page)),n=null!=e?e:t;switch(null==n?void 0:n.type){case exports.PageType.Pool:return G.jsx(Up,{params:n.params});case exports.PageType.createPoolAMMV2:return G.jsx(Sd,{});case exports.PageType.createPoolAMMV3:return G.jsx(Cu,{params:n.params,handleGoBack:()=>{Gs.getState().push({type:exports.PageType.Pool})},handleGoToPoolList:()=>{Gs.getState().push({type:exports.PageType.Pool})}});default:return G.jsx(Up,{params:null==n?void 0:n.params})}},exports.PoolList=Up,exports.Swap=function({getAutoSlippage:s,onPayTokenChange:d,onReceiveTokenChange:c}={}){var u,p;const h=o.useTheme(),{isInflight:m}=Ii(),{chainId:f,account:x}=Zo(),g=l.useDispatch(),{defaultChainId:y,noPowerBy:v,onlyChainId:b,onlySolana:j}=Fo(),[C,w]=i.useState(!1);i.useMemo((()=>{var e;return null===(e=n.basicTokenMap[null!=f?f:y])||void 0===e?void 0:e.address}),[f,y]);const[k,T]=i.useState(""),[R,S]=i.useState(""),[I,B]=i.useState(""),[M,E]=i.useState(""),L=i.useMemo((()=>a.debounce((e=>B(e)),1e3)),[]),O=i.useMemo((()=>a.debounce((e=>E(e)),1e3)),[]),[W,V]=i.useState(null),[F,P]=i.useState(null),[Z,N]=i.useState(!1),[U,H]=i.useState(!1),{toFiatPrice:D,fromFiatPrice:Y}=Li({toToken:F,fromToken:W});!function({token:e,fiatPrice:t}){i.useMemo((()=>{var n;const o=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,i=null!=t?new r(500).div(t):new r(0),a=ni(i,o);return(a.lt(new r(1).times(new r(10).pow(o-3)))?new r(0):a).toString(10)}),[null==e?void 0:e.decimals,t])}({token:C?F:W,fiatPrice:C?D:Y}),function({fromToken:e,toToken:t,getAutoSlippage:n}){const o=l.useDispatch();i.useEffect((()=>{(()=>{Wo(this,void 0,void 0,(function*(){if(!n)return;const i=n({fromToken:e,toToken:t});if(void 0!==i&&"number"!=typeof i){o(qo(!0));try{const e=yield i;o(zo({loading:!1,value:null!=e?e:null}))}catch(e){console.error(e),o(zo({loading:!1,value:null}))}}else o(zo({loading:!1,value:null}))}))})()}),[e,t])}({fromToken:W,toToken:F,getAutoSlippage:s});const{slippage:z,slippageLoading:q}=ar({fromToken:W,toToken:F}),{isApproving:X,isGetApproveLoading:_,needApprove:J,insufficientBalance:Q,submitApprove:K,getMaxBalance:$}=ur(W,{amount:I}),ee=i.useCallback((()=>{ce($())}),[$]);i.useMemo((()=>!(!x||Q||X||_||J)),[x,Q,X,_,J]);const{status:te,rawBrief:ne,executeSwap:oe}=Wi({toToken:F,fromToken:W,fromAmount:I,slippage:z}),{resAmount:ie,priceImpact:re,baseFeeAmount:ae,additionalFeeAmount:le,resPricePerToToken:se,resPricePerFromToken:de}=i.useMemo((()=>{if(!ne)return{resAmount:null,priceImpact:null,baseFeeAmount:null,additionalFeeAmount:null,resPricePerToToken:null,resPricePerFromToken:null};const e=new r(ne.inAmount).dividedBy(ne.outAmount).toNumber(),t=new r(ne.outAmount).dividedBy(ne.inAmount).toNumber();return{resAmount:ne.resAmount,priceImpact:ne.priceImpact,baseFeeAmount:0,additionalFeeAmount:0,resPricePerToToken:e,resPricePerFromToken:t}}),[ne]),ce=i.useCallback((e=>{const t=e.toString();T(t),L(t)}),[T,L]),ue=i.useCallback((e=>{const t=e.toString();S(t),O(t)}),[S,O]),pe=i.useCallback((e=>V((t=>{var n;const o="function"==typeof e?e(t):e;return f||g(bi(null!==(n=null==o?void 0:o.chainId)&&void 0!==n?n:void 0)),d&&o&&o!==t&&d(o),o}))),[g,bi,d,f]),he=i.useCallback((e=>P((t=>{const n="function"==typeof e?e(t):e;return c&&n&&n!==t&&c(n),n}))),[c]);Qi({fromToken:W,toToken:F,setFromToken:pe,setToToken:he,updateFromAmt:ce,updateToAmt:ue,setIsReverseRouting:w});const me=i.useCallback((()=>{ce(""),ue(""),pe(F),he(W),jo("from",F),jo("to",W)}),[pe,F,he,W,ce,ue]),fe=i.useCallback(((e,t)=>{if(t)return me();ce(""),ue(""),pe(e),jo("from",e)}),[me,ce,ue,pe,jo]),xe=i.useCallback(((e,t)=>{if(t)return me();ce(""),ue(""),he(e),jo("to",e)}),[me,ce,ue,pe,jo]),ge=i.useCallback((()=>{C&&ce(""),w(!1)}),[C,ce,g]);i.useCallback((()=>{C||ue(""),w(!0)}),[C,ue,g]);const ye=(e=>{const{defaultSlippage:t}=$i(void 0===e),n=l.useSelector(Ki)||t;return i.useMemo((()=>(void 0===e?Number(n):e)>5),[n,e])})(z),ve=i.useMemo((()=>re?new r(re).multipliedBy(100).dp(4,r.ROUND_DOWN).toString():null),[re]),be=i.useMemo((()=>{const e=C?ie:I;return e&&Y?new r(Y).multipliedBy(e):null}),[Y,I,C,ie]),je=i.useMemo((()=>{if(!D)return null;const e=C?M:ie;return e?new r(D).multipliedBy(e):null}),[D,M,C,ie]),Ce=i.useMemo((()=>G.jsxs(o.Box,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[G.jsx(vs,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),G.jsxs(o.Box,{sx:{display:"flex"},children:[G.jsx(e.Trans,{id:"6+mYrD",message:"Current price impact"}),G.jsxs(o.Box,{sx:{color:h.palette.error.main,ml:4},children:[ve,"%"]})]})]})),[ve,h.palette.error.main]),we=i.useMemo((()=>G.jsx(qs,{toToken:F,fromToken:W,priceStatus:te,pricePerToToken:se,pricePerFromToken:de})),[F,W,te,se,de]),ke=i.useMemo((()=>!(n.ChainId[f||1]||b&&b===f)),[f]),Te=i.useMemo((()=>!j&&!!f&&!!(null==W?void 0:W.chainId)&&(null==W?void 0:W.chainId)!==f),[f,null==W?void 0:W.chainId,j]),Re=function({fromToken:e,toToken:t}){const n=l.useSelector(Gi);return i.useMemo((()=>!(!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:W,toToken:F}),Se=i.useMemo((()=>ye&&new r(C?M:I).gt(0)&&!Q&&te===Oi.Success?G.jsxs(o.Box,{sx:{textAlign:"center",mb:8},children:[G.jsx(o.Box,{component:A.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),t.i18n._({id:"//95jS",message:"The current slippage protection coefficient set exceeds {maxSlippageWarning}%, which may result in losses.",values:{maxSlippageWarning:5}})]}):null),[ye,C,I,M,te]),Ie=i.useMemo((()=>Te?G.jsxs(o.Box,{sx:{textAlign:"center"},children:[G.jsx(o.Box,{component:A.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"54ffaC",message:"The current network is inconsistent with the wallet - please switch in wallet"})]}):te===Oi.Loading?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsxs(G.Fragment,{children:[G.jsx(o.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]})}):ke?G.jsxs(G.Fragment,{children:[G.jsx(o.Box,{component:A.Warn,sx:{mr:6,width:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"udsWDJ",message:"Unsupported network - switch to trade"})]}):k&&ve&&new r(ve).gt(wo)?Ce:G.jsxs(G.Fragment,{children:[Se,we]})),[te,we,k,Ce,ve,ke,Te,Se]),Be=i.useMemo((()=>C?new r(R).gt(0)?Ko({input:ie,decimals:null==W?void 0:W.decimals}):"-":k),[k,R,ie,W,C]),Me=i.useMemo((()=>C?R:new r(k).gt(0)?Ko({input:ie,decimals:null==F?void 0:F.decimals}):"-"),[k,R,ie,F,C]),Ee=i.useMemo((()=>{if(!x||(null==W?void 0:W.chainId)&&f!==W.chainId)return G.jsx(js,{needSwitchChain:null==W?void 0:W.chainId});if(m)return G.jsx(o.Button,{fullWidth:!0,isLoading:!0,disabled:!0,children:G.jsx(e.Trans,{id:"FRBvjQ",message:"Transaction Pending"})});if(!W||!F)return G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:G.jsx(e.Trans,{id:"KlvBGJ",message:"Select Tokens"})});if(J)return G.jsx(o.Button,{fullWidth:!0,disabled:X,onClick:()=>K(),children:X?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):G.jsx(e.Trans,{id:"Z7ZXbT",message:"Approve"})});if(!new r(C?M:I).gt(0))return G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:G.jsx(e.Trans,{id:"iPMIoT",message:"Enter an amount"})});if(te===Oi.Loading)return G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:G.jsx(e.Trans,{id:"OauUE6",message:"Fetching Price..."})});return!ie||te===Oi.Failed?G.jsx(o.Button,{fullWidth:!0,disabled:!0,children:G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})}):Q?G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):G.jsx(o.Button,{fullWidth:!0,onClick:()=>N(!0),"data-testid":"swap-review-btn",children:G.jsx(e.Trans,{id:"K/Ay/d",message:"Review Swap"})})}),[x,W,f,m,F,J,X,C,M,I,te,ie,Q,K]),Le=i.useMemo((()=>W&&F?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{token:W,width:16,height:16,marginRight:6,chainId:W.chainId,noShowChain:!!b}),`${Ko({input:C?ie:I,decimals:null==W?void 0:W.decimals})} ${null==W?void 0:W.symbol}`,G.jsx(o.Box,{component:A.DoubleRight,sx:{width:12,height:12,mx:16}}),G.jsx(Wa,{token:F,width:16,height:16,marginRight:6,chainId:F.chainId,noShowChain:!!b}),`${Ko({input:C?M:ie,decimals:null==F?void 0:F.decimals})} ${null==F?void 0:F.symbol}`]}):G.jsx(o.Box,{})),[W,F,I,M,ie,C,b]);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"caption",margin:20},children:[G.jsx(e.Trans,{id:"vH2C/2",message:"Swap"}),G.jsx(o.Tooltip,{open:void 0,title:G.jsx(e.Trans,{id:"NSCBTb",message:"The setting has been switched to swap mode"}),placement:"bottom-end",children:G.jsx(o.Box,{component:o.ButtonBase,children:G.jsx(o.Box,{component:A.Setting,onClick:()=>H(!0),sx:{width:19,height:19,color:"text.primary",cursor:"pointer"}})})})]}),G.jsxs(o.Box,{sx:{flex:1,padding:"0 16px 12px",overflowY:"auto"},children:[G.jsxs(o.Box,{children:[G.jsx(zs,{sx:{mb:4},token:W,side:"from",amt:Be,defaultLoadBalance:!0,onMaxClick:ee,onInputChange:ce,onInputFocus:ge,showMaxBtn:!C&&!k,occupiedAddrs:[null!==(u=null==F?void 0:F.address)&&void 0!==u?u:""],occupiedChainId:null==F?void 0:F.chainId,fiatPriceTxt:be?`$${Qo({input:be,showDecimals:1})}`:"-",onTokenChange:fe,readOnly:C,showChainLogo:!b,showChainName:!b,notTokenPickerModal:!0}),G.jsx(Is,{onClick:me,disabled:Re}),G.jsx(zs,{token:F,side:"to",amt:Me,onInputChange:ue,occupiedAddrs:[null!==(p=null==W?void 0:W.address)&&void 0!==p?p:""],occupiedChainId:null==W?void 0:W.chainId,fiatPriceTxt:je?`$${Qo({input:je,showDecimals:1})}(${ve}%)`:"-",onTokenChange:xe,readOnly:!0,showChainLogo:!b,showChainName:!b,notTokenPickerModal:!0}),G.jsx(o.Box,{sx:{py:12,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:Ie})]}),Ee,v?"":G.jsxs(o.Box,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:h.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[G.jsx(o.Box,{sx:{width:18,height:18,transform:"translate(1px, 2px)","& path":{fill:h.palette.text.disabled}},component:A.Dodo}),G.jsx(e.Trans,{id:"7X+IbB",message:"Powered by DODO protocol"})]})]}),G.jsx(Cs,{toToken:F,fromToken:W,fromAmount:C?ie:I,toAmount:C?M:ie,open:Z,baseFeeAmount:ae,priceImpact:ve,additionalFeeAmount:le,curToFiatPrice:je,execute:()=>oe(Le),clearFromAmt:()=>ce(""),clearToAmt:()=>ue(""),curFromFiatPrice:be,onClose:()=>N(!1),loading:te===Oi.Loading,slippage:z}),G.jsx(Ss,{open:U,onClose:()=>H(!1),fromToken:W,toToken:F})]})},exports.UnstyleWidget=ys,exports.Widget=function(e){const t=o.createTheme({mode:e.colorMode,theme:e.theme,lang:e.locale||Va});return e.apikey||e.apiServices||console.error("apikey and apiServices must have a."),G.jsxs(o.ThemeProvider,{theme:t,children:[G.jsx(o.CssBaseline,{container:`.${fs}, .${o.WIDGET_MODAL_CLASS}, .${o.WIDGET_MODAL_FIXED_CLASS}`}),G.jsx(d.QueryClientProvider,{client:Qa,children:G.jsxs(ys,{...e,children:[e.children,G.jsx(ns,{})]})})]})},exports.useRouterStore=Gs;
23
+ */function vl(){if(al)return rl;al=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return rl=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 o={};return"abcdefghijklmnopqrst".split("").forEach((function(e){o[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}()?Object.assign:function(o,i){for(var r,a,l=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(o),s=1;s<arguments.length;s++){for(var d in r=Object(arguments[s]))t.call(r,d)&&(l[d]=r[d]);if(e){a=e(r);for(var c=0;c<a.length;c++)n.call(r,a[c])&&(l[a[c]]=r[a[c]])}}return l},rl}function bl(){if(sl)return ll;sl=1;return ll="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}function jl(){return cl?dl:(cl=1,dl=Function.call.bind(Object.prototype.hasOwnProperty))}if("production"!==process.env.NODE_ENV){var Cl=yl();el.exports=function(){if(ml)return hl;ml=1;var e=yl(),t=vl(),n=bl(),o=jl(),i=function(){if(pl)return ul;pl=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=bl(),n={},o=jl();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function i(i,r,a,l,s){if("production"!==process.env.NODE_ENV)for(var d in i)if(o(i,d)){var c;try{if("function"!=typeof i[d]){var u=Error((l||"React class")+": "+a+" type `"+d+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof i[d]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw u.name="Invariant Violation",u}c=i[d](r,d,l,a,null,t)}catch(e){c=e}if(!c||c instanceof Error||e((l||"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=s?s():"";e("Failed "+a+" type: "+c.message+(null!=p?p:""))}}}return i.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},ul=i}(),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){}}),hl=function(l,s){var d="function"==typeof Symbol&&Symbol.iterator,c="@@iterator",u="<<anonymous>>",p={array:x("array"),bigint:x("bigint"),bool:x("boolean"),func:x("function"),number:x("number"),object:x("object"),string:x("string"),symbol:x("symbol"),any:f(a),arrayOf:function(e){return f((function(t,o,i,r,a){if("function"!=typeof e)return new m("Property `"+a+"` of component `"+i+"` has invalid PropType notation inside arrayOf.");var l=t[o];if(!Array.isArray(l))return new m("Invalid "+r+" `"+a+"` of type `"+v(l)+"` supplied to `"+i+"`, expected an array.");for(var s=0;s<l.length;s++){var d=e(l,s,i,r,a+"["+s+"]",n);if(d instanceof Error)return d}return null}))},element:f((function(e,t,n,o,i){var r=e[t];return l(r)?null:new m("Invalid "+o+" `"+i+"` of type `"+v(r)+"` supplied to `"+n+"`, expected a single ReactElement.")})),elementType:f((function(t,n,o,i,r){var a=t[n];return e.isValidElementType(a)?null:new m("Invalid "+i+" `"+r+"` of type `"+v(a)+"` supplied to `"+o+"`, expected a single ReactElement type.")})),instanceOf:function(e){return f((function(t,n,o,i,r){if(!(t[n]instanceof e)){var a=e.name||u;return new m("Invalid "+i+" `"+r+"` of type `"+((l=t[n]).constructor&&l.constructor.name?l.constructor.name:u)+"` supplied to `"+o+"`, expected instance of `"+a+"`.")}var l;return null}))},node:f((function(e,t,n,o,i){return y(e[t])?null:new m("Invalid "+o+" `"+i+"` supplied to `"+n+"`, expected a ReactNode.")})),objectOf:function(e){return f((function(t,i,r,a,l){if("function"!=typeof e)return new m("Property `"+l+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var s=t[i],d=v(s);if("object"!==d)return new m("Invalid "+a+" `"+l+"` of type `"+d+"` supplied to `"+r+"`, expected an object.");for(var c in s)if(o(s,c)){var u=e(s,c,r,a,l+"."+c,n);if(u instanceof Error)return u}return null}))},oneOf:function(e){return Array.isArray(e)?f((function(t,n,o,i,r){for(var a=t[n],l=0;l<e.length;l++)if(h(a,e[l]))return null;var s=JSON.stringify(e,(function(e,t){return"symbol"===b(t)?String(t):t}));return new m("Invalid "+i+" `"+r+"` of value `"+String(a)+"` supplied to `"+o+"`, expected one of "+s+".")})):("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 i=e[t];if("function"!=typeof i)return r("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+j(i)+" at index "+t+"."),a}return f((function(t,i,r,a,l){for(var s=[],d=0;d<e.length;d++){var c=(0,e[d])(t,i,r,a,l,n);if(null==c)return null;c.data&&o(c.data,"expectedType")&&s.push(c.data.expectedType)}return new m("Invalid "+a+" `"+l+"` supplied to `"+r+"`"+(s.length>0?", expected one of type ["+s.join(", ")+"]":"")+".")}))},shape:function(e){return f((function(t,o,i,r,a){var l=t[o],s=v(l);if("object"!==s)return new m("Invalid "+r+" `"+a+"` of type `"+s+"` supplied to `"+i+"`, expected `object`.");for(var d in e){var c=e[d];if("function"!=typeof c)return g(i,r,a,d,b(c));var u=c(l,d,i,r,a+"."+d,n);if(u)return u}return null}))},exact:function(e){return f((function(i,r,a,l,s){var d=i[r],c=v(d);if("object"!==c)return new m("Invalid "+l+" `"+s+"` of type `"+c+"` supplied to `"+a+"`, expected `object`.");var u=t({},i[r],e);for(var p in u){var h=e[p];if(o(e,p)&&"function"!=typeof h)return g(a,l,s,p,b(h));if(!h)return new m("Invalid "+l+" `"+s+"` key `"+p+"` supplied to `"+a+"`.\nBad object: "+JSON.stringify(i[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var f=h(d,p,a,l,s+"."+p,n);if(f)return f}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 f(e){if("production"!==process.env.NODE_ENV)var t={},o=0;function i(i,a,l,d,c,p,h){if(d=d||u,p=p||l,h!==n){if(s){var f=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 f.name="Invariant Violation",f}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var x=d+":"+l;!t[x]&&o<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[x]=!0,o++)}}return null==a[l]?i?null===a[l]?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,l,d,c,p)}var a=i.bind(null,!1);return a.isRequired=i.bind(null,!0),a}function x(e){return f((function(t,n,o,i,r,a){var l=t[n];return v(l)!==e?new m("Invalid "+i+" `"+r+"` of type `"+b(l)+"` supplied to `"+o+"`, expected `"+e+"`.",{expectedType:e}):null}))}function g(e,t,n,o,i){return new m((e||"React class")+": "+t+" type `"+n+"."+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+i+"`.")}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||l(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,o=t.call(e);if(t!==e.entries){for(;!(n=o.next()).done;)if(!y(n.value))return!1}else for(;!(n=o.next()).done;){var i=n.value;if(i&&!y(i[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=i,p.resetWarningCache=i.resetWarningCache,p.PropTypes=p,p},hl}()(Cl.isElement,!0)}else el.exports=function(){if(xl)return fl;xl=1;var e=bl();function t(){}function n(){}return n.resetWarningCache=t,fl=function(){function o(t,n,o,i,r,a){if(a!==e){var l=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 l.name="Invariant Violation",l}}function i(){return o}o.isRequired=o;var r={array:o,bigint:o,bool:o,func:o,number:o,object:o,string:o,symbol:o,any:o,arrayOf:i,element:o,elementType:o,instanceOf:i,node:o,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:t};return r.PropTypes=r,r}}()();var wl=W(el.exports);function kl(e,t){return"production"===process.env.NODE_ENV?()=>null:function(...n){return e(...n)||t(...n)}}function Tl(e,t,n,o,i){const r=e[t],a=i||t;if(null==r||"undefined"==typeof window)return null;let l;const s=r.type;return"function"!=typeof s||function(e){const{prototype:t={}}=e;return Boolean(t.isReactComponent)}(s)||(l="Did you accidentally use a plain function component for an element instead?"),void 0!==l?new Error(`Invalid ${o} \`${a}\` supplied to \`${n}\`. Expected an element that can hold a ref. ${l} For more information see https://mui.com/r/caveat-with-refs-guide`):null}const Rl=kl(wl.element,Tl);Rl.isRequired=kl(wl.element.isRequired,Tl);const Sl="exact-prop: ​";function Il(e){return e&&e.ownerDocument||document}const Bl="undefined"!=typeof window?O.useLayoutEffect:O.useEffect;function Ml(e){const t=O.useRef(e);return Bl((()=>{t.current=e})),O.useRef(((...e)=>(0,t.current)(...e))).current}function El(...e){return O.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 Ll={};const Ol=[];class Wl{static create(){return new Wl}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 Vl(){const e=function(e,t){const n=O.useRef(Ll);return n.current===Ll&&(n.current=e(t)),n}(Wl.create).current;var t;return t=e.disposeEffect,O.useEffect(t,Ol),e}const Al={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 Fl(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Fl(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Pl(){for(var e,t,n=0,o="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Fl(e))&&(o&&(o+=" "),o+=t);return o}function Zl(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 Nl(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 Ul(e){const{elementType:t,externalSlotProps:n,ownerState:o,skipResolvingSlotProps:i=!1,...r}=e,a=i?{}:function(e,t,n){return"function"==typeof e?e(t,n):e}(n,o),{props:l,internalRef:s}=function(e){const{getSlotProps:t,additionalProps:n,externalSlotProps:o,externalForwardedProps:i,className:r}=e;if(!t){const e=Pl(n?.className,r,i?.className,o?.className),t={...n?.style,...i?.style,...o?.style},a={...n,...i,...o};return e.length>0&&(a.className=e),Object.keys(t).length>0&&(a.style=t),{props:a,internalRef:void 0}}const a=Zl({...i,...o}),l=Nl(o),s=Nl(i),d=t(a),c=Pl(d?.className,n?.className,r,i?.className,o?.className),u={...d?.style,...n?.style,...i?.style,...o?.style},p={...d,...n,...s,...l};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,{...l,ref:El(s,a?.ref,e.additionalProps?.ref)},o);return d}function Hl(e){return e.substring(2).toLowerCase()}function Dl(e){const{children:t,disableReactTree:n=!1,mouseEvent:o="onClick",onClickAway:i,touchEvent:r="onTouchEnd"}=e,a=O.useRef(!1),l=O.useRef(null),s=O.useRef(!1),d=O.useRef(!1);O.useEffect((()=>(setTimeout((()=>{s.current=!0}),0),()=>{s.current=!1})),[]);const c=El((u=t)&&O.isValidElement(u)?u.props.propertyIsEnumerable("ref")?u.props.ref:u.ref:null,l);var u;const p=Ml((e=>{const t=d.current;d.current=!1;const o=Il(l.current);if(!s.current||!l.current||"clientX"in e&&function(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}(e,o))return;if(a.current)return void(a.current=!1);let r;r=e.composedPath?e.composedPath().indexOf(l.current)>-1:!o.documentElement.contains(e.target)||l.current.contains(e.target),r||!n&&t||i(e)})),h=e=>n=>{d.current=!0;const o=t.props[e];o&&o(n)},m={ref:c};return!1!==r&&(m[r]=h(r)),O.useEffect((()=>{if(!1!==r){const e=Hl(r),t=Il(l.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!==o&&(m[o]=h(o)),O.useEffect((()=>{if(!1!==o){const e=Hl(o),t=Il(l.current);return t.addEventListener(e,p),()=>{t.removeEventListener(e,p)}}}),[p,o]),G.jsx(O.Fragment,{children:O.cloneElement(t,m)})}"production"!==process.env.NODE_ENV&&(Dl.propTypes={children:Rl.isRequired,disableReactTree:wl.bool,mouseEvent:wl.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:wl.func.isRequired,touchEvent:wl.oneOf(["onTouchEnd","onTouchStart",!1])}),"production"!==process.env.NODE_ENV&&(Dl.propTypes=function(e){return"production"===process.env.NODE_ENV?e:{...e,[Sl]: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}}}(Dl.propTypes));const Yl="base";function zl(e,t){const n=Al[t];return n?`${Yl}--${n}`:function(e,t){return`${Yl}-${e}-${t}`}(e,t)}const ql="Snackbar";function Xl(e){return zl(ql,e)}!function(e,t){const n={};t.forEach((t=>{n[t]=zl(e,t)}))}(ql,["root"]);const Gl={disableDefaultClasses:!1},_l=O.createContext(Gl);"production"!==process.env.NODE_ENV&&(_l.displayName="ClassNameConfiguratorContext");const Jl=()=>function(e,t,n){const o={};for(const i in e){const r=e[i];let a="";for(let e=0;e<r.length;e+=1){const o=r[e];o&&(a+=t(o)+" ",n&&n[o]&&(a+=n[o]+" "))}o[i]=a}return o}({root:["root"]},function(e){const{disableDefaultClasses:t}=O.useContext(_l);return n=>t?"":e(n)}(Xl)),Ql=O.forwardRef((function(e,t){const{autoHideDuration:n=null,children:o,disableWindowBlurListener:i=!1,exited:r=!0,onBlur:a,onClose:l,onFocus:s,onMouseEnter:d,onMouseLeave:c,open:u,resumeHideDuration:p,slotProps:h={},slots:m={},...f}=e,x=Jl(),{getRootProps:g,onClickAway:y}=function(e={}){const{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:o,open:i,resumeHideDuration:r}=e,a=Vl();O.useEffect((()=>{if(i)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)};function e(e){e.defaultPrevented||"Escape"===e.key&&o?.(e,"escapeKeyDown")}}),[i,o]);const l=Ml(((e,t)=>{o?.(e,t)})),s=Ml((e=>{o&&null!=e&&a.start(e,(()=>{l(null,"timeout")}))}));O.useEffect((()=>(i&&s(t),a.clear)),[i,t,s,a]);const d=a.clear,c=O.useCallback((()=>{null!=t&&s(null!=r?r:.5*t)}),[t,r,s]),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 O.useEffect((()=>{if(!n&&i)return window.addEventListener("focus",c),window.addEventListener("blur",d),()=>{window.removeEventListener("focus",c),window.removeEventListener("blur",d)}}),[n,i,c,d]),{getRootProps:(t={})=>{const n={...Zl(e),...Zl(t)};return{role:"presentation",...t,...n,onBlur:(o=n,e=>{const t=o.onBlur;t?.(e),c()}),onFocus:u(n),onMouseEnter:p(n),onMouseLeave:h(n)};var o},onClickAway:e=>{o?.(e,"clickaway")}}}({...e,autoHideDuration:n,disableWindowBlurListener:i,onClose:l,open:u,resumeHideDuration:p}),v=e,b=m.root||"div",j=Ul({elementType:b,getSlotProps:g,externalForwardedProps:f,externalSlotProps:h.root,additionalProps:{ref:t},ownerState:v,className:x.root}),C=Ul({elementType:Dl,externalSlotProps:h.clickAwayListener,additionalProps:{onClickAway:y},ownerState:v});return delete C.ownerState,!u&&r?null:G.jsx(Dl,{...C,children:G.jsx(b,{...j,children:o})})}));function Kl({size:e,color:t,time:n,strokeWidth:r=2,sx:a}){const[l,s]=i.useState("0 1069"),d=e/2,c=d-1;return i.useEffect((()=>{s(2*Math.PI*c+" 0")}),[]),G.jsx(o.Box,{width:e,height:e,component:"svg",sx:Object.assign({position:"absolute",top:`-${r}`,left:`-${r}`,transform:"rotate(-90deg)"},a),children:G.jsx(o.Box,{component:"circle",cx:d,cy:d,r:c,strokeWidth:r,stroke:t,fill:"none",strokeDasharray:l,sx:{transition:`stroke-dasharray ${n}`}})})}"production"!==process.env.NODE_ENV&&(Ql.propTypes={autoHideDuration:wl.number,children:wl.node,disableWindowBlurListener:wl.bool,exited:wl.bool,onClose:wl.func,open:wl.bool,resumeHideDuration:wl.number,slotProps:wl.shape({clickAwayListener:wl.oneOfType([wl.func,wl.shape({children:wl.element.isRequired,disableReactTree:wl.bool,mouseEvent:wl.oneOf(["onClick","onMouseDown","onMouseUp","onPointerDown","onPointerUp",!1]),onClickAway:wl.func,touchEvent:wl.oneOf(["onTouchEnd","onTouchStart",!1])})]),root:wl.oneOfType([wl.func,wl.object])}),slots:wl.shape({root:wl.elementType})});var $l=i.memo(Kl);const es=f.create((e=>({notify:null,toast:t=>{e({notify:t})},close:()=>{e({notify:null})}}))),ts={entering:"translateX(0)",entered:"translateX(0)",exiting:"translateX(500px)",exited:"translateX(500px)",unmounted:"translateX(500px)"};function ns(){const e=o.useTheme(),{notify:t,close:n}=es(),[r,a]=i.useState(!0),l=i.useRef(null),s=null==t?void 0:t.timeout,d=!!t;let c=G.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 36 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18",r:"16.5",stroke:"#2FBA90",strokeWidth:"3"}),G.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=G.jsxs("svg",{width:"36",height:"37",viewBox:"0 0 36 37",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.jsx("circle",{cx:"18",cy:"18.5",r:"16.5",stroke:"#FF6187",strokeWidth:"3"}),G.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=G.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[G.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"}),G.jsx("path",{d:"M15.1664 7.58398H12.8331V16.9173H15.1664V7.58398Z",fill:"#B15600"}),G.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 G.jsx(o.Box,{component:Ql,open:d,autoHideDuration:s,onClose:(e,t)=>{"clickaway"!==t&&n()},exited:r,sx:{position:"fixed",top:20,left:20,right:20,zIndex:1,[e.breakpoints.up("tablet")]:{left:"auto"}},children:G.jsx(C.Transition,{timeout:{enter:400,exit:400},in:d,appear:!0,unmountOnExit:!0,onEnter:()=>{a(!1)},onExited:()=>{a(!0)},nodeRef:l,children:i=>G.jsxs(o.Box,{ref:l,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:ts[i],transition:"transform 300ms ease",[e.breakpoints.up("tablet")]:{p:20,width:"auto",maxWidth:328}},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{sx:{mt:7,"& > svg":{width:28,height:28},[e.breakpoints.up("tablet")]:{"& > svg":{width:36,height:36}}},children:t?c:""}),G.jsxs(o.Box,{sx:{ml:20},children:[G.jsx(o.Box,{sx:{typography:"caption"},children:null==t?void 0:t.message}),(null==t?void 0:t.link)?G.jsxs(o.Box,{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,G.jsx(o.Box,{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:G.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)?G.jsx(o.Box,{sx:{mt:4,typography:"body2",color:"text.secondary"},children:t.content}):""]})]}),G.jsxs(o.Box,{sx:{position:"relative",top:10,ml:12,display:"flex",alignItems:"center",justifyContent:"center",width:24,height:24,borderRadius:12,borderStyle:"solid",borderWidth:s?"2.4px":0,borderColor:e.palette.border.main,backgroundColor:s?"transparent":e.palette.background.paperDarkContrast,cursor:"pointer",boxSizing:"border-box",[e.breakpoints.up("tablet")]:{ml:28}},onClick:n,children:[s?G.jsx($l,{size:24,strokeWidth:"2.4px",time:`${s}ms`,color:e.palette.text.disabled}):"",G.jsx(o.Box,{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:G.jsx("g",{children:G.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 os;function is(){return is=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},is.apply(null,arguments)}const rs=e=>O.createElement("svg",is({width:"33px",height:"33px",viewBox:"0 0 33 33",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),os||(os=O.createElement("g",{stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},O.createElement("g",{transform:"translate(-186.000000, -375.000000)",stroke:"currentColor",strokeWidth:4},O.createElement("g",{transform:"translate(18.000000, 291.000000)"},O.createElement("g",{transform:"translate(40.000000, 83.000000)"},O.createElement("path",{d:"M159,32 C159,15.9837423 146.016258,3 130,3"}))))))),as=300;function ls({open:e,onClose:t,afterClose:n,title:i,rightSlot:r,canBack:a=!0,children:l,height:s,testId:d}){return G.jsxs(o.Box,{sx:{position:"absolute",top:e?0:"100%",transition:`all ${as}ms`,zIndex:20,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",backgroundColor:"background.paper",borderRadius:16,height:s},"data-testid":d,"data-active":e?"1":"0",children:[i?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:i}),r,!r&&a&&G.jsx(o.Box,{component:A.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{t&&t(),setTimeout((()=>n&&n()),as)}})]}):"",e?l:""]})}function ss({open:e,onClose:t,afterClose:n,title:i,rightSlot:r,canBack:a=!0,children:l,height:s,testId:d}){return G.jsx(o.Modal,{open:e,onClose:t,"data-testid":d,"data-active":e?"1":"0",children:G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",height:s},children:[i?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20},children:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",typography:"caption"},children:i}),r,!r&&a&&G.jsx(o.Box,{component:A.Error,sx:{color:"text.secondary",cursor:"pointer"},onClick:()=>{t&&t(),setTimeout((()=>n&&n()),as)}})]}):"",e?l:""]})})}function ds(e){var{scope:t,modal:n}=e,o=Oo(e,["scope","modal"]);const{widgetRef:i,DialogComponent:r}=Fo();if(r)return G.jsx(r,{scope:t,...o});const a=n?ss:ls;return(null==i?void 0:i.current)&&!t?w.createPortal(G.jsx(a,{...o}),i.current):G.jsx(a,{...o})}const cs=6;function us({showingDone:e,errorMessage:t}){var n;const i=o.useTheme();return t?G.jsx(o.Box,{component:A.ErrorWarn,sx:{width:64,height:64,color:"error.main"}}):e?G.jsx(o.Box,{component:A.DoneBorder,sx:{width:64,height:64,color:"success.main"}}):G.jsx(o.Box,{sx:{mx:"auto",border:`${cs}px solid ${null===(n=i.palette)||void 0===n?void 0:n.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:G.jsx(o.Box,{component:rs,sx:{position:"absolute",top:`-${cs}px`,right:`-${cs}px`,color:"primary.main"}})})}function ps({showingDone:e,showing:n}){return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[G.jsx(o.Box,{sx:{mt:60},children:e?t.i18n._({id:"4xbbt/",message:"{0} confirmed",values:{0:null==n?void 0:n.brief}}):t.i18n._({id:"/nzjSF",message:"{0} pending",values:{0:null==n?void 0:n.brief}})}),(null==n?void 0:n.subtitle)?G.jsx(o.Box,{sx:{mt:20,typography:"body2"},children:null==n?void 0:n.subtitle}):""]})}function hs({isStarted:t,isEnded:n,tx:r}){const[a,l]=i.useState(0),{chainId:s}=Zo(),d=i.useMemo((()=>`https://${yo[s||1]}/tx/${r}`),[r,s]),c=i.useMemo((()=>{const e=Math.floor(a/60),t=a%60;return e?`${e}m ${t}s`:`${t}s`}),[a]),u=i.useRef();return i.useEffect((()=>(t&&(l(0),window.clearInterval(u.current),u.current=window.setInterval((()=>{l((e=>e+1))}),1e3)),()=>{window.clearInterval(u.current)})),[t]),i.useEffect((()=>{n&&window.clearInterval(u.current)}),[n]),G.jsxs(o.Box,{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:[G.jsxs(o.Box,{children:[G.jsx(e.Trans,{id:"+Jkdiu",message:"Transaction Time:"}),c]}),G.jsxs(o.HoverOpacity,{sx:{display:"flex",alignItems:"center",cursor:"pointer"},component:"a",href:d,target:"_blank",rel:"noopener noreferrer",children:[G.jsx(e.Trans,{id:"S3piC2",message:"Tx"}),G.jsx(o.Box,{component:A.ArrowTopRightBorder,sx:{width:16,height:16,ml:6}})]})]})}function ms(t){var{children:n,executionStatus:i}=t;const r=Ti(Oo(t,["children","executionStatus"])),{ctxVal:a,showing:s,closeShowing:d,showingDone:c,errorMessage:u,transactionTx:p}=Object.assign(Object.assign({},r),i),h=l.useDispatch(),m=Fo((e=>e.noSubmissionDialog));return G.jsxs(Ri.Provider,{value:a,children:[n,G.jsx(ds,{open:!!s&&!m,onClose:d,id:"submission",children:G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-between",px:20,pb:20,flex:1,overflowY:"auto"},children:[G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{textAlign:"center",pt:60},children:G.jsx(us,{showingDone:c,errorMessage:u})}),u?G.jsxs(o.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(o.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(o.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:u})]}):G.jsxs(G.Fragment,{children:[G.jsx(ps,{showingDone:c,showing:s}),G.jsx(hs,{isStarted:!!s,isEnded:c,tx:p})]})]}),G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:()=>{h(Yo(Xo.Initial)),d()},sx:{mt:20},children:u?G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"}):G.jsx(e.Trans,{id:"yz7wBu",message:"Close"})})]})})]})}const fs="dodo-widget-container";function xs(e){return e.noLangProvider?G.jsx(G.Fragment,{children:e.children}):G.jsx(Ja,{locale:e.locale,children:G.jsx(ms,{...e,children:e.children})})}function gs(e){!function({tokenList:e,popularTokenList:t}){const n=l.useDispatch();i.useEffect((()=>{(()=>{Wo(this,void 0,void 0,(function*(){let o=[];o=a.isArray(e)?e:a.unionBy(t,pr,(e=>e.address.toLowerCase()+e.chainId+e.side)),n(hr(o))}))})()}),[e,n,t]),i.useEffect((()=>{n(mr(null!=t?t:[]))}),[t,n])}(e),Ci();const t=e.width||375,n=e.height||494,{widgetRef:r}=Fo();return e.noUI?G.jsx(xs,{...e,children:e.children}):G.jsx(xs,{...e,children:G.jsx(o.Box,{sx:{width:t,height:n,overflow:"hidden",position:"relative",display:"flex",flexDirection:"column",minWidth:335,minHeight:494,borderRadius:16,backgroundColor:"background.paper"},className:fs,ref:r,children:e.children})})}function ys(e){var t,n;const o=i.useRef(null);return G.jsx(l.Provider,{store:Di,children:G.jsx(Ao,{...Object.assign(Object.assign({},e),{widgetRef:null!==(t=e.widgetRef)&&void 0!==t?t:o,apiDomain:null!==(n=e.apiDomain)&&void 0!==n?n:"dodoex.io"}),children:G.jsx(Ka,{children:G.jsx(Na,{children:G.jsx(gs,{...e})})})})})}function vs(e){var{sx:t}=e,n=Oo(e,["sx"]);const{width:r}=Fo(),a=i.useMemo((()=>{let e="";return"number"==typeof r?e=`${r}px`:r&&(e=r),e?`calc(${e} - 40px)`:"auto"}),[r]);return G.jsx(o.QuestionTooltip,{container:document.querySelector(`.${fs}`),maxWidth:a,sx:Object.assign({cursor:"help"},t),...n})}function bs(t){var n,{chainId:r,includeButton:a}=t,l=Oo(t,["chainId","includeButton"]);const{account:s,chainId:d}=Zo(),{onConnectWalletClick:c}=Fo(),[u,p]=i.useState(!1),{setVisible:h}=j.useWalletModal();return!s||u||void 0===d||r&&r!==d?G.jsx(G.Fragment,{children:G.jsx(o.Button,{...l,isLoading:u,onClick:()=>Wo(this,void 0,void 0,(function*(){if(c){p(!0);const e=yield c();if(p(!1),e)return}h(!0)})),children:u?G.jsx(e.Trans,{id:"J28zul",message:"Connecting..."}):G.jsx(e.Trans,{id:"r7ScnQ",message:"Connect to a wallet"})})}):a?G.jsx(G.Fragment,{children:null!==(n=l.children)&&void 0!==n?n:null}):G.jsx(o.Button,{...l})}function js({needSwitchChain:e}){return G.jsx(G.Fragment,{children:G.jsx(bs,{size:o.Button.Size.middle,fullWidth:!0,"data-testid":Io,chainId:e})})}function Cs({open:t,execute:n,onClose:a,toToken:s,fromToken:d,fromAmount:c,toAmount:u,priceImpact:p,clearFromAmt:h,clearToAmt:m,baseFeeAmount:f,curToFiatPrice:x,curFromFiatPrice:g,additionalFeeAmount:y,loading:v,slippage:b}){var j,C;const w=o.useTheme(),k=l.useDispatch(),T=l.useSelector(Yi),R=i.useMemo((()=>!!p&&new r(p).gt(wo)),[p]),[S,I]=i.useState(!1),[B,M]=i.useState(!1);return i.useEffect((()=>{T!==Xo.Pending&&a(),T===Xo.TxSuccess&&(m(),h())}),[T]),i.useEffect((()=>{I(!1)}),[x]),G.jsx(ds,{open:t,onClose:()=>{k(Yo(Xo.Initial)),a()},id:"swap-summary",title:G.jsx(e.Trans,{id:"QR4/RH",message:"Swap summary"}),children:G.jsxs(o.Box,{sx:{margin:20,display:"flex",height:"100%",flexDirection:"column",borderTop:`1px solid ${w.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{py:20,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexDirection:"column",borderBottom:`1px solid ${w.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[G.jsx(Wa,{width:16,height:16,url:null==d?void 0:d.logoURI,address:null!==(j=null==d?void 0:d.address)&&void 0!==j?j:"",marginRight:6}),G.jsx(o.Box,{children:`${Ko({input:c,decimals:null==d?void 0:d.decimals})} ${null==d?void 0:d.symbol}`})]}),null!==g&&G.jsx(o.Box,{sx:{mt:4,typography:"h6",color:w.palette.text.secondary},children:g?`$${Qo({input:g,showDecimals:1})}`:"-"})]}),G.jsx(o.Box,{sx:{width:16,mx:16},component:A.DoubleRight}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex"},children:[G.jsx(Wa,{width:16,height:16,marginRight:6,url:null==s?void 0:s.logoURI,address:null!==(C=null==s?void 0:s.address)&&void 0!==C?C:""}),G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:`${Ko({input:u,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`})]}),null!==g&&G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},sx:{typography:"h6",mt:4,color:w.palette.text.secondary},children:x?`$${Qo({input:x,showDecimals:1})}(${p}%)`:"-"})]})]}),G.jsxs(o.Box,{sx:{mt:12,display:"flex",alignItems:"center",typography:"h6"},children:["1",null==d?void 0:d.symbol," = ",G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:Ko({input:new r(u).dividedBy(new r(c)),decimals:null==s?void 0:s.decimals})})," ",null==s?void 0:s.symbol]})]}),G.jsxs(o.Box,{sx:{py:15,typography:"body2",borderBottom:`1px solid ${w.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",color:w.palette.text.secondary},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{sx:{width:16,mr:7},component:A.DetailBorder}),G.jsx(e.Trans,{id:"XeovX3",message:"Swap Detail"})]}),G.jsx(o.Box,{component:o.ButtonBase,children:G.jsx(o.Box,{onClick:()=>M(!B),sx:{width:10,color:"text.secondary",transform:B?"rotateX(0deg)":"rotateX(180deg)"},component:A.CaretUp})})]}),G.jsxs(o.Box,{sx:{mt:16,display:B?"initial":"none"},children:[G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"93m8jT",message:"Basic Fee"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"8Z29ZO",message:"Estimated service provider fees"}),ml:5})]}),G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:f?`${Ko({input:f,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"J39pAJ",message:"Additional Fee"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"ZXvy7b",message:"Additional routing fees set by the Widget user"}),ml:5})]}),G.jsx(o.LoadingSkeleton,{loading:v,loadingProps:{width:30},children:y?`${Ko({input:y,decimals:null==s?void 0:s.decimals})} ${null==s?void 0:s.symbol}`:"0"})]}),!!p&&G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"T+qgFw",message:"Price Impact"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),ml:5})]}),G.jsx(o.Box,{children:`${p}%`})]}),G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"CMHmbm",message:"Slippage"}),G.jsx(vs,{title:G.jsx(e.Trans,{id:"GAypnX",message:"High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:5})]}),G.jsxs(o.Box,{children:[b,"%"]})]})]})]}),G.jsx(o.Box,{sx:{flex:1}}),R&&G.jsxs(o.Box,{sx:{mb:14,display:"flex",cursor:"pointer",justifyContent:"center",alignItems:"center",typography:"h6"},onClick:()=>I(!S),children:[G.jsx(o.Box,{sx:{mr:4,width:18,height:18,alignItems:"center"},children:S?G.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"secondary.main"},children:G.jsx(o.Box,{component:A.Done,sx:{width:14,color:"#1a1a1b"}})}):G.jsx(o.Box,{sx:{width:"100%",height:"100%",borderRadius:4,border:`1px solid ${w.palette.text.secondary}`}})}),G.jsx(o.Box,{children:G.jsx(e.Trans,{components:{0:G.jsx(o.Box,{component:"span",sx:{color:"error.main"}})},values:{priceImpact:p},id:"Price impact reaches <0>{priceImpact}</0>%, accept the quote"})})]}),G.jsx(o.Button,{isLoading:T==Xo.Pending,disabled:R&&!S,fullWidth:!0,onClick:()=>{n(),k(Yo(Xo.Pending))},children:T==Xo.Pending?G.jsx(e.Trans,{id:"P+K/3O",message:"Confirming"}):G.jsx(e.Trans,{id:"lQ6r7x",message:"Confirm swap"})})]})})}var ws;function ks({fromToken:t,toToken:n}){const a=o.useTheme(),{onlySolana:l}=Fo();or();const{customSlippage:s,customSlippageNum:d,handleSlippageChange:c,forecastSlippage:u,forecastSlippageQuery:p,recommendSlippage:h}=ar({fromToken:t,toToken:n}),[m,f]=i.useState(!1),[x,g]=i.useState();!x&&t&&n&&g(s?ws.custom:ws.recommend);const y=x===ws.custom;return i.useRef(null),i.useMemo((()=>x===ws.custom?d?new r(d).div(100).toNumber():void 0:new r(h).div(100).toNumber()),[x,h,d]),i.useCallback((e=>{y||g(ws.custom),c({slippage:new r(e).times(100).toString(),disabled:!1,deleted:!1,recommend:String(h)})}),[y,h,c]),l?G.jsxs(o.Box,{sx:{pt:20,borderTop:`1px solid ${a.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{mb:16,display:"flex",alignItems:"center"},children:[G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"}),G.jsx(o.QuestionTooltip,{title:G.jsx(e.Trans,{id:"KAmxpM",message:"Attention: High slippage tolerance will increase the success rate of transaction, but might not get the best quote."}),ml:7})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column"},children:[G.jsx(o.Input,{placeholder:String(h),fullWidth:!0,sx:{height:36,"& input":{boxSizing:"border-box","&::placeholder":{color:"custom.input.placeholder",opacity:1}}},inputMode:"decimal",suffix:G.jsx(o.Box,{sx:{color:"text.disabled"},children:"%"}),value:s||"",onChange:e=>{const t=e.target.value;c({slippage:t,disabled:!1,recommend:String(h)})},onBlur:()=>{setTimeout((()=>{if(f(!1),!d)return void g(ws.recommend);const e=!d||d<0;e&&s&&c({slippage:s,disabled:e,deleted:e,recommend:String(h)})}),10)}}),Number(s)>=To&&G.jsx(o.Box,{sx:{typography:"h6",mt:6,color:"error.main"},children:G.jsx(e.Trans,{id:"Zm56FI",message:"Maximum slippage do not exceed 50%"})})]})]}):null}function Ts({checked:t,onChange:n,sx:i,disabled:r}){const a=o.useTheme();let l=a.palette.background.paper;return t&&(l=a.palette.secondary.main),G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",position:"relative",borderRadius:8,backgroundColor:a.palette.background.input,opacity:r?.5:1},i),component:o.ButtonBase,disabled:r,onClick:()=>{r||n(!t)},children:[G.jsx(o.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"az8lvo",message:"Off"})}),G.jsx(o.Box,{sx:{typography:"body2",fontWeight:600,pl:12,pr:13,pt:8,pb:9,width:"50%",zIndex:1,color:t?a.palette.secondary.contrastText:a.palette.text.primary,whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"Z5HWHd",message:"On"})}),G.jsx(o.Box,{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 Rs({show:t,onClick:n}){const i=o.useTheme();return G.jsxs(o.HoverOpacity,{weak:!0,sx:{display:t?"flex":"none",alignItems:"center",position:"absolute",bottom:28,left:"50%",transform:"translateX(-50%)",p:i.spacing(8,20),fontWeight:600,borderRadius:20,border:`solid 1px ${i.palette.border.main}`,backgroundColor:"background.paperContrast",boxShadow:`0px 8px 16px 0px ${o.alpha("light"===i.palette.mode?"#FFF":"#000",.1)}`,cursor:"pointer",whiteSpace:"nowrap",gap:4},onClick:n,children:[G.jsx(e.Trans,{id:"F8yRdq",message:"More trade settings"}),G.jsx(o.Box,{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:G.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 Ss({open:t,onClose:n,fromToken:r,toToken:l}){const s=o.useTheme(),{ddl:d,disableIndirectRouting:c}=or(),{onlySolana:u}=Fo(),p=i.useRef(null),[h,m]=i.useState(!1);return i.useEffect((()=>{const e=p.current,t=new ResizeObserver((()=>{e&&m(e.scrollHeight!==e.offsetHeight)})),n=a.throttle((()=>{if(!e)return;const t=e.scrollTop+e.clientHeight<e.scrollHeight-2;m(t)}),50);return e&&(m(e.scrollHeight!==e.clientHeight),t.observe(e),e.addEventListener("scroll",n)),()=>{e&&(t.unobserve(e),e.removeEventListener("scroll",n))}}),[null==p?void 0:p.current]),G.jsx(ds,{open:t,onClose:n,id:"swap-settings",title:G.jsx(e.Trans,{id:"Tz0i8g",message:"Settings"}),children:G.jsxs(o.Box,{sx:{px:20,pb:34,overflowY:"auto"},ref:p,children:[G.jsx(ks,{fromToken:r,toToken:l}),!u&&G.jsxs(o.Box,{sx:{mt:24,pt:14,borderTop:`solid 1px ${s.palette.border.main}`},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600},children:[G.jsx(e.Trans,{id:"zSMRJ/",message:"Transaction Deadline"}),G.jsx(vs,{title:G.jsx(e.Trans,{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})]}),G.jsxs(o.Box,{sx:{mt:16,display:"flex",alignItems:"center",gap:8,typography:"body2"},children:[G.jsx(o.Input,{sx:{width:80,height:34,lineHeight:1,typography:"body2","& input":{px:16,py:6}},placeholder:String(Ro),value:d,onChange:e=>{or.setState({ddl:e.target.value})}}),G.jsx(e.Trans,{id:"H9HlDe",message:"minutes"})]})]}),!u&&G.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:24,pt:14,borderTop:`solid 1px ${s.palette.border.main}`},children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(o.Box,{sx:{fontWeight:600},children:[G.jsx(e.Trans,{id:"MXQodB",message:"Disable Indirect Routing"}),G.jsx(vs,{title:G.jsx(e.Trans,{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})]}),G.jsx(Ts,{checked:c,onChange:e=>{or.setState({disableIndirectRouting:e})}})]})}),G.jsx(Rs,{show:h,onClick:()=>{var e,t;null===(e=p.current)||void 0===e||e.scrollTo({top:null===(t=p.current)||void 0===t?void 0:t.scrollHeight,behavior:"smooth"})}})]})})}function Is({onClick:e,disabled:t,plus:n}){const i=o.useTheme(),r=t||n||!e;return G.jsx(o.Box,{sx:{width:"100%",position:"relative"},children:G.jsx(o.Box,{component:o.ButtonBase,sx:Object.assign({width:36,height:36,borderRadius:"50%",backgroundColor:i.palette.background.input,border:`4px solid ${i.palette.background.paper}`,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:28,height:28,border:"solid 1px",borderColor:"text.primary"}}}),disabled:r,onClick:()=>{r||e&&e()},children:n?G.jsx(o.Box,{component:A.Plus,sx:{width:18,height:18}}):G.jsx(o.Box,{component:A.ArrowBack,sx:{width:18,height:18}})})})}!function(e){e.recommend="recommend",e.custom="custom"}(ws||(ws={}));const Bs=()=>{const{requests:e,updateText:t}=Si(),n=i.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var o,i;if((n===No.Running||n===No.Success)&&(null===(o=e.metadata)||void 0===o?void 0:o.logBalance)&&(!e.doneTime||Math.ceil(Date.now()/1e3)-e.doneTime<300)){const n=null===(i=e.metadata)||void 0===i?void 0:i.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),o=i.useMemo((()=>{let t={};return null==e||e.forEach((([e,n])=>{var o,i;if(n===No.Success&&(null===(o=e.metadata)||void 0===o?void 0:o.logBalance)&&e.doneTime&&Math.ceil(Date.now()/1e3)-e.doneTime<300){const n=null===(i=e.metadata)||void 0===i?void 0:i.logBalance;t=Object.assign(Object.assign({},t),n)}})),t}),[e&&Array.from(e)]),a=i.useCallback(((e,n,o)=>{const i=e[n];if(!i)return!1;return!!(r.isBigNumber(o)?o:new r(o)).isEqualTo(i)||(t((e=>{var t;const o=Object.assign({},e.metadata);return(null===(t=null==o?void 0:o.logBalance)||void 0===t?void 0:t[n])?(delete o.logBalance[n],Object.keys(o.logBalance).length||delete o.logBalance,{brief:e.brief,spec:e.spec,metadata:o}):null})),!1)}),[t]),l=i.useCallback(((e,t)=>a(n,e,t)),[n,a]),s=i.useCallback(((e,t)=>a(o,e,t)),[o,a]);return{balanceData:n,balanceDataDone:o,isTokenLoading:l,isTokenLoadingDone:s}};function Ms({onClick:t,balance:n,decimals:i,address:r,showMaxBtn:a,canClickBalance:l,loading:s,balanceText:d}){const{palette:c}=o.useTheme(),u=l&&(null==n?void 0:n.gt(0))&&t;return G.jsxs(o.Box,{sx:Object.assign({typography:"body2",alignItems:"center",color:c.text.secondary,wordBreak:"break-word",textAlign:"right"},u?{"&:hover":{color:c.text.primary,cursor:"pointer"}}:{}),onClick:u?()=>t(n?n.toString():""):void 0,children:[null!=d?d:G.jsx(e.Trans,{id:"0QDjxt",message:"Balance:"})," ",s?G.jsx(o.RotatingIcon,{sx:{position:"relative",top:-2,verticalAlign:"middle"}}):G.jsxs(G.Fragment,{children:[r?Ko({input:n,decimals:Math.min(i||4,4)}):"-",a&&n&&n.gt(0)&&t&&G.jsx(o.Box,{component:o.ButtonBase,sx:{ml:6,color:(null==n?void 0:n.gt(0))?c.primary.main:c.text.disabled,cursor:r?"pointer":"unset",typography:"body2"},onClick:()=>t&&t(n?n.toString():""),children:G.jsx(e.Trans,{id:"CK1KXz",message:"Max"})})]})]})}const Es=i.forwardRef((function({readOnly:e,sx:t,value:n,decimals:r,onChange:a,suffix:l,suffixGap:s=0,withClear:d,onFocus:c,placeholder:u,readonlyShowSuffix:p,typography:h},m){const f=o.useTheme(),x=i.useMemo((()=>l||(d&&n&&a?G.jsx(o.Box,{component:o.ButtonBase,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:()=>{a&&a("")},children:G.jsx(o.Box,{component:A.Error,sx:{width:12}})}):void 0)),[a,l,f.palette.text.primary,n,d]);return G.jsx(o.Input,{fullWidth:!0,value:n,readOnly:e,placeholder:u||"0.00",onFocus:c,onChange:e=>{const t=e.target.value,n=0===t.length?"":ti(t,r);a&&a(n)},"data-testid":"number-input-wrapper",suffix:(!e||p)&&x,suffixGap:s,ref:m,sx:Object.assign({border:"none","& input":{fontSize:24,typography:h,border:"none",outline:"none",padding:0,color:"text.primary","&::placeholder":{fontSize:24,typography:h,color:"text.disabled"}}},t)})}));function Ls(){const e=o.useTheme(),t=Fo((e=>e.width)),[n,r]=i.useState(null!=t?t:"undefined"==typeof window?375:document.body.clientWidth);i.useEffect((()=>{const e=()=>{r("undefined"==typeof window?375:document.body.clientWidth)};return"number"!=typeof t?(e(),window.addEventListener("resize",e)):r(t),()=>{window.removeEventListener("resize",e)}}),[t]);return{isMobile:i.useMemo((()=>"number"==typeof n&&n<e.breakpoints.values.tablet),[n,e.breakpoints.values]),isTablet:i.useMemo((()=>"number"==typeof n&&n<e.breakpoints.values.tablet),[n,e.breakpoints.values]),minDevice:i.useCallback((e=>"number"==typeof n&&n>e),[n]),maxDevice:i.useCallback((e=>"number"==typeof n&&n<e),[n])}}const Os=[.25,.5,.75,1];function Ws({value:e,onChange:t,sx:n}){const i=o.useTheme(),r="light"===i.palette.mode,{isMobile:a}=Ls();return G.jsx(o.Box,{sx:Object.assign({display:"grid",gap:a?10:14,gridTemplateColumns:`repeat(${Os.length}, 1fr)`},n),children:Os.map((n=>{const a=n===e;return G.jsxs(o.ButtonBase,{disabled:!t,sx:{typography:"h6",borderRadius:4,padding:i.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:disabled":{color:"text.disabled"},"&:not(:disabled)&:hover":{color:i.palette.text.primary,backgroundColor:o.alpha(i.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:r?i.palette.primary.main:o.alpha(i.palette.text.primary,.4)}},onClick:()=>{!a&&t&&t(n)},className:a?"selected":void 0,children:[100*n,"%"]},n)}))})}function Vs({token:t,onClick:n,showChainLogo:i,readonly:r,showChainName:a}){var l,s;const d=o.useTheme(),c=(null==t?void 0:t.chainId)?La.get(t.chainId):null,u=a&&!!c;return G.jsxs(o.Box,{component:o.ButtonBase,sx:{display:"flex",alignItems:"center",gap:8,color:d.palette.text.primary,typography:u?"body2":"body1",fontWeight:600,"&:focus-visible":{opacity:.5}},onClick:e=>{r||n&&n(e)},"data-testid":Bo,children:[!!(null==t?void 0:t.address)&&G.jsx(Wa,{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:!i,width:30,height:30,chainSize:16,logoOffset:10,marginRight:0}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[(null==t?void 0:t.address)?G.jsx(G.Fragment,{children:G.jsx(o.Box,{children:null!==(s=null==t?void 0:t.symbol)&&void 0!==s?s:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!r&&G.jsx("svg",{width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9 11.75L12 7.25H6L9 11.75Z",fill:"currentColor"})})]}),!!u&&G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[c.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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 As({token:e,disabled:t,style:n,balance:i,onClick:r}){const a=o.useTheme(),{account:l}=Zo(),s=i?Qo({input:i}):"";return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2",px:6,py:5,borderRadius:8,cursor:t?"auto":"pointer",opacity:t?.5:1,"&:hover":{backgroundColor:"hover.default"}},style:n,onClick:()=>{t||r()},"data-testid":Lo,children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{token:e}),G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{fontWeight:600,textAlign:"left"},children:e.symbol}),l&&G.jsx(o.Box,{sx:{mt:4,textAlign:"left"},children:(null==i?void 0:i.gte(0))?s:G.jsx(o.Box,{component:A.Loading,width:18,sx:{"& path":{fill:a.palette.text.disabled},animation:"loadingRotate 1.1s infinite linear","@keyframes loadingRotate":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(359deg)"}}}})})]})]}),G.jsx(o.Box,{sx:{color:"text.secondary",textAlign:"right"},children:e.name})]})}function Fs({chain:t,active:n,onClick:i}){return G.jsx(o.Tooltip,{title:t.name,placement:"top",onlyHover:!0,children:G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",p:8,borderRadius:8,cursor:"pointer"},n?{backgroundColor:"secondary.main",color:"secondary.contrastText"}:{border:"1px solid",borderColor:"border.main","&:hover":{backgroundColor:"hover.default"}}),onClick:i,children:[G.jsx(o.Box,{component:t.logo,sx:{width:24,height:24}}),n?G.jsxs(o.Box,{sx:{ml:8},children:[G.jsx(e.Trans,{id:"Fdp03t",message:"on"}),` ${t.name}`]}):""]})},t.chainId)}function Ps(e){try{return new u.PublicKey(e),!0}catch(e){return!1}}function Zs(e){if(e.length<=10)return e;try{return new u.PublicKey(e),`${e.slice(0,4)}...${e.slice(-4)}`}catch(t){return`${e.slice(0,6)}...${e.slice(-4)}`}}function Ns(e,t,n="address"){return`https://${yo[e]}${t?`/${n}/${t}`:""}`}function Us(){return G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between"},children:[G.jsx(o.Skeleton,{variant:"circular",width:32,sx:{mt:8}}),G.jsxs(o.Box,{sx:{ml:8,flex:"1 0 auto"},children:[G.jsx(o.Skeleton,{sx:{borderRadius:4},height:24}),G.jsx(o.Skeleton,{sx:{mt:4,borderRadius:4},height:19,width:137})]})]})}function Hs({chainId:e,value:n,onChange:r,occupiedAddrs:a,occupiedChainId:s,hiddenAddrs:c,showAddrs:u,visible:p,side:h,defaultLoadBalance:m,multiple:f,searchPlaceholder:x,searchOtherAddress:g,sx:y}){const{chainList:v,selectChainId:b,setSelectChainId:j}=function(e){const{chainId:t}=Zo(),n=l.useSelector(Gi),{crossChain:o,onlyChainId:r}=Fo(),a=i.useMemo((()=>{const t=new Set;return n.forEach((n=>{n.side&&e&&n.side!==e||t.add(n.chainId)})),t}),[n,e]),s=i.useMemo((()=>{if(!o||r)return[];const e=new Map;let n;return La.forEach(((o,i)=>{if(a.has(o.chainId)){if(o.mainnet){if(t!==o.chainId)return;n=o.mainnet}e.set(i,Object.assign({},o))}})),void 0!==n&&e.delete(n),Array.from(e.values())}),[t,n,o,r]),d=i.useMemo((()=>!s.length||t&&a.has(t)?t:s[0].chainId),[t,a]),[c,u]=i.useState(d);i.useEffect((()=>{void 0===c&&u(d)}),[d]);const p=i.useMemo((()=>null!=c?c:d),[c,d]);return{chainList:s,selectChainId:p,setSelectChainId:u}}(h),{showTokenList:C,filter:w,setFilter:T,onSelectToken:R,popularTokenList:S,tokenInfoMap:I}=br({value:n,onChange:r,occupiedAddrs:a,occupiedChainId:s,hiddenAddrs:c,showAddrs:u,side:h,chainId:null!=e?e:b,visible:p,defaultLoadBalance:m,multiple:f}),B=i.useRef(null),[M,E]=i.useState(0);i.useEffect((()=>{if(p&&n)if(Array.isArray(n)){const[e]=n;e&&e.chainId!==b&&j(e.chainId)}else j(n.chainId)}),[n,p]),i.useEffect((()=>{let e;return p&&(e=window.setTimeout((()=>{B.current&&E(B.current.offsetHeight-16)}),300)),()=>clearTimeout(e)}),[B,p,b]);const L=d.useQuery({queryKey:["token-picker-searchOtherAddress",w],queryFn:()=>g?g(w):null,enabled:Ps(w)&&!!g}),O=i.useCallback((({index:e,style:t})=>{var o;const i=C[e];if(!i)return null;let r=!1;return n&&(r=Array.isArray(n)?n.some((e=>e.address===i.address&&e.chainId===i.chainId)):n.address===i.address&&n.chainId===i.chainId),G.jsx(As,{token:i,disabled:r,style:t,onClick:()=>R(i),balance:null===(o=I.get(`${i.chainId}-${i.address}`))||void 0===o?void 0:o.balance},i.address+i.chainId)}),[C,S,n]);return G.jsxs(o.Box,{sx:Object.assign({display:"flex",flexDirection:"column",px:20,flex:1,overflow:"hidden"},y),children:[G.jsx(o.SearchInput,{fullWidth:!0,height:48,value:w,onChange:e=>T(e.target.value),clearValue:()=>T(""),placeholder:null!=x?x:t.i18n._({id:"72/M0o",message:"Enter the token symbol or address"}),sx:{mb:16}}),void 0===e&&v.length?G.jsx(o.Box,{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:v.map((e=>G.jsx(Fs,{chain:e,active:e.chainId===b,onClick:()=>{j(e.chainId)}},e.chainId)))}):"",G.jsx(o.Box,{sx:{pb:16,flex:1,minHeight:64},ref:B,children:C.length?G.jsx(k.FixedSizeList,{height:M,itemCount:C.length,itemSize:52,width:"100%",className:"token-list",children:O}):G.jsxs(o.Box,{sx:{height:M,overflowY:"auto"},children:[L.isLoading?G.jsx(Us,{}):"",L.data?L.data:""]})})]})}function Ds({open:t,title:n,value:o,onClose:i,occupiedAddrs:r,hiddenAddrs:a,occupiedChainId:l,onTokenChange:s,side:d,defaultLoadBalance:c,multiple:u,searchPlaceholder:p,searchOtherAddress:h,chainId:m,modal:f}){const{height:x}=Fo(),{isMobile:g}=Ls();return G.jsx(ds,{height:f?"80vh":x,open:t,onClose:i,title:null!=n?n:G.jsx(e.Trans,{id:"T0Y2+3",message:"Select a token"}),id:"select-token",testId:Eo,modal:f,children:G.jsx(Hs,{value:o,visible:t,onChange:s,occupiedAddrs:r,occupiedChainId:l,hiddenAddrs:a,side:d,defaultLoadBalance:c,multiple:u,searchPlaceholder:p,searchOtherAddress:h,chainId:m,sx:f?{width:g?"100%":420,borderRadius:16}:void 0})})}function Ys(){return G.jsx(o.Box,{sx:{position:"relative",height:4},children:G.jsx(o.Box,{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:G.jsx(o.Box,{component:A.Plus})})})}function zs({sx:t,inputSx:n,amt:r,token:a,readOnly:l,showMaxBtn:s,canClickBalance:c,onMaxClick:u,fiatPriceTxt:p,occupiedAddrs:h,occupiedChainId:m,onInputFocus:f,onTokenClick:x,onInputChange:g,onTokenChange:y,side:v,showChainLogo:b,showChainName:j,defaultLoadBalance:C,overrideBalance:w,overrideBalanceLoading:k,balanceText:T,showPercentage:R,inputReadonlyTooltip:S,inputTypography:I,chainId:B,hideToken:M,checkLogBalance:E,notTokenPickerModal:L}){var O,W;const{account:V,isSolana:A}=Zo(),F=o.useTheme(),{gotoBuyToken:P}=Fo(),[Z,N]=i.useState(!1),{fetchTokenBalance:U}=yi(),H=d.useQuery({queryKey:["token","getFetchTokenQuery",B,null==V?void 0:V.toLocaleLowerCase(),void 0,null==a?void 0:a.address],queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!a)return;const e=yield U(a.address);return Object.assign(Object.assign({},a),{balance:e.amount,allowance:Jo})})),enabled:!!V&&A&&!!a}),D=null!==(W=null!=w?w:null===(O=H.data)||void 0===O?void 0:O.balance)&&void 0!==W?W:null,{isTokenLoading:Y}=Bs();let z=null!=k?k:H.isLoading;!z&&D&&(E?z=Object.entries(E).some((([e,t])=>Y(e,t))):a&&(z=Y(a.address,D))),vi({tokenList:a?[a]:[],chainId:null==a?void 0:a.chainId});const[q,X]=i.useState(0),_=i.useRef("");i.useEffect((()=>{r!==_.current&&X(0)}),[r]);let J=P&&D&&r&&D.lt(r);const Q=!!g||!!S;return G.jsxs(o.Box,{sx:Object.assign({minHeight:Q?133:"auto",padding:F.spacing(20,20,24),borderRadius:12,overflow:"hidden",display:"flex",flexDirection:"column",justifyContent:"space-between",backgroundColor:F.palette.background.input},t),children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[M?G.jsx(o.Box,{}):G.jsx(Vs,{token:a,showChainLogo:b,showChainName:j,onClick:()=>N(!0),readonly:!y}),G.jsx(Ms,{balance:D,balanceText:T,onClick:l||!u&&!g?void 0:e=>{u?u(e):g&&g(e),0!==q&&1!==q&&(X(1),_.current=e)},showMaxBtn:s,canClickBalance:c,address:null==a?void 0:a.address,decimals:null==a?void 0:a.decimals,loading:z})]}),Q&&(l&&S?G.jsx(o.TooltipToast,{title:S,arrow:!1,children:G.jsx(o.Box,{children:G.jsx(Es,{value:r,readOnly:!0,withClear:!0,sx:Object.assign({mt:12},n)})})}):G.jsx(Es,{value:r,onFocus:f,onChange:g?e=>{g(e),X(0)}:void 0,readOnly:l,withClear:!0,suffix:J?G.jsx(o.Button,{variant:o.Button.Variant.tag,backgroundColor:F.palette.background.paperDarkContrast,sx:{fontSize:12},onClick:e=>{e.stopPropagation(),null==P||P({token:a,account:V})},children:G.jsx(e.Trans,{id:"qiOIiY",message:"Buy"})}):void 0,typography:I,sx:{mt:12}})),!l&&R?G.jsx(Ws,{sx:{mt:16},value:q,onChange:D&&void 0!==(null==a?void 0:a.decimals)?e=>{if(D&&(null==a?void 0:a.decimals))if(X(e),1===e){const e=D.toString();u?u(e):g&&g(e),_.current=e}else if(g){const t=D.multipliedBy(e).dp(a.decimals).toString();g(t),_.current=t}}:void 0}):"",void 0!==p?G.jsx(o.Box,{sx:{mt:R?9:0,typography:"h6",color:F.palette.text.secondary},children:p}):"",G.jsx(Ds,{value:a,open:Z,side:v,chainId:B,occupiedAddrs:h,occupiedChainId:m,defaultLoadBalance:C,onClose:()=>{N(!1),x&&x()},onTokenChange:(e,t)=>{N(!1),setTimeout((()=>{!Array.isArray(e)&&y&&y(e,t)}),as)},modal:!L})]})}function qs({toToken:t,fromToken:n,priceStatus:r,pricePerToToken:a,pricePerFromToken:l}){const[s,d]=i.useState("-"),[c,u]=i.useState(null),[p,h]=i.useState("-"),[m,f]=i.useState(null);i.useEffect((()=>{d(null==n?void 0:n.symbol),h(null==t?void 0:t.symbol),u(a),f(l)}),[n,t,a,l]);const x=i.useCallback((()=>{d(p),h(s),u(m),f(c)}),[s,c,p,m]);return G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:{[Oi.Initial]:"-",[Oi.Loading]:G.jsxs(G.Fragment,{children:[G.jsx(o.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]}),[Oi.Failed]:G.jsxs(G.Fragment,{children:[G.jsx(o.Box,{component:A.Warn,sx:{width:15,mr:5,color:"warning.main"}}),G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})]}),[Oi.Success]:G.jsxs(G.Fragment,{children:[G.jsx(o.Box,{sx:{typography:"body2"},children:`1 ${s} = ${Qo({input:m,showDecimals:4})} ${p}`}),G.jsx(o.Box,{component:o.ButtonBase,sx:{width:18,height:18,ml:6,borderRadius:"50%",backgroundColor:"border.main",display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsx(o.Box,{sx:{width:16,color:"text.secondary"},onClick:x,component:A.Switch})})]})}[r]})}var Xs;exports.PageType=void 0,(Xs=exports.PageType||(exports.PageType={})).Pool="pool",Xs.PoolDetail="poolDetail",Xs.CreatePool="createPool",Xs.ModifyPool="modifyPool",Xs.MiningList="miningList",Xs.MiningDetail="miningDetail",Xs.createPoolAMMV2="createPoolAMMV2",Xs.createPoolAMMV3="createPoolAMMV3";const Gs=f.create(((e,t)=>({page:void 0,historyList:[],push:t=>{e((e=>{var n;const o=[...e.historyList,null!==(n=e.page)&&void 0!==n?n:{type:exports.PageType.Pool}];return{page:t,historyList:o}}))},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 _s({sx:t,onClick:n}){const i=o.useTheme();return G.jsxs(o.HoverOpacity,{onClick:()=>{n?n():Gs.getState().back()},sx:a.merge({display:"inline-flex",alignItems:"center",cursor:"pointer","& > svg":{mr:10}},t),children:[G.jsx(o.Box,{sx:{color:i.palette.text.secondary,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderColor:i.palette.border.main,borderStyle:"solid",borderWidth:1,borderRadius:"50%",backgroundColor:i.palette.background.paper,mr:6},children:G.jsx(A.ArrowBack,{})}),G.jsx(e.Trans,{id:"CKyk7Q",message:"Go back"})]})}function Js({statuses:t,children:n,buttonProps:i}){var r;if(!t.find((e=>e.needShowTokenStatusButton))&&n)return G.jsx(G.Fragment,{children:n});const a=t.find((e=>e.insufficientBalance));if(a)return G.jsx(o.Button,{fullWidth:!0,disabled:!0,...i,children:G.jsx(e.Trans,{id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null===(r=a.token)||void 0===r?void 0:r.symbol}})});const l=t.some((e=>e.isApproving));return G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:t.map(((t,n)=>{var r,a;let s="";return t.isApproving?s=G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):(t.needReset||t.needApprove)&&(s=t.approveTitle),s?G.jsx(o.Button,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance||l,...i,children:s},null!==(a=null===(r=t.token)||void 0===r?void 0:r.symbol)&&void 0!==a?a:n):null}))})}function Qs({token:t,chainId:n,showChainLogo:r,readonly:a,showChainName:l,logoSize:s=24,chainLogoSize:d=12,side:c,occupiedToken:u,defaultLoadBalance:p,notTokenPickerModal:h,border:m,px:f=20,py:x=8,highlightDefault:g,onTokenClick:y,onTokenChange:v}){var b,j;const{onlyChainId:C}=Fo(),w=n||C,k=o.useTheme(),[T,R]=i.useState(!1),S=(null==t?void 0:t.chainId)?La.get(t.chainId):null,I=l&&!!S;return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,sx:Object.assign(Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,color:k.palette.text.primary,typography:I?"body2":"body1",fontWeight:600,px:f,py:x,"&:focus-visible":{opacity:.5}},!!m&&{border:`solid 1px ${k.palette.border.main}`,borderRadius:8,"&:hover":{backgroundColor:k.palette.hover.default}}),!(!g||t)&&{backgroundColor:k.palette.primary.main,color:k.palette.primary.contrastText,"&:hover":{opacity:.8}}),onClick:()=>{a||R(!0)},"data-testid":Mo,children:[!!(null==t?void 0:t.address)&&G.jsx(Wa,{url:null==t?void 0:t.logoURI,address:null!==(b=null==t?void 0:t.address)&&void 0!==b?b:"",chainId:null==t?void 0:t.chainId,noShowChain:!r,width:s,height:s,chainSize:d,logoOffset:10,marginRight:0}),G.jsxs(o.Box,{sx:{flex:1},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(null==t?void 0:t.address)?G.jsx(G.Fragment,{children:G.jsx(o.Box,{children:null!==(j=null==t?void 0:t.symbol)&&void 0!==j?j:"-"})}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"}),!a&&G.jsx(o.Box,{component:"svg",width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",sx:{flexShrink:0},children:G.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"})})]}),!!I&&G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",typography:"h6",color:"text.secondary"},children:[S.name,G.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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"})})]})]})]}),G.jsx(Ds,{value:t,open:T,side:c,chainId:w,occupiedAddrs:u?[u.address]:void 0,occupiedChainId:null==u?void 0:u.chainId,defaultLoadBalance:p,onClose:()=>{R(!1),y&&y()},onTokenChange:(e,t)=>{R(!1),setTimeout((()=>{!Array.isArray(e)&&v&&v(e,t)}),as)},modal:!h})]})}const Ks=i.forwardRef((function(e,t){var{sx:n}=e,i=Oo(e,["sx"]);const{isMobile:r}=Ls(),a=o.useTheme();return G.jsx(o.Box,{className:"widget-module-container",ref:t,sx:Object.assign(Object.assign({flex:1,overflowY:"auto"},r?{padding:0,height:"100%",width:"100%",overflowX:"hidden"}:{padding:a.spacing(28,20,40,40),height:"auto"}),n),...i})})),$s="auto",ed="0.1",td="0.5",nd="0.5";function od(e){const t=i.useRef();return i.useEffect((()=>{t.current=e})),t.current}function id({baseToken:n,quoteToken:o,pairMintAAmount:i,pairMintBAmount:r,slippage:a,isExists:l,poolInfo:s,poolKeys:c,successBack:u,submittedBack:p}){const h=Si(),{account:m}=Zo(),f=Ua();return e.useLingui(),d.useMutation({mutationFn:()=>Wo(this,void 0,void 0,(function*(){if(!n||!o)throw new Error("token is undefined");if(!m)throw new Error("account is undefined");if(!s||!i||!r)throw new Error("poolInfo is undefined");if(!f)throw new Error("raydium is undefined");const e=new T(new R(i).mul(10**s.mintA.decimals).toFixed(0,R.ROUND_DOWN)),d=new y.Percent(100*a*100,1e4),{execute:x}=l?yield f.cpmm.addLiquidity({poolInfo:s,poolKeys:c,inputAmount:e,slippage:d,baseIn:!0,txVersion:y.TxVersion.LEGACY}):yield f.cpmm.createPool({programId:ui,poolFeeAccount:pi,mintA:s.mintA,mintB:s.mintB,mintAAmount:e,mintBAmount:new T(new R(r).mul(10**s.mintB.decimals).toFixed(0,R.ROUND_DOWN)),startTime:new T(0),feeConfig:hi[0],associatedOnly:!1,ownerInfo:{useSOLBalance:!0},txVersion:Aa});return yield h.executeCustom({brief:l?t.i18n._({id:"E6MqGy",message:"Add liquidity"}):t.i18n._({id:"L37FfW",message:"Create AMM V2 Position"}),metadata:{[l?exports.MetadataFlag.addLiquidityAMMV2Position:exports.MetadataFlag.createAMMV2Position]:!0},handler:e=>Wo(this,void 0,void 0,(function*(){const{txId:t}=yield x({sendAndConfirm:!0});e.onSuccess(t)})),successBack:u,submittedBack:p})})),onError:e=>{console.error(e)}})}function rd({pool:e,baseAmount:t,quoteAmount:n,slippage:o}){var a,l,s,c,p,h,m,f,x,g,v,b,j,C;const{account:w}=Zo(),k=Ua(),[R,S,I,B,M]=i.useMemo((()=>{if(!(null==e?void 0:e.baseToken)||!e.quoteToken)return[void 0,void 0,void 0,void 0,!0];const{baseToken:o,quoteToken:i}=e,r=new T(new u.PublicKey(o.address).toBuffer()).lte(new T(new u.PublicKey(i.address).toBuffer())),[a,l]=r?[o,i]:[i,o],[s,d]=r?[t,n]:[n,t];return[a,l,s,d,r]}),[t,e,n]),E=d.useQuery({queryKey:["cpmm","poolInfo",null==e?void 0:e.address],enabled:null!=(null==e?void 0:e.address),queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!(null==e?void 0:e.address)||!k)return null;const{poolInfo:t,poolKeys:n,rpcData:o}=yield k.cpmm.getPoolInfoFromRpc(e.address);if(!o)return{baseReserve:0,quoteReserve:0,lpAmount:0};const[i,r]=t.mintA.address.toLowerCase()===e.baseToken.address.toLowerCase()?[e.baseToken.symbol,e.quoteToken.symbol]:[e.quoteToken.symbol,e.baseToken.symbol],a=oi(t.lpAmount,t.lpMint.decimals);return{baseReserve:oi(o.baseReserve.toNumber(),n.mintA.decimals),quoteReserve:oi(o.quoteReserve.toNumber(),n.mintB.decimals),lpAmount:a,lpMint:t.lpMint,poolKeys:Object.assign(Object.assign({},n),{mintA:Object.assign(Object.assign({},n.mintA),{symbol:i}),mintB:Object.assign(Object.assign({},n.mintB),{symbol:r})}),poolInfo:Object.assign(Object.assign({},t),{lpAmount:a.toNumber(),mintA:Object.assign(Object.assign({},t.mintA),{symbol:i}),mintB:Object.assign(Object.assign({},t.mintB),{symbol:r})}),rpcData:o}}))}),L=d.useQuery({queryKey:["cpmm","lpBalance",null===(l=null===(a=E.data)||void 0===a?void 0:a.lpMint)||void 0===l?void 0:l.address],enabled:!!(w&&E.data&&(null===(s=E.data)||void 0===s?void 0:s.lpMint)&&(null===(p=null===(c=E.data)||void 0===c?void 0:c.lpMint)||void 0===p?void 0:p.address)&&(null===(m=null===(h=E.data)||void 0===h?void 0:h.lpMint)||void 0===m?void 0:m.decimals)),queryFn:()=>Wo(this,void 0,void 0,(function*(){var e,t,n,o,i;if(!(w&&E.data&&(null===(e=E.data)||void 0===e?void 0:e.lpMint)&&(null===(n=null===(t=E.data)||void 0===t?void 0:t.lpMint)||void 0===n?void 0:n.address)&&(null===(i=null===(o=E.data)||void 0===o?void 0:o.lpMint)||void 0===i?void 0:i.decimals)&&k))return null;yield k.account.fetchWalletTokenAccounts();const r=E.data.lpMint.address,a=k.account.tokenAccounts.find((e=>e.mint.toBase58()===r));if(!a)throw new Error(`you do not have balance in pool: ${r}`);return oi(a.amount.toNumber(),E.data.lpMint.decimals)}))}),O=d.useQuery({queryKey:["cpmm","pairAmount",I,null===(f=E.data)||void 0===f?void 0:f.poolInfo],enabled:!(!E.data||!(null===(x=E.data)||void 0===x?void 0:x.poolInfo)||!I),queryFn:()=>Wo(this,void 0,void 0,(function*(){var e;if(!(E.data&&(null===(e=E.data)||void 0===e?void 0:e.poolInfo)&&I&&k))return null;const t=E.data.poolInfo,n=yield k.cpmm.computePairAmount({baseReserve:E.data.rpcData.baseReserve,quoteReserve:E.data.rpcData.quoteReserve,poolInfo:t,amount:I,slippage:new y.Percent(100*o*100,1e4),baseIn:!0,epochInfo:yield k.fetchEpochInfo()});return{pairMintAAmount:I,pairMintBAmount:oi(n.anotherAmount.amount.toString(),t.mintB.decimals).toString(),liquidityMinted:oi(n.liquidity.toString(),t.lpMint.decimals)}}))}),[W,V,A,F]=i.useMemo((()=>{if(!E.data||!L.data)return[void 0,void 0,void 0,void 0];const{baseReserve:e,quoteReserve:t,lpAmount:n}=E.data,o=L.data,i=o.div(n),r=o.multipliedBy(e).div(n),a=o.multipliedBy(t).div(n);return[o,i,r,a]}),[E.data,L.data]),P=i.useMemo((()=>E.isFetched&&null!=E.data),[E.isFetched,E.data]),[Z,N]=i.useMemo((()=>{var e,o;if(P){if(null!=(null===(o=null===(e=E.data)||void 0===e?void 0:e.poolInfo)||void 0===o?void 0:o.price)){const e=new r(E.data.poolInfo.price);return[e,new r(1).div(e)]}return[void 0,void 0]}return t&&n?[new r(n).div(t),new r(t).div(n)]:[void 0,void 0]}),[t,P,null===(v=null===(g=E.data)||void 0===g?void 0:g.poolInfo)||void 0===v?void 0:v.price,n]);return{isFront:M,poolInfoQuery:E,lpBalanceQuery:L,lpBalance:W,lpBalancePercentage:V,lpToAmountA:A,lpToAmountB:F,price:Z,invertedPrice:N,liquidityMinted:null===(b=O.data)||void 0===b?void 0:b.liquidityMinted,pairMintAAmount:null===(j=O.data)||void 0===j?void 0:j.pairMintAAmount,pairMintBAmount:null===(C=O.data)||void 0===C?void 0:C.pairMintBAmount,isExists:P}}const ad="DODO_WIDGET_POOL_LIST_TAB",ld="DODO_WIDGET_POOLS_LIST_FILTER_CHAIN";var sd;!function(e){e.addLiquidity="add-liquidity",e.myLiquidity="my-liquidity",e.myCreated="my-created"}(sd||(sd={}));var dd=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,n=[],o=0;o<e.rangeCount;o++)n.push(e.getRangeAt(o));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()}},cd={"text/plain":"Text","text/html":"Url",default:"Text"};var ud=function(e,t){var n,o,i,r,a,l,s=!1;t||(t={}),n=t.debug||!1;try{if(i=dd(),r=document.createRange(),a=document.getSelection(),(l=document.createElement("span")).textContent=e,l.ariaHidden="true",l.style.all="unset",l.style.position="fixed",l.style.top=0,l.style.clip="rect(0, 0, 0, 0)",l.style.whiteSpace="pre",l.style.webkitUserSelect="text",l.style.MozUserSelect="text",l.style.msUserSelect="text",l.style.userSelect="text",l.addEventListener("copy",(function(o){if(o.stopPropagation(),t.format)if(o.preventDefault(),void 0===o.clipboardData){n&&console.warn("unable to use e.clipboardData"),n&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var i=cd[t.format]||cd.default;window.clipboardData.setData(i,e)}else o.clipboardData.clearData(),o.clipboardData.setData(t.format,e);t.onCopy&&(o.preventDefault(),t.onCopy(o.clipboardData))})),document.body.appendChild(l),r.selectNodeContents(l),a.addRange(r),!document.execCommand("copy"))throw new Error("copy command was unsuccessful");s=!0}catch(i){n&&console.error("unable to copy using execCommand: ",i),n&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),s=!0}catch(i){n&&console.error("unable to copy using clipboardData: ",i),n&&console.error("falling back to prompt"),o=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(o,e)}}finally{a&&("function"==typeof a.removeRange?a.removeRange(r):a.removeAllRanges()),l&&document.body.removeChild(l),i()}return s},pd=W(ud);function hd({copyText:e,size:n,sx:r,componentProps:a,onClick:l,children:s}){var d;const[c,u]=i.useState(!1);return G.jsx(o.TooltipToast,{title:t.i18n._({id:"6V3Ea3",message:"Copied"}),open:c,onClose:()=>u(!1),arrow:!1,children:G.jsxs(o.Box,{...a,component:null!==(d=null==a?void 0:a.component)&&void 0!==d?d:o.ButtonBase,onClick:t=>{if(null==a?void 0:a.onClick)return a.onClick(t);t.stopPropagation(),e&&(pd(e),u(!0)),l&&l()},sx:Object.assign({cursor:"pointer"},null==a?void 0:a.sx),children:[G.jsx(o.Box,{component:A.Copy,sx:Object.assign({width:n||"auto",height:n||"auto"},r)}),s]})})}function md({truncate:e,address:t,disabledAddress:n,sx:i,handleOpen:r,addressHoverColor:a,addressHoverShowIcon:l}){return n?G.jsx(o.Box,{children:e?Zs(t):t}):G.jsx(o.HoverAddUnderLine,{lineSx:{bottom:-1},lineColor:null!=a?a:(null==i?void 0:i.color)||"",hoverSx:{color:"addressHoverColor","& svg":{display:"inline-block"}},className:"truncate-address-link",children:G.jsxs(o.Box,{onClick:e=>{null==r||r(e,"address")},sx:{display:"flex",alignItems:"center",cursor:"pointer"},children:[e?Zs(t):t,l?G.jsx(o.Box,{component:A.ArrowRight,sx:{display:"none",width:14,height:14}}):""]})})}function fd({address:e,truncate:t,showCopy:n,size:i="medium",iconSize:r,iconSpace:a,sx:l,iconDarkHover:s,disabledAddress:d,addressHoverColor:c,addressHoverShowIcon:u,customChainId:p,handleOpen:h,onAddressClick:m}){const f=o.useTheme(),x="big"===i,g="medium"===i,y=s?o.HoverAddBackground:o.HoverOpacity,v=e=>{let t=e?12:8;return a&&(t=a),s&&(t-=3),t},b=x?"h5":g?"body1":"body2",{chainId:j}=Zo(),C=null!=p?p:j,w=(t,n)=>{h?h(t,n):C&&(t.stopPropagation(),window.open(Ns(C,e,"address")))};return G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",typography:b,color:f.palette.text.primary,lineHeight:"normal"},l||{}),children:[G.jsx(md,{truncate:t,address:e,disabledAddress:d,sx:l,typography:b,handleOpen:null!=m?m:w,addressHoverColor:c,addressHoverShowIcon:u}),G.jsx(y,{sx:{display:"inline-flex",ml:v(g),cursor:"pointer"},onClick:e=>{w(e,"icon")},children:G.jsx(o.Box,{component:A.ArrowTopRightBorder,sx:{width:r||(g?16:14),height:r||(g?16:14)}})}),n?G.jsx(hd,{size:r||(g?16:14),copyText:e,componentProps:{component:y,sx:{ml:v(g)}}}):null]})}function xd(e){var{sx:t,label:n,children:i}=e,r=Oo(e,["sx","label","children"]);return G.jsxs(o.Box,{sx:Object.assign({display:"flex",justifyContent:"space-between"},t),...r,children:[G.jsx(o.Box,{children:n}),G.jsx(o.Box,{sx:{textAlign:"right",fontWeight:600},children:i})]})}function gd({tokens:e,width:t=24,height:n=24,gap:i=-4,cross:r,mr:a,chainId:l,showChainLogo:s,sx:d}){var c;const u=o.useTheme(),{onlyChainId:p}=Fo(),h=s&&!p;if(!e||e.length<=0)return null;const m=t/2;return G.jsxs(o.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center",mr:a,position:"relative",zIndex:0},d),children:[e.map(((e,n)=>G.jsx(o.Box,{sx:{display:"inline-flex",width:t,height:t,ml:n>0?i:0,borderRadius:"50%",backgroundColor:u.palette.background.default},children:"object"==typeof e?G.jsx(Wa,{address:e.address,width:t,height:t,chainId:l,url:e.logoURI,cross:r,noShowChain:!0,noBorder:!0,marginRight:0}):G.jsx(o.Box,{component:"img",height:t,src:e})},n))),h&&La.has(l)?G.jsx(o.Box,{component:null===(c=La.get(l))||void 0===c?void 0:c.logo,sx:{position:"absolute",bottom:0,right:0,zIndex:e.length+1,transform:"translateX(50%)",width:m,height:m}}):""]})}function yd({baseToken:e,quoteToken:t,midPrice:n,loading:a,disabled:l}){const s=o.useTheme(),[d,c]=i.useState(!1),u=d?null==t?void 0:t.symbol:null==e?void 0:e.symbol,p=d&&n?new r(1).div(n):n,h=d?null==e?void 0:e.symbol:null==t?void 0:t.symbol;return G.jsxs(o.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:a,loadingProps:{width:50},children:[e&&t?G.jsx(o.Tooltip,{title:`1 ${u} = ${p?Qo({input:p}):""} ${h}`,children:n?G.jsx(o.Box,{sx:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:`1 ${u} = ${p?Qo({input:p}):""} ${h}`}):G.jsxs(o.Box,{children:[`1 ${u} = `,G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:30},component:"span",sx:{display:"inline-block"},children:"-"}),` ${h}`]})}):"-",G.jsx(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",ml:4,width:18,height:18,backgroundColor:"background.paperDarkContrast",borderRadius:"50%"},!l&&{cursor:"pointer","&:hover":{backgroundColor:o.alpha(s.palette.text.primary,.04)}}),onClick:()=>{l||c((e=>!e))},children:G.jsx(o.Box,{component:A.Switch,sx:{width:18,height:18}})})]})}function vd({baseToken:t,quoteToken:n,loading:i,midPrice:a,lpBalancePercentage:l,sx:s}){const d=o.useTheme(),c=!t||!n;return G.jsxs(o.Box,{sx:Object.assign({mt:20,border:"solid 1px",borderColor:"border.main",borderRadius:8},s),children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:12,py:4,height:36,typography:"body2"},children:[G.jsx(o.Box,{sx:{color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"kNeEXg",message:"Current Price"})}),G.jsx(yd,{baseToken:t,quoteToken:n,loading:i,disabled:c,midPrice:a})]}),G.jsxs(o.Box,{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:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"})}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",fontWeight:600,textAlign:"right",ml:8,overflow:"hidden"},children:G.jsx(o.LoadingSkeleton,{sx:{display:"flex",alignItems:"center",fontWeight:600,overflow:"hidden"},loading:i,loadingProps:{width:50},children:l?`${di({input:l,roundingMode:r.ROUND_DOWN})}`:"-%"})})]})]})}function bd({open:t,onClose:n,slippage:i,baseToken:r,quoteToken:a,pairMintAAmount:l,pairMintBAmount:s,lpAmount:d,feeRate:c,price:u,lpBalancePercentage:p,pairAddress:h,createMutation:m}){const f=o.useTheme(),{isMobile:x}=Ls();return G.jsx(ds,{modal:!0,open:t,onClose:n,title:d?G.jsx(e.Trans,{id:"AeZIvT",message:"You will receive"}):G.jsx(e.Trans,{id:"aM1tos",message:"You are creating a pool"}),children:G.jsxs(o.Box,{sx:{px:20,py:24,borderTopWidth:1,width:x?"100%":420},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h3"},children:[G.jsx(gd,{width:24,height:24,tokens:r&&a?[r,a]:[]}),d?Ko({input:d,decimals:null==r?void 0:r.decimals}):""]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,fontWeight:600},children:[G.jsx(e.Trans,{id:"syToc5",message:"{0}/{1} Pool Tokens",values:{0:null==r?void 0:r.symbol,1:null==a?void 0:a.symbol}}),G.jsx(o.Box,{sx:{px:4,py:2,fontSize:10,lineHeight:1,backgroundColor:o.alpha(f.palette.purple.main,.1),color:f.palette.purple.main,borderRadius:4},children:G.jsx(e.Trans,{id:"rbsyJM",message:"AMM V2"})})]})]}),G.jsx(o.Box,{sx:{mt:16,typography:"h6",color:"text.secondary",textAlign:"center"},children:G.jsx(e.Trans,{id:"rQ9c+8",message:"Output is estimated. If the price changes by more than {0} your transaction will revert.",values:{0:di({input:i})}})}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:12,mt:20,p:20,typography:"body2",borderRadius:12,backgroundColor:f.palette.background.paperContrast},children:[G.jsx(xd,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==r?void 0:r.symbol}}),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",lineHeight:1},children:[G.jsx(Wa,{width:18,height:18,marginRight:4,token:r}),Ko({input:l,decimals:null==r?void 0:r.decimals})]})}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"YG004A",message:"{0} deposited",values:{0:null==a?void 0:a.symbol}}),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{width:18,height:18,marginRight:4,token:a}),Ko({input:s,decimals:null==a?void 0:a.decimals})]})}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"}),children:null!=c?Number(c)/1e4+"%":"-"}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"fqDzSu",message:"Rate"}),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{width:18,height:18,marginRight:4,token:r}),G.jsx(yd,{baseToken:r,quoteToken:a,midPrice:u})]})}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"SbBMxj",message:"Share of pool"}),children:p?`${di({input:p})}`:"-%"}),G.jsx(xd,{label:G.jsx(e.Trans,{id:"ESQO1L",message:"Pool address"}),children:G.jsx(fd,{showCopy:!1,address:null!=h?h:"",customChainId:null==r?void 0:r.chainId,truncate:!0,iconSpace:4,sx:{typography:"body2"}})})]}),G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,sx:{mt:20},isLoading:m.isPending,onClick:()=>{m.mutate()},children:m.isPending?G.jsx(e.Trans,{id:"pwUZo2",message:"Confirming..."}):G.jsx(e.Trans,{id:"7VpPHA",message:"Confirm"})})]})})}function jd({title:e,disabled:t,children:n}){return G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:12,opacity:t?.3:void 0},children:[G.jsx(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",fontWeight:600},children:e}),n]})}function Cd({disabled:t,feeIndex:n,onChange:a,feeList:l}){const s=o.useTheme(),[d,c]=i.useState(!1),{isMobile:u}=Ls(),p=t,h=l[n];return G.jsxs(o.Box,{sx:{opacity:t?.3:void 0,fontWeight:600},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:12,borderWidth:1,borderRadius:12},children:[G.jsx(e.Trans,{id:"tMMG40",message:"{0}% fee tier",values:{0:h?new r(h.tradeFeeRate).div(1e4).toString():"-"}}),G.jsx(o.ButtonBase,{sx:{px:16,py:7,border:`solid 1px ${s.palette.text.primary}`,borderRadius:8,fontWeight:600,color:"text.primary",cursor:p?"default":"pointer"},disabled:p,onClick:()=>{p||c((e=>!e))},children:d?G.jsx(e.Trans,{id:"vLyv1R",message:"Hide"}):G.jsx(e.Trans,{id:"ePK91l",message:"Edit"})})]}),d&&G.jsx(G.Fragment,{children:G.jsx(o.Box,{sx:Object.assign({mt:12},u?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8,"& > label":{flex:1}}),children:l.map(((e,t)=>{const i=n===t;return G.jsxs(o.Box,{component:"label",sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderRadius:12,cursor:"pointer"},i&&{borderColor:s.palette.primary.main}),children:[e.tradeFeeRate/1e4,"%",G.jsx(o.Radio,{size:18,checked:i,onChange:(e,n)=>{n&&a(t)}})]},e.id)}))})})]})}function wd({chainId:e,address:t,showName:n,size:i,offset:r,rightContent:a}){const l=G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:r},children:[G.jsx(Wa,{chainId:e,address:t,width:i,height:i,noShowChain:!0,marginRight:0}),n]});return a?G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l,a]}):l}function kd({isExists:t,poolInfo:i,poolInfoLoading:a,lpBalanceLoading:l,lpBalance:s,lpBalancePercentage:d,lpToAmountA:c,lpToAmountB:u,sx:p}){var h,m;const f=d?`${di({input:d,roundingMode:r.ROUND_DOWN})}`:void 0;return t&&i?G.jsxs(o.Box,{sx:Object.assign({px:20,py:12,borderWidth:1,borderRadius:8},p),children:[G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(o.Box,{sx:{mt:12,display:"flex",alignItems:"center",flexWrap:"wrap"},children:[G.jsx(gd,{width:18,height:18,tokens:[i.mintA,i.mintB],mr:4}),G.jsx(o.LoadingSkeleton,{loading:l,loadingProps:{width:50},sx:{mr:4},children:Ko({input:s,decimals:i.lpMint.decimals})}),`${i.mintA.symbol}/${i.mintB.symbol} LP`,G.jsx(o.Tooltip,{title:G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:10,typography:"body2",color:"text.primary"},children:[G.jsx(wd,{address:i.mintA.address,chainId:i.mintA.chainId,showName:null!==(h=i.mintA.symbol)&&void 0!==h?h:"",size:14,offset:4,rightContent:G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:50},children:Ko({input:c,decimals:i.mintA.decimals})})}),G.jsx(wd,{address:i.mintB.address,chainId:i.mintB.chainId,showName:null!==(m=i.mintB.symbol)&&void 0!==m?m:"",size:14,offset:4,rightContent:G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:50},children:Ko({input:u,decimals:i.mintB.decimals})})}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsx(e.Trans,{id:"c4miqE",message:"Pool share"}),G.jsx(o.LoadingSkeleton,{loading:a,loadingProps:{width:50},children:f})]})]}),sx:{padding:20,width:256},children:G.jsx(o.HoverOpacity,{component:A.DetailBorder,sx:{ml:4,width:16,height:16,cursor:"pointer"}})}),G.jsx(o.Box,{component:"a",target:"_blank",rel:"noopener noreferrer",href:Ns(n.ChainId.SOON_TESTNET,i.lpMint.address,"address"),sx:{ml:4,display:"inline-flex",height:16},children:G.jsx(o.HoverOpacity,{component:A.ArrowTopRightBorder,sx:{width:16,height:16}})})]})]}):null}function Td({active:t,sx:n,onClick:i}){const r=o.useTheme(),a="light"===r.palette.mode;let l=r.palette.primary.main,s="transparent";return t&&(l=r.palette.primary.contrastText,s=o.alpha(r.palette.primary.main,.8)),G.jsx(o.Box,{component:o.ButtonBase,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:s,borderRadius:8,fontWeight:600,"&:hover":{color:t?r.palette.primary.contrastText:r.palette.primary.main,backgroundColor:t?r.palette.primary.main:a?"rgba(26, 26, 27, 0.04)":"rgba(241, 249, 2, 0.08)"}},n),onClick:i,children:G.jsx(e.Trans,{id:"R9Khdg",message:"Auto"})})}function Rd({sx:t,disabled:n,slippage:a,onChangeSlippage:l}){const s=o.useTheme(),d=a===$s,[c,u]=i.useState(d?"":new r(a).times(100).toNumber());return G.jsx(o.Tooltip,{disabled:n,onlyClick:!0,title:G.jsxs(o.Box,{sx:{backgroundColor:s.palette.background.paper,padding:s.spacing(16,20),borderRadius:16,width:375,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2",color:"text.primary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[d?td:a&&new r(a).times(100).toNumber(),"%"]})]}),G.jsxs(o.Box,{sx:{mt:16,display:"flex",alignItems:"center",margin:s.spacing(16,0,0,0)},children:[G.jsx(Td,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{u(""),l($s)},active:d}),G.jsx(o.Input,{placeholder:String(td),value:c,onChange:e=>{const{value:t}=e.target;u(t),l(t?new r(t).div(100).toNumber():$s)},onBlur:()=>{(!d&&new r(a).gt(.1)||new r(a).lte(0))&&(u(10),l(.1))},suffix:G.jsx(o.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(o.HoverAddBackground,{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:G.jsx(o.Box,{component:A.Setting,sx:{width:18,height:18,"& path:last-child":{fill:s.palette.text.primary}}})})})}function Sd(){var t,n,a;const[l,s]=i.useState(0),[d,c]=i.useState(),[p,h]=i.useState(),[m,f]=i.useState(""),[x,g]=i.useState(""),[v,b]=i.useState($s),j=v===$s?new r(td).div(100).toNumber():v,{isMobile:C}=Ls(),{onlyChainId:w}=Fo(),k=i.useMemo((()=>w||(null==d?void 0:d.chainId)||(null==p?void 0:p.chainId)),[w,d,p]),{poolKeys:R,poolInfo:S,pairAddress:I,price:B,isInvalidPair:M,invertedPrice:E,poolInfoLoading:L,lpBalanceLoading:O,lpBalance:W,lpBalancePercentage:V,lpToAmountA:F,lpToAmountB:P,liquidityMinted:Z,pairMintAAmount:N,pairMintBAmount:U,isExists:H}=function({baseToken:e,quoteToken:t,baseAmount:n,quoteAmount:o,feeIndex:r,slippage:a}){var l,s,d;const[c,p]=i.useMemo((()=>{if(!e||!t||null==r)return[void 0,!0];const n=new T(new u.PublicKey(e.address).toBuffer()).lte(new T(new u.PublicKey(t.address).toBuffer())),[o,i]=n?[e,t]:[t,e],[a,l]=[new u.PublicKey(o.address),new u.PublicKey(i.address)];return[y.getCreatePoolKeys({poolId:void 0,programId:ui,configId:new u.PublicKey(hi[r].id),mintA:a,mintB:l}),a.toBase58()===l.toBase58()]}),[r,e,t]),{price:h,invertedPrice:m,poolInfoQuery:f,lpBalanceQuery:x,lpBalance:g,lpBalancePercentage:v,lpToAmountA:b,lpToAmountB:j,liquidityMinted:C,pairMintAAmount:w,pairMintBAmount:k,isExists:R}=rd({pool:e&&t&&c?{baseToken:e,quoteToken:t,address:c.poolId.toBase58()}:void 0,baseAmount:n,quoteAmount:o,slippage:a});return{poolKeys:null===(l=f.data)||void 0===l?void 0:l.poolKeys,poolInfo:null===(s=f.data)||void 0===s?void 0:s.poolInfo,pairAddress:null===(d=null==c?void 0:c.poolId)||void 0===d?void 0:d.toBase58(),isInvalidPair:p,price:h,invertedPrice:m,poolInfoLoading:f.isLoading,lpBalanceLoading:x.isLoading,lpBalance:g,lpBalancePercentage:v,lpToAmountA:b,lpToAmountB:j,liquidityMinted:C,pairMintAAmount:w,pairMintBAmount:k,isExists:R}}({baseToken:d,quoteToken:p,baseAmount:m,quoteAmount:x,feeIndex:l,slippage:j}),D=od(B);if(B&&m&&!B.isEqualTo(null!=D?D:0)&&H){const e=B.times(m).dp(null!==(t=null==p?void 0:p.decimals)&&void 0!==t?t:18);e.isEqualTo(x)||g(e.toString())}const Y=ur(d,{amount:m}),z=ur(p,{amount:x}),[q,X]=i.useState(!1),_=!d||!p,J=()=>{Gs.getState().push({type:exports.PageType.Pool})},Q=id({baseToken:d,quoteToken:p,pairMintAAmount:N,pairMintBAmount:U,isExists:H,poolKeys:R,poolInfo:S,slippage:j,successBack:()=>{Gs.getState().push({type:exports.PageType.Pool,params:{tab:sd.myLiquidity}})}});return G.jsxs(Ks,{children:[G.jsxs(o.Box,{sx:{mx:"auto",borderRadius:C?0:16,backgroundColor:"background.paper",width:C?"100%":600,position:"relative",overflow:"hidden"},children:[C?G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:20,pb:0},children:G.jsx(_s,{onClick:J})}):G.jsxs(o.Box,{sx:{position:"relative",display:"flex",justifyContent:"center",alignItems:"center",px:20,py:24,typography:"caption"},children:[G.jsx(o.Box,{component:A.ArrowBack,sx:{position:"absolute",left:20,cursor:"pointer"},onClick:J}),G.jsx(e.Trans,{id:"E6MqGy",message:"Add liquidity"})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:20,pt:24,px:20,pb:20},children:[G.jsx(kd,{isExists:H,poolInfo:S,poolInfoLoading:L,lpBalanceLoading:O,lpBalance:W,lpBalancePercentage:V,lpToAmountA:F,lpToAmountB:P}),G.jsxs(jd,{title:G.jsx(e.Trans,{id:"nxRg31",message:"Select pair"}),children:[G.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:C?"repeat(1, 1fr)":"repeat(2, 1fr)",gap:12},children:[G.jsx(Qs,{border:!0,highlightDefault:!0,chainId:k,token:d,onTokenChange:(e,t)=>{t?(c(p),h(d),f(""),g("")):(c(e),f(""))},occupiedToken:p}),G.jsx(Qs,{border:!0,highlightDefault:!0,chainId:k,token:p,onTokenChange:(e,t)=>{t?(c(p),h(d)):(h(e),g(""))},occupiedToken:d})]}),G.jsx(Cd,{feeIndex:l,onChange:s,feeList:hi,disabled:_})]}),G.jsx(jd,{title:G.jsx(e.Trans,{id:"MU9s7M",message:"Deposit amounts"}),disabled:_,children:G.jsxs(o.Box,{children:[G.jsx(zs,{sx:{mb:4,pb:28,minHeight:"auto"},token:d,amt:m,defaultLoadBalance:!0,onInputChange:e=>{var t;f(e);const n=Number(e);H&&B&&n&&g(B.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:_}),G.jsx(Is,{plus:!0}),G.jsx(zs,{sx:{pb:20,minHeight:"auto"},token:p,amt:x,defaultLoadBalance:!0,onInputChange:e=>{var t;g(e);const n=Number(e);H&&E&&n&&f(E.times(e).dp(null!==(t=null==d?void 0:d.decimals)&&void 0!==t?t:18).toString())},showMaxBtn:!0,occupiedAddrs:[null!==(a=null==d?void 0:d.address)&&void 0!==a?a:""],occupiedChainId:null==d?void 0:d.chainId,notTokenPickerModal:!0,showPercentage:!0,readOnly:_}),G.jsx(Rd,{slippage:v,onChangeSlippage:b,disabled:_,sx:{mt:8}}),G.jsx(vd,{baseToken:d,quoteToken:p,loading:L,midPrice:B,lpBalancePercentage:H?V:100}),!!H&&G.jsxs(o.Box,{sx:{mt:20,p:20,borderRadius:16,backgroundColor:"background.paperContrast",typography:"h6",textAlign:"center","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"XoymfI",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:di({input:hi[l].tradeFeeRate/1e4})},components:{0:G.jsx("b",{})}})]})]})})]}),G.jsx(o.Box,{sx:{py:16,px:20,borderTopWidth:1},children:G.jsx(bs,{fullWidth:!0,includeButton:!0,size:o.Button.Size.big,disabled:_,chainId:k,children:G.jsx(Js,{statuses:[Y,z],buttonProps:{size:o.Button.Size.big},children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,disabled:!(d&&p&&m&&x&&!M&&null!=l),onClick:()=>X(!0),children:M?G.jsx(e.Trans,{id:"R7D79P",message:"Invalid pair"}):G.jsx(e.Trans,{id:"bwSQI0",message:"Supply"})})})})})]}),G.jsx(bd,{open:q,onClose:()=>X(!1),slippage:j,baseToken:d,pairMintAAmount:N,quoteToken:p,pairMintBAmount:U,feeRate:hi[l].tradeFeeRate,price:B,lpAmount:Z,lpBalancePercentage:H?V:100,pairAddress:I,createMutation:Q})]})}const Id=({type:e})=>{const[t,o]=i.useState($s),a=i.useMemo((()=>t===$s?e===n.CLMM?new r(nd).div(100).toNumber():e===n.CPMM?new r(td).div(100).toNumber():new r(ed).div(100).toNumber():t),[t,e]);return{slipper:t,setSlipper:o,slipperValue:a,resetSlipper:()=>{o($s)}}};function Bd({type:t,disabled:a,value:l,onChange:s,sx:d}){const c=o.useTheme(),u=l===$s,[p,h]=i.useState(u?"":new r(l).times(100).toNumber()),m=t===n.CLMM?nd:t===n.CPMM?td:ed;return G.jsx(o.Tooltip,{disabled:a,onlyClick:!0,title:G.jsxs(o.Box,{sx:{backgroundColor:c.palette.background.paper,padding:c.spacing(12,20),borderRadius:8,width:318,maxWidth:"90vw",boxSizing:"border-box"},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",typography:"body2"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"lqTDfd",message:"Slippage Tolerance"})}),G.jsxs("span",{children:[u?m:l&&new r(l).times(100).toNumber(),"%"]})]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",margin:c.spacing(16,0,0,0)},children:[G.jsx(Td,{sx:{borderRadius:8,whiteSpace:"nowrap"},onClick:()=>{h(""),s($s)},active:u}),G.jsx(o.Input,{placeholder:String(m),value:p,onChange:e=>{const{value:t}=e.target;h(t),s(t?new r(t).div(100).toNumber():$s)},onBlur:()=>{(!u&&new r(l).gt(.1)||new r(l).lte(0))&&(h(10),s(.1))},suffix:G.jsx(o.Box,{sx:{mr:16},children:"%"}),sx:{ml:8,"& input":{px:16,py:0,height:"39px"}}})]})]}),sx:{p:0},arrow:!1,placement:"bottom-end",children:G.jsx(o.HoverAddBackground,{sx:Object.assign({width:"max-content",alignItems:"right",margin:c.spacing(0,0,0,"auto"),p:c.spacing(4,12),borderRadius:20,backgroundColor:"background.paperDarkContrast"},d),children:G.jsx(o.Box,{component:A.Setting,sx:{width:18,height:18,"& path:last-child":{fill:c.palette.text.primary}}})})})}const Md=({chainId:e,isValid:n,errorMessage:i,setShowConfirm:r})=>G.jsx(bs,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:()=>{r(!0)},disabled:!n,danger:!n,children:i||t.i18n._({id:"rdUucN",message:"Preview"})})}),Ed=[.25,.5,.75,1];function Ld({currentValue:e,onClick:t,sx:n}){const r=o.useTheme(),a="light"===r.palette.mode,{isMobile:l}=Ls(),[s,d]=i.useState(null),c=i.useRef(0);i.useEffect((()=>{e?(c.current+=1,c.current>=2&&(d(null),c.current=0)):d(null)}),[e]);const u=od(e);return i.useEffect((()=>{u===e&&1===s&&(c.current=1)}),[e,u,s]),G.jsx(o.Box,{sx:Object.assign({display:"grid",gap:l?10:14,gridTemplateColumns:`repeat(${Ed.length}, 1fr)`},n),children:Ed.map((e=>{const n=e===s;return G.jsxs(o.ButtonBase,{sx:{typography:"h6",borderRadius:4,padding:r.spacing(4,0),width:"100%",color:"text.secondary",backgroundColor:"background.paperDarkContrast","&:hover":{color:r.palette.text.primary,backgroundColor:o.alpha(r.palette.text.primary,.2)},"&.selected, &:focus":{color:"#fff",backgroundColor:a?r.palette.primary.main:o.alpha(r.palette.text.primary,.4)}},onClick:()=>{n||(c.current=0,d(e),t(e))},className:n?"selected":void 0,children:[100*e,"%"]},e)}))})}const Od=({value:n,onUserInput:r,maxAmount:a,balance:l,mint:s,locked:d})=>{var c,u;const p=o.useTheme(),h=i.useCallback((e=>{if(!a||!s)return;const t=a.multipliedBy(e).dp(s.decimals).toString();r(t)}),[s,a,r]),m=i.useMemo((()=>l?Ko({input:l,decimals:null==s?void 0:s.decimals}):"-"),[null==s?void 0:s.decimals,l]);return G.jsxs(o.Box,{sx:{pt:12,pb:20,px:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",borderRadius:12,backgroundColor:p.palette.background.input},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:4},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:p.palette.text.primary,typography:"h5"},children:[(null==s?void 0:s.address)&&G.jsx(Wa,{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}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:(null==s?void 0:s.address)?G.jsx(o.Box,{children:null!==(u=null==s?void 0:s.symbol)&&void 0!==u?u:"-"}):G.jsx(e.Trans,{id:"sIPJGT",message:"SELECT TOKEN"})})]}),G.jsxs(o.Box,{component:o.ButtonBase,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:[G.jsxs(o.Box,{sx:{wordBreak:"keep-all"},children:[t.i18n._({id:"fsBGk0",message:"Balance"}),": "]}),G.jsx(o.Box,{sx:{wordBreak:"break-all",textAlign:"right",display:"flex",alignItems:"center"},children:m})]})]}),G.jsx(Es,{sx:{mt:4},suffix:void 0,value:n,onChange:r,readOnly:d,withClear:!d}),d?null:G.jsx(Ld,{sx:{mt:20,mb:0},onClick:h,currentValue:n})]})};var Wd,Vd;function Ad(e,t){switch(t.type){case Wd.UpdateMint1:{const n=t.payload;return Object.assign(Object.assign({},e),{mint1:n})}case Wd.UpdateDefaultMint1:{const n=t.payload;return e.mint1?e:Object.assign(Object.assign({},e),{mint1:n})}case Wd.UpdateMint2:{const n=t.payload;return Object.assign(Object.assign({},e),{mint2:n})}case Wd.UpdateDefaultMint2:{const n=t.payload;return e.mint2?e:Object.assign(Object.assign({},e),{mint2:n})}case Wd.UpdateMint1AndClearMint2:{const n=t.payload;return Object.assign(Object.assign({},e),{mint1:n,mint2:void 0})}case Wd.UpdateFeeAmount:return Object.assign(Object.assign({},e),{feeAmount:t.payload});case Wd.UpdateSelectedMintIndex:return Object.assign(Object.assign({},e),{selectedMintIndex:t.payload});case Wd.setFullRange:return Object.assign(Object.assign({},e),{leftRangeTypedValue:!0,rightRangeTypedValue:!0});case Wd.typeStartPriceInput:return Object.assign(Object.assign({},e),{startPriceTypedValue:t.payload.typedValue});case Wd.typeLeftRangeInput:return Object.assign(Object.assign({},e),{leftRangeTypedValue:t.payload.typedValue});case Wd.typeRightRangeInput:return Object.assign(Object.assign({},e),{rightRangeTypedValue:t.payload.typedValue});case Wd.typeInput:{const{payload:{field:n,typedValue:o}}=t;return Object.assign(Object.assign({},e),{independentField:n,typedValue:o})}default:throw Error("Unknown action: "+t.type)}}!function(e){e[e.UpdateMint1=0]="UpdateMint1",e[e.UpdateMint2=1]="UpdateMint2",e[e.UpdateDefaultMint1=2]="UpdateDefaultMint1",e[e.UpdateDefaultMint2=3]="UpdateDefaultMint2",e[e.UpdateMint1AndClearMint2=4]="UpdateMint1AndClearMint2",e[e.UpdateFeeAmount=5]="UpdateFeeAmount",e[e.UpdateSelectedMintIndex=6]="UpdateSelectedMintIndex",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"}(Wd||(Wd={})),function(e){e[e.LOW=1e3]="LOW"}(Vd||(Vd={}));const Fd={[Vd.LOW]:20},Pd={[Vd.LOW]:{label:"0.1%"}},Zd=({disabled:e,feeAmount:n,dispatch:r})=>{const a=o.useTheme(),{isMobile:l}=Ls(),[s,d]=i.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"space-between",px:20,py:12,borderWidth:1,borderStyle:"solid",borderColor:a.palette.border.main,borderRadius:12},e?{opacity:.3}:void 0),children:[G.jsx(o.Box,{sx:{typography:"h5",color:a.palette.text.primary},children:n?`${Pd[n].label} ${t.i18n._({id:"fxRyGG",message:"fee tier"})}`:t.i18n._({id:"EU3wU4",message:"Fee tier"})}),G.jsx(o.Button,{size:o.Button.Size.small,variant:o.Button.Variant.outlined,disabled:e,onClick:()=>d((e=>!e)),sx:{color:a.palette.text.primary,border:`solid 1px ${a.palette.text.primary}`},children:s?t.i18n._({id:"vLyv1R",message:"Hide"}):t.i18n._({id:"ePK91l",message:"Edit"})})]}),s&&G.jsx(o.Box,{sx:Object.assign({},l?{display:"grid",gap:8,gridTemplateColumns:"repeat(2, 1fr)"}:{display:"flex",alignItems:"center",gap:8}),children:[Vd.LOW].map((t=>{const i=n===t;return G.jsxs(o.Button,{size:o.Button.Size.middle,variant:o.Button.Variant.outlined,disabled:e,onClick:()=>{r({type:Wd.UpdateFeeAmount,payload:t})},sx:{flexBasis:"50%",flexShrink:1,flexGrow:1,justifyContent:"space-between",px:20,color:a.palette.text.primary,borderRadius:12,borderColor:i?a.palette.primary.main:a.palette.border.main,[a.breakpoints.up("tablet")]:{flexBasis:"25%"}},children:[Pd[t].label,i?G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:[G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.primary.main}),G.jsx("rect",{x:"4.5",y:"4.5",width:"9",height:"9",rx:"4.5",fill:a.palette.primary.main,stroke:a.palette.primary.main})]}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("rect",{x:"0.5",y:"0.5",width:"17",height:"17",rx:"8.5",stroke:a.palette.text.secondary})})]},t)}))})]})};var Nd,Ud,Hd;!function(e){e.DEPOSIT_1="DEPOSIT_1",e.DEPOSIT_2="DEPOSIT_2"}(Nd||(Nd={})),function(e){e.LOWER="LOWER",e.UPPER="UPPER"}(Ud||(Ud={})),function(e){e.TOKEN0="TOKEN0",e.TOKEN1="TOKEN1"}(Hd||(Hd={}));const Dd={xs:"4px",sm:"8px",md:"12px",lg:"24px",xl:"32px"},Yd=({children:e,sx:t})=>(o.useTheme(),G.jsx(o.Box,{sx:Object.assign({display:"flex",flexDirection:"column",gap:20,px:20,py:20,borderRadius:12},t),children:e})),zd=({children:e,sx:t})=>{const n=o.useTheme();return G.jsx(Yd,{sx:Object.assign(Object.assign({},t),{backgroundColor:n.palette.background.paperContrast}),children:e})},qd=({children:e})=>{const t=o.useTheme();return G.jsxs(o.Box,{sx:{p:8,borderRadius:8,backgroundColor:o.alpha(t.palette.warning.main,.1),display:"flex",alignItems:"center",gap:8},children:[G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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})}),G.jsx(o.Box,{sx:{typography:"h6",color:t.palette.warning.main,textAlign:"left"},children:e})]})};function Xd({gap:e,flex:t,children:n,style:i}){return G.jsx(o.Box,{sx:Object.assign(Object.assign(Object.assign({display:"flex",flexDirection:"column",justifyContent:"flex-start",gap:e&&Dd[e]||e},t&&{flex:t}),{width:"100%",alignItems:"center"}),i),children:n})}function Gd({gap:e,justify:t,grow:n,children:i,style:r}){return G.jsx(o.Box,{sx:Object.assign({display:"grid",gridAutoRows:"auto",gridRowGap:e&&Dd[e]||e,justifyItems:t,flexGrow:n&&1},r),children:i})}function _d({gap:e,children:t,sx:n}){return G.jsx(o.Box,{sx:Object.assign({width:"100%",display:"flex",padding:0,alignItems:"center",justifyContent:"flex-start",gap:e&&Dd[e]||e},n),children:t})}function Jd({children:e,style:t}){return G.jsx(_d,{sx:Object.assign({justifyContent:"space-between"},t),children:e})}function Qd({gap:e,justify:t,children:n,sx:o}){return G.jsx(_d,{sx:Object.assign({position:"relative",width:"fit-content",margin:`-${e}`},o),children:n})}function Kd({children:e,disabled:t,sx:n}){return G.jsx(_d,{sx:Object.assign({display:"flex",flexDirection:"column",alignItems:"stretch",gap:12,opacity:t?.2:1,pointerEvents:t?"none":"auto"},n),children:e})}const $d={neutral1:"#222222",neutral2:"#7D7D7D",accent1:"#FC72FF",critical:"FF5F52",white:"#FFFFFF",surface3:"#22222212",opacity:{hover:.6,click:.4,disabled:.5,enabled:1}},ec=({series:e,xScale:t,yScale:n,xValue:r,yValue:a,fill:l})=>i.useMemo((()=>{var i;return G.jsx(o.Box,{component:"path",opacity:.5,stroke:null!=l?l:$d.accent1,fill:null!=l?l:$d.accent1,d:null!==(i=I.area().curve(I.curveStepAfter).x((e=>t(r(e)))).y1((e=>n(a(e)))).y0(n(0))(e.filter((e=>{const n=t(r(e));return n>0&&n<=window.innerWidth}))))&&void 0!==i?i:void 0})}),[l,e,t,r,n,a]),tc=({axisGenerator:e})=>G.jsx("g",{ref:t=>{t&&I.select(t).call(e).call((e=>e.select(".domain").remove()))}}),nc=({xScale:e,innerHeight:t,offset:n=0})=>i.useMemo((()=>G.jsx(o.Box,{component:"g",transform:`translate(0, ${t+n})`,sx:{"& line":{display:"none"},"& text":{color:$d.neutral2,transform:"translateY(5px)"}},children:G.jsx(tc,{axisGenerator:I.axisBottom(e).ticks(6)})})),[t,n,e]),oc=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(" "),ic=()=>["m 5 7","v 14","M 0 0","m 9 7","v 14","z"].join(" "),rc=({color:e,size:t=10,margin:n=10})=>G.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 ac=({color:e,d:t})=>G.jsx(o.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",strokeWidth:3,stroke:e,fill:e,d:t}),lc=({d:e})=>G.jsx(o.Box,{component:"path",cursor:"ew-resize",pointerEvents:"none",stroke:$d.white,opacity:$d.opacity.hover,d:e}),sc=({visible:e,transform:t,children:n})=>G.jsx(o.Box,{component:"g",opacity:e?"1":"0",transform:t,sx:{transition:"opacity 300ms"},children:n}),dc=({y:e,x:t,height:n,width:i,rx:r})=>G.jsx(o.Box,{component:"rect",fill:$d.surface3,y:e,x:t,height:n,width:i,rx:r}),cc=({y:e,transform:t,dominantBaseline:n,children:i})=>G.jsx(o.Box,{component:"text",y:e,textAnchor:"middle",fontSize:"13px",fill:$d.neutral1,transform:t,dominantBaseline:n,children:i}),uc=(e,t,n)=>{const o=e.map((e=>n(e).toFixed(1))),i=t.map((e=>n(e).toFixed(1)));return o.every(((e,t)=>e===i[t]))},pc=({id:e,xScale:t,interactive:n,brushLabelValue:o,brushExtent:r,setBrushExtent:a,innerWidth:l,innerHeight:s,westHandleColor:d,eastHandleColor:c})=>{const u=i.useRef(null),p=i.useRef(null),[h,m]=i.useState(r),[f,x]=i.useState(!1),[g,y]=i.useState(!1),v=function(e){const t=i.useRef();return i.useEffect((()=>{t.current=e}),[e]),t.current}(r),b=i.useCallback((e=>{const{type:n,selection:o,mode:i}=e;if(!o)return void m(null);const l=o.map(t.invert);"end"!==n||uc(r,l,t)||a(l,i),m(l)}),[t,r,a]);i.useEffect((()=>{m(r)}),[r]),i.useEffect((()=>{u.current&&(p.current=I.brushX().extent([[Math.max(2,t(0)),0],[l-2,s]]).handleSize(30).filter((()=>n)).on("brush end",b),p.current(I.select(u.current)),v&&uc(r,v,t)&&I.select(u.current).transition().call(p.current.move,r.map(t)),I.select(u.current).selectAll(".selection").attr("stroke","none").attr("fill-opacity","0.1").attr("fill",`url(#${e}-gradient-selection)`))}),[r,b,e,s,l,n,v,t]),i.useEffect((()=>{u.current&&p.current&&p.current.move(I.select(u.current),r.map(t))}),[r,t]),i.useEffect((()=>{x(!0);const e=setTimeout((()=>x(!1)),1500);return()=>clearTimeout(e)}),[h]);const j=h&&t(h[0])>20,C=h&&t(h[1])>l-20,w=h&&(t(h[0])<0||t(h[1])<0),k=h&&(t(h[0])>l||t(h[1])>l),T=h&&t(h[0])>=0&&t(h[0])<=l,R=h&&t(h[1])>=0&&t(h[1])<=l;return i.useMemo((()=>G.jsxs(G.Fragment,{children:[G.jsxs("defs",{children:[G.jsxs("linearGradient",{id:`${e}-gradient-selection`,x1:"0%",y1:"100%",x2:"100%",y2:"100%",children:[G.jsx("stop",{stopColor:d}),G.jsx("stop",{stopColor:c,offset:"1"})]}),G.jsx("clipPath",{id:`${e}-brush-clip`,children:G.jsx("rect",{x:"0",y:"0",width:l,height:s})})]}),G.jsx("g",{ref:u,clipPath:`url(#${e}-brush-clip)`,onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1)}),h&&G.jsxs(G.Fragment,{children:[T?G.jsxs("g",{transform:`translate(${Math.max(0,t(h[0]))}, 0), scale(${j?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(ac,{color:d,d:oc(s)}),G.jsx(lc,{d:ic()})]}),G.jsxs(sc,{transform:`translate(50,0), scale(${j?"1":"-1"}, 1)`,visible:f||g,children:[G.jsx(dc,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(cc,{transform:"scale(-1, 1)",y:"15",dominantBaseline:"middle",children:o("w",h[0])})]})]}):null,R?G.jsxs("g",{transform:`translate(${t(h[1])}, 0), scale(${C?"-1":"1"}, 1)`,children:[G.jsxs("g",{children:[G.jsx(ac,{color:c,d:oc(s)}),G.jsx(lc,{d:ic()})]}),G.jsxs(sc,{transform:`translate(50,0), scale(${C?"-1":"1"}, 1)`,visible:f||g,children:[G.jsx(dc,{y:"0",x:"-30",height:"30",width:"60",rx:"8"}),G.jsx(cc,{y:"15",dominantBaseline:"middle",children:o("e",h[1])})]})]}):null,w&&G.jsx(rc,{color:d}),k&&G.jsx("g",{transform:`translate(${l}, 0) scale(-1, 1)`,children:G.jsx(rc,{color:c})})]})]})),[o,c,R,C,j,g,e,s,l,h,k,f,w,d,T,t])},hc=({value:e,xScale:t,innerHeight:n})=>i.useMemo((()=>G.jsx(o.Box,{component:"line",x1:t(e),y1:"0",x2:t(e),y2:n,sx:{opacity:.5,strokeWidth:2,stroke:$d.neutral1,fill:"none"}})),[e,t,n]);function mc({svg:e,xScale:t,setZoom:n,width:r,height:a,resetBrush:l,showResetButton:s,zoomLevels:d}){const c=i.useRef(),[u,p,h,m]=i.useMemo((()=>[()=>e&&c.current&&I.select(e).transition().call(c.current.scaleBy,2),()=>e&&c.current&&I.select(e).transition().call(c.current.scaleBy,.5),()=>e&&c.current&&I.select(e).transition().call(c.current.scaleTo,.5),()=>e&&c.current&&I.select(e).call(c.current.transform,I.zoomIdentity.translate(0,0).scale(1)).transition().call(c.current.scaleTo,.5)]),[e]);return i.useEffect((()=>{e&&(c.current=I.zoom().scaleExtent([d.min,d.max]).extent([[0,0],[r,a]]).on("zoom",(({transform:e})=>n(e))),I.select(e).call(c.current))}),[a,r,n,e,t,c,d,d.max,d.min]),i.useEffect((()=>{h()}),[h,d]),G.jsxs(o.Box,{sx:{display:"grid",gridTemplateColumns:`repeat(${s?3:2}, 1fr)`,gridGap:"6px",position:"absolute",top:"-32px",right:0},children:[s&&G.jsx(o.Button,{size:o.Button.Size.small,sx:{borderRadius:16},onClick:()=>{l(),m()},disabled:!1,children:G.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:[G.jsx("polyline",{points:"1 4 1 10 7 10"}),G.jsx("polyline",{points:"23 20 23 14 17 14"}),G.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"})]})}),G.jsx(o.Button,{size:o.Button.Size.small,sx:{borderRadius:16},onClick:u,disabled:!1,children:G.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:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})}),G.jsx(o.Button,{size:o.Button.Size.small,sx:{borderRadius:16},onClick:p,disabled:!1,children:G.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:[G.jsx("circle",{cx:"11",cy:"11",r:"8"}),G.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),G.jsx("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]})}const fc=e=>e.price0,xc=e=>e.activeLiquidity;function gc({id:e="liquidityChartRangeInput",data:{series:t,current:n},ticksAtLimit:r,styles:a,dimensions:{width:l,height:s},margins:d,interactive:c=!0,brushDomain:u,brushLabels:p,onBrushDomainChange:h,zoomLevels:m}){const f=i.useRef(null),[x,g]=i.useState(null),[y,v]=i.useMemo((()=>[s-d.top-d.bottom,l-d.left-d.right]),[l,s,d]),{xScale:b,yScale:j}=i.useMemo((()=>{const e={xScale:I.scaleLinear().domain([n*m.initialMin,n*m.initialMax]).range([0,v]),yScale:I.scaleLinear().domain([0,I.max(t,xc)]).range([y,0])};if(x){const t=x.rescaleX(e.xScale);e.xScale.domain(t.domain())}return e}),[n,m.initialMin,m.initialMax,v,t,y,x]);return i.useEffect((()=>{g(null)}),[m]),i.useEffect((()=>{u||h(b.domain(),void 0)}),[u,h,b]),G.jsxs(G.Fragment,{children:[G.jsx(mc,{svg:f.current,xScale:b,setZoom:g,width:v,height:s,resetBrush:()=>{h([n*m.initialMin,n*m.initialMax],"reset")},showResetButton:Boolean(r[Ud.LOWER]||r[Ud.UPPER]),zoomLevels:m}),G.jsxs("svg",{width:"100%",height:"100%",viewBox:`0 0 ${l} ${s}`,style:{overflow:"visible"},children:[G.jsxs("defs",{children:[G.jsx("clipPath",{id:`${e}-chart-clip`,children:G.jsx("rect",{x:"0",y:"0",width:v,height:s})}),u&&G.jsx("mask",{id:`${e}-chart-area-mask`,children:G.jsx("rect",{fill:"white",x:b(u[0]),y:"0",width:b(u[1])-b(u[0]),height:y})})]}),G.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[G.jsxs("g",{clipPath:`url(#${e}-chart-clip)`,children:[G.jsx(ec,{series:t,xScale:b,yScale:j,xValue:fc,yValue:xc}),u&&G.jsx("g",{mask:`url(#${e}-chart-area-mask)`,children:G.jsx(ec,{series:t,xScale:b,yScale:j,xValue:fc,yValue:xc,fill:a.area.selection})}),G.jsx(hc,{value:n,xScale:b,innerHeight:y}),G.jsx(nc,{xScale:b,innerHeight:y})]}),G.jsx(o.Box,{component:"rect",width:v,height:s,ref:f,sx:{fill:"transparent",cursor:"grab","&:active":{cursor:"grabbing"}}}),G.jsx(pc,{id:e,xScale:b,interactive:c,brushLabelValue:p,brushExtent:null!=u?u:b.domain(),innerWidth:v,innerHeight:y,setBrushExtent:h,westHandleColor:a.brush.handle.west,eastHandleColor:a.brush.handle.east})]})]})]})}function yc({tick:e,decimalsA:t,decimalsB:n}){if(!t||!n||"number"!=typeof e)return;const o=y.SqrtPriceMath.getSqrtPriceX64FromTick(e);return new r(y.SqrtPriceMath.sqrtPriceX64ToPrice(o,t,n).toString())}var vc;function bc(e){const t=Ua(),n=d.useQuery({queryKey:["clmm","getPoolInfoFromRpc",e],enabled:null!=e&&null!=t,queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!t||!e)return null;try{const{poolInfo:n,poolKeys:o,computePoolInfo:i,tickData:r}=yield t.clmm.getPoolInfoFromRpc(e);return{poolInfo:n,poolKeys:o,computePoolInfo:i,tickData:r}}catch(e){return console.error("getPoolInfoFromRpc error",e),null}}))});return n.isLoading?[vc.LOADING,null,e]:n.isError?[vc.INVALID,null,e]:n.data?[vc.EXISTS,n.data,e]:[vc.NOT_EXISTS,null,e]}function jc(e,t,n,o){return bc(i.useMemo((()=>{if(!e||!t||!n)return null;const i=function({chainId:e,feeAmount:t,mint1Address:n,mint2Address:o}){const[i,r]=new T(new u.PublicKey(n).toBuffer()).gt(new T(new u.PublicKey(o).toBuffer()))?[o,n]:[n,o],[a,l]=[new u.PublicKey(i),new u.PublicKey(r)],s=gi[e];if(!s)throw new Error("Invalid config");const d=s.config.find((e=>e.tradeFeeRate===t));if(!d)throw new Error("Invalid fee");const{publicKey:c}=y.getPdaPoolId(s.programId,new u.PublicKey(d.id),a,l);return c}({mint1Address:e,mint2Address:t,feeAmount:n,chainId:o}).toBase58();return i}),[o,n,e,t]))}!function(e){e[e.LOADING=0]="LOADING",e[e.NOT_EXISTS=1]="NOT_EXISTS",e[e.EXISTS=2]="EXISTS",e[e.INVALID=3]="INVALID"}(vc||(vc={}));const Cc=8,wc=(e,t)=>e&&t?Math.floor(e/Fd[t])*Fd[t]:void 0,kc=1e3;function Tc(e,t){const[o,r]=i.useState(0),[a,l]=i.useState([]),{data:s,error:c,isLoading:u}=function(e,t=0,o){const i=rr().getQuery(n.AMMV3Api.graphql.AllV3TicksDocument,{skip:t,first:kc,where:{chain:o?n.chainIdToShortName[o]:n.chainIdShortNameEnum.SOON_TESTNET,poolAddress:null!=e?e:"",pairType:n.CLMM}});return d.useQuery(Object.assign(Object.assign({},i),{enabled:!!e}))}(e,o,t),p=null==s?void 0:s.amm_getTicksData.ticks;return i.useEffect((()=>{(null==p?void 0:p.length)&&(l((e=>[...e,...p])),(null==p?void 0:p.length)===kc&&r((e=>e+kc)))}),[p]),{isLoading:u||(null==p?void 0:p.length)===kc,error:c,ticks:a}}function Rc({mint1:e,mint2:t,feeAmount:n}){const{isLoading:o,error:r,data:a}=function(e,t,n,o){var r,a;const{chainId:l}=Zo(),[s,d,c]=jc(null==e?void 0:e.address,null==t?void 0:t.address,n,l),u=null===(r=null==d?void 0:d.computePoolInfo)||void 0===r?void 0:r.tickCurrent,p=i.useMemo((()=>wc(u,n)),[u,n]),{isLoading:h,error:m,ticks:f}=Tc(c,l);return i.useMemo((()=>{var n,o,i,r,a,l;if(!e||!t||void 0===p||s!==vc.EXISTS||!f||0===f.length||h)return{isLoading:h||s===vc.LOADING,error:m,activeTick:p,data:void 0};const c=f.findIndex((e=>(null==e?void 0:e.tickIdx)&&e.tickIdx>p))-1;if(c<0)return console.log("usePoolTickData","usePoolActiveLiquidity","TickData pivot not found",{mint1:e.address,mint2:t.address,chainId:e.chainId}),{isLoading:h,error:m,activeTick:p,data:void 0};const u=yc({decimalsA:e.decimals,decimalsB:t.decimals,tick:p}),x={liquidityActive:null!==(o=null===(n=null==d?void 0:d.computePoolInfo)||void 0===n?void 0:n.liquidity.toNumber())&&void 0!==o?o:0,tick:p,liquidityNet:Number(null===(i=f[c])||void 0===i?void 0:i.tickIdx)===p?Number(null!==(a=null===(r=f[c])||void 0===r?void 0:r.liquidityNet)&&void 0!==a?a:0):0,price0:null!==(l=null==u?void 0:u.toFixed(Cc))&&void 0!==l?l:"",sdkPrice:u},g=[].concat(x).concat([]);return{isLoading:h,error:m,data:g}}),[p,m,h,e,t,null===(a=null==d?void 0:d.computePoolInfo)||void 0===a?void 0:a.liquidity,s,f])}(e,t,n),l=i.useCallback((()=>{if(!(null==a?void 0:a.length))return;const e=[];for(let t=0;t<a.length;t++){const n=a[t],o={activeLiquidity:parseFloat(n.liquidityActive.toString()),price0:parseFloat(n.price0)};o.activeLiquidity>0&&e.push(o)}return e}),[a]);return i.useMemo((()=>({isLoading:o,error:r,formattedData:o?void 0:l()})),[o,r,l])}const Sc={[Vd.LOW]:{initialMin:.999,initialMax:1.001,min:1e-5,max:1.5}};function Ic({message:e,icon:t}){return G.jsxs(Xd,{style:{height:"100%",justifyContent:"center"},children:[t,e&&G.jsx(o.Box,{sx:{mt:20,p:10,typography:"caption",textAlign:"center"},children:e})]})}function Bc(){return G.jsx(o.LoadingSkeleton,{})}function Mc({mint1:t,mint2:n,feeAmount:r,ticksAtLimit:a,price:s,priceLower:d,priceUpper:c,onLeftRangeInput:u,onRightRangeInput:p,interactive:h}){const m=!0,{isLoading:f,error:x,formattedData:g}=Rc({mint1:t,mint2:n,feeAmount:r}),y=i.useCallback(((e,t)=>{let n=Number(e[0]);const o=Number(e[1]);n<=0&&(n=1/10**6),l.batch((()=>{(!a[Ud.LOWER]||"handle"===t||"reset"===t)&&n>0&&u(n.toFixed(6)),(!a[Ud.UPPER]||"reset"===t)&&o>0&&o<1e35&&p(o.toFixed(6))}))}),[m,u,p,a]);h=h&&Boolean(null==g?void 0:g.length);const v=i.useMemo((()=>{const e=d,t=c;return e&&t?[parseFloat(null==e?void 0:e.toString()),parseFloat(null==t?void 0:t.toString())]:void 0}),[d,c]),b=i.useCallback(((e,t)=>{if(!s)return"";if("w"===e&&a[Ud.LOWER])return"0";if("e"===e&&a[Ud.UPPER])return"∞";const n=(t<s?-1:1)*((Math.max(t,s)-Math.min(t,s))/s)*100;return s?`${Ko({input:n,decimals:2})}%`:""}),[m,s,a]),j=!t||!n||void 0===g&&!f&&!x;return G.jsx(Gd,{gap:"md",style:{minHeight:"200px"},children:j?G.jsx(Ic,{message:G.jsx(e.Trans,{id:"OZUH85",message:"Your position will appear here."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:$d.neutral1,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),G.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"})]})}):f?G.jsx(Bc,{}):x?G.jsx(Ic,{message:G.jsx(e.Trans,{id:"79D0qY",message:"Liquidity data not available."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:$d.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.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"}),G.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}):g&&0!==g.length&&s?G.jsx(o.Box,{sx:{position:"relative",width:"100%",maxHeight:"200px",justifyContent:"center",alignContent:"center"},children:G.jsx(gc,{data:{series:g,current:s},dimensions:{width:560,height:200},margins:{top:10,right:2,bottom:20,left:0},styles:{area:{selection:$d.accent1},brush:{handle:{west:$d.critical,east:$d.accent1}}},interactive:h,brushLabels:b,brushDomain:v,onBrushDomainChange:y,zoomLevels:Sc[null!=r?r:Vd.LOW],ticksAtLimit:a})}):G.jsx(Ic,{message:G.jsx(e.Trans,{id:"rH6vg9",message:"There is no liquidity data."}),icon:G.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"56",height:"56",viewBox:"0 0 24 24",fill:"none",stroke:$d.neutral2,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[G.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"10"}),G.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4"}),G.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"14"})]})})})}const Ec=({value:e,decrement:t,increment:n,decrementDisabled:r=!1,incrementDisabled:a=!1,locked:l,onUserInput:s,title:d,perPriceText:c})=>{const u=o.useTheme(),[p,h]=i.useState(""),[m,f]=i.useState(!1),x=i.useCallback((()=>{f(!1),s(p)}),[p,s]),g=i.useCallback((()=>{f(!1),s(t())}),[t,s]),y=i.useCallback((()=>{f(!1),s(n())}),[n,s]);return i.useEffect((()=>{p===e||m||setTimeout((()=>{h(e)}),0)}),[p,m,e]),G.jsx(o.Box,{onFocus:()=>{f(!0)},onBlur:x,sx:{width:"100%",py:12,px:20,borderRadius:16,backgroundColor:u.palette.background.input},children:G.jsxs(o.Box,{sx:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsx(o.Box,{sx:{typography:"body2",fontWeight:600,color:u.palette.text.primary},children:d}),G.jsx(o.Box,{sx:{mt:4,typography:"h6",fontWeight:500,color:u.palette.text.secondary},children:c}),G.jsx(Es,{sx:{mt:12},value:p,onChange:e=>{h(e)},readOnly:l})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:8},children:[!l&&G.jsx(o.Button,{size:o.Button.Size.small,onClick:y,disabled:a,sx:{px:4,backgroundColor:u.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("path",{d:"M14.25 9.75H9.75V14.25H8.25V9.75H3.75V8.25H8.25V3.75H9.75V8.25H14.25V9.75Z",fill:r?u.palette.text.disabled:u.palette.text.primary})})}),!l&&G.jsx(o.Button,{size:o.Button.Size.small,onClick:g,disabled:r,sx:{px:4,backgroundColor:u.palette.background.paper,"&[disabled]":{cursor:"default"}},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.jsx("rect",{x:"3.75",y:"8.25",width:"10.5",height:"1.5",fill:r?u.palette.text.disabled:u.palette.text.primary})})})]})]})})},Lc=({priceLower:t,priceUpper:n,onLeftRangeInput:i,onRightRangeInput:r,getDecrementLower:a,getIncrementLower:l,getDecrementUpper:s,getIncrementUpper:d,perPriceText:c,ticksAtLimit:u})=>{var p,h;const m=t,f=n;return G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:8},children:[G.jsx(Ec,{value:u[Ud.LOWER]?"0":null!==(p=null==m?void 0:m.dp(8).toString())&&void 0!==p?p:"",onUserInput:i,decrement:a,increment:l,decrementDisabled:void 0===m||u[Ud.LOWER],incrementDisabled:void 0===m||u[Ud.LOWER],title:G.jsx(e.Trans,{id:"uEoBVI",message:"Low price"}),perPriceText:c}),G.jsx(Ec,{value:u[Ud.UPPER]?"∞":null!==(h=null==f?void 0:f.dp(8).toString())&&void 0!==h?h:"",onUserInput:r,decrement:s,increment:d,incrementDisabled:void 0===f||u[Ud.UPPER],decrementDisabled:void 0===f||u[Ud.UPPER],title:G.jsx(e.Trans,{id:"kAC8rT",message:"High price"}),perPriceText:c})]})},Oc=({mintA:e,mintB:t,selectedMintIndex:n,handleRateToggle:i,sx:r})=>{const a=o.useTheme();return G.jsx(o.Box,{component:o.ButtonBase,onClick:i,sx:Object.assign({display:"flex",alignItems:"center",p:1,borderRadius:8,backgroundColor:a.palette.border.main},r),children:G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",width:"100%",[a.breakpoints.up("tablet")]:{width:"auto"}},children:[e,t].map(((e,t)=>{const i=n===t;return G.jsx(o.Box,{sx:Object.assign({flexGrow:1,flexShrink:1,flexBasis:"50%",px:12,py:4,borderRadius:7,textAlign:"center",typography:"h6",whiteSpace:"nowrap"},i?{color:a.palette.text.primary,backgroundColor:a.palette.background.paper}:{color:a.palette.text.secondary,backgroundColor:"transparent"}),children:e.symbol},e.address)}))})})};function Wc(e,t){var n;return e?{chainId:t,address:e.id,name:e.name,decimals:Number(e.decimals),symbol:e.symbol,logoURI:null!==(n=e.logoImg)&&void 0!==n?n:""}:e}function Vc(e){var t,n,o,i;const r=null==e?void 0:e.pair;if(r)return{address:r.id,chainId:r.chainId,baseToken:Wc(r.baseToken,r.chainId),quoteToken:Wc(r.quoteToken,r.chainId),type:r.type,creator:r.creator,baseLpToken:{id:null===(t=r.baseLpToken)||void 0===t?void 0:t.id},quoteLpToken:{id:null===(n=r.quoteLpToken)||void 0===n?void 0:n.id},lpFeeRate:null===(o=null==e?void 0:e.pair)||void 0===o?void 0:o.lpFeeRate,mtFeeRate:null===(i=null==e?void 0:e.pair)||void 0===i?void 0:i.mtFeeRate}}function Ac(e){const t=Vc(e);if(t)return Object.assign(Object.assign({},t),{liquidityPositions:null==e?void 0:e.liquidityPositions})}function Fc(e){switch(e){case"SVM_AMMV2":return"AMM V2";case"SVM_AMMV3":return"AMM V3";default:return"PMM"}}function Pc({type:e,lpFeeRate:t,mtFeeRate:n}){var o,i;return"SVM_AMMV3"===e?null!==(i=null===(o=Pd[t])||void 0===o?void 0:o.label)&&void 0!==i?i:"-":`${Ko({input:new r(null!=t?t:0).plus(null!=n?n:0).div(1e4),decimals:4})}%`}new n.PoolApi,new n.AMMV3Api;const Zc=({sx:e})=>{const n=o.useTheme();return G.jsx(o.Box,{sx:Object.assign({py:4,px:8,color:n.palette.primary.main,borderRadius:4,backgroundColor:o.alpha(n.palette.primary.main,.1),typography:"h6"},e),children:t.i18n._({id:"m8r/Yx",message:"AMM V3"})})};function Nc({removed:e,inRange:n}){const i=o.useTheme(),r={py:4,px:8,color:i.palette.success.main,borderRadius:4,backgroundColor:o.alpha(i.palette.success.main,.1),typography:"h6"};return e?G.jsx(o.Tooltip,{title:t.i18n._({id:"MZPP7t",message:"Your position has 0 liquidity, and is not earning fees."}),children:G.jsx(o.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.warning.main,backgroundColor:o.alpha(i.palette.warning.main,.1)}),children:t.i18n._({id:"D87pha",message:"Closed"})})}):n?G.jsx(o.Tooltip,{title:t.i18n._({id:"aIvv/z",message:"The price of this pool is within your selected range. Your position is currently earning fees."}),children:G.jsx(o.Box,{sx:r,children:t.i18n._({id:"vOyUlD",message:"In range"})})}):G.jsx(o.Tooltip,{title:t.i18n._({id:"IwiTcw",message:"The price of this pool is outside of your selected range. Your position is not currently earning fees."}),children:G.jsx(o.Box,{sx:Object.assign(Object.assign({},r),{color:i.palette.error.main,backgroundColor:o.alpha(i.palette.error.main,.1)}),children:t.i18n._({id:"i3Z+/Z",message:"Out of range"})})})}function Uc({price:e,atLimit:t,direction:n}){return t[n]?n===Ud.LOWER?"0":"∞":"string"==typeof e&&"∞"===e?"∞":Ko({input:e})}const Hc=({position:t,title:n,ticksAtLimit:r})=>{const{poolInfo:{mintA:a,mintB:l,feeRate:s,price:d},liquidity:c,amountA:u,amountB:p,tickLowerPrice:h,tickUpperPrice:m}=t,f=o.useTheme(),[x,g]=i.useState(a),y=i.useMemo((()=>x.address===a.address?l:a),[x.address,a,l]),v=i.useCallback((()=>{g(y)}),[y]);return G.jsxs(Gd,{gap:"md",children:[G.jsxs(Jd,{children:[n?G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:f.palette.text.secondary},children:n}):G.jsx("div",{}),G.jsx(Oc,{mintA:a,mintB:l,selectedMintIndex:0,handleRateToggle:v})]}),G.jsxs(Jd,{children:[G.jsxs(zd,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"EQs1sJ",message:"Min price"})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:y.symbol,1:x.symbol}})})]}),G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"caption"},children:Uc({price:h,atLimit:r,direction:Ud.LOWER})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==x?void 0:x.symbol}})})]}),G.jsxs(zd,{sx:{width:"48%",py:12,gap:12},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",gap:4},children:[G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"5etEUX",message:"Max price"})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:y.symbol,1:x.symbol}})})]}),G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"caption"},children:Uc({price:m,atLimit:r,direction:Ud.UPPER})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"WgTuci",message:"Your position will be 100% composed of {0} at this price",values:{0:null==y?void 0:y.symbol}})})]})]}),G.jsxs(zd,{sx:{py:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},children:[G.jsxs(Gd,{gap:"4px",justify:"flex-start",children:[G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"body2"},children:G.jsx(e.Trans,{id:"DWd30U",message:"Current price"})}),G.jsx(o.Box,{sx:{color:f.palette.text.secondary,typography:"h6"},children:G.jsx(e.Trans,{id:"7Z4WfS",message:"{0} per {1}",values:{0:y.symbol,1:x.symbol}})})]}),G.jsx(o.Box,{sx:{color:f.palette.text.primary,typography:"caption"},children:Ko({input:d})})]})]})},Dc=({position:t,title:i,inRange:r,ticksAtLimit:a})=>{Zo();const{poolInfo:{mintA:l,mintB:s,feeRate:d},liquidity:c,amountA:u,amountB:p}=t,h=c.isZero();return G.jsxs(Gd,{gap:"md",style:{marginTop:"0.5rem"},children:[G.jsxs(Jd,{style:{gap:4},children:[G.jsxs(Qd,{children:[G.jsx(gd,{tokens:[{address:l.address},{address:s.address}],mr:8}),G.jsxs(o.Box,{sx:{typography:"h5"},children:[l.symbol," / ",s.symbol]})]}),G.jsx(Zc,{sx:{ml:"auto"}}),G.jsx(Nc,{removed:h,inRange:r})]}),G.jsxs(zd,{children:[G.jsxs(Gd,{gap:"md",children:[G.jsxs(Jd,{children:[G.jsxs(Qd,{children:[G.jsx(Wa,{address:l.address,chainId:l.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(o.Box,{sx:{ml:8},children:l.symbol})]}),G.jsx(Qd,{children:G.jsx(o.Box,{sx:{mr:8},children:Ko({input:u,decimals:l.decimals})})})]}),G.jsxs(Jd,{children:[G.jsxs(Qd,{children:[G.jsx(Wa,{address:s.address,chainId:s.chainId,noShowChain:!0,width:32,height:32,marginRight:0}),G.jsx(o.Box,{ml:"8px",children:s.symbol})]}),G.jsx(Qd,{children:G.jsx(o.Box,{mr:"8px",children:Ko({input:p,decimals:s.decimals})})})]})]}),G.jsxs(Jd,{children:[G.jsx(o.Box,{children:G.jsx(e.Trans,{id:"EU3wU4",message:"Fee tier"})}),G.jsx(o.Box,{children:Pc({type:n.CLMM,lpFeeRate:d,mtFeeRate:0})})]})]}),G.jsx(Hc,{position:t,title:i,ticksAtLimit:a})]})},Yc=({position:e,outOfRange:n,ticksAtLimit:i,on:r,onClose:a,onConfirm:l,loading:s})=>{const{isMobile:d}=Ls();return G.jsx(ds,{open:r,onClose:a,modal:!0,title:t.i18n._({id:"E6MqGy",message:"Add liquidity"}),height:683,children:G.jsxs(o.Box,{sx:{flex:1,px:20,pb:24,display:"flex",flexDirection:"column",justifyContent:"space-between",width:d?void 0:420},children:[G.jsx(o.Box,{sx:{pt:0,px:0},children:e?G.jsx(Dc,{position:e,inRange:!n,ticksAtLimit:i,title:t.i18n._({id:"3VUfrF",message:"Selected Range"})}):null}),G.jsx(o.Button,{size:o.Button.Size.big,fullWidth:!0,isLoading:s,sx:{mt:20},onClick:l,children:t.i18n._({id:"m16xKo",message:"Add"})})]})})};var zc;function qc(){return qc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},qc.apply(null,arguments)}const Xc=e=>O.createElement("svg",qc({width:18,height:18,viewBox:"0 0 18 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),zc||(zc=O.createElement("g",{id:"ICON/18px/arrow/\\xE6\\x94\\xB6\\xE8\\xB5\\xB7/Dark"},O.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 Gc({token:e,oppositeTokenAddress:n,dispatch:r,tokenSelectOnChange:a}){const l=o.useTheme(),{chainId:s}=Zo(),[d,c]=i.useState(!1);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,sx:{flexBasis:"100%",flexGrow:1,flexShrink:1,display:"flex",alignItems:"center",px:20,py:8,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:e?l.palette.border.main:l.palette.primary.main,color:e?l.palette.text.primary:l.palette.primary.contrastText,backgroundColor:e?"transparent":l.palette.primary.main,"&:hover":{borderColor:e?l.palette.border.main:l.palette.primary.main},[l.breakpoints.up("tablet")]:{flexBasis:"50%"}},onClick:()=>{c(!0)},children:[e?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[G.jsx(Wa,{address:e.address,marginRight:0,width:24,height:24,chainId:e.chainId||s,noShowChain:!0,sx:{flexShrink:0}}),G.jsx(o.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:e.symbol})]}):G.jsx(o.Box,{sx:{typography:"h5",fontWeight:600,lineHeight:"32px",flexShrink:0},children:t.i18n._({id:"0RrIzN",message:"Select token"})}),G.jsx(o.Box,{component:Xc,sx:{flexShrink:0,ml:"auto",width:18,height:18}})]}),G.jsx(Ds,{value:e,open:d,chainId:s,occupiedAddrs:[n],occupiedChainId:null==e?void 0:e.chainId,onClose:()=>{c(!1)},onTokenChange:(e,t)=>{if(!Array.isArray(e)){if(t)return r({type:Wd.UpdateMint1AndClearMint2,payload:e}),void c(!1);a(e),c(!1)}},modal:!0})]})}const _c=({mint1:e,mint2:t,dispatch:n})=>{var i,r;const a=o.useTheme();return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",[a.breakpoints.up("tablet")]:{flexWrap:"nowrap"}},children:[G.jsx(Gc,{token:e,oppositeTokenAddress:null!==(i=null==t?void 0:t.address)&&void 0!==i?i:"",dispatch:n,tokenSelectOnChange:e=>{n({type:Wd.UpdateMint1,payload:e})}}),G.jsx(Gc,{token:t,oppositeTokenAddress:null!==(r=null==e?void 0:e.address)&&void 0!==r?r:"",dispatch:n,tokenSelectOnChange:e=>{n({type:Wd.UpdateMint2,payload:e})}})]})};function Jc({mint:e,chainId:t,symbol:n}){const{fetchTokenInfo:o}=yi();return d.useQuery({queryKey:["token","info",t,e],queryFn:()=>Wo(this,void 0,void 0,(function*(){return yield o({mint:e,chainId:t,symbol:n})})),enabled:!!e}).data}function Qc(e,t){B(Number.isInteger(e)&&Number.isInteger(t),"INTEGERS"),B(t>0,"TICK_SPACING"),B(e>=y.MIN_TICK&&e<=y.MAX_TICK,"TICK_BOUND");const n=Math.round(e/t)*t;return n<y.MIN_TICK?n+t:n>y.MAX_TICK?n-t:n}function Kc({price:e,feeAmount:t,mintDecimalsA:n,mintDecimalsB:o,baseIn:i}){const r=new S(e.toString()),a=i?r:new S(1).div(r),l=y.TickMath.getTickWithPriceAndTickspacing(a,Fd[t],n,o),s=y.SqrtPriceMath.getSqrtPriceX64FromTick(l),d=y.SqrtPriceMath.sqrtPriceX64ToPrice(s,n,o);return i?{tick:l,price:d}:{tick:l,price:new S(1).div(d)}}const $c=[n.ChainId.MAINNET,n.ChainId.ARBITRUM_ONE,n.ChainId.SEPOLIA,n.ChainId.TAIKO],eu={v3CoreFactoryAddress:"0x3d2A7Bac4E8439ABe86B58324695e921a5FC0987",nonfungiblePositionManagerAddress:"0x483E5c0f309577f79b0a19cE65E332DD388aD7A8"},tu=Object.assign({},eu),nu=Object.assign({},eu),ou={v3CoreFactoryAddress:"0x3d2A7Bac4E8439ABe86B58324695e921a5FC0987",nonfungiblePositionManagerAddress:"0x483E5c0f309577f79b0a19cE65E332DD388aD7A8"},iu={[n.ChainId.MAINNET]:tu,[n.ChainId.ARBITRUM_ONE]:nu,[n.ChainId.SEPOLIA]:ou,[n.ChainId.TAIKO]:ou};var ru,au;Object.assign({},$c.reduce(((e,t)=>(e[t]=iu[t].v3CoreFactoryAddress,e)),{})),Object.assign({},$c.reduce(((e,t)=>{const n=iu[t].nonfungiblePositionManagerAddress;return n&&(e[t]=n),e}),{})),function(e){e[e.EXACT_INPUT=0]="EXACT_INPUT",e[e.EXACT_OUTPUT=1]="EXACT_OUTPUT"}(ru||(ru={})),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"}(au||(au={})),M.BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const lu={[au.ROUND_DOWN]:r.ROUND_DOWN,[au.ROUND_HALF_UP]:r.ROUND_HALF_UP,[au.ROUND_UP]:r.ROUND_UP},su={[au.ROUND_DOWN]:r.ROUND_DOWN,[au.ROUND_HALF_UP]:r.ROUND_HALF_UP,[au.ROUND_UP]:r.ROUND_UP};class du{constructor(e,t=M.BigInt(1)){this.numerator=M.BigInt(e),this.denominator=M.BigInt(t)}static tryParseFraction(e){if(e instanceof M||"number"==typeof e||"string"==typeof e)return new du(e);if("numerator"in e&&"denominator"in e)return e;throw new Error("Could not parse fraction")}get quotient(){return M.divide(this.numerator,this.denominator)}get remainder(){return new du(M.remainder(this.numerator,this.denominator),this.denominator)}invert(){return new du(this.denominator,this.numerator)}add(e){const t=du.tryParseFraction(e);return M.equal(this.denominator,t.denominator)?new du(M.add(this.numerator,t.numerator),this.denominator):new du(M.add(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator)),M.multiply(this.denominator,t.denominator))}subtract(e){const t=du.tryParseFraction(e);return M.equal(this.denominator,t.denominator)?new du(M.subtract(this.numerator,t.numerator),this.denominator):new du(M.subtract(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator)),M.multiply(this.denominator,t.denominator))}lessThan(e){const t=du.tryParseFraction(e);return M.lessThan(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator))}equalTo(e){const t=du.tryParseFraction(e);return M.equal(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator))}greaterThan(e){const t=du.tryParseFraction(e);return M.greaterThan(M.multiply(this.numerator,t.denominator),M.multiply(t.numerator,this.denominator))}multiply(e){const t=du.tryParseFraction(e);return new du(M.multiply(this.numerator,t.numerator),M.multiply(this.denominator,t.denominator))}divide(e){const t=du.tryParseFraction(e);return new du(M.multiply(this.numerator,t.denominator),M.multiply(this.denominator,t.numerator))}toSignificant(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=au.ROUND_HALF_UP){B(Number.isInteger(e),`${e} is not an integer.`),B(e>0,`${e} is not positive.`);const o=lu[n],i=new r(this.numerator.toString()).div(this.denominator.toString()).precision(e,o);return i.toFormat(i.decimalPlaces(),o,t)}toFixed(e,t={decimalSeparator:".",groupSeparator:"",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:"",fractionGroupSize:0},n=au.ROUND_HALF_UP){B(Number.isInteger(e),`${e} is not an integer.`),B(e>=0,`${e} is negative.`);const o=su[n];return new r(this.numerator.toString()).decimalPlaces(e,o).div(this.denominator.toString()).toFormat(e,o,t)}get asFraction(){return new du(this.numerator,this.denominator)}}const cu=new du(M.BigInt(100));function uu(e){return new pu(e.numerator,e.denominator)}class pu extends du{constructor(){super(...arguments),this.isPercent=!0}add(e){return uu(super.add(e))}subtract(e){return uu(super.subtract(e))}multiply(e){return uu(super.multiply(e))}divide(e){return uu(super.divide(e))}toSignificant(e=5,t,n){return super.multiply(cu).toSignificant(e,t,n)}toFixed(e=2,t,n){return super.multiply(cu).toFixed(e,t,n)}}function hu(e){const t=new r(e);if(t.isFinite())return t}M.BigInt(Number.MAX_SAFE_INTEGER),M.BigInt(0),M.BigInt(1),M.BigInt(2),M.BigInt(0);new pu(M.BigInt(1),1e4),new pu(1,100),new pu(3,100),new pu(5,100),new pu(10,100),new pu(15,100);const mu=new pu(0);function fu({mint:e,chainId:t}){const{account:n}=Zo(),{fetchTokenBalance:o}=yi();return d.useQuery({queryKey:["token","balance",t,n,e],queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!e)return;return(yield o(e.toString())).amount})),enabled:!!n&&!!e}).data}function xu({state:e,existingPosition:n,slipperValue:o}){const{account:a,chainId:l}=Zo(),s=Ua(),{feeAmount:d,selectedMintIndex:p,independentField:h,typedValue:m,leftRangeTypedValue:f,rightRangeTypedValue:x,startPriceTypedValue:g}=e,{mint1:v,mint2:b}=e,[j,C]=i.useMemo((()=>v&&b?new T(new u.PublicKey(v.address).toBuffer()).gt(new T(new u.PublicKey(b.address).toBuffer()))?[b,v]:[v,b]:[void 0,void 0]),[v,b]),w=h===Nd.DEPOSIT_1?Nd.DEPOSIT_2:Nd.DEPOSIT_1,[k,R]=i.useMemo((()=>j&&C?0==p?[j,C]:[C,j]:[void 0,void 0]),[j,C,p]),I=fu({mint:null==k?void 0:k.address,chainId:null==k?void 0:k.chainId}),B=fu({mint:null==R?void 0:R.address,chainId:null==R?void 0:R.chainId}),M=i.useMemo((()=>({[Nd.DEPOSIT_1]:I,[Nd.DEPOSIT_2]:B})),[I,B]),[E,L,O]=jc(null==v?void 0:v.address,null==b?void 0:b.address,d,l),W=E===vc.NOT_EXISTS,V=i.useMemo((()=>{if(!C)return;if(W){const e=hu(g);if(!e)return;return 0===p?e:new r(1).div(e).dp(C.decimals,r.ROUND_UP)}if(!L||null==L.poolInfo.price)return;return new r(L.poolInfo.price)}),[C,W,L,g,p]),A=i.useMemo((()=>{if(!V||null==(null==j?void 0:j.decimals)||null==(null==C?void 0:C.decimals))return!0;const e=y.SqrtPriceMath.priceToSqrtPriceX64(new S(V.toString()),null==j?void 0:j.decimals,null==C?void 0:C.decimals);return!(e&&!e.gt(y.MAX_SQRT_PRICE_X64)&&!e.lt(y.MIN_SQRT_PRICE_X64))}),[V,j,C]),F=i.useMemo((()=>{if(j&&C){if(L){return Object.assign(Object.assign({},L.poolInfo),{mintA:Object.assign(Object.assign({},L.poolInfo.mintA),{chainId:j.chainId,symbol:j.symbol}),mintB:Object.assign(Object.assign({},L.poolInfo.mintB),{chainId:C.chainId,symbol:C.symbol}),tickCurrent:L.computePoolInfo.tickCurrent})}if(d&&V&&!A&&O){const e=gi[l];if(!e)throw new Error("Invalid config");const t=e.config.find((e=>e.tradeFeeRate===d));if(!t)throw new Error("Invalid fee");const{tick:n}=Kc({mintDecimalsA:j.decimals,mintDecimalsB:C.decimals,feeAmount:d,price:V,baseIn:0===p});if(null==n)throw new Error("Invalid tick");return{type:"Concentrated",config:t,programId:e.programId.toBase58(),id:O,mintA:Object.assign(Object.assign({},y.toApiV3Token({address:j.address,decimals:j.decimals,programId:c.TOKEN_PROGRAM_ID.toBase58(),extensions:{feeConfig:void 0}})),{chainId:j.chainId,symbol:j.symbol}),mintB:Object.assign(Object.assign({},y.toApiV3Token({address:C.address,decimals:C.decimals,programId:c.TOKEN_PROGRAM_ID.toBase58(),extensions:{feeConfig:void 0}})),{chainId:C.chainId,symbol:C.symbol}),rewardDefaultInfos:[],rewardDefaultPoolInfos:"Clmm",price:V.toNumber(),tickCurrent:n,mintAmountA:0,mintAmountB:0,feeRate:t.tradeFeeRate,openTime:"",tvl:0,day:{volume:0,volumeQuote:0,volumeFee:0,feeApr:0,rewardApr:[0],apr:0,priceMax:0,priceMin:0},week:{volume:0,volumeQuote:0,volumeFee:0,feeApr:0,rewardApr:[0],apr:0,priceMax:0,priceMin:0},month:{volume:0,volumeQuote:0,volumeFee:0,feeApr:0,rewardApr:[0],apr:0,priceMax:0,priceMin:0},pooltype:[],farmUpcomingCount:0,farmOngoingCount:0,farmFinishedCount:0,burnPercent:0}}}}),[l,d,A,j,C,L,O,V,p]),P=i.useMemo((()=>({[Ud.LOWER]:d?Qc(y.MIN_TICK,Fd[d]):void 0,[Ud.UPPER]:d?Qc(y.MAX_TICK,Fd[d]):void 0})),[d]),Z=i.useMemo((()=>{if(n&&n.tickLower&&"number"==typeof(null==n?void 0:n.tickLower)&&n.tickUpper&&"number"==typeof(null==n?void 0:n.tickUpper))return{[Ud.LOWER]:n.tickLower,[Ud.UPPER]:n.tickUpper};if(!j||!C||!d)return{[Ud.LOWER]:void 0,[Ud.UPPER]:void 0};const e="boolean"==typeof f?void 0:hu(f),t="boolean"==typeof x?void 0:hu(x),o=0===p;return{[Ud.LOWER]:"boolean"==typeof f?P[Ud.LOWER]:e?Kc({mintDecimalsA:j.decimals,mintDecimalsB:C.decimals,feeAmount:d,price:e,baseIn:o}).tick:void 0,[Ud.UPPER]:"boolean"==typeof x?P[Ud.UPPER]:t?Kc({mintDecimalsA:j.decimals,mintDecimalsB:C.decimals,feeAmount:d,price:t,baseIn:o}).tick:void 0}}),[n,d,f,j,C,x,p,P]),{[Ud.LOWER]:N,[Ud.UPPER]:U}=Z,H=i.useMemo((()=>({[Ud.LOWER]:d&&N===P.LOWER,[Ud.UPPER]:d&&U===P.UPPER})),[P,N,U,d]),D=Boolean("number"==typeof N&&"number"==typeof U&&N>=U),Y=i.useMemo((()=>({[Ud.LOWER]:yc({tick:P.LOWER,decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals}),[Ud.UPPER]:yc({tick:P.UPPER,decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals})})),[null==j?void 0:j.decimals,null==C?void 0:C.decimals,P.LOWER,P.UPPER]),z=i.useMemo((()=>({[Ud.LOWER]:yc({tick:Z[Ud.LOWER],decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals}),[Ud.UPPER]:yc({tick:Z[Ud.UPPER],decimalsA:null==j?void 0:j.decimals,decimalsB:null==C?void 0:C.decimals})})),[null==j?void 0:j.decimals,null==C?void 0:C.decimals,Z]),{[Ud.LOWER]:q,[Ud.UPPER]:X}=z,G=Boolean(!D&&V&&q&&X&&(V.lt(q)||V.gt(X))),_=i.useMemo((()=>hu(m)),[m]),[J,Q]=i.useState(void 0);i.useEffect((()=>{let e=!0;return function(){Wo(this,void 0,void 0,(function*(){try{if(!s||!F||null==N||null==U)return;const t=yield s.fetchEpochInfo(),n=yield y.PoolUtils.getLiquidityAmountOutFromAmountIn({poolInfo:F,slippage:o,inputA:!0,tickLower:Math.min(N,U),tickUpper:Math.max(N,U),amount:new T(new S(m||"0").mul(10**F.mintA.decimals).toFixed(0)),add:!0,amountHasFee:!0,epochInfo:t});if(e){if(!n.amountSlippageB.amount)return;Q(new r(n.amountSlippageB.amount.toString()).div(new r(10**F.mintB.decimals)).dp(F.mintB.decimals,r.ROUND_UP))}}catch(e){console.error("error",e)}}))}(),()=>{e=!1}}),[F,s,o,N,U,m]);const K=i.useMemo((()=>({[Nd.DEPOSIT_1]:h===Nd.DEPOSIT_1?_:J,[Nd.DEPOSIT_2]:h===Nd.DEPOSIT_1?J:_})),[J,_,h]),$=Boolean("number"==typeof U&&(null==F?void 0:F.tickCurrent)&&F.tickCurrent>=U),ee=Boolean("number"==typeof N&&(null==F?void 0:F.tickCurrent)&&F.tickCurrent<=N),te=D||Boolean($&&F&&v&&new u.PublicKey(F.mintA.address).equals(new u.PublicKey(v.address))||ee&&F&&b&&new u.PublicKey(F.mintA.address).equals(new u.PublicKey(b.address))),ne=D||Boolean($&&F&&b&&new u.PublicKey(F.mintA.address).equals(new u.PublicKey(b.address))||ee&&F&&v&&new u.PublicKey(F.mintB.address).equals(new u.PublicKey(v.address))),{inputTax:oe,outputTax:ie}=function(){const[{inputTax:e,outputTax:t},n]=i.useState({inputTax:mu,outputTax:mu});return{inputTax:e,outputTax:t}}(),[re,ae]=i.useState();let le;i.useEffect((()=>{let e=!0;return function(){Wo(this,void 0,void 0,(function*(){try{if(!s||!F||null==N||null==U)return;const t=yield s.fetchEpochInfo(),n=yield y.PoolUtils.getLiquidityAmountOutFromAmountIn({poolInfo:F,slippage:o,inputA:!0,tickLower:Math.min(N,U),tickUpper:Math.max(N,U),amount:new T(new S(m||"0").mul(10**F.mintA.decimals).toFixed(0)),add:!0,amountHasFee:!0,epochInfo:t});e&&ae({poolInfo:F,tickLower:N,tickUpper:U,tickLowerPrice:q,tickUpperPrice:X,liquidity:new r(n.liquidity.toString()),amountA:new r(n.amountSlippageA.amount.toString()).div(new r(10**F.mintA.decimals)).dp(F.mintA.decimals,r.ROUND_UP),amountB:new r(n.amountSlippageB.amount.toString()).div(new r(10**F.mintB.decimals)).dp(F.mintB.decimals,r.ROUND_UP)})}catch(e){console.error("error",e)}}))}(),()=>{e=!1}}),[q,F,z,s,o,N,U,m,X]),a||(le=t.i18n._({id:"r7ScnQ",message:"Connect to a wallet"})),E===vc.INVALID&&(le=null!=le?le:t.i18n._({id:"R7D79P",message:"Invalid pair"})),A&&(le=null!=le?le:t.i18n._({id:"HXBqgG",message:"Invalid price input"})),(K[Nd.DEPOSIT_1]||te)&&(K[Nd.DEPOSIT_2]||ne)||(le=null!=le?le:t.i18n._({id:"iPMIoT",message:"Enter an amount"}));const{[Nd.DEPOSIT_1]:se,[Nd.DEPOSIT_2]:de}=K;se&&(null==I?void 0:I.lt(se))&&(le=t.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null==k?void 0:k.symbol}})),de&&(null==B?void 0:B.lt(de))&&(le=t.i18n._({id:"m6RmA/",message:"Insufficient {0} balance",values:{0:null==R?void 0:R.symbol}}));const ce=oe.greaterThan(0)||ie.greaterThan(0),ue=E===vc.INVALID||ce;return{mintA:j,mintB:C,dependentField:w,mints:{[Nd.DEPOSIT_1]:k,[Nd.DEPOSIT_2]:R},poolInfo:F,poolState:E,depositBalances:M,parsedAmounts:K,ticks:Z,price:V,pricesAtTicks:z,pricesAtLimit:Y,position:re,poolIsNoExisted:W,errorMessage:le,invalidPool:ue,invalidRange:D,outOfRange:G,depositADisabled:te,depositBDisabled:ne,ticksAtLimit:H,isTaxed:ce,poolKeys:W||null==L?void 0:L.poolKeys}}function gu({dispatch:e}){return{onField1Input:i.useCallback((t=>{e({type:Wd.typeInput,payload:{field:Nd.DEPOSIT_1,typedValue:t}})}),[e]),onField2Input:i.useCallback((t=>{e({type:Wd.typeInput,payload:{field:Nd.DEPOSIT_2,typedValue:t}})}),[e]),onLeftRangeInput:i.useCallback((t=>{e({type:Wd.typeLeftRangeInput,payload:{typedValue:t}})}),[e]),onRightRangeInput:i.useCallback((t=>{e({type:Wd.typeRightRangeInput,payload:{typedValue:t}})}),[e]),onStartPriceInput:i.useCallback((t=>{e({type:Wd.typeStartPriceInput,payload:{typedValue:t}})}),[e])}}new pu(1);const yu=new r(.01);function vu(e){if(e)return e.gt(yu)?e.minus(yu):new r(0)}const bu=Buffer.from("support_mint","utf8");function ju(e,t){return y.findProgramAddress([bu,t.toBuffer()],e)}function Cu({params:e,handleGoBack:a,handleGoToPoolList:l}){var s,p,h,m,f,x;const{chainId:g,account:v}=Zo(),b=Ua(),j=o.useTheme(),C=Si(),{isMobile:w}=Ls(),k=Jc({mint:null==e?void 0:e.mint1,chainId:g}),R=Jc({mint:null==e?void 0:e.mint2,chainId:g}),[I,B]=i.useReducer(Ad,{mint1:k,mint2:R,feeAmount:(null==e?void 0:e.fee)?Number(null==e?void 0:e.fee):void 0,selectedMintIndex:0,independentField:Nd.DEPOSIT_1,typedValue:"",startPriceTypedValue:"1",leftRangeTypedValue:"",rightRangeTypedValue:""});i.useEffect((()=>{k&&B({type:Wd.UpdateDefaultMint1,payload:k})}),[k]),i.useEffect((()=>{R&&B({type:Wd.UpdateDefaultMint2,payload:R})}),[R]);const{independentField:M,typedValue:E,startPriceTypedValue:L}=I,{slipper:O,setSlipper:W,slipperValue:V,resetSlipper:A}=Id({type:n.CLMM}),{mintA:F,mintB:P,poolInfo:Z,poolKeys:N,ticks:U,dependentField:H,price:D,pricesAtTicks:Y,pricesAtLimit:z,parsedAmounts:q,depositBalances:X,position:_,poolIsNoExisted:J,mints:Q,errorMessage:K,invalidPool:$,invalidRange:ee,outOfRange:te,depositADisabled:ne,depositBDisabled:oe,ticksAtLimit:ie}=xu({state:I,slipperValue:V,existingPosition:void 0}),{onField1Input:re,onField2Input:ae,onLeftRangeInput:le,onRightRangeInput:se,onStartPriceInput:de}=gu({dispatch:B}),ce=!K&&!ee,[ue,pe]=i.useState(!1),he={[M]:E,[H]:null!==(p=null===(s=q[H])||void 0===s?void 0:s.toString())&&void 0!==p?p:""},me=[Nd.DEPOSIT_1,Nd.DEPOSIT_2].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:vu(X[t])})),{}),{[Ud.LOWER]:fe,[Ud.UPPER]:xe}=U,{[Ud.LOWER]:ge,[Ud.UPPER]:ye}=Y,{getDecrementLower:ve,getIncrementLower:be,getDecrementUpper:je,getIncrementUpper:Ce,getSetFullRange:we}=function({tickLower:e,tickUpper:t,poolInfo:n,state:o,dispatch:a}){var l,s;const{feeAmount:d}=o,c=null===(l=null==n?void 0:n.mintA)||void 0===l?void 0:l.decimals,u=null===(s=null==n?void 0:n.mintB)||void 0===s?void 0:s.decimals;return{getDecrementLower:i.useCallback((()=>{if(!d)return"";const t="number"==typeof e?e:null==n?void 0:n.tickCurrent;if(!t)return"";const o=yc({decimalsA:c,decimalsB:u,tick:t-Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,e]),getIncrementLower:i.useCallback((()=>{if(!d)return"";const t="number"==typeof e?e:null==n?void 0:n.tickCurrent;if(!t)return"";const o=yc({decimalsA:c,decimalsB:u,tick:t+Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,e]),getDecrementUpper:i.useCallback((()=>{if(!d)return"";const e="number"==typeof t?t:null==n?void 0:n.tickCurrent;if(!e)return"";const o=yc({decimalsA:c,decimalsB:u,tick:e-Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,t]),getIncrementUpper:i.useCallback((()=>{if(!d)return"";const e="number"==typeof t?t:null==n?void 0:n.tickCurrent;if(!e)return"";const o=yc({decimalsA:c,decimalsB:u,tick:e+Fd[d]});return o?o.dp(5,r.ROUND_UP).toString():""}),[c,u,d,null==n?void 0:n.tickCurrent,t]),getSetFullRange:i.useCallback((()=>{a({type:Wd.setFullRange,payload:void 0})}),[a])}}({tickLower:fe,tickUpper:xe,poolInfo:Z,state:I,dispatch:B}),ke=i.useCallback((()=>{we()}),[we,le,se,z]),Te=d.useMutation({mutationFn:()=>Wo(this,void 0,void 0,(function*(){if(!v||!g)return;if(!Z)throw new Error("poolInfo is undefined");if(!D)throw new Error("price is undefined");if(!b)throw new Error("raydium is undefined");const e=gi[g];if(!e)throw new Error("Invalid config");const n=b.clmm;b.clmm.scope.checkOwner();const o=new y.TxBuilder({connection:n.scope.connection,feePayer:n.scope.ownerPubKey,cluster:n.scope.cluster,owner:n.scope.owner,blockhashCommitment:n.scope.blockhashCommitment,loopMultiTxStatus:n.scope.loopMultiTxStatus,api:n.scope.api,signAllTransactions:n.scope.signAllTransactions}),i=J?yield function(e){return Wo(this,void 0,void 0,(function*(){var t;const{programId:n,mint1:o,mint2:i,ammConfig:r,initialPrice:a,computeBudgetConfig:l,forerunCreate:s,getObserveState:d,txVersion:p,txTipConfig:h,feePayer:m,clmm:f,txBuilder:x}=e,g=(null===(t=f.scope.owner)||void 0===t?void 0:t.publicKey)||u.PublicKey.default,[v,b,j]=new T(new u.PublicKey(o.address).toBuffer()).gt(new T(new u.PublicKey(i.address).toBuffer()))?[i,o,new S(1).div(a)]:[o,i,a],C=y.SqrtPriceMath.priceToSqrtPriceX64(j,v.decimals,b.decimals),w=[],k=[];v.programId===c.TOKEN_2022_PROGRAM_ID.toBase58()&&k.push(ju(n,new u.PublicKey(v.address)).publicKey),b.programId===c.TOKEN_2022_PROGRAM_ID.toBase58()&&k.push(ju(n,new u.PublicKey(b.address)).publicKey),(yield f.scope.connection.getMultipleAccountsInfo(k)).forEach(((e,t)=>{e&&w.push(k[t])}));const R=yield y.ClmmInstrument.createPoolInstructions({connection:f.scope.connection,programId:n,owner:g,mintA:v,mintB:b,ammConfigId:r.id,initialPriceX64:C,forerunCreate:!d&&s,extendMintAccount:w});return x.addInstruction(R),{address:Object.assign(Object.assign({},R.address),{observationId:R.address.observationId.toBase58(),exBitmapAccount:R.address.exBitmapAccount.toBase58(),programId:n.toString(),id:R.address.poolId.toString(),mintA:v,mintB:b,openTime:"0",vault:{A:R.address.mintAVault.toString(),B:R.address.mintBVault.toString()},rewardInfos:[],config:{id:r.id.toString(),index:r.index,protocolFeeRate:r.protocolFeeRate,tradeFeeRate:r.tradeFeeRate,tickSpacing:r.tickSpacing,fundFeeRate:r.fundFeeRate,description:r.description,defaultRange:0,defaultRangePoint:[]}}),mockPoolInfo:Object.assign({type:"Concentrated",rewardDefaultPoolInfos:"Clmm",id:R.address.poolId.toString(),mintA:v,mintB:b,feeRate:r.tradeFeeRate,openTime:"0",programId:n.toString(),price:j.toNumber(),config:{id:r.id.toString(),index:r.index,protocolFeeRate:r.protocolFeeRate,tradeFeeRate:r.tradeFeeRate,tickSpacing:r.tickSpacing,fundFeeRate:r.fundFeeRate,description:r.description,defaultRange:0,defaultRangePoint:[]},burnPercent:0},y.mockV3CreatePoolInfo),forerunCreate:s}}))}({programId:e.programId,mint1:Z.mintA,mint2:Z.mintB,ammConfig:Object.assign(Object.assign({},Z.config),{id:new u.PublicKey(Z.config.id),fundOwner:"",description:""}),initialPrice:new S(D.toString()),clmm:n,txBuilder:o}):void 0;if(!_)throw new Error("position is undefined");const l=yield function(e){return Wo(this,arguments,void 0,(function*({poolInfo:e,poolKeys:t,ownerInfo:n,tickLower:o,tickUpper:i,base:r,baseAmount:a,otherAmountMax:l,nft2022:s,associatedOnly:d=!0,checkCreateATAOwner:c=!1,withMetadata:p="create",getEphemeralSigners:h,computeBudgetConfig:m,txTipConfig:f,txVersion:x,feePayer:g,clmm:v,txBuilder:b}){!1===v.scope.availability.addConcentratedPosition&&v.logAndCreateError("add position feature disabled in your region");let j=null,C=null;const w=n.useSOLBalance&&e.mintA.address===y.WSOLMint.toString(),k=n.useSOLBalance&&e.mintB.address===y.WSOLMint.toString(),[T,R]="MintA"===r?[a,l]:[l,a],{account:S,instructionParams:I}=yield v.scope.account.getOrCreateTokenAccount({tokenProgram:e.mintA.programId,mint:new u.PublicKey(e.mintA.address),owner:v.scope.ownerPubKey,createInfo:w||T.isZero()?{payer:v.scope.ownerPubKey,amount:T}:void 0,skipCloseAccount:!w,notUseTokenAccount:w,associatedOnly:!w&&d,checkCreateATAOwner:c});S&&(j=S),b.addInstruction(I||{});const{account:B,instructionParams:M}=yield v.scope.account.getOrCreateTokenAccount({tokenProgram:e.mintB.programId,mint:new u.PublicKey(e.mintB.address),owner:v.scope.ownerPubKey,createInfo:k||R.isZero()?{payer:v.scope.ownerPubKey,amount:R}:void 0,skipCloseAccount:!k,notUseTokenAccount:k,associatedOnly:!k&&d,checkCreateATAOwner:c});B&&(C=B),b.addInstruction(M||{}),j&&C||v.logAndCreateError("cannot found target token accounts","tokenAccounts",{ownerTokenAccountA:null==j?void 0:j.toBase58(),ownerTokenAccountB:null==C?void 0:C.toBase58()});const E=t||(yield v.getClmmPoolKeys(e.id)),L=yield y.ClmmInstrument.openPositionFromBaseInstructions({poolInfo:e,poolKeys:E,ownerInfo:Object.assign(Object.assign({},n),{feePayer:v.scope.ownerPubKey,wallet:v.scope.ownerPubKey,tokenAccountA:j,tokenAccountB:C}),tickLower:o,tickUpper:i,base:r,baseAmount:a,otherAmountMax:l,withMetadata:p,getEphemeralSigners:h,nft2022:s});return b.addInstruction(L),Object.assign({},L.address)}))}({poolInfo:Z,poolKeys:null!=N?N:null==i?void 0:i.address,tickUpper:Math.max(_.tickLower,_.tickUpper),tickLower:Math.min(_.tickLower,_.tickUpper),base:"MintA",ownerInfo:{useSOLBalance:!0},baseAmount:new T(new S(E||"0").mul(10**Z.mintA.decimals).toFixed(0)),otherAmountMax:new T(_.amountB.multipliedBy(new r(10**Z.mintB.decimals)).toFixed(0)),clmm:n,txBuilder:o});o.addCustomComputeBudget({units:6e5,microLamports:1e3});const{transaction:s,signers:d}=yield o.versionBuild({txVersion:y.TxVersion.LEGACY,extInfo:l});const p=yield C.executeCustom({brief:J?t.i18n._({id:"8OiU8L",message:"Pool Creation"}):t.i18n._({id:"OBdohg",message:"Add Liquidity"}),metadata:{[J?exports.MetadataFlag.createAMMV3Pool:exports.MetadataFlag.addAMMV3Pool]:!0},handler:e=>Wo(this,void 0,void 0,(function*(){const{txId:t}=yield function(){return Wo(this,void 0,void 0,(function*(){var e,t,o;if(!b)throw new Error("raydium is undefined");const i=yield y.getRecentBlockHash(b.connection,b.blockhashCommitment);s.recentBlockhash=i,d.length&&s.sign(...d),y.printSimulate([s]);const r=yield null===(t=(e=n.scope).signAllTransactions)||void 0===t?void 0:t.call(e,[s]);if(d.length)for(const e of r);const a=null===(o=null==r?void 0:r[0])||void 0===o?void 0:o.serialize();if(!a)throw new Error("rawTransaction is undefined");return{txId:yield n.scope.connection.sendRawTransaction(a,{skipPreflight:!0}),signedTx:null==r?void 0:r[0]}}))}();e.onSuccess(t)})),successBack:()=>{a()},submittedBack:()=>{a()}});return p})),onError:e=>{console.error(e)}}),Re=F&&P?0===I.selectedMintIndex?`${null==P?void 0:P.symbol} per ${null==F?void 0:F.symbol}`:`${null==F?void 0:F.symbol} per ${null==P?void 0:P.symbol}`:"-";return G.jsx(Ks,{children:G.jsxs(o.Box,{sx:{mx:"auto",borderRadius:w?0:16,backgroundColor:"background.paper",width:w?"100%":600,display:"flex",flexDirection:"column",alignItems:"stretch"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:j.palette.background.paper},children:[G.jsx(o.Box,{component:o.ButtonBase,onClick:a,sx:{flexGrow:0,flexShrink:0,display:"flex",alignItems:"center",color:j.palette.text.primary,width:24,height:24},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"25",viewBox:"0 0 24 25",fill:"none",children:G.jsx("path",{d:"M20 11.5H7.83L13.42 5.91L12 4.5L4 12.5L12 20.5L13.41 19.09L7.83 13.5H20V11.5Z",fill:"currentColor"})})}),G.jsx(o.Box,{sx:{flexGrow:1,textAlign:"center",typography:"caption",color:j.palette.text.primary},children:t.i18n._({id:"E6MqGy",message:"Add liquidity"})}),G.jsx(o.Box,{sx:{flexGrow:0,flexShrink:0,width:24,height:24}})]}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:20,p:20},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"nxRg31",message:"Select pair"})}),G.jsx(_c,{mint1:I.mint1,mint2:I.mint2,dispatch:B}),G.jsx(Zd,{disabled:!I.mint1||!I.mint2,feeAmount:I.feeAmount,dispatch:B})]}),G.jsxs(Kd,{disabled:!I.feeAmount||$,children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"5CZbyC",message:"Set price range"})}),F&&P&&G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8,width:"100%",[j.breakpoints.up("tablet")]:{ml:"auto",width:"auto"}},children:[G.jsx(o.Button,{size:o.Button.Size.small,variant:o.Button.Variant.outlined,onClick:ke,sx:Object.assign({py:4,px:12,height:26,typography:"h6",fontWeight:600},w?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0),children:t.i18n._({id:"5IHTSS",message:"Full range"})}),G.jsx(Oc,{mintA:F,mintB:P,selectedMintIndex:I.selectedMintIndex,handleRateToggle:()=>{B({type:Wd.UpdateSelectedMintIndex,payload:0===I.selectedMintIndex?1:0})},sx:w?{flexGrow:0,flexShrink:1,flexBasis:"50%"}:void 0})]})]}),G.jsx(Lc,{priceLower:ge,priceUpper:ye,getDecrementLower:ve,getIncrementLower:be,getDecrementUpper:je,getIncrementUpper:Ce,onLeftRangeInput:le,onRightRangeInput:se,ticksAtLimit:ie,perPriceText:Re}),te&&G.jsx(qd,{children:t.i18n._({id:"b+KjnH",message:"Your position will not earn fees or be used in trades until the market price moves into your range."})}),ee&&G.jsx(qd,{children:t.i18n._({id:"Jh223O",message:"Invalid range selected. The min price must be lower than the max price."})})]}),J?G.jsxs(Kd,{children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"zeSosD",message:"Starting price"})}),G.jsx(o.Box,{sx:{p:8,borderRadius:8,backgroundColor:o.alpha(j.palette.primary.main,.1),typography:"h6",color:j.palette.primary.main},children:t.i18n._({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."})}),G.jsx(o.Box,{sx:{px:16,py:12,borderRadius:8,borderWidth:1,borderColor:j.palette.border.main,borderStyle:"solid"},children:G.jsx(Es,{sx:{backgroundColor:"transparent"},value:L,onChange:de,suffix:G.jsx(o.Box,{sx:{typography:"h6",color:j.palette.text.secondary},children:Re})})})]}):G.jsxs(Kd,{disabled:!I.feeAmount||$,children:[G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:[t.i18n._({id:"DWd30U",message:"Current price"}),G.jsxs(o.Box,{children:[Ko({input:D,decimals:9})," ",t.i18n._({id:"b2jAb+",message:"per"})," ",null!==(m=null===(h=I.mint1)||void 0===h?void 0:h.symbol)&&void 0!==m?m:""]})]}),G.jsx(Mc,{mint1:I.mint1,mint2:I.mint2,feeAmount:I.feeAmount,ticksAtLimit:ie,price:D?D.toNumber():void 0,priceLower:ge,priceUpper:ye,onLeftRangeInput:le,onRightRangeInput:se,interactive:!0})]}),G.jsxs(Kd,{disabled:$||ee||J&&!L,children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:j.palette.text.primary,textAlign:"left"},children:t.i18n._({id:"MU9s7M",message:"Deposit amounts"})}),G.jsxs(o.Box,{children:[G.jsx(Od,{value:he[Nd.DEPOSIT_1],onUserInput:re,maxAmount:me[Nd.DEPOSIT_1],balance:X[Nd.DEPOSIT_1],mint:null!==(f=Q[Nd.DEPOSIT_1])&&void 0!==f?f:null,locked:ne}),G.jsx(Ys,{}),G.jsx(Od,{value:he[Nd.DEPOSIT_2],onUserInput:ae,maxAmount:me[Nd.DEPOSIT_2],balance:X[Nd.DEPOSIT_2],mint:null!==(x=Q[Nd.DEPOSIT_2])&&void 0!==x?x:null,locked:oe})]}),G.jsx(Bd,{value:O,onChange:W,disabled:!1,type:n.CLMM})]})]}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:j.palette.background.paper},children:G.jsx(Md,{chainId:g,isValid:ce,errorMessage:K,setShowConfirm:pe})}),G.jsx(Yc,{position:_,outOfRange:te,ticksAtLimit:ie,on:ue,onClose:()=>{pe(!1)},onConfirm:Te.mutate,loading:Te.isPending})]})})}function wu({title:t,desc:n,linkTo:i,LeftImage:r,sx:a}){const l=o.useTheme(),s="light"===l.palette.mode;return G.jsxs(o.Box,{sx:Object.assign({backgroundColor:l.palette.background.paper,borderRadius:16,padding:20},a),children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[G.jsx(o.Box,{sx:{backgroundColor:o.alpha(l.palette.secondary.main,.3),color:s?"#EB8D27":l.palette.secondary.main,borderRadius:6,width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center"},children:G.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",children:G.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.55558 0.888672C3.87558 0.888672 0.888916 3.87534 0.888916 7.55534C0.888916 11.2353 3.87558 14.222 7.55558 14.222C11.2356 14.222 14.2222 11.2353 14.2222 7.55534C14.2222 3.87534 11.2356 0.888672 7.55558 0.888672ZM8.22225 11.5553V10.222H6.88892V11.5553H8.22225ZM4.88892 6.22201C4.88892 4.74867 6.08225 3.55534 7.55558 3.55534C9.02892 3.55534 10.2222 4.74867 10.2222 6.22201C10.2222 7.07728 9.69557 7.53755 9.18276 7.9857C8.69626 8.41085 8.22225 8.82509 8.22225 9.55534H6.88892C6.88892 8.34116 7.51699 7.85973 8.06921 7.43646C8.50241 7.10441 8.88892 6.80815 8.88892 6.22201C8.88892 5.48867 8.28892 4.88867 7.55558 4.88867C6.82225 4.88867 6.22225 5.48867 6.22225 6.22201H4.88892Z",fill:"currentColor"})})}),G.jsx(o.Box,{sx:{color:l.palette.text.primary,typography:"body1",fontWeight:600,ml:4},children:G.jsx(e.Trans,{id:"cmUrtC",message:"SEE HOW IT WORKS"})})]}),G.jsxs(o.Box,{sx:{mt:20,borderTopWidth:1,pt:20,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{component:r,sx:{width:64,height:64,flexShrink:0}}),G.jsxs(o.Box,{sx:{ml:16,color:l.palette.text.primary,typography:"body1",fontWeight:600},children:[t,G.jsx(o.Box,{sx:{mt:4,color:l.palette.text.secondary,typography:"body2",fontWeight:500},children:n})]})]}),G.jsx(o.Box,{component:"a",href:i,target:"_blank",rel:"noopener noreferrer",sx:{pl:16,flexShrink:0},children:G.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:G.jsx("path",{d:"M7.23375 3.75L6 4.98375L10.0075 9L6 13.0162L7.23375 14.25L12.4838 9L7.23375 3.75Z",fill:l.palette.text.primary})})})]})]})}const ku=[{value:0,label:"0%"},{value:25,label:"25%"},{value:50,label:"50%"},{value:75,label:"75%"},{value:100,label:"100%"}];function Tu({disabled:e,value:t,onChange:n,sx:i}){return G.jsxs(o.Box,{sx:Object.assign({p:20,backgroundColor:"background.input",borderRadius:12},i),children:[G.jsx(Es,{value:String(t),onChange:e=>n(+e),readOnly:!0,readonlyShowSuffix:!0,suffix:G.jsx(o.Box,{sx:{typography:"h2"},children:"%"}),sx:{mt:12,"& input":{pl:0,typography:"h1"}}}),G.jsx(o.Box,{sx:{mt:20},children:G.jsx(o.Slider,{marks:ku,step:1,disabled:e,value:t,onChange:(e,t)=>n(t)})})]})}const Ru=50;var Su;!function(e){e[e.quantity=1]="quantity",e[e.percentage=2]="percentage"}(Su||(Su={}));const Iu=({chainId:e,disabled:n,isLoading:i,onConfirm:r})=>G.jsx(bs,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:r,disabled:n,isLoading:i,children:t.i18n._({id:"h5pjuM",message:"Collect fees"})})}),Bu=({mint:e,pooledAmount:t})=>{var n;const i=o.useTheme();return G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Wa,{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}),G.jsxs(o.Box,{sx:{typography:"body1",color:i.palette.text.primary},children:[Ko({input:t,decimals:null==e?void 0:e.decimals})," ",null==e?void 0:e.symbol]}),G.jsx(o.ButtonBase,{sx:{display:"flex",alignItems:"center",color:i.palette.text.secondary,"&:hover":{color:i.palette.text.primary}},onClick:()=>{e&&window.open(Ns(e.chainId,e.address,"address"))},children:G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:G.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"})})})]})},Mu=({mintA:i,mintB:r,feeAmount:a,existingPosition:l,positionInfo:s,inRange:d,removed:c})=>{const u=o.useTheme();return G.jsxs(o.Box,{sx:{border:"solid 1px",borderColor:"border.main",borderRadius:8},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:u.spacing(12,20),borderBottomStyle:"solid",borderBottomColor:"border.main",borderBottomWidth:1},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(o.Box,{sx:{typography:"body2",color:u.palette.text.primary},children:[t.i18n._({id:"PVa3KL",message:"Position on"})," ",null==i?void 0:i.symbol,"/",null==r?void 0:r.symbol]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Nc,{removed:c,inRange:d}),G.jsx(o.Box,{sx:{py:4,px:8,color:u.palette.primary.main,borderRadius:4,backgroundColor:o.alpha(u.palette.primary.main,.1),typography:"h6"},children:Pc({type:n.CLMM,lpFeeRate:a,mtFeeRate:0})})]})]}),G.jsxs(o.ButtonBase,{sx:{display:"flex",alignItems:"center",gap:0,typography:"body2",color:u.palette.text.secondary,"&:hover":{color:u.palette.text.primary}},onClick:()=>{(null==i?void 0:i.chainId)&&window.open(Ns(i.chainId,null==l?void 0:l.poolId.toBase58(),"address"))},children:[t.i18n._({id:"URmyfc",message:"Details"}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.jsx("path",{d:"M7.5 5L6.4425 6.0575L9.8775 9.5L6.4425 12.9425L7.5 14L12 9.5L7.5 5Z",fill:"currentColor"})})]})]}),G.jsxs(o.Box,{sx:{p:u.spacing(12,20)},children:[G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),G.jsxs(o.Box,{sx:{mt:12},children:[G.jsx(Bu,{mint:i,pooledAmount:null==s?void 0:s.pooledAmountA}),G.jsx(Bu,{mint:r,pooledAmount:null==s?void 0:s.pooledAmountB})]})]})]})},Eu=({chainId:e,disabled:n,removed:i,isLoading:r,onConfirm:a})=>G.jsx(bs,{includeButton:!0,fullWidth:!0,chainId:e,children:G.jsx(o.Button,{fullWidth:!0,size:o.Button.Size.big,onClick:a,disabled:n,isLoading:r,children:i?t.i18n._({id:"D87pha",message:"Closed"}):t.i18n._({id:"t/YqKh",message:"Remove"})})});function Lu({position:e}){const t=Ua(),[,n]=bc(e?e.poolId.toBase58():null),{data:o}=d.useQuery({queryKey:["clmm","getPositionInfo",e,null==n?void 0:n.poolInfo],enabled:!!e&&!!(null==n?void 0:n.poolInfo),queryFn:()=>Wo(this,void 0,void 0,(function*(){const o=null==n?void 0:n.poolInfo;if(!o||!t||!e)return null;const i=y.TickUtils.getTickPrice({poolInfo:o,tick:e.tickLower,baseIn:!0}),a=y.TickUtils.getTickPrice({poolInfo:o,tick:e.tickUpper,baseIn:!0}),l=yield t.connection.getEpochInfo(),{amountA:s,amountB:d}=y.PositionUtils.getAmountsFromLiquidity({poolInfo:o,ownerPosition:e,liquidity:e.liquidity,slippage:0,add:!1,epochInfo:l}),[c,u]=[new r(s.amount.toString()).div(10**o.mintA.decimals),new r(d.amount.toString()).div(10**o.mintB.decimals)];return{pooledAmountA:c,pooledAmountB:u,priceLower:new r(i.price.toString()),priceUpper:new r(a.price.toString())}}))});return{pool:n,positionInfo:null!=o?o:null}}function Ou(e){var t;const n=Ua(),o=d.useQuery({queryKey:["clmm","getOwnerPositionInfo",e,null==n?void 0:n.owner],enabled:null!=e&&null!=n&&null!=n.owner,queryFn:()=>Wo(this,void 0,void 0,(function*(){if(!n||!n.owner||!e)return null;const t=gi[e];if(!t)throw new Error("Invalid config");try{const e=yield n.clmm.getOwnerPositionInfo({programId:t.programId});return e.forEach((e=>{console.log("getOwnerPositionInfo p",e.poolId.toBase58(),e.nftMint.toBase58(),e.liquidity.toString(),e.tickLower,e.tickUpper)})),{allPosition:e}}catch(e){return console.error("getOwnerPositionInfo error",e),null}}))});return{loading:o.isLoading,positions:null===(t=o.data)||void 0===t?void 0:t.allPosition}}const Wu=({mint:e,rewardAmountOwed:t})=>{var n;const i=o.useTheme();return G.jsxs(o.Box,{sx:{py:8,display:"flex",alignItems:"center",gap:6,typography:"h5",color:i.palette.text.primary},children:[G.jsx(Wa,{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}),G.jsx(o.Box,{children:null==e?void 0:e.symbol}),G.jsx(o.Box,{sx:{ml:"auto"},children:Ko({input:null==t?void 0:t.toString(),decimals:null==e?void 0:e.decimals})})]})},Vu=({mint1Address:e,mint2Address:a,feeAmount:l,poolId:s,nftMint:c,onClose:p})=>{const{isMobile:h}=Ls(),m=o.useTheme(),f=Si(),x=d.useQueryClient(),{account:g,chainId:v}=Zo(),b=Ua(),{position:j}=function({chainId:e,nftMint:t,poolId:n}){const o=Ou(e);return{position:i.useMemo((()=>{if(o.positions)return o.positions.find((e=>e.nftMint.equals(new u.PublicKey(t))&&e.poolId.equals(new u.PublicKey(n))))}),[o,t,n]),loading:o.loading}}({chainId:v,nftMint:c,poolId:s}),{positionInfo:C,pool:w}=Lu({position:j}),[k,R]=i.useState("stake"),[I,B]=i.useState(!1),[M,E]=i.useState(Ru),L=Jc({mint:e,chainId:v}),O=Jc({mint:a,chainId:v}),[W,V]=i.useReducer(Ad,{mint1:L,mint2:O,feeAmount:l,selectedMintIndex:0,independentField:Nd.DEPOSIT_1,typedValue:"",startPriceTypedValue:"",leftRangeTypedValue:"",rightRangeTypedValue:""});i.useEffect((()=>{L&&V({type:Wd.UpdateDefaultMint1,payload:L})}),[L]),i.useEffect((()=>{O&&V({type:Wd.UpdateDefaultMint2,payload:O})}),[O]);const{independentField:F,typedValue:P}=W,{slipper:Z,setSlipper:N,slipperValue:U}=Id({type:n.CLMM}),{mintA:H,mintB:D,dependentField:Y,parsedAmounts:z,depositBalances:q,position:X,mints:_,errorMessage:J,invalidRange:Q,outOfRange:K,depositADisabled:$,depositBDisabled:ee,ticksAtLimit:te}=xu({state:W,existingPosition:j,slipperValue:U}),ne=(null==j?void 0:j.liquidity)&&j.liquidity.eq(new T(0)),{onField1Input:oe,onField2Input:ie}=gu({dispatch:V}),re=!J&&!Q,ae=i.useMemo((()=>{var e,t;return{[F]:P,[Y]:null!==(t=null===(e=z[Y])||void 0===e?void 0:e.toString())&&void 0!==t?t:""}}),[Y,F,z,P]),le=[Nd.DEPOSIT_1,Nd.DEPOSIT_2].reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:vu(q[t])})),{}),se=d.useMutation({mutationFn:()=>Wo(void 0,void 0,void 0,(function*(){if(!g)throw new Error("account is undefined");if(!b)throw new Error("raydium is undefined");if(!j)throw new Error("existingPosition is undefined");if(!(null==w?void 0:w.poolInfo))throw new Error("poolInfo is undefined");if(!X)throw new Error("position is undefined");const{execute:e}=yield b.clmm.increasePositionFromLiquidity({poolInfo:w.poolInfo,poolKeys:w.poolKeys,ownerPosition:j,ownerInfo:{useSOLBalance:!0},liquidity:new T(new S(X.liquidity.toString()).mul(1-U).toFixed(0)),amountMaxA:new T(new S(P||"0").mul(10**w.poolInfo.mintA.decimals).toFixed(0)),amountMaxB:new T(X.amountB.multipliedBy(1+U).multipliedBy(new r(10**w.poolInfo.mintB.decimals)).toFixed(0)),checkCreateATAOwner:!0,txVersion:y.TxVersion.LEGACY});(yield f.executeCustom({brief:t.i18n._({id:"OBdohg",message:"Add Liquidity"}),metadata:{[exports.MetadataFlag.addAMMV3Pool]:!0},handler:t=>Wo(void 0,void 0,void 0,(function*(){const{txId:n}=yield e({sendAndConfirm:!0});t.onSuccess(n)}))}))===Ho.Success&&(B(!1),setTimeout((()=>{null==p||p()}),100)),x.invalidateQueries({queryKey:["clmm"],refetchType:"all"})})),onError:e=>{console.error(e)}}),de=d.useMutation({mutationFn:()=>Wo(void 0,void 0,void 0,(function*(){if(!g)throw new Error("account is undefined");if(!b)throw new Error("raydium is undefined");if(!j)throw new Error("existingPosition is undefined");if(!(null==w?void 0:w.poolInfo))throw new Error("poolInfo is undefined");const e=new T(new S(j.liquidity.toString()).mul(1-M/100).toFixed(0)),{execute:n}=yield b.clmm.decreaseLiquidity({poolInfo:w.poolInfo,poolKeys:w.poolKeys,ownerPosition:j,ownerInfo:{useSOLBalance:!0,closePosition:!1},liquidity:e,amountMinA:new T(0),amountMinB:new T(0),txVersion:y.TxVersion.LEGACY});(yield f.executeCustom({brief:t.i18n._({id:"3XBvkd",message:"Remove Liquidity"}),metadata:{[exports.MetadataFlag.removeAMMV3Pool]:!0},handler:e=>Wo(void 0,void 0,void 0,(function*(){const{txId:t}=yield n({sendAndConfirm:!0});e.onSuccess(t)}))}))===Ho.Success&&setTimeout((()=>{null==p||p()}),100),x.invalidateQueries({queryKey:["clmm"],refetchType:"all"})})),onError:e=>{console.error("onRemoveMutation",e)}}),ce=d.useMutation({mutationFn:()=>Wo(void 0,void 0,void 0,(function*(){if(!b)throw new Error("raydium is undefined");if(!(null==w?void 0:w.poolInfo))throw new Error("poolInfo is undefined");const{execute:e}=yield b.clmm.collectRewards({poolInfo:w.poolInfo,ownerInfo:{useSOLBalance:!0},rewardMints:w.poolInfo.rewardDefaultInfos.map((e=>new u.PublicKey(e.mint.address))),associatedOnly:!0,checkCreateATAOwner:!0,computeBudgetConfig:void 0,txTipConfig:void 0});(yield f.executeCustom({brief:t.i18n._({id:"zXCpR0",message:"Claim Rewards"}),metadata:{[exports.MetadataFlag.claimAMMV3Pool]:!0},handler:t=>Wo(void 0,void 0,void 0,(function*(){const{txId:n}=yield e();t.onSuccess(n)}))}))===Ho.Success&&setTimeout((()=>{null==p||p()}),100),x.invalidateQueries({queryKey:["clmm"],refetchType:"all"})})),onError:e=>{console.error("onClaimMutation",e)}}),ue=i.useMemo((()=>{var e,i;const r=[{key:"stake",value:t.i18n._({id:"JYKRJS",message:"Stake"})},{key:"unstake",value:t.i18n._({id:"OFjZGo",message:"Unstake"})},{key:"claim",value:t.i18n._({id:"hom7qf",message:"Claim"})}];return G.jsxs(o.Box,{sx:{borderRadius:16,backgroundColor:m.palette.background.paper},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:20,py:24,borderTopLeftRadius:16,borderTopRightRadius:16,backgroundColor:m.palette.background.paper},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.primary},children:t.i18n._({id:"E6MqGy",message:"Add liquidity"})}),p?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(o.Box,{component:A.Error,sx:{width:16,height:16},onClick:()=>{p()}})}):void 0]}),G.jsx(o.Box,{sx:{mx:20,mb:16},children:G.jsx(Mu,{existingPosition:j,positionInfo:C,inRange:!K,removed:ne,mintA:H,mintB:D,feeAmount:l})}),G.jsxs(o.Tabs,{value:k,onChange:(e,t)=>{R(t)},children:[G.jsx(o.TabsButtonGroup,{tabs:r,variant:"inPaper",tabsListSx:{mx:20}}),G.jsxs(o.TabPanel,{value:"stake",children:[X&&G.jsx(o.Box,{sx:{mt:16,mx:20},children:G.jsx(Hc,{position:X,title:t.i18n._({id:"3VUfrF",message:"Selected Range"}),ticksAtLimit:te})}),G.jsxs(o.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.secondary,textAlign:"left"},children:t.i18n._({id:"BRi+RY",message:"Add more liquidity"})}),G.jsxs(o.Box,{children:[G.jsx(Od,{value:ae[Nd.DEPOSIT_1],onUserInput:oe,maxAmount:le[Nd.DEPOSIT_1],balance:q[Nd.DEPOSIT_1],mint:null!==(e=_[Nd.DEPOSIT_1])&&void 0!==e?e:null,locked:$}),G.jsx(Ys,{}),G.jsx(Od,{value:ae[Nd.DEPOSIT_2],onUserInput:ie,maxAmount:le[Nd.DEPOSIT_2],balance:q[Nd.DEPOSIT_2],mint:null!==(i=_[Nd.DEPOSIT_2])&&void 0!==i?i:null,locked:ee})]}),G.jsx(Bd,{value:Z,onChange:N,disabled:!1,type:n.CLMM})]}),G.jsx(o.Box,{sx:{display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:m.palette.background.paper},children:G.jsx(Md,{chainId:v,isValid:re,errorMessage:J,setShowConfirm:B})}),G.jsx(Yc,{position:X,outOfRange:K,ticksAtLimit:te,on:I,onClose:()=>{B(!1)},onConfirm:se.mutate,loading:se.isPending})]}),G.jsxs(o.TabPanel,{value:"unstake",children:[G.jsxs(o.Box,{sx:{mt:16,mx:20,display:"flex",flexDirection:"column",alignItems:"stretch",gap:12},children:[G.jsx(Tu,{disabled:!1,value:M,onChange:e=>E(e)}),G.jsx(Bd,{value:Z,onChange:N,disabled:!1,type:n.CLMM})]}),G.jsxs(o.Box,{sx:{mt:16,mx:20,display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[G.jsx(o.Box,{sx:{typography:"body2",color:m.palette.text.secondary},children:"Receive"}),G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.primary},children:[G.jsx(o.Box,{component:"span",sx:{color:m.palette.primary.main},children:(null==C?void 0:C.pooledAmountA)?Ko({input:C.pooledAmountA.multipliedBy(M/100),decimals:null==H?void 0:H.decimals}):"-"})," ",null==H?void 0:H.symbol]}),G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:m.palette.text.primary},children:[G.jsx(o.Box,{component:"span",sx:{color:m.palette.primary.main},children:(null==C?void 0:C.pooledAmountB)?Ko({input:C.pooledAmountB.multipliedBy(M/100),decimals:null==D?void 0:D.decimals}):"-"})," ",null==D?void 0:D.symbol]})]})]}),G.jsx(o.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:m.palette.background.paper},children:G.jsx(Eu,{chainId:v,disabled:ne||0===M,removed:ne,onConfirm:de.mutate,isLoading:de.isPending})})]}),G.jsxs(o.TabPanel,{value:"claim",children:[G.jsxs(o.Box,{sx:{mx:20,mt:16,borderRadius:12,borderWidth:1,borderStyle:"solid",borderColor:m.palette.border.main},children:[G.jsx(o.Box,{sx:{py:12,px:20,typography:"body1",color:m.palette.text.primary,borderBottomWidth:1,borderBottomStyle:"solid",borderBottomColor:m.palette.border.main},children:t.i18n._({id:"tu/fxg",message:"Claim fees"})}),G.jsx(o.Box,{sx:{p:20},children:null==w?void 0:w.poolInfo.rewardDefaultInfos.map(((e,t)=>{const n=null==j?void 0:j.rewardInfos[t].rewardAmountOwed;return G.jsx(Wu,{mint:e.mint,rewardAmountOwed:n},e.mint.address)}))})]}),G.jsx(o.Box,{sx:{mx:20,mt:16,typography:"h6",color:m.palette.text.secondary},children:t.i18n._({id:"Joa5Dk",message:"*Collecting fees will withdraw currently available fees for you."})}),G.jsx(o.Box,{sx:{mt:20,display:"flex",alignItems:"center",px:20,py:16,borderBottomLeftRadius:16,borderBottomRightRadius:16,backgroundColor:m.palette.background.paper},children:G.jsx(Iu,{chainId:v,disabled:ce.isPending||!(null==w?void 0:w.poolInfo)||0===(null==w?void 0:w.poolInfo.rewardDefaultInfos.length),onConfirm:ce.mutate,isLoading:ce.isPending})})]})]})]})}),[v,$,ee,q,J,j,l,ae,re,le,H,D,_,se.isPending,se.mutate,ce.isPending,ce.mutate,p,oe,ie,de.isPending,de.mutate,k,K,null==w?void 0:w.poolInfo,X,C,ne,N,I,M,Z,m.palette.background.paper,m.palette.border.main,m.palette.primary.main,m.palette.text.primary,m.palette.text.secondary,te]);return h?G.jsx(ds,{open:null!=H&&null!=D,onClose:p,scope:!h,modal:void 0,id:"pool-operate",children:ue}):ue};const Au=({outOfRange:e})=>{const n=o.useTheme();return G.jsx(o.Tooltip,{title:e?t.i18n._({id:"i3Z+/Z",message:"Out of range"}):t.i18n._({id:"vOyUlD",message:"In range"}),children:G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:e?G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:G.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:n.palette.warning.main})}):G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:G.jsx("circle",{cx:"4",cy:"4",r:"4",fill:n.palette.success.main})})})})},Fu=({position:e,mintA:n,mintB:r,feeAmount:a,onClickManage:l})=>{const s=o.useTheme(),{positionInfo:d,pool:c}=Lu({position:e}),u=function(e,t,n){return i.useMemo((()=>({[Ud.LOWER]:e&&t?t===Qc(y.MIN_TICK,Fd[e]):void 0,[Ud.UPPER]:e&&n?n===Qc(y.MAX_TICK,Fd[e]):void 0})),[e,t,n])}(a,e.tickLower,e.tickUpper),p=null==d?void 0:d.priceLower,h=null==d?void 0:d.priceUpper,m=!!(null==c?void 0:c.computePoolInfo)&&(c.computePoolInfo.tickCurrent<e.tickLower||c.computePoolInfo.tickCurrent>=e.tickUpper),f=null==c?void 0:c.poolInfo.price;return G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:24,px:20,py:20,pb:12,borderRadius:12,backgroundColor:s.palette.background.paperContrast},children:[G.jsxs(o.Box,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"h5",color:s.palette.text.primary},children:[G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:p,atLimit:u,direction:Ud.LOWER})," "]}),null==r?void 0:r.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.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"})}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:h,atLimit:u,direction:Ud.UPPER})," "]}),null==r?void 0:r.symbol]})})]}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(Au,{outOfRange:m}),G.jsxs(o.Box,{sx:{typography:"h6",color:s.palette.text.secondary},children:["Current price: ",Ko({input:f})," ",null==r?void 0:r.symbol," per ",null==n?void 0:n.symbol]})]})]}),G.jsx(o.Button,{variant:o.Button.Variant.outlined,size:o.Button.Size.small,fullWidth:!0,onClick:l,children:t.i18n._({id:"wckWOP",message:"Manage"})})]})};const Pu=({mint1Address:e,mint2Address:n,feeAmount:r,poolId:a,onClose:l,handleGoToAddLiquidityV3:s})=>{const{isMobile:d}=Ls(),c=o.useTheme(),{chainId:p,account:h}=Zo(),{positions:m,loading:f}=Ou(p),{mintA:x,mintB:g}=function({mint1Address:e,mint2Address:t}){const{chainId:n}=Zo(),o=Jc({mint:e,chainId:n}),r=Jc({mint:t,chainId:n}),[a,l]=i.useMemo((()=>o&&r?new T(new u.PublicKey(o.address).toBuffer()).gt(new T(new u.PublicKey(r.address).toBuffer()))?[r,o]:[o,r]:[void 0,void 0]),[o,r]);return{mintA:a,mintB:l}}({mint1Address:e,mint2Address:n}),y=i.useMemo((()=>{if(void 0!==m)return m.filter((e=>e.poolId.equals(new u.PublicKey(a))))}),[m,a]),[v,b]=i.useState(null),j=i.useMemo((()=>{var e;return G.jsxs(o.Box,{sx:{p:20,display:"flex",flexDirection:"column",gap:16,borderRadius:16,backgroundColor:c.palette.background.paper,minHeight:480},children:[G.jsxs(o.Box,{sx:{pb:16,borderBottomColor:c.palette.border.main,borderBottomStyle:"solid",borderBottomWidth:1,display:"flex",justifyContent:"space-between",alignItems:"center"},children:[G.jsxs(o.Box,{sx:{typography:"body1",fontWeight:600,color:c.palette.text.primary},children:[t.i18n._({id:"Gs02OK",message:"My Positions"})," (",null!==(e=null==y?void 0:y.length)&&void 0!==e?e:0,")"]}),l?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(o.Box,{component:A.Error,sx:{width:16,height:16},onClick:()=>{l()}})}):void 0]}),f||!y?G.jsx(G.Fragment,{children:G.jsx(o.Box,{sx:{mt:100,display:"flex",justifyContent:"center"},children:G.jsx(_a,{})})}):y.length>0?G.jsxs(G.Fragment,{children:[null==y?void 0:y.map((e=>G.jsx(Fu,{position:e,mintA:x,mintB:g,feeAmount:r,onClickManage:()=>{b(e)}},e.nftMint.toBase58()))),G.jsxs(o.Button,{size:o.Button.Size.big,variant:o.Button.Variant.second,onClick:()=>{s({mint1:null==x?void 0:x.address,mint2:null==g?void 0:g.address,fee:String(r)})},sx:{gap:8},children:[G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",children:G.jsx("path",{d:"M19 13H13V19H11V13H5V11H11V5H13V11H19V13Z",fill:"currentColor"})}),t.i18n._({id:"FQ4aT9",message:"Add Position"})]})]}):G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{mt:100,display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[G.jsx(o.EmptyDataIcon,{sx:{width:60,height:60,borderRadius:24/105*60}}),G.jsx(o.Box,{sx:{typography:"body1",color:c.palette.text.secondary},children:t.i18n._({id:"/6L4mj",message:"Your position is empty"})})]}),G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsx(bs,{size:o.Button.Size.small,includeButton:!0,children:G.jsx(o.Button,{size:o.Button.Size.small,onClick:()=>{s({mint1:null==x?void 0:x.address,mint2:null==g?void 0:g.address,fee:String(r)})},children:t.i18n._({id:"FQ4aT9",message:"Add Position"})})})})]})]})}),[y,r,s,f,x,g,l,c.palette.background.paper,c.palette.border.main,c.palette.text.primary,c.palette.text.secondary]);return null!==v?G.jsx(Vu,{mint1Address:e,mint2Address:n,feeAmount:r,poolId:v.poolId.toBase58(),nftMint:v.nftMint.toBase58(),onClose:()=>{b(null)}}):d?G.jsx(ds,{open:null!=x&&null!=g,onClose:l,scope:!d,modal:void 0,id:"pool-operate",children:j}):j};var Zu,Nu;function Uu({message:t,onClose:n}){return G.jsx(ds,{open:!!t,onClose:n,id:"error-message",children:G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{flex:1,textAlign:"center"},children:[G.jsx(o.Box,{component:A.ErrorWarn,sx:{mt:60,width:64,height:64,color:"error.main"}}),t?G.jsxs(o.Box,{sx:{textAlign:"center",mt:60},children:[G.jsx(o.Box,{children:G.jsx(e.Trans,{id:"kf83Ld",message:"Something went wrong."})}),G.jsx(o.Box,{sx:{color:"text.secondary",mt:12,typography:"body2",wordBreak:"break-all"},children:t})]}):""]}),G.jsx(o.Box,{sx:{px:16,py:20},children:G.jsx(o.Button,{onClick:n,fullWidth:!0,children:G.jsx(e.Trans,{id:"1QfxQT",message:"Dismiss"})})})]})})}function Hu({status:t,children:n,buttonProps:i}){return!t.needShowTokenStatusButton&&n?G.jsx(G.Fragment,{children:n}):t.insufficientBalance?G.jsx(o.Button,{fullWidth:!0,disabled:!0,...i,children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):G.jsx(o.Button,{fullWidth:!0,isLoading:t.isApproving,onClick:t.submitApprove,disabled:t.insufficientBalance,...i,children:t.isApproving?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):t.approveTitle})}function Du({chainId:t,baseTokenStatus:n,quoteTokenStatus:i,children:r}){const{runningRequests:a}=Ii(),{account:l,chainId:s}=Zo();if(!l||t!==s)return G.jsx(bs,{chainId:t,fullWidth:!0});const d=a.some((e=>{var t,n;return(null===(t=e.metadata)||void 0===t?void 0:t[exports.MetadataFlag.addLiquidity])||(null===(n=e.metadata)||void 0===n?void 0:n[exports.MetadataFlag.removeLiquidity])})),c=[];n.needShowTokenStatusButton&&c.push(G.jsx(Hu,{status:n})),i.needShowTokenStatusButton&&!n.isApproving&&c.push(G.jsx(Hu,{status:i}));const u=c.length;return 2===u?G.jsx(o.Box,{sx:{display:"flex","& > button":{flex:1,"&:last-child":{ml:8}}},children:c.map((e=>e))}):1===u?c[0]:d?G.jsx(o.Button,{fullWidth:!0,disabled:!0,isLoading:!0,children:G.jsx(e.Trans,{id:"UbRKMZ",message:"Pending"})}):G.jsx(G.Fragment,{children:r})}function Yu({pool:e,maxBaseAmount:t,maxQuoteAmount:n,isRemove:o}){const[a,l]=i.useState(""),[s,d]=i.useState(""),[c,u]=i.useState(Co),p=c===Co?new r(td).div(100).toNumber():c,h=()=>{l(""),d("")},m=rd({pool:(null==e?void 0:e.baseToken)&&e.quoteToken?{baseToken:e.baseToken,quoteToken:e.quoteToken,address:e.address}:void 0,baseAmount:a,quoteAmount:s,slippage:p}),f=m.isFront?m.price:m.invertedPrice,x=f||new r(1),g=i.useRef(x);if(!e||x.isNaN())return{baseAmount:a,quoteAmount:s,handleChangeBaseAmount:()=>{},handleChangeQuoteAmount:()=>{},reset:h,uniV2Pair:m,slippage:c,slippageNumber:p,setSlippage:u};const y=e.baseToken.decimals,v=e.quoteToken.decimals,b=e=>{if(e){let i=x.multipliedBy(e).dp(v).toString();n&&o&&(n.lte(i)||(null==t?void 0:t.lte(0)))&&(i=n.toString()),d(i)}else d(e)};g.current&&x.isEqualTo(g.current)||(g.current=x,b(a));return{baseAmount:a,quoteAmount:s,handleChangeBaseAmount:e=>{let t=ti(e,y);null===t&&(t=a),l(t),b(t)},handleChangeQuoteAmount:e=>{let i=ti(e,v);null===i&&(i=s),d(i),(e=>{if(e){let i=new r(e).div(x).dp(y).toString();t&&o&&(t.lte(i)||(null==n?void 0:n.lte(0)))&&(i=t.toString()),l(i)}else l(e)})(i)},reset:h,midPrice:f,addPortion:x,amountCheckedDisabled:!a||!s,uniV2Pair:m,slippage:c,slippageNumber:p,setSlippage:u}}function zu({submittedBack:e,pool:n}){var r,a,l;const s="SVM_AMMV2"===(null==n?void 0:n.type),[d,c]=i.useState(!1),{baseAmount:u,quoteAmount:p,midPrice:h,amountCheckedDisabled:m,uniV2Pair:f,handleChangeBaseAmount:x,handleChangeQuoteAmount:g,reset:y,slippage:v,slippageNumber:b,setSlippage:j}=Yu({pool:n});i.useEffect((()=>{y()}),[n]);const C=ur(null==n?void 0:n.baseToken,{amount:u}),w=ur(null==n?void 0:n.quoteToken,{amount:p}),k=C.insufficientBalance||w.insufficientBalance,T=!n||k||!h||!!f.poolInfoQuery.isLoading||!!f.poolInfoQuery.error||m||f.poolInfoQuery.isLoading;let R=s?t.i18n._({id:"bwSQI0",message:"Supply"}):t.i18n._({id:"m16xKo",message:"Add"});k&&(R=t.i18n._({id:"znqB4T",message:"Insufficient balance"}));const S=id({baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,pairMintAAmount:f.pairMintAAmount,pairMintBAmount:f.pairMintBAmount,isExists:f.isExists,poolKeys:null===(r=f.poolInfoQuery.data)||void 0===r?void 0:r.poolKeys,poolInfo:null===(a=f.poolInfoQuery.data)||void 0===a?void 0:a.poolInfo,slippage:b,submittedBack:()=>{y(),e&&e(),c(!1)}}),I=!(null==n?void 0:n.baseToken)||!(null==n?void 0:n.quoteToken);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{pt:20,pb:18,px:20},children:[G.jsx(zs,{sx:{mb:4,pb:28,minHeight:"auto"},amt:u,token:null==n?void 0:n.baseToken,canClickBalance:!0,showPercentage:!0,onInputChange:x,readOnly:f.poolInfoQuery.isLoading}),G.jsx(Is,{plus:!0}),G.jsx(zs,{sx:{pb:20,minHeight:"auto"},amt:p,token:null==n?void 0:n.quoteToken,canClickBalance:!0,showPercentage:!0,onInputChange:g,readOnly:f.poolInfoQuery.isLoading}),G.jsx(Rd,{slippage:v,onChangeSlippage:j,disabled:I,sx:{mt:8}}),G.jsx(vd,{baseToken:null==n?void 0:n.baseToken,quoteToken:null==n?void 0:n.quoteToken,loading:f.poolInfoQuery.isLoading,midPrice:h,lpBalancePercentage:f.isExists?f.lpBalancePercentage:100})]}),G.jsx(o.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:n?G.jsx(Du,{chainId:n.chainId,baseTokenStatus:C,quoteTokenStatus:w,children:G.jsx(o.Button,{fullWidth:!0,disabled:T,isLoading:S.isPending,onClick:()=>{T||c(!0)},children:R})}):G.jsx(o.Button,{fullWidth:!0,disabled:!0,children:R})}),G.jsx(Uu,{message:null===(l=S.error)||void 0===l?void 0:l.message,onClose:()=>S.reset()}),s&&!!n&&G.jsx(bd,{open:d,onClose:()=>c(!1),slippage:b,baseToken:n.baseToken,quoteToken:n.quoteToken,pairMintAAmount:f.pairMintAAmount,pairMintBAmount:f.pairMintBAmount,feeRate:n.lpFeeRate,price:null==f?void 0:f.price,lpAmount:null==f?void 0:f.liquidityMinted,lpBalancePercentage:f.isExists?f.lpBalancePercentage:100,pairAddress:n.address,createMutation:S})]})}function qu({hidePoolInfo:t,pool:n,children:i}){var r,a,l,s,d;const c=o.useTheme(),u=!n,p="SVM_AMMV2"===(null==n?void 0:n.type),h=n?Pc({type:n.type,lpFeeRate:null!==(r=n.lpFeeRate)&&void 0!==r?r:"0",mtFeeRate:null!==(a=n.mtFeeRate)&&void 0!==a?a:"0"}):"-";return G.jsxs(o.Box,{sx:{mt:16,mx:20,border:"solid 1px",borderColor:"border.main",borderRadius:12},children:[t?"":G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",p:c.spacing(12,20),borderStyle:"solid",borderColor:"border.main",borderWidth:c.spacing(0,0,1)},children:[G.jsxs(o.Box,{children:[G.jsxs(o.LoadingSkeleton,{loading:u,loadingSx:{width:100,mb:4},sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[null===(l=null==n?void 0:n.baseToken)||void 0===l?void 0:l.symbol,"/",null===(s=null==n?void 0:n.quoteToken)||void 0===s?void 0:s.symbol,p&&G.jsx(o.Tooltip,{title:G.jsxs(o.Box,{sx:{typography:"h6","& > b":{fontWeight:600,color:"primary.main"}},children:["🌟",G.jsx("b",{children:G.jsx(e.Trans,{id:"e38JNU",message:"Tips:"})})," ",G.jsx(e.Trans,{id:"ipqmyu",message:"By adding liquidity you’ll earn <0>{feeRate}</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:{feeRate:h},components:{0:G.jsx("b",{})}})]}),sx:{maxWidth:240},children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.disabled"},children:h})})]}),G.jsx(o.LoadingSkeleton,{loading:u,children:G.jsx(fd,{address:null!==(d=null==n?void 0:n.address)&&void 0!==d?d:"",truncate:!0,iconSize:14,iconSpace:4,customChainId:null==n?void 0:n.chainId,sx:{typography:"h6",color:"text.secondary"}})})]}),(null==n?void 0:n.address)&&!p?G.jsxs(o.Box,{component:o.ButtonBase,sx:{typography:"body2",display:"flex",alignItems:"center",color:"text.secondary"},onClick:()=>{Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:n.chainId,address:n.address}})},children:[G.jsx(e.Trans,{id:"URmyfc",message:"Details"}),G.jsx(o.Box,{component:A.ArrowRight,sx:{ml:4,position:"relative",top:1.2,width:16,height:16}})]}):""]}),G.jsx(o.Box,{sx:{p:c.spacing(12,20)},children:i})]})}function Xu({submittedBack:n,pool:a}){var l,s,c;const[u,p]=i.useState(""),[h,m]=i.useState(""),[f,x]=i.useState(Co),g=f===Co?new r(td).div(100).toNumber():f,{isFront:v,price:b,invertedPrice:j,poolInfoQuery:C,lpBalanceQuery:w,lpBalance:k,lpBalancePercentage:R,lpToAmountA:I,lpToAmountB:B,liquidityMinted:M,pairMintAAmount:E,pairMintBAmount:L,isExists:O}=rd({pool:(null==a?void 0:a.baseToken)&&a.quoteToken?{baseToken:a.baseToken,quoteToken:a.quoteToken,address:a.address}:void 0,baseAmount:void 0,quoteAmount:void 0,slippage:0}),{mode:W,modeOptions:V,handleChangeMode:A,sliderPercentage:F,handleChangeSliderPercentage:P,resetPercentage:Z}=function({isBase:e,pool:n,baseOverride:o,quoteOverride:r,resetAmount:a,handleChangeBaseAmount:l,handleChangeQuoteAmount:s}){const[d,c]=i.useState(Su.percentage),[u,p]=i.useState(Ru),h=i.useRef(null),m=()=>{h.current&&clearTimeout(h.current)},f=()=>{m(),p(Ru)};return i.useEffect((()=>m),[]),{mode:d,modeOptions:[{key:Su.percentage,value:t.i18n._({id:"x4QVeW",message:"Percentage to remove"})}],handleChangeMode:e=>{c(e),null==a||a(),f()},sliderPercentage:u,handleChangeSliderPercentage:t=>{if(m(),t!==u&&p(t),!n)return;const i=100===t,a=()=>{if(n)if(e||void 0===e){if(o){let e=o.toString();i||(e=ei(o.times(t/100),n.baseToken.decimals)),null==l||l(e)}}else if(r){let e=r.toString();i||(e=ei(r.times(t/100),n.quoteToken.decimals)),null==s||s(e)}};i?a():h.current=setTimeout(a,100)},resetPercentage:f}}({isBase:!0,pool:a,baseOverride:I,quoteOverride:B}),N=ur(null==a?void 0:a.baseToken,{amount:u}),U=ur(null==a?void 0:a.quoteToken,{amount:h}),H=!a||!!C.isLoading||!!C.error||!!w.error||w.isLoading,D=t.i18n._({id:"t/YqKh",message:"Remove"}),Y=function({liquidityAmount:n,slippage:o,poolInfo:i,poolKeys:r,submittedBack:a}){const l=Si(),s=Ua();return e.useLingui(),d.useMutation({mutationFn:()=>Wo(this,void 0,void 0,(function*(){if(!s)throw new Error("raydium is undefined");if(!i||!r)throw new Error("poolInfo or poolKeys is undefined");if(!n)throw new Error("liquidityAmount is undefined");const e=new T(new S(n.toString()).mul(10**i.lpMint.decimals).toFixed(0,S.ROUND_DOWN)),d=new y.Percent(100*o*100,1e4),{execute:c}=yield s.cpmm.withdrawLiquidity({poolInfo:i,poolKeys:r,lpAmount:e,txVersion:y.TxVersion.LEGACY,slippage:d});return yield l.executeCustom({brief:t.i18n._({id:"cJtosk",message:"Remove liquidity"}),metadata:{[exports.MetadataFlag.removeLiqidityAMMV2Position]:!0},handler:e=>Wo(this,void 0,void 0,(function*(){const{txId:t}=yield c({sendAndConfirm:!0});e.onSuccess(t)})),submittedBack:a})}))})}({liquidityAmount:null==k?void 0:k.times(F/100),slippage:g,poolKeys:null===(l=C.data)||void 0===l?void 0:l.poolKeys,poolInfo:null===(s=C.data)||void 0===s?void 0:s.poolInfo,submittedBack:()=>{n&&n()}}),z=!(null==a?void 0:a.baseToken)||!(null==a?void 0:a.quoteToken);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{pb:18,px:20},children:[G.jsx(o.Box,{sx:{pt:20},children:W===Su.percentage?G.jsx(Tu,{disabled:C.isLoading||!k||k.lte(0),value:F,onChange:P}):G.jsx(G.Fragment,{})}),G.jsx(Rd,{slippage:f,onChangeSlippage:x,disabled:z,sx:{mt:8}}),G.jsx(vd,{baseToken:null==a?void 0:a.baseToken,quoteToken:null==a?void 0:a.quoteToken,loading:C.isLoading,midPrice:v?b:j,lpBalancePercentage:O?R:100})]}),G.jsx(o.Box,{sx:{px:20,py:16,position:"sticky",bottom:0,borderStyle:"solid",borderWidth:"1px 0 0",borderColor:"border.main",backgroundColor:"background.paper"},children:a?G.jsx(Du,{chainId:a.chainId,baseTokenStatus:N,quoteTokenStatus:U,children:G.jsx(o.Button,{fullWidth:!0,disabled:H,isLoading:Y.isPending,onClick:()=>{H||Y.mutate()},children:D})}):G.jsx(o.Button,{fullWidth:!0,disabled:!0,children:D})}),G.jsx(Uu,{message:null===(c=Y.error)||void 0===c?void 0:c.message,onClose:()=>Y.reset()})]})}function Gu({pool:t,operate:n,hidePoolInfo:r,submittedBack:a}){var l;const{operateTab:s,operateTabs:d,handleChangeTab:c}=function(t=Nu.Add){const{i18n:n}=e.useLingui(),[o,r]=i.useState(t),a=i.useMemo((()=>[{key:Nu.Add,value:n._({id:"m16xKo",message:"Add"})},{key:Nu.Remove,value:n._({id:"t/YqKh",message:"Remove"})}]),[n._]);return i.useEffect((()=>{r(t)}),[t]),{operateTab:o,operateTabs:a,handleChangeTab:e=>{r(e)}}}(n);Zo();const{price:u,invertedPrice:p,poolInfoQuery:h,lpBalanceQuery:m,lpBalance:f,lpBalancePercentage:x,lpToAmountA:g,lpToAmountB:y,liquidityMinted:v,pairMintAAmount:b,pairMintBAmount:j,isExists:C}=rd({pool:(null==t?void 0:t.baseToken)&&t.quoteToken?{baseToken:t.baseToken,quoteToken:t.quoteToken,address:t.address}:void 0,baseAmount:void 0,quoteAmount:void 0,slippage:0});return G.jsxs(G.Fragment,{children:[G.jsx(qu,{pool:t,hidePoolInfo:r,children:G.jsx(kd,{isExists:C,poolInfo:null===(l=h.data)||void 0===l?void 0:l.poolInfo,poolInfoLoading:h.isLoading,lpBalanceLoading:m.isLoading,lpBalance:f,lpBalancePercentage:x,lpToAmountA:g,lpToAmountB:y,sx:{px:0,py:0,border:"none"}})}),G.jsxs(o.Tabs,{value:s,onChange:(e,t)=>{c(t)},children:[G.jsx(o.TabsButtonGroup,{tabs:d,variant:"inPaper",tabsListSx:{mt:16,mx:20}}),G.jsx(o.TabPanel,{value:Nu.Add,children:G.jsx(zu,{pool:t,submittedBack:a})}),G.jsx(o.TabPanel,{value:Nu.Remove,children:G.jsx(Xu,{pool:t,submittedBack:a})})]})]})}function _u({onClose:t,pool:n,operate:r,hasMining:a,hidePoolInfo:l,sx:s}){const{poolOrMiningTab:d,poolOrMiningTabs:c,handleChangeTab:u}=function({hasMining:t}){const{i18n:n}=e.useLingui(),[o,r]=i.useState(Zu.Liquidity);return{poolOrMiningTab:o,poolOrMiningTabs:i.useMemo((()=>{const e=[{key:Zu.Liquidity,value:n._({id:"6y2TB3",message:"Liquidity"})},{key:Zu.Mining,value:n._({id:"Sti4vy",message:"Mining"})}];return t?e:e.slice(0,1)}),[n._,t]),handleChangeTab:e=>{r(e)}}}({hasMining:a});return G.jsx(o.Box,{sx:s,children:G.jsxs(o.Tabs,{value:d,onChange:(e,t)=>{u(t)},sx:{display:"flex",flexDirection:"column",overflow:"hidden",height:"100%"},children:[G.jsx(o.TabsGroup,{tabs:c,tabsListSx:Object.assign({mx:20,justifyContent:t?"space-between":"flex-start"},{}),rightSlot:G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",gap:12},children:t?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:24,height:24,borderRadius:"50%",borderWidth:1,color:"text.secondary",cursor:"pointer"},children:G.jsx(o.Box,{component:A.Error,sx:{width:16,height:16},onClick:()=>{t()}})}):void 0})}),G.jsx(o.TabPanel,{value:Zu.Liquidity,sx:{flex:1,overflowY:"auto"},children:G.jsx(Gu,{pool:n,operate:r,hidePoolInfo:l,submittedBack:()=>{a&&u(Zu.Mining)}})})]})})}function Ju(e){var{modal:t}=e,n=Oo(e,["modal"]);const{isMobile:o}=Ls();return G.jsx(ds,{open:!!n.pool,onClose:n.onClose,scope:!o,modal:t,id:"pool-operate",children:G.jsx(_u,{...n})})}!function(e){e[e.Liquidity=1]="Liquidity",e[e.Mining=2]="Mining"}(Zu||(Zu={})),function(e){e[e.Add=1]="Add",e[e.Remove=2]="Remove"}(Nu||(Nu={}));const Qu=e=>Object.keys(new Array(e+1).join(","));var Ku,$u,ep;function tp({sx:t,hasSearch:n,emptyText:i}){return G.jsxs(o.Box,{sx:Object.assign({display:"flex",flexDirection:"column",gap:12,justifyContent:"center",alignItems:"center",typography:"body2",fontWeight:500,color:"text.secondary",textAlign:"center"},t),children:[G.jsx(o.EmptyDataIcon,{hasSearch:n,sx:{width:60,height:60,borderRadius:12}}),G.jsx(o.Box,{children:null!=i?i:G.jsx(e.Trans,{id:"AxPAXW",message:"No results found"})})]})}function np(){return np=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},np.apply(null,arguments)}!function(e){e[e.Failed=0]="Failed",e[e.Success=1]="Success",e[e.Warning=2]="Warning"}(Ku||(Ku={}));const op=e=>O.createElement("svg",np({width:60,height:60,viewBox:"0 0 60 60",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),O.createElement("g",{opacity:.5},O.createElement("mask",{id:"mask0_3521_179418",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:0,y:0,width:60,height:60},$u||($u=O.createElement("rect",{width:60,height:60,rx:16,fill:"white"}))),ep||(ep=O.createElement("g",{mask:"url(#mask0_3521_179418)"},O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 30.0352H60V16.0352C60 7.1986 52.8366 0.0351562 44 0.0351562H16C7.16344 0.0351562 0 7.1986 0 16.0352V30.0352Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{d:"M29.4643 4H16C9.37258 4 4 9.37258 4 16V27H27.1154L31.7914 18.7271L23.1831 13.6634L29.4643 4Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{d:"M31.7101 27H56V16C56 9.37258 50.6274 4 44 4H34.0384L34.1766 4.08987L28.8164 12.3364L37.2081 17.2727L31.7101 27Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0 44C0 52.8366 7.16344 60 16 60H44C52.8366 60 60 52.8366 60 44V30H0V44Z",fill:"#ABABAB",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M59.4395 44.8861C59.4395 53.0965 52.7625 59.7526 44.5257 59.7526C36.2891 59.7526 29.6118 53.0965 29.6118 44.8861C29.6118 36.6756 36.2891 30.0195 44.5257 30.0195C52.7625 30.0195 59.4395 36.6756 59.4395 44.8861Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M29.8277 44.8665C29.8277 53.077 23.1507 59.7331 14.9139 59.7331C6.67727 59.7331 0 53.077 0 44.8665C0 36.6561 6.67727 30 14.9139 30C23.1507 30 29.8277 36.6561 29.8277 44.8665Z",fill:"#727272",fillOpacity:.4}),O.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M51.9177 44.8883C51.9177 48.958 48.6082 52.257 44.5255 52.257C40.4431 52.257 37.1333 48.958 37.1333 44.8883C37.1333 40.8186 40.4431 37.5195 44.5255 37.5195C48.6082 37.5195 51.9177 40.8186 51.9177 44.8883Z",fill:"#444446"})))));function ip({sx:t,refresh:n}){return G.jsxs(o.Box,{sx:a.merge({display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},t),children:[G.jsx(o.Box,{component:op,sx:{display:"inline-block",width:60,height:60,mb:12}}),G.jsx(o.Box,{sx:{typography:"body2",width:252,textAlign:"center"},children:G.jsx(o.Box,{component:"span",sx:{color:"text.secondary"},children:G.jsx(e.Trans,{id:"Vmw6BM",message:"Something went wrong…<0>Refresh again</0>",components:{0:G.jsx(o.HoverOpacity,{component:"span",color:"primary.main",weak:!0,sx:{cursor:"pointer"},onClick:()=>{n()}})}})})})]})}function rp({loading:e,empty:t,hasSearch:n,children:i,refetch:r}){return e?G.jsx(o.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"center",gap:24,px:24,height:320},children:Qu(4).map(((e,t)=>G.jsx(o.Skeleton,{width:"100%",height:45},t)))}):r?G.jsx(ip,{refresh:r,sx:{height:320}}):t?G.jsx(tp,{hasSearch:n,sx:{height:320}}):G.jsx(G.Fragment,{children:i})}function ap({children:e,sx:t,gap:n=20,repeatBaseForLargeScreen:i=3}){const{isMobile:r,minDevice:a}=Ls();let l={};if(r)l={display:"flex",flexDirection:"column",gap:n};else{let e=2;[1418,1761,2104].some(((t,n)=>{if(a(t))return e=i+n,!0})),l={display:"grid",gap:n,gridTemplateColumns:`repeat(${e}, 1fr)`}}return G.jsx(o.Box,{sx:Object.assign(Object.assign({},l),t),children:e})}function lp({address:t,chainId:i,hideName:r,sx:a}){const l=o.useTheme(),s=rr(),{onlyChainId:c}=Fo(),u=d.useQuery(Object.assign({},s.getQuery(n.SystemApi.graphql.fetchLiquidityLpPartnerRewards,{where:{chainId:c||void 0}})));if(!t)return null;const p=[];return("string"==typeof t?[t]:Array.from(new Set(t)).filter((e=>!!e))).forEach((e=>{var t,n,o;e&&(null===(o=null===(n=null===(t=u.data)||void 0===t?void 0:t.liquidity_getLpPartnerRewards)||void 0===n?void 0:n.partnerRewards)||void 0===o||o.some((t=>{var n,o,r,a,l,s,d,c,h,m,f,x,g,y;if((null==t?void 0:t.chainId)===i&&(null===(n=null==t?void 0:t.pool)||void 0===n?void 0:n.toLocaleLowerCase())===e.toLocaleLowerCase()){const e=null===(a=null===(r=null===(o=u.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;p.push({partner:{name:null!==(l=null==e?void 0:e.partner)&&void 0!==l?l:"",logo:null!==(s=null==e?void 0:e.logo)&&void 0!==s?s:"",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!==(h=null==e?void 0:e.extra)&&void 0!==h?h:{},background:(null===(m=null==e?void 0:e.theme)||void 0===m?void 0:m[0])||void 0,color:(null===(f=null==e?void 0:e.theme)||void 0===f?void 0:f[1])||void 0},reward:null!==(x=null==t?void 0:t.reward)&&void 0!==x?x:"",type:null!==(g=null==t?void 0:t.type)&&void 0!==g?g:"stakelp",sort:null!==(y=null==e?void 0:e.sort)&&void 0!==y?y:Number.MAX_SAFE_INTEGER})}})))})),(null==p?void 0:p.length)?(p.sort(((e,t)=>e.sort-t.sort)),G.jsx(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:4},a),children:p.map((t=>G.jsx(o.Tooltip,{leaveDelay:100,title:G.jsxs(o.Box,{sx:{maxWidth:240,whiteSpace:"pre-wrap"},children:[t.partner.introduction,!!t.partner.link&&G.jsxs(o.Box,{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:[G.jsx(e.Trans,{id:"zwWKhA",message:"Learn more"})," ",G.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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:G.jsxs(o.ButtonBase,{sx:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,p:l.spacing(0,4),height:20,borderRadius:4,background:t.partner.background,color:t.partner.color,whiteSpace:"nowrap"},children:[G.jsx(o.Box,{component:"img",src:t.partner.logo,alt:t.partner.name,sx:{width:14,height:14,borderRadius:"50%"}}),!r&&!!t.reward&&G.jsx(o.Box,{sx:{fontSize:"10px",fontWeight:600},children:t.reward})]})},t.partner.name+t.reward)))})):null}var sp,dp;function cp(){return cp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},cp.apply(null,arguments)}const up=e=>O.createElement("svg",cp({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),sp||(sp=O.createElement("circle",{cx:16,cy:16,r:16,fill:"#FFE804"})),dp||(dp=O.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"}))),pp="_default";function hp({value:e,onChange:t,placeholder:n,options:i,sx:r,readOnly:l,valueOnlyIcon:s}){const d=o.useTheme();return G.jsx(o.Select,{value:null!=e?e:pp,onChange:(n,o)=>{const i="number"==typeof e?Number(o):o;t(i===pp?void 0:i)},disabled:l,sx:a.merge({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:l?"text.disabled":"text.primary"},"& .MuiOutlinedInput-notchedOutline":{display:"none"}},r),renderValue:t=>{if(!(null==t?void 0:t.value)||t.value===pp)return G.jsx(o.Box,{sx:{color:"text.secondary"},children:null!=n?n:""});const r=i.find((t=>t.key===e));return r?G.jsxs(G.Fragment,{children:[r.logo,s?"":r.value]}):null},options:[...i]})}function mp({isMobileStyle:e,chain:t,isLastItem:n,logoWidth:i,mobileLogoWidth:r,sx:a}){const l=o.useTheme();return e?G.jsxs(o.Box,{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"},a),children:[G.jsx(o.Box,{component:null==t?void 0:t.logo,sx:{width:r,height:r}}),G.jsx(o.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]}):G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Box,{component:null==t?void 0:t.logo,sx:{width:i,height:i}}),G.jsx(o.Box,{component:"span",className:"name",sx:{marginLeft:8},children:null==t?void 0:t.name})]})}const fp=-1;function xp({chainId:t,setChainId:n,logoWidth:r=24,mobileLogoWidth:a=32,mainLogoWidth:l=24,mainMobileLogoWidth:s=18,notShowAllChain:d,valueOnlyIcon:c,sx:u}){const p=function(){const{chainId:e}=g.useWeb3React();return i.useMemo((()=>{const t=new Map;let n;return La.forEach(((o,i)=>{if(o.mainnet){if(e!==o.chainId)return;n=o.mainnet}t.set(i,Object.assign({},o))})),void 0!==n&&t.delete(n),Array.from(t.values())}),[e])}(),[h,m]=i.useState(!1),{isMobile:f}=Ls(),{i18n:x}=e.useLingui(),y=i.useCallback((()=>{const e=void 0===t?p[0]:p.find((e=>e.chainId===t));if(c){if(void 0===t||!e)return"";const n=f?a:l;return G.jsx(o.Box,{component:null==e?void 0:e.logo,sx:{width:n,height:n}})}return void 0!==t||d?e?G.jsx(mp,{isMobileStyle:f,chain:e,logoWidth:l,mobileLogoWidth:s}):null:G.jsx(mp,{isMobileStyle:f,chain:{chainId:fp,logo:up,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:l,mobileLogoWidth:s,sx:{border:"none"}})}),[t,p,d,c,f,x._]),v=i.useMemo((()=>{const e=[];return d||e.push({key:fp,value:G.jsx(mp,{isMobileStyle:f,chain:{chainId:fp,logo:up,name:x._({id:"pY/ok7",message:"All chains"})},logoWidth:r,mobileLogoWidth:a})}),p.forEach(((t,n)=>{e.push({key:t.chainId,value:G.jsx(mp,{isLastItem:n===p.length-1,isMobileStyle:f,chain:t,logoWidth:r,mobileLogoWidth:a})})})),e}),[f,r,a,p,d]);return f?G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,onClick:()=>m(!0),sx:Object.assign({display:"flex",alignItems:"center",backgroundColor:"background.tag",borderRadius:8,border:"none",px:8,height:32,fontWeight:600,typography:"body2"},u),children:[G.jsx(o.Box,{sx:{pr:5},children:y()}),G.jsx(o.Box,{component:A.CaretUp,sx:{width:12,height:12,transform:"rotate(180deg)"}})]}),G.jsx(ds,{open:h,title:G.jsx(e.Trans,{id:"lJvbHq",message:"Select Network"}),onClose:()=>m(!1),id:"select-chain",modal:!0,children:G.jsx(o.Box,{sx:{mb:20},children:v.map((e=>G.jsxs(o.Box,{onClick:()=>{const t=e.key;n(t===fp?void 0:Number(t)),m(!1)},sx:{position:"relative",px:20,"&:active":{backgroundColor:"hover.default"},"&:hover":{backgroundColor:"hover.default"},cursor:"pointer"},children:[e.value,(t?e.key===t:e.key===fp)&&G.jsx(o.Box,{sx:{position:"absolute",left:0,top:24,height:20,width:2,backgroundColor:"text.primary"}})]},e.key)))})})]}):G.jsx(hp,{value:null!=t?t:fp,onChange:e=>{n(e===fp?void 0:e)},placeholder:x._({id:"lJvbHq",message:"Select Network"}),options:v,valueOnlyIcon:c,sx:Object.assign({height:32,fontWeight:600,typography:"body2"},u)})}function gp({text:e,onClick:t}){const n=o.useTheme();return G.jsxs(o.Box,{sx:{typography:"body2",display:"inline-flex",alignItems:"center",p:n.spacing(0,4,0,8),width:"max-content",height:32,backgroundColor:"hover.default",borderWidth:1,borderRadius:8,cursor:"pointer"},onClick:t,children:[e,G.jsx(o.Box,{component:A.ArrowBack,sx:{ml:2,width:16,height:16,transform:"rotate(180deg)"}})]})}function yp({lqList:e,onDeleteTag:t,sx:n}){var i;if(!(null==e?void 0:e.length))return null;if(!(null===(i=e[0])||void 0===i?void 0:i.pair))return null;const{pair:r}=e[0],a=Wc(r.baseToken,r.chainId),l=Wc(r.quoteToken,r.chainId);return a&&l?G.jsxs(o.Box,{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:[G.jsx(gd,{tokens:[a,l],chainId:a.chainId,width:20,mr:8}),a.symbol,"+",l.symbol,G.jsx(o.Box,{component:A.Error,sx:{ml:4,width:16,height:16,cursor:"pointer",color:"text.secondary",position:"relative",top:1.5},onClick:()=>t()})]}):null}function vp({tags:e,onDeleteTag:t,sx:n}){return e.length?G.jsx(o.Box,{sx:Object.assign({display:"inline-flex",alignItems:"center"},n),children:e.map((e=>G.jsxs(o.Box,{sx:{typography:"body2",display:"flex",alignItems:"center",px:8,mr:8,borderRadius:8,fontWeight:600,height:32,backgroundColor:"hover.default"},children:[G.jsx(Wa,{address:e.address,width:20,height:20,chainId:e.chainId,url:e.logoURI,noShowChain:!0,marginRight:8}),e.symbol,G.jsx(o.Box,{component:A.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 bp({chainId:e,address:t}){const{isMobile:n}=Ls();return G.jsx(o.Box,{component:"button",onClick:n=>{n.stopPropagation(),Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:e,address:t}})},sx:Object.assign({display:"flex",alignItems:"center",justifyContent:"center",borderRadius:8,cursor:"pointer",flexShrink:0,height:36,"&:hover":{opacity:.5}},n?{width:64,backgroundColor:"background.tag"}:{width:40,backgroundColor:"transparent",borderWidth:1}),children:G.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:G.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:"#1A1A1B"})})})}function jp(t){var{sx:n,children:i,hasMore:r,loadMore:a,loadMoreLoading:l}=t,s=Oo(t,["sx","children","hasMore","loadMore","loadMoreLoading"]);const d=o.useTheme();return G.jsxs(o.Box,{sx:Object.assign({position:"relative",flex:1,overflowY:"auto"},n),...s,children:[G.jsx(o.Box,{component:"table",sx:{width:"100%",borderCollapse:"collapse","& th":{p:24,typography:"body1",textAlign:"left",color:"text.secondary"},"& td":{px:24,py:20},"& thead":{position:"sticky",top:0,zIndex:2,backgroundColor:"background.paper"},"& th:last-child, & td:last-child":{position:"sticky",right:0,zIndex:1,backgroundColor:"background.paper","&::before":{content:'""',position:"absolute",top:0,bottom:0,left:1,width:"1px",boxShadow:`${o.alpha(d.palette.text.primary,.1)} -2px 0px 4px 0px`}}},children:i}),r&&G.jsx(o.ButtonBase,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:64,width:"100%",borderStyle:"solid",borderColor:"border.main",borderWidth:d.spacing(1,0,0,0),typography:"body2",color:"text.secondary","&:hover":{color:"text.primary"}},onClick:a,children:l?G.jsx(o.RotatingIcon,{}):G.jsxs(G.Fragment,{children:[G.jsx(e.Trans,{id:"yQ2kGp",message:"Load more"}),G.jsx(o.Box,{component:A.ArrowRight,sx:{transform:"rotate(90deg)"}})]})})]})}function Cp({sx:t}){return G.jsxs(o.Box,{sx:Object.assign({px:20,pt:20,pb:12,backgroundColor:"background.paperContrast",borderRadius:16,display:"flex",flexDirection:"column"},t),children:[G.jsx(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(o.Skeleton,{variant:"circular",width:48}),G.jsx(o.Skeleton,{variant:"rounded",height:28,width:100,sx:{ml:8}})]})}),G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",mt:44},children:[G.jsxs(o.Box,{children:[G.jsx(o.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]}),G.jsx(o.Box,{sx:{display:"inline-block",mx:20,height:24,width:"1px",backgroundColor:"custom.border.default"}}),G.jsxs(o.Box,{children:[G.jsx(o.Skeleton,{variant:"rounded",height:24,width:100}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]})]}),G.jsx(o.Skeleton,{variant:"rounded",height:32})]})}function wp({chainId:t,baseToken:n,quoteToken:i,apy:a,hasQuote:l,hasMining:s,sx:d,children:c}){if(!n)return null;const u=l?[{token:n,transactionApy:null==a?void 0:a.transactionBaseApy,miningApy:null==a?void 0:a.miningBaseApy},{token:i,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}];return G.jsx(o.Tooltip,{children:null!=c?c:G.jsx(o.HoverOpacity,{component:A.QuestionBorder,sx:Object.assign({width:15,height:15},d)}),title:G.jsx(o.Box,{sx:{width:236},children:u.map(((a,l)=>{var d,c,u,p;return G.jsxs(o.Box,{sx:{mt:0===l?0:20},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",typography:"body2",fontWeight:600,color:"text.primary"},children:[G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:a.token?G.jsxs(G.Fragment,{children:[G.jsx(Wa,{width:14,height:14,marginRight:4,address:a.token.address,url:a.token.logoURI,chainId:t,noShowChain:!0}),a.token.symbol]}):G.jsxs(G.Fragment,{children:[G.jsx(gd,{tokens:[n,i],width:14,mr:4,chainId:t}),n.symbol,"/",null==i?void 0:i.symbol]})}),G.jsx(o.Box,{children:ci(new r(null!==(u=a.transactionApy)&&void 0!==u?u:0).plus(null!==(p=a.miningApy)&&void 0!==p?p:0))})]}),G.jsxs(o.Box,{sx:{mt:8,display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"OnDEky",message:"LP Fee"})}),G.jsx("span",{children:a.transactionApy?ci(new r(a.transactionApy)):"-"})]}),s?G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"h6",color:"text.secondary"},children:[G.jsx("span",{children:G.jsx(e.Trans,{id:"pSQ1lM",message:"MT Fee"})}),G.jsx("span",{children:a.miningApy?ci(new r(a.miningApy)):"-"})]}):""]},null!==(c=null===(d=a.token)||void 0===d?void 0:d.address)&&void 0!==c?c:1)}))})})}function kp({sx:n,value:r,onChange:a,searchAddress:l}){const[s,d]=i.useState(!1),{isMobile:c}=Ls();return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{component:o.ButtonBase,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},c?{}:{minWidth:220}),n),onClick:()=>d(!0),children:[G.jsx(o.Box,{component:A.Search,sx:{width:16,height:16,mr:8,flexShrink:0}}),G.jsx(e.Trans,{id:"A1taO8",message:"Search"})]}),G.jsx(Ds,{value:r,open:s,multiple:!0,title:G.jsx(e.Trans,{id:"o8aMNm",message:"Select a liquidity pool"}),searchPlaceholder:t.i18n._({id:"4nzwq3",message:"Search by token or pool address"}),onClose:()=>{d(!1)},onTokenChange:e=>{if(Array.isArray(e)){if(e.length>2){const t=[e[0],e[2]];a(t)}else a(e);d(!1)}},searchOtherAddress:e=>l(e,(()=>d(!1))),modal:!0})]})}function Tp({list:t,onClick:i}){return G.jsx(G.Fragment,{children:null==t?void 0:t.map((t=>{var a,l,s,d;if(!(null==t?void 0:t.pair))return null;const c=t.pair,u=Wc(c.baseToken,c.chainId),p=Wc(c.quoteToken,c.chainId),h=c.apy?ci(new r(null===(a=c.apy)||void 0===a?void 0:a.transactionBaseApy).plus(null!==(s=null===(l=c.apy)||void 0===l?void 0:l.miningBaseApy)&&void 0!==s?s:0)):void 0,m=n.PoolApi.utils.singleSideLp(c.type)&&c.apy?ci(new r(c.apy.transactionQuoteApy).plus(null!==(d=c.apy.miningQuoteApy)&&void 0!==d?d:0)):void 0;return u&&p?G.jsxs(o.Box,{onClick:i,sx:{display:"flex",justifyContent:"space-between",alignItems:"center",px:10,py:20,borderRadius:8,cursor:"pointer","&:hover":{backgroundColor:"custom.background.listHover"}},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(gd,{tokens:[u,p],chainId:c.chainId,width:24,mr:10}),G.jsxs(o.Box,{sx:{typography:"h5"},children:[u.symbol,"/",p.symbol]})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{color:"custom.status.green.default",fontWeight:600},children:[h,m?`/${m}`:""]}),G.jsx(o.Box,{sx:{mt:2,typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})})]})]},c.id):null}))})}function Rp(){const[e,t]=i.useState([]),[n,o]=i.useState([]),[r,a]=i.useMemo((()=>{const[t,n]=e;return[null==t?void 0:t.symbol,null==n?void 0:n.symbol]}),[e]);return{filterTokens:e,filterASymbol:r,filterBSymbol:a,filterAddressLqList:n,handleDeleteToken:e=>{t((t=>{const n=[...t],o=n.indexOf(e);return-1!==o&&n.splice(o,1),n}))},handleChangeFilterTokens:e=>{o([]),t(e)},handleChangeFilterAddress:e=>{o(e),t([])}}}function Sp({lqList:t,setOperatePool:i,supportAMM:a}){const l=o.useTheme();return G.jsx(G.Fragment,{children:null==t?void 0:t.map((t=>{var s,d,c,u,p,h,m;if(!(null==t?void 0:t.pair))return null;const f=t.pair,x=Wc(f.baseToken,f.chainId),g=Wc(f.quoteToken,f.chainId),y=f.apy?ci(new r(null===(s=f.apy)||void 0===s?void 0:s.transactionBaseApy).plus(null!==(c=null===(d=f.apy)||void 0===d?void 0:d.miningBaseApy)&&void 0!==c?c:0)):void 0,v=n.PoolApi.utils.singleSideLp(f.type)&&f.apy?ci(new r(f.apy.transactionQuoteApy).plus(null!==(u=f.apy.miningQuoteApy)&&void 0!==u?u:0)):void 0,b=!!(null===(p=f.miningAddress)||void 0===p?void 0:p[0]),j=Fc(f.type);return G.jsx(o.Box,{sx:{p:8,borderRadius:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"border.disabled",backdropFilter:"blur(5px)"},children:G.jsxs(o.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:"border.main"},className:"gradient-card-border",onClick:()=>{a||Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:f.chainId,address:f.id}})},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[x&&g?G.jsx(gd,{tokens:[x,g],width:24,mr:6,chainId:f.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==x?void 0:x.symbol}/${null==g?void 0:g.symbol}`,G.jsx(lp,{address:f.id,chainId:f.chainId})]})]}),b?G.jsxs(o.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${o.alpha(l.palette.secondary.main,.3)} 0%, ${o.alpha(l.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(o.Box,{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:[a&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[j,G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:f.type,lpFeeRate:null!==(h=f.lpFeeRate)&&void 0!==h?h:0,mtFeeRate:null!==(m=f.mtFeeRate)&&void 0!==m?m:0})})})]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5",color:"success.main"},children:[y,v?`/${v}`:""]}),G.jsxs(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(wp,{chainId:f.chainId,apy:f.apy,baseToken:x,quoteToken:g,hasQuote:!!v,hasMining:b,sx:{width:14,height:14}})]})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5"},children:["$",si(new r(f.tvl))]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]}),a&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:["$",Qo({input:f.volume24H||0})]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"Q8W3SC",message:"Volume (1D)"})})]})]}),G.jsxs(o.Box,{sx:{mt:20,display:"flex",gap:"8px"},children:[G.jsx(bs,{fullWidth:!0,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),i({pool:Vc(t),hasMining:b})},children:G.jsx(e.Trans,{id:"m16xKo",message:"Add"})}),a&&"PMM"===j&&G.jsx(bp,{chainId:f.chainId,address:f.id})]})]})},f.id+f.chainId)}))})}function Ip({lqList:i,operatePool:a,setOperatePool:l,hasMore:s,loadMore:d,loadMoreLoading:c,supportAMM:u}){const p=o.useTheme();return G.jsxs(jp,{hasMore:s,loadMore:d,loadMoreLoading:c,children:[G.jsx(o.Box,{component:"thead",children:G.jsxs(o.Box,{component:"tr",children:[G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),u&&G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})}),G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})}),u&&G.jsx("th",{children:G.jsx(e.Trans,{id:"Q8W3SC",message:"Volume (1D)"})}),G.jsx(o.Box,{component:"th",sx:{width:80}})]})}),G.jsx(o.Box,{component:"tbody",children:null==i?void 0:i.map((i=>{var s,d,c,h,m,f,x,g;if(!(null==i?void 0:i.pair))return null;const y=i.pair,v=Wc(y.baseToken,y.chainId),b=Wc(y.quoteToken,y.chainId),j=y.apy?ci(new r(null===(s=y.apy)||void 0===s?void 0:s.transactionBaseApy).plus(null!==(c=null===(d=y.apy)||void 0===d?void 0:d.miningBaseApy)&&void 0!==c?c:0)):void 0,C=n.PoolApi.utils.singleSideLp(y.type)&&y.apy?ci(new r(y.apy.transactionQuoteApy).plus(null!==(h=y.apy.miningQuoteApy)&&void 0!==h?h:0)):void 0;let w="";if((null===(m=null==a?void 0:a.pool)||void 0===m?void 0:m.address)===y.id||(null==a?void 0:a.address)===y.id)if(a.operate===Nu.Remove)w=t.i18n._({id:"0+31GV",message:"Removing"});else w=t.i18n._({id:"1yHVE+",message:"Adding"});const k=!!(null===(f=y.miningAddress)||void 0===f?void 0:f[0]),T=Fc(y.type),R=p.palette.background.tag;return G.jsxs(o.Box,{component:"tr",sx:{["&:hover td"+(w?", & td":"")]:{backgroundImage:`linear-gradient(${R}, ${R})`}},children:[G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[v&&b?G.jsx(gd,{tokens:[v,b],width:24,mr:10,chainId:y.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==v?void 0:v.symbol}/${null==b?void 0:b.symbol}`,G.jsx(lp,{address:y.id,chainId:y.chainId})]}),G.jsx(fd,{address:y.id,customChainId:y.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,sx:{typography:"h6",color:"text.secondary"},disabledAddress:u,onAddressClick:()=>{Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:y.chainId,address:y.id}})}})]})]})}),u&&G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:T}),G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:y.type,lpFeeRate:null!==(x=y.lpFeeRate)&&void 0!==x?x:0,mtFeeRate:null!==(g=y.mtFeeRate)&&void 0!==g?g:0})})})]})}),G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{typography:"body2"},title:y.tvl?`$${Qo({input:y.tvl})}`:void 0,children:["$",si(new r(y.tvl))]})}),G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[k?G.jsx(o.Tooltip,{title:t.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(wp,{chainId:y.chainId,apy:y.apy,baseToken:v,quoteToken:b,hasQuote:!!C,hasMining:k,children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[j,C?`/${C}`:""]})})]})}),u&&G.jsxs(o.Box,{component:"td",children:["$",Qo({input:y.volume24H||0})]}),G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[u&&"PMM"===T&&G.jsx(bp,{chainId:y.chainId,address:y.id}),w?G.jsx(gp,{text:w,onClick:()=>l(null)}):G.jsx(o.Button,{size:o.Button.Size.small,onClick:()=>{l({pool:Vc(i),hasMining:k})},children:t.i18n._({id:"m16xKo",message:"Add"})})]})})]},y.id+y.chainId)}))})]})}function Bp({scrollParentRef:e,filterChainIds:t,activeChainId:i,handleChangeActiveChainId:r,operatePool:l,setOperatePool:s}){var c;const{onlyChainId:u,supportAMMV2:p,supportAMMV3:h,notSupportPMM:m}=Fo(),{minDevice:f,isMobile:x}=Ls(),g=d.useQueryClient(),{filterTokens:y,filterASymbol:v,filterBSymbol:b,filterAddressLqList:j,handleDeleteToken:C,handleChangeFilterTokens:w,handleChangeFilterAddress:k}=Rp(),T=[];p&&T.push("SVM_AMMV2"),h&&T.push("SVM_AMMV3");const R={chainIds:t,pageSize:x?4:8,filterState:{viewOnlyOwn:!1,filterTypes:T}},S=rr(),I=S.getInfiniteQuery(n.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},R),{filterState:Object.assign({filterASymbol:v,filterBSymbol:b},R.filterState)})}),B=d.useInfiniteQuery(Object.assign(Object.assign({},I),{initialPageParam:1,getNextPageParam:e=>{var t;const{currentPage:n,totalCount:o,pageSize:i}=null!==(t=e.liquidity_list)&&void 0!==t?t:{};if(!n||!o||!i)return null;let r=Math.floor(o/i);return o%i&&(r+=1),n>=r?null:n+1}}));let M=[];const L=!!(null==j?void 0:j.length);L?M=[...j]:null===(c=B.data)||void 0===c||c.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==M||M.push(e)}))}));const O=B.hasNextPage&&!L;return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:Object.assign(Object.assign({py:16,display:"flex",gap:8},f(475)?{}:{flexDirection:"column"}),x?{}:{px:20,borderBottomWidth:1}),children:[G.jsxs(o.Box,{sx:Object.assign({display:"flex",alignItems:"center",gap:8},f(475)?{}:{"& > button":{flex:1}}),children:[!u&&G.jsx(xp,{chainId:i,setChainId:r}),G.jsx(kp,{value:y,onChange:w,searchAddress:(e,t)=>Wo(this,void 0,void 0,(function*(){var o;const i=S.getInfiniteQuery(n.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},R),{filterState:Object.assign({address:e},R.filterState)})}),r=null===(o=(yield g.fetchQuery(i)).liquidity_list)||void 0===o?void 0:o.lqList;return(null==r?void 0:r.length)?G.jsx(Tp,{list:r,onClick:()=>{k(r),t()}}):null}))})]}),(L||!!y.length)&&G.jsxs(o.Box,{sx:{my:0},children:[L?G.jsx(yp,{lqList:j,onDeleteTag:()=>k([])}):"",G.jsx(vp,{tags:y,onDeleteTag:C})]})]}),x?G.jsx(E,{hasMore:O,threshold:300,loadMore:a.debounce((()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()}),500),useWindow:!1,getScrollParent:()=>e.current||null,loader:G.jsx(Cp,{sx:{mt:20}},"loader"),children:G.jsxs(ap,{gap:12,children:[B.isLoading?G.jsx(Cp,{}):"",!B.isLoading&&!(null==M?void 0:M.length)&&!B.error&&G.jsx(tp,{sx:{mt:40},hasSearch:!!(i&&!u||v||b)}),!!B.error&&G.jsx(ip,{refresh:B.refetch,sx:{mt:40}}),G.jsx(Sp,{lqList:M,setOperatePool:s,supportAMM:p||h})]})}):G.jsxs(G.Fragment,{children:[G.jsx(Ip,{lqList:M,operatePool:l,setOperatePool:s,hasMore:O,loadMoreLoading:B.isFetchingNextPage,loadMore:()=>{B.hasNextPage&&!B.isFetching&&B.fetchNextPage()},supportAMM:p||h}),G.jsx(rp,{loading:B.isLoading,refetch:B.error?B.refetch:void 0,empty:!(null==M?void 0:M.length),hasSearch:!!(i&&!u||v||b)})]})]})}function Mp({onClick:e,title:t,desc:n}){const i=o.useTheme();return G.jsx(o.Box,{sx:{mx:20,px:0,py:14,borderTop:`1px solid ${i.palette.border.main}`,[i.breakpoints.up("tablet")]:{borderTop:"none",mx:0,px:16,py:8}},children:G.jsxs(o.ButtonBase,{onClick:e,sx:{width:"100%",display:"flex",flexDirection:"column",gap:0,p:0,borderRadius:8,"&:hover":{backgroundColor:i.palette.background.tag},[i.breakpoints.up("tablet")]:{p:8}},children:[G.jsx(o.Box,{sx:{typography:"body1",fontWeight:600,color:i.palette.text.primary,textAlign:"left"},children:t}),G.jsx(o.Box,{sx:{typography:"h6",fontWeight:500,color:i.palette.text.secondary,textAlign:"left"},children:n})]})})}const Ep=t=>{const n=o.useTheme(),{isMobile:r}=Ls(),{supportAMMV2:a,supportAMMV3:l,notSupportPMM:s}=Fo(),[d,c]=i.useState(!1),u={[exports.PageType.CreatePool]:!s,[exports.PageType.createPoolAMMV2]:!!a,[exports.PageType.createPoolAMMV3]:!!l},p=Object.entries(u).filter((([e,t])=>!0===t)),h=1===p.length?p[0][0]:void 0;if(!h){const t=G.jsxs(G.Fragment,{children:[!s&&G.jsx(Mp,{onClick:()=>{Gs.getState().push({type:exports.PageType.CreatePool})},title:G.jsx(e.Trans,{id:"Eif7f6",message:"PMM Pool"}),desc:G.jsx(e.Trans,{id:"ukTFO0",message:"Description of this type of pool"})}),a&&G.jsx(Mp,{onClick:()=>{Gs.getState().push({type:exports.PageType.createPoolAMMV2})},title:G.jsx(e.Trans,{id:"lNYomJ",message:"AMM V2 Position"}),desc:G.jsx(e.Trans,{id:"ukTFO0",message:"Description of this type of pool"})}),l&&G.jsx(Mp,{onClick:()=>{Gs.getState().push({type:exports.PageType.createPoolAMMV3})},title:G.jsx(e.Trans,{id:"sVlqoo",message:"AMM V3 Position"}),desc:G.jsx(e.Trans,{id:"ukTFO0",message:"Description of this type of pool"})})]});return r?G.jsxs(G.Fragment,{children:[G.jsxs(o.Button,{variant:o.Button.Variant.outlined,fullWidth:r,onClick:()=>{c(!0)},sx:{height:40},children:[G.jsx(o.Box,{component:A.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]}),G.jsx(ds,{open:d,title:G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"}),onClose:()=>{c(!1)},modal:!0,children:G.jsx(o.Box,{sx:{mb:0},children:t})})]}):G.jsx(o.Tooltip,{arrow:!1,leaveDelay:300,placement:r?"bottom":"bottom-end",sx:{p:0,backgroundColor:"background.paper"},title:G.jsx(o.Box,{children:t}),children:G.jsxs(o.Box,{sx:{width:r?"100%":"auto",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:10,pl:8,pr:16,py:7,borderRadius:8,borderWidth:1,borderColor:n.palette.text.primary,typography:"body1",fontWeight:600,color:n.palette.text.primary,cursor:"pointer","&:hover":{backgroundColor:n.palette.background.tag}},children:[G.jsx(o.Box,{component:A.Plus}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})})}return G.jsxs(o.Button,{variant:o.Button.Variant.outlined,fullWidth:r,onClick:()=>{Gs.getState().push({type:h})},sx:{height:40},children:[G.jsx(o.Box,{component:A.Plus,sx:{mr:4}}),G.jsx(e.Trans,{id:"p2jbcE",message:"Create Pool"})]})};const Lp=({onlyV3:e,setOnlyV3:n,sx:i})=>{const r=o.useTheme(),{notSupportPMM:a}=Fo();return G.jsx(o.Box,{component:o.ButtonBase,onClick:()=>n(!e),sx:Object.assign({display:"flex",alignItems:"center",p:2,borderRadius:8,backgroundColor:r.palette.border.main},i),children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",width:"100%",[r.breakpoints.up("tablet")]:{width:194}},children:[G.jsx(o.Box,{sx:Object.assign({flex:1,width:0,pt:4,pb:5,borderRadius:6,textAlign:"center",typography:"body2",whiteSpace:"nowrap"},e?{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}:{color:r.palette.text.secondary,backgroundColor:"transparent"}),children:t.i18n._({id:"yoR+O6",message:"V3"})}),G.jsx(o.Box,{sx:Object.assign({flex:1,width:0,pt:4,pb:5,borderRadius:6,textAlign:"center",typography:"body2",whiteSpace:"nowrap"},e?{color:r.palette.text.secondary,backgroundColor:"transparent"}:{color:r.palette.text.primary,backgroundColor:r.palette.background.paper}),children:a?"V2":t.i18n._({id:"eK6I8d",message:"V2 & PMM"})})]})})};function Op({account:t,lqList:i,setOperatePool:a,supportAMM:l}){const s=o.useTheme();return G.jsx(G.Fragment,{children:null==i?void 0:i.map((i=>{var d,c,u,p,h,m,f,x,g,y,v,b,j,C;if(!(null==i?void 0:i.pair))return null;const w=i.pair,k=Wc(w.baseToken,w.chainId),T=Wc(w.quoteToken,w.chainId),R=n.PoolApi.utils.singleSideLp(w.type),S=w.apy?ci(new r(null===(d=w.apy)||void 0===d?void 0:d.transactionBaseApy).plus(null!==(u=null===(c=w.apy)||void 0===c?void 0:c.miningBaseApy)&&void 0!==u?u:0)):"0%",I=R&&w.apy?ci(new r(w.apy.transactionQuoteApy).plus(null!==(p=w.apy.miningQuoteApy)&&void 0!==p?p:0)):void 0;let B,M;(null===(h=i.liquidityPositions)||void 0===h?void 0:h.length)&&i.liquidityPositions.forEach((e=>{var t,n,o,i,a;if(null==e?void 0:e.liquidityTokenBalance){const l=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==l?void 0:l.length)){const t=l[1].toLocaleLowerCase();if((null===(o=null===(n=null==w?void 0:w.baseLpToken)||void 0===n?void 0:n.id)||void 0===o?void 0:o.toLocaleLowerCase())===t)return void(B=new r(e.liquidityTokenBalance));(null===(a=null===(i=null==w?void 0:w.quoteLpToken)||void 0===i?void 0:i.id)||void 0===a?void 0:a.toLocaleLowerCase())===t&&(M=new r(e.liquidityTokenBalance))}}}));const E=!!(null===(m=w.miningAddress)||void 0===m?void 0:m[0]),L=null===(f=i.liquidityPositions)||void 0===f?void 0:f[0],O=w.type,W=Fc(O),V="SVM_AMMV2"===O,A="SVM_AMMV3"===O;return G.jsx(o.Box,{sx:{p:8,borderRadius:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"border.disabled",backdropFilter:"blur(5px)"},children:G.jsxs(o.Box,{sx:{px:20,pt:20,pb:12,backgroundColor:"background.paper",borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:"border.main"},className:"gradient-card-border",onClick:()=>{l||Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:w.chainId,address:w.id}})},children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap"},children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:8},children:[k&&T?G.jsx(gd,{tokens:[k,T],width:24,mr:6,chainId:w.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{sx:{typography:"body2",fontWeight:600},children:[`${null==k?void 0:k.symbol}/${null==T?void 0:T.symbol}`,G.jsx(lp,{address:w.id,chainId:w.chainId})]})]}),E?G.jsxs(o.Box,{sx:{p:8,typography:"h6",fontWeight:"bold",background:`linear-gradient(180deg, ${o.alpha(s.palette.secondary.main,.3)} 0%, ${o.alpha(s.palette.purple.main,.3)} 100%)`,borderRadius:8,color:"purple.main",whiteSpace:"nowrap"},children:["✨ ",G.jsx(e.Trans,{id:"Sti4vy",message:"Mining"})]}):""]}),G.jsxs(o.Box,{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:[l&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,whiteSpace:"nowrap"},children:[W,G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:w.type,lpFeeRate:null!==(x=w.lpFeeRate)&&void 0!==x?x:0,mtFeeRate:null!==(g=w.mtFeeRate)&&void 0!==g?g:0})})})]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})})]}),A?null:G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5",color:"success.main"},children:[S,I?`/${I}`:""]}),G.jsxs(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:[G.jsx(e.Trans,{id:"rSayea",message:"APY"}),G.jsx(wp,{chainId:w.chainId,apy:w.apy,baseToken:k,quoteToken:T,hasQuote:!!I,hasMining:E,sx:{width:14,height:14}})]})]}),G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{typography:"h5"},children:["$",si(new r(w.tvl||0))]}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})})]})]}),V&&G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{typography:"h5"},children:di({input:null===(v=null===(y=i.liquidityPositions)||void 0===y?void 0:y[0])||void 0===v?void 0:v.poolShare})}),G.jsx(o.Box,{sx:{typography:"h6",color:"text.secondary"},children:G.jsx(e.Trans,{id:"h3PbRN",message:"My Pool Share"})})]}),G.jsxs(o.Box,{children:[G.jsx(o.Box,{sx:{typography:"h5",display:"flex",alignItems:"center",fontWeight:"bold"},children:A?(null==L?void 0:L.liquidityUSD)?`$${Ko({input:L.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[R?G.jsx(Wa,{address:null==k?void 0:k.address,chainId:w.chainId,url:null==k?void 0:k.logoURI,width:18,height:18,sx:{mr:4}}):G.jsx(gd,{tokens:k&&T?[k,T]:[],width:18,mr:4,showChainLogo:!1,chainId:w.chainId}),B?Qo({input:B}):"",R&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Wa,{address:null==T?void 0:T.address,chainId:w.chainId,url:null==T?void 0:T.logoURI,width:18,height:18,sx:{mx:4}}),M?Qo({input:M}):"0"]})]})}),G.jsx(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})})]}),A&&G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Au,{outOfRange:null!==(b=null==L?void 0:L.outOfRange)&&void 0!==b&&b}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(j=null==L?void 0:L.priceRange)||void 0===j?void 0:j.token0LowerPrice,atLimit:{},direction:Ud.LOWER})," "]}),null==k?void 0:k.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.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"})}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(C=null==L?void 0:L.priceRange)||void 0===C?void 0:C.token1LowerPrice,atLimit:{},direction:Ud.UPPER})," "]}),null==k?void 0:k.symbol]})})]}),G.jsx(o.Box,{sx:{typography:"h6",display:"flex",alignItems:"center",color:"text.secondary"},children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})})]})]}),G.jsxs(o.Box,{sx:{mt:20,display:"flex",gap:"8px"},children:[A?null:!!t&&G.jsx(bs,{fullWidth:!0,variant:o.Button.Variant.outlined,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),a({operate:Nu.Remove,pool:Ac(i),hasMining:E})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(bs,{fullWidth:!0,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),a({operate:Nu.Add,pool:Ac(i),hasMining:E})},children:G.jsx(e.Trans,{id:"J/hVSQ",message:"{0}",values:{0:A?"Manage":"Add"}})}),l&&"PMM"===W&&G.jsx(bp,{chainId:w.chainId,address:w.id})]})]})},A?null==L?void 0:L.id:w.id+w.chainId)}))})}function Wp({account:i,lqList:a,operatePool:l,setOperatePool:s,supportAMM:d,onlyV3:c}){const u=o.useTheme();return G.jsxs(jp,{children:[G.jsx(o.Box,{component:"thead",children:G.jsxs(o.Box,{component:"tr",children:[G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"AxdOHo",message:"Pair"})}),d&&G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"1Qz63U",message:"Pool Type"})}),c?null:G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"FHKsZF",message:"TVL"})}),c?null:G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"rSayea",message:"APY"})}),G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"YHc3B+",message:"My Liquidity"})}),c?G.jsx(o.Box,{component:"th",children:G.jsx(e.Trans,{id:"YA4hwj",message:"Price Range"})}):null,G.jsx(o.Box,{component:"th",sx:{width:210}})]})}),G.jsx(o.Box,{component:"tbody",children:null==a?void 0:a.map((a=>{var p,h,m,f,x,g,y,v,b,j,C,w,k,T,R,S,I,B;if(!(null==a?void 0:a.pair))return null;const M=a.pair,E=Wc(M.baseToken,M.chainId),L=Wc(M.quoteToken,M.chainId),O=n.PoolApi.utils.singleSideLp(M.type),W=M.apy?ci(new r(null===(p=M.apy)||void 0===p?void 0:p.transactionBaseApy).plus(null!==(m=null===(h=M.apy)||void 0===h?void 0:h.miningBaseApy)&&void 0!==m?m:0)):void 0,V=O&&M.apy?ci(new r(M.apy.transactionQuoteApy).plus(null!==(f=M.apy.miningQuoteApy)&&void 0!==f?f:0)):void 0;let A,F;(null===(x=a.liquidityPositions)||void 0===x?void 0:x.length)&&a.liquidityPositions.forEach((e=>{var t,n,o,i,a;if(null==e?void 0:e.liquidityTokenBalance){const l=null===(t=e.id)||void 0===t?void 0:t.split("-");if(2===(null==l?void 0:l.length)){const t=l[1].toLocaleLowerCase();if((null===(o=null===(n=null==M?void 0:M.baseLpToken)||void 0===n?void 0:n.id)||void 0===o?void 0:o.toLocaleLowerCase())===t)return void(A=new r(e.liquidityTokenBalance));(null===(a=null===(i=null==M?void 0:M.quoteLpToken)||void 0===i?void 0:i.id)||void 0===a?void 0:a.toLocaleLowerCase())===t&&(F=new r(e.liquidityTokenBalance))}}}));const P=null===(g=a.liquidityPositions)||void 0===g?void 0:g[0],Z=M.type,N=Fc(Z),U="SVM_AMMV2"===Z,H="SVM_AMMV3"===Z;let D="";if(H)(null===(b=null===(v=null===(y=null==l?void 0:l.pool)||void 0===y?void 0:y.liquidityPositions)||void 0===v?void 0:v[0])||void 0===b?void 0:b.id)===(null==P?void 0:P.id)&&(D=t.i18n._({id:"p3607o",message:"Managing"}));else if((null===(j=null==l?void 0:l.pool)||void 0===j?void 0:j.address)===M.id||(null==l?void 0:l.address)===M.id)if(l.operate===Nu.Remove)D=t.i18n._({id:"0+31GV",message:"Removing"});else D=t.i18n._({id:"1yHVE+",message:"Adding"});const Y=!!(null===(C=M.miningAddress)||void 0===C?void 0:C[0]),z=u.palette.background.tag;return G.jsxs(o.Box,{component:"tr",sx:{["&:hover td"+(D?", & td":"")]:{backgroundImage:`linear-gradient(${z}, ${z})`}},children:[G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[E&&L?G.jsx(gd,{tokens:[E,L],width:24,mr:10,chainId:M.chainId,showChainLogo:!0}):"",G.jsxs(o.Box,{children:[G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,typography:"body2",fontWeight:600},children:[`${null==E?void 0:E.symbol}/${null==L?void 0:L.symbol}`,G.jsx(lp,{address:M.id,chainId:M.chainId})]}),G.jsx(fd,{address:M.id,customChainId:M.chainId,truncate:!0,showCopy:!0,iconDarkHover:!0,iconSize:14,iconSpace:4,disabledAddress:d,onAddressClick:()=>{Gs.getState().push({type:exports.PageType.PoolDetail,params:{chainId:M.chainId,address:M.id}})},sx:{typography:"h6",color:"text.secondary"}})]})]})}),d&&G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4},children:[G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary",whiteSpace:"nowrap"},children:N}),G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"O6RUgz",message:"Fee rate"}),children:G.jsx(o.Box,{sx:{px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:Pc({type:M.type,lpFeeRate:null!==(w=M.lpFeeRate)&&void 0!==w?w:0,mtFeeRate:null!==(k=M.mtFeeRate)&&void 0!==k?k:0})})})]})}),H?null:G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{typography:"body2"},title:M.tvl?`$${Qo({input:M.tvl||0})}`:void 0,children:["$",si(new r(M.tvl||0))]})}),H?null:G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[Y?G.jsx(o.Tooltip,{title:t.i18n._({id:"Sti4vy",message:"Mining"}),children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",color:"success.main"},children:["✨"," "]})}):"",G.jsx(wp,{chainId:M.chainId,apy:M.apy,baseToken:E,quoteToken:L,hasQuote:!!V,hasMining:Y,children:G.jsxs(o.Box,{component:"span",sx:{typography:"body2",fontWeight:600,display:"flex",alignItems:"center",width:"max-content",color:"success.main",cursor:"auto"},children:[W||"0%",V?`/${V}`:""]})})]})}),G.jsx(o.Box,{component:"td",children:G.jsx(o.Box,{sx:{display:"flex",alignItems:"center"},children:H?(null==P?void 0:P.liquidityUSD)?`$${Ko({input:P.liquidityUSD,decimals:2})}`:"-":G.jsxs(G.Fragment,{children:[O?G.jsx(Wa,{address:null==E?void 0:E.address,chainId:M.chainId,url:null==E?void 0:E.logoURI,width:24,height:24,noShowChain:!0,sx:{mr:4}}):G.jsx(gd,{tokens:E&&L?[E,L]:[],width:24,mr:4,showChainLogo:!1,chainId:M.chainId}),A?Qo({input:A}):"-",O&&G.jsxs(G.Fragment,{children:[" / ",G.jsx(Wa,{address:null==L?void 0:L.address,chainId:M.chainId,url:null==L?void 0:L.logoURI,width:24,height:24,noShowChain:!0,sx:{mx:4}}),F?Qo({input:F}):"0"]}),U&&G.jsx(o.Tooltip,{title:G.jsx(e.Trans,{id:"NXZdrO",message:"My pool share"}),children:G.jsx(o.Box,{sx:{ml:4,px:8,py:4,borderRadius:4,typography:"h6",backgroundColor:"background.tag",color:"text.secondary"},children:di({input:null===(R=null===(T=a.liquidityPositions)||void 0===T?void 0:T[0])||void 0===R?void 0:R.poolShare})})})]})})}),c?G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",gap:4,color:"text.primary"},children:[G.jsx(Au,{outOfRange:null!==(S=null==P?void 0:P.outOfRange)&&void 0!==S&&S}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(I=null==P?void 0:P.priceRange)||void 0===I?void 0:I.token0LowerPrice,atLimit:{},direction:Ud.LOWER})," "]}),null==E?void 0:E.symbol]})}),G.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"19",viewBox:"0 0 18 19",fill:"none",children:G.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"})}),G.jsx(o.Box,{children:G.jsxs(G.Fragment,{children:[G.jsxs("span",{children:[Uc({price:null===(B=null==P?void 0:P.priceRange)||void 0===B?void 0:B.token0UpperPrice,atLimit:{},direction:Ud.UPPER})," "]}),null==E?void 0:E.symbol]})})]})}):null,G.jsx(o.Box,{component:"td",children:G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[d&&"PMM"===N&&G.jsx(bp,{chainId:M.chainId,address:M.id}),D?G.jsx(gp,{text:D,onClick:()=>s(null)}):G.jsxs(G.Fragment,{children:[H?null:!!i&&G.jsx(bs,{variant:o.Button.Variant.outlined,size:o.Button.Size.small,onClick:e=>{e.stopPropagation(),s({operate:Nu.Remove,pool:Ac(a),hasMining:Y})},children:G.jsx(e.Trans,{id:"t/YqKh",message:"Remove"})}),G.jsx(bs,{size:o.Button.Size.small,onClick:()=>{s({pool:Ac(a),hasMining:Y})},children:H?t.i18n._({id:"wckWOP",message:"Manage"}):t.i18n._({id:"m16xKo",message:"Add"})})]})]})})]},H?null==P?void 0:P.id:M.id+M.chainId)}))})]})}function Vp({account:e,filterChainIds:t,activeChainId:r,handleChangeActiveChainId:a,operatePool:l,setOperatePool:s}){var c,u,p,h,m,f,x;o.useTheme();const{minDevice:g,isMobile:y}=Ls(),v=d.useQueryClient(),{onlyChainId:b,supportAMMV2:j,supportAMMV3:C,notSupportPMM:w}=Fo(),[k,T]=i.useState(!1),{filterTokens:R,filterASymbol:S,filterBSymbol:I,filterAddressLqList:B,handleDeleteToken:M,handleChangeFilterTokens:E,handleChangeFilterAddress:L}=Rp();let O=[];j&&O.push("SVM_AMMV2"),C&&k&&(O=["SVM_AMMV3"]);const W={currentPage:1,pageSize:1e3,user:e,filterState:{viewOnlyOwn:!0,filterTypes:O}},V=rr(),A=V.getQuery(n.PoolApi.graphql.fetchMyLiquidityList,{where:Object.assign(Object.assign({},W),{filterState:Object.assign({filterASymbol:S,filterBSymbol:I},W.filterState)})}),F=d.useQuery(Object.assign({},A));let P=null!==(p=null===(u=null===(c=F.data)||void 0===c?void 0:c.liquidity_list)||void 0===u?void 0:u.lqList)&&void 0!==p?p:[];const Z=!!(null==B?void 0:B.length);Z?P=[...B]:t&&(P=null!==(x=null===(f=null===(m=null===(h=F.data)||void 0===h?void 0:h.liquidity_list)||void 0===m?void 0:m.lqList)||void 0===f?void 0:f.filter((e=>{var n,o;return t.includes(null!==(o=null===(n=null==e?void 0:e.pair)||void 0===n?void 0:n.chainId)&&void 0!==o?o:0)})))&&void 0!==x?x:[]);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:Object.assign(Object.assign({py:16,display:"flex",gap:8},g(475)?{}:{flexDirection:"column"}),y?{}:{px:20,borderBottomWidth:1}),children:[G.jsxs(o.Box,{sx:Object.assign(Object.assign({display:"flex",alignItems:"center",gap:8},g(475)?{}:{"& > button":{flex:1,flexBasis:"100%"}}),y?{flexWrap:"wrap"}:{}),children:[!b&&G.jsx(xp,{chainId:r,setChainId:a}),C&&G.jsx(Lp,{onlyV3:k,setOnlyV3:T,sx:y?{flexGrow:1,flexBasis:"100%"}:void 0}),G.jsx(kp,{value:R,onChange:E,searchAddress:(e,t)=>Wo(this,void 0,void 0,(function*(){var o;const i=V.getInfiniteQuery(n.PoolApi.graphql.fetchLiquidityList,"currentPage",{where:Object.assign(Object.assign({},W),{filterState:Object.assign({address:e},W.filterState)})}),r=null===(o=(yield v.fetchQuery(i)).liquidity_list)||void 0===o?void 0:o.lqList;return(null==r?void 0:r.length)?G.jsx(Tp,{list:r,onClick:()=>{L(r),t()}}):null}))})]}),(Z||!!R.length)&&G.jsxs(o.Box,{sx:{my:0},children:[Z?G.jsx(yp,{lqList:B,onDeleteTag:()=>L([])}):"",G.jsx(vp,{tags:R,onDeleteTag:M})]})]}),y?G.jsxs(ap,{gap:12,children:[F.isLoading?G.jsx(Cp,{}):"",!F.isLoading&&!(null==P?void 0:P.length)&&!F.error&&G.jsx(tp,{sx:{mt:40},hasSearch:!!(r&&!b||S||I)}),!!F.error&&G.jsx(ip,{refresh:F.refetch,sx:{mt:40}}),G.jsx(Op,{account:e,lqList:P,setOperatePool:s,supportAMM:j||C})]}):G.jsxs(G.Fragment,{children:[G.jsx(Wp,{account:e,lqList:P,operatePool:l,setOperatePool:s,supportAMM:j||C,onlyV3:k}),G.jsx(rp,{loading:F.isLoading,refetch:F.error?F.refetch:void 0,empty:!(null==P?void 0:P.length),hasSearch:!!(r&&!b||S||I)})]})]})}var Ap,Fp;function Pp(){return Pp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},Pp.apply(null,arguments)}const Zp=e=>O.createElement("svg",Pp({width:66,height:64,viewBox:"0 0 66 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink"},e),Ap||(Ap=O.createElement("rect",{width:64,height:60.1342,fill:"url(#pattern0)"})),Fp||(Fp=O.createElement("defs",null,O.createElement("pattern",{id:"pattern0",patternContentUnits:"objectBoundingBox",width:1,height:1},O.createElement("use",{xlinkHref:"#image0_2465_53170",transform:"matrix(0.00671141 0 0 0.00714286 -0.503356 -0.9)"})),O.createElement("image",{id:"image0_2465_53170",width:300,height:300,xlinkHref:"data:image/png;base64,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"}))));function Np(e){var{sx:t}=e,n=Oo(e,["sx"]);return G.jsx(o.TabPanel,{...n,sx:Object.assign(Object.assign({},t),{display:"flex",flexDirection:"column",overflow:"hidden"})})}function Up({params:r}){var a,l,s;const{isMobile:d}=Ls(),c=Fo((e=>e.noDocumentLink)),u=i.useRef(null),{account:p}=Zo(),{poolTab:h,tabs:m,handleChangePoolTab:f}=function({account:t,paramsTab:n}){const{i18n:o}=e.useLingui(),[r,a]=i.useState(sd.addLiquidity),{supportAMMV2:l,supportAMMV3:s,notSupportPMM:d}=Fo(),c=i.useMemo((()=>{const e=[{key:sd.addLiquidity,value:o._({id:"OBdohg",message:"Add Liquidity"})},{key:sd.myLiquidity,value:o._({id:"YHc3B+",message:"My Liquidity"})}];return d||e.push({key:sd.myCreated,value:l||s?o._({id:"zcVtwU",message:"My Pools (PMM)"}):o._({id:"fZFkP1",message:"My Pools"})}),e}),[o._,l,s,d]),u=i.useRef(!1);i.useEffect((()=>{const e=sessionStorage.getItem(ad);t&&e&&!u.current&&(u.current=!0,a(e))}),[t]);const p=e=>{a(e),sessionStorage.setItem(ad,e)};return i.useEffect((()=>{n&&p(n)}),[n]),{poolTab:r,tabs:c,handleChangePoolTab:p}}({account:p,paramsTab:null==r?void 0:r.tab}),{activeChainId:x,filterChainIds:g,handleChangeActiveChainId:y}=function(){const{chainId:e}=Zo(),{onlyChainId:t}=Fo(),[o,r]=i.useState(t),a=i.useMemo((()=>void 0!==o?[o]:Oa(e)?void 0:Object.values(n.ChainId).filter((e=>!!Number(e)))),[e,o]);return i.useEffect((()=>{const e=sessionStorage.getItem(ld);e&&r(Number(e))}),[]),{activeChainId:o,filterChainIds:a,handleChangeActiveChainId:e=>{void 0===e?sessionStorage.removeItem(ld):sessionStorage.setItem(ld,String(e)),r(e)}}}(),[v,b]=i.useState(null);return G.jsxs(Ks,{sx:Object.assign({},d?{p:20}:{display:"flex",gap:12,flex:1}),ref:u,children:[G.jsx(o.Box,{sx:d?{}:{p:8,borderRadius:20,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"border.disabled",backdropFilter:"blur(5px)",flex:1,overflow:"hidden",height:"max-content",maxHeight:"100%"},children:G.jsxs(o.Tabs,{value:h,onChange:(e,t)=>{f(t)},sx:d?{}:{display:"flex",flexDirection:"column",borderRadius:16,borderWidth:1,borderStyle:"solid",borderColor:"border.main",backgroundColor:"background.paper"},className:d?void 0:"gradient-card-border",children:[G.jsxs(o.Box,{sx:d?{}:{display:"flex",justifyContent:"space-between",p:20,borderBottomWidth:1},children:[G.jsx(o.TabsGroup,{tabs:m,variant:"rounded",tabsListSx:Object.assign({},d?{mb:16}:{borderBottomWidth:0,justifyContent:"space-between"}),tabSx:d?void 0:{mb:0}}),G.jsx(Ep,{})]}),G.jsx(Np,{value:sd.addLiquidity,sx:{display:"flex",flexDirection:"column",overflow:"hidden"},children:G.jsx(Bp,{account:p,filterChainIds:g,scrollParentRef:u,activeChainId:x,handleChangeActiveChainId:y,operatePool:v,setOperatePool:b})}),G.jsx(Np,{value:sd.myLiquidity,children:G.jsx(Vp,{account:p,filterChainIds:g,activeChainId:x,handleChangeActiveChainId:y,operatePool:v,setOperatePool:b})})]})}),G.jsxs(o.Box,{sx:{position:"relative",width:c&&!v?"auto":375},children:[!c&&G.jsx(wu,{title:t.i18n._({id:"6y2TB3",message:"Liquidity"}),desc:t.i18n._({id:"QNrpkx",message:"Classical AMM-like pool. Suitable for most assets."}),linkTo:"https://docs.dodoex.io/product/tutorial/how-to-provide-liquidity",LeftImage:Zp}),"SVM_AMMV3"===(null===(a=null==v?void 0:v.pool)||void 0===a?void 0:a.type)&&v.pool.chainId?h===sd.myLiquidity&&(null===(s=null===(l=v.pool.liquidityPositions)||void 0===l?void 0:l[0])||void 0===s?void 0:s.tokenId)?G.jsx(Vu,{mint1Address:v.pool.baseToken.address,mint2Address:v.pool.quoteToken.address,feeAmount:Number(v.pool.lpFeeRate),poolId:v.pool.address,nftMint:v.pool.liquidityPositions[0].tokenId,onClose:()=>b(null)}):G.jsx(Pu,{mint1Address:v.pool.baseToken.address,mint2Address:v.pool.quoteToken.address,feeAmount:Number(v.pool.lpFeeRate),poolId:v.pool.address,onClose:()=>b(null),handleGoToAddLiquidityV3:e=>{Gs.getState().push({type:exports.PageType.createPoolAMMV3,params:e})}}):d?G.jsx(Ju,{account:p,onClose:()=>b(null),modal:d,pool:null==v?void 0:v.pool,operate:null==v?void 0:v.operate,hasMining:!1,hidePoolInfo:!1}):!!v&&G.jsx(_u,{account:p,onClose:()=>b(null),pool:null==v?void 0:v.pool,operate:null==v?void 0:v.operate,hasMining:!1,hidePoolInfo:!1,sx:{width:375,height:"max-content",backgroundColor:"background.paper",borderRadius:16,overflow:"hidden"}})]})]})}exports.AMMV2Create=Sd,exports.AMMV3PositionManage=Vu,exports.AMMV3PositionsView=Pu,exports.AddLiquidityV3=Cu,exports.Pool=function(){const{routerPage:e}=Fo(),t=Gs((e=>e.page)),n=null!=e?e:t;switch(null==n?void 0:n.type){case exports.PageType.Pool:return G.jsx(Up,{params:n.params});case exports.PageType.createPoolAMMV2:return G.jsx(Sd,{});case exports.PageType.createPoolAMMV3:return G.jsx(Cu,{params:n.params,handleGoBack:()=>{Gs.getState().push({type:exports.PageType.Pool})},handleGoToPoolList:()=>{Gs.getState().push({type:exports.PageType.Pool})}});default:return G.jsx(Up,{params:null==n?void 0:n.params})}},exports.PoolList=Up,exports.Swap=function({getAutoSlippage:s,onPayTokenChange:d,onReceiveTokenChange:c}={}){var u,p;const h=o.useTheme(),{isInflight:m}=Ii(),{chainId:f,account:x}=Zo(),g=l.useDispatch(),{defaultChainId:y,noPowerBy:v,onlyChainId:b,onlySolana:j}=Fo(),[C,w]=i.useState(!1);i.useMemo((()=>{var e;return null===(e=n.basicTokenMap[null!=f?f:y])||void 0===e?void 0:e.address}),[f,y]);const[k,T]=i.useState(""),[R,S]=i.useState(""),[I,B]=i.useState(""),[M,E]=i.useState(""),L=i.useMemo((()=>a.debounce((e=>B(e)),1e3)),[]),O=i.useMemo((()=>a.debounce((e=>E(e)),1e3)),[]),[W,V]=i.useState(null),[F,P]=i.useState(null),[Z,N]=i.useState(!1),[U,H]=i.useState(!1),{toFiatPrice:D,fromFiatPrice:Y}=Li({toToken:F,fromToken:W});!function({token:e,fiatPrice:t}){i.useMemo((()=>{var n;const o=null!==(n=null==e?void 0:e.decimals)&&void 0!==n?n:6,i=null!=t?new r(500).div(t):new r(0),a=ni(i,o);return(a.lt(new r(1).times(new r(10).pow(o-3)))?new r(0):a).toString(10)}),[null==e?void 0:e.decimals,t])}({token:C?F:W,fiatPrice:C?D:Y}),function({fromToken:e,toToken:t,getAutoSlippage:n}){const o=l.useDispatch();i.useEffect((()=>{(()=>{Wo(this,void 0,void 0,(function*(){if(!n)return;const i=n({fromToken:e,toToken:t});if(void 0!==i&&"number"!=typeof i){o(qo(!0));try{const e=yield i;o(zo({loading:!1,value:null!=e?e:null}))}catch(e){console.error(e),o(zo({loading:!1,value:null}))}}else o(zo({loading:!1,value:null}))}))})()}),[e,t])}({fromToken:W,toToken:F,getAutoSlippage:s});const{slippage:z,slippageLoading:q}=ar({fromToken:W,toToken:F}),{isApproving:X,isGetApproveLoading:_,needApprove:J,insufficientBalance:Q,submitApprove:K,getMaxBalance:$}=ur(W,{amount:I}),ee=i.useCallback((()=>{ce($())}),[$]);i.useMemo((()=>!(!x||Q||X||_||J)),[x,Q,X,_,J]);const{status:te,rawBrief:ne,executeSwap:oe}=Wi({toToken:F,fromToken:W,fromAmount:I,slippage:z}),{resAmount:ie,priceImpact:re,baseFeeAmount:ae,additionalFeeAmount:le,resPricePerToToken:se,resPricePerFromToken:de}=i.useMemo((()=>{if(!ne)return{resAmount:null,priceImpact:null,baseFeeAmount:null,additionalFeeAmount:null,resPricePerToToken:null,resPricePerFromToken:null};const e=new r(ne.inAmount).dividedBy(ne.outAmount).toNumber(),t=new r(ne.outAmount).dividedBy(ne.inAmount).toNumber();return{resAmount:ne.resAmount,priceImpact:ne.priceImpact,baseFeeAmount:0,additionalFeeAmount:0,resPricePerToToken:e,resPricePerFromToken:t}}),[ne]),ce=i.useCallback((e=>{const t=e.toString();T(t),L(t)}),[T,L]),ue=i.useCallback((e=>{const t=e.toString();S(t),O(t)}),[S,O]),pe=i.useCallback((e=>V((t=>{var n;const o="function"==typeof e?e(t):e;return f||g(bi(null!==(n=null==o?void 0:o.chainId)&&void 0!==n?n:void 0)),d&&o&&o!==t&&d(o),o}))),[g,bi,d,f]),he=i.useCallback((e=>P((t=>{const n="function"==typeof e?e(t):e;return c&&n&&n!==t&&c(n),n}))),[c]);Qi({fromToken:W,toToken:F,setFromToken:pe,setToToken:he,updateFromAmt:ce,updateToAmt:ue,setIsReverseRouting:w});const me=i.useCallback((()=>{ce(""),ue(""),pe(F),he(W),jo("from",F),jo("to",W)}),[pe,F,he,W,ce,ue]),fe=i.useCallback(((e,t)=>{if(t)return me();ce(""),ue(""),pe(e),jo("from",e)}),[me,ce,ue,pe,jo]),xe=i.useCallback(((e,t)=>{if(t)return me();ce(""),ue(""),he(e),jo("to",e)}),[me,ce,ue,pe,jo]),ge=i.useCallback((()=>{C&&ce(""),w(!1)}),[C,ce,g]);i.useCallback((()=>{C||ue(""),w(!0)}),[C,ue,g]);const ye=(e=>{const{defaultSlippage:t}=$i(void 0===e),n=l.useSelector(Ki)||t;return i.useMemo((()=>(void 0===e?Number(n):e)>5),[n,e])})(z),ve=i.useMemo((()=>re?new r(re).multipliedBy(100).dp(4,r.ROUND_DOWN).toString():null),[re]),be=i.useMemo((()=>{const e=C?ie:I;return e&&Y?new r(Y).multipliedBy(e):null}),[Y,I,C,ie]),je=i.useMemo((()=>{if(!D)return null;const e=C?M:ie;return e?new r(D).multipliedBy(e):null}),[D,M,C,ie]),Ce=i.useMemo((()=>G.jsxs(o.Box,{sx:{display:"flex",fontWeight:600,typography:"body2",alignItems:"center",justifyContent:"center"},children:[G.jsx(vs,{title:G.jsx(e.Trans,{id:"4kY4C4",message:"Due to the market condition, market price and estimated price may have a slight difference"}),mr:8}),G.jsxs(o.Box,{sx:{display:"flex"},children:[G.jsx(e.Trans,{id:"6+mYrD",message:"Current price impact"}),G.jsxs(o.Box,{sx:{color:h.palette.error.main,ml:4},children:[ve,"%"]})]})]})),[ve,h.palette.error.main]),we=i.useMemo((()=>G.jsx(qs,{toToken:F,fromToken:W,priceStatus:te,pricePerToToken:se,pricePerFromToken:de})),[F,W,te,se,de]),ke=i.useMemo((()=>!(n.ChainId[f||1]||b&&b===f)),[f]),Te=i.useMemo((()=>!j&&!!f&&!!(null==W?void 0:W.chainId)&&(null==W?void 0:W.chainId)!==f),[f,null==W?void 0:W.chainId,j]),Re=function({fromToken:e,toToken:t}){const n=l.useSelector(Gi);return i.useMemo((()=>!(!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:W,toToken:F}),Se=i.useMemo((()=>ye&&new r(C?M:I).gt(0)&&!Q&&te===Oi.Success?G.jsxs(o.Box,{sx:{textAlign:"center",mb:8},children:[G.jsx(o.Box,{component:A.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),t.i18n._({id:"//95jS",message:"The current slippage protection coefficient set exceeds {maxSlippageWarning}%, which may result in losses.",values:{maxSlippageWarning:5}})]}):null),[ye,C,I,M,te]),Ie=i.useMemo((()=>Te?G.jsxs(o.Box,{sx:{textAlign:"center"},children:[G.jsx(o.Box,{component:A.Warn,sx:{position:"relative",top:2,mr:6,width:16,height:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"54ffaC",message:"The current network is inconsistent with the wallet - please switch in wallet"})]}):te===Oi.Loading?G.jsx(o.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:G.jsxs(G.Fragment,{children:[G.jsx(o.RotatingIcon,{sx:{mr:5}}),G.jsx(e.Trans,{id:"JdNn1Y",message:"Fetching best price..."})]})}):ke?G.jsxs(G.Fragment,{children:[G.jsx(o.Box,{component:A.Warn,sx:{mr:6,width:16,color:"warning.main"}}),G.jsx(e.Trans,{id:"udsWDJ",message:"Unsupported network - switch to trade"})]}):k&&ve&&new r(ve).gt(wo)?Ce:G.jsxs(G.Fragment,{children:[Se,we]})),[te,we,k,Ce,ve,ke,Te,Se]),Be=i.useMemo((()=>C?new r(R).gt(0)?Ko({input:ie,decimals:null==W?void 0:W.decimals}):"-":k),[k,R,ie,W,C]),Me=i.useMemo((()=>C?R:new r(k).gt(0)?Ko({input:ie,decimals:null==F?void 0:F.decimals}):"-"),[k,R,ie,F,C]),Ee=i.useMemo((()=>{if(!x||(null==W?void 0:W.chainId)&&f!==W.chainId)return G.jsx(js,{needSwitchChain:null==W?void 0:W.chainId});if(m)return G.jsx(o.Button,{fullWidth:!0,isLoading:!0,disabled:!0,children:G.jsx(e.Trans,{id:"FRBvjQ",message:"Transaction Pending"})});if(!W||!F)return G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-select-token-btn",children:G.jsx(e.Trans,{id:"KlvBGJ",message:"Select Tokens"})});if(J)return G.jsx(o.Button,{fullWidth:!0,disabled:X,onClick:()=>K(),children:X?G.jsx(e.Trans,{id:"j2Uisd",message:"Approving"}):G.jsx(e.Trans,{id:"Z7ZXbT",message:"Approve"})});if(!new r(C?M:I).gt(0))return G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-enter-amount-btn",children:G.jsx(e.Trans,{id:"iPMIoT",message:"Enter an amount"})});if(te===Oi.Loading)return G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-fetch-price-btn",children:G.jsx(e.Trans,{id:"OauUE6",message:"Fetching Price..."})});return!ie||te===Oi.Failed?G.jsx(o.Button,{fullWidth:!0,disabled:!0,children:G.jsx(e.Trans,{id:"NVAuTg",message:"Quote not available"})}):Q?G.jsx(o.Button,{fullWidth:!0,disabled:!0,"data-testid":"swap-alert-insufficient-balance-btn",children:G.jsx(e.Trans,{id:"znqB4T",message:"Insufficient balance"})}):G.jsx(o.Button,{fullWidth:!0,onClick:()=>N(!0),"data-testid":"swap-review-btn",children:G.jsx(e.Trans,{id:"K/Ay/d",message:"Review Swap"})})}),[x,W,f,m,F,J,X,C,M,I,te,ie,Q,K]),Le=i.useMemo((()=>W&&F?G.jsxs(o.Box,{sx:{display:"flex",alignItems:"center"},children:[G.jsx(Wa,{token:W,width:16,height:16,marginRight:6,chainId:W.chainId,noShowChain:!!b}),`${Ko({input:C?ie:I,decimals:null==W?void 0:W.decimals})} ${null==W?void 0:W.symbol}`,G.jsx(o.Box,{component:A.DoubleRight,sx:{width:12,height:12,mx:16}}),G.jsx(Wa,{token:F,width:16,height:16,marginRight:6,chainId:F.chainId,noShowChain:!!b}),`${Ko({input:C?M:ie,decimals:null==F?void 0:F.decimals})} ${null==F?void 0:F.symbol}`]}):G.jsx(o.Box,{})),[W,F,I,M,ie,C,b]);return G.jsxs(G.Fragment,{children:[G.jsxs(o.Box,{sx:{display:"flex",justifyContent:"space-between",typography:"caption",margin:20},children:[G.jsx(e.Trans,{id:"vH2C/2",message:"Swap"}),G.jsx(o.Tooltip,{open:void 0,title:G.jsx(e.Trans,{id:"NSCBTb",message:"The setting has been switched to swap mode"}),placement:"bottom-end",children:G.jsx(o.Box,{component:o.ButtonBase,children:G.jsx(o.Box,{component:A.Setting,onClick:()=>H(!0),sx:{width:19,height:19,color:"text.primary",cursor:"pointer"}})})})]}),G.jsxs(o.Box,{sx:{flex:1,padding:"0 16px 12px",overflowY:"auto"},children:[G.jsxs(o.Box,{children:[G.jsx(zs,{sx:{mb:4},token:W,side:"from",amt:Be,defaultLoadBalance:!0,onMaxClick:ee,onInputChange:ce,onInputFocus:ge,showMaxBtn:!C&&!k,occupiedAddrs:[null!==(u=null==F?void 0:F.address)&&void 0!==u?u:""],occupiedChainId:null==F?void 0:F.chainId,fiatPriceTxt:be?`$${Qo({input:be,showDecimals:1})}`:"-",onTokenChange:fe,readOnly:C,showChainLogo:!b,showChainName:!b,notTokenPickerModal:!0}),G.jsx(Is,{onClick:me,disabled:Re}),G.jsx(zs,{token:F,side:"to",amt:Me,onInputChange:ue,occupiedAddrs:[null!==(p=null==W?void 0:W.address)&&void 0!==p?p:""],occupiedChainId:null==W?void 0:W.chainId,fiatPriceTxt:je?`$${Qo({input:je,showDecimals:1})}(${ve}%)`:"-",onTokenChange:xe,readOnly:!0,showChainLogo:!b,showChainName:!b,notTokenPickerModal:!0}),G.jsx(o.Box,{sx:{py:12,display:"flex",typography:"body2",alignItems:"center",justifyContent:"center",flexWrap:"wrap"},children:Ie})]}),Ee,v?"":G.jsxs(o.Box,{sx:{mt:13,display:"flex",typography:"h6",cursor:"pointer",justifyContent:"center",alignItems:"center",color:h.palette.text.disabled},onClick:()=>window.open("https://app.dodoex.io"),children:[G.jsx(o.Box,{sx:{width:18,height:18,transform:"translate(1px, 2px)","& path":{fill:h.palette.text.disabled}},component:A.Dodo}),G.jsx(e.Trans,{id:"7X+IbB",message:"Powered by DODO protocol"})]})]}),G.jsx(Cs,{toToken:F,fromToken:W,fromAmount:C?ie:I,toAmount:C?M:ie,open:Z,baseFeeAmount:ae,priceImpact:ve,additionalFeeAmount:le,curToFiatPrice:je,execute:()=>oe(Le),clearFromAmt:()=>ce(""),clearToAmt:()=>ue(""),curFromFiatPrice:be,onClose:()=>N(!1),loading:te===Oi.Loading,slippage:z}),G.jsx(Ss,{open:U,onClose:()=>H(!1),fromToken:W,toToken:F})]})},exports.UnstyleWidget=ys,exports.Widget=function(e){const t=o.createTheme({mode:e.colorMode,theme:e.theme,lang:e.locale||Va});return e.apikey||e.apiServices||console.error("apikey and apiServices must have a."),G.jsxs(o.ThemeProvider,{theme:t,children:[G.jsx(o.CssBaseline,{container:`.${fs}, .${o.WIDGET_MODAL_CLASS}, .${o.WIDGET_MODAL_FIXED_CLASS}`}),G.jsx(d.QueryClientProvider,{client:Qa,children:G.jsxs(ys,{...e,children:[e.children,G.jsx(ns,{})]})})]})},exports.useRouterStore=Gs;