// src/utils/utils.ts
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs) {
  return twMerge(clsx(inputs));
}

// src/components/Text/Text.tsx
import { jsx } from "react/jsx-runtime";
var Text = ({
  children,
  size = "md",
  weight = "normal",
  color = "text-text-950",
  as,
  className = "",
  ...props
}) => {
  let sizeClasses;
  let weightClasses;
  const sizeClassMap = {
    "2xs": "text-2xs",
    xs: "text-xs",
    sm: "text-sm",
    md: "text-md",
    lg: "text-lg",
    xl: "text-xl",
    "2xl": "text-2xl",
    "3xl": "text-3xl",
    "4xl": "text-4xl",
    "5xl": "text-5xl",
    "6xl": "text-6xl"
  };
  sizeClasses = sizeClassMap[size] ?? sizeClassMap.md;
  const weightClassMap = {
    hairline: "font-hairline",
    light: "font-light",
    normal: "font-normal",
    medium: "font-medium",
    semibold: "font-semibold",
    bold: "font-bold",
    extrabold: "font-extrabold",
    black: "font-black"
  };
  weightClasses = weightClassMap[weight] ?? weightClassMap.normal;
  const baseClasses = "font-primary";
  const Component = as ?? "p";
  return /* @__PURE__ */ jsx(
    Component,
    {
      className: cn(baseClasses, sizeClasses, weightClasses, color, className),
      ...props,
      children
    }
  );
};
var Text_default = Text;

// src/components/shared/ChartComponents.tsx
import { useState } from "react";
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
var calculateYAxisTicks = (maxValue) => {
  if (maxValue <= 0) return [0];
  const niceMax = Math.ceil(maxValue / 10) * 10;
  const step = niceMax / 4;
  return [
    niceMax,
    Math.round(step * 3),
    Math.round(step * 2),
    Math.round(step),
    0
  ];
};
var LegendItem = ({
  color,
  label
}) => /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center gap-2", children: [
  /* @__PURE__ */ jsx2("div", { className: cn("w-2 h-2 rounded-full", color) }),
  /* @__PURE__ */ jsx2(Text_default, { size: "xs", weight: "medium", className: "text-text-600", children: label })
] });
var DataBar = ({
  label,
  value,
  maxValue,
  colorClass,
  chartHeight
}) => {
  const percentage = maxValue === 0 ? 0 : value / maxValue * 100;
  const barHeight = percentage / 100 * chartHeight;
  return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-2 flex-1", children: [
    /* @__PURE__ */ jsx2(
      "div",
      {
        className: "w-full flex items-end justify-center",
        style: { height: chartHeight },
        children: /* @__PURE__ */ jsx2(
          "div",
          {
            className: cn(
              "w-16 rounded-lg transition-all duration-300",
              colorClass
            ),
            style: { height: `${barHeight}px` }
          }
        )
      }
    ),
    /* @__PURE__ */ jsx2(Text_default, { size: "xs", weight: "medium", className: "text-text-600 text-center", children: label })
  ] });
};
var GridLines = ({
  ticks,
  chartHeight
}) => /* @__PURE__ */ jsx2(
  "div",
  {
    className: "absolute inset-0 flex flex-col justify-between pointer-events-none",
    style: { height: chartHeight },
    children: ticks.map((tick, index) => /* @__PURE__ */ jsx2(
      "div",
      {
        className: "w-full border-t border-dashed border-border-200",
        style: { marginTop: index === 0 ? 0 : void 0 }
      },
      `${tick}-${index}`
    ))
  }
);
var YAxis = ({
  ticks,
  chartHeight
}) => /* @__PURE__ */ jsx2(
  "div",
  {
    className: "flex flex-col justify-between items-end pr-3",
    style: { height: chartHeight },
    "aria-hidden": "true",
    children: ticks.map((tick, index) => /* @__PURE__ */ jsx2(
      Text_default,
      {
        size: "xs",
        weight: "medium",
        className: "text-text-500",
        children: tick
      },
      `${tick}-${index}`
    ))
  }
);

// src/components/QuestionsData/QuestionsData.tsx
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
var BAR_COLORS = {
  total: "bg-info-600",
  corretas: "bg-success-200",
  incorretas: "bg-warning-400",
  emBranco: "bg-background-300"
};
var QuestionsData = ({
  title = "Dados de quest\xF5es",
  data,
  showEmBranco = false,
  maxValue,
  chartHeight = 180,
  className,
  ...props
}) => {
  const chartMaxValue = maxValue ?? data.total;
  const yAxisTicks = calculateYAxisTicks(chartMaxValue);
  const adjustedMaxValue = yAxisTicks[0];
  const blankSuffix = showEmBranco && data.emBranco !== void 0 ? `, ${data.emBranco} em branco` : "";
  const chartDescription = `Gr\xE1fico de barras mostrando ${data.total} quest\xF5es respondidas, ${data.corretas} corretas, ${data.incorretas} incorretas${blankSuffix}`;
  const barItems = [
    {
      key: "total",
      label: "Total",
      legendLabel: "Total de quest\xF5es respondidas",
      value: data.total,
      colorClass: BAR_COLORS.total
    },
    {
      key: "corretas",
      label: "Corretas",
      legendLabel: "Quest\xF5es corretas",
      value: data.corretas,
      colorClass: BAR_COLORS.corretas
    },
    {
      key: "incorretas",
      label: "Incorretas",
      legendLabel: "Quest\xF5es incorretas",
      value: data.incorretas,
      colorClass: BAR_COLORS.incorretas
    }
  ];
  if (showEmBranco && data.emBranco !== void 0) {
    barItems.push({
      key: "emBranco",
      label: "Em branco",
      legendLabel: "Quest\xF5es em branco",
      value: data.emBranco,
      colorClass: BAR_COLORS.emBranco
    });
  }
  return /* @__PURE__ */ jsxs2(
    "div",
    {
      className: cn(
        "flex flex-col p-5 gap-4 bg-background border border-border-50 rounded-xl",
        className
      ),
      ...props,
      children: [
        /* @__PURE__ */ jsx3(
          Text_default,
          {
            as: "h3",
            size: "lg",
            weight: "bold",
            className: "text-text-950 tracking-[0.2px]",
            children: title
          }
        ),
        /* @__PURE__ */ jsx3("div", { className: "flex flex-row flex-wrap gap-x-6 gap-y-2 mb-4", children: barItems.map((item) => /* @__PURE__ */ jsx3(
          LegendItem,
          {
            color: BAR_COLORS[item.key],
            label: item.legendLabel
          },
          item.key
        )) }),
        /* @__PURE__ */ jsxs2("div", { className: "flex flex-row", "aria-label": chartDescription, children: [
          /* @__PURE__ */ jsx3(YAxis, { ticks: yAxisTicks, chartHeight }),
          /* @__PURE__ */ jsx3("div", { className: "w-4" }),
          /* @__PURE__ */ jsxs2("div", { className: "flex-1 relative", children: [
            /* @__PURE__ */ jsx3(GridLines, { ticks: yAxisTicks, chartHeight }),
            /* @__PURE__ */ jsx3("div", { className: "flex flex-row flex-1 gap-4 relative z-10", children: barItems.map((item) => /* @__PURE__ */ jsx3(
              DataBar,
              {
                label: item.label,
                value: item.value,
                maxValue: adjustedMaxValue,
                colorClass: item.colorClass,
                chartHeight
              },
              item.key
            )) })
          ] })
        ] })
      ]
    }
  );
};
var QuestionsData_default = QuestionsData;
export {
  QuestionsData,
  QuestionsData_default as default
};
//# sourceMappingURL=index.mjs.map