195 lines
49 KiB
JavaScript
195 lines
49 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).numbro=t()}(this,(function(){"use strict";var e,t,r,n,i,a,o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
|
||||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/function s(){return t?e:(t=1,e={languageTag:"en-US",delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},spaceSeparated:!1,ordinal:function(e){let t=e%10;return 1==~~(e%100/10)?"th":1===t?"st":2===t?"nd":3===t?"rd":"th"},bytes:{binarySuffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],decimalSuffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},currency:{symbol:"$",position:"prefix",code:"USD"},currencyFormat:{thousandSeparated:!0,totalLength:4,spaceSeparated:!0,spaceSeparatedCurrency:!0},formats:{fourDigits:{totalLength:4,spaceSeparated:!0},fullWithTwoDecimals:{output:"currency",thousandSeparated:!0,mantissa:2},fullWithTwoDecimalsNoCurrency:{thousandSeparated:!0,mantissa:2},fullWithNoDecimals:{output:"currency",thousandSeparated:!0,mantissa:0}}})}
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/function l(){if(n)return r;n=1;const e=[{key:"ZiB",factor:Math.pow(1024,7)},{key:"ZB",factor:Math.pow(1e3,7)},{key:"YiB",factor:Math.pow(1024,8)},{key:"YB",factor:Math.pow(1e3,8)},{key:"TiB",factor:Math.pow(1024,4)},{key:"TB",factor:Math.pow(1e3,4)},{key:"PiB",factor:Math.pow(1024,5)},{key:"PB",factor:Math.pow(1e3,5)},{key:"MiB",factor:Math.pow(1024,2)},{key:"MB",factor:Math.pow(1e3,2)},{key:"KiB",factor:Math.pow(1024,1)},{key:"KB",factor:Math.pow(1e3,1)},{key:"GiB",factor:Math.pow(1024,3)},{key:"GB",factor:Math.pow(1e3,3)},{key:"EiB",factor:Math.pow(1024,6)},{key:"EB",factor:Math.pow(1e3,6)},{key:"B",factor:1}];function t(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function i(r,n,a,o,u,s,l){if(!isNaN(+r))return+r;let c="",f=r.replace(/(^[^(]*)\((.*)\)([^)]*$)/,"$1$2$3");if(f!==r)return-1*i(f,n,a,o,u,s);for(let t=0;t<e.length;t++){let l=e[t];if(c=r.replace(RegExp(`([0-9 ])(${l.key})$`),"$1"),c!==r)return i(c,n,a,o,u,s)*l.factor}if(c=r.replace("%",""),c!==r)return i(c,n,a,o,u,s)/100;let p=parseFloat(r);if(isNaN(p))return;let g=o(p);if(g&&"."!==g&&(c=r.replace(new RegExp(`${t(g)}$`),""),c!==r))return i(c,n,a,o,u,s);let h={};Object.keys(s).forEach((e=>{h[s[e]]=e}));let d=Object.keys(h).sort().reverse(),m=d.length;for(let e=0;e<m;e++){let t=d[e],l=h[t];if(c=r.replace(t,""),c!==r){let e;switch(l){case"thousand":e=Math.pow(10,3);break;case"million":e=Math.pow(10,6);break;case"billion":e=Math.pow(10,9);break;case"trillion":e=Math.pow(10,12)}return i(c,n,a,o,u,s)*e}}}function a(e,r,n="",a,o,u,s){if(""===e)return;if(e===o)return 0;let l=function(e,r,n){let i=e.replace(n,"");return i=i.replace(new RegExp(`([0-9])${t(r.thousands)}([0-9])`,"g"),"$1$2"),i=i.replace(r.decimal,"."),i}(e,r,n);return i(l,r,n,a,o,u)}return r={unformat:function(e,t){const r=h();let n,i=r.currentDelimiters(),o=r.currentCurrency().symbol,u=r.currentOrdinal(),s=r.getZeroFormat(),l=r.currentAbbreviations();if("string"==typeof e)n=function(e,t){if(!e.indexOf(":")||":"===t.thousands)return!1;let r=e.split(":");if(3!==r.length)return!1;let n=+r[0],i=+r[1],a=+r[2];return!isNaN(n)&&!isNaN(i)&&!isNaN(a)}(e,i)?function(e){let t=e.split(":"),r=+t[0],n=+t[1];return+t[2]+60*n+3600*r}(e):a(e,i,o,u,s,l);else{if("number"!=typeof e)return;n=e}if(void 0!==n)return n}},r}
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/function c(){if(a)return i;a=1;let e=l();const t=/^[a-z]{2,3}(-[a-zA-Z]{4})?(-([A-Z]{2}|[0-9]{3}))?$/,r={output:{type:"string",validValues:["currency","percent","byte","time","ordinal","number"]},base:{type:"string",validValues:["decimal","binary","general"],restriction:(e,t)=>"byte"===t.output,message:"`base` must be provided only when the output is `byte`",mandatory:e=>"byte"===e.output},characteristic:{type:"number",restriction:e=>e>=0,message:"value must be positive"},prefix:"string",postfix:"string",forceAverage:{type:"string",validValues:["trillion","billion","million","thousand"]},average:"boolean",lowPrecision:{type:"boolean",restriction:(e,t)=>!0===t.average,message:"`lowPrecision` must be provided only when the option `average` is set"},currencyPosition:{type:"string",validValues:["prefix","infix","postfix"]},currencySymbol:"string",totalLength:{type:"number",restrictions:[{restriction:e=>e>=0,message:"value must be positive"},{restriction:(e,t)=>!t.exponential,message:"`totalLength` is incompatible with `exponential`"}]},mantissa:{type:"number",restriction:e=>e>=0,message:"value must be positive"},optionalMantissa:"boolean",trimMantissa:"boolean",roundingFunction:"function",optionalCharacteristic:"boolean",thousandSeparated:"boolean",spaceSeparated:"boolean",spaceSeparatedCurrency:"boolean",spaceSeparatedAbbreviation:"boolean",abbreviations:{type:"object",children:{thousand:"string",million:"string",billion:"string",trillion:"string"}},negative:{type:"string",validValues:["sign","parenthesis"]},forceSign:"boolean",exponential:{type:"boolean"},prefixSymbol:{type:"boolean",restriction:(e,t)=>"percent"===t.output,message:"`prefixSymbol` can be provided only when the output is `percent`"}},n={languageTag:{type:"string",mandatory:!0,restriction:e=>e.match(t),message:"the language tag must follow the BCP 47 specification (see https://tools.ieft.org/html/bcp47)"},delimiters:{type:"object",children:{thousands:"string",decimal:"string",thousandsSize:"number"},mandatory:!0},abbreviations:{type:"object",children:{thousand:{type:"string",mandatory:!0},million:{type:"string",mandatory:!0},billion:{type:"string",mandatory:!0},trillion:{type:"string",mandatory:!0}},mandatory:!0},spaceSeparated:"boolean",spaceSeparatedCurrency:"boolean",ordinal:{type:"function",mandatory:!0},bytes:{type:"object",children:{binarySuffixes:"object",decimalSuffixes:"object"}},currency:{type:"object",children:{symbol:"string",position:"string",code:"string"},mandatory:!0},defaults:"format",ordinalFormat:"format",byteFormat:"format",percentageFormat:"format",currencyFormat:"format",timeDefaults:"format",formats:{type:"object",children:{fourDigits:{type:"format",mandatory:!0},fullWithTwoDecimals:{type:"format",mandatory:!0},fullWithTwoDecimalsNoCurrency:{type:"format",mandatory:!0},fullWithNoDecimals:{type:"format",mandatory:!0}}}};function o(t){return void 0!==e.unformat(t)}function u(e,t,n,i=!1){let a=Object.keys(e).map((i=>{if(!t[i])return console.error(`${n} Invalid key: ${i}`),!1;let a=e[i],o=t[i];if("string"==typeof o&&(o={type:o}),"format"===o.type){if(!u(a,r,`[Validate ${i}]`,!0))return!1}else if(typeof a!==o.type)return console.error(`${n} ${i} type mismatched: "${o.type}" expected, "${typeof a}" provided`),!1;if(o.restrictions&&o.restrictions.length){let t=o.restrictions.length;for(let r=0;r<t;r++){let{restriction:t,message:u}=o.restrictions[r];if(!t(a,e))return console.error(`${n} ${i} invalid value: ${u}`),!1}}if(o.restriction&&!o.restriction(a,e))return console.error(`${n} ${i} invalid value: ${o.message}`),!1;if(o.validValues&&-1===o.validValues.indexOf(a))return console.error(`${n} ${i} invalid value: must be among ${JSON.stringify(o.validValues)}, "${a}" provided`),!1;if(o.children){if(!u(a,o.children,`[Validate ${i}]`))return!1}return!0}));return i||a.push(...Object.keys(t).map((r=>{let i=t[r];if("string"==typeof i&&(i={type:i}),i.mandatory){let t=i.mandatory;if("function"==typeof t&&(t=t(e)),t&&void 0===e[r])return console.error(`${n} Missing mandatory key "${r}"`),!1}return!0}))),a.reduce(((e,t)=>e&&t),!0)}function s(e){retur
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/var f,p,g={parseFormat:function(e,t={}){return"string"!=typeof e?e:(function(e,t){if(-1===e.indexOf("$")){if(-1===e.indexOf("%"))return-1!==e.indexOf("bd")?(t.output="byte",void(t.base="general")):-1!==e.indexOf("b")?(t.output="byte",void(t.base="binary")):-1!==e.indexOf("d")?(t.output="byte",void(t.base="decimal")):void(-1===e.indexOf(":")?-1!==e.indexOf("o")&&(t.output="ordinal"):t.output="time");t.output="percent"}else t.output="currency"}(e=function(e,t){let r=e.match(/{([^}]*)}$/);return r?(t.postfix=r[1],e.slice(0,-r[0].length)):e}(e=function(e,t){let r=e.match(/^{([^}]*)}/);return r?(t.prefix=r[1],e.slice(r[0].length)):e}(e,t),t),t),function(e,t){let r=e.match(/[1-9]+[0-9]*/);r&&(t.totalLength=+r[0])}(e,t),function(e,t){let r=e.split(".")[0].match(/0+/);r&&(t.characteristic=r[0].length)}(e,t),function(e,t){if(-1!==e.indexOf(".")){let r=e.split(".")[0];t.optionalCharacteristic=-1===r.indexOf("0")}}(e,t),function(e,t){-1!==e.indexOf("a")&&(t.average=!0)}(e,t),function(e,t){-1!==e.indexOf("K")?t.forceAverage="thousand":-1!==e.indexOf("M")?t.forceAverage="million":-1!==e.indexOf("B")?t.forceAverage="billion":-1!==e.indexOf("T")&&(t.forceAverage="trillion")}(e,t),function(e,t){let r=e.split(".")[1];if(r){let e=r.match(/0+/);e&&(t.mantissa=e[0].length)}}(e,t),function(e,t){e.match(/\[\.]/)?t.optionalMantissa=!0:e.match(/\./)&&(t.optionalMantissa=!1)}(e,t),function(e,t){const r=e.split(".")[1];r&&(t.trimMantissa=-1!==r.indexOf("["))}(e,t),function(e,t){-1!==e.indexOf(",")&&(t.thousandSeparated=!0)}(e,t),function(e,t){-1!==e.indexOf(" ")&&(t.spaceSeparated=!0,t.spaceSeparatedCurrency=!0,(t.average||t.forceAverage)&&(t.spaceSeparatedAbbreviation=!0))}(e,t),function(e,t){e.match(/^\+?\([^)]*\)$/)&&(t.negative="parenthesis"),e.match(/^\+?-/)&&(t.negative="sign")}(e,t),function(e,t){e.match(/^\+/)&&(t.forceSign=!0)}(e,t),t)}};
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/function h(){if(p)return f;p=1;const e=s(),t=c(),r=g;let n,i={},a={},o=null,u={};function l(e){n=e}function h(){return a[n]}return i.languages=()=>Object.assign({},a),i.currentLanguage=()=>n,i.currentBytes=()=>h().bytes||{},i.currentCurrency=()=>h().currency,i.currentAbbreviations=()=>h().abbreviations,i.currentDelimiters=()=>h().delimiters,i.currentOrdinal=()=>h().ordinal,i.currentDefaults=()=>Object.assign({},h().defaults,u),i.currentOrdinalDefaultFormat=()=>Object.assign({},i.currentDefaults(),h().ordinalFormat),i.currentByteDefaultFormat=()=>Object.assign({},i.currentDefaults(),h().byteFormat),i.currentPercentageDefaultFormat=()=>Object.assign({},i.currentDefaults(),h().percentageFormat),i.currentCurrencyDefaultFormat=()=>Object.assign({},i.currentDefaults(),h().currencyFormat),i.currentTimeDefaultFormat=()=>Object.assign({},i.currentDefaults(),h().timeFormat),i.setDefaults=e=>{e=r.parseFormat(e),t.validateFormat(e)&&(u=e)},i.getZeroFormat=()=>o,i.setZeroFormat=e=>o="string"==typeof e?e:null,i.hasZeroFormat=()=>null!==o,i.languageData=e=>{if(e){if(a[e])return a[e];throw new Error(`Unknown tag "${e}"`)}return h()},i.registerLanguage=(e,r=!1)=>{if(!t.validateLanguage(e))throw new Error("Invalid language data");a[e.languageTag]=e,r&&l(e.languageTag)},i.setLanguage=(t,r=e.languageTag)=>{if(!a[t]){let e=t.split("-")[0],n=Object.keys(a).find((t=>t.split("-")[0]===e));return a[n]?void l(n):void l(r)}l(t)},i.registerLanguage(e),n=e.languageTag,f=i}
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/
|
|||
|
|
function d(e,t){e.forEach((e=>{let r;try{r=function(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}(`../languages/${e}`)}catch(t){console.error(`Unable to load "${e}". No matching language file found.`)}r&&t.registerLanguage(r)}))}var m={exports:{}};!function(e){!function(t){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,a=Math.floor,o="[BigNumber Error] ",u=o+"Number primitive has more than 15 significant digits: ",s=1e14,l=14,c=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,g=1e9;function h(e){var t=0|e;return e>0||e===t?t:t-1}function d(e){for(var t,r,n=1,i=e.length,a=e[0]+"";n<i;){for(t=e[n++]+"",r=l-t.length;r--;t="0"+t);a+=t}for(i=a.length;48===a.charCodeAt(--i););return a.slice(0,i+1||1)}function m(e,t){var r,n,i=e.c,a=t.c,o=e.s,u=t.s,s=e.e,l=t.e;if(!o||!u)return null;if(r=i&&!i[0],n=a&&!a[0],r||n)return r?n?0:-u:o;if(o!=u)return o;if(r=o<0,n=s==l,!i||!a)return n?0:!i^r?1:-1;if(!n)return s>l^r?1:-1;for(u=(s=i.length)<(l=a.length)?s:l,o=0;o<u;o++)if(i[o]!=a[o])return i[o]>a[o]^r?1:-1;return s==l?0:s>l^r?1:-1}function y(e,t,r,n){if(e<t||e>r||e!==a(e))throw Error(o+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return h(e.e/l)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}r=function e(t){var r,O,x,S,N,$,B,M,D,F,E=q.prototype={constructor:q,toString:null,valueOf:null},A=new q(1),_=20,k=4,L=-7,P=21,T=-1e7,C=1e7,j=!1,U=1,R=0,I={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},G="0123456789abcdefghijklmnopqrstuvwxyz",V=!0;function q(e,t){var r,i,o,s,f,p,g,h,d=this;if(!(d instanceof q))return new q(e,t);if(null==t){if(e&&!0===e._isBigNumber)return d.s=e.s,void(!e.c||e.e>C?d.c=d.e=null:e.e<T?d.c=[d.e=0]:(d.e=e.e,d.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(d.s=1/e<0?(e=-e,-1):1,e===~~e){for(s=0,f=e;f>=10;f/=10,s++);return void(s>C?d.c=d.e=null:(d.e=s,d.c=[e]))}h=String(e)}else{if(!n.test(h=String(e)))return x(d,h,p);d.s=45==h.charCodeAt(0)?(h=h.slice(1),-1):1}(s=h.indexOf("."))>-1&&(h=h.replace(".","")),(f=h.search(/e/i))>0?(s<0&&(s=f),s+=+h.slice(f+1),h=h.substring(0,f)):s<0&&(s=h.length)}else{if(y(t,2,G.length,"Base"),10==t&&V)return H(d=new q(e),_+d.e+1,k);if(h=String(e),p="number"==typeof e){if(0*e!=0)return x(d,h,p,t);if(d.s=1/e<0?(h=h.slice(1),-1):1,q.DEBUG&&h.replace(/^0\.0*|\./,"").length>15)throw Error(u+e)}else d.s=45===h.charCodeAt(0)?(h=h.slice(1),-1):1;for(r=G.slice(0,t),s=f=0,g=h.length;f<g;f++)if(r.indexOf(i=h.charAt(f))<0){if("."==i){if(f>s){s=g;continue}}else if(!o&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){o=!0,f=-1,s=0;continue}return x(d,String(e),p,t)}p=!1,(s=(h=O(h,t,10,d.s)).indexOf("."))>-1?h=h.replace(".",""):s=h.length}for(f=0;48===h.charCodeAt(f);f++);for(g=h.length;48===h.charCodeAt(--g););if(h=h.slice(f,++g)){if(g-=f,p&&q.DEBUG&&g>15&&(e>c||e!==a(e)))throw Error(u+d.s*e);if((s=s-f-1)>C)d.c=d.e=null;else if(s<T)d.c=[d.e=0];else{if(d.e=s,d.c=[],f=(s+1)%l,s<0&&(f+=l),f<g){for(f&&d.c.push(+h.slice(0,f)),g-=l;f<g;)d.c.push(+h.slice(f,f+=l));f=l-(h=h.slice(f)).length}else f-=g;for(;f--;h+="0");d.c.push(+h)}}else d.c=[d.e=0]}function Z(e,t,r,n){var i,a,o,u,s;if(null==r?r=k:y(r,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,null==t)s=d(e.c),s=1==n||2==n&&(o<=L||o>=P)?v(s,o):w(s,o,"0");else if(a=(e=H(new q(e),t,r)).e,u=(s=d(e.c)).length,1==n||2==n&&(t<=a||a<=L)){for(;u<t;s+="0",u++);s=v(s,a)}else if(t-=o,s=w(s,a,"0"),a+1>u){if(--t>0)for(s+=".";t--;s+="0");}else if((t+=a-u)>0)for(a+1==u&&(s+=".");t--;s+="0");return e.s<0&&
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/const b=h(),v=c(),w=g,O=y,x={trillion:Math.pow(10,12),billion:Math.pow(10,9),million:Math.pow(10,6),thousand:Math.pow(10,3)},S={totalLength:0,characteristic:0,forceAverage:!1,average:!1,mantissa:-1,optionalMantissa:!0,thousandSeparated:!1,spaceSeparated:!1,negative:"sign",forceSign:!1,roundingFunction:Math.round,spaceSeparatedAbbreviation:!1},{binarySuffixes:N,decimalSuffixes:$}=b.currentBytes(),B={general:{scale:1024,suffixes:$,marker:"bd"},binary:{scale:1024,suffixes:N,marker:"b"},decimal:{scale:1e3,suffixes:$,marker:"d"}};function M(e,t={},r){if("string"==typeof t&&(t=w.parseFormat(t)),!v.validateFormat(t))return"ERROR: invalid format";let n=t.prefix||"",i=t.postfix||"",a=function(e,t,r){switch(t.output){case"currency":return function(e,t,r){const n=r.currentCurrency();let i,a=Object.assign({},t),o=Object.assign({},S,a),u="",s=!!o.totalLength||!!o.forceAverage||o.average,l=a.currencyPosition||n.position,c=a.currencySymbol||n.symbol;const f=void 0!==o.spaceSeparatedCurrency?o.spaceSeparatedCurrency:o.spaceSeparated;void 0===a.lowPrecision&&(a.lowPrecision=!1);f&&(u=" ");"infix"===l&&(i=u+c+u);let p=A({instance:e,providedFormat:a,state:r,decimalSeparator:i});"prefix"===l&&(p=e._value<0&&"sign"===o.negative?`-${u}${c}${p.slice(1)}`:e._value>0&&o.forceSign?`+${u}${c}${p.slice(1)}`:c+u+p);l&&"postfix"!==l||(u=!o.spaceSeparatedAbbreviation&&s?"":u,p=p+u+c);return p}(e,t=_(t,b.currentCurrencyDefaultFormat()),b);case"percent":return function(e,t,r,n){let i=t.prefixSymbol,a=A({instance:n(100*e._value),providedFormat:t,state:r}),o=Object.assign({},S,t);if(i)return`%${o.spaceSeparated?" ":""}${a}`;return`${a}${o.spaceSeparated?" ":""}%`}(e,t=_(t,b.currentPercentageDefaultFormat()),b,r);case"byte":return function(e,t,r,n){let i=t.base||"binary",a=Object.assign({},S,t);const{binarySuffixes:o,decimalSuffixes:u}=r.currentBytes();let s={general:{scale:1024,suffixes:u||$,marker:"bd"},binary:{scale:1024,suffixes:o||N,marker:"b"},decimal:{scale:1e3,suffixes:u||$,marker:"d"}}[i],{value:l,suffix:c}=D(e._value,s.suffixes,s.scale),f=A({instance:n(l),providedFormat:t,state:r,defaults:r.currentByteDefaultFormat()});return`${f}${a.spaceSeparated?" ":""}${c}`}(e,t=_(t,b.currentByteDefaultFormat()),b,r);case"time":return t=_(t,b.currentTimeDefaultFormat()),function(e){let t=Math.floor(e._value/60/60),r=Math.floor((e._value-60*t*60)/60),n=Math.round(e._value-60*t*60-60*r);return`${t}:${r<10?"0":""}${r}:${n<10?"0":""}${n}`}(e);case"ordinal":return function(e,t,r){let n=r.currentOrdinal(),i=Object.assign({},S,t),a=A({instance:e,providedFormat:t,state:r}),o=n(e._value);return`${a}${i.spaceSeparated?" ":""}${o}`}(e,t=_(t,b.currentOrdinalDefaultFormat()),b);default:return A({instance:e,providedFormat:t,numbro:r})}}(e,t,r);return a=function(e,t){return t+e}(a,n),a=function(e,t){return e+t}(a,i),a}function D(e,t,r){let n=t[0],i=Math.abs(e);if(i>=r){for(let a=1;a<t.length;++a){let o=Math.pow(r,a),u=Math.pow(r,a+1);if(i>=o&&i<u){n=t[a],e/=o;break}}n===t[0]&&(e/=Math.pow(r,t.length-1),n=t[t.length-1])}return{value:e,suffix:n}}function F(e){let t="";for(let r=0;r<e;r++)t+="0";return t}function E(e,t,r=Math.round){if(-1!==e.toString().indexOf("e"))return function(e,t){let r=e.toString(),[n,i]=r.split("e"),[a,o=""]=n.split(".");if(+i>0)r=a+o+F(i-o.length);else{let e=".";e=+a<0?`-0${e}`:`0${e}`;let n=(F(-i-1)+Math.abs(a)+o).substr(0,t);n.length<t&&(n+=F(t-n.length)),r=e+n}return+i>0&&t>0&&(r+=`.${F(t)}`),r}(e,t);return new O(r(+`${e}e+${t}`)/Math.pow(10,t)).toFixed(t)}function A({instance:e,providedFormat:t,state:r=b,decimalSeparator:n,defaults:i=r.currentDefaults()}){let a=e._value;if(0===a&&r.hasZeroFormat())return r.getZeroFormat();if(!isFinite(a))return a.toString();let o=Object.assign({},S,i,t),u=o.totalLength,s=u?0:o.characteristic,l=o.optionalCharacteristic,c=o.forceAverage,f=o.lowPrecision,p=!!u||!!c||o.average,g=u?-1:p&&void 0===t.mantissa?0:o.mantissa,h=!u&&(void 0===t.optionalMantissa?-1===g:o.optionalMantissa),d=o.trimMantissa,m=o.thousandSeparated,y=o.spaceSeparated,v=o.negative,w=o.forceSign,O=o.exponential,N=o.roundingFunction,$="";if(p){le
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/
|
|||
|
|
const k=y;function L(e,t,r){let n=new k(e._value),i=t;return r.isNumbro(t)&&(i=t._value),i=new k(i),e._value=n.minus(i).toNumber(),e}
|
|||
|
|
/*!
|
|||
|
|
* Copyright (c) 2017 Benjamin Van Ryseghem<benjamin@vanryseghem.com>
|
|||
|
|
*
|
|||
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|||
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|||
|
|
* in the Software without restriction, including without limitation the rights
|
|||
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|||
|
|
* furnished to do so, subject to the following conditions:
|
|||
|
|
*
|
|||
|
|
* The above copyright notice and this permission notice shall be included in
|
|||
|
|
* all copies or substantial portions of the Software.
|
|||
|
|
*
|
|||
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|||
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|||
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|||
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|||
|
|
* SOFTWARE.
|
|||
|
|
*/
|
|||
|
|
const P=h(),T=c(),C=(e=>({loadLanguagesInNode:t=>d(t,e)}))(q),j=l();let U=(e=>({format:(...t)=>M(...t,e),getByteUnit:(...t)=>function(e){let t=B.general;return D(e._value,t.suffixes,t.scale).suffix}(...t,e),getBinaryByteUnit:(...t)=>function(e){let t=B.binary;return D(e._value,t.suffixes,t.scale).suffix}(...t,e),getDecimalByteUnit:(...t)=>function(e){let t=B.decimal;return D(e._value,t.suffixes,t.scale).suffix}(...t,e),formatOrDefault:_}))(q),R=(e=>({add:(t,r)=>function(e,t,r){let n=new k(e._value),i=t;return r.isNumbro(t)&&(i=t._value),i=new k(i),e._value=n.plus(i).toNumber(),e}(t,r,e),subtract:(t,r)=>L(t,r,e),multiply:(t,r)=>function(e,t,r){let n=new k(e._value),i=t;return r.isNumbro(t)&&(i=t._value),i=new k(i),e._value=n.times(i).toNumber(),e}(t,r,e),divide:(t,r)=>function(e,t,r){let n=new k(e._value),i=t;return r.isNumbro(t)&&(i=t._value),i=new k(i),e._value=n.dividedBy(i).toNumber(),e}(t,r,e),set:(t,r)=>function(e,t,r){let n=t;return r.isNumbro(t)&&(n=t._value),e._value=n,e}(t,r,e),difference:(t,r)=>function(e,t,r){let n=r(e._value);return L(n,t,r),Math.abs(n._value)}(t,r,e),BigNumber:k}))(q);const I=g;class G{constructor(e){this._value=e}clone(){return q(this._value)}format(e={}){return U.format(this,e)}formatCurrency(e){return"string"==typeof e&&(e=I.parseFormat(e)),(e=U.formatOrDefault(e,P.currentCurrencyDefaultFormat())).output="currency",U.format(this,e)}formatTime(e={}){return e.output="time",U.format(this,e)}binaryByteUnits(){return U.getBinaryByteUnit(this)}decimalByteUnits(){return U.getDecimalByteUnit(this)}byteUnits(){return U.getByteUnit(this)}difference(e){return R.difference(this,e)}add(e){return R.add(this,e)}subtract(e){return R.subtract(this,e)}multiply(e){return R.multiply(this,e)}divide(e){return R.divide(this,e)}set(e){return R.set(this,V(e))}value(){return this._value}valueOf(){return this._value}}function V(e){let t=e;return q.isNumbro(e)?t=e._value:"string"==typeof e?t=q.unformat(e):isNaN(e)&&(t=NaN),t}function q(e){return new G(V(e))}return q.version="2.5.0",q.isNumbro=function(e){return e instanceof G},q.language=P.currentLanguage,q.registerLanguage=P.registerLanguage,q.setLanguage=P.setLanguage,q.languages=P.languages,q.languageData=P.languageData,q.zeroFormat=P.setZeroFormat,q.defaultFormat=P.currentDefaults,q.setDefaults=P.setDefaults,q.defaultCurrencyFormat=P.currentCurrencyDefaultFormat,q.validate=T.validate,q.loadLanguagesInNode=C.loadLanguagesInNode,q.unformat=j.unformat,q.BigNumber=R.BigNumber,u(q)}));
|
|||
|
|
//# sourceMappingURL=numbro.min.js.map
|