WRMCB=function(e){var c=console;if(c&&c.log&&c.error){c.log('Error running batched script.');c.error(e);}}
;
try {
/* module-key = 'com.tempoplugin.tempo-core:core-number-format-resource', location = '/com/tempoplugin/core/lib/kt-currency/kt-currency.js' */
define('tempo-core/kt-currency', [
    'jquery',
    'tempo-core/context-path'
], function ($, contextPath) {

    var currencies = [];

    var _findCurrencyByCode = function (code) {

        return $.grep(_getCurrencies(), function (currency) {
            return currency.code === code;
        })[0];

    };

    var _getCurrencies = function () {

        if (currencies.length < 1) {

            $.ajax({
                url: contextPath() + '/rest/tempo-planning/1/currency',
                async: false,
                success: function (data) {
                    currencies = data.success;
                }
            });

        }

        return currencies;
    };

    return {
        getCurrencies: _getCurrencies,
        findCurrencyByCode: _findCurrencyByCode
    };
});
}catch(e){WRMCB(e)};
;
try {
/* module-key = 'com.tempoplugin.tempo-core:core-number-format-resource', location = '/com/tempoplugin/core/format/number-parser.js' */
define('tempo-core/number-parser', [], function () {
    return {
        parseLocaleFormattedNumber: function (number) {
            if (number) {
                var numberStr = number.toString();
                var commaIndex = numberStr.indexOf(',');
                var dotIndex = numberStr.indexOf('.');
                if (commaIndex > -1) {
                    if (dotIndex > -1) {
                        if (commaIndex < dotIndex) {
                            // Comma is used as a thousand separator
                            numberStr = numberStr.replace(/[,]/g, '');
                        } else if (dotIndex < commaIndex) {
                            // Dot is used as a thousand separator
                            numberStr = numberStr.replace(/[.]/g, '');
                        }
                    }
                    number = numberStr.replace(',', '.');
                }

                if (!isNaN(parseFloat(number))) {
                    number = parseFloat(number);
                }
            }

            return number;
        }
    };
});
}catch(e){WRMCB(e)};
;
try {
/* module-key = 'com.tempoplugin.tempo-core:core-number-format-resource', location = '/com/tempoplugin/core/format/number-format.js' */
define('tempo-core/number-format', [
    'underscore',
    'tempo-core/ajs-meta',
    'tempo-core/number-parser',
    'tempo-core/kt-currency'
], function (_, Meta, NumberParser, KTCurrency) {
    return {
        locale: Meta.get('user-locale'),

        replaceLocaleUnderscore: function (locale) {
            return locale.replace('_', '-');
        },

        parseLocaleFormattedNumber: function (number) {
            return NumberParser.parseLocaleFormattedNumber(number);
        },

        getNumberFormat: function (number, fractions) {
            var fraction = typeof fractions === 'undefined' ? this.getDecimalPlaces(number) : fractions;
            number = this.parseLocaleFormattedNumber(number);
            if (typeof number === 'undefined') {
                return;
            }
            if (this.BrowserCheck.isSafari()) {
                return parseFloat(Math.round(number * 100) / 100).toFixed(2);
            }
            return number.toLocaleString(this.replaceLocaleUnderscore(this.locale), {
                minimumFractionDigits: fraction,
                maximumFractionDigits: fraction
            });
        },

        getCurrencySignFromCode: function (currencyCode) {
            var currency = KTCurrency.findCurrencyByCode(currencyCode);
            return currency && currency.symbol ? currency.symbol : currencyCode;
        },

        getNumberAndCurrencyFormat: function (number, currencyCode, fractions) {
            var fraction = typeof fractions === 'undefined' ? 2 : fractions;
            number = this.parseLocaleFormattedNumber(number);
            var currencySign = this.getCurrencySignFromCode(currencyCode);

            // Detects IE 10 and older
            if (document.all) {
                var numberToLocale = (isNaN(number) || number === null) ? number : number.toLocaleString();
                return number === null ? currencySign : numberToLocale + ' ' + currencySign;
            }

            if (!_.isNumber(number)) {
                return currencySign;
            }

            var replacedLocale = this.replaceLocaleUnderscore(this.locale);
            var numberWithCurrency = number.toLocaleString(replacedLocale, {
                style: 'currency',
                currency: currencyCode,
                minimumFractionDigits: fraction,
                maximumFractionDigits: fraction
            });
            var regexp = new RegExp(currencyCode, 'i');
            if (numberWithCurrency.match(regexp)) {
                // The currency code is only returned correctly in IE
                numberWithCurrency = numberWithCurrency.replace(regexp, currencySign);
            }
            return numberWithCurrency;
        },

        BrowserCheck: {
            isSafari: function () {
                return navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
            },
            isChrome: function () {
                return navigator.userAgent.indexOf('Chrome') > -1;
            },
            isExplorer: function () {
                return navigator.userAgent.indexOf('MSIE') > -1;
            },
            isFirefox: function () {
                return navigator.userAgent.indexOf('Firefox') > -1;
            }
        },

        getDecimalPlaces: function (num) {
            // http://stackoverflow.com/a/10454560
            num = Number(num);
            var match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
            if (!match) {
                return 0;
            }
            return Math.max(
                0,
                // Number of digits right of decimal point.
                (match[1] ? match[1].length : 0)
                // Adjust for scientific notation.
                - (match[2] ? +match[2] : 0));
        }
    };
});

}catch(e){WRMCB(e)};