"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.bytesToSize = bytesToSize;
exports.bytesToSizeObject = bytesToSizeObject;
exports.supportsFolderUpload = supportsFolderUpload;
const UNITS = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
const K = 1024;
function bytesToSizeObject(bytes) {
  let params = {
    value: 0,
    precision: 1,
    unit: UNITS[0],
    order: 0
  };
  if (bytes > 0) {
    const order = Math.floor(Math.log(bytes) / Math.log(K));
    const value = bytes / K ** order;
    const precision = value > 999 ? 4 : 3;
    params = {
      value,
      precision,
      unit: UNITS[order],
      order
    };
  }
  return params;
}
function bytesToSize(bytes) {
  const {
    value,
    precision,
    unit
  } = bytesToSizeObject(bytes);
  return `${value.toPrecision(precision)} ${unit}`;
}
function supportsFolderUpload() {
  const elem = document.createElement('input');
  return ['mozdirectory', 'webkitdirectory'].some(attr => attr in elem);
}