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