function r(r,t){if(!isFinite(r)||0===r)return null;var i=(r=t?r.toExponential(t-1):r.toExponential()).indexOf("e"),n=r.slice(0,i);return[n.length>1?n[0]+n.slice(2):n,+r.slice(i+1)]}function t(t){return(t=r(Math.abs(t)))?t[1]:NaN}var i,n=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function a(r){if(!(t=n.exec(r)))throw new Error("invalid format: "+r);var t;return new o({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}function o(r){this.fill=void 0===r.fill?" ":r.fill+"",this.align=void 0===r.align?">":r.align+"",this.sign=void 0===r.sign?"-":r.sign+"",this.symbol=void 0===r.symbol?"":r.symbol+"",this.zero=!!r.zero,this.width=void 0===r.width?void 0:+r.width,this.comma=!!r.comma,this.precision=void 0===r.precision?void 0:+r.precision,this.trim=!!r.trim,this.type=void 0===r.type?"":r.type+""}function e(t,i){var n=r(t,i);if(!n)return t+"";var a=n[0],o=n[1];return o<0?"0."+new Array(-o).join("0")+a:a.length>o+1?a.slice(0,o+1)+"."+a.slice(o+1):a+new Array(o-a.length+2).join("0")}a.prototype=o.prototype,o.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};const h={"%":(r,t)=>(100*r).toFixed(t),b:r=>Math.round(r).toString(2),c:r=>r+"",d:function(r){return Math.abs(r=Math.round(r))>=1e21?r.toLocaleString("en").replace(/,/g,""):r.toString(10)},e:(r,t)=>r.toExponential(t),f:(r,t)=>r.toFixed(t),g:(r,t)=>r.toPrecision(t),o:r=>Math.round(r).toString(8),p:(r,t)=>e(100*r,t),r:e,s:function(t,n){var a=r(t,n);if(!a)return i=void 0,t.toPrecision(n);var o=a[0],e=a[1],h=e-(i=3*Math.max(-8,Math.min(8,Math.floor(e/3))))+1,u=o.length;return h===u?o:h>u?o+new Array(h-u+1).join("0"):h>0?o.slice(0,h)+"."+o.slice(h):"0."+new Array(1-h).join("0")+r(t,Math.max(0,n+h-1))[0]},X:r=>Math.round(r).toString(16).toUpperCase(),x:r=>Math.round(r).toString(16)};function u(r){return r}var s,f,v,d=Array.prototype.map,c=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function M(r){var n,o,e=void 0===r.grouping||void 0===r.thousands?u:(n=d.call(r.grouping,Number),o=r.thousands+"",function(r,t){for(var i=r.length,a=[],e=0,h=n[0],u=0;i>0&&h>0&&(u+h+1>t&&(h=Math.max(1,t-u)),a.push(r.substring(i-=h,i+h)),!((u+=h+1)>t));)h=n[e=(e+1)%n.length];return a.reverse().join(o)}),s=void 0===r.currency?"":r.currency[0]+"",f=void 0===r.currency?"":r.currency[1]+"",v=void 0===r.decimal?".":r.decimal+"",M=void 0===r.numerals?u:function(r){return function(t){return t.replace(/[0-9]/g,function(t){return r[+t]})}}(d.call(r.numerals,String)),b=void 0===r.percent?"%":r.percent+"",g=void 0===r.minus?"−":r.minus+"",w=void 0===r.nan?"NaN":r.nan+"";function l(r,t){var n=(r=a(r)).fill,o=r.align,u=r.sign,d=r.symbol,l=r.zero,y=r.width,m=r.comma,p=r.precision,N=r.trim,k=r.type;"n"===k?(m=!0,k="g"):h[k]||(void 0===p&&(p=12),N=!0,k="g"),(l||"0"===n&&"="===o)&&(l=!0,n="0",o="=");var A=(t&&void 0!==t.prefix?t.prefix:"")+("$"===d?s:"#"===d&&/[boxX]/.test(k)?"0"+k.toLowerCase():""),x=("$"===d?f:/[%p]/.test(k)?b:"")+(t&&void 0!==t.suffix?t.suffix:""),$=h[k],z=/[defgprs%]/.test(k);function E(r){var t,a,h,s=A,f=x;if("c"===k)f=$(r)+f,r="";else{var d=(r=+r)<0||1/r<0;if(r=isNaN(r)?w:$(Math.abs(r),p),N&&(r=function(r){r:for(var t,i=r.length,n=1,a=-1;n<i;++n)switch(r[n]){case".":a=t=n;break;case"0":0===a&&(a=n),t=n;break;default:if(!+r[n])break r;a>0&&(a=0)}return a>0?r.slice(0,a)+r.slice(t+1):r}(r)),d&&0===+r&&"+"!==u&&(d=!1),s=(d?"("===u?u:g:"-"===u||"("===u?"":u)+s,f=("s"!==k||isNaN(r)||void 0===i?"":c[8+i/3])+f+(d&&"("===u?")":""),z)for(t=-1,a=r.length;++t<a;)if(48>(h=r.charCodeAt(t))||h>57){f=(46===h?v+r.slice(t+1):r.slice(t))+f,r=r.slice(0,t);break}}m&&!l&&(r=e(r,1/0));var b=s.length+r.length+f.length,E=b<y?new Array(y-b+1).join(n):"";switch(m&&l&&(r=e(E+r,E.length?y-f.length:1/0),E=""),o){case"<":r=s+r+f+E;break;case"=":r=s+E+r+f;break;case"^":r=E.slice(0,b=E.length>>1)+s+r+f+E.slice(b);break;default:r=E+s+r+f}return M(r)}return p=void 0===p?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,p)):Math.max(0,Math.min(20,p)),E.toString=function(){return r+""},E}return{format:l,formatPrefix:function(r,i){var n=3*Math.max(-8,Math.min(8,Math.floor(t(i)/3))),o=Math.pow(10,-n),e=l(((r=a(r)).type="f",r),{suffix:c[8+n/3]});return function(r){return e(o*r)}}}}s=M({thousands:",",grouping:[3],currency:["$",""]}),f=s.format,v=s.formatPrefix;export{v as a,f as b,t as e,a as f};
