"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const React = require('react');
const LucideIcons = require('lucide-react');
const button = require('../../../../../../../ui/src/components/button.cjs');
const badge = require('../../../../../../../ui/src/components/badge.cjs');
const kanban = require('../../../../../../../ui/src/components/kanban.cjs');
const dateFns = require('date-fns');
const utils = require('../../../utils.cjs');
const kanbanHooks = require('../../hooks/kanban-hooks.cjs');
const userAvatar = require('./user-avatar.cjs');

function TaskCardComponent({ task, onClick }) {
  const priorityConfig = utils.getPriorityConfig(task.priority);
  const { data: assignee } = kanbanHooks.useResolveUser(task.assigneeId);
  return /* @__PURE__ */ jsxRuntime.jsx(kanban.KanbanItem, { value: task.id, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    {
      className: "rounded-md border bg-card p-3 shadow-xs cursor-pointer hover:shadow-md transition-shadow",
      onClick,
      children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
        /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
          /* @__PURE__ */ jsxRuntime.jsx(kanban.KanbanItemHandle, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
            button.Button,
            {
              variant: "ghost",
              size: "icon",
              className: "h-6 w-6",
              onClick: (e) => e.stopPropagation(),
              children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GripVertical, { className: "h-3 w-3" })
            }
          ) }),
          /* @__PURE__ */ jsxRuntime.jsx(
            "span",
            {
              className: "line-clamp-1 font-medium text-base flex-1 text-left cursor-pointer hover:text-primary",
              title: task.title,
              children: task.title
            }
          ),
          /* @__PURE__ */ jsxRuntime.jsx(
            badge.Badge,
            {
              variant: priorityConfig.variant,
              className: `pointer-events-none h-5 rounded-sm px-1.5 text-[11px] capitalize ${priorityConfig.className}`,
              children: priorityConfig.label
            }
          )
        ] }),
        /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-muted-foreground text-xs", children: [
          task.assigneeId ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
            /* @__PURE__ */ jsxRuntime.jsx(userAvatar.UserAvatar, { user: assignee ?? null, size: "sm" }),
            /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-1", children: assignee?.name || "Assigned" })
          ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
            /* @__PURE__ */ jsxRuntime.jsx(userAvatar.UserAvatar, { user: null, size: "sm" }),
            /* @__PURE__ */ jsxRuntime.jsx("span", { className: "line-clamp-1", children: "Unassigned" })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsx("time", { className: "tabular-nums", children: dateFns.format(new Date(task.createdAt), "MMM d") })
        ] })
      ] })
    }
  ) });
}
const TaskCard = React.memo(TaskCardComponent);

exports.TaskCard = TaskCard;
