import type { Permission } from "@/modules/core/types";

export type NavIconKey =
  | "alerts"
  | "audit"
  | "beds"
  | "care"
  | "dashboard"
  | "devices"
  | "emergency"
  | "family"
  | "global"
  | "health"
  | "knowledge"
  | "notices"
  | "organizations"
  | "roles"
  | "status"
  | "users";

export type NavItem = {
  path: string;
  label: string;
  icon: NavIconKey;
  permission?: Permission;
  anyPermissions?: Permission[];
};

export type NavGroup = {
  label: string;
  items: NavItem[];
};

export const navGroups: NavGroup[] = [
  {
    label: "运营",
    items: [
      {
        path: "/dashboard",
        label: "运营看板",
        icon: "dashboard",
        anyPermissions: ["elder:read", "facility:read", "admission:read", "incident:read"],
      },
      {
        path: "/elders",
        label: "老人档案",
        icon: "users",
        permission: "elder:read",
      },
      {
        path: "/beds",
        label: "床位房间",
        icon: "beds",
        anyPermissions: ["facility:read", "admission:read"],
      },
      {
        path: "/health",
        label: "健康照护",
        icon: "health",
        permission: "health:read",
      },
      {
        path: "/care",
        label: "护理服务",
        icon: "care",
        permission: "care:read",
      },
      {
        path: "/emergency",
        label: "安全应急",
        icon: "emergency",
        permission: "incident:read",
      },
    ],
  },
  {
    label: "协同",
    items: [
      {
        path: "/devices",
        label: "设备运维",
        icon: "devices",
        permission: "device:read",
      },
      {
        path: "/notices",
        label: "公告通知",
        icon: "notices",
        permission: "notice:read",
      },
      {
        path: "/alerts",
        label: "规则预警",
        icon: "alerts",
        permission: "alert:read",
      },
      {
        path: "/family",
        label: "家属服务",
        icon: "family",
        permission: "family:read",
      },
    ],
  },
  {
    label: "管理系统",
    items: [
      {
        path: "/settings/global",
        label: "全局配置",
        icon: "global",
        permission: "platform:manage",
      },
      {
        path: "/settings/organizations",
        label: "机构管理",
        icon: "organizations",
        permission: "organization:read",
      },
      {
        path: "/settings/users",
        label: "用户管理",
        icon: "users",
        permission: "account:read",
      },
      {
        path: "/settings/roles",
        label: "角色权限",
        icon: "roles",
        permission: "role:read",
      },
      {
        path: "/settings/health",
        label: "健康数据管理",
        icon: "health",
        permission: "health:read",
      },
      {
        path: "/settings/knowledge",
        label: "知识库",
        icon: "knowledge",
        permission: "knowledge:read",
      },
      {
        path: "/settings/audit",
        label: "审计日志",
        icon: "audit",
        permission: "audit:read",
      },
      {
        path: "/settings/status",
        label: "运行状态",
        icon: "status",
        permission: "incident:read",
      },
    ],
  },
];

export const navItems: NavItem[] = navGroups.flatMap((group) => group.items);
