"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),i=require("react"),t=require("prop-types"),a=require("classnames"),r=require("@material-ui/core"),s=require("./icons/LeftArrow.js"),n=require("./icons/GoLive.js"),l=require("./icons/RightArrow.js"),u=require("./icons/ZoomIn.js"),o=require("./icons/TimeRange.js"),c=require("./icons/ZoomOut.js"),d=require("./ChartActionsList.css.js"),f=require("../Modal/Modal.js"),m=require("react/jsx-runtime");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=h(e),j=h(t),x=h(a),v=function(e){var t=e.onChange,a=e.min,h=e.max,j=e.left,v=e.right,q=e.classes,b=i.useState(!1),g=p.default(b,2),C=g[0],k=g[1],y=i.useState(j),A=p.default(y,2),N=A[0],R=A[1],F=i.useState(v),T=p.default(F,2),L=T[0],S=T[1];i.useEffect((function(){S(v),R(j)}),[j,v]);var w=v-j>=1,I=a<j||h>v,P=j>a,V=v<h,B=v!==h,M=N<a||L>h||N+1>L,W=function(){k(!1)};return m.jsxs("div",{className:d.container,children:[m.jsx("span",{className:x.default(d.action,!w&&d.disabled),onClick:function(){var e=v-j,i=j+e/4,a=v-e/4,r=a-i;if(r<1){var s=(1-r)/2;i+=s,a-=s}t({left:i,right:a})},children:m.jsx(u,{isActive:w})}),m.jsx("span",{className:x.default(d.action,!I&&d.disabled),onClick:function(){var e=v-j,i=j-e/2,r=v+e/2,s=r-i;i<a&&r>h?(i=a,r=h):i<a?(i=a,r=a+s):r>h&&(r=h,i=h-s),t({left:i,right:r})},children:m.jsx(c,{isActive:I})}),m.jsx("span",{className:x.default(d.action,!P&&d.disabled),onClick:function(){var e=.75*(v-j),i=j-e,r=v-e;i<a&&(i=a,r=a+e),t({left:i,right:r})},children:m.jsx(s,{isActive:P})}),m.jsx("span",{className:x.default(d.action,!V&&d.disabled),onClick:function(){var e=.75*(v-j),i=j+e,a=v+e;a>h&&(a=h,i=h-e),t({left:i,right:a})},children:m.jsx(l,{isActive:V})}),m.jsx("span",{className:x.default(d.action,!B&&d.disabled),onClick:function(){t({left:j,right:h})},children:m.jsx(n,{isActive:B})}),m.jsx("span",{className:d.action,onClick:function(){k(!0)},children:m.jsx(o,{})}),m.jsx(f,{open:C,onClose:W,title:"Jump to Selected Range",actions:m.jsxs("div",{className:d.actions,children:[m.jsx(r.Button,{variant:"textPrimary",onClick:W,children:"Cancel"}),m.jsx(r.Button,{variant:"contained",color:"primary",onClick:function(){t({left:N,right:L}),k(!1)},disabled:M,children:"Apply"})]}),children:m.jsxs("form",{noValidate:!0,className:d.form,children:[m.jsx(r.TextField,{id:"depth-from",label:"From",type:"number",defaultValue:N,onChange:function(e){R(parseFloat(e.target.value))},InputLabelProps:{shrink:!0},error:N<a,autoFocus:!0,className:q.input,fullWidth:!0}),m.jsx(r.TextField,{id:"depth-from",label:"To",type:"number",defaultValue:L,onChange:function(e){S(parseFloat(e.target.value))},InputLabelProps:{shrink:!0},error:L>h,fullWidth:!0})]})})]})};v.propTypes={onChange:j.default.func.isRequired,min:j.default.number.isRequired,max:j.default.number.isRequired,left:j.default.number.isRequired,right:j.default.number.isRequired,classes:j.default.shape({}).isRequired};var q=r.withStyles({input:{marginRight:20}})(v);module.exports=q;
//# sourceMappingURL=ChartActionsList.js.map
