import 'hyperscript.org'; import './_htmx.js'; import Alpine from "alpinejs"; import mask from '@alpinejs/mask'; import collapse from '@alpinejs/collapse' import sort from '@alpinejs/sort'; import { create, all } from 'mathjs'; window.Alpine = Alpine; window.math = create(all, { number: 'BigNumber', }); Alpine.plugin(mask); Alpine.plugin(collapse); Alpine.plugin(sort); Alpine.start(); /** * Parse a localized number to a float. * @param {string} stringNumber - the localized number * @param {string} locale - [optional] the locale that the number is represented in. Omit this parameter to use the current locale. */ window.parseLocaleNumber = function parseLocaleNumber(stringNumber, locale) { let thousandSeparator = Intl.NumberFormat(locale).format(11111).replace(/\d/g, ''); let decimalSeparator = Intl.NumberFormat(locale).format(1.1).replace(/\d/g, ''); return parseFloat(stringNumber .replace(new RegExp('\\' + thousandSeparator, 'g'), '') .replace(new RegExp('\\' + decimalSeparator), '.') ); };