import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
import prettyBytes from 'pretty-bytes';
function PrettyBytes({ bytes, decimals = 0, unit = 'iB' }) {
    if (bytes === undefined || bytes === null)
        return _jsx(_Fragment, { children: "-" });
    let fractionDigits = decimals;
    if (!Number.isFinite(decimals) ||
        (decimals !== undefined && decimals !== null && decimals < 0) ||
        bytes < 1024)
        fractionDigits = 0;
    if (!Number.isFinite(bytes) || !bytes || bytes < 0)
        return bytes === Infinity ||
            bytes === -Infinity ||
            (bytes === 0 && !Object.is(bytes, -0)) ? (_jsx(_Fragment, { children: "0 B" })) : (_jsx(_Fragment, { children: "-" }));
    return (_jsx(_Fragment, { children: prettyBytes(bytes, {
            locale: 'en',
            binary: unit === 'iB',
            minimumFractionDigits: fractionDigits !== null && fractionDigits !== void 0 ? fractionDigits : undefined,
            maximumFractionDigits: fractionDigits !== null && fractionDigits !== void 0 ? fractionDigits : undefined,
        })
            .replace(/,/g, ' ')
            .replace(/kiB/g, 'KiB') }));
}
export { PrettyBytes };
