import { T as reactExports, K as jsxRuntimeExports } from "./server-ChzsfjB9.js";
import { a as AppLayout, P as Package, C as Card, f as CardContent, x as Skeleton, g as CardHeader, h as CardTitle } from "./card-HyNxoILF.js";
import { e as createLucideIcon, I as Input, B as Button } from "./input-muzHTpl5.js";
import { L as Label } from "./label-2bHC70jG.js";
import { S as Select, c as SelectTrigger, d as SelectValue, a as SelectContent, b as SelectItem } from "./select-YkkkCruU.js";
import { u as useCurrentCliente, l as useCurrentClienteId, L as LoadingOverlay, C as ClienteDbStatus, i as formatDateToSQL, a as executeClienteQuery, t as toNum, e as executeClienteBatchQuery, f as formatBRL, j as formatNumber, c as exportChartToPDF, b as exportChartToExcel } from "./exporters-Br36eL2f.js";
import { C as CalendarDays } from "./calendar-days-HMPXAKu8.js";
import { T as TrendingUp } from "./trending-up-fVcv4n6f.js";
import "node:async_hooks";
import "node:stream/web";
import "node:stream";
import "./router-uu4vGjiO.js";
import "./index-BxBx9O65.js";
import "./index-CZazwQDH.js";
import "./lock-0me_4kb9.js";
const __iconNode$5 = [
  [
    "path",
    {
      d: "M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",
      key: "3c2336"
    }
  ],
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
  ["path", { d: "M9 9h.01", key: "1q5me6" }],
  ["path", { d: "M15 15h.01", key: "lqbp3k" }]
];
const BadgePercent = createLucideIcon("badge-percent", __iconNode$5);
const __iconNode$4 = [
  ["path", { d: "M8 2v4", key: "1cmpym" }],
  ["path", { d: "M16 2v4", key: "4m81vk" }],
  ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
  ["path", { d: "M3 10h18", key: "8toen8" }],
  ["path", { d: "m9 16 2 2 4-4", key: "19s6y9" }]
];
const CalendarCheck = createLucideIcon("calendar-check", __iconNode$4);
const __iconNode$3 = [
  ["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
  ["path", { d: "M16 2v4", key: "4m81vk" }],
  ["path", { d: "M3 10h18", key: "8toen8" }],
  ["path", { d: "M8 2v4", key: "1cmpym" }],
  ["path", { d: "M17 14h-6", key: "bkmgh3" }],
  ["path", { d: "M13 18H7", key: "bb0bb7" }],
  ["path", { d: "M7 14h.01", key: "1qa3f1" }],
  ["path", { d: "M17 18h.01", key: "1bdyru" }]
];
const CalendarRange = createLucideIcon("calendar-range", __iconNode$3);
const __iconNode$2 = [
  ["path", { d: "M13.744 17.736a6 6 0 1 1-7.48-7.48", key: "bq4yh3" }],
  ["path", { d: "M15 6h1v4", key: "11y1tn" }],
  ["path", { d: "m6.134 14.768.866-.5 2 3.464", key: "17snzx" }],
  ["circle", { cx: "16", cy: "8", r: "6", key: "14bfc9" }]
];
const Coins = createLucideIcon("coins", __iconNode$2);
const __iconNode$1 = [
  [
    "path",
    {
      d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
      key: "1oefj6"
    }
  ],
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
  ["path", { d: "M12 18v-6", key: "17g6i2" }],
  ["path", { d: "m9 15 3 3 3-3", key: "1npd3o" }]
];
const FileDown = createLucideIcon("file-down", __iconNode$1);
const __iconNode = [
  [
    "path",
    {
      d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
      key: "1oefj6"
    }
  ],
  ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
  ["path", { d: "M8 13h2", key: "yr2amv" }],
  ["path", { d: "M14 13h2", key: "un5t4a" }],
  ["path", { d: "M8 17h2", key: "2yhykz" }],
  ["path", { d: "M14 17h2", key: "10kma7" }]
];
const FileSpreadsheet = createLucideIcon("file-spreadsheet", __iconNode);
const today = () => formatDateToSQL(/* @__PURE__ */ new Date());
const daysAgo = (n) => {
  const d = /* @__PURE__ */ new Date();
  d.setDate(d.getDate() - n);
  return formatDateToSQL(d);
};
function Page() {
  const cliente = useCurrentCliente();
  const clienteId = useCurrentClienteId();
  const [dataIni, setDataIni] = reactExports.useState(daysAgo(30));
  const [dataFim, setDataFim] = reactExports.useState(today());
  const [loja, setLoja] = reactExports.useState("__all__");
  const [lojas, setLojas] = reactExports.useState([]);
  const [topHoje, setTopHoje] = reactExports.useState(null);
  const [top7, setTop7] = reactExports.useState(null);
  const [topMes, setTopMes] = reactExports.useState(null);
  const [vendidos, setVendidos] = reactExports.useState([]);
  const [descontos, setDescontos] = reactExports.useState([]);
  const [lucro, setLucro] = reactExports.useState([]);
  const [loading, setLoading] = reactExports.useState(false);
  const [erro, setErro] = reactExports.useState(null);
  const lastLoadKeyRef = reactExports.useRef("");
  const params = reactExports.useMemo(() => ({
    data_ini: dataIni,
    data_fim: dataFim,
    loja: loja === "__all__" ? null : Number(loja) || loja,
    limit: 10
  }), [dataIni, dataFim, loja]);
  async function buscarGraficos() {
    if (!clienteId) {
      setErro({
        code: "NO_ACTIVE_CLIENT",
        message: "Nenhum cliente ativo selecionado."
      });
      return;
    }
    setLoading(true);
    setErro(null);
    setTopHoje(null);
    setTop7(null);
    setTopMes(null);
    setVendidos([]);
    setDescontos([]);
    setLucro([]);
    try {
      const falhas = [];
      if (lojas.length === 0) {
        const r = await executeClienteQuery("ranking.lojas", {}, clienteId);
        if (r.code === "OK") setLojas(r.rows);
        else falhas.push(`ranking.lojas: ${r.code} - ${r.message}`);
      }
      const lojaParams = {
        loja: params.loja
      };
      const setTop = (set) => (rows) => {
        const r = rows[0];
        if (!r) return set(null);
        set({
          cod_prod: r.cod_prod,
          produto: String(r.produto ?? "Produto"),
          qtd: toNum(r.qtd),
          total: toNum(r.total)
        });
      };
      const steps = [["produtos.mais_vendido_hoje", lojaParams, setTop(setTopHoje)], ["produtos.mais_vendido_7_dias", lojaParams, setTop(setTop7)], ["produtos.mais_vendido_mes", lojaParams, setTop(setTopMes)], ["produtos.top_vendidos", params, (rows) => setVendidos(rows.map((r) => ({
        ...r,
        qtd: toNum(r.qtd),
        total: toNum(r.total)
      })))], ["produtos.top_descontos", params, (rows) => setDescontos(rows.map((r) => ({
        ...r,
        qtd: toNum(r.qtd),
        vr_desc: toNum(r.vr_desc)
      })))], ["produtos.top_lucro", params, (rows) => setLucro(rows.map((r) => ({
        ...r,
        qtd: toNum(r.qtd),
        receita: toNum(r.receita),
        custo: toNum(r.custo),
        lucro: toNum(r.lucro)
      })))]];
      const batch = await executeClienteBatchQuery(steps.map(([key, p]) => ({
        key,
        params: p
      })), clienteId);
      for (const [key, , apply] of steps) {
        const r = batch.results[key];
        if (!r || r.code !== "OK") {
          falhas.push(`${key}: ${r?.code ?? "ERR"} - ${r?.message || "Falha na consulta."}`);
          continue;
        }
        apply(r.rows);
      }
      if (falhas.length > 0) setErro({
        code: "QUERY_FAIL",
        message: falhas.join("\n")
      });
    } catch (e) {
      setErro({
        code: "INTERNAL",
        message: e instanceof Error ? e.message : "Erro inesperado"
      });
    } finally {
      setLoading(false);
    }
  }
  reactExports.useEffect(() => {
    if (!clienteId) {
      lastLoadKeyRef.current = "";
      setErro({
        code: "NO_ACTIVE_CLIENT",
        message: "Nenhum cliente ativo selecionado."
      });
      return;
    }
    const loadKey = JSON.stringify({
      clienteId,
      dataIni,
      dataFim,
      loja
    });
    if (lastLoadKeyRef.current === loadKey) return;
    const t = setTimeout(() => {
      lastLoadKeyRef.current = loadKey;
      buscarGraficos();
    }, 300);
    return () => clearTimeout(t);
  }, [clienteId, dataIni, dataFim, loja]);
  reactExports.useEffect(() => {
    if (lojas.length === 1 && loja === "__all__") {
      setLoja(String(lojas[0].id));
    }
  }, [lojas, loja]);
  return /* @__PURE__ */ jsxRuntimeExports.jsx(AppLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative space-y-6", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { show: loading, title: "Carregando produtos...", subtitle: "Aguarde, estamos montando os gráficos." }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-end justify-between gap-3", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Vendas Produtos" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: cliente ? `Cliente: ${cliente.fantasyName}` : "Selecione um cliente ativo" })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-end gap-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "De" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { type: "date", value: dataIni, onChange: (e) => setDataIni(e.target.value), className: "h-9 w-[150px]" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Até" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { type: "date", value: dataFim, onChange: (e) => setDataFim(e.target.value), className: "h-9 w-[150px]" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs", children: "Loja" }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs(Select, { value: loja, onValueChange: setLoja, children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "h-9 w-[200px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { placeholder: "Todas as lojas" }) }),
            /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "__all__", children: "Todas as lojas" }),
              lojas.map((l) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: String(l.id), children: l.nome }, String(l.id)))
            ] })
          ] })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "outline", size: "sm", className: "h-9", onClick: () => {
          lastLoadKeyRef.current = "";
          buscarGraficos();
        }, disabled: loading, children: loading ? "Carregando…" : "Atualizar" })
      ] })
    ] }),
    erro && /* @__PURE__ */ jsxRuntimeExports.jsx(ClienteDbStatus, { code: erro.code, message: erro.message }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(TopCard, { title: "Mais vendido hoje", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarCheck, { className: "h-5 w-5" }), iconBg: "bg-blue-500", data: topHoje, loading: loading && !topHoje }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TopCard, { title: "Mais vendido (7 dias)", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarRange, { className: "h-5 w-5" }), iconBg: "bg-violet-500", data: top7, loading: loading && !top7 }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TopCard, { title: "Mais vendido no mês", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDays, { className: "h-5 w-5" }), iconBg: "bg-emerald-500", data: topMes, loading: loading && !topMes })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-3 gap-4", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(RankingCard, { title: "Mais Vendidos", subtitle: "Produtos com maior volume de vendas", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Package, { className: "h-4 w-4" }), color: "blue", rows: vendidos, loading: loading && vendidos.length === 0, valueKey: "total", valueLabel: "Total", exportName: "vendas-produtos-mais-vendidos", exportColumns: [{
        header: "#",
        key: "rank",
        format: "int"
      }, {
        header: "Código",
        key: "cod_prod",
        format: "text"
      }, {
        header: "Produto",
        key: "produto",
        format: "text"
      }, {
        header: "Quantidade",
        key: "qtd",
        format: "int"
      }, {
        header: "Total",
        key: "total",
        format: "brl"
      }] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(RankingCard, { title: "Maiores Descontos", subtitle: "Produtos com maior desconto concedido", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(BadgePercent, { className: "h-4 w-4" }), color: "orange", rows: descontos, loading: loading && descontos.length === 0, valueKey: "vr_desc", valueLabel: "Desconto", exportName: "vendas-produtos-maiores-descontos", exportColumns: [{
        header: "#",
        key: "rank",
        format: "int"
      }, {
        header: "Código",
        key: "cod_prod",
        format: "text"
      }, {
        header: "Produto",
        key: "produto",
        format: "text"
      }, {
        header: "Quantidade",
        key: "qtd",
        format: "int"
      }, {
        header: "Desconto",
        key: "vr_desc",
        format: "brl"
      }] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(RankingCard, { title: "Maior Lucro", subtitle: "Produtos com maior margem de lucro", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Coins, { className: "h-4 w-4" }), color: "green", rows: lucro, loading: loading && lucro.length === 0, valueKey: "lucro", valueLabel: "Lucro", exportName: "vendas-produtos-maior-lucro", exportColumns: [{
        header: "#",
        key: "rank",
        format: "int"
      }, {
        header: "Código",
        key: "cod_prod",
        format: "text"
      }, {
        header: "Produto",
        key: "produto",
        format: "text"
      }, {
        header: "Quantidade",
        key: "qtd",
        format: "int"
      }, {
        header: "Receita",
        key: "receita",
        format: "brl"
      }, {
        header: "Custo",
        key: "custo",
        format: "brl"
      }, {
        header: "Lucro",
        key: "lucro",
        format: "brl"
      }] })
    ] })
  ] }) });
}
function TopCard({
  title,
  icon,
  iconBg,
  data,
  loading
}) {
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "p-5", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs uppercase tracking-wide text-muted-foreground font-medium", children: title }),
      loading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 space-y-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-5 w-3/4" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-1/2" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-7 w-2/3 mt-2" })
      ] }) : data ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-base font-semibold leading-tight line-clamp-2", children: data.produto }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 text-xs text-muted-foreground", children: [
          "Cód: ",
          String(data.cod_prod)
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-3 text-2xl font-bold tracking-tight", children: formatBRL(data.total) }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 text-xs text-muted-foreground flex items-center gap-1", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(TrendingUp, { className: "h-3 w-3" }),
          formatNumber(data.qtd),
          " un."
        ] })
      ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 text-base font-semibold text-muted-foreground", children: "—" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-3 text-2xl font-bold tracking-tight text-muted-foreground", children: "—" })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `shrink-0 h-11 w-11 rounded-xl ${iconBg} text-white flex items-center justify-center shadow-md`, children: icon })
  ] }) }) });
}
const COLOR_MAP = {
  blue: {
    badge: "bg-blue-500 text-white",
    bar: "bg-gradient-to-r from-blue-500 to-blue-400",
    iconBox: "bg-blue-100 text-blue-600",
    barBg: "bg-blue-50"
  },
  orange: {
    badge: "bg-orange-500 text-white",
    bar: "bg-gradient-to-r from-orange-500 to-orange-400",
    iconBox: "bg-orange-100 text-orange-600",
    barBg: "bg-orange-50"
  },
  green: {
    badge: "bg-emerald-500 text-white",
    bar: "bg-gradient-to-r from-emerald-500 to-emerald-400",
    iconBox: "bg-emerald-100 text-emerald-600",
    barBg: "bg-emerald-50"
  }
};
function RankingCard({
  title,
  subtitle,
  icon,
  color,
  rows,
  loading,
  valueKey,
  valueLabel,
  exportName,
  exportColumns
}) {
  const c = COLOR_MAP[color];
  const max = Math.max(1, ...rows.map((r) => Number(r[valueKey] ?? 0)));
  const exportRows = rows.map((r, i) => ({
    ...r,
    rank: i + 1
  }));
  const handlePDF = () => {
    if (!exportRows.length) return;
    exportChartToPDF({
      title,
      subtitle,
      columns: exportColumns,
      rows: exportRows,
      filename: exportName
    });
  };
  const handleExcel = () => {
    if (!exportRows.length) return;
    exportChartToExcel({
      sheetName: title,
      columns: exportColumns,
      rows: exportRows,
      filename: exportName
    });
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "overflow-hidden", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(CardHeader, { className: "pb-3", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-2", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base flex items-center gap-2", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `h-7 w-7 rounded-lg ${c.iconBox} flex items-center justify-center`, children: icon }),
          title
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: subtitle })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-1 shrink-0", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "outline", size: "sm", className: "h-8 px-2", onClick: handlePDF, disabled: loading || rows.length === 0, title: "Exportar PDF", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(FileDown, { className: "h-3.5 w-3.5" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hidden sm:inline ml-1 text-xs", children: "PDF" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "outline", size: "sm", className: "h-8 px-2", onClick: handleExcel, disabled: loading || rows.length === 0, title: "Exportar Excel", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(FileSpreadsheet, { className: "h-3.5 w-3.5" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hidden sm:inline ml-1 text-xs", children: "Excel" })
        ] })
      ] })
    ] }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: loading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-3", children: Array.from({
      length: 6
    }).map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-14 w-full" }, i)) }) : rows.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-8 text-center", children: "Sem dados." }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "space-y-3", children: rows.slice(0, 10).map((r, i) => {
      const v = Number(r[valueKey] ?? 0);
      const pct = v / max * 100;
      return /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { className: "space-y-1.5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `shrink-0 h-7 w-7 rounded-full ${c.badge} flex items-center justify-center text-xs font-bold`, children: i + 1 }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-sm font-medium line-clamp-1", children: r.produto }),
            /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-[11px] text-muted-foreground", children: [
              "Cód: ",
              String(r.cod_prod)
            ] })
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold tabular-nums text-sm shrink-0", children: formatBRL(v) })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `h-2 rounded-full ${c.barBg} overflow-hidden`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `h-full ${c.bar} rounded-full transition-all`, style: {
          width: `${pct}%`
        } }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between text-[11px] text-muted-foreground", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: valueLabel }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
            formatNumber(r.qtd),
            " un."
          ] })
        ] })
      ] }, String(r.cod_prod) + i);
    }) }) })
  ] });
}
export {
  Page as component
};
