import { jsx as t, jsxs as r, Fragment as de } from "react/jsx-runtime";
import { useState as o, useCallback as M, useEffect as V, useRef as me } from "react";
import { useTranslation as z } from "react-i18next";
import { x as pe, P as _, Z as te, a as Ce, v as re, E as Re } from "./index-CeEMms9z.js";
import { Loader2 as E, AlertTriangle as G, AlertCircle as ve, CheckCircle as D, XCircle as se, RefreshCw as $, Play as Ee, Cloud as X, Database as ke, Calendar as he, Link2 as Ae, Building2 as Y, Users as P, Clock as be, X as ee, Search as Ie, Filter as ge, LayoutGrid as De, List as Ge, Shield as L, Plus as ue, ChevronUp as Te, ChevronDown as Fe, GitBranch as H, Mail as Pe, ExternalLink as ae, Check as Me, Copy as Ue, Key as Le, EyeOff as $e, Eye as je, TestTube as Ke, Save as xe, Layers as Oe, GitMerge as He, Settings as Ve } from "lucide-react";
import { e as N, C as ze, R as _e } from "./ResolutionModal-C8B71UhR.js";
import { useNavigate as ye, Link as We } from "react-router-dom";
function Be({
  resourceType: e,
  icon: v,
  status: w,
  lastFullSyncAt: x,
  lastDeltaSyncAt: h,
  totalItemsSynced: S,
  pendingConflicts: y,
  lastError: b,
  syncing: f,
  canSync: s,
  onSync: d,
  formatDate: u,
  t: n
}) {
  const m = (() => {
    switch (w) {
      case "Success":
        return {
          icon: D,
          color: "text-[var(--success-text)]",
          bg: "bg-[var(--success-bg)]",
          label: n("common:success")
        };
      case "Failed":
        return {
          icon: se,
          color: "text-[var(--error-text)]",
          bg: "bg-[var(--error-bg)]",
          label: n("common:failed")
        };
      case "Running":
        return {
          icon: E,
          color: "text-[var(--color-accent-500)]",
          bg: "bg-[var(--color-accent-100)]",
          label: n("common:running"),
          animate: !0
        };
      default:
        return {
          icon: be,
          color: "text-[var(--text-tertiary)]",
          bg: "bg-[var(--bg-tertiary)]",
          label: n("common:pending")
        };
    }
  })(), c = m.icon;
  return /* @__PURE__ */ r("div", { className: "h-full flex flex-col rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-card)] overflow-hidden shadow-sm hover:shadow-md transition-shadow", children: [
    /* @__PURE__ */ t("div", { className: "px-4 py-3 bg-gradient-to-r from-[var(--color-accent-500)]/10 to-[var(--color-accent-600)]/5 border-b border-[var(--border-color)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-lg bg-[var(--color-accent-500)]/20", children: /* @__PURE__ */ t(v, { className: "w-5 h-5 text-[var(--color-accent-600)]" }) }),
        /* @__PURE__ */ t("h3", { className: "font-semibold text-[var(--text-primary)]", children: n(`entra:resourceTypes.${e.toLowerCase()}`) })
      ] }),
      /* @__PURE__ */ r("div", { className: `inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium ${m.bg} ${m.color}`, children: [
        /* @__PURE__ */ t(c, { className: `w-3.5 h-3.5 ${m.animate ? "animate-spin" : ""}` }),
        m.label
      ] })
    ] }) }),
    /* @__PURE__ */ r("div", { className: "flex-1 flex flex-col p-4", children: [
      /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-3 mb-4", children: [
        /* @__PURE__ */ r("div", { className: "text-center p-3 rounded-lg bg-[var(--bg-secondary)]", children: [
          /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1 mb-1", children: /* @__PURE__ */ t(ke, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]" }) }),
          /* @__PURE__ */ t("p", { className: "text-xl font-bold text-[var(--text-primary)]", children: S.toLocaleString() }),
          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: n("entra:dashboard.itemsSynced") })
        ] }),
        /* @__PURE__ */ r("div", { className: "text-center p-3 rounded-lg bg-[var(--bg-secondary)]", children: [
          /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1 mb-1", children: /* @__PURE__ */ t(he, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]" }) }),
          /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", title: u(x), children: x ? new Date(x).toLocaleDateString("fr-FR", { day: "numeric", month: "short" }) : "-" }),
          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: n("entra:dashboard.lastFullSync") })
        ] }),
        /* @__PURE__ */ r("div", { className: "text-center p-3 rounded-lg bg-[var(--bg-secondary)]", children: [
          /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1 mb-1", children: /* @__PURE__ */ t($, { className: "w-3.5 h-3.5 text-[var(--text-tertiary)]" }) }),
          /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", title: u(h), children: h ? new Date(h).toLocaleDateString("fr-FR", { day: "numeric", month: "short" }) : "-" }),
          /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: n("entra:dashboard.lastDeltaSync") })
        ] })
      ] }),
      y > 0 && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-3 mb-4 rounded-lg bg-[var(--warning-bg)] border border-[var(--warning-border)]", children: [
        /* @__PURE__ */ t(ve, { className: "w-4 h-4 text-[var(--warning-text)] flex-shrink-0" }),
        /* @__PURE__ */ r("span", { className: "text-sm text-[var(--warning-text)] font-medium", children: [
          y,
          " ",
          n("entra:dashboard.pendingConflicts")
        ] })
      ] }),
      b && /* @__PURE__ */ t("div", { className: "p-3 mb-4 rounded-lg bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ t("p", { className: "text-xs text-[var(--error-text)] line-clamp-2", children: b }) }),
      /* @__PURE__ */ t(
        te,
        {
          content: s ? void 0 : n("entra:dashboard.noSyncPermission"),
          position: "top",
          variant: "error",
          disabled: s,
          children: /* @__PURE__ */ r(
            "button",
            {
              onClick: d,
              disabled: f || !s,
              className: "mt-auto w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors shadow-sm",
              children: [
                f ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t($, { className: "w-4 h-4" }),
                n("entra:dashboard.syncNow")
              ]
            }
          )
        }
      )
    ] })
  ] });
}
function ot() {
  const { t: e } = z(["entra", "common"]), { hasPermission: v } = pe(), [w, x] = o(!0), [h, S] = o(!1), [y, b] = o([]), [f, s] = o(null), [d, u] = o(null), [n, p] = o(null), m = v("administration.entra.execute"), c = M(async () => {
    try {
      s(null);
      const l = await N.dashboard.getSyncStatus();
      b(Array.isArray(l) ? l : []);
    } catch (l) {
      console.error("Failed to load Entra dashboard data:", l), b([]);
      const g = l;
      g.response?.status === 401 ? s(e("common:errors.sessionExpired")) : g.response?.status === 403 ? s(e("common:errors.noPermission")) : s(e("entra:dashboard.loadError"));
    } finally {
      x(!1), S(!1);
    }
  }, [e]);
  V(() => {
    c();
  }, [c]);
  const C = () => {
    S(!0), c();
  }, A = async (l) => {
    u(l), p(null);
    try {
      let g;
      switch (l) {
        case "users":
          g = await N.sync.syncUsers();
          break;
        case "groups":
          g = await N.sync.syncGroups();
          break;
        case "memberships":
          g = await N.sync.syncMemberships();
          break;
        default:
          g = await N.sync.syncAll();
      }
      p(g), await c();
    } catch (g) {
      console.error("Sync failed:", g);
      const F = g;
      F.response?.status === 403 ? s(e("entra:dashboard.syncPermissionDenied")) : F.response?.status === 401 ? s(e("common:errors.sessionExpired")) : s(e("entra:dashboard.syncError"));
    } finally {
      u(null);
    }
  }, T = async () => {
    if (confirm(e("entra:dashboard.forceFullSyncConfirm"))) {
      u("force");
      try {
        await N.sync.forceFullSync(), await c();
      } catch (l) {
        console.error("Force full sync failed:", l);
        const g = l;
        g.response?.status === 403 ? s(e("entra:dashboard.syncPermissionDenied")) : g.response?.status === 401 ? s(e("common:errors.sessionExpired")) : s(e("entra:dashboard.syncError"));
      } finally {
        u(null);
      }
    }
  }, I = (l) => l ? new Intl.DateTimeFormat("fr-FR", {
    dateStyle: "medium",
    timeStyle: "short"
  }).format(new Date(l)) : e("common:never"), U = (l) => {
    switch (l) {
      case "Users":
        return P;
      case "Groups":
        return Y;
      case "Memberships":
        return Ae;
      default:
        return X;
    }
  };
  if (w)
    return /* @__PURE__ */ t("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) });
  const k = y.reduce((l, g) => l + g.pendingConflicts, 0);
  return /* @__PURE__ */ t(
    _,
    {
      title: e("entra:dashboard.title"),
      subtitle: e("entra:dashboard.subtitle"),
      icon: /* @__PURE__ */ t(X, { className: "w-6 h-6" }),
      breadcrumbs: [
        { label: e("header.title"), href: "/administration" },
        { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
        { label: e("entra:dashboard.title") }
      ],
      actions: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
        /* @__PURE__ */ r(
          "button",
          {
            onClick: C,
            disabled: h,
            className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] disabled:opacity-50 transition-colors",
            children: [
              /* @__PURE__ */ t($, { className: `w-4 h-4 ${h ? "animate-spin" : ""}` }),
              e("common:refresh")
            ]
          }
        ),
        /* @__PURE__ */ t(
          te,
          {
            content: m ? void 0 : e("entra:dashboard.noSyncPermission"),
            position: "bottom",
            variant: "error",
            disabled: m,
            children: /* @__PURE__ */ r(
              "button",
              {
                onClick: () => A("all"),
                disabled: d !== null || !m,
                className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
                children: [
                  d === "all" ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(Ee, { className: "w-4 h-4" }),
                  e("entra:dashboard.syncAll")
                ]
              }
            )
          }
        )
      ] }),
      children: /* @__PURE__ */ r("div", { className: "space-y-6", children: [
        f && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
          /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
          /* @__PURE__ */ t("span", { children: f })
        ] }) }),
        k > 0 && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--warning-bg)] border border-[var(--warning-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--warning-text)]", children: [
          /* @__PURE__ */ t(ve, { className: "w-5 h-5" }),
          /* @__PURE__ */ t("span", { children: e("entra:dashboard.conflictsWarning", { count: k }) })
        ] }) }),
        n && /* @__PURE__ */ r("div", { className: `p-4 rounded-[var(--radius-card)] border ${n.success ? "bg-[var(--success-bg)] border-[var(--success-border)]" : "bg-[var(--error-bg)] border-[var(--error-border)]"}`, children: [
          /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
            /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
              n.success ? /* @__PURE__ */ t(D, { className: "w-5 h-5 text-[var(--success-text)]" }) : /* @__PURE__ */ t(se, { className: "w-5 h-5 text-[var(--error-text)]" }),
              /* @__PURE__ */ t("span", { className: n.success ? "text-[var(--success-text)]" : "text-[var(--error-text)]", children: n.success ? e("entra:dashboard.syncSuccess") : e("entra:dashboard.syncFailed") })
            ] }),
            /* @__PURE__ */ t("div", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:dashboard.syncStats", {
              created: n.created,
              updated: n.updated,
              deleted: n.deleted
            }) })
          ] }),
          n.errorMessage && /* @__PURE__ */ t("p", { className: "mt-2 text-sm text-[var(--error-text)]", children: n.errorMessage })
        ] }),
        /* @__PURE__ */ t("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-6", children: y.map((l) => /* @__PURE__ */ t(
          Be,
          {
            resourceType: l.resourceType,
            icon: U(l.resourceType),
            status: l.status,
            lastFullSyncAt: l.lastFullSyncAt,
            lastDeltaSyncAt: l.lastDeltaSyncAt,
            totalItemsSynced: l.totalItemsSynced,
            pendingConflicts: l.pendingConflicts,
            lastError: l.lastError,
            syncing: d === l.resourceType.toLowerCase(),
            canSync: m,
            onSync: () => A(l.resourceType.toLowerCase()),
            formatDate: I,
            t: e
          },
          l.resourceType
        )) }),
        /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-secondary)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
          /* @__PURE__ */ r("div", { children: [
            /* @__PURE__ */ t("h3", { className: "font-semibold text-[var(--text-primary)]", children: e("entra:dashboard.forceFullSync") }),
            /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)]", children: e("entra:dashboard.forceFullSyncDescription") })
          ] }),
          /* @__PURE__ */ t(
            te,
            {
              content: m ? void 0 : e("entra:dashboard.noSyncPermission"),
              position: "left",
              variant: "error",
              disabled: m,
              children: /* @__PURE__ */ r(
                "button",
                {
                  onClick: T,
                  disabled: d !== null || !m,
                  className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--warning-border)] bg-[var(--warning-bg)] text-[var(--warning-text)] hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
                  children: [
                    d === "force" ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(G, { className: "w-4 h-4" }),
                    e("entra:dashboard.forceFullSync")
                  ]
                }
              )
            }
          )
        ] }) })
      ] })
    }
  );
}
const Qe = (e) => e.parentGroupName ? /* @__PURE__ */ r("span", { className: "flex items-center gap-1 text-xs", children: [
  /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
  e.parentGroupName
] }) : e.childGroupCount > 0 ? /* @__PURE__ */ r("span", { className: "flex items-center gap-1 text-xs text-[var(--text-tertiary)]", children: [
  e.childGroupCount,
  " child groups"
] }) : /* @__PURE__ */ t("span", { className: "text-xs text-[var(--text-tertiary)]", children: "-" });
function ct() {
  const { t: e } = z(["entra", "admin", "common"]), { hasPermission: v } = pe(), { currentTenant: w, isGlobalView: x } = Ce(), h = ye(), [S, y] = o(!0), [b, f] = o([]), [s, d] = o([]), [u, n] = o(null), [p, m] = o(""), [c, C] = o(null), [A, T] = o(!1), [I, U] = o(null), [k, l] = o({}), [g, F] = o(null), [W, ne] = o("cards"), [j, fe] = o("all"), [ie, oe] = o(!1), B = v("administration.entra.assign"), Z = M(async () => {
    try {
      n(null);
      const [a, i] = await Promise.all([
        N.groups.getAll(),
        re.roles.getAssignable()
      ]);
      f(Array.isArray(a) ? a : []), d(Array.isArray(i) ? i : []);
    } catch (a) {
      console.error("Failed to load Entra groups:", a), f([]), d([]);
      const i = a;
      i.response?.status === 401 ? n(e("common:errors.sessionExpired")) : i.response?.status === 403 ? n(e("common:errors.noPermission")) : i.response?.data?.code === "TENANT_REQUIRED" ? n(e("entra:groups.tenantRequired")) : n(e("entra:groups.loadError"));
    } finally {
      y(!1);
    }
  }, [e]);
  V(() => {
    Z();
  }, [Z, w?.id, x]);
  const Ne = async (a) => {
    if (k[a]) {
      U(I === a ? null : a);
      return;
    }
    F(a);
    try {
      const i = await N.groups.getMembers(a);
      l((R) => ({ ...R, [a]: i })), U(a);
    } catch (i) {
      console.error("Failed to load members:", i), n(e("entra:groups.loadMembersError"));
    } finally {
      F(null);
    }
  }, ce = M(async () => {
    const [a, i] = await Promise.all([
      N.groups.getAll(),
      re.roles.getAssignable()
    ]), R = Array.isArray(a) ? a : [];
    return f(R), d(Array.isArray(i) ? i : []), R;
  }, []), we = async (a, i = !0) => {
    if (c) {
      oe(!0);
      try {
        await N.groups.assignRole(c.id, { roleId: a, isInheritable: i });
        const O = (await ce()).find((J) => J.id === c.id);
        O && C(O);
      } catch (R) {
        console.error("Failed to assign role:", R), n(e("entra:groups.assignError"));
      } finally {
        oe(!1);
      }
    }
  }, Se = async (a, i) => {
    if (confirm(e("entra:groups.removeRoleConfirm")))
      try {
        if (await N.groups.removeRole(a, i), await ce(), c?.id === a) {
          const O = (await N.groups.getAll()).find((J) => J.id === a);
          O && C(O);
        }
      } catch (R) {
        console.error("Failed to remove role:", R), n(e("entra:groups.removeError"));
      }
  }, K = b.filter((a) => {
    const i = a.displayName.toLowerCase().includes(p.toLowerCase()) || a.description?.toLowerCase().includes(p.toLowerCase()), R = j === "all" || j === "security" && a.isSecurityGroup || j === "distribution" && !a.isSecurityGroup;
    return i && R;
  }), le = (a) => a ? new Intl.DateTimeFormat("fr-FR", {
    dateStyle: "medium",
    timeStyle: "short"
  }).format(new Date(a)) : "-";
  return S ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) }) : /* @__PURE__ */ t(
    _,
    {
      title: e("entra:groups.title"),
      subtitle: e("entra:groups.subtitle", { count: b.length }),
      icon: /* @__PURE__ */ t(X, { className: "w-6 h-6" }),
      breadcrumbs: [
        { label: e("header.title"), href: "/administration" },
        { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
        { label: e("entra:groups.title") }
      ],
      actions: /* @__PURE__ */ r(
        "button",
        {
          onClick: Z,
          className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] transition-colors",
          children: [
            /* @__PURE__ */ t($, { className: "w-4 h-4" }),
            e("common:refresh")
          ]
        }
      ),
      children: /* @__PURE__ */ r("div", { className: "space-y-6", children: [
        /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--info-bg)] border border-[var(--info-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-3", children: [
          /* @__PURE__ */ t(X, { className: "w-5 h-5 text-[var(--info-text)] flex-shrink-0 mt-0.5" }),
          /* @__PURE__ */ r("div", { children: [
            /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-primary)]", children: e("entra:groups.syncedInfo") }),
            /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-secondary)] mt-1", children: e("entra:groups.syncedInfoDescription") })
          ] })
        ] }) }),
        u && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
          /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
          /* @__PURE__ */ t("span", { children: u }),
          /* @__PURE__ */ t(
            "button",
            {
              onClick: () => n(null),
              className: "ml-auto p-1 hover:bg-[var(--error-text)]/10 rounded",
              children: /* @__PURE__ */ t(ee, { className: "w-4 h-4" })
            }
          )
        ] }) }),
        /* @__PURE__ */ r("div", { className: "flex flex-col sm:flex-row gap-4", children: [
          /* @__PURE__ */ r("div", { className: "relative flex-1", children: [
            /* @__PURE__ */ t(Ie, { className: "absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-[var(--text-tertiary)]" }),
            /* @__PURE__ */ t(
              "input",
              {
                type: "text",
                placeholder: e("entra:groups.searchPlaceholder"),
                value: p,
                onChange: (a) => m(a.target.value),
                className: "w-full pl-10 pr-4 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]"
              }
            )
          ] }),
          /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ t(ge, { className: "w-4 h-4 text-[var(--text-tertiary)]" }),
            /* @__PURE__ */ r(
              "select",
              {
                value: j,
                onChange: (a) => fe(a.target.value),
                className: "px-3 py-2 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-primary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)]",
                children: [
                  /* @__PURE__ */ t("option", { value: "all", children: e("admin:groups.allTypes") }),
                  /* @__PURE__ */ t("option", { value: "security", children: e("admin:groups.securityGroup") }),
                  /* @__PURE__ */ t("option", { value: "distribution", children: e("admin:groups.distributionGroup") })
                ]
              }
            )
          ] }),
          /* @__PURE__ */ r("div", { className: "flex items-center gap-1 p-1 rounded-[var(--radius-button)] bg-[var(--bg-secondary)] border border-[var(--border-color)]", children: [
            /* @__PURE__ */ t(
              "button",
              {
                onClick: () => ne("cards"),
                className: `p-2 rounded-[var(--radius-button)] transition-colors ${W === "cards" ? "bg-[var(--color-accent-500)] text-white" : "text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,
                title: e("admin:groups.cardView"),
                children: /* @__PURE__ */ t(De, { className: "w-4 h-4" })
              }
            ),
            /* @__PURE__ */ t(
              "button",
              {
                onClick: () => ne("table"),
                className: `p-2 rounded-[var(--radius-button)] transition-colors ${W === "table" ? "bg-[var(--color-accent-500)] text-white" : "text-[var(--text-tertiary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-hover)]"}`,
                title: e("admin:groups.tableView"),
                children: /* @__PURE__ */ t(Ge, { className: "w-4 h-4" })
              }
            )
          ] })
        ] }),
        K.length === 0 && /* @__PURE__ */ t("div", { className: "text-center py-12 text-[var(--text-secondary)]", children: e(p || j !== "all" ? "admin:groups.noResults" : "entra:groups.noGroups") }),
        K.length > 0 && W === "table" && /* Table View */
        /* @__PURE__ */ t("div", { className: "rounded-[var(--radius-card)] border border-[var(--border-color)] overflow-hidden", children: /* @__PURE__ */ r("table", { className: "w-full", children: [
          /* @__PURE__ */ t("thead", { className: "bg-[var(--bg-secondary)]", children: /* @__PURE__ */ r("tr", { children: [
            /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("admin:groups.groupName") }),
            /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("common:type") }),
            /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("admin:groups.members") }),
            /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("entra:groups.hierarchy") }),
            /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("admin:groups.assignedRoles") }),
            /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)]", children: e("entra:groups.lastSynced") }),
            B && !x && /* @__PURE__ */ t("th", { className: "px-4 py-3 text-right text-sm font-medium text-[var(--text-secondary)]", children: e("common:actionsColumn") })
          ] }) }),
          /* @__PURE__ */ t("tbody", { className: "divide-y divide-[var(--border-color)]", children: K.map((a) => /* @__PURE__ */ r(
            "tr",
            {
              className: "hover:bg-[var(--bg-hover)] cursor-pointer",
              onClick: () => h(`/administration/users/groups/${a.id}`),
              children: [
                /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
                  /* @__PURE__ */ t("div", { className: `w-8 h-8 rounded-full flex items-center justify-center ${a.isSecurityGroup, "bg-[var(--info-bg)] text-[var(--info-text)]"}`, children: a.isSecurityGroup ? /* @__PURE__ */ t(L, { className: "w-4 h-4" }) : /* @__PURE__ */ t(Y, { className: "w-4 h-4" }) }),
                  /* @__PURE__ */ r("div", { children: [
                    /* @__PURE__ */ t("span", { className: "font-medium text-[var(--text-primary)]", children: a.displayName }),
                    a.description && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] truncate max-w-xs", children: a.description })
                  ] })
                ] }) }),
                /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ t("span", { className: `px-2 py-1 text-xs rounded-[var(--radius-badge)] ${a.isSecurityGroup, "bg-[var(--info-bg)] text-[var(--info-text)]"}`, children: a.isSecurityGroup ? e("admin:groups.securityGroup") : e("admin:groups.distributionGroup") }) }),
                /* @__PURE__ */ t("td", { className: "px-4 py-3 text-sm text-[var(--text-secondary)]", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
                  /* @__PURE__ */ t(P, { className: "w-4 h-4" }),
                  a.memberCount
                ] }) }),
                /* @__PURE__ */ t("td", { className: "px-4 py-3 text-sm text-[var(--text-secondary)]", children: Qe(a) }),
                /* @__PURE__ */ t("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1", children: [
                  a.assignedRoles.slice(0, 2).map((i) => /* @__PURE__ */ t(
                    "span",
                    {
                      className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--color-accent-500)]/10 text-[var(--color-accent-500)]",
                      children: i.roleName
                    },
                    i.roleId
                  )),
                  a.assignedRoles.length > 2 && /* @__PURE__ */ r("span", { className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]", children: [
                    "+",
                    a.assignedRoles.length - 2
                  ] }),
                  a.inheritedRoles.length > 0 && /* @__PURE__ */ r("span", { className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--success-bg)] text-[var(--success-text)]", title: e("entra:groups.inheritedRoles"), children: [
                    "+",
                    a.inheritedRoles.length,
                    " ",
                    e("entra:groups.inherited")
                  ] })
                ] }) }),
                /* @__PURE__ */ t("td", { className: "px-4 py-3 text-xs text-[var(--text-tertiary)]", children: le(a.lastSyncedAt) }),
                B && !x && /* @__PURE__ */ t("td", { className: "px-4 py-3 text-right", onClick: (i) => i.stopPropagation(), children: /* @__PURE__ */ t(
                  "button",
                  {
                    onClick: () => {
                      C(a), T(!0);
                    },
                    className: "p-2 rounded-[var(--radius-button)] text-[var(--text-tertiary)] hover:text-[var(--color-accent-500)] hover:bg-[var(--bg-hover)] transition-colors",
                    title: e("admin:groups.assignRole"),
                    children: /* @__PURE__ */ t(ue, { className: "w-4 h-4" })
                  }
                ) })
              ]
            },
            a.id
          )) })
        ] }) }),
        K.length > 0 && W !== "table" && /* Cards View */
        /* @__PURE__ */ t("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-4", children: K.map((a) => /* @__PURE__ */ r(
          "button",
          {
            type: "button",
            className: "rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-secondary)] overflow-hidden cursor-pointer hover:border-[var(--color-accent-500)] transition-colors text-left",
            onClick: () => h(`/administration/users/groups/${a.id}`),
            children: [
              /* @__PURE__ */ r("div", { className: "p-4", children: [
                /* @__PURE__ */ r("div", { className: "flex items-start justify-between gap-4", children: [
                  /* @__PURE__ */ r("div", { className: "flex items-start gap-3 min-w-0", children: [
                    /* @__PURE__ */ t("div", { className: `p-2.5 rounded-[var(--radius-button)] flex-shrink-0 ${a.isSecurityGroup, "bg-[var(--info-bg)] text-[var(--info-text)]"}`, children: a.isSecurityGroup ? /* @__PURE__ */ t(L, { className: "w-5 h-5" }) : /* @__PURE__ */ t(Y, { className: "w-5 h-5" }) }),
                    /* @__PURE__ */ r("div", { className: "min-w-0", children: [
                      /* @__PURE__ */ r("div", { className: "flex items-center gap-2 flex-wrap", children: [
                        /* @__PURE__ */ t("span", { className: "font-semibold text-[var(--text-primary)] truncate", children: a.displayName }),
                        /* @__PURE__ */ t("span", { className: `px-2 py-0.5 text-xs rounded-[var(--radius-badge)] ${a.isSecurityGroup, "bg-[var(--info-bg)] text-[var(--info-text)] border border-[var(--info-border)]"}`, children: a.isSecurityGroup ? e("admin:groups.securityGroup") : e("admin:groups.distributionGroup") }),
                        !a.isActive && /* @__PURE__ */ t("span", { className: "px-2 py-0.5 text-xs rounded-[var(--radius-badge)] bg-[var(--warning-bg)] text-[var(--warning-text)] border border-[var(--warning-border)]", children: e("common:inactive") })
                      ] }),
                      a.description && /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)] mt-1 line-clamp-2", children: a.description }),
                      /* @__PURE__ */ r("div", { className: "flex items-center gap-4 mt-2 text-sm text-[var(--text-tertiary)] flex-wrap", children: [
                        /* @__PURE__ */ r(
                          "button",
                          {
                            onClick: (i) => {
                              i.stopPropagation(), Ne(a.id);
                            },
                            className: "flex items-center gap-1 hover:text-[var(--color-accent-500)] transition-colors",
                            children: [
                              /* @__PURE__ */ t(P, { className: "w-4 h-4" }),
                              e("admin:groups.memberCount", { count: a.memberCount }),
                              g === a.id && /* @__PURE__ */ t(E, { className: "w-3 h-3 animate-spin ml-1" }),
                              g !== a.id && I === a.id && /* @__PURE__ */ t(Te, { className: "w-3 h-3 ml-1" }),
                              g !== a.id && I !== a.id && /* @__PURE__ */ t(Fe, { className: "w-3 h-3 ml-1" })
                            ]
                          }
                        ),
                        a.childGroupCount > 0 && /* @__PURE__ */ r("span", { className: "flex items-center gap-1 text-xs", children: [
                          /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
                          a.childGroupCount,
                          " ",
                          e("entra:groups.childGroups")
                        ] })
                      ] }),
                      a.parentGroupName && /* @__PURE__ */ r("p", { className: "text-xs text-[var(--text-tertiary)] mt-1 flex items-center gap-1", children: [
                        /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
                        e("entra:groups.parentGroup"),
                        ": ",
                        a.parentGroupName
                      ] }),
                      /* @__PURE__ */ r("p", { className: "text-xs text-[var(--text-tertiary)] mt-1", children: [
                        e("entra:groups.lastSynced"),
                        ": ",
                        le(a.lastSyncedAt)
                      ] })
                    ] })
                  ] }),
                  B && !x && /* @__PURE__ */ r(
                    "button",
                    {
                      onClick: (i) => {
                        i.stopPropagation(), C(a), T(!0);
                      },
                      className: "inline-flex items-center gap-1 px-3 py-1.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] transition-colors flex-shrink-0",
                      children: [
                        /* @__PURE__ */ t(ue, { className: "w-4 h-4" }),
                        e("admin:groups.assignRole")
                      ]
                    }
                  )
                ] }),
                (a.assignedRoles.length > 0 || a.inheritedRoles.length > 0) && /* @__PURE__ */ r("div", { className: "mt-4 pt-4 border-t border-[var(--border-color)]", children: [
                  a.assignedRoles.length > 0 && /* @__PURE__ */ r(de, { children: [
                    /* @__PURE__ */ t("h4", { className: "text-sm font-medium text-[var(--text-primary)] mb-2", children: e("admin:groups.assignedRoles") }),
                    /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2 mb-3", children: a.assignedRoles.map((i) => /* @__PURE__ */ r(
                      "div",
                      {
                        className: "inline-flex items-center gap-2 px-3 py-1.5 rounded-[var(--radius-badge)] bg-[var(--bg-primary)] border border-[var(--border-color)] group",
                        children: [
                          /* @__PURE__ */ t(L, { className: "w-4 h-4 text-[var(--color-accent-500)]" }),
                          /* @__PURE__ */ t("span", { className: "text-sm text-[var(--text-primary)]", children: i.roleName }),
                          i.isInheritable && /* @__PURE__ */ t("span", { className: "text-xs text-[var(--success-text)]", title: e("entra:groups.inheritableRole"), children: "↓" }),
                          B && /* @__PURE__ */ t(
                            "button",
                            {
                              onClick: (R) => {
                                R.stopPropagation(), Se(a.id, i.roleId);
                              },
                              className: "ml-1 p-0.5 rounded opacity-0 group-hover:opacity-100 hover:bg-[var(--error-bg)] text-[var(--text-tertiary)] hover:text-[var(--error-text)] transition-all",
                              title: e("common:remove"),
                              children: /* @__PURE__ */ t(ee, { className: "w-3 h-3" })
                            }
                          )
                        ]
                      },
                      i.roleId
                    )) })
                  ] }),
                  a.inheritedRoles.length > 0 && /* @__PURE__ */ r(de, { children: [
                    /* @__PURE__ */ r("h4", { className: "text-xs font-medium text-[var(--text-tertiary)] mb-2 flex items-center gap-1", children: [
                      /* @__PURE__ */ t(H, { className: "w-3 h-3" }),
                      e("entra:groups.inheritedRoles")
                    ] }),
                    /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: a.inheritedRoles.map((i) => /* @__PURE__ */ r(
                      "div",
                      {
                        className: "inline-flex items-center gap-2 px-2 py-1 rounded-[var(--radius-badge)] bg-[var(--success-bg)]/30 border border-[var(--success-border)]",
                        title: `${e("entra:groups.inheritedFrom")} ${i.sourceGroupName}`,
                        children: [
                          /* @__PURE__ */ t(L, { className: "w-3 h-3 text-[var(--success-text)]" }),
                          /* @__PURE__ */ t("span", { className: "text-xs text-[var(--success-text)]", children: i.roleName }),
                          /* @__PURE__ */ r("span", { className: "text-xs text-[var(--success-text)]/60", children: [
                            "← ",
                            i.sourceGroupName
                          ] })
                        ]
                      },
                      `${i.roleId}-${i.sourceGroupId}`
                    )) })
                  ] })
                ] })
              ] }),
              I === a.id && k[a.id] && /* @__PURE__ */ t("div", { className: "border-t border-[var(--border-color)] bg-[var(--bg-primary)]", onClick: (i) => i.stopPropagation(), onKeyDown: (i) => i.stopPropagation(), role: "presentation", children: /* @__PURE__ */ r("div", { className: "p-4", children: [
                /* @__PURE__ */ r("h4", { className: "text-sm font-medium text-[var(--text-primary)] mb-3 flex items-center gap-2", children: [
                  /* @__PURE__ */ t(P, { className: "w-4 h-4" }),
                  e("admin:groups.members"),
                  " (",
                  k[a.id].length,
                  ")"
                ] }),
                k[a.id].length === 0 ? /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-tertiary)]", children: e("admin:groups.noMembers") }) : /* @__PURE__ */ t("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-2 max-h-64 overflow-y-auto", children: k[a.id].slice(0, 10).map((i) => /* @__PURE__ */ r(
                  We,
                  {
                    to: `/administration/users/${i.userId}`,
                    className: "flex items-center gap-3 p-2 rounded-[var(--radius-button)] hover:bg-[var(--bg-hover)] transition-colors",
                    children: [
                      /* @__PURE__ */ t("div", { className: "w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium bg-[var(--color-accent-500)]/10 text-[var(--color-accent-500)]", children: i.fullName.charAt(0).toUpperCase() }),
                      /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: [
                        /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", children: i.fullName }),
                        /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] truncate", children: i.email })
                      ] }),
                      !i.isDirect && i.sourceGroupName && /* @__PURE__ */ t("span", { className: "text-xs text-[var(--text-tertiary)] flex items-center gap-1", title: e("entra:groups.memberFromChildGroup"), children: /* @__PURE__ */ t(H, { className: "w-3 h-3" }) })
                    ]
                  },
                  i.userId
                )) }),
                k[a.id].length > 10 && /* @__PURE__ */ t("p", { className: "mt-3 text-center text-sm text-[var(--text-tertiary)]", children: e("admin:groups.showingMembers", {
                  shown: 10,
                  total: k[a.id].length
                }) })
              ] }) })
            ]
          },
          a.id
        )) }),
        A && c && /* @__PURE__ */ t("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ r("div", { className: "w-full max-w-md rounded-[var(--radius-card)] bg-[var(--bg-secondary)] border border-[var(--border-color)] shadow-xl", children: [
          /* @__PURE__ */ r("div", { className: "flex items-center justify-between p-4 border-b border-[var(--border-color)]", children: [
            /* @__PURE__ */ t("h2", { className: "text-lg font-semibold text-[var(--text-primary)]", children: e("admin:groups.assignRoleTitle") }),
            /* @__PURE__ */ t(
              "button",
              {
                onClick: () => {
                  T(!1), C(null);
                },
                className: "p-1 rounded hover:bg-[var(--bg-hover)] text-[var(--text-tertiary)]",
                children: /* @__PURE__ */ t(ee, { className: "w-5 h-5" })
              }
            )
          ] }),
          /* @__PURE__ */ r("div", { className: "p-4", children: [
            /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-secondary)] mb-4", children: e("admin:groups.assignRoleDescription", { group: c.displayName }) }),
            /* @__PURE__ */ r("div", { className: "space-y-2 max-h-64 overflow-y-auto", children: [
              s.filter((a) => !c.assignedRoles.some((i) => i.roleId === a.id)).map((a) => /* @__PURE__ */ r(
                "button",
                {
                  onClick: () => we(a.id),
                  disabled: ie,
                  className: "w-full flex items-center gap-3 p-3 rounded-[var(--radius-button)] border border-[var(--border-color)] hover:border-[var(--color-accent-500)] hover:bg-[var(--bg-hover)] transition-colors text-left disabled:opacity-50",
                  children: [
                    /* @__PURE__ */ t(L, { className: "w-5 h-5 text-[var(--color-accent-500)]" }),
                    /* @__PURE__ */ r("div", { className: "flex-1", children: [
                      /* @__PURE__ */ t("p", { className: "font-medium text-[var(--text-primary)]", children: a.name }),
                      a.description && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: a.description })
                    ] }),
                    ie && /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin text-[var(--color-accent-500)]" })
                  ]
                },
                a.id
              )),
              s.filter((a) => !c.assignedRoles.some((i) => i.roleId === a.id)).length === 0 && /* @__PURE__ */ t("p", { className: "text-sm text-[var(--text-tertiary)] text-center py-4", children: e("admin:groups.allRolesAssigned") })
            ] })
          ] })
        ] }) })
      ] })
    }
  );
}
function lt() {
  const { t: e } = z(["entra", "common"]), v = ye(), [w, x] = o(!0), [h, S] = o([]), [y, b] = o(null), f = M(async () => {
    try {
      x(!0), b(null);
      const n = await re.users.getAll({ pageSize: 1e3, entraOnly: !0 });
      S(n?.items ?? []);
    } catch (n) {
      console.error("Failed to load users:", n);
      const p = n;
      p.response?.status === 401 ? b(e("common:errors.sessionExpired")) : p.response?.status === 403 ? b(e("common:errors.noPermission")) : b(e("entra:users.loadError"));
    } finally {
      x(!1);
    }
  }, [e]);
  V(() => {
    f();
  }, [f]);
  const s = (n) => n ? new Intl.DateTimeFormat("fr-FR", {
    dateStyle: "medium",
    timeStyle: "short"
  }).format(new Date(n)) : e("common:never"), d = [
    {
      key: "fullName",
      label: e("entra:users.columns.user"),
      sortable: !0,
      render: (n) => /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "w-10 h-10 rounded-full bg-[var(--color-primary-100)] dark:bg-[var(--color-primary-900)] flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ t("span", { className: "text-sm font-medium text-[var(--color-primary-600)]", children: n.fullName?.charAt(0).toUpperCase() || "?" }) }),
        /* @__PURE__ */ t("span", { className: "font-medium text-[var(--text-primary)]", children: n.fullName })
      ] })
    },
    {
      key: "email",
      label: e("entra:users.columns.email"),
      sortable: !0,
      render: (n) => /* @__PURE__ */ r("div", { className: "flex items-center gap-1 text-sm text-[var(--text-secondary)]", children: [
        /* @__PURE__ */ t(Pe, { className: "w-4 h-4" }),
        n.email
      ] })
    },
    {
      key: "isActive",
      label: e("entra:users.columns.status"),
      sortable: !0,
      render: (n) => n.isActive ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--success-bg)] text-[var(--success-text)]", children: [
        /* @__PURE__ */ t(D, { className: "w-3 h-3" }),
        e("common:active")
      ] }) : /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1 px-2 py-1 text-xs rounded-full bg-[var(--bg-secondary)] text-[var(--text-secondary)]", children: [
        /* @__PURE__ */ t(se, { className: "w-3 h-3" }),
        e("common:inactive")
      ] })
    },
    {
      key: "lastEntraSyncAt",
      label: e("entra:users.columns.lastSync"),
      sortable: !0,
      render: (n) => /* @__PURE__ */ r("div", { className: "flex items-center gap-1 text-sm text-[var(--text-secondary)]", children: [
        /* @__PURE__ */ t(he, { className: "w-4 h-4" }),
        s(n.lastEntraSyncAt)
      ] })
    },
    {
      key: "actions",
      label: e("entra:users.columns.actions"),
      align: "right",
      render: (n) => /* @__PURE__ */ r(
        "button",
        {
          onClick: (p) => {
            p.stopPropagation(), v(`/administration/users/${n.id}`);
          },
          className: "inline-flex items-center gap-1 text-sm text-[var(--color-primary-600)] hover:underline",
          children: [
            e("common:viewDetails"),
            /* @__PURE__ */ t(ae, { className: "w-4 h-4" })
          ]
        }
      )
    }
  ], u = (n, p) => {
    const m = p.toLowerCase();
    return n.fullName?.toLowerCase().includes(m) || n.email?.toLowerCase().includes(m) || !1;
  };
  return /* @__PURE__ */ t(
    _,
    {
      title: e("entra:users.title"),
      subtitle: e("entra:users.subtitle", { count: h.length }),
      icon: /* @__PURE__ */ t(P, { className: "w-6 h-6" }),
      breadcrumbs: [
        { label: e("header.title"), href: "/administration" },
        { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
        { label: e("entra:users.title") }
      ],
      actions: /* @__PURE__ */ r(
        "button",
        {
          onClick: f,
          className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-lg border border-[var(--border-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)] hover:bg-[var(--bg-secondary)]",
          children: [
            /* @__PURE__ */ t($, { className: "w-4 h-4" }),
            e("common:refresh")
          ]
        }
      ),
      children: /* @__PURE__ */ r("div", { className: "space-y-6", children: [
        y && /* @__PURE__ */ t("div", { className: "p-4 rounded-lg bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
          /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
          /* @__PURE__ */ t("span", { children: y })
        ] }) }),
        /* @__PURE__ */ t(
          Re,
          {
            data: h,
            columns: d,
            loading: w,
            searchable: !0,
            searchPlaceholder: e("entra:users.searchPlaceholder"),
            searchFilter: u,
            pagination: { pageSize: 20, showSizeSelector: !0 },
            onRowClick: (n) => v(`/administration/users/${n.id}`),
            getRowKey: (n) => n.id,
            emptyMessage: e("entra:users.noUsers"),
            emptyIcon: /* @__PURE__ */ t(P, { className: "w-12 h-12 mx-auto text-[var(--text-secondary)] opacity-50" }),
            defaultSortKey: "fullName",
            striped: !0
          }
        )
      ] })
    }
  );
}
function dt() {
  const { t: e } = z(["entra", "common"]), [v, w] = o(!0), [x, h] = o([]), [S, y] = o(null), [b, f] = o(null), [s, d] = o(!1), u = me(null), n = me(!1), p = M(async () => {
    if (!n.current) {
      u.current && u.current.abort(), u.current = new AbortController(), n.current = !0;
      try {
        y(null);
        const c = await N.conflicts.getAll();
        h(Array.isArray(c) ? c : []);
      } catch (c) {
        if (c instanceof Error && c.name === "AbortError")
          return;
        console.error("Failed to load conflicts:", c instanceof Error ? c.message : "Unknown error"), h([]);
        const C = c;
        C.response?.status === 401 ? y(e("common:errors.sessionExpired")) : C.response?.status === 403 ? y(e("common:errors.noPermission")) : y(e("entra:conflicts.loadError"));
      } finally {
        n.current = !1, w(!1);
      }
    }
  }, [e]);
  V(() => (p(), () => {
    u.current && u.current.abort();
  }), [p]);
  const m = M(async (c, C) => {
    if (!(!b || s)) {
      d(!0);
      try {
        await N.conflicts.resolve(b.id, {
          resolution: c,
          notes: C || void 0
        }), f(null), await p();
      } catch (A) {
        console.error("Failed to resolve conflict:", A instanceof Error ? A.message : "Unknown error"), y(e("entra:conflicts.resolveError"));
      } finally {
        d(!1);
      }
    }
  }, [b, s, p, e]);
  return v ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center min-h-[400px]", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) }) : /* @__PURE__ */ t(
    _,
    {
      title: e("entra:conflicts.title"),
      subtitle: e("entra:conflicts.subtitle", { count: x.length }),
      icon: /* @__PURE__ */ t(G, { className: "w-6 h-6" }),
      breadcrumbs: [
        { label: e("header.title"), href: "/administration" },
        { label: e("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
        { label: e("entra:conflicts.title") }
      ],
      actions: /* @__PURE__ */ r(
        "button",
        {
          onClick: p,
          disabled: v,
          className: "inline-flex items-center gap-2 px-4 py-2 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors disabled:opacity-50",
          children: [
            /* @__PURE__ */ t($, { className: `w-4 h-4 ${v ? "animate-spin" : ""}` }),
            e("common:refresh")
          ]
        }
      ),
      children: /* @__PURE__ */ r("div", { className: "space-y-6", children: [
        S && /* @__PURE__ */ t("div", { className: "p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
          /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[var(--error-text)]", children: [
            /* @__PURE__ */ t(G, { className: "w-5 h-5" }),
            /* @__PURE__ */ t("span", { children: S })
          ] }),
          /* @__PURE__ */ t(
            "button",
            {
              onClick: () => y(null),
              className: "text-[var(--error-text)] hover:opacity-70",
              children: "×"
            }
          )
        ] }) }),
        x.length === 0 ? /* @__PURE__ */ r("div", { className: "text-center py-16 px-6 rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-card)]", children: [
          /* @__PURE__ */ t("div", { className: "mx-auto w-16 h-16 rounded-full bg-[var(--success-bg)] flex items-center justify-center mb-4", children: /* @__PURE__ */ t(D, { className: "w-8 h-8 text-[var(--success-text)]" }) }),
          /* @__PURE__ */ t("h2", { className: "text-xl font-semibold text-[var(--text-primary)] mb-2", children: e("entra:conflicts.noConflicts") }),
          /* @__PURE__ */ t("p", { className: "text-[var(--text-secondary)] max-w-md mx-auto", children: e("entra:conflicts.noConflictsDescription") })
        ] }) : (
          /* Conflicts Grid */
          /* @__PURE__ */ t("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-6", children: x.map((c) => /* @__PURE__ */ t(
            ze,
            {
              conflict: c,
              onResolve: f
            },
            c.id
          )) })
        ),
        b && /* @__PURE__ */ t(
          _e,
          {
            conflict: b,
            onClose: () => f(null),
            onResolve: m,
            resolving: s
          }
        )
      ] })
    }
  );
}
const qe = [
  { id: "member", labelKey: "userTypes.member", descriptionKey: "userTypes.memberDescription", supported: !0 },
  { id: "guest", labelKey: "userTypes.guest", descriptionKey: "userTypes.guestDescription", supported: !0 },
  { id: "shared", labelKey: "userTypes.shared", descriptionKey: "userTypes.sharedDescription", supported: !1 },
  { id: "room", labelKey: "userTypes.room", descriptionKey: "userTypes.roomDescription", supported: !1 },
  { id: "equipment", labelKey: "userTypes.equipment", descriptionKey: "userTypes.equipmentDescription", supported: !1 }
], Xe = [
  { code: "User.Read.All", descriptionKey: "userReadAll" },
  { code: "Group.Read.All", descriptionKey: "groupReadAll" },
  { code: "GroupMember.Read.All", descriptionKey: "groupMemberReadAll" }
];
function Q({ icon: e, title: v, description: w, action: x, children: h, className: S = "" }) {
  return /* @__PURE__ */ r("div", { className: `rounded-[var(--radius-card)] border border-[var(--border-color)] bg-[var(--bg-card)] shadow-sm overflow-hidden ${S}`, children: [
    /* @__PURE__ */ t("div", { className: "px-6 py-4 border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)]", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
      /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
        /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-[var(--color-accent-100)] dark:bg-[var(--color-accent-900)]/30", children: /* @__PURE__ */ t(e, { className: "w-5 h-5 text-[var(--color-accent-500)]" }) }),
        /* @__PURE__ */ r("div", { children: [
          /* @__PURE__ */ t("h2", { className: "text-base font-semibold text-[var(--text-primary)]", children: v }),
          w && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mt-0.5", children: w })
        ] })
      ] }),
      x
    ] }) }),
    /* @__PURE__ */ t("div", { className: "p-6", children: h })
  ] });
}
function q({ checked: e, onChange: v, label: w, description: x }) {
  return /* @__PURE__ */ r("div", { className: "flex items-center justify-between py-3", children: [
    /* @__PURE__ */ r("div", { className: "flex-1 min-w-0 pr-4", children: [
      /* @__PURE__ */ t("label", { className: "text-sm font-medium text-[var(--text-primary)]", children: w }),
      x && /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mt-0.5", children: x })
    ] }),
    /* @__PURE__ */ t(
      "button",
      {
        type: "button",
        role: "switch",
        "aria-checked": e,
        onClick: v,
        className: `relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:ring-offset-2 focus:ring-offset-[var(--bg-primary)] ${e ? "bg-[var(--color-accent-600)]" : "bg-[var(--bg-tertiary)]"}`,
        children: /* @__PURE__ */ t(
          "span",
          {
            className: `inline-block h-4 w-4 transform rounded-full bg-[var(--toggle-knob)] shadow-md transition-transform ${e ? "translate-x-6" : "translate-x-1"}`
          }
        )
      }
    )
  ] });
}
const Ye = (e) => e ? /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e) : !0, Ze = () => {
  const { t: e } = z(["entra", "common"]), [v, w] = o(!0), [x, h] = o(!1), [S, y] = o(!1), [b, f] = o(null), [s, d] = o(!1), [u, n] = o(null), [p, m] = o(null), [c, C] = o(!1), [A, T] = o(null), [I, U] = o({}), [k, l] = o({
    tenantId: "",
    clientId: "",
    clientSecret: ""
  }), [g, F] = o({
    syncEnabled: !1,
    syncIntervalMinutes: 60,
    useDeltaSync: !0,
    defaultConflictResolution: "ManualReview",
    autoCreateReferences: !0,
    syncOnlyActiveUsers: !0,
    syncUserTypes: "member"
  });
  return {
    t: e,
    loading: v,
    setLoading: w,
    saving: x,
    setSaving: h,
    testing: S,
    setTesting: y,
    testResult: b,
    setTestResult: f,
    showSecret: s,
    setShowSecret: d,
    error: u,
    setError: n,
    success: p,
    setSuccess: m,
    hasExistingSecret: c,
    setHasExistingSecret: C,
    copiedPermission: A,
    setCopiedPermission: T,
    validationErrors: I,
    setValidationErrors: U,
    credentials: k,
    setCredentials: l,
    syncSettings: g,
    setSyncSettings: F
  };
};
function Je(e, v) {
  return e ? "opacity-50 cursor-not-allowed border-[var(--border-color)] bg-[var(--bg-tertiary)]" : v ? "cursor-pointer border-[var(--color-accent-500)] bg-[var(--color-accent-50)] dark:bg-[var(--color-accent-900)]/20" : "cursor-pointer border-[var(--border-color)] bg-[var(--bg-secondary)] hover:bg-[var(--bg-tertiary)]";
}
function mt() {
  const e = Ze(), v = M(async () => {
    try {
      e.setLoading(!0);
      const s = await N.settings.getConfiguration();
      e.setCredentials({
        tenantId: s.tenantId || "",
        clientId: s.clientId || "",
        clientSecret: ""
      }), e.setHasExistingSecret(s.hasClientSecret), e.setSyncSettings({
        syncEnabled: s.syncEnabled,
        syncIntervalMinutes: s.syncIntervalMinutes,
        useDeltaSync: s.useDeltaSync,
        defaultConflictResolution: s.defaultConflictResolution,
        autoCreateReferences: s.autoCreateReferences,
        syncOnlyActiveUsers: s.syncOnlyActiveUsers ?? !0,
        syncUserTypes: s.syncUserTypes ?? "member"
      });
    } catch (s) {
      console.error("Failed to load configuration:", s), e.setError(e.t("entra:settings.saveError"));
    } finally {
      e.setLoading(!1);
    }
  }, []);
  V(() => {
    v();
  }, [v]);
  const w = async (s) => {
    try {
      await navigator.clipboard.writeText(s), e.setCopiedPermission(s), setTimeout(() => e.setCopiedPermission(null), 2e3);
    } catch (d) {
      console.error("Failed to copy:", d);
    }
  }, x = (s, d) => {
    const u = Ye(d) ? void 0 : e.t("entra:settings.invalidGuidFormat");
    e.setValidationErrors((n) => ({ ...n, [s]: u }));
  }, h = (s, d) => {
    e.setCredentials((u) => ({ ...u, [s]: d })), (s === "tenantId" || s === "clientId") && x(s, d);
  }, S = !!(e.validationErrors.tenantId || e.validationErrors.clientId), y = async () => {
    e.setTesting(!0), e.setTestResult(null), e.setError(null), e.setSuccess(null);
    try {
      let s;
      if (e.credentials.clientSecret)
        s = await N.settings.testConnection({
          tenantId: e.credentials.tenantId,
          clientId: e.credentials.clientId,
          clientSecret: e.credentials.clientSecret
        });
      else if (e.hasExistingSecret)
        s = await N.settings.testStoredConnection();
      else {
        e.setError(e.t("entra:settings.testFailed")), e.setTesting(!1);
        return;
      }
      e.setTestResult(s), s.success ? e.setSuccess(e.t("entra:settings.testSuccess")) : e.setError(s.errorMessage || e.t("entra:settings.testFailed"));
    } catch (s) {
      console.error("Connection test failed:", s), e.setTestResult({ success: !1, errorMessage: e.t("entra:settings.testFailed"), tenantName: null, userCount: null, groupCount: null }), e.setError(e.t("entra:settings.testFailed"));
    } finally {
      e.setTesting(!1);
    }
  }, b = async () => {
    e.setSaving(!0), e.setError(null), e.setSuccess(null);
    try {
      await N.settings.saveCredentials({
        tenantId: e.credentials.tenantId,
        clientId: e.credentials.clientId,
        clientSecret: e.credentials.clientSecret
      }), e.setSuccess(e.t("entra:settings.credentialsSaved")), e.setHasExistingSecret(!0), e.setCredentials((s) => ({ ...s, clientSecret: "" }));
    } catch (s) {
      console.error("Failed to save credentials:", s), e.setError(e.t("entra:settings.saveError"));
    } finally {
      e.setSaving(!1);
    }
  }, f = async () => {
    e.setSaving(!0), e.setError(null), e.setSuccess(null);
    try {
      await N.settings.saveSyncSettings({
        syncEnabled: e.syncSettings.syncEnabled,
        syncIntervalMinutes: e.syncSettings.syncIntervalMinutes,
        useDeltaSync: e.syncSettings.useDeltaSync,
        defaultConflictResolution: e.syncSettings.defaultConflictResolution,
        autoCreateReferences: e.syncSettings.autoCreateReferences,
        syncOnlyActiveUsers: e.syncSettings.syncOnlyActiveUsers,
        syncUserTypes: e.syncSettings.syncUserTypes
      }), e.setSuccess(e.t("entra:settings.settingsSaved"));
    } catch (s) {
      console.error("Failed to save settings:", s), e.setError(e.t("entra:settings.saveError"));
    } finally {
      e.setSaving(!1);
    }
  };
  return e.loading ? /* @__PURE__ */ t("div", { className: "flex items-center justify-center h-64", children: /* @__PURE__ */ t(E, { className: "w-8 h-8 animate-spin text-[var(--color-accent-500)]" }) }) : /* @__PURE__ */ t(
    _,
    {
      title: e.t("entra:settings.title"),
      subtitle: e.t("entra:settings.subtitle"),
      icon: /* @__PURE__ */ t(Ve, { className: "w-6 h-6" }),
      breadcrumbs: [
        { label: e.t("header.title"), href: "/administration" },
        { label: e.t("entra.title", "Microsoft Entra ID"), href: "/administration/entra" },
        { label: e.t("entra:settings.title") }
      ],
      children: /* @__PURE__ */ r("div", { className: "space-y-6", children: [
        /* @__PURE__ */ t("div", { className: "rounded-[var(--radius-card)] border-2 border-[var(--warning-border)] bg-[var(--warning-bg)] overflow-hidden", children: /* @__PURE__ */ t("div", { className: "px-5 py-4", children: /* @__PURE__ */ r("div", { className: "flex items-start gap-4", children: [
          /* @__PURE__ */ t("div", { className: "p-2 rounded-[var(--radius-button)] bg-[var(--warning-border)]", children: /* @__PURE__ */ t(L, { className: "w-5 h-5 text-[var(--warning-text)]" }) }),
          /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
            /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-4 mb-2", children: [
              /* @__PURE__ */ t("h2", { className: "font-semibold text-[var(--warning-text)]", children: e.t("entra:settings.permissionsWarningTitle") }),
              /* @__PURE__ */ r(
                "a",
                {
                  href: "https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
                  target: "_blank",
                  rel: "noopener noreferrer",
                  className: "inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--warning-border)] text-[var(--warning-text)] hover:opacity-80 transition-opacity",
                  children: [
                    e.t("entra:settings.configureInAzure"),
                    /* @__PURE__ */ t(ae, { className: "w-3.5 h-3.5" })
                  ]
                }
              )
            ] }),
            /* @__PURE__ */ t("p", { className: "text-sm text-[var(--warning-text)] opacity-90 mb-4", children: e.t("entra:settings.permissionsWarningDescription") }),
            /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: Xe.map((s) => /* @__PURE__ */ r(
              "button",
              {
                onClick: () => w(s.code),
                className: "group inline-flex items-center gap-2 px-3 py-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)] border border-[var(--warning-border)] hover:border-[var(--warning-dot)] transition-all hover:shadow-sm",
                title: e.t(`entra:settings.permissions.${s.descriptionKey}`),
                children: [
                  /* @__PURE__ */ t("code", { className: "text-sm font-mono font-medium text-[var(--text-primary)]", children: s.code }),
                  e.copiedPermission === s.code ? /* @__PURE__ */ t(Me, { className: "w-4 h-4 text-[var(--success-text)]" }) : /* @__PURE__ */ t(Ue, { className: "w-4 h-4 text-[var(--warning-text)] group-hover:opacity-80" })
                ]
              },
              s.code
            )) })
          ] })
        ] }) }) }),
        e.error && /* @__PURE__ */ r("div", { className: "flex items-center gap-3 p-4 rounded-[var(--radius-card)] bg-[var(--error-bg)] border border-[var(--error-border)]", children: [
          /* @__PURE__ */ t(G, { className: "w-5 h-5 text-[var(--error-text)] flex-shrink-0" }),
          /* @__PURE__ */ t("span", { className: "text-sm text-[var(--error-text)]", children: e.error })
        ] }),
        e.success && /* @__PURE__ */ r("div", { className: "flex items-center gap-3 p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)]", children: [
          /* @__PURE__ */ t(D, { className: "w-5 h-5 text-[var(--success-text)] flex-shrink-0" }),
          /* @__PURE__ */ t("span", { className: "text-sm text-[var(--success-text)]", children: e.success })
        ] }),
        /* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-6", children: [
          /* @__PURE__ */ t(
            Q,
            {
              icon: Le,
              title: e.t("entra:settings.credentials"),
              description: "Azure AD Application",
              action: /* @__PURE__ */ r(
                "a",
                {
                  href: "https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
                  target: "_blank",
                  rel: "noopener noreferrer",
                  className: "inline-flex items-center gap-1.5 text-sm text-[var(--color-accent-500)] hover:text-[var(--color-accent-600)] transition-colors",
                  children: [
                    e.t("entra:settings.azurePortal"),
                    /* @__PURE__ */ t(ae, { className: "w-4 h-4" })
                  ]
                }
              ),
              children: /* @__PURE__ */ r("div", { className: "space-y-5", children: [
                /* @__PURE__ */ r("div", { children: [
                  /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1.5", children: e.t("entra:settings.tenantId") }),
                  /* @__PURE__ */ t(
                    "input",
                    {
                      type: "text",
                      value: e.credentials.tenantId,
                      onChange: (s) => h("tenantId", s.target.value),
                      placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                      autoComplete: "off",
                      className: `w-full px-3 py-2.5 rounded-[var(--radius-input)] border bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:border-transparent transition-shadow ${e.validationErrors.tenantId ? "border-[var(--error-border)] focus:ring-[var(--error-border)]" : "border-[var(--border-color)] focus:ring-[var(--color-accent-500)]"}`
                    }
                  ),
                  e.validationErrors.tenantId ? /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--error-text)]", children: e.validationErrors.tenantId }) : /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.tenantIdHelp") })
                ] }),
                /* @__PURE__ */ r("div", { children: [
                  /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1.5", children: e.t("entra:settings.clientId") }),
                  /* @__PURE__ */ t(
                    "input",
                    {
                      type: "text",
                      value: e.credentials.clientId,
                      onChange: (s) => h("clientId", s.target.value),
                      placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                      autoComplete: "off",
                      className: `w-full px-3 py-2.5 rounded-[var(--radius-input)] border bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:border-transparent transition-shadow ${e.validationErrors.clientId ? "border-[var(--error-border)] focus:ring-[var(--error-border)]" : "border-[var(--border-color)] focus:ring-[var(--color-accent-500)]"}`
                    }
                  ),
                  e.validationErrors.clientId ? /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--error-text)]", children: e.validationErrors.clientId }) : /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.clientIdHelp") })
                ] }),
                /* @__PURE__ */ r("div", { children: [
                  /* @__PURE__ */ r("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-1.5", children: [
                    e.t("entra:settings.clientSecret"),
                    e.hasExistingSecret && /* @__PURE__ */ r("span", { className: "ml-2 inline-flex items-center gap-1 text-xs text-[var(--success-text)]", children: [
                      /* @__PURE__ */ t(D, { className: "w-3 h-3" }),
                      e.t("common:configured")
                    ] })
                  ] }),
                  /* @__PURE__ */ r("div", { className: "relative", children: [
                    /* @__PURE__ */ t(
                      "input",
                      {
                        type: e.showSecret ? "text" : "password",
                        value: e.credentials.clientSecret,
                        onChange: (s) => h("clientSecret", s.target.value),
                        placeholder: e.hasExistingSecret ? "••••••••••••••••••••••••••••••••••••••••" : "OvA8Q~xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                        autoComplete: "new-password",
                        className: "w-full px-3 py-2.5 pr-10 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] font-mono text-sm focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] focus:border-transparent transition-shadow"
                      }
                    ),
                    /* @__PURE__ */ t(
                      "button",
                      {
                        type: "button",
                        onClick: () => e.setShowSecret(!e.showSecret),
                        className: "absolute right-3 top-1/2 -translate-y-1/2 p-1 text-[var(--text-tertiary)] hover:text-[var(--text-primary)] transition-colors",
                        children: e.showSecret ? /* @__PURE__ */ t($e, { className: "w-4 h-4" }) : /* @__PURE__ */ t(je, { className: "w-4 h-4" })
                      }
                    )
                  ] }),
                  /* @__PURE__ */ t("p", { className: "mt-1.5 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.clientSecretHelp") })
                ] }),
                /* @__PURE__ */ r("div", { className: "flex items-center gap-3 pt-2", children: [
                  /* @__PURE__ */ r(
                    "button",
                    {
                      onClick: y,
                      disabled: e.testing || S || !e.credentials.tenantId || !e.credentials.clientId || !e.credentials.clientSecret && !e.hasExistingSecret,
                      className: "inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-[var(--radius-button)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors",
                      children: [
                        e.testing && /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }),
                        !e.testing && e.testResult?.success && /* @__PURE__ */ t(D, { className: "w-4 h-4 text-[var(--success-text)]" }),
                        !e.testing && e.testResult && !e.testResult.success && /* @__PURE__ */ t(G, { className: "w-4 h-4 text-[var(--error-text)]" }),
                        !e.testing && !e.testResult && /* @__PURE__ */ t(Ke, { className: "w-4 h-4" }),
                        e.t("entra:settings.testConnection")
                      ]
                    }
                  ),
                  /* @__PURE__ */ r(
                    "button",
                    {
                      type: "button",
                      onClick: b,
                      disabled: e.saving || S || !e.credentials.tenantId || !e.credentials.clientId || !e.credentials.clientSecret,
                      className: "inline-flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors shadow-sm",
                      children: [
                        e.saving ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(xe, { className: "w-4 h-4" }),
                        e.t("entra:settings.saveCredentials", { defaultValue: "Enregistrer les identifiants" })
                      ]
                    }
                  )
                ] }),
                e.testResult?.success && /* @__PURE__ */ r("div", { className: "mt-4 p-4 rounded-[var(--radius-card)] bg-[var(--success-bg)] border border-[var(--success-border)]", children: [
                  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 mb-3", children: [
                    /* @__PURE__ */ t(D, { className: "w-5 h-5 text-[var(--success-text)]" }),
                    /* @__PURE__ */ t("span", { className: "font-medium text-[var(--success-text)]", children: e.t("entra:settings.connectionSuccessful") })
                  ] }),
                  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-3 gap-3", children: [
                    e.testResult.tenantName && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)]", children: [
                      /* @__PURE__ */ t(Y, { className: "w-4 h-4 text-[var(--success-text)]" }),
                      /* @__PURE__ */ r("div", { className: "min-w-0", children: [
                        /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.tenantName") }),
                        /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)] truncate", children: e.testResult.tenantName })
                      ] })
                    ] }),
                    e.testResult.userCount !== null && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)]", children: [
                      /* @__PURE__ */ t(P, { className: "w-4 h-4 text-[var(--success-text)]" }),
                      /* @__PURE__ */ r("div", { children: [
                        /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.userCount") }),
                        /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)]", children: e.testResult.userCount })
                      ] })
                    ] }),
                    e.testResult.groupCount !== null && /* @__PURE__ */ r("div", { className: "flex items-center gap-2 p-2 rounded-[var(--radius-button)] bg-[var(--bg-primary)]", children: [
                      /* @__PURE__ */ t(Oe, { className: "w-4 h-4 text-[var(--success-text)]" }),
                      /* @__PURE__ */ r("div", { children: [
                        /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.groupCount") }),
                        /* @__PURE__ */ t("p", { className: "text-sm font-medium text-[var(--text-primary)]", children: e.testResult.groupCount })
                      ] })
                    ] })
                  ] })
                ] })
              ] })
            }
          ),
          /* @__PURE__ */ r("div", { className: "space-y-6", children: [
            /* @__PURE__ */ t(
              Q,
              {
                icon: be,
                title: e.t("entra:settings.syncSettings"),
                description: "Scheduling & Performance",
                children: /* @__PURE__ */ r("div", { className: "divide-y divide-[var(--border-subtle)]", children: [
                  /* @__PURE__ */ t(
                    q,
                    {
                      checked: e.syncSettings.syncEnabled,
                      onChange: () => e.setSyncSettings((s) => ({ ...s, syncEnabled: !s.syncEnabled })),
                      label: e.t("entra:settings.syncEnabled"),
                      description: e.t("entra:settings.syncEnabledHelp")
                    }
                  ),
                  /* @__PURE__ */ r("div", { className: "py-4", children: [
                    /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-2", children: e.t("entra:settings.syncInterval") }),
                    /* @__PURE__ */ r(
                      "select",
                      {
                        value: e.syncSettings.syncIntervalMinutes,
                        onChange: (s) => e.setSyncSettings((d) => ({ ...d, syncIntervalMinutes: Number(s.target.value) })),
                        className: "w-full px-3 py-2.5 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] transition-shadow",
                        children: [
                          /* @__PURE__ */ r("option", { value: 15, children: [
                            "15 ",
                            e.t("common:minutes")
                          ] }),
                          /* @__PURE__ */ r("option", { value: 30, children: [
                            "30 ",
                            e.t("common:minutes")
                          ] }),
                          /* @__PURE__ */ r("option", { value: 60, children: [
                            "1 ",
                            e.t("common:hour")
                          ] }),
                          /* @__PURE__ */ r("option", { value: 120, children: [
                            "2 ",
                            e.t("common:hours")
                          ] }),
                          /* @__PURE__ */ r("option", { value: 360, children: [
                            "6 ",
                            e.t("common:hours")
                          ] }),
                          /* @__PURE__ */ r("option", { value: 720, children: [
                            "12 ",
                            e.t("common:hours")
                          ] }),
                          /* @__PURE__ */ r("option", { value: 1440, children: [
                            "24 ",
                            e.t("common:hours")
                          ] })
                        ]
                      }
                    )
                  ] }),
                  /* @__PURE__ */ t(
                    q,
                    {
                      checked: e.syncSettings.useDeltaSync,
                      onChange: () => e.setSyncSettings((s) => ({ ...s, useDeltaSync: !s.useDeltaSync })),
                      label: e.t("entra:settings.useDeltaSync"),
                      description: e.t("entra:settings.useDeltaSyncHelp")
                    }
                  ),
                  /* @__PURE__ */ t(
                    q,
                    {
                      checked: e.syncSettings.autoCreateReferences,
                      onChange: () => e.setSyncSettings((s) => ({ ...s, autoCreateReferences: !s.autoCreateReferences })),
                      label: e.t("entra:settings.autoCreateReferences"),
                      description: e.t("entra:settings.autoCreateReferencesHelp")
                    }
                  )
                ] })
              }
            ),
            /* @__PURE__ */ t(
              Q,
              {
                icon: He,
                title: e.t("entra:settings.conflictResolution"),
                description: "Data Priority",
                children: /* @__PURE__ */ r("div", { children: [
                  /* @__PURE__ */ r(
                    "select",
                    {
                      value: e.syncSettings.defaultConflictResolution,
                      onChange: (s) => e.setSyncSettings((d) => ({ ...d, defaultConflictResolution: s.target.value })),
                      className: "w-full px-3 py-2.5 rounded-[var(--radius-input)] border border-[var(--border-color)] bg-[var(--bg-secondary)] text-[var(--text-primary)] focus:outline-none focus:ring-2 focus:ring-[var(--color-accent-500)] transition-shadow",
                      children: [
                        /* @__PURE__ */ t("option", { value: "ManualReview", children: e.t("entra:settings.conflictResolutions.manualReview") }),
                        /* @__PURE__ */ t("option", { value: "EntraWins", children: e.t("entra:settings.conflictResolutions.entraWins") }),
                        /* @__PURE__ */ t("option", { value: "LocalWins", children: e.t("entra:settings.conflictResolutions.localWins") })
                      ]
                    }
                  ),
                  /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-[var(--text-tertiary)]", children: e.t("entra:settings.conflictResolutionHelp") })
                ] })
              }
            ),
            /* @__PURE__ */ t(
              Q,
              {
                icon: ge,
                title: e.t("entra:settings.userSyncFilters"),
                description: "User Types & Filters",
                children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
                  /* @__PURE__ */ t(
                    q,
                    {
                      checked: e.syncSettings.syncOnlyActiveUsers,
                      onChange: () => e.setSyncSettings((s) => ({ ...s, syncOnlyActiveUsers: !s.syncOnlyActiveUsers })),
                      label: e.t("entra:settings.syncOnlyActiveUsers"),
                      description: e.t("entra:settings.syncOnlyActiveUsersHelp")
                    }
                  ),
                  /* @__PURE__ */ r("div", { className: "pt-2 border-t border-[var(--border-subtle)]", children: [
                    /* @__PURE__ */ t("label", { className: "block text-sm font-medium text-[var(--text-primary)] mb-2", children: e.t("entra:settings.syncUserTypesLabel") }),
                    /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mb-3", children: e.t("entra:settings.syncUserTypesHelp") }),
                    /* @__PURE__ */ t("div", { className: "space-y-2", children: qe.map((s) => {
                      const d = e.syncSettings.syncUserTypes.split(",").map((m) => m.trim()).filter(Boolean), u = d.includes(s.id), n = !s.supported, p = () => {
                        if (n) return;
                        let m;
                        u ? m = d.filter((c) => c !== s.id) : m = [...d, s.id], m.length === 0 && (m = ["member"]), e.setSyncSettings((c) => ({ ...c, syncUserTypes: m.join(",") }));
                      };
                      return /* @__PURE__ */ r(
                        "label",
                        {
                          className: `flex items-start gap-3 p-3 rounded-[var(--radius-button)] border transition-all ${Je(n, u)}`,
                          children: [
                            /* @__PURE__ */ t(
                              "input",
                              {
                                type: "checkbox",
                                checked: u,
                                onChange: p,
                                disabled: n,
                                className: "mt-0.5 w-4 h-4 rounded border-[var(--border-color)] text-[var(--color-accent-600)] focus:ring-[var(--color-accent-500)] disabled:opacity-50"
                              }
                            ),
                            /* @__PURE__ */ r("div", { className: "flex-1 min-w-0", children: [
                              /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
                                /* @__PURE__ */ t("span", { className: "text-sm font-medium text-[var(--text-primary)]", children: e.t(`entra:settings.${s.labelKey}`) }),
                                n && /* @__PURE__ */ t("span", { className: "text-xs px-1.5 py-0.5 rounded bg-[var(--bg-tertiary)] text-[var(--text-tertiary)]", children: e.t("common:comingSoon") })
                              ] }),
                              /* @__PURE__ */ t("p", { className: "text-xs text-[var(--text-tertiary)] mt-0.5", children: e.t(`entra:settings.${s.descriptionKey}`) })
                            ] })
                          ]
                        },
                        s.id
                      );
                    }) })
                  ] })
                ] })
              }
            ),
            /* @__PURE__ */ t("div", { className: "flex justify-end", children: /* @__PURE__ */ r(
              "button",
              {
                type: "button",
                onClick: f,
                disabled: e.saving,
                className: "inline-flex items-center gap-2 px-6 py-2.5 text-sm font-medium rounded-[var(--radius-button)] bg-[var(--color-accent-600)] text-white hover:bg-[var(--color-accent-700)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors shadow-sm",
                children: [
                  e.saving ? /* @__PURE__ */ t(E, { className: "w-4 h-4 animate-spin" }) : /* @__PURE__ */ t(xe, { className: "w-4 h-4" }),
                  e.t("entra:settings.saveSettings", { defaultValue: "Enregistrer les paramètres" })
                ]
              }
            ) })
          ] })
        ] })
      ] })
    }
  );
}
export {
  dt as EntraConflictsPage,
  ot as EntraDashboardPage,
  ct as EntraGroupsPage,
  mt as EntraSettingsPage,
  lt as EntraUsersPage
};
//# sourceMappingURL=index-8aGkNjh2.js.map
