import { U as reactExports, L as jsxRuntimeExports } from "./server-DSC_YmUp.js";
import { i as Route, G as useAuth, S as useNavigate, z as supabase, L as Link, B as Button } from "./router-CEZm8MTA.js";
import { i as Avatar, k as AvatarImage, j as AvatarFallback, T as Tabs, p as TabsList, q as TabsTrigger, o as TabsContent, C as Chat } from "./tabs-BcrBvEup.js";
import { T as Target, a as TargetsPanel, W as WeightTracker } from "./TargetsPanel-DjzMGHx9.js";
import { A as ArrowLeft } from "./arrow-left-CNLv9jsf.js";
import { M as MessageCircle } from "./utensils-Cya-B9wL.js";
import { T as TrendingUp } from "./trending-up-DlL_CVAh.js";
import "node:async_hooks";
import "node:stream/web";
import "node:stream";
import "./label-gF41I2IG.js";
import "./card-CdzUIPcf.js";
import "./textarea-Bvg_-Pfo.js";
function AdminClient() {
  const {
    clientId
  } = Route.useParams();
  const {
    user,
    loading,
    isAdmin
  } = useAuth();
  const navigate = useNavigate();
  const [profile, setProfile] = reactExports.useState(null);
  reactExports.useEffect(() => {
    if (!loading && (!user || !isAdmin)) navigate({
      to: "/dashboard"
    });
  }, [user, loading, isAdmin, navigate]);
  reactExports.useEffect(() => {
    supabase.from("profiles").select("full_name,nickname,avatar_url,email,goal_weight_kg,height_cm,current_weight_kg").eq("id", clientId).maybeSingle().then(({
      data
    }) => setProfile(data));
  }, [clientId]);
  if (!user || !isAdmin) return null;
  const display = profile?.nickname ? `${profile.nickname} (${profile.full_name || "—"})` : profile?.full_name || "Client";
  return /* @__PURE__ */ jsxRuntimeExports.jsx("main", { className: "bg-soft min-h-[calc(100svh-4rem)]", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "container mx-auto px-3 sm:px-4 py-6 sm:py-8 max-w-5xl", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/admin", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { variant: "ghost", size: "sm", className: "mb-4 rounded-full -ml-2", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx(ArrowLeft, { className: "h-4 w-4 mr-1" }),
      " Toți clienții"
    ] }) }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "relative overflow-hidden rounded-3xl border border-border bg-card p-5 sm:p-7 shadow-[var(--shadow-card)] mb-6", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute -right-16 -top-16 h-56 w-56 rounded-full bg-primary/10 blur-3xl" }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex flex-col sm:flex-row sm:items-center gap-4 sm:gap-5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Avatar, { className: "h-16 w-16 ring-2 ring-primary/15 ring-offset-2 ring-offset-card", children: [
          profile?.avatar_url && /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarImage, { src: profile.avatar_url }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarFallback, { className: "bg-primary/15 text-primary font-display font-bold text-lg", children: (profile?.nickname || profile?.full_name || "?").slice(0, 2).toUpperCase() })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "font-display text-2xl sm:text-3xl font-bold tracking-tight break-words", children: display }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground mt-1 break-all", children: profile?.email }),
          /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground font-num", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
              "Țintă:",
              " ",
              /* @__PURE__ */ jsxRuntimeExports.jsxs("b", { className: "text-foreground", children: [
                profile?.goal_weight_kg ?? "—",
                " kg"
              ] })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
              "Înălțime:",
              " ",
              /* @__PURE__ */ jsxRuntimeExports.jsxs("b", { className: "text-foreground", children: [
                profile?.height_cm ?? "—",
                " cm"
              ] })
            ] }),
            /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
              "Curent:",
              " ",
              /* @__PURE__ */ jsxRuntimeExports.jsxs("b", { className: "text-foreground", children: [
                profile?.current_weight_kg ?? "—",
                " kg"
              ] })
            ] })
          ] })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { defaultValue: "targets", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "w-full grid grid-cols-3 h-auto bg-card p-1.5 rounded-2xl border shadow-[var(--shadow-card)]", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "targets", className: "gap-1.5 text-xs sm:text-sm py-2.5 rounded-xl", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Target, { className: "h-4 w-4" }),
          " Ținte"
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "chat", className: "gap-1.5 text-xs sm:text-sm py-2.5 rounded-xl", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(MessageCircle, { className: "h-4 w-4" }),
          " Chat"
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "weight", className: "gap-1.5 text-xs sm:text-sm py-2.5 rounded-xl", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(TrendingUp, { className: "h-4 w-4" }),
          " Progres"
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "targets", className: "mt-5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(TargetsPanel, { clientId, isAdmin: true, currentUserId: user.id }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "chat", className: "mt-5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Chat, { clientId, currentUserId: user.id, isAdmin: true }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "weight", className: "mt-5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(WeightTracker, { userId: clientId, canAdd: false, goalKg: profile?.goal_weight_kg }) })
    ] })
  ] }) });
}
export {
  AdminClient as component
};
