"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Chart_stories_exports = {};
__export(Chart_stories_exports, {
  Default: () => Default,
  Small: () => Small,
  default: () => Chart_stories_default
});
module.exports = __toCommonJS(Chart_stories_exports);
var import_react = __toESM(require("react"));
var import_styled_components = __toESM(require("styled-components"));
var import_index = __toESM(require("./index"));
var import_Flex = __toESM(require("../layout/Flex"));
var import_Button = __toESM(require("../cta/Button"));
function getRandomChartDate() {
  const fromTime = /* @__PURE__ */ new Date("2020-09-01T01:57:45.271Z");
  const toTime = /* @__PURE__ */ new Date("2021-02-12T01:57:45.271Z");
  return new Date(fromTime.getTime() + Math.random() * (toTime.getTime() - fromTime.getTime()));
}
function getRandomChartValue() {
  const min = 1e3;
  const max = 25e5;
  return Math.floor(Math.random() * (max - min) + min);
}
const generateData = () => {
  return new Array(50).fill({}).map(() => ({ value: getRandomChartValue(), date: getRandomChartDate() })).sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
};
var Chart_stories_default = {
  title: "Charts/Chart",
  component: import_index.default,
  argTypes: {
    data: {
      control: false,
      description: "Date is the only accepted type on the x-axis. On the y-axis, number and string are accepted."
    },
    color: {
      type: "string",
      control: "color",
      defaultValue: "#0EBDCD",
      description: "This property defines the color of the stroke and the color used to created the gradient. This property any color format."
    },
    valueKey: {
      control: false,
      description: "This optional property is useful to override the key in charge of storing the value used on the x-axis."
    },
    variant: {
      type: "enum",
      defaultValue: "default",
      description: "The small variant is used to display a gridless, tickerless chart. The default one is a full chart that allows more controls and optimisations.",
      options: ["default", "small"],
      control: false
    },
    timeOptions: {
      type: "object",
      description: "This optional property is only used by the default variant to know how to format ticker on the x-axis. See https://www.chartjs.org/docs/latest/axes/cartesian/time.html#time-units.",
      control: { type: "object" },
      defaultValue: { unit: "month", displayFormats: { month: "MMM." } }
    }
  },
  parameters: {
    docs: {
      description: {
        component: "This component chart componnet has two variants, the default and the small one. The small one is like a preview, it has no controls and allow less optimisations. The default one is a component that displays grid, axis, tickers and allow lot of customisation."
      }
    }
  }
};
const Default = ({ data: _, ...args }) => {
  const [data, setData] = import_react.default.useState(generateData());
  const handleClick = () => setData(generateData());
  return /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { alignItems: "flex-start", flexDirection: "column", rowGap: "1.5rem" }, /* @__PURE__ */ import_react.default.createElement(
    import_Flex.default,
    {
      style: args.variant === "default" ? { position: "relative", width: "100%", aspectRatio: "2 / 1" } : {}
    },
    /* @__PURE__ */ import_react.default.createElement(import_index.default, { ...args, data })
  ), /* @__PURE__ */ import_react.default.createElement(import_Button.default, { variant: "main", outline: true, onClick: handleClick }, "Generate new data"));
};
const CardChart = import_styled_components.default.div`
  position: relative;
  width: 221px;
  height: 86px;
`;
const Small = (args) => {
  const theme = (0, import_styled_components.useTheme)();
  const [data, setData] = import_react.default.useState(generateData());
  const handleClick = () => setData(generateData());
  return /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { alignItems: "flex-start", flexDirection: "column", rowGap: "1rem" }, /* @__PURE__ */ import_react.default.createElement(import_Flex.default, { flexWrap: "wrap", rowGap: "1.5rem", columnGap: "2rem" }, /* @__PURE__ */ import_react.default.createElement(CardChart, null, /* @__PURE__ */ import_react.default.createElement(import_index.default, { id: "static", variant: "small", color: theme.colors.primary.c100, data })), /* @__PURE__ */ import_react.default.createElement(CardChart, null, /* @__PURE__ */ import_react.default.createElement(import_index.default, { id: "dynamic", variant: "small", color: args.color, data }))), /* @__PURE__ */ import_react.default.createElement(import_Button.default, { variant: "main", outline: true, onClick: handleClick }, "Generate new data"));
};
//# sourceMappingURL=Chart.stories.js.map
