"use client";
import { Workspace } from './chunk-PCYL4MII.mjs';
import { HeroSection, CreateActionButton, EntityCard, InlineForm, FormSelect, Button, GlassModal, FormGrid, FormInput } from './chunk-JN6IL6OH.mjs';
import { useLocale } from './chunk-7VJ7CMMT.mjs';
import { useState } from 'react';
import { UserGroupIcon, ShieldCheckIcon } from '@heroicons/react/24/outline';
import { jsxs, jsx } from 'react/jsx-runtime';

var ROLE_OPTIONS = [
  { value: "admin", label: "Admin" },
  { value: "manager", label: "Manager" },
  { value: "analyst", label: "Analyst" },
  { value: "viewer", label: "Viewer" }
];
function UsersPageView({ labels, users, onCreateUser, onUpdateRole }) {
  const [createOpen, setCreateOpen] = useState(false);
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
    /* @__PURE__ */ jsx(
      HeroSection,
      {
        icon: /* @__PURE__ */ jsx(UserGroupIcon, { className: "h-5 w-5" }),
        label: labels.title,
        title: labels.title,
        subtitle: labels.subtitle,
        gradient: "from-violet-500 to-indigo-600",
        toolbar: /* @__PURE__ */ jsx(
          CreateActionButton,
          {
            mode: "desktop",
            label: labels.create,
            onClick: () => setCreateOpen(true),
            accent: "violet"
          }
        )
      }
    ),
    /* @__PURE__ */ jsx(
      CreateActionButton,
      {
        mode: "mobile",
        label: labels.create,
        onClick: () => setCreateOpen(true),
        accent: "violet"
      }
    ),
    /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
      /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: labels.list }),
      /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: users.map((user) => /* @__PURE__ */ jsx(
        EntityCard,
        {
          accentGradient: "from-violet-500 to-indigo-700",
          icon: /* @__PURE__ */ jsx("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg bg-violet-500/10 text-violet-600 dark:bg-violet-500/20 dark:text-violet-400", children: /* @__PURE__ */ jsx(UserGroupIcon, { className: "h-6 w-6" }) }),
          title: user.name,
          subtitle: user.email,
          status: /* @__PURE__ */ jsx(
            "span",
            {
              className: `shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold ${user.active ? "bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-300" : "bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-300"}`,
              children: user.active ? labels.statusActive : labels.statusInactive
            }
          ),
          footer: /* @__PURE__ */ jsx(
            "form",
            {
              onSubmit: (event) => {
                event.preventDefault();
                const formData = new FormData(event.currentTarget);
                const role = String(formData.get("role") ?? "viewer");
                onUpdateRole({ email: user.email, role });
              },
              children: /* @__PURE__ */ jsxs(InlineForm, { children: [
                /* @__PURE__ */ jsx(FormSelect, { name: "role", options: ROLE_OPTIONS, defaultValue: user.role }),
                /* @__PURE__ */ jsx(Button, { type: "submit", outline: true, size: "sm", children: labels.save })
              ] })
            }
          )
        },
        user.email
      )) })
    ] }),
    /* @__PURE__ */ jsx(
      GlassModal,
      {
        open: createOpen,
        onClose: () => setCreateOpen(false),
        title: labels.create,
        maxWidth: "lg",
        showFormFooter: true,
        cancelLabel: labels.list,
        submitLabel: labels.add,
        onSubmit: (event) => {
          const formData = new FormData(event.currentTarget);
          const name = String(formData.get("name") ?? "").trim();
          const email = String(formData.get("email") ?? "").trim().toLowerCase();
          const role = String(formData.get("role") ?? "viewer");
          if (!name || !email) return;
          onCreateUser({ name, email, role });
          setCreateOpen(false);
        },
        children: /* @__PURE__ */ jsxs(FormGrid, { children: [
          /* @__PURE__ */ jsx(FormInput, { name: "name", label: labels.name, placeholder: labels.userNamePlaceholder, required: true }),
          /* @__PURE__ */ jsx(FormInput, { name: "email", label: labels.email, placeholder: labels.userEmailPlaceholder, required: true, type: "email" }),
          /* @__PURE__ */ jsx(FormSelect, { name: "role", label: labels.role, options: ROLE_OPTIONS })
        ] })
      }
    )
  ] });
}
function RolesPageView({
  labels,
  users,
  onAssignRole,
  roleDefinitions,
  roleOptions
}) {
  const [assignOpen, setAssignOpen] = useState(false);
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
    /* @__PURE__ */ jsx(
      HeroSection,
      {
        icon: /* @__PURE__ */ jsx(ShieldCheckIcon, { className: "h-5 w-5" }),
        label: labels.title,
        title: labels.title,
        subtitle: labels.subtitle,
        gradient: "from-emerald-500 to-teal-600",
        toolbar: /* @__PURE__ */ jsx(
          CreateActionButton,
          {
            mode: "desktop",
            label: labels.assign,
            onClick: () => setAssignOpen(true),
            accent: "emerald"
          }
        )
      }
    ),
    /* @__PURE__ */ jsx(
      CreateActionButton,
      {
        mode: "mobile",
        label: labels.assign,
        onClick: () => setAssignOpen(true),
        accent: "emerald"
      }
    ),
    /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
      /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: labels.definitions }),
      /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: Object.values(roleDefinitions).map((role) => /* @__PURE__ */ jsxs(
        EntityCard,
        {
          accentGradient: "from-emerald-500 to-teal-700",
          icon: /* @__PURE__ */ jsx("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg bg-emerald-500/10 text-emerald-600 dark:bg-emerald-500/20 dark:text-emerald-400", children: /* @__PURE__ */ jsx(ShieldCheckIcon, { className: "h-6 w-6" }) }),
          title: role.label,
          subtitle: role.id,
          children: [
            /* @__PURE__ */ jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: role.description }),
            /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs font-medium text-slate-600 dark:text-slate-300", children: labels.permissionsEnabled })
          ]
        },
        role.id
      )) })
    ] }),
    /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
      /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-slate-900 dark:text-slate-100", children: labels.current }),
      /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: users.map((user) => /* @__PURE__ */ jsx(
        EntityCard,
        {
          accentGradient: "from-violet-500 to-indigo-700",
          icon: /* @__PURE__ */ jsx("div", { className: "flex h-11 w-11 items-center justify-center rounded-lg bg-violet-500/10 text-violet-600 dark:bg-violet-500/20 dark:text-violet-400", children: /* @__PURE__ */ jsx(ShieldCheckIcon, { className: "h-6 w-6" }) }),
          title: user.name,
          subtitle: user.email,
          status: /* @__PURE__ */ jsx("span", { className: "shrink-0 rounded-full bg-violet-100 px-2 py-0.5 text-[10px] font-semibold text-violet-700 dark:bg-violet-900/30 dark:text-violet-300", children: user.role })
        },
        user.email
      )) })
    ] }),
    /* @__PURE__ */ jsx(
      GlassModal,
      {
        open: assignOpen,
        onClose: () => setAssignOpen(false),
        title: labels.assign,
        maxWidth: "lg",
        showFormFooter: true,
        cancelLabel: labels.current,
        submitLabel: labels.apply,
        onSubmit: (event) => {
          const formData = new FormData(event.currentTarget);
          const email = String(formData.get("email") ?? "").trim().toLowerCase();
          const role = String(formData.get("role") ?? "viewer");
          if (!email) return;
          onAssignRole({ email, role });
          setAssignOpen(false);
        },
        children: /* @__PURE__ */ jsxs(FormGrid, { children: [
          /* @__PURE__ */ jsx(FormInput, { name: "email", label: labels.userEmail, placeholder: "user@company.com", required: true }),
          /* @__PURE__ */ jsx(FormSelect, { name: "role", label: labels.role, options: roleOptions })
        ] })
      }
    )
  ] });
}
function WorkflowWorkspace({ graph }) {
  const locale = useLocale();
  return /* @__PURE__ */ jsx(Workspace, { initialGraph: graph, locale });
}

export { RolesPageView, UsersPageView, WorkflowWorkspace };
//# sourceMappingURL=chunk-O6M3KDGT.mjs.map
//# sourceMappingURL=chunk-O6M3KDGT.mjs.map