!function(e){"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?module.exports=e():window.wNumb=e()}(function(){"use strict";var e=["decimals","thousand","mark","prefix","postfix","encoder","decoder","negativeBefore","negative","edit","undo"];function n(e){return e.split("").reverse().join("")}function t(e,n){return e.substring(0,n.length)===n}function r(e,n,t){if((e[n]||e[t])&&e[n]===e[t])throw new Error(n)}function i(e){return"number"==typeof e&&isFinite(e)}function o(e,t,r,o,f,u,a,c,s,p,d,l){var h,g,v,w,m,x,y=l,b="",j="";return u&&(l=u(l)),!!i(l)&&(!1!==e&&0===parseFloat(l.toFixed(e))&&(l=0),l<0&&(h=!0,l=Math.abs(l)),!1!==e&&(w=l,m=e,x=Math.pow(10,m),l=(Math.round(w*x)/x).toFixed(m)),-1!==(l=l.toString()).indexOf(".")?(v=(g=l.split("."))[0],r&&(b=r+g[1])):v=l,t&&(v=n((v=n(v).match(/.{1,3}/g)).join(n(t)))),h&&c&&(j+=c),o&&(j+=o),h&&s&&(j+=s),j+=v,j+=b,f&&(j+=f),p&&(j=p(j,y)),j)}function f(e,n,r,o,f,u,a,c,s,p,d,l){var h,g,v="";return d&&(l=d(l)),!(!l||"string"!=typeof l)&&(c&&t(l,c)&&(l=l.replace(c,""),h=!0),o&&t(l,o)&&(l=l.replace(o,"")),s&&t(l,s)&&(l=l.replace(s,""),h=!0),f&&(g=f,l.slice(-1*g.length)===g)&&(l=l.slice(0,-1*f.length)),n&&(l=l.split(n).join("")),r&&(l=l.replace(r,".")),h&&(v+="-"),""!==(v=(v+=l).replace(/[^0-9\.\-.]/g,""))&&(v=Number(v),a&&(v=a(v)),!!i(v)&&v))}function u(n,t,r){var i,o=[];for(i=0;i<e.length;i+=1)o.push(n[e[i]]);return o.push(r),t.apply("",o)}return function n(t){if(!(this instanceof n))return new n(t);"object"==typeof t&&(t=function(n){var t,i,o,f={};for(t=0;t<e.length;t+=1)if(void 0===(o=n[i=e[t]]))"negative"!==i||f.negativeBefore?"mark"===i&&"."!==f.thousand?f[i]=".":f[i]=!1:f[i]="-";else if("decimals"===i){if(!(o>=0&&o<8))throw new Error(i);f[i]=o}else if("encoder"===i||"decoder"===i||"edit"===i||"undo"===i){if("function"!=typeof o)throw new Error(i);f[i]=o}else{if("string"!=typeof o)throw new Error(i);f[i]=o}return r(f,"mark","thousand"),r(f,"prefix","negative"),r(f,"prefix","negativeBefore"),f}(t),this.to=function(e){return u(t,o,e)},this.from=function(e){return u(t,f,e)})}});