/**
 * Initializes dashboard KPI cards.
 *
 * @param {HTMLElement} container
 *   Dashboard root element.
 */
export default function initKpiCards(container) {
  const cards = container.querySelectorAll(".no-kpi-card");

  cards.forEach((card) => {
    const chartCanvas = card.querySelector(".no-kpi-card__sparkline");
    const hasChart = Boolean(chartCanvas);

    // Marks the card as initialized.
    card.classList.add("is-ready");

    // Exposes a simple UI state for cards without chart data.
    if (!hasChart) {
      card.classList.add("no-kpi-card--no-chart");
    }
  });
}
