import { jsx as a, jsxs as s } from "react/jsx-runtime";
import na, { useState as b, useEffect as q, useMemo as I, useCallback as Y } from "react";
import { useNavigate as la } from "react-router-dom";
import { useTranslation as T } from "react-i18next";
import { TrendingUp as U, Users as J, Clock as j, PieChart as ca, Home as da, ChevronRight as ha, ArrowLeft as pa, Layers as O, Loader2 as ma, AlertTriangle as ua, RefreshCw as _, Activity as G, BarChart3 as W } from "lucide-react";
import { q as P, a as ba, P as H, K as S } from "./index-CeEMms9z.js";
import { a as R } from "./applicationAnalyticsApi-BdESQcDo.js";
import { ResponsiveContainer as z, LineChart as va, CartesianGrid as ga, XAxis as fa, YAxis as xa, Tooltip as ya, Line as Na, PieChart as Q, Pie as Z, Cell as aa } from "recharts";
import { C as F, a as K } from "./ChartLegend-BdZxV6Ho.js";
import { C as wa, a as Ca, N as La, P as E } from "./chartConstants-Ds00dPgh.js";
import { c as ea } from "./renderActiveShape-Cwe7yij0.js";
function X(n, e) {
  return n.color ? n.color : P(e);
}
function Da({
  period: n = 30,
  mode: e = "access",
  title: h,
  subtitle: c,
  yAxisLabel: N,
  durationSuffix: x
}) {
  const { t: y, i18n: C } = T("common"), [r, w] = b(null), [p, i] = b(!0), [l, v] = b(null);
  q(() => {
    let o = !1;
    return (async () => {
      try {
        i(!0);
        const d = await R.getTrendsByApplication(n);
        o || (w(d), v(null));
      } catch (d) {
        o || v(d instanceof Error ? d.message : "Failed to load trends");
      } finally {
        o || i(!1);
      }
    })(), () => {
      o = !0;
    };
  }, [n]);
  const L = I(() => !r?.dailyData?.length || !r?.applications?.length ? [] : r.dailyData.map((o) => {
    const u = {
      date: new Date(o.date).toLocaleDateString(C.language, {
        day: "2-digit",
        month: "short"
      })
    };
    return r.applications.forEach((d) => {
      u[d.name] = e === "access" ? o.applicationCounts[d.name] ?? 0 : o.applicationDurations?.[d.name] ?? 0;
    }), u;
  }), [r, e, C.language]), m = (r?.applications ?? []).map((o, u) => ({
    id: o.name,
    label: o.name,
    color: X(o, u),
    value: e === "access" ? o.totalAccess.toLocaleString() : `${o.totalDurationMinutes.toLocaleString()} ${x}`
  })), A = !p && !l && (L.length === 0 || m.length === 0);
  return /* @__PURE__ */ a(
    F,
    {
      title: h,
      subtitle: c,
      icon: /* @__PURE__ */ a(U, { className: "w-5 h-5" }),
      height: "md",
      loading: p,
      loadingLabel: y("dashboard.loading"),
      empty: A,
      emptyMessage: y("dashboard.noChartData"),
      emptyHint: y("dashboard.noDataHint"),
      footer: !p && !l && m.length > 0 && /* @__PURE__ */ a(K, { items: m, ariaLabel: h }),
      children: l ? /* @__PURE__ */ a(
        "div",
        {
          role: "alert",
          className: "flex items-center justify-center w-full h-full text-sm",
          style: { color: "var(--error-text)" },
          children: l
        }
      ) : /* @__PURE__ */ a(z, { width: "100%", height: "100%", children: /* @__PURE__ */ s(va, { data: L, margin: wa, children: [
        /* @__PURE__ */ a(ga, { strokeDasharray: "3 3", stroke: "var(--border-color)" }),
        /* @__PURE__ */ a(
          fa,
          {
            dataKey: "date",
            stroke: "var(--text-secondary)",
            style: { fontSize: "11px" },
            tick: { fill: "var(--text-secondary)" }
          }
        ),
        /* @__PURE__ */ a(
          xa,
          {
            stroke: "var(--text-secondary)",
            style: { fontSize: "11px" },
            tick: { fill: "var(--text-secondary)" },
            label: {
              value: N,
              angle: -90,
              position: "insideLeft",
              style: { fill: "var(--text-secondary)", fontSize: "11px" }
            }
          }
        ),
        /* @__PURE__ */ a(ya, { content: /* @__PURE__ */ a(Ca, {}) }),
        (r?.applications ?? []).map((o, u) => {
          const d = X(o, u);
          return /* @__PURE__ */ a(
            Na,
            {
              type: "monotone",
              dataKey: o.name,
              stroke: d,
              strokeWidth: 2,
              dot: { r: 2, fill: d },
              activeDot: { r: 5, fill: d }
            },
            o.name
          );
        })
      ] }) })
    }
  );
}
function Aa(n) {
  if (n < 60) return `${n}s`;
  const e = Math.floor(n / 60), h = n % 60;
  return h > 0 ? `${e}m ${h}s` : `${e}m`;
}
function ka({
  data: n,
  mode: e = "access",
  valueLabel: h,
  usersLabel: c,
  avgLabel: N
}) {
  const { t: x } = T("common");
  if (!n || n.length === 0)
    return /* @__PURE__ */ a(La, { message: x("dashboard.noChartData"), hint: x("dashboard.noDataHint") });
  const y = (r) => e === "access" ? r.accessCount : r.totalDurationMinutes, C = Math.max(...n.map((r) => y(r)), 1);
  return /* @__PURE__ */ a("div", { className: "space-y-3", children: n.map((r, w) => {
    const p = P(w), i = y(r), l = i / C * 100;
    return /* @__PURE__ */ s(
      "article",
      {
        className: "rounded-[var(--radius-card)] bg-[var(--dataviz-surface-elevated)] p-4 hover:shadow-sm transition-shadow border-l-4",
        style: { borderLeftColor: p },
        children: [
          /* @__PURE__ */ s("div", { className: "flex items-center gap-3 mb-2", children: [
            /* @__PURE__ */ s("div", { className: "flex-1 min-w-0", children: [
              /* @__PURE__ */ s("div", { className: "text-xs text-[var(--text-tertiary)] mb-1 font-mono truncate", children: [
                /* @__PURE__ */ a("span", { children: r.applicationName }),
                /* @__PURE__ */ a("span", { className: "mx-1", children: "›" }),
                /* @__PURE__ */ a("span", { children: r.moduleName })
              ] }),
              /* @__PURE__ */ a("h5", { className: "font-semibold text-[var(--text-primary)] truncate", children: r.moduleName })
            ] }),
            /* @__PURE__ */ s("div", { className: "text-right flex-shrink-0", children: [
              /* @__PURE__ */ a("div", { className: "text-xl font-bold tabular-nums", style: { color: p }, children: i.toLocaleString() }),
              /* @__PURE__ */ a("div", { className: "text-xs text-[var(--text-secondary)]", children: h })
            ] })
          ] }),
          /* @__PURE__ */ a("div", { className: "h-2 bg-[var(--bg-primary)] rounded-full overflow-hidden mb-2", children: /* @__PURE__ */ a(
            "div",
            {
              className: "h-full rounded-full transition-all duration-500",
              style: { width: `${l}%`, backgroundColor: p }
            }
          ) }),
          /* @__PURE__ */ s("div", { className: "flex items-center gap-4 text-xs text-[var(--text-secondary)]", children: [
            /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
              /* @__PURE__ */ a(J, { className: "w-3 h-3", "aria-hidden": "true" }),
              /* @__PURE__ */ s("span", { children: [
                r.uniqueUsers,
                " ",
                c
              ] })
            ] }),
            /* @__PURE__ */ s("div", { className: "flex items-center gap-1", children: [
              /* @__PURE__ */ a(j, { className: "w-3 h-3", "aria-hidden": "true" }),
              /* @__PURE__ */ s("span", { children: [
                N,
                ": ",
                Aa(r.avgDuration)
              ] })
            ] })
          ] })
        ]
      },
      r.moduleId
    );
  }) });
}
function Sa({
  data: n,
  title: e,
  subtitle: h,
  valueLabel: c
}) {
  const { t: N } = T("common"), [x, y] = b(0), C = !n || n.length === 0, r = I(
    () => (n ?? []).map((i, l) => ({
      ...i,
      name: i.applicationName,
      value: i.accessCount,
      fill: P(l)
    })),
    [n]
  ), w = I(
    () => ea({
      getLabel: (i) => String(i.applicationName ?? ""),
      getValueText: (i) => `${i.toLocaleString()} ${c}`
    }),
    [c]
  ), p = r.map((i) => ({
    id: i.applicationId,
    label: i.applicationName,
    color: i.fill,
    value: `${i.accessCount.toLocaleString()} ${c}`
  }));
  return /* @__PURE__ */ a(
    F,
    {
      title: e,
      subtitle: h,
      icon: /* @__PURE__ */ a(ca, { className: "w-5 h-5" }),
      height: "lg",
      empty: C,
      emptyMessage: N("dashboard.noChartData"),
      emptyHint: N("dashboard.noDataHint"),
      footer: !C && /* @__PURE__ */ a(
        K,
        {
          items: p,
          activeId: r[x]?.applicationId,
          onHover: (i) => {
            if (!i) return;
            const l = r.findIndex((v) => v.applicationId === i);
            l >= 0 && y(l);
          },
          ariaLabel: e
        }
      ),
      children: /* @__PURE__ */ a(z, { width: "100%", height: "100%", children: /* @__PURE__ */ a(Q, { children: /* @__PURE__ */ a(
        Z,
        {
          activeIndex: x,
          activeShape: w,
          data: r,
          cx: "50%",
          cy: "50%",
          innerRadius: E.inner,
          outerRadius: E.outer,
          dataKey: "value",
          onMouseEnter: (i, l) => y(l),
          isAnimationActive: !1,
          children: r.map((i) => /* @__PURE__ */ a(aa, { fill: i.fill }, i.applicationId))
        }
      ) }) })
    }
  );
}
function $a({
  period: n,
  mode: e = "access",
  title: h,
  subtitle: c,
  valueLabel: N,
  usersLabel: x,
  rootBreadcrumbLabel: y,
  backLabel: C,
  clickToExploreLabel: r
}) {
  const { t: w } = T("common"), [p, i] = b(null), [l, v] = b(!0), [L, m] = b(null), [A, o] = b(0), [u, d] = b(0), [M, g] = b(), $ = Y(async () => {
    try {
      v(!0), m(null);
      const t = await R.getHierarchyData(
        u,
        M,
        n
      );
      i(t), o(0);
    } catch (t) {
      m(t instanceof Error ? t.message : "Failed to load data");
    } finally {
      v(!1);
    }
  }, [u, M, n]);
  q(() => {
    $();
  }, [$]);
  const B = (t) => {
    t.hasChildren && u === 0 && (g(t.id), d(1));
  }, ta = () => {
    u === 1 && (g(void 0), d(0));
  }, D = I(
    () => (p?.items ?? []).map((t, f) => ({
      ...t,
      value: e === "access" ? t.accessCount : t.totalDurationMinutes,
      fill: P(f)
    })),
    [p?.items, e]
  ), ra = I(
    () => ea({
      getLabel: (t) => String(t.name ?? ""),
      getValueText: (t, f) => {
        const k = `${t.toLocaleString()} ${N}`, V = typeof f.uniqueUsers == "number" ? f.uniqueUsers : null;
        return V !== null ? `${k} · ${V} ${x}` : k;
      }
    }),
    [N, x]
  ), ia = D.map((t) => ({
    id: t.id,
    label: t.name,
    color: t.fill,
    value: `${t.value.toLocaleString()} ${N}`
  })), sa = /* @__PURE__ */ s(
    "nav",
    {
      "aria-label": h,
      className: "flex items-center gap-2 text-xs flex-wrap",
      children: [
        /* @__PURE__ */ s(
          "button",
          {
            type: "button",
            onClick: () => {
              d(0), g(void 0);
            },
            className: [
              "inline-flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] transition-colors",
              "hover:bg-[var(--bg-hover)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",
              u === 0 ? "font-semibold text-[var(--dataviz-accent)]" : "text-[var(--text-secondary)]"
            ].join(" "),
            children: [
              /* @__PURE__ */ a(da, { className: "w-3.5 h-3.5", "aria-hidden": "true" }),
              /* @__PURE__ */ a("span", { children: y })
            ]
          }
        ),
        p?.breadcrumb?.map((t) => /* @__PURE__ */ s(na.Fragment, { children: [
          /* @__PURE__ */ a(ha, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]", "aria-hidden": "true" }),
          /* @__PURE__ */ a(
            "span",
            {
              className: "px-2 py-1 font-semibold",
              style: { color: "var(--dataviz-accent)" },
              children: t.name
            }
          )
        ] }, t.id)),
        u > 0 && /* @__PURE__ */ s(
          "button",
          {
            type: "button",
            onClick: ta,
            className: "ml-auto inline-flex items-center gap-1 px-2 py-1 rounded-[var(--radius-button)] bg-[var(--bg-hover)] hover:bg-[var(--bg-active)] transition-colors text-[var(--text-secondary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",
            children: [
              /* @__PURE__ */ a(pa, { className: "w-3.5 h-3.5", "aria-hidden": "true" }),
              /* @__PURE__ */ a("span", { children: C })
            ]
          }
        )
      ]
    }
  ), oa = !l && !L && !p?.items?.length;
  return /* @__PURE__ */ s(
    F,
    {
      title: h,
      subtitle: c,
      icon: /* @__PURE__ */ a(O, { className: "w-5 h-5" }),
      height: "lg",
      actions: sa,
      loading: l,
      loadingLabel: w("dashboard.loading"),
      empty: oa,
      emptyMessage: w("dashboard.noChartData"),
      emptyHint: w("dashboard.noDataHint"),
      footer: !l && !L && D.length > 0 && /* @__PURE__ */ a(
        K,
        {
          items: ia,
          activeId: D[A]?.id,
          onHover: (t) => {
            if (!t) return;
            const f = D.findIndex((k) => k.id === t);
            f >= 0 && o(f);
          },
          onSelect: (t) => {
            const f = D.find((k) => k.id === t);
            f && B(f);
          },
          ariaLabel: h
        }
      ),
      children: [
        L ? /* @__PURE__ */ a(
          "div",
          {
            role: "alert",
            className: "flex items-center justify-center w-full h-full text-sm",
            style: { color: "var(--error-text)" },
            children: L
          }
        ) : /* @__PURE__ */ a(z, { width: "100%", height: "100%", children: /* @__PURE__ */ a(Q, { children: /* @__PURE__ */ a(
          Z,
          {
            activeIndex: A,
            activeShape: ra,
            data: D,
            cx: "50%",
            cy: "50%",
            innerRadius: E.inner,
            outerRadius: E.outer,
            dataKey: "value",
            onMouseEnter: (t, f) => o(f),
            onClick: (t, f) => {
              const k = D[f];
              k && B(k);
            },
            style: { cursor: D[A]?.hasChildren ? "pointer" : "default" },
            isAnimationActive: !1,
            children: D.map((t) => /* @__PURE__ */ a(aa, { fill: t.fill }, t.id))
          }
        ) }) }),
        !l && !L && D[A]?.hasChildren && /* @__PURE__ */ a(
          "p",
          {
            "aria-live": "polite",
            className: "absolute bottom-2 left-1/2 -translate-x-1/2 text-xs",
            style: { color: "var(--text-tertiary)" },
            children: r
          }
        )
      ]
    }
  );
}
const Fa = () => {
  const n = la(), { t: e } = T("admin"), { currentTenant: h } = ba(), [c, N] = b(null), [x, y] = b([]), [C, r] = b(!0), [w, p] = b(!1), [i, l] = b(null), [v, L] = b(30), [m, A] = b("access"), o = Y(async () => {
    try {
      l(null);
      const [g, $] = await Promise.all([
        R.getDashboardStats(v),
        R.getTopModules(5, v)
      ]);
      N(g), y($);
    } catch (g) {
      l(g instanceof Error ? g.message : "Failed to load dashboard");
    } finally {
      r(!1), p(!1);
    }
  }, [v]);
  q(() => {
    o();
  }, [o, h?.id]);
  const u = () => {
    p(!0), o();
  }, d = (g) => g < 60 ? `${g}s` : `${Math.floor(g / 60)}m`;
  if (C)
    return /* @__PURE__ */ a(
      H,
      {
        title: e("dashboard.title", "Dashboard"),
        breadcrumbs: [
          { label: e("header.title"), href: "/administration" },
          { label: e("dashboard.title", "Dashboard") }
        ],
        children: /* @__PURE__ */ a("div", { className: "flex h-96 items-center justify-center", children: /* @__PURE__ */ a(ma, { className: "h-8 w-8 animate-spin text-[var(--color-primary-600)]" }) })
      }
    );
  if (i)
    return /* @__PURE__ */ a(
      H,
      {
        title: e("dashboard.title", "Dashboard"),
        breadcrumbs: [
          { label: e("header.title"), href: "/administration" },
          { label: e("dashboard.title", "Dashboard") }
        ],
        children: /* @__PURE__ */ a("div", { className: "space-y-6", children: /* @__PURE__ */ s("div", { className: "bg-[var(--error-bg)] border border-[var(--error-border)] rounded-[var(--radius-card)] p-4 flex items-center gap-3", children: [
          /* @__PURE__ */ a(ua, { className: "h-5 w-5 text-[var(--error-text)] flex-shrink-0" }),
          /* @__PURE__ */ a("div", { className: "flex-1", children: /* @__PURE__ */ a("p", { className: "text-[var(--error-text)] font-medium", children: i }) }),
          /* @__PURE__ */ a(
            "button",
            {
              onClick: u,
              className: "text-[var(--error-text)] hover:opacity-80",
              children: /* @__PURE__ */ a(_, { className: "h-5 w-5" })
            }
          )
        ] }) })
      }
    );
  const M = /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
    /* @__PURE__ */ s("div", { className: "flex items-center gap-1 rounded-lg border border-[var(--item-color-border)] bg-[var(--bg-secondary)] p-1", children: [
      /* @__PURE__ */ a(
        "button",
        {
          onClick: () => A("access"),
          className: `px-3 py-1.5 text-sm font-medium rounded-md transition-all ${m === "access" ? "bg-[var(--color-primary-600)] text-white shadow-sm" : "text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,
          children: /* @__PURE__ */ s("span", { className: "flex items-center gap-1.5", children: [
            /* @__PURE__ */ a(G, { className: "w-3.5 h-3.5" }),
            e("applications.dashboard.actions.accesses")
          ] })
        }
      ),
      /* @__PURE__ */ a(
        "button",
        {
          onClick: () => A("duration"),
          className: `px-3 py-1.5 text-sm font-medium rounded-md transition-all ${m === "duration" ? "bg-[var(--color-primary-600)] text-white shadow-sm" : "text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]"}`,
          children: /* @__PURE__ */ s("span", { className: "flex items-center gap-1.5", children: [
            /* @__PURE__ */ a(j, { className: "w-3.5 h-3.5" }),
            e("applications.dashboard.actions.duration")
          ] })
        }
      )
    ] }),
    /* @__PURE__ */ s(
      "select",
      {
        value: v,
        onChange: (g) => L(Number(g.target.value)),
        className: "rounded-[var(--radius-input)] border border-[var(--item-color-border)] bg-[var(--bg-secondary)] px-4 py-2 text-[var(--text-primary)] focus:border-[var(--color-primary-600)] focus:outline-none",
        children: [
          /* @__PURE__ */ a("option", { value: 7, children: e("applications.dashboard.actions.period7days") }),
          /* @__PURE__ */ a("option", { value: 30, children: e("applications.dashboard.actions.period30days") }),
          /* @__PURE__ */ a("option", { value: 90, children: e("applications.dashboard.actions.period90days") })
        ]
      }
    ),
    /* @__PURE__ */ s(
      "button",
      {
        onClick: u,
        disabled: w,
        className: "rounded-[var(--radius-button)] border border-[var(--item-color-border)] bg-[var(--bg-secondary)] px-4 py-2 text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] flex items-center gap-2 transition-colors",
        children: [
          /* @__PURE__ */ a(_, { className: `w-4 h-4 ${w ? "animate-spin" : ""}` }),
          e("applications.dashboard.actions.refresh")
        ]
      }
    )
  ] });
  return /* @__PURE__ */ s(
    H,
    {
      title: e("applications.dashboard.title"),
      subtitle: e("applications.dashboard.subtitle"),
      icon: /* @__PURE__ */ a(W, { className: "h-6 w-6" }),
      breadcrumbs: [
        { label: e("header.title"), href: "/administration" },
        { label: e("applications.dashboard.title") }
      ],
      actions: M,
      children: [
        /* @__PURE__ */ s("div", { className: "grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4", children: [
          /* @__PURE__ */ a(
            S,
            {
              title: e("applications.dashboard.kpi.totalApplications"),
              value: c?.totalApplications || 0,
              icon: /* @__PURE__ */ a(W, { className: "h-5 w-5" }),
              accent: "primary"
            }
          ),
          /* @__PURE__ */ a(
            S,
            {
              title: e("applications.dashboard.kpi.activeApplications"),
              value: c?.activeApplications || 0,
              icon: /* @__PURE__ */ a(G, { className: "h-5 w-5" }),
              accent: 5
            }
          ),
          /* @__PURE__ */ a(
            S,
            {
              title: e("applications.dashboard.kpi.totalUsers"),
              value: c?.totalUsers || 0,
              icon: /* @__PURE__ */ a(J, { className: "h-5 w-5" }),
              accent: 2
            }
          ),
          /* @__PURE__ */ a(
            S,
            {
              title: e("applications.dashboard.kpi.activeToday"),
              value: c?.activeUsersToday || 0,
              icon: /* @__PURE__ */ a(U, { className: "h-5 w-5" }),
              accent: 3
            }
          ),
          /* @__PURE__ */ a(
            S,
            {
              title: e("applications.dashboard.kpi.avgSession"),
              value: d(c?.avgSessionDuration || 0),
              icon: /* @__PURE__ */ a(j, { className: "h-5 w-5" }),
              subtitle: e("applications.dashboard.kpi.periodDaysLabel", { count: v })
            }
          ),
          /* @__PURE__ */ a(
            S,
            {
              title: e("applications.dashboard.kpi.growthRate"),
              value: `${c?.growthRate.toFixed(1) || 0}%`,
              icon: /* @__PURE__ */ a(U, { className: "h-5 w-5" }),
              accent: (c?.growthRate ?? 0) >= 0 ? 5 : void 0,
              trend: (c?.growthRate ?? 0) < 0 ? { value: `${Math.abs(c?.growthRate ?? 0).toFixed(1)}%`, direction: "down" } : void 0,
              subtitle: e("applications.dashboard.kpi.vsPreviousPeriod")
            }
          )
        ] }),
        /* @__PURE__ */ s("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-6", children: [
          /* @__PURE__ */ a(
            $a,
            {
              period: v,
              mode: m,
              title: e("applications.dashboard.hierarchy"),
              subtitle: e("applications.dashboard.hierarchySubtitle"),
              valueLabel: e(m === "access" ? "applications.dashboard.accessLabel" : "applications.dashboard.durationLabel"),
              usersLabel: e("applications.dashboard.usersLabel"),
              rootBreadcrumbLabel: e("applications.dashboard.applicationsBreadcrumb"),
              backLabel: e("applications.dashboard.back"),
              clickToExploreLabel: e("applications.dashboard.clickToExplore")
            },
            `hierarchy-${h?.id ?? "global"}`
          ),
          /* @__PURE__ */ a(
            Sa,
            {
              data: c?.mostPopularApps ?? [],
              title: e("applications.dashboard.topApplications"),
              subtitle: e("applications.dashboard.topApplicationsSubtitle"),
              valueLabel: e(m === "access" ? "applications.dashboard.accessLabel" : "applications.dashboard.durationLabel")
            }
          )
        ] }),
        /* @__PURE__ */ a(
          Da,
          {
            period: v,
            mode: m,
            title: e("applications.dashboard.usageTrend"),
            subtitle: e("applications.dashboard.usageTrendSubtitle"),
            yAxisLabel: e(m === "access" ? "applications.dashboard.accessLabel" : "applications.dashboard.durationLabel"),
            durationSuffix: e("applications.dashboard.durationLabel")
          },
          `trends-${h?.id ?? "global"}`
        ),
        /* @__PURE__ */ s("div", { className: "rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-[var(--bg-card)] p-4", children: [
          /* @__PURE__ */ s("h3", { className: "font-semibold mb-4 flex items-center gap-2 text-[var(--text-primary)]", children: [
            /* @__PURE__ */ a(O, { className: "h-5 w-5 text-[var(--info-text)]" }),
            e(m === "access" ? "applications.dashboard.modulesPopular" : "applications.dashboard.modulesUsed"),
            /* @__PURE__ */ a("span", { className: "text-xs font-normal text-[var(--text-secondary)] ml-2", children: e("applications.dashboard.modulesHint") })
          ] }),
          (x?.length ?? 0) > 0 ? /* @__PURE__ */ a(
            ka,
            {
              data: x,
              mode: m,
              valueLabel: e(m === "access" ? "applications.dashboard.accessLabel" : "applications.dashboard.durationLabel"),
              usersLabel: e("applications.dashboard.usersLabel"),
              avgLabel: e("applications.dashboard.usageTrend", "Avg")
            }
          ) : /* @__PURE__ */ a("div", { className: "text-center py-8 text-[var(--text-secondary)]", children: e("applications.dashboard.noModuleData") })
        ] }),
        /* @__PURE__ */ a("div", { className: "rounded-[var(--radius-card)] border border-[var(--item-color-border)] bg-gradient-to-r from-[var(--color-primary-600)]/10 to-[var(--color-accent-500)]/10 p-6", children: /* @__PURE__ */ s("div", { className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between", children: [
          /* @__PURE__ */ s("div", { children: [
            /* @__PURE__ */ a("h3", { className: "font-bold text-[var(--text-primary)]", children: "Explorer toutes les Applications" }),
            /* @__PURE__ */ a("p", { className: "mt-1 text-sm text-[var(--text-secondary)]", children: "Voir les analyses détaillées pour chaque application et gérer les permissions" })
          ] }),
          /* @__PURE__ */ a(
            "button",
            {
              onClick: () => n("/administration/applications/list"),
              className: "whitespace-nowrap rounded-[var(--radius-button)] bg-[var(--color-primary-600)] px-4 py-2 font-medium text-white transition-all hover:shadow-md",
              children: "Voir les Applications"
            }
          )
        ] }) })
      ]
    }
  );
};
export {
  Fa as ApplicationsDashboardPage
};
//# sourceMappingURL=ApplicationsDashboardPage-ClqsCdYK.js.map
