text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.convertCurrency=convertCurrency,exports.converAmount=converAmount,exports.tipTool=tipTool,exports.amountFormatter=amountFormatter,exports.isAmount=isAmount,exports.getInputSelection=getInputSelection,exports.moveInputCursorPos=moveInputCursorPos,exports.getNowPos=getNowPos;var cnNums=Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖"),cnIntRadice=Array("","拾","佰","仟"),cnIntUnits=Array("","万","亿","兆"),cnDecUnits=Array("角","分","厘"),cnInteger="整",cnIntLast="元",zero="零元整",maxNum=1e16,negative="负";function convertCurrency(e){var t="",n="";if(""===e)return"";if(Number(e)<0&&(e=(e+"").substr(1),n=negative),e=parseFloat(e),maxNum<=e)return"超出输入范围";if(0===e)return zero;var r=(e=e.toString()).split("."),o=e.split(".")?r[0]:e,a=1<e.split(".").length?r[1].substr(0,3):"";if(0<parseInt(o,10)){for(var u=0,c=0;c<o.length;c++){var s=o.substr(c,1),i=o.length-c-1,l=i/4,p=i%4;"0"===s?u++:(0<u&&(t+=cnNums[0]),u=0,t+=cnNums[parseInt(s)]+cnIntRadice[p]),0==p&&u<4&&(t+=cnIntUnits[l])}t+=cnIntLast}if(""!==a)for(var m=a.length,v=0;v<m;v++){var g=a.substr(v,1);"0"!==g&&(t+=cnNums[Number(g)]+cnDecUnits[v])}return n+(t+=""===t?cnNums[0]+cnIntLast+cnInteger:""===a?cnInteger:"")}function converAmount(e){var t="";if(!e)return 0;e.substr(0,1)===negative&&(t="-");var n=e.split(cnIntLast),r=n[0],o=r?getIntegerValue(r):0,a=n[1],u=a&&a!==cnInteger?a:null,c=u?getFloatValue(u):0;return Number(t+(o+c))}function getFloatValue(e){return parseFloatForNumber(parseNumberAndUnit(e))}var cn2number={"零":0,"壹":1,"贰":2,"叁":3,"肆":4,"伍":5,"陆":6,"柒":7,"捌":8,"玖":9},unit={"拾":10,"佰":100,"仟":1e3,"万":1e4,"亿":1e8,"兆":1e12};function parseNumberAndUnit(e){var r=[];return e.split("").forEach(function(e){var t=cn2number[e];void 0!==t&&r.push(t);var n=unit[e];void 0!==n&&r.push(n)}),r}function getIntegerValue(e){var n=parseNumberAndUnit(e),r=[];n.forEach(function(e,t){9<e&&e<1e4&&0<t?r[r.length-1]=n[t-1]*e:r.push(e)});var t=[],o=0,a=0;return r.forEach(function(e){1e4<=e?(o*=e,t.splice(t.length-a,a,o),a=o=0):(a++,o+=e,t.push(e))}),parseIntForNumber(t)}function parseIntForNumber(e){var n=e.length-1,r=0;return e.forEach(function(e,t){r+=9<e?e:e*Math.pow(10,n-t)}),r}function parseFloatForNumber(e){var n=0;return e.forEach(function(e,t){n+=e*Math.pow(10,-(t+1))}),n}function tipTool(e,t){return e&&t?t(e):""}function amountFormatter(e){return(""+e).replace(/\B(?=(\d{3})+(?!\d))/g,",")}var parser=exports.parser=function(e){return e.replace(/\$\s?|(,*)/g,"")};function isAmount(e){return void 0!==e&&-1===(e+"").indexOf("元")}function getInputSelection(e){var t=0,n=0,r=void 0,o=void 0,a=void 0,u=void 0,c=void 0;return"number"==typeof e.selectionStart&&"number"==typeof e.selectionEnd?(t=e.selectionStart,n=e.selectionEnd):(o=document.selection.createRange())&&o.parentElement()==e&&(u=e.value.length,r=e.value.replace(/\r\n/g,"\n"),(a=e.createTextRange()).moveToBookmark(o.getBookmark()),(c=e.createTextRange()).collapse(!1),-1<a.compareEndPoints("StartToEnd",c)?t=n=u:(t=-a.moveStart("character",-u),t+=r.slice(0,t).split("\n").length-1,-1<a.compareEndPoints("EndToEnd",c)?n=u:(n=-a.moveEnd("character",-u),n+=r.slice(0,n).split("\n").length-1))),{start:t,end:n}}function moveInputCursorPos(e,t){if(e.setSelectionRange)e.setSelectionRange(t,t);else if(e.createTextRange){var n=e.createTextRange();n.collapse(!0),n.move("character",t),n.select()}}function getNowPos(e,t,n){for(var r=e.substr(0,n).replace(/,/g,"").split(""),o=amountFormatter(t).split(""),a=0,u=0;u<o.length&&a<r.length;u++)","!==o[u]&&r[a]===o[u]&&a++;return u}