import { K as jsxRuntimeExports, T as reactExports } from "./server-ChzsfjB9.js";
import { C as Card, X, x as Skeleton, f as CardContent, a as AppLayout, z as Trophy, g as CardHeader, h as CardTitle, c as Avatar, d as AvatarFallback } from "./card-HyNxoILF.js";
import { e as createLucideIcon, a as cn, B as Button, I as Input } from "./input-muzHTpl5.js";
import { T as TrendingUp } from "./trending-up-fVcv4n6f.js";
import { B as Badge } from "./badge-DHuXnmRX.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 { l as useCurrentClienteId, a as executeClienteQuery, t as toNum, g as formatDateBR, f as formatBRL, j as formatNumber, k as formatPercent, C as ClienteDbStatus, b as exportChartToExcel, c as exportChartToPDF, u as useCurrentCliente, L as LoadingOverlay, i as formatDateToSQL, e as executeClienteBatchQuery } from "./exporters-Br36eL2f.js";
import { D as Dialog, a as DialogContent, d as DialogHeader, e as DialogTitle } from "./dialog-B868fIfK.js";
import { S as Sheet, F as FileText } from "./sheet-CpXgBl29.js";
import { D as DollarSign, S as ShoppingBag, P as Percent, b as PieChart, a as Pie } from "./PieChart-DFpMmo8M.js";
import { R as Receipt, a as AreaChart, A as Area } from "./AreaChart-BUqNOUUz.js";
import { R as ResponsiveContainer, C as CartesianGrid, X as XAxis, Y as YAxis, g as Tooltip, b as Cell, f as Legend, a as BarChart, B as Bar } from "./BarChart-BhbIu8Yo.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$1 = [
  ["rect", { width: "20", height: "14", x: "2", y: "5", rx: "2", key: "ynyp8z" }],
  ["line", { x1: "2", x2: "22", y1: "10", y2: "10", key: "1b3vmo" }]
];
const CreditCard = createLucideIcon("credit-card", __iconNode$1);
const __iconNode = [
  ["path", { d: "M16 17h6v-6", key: "t6n2it" }],
  ["path", { d: "m22 17-8.5-8.5-5 5L2 7", key: "x473p" }]
];
const TrendingDown = createLucideIcon("trending-down", __iconNode);
const accentMap = {
  primary: "from-primary/15 to-primary/5 text-primary",
  success: "from-success/15 to-success/5 text-success",
  warning: "from-warning/20 to-warning/5 text-warning",
  info: "from-info/15 to-info/5 text-info"
};
function KpiCard({ title, value, delta, icon: Icon, accent = "primary" }) {
  const positive = (delta ?? 0) >= 0;
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "p-5 hover:shadow-md transition-shadow", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm text-muted-foreground font-medium", children: title }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-2xl font-bold tracking-tight", children: value })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(
        "div",
        {
          className: cn(
            "flex h-11 w-11 items-center justify-center rounded-xl bg-gradient-to-br",
            accentMap[accent]
          ),
          children: /* @__PURE__ */ jsxRuntimeExports.jsx(Icon, { className: "h-5 w-5" })
        }
      )
    ] }),
    delta !== void 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 flex items-center gap-1.5 text-xs", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(
        "span",
        {
          className: cn(
            "inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-semibold",
            positive ? "bg-success/10 text-success" : "bg-destructive/10 text-destructive"
          ),
          children: [
            positive ? /* @__PURE__ */ jsxRuntimeExports.jsx(TrendingUp, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(TrendingDown, { className: "h-3 w-3" }),
            positive ? "+" : "",
            delta,
            "%"
          ]
        }
      ),
      /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground", children: "vs. mês anterior" })
    ] })
  ] });
}
function FormaPagamentoDetalheDialog({
  open,
  onOpenChange,
  forma,
  codDoc,
  dataIni,
  dataFim,
  loja,
  totalGeralFormas
}) {
  const clienteId = useCurrentClienteId();
  const [rows, setRows] = reactExports.useState([]);
  const [loading, setLoading] = reactExports.useState(false);
  const [erro, setErro] = reactExports.useState(null);
  reactExports.useEffect(() => {
    if (!open || !clienteId) return;
    let cancelled = false;
    (async () => {
      setLoading(true);
      setErro(null);
      setRows([]);
      const r = await executeClienteQuery(
        "home.formas_pagamento_detalhe",
        { data_ini: dataIni, data_fim: dataFim, loja, cod_doc: codDoc },
        clienteId
      );
      if (cancelled) return;
      if (r.code === "OK") setRows(r.rows);
      else setErro({ code: r.code, message: r.message || "Falha ao carregar detalhamento." });
      setLoading(false);
    })();
    return () => {
      cancelled = true;
    };
  }, [open, clienteId, dataIni, dataFim, loja, codDoc]);
  const { totalForma, qtd, percentual } = reactExports.useMemo(() => {
    const total = rows.reduce((a, r) => a + toNum(r.valor_total_venda), 0);
    const q = rows.length;
    const p = totalGeralFormas > 0 ? total / totalGeralFormas * 100 : 0;
    return { totalForma: total, qtd: q, percentual: p };
  }, [rows, totalGeralFormas]);
  const safeForma = (forma || "forma").toLowerCase().replace(/[^a-z0-9]+/gi, "-");
  const baseName = `detalhamento-forma-pagamento-${safeForma}-${dataIni}-${dataFim}`;
  const columns = [
    { header: "Data", key: "data_venda", format: "text" },
    { header: "Loja", key: "loja", format: "text" },
    { header: "Nº Venda", key: "cod_movimento", format: "text" },
    { header: "Cliente", key: "cliente", format: "text" },
    { header: "Vendedor", key: "vendedor", format: "text" },
    { header: "Forma", key: "forma", format: "text" },
    { header: "Valor da venda", key: "valor_total_venda", format: "brl" }
  ];
  const exportRows = rows.map((r) => ({
    ...r,
    data_venda: formatDateBR(r.data_venda)
  }));
  const handlePDF = () => exportChartToPDF({
    title: `Detalhamento - Forma de Pagamento: ${forma}`,
    subtitle: `Período: ${formatDateBR(dataIni)} a ${formatDateBR(dataFim)} • ${qtd} vendas • ${formatBRL(totalForma)}`,
    columns,
    rows: exportRows,
    filename: baseName,
    totals: { cliente: "Total", valor_total_venda: totalForma }
  });
  const handleExcel = () => exportChartToExcel({
    sheetName: "Detalhamento",
    columns,
    rows: exportRows,
    filename: baseName
  });
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(DialogContent, { className: "p-0 gap-0 overflow-hidden w-[95vw] max-w-5xl max-h-[90vh] sm:w-full", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(DialogHeader, { className: "px-4 sm:px-6 py-3 sm:py-4 border-b border-border bg-gradient-to-r from-primary/5 to-transparent", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(DialogTitle, { className: "text-base sm:text-lg flex items-center gap-2", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "h-5 w-5 text-primary shrink-0" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate", children: "Detalhamento - Forma de Pagamento" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-muted-foreground mt-1 truncate", children: [
          forma,
          " • ",
          formatDateBR(dataIni),
          " até ",
          formatDateBR(dataFim)
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1.5 sm:mr-6", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(
          Button,
          {
            size: "sm",
            variant: "outline",
            onClick: handleExcel,
            disabled: loading || rows.length === 0,
            className: "h-8 gap-1 border-success/30 text-success hover:bg-success/10 hover:text-success",
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(Sheet, { className: "h-3.5 w-3.5" }),
              "Excel"
            ]
          }
        ),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(
          Button,
          {
            size: "sm",
            variant: "outline",
            onClick: handlePDF,
            disabled: loading || rows.length === 0,
            className: "h-8 gap-1 border-destructive/30 text-destructive hover:bg-destructive/10 hover:text-destructive",
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "h-3.5 w-3.5" }),
              "PDF"
            ]
          }
        ),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(
          Button,
          {
            size: "sm",
            variant: "ghost",
            onClick: () => onOpenChange(false),
            className: "h-8 gap-1 sm:hidden",
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3.5 w-3.5" }),
              "Fechar"
            ]
          }
        )
      ] })
    ] }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 sm:px-6 py-4 space-y-4 max-h-[calc(90vh-110px)] overflow-y-auto sm:overflow-hidden flex flex-col", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-4", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          SummaryCard,
          {
            icon: /* @__PURE__ */ jsxRuntimeExports.jsx(CreditCard, { className: "h-4 w-4" }),
            label: "Forma",
            value: forma,
            accent: "primary"
          }
        ),
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          SummaryCard,
          {
            icon: /* @__PURE__ */ jsxRuntimeExports.jsx(DollarSign, { className: "h-4 w-4" }),
            label: "Total vendido",
            value: loading ? "..." : formatBRL(totalForma),
            accent: "success"
          }
        ),
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          SummaryCard,
          {
            icon: /* @__PURE__ */ jsxRuntimeExports.jsx(ShoppingBag, { className: "h-4 w-4" }),
            label: "Qtd vendas",
            value: loading ? "..." : formatNumber(qtd),
            accent: "info"
          }
        ),
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          SummaryCard,
          {
            icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Percent, { className: "h-4 w-4" }),
            label: "% sobre o total",
            value: loading ? "..." : formatPercent(percentual),
            accent: "warning"
          }
        )
      ] }),
      erro && /* @__PURE__ */ jsxRuntimeExports.jsx(ClienteDbStatus, { code: erro.code, message: erro.message }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "md:hidden space-y-2", children: loading ? Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-32 w-full" }, i)) : rows.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-center py-10 text-sm text-muted-foreground", children: "Nenhuma venda encontrada para esta forma de pagamento." }) : rows.map((r, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "border-border/60", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: "p-3 space-y-1.5 text-sm", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-start gap-2", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "font-semibold tabular-nums", children: [
            "#",
            String(r.cod_movimento)
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground tabular-nums", children: formatDateBR(r.data_venda) })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground", children: [
          "Loja: ",
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-foreground", children: r.loja })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground truncate", children: [
          "Cliente: ",
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-foreground", children: r.cliente })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground truncate", children: [
          "Vendedor: ",
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-foreground", children: r.vendedor })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground", children: [
          "Forma: ",
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-foreground", children: r.forma })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center pt-1.5 border-t border-border/40", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs text-muted-foreground", children: "Valor da venda" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold tabular-nums text-success", children: formatBRL(r.valor_total_venda) })
        ] })
      ] }) }, String(r.cod_movimento) + i)) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden md:flex flex-1 min-h-0 rounded-lg border border-border overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "overflow-auto max-h-[55vh] w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full text-sm", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { className: "sticky top-0 z-10 bg-muted/80 backdrop-blur", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "text-left text-xs text-muted-foreground uppercase tracking-wide", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium", children: "Data" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium", children: "Loja" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium", children: "Nº Venda" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium", children: "Cliente" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium", children: "Vendedor" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium", children: "Forma" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2.5 px-3 font-medium text-right", children: "Valor da venda" })
        ] }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: loading ? Array.from({ length: 8 }).map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { className: "border-t border-border/40", children: /* @__PURE__ */ jsxRuntimeExports.jsx("td", { colSpan: 7, className: "p-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-7 w-full" }) }) }, i)) : rows.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("td", { colSpan: 7, className: "text-center py-10 text-sm text-muted-foreground", children: "Nenhuma venda encontrada para esta forma de pagamento." }) }) : rows.map((r, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
          "tr",
          {
            className: "border-t border-border/40 hover:bg-muted/40 transition-colors",
            children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3 tabular-nums", children: formatDateBR(r.data_venda) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3", children: r.loja }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3 tabular-nums", children: String(r.cod_movimento) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3 max-w-[220px] truncate", title: r.cliente, children: r.cliente }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3 max-w-[180px] truncate", title: r.vendedor, children: r.vendedor }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3", children: r.forma }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3 text-right tabular-nums font-medium", children: formatBRL(r.valor_total_venda) })
            ]
          },
          String(r.cod_movimento) + i
        )) }),
        !loading && rows.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("tfoot", { className: "sticky bottom-0 bg-muted/80 backdrop-blur", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-t border-border text-sm font-semibold", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("td", { colSpan: 6, className: "py-2.5 px-3 text-right", children: "Total" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2.5 px-3 text-right tabular-nums", children: formatBRL(totalForma) })
        ] }) })
      ] }) }) })
    ] })
  ] }) });
}
function SummaryCard({
  icon,
  label,
  value,
  accent
}) {
  const tone = accent === "success" ? "from-success/15 to-success/0 text-success" : accent === "info" ? "from-info/15 to-info/0 text-info" : accent === "warning" ? "from-warning/15 to-warning/0 text-warning" : "from-primary/15 to-primary/0 text-primary";
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Card, { className: "border-border/60", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(CardContent, { className: `p-3 bg-gradient-to-br ${tone} rounded-xl`, children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-[11px] uppercase tracking-wide text-muted-foreground font-medium", children: label }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "opacity-80", children: icon })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-1 text-lg font-bold text-foreground truncate", title: value, children: value })
  ] }) });
}
const tooltipStyle = {
  backgroundColor: "var(--popover)",
  border: "1px solid var(--border)",
  borderRadius: "10px",
  fontSize: "12px",
  boxShadow: "0 8px 24px -8px rgb(0 0 0 / 0.12)"
};
const fmtBRL = (v) => (v ?? 0).toLocaleString("pt-BR", {
  style: "currency",
  currency: "BRL"
});
const fmtInt = (v) => (v ?? 0).toLocaleString("pt-BR");
const today = () => formatDateToSQL(/* @__PURE__ */ new Date());
const sevenDaysAgo = () => {
  const d = /* @__PURE__ */ new Date();
  d.setDate(d.getDate() - 7);
  return formatDateToSQL(d);
};
const MESES = ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"];
const PIE_COLORS = ["var(--chart-1)", "var(--chart-2)", "var(--chart-3)", "var(--chart-4)", "var(--chart-5)"];
function Index() {
  const cliente = useCurrentCliente();
  const clienteId = useCurrentClienteId();
  const [dataIni, setDataIni] = reactExports.useState(sevenDaysAgo());
  const [dataFim, setDataFim] = reactExports.useState(today());
  const [loja, setLoja] = reactExports.useState("__all__");
  const [lojas, setLojas] = reactExports.useState([]);
  const [totalDia, setTotalDia] = reactExports.useState(null);
  const [totalPeriodo, setTotalPeriodo] = reactExports.useState(null);
  const [qtdVendas, setQtdVendas] = reactExports.useState(null);
  const [ticketMedio, setTicketMedio] = reactExports.useState(null);
  const [topGrupos, setTopGrupos] = reactExports.useState([]);
  const [topProdutos, setTopProdutos] = reactExports.useState([]);
  const [vendasMes, setVendasMes] = reactExports.useState([]);
  const [topVendedores, setTopVendedores] = reactExports.useState([]);
  const [formas, setFormas] = reactExports.useState([]);
  const [loading, setLoading] = reactExports.useState(false);
  const [erro, setErro] = reactExports.useState(null);
  const [formaSel, setFormaSel] = 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: 20
  }), [dataIni, dataFim, loja]);
  async function buscar() {
    if (!clienteId) {
      setErro({
        code: "NO_ACTIVE_CLIENT",
        message: "Nenhum cliente ativo selecionado."
      });
      return;
    }
    setLoading(true);
    setErro(null);
    setTotalDia(null);
    setTotalPeriodo(null);
    setQtdVendas(null);
    setTicketMedio(null);
    setTopGrupos([]);
    setTopProdutos([]);
    setVendasMes([]);
    setTopVendedores([]);
    setFormas([]);
    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 steps = [["home.total_dia", {
        loja: params.loja
      }, (rows) => setTotalDia(toNum(rows[0]?.total_dia))], ["home.total_periodo", params, (rows) => setTotalPeriodo(toNum(rows[0]?.total_periodo))], ["home.qtd_vendas", params, (rows) => setQtdVendas(toNum(rows[0]?.qtd_vendas))], ["home.ticket_medio", params, (rows) => setTicketMedio(toNum(rows[0]?.ticket_medio))], ["home.top_grupos", params, (rows) => setTopGrupos(rows.map((r) => ({
        ...r,
        total: toNum(r.total)
      })))], ["home.top_produtos", params, (rows) => setTopProdutos(rows.map((r) => ({
        ...r,
        qtd: toNum(r.qtd),
        total: toNum(r.total)
      })))], ["home.vendas_mes_ano", {
        loja: params.loja
      }, (rows) => setVendasMes(rows.map((r) => ({
        ...r,
        mes: toNum(r.mes),
        total: toNum(r.total)
      })))], ["home.top_vendedores", params, (rows) => setTopVendedores(rows.map((r) => ({
        ...r,
        total: toNum(r.total),
        qtd_vendas: toNum(r.qtd_vendas)
      })))], ["home.formas_pagamento", params, (rows) => setFormas(rows.map((r) => ({
        ...r,
        total: toNum(r.total)
      })))]];
      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;
        }
        if ((r.rows ?? []).length === 0) falhas.push(`${key}: retornou 0 linhas para o período selecionado.`);
        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;
      buscar();
    }, 300);
    return () => clearTimeout(t);
  }, [clienteId, dataIni, dataFim, loja]);
  reactExports.useEffect(() => {
    if (lojas.length === 1 && loja === "__all__") {
      setLoja(String(lojas[0].id));
    }
  }, [lojas, loja]);
  const vendasMesData = reactExports.useMemo(() => {
    const map = new Map(vendasMes.map((v) => [Number(v.mes), Number(v.total)]));
    return MESES.map((m, i) => ({
      month: m,
      vendas: map.get(i + 1) ?? 0
    }));
  }, [vendasMes]);
  const totalFormas = formas.reduce((acc, f) => acc + Number(f.total || 0), 0);
  const formasData = formas.map((f, i) => ({
    name: f.forma,
    cod_doc: f.cod_doc ?? null,
    value: totalFormas > 0 ? Number((Number(f.total) / totalFormas * 100).toFixed(1)) : 0,
    total: Number(f.total),
    color: PIE_COLORS[i % PIE_COLORS.length]
  }));
  return /* @__PURE__ */ jsxRuntimeExports.jsx(AppLayout, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative space-y-6", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(LoadingOverlay, { show: loading, title: "Carregando dados...", subtitle: "Aguarde, estamos montando os gráficos." }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-end md:justify-between", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-2xl font-bold tracking-tight", children: "Visão Geral" }),
        /* @__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 = "";
          buscar();
        }, disabled: loading, children: loading ? "Carregando…" : "Atualizar" })
      ] })
    ] }),
    erro && /* @__PURE__ */ jsxRuntimeExports.jsx(ClienteDbStatus, { code: erro.code, message: erro.message }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-4 sm:grid-cols-2 xl:grid-cols-4", children: [
      totalDia == null && loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[108px] w-full" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(KpiCard, { title: "Vendas Hoje", value: fmtBRL(totalDia ?? 0), icon: DollarSign, accent: "primary" }),
      totalPeriodo == null && loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[108px] w-full" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(KpiCard, { title: "Vendas no Período", value: fmtBRL(totalPeriodo ?? 0), icon: ShoppingBag, accent: "success" }),
      ticketMedio == null && loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[108px] w-full" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(KpiCard, { title: "Ticket Médio", value: fmtBRL(ticketMedio ?? 0), icon: Receipt, accent: "warning" }),
      qtdVendas == null && loading ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[108px] w-full" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(KpiCard, { title: "Qtd. Vendas", value: fmtInt(qtdVendas ?? 0), icon: Trophy, accent: "info" })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-4 lg:grid-cols-3", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "lg:col-span-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base", children: [
            "Vendas por Mês (",
            (/* @__PURE__ */ new Date()).getFullYear(),
            ")"
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Evolução mensal do ano atual" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: loading && vendasMes.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[290px] w-full" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { width: "100%", height: 290, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AreaChart, { data: vendasMesData, margin: {
          left: -10,
          right: 8,
          top: 8
        }, children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: "vendasGrad", x1: "0", y1: "0", x2: "0", y2: "1", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset: "0%", stopColor: "var(--primary)", stopOpacity: 0.35 }),
            /* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset: "100%", stopColor: "var(--primary)", stopOpacity: 0 })
          ] }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: "var(--border)", vertical: false }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "month", stroke: "var(--muted-foreground)", fontSize: 12, tickLine: false, axisLine: false }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { stroke: "var(--muted-foreground)", fontSize: 12, tickLine: false, axisLine: false, tickFormatter: (v) => `${Math.round(v / 1e3)}k` }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { contentStyle: tooltipStyle, formatter: (v) => fmtBRL(v) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Area, { type: "monotone", dataKey: "vendas", stroke: "var(--primary)", strokeWidth: 2.5, fill: "url(#vendasGrad)" })
        ] }) }) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: "Formas de Pagamento" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Distribuição no período" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: loading && formas.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[250px] w-full" }) : formas.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-12 text-center", children: "Sem dados." }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { width: "100%", height: 250, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(PieChart, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Pie, { data: formasData, dataKey: "value", nameKey: "name", innerRadius: 55, outerRadius: 85, paddingAngle: 3, stroke: "var(--background)", strokeWidth: 2, cursor: "pointer", onClick: (d) => {
            const p = d?.payload ?? d;
            if (!p?.name) return;
            setFormaSel({
              forma: p.name,
              cod_doc: p.cod_doc ?? null
            });
          }, children: formasData.map((entry, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(Cell, { fill: entry.color, style: {
            cursor: "pointer"
          } }, i)) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { contentStyle: tooltipStyle, formatter: (v, _n, p) => [`${v}% — ${fmtBRL(p.payload.total)}`, p.payload.name] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Legend, { verticalAlign: "bottom", iconType: "circle", wrapperStyle: {
            fontSize: 11,
            paddingTop: 8
          } })
        ] }) }) })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid gap-4 lg:grid-cols-3", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "lg:col-span-2", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: "Grupos Mais Vendidos" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Receita por grupo no período" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: loading && topGrupos.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-[280px] w-full" }) : topGrupos.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-12 text-center", children: "Sem dados." }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResponsiveContainer, { width: "100%", height: 280, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(BarChart, { data: topGrupos, margin: {
            left: -10,
            right: 8,
            top: 8
          }, children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx("defs", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("linearGradient", { id: "barGrad", x1: "0", y1: "0", x2: "0", y2: "1", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset: "0%", stopColor: "var(--primary-glow)" }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("stop", { offset: "100%", stopColor: "var(--primary)" })
            ] }) }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(CartesianGrid, { strokeDasharray: "3 3", stroke: "var(--border)", vertical: false }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(XAxis, { dataKey: "grupo", stroke: "var(--muted-foreground)", fontSize: 11, tickLine: false, axisLine: false, interval: 0, angle: -15, textAnchor: "end", height: 60 }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(YAxis, { stroke: "var(--muted-foreground)", fontSize: 12, tickLine: false, axisLine: false, tickFormatter: (v) => `${Math.round(v / 1e3)}k` }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(Tooltip, { contentStyle: tooltipStyle, formatter: (v) => fmtBRL(v) }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(Bar, { dataKey: "total", fill: "url(#barGrad)", radius: [8, 8, 0, 0], maxBarSize: 56 })
          ] }) }) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "md:hidden space-y-3", children: (() => {
            const list = [...topGrupos].sort((a, b) => Number(b.total) - Number(a.total)).slice(0, 12);
            const max = Math.max(...list.map((g) => Number(g.total) || 0), 1);
            return list.map((g, i) => {
              const pct = Number(g.total) / max * 100;
              return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
                /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
                  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium line-clamp-1 flex-1", children: g.grupo }),
                  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-semibold tabular-nums whitespace-nowrap", children: fmtBRL(Number(g.total)) })
                ] }),
                /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-2.5 w-full rounded-full bg-muted overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full rounded-full bg-gradient-to-r from-primary to-primary-glow", style: {
                  width: `${pct}%`
                } }) })
              ] }, String(g.cod_grupo) + i);
            });
          })() })
        ] }) })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(CardTitle, { className: "text-base flex items-center gap-2", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(Trophy, { className: "h-4 w-4 text-warning" }),
            "Top Vendedores"
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Performance no período" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { className: "space-y-3", children: loading && topVendedores.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: Array.from({
          length: 5
        }).map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10 w-full" }, i)) }) : topVendedores.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-6 text-center", children: "Sem dados." }) : topVendedores.slice(0, 10).map((s, i) => {
          const initials = s.vendedor.split(" ").filter(Boolean).slice(0, 2).map((p) => p[0]).join("").toUpperCase();
          return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("flex items-center gap-3", i >= 5 && "md:hidden"), children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative shrink-0", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx(Avatar, { className: "h-9 w-9", children: /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarFallback, { className: "bg-gradient-to-br from-primary to-primary-glow text-primary-foreground text-xs font-semibold", children: initials || "?" }) }),
              /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute -bottom-1 -right-1 flex h-4 w-4 items-center justify-center rounded-full bg-background text-[10px] font-bold border border-border", children: i + 1 })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
              /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium leading-tight line-clamp-2 break-words", children: s.vendedor }),
              /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-muted-foreground mt-0.5", children: [
                fmtInt(s.qtd_vendas),
                " vendas"
              ] })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-sm font-semibold tabular-nums whitespace-nowrap shrink-0", children: fmtBRL(s.total) })
          ] }, s.vendedor + i);
        }) })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(CardTitle, { className: "text-base", children: "Top Produtos Vendidos" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: "Ranking por quantidade e faturamento" })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(CardContent, { children: loading && topProdutos.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: Array.from({
        length: 6
      }).map((_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-10 w-full" }, i)) }) : topProdutos.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-6 text-center", children: "Sem dados." }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full text-sm", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-b border-border text-left text-xs text-muted-foreground uppercase tracking-wide", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-3 pr-4 font-medium", children: "#" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-3 pr-4 font-medium", children: "Produto" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-3 pr-4 font-medium text-right", children: "Quantidade" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-3 font-medium text-right", children: "Faturamento" })
        ] }) }),
        /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: topProdutos.map((p, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-b border-border/50 last:border-0 hover:bg-muted/40 transition-colors", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-3 pr-4 text-muted-foreground font-medium", children: String(i + 1).padStart(2, "0") }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-3 pr-4 font-medium", children: p.produto }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-3 pr-4 text-right tabular-nums", children: fmtInt(p.qtd) }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-3 text-right font-semibold tabular-nums", children: fmtBRL(p.total) })
        ] }, String(p.cod_prod) + i)) })
      ] }) }) })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Badge, { variant: "secondary", className: "gap-1.5 px-3 py-1.5", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `h-2 w-2 rounded-full ${loading ? "bg-warning animate-pulse" : "bg-success"}` }),
      loading ? "Atualizando…" : "Dados atualizados"
    ] }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsx(FormaPagamentoDetalheDialog, { open: formaSel !== null, onOpenChange: (o) => !o && setFormaSel(null), forma: formaSel?.forma ?? "", codDoc: formaSel?.cod_doc ?? null, dataIni, dataFim, loja: params.loja, totalGeralFormas: totalFormas })
  ] }) });
}
export {
  Index as component
};
