'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var react = require('@linaria/react');
var index$a = require('../../core/Bit/index.js');
var index$9 = require('../../core/BitPerSecond/index.js');
var index$8 = require('../../core/Bps/index.js');
var index$4 = require('../../core/Byte/index.js');
var index$5 = require('../../core/BytePerSecond/index.js');
var index = require('../../core/Empty/index.js');
var index$6 = require('../../core/Frequency/index.js');
var index$2 = require('../../core/Percent/index.js');
var index$b = require('../../core/Second/index.js');
var index$7 = require('../../core/Speed/index.js');
var index$1 = require('../BarChart/index.js');
var index$3 = require('../DeprecatedDonutChart/index.js');
var React = require('react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
  enumerable: true,
  configurable: true,
  writable: true,
  value
}) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
    if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
  }
  return a;
};
const units = {
  Percent: index$2,
  Byte: index$4,
  BytePerSecond: index$5,
  Frequency: index$6,
  Speed: index$7,
  Bps: index$8,
  BitPerSecond: index$9,
  Bit: index$a,
  Second: index$b
};
const Wrapper = /*#__PURE__*/react.styled('div')({
  name: "Wrapper",
  class: "E_4100_0_7_wg1tsps",
  propsAsIs: false
});
const BarChartWrapper = "E_4100_0_7_b1ctd5xy";
const UnitWrapper = "E_4100_0_7_u1p8acpn";
const Sizes = {
  small: {
    width: 22,
    height: 22,
    barSize: 4,
    innerRadius: 8,
    outerRadius: 16
  },
  medium: {
    width: 50,
    height: 50,
    barSize: 8,
    innerRadius: 18,
    outerRadius: 34
  },
  large: {
    width: 100,
    height: 100,
    barSize: 15,
    innerRadius: 40,
    outerRadius: 70
  }
};
const UnitWithChart = ({
  rawValue,
  total,
  unit,
  color = "#0080FF",
  size = "small",
  chartType = "donutChart",
  data,
  saturated
}) => {
  if (typeof rawValue !== "number" || typeof total !== "number") {
    return /* @__PURE__ */React__default.default.createElement(index, null);
  }
  const Unit = units[unit];
  return /* @__PURE__ */React__default.default.createElement(Wrapper, {
    className: "unit-chart"
  }, chartType === "barChart" && /* @__PURE__ */React__default.default.createElement("span", {
    className: BarChartWrapper
  }, /* @__PURE__ */React__default.default.createElement("span", {
    className: "chart"
  }, /* @__PURE__ */React__default.default.createElement(index$1.default, {
    data: data || [],
    total
  }))), /* @__PURE__ */React__default.default.createElement("span", {
    className: UnitWrapper
  }, unit === "Percent" ? /* @__PURE__ */React__default.default.createElement(index$2, {
    rawValue,
    decimals: 1,
    saturated
  }) : /* @__PURE__ */React__default.default.createElement(Unit, {
    rawValue
  })), chartType === "donutChart" && /* @__PURE__ */React__default.default.createElement(index$3, __spreadValues({
    data: [{
      used: rawValue / total,
      fill: color
    }],
    dataKey: "used"
  }, Sizes[size])));
};
var UnitWithChart$1 = UnitWithChart;

exports.UnitWrapper = UnitWrapper;
exports.default = UnitWithChart$1;
