"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),s=require("@babel/runtime/helpers/slicedToArray"),i=require("react"),o=require("@material-ui/core"),r=require("classnames");require("./styles/sliderStyles.js");var n=require("./styles/handleStyles.js"),t=require("./utils.js"),a=require("./constants.js"),l=require("../../icons/iconParkIcons.js");require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js");var u=require("react/jsx-runtime");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=c(e),m=c(s),I=c(r);exports.Handle=function(e){var s,r,c,f,v=e.value,h=e.orientation,j=e.placement,q=e.dimension,R=e.readOnly,A=e.onChange,E=e.min,H=e.max,p=e.displayFormatter,b=e.isInsideArrowsVisible,N=e.arrowsOutsideConfig,_=e.classes,O=e.minimal,T=e["data-testid"],g=i.useState(!1),C=m.default(g,2),y=C[0],x=C[1],F=i.useState(v),w=m.default(F,2),S=w[0],V=w[1],M=i.useRef(null),k=h===a.HORIZONTAL_ORIENTATION,D=h===a.VERTICAL_ORIENTATION,L=j===a.HEAD_PLACEMENT,z=n.useHandleStyles({distance:null==N?void 0:N.distance,minimal:O,hoverAreaHeight:k?a.HOVER_ARREA_WIDTH_BY_DIMENSION[q]:a.HOVER_ARREA_HEIGHT,hoverAreaWidth:k?a.HOVER_ARREA_HEIGHT:a.HOVER_ARREA_WIDTH_BY_DIMENSION[q]}),G=function(e){if(!R){var s=Number(e);t.getIsInputValueValid(s)?A(t.getValidatedValue(s,E,H)):x(!0)}};return i.useEffect((function(){V(v),y&&x(!1)}),[v]),u.jsxs("div",{className:I.default(z.root,_.handleRoot,z[q],(s={},d.default(s,z.horizontalHeadRoot,k&&L),d.default(s,z.horizontalTailRoot,k&&!L),d.default(s,z.verticalHeadRoot,D&&L),d.default(s,z.verticalTailRoot,D&&!L),d.default(s,z.minimalHandleRoot,O),s)),children:[u.jsx(l.LeftIcon,{size:16,className:I.default(z.leftArrow,(r={},d.default(r,z.reversedLeftArrow,D),d.default(r,z.isInvisible,b&&!L||L&&(null==N?void 0:N.isLeftArrowInvisible)),r)),fill:"white"}),u.jsx("div",{className:I.default(z.handle,_.handle,(c={},d.default(c,z.horizontalHeadHandle,k&&L),d.default(c,z.horizontalTailHandle,k&&!L),d.default(c,z.verticalHeadHandle,D&&L),d.default(c,z.verticalTailHandle,D&&!L),d.default(c,z.minimalHandle,O),d.default(c,z.minimalVerticalHandle,O&&D),c)),"data-testid":T,children:!O&&u.jsx(o.Input,{inputProps:{"data-testid":"handle-input"},readOnly:R,inputRef:M,onKeyDown:function(e){var s=e.keyCode,i=e.target;13===s&&G(i.value)},onBlur:function(e){var s=e.target;G(s.value)},classes:{root:I.default(z.inputRoot,y&&z.hasError)},value:R?p(S):S,onChange:function(e){var s=e.target.value;(function(e){var s,i,o=null==e||null===(s=e.target)||void 0===s?void 0:s.value,r=o?parseFloat(o):0,n=r>=Number.MIN_SAFE_INTEGER&&r<Number.MAX_SAFE_INTEGER,t=null==e||null===(i=e.nativeEvent)||void 0===i?void 0:i.data,a=o.split(".").length-1;return!n||!(!t||"."===t||"-"===t||t>="0"&&t<="9")||a>1||"-"===t&&""===o})(e)||(V(s),y&&x(!1))},disableUnderline:!0,error:!(Number.isFinite(+S)&&+S>=E&&+S<=H)})}),u.jsx(l.RightIcon,{size:16,className:I.default(z.rightArrow,(f={},d.default(f,z.reversedRightArrow,D),d.default(f,z.isInvisible,b&&L||!L&&(null==N?void 0:N.isRightArrowInvisible)),f)),fill:"white"})]})};
