const l=["B","kB","MB","GB","TB","PB","EB","ZB","YB"],T=["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],y=["b","kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],d=["b","kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],f=(t,i,e)=>{let a=t;return typeof i=="string"||Array.isArray(i)?a=t.toLocaleString(i,e):(i===!0||e!==void 0)&&(a=t.toLocaleString(void 0,e)),a};function S(t,i){if(!Number.isFinite(t))throw new TypeError(`Expected a finite number, got ${typeof t}: ${t}`);i={bits:!1,binary:!1,space:!0,...i};const e=i.bits?i.binary?d:y:i.binary?T:l,a=i.space?" ":"";if(i.signed&&t===0)return` 0${a}${e[0]}`;const n=t<0,c=n?"-":i.signed?"+":"";n&&(t=-t);let r;if(i.minimumFractionDigits!==void 0&&(r={minimumFractionDigits:i.minimumFractionDigits}),i.maximumFractionDigits!==void 0&&(r={maximumFractionDigits:i.maximumFractionDigits,...r}),t<1){const b=f(t,i.locale,r);return c+b+a+e[0]}const B=Math.min(Math.floor(i.binary?Math.log(t)/Math.log(1024):Math.log10(t)/3),e.length-1);t/=(i.binary?1024:1e3)**B,r||(t=t.toPrecision(3));const s=f(Number(t),i.locale,r),g=e[B];return c+s+a+g}export{S as p};