(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7333],{57333:function(t,e,r){"use strict";var o=r(67294);function a(){}function n(t){return!!(t||"").match(/\d/)}function i(t){return null===t||void 0===t}function s(t){return t.replace(/[-[\]/{}()*+?.\\^$|]/g,"\\$&")}function u(t,e){void 0===e&&(e=!0);var r="-"===t[0],o=r&&e,a=(t=t.replace("-","")).split(".");return{beforeDecimal:a[0],afterDecimal:a[1]||"",hasNagation:r,addNegation:o}}function l(t,e,r){for(var o="",a=r?"0":"",n=0;n<=e-1;n++)o+=t[n]||a;return o}function p(t,e){return Array(e+1).join(t)}function c(t,e){if(t.value=t.value,null!==t){if(t.createTextRange){var r=t.createTextRange();return r.move("character",e),r.select(),!0}return t.selectionStart||0===t.selectionStart?(t.focus(),t.setSelectionRange(e,e),!0):(t.focus(),!1)}}function f(t,e,r){return Math.min(Math.max(t,e),r)}function h(t){return Math.max(t.selectionStart,t.selectionEnd)}var m={displayType:"input",decimalSeparator:".",thousandsGroupStyle:"thousand",fixedDecimalScale:!1,prefix:"",suffix:"",allowNegative:!0,allowEmptyFormatting:!1,allowLeadingZeros:!1,isNumericString:!1,type:"text",onValueChange:a,onChange:a,onKeyDown:a,onMouseUp:a,onFocus:a,onBlur:a,isAllowed:function(){return!0}},g=function(t){function e(e){t.call(this,e);var r=e.defaultValue;this.validateProps();var o=this.formatValueProp(r);this.state={value:o,numAsString:this.removeFormatting(o),mounted:!1},this.selectionBeforeInput={selectionStart:0,selectionEnd:0},this.onChange=this.onChange.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.componentDidMount=function(){this.setState({mounted:!0})},e.prototype.componentDidUpdate=function(t){this.updateValueIfRequired(t)},e.prototype.componentWillUnmount=function(){clearTimeout(this.focusTimeout),clearTimeout(this.caretPositionTimeout)},e.prototype.updateValueIfRequired=function(t){var e=this,r=e.props,o=e.state,a=e.focusedElm,n=o.value,s=o.numAsString;if(void 0===s&&(s=""),t!==r){this.validateProps();var u=this.formatNumString(s),l=i(r.value)?u:this.formatValueProp(),p=this.removeFormatting(l),c=parseFloat(p),f=parseFloat(s);(isNaN(c)&&isNaN(f)||c===f)&&u===n&&(null!==a||l===n)||this.updateValue({formattedValue:l,numAsString:p,input:a})}},e.prototype.getFloatString=function(t){void 0===t&&(t="");var e=this.props.decimalScale,r=this.getSeparators().decimalSeparator,o=this.getNumberRegex(!0),a="-"===t[0];a&&(t=t.replace("-","")),r&&0===e&&(t=t.split(r)[0]);var n=(t=(t.match(o)||[]).join("").replace(r,".")).indexOf(".");return-1!==n&&(t=t.substring(0,n)+"."+t.substring(n+1,t.length).replace(new RegExp(s(r),"g"),"")),a&&(t="-"+t),t},e.prototype.getNumberRegex=function(t,e){var r=this.props,o=r.format,a=r.decimalScale,n=r.customNumerals,i=this.getSeparators().decimalSeparator;return new RegExp("[0-9"+(n?n.join(""):"")+"]"+(!i||0===a||e||o?"":"|"+s(i)),t?"g":void 0)},e.prototype.getSeparators=function(){var t=this.props.decimalSeparator,e=this.props,r=e.thousandSeparator,o=e.allowedDecimalSeparators;return!0===r&&(r=","),o||(o=[t,"."]),{decimalSeparator:t,thousandSeparator:r,allowedDecimalSeparators:o}},e.prototype.getMaskAtIndex=function(t){var e=this.props.mask;return void 0===e&&(e=" "),"string"===typeof e?e:e[t]||" "},e.prototype.getValueObject=function(t,e){var r=parseFloat(e);return{formattedValue:t,value:e,floatValue:isNaN(r)?void 0:r}},e.prototype.validateProps=function(){var t=this.props.mask,e=this.getSeparators(),r=e.decimalSeparator,o=e.thousandSeparator;if(r===o)throw new Error("\n Decimal separator can't be same as thousand separator.\n thousandSeparator: "+o+' (thousandSeparator = {true} is same as thousandSeparator = ",")\n decimalSeparator: '+r+" (default value for decimalSeparator is .)\n ");if(t&&("string"===t?t:t.toString()).match(/\d/g))throw new Error("\n Mask "+t+" should not contain numeric character;\n ")},e.prototype.setPatchedCaretPosition=function(t,e,r){c(t,e),this.caretPositionTimeout=setTimeout((function(){t.value===r&&c(t,e)}),0)},e.prototype.correctCaretPosition=function(t,e,r){var o=this.props,a=o.prefix,i=o.suffix,s=o.format;if(""===t)return 0;if(e=f(e,0,t.length),!s){var u="-"===t[0];return f(e,a.length+(u?1:0),t.length-i.length)}if("function"===typeof s)return e;if("#"===s[e]&&n(t[e]))return e;if("#"===s[e-1]&&n(t[e-1]))return e;var l=s.indexOf("#");e=f(e,l,s.lastIndexOf("#")+1);for(var p=s.substring(e,s.length).indexOf("#"),c=e,h=e+(-1===p?0:p);c>l&&("#"!==s[c]||!n(t[c]));)c-=1;return!n(t[h])||"left"===r&&e!==l||e-c=i?o+=p("0",n-i):o=(o.substring(0,n)||"0")+"."+o.substring(n),e+o}(c),f=!0),"Infinity"===c&&f&&(c=""),f&&!r&&"number"===typeof o&&(c=function(t,e,r){if(-1!==["","-"].indexOf(t))return t;var o=-1!==t.indexOf(".")&&e,a=u(t),n=a.beforeDecimal,i=a.afterDecimal,s=a.hasNagation,p=parseFloat("0."+(i||"0")),c=(i.length<=e?"0."+i:p.toFixed(e)).split(".");return(s?"-":"")+n.split("").reverse().reduce((function(t,e,r){return t.length>r?(Number(t[0])+Number(e)).toString()+t.substring(1,t.length):e+t}),c[0])+(o?".":"")+l(c[1]||"",Math.min(e,i.length),r)}(c,o,a)),f?this.formatNumString(c):this.formatInput(c))},e.prototype.formatNegation=function(t){void 0===t&&(t="");var e=this.props.allowNegative,r=new RegExp("(-)"),o=new RegExp("(-)(.)*(-)"),a=r.test(t),n=o.test(t);return t=t.replace(/-/g,""),a&&!n&&e&&(t="-"+t),t},e.prototype.formatInput=function(t){return void 0===t&&(t=""),this.props.format||(t=this.removePrefixAndSuffix(t),t=this.formatNegation(t)),t=this.removeFormatting(t),this.formatNumString(t)},e.prototype.isCharacterAFormat=function(t,e){var r=this.props,o=r.format,a=r.prefix,n=r.suffix,i=r.decimalScale,s=r.fixedDecimalScale,u=this.getSeparators().decimalSeparator;return"string"===typeof o&&"#"!==o[t]||!(o||!(t=e.length-n.length||i&&s&&e[t]===u))},e.prototype.correctInputValue=function(t,e,r){var o=this,a=this.props,n=a.format,i=a.allowNegative,s=a.prefix,l=a.suffix,p=a.decimalScale,c=this.getSeparators(),f=c.allowedDecimalSeparators,h=c.decimalSeparator,m=this.state.numAsString||"",g=this.selectionBeforeInput,d=g.selectionStart,v=g.selectionEnd,S=function(t,e){for(var r=0,o=0,a=t.length,n=e.length;t[r]===e[r]&&rr&&a-o>r;)o++;return{start:r,end:a-o}}(e,r),y=S.start,x=S.end;if(!n&&y===x&&-1!==f.indexOf(r[d])){var b=0===p?"":h;return r.substr(0,d)+b+r.substr(d+1,r.length)}var w=n?0:s.length,N=e.length-(n?0:l.length);if(r.length>e.length||!r.length||y===x||0===d&&v===e.length||0===y&&x===e.length||d===w&&v===N)return r;var P=e.substr(y,x-y);if(!![].concat(P).find((function(t,r){return o.isCharacterAFormat(r+y,e)}))){var F=e.substr(y),C={},D=[];[].concat(F).forEach((function(t,r){o.isCharacterAFormat(r+y,e)?C[r]=t:r>P.length-1&&D.push(t)})),Object.keys(C).forEach((function(t){D.length>t?D.splice(t,0,C[t]):D.push(C[t])})),r=e.substr(0,y)+D.join("")}if(!n){var E=this.removeFormatting(r),V=u(E,i),A=V.beforeDecimal,O=V.afterDecimal,j=V.addNegation,I=ty;)S--;S=this.correctCaretPosition(i,S,"left")}}else for(;!g.test(i[S])&&Sx)&&(t.preventDefault(),this.setPatchedCaretPosition(r,S,i)),t.isUnitTestRun&&this.setPatchedCaretPosition(r,S,i),h(t)}else h(t)},e.prototype.onMouseUp=function(t){var e=t.target,r=e.selectionStart,o=e.selectionEnd,a=e.value;if(void 0===a&&(a=""),r===o){var n=this.correctCaretPosition(a,r);n!==r&&this.setPatchedCaretPosition(e,n,a)}this.props.onMouseUp(t)},e.prototype.onFocus=function(t){var e=this;t.persist(),this.focusedElm=t.target,this.focusTimeout=setTimeout((function(){var r=t.target,o=r.selectionStart,a=r.selectionEnd,n=r.value;void 0===n&&(n="");var i=e.correctCaretPosition(n,o);i===o||0===o&&a===n.length||e.setPatchedCaretPosition(r,i,n),e.props.onFocus(t)}),0)},e.prototype.render=function(){var t=this.props,e=t.type,r=t.displayType,a=t.customInput,n=t.renderText,i=t.getInputRef,s=t.format,u=(t.thousandSeparator,t.decimalSeparator,t.allowedDecimalSeparators,t.thousandsGroupStyle,t.decimalScale,t.fixedDecimalScale,t.prefix,t.suffix,t.removeFormatting,t.mask,t.defaultValue,t.isNumericString,t.allowNegative,t.allowEmptyFormatting,t.allowLeadingZeros,t.onValueChange,t.isAllowed,t.customNumerals,t.onChange,t.onKeyDown,t.onMouseUp,t.onFocus,t.onBlur,t.value,function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&-1===e.indexOf(o)&&(r[o]=t[o]);return r}(t,["type","displayType","customInput","renderText","getInputRef","format","thousandSeparator","decimalSeparator","allowedDecimalSeparators","thousandsGroupStyle","decimalScale","fixedDecimalScale","prefix","suffix","removeFormatting","mask","defaultValue","isNumericString","allowNegative","allowEmptyFormatting","allowLeadingZeros","onValueChange","isAllowed","customNumerals","onChange","onKeyDown","onMouseUp","onFocus","onBlur","value"])),l=this.state,p=l.value,c=l.mounted&&function(t){return t||"undefined"!==typeof navigator&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}(s)?"numeric":void 0,f=Object.assign({inputMode:c},u,{type:e,value:p,onChange:this.onChange,onKeyDown:this.onKeyDown,onMouseUp:this.onMouseUp,onFocus:this.onFocus,onBlur:this.onBlur});if("text"===r)return n?n(p,u)||null:o.createElement("span",Object.assign({},u,{ref:i}),p);if(a){var h=a;return o.createElement(h,Object.assign({},f,{ref:i}))}return o.createElement("input",Object.assign({},f,{ref:i}))},e}(o.Component);g.defaultProps=m,e.Z=g}}]); //# sourceMappingURL=7333-a5a3eac91b793e5358a6.js.map