"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import { useState, useEffect } from "react";
import { useTranslations } from "next-intl";
import { cn } from "../../../lib/utils/index.js";
import { useSidebar } from "../../../contexts/sidebar-context.js";
import { sel } from "../../../lib/test/index.js";
import { DynamicNavigation } from "../navigation/DynamicNavigation.js";
import { TeamSwitcherCompact } from "../../teams/TeamSwitcherCompact.js";
function Sidebar({ className, entities }) {
  const { isCollapsed } = useSidebar();
  const t = useTranslations("common");
  const appName = t("appName");
  const [statusMessage, setStatusMessage] = useState("");
  useEffect(() => {
    if (isCollapsed) {
      setStatusMessage("Sidebar en modo contra\xEDdo. Use Tab para navegar.");
    }
  }, [isCollapsed]);
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      "div",
      {
        "aria-live": "polite",
        "aria-atomic": "true",
        className: "sr-only",
        children: statusMessage
      }
    ),
    /* @__PURE__ */ jsx(
      "div",
      {
        className: cn(
          "hidden lg:flex flex-col bg-background border-r border-border fixed left-0 top-0 h-screen z-50 transition-all duration-300",
          isCollapsed ? "w-16" : "w-64",
          className
        ),
        role: "complementary",
        "aria-label": isCollapsed ? "Sidebar de navegaci\xF3n contra\xEDdo" : "Sidebar de navegaci\xF3n expandido",
        "data-cy": sel("dashboard.sidebar.container"),
        "data-collapsed": isCollapsed,
        children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
          /* @__PURE__ */ jsx("header", { className: "p-4", children: /* @__PURE__ */ jsx(
            "div",
            {
              className: "flex items-center justify-between",
              role: "banner",
              "data-cy": sel("dashboard.sidebar.header"),
              children: /* @__PURE__ */ jsxs(
                Link,
                {
                  href: "/",
                  className: "flex items-center gap-2",
                  "aria-label": isCollapsed ? "Ir a la p\xE1gina principal" : `${appName} - Ir a la p\xE1gina principal`,
                  "data-cy": sel("dashboard.sidebar.logo"),
                  children: [
                    /* @__PURE__ */ jsx(
                      "div",
                      {
                        className: "w-8 h-8 rounded-lg bg-primary flex items-center justify-center",
                        role: "img",
                        "aria-label": `Logo de ${appName}`,
                        children: /* @__PURE__ */ jsx("span", { className: "text-primary-foreground font-bold text-sm", "aria-hidden": "true", children: appName.charAt(0) })
                      }
                    ),
                    !isCollapsed && /* @__PURE__ */ jsx(
                      "span",
                      {
                        className: "font-semibold text-lg",
                        children: appName
                      }
                    )
                  ]
                }
              )
            }
          ) }),
          /* @__PURE__ */ jsx(
            "nav",
            {
              className: "flex-1 px-2 pb-4 overflow-y-auto",
              id: "sidebar-navigation",
              role: "navigation",
              "aria-label": "Navegaci\xF3n principal del dashboard",
              "data-cy": sel("dashboard.sidebar.content"),
              children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("section", { "aria-labelledby": !isCollapsed ? "nav-heading" : void 0, children: [
                !isCollapsed && /* @__PURE__ */ jsx(
                  "h3",
                  {
                    id: "nav-heading",
                    className: "px-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3",
                    children: "Navigation"
                  }
                ),
                /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(DynamicNavigation, { entities, isCollapsed }) })
              ] }) })
            }
          ),
          !isCollapsed && /* @__PURE__ */ jsx("div", { className: "mt-auto", children: /* @__PURE__ */ jsx(TeamSwitcherCompact, {}) })
        ] })
      }
    )
  ] });
}
export {
  Sidebar
};
