mirror of
https://gh.wpcy.net/https://github.com/CaptainCore/captaincore-manager.git
synced 2026-04-23 09:32:15 +08:00
8 lines
No EOL
11 KiB
JavaScript
8 lines
No EOL
11 KiB
JavaScript
/**
|
|
* Minified by jsDelivr using UglifyJS v3.4.1.
|
|
* Original file: /npm/numeral@2.0.6/numeral.js
|
|
*
|
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
*/
|
|
!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof module&&module.exports?module.exports=r():e.numeral=r()}(this,function(){var _,o,u,s,e,l={},y={},r={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},c={currentLocale:r.currentLocale,zeroFormat:r.zeroFormat,nullFormat:r.nullFormat,defaultFormat:r.defaultFormat,scalePercentBy100:r.scalePercentBy100};function a(e,r){this._input=e,this._value=r}return(_=function(e){var r,t,n,i;if(_.isNumeral(e))r=e.value();else if(0===e||void 0===e)r=0;else if(null===e||o.isNaN(e))r=null;else if("string"==typeof e)if(c.zeroFormat&&e===c.zeroFormat)r=0;else if(c.nullFormat&&e===c.nullFormat||!e.replace(/[^0-9]+/g,"").length)r=null;else{for(t in l)if((i="function"==typeof l[t].regexps.unformat?l[t].regexps.unformat():l[t].regexps.unformat)&&e.match(i)){n=l[t].unformat;break}r=(n=n||_._.stringToNumber)(e)}else r=Number(e)||null;return new a(e,r)}).version="2.0.6",_.isNumeral=function(e){return e instanceof a},_._=o={numberToFormat:function(e,r,t){var n,i,o,a,l,u,s,c,f=y[_.options.currentLocale],m=!1,h=!1,d="",b=1e12,p="",g=!1;if(e=e||0,o=Math.abs(e),_._.includes(r,"(")?(m=!0,r=r.replace(/[\(|\)]/g,"")):(_._.includes(r,"+")||_._.includes(r,"-"))&&(u=_._.includes(r,"+")?r.indexOf("+"):e<0?r.indexOf("-"):-1,r=r.replace(/[\+|\-]/g,"")),_._.includes(r,"a")&&(i=!!(i=r.match(/a(k|m|b|t)?/))&&i[1],_._.includes(r," a")&&(d=" "),r=r.replace(new RegExp(d+"a[kmbt]?"),""),b<=o&&!i||"t"===i?(d+=f.abbreviations.trillion,e/=b):o<b&&1e9<=o&&!i||"b"===i?(d+=f.abbreviations.billion,e/=1e9):o<1e9&&1e6<=o&&!i||"m"===i?(d+=f.abbreviations.million,e/=1e6):(o<1e6&&1e3<=o&&!i||"k"===i)&&(d+=f.abbreviations.thousand,e/=1e3)),_._.includes(r,"[.]")&&(h=!0,r=r.replace("[.]",".")),a=e.toString().split(".")[0],l=r.split(".")[1],s=r.indexOf(","),n=(r.split(".")[0].split(",")[0].match(/0/g)||[]).length,l?(_._.includes(l,"[")?(l=(l=l.replace("]","")).split("["),p=_._.toFixed(e,l[0].length+l[1].length,t,l[1].length)):p=_._.toFixed(e,l.length,t),a=p.split(".")[0],p=_._.includes(p,".")?f.delimiters.decimal+p.split(".")[1]:"",h&&0===Number(p.slice(1))&&(p="")):a=_._.toFixed(e,0,t),d&&!i&&1e3<=Number(a)&&d!==f.abbreviations.trillion)switch(a=String(Number(a)/1e3),d){case f.abbreviations.thousand:d=f.abbreviations.million;break;case f.abbreviations.million:d=f.abbreviations.billion;break;case f.abbreviations.billion:d=f.abbreviations.trillion}if(_._.includes(a,"-")&&(a=a.slice(1),g=!0),a.length<n)for(var v=n-a.length;0<v;v--)a="0"+a;return-1<s&&(a=a.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+f.delimiters.thousands)),0===r.indexOf(".")&&(a=""),c=a+p+(d||""),m?c=(m&&g?"(":"")+c+(m&&g?")":""):0<=u?c=0===u?(g?"-":"+")+c:c+(g?"-":"+"):g&&(c="-"+c),c},stringToNumber:function(e){var r,t,n,i=y[c.currentLocale],o=e,a={thousand:3,million:6,billion:9,trillion:12};if(c.zeroFormat&&e===c.zeroFormat)t=0;else if(c.nullFormat&&e===c.nullFormat||!e.replace(/[^0-9]+/g,"").length)t=null;else{for(r in t=1,"."!==i.delimiters.decimal&&(e=e.replace(/\./g,"").replace(i.delimiters.decimal,".")),a)if(n=new RegExp("[^a-zA-Z]"+i.abbreviations[r]+"(?:\\)|(\\"+i.currency.symbol+")?(?:\\))?)?$"),o.match(n)){t*=Math.pow(10,a[r]);break}t*=(e.split("-").length+Math.min(e.split("(").length-1,e.split(")").length-1))%2?1:-1,e=e.replace(/[^0-9\.]+/g,""),t*=Number(e)}return t},isNaN:function(e){return"number"==typeof e&&isNaN(e)},includes:function(e,r){return-1!==e.indexOf(r)},insert:function(e,r,t){return e.slice(0,t)+r+e.slice(t)},reduce:function(e,r){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof r)throw new TypeError(r+" is not a function");var t,n=Object(e),i=n.length>>>0,o=0;if(3===arguments.length)t=arguments[2];else{for(;o<i&&!(o in n);)o++;if(i<=o)throw new TypeError("Reduce of empty array with no initial value");t=n[o++]}for(;o<i;o++)o in n&&(t=r(t,n[o],o,n));return t},multiplier:function(e){var r=e.toString().split(".");return r.length<2?1:Math.pow(10,r[1].length)},correctionFactor:function(){return Array.prototype.slice.call(arguments).reduce(function(e,r){var t=o.multiplier(r);return t<e?e:t},1)},toFixed:function(e,r,t,n){var i,o,a,l,u=e.toString().split("."),s=r-(n||0);return i=2===u.length?Math.min(Math.max(u[1].length,s),r):s,a=Math.pow(10,i),l=(t(e+"e+"+i)/a).toFixed(i),r-i<n&&(o=new RegExp("\\.?0{1,"+(n-(r-i))+"}$"),l=l.replace(o,"")),l}},_.options=c,_.formats=l,_.locales=y,_.locale=function(e){return e&&(c.currentLocale=e.toLowerCase()),c.currentLocale},_.localeData=function(e){if(!e)return y[c.currentLocale];if(e=e.toLowerCase(),!y[e])throw new Error("Unknown locale : "+e);return y[e]},_.reset=function(){for(var e in r)c[e]=r[e]},_.zeroFormat=function(e){c.zeroFormat="string"==typeof e?e:null},_.nullFormat=function(e){c.nullFormat="string"==typeof e?e:null},_.defaultFormat=function(e){c.defaultFormat="string"==typeof e?e:"0.0"},_.register=function(e,r,t){if(r=r.toLowerCase(),this[e+"s"][r])throw new TypeError(r+" "+e+" already registered.");return this[e+"s"][r]=t},_.validate=function(e,r){var t,n,i,o,a,l,u,s;if("string"!=typeof e&&(e+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",e)),(e=e.trim()).match(/^\d+$/))return!0;if(""===e)return!1;try{u=_.localeData(r)}catch(e){u=_.localeData(_.locale())}return i=u.currency.symbol,a=u.abbreviations,t=u.delimiters.decimal,n="."===u.delimiters.thousands?"\\.":u.delimiters.thousands,(null===(s=e.match(/^[^\d]+/))||(e=e.substr(1),s[0]===i))&&((null===(s=e.match(/[^\d]+$/))||(e=e.slice(0,-1),s[0]===a.thousand||s[0]===a.million||s[0]===a.billion||s[0]===a.trillion))&&(l=new RegExp(n+"{2}"),!e.match(/[^\d.,]/g)&&(!(2<(o=e.split(t)).length)&&(o.length<2?!!o[0].match(/^\d+.*\d$/)&&!o[0].match(l):1===o[0].length?!!o[0].match(/^\d+$/)&&!o[0].match(l)&&!!o[1].match(/^\d+$/):!!o[0].match(/^\d+.*\d$/)&&!o[0].match(l)&&!!o[1].match(/^\d+$/)))))},_.fn=a.prototype={clone:function(){return _(this)},format:function(e,r){var t,n,i,o=this._value,a=e||c.defaultFormat;if(r=r||Math.round,0===o&&null!==c.zeroFormat)n=c.zeroFormat;else if(null===o&&null!==c.nullFormat)n=c.nullFormat;else{for(t in l)if(a.match(l[t].regexps.format)){i=l[t].format;break}n=(i=i||_._.numberToFormat)(o,a,r)}return n},value:function(){return this._value},input:function(){return this._input},set:function(e){return this._value=Number(e),this},add:function(e){var i=o.correctionFactor.call(null,this._value,e);return this._value=o.reduce([this._value,e],function(e,r,t,n){return e+Math.round(i*r)},0)/i,this},subtract:function(e){var i=o.correctionFactor.call(null,this._value,e);return this._value=o.reduce([e],function(e,r,t,n){return e-Math.round(i*r)},Math.round(this._value*i))/i,this},multiply:function(e){return this._value=o.reduce([this._value,e],function(e,r,t,n){var i=o.correctionFactor(e,r);return Math.round(e*i)*Math.round(r*i)/Math.round(i*i)},1),this},divide:function(e){return this._value=o.reduce([this._value,e],function(e,r,t,n){var i=o.correctionFactor(e,r);return Math.round(e*i)/Math.round(r*i)}),this},difference:function(e){return Math.abs(_(this._value).subtract(e).value())}},_.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(e){var r=e%10;return 1==~~(e%100/10)?"th":1===r?"st":2===r?"nd":3===r?"rd":"th"},currency:{symbol:"$"}}),_.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(e,r,t){var n,i=_._.includes(r," BPS")?" ":"";return e*=1e4,r=r.replace(/\s?BPS/,""),n=_._.numberToFormat(e,r,t),_._.includes(n,")")?((n=n.split("")).splice(-1,0,i+"BPS"),n=n.join("")):n=n+i+"BPS",n},unformat:function(e){return+(1e-4*_._.stringToNumber(e)).toFixed(15)}}),s={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},e="("+(e=(u={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}).suffixes.concat(s.suffixes.filter(function(e){return u.suffixes.indexOf(e)<0})).join("|")).replace("B","B(?!PS)")+")",_.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(e,r,t){var n,i,o,a=_._.includes(r,"ib")?s:u,l=_._.includes(r," b")||_._.includes(r," ib")?" ":"";for(r=r.replace(/\s?i?b/,""),n=0;n<=a.suffixes.length;n++)if(i=Math.pow(a.base,n),o=Math.pow(a.base,n+1),null===e||0===e||i<=e&&e<o){l+=a.suffixes[n],0<i&&(e/=i);break}return _._.numberToFormat(e,r,t)+l},unformat:function(e){var r,t,n=_._.stringToNumber(e);if(n){for(r=u.suffixes.length-1;0<=r;r--){if(_._.includes(e,u.suffixes[r])){t=Math.pow(u.base,r);break}if(_._.includes(e,s.suffixes[r])){t=Math.pow(s.base,r);break}}n*=t||1}return n}}),_.register("format","currency",{regexps:{format:/(\$)/},format:function(e,r,t){var n,i,o=_.locales[_.options.currentLocale],a={before:r.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:r.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(r=r.replace(/\s?\$\s?/,""),n=_._.numberToFormat(e,r,t),0<=e?(a.before=a.before.replace(/[\-\(]/,""),a.after=a.after.replace(/[\-\)]/,"")):e<0&&!_._.includes(a.before,"-")&&!_._.includes(a.before,"(")&&(a.before="-"+a.before),i=0;i<a.before.length;i++)switch(a.before[i]){case"$":n=_._.insert(n,o.currency.symbol,i);break;case" ":n=_._.insert(n," ",i+o.currency.symbol.length-1)}for(i=a.after.length-1;0<=i;i--)switch(a.after[i]){case"$":n=i===a.after.length-1?n+o.currency.symbol:_._.insert(n,o.currency.symbol,-(a.after.length-(1+i)));break;case" ":n=i===a.after.length-1?n+" ":_._.insert(n," ",-(a.after.length-(1+i)+o.currency.symbol.length-1))}return n}}),_.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(e,r,t){var n=("number"!=typeof e||_._.isNaN(e)?"0e+0":e.toExponential()).split("e");return r=r.replace(/e[\+|\-]{1}0/,""),_._.numberToFormat(Number(n[0]),r,t)+"e"+n[1]},unformat:function(e){var r=_._.includes(e,"e+")?e.split("e+"):e.split("e-"),t=Number(r[0]),n=Number(r[1]);return n=_._.includes(e,"e-")?n*=-1:n,_._.reduce([t,Math.pow(10,n)],function(e,r,t,n){var i=_._.correctionFactor(e,r);return e*i*(r*i)/(i*i)},1)}}),_.register("format","ordinal",{regexps:{format:/(o)/},format:function(e,r,t){var n=_.locales[_.options.currentLocale],i=_._.includes(r," o")?" ":"";return r=r.replace(/\s?o/,""),i+=n.ordinal(e),_._.numberToFormat(e,r,t)+i}}),_.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(e,r,t){var n,i=_._.includes(r," %")?" ":"";return _.options.scalePercentBy100&&(e*=100),r=r.replace(/\s?\%/,""),n=_._.numberToFormat(e,r,t),_._.includes(n,")")?((n=n.split("")).splice(-1,0,i+"%"),n=n.join("")):n=n+i+"%",n},unformat:function(e){var r=_._.stringToNumber(e);return _.options.scalePercentBy100?.01*r:r}}),_.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(e,r,t){var n=Math.floor(e/60/60),i=Math.floor((e-60*n*60)/60),o=Math.round(e-60*n*60-60*i);return n+":"+(i<10?"0"+i:i)+":"+(o<10?"0"+o:o)},unformat:function(e){var r=e.split(":"),t=0;return 3===r.length?(t+=60*Number(r[0])*60,t+=60*Number(r[1]),t+=Number(r[2])):2===r.length&&(t+=60*Number(r[0]),t+=Number(r[1])),Number(t)}}),_});
|
|
//# sourceMappingURL=/sm/85bb06c05da559f5cb84df124b13ace5e7e7c3b381f35281fd90f009db1b5036.map
|