"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import { useState, useEffect } from "react";
import { cn } from "../../../lib/utils";
import { useSidebar } from "../../../contexts/sidebar-context";
import { createTestId, createCyId } from "../../../lib/test";
import { DynamicNavigation } from "../navigation/DynamicNavigation";
import { TeamSwitcherCompact } from "../../teams/TeamSwitcherCompact";
function Sidebar({ className, entities }) {
  const { isCollapsed } = useSidebar();
  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",
        ...createTestId("sidebar", "status", "message") && { "data-testid": createTestId("sidebar", "status", "message") },
        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",
        ...createTestId("sidebar", "container") && { "data-testid": createTestId("sidebar", "container") },
        ...createCyId("sidebar", "main") && { "data-cy": createCyId("sidebar", "main") },
        "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",
              ...createTestId("sidebar", "header") && { "data-testid": createTestId("sidebar", "header") },
              ...createCyId("sidebar", "header-section") && { "data-cy": createCyId("sidebar", "header-section") },
              children: /* @__PURE__ */ jsxs(
                Link,
                {
                  href: "/",
                  className: "flex items-center gap-2",
                  "aria-label": isCollapsed ? "Ir a la p\xE1gina principal" : "Boilerplate - Ir a la p\xE1gina principal",
                  ...createTestId("sidebar", "logo", "link") && { "data-testid": createTestId("sidebar", "logo", "link") },
                  ...createCyId("sidebar", "logo") && { "data-cy": createCyId("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 Boilerplate",
                        ...createTestId("sidebar", "logo", "icon") && { "data-testid": createTestId("sidebar", "logo", "icon") },
                        children: /* @__PURE__ */ jsx("span", { className: "text-primary-foreground font-bold text-sm", "aria-hidden": "true", children: "B" })
                      }
                    ),
                    !isCollapsed && /* @__PURE__ */ jsx(
                      "span",
                      {
                        className: "font-semibold text-lg",
                        ...createTestId("sidebar", "brand", "text") && { "data-testid": createTestId("sidebar", "brand", "text") },
                        children: "Boilerplate"
                      }
                    )
                  ]
                }
              )
            }
          ) }),
          /* @__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",
              ...createTestId("sidebar", "navigation") && { "data-testid": createTestId("sidebar", "navigation") },
              ...createCyId("sidebar", "nav") && { "data-cy": createCyId("sidebar", "nav") },
              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",
                    ...createTestId("sidebar", "nav", "heading") && { "data-testid": createTestId("sidebar", "nav", "heading") },
                    children: "Navigation"
                  }
                ),
                /* @__PURE__ */ jsx(
                  "div",
                  {
                    ...createTestId("sidebar", "nav", "items") && { "data-testid": createTestId("sidebar", "nav", "items") },
                    ...createCyId("sidebar", "nav-items") && { "data-cy": createCyId("sidebar", "nav-items") },
                    children: /* @__PURE__ */ jsx(DynamicNavigation, { entities })
                  }
                )
              ] }) })
            }
          ),
          !isCollapsed && /* @__PURE__ */ jsx("div", { className: "mt-auto", children: /* @__PURE__ */ jsx(TeamSwitcherCompact, {}) })
        ] })
      }
    )
  ] });
}
export {
  Sidebar
};
