/*!
 * accounting.js v0.4.2
 * Copyright 2014 Open Exchange Rates
 *
 * Freely distributable under the MIT license.
 * Portions of accounting.js are inspired or borrowed from underscore.js
 *
 * Full details and documentation:
 * http://openexchangerates.github.io/accounting.js/
 */
!function(n){var f={version:"0.4.1",settings:{currency:{symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3},number:{precision:0,grouping:3,thousand:",",decimal:"."}}},i=Array.prototype.map,r=Array.isArray,e=Object.prototype.toString;function p(n){return""===n||n&&n.charCodeAt&&n.substr}function l(n){return r?r(n):"[object Array]"===e.call(n)}function m(n){return n&&"[object Object]"===e.call(n)}function d(n,r){for(var e in n=n||{},r=r||{})r.hasOwnProperty(e)&&null==n[e]&&(n[e]=r[e]);return n}function g(n,r,e){var t,o,a=[];if(n){if(i&&n.map===i)return n.map(r,e);for(t=0,o=n.length;t<o;t++)a[t]=r.call(e,n[t],t,n)}return a}function h(n,r){return n=Math.round(Math.abs(n)),isNaN(n)?r:n}function y(n){var r=f.settings.currency.format;return p(n="function"==typeof n?n():n)&&n.match("%v")?{pos:n,neg:n.replace("-","").replace("%v","-%v"),zero:n}:n&&n.pos&&n.pos.match("%v")?n:p(r)?f.settings.currency.format={pos:r,neg:r.replace("%v","-%v"),zero:r}:r}var t,b=f.unformat=f.parse=function(n,r){if(l(n))return g(n,function(n){return b(n,r)});if("number"==typeof(n=n||0))return n;r=r||f.settings.number.decimal;var e=new RegExp("[^0-9-"+r+"]",["g"]),n=parseFloat((""+n).replace(/\((.*)\)/,"-$1").replace(e,"").replace(r,"."));return isNaN(n)?0:n},s=f.toFixed=function(n,r){r=h(r,f.settings.number.precision);var e=Math.pow(10,r);return(Math.round(f.unformat(n)*e)/e).toFixed(r)},v=f.formatNumber=f.format=function(n,r,e,t){if(l(n))return g(n,function(n){return v(n,r,e,t)});n=b(n);var o=d(m(r)?r:{precision:r,thousand:e,decimal:t},f.settings.number),a=h(o.precision),i=n<0?"-":"",u=parseInt(s(Math.abs(n||0),a),10)+"",c=3<u.length?u.length%3:0;return i+(c?u.substr(0,c)+o.thousand:"")+u.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+o.thousand)+(a?o.decimal+s(Math.abs(n),a).split(".")[1]:"")},c=f.formatMoney=function(n,r,e,t,o,a){if(l(n))return g(n,function(n){return c(n,r,e,t,o,a)});n=b(n);var i=d(m(r)?r:{symbol:r,precision:e,thousand:t,decimal:o,format:a},f.settings.currency),u=y(i.format);return(0<n?u.pos:n<0?u.neg:u.zero).replace("%s",i.symbol).replace("%v",v(Math.abs(n),h(i.precision),i.thousand,i.decimal))};f.formatColumn=function(n,r,e,t,o,a){var i,u,c,s;return n?(i=d(m(r)?r:{symbol:r,precision:e,thousand:t,decimal:o,format:a},f.settings.currency),u=y(i.format),c=u.pos.indexOf("%s")<u.pos.indexOf("%v"),s=0,r=g(n,function(n,r){return l(n)?f.formatColumn(n,i):((n=(0<(n=b(n))?u.pos:n<0?u.neg:u.zero).replace("%s",i.symbol).replace("%v",v(Math.abs(n),h(i.precision),i.thousand,i.decimal))).length>s&&(s=n.length),n)}),g(r,function(n,r){return p(n)&&n.length<s?c?n.replace(i.symbol,i.symbol+new Array(s-n.length+1).join(" ")):new Array(s-n.length+1).join(" ")+n:n})):[]},"undefined"!=typeof exports?(exports="undefined"!=typeof module&&module.exports?module.exports=f:exports).accounting=f:"function"==typeof define&&define.amd?define([],function(){return f}):(f.noConflict=(t=n.accounting,function(){return n.accounting=t,f.noConflict=void 0,f}),n.accounting=f)}(this);